From fe0db9c71d4c259e5cba5b1f506c89c3846c734e Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Tue, 12 Aug 2025 07:49:05 +0900 Subject: [PATCH 001/489] update rotate operation doc --- src/intrinsic/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index eb0a5336a1f1..82275d8833a4 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -493,9 +493,10 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc } sym::bitreverse => self.bit_reverse(width, args[0].immediate()), sym::rotate_left | sym::rotate_right => { - // TODO(antoyo): implement using algorithm from: + // Using optimized branchless algorithm from: // https://blog.regehr.org/archives/1063 - // for other platforms. + // This implementation uses the pattern (x<>(-n&(width-1))) + // which generates efficient code for other platforms. let is_left = name == sym::rotate_left; let val = args[0].immediate(); let raw_shift = args[1].immediate(); From 0e05f58e6284da68f68412fc6dee00d32517f17b Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Tue, 12 Aug 2025 11:40:37 +0800 Subject: [PATCH 002/489] Fix guess renamed macro braces --- .../ide-completion/src/render/macro_.rs | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/render/macro_.rs b/src/tools/rust-analyzer/crates/ide-completion/src/render/macro_.rs index 35fe407b2e68..6efa8a84553e 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/render/macro_.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/render/macro_.rs @@ -46,12 +46,17 @@ fn render( ctx.source_range() }; - let (name, escaped_name) = - (name.as_str(), name.display(ctx.db(), completion.edition).to_smolstr()); + let orig_name = macro_.name(ctx.db()); + let (name, orig_name, escaped_name) = ( + name.as_str(), + orig_name.as_str(), + name.display(ctx.db(), completion.edition).to_smolstr(), + ); let docs = ctx.docs(macro_); let docs_str = docs.as_ref().map(Documentation::as_str).unwrap_or_default(); let is_fn_like = macro_.is_fn_like(completion.db); - let (bra, ket) = if is_fn_like { guess_macro_braces(name, docs_str) } else { ("", "") }; + let (bra, ket) = + if is_fn_like { guess_macro_braces(name, orig_name, docs_str) } else { ("", "") }; let needs_bang = is_fn_like && !is_use_path && !has_macro_bang; @@ -109,9 +114,13 @@ fn banged_name(name: &str) -> SmolStr { SmolStr::from_iter([name, "!"]) } -fn guess_macro_braces(macro_name: &str, docs: &str) -> (&'static str, &'static str) { +fn guess_macro_braces( + macro_name: &str, + orig_name: &str, + docs: &str, +) -> (&'static str, &'static str) { let mut votes = [0, 0, 0]; - for (idx, s) in docs.match_indices(¯o_name) { + for (idx, s) in docs.match_indices(macro_name).chain(docs.match_indices(orig_name)) { let (before, after) = (&docs[..idx], &docs[idx + s.len()..]); // Ensure to match the full word if after.starts_with('!') @@ -240,7 +249,25 @@ fn main() { $0 } macro_rules! foo { () => {} } fn main() { foo! {$0} } "#, - ) + ); + + check_edit( + "bar!", + r#" +/// `foo![]` +#[macro_export] +macro_rules! foo { () => {} } +pub use crate::foo as bar; +fn main() { $0 } +"#, + r#" +/// `foo![]` +#[macro_export] +macro_rules! foo { () => {} } +pub use crate::foo as bar; +fn main() { bar![$0] } +"#, + ); } #[test] From 4fa62c6f40c201f0d04c14fb715bca0d7cf5bf4c Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Tue, 12 Aug 2025 10:54:36 +0800 Subject: [PATCH 003/489] Add guess braces doc `T![]` for `T_` --- .../rust-analyzer/crates/parser/src/syntax_kind/generated.rs | 1 + src/tools/rust-analyzer/xtask/src/codegen/grammar.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs b/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs index 3a8041d2df9e..2805242ca95e 100644 --- a/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs +++ b/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs @@ -1007,6 +1007,7 @@ impl SyntaxKind { Some(tok) } } +#[doc = r" `T![]`"] #[macro_export] macro_rules ! T_ { [$] => { $ crate :: SyntaxKind :: DOLLAR } ; [;] => { $ crate :: SyntaxKind :: SEMICOLON } ; [,] => { $ crate :: SyntaxKind :: COMMA } ; ['('] => { $ crate :: SyntaxKind :: L_PAREN } ; [')'] => { $ crate :: SyntaxKind :: R_PAREN } ; ['{'] => { $ crate :: SyntaxKind :: L_CURLY } ; ['}'] => { $ crate :: SyntaxKind :: R_CURLY } ; ['['] => { $ crate :: SyntaxKind :: L_BRACK } ; [']'] => { $ crate :: SyntaxKind :: R_BRACK } ; [<] => { $ crate :: SyntaxKind :: L_ANGLE } ; [>] => { $ crate :: SyntaxKind :: R_ANGLE } ; [@] => { $ crate :: SyntaxKind :: AT } ; [#] => { $ crate :: SyntaxKind :: POUND } ; [~] => { $ crate :: SyntaxKind :: TILDE } ; [?] => { $ crate :: SyntaxKind :: QUESTION } ; [&] => { $ crate :: SyntaxKind :: AMP } ; [|] => { $ crate :: SyntaxKind :: PIPE } ; [+] => { $ crate :: SyntaxKind :: PLUS } ; [*] => { $ crate :: SyntaxKind :: STAR } ; [/] => { $ crate :: SyntaxKind :: SLASH } ; [^] => { $ crate :: SyntaxKind :: CARET } ; [%] => { $ crate :: SyntaxKind :: PERCENT } ; [_] => { $ crate :: SyntaxKind :: UNDERSCORE } ; [.] => { $ crate :: SyntaxKind :: DOT } ; [..] => { $ crate :: SyntaxKind :: DOT2 } ; [...] => { $ crate :: SyntaxKind :: DOT3 } ; [..=] => { $ crate :: SyntaxKind :: DOT2EQ } ; [:] => { $ crate :: SyntaxKind :: COLON } ; [::] => { $ crate :: SyntaxKind :: COLON2 } ; [=] => { $ crate :: SyntaxKind :: EQ } ; [==] => { $ crate :: SyntaxKind :: EQ2 } ; [=>] => { $ crate :: SyntaxKind :: FAT_ARROW } ; [!] => { $ crate :: SyntaxKind :: BANG } ; [!=] => { $ crate :: SyntaxKind :: NEQ } ; [-] => { $ crate :: SyntaxKind :: MINUS } ; [->] => { $ crate :: SyntaxKind :: THIN_ARROW } ; [<=] => { $ crate :: SyntaxKind :: LTEQ } ; [>=] => { $ crate :: SyntaxKind :: GTEQ } ; [+=] => { $ crate :: SyntaxKind :: PLUSEQ } ; [-=] => { $ crate :: SyntaxKind :: MINUSEQ } ; [|=] => { $ crate :: SyntaxKind :: PIPEEQ } ; [&=] => { $ crate :: SyntaxKind :: AMPEQ } ; [^=] => { $ crate :: SyntaxKind :: CARETEQ } ; [/=] => { $ crate :: SyntaxKind :: SLASHEQ } ; [*=] => { $ crate :: SyntaxKind :: STAREQ } ; [%=] => { $ crate :: SyntaxKind :: PERCENTEQ } ; [&&] => { $ crate :: SyntaxKind :: AMP2 } ; [||] => { $ crate :: SyntaxKind :: PIPE2 } ; [<<] => { $ crate :: SyntaxKind :: SHL } ; [>>] => { $ crate :: SyntaxKind :: SHR } ; [<<=] => { $ crate :: SyntaxKind :: SHLEQ } ; [>>=] => { $ crate :: SyntaxKind :: SHREQ } ; [Self] => { $ crate :: SyntaxKind :: SELF_TYPE_KW } ; [abstract] => { $ crate :: SyntaxKind :: ABSTRACT_KW } ; [as] => { $ crate :: SyntaxKind :: AS_KW } ; [become] => { $ crate :: SyntaxKind :: BECOME_KW } ; [box] => { $ crate :: SyntaxKind :: BOX_KW } ; [break] => { $ crate :: SyntaxKind :: BREAK_KW } ; [const] => { $ crate :: SyntaxKind :: CONST_KW } ; [continue] => { $ crate :: SyntaxKind :: CONTINUE_KW } ; [crate] => { $ crate :: SyntaxKind :: CRATE_KW } ; [do] => { $ crate :: SyntaxKind :: DO_KW } ; [else] => { $ crate :: SyntaxKind :: ELSE_KW } ; [enum] => { $ crate :: SyntaxKind :: ENUM_KW } ; [extern] => { $ crate :: SyntaxKind :: EXTERN_KW } ; [false] => { $ crate :: SyntaxKind :: FALSE_KW } ; [final] => { $ crate :: SyntaxKind :: FINAL_KW } ; [fn] => { $ crate :: SyntaxKind :: FN_KW } ; [for] => { $ crate :: SyntaxKind :: FOR_KW } ; [if] => { $ crate :: SyntaxKind :: IF_KW } ; [impl] => { $ crate :: SyntaxKind :: IMPL_KW } ; [in] => { $ crate :: SyntaxKind :: IN_KW } ; [let] => { $ crate :: SyntaxKind :: LET_KW } ; [loop] => { $ crate :: SyntaxKind :: LOOP_KW } ; [macro] => { $ crate :: SyntaxKind :: MACRO_KW } ; [match] => { $ crate :: SyntaxKind :: MATCH_KW } ; [mod] => { $ crate :: SyntaxKind :: MOD_KW } ; [move] => { $ crate :: SyntaxKind :: MOVE_KW } ; [mut] => { $ crate :: SyntaxKind :: MUT_KW } ; [override] => { $ crate :: SyntaxKind :: OVERRIDE_KW } ; [priv] => { $ crate :: SyntaxKind :: PRIV_KW } ; [pub] => { $ crate :: SyntaxKind :: PUB_KW } ; [ref] => { $ crate :: SyntaxKind :: REF_KW } ; [return] => { $ crate :: SyntaxKind :: RETURN_KW } ; [self] => { $ crate :: SyntaxKind :: SELF_KW } ; [static] => { $ crate :: SyntaxKind :: STATIC_KW } ; [struct] => { $ crate :: SyntaxKind :: STRUCT_KW } ; [super] => { $ crate :: SyntaxKind :: SUPER_KW } ; [trait] => { $ crate :: SyntaxKind :: TRAIT_KW } ; [true] => { $ crate :: SyntaxKind :: TRUE_KW } ; [type] => { $ crate :: SyntaxKind :: TYPE_KW } ; [typeof] => { $ crate :: SyntaxKind :: TYPEOF_KW } ; [unsafe] => { $ crate :: SyntaxKind :: UNSAFE_KW } ; [unsized] => { $ crate :: SyntaxKind :: UNSIZED_KW } ; [use] => { $ crate :: SyntaxKind :: USE_KW } ; [virtual] => { $ crate :: SyntaxKind :: VIRTUAL_KW } ; [where] => { $ crate :: SyntaxKind :: WHERE_KW } ; [while] => { $ crate :: SyntaxKind :: WHILE_KW } ; [yield] => { $ crate :: SyntaxKind :: YIELD_KW } ; [asm] => { $ crate :: SyntaxKind :: ASM_KW } ; [att_syntax] => { $ crate :: SyntaxKind :: ATT_SYNTAX_KW } ; [auto] => { $ crate :: SyntaxKind :: AUTO_KW } ; [builtin] => { $ crate :: SyntaxKind :: BUILTIN_KW } ; [clobber_abi] => { $ crate :: SyntaxKind :: CLOBBER_ABI_KW } ; [default] => { $ crate :: SyntaxKind :: DEFAULT_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [format_args] => { $ crate :: SyntaxKind :: FORMAT_ARGS_KW } ; [global_asm] => { $ crate :: SyntaxKind :: GLOBAL_ASM_KW } ; [inlateout] => { $ crate :: SyntaxKind :: INLATEOUT_KW } ; [inout] => { $ crate :: SyntaxKind :: INOUT_KW } ; [label] => { $ crate :: SyntaxKind :: LABEL_KW } ; [lateout] => { $ crate :: SyntaxKind :: LATEOUT_KW } ; [macro_rules] => { $ crate :: SyntaxKind :: MACRO_RULES_KW } ; [may_unwind] => { $ crate :: SyntaxKind :: MAY_UNWIND_KW } ; [naked_asm] => { $ crate :: SyntaxKind :: NAKED_ASM_KW } ; [nomem] => { $ crate :: SyntaxKind :: NOMEM_KW } ; [noreturn] => { $ crate :: SyntaxKind :: NORETURN_KW } ; [nostack] => { $ crate :: SyntaxKind :: NOSTACK_KW } ; [offset_of] => { $ crate :: SyntaxKind :: OFFSET_OF_KW } ; [options] => { $ crate :: SyntaxKind :: OPTIONS_KW } ; [out] => { $ crate :: SyntaxKind :: OUT_KW } ; [preserves_flags] => { $ crate :: SyntaxKind :: PRESERVES_FLAGS_KW } ; [pure] => { $ crate :: SyntaxKind :: PURE_KW } ; [raw] => { $ crate :: SyntaxKind :: RAW_KW } ; [readonly] => { $ crate :: SyntaxKind :: READONLY_KW } ; [safe] => { $ crate :: SyntaxKind :: SAFE_KW } ; [sym] => { $ crate :: SyntaxKind :: SYM_KW } ; [union] => { $ crate :: SyntaxKind :: UNION_KW } ; [yeet] => { $ crate :: SyntaxKind :: YEET_KW } ; [async] => { $ crate :: SyntaxKind :: ASYNC_KW } ; [await] => { $ crate :: SyntaxKind :: AWAIT_KW } ; [dyn] => { $ crate :: SyntaxKind :: DYN_KW } ; [gen] => { $ crate :: SyntaxKind :: GEN_KW } ; [try] => { $ crate :: SyntaxKind :: TRY_KW } ; [lifetime_ident] => { $ crate :: SyntaxKind :: LIFETIME_IDENT } ; [int_number] => { $ crate :: SyntaxKind :: INT_NUMBER } ; [ident] => { $ crate :: SyntaxKind :: IDENT } ; [string] => { $ crate :: SyntaxKind :: STRING } ; [shebang] => { $ crate :: SyntaxKind :: SHEBANG } ; [frontmatter] => { $ crate :: SyntaxKind :: FRONTMATTER } ; } impl ::core::marker::Copy for SyntaxKind {} diff --git a/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs b/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs index 824b38fc872d..effe150e21f4 100644 --- a/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs +++ b/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs @@ -659,6 +659,7 @@ fn generate_syntax_kinds(grammar: KindsSrc) -> String { } } + /// `T![]` #[macro_export] macro_rules! T_ { #([#punctuation_values] => { $crate::SyntaxKind::#punctuation };)* From 4816e420d066d52c5de02a7318ca511809faffa9 Mon Sep 17 00:00:00 2001 From: Benjamin Brienen Date: Sun, 17 Aug 2025 01:37:36 +0200 Subject: [PATCH 004/489] Remove conflicting advice --- .../docs/book/src/contributing/style.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/tools/rust-analyzer/docs/book/src/contributing/style.md b/src/tools/rust-analyzer/docs/book/src/contributing/style.md index fe09fb6c2fd5..0c58a83a1d48 100644 --- a/src/tools/rust-analyzer/docs/book/src/contributing/style.md +++ b/src/tools/rust-analyzer/docs/book/src/contributing/style.md @@ -236,22 +236,6 @@ In the "Good" version, the precondition check and usage are checked in the same **Rationale:** non-local code properties degrade under change. -When checking a boolean precondition, prefer `if !invariant` to `if negated_invariant`: - -```rust -// GOOD -if !(idx < len) { - return None; -} - -// BAD -if idx >= len { - return None; -} -``` - -**Rationale:** it's useful to see the invariant relied upon by the rest of the function clearly spelled out. - ## Control Flow As a special case of the previous rule, do not hide control flow inside functions, push it to the caller: From 09186d3f811c97eb0d77c74089e6bdccfa1cae8a Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sat, 30 Aug 2025 22:25:50 +0800 Subject: [PATCH 005/489] Fix nested if-let for merge_nested_if ```rust fn f() { $0if let Some(x) = y { if x == 4 { 1 } } } ``` -> ```rust fn f() { if let Some(x) = y && x == 4 { 1 } } ``` --- .../src/handlers/merge_nested_if.rs | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs index 73cb8204f209..b3487bb62364 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs @@ -1,4 +1,3 @@ -use ide_db::syntax_helpers::node_ext::is_pattern_cond; use syntax::{ T, ast::{self, AstNode, BinaryOp}, @@ -39,10 +38,6 @@ pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt } let cond = expr.condition()?; - //should not apply for if-let - if is_pattern_cond(cond.clone()) { - return None; - } let cond_range = cond.syntax().text_range(); @@ -62,9 +57,6 @@ pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt return None; } let nested_if_cond = nested_if_to_merge.condition()?; - if is_pattern_cond(nested_if_cond.clone()) { - return None; - } let nested_if_then_branch = nested_if_to_merge.then_branch()?; let then_branch_range = then_branch.syntax().text_range(); @@ -171,6 +163,24 @@ mod tests { ) } + #[test] + fn merge_nested_if_test8() { + check_assist( + merge_nested_if, + "fn f() { i$0f let Some(x) = y { if x == 4 { 1 } } }", + "fn f() { if let Some(x) = y && x == 4 { 1 } }", + ) + } + + #[test] + fn merge_nested_if_test9() { + check_assist( + merge_nested_if, + "fn f() { i$0f y == 0 { if let Some(x) = y { 1 } } }", + "fn f() { if y == 0 && let Some(x) = y { 1 } }", + ) + } + #[test] fn merge_nested_if_do_not_apply_to_if_with_else_branch() { check_assist_not_applicable( @@ -187,22 +197,6 @@ mod tests { ) } - #[test] - fn merge_nested_if_do_not_apply_to_if_let() { - check_assist_not_applicable( - merge_nested_if, - "fn f() { i$0f let Some(x) = y { if x == 4 { 1 } } }", - ) - } - - #[test] - fn merge_nested_if_do_not_apply_to_nested_if_let() { - check_assist_not_applicable( - merge_nested_if, - "fn f() { i$0f y == 0 { if let Some(x) = y { 1 } } }", - ) - } - #[test] fn merge_nested_if_do_not_apply_to_if_with_else_branch_and_nested_if() { check_assist_not_applicable( From ccd7b34bb98a3349ee98c5c01cac18986c67a097 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sat, 30 Aug 2025 22:40:13 +0800 Subject: [PATCH 006/489] Fix indent for merge_nested_if **Input**: ```rust fn f() { i$0f x == 3 { if y == 4 { 1 } } } ``` **Before this PR**: ```rust fn f() { if x == 3 && y == 4 { 1 } } ``` **After this PR**: ```rust fn f() { if x == 3 && y == 4 { 1 } } ``` --- .../src/handlers/merge_nested_if.rs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs index 73cb8204f209..a997e06fb442 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/merge_nested_if.rs @@ -1,7 +1,7 @@ use ide_db::syntax_helpers::node_ext::is_pattern_cond; use syntax::{ T, - ast::{self, AstNode, BinaryOp}, + ast::{self, AstNode, BinaryOp, edit::AstNodeEdit}, }; use crate::{ @@ -67,7 +67,6 @@ pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt } let nested_if_then_branch = nested_if_to_merge.then_branch()?; - let then_branch_range = then_branch.syntax().text_range(); acc.add(AssistId::refactor_rewrite("merge_nested_if"), "Merge nested if", if_range, |edit| { let cond_text = if has_logic_op_or(&cond) { @@ -85,7 +84,7 @@ pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt let replace_cond = format!("{cond_text} && {nested_if_cond_text}"); edit.replace(cond_range, replace_cond); - edit.replace(then_branch_range, nested_if_then_branch.syntax().text()); + edit.replace_ast(then_branch, nested_if_then_branch.dedent(1.into())); }) } @@ -112,8 +111,20 @@ mod tests { fn merge_nested_if_test1() { check_assist( merge_nested_if, - "fn f() { i$0f x == 3 { if y == 4 { 1 } } }", - "fn f() { if x == 3 && y == 4 { 1 } }", + " + fn f() { + i$0f x == 3 { + if y == 4 { + 1 + } + } + }", + " + fn f() { + if x == 3 && y == 4 { + 1 + } + }", ) } From 97d0f6d75368d7c4fad7d715ffb950e68df89773 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Wed, 3 Sep 2025 17:26:55 +0800 Subject: [PATCH 007/489] Add LetStmt doc for convert_to_guarded_return --- .../src/handlers/convert_to_guarded_return.rs | 15 ++++++++++++++ .../crates/ide-assists/src/tests/generated.rs | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_to_guarded_return.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_to_guarded_return.rs index 2ea032fb62ba..003686d17ce4 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_to_guarded_return.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_to_guarded_return.rs @@ -43,6 +43,21 @@ use crate::{ // bar(); // } // ``` +// --- +// ``` +// //- minicore: option +// fn foo() -> Option { None } +// fn main() { +// $0let x = foo(); +// } +// ``` +// -> +// ``` +// fn foo() -> Option { None } +// fn main() { +// let Some(x) = foo() else { return }; +// } +// ``` pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> { if let Some(let_stmt) = ctx.find_node_at_offset() { let_stmt_to_guarded_return(let_stmt, acc, ctx) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs b/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs index 91348be97eb7..88d54ba80a6e 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs @@ -736,6 +736,26 @@ fn main() { ) } +#[test] +fn doctest_convert_to_guarded_return_1() { + check_doc_test( + "convert_to_guarded_return", + r#####" +//- minicore: option +fn foo() -> Option { None } +fn main() { + $0let x = foo(); +} +"#####, + r#####" +fn foo() -> Option { None } +fn main() { + let Some(x) = foo() else { return }; +} +"#####, + ) +} + #[test] fn doctest_convert_tuple_return_type_to_struct() { check_doc_test( From 664875e01d69ead828d9bcc7389af6297060a0e1 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Tue, 21 Oct 2025 20:22:48 +0000 Subject: [PATCH 008/489] fix: `if_not_else` wrong unmangled macros --- clippy_lints/src/if_not_else.rs | 37 ++++++++++++++++----------- tests/ui/if_not_else.fixed | 17 +++++++++++++ tests/ui/if_not_else.rs | 17 +++++++++++++ tests/ui/if_not_else.stderr | 44 ++++++++++++++++++++++++++++++++- 4 files changed, 99 insertions(+), 16 deletions(-) diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index 54e9538fcb99..ff22ba4fcd0d 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -1,7 +1,7 @@ use clippy_utils::consts::is_zero_integer_const; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::is_else_clause; -use clippy_utils::source::{HasSession, indent_of, reindent_multiline, snippet}; +use clippy_utils::source::{HasSession, indent_of, reindent_multiline, snippet_with_context}; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; @@ -78,6 +78,7 @@ impl LateLintPass<'_> for IfNotElse { // } // ``` if !e.span.from_expansion() && !is_else_clause(cx.tcx, e) { + let mut applicability = Applicability::MachineApplicable; match cond.kind { ExprKind::Unary(UnOp::Not, _) | ExprKind::Binary(_, _, _) => span_lint_and_sugg( cx, @@ -85,8 +86,16 @@ impl LateLintPass<'_> for IfNotElse { e.span, msg, "try", - make_sugg(cx, &cond.kind, cond_inner.span, els.span, "..", Some(e.span)), - Applicability::MachineApplicable, + make_sugg( + cx, + e.span, + &cond.kind, + cond_inner.span, + els.span, + "..", + &mut applicability, + ), + applicability, ), _ => span_lint_and_help(cx, IF_NOT_ELSE, e.span, msg, None, help), } @@ -97,28 +106,26 @@ impl LateLintPass<'_> for IfNotElse { fn make_sugg<'a>( sess: &impl HasSession, + expr_span: Span, cond_kind: &'a ExprKind<'a>, cond_inner: Span, els_span: Span, default: &'a str, - indent_relative_to: Option, + applicability: &mut Applicability, ) -> String { - let cond_inner_snip = snippet(sess, cond_inner, default); - let els_snip = snippet(sess, els_span, default); - let indent = indent_relative_to.and_then(|s| indent_of(sess, s)); + let (cond_inner_snip, _) = snippet_with_context(sess, cond_inner, expr_span.ctxt(), default, applicability); + let (els_snip, _) = snippet_with_context(sess, els_span, expr_span.ctxt(), default, applicability); + let indent = indent_of(sess, expr_span); let suggestion = match cond_kind { ExprKind::Unary(UnOp::Not, cond_rest) => { - format!( - "if {} {} else {}", - snippet(sess, cond_rest.span, default), - els_snip, - cond_inner_snip - ) + let (cond_rest_snip, _) = + snippet_with_context(sess, cond_rest.span, expr_span.ctxt(), default, applicability); + format!("if {cond_rest_snip} {els_snip} else {cond_inner_snip}") }, ExprKind::Binary(_, lhs, rhs) => { - let lhs_snip = snippet(sess, lhs.span, default); - let rhs_snip = snippet(sess, rhs.span, default); + let (lhs_snip, _) = snippet_with_context(sess, lhs.span, expr_span.ctxt(), default, applicability); + let (rhs_snip, _) = snippet_with_context(sess, rhs.span, expr_span.ctxt(), default, applicability); format!("if {lhs_snip} == {rhs_snip} {els_snip} else {cond_inner_snip}") }, diff --git a/tests/ui/if_not_else.fixed b/tests/ui/if_not_else.fixed index 4e6f43e5671e..a29847f0cf97 100644 --- a/tests/ui/if_not_else.fixed +++ b/tests/ui/if_not_else.fixed @@ -76,3 +76,20 @@ fn with_annotations() { println!("foo is false"); } } + +fn issue15924() { + let x = 0; + if matches!(x, 0..10) { + println!(":("); + } else { + //~^ if_not_else + println!(":)"); + } + + if dbg!(x) == 1 { + println!(":("); + } else { + //~^ if_not_else + println!(":)"); + } +} diff --git a/tests/ui/if_not_else.rs b/tests/ui/if_not_else.rs index 6cd2e3bd63fe..4ae11d6ad90e 100644 --- a/tests/ui/if_not_else.rs +++ b/tests/ui/if_not_else.rs @@ -76,3 +76,20 @@ fn with_annotations() { println!("foo"); /* foo */ } } + +fn issue15924() { + let x = 0; + if !matches!(x, 0..10) { + //~^ if_not_else + println!(":)"); + } else { + println!(":("); + } + + if dbg!(x) != 1 { + //~^ if_not_else + println!(":)"); + } else { + println!(":("); + } +} diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index 824837bd52bb..0682bf80da55 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -147,5 +147,47 @@ LL + println!("foo is false"); LL + } | -error: aborting due to 6 previous errors +error: unnecessary boolean `not` operation + --> tests/ui/if_not_else.rs:82:5 + | +LL | / if !matches!(x, 0..10) { +LL | | +LL | | println!(":)"); +LL | | } else { +LL | | println!(":("); +LL | | } + | |_____^ + | +help: try + | +LL ~ if matches!(x, 0..10) { +LL + println!(":("); +LL + } else { +LL + +LL + println!(":)"); +LL + } + | + +error: unnecessary `!=` operation + --> tests/ui/if_not_else.rs:89:5 + | +LL | / if dbg!(x) != 1 { +LL | | +LL | | println!(":)"); +LL | | } else { +LL | | println!(":("); +LL | | } + | |_____^ + | +help: try + | +LL ~ if dbg!(x) == 1 { +LL + println!(":("); +LL + } else { +LL + +LL + println!(":)"); +LL + } + | + +error: aborting due to 8 previous errors From 1a5576dcd25224035336ff80780f9fc426f32cb1 Mon Sep 17 00:00:00 2001 From: alexey semenyuk Date: Thu, 6 Nov 2025 00:13:26 +0500 Subject: [PATCH 009/489] Upgrade Node.js setup action and version --- .github/workflows/remark.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/remark.yml b/.github/workflows/remark.yml index c2cc48ab9511..980379a6c6ad 100644 --- a/.github/workflows/remark.yml +++ b/.github/workflows/remark.yml @@ -17,9 +17,9 @@ jobs: persist-credentials: false - name: Setup Node.js - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: - node-version: '20.x' + node-version: '24.x' - name: Install remark run: npm install remark-cli remark-lint remark-lint-maximum-line-length@^3.1.3 remark-preset-lint-recommended remark-gfm From 8785dd6689f6d662d025563560628d20827ce38c Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sat, 8 Nov 2025 21:15:45 +0800 Subject: [PATCH 010/489] Add ide-assist: add_explicit_method_call_deref Insert explicit method call reference and dereferences. Example --- ```rust struct Foo; impl Foo { fn foo(&self) {} } fn test() { Foo$0.$0foo(); } ``` -> ```rust struct Foo; impl Foo { fn foo(&self) {} } fn test() { (&Foo).foo(); } ``` --- .../src/handlers/add_explicit_dot_deref.rs | 214 ++++++++++++++++++ .../crates/ide-assists/src/lib.rs | 2 + .../crates/ide-assists/src/tests/generated.rs | 21 ++ .../crates/syntax/src/ast/make.rs | 7 + .../src/ast/syntax_factory/constructors.rs | 16 ++ 5 files changed, 260 insertions(+) create mode 100644 src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs new file mode 100644 index 000000000000..d27a6b4ce770 --- /dev/null +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_explicit_dot_deref.rs @@ -0,0 +1,214 @@ +use hir::{Adjust, Mutability}; +use ide_db::assists::AssistId; +use itertools::Itertools; +use syntax::{ + AstNode, T, + ast::{self, syntax_factory::SyntaxFactory}, +}; + +use crate::{AssistContext, Assists}; + +// Assist: add_explicit_method_call_deref +// +// Insert explicit method call reference and dereferences. +// +// ``` +// struct Foo; +// impl Foo { fn foo(&self) {} } +// fn test() { +// Foo$0.$0foo(); +// } +// ``` +// -> +// ``` +// struct Foo; +// impl Foo { fn foo(&self) {} } +// fn test() { +// (&Foo).foo(); +// } +// ``` +pub(crate) fn add_explicit_method_call_deref( + acc: &mut Assists, + ctx: &AssistContext<'_>, +) -> Option<()> { + if ctx.has_empty_selection() { + return None; + } + let dot_token = ctx.find_token_syntax_at_offset(T![.])?; + if ctx.selection_trimmed() != dot_token.text_range() { + return None; + } + let method_call_expr = dot_token.parent().and_then(ast::MethodCallExpr::cast)?; + let receiver = method_call_expr.receiver()?; + + let adjustments = ctx.sema.expr_adjustments(&receiver)?; + let adjustments = + adjustments.into_iter().filter_map(|adjust| simple_adjust_kind(adjust.kind)).collect_vec(); + if adjustments.is_empty() { + return None; + } + + acc.add( + AssistId::refactor_rewrite("add_explicit_method_call_deref"), + "Insert explicit method call derefs", + dot_token.text_range(), + |builder| { + let mut edit = builder.make_editor(method_call_expr.syntax()); + let make = SyntaxFactory::without_mappings(); + let mut expr = receiver.clone(); + + for adjust_kind in adjustments { + expr = adjust_kind.wrap_expr(expr, &make); + } + + expr = make.expr_paren(expr).into(); + edit.replace(receiver.syntax(), expr.syntax()); + + builder.add_file_edits(ctx.vfs_file_id(), edit); + }, + ) +} + +fn simple_adjust_kind(adjust: Adjust) -> Option { + match adjust { + Adjust::NeverToAny | Adjust::Pointer(_) => None, + Adjust::Deref(_) => Some(AdjustKind::Deref), + Adjust::Borrow(hir::AutoBorrow::Ref(mutability)) => Some(AdjustKind::Ref(mutability)), + Adjust::Borrow(hir::AutoBorrow::RawPtr(mutability)) => Some(AdjustKind::RefRaw(mutability)), + } +} + +enum AdjustKind { + Deref, + Ref(Mutability), + RefRaw(Mutability), +} + +impl AdjustKind { + fn wrap_expr(self, expr: ast::Expr, make: &SyntaxFactory) -> ast::Expr { + match self { + AdjustKind::Deref => make.expr_prefix(T![*], expr).into(), + AdjustKind::Ref(mutability) => make.expr_ref(expr, mutability.is_mut()), + AdjustKind::RefRaw(mutability) => make.expr_raw_ref(expr, mutability.is_mut()), + } + } +} + +#[cfg(test)] +mod tests { + use crate::tests::check_assist; + + use super::*; + + #[test] + fn works_ref() { + check_assist( + add_explicit_method_call_deref, + r#" + struct Foo; + impl Foo { fn foo(&self) {} } + fn test() { + Foo$0.$0foo(); + }"#, + r#" + struct Foo; + impl Foo { fn foo(&self) {} } + fn test() { + (&Foo).foo(); + }"#, + ); + } + + #[test] + fn works_ref_mut() { + check_assist( + add_explicit_method_call_deref, + r#" + struct Foo; + impl Foo { fn foo(&mut self) {} } + fn test() { + Foo$0.$0foo(); + }"#, + r#" + struct Foo; + impl Foo { fn foo(&mut self) {} } + fn test() { + (&mut Foo).foo(); + }"#, + ); + } + + #[test] + fn works_deref() { + check_assist( + add_explicit_method_call_deref, + r#" + struct Foo; + impl Foo { fn foo(self) {} } + fn test() { + let foo = &Foo; + foo$0.$0foo(); + }"#, + r#" + struct Foo; + impl Foo { fn foo(self) {} } + fn test() { + let foo = &Foo; + (*foo).foo(); + }"#, + ); + } + + #[test] + fn works_reborrow() { + check_assist( + add_explicit_method_call_deref, + r#" + struct Foo; + impl Foo { fn foo(&self) {} } + fn test() { + let foo = &mut Foo; + foo$0.$0foo(); + }"#, + r#" + struct Foo; + impl Foo { fn foo(&self) {} } + fn test() { + let foo = &mut Foo; + (&*foo).foo(); + }"#, + ); + } + + #[test] + fn works_deref_reborrow() { + check_assist( + add_explicit_method_call_deref, + r#" + //- minicore: deref + struct Foo; + struct Bar; + impl core::ops::Deref for Foo { + type Target = Bar; + fn deref(&self) -> &Self::Target {} + } + impl Bar { fn bar(&self) {} } + fn test() { + let foo = &mut Foo; + foo$0.$0bar(); + }"#, + r#" + struct Foo; + struct Bar; + impl core::ops::Deref for Foo { + type Target = Bar; + fn deref(&self) -> &Self::Target {} + } + impl Bar { fn bar(&self) {} } + fn test() { + let foo = &mut Foo; + (&**foo).bar(); + }"#, + ); + } +} diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/lib.rs b/src/tools/rust-analyzer/crates/ide-assists/src/lib.rs index 4b4aa9427955..df9fc4f740c9 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/lib.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/lib.rs @@ -105,6 +105,7 @@ mod handlers { pub(crate) type Handler = fn(&mut Assists, &AssistContext<'_>) -> Option<()>; mod add_braces; + mod add_explicit_dot_deref; mod add_explicit_enum_discriminant; mod add_explicit_type; mod add_label_to_loop; @@ -241,6 +242,7 @@ mod handlers { &[ // These are alphabetic for the foolish consistency add_braces::add_braces, + add_explicit_dot_deref::add_explicit_method_call_deref, add_explicit_enum_discriminant::add_explicit_enum_discriminant, add_explicit_type::add_explicit_type, add_label_to_loop::add_label_to_loop, diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs b/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs index 7f0836abdf3c..17c74e20516d 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/tests/generated.rs @@ -69,6 +69,27 @@ enum TheEnum { ) } +#[test] +fn doctest_add_explicit_method_call_deref() { + check_doc_test( + "add_explicit_method_call_deref", + r#####" +struct Foo; +impl Foo { fn foo(&self) {} } +fn test() { + Foo$0.$0foo(); +} +"#####, + r#####" +struct Foo; +impl Foo { fn foo(&self) {} } +fn test() { + (&Foo).foo(); +} +"#####, + ) +} + #[test] fn doctest_add_explicit_type() { check_doc_test( diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/make.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/make.rs index dba39204e32e..7fbf9eeba459 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/make.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/make.rs @@ -690,6 +690,13 @@ pub fn expr_macro(path: ast::Path, tt: ast::TokenTree) -> ast::MacroExpr { pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr { expr_from_text(&if exclusive { format!("&mut {expr}") } else { format!("&{expr}") }) } +pub fn expr_raw_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr { + expr_from_text(&if exclusive { + format!("&raw mut {expr}") + } else { + format!("&raw const {expr}") + }) +} pub fn expr_reborrow(expr: ast::Expr) -> ast::Expr { expr_from_text(&format!("&mut *{expr}")) } diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs index 969552392180..32fc1e6fedd4 100644 --- a/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs +++ b/src/tools/rust-analyzer/crates/syntax/src/ast/syntax_factory/constructors.rs @@ -566,6 +566,22 @@ impl SyntaxFactory { ast.into() } + pub fn expr_raw_ref(&self, expr: ast::Expr, exclusive: bool) -> ast::Expr { + let ast::Expr::RefExpr(ast) = + make::expr_raw_ref(expr.clone(), exclusive).clone_for_update() + else { + unreachable!() + }; + + if let Some(mut mapping) = self.mappings() { + let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone()); + builder.map_node(expr.syntax().clone(), ast.expr().unwrap().syntax().clone()); + builder.finish(&mut mapping); + } + + ast.into() + } + pub fn expr_closure( &self, pats: impl IntoIterator, From a197ebdb07e0908a6bbfc6faf6874ecb709c1e88 Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Wed, 27 Aug 2025 16:15:08 +0300 Subject: [PATCH 011/489] {CStr,OsStr,Path}::as_$1 --- library/core/src/ffi/c_str.rs | 11 +++++++++++ library/std/src/ffi/os_str.rs | 11 +++++++++++ library/std/src/path.rs | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 09d9b160700c..02e43b870cb7 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -648,6 +648,17 @@ impl CStr { pub fn display(&self) -> impl fmt::Display { crate::bstr::ByteStr::from_bytes(self.to_bytes()) } + + /// Returns the same string as a string slice `&CStr`. + /// + /// This method is redundant when used directly on `&CStr`, but + /// it helps dereferencing other string-like types to string slices, + /// for example references to `Box` or `Arc`. + #[inline] + #[unstable(feature = "str_as_str", issue = "130366")] + pub const fn as_c_str(&self) -> &CStr { + self + } } #[stable(feature = "c_string_eq_c_str", since = "1.90.0")] diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 09bd911aa769..5fdf745bc18d 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1278,6 +1278,17 @@ impl OsStr { pub fn display(&self) -> Display<'_> { Display { os_str: self } } + + /// Returns the same string as a string slice `&OsStr`. + /// + /// This method is redundant when used directly on `&OsStr`, but + /// it helps dereferencing other string-like types to string slices, + /// for example references to `Box` or `Arc`. + #[inline] + #[unstable(feature = "str_as_str", issue = "130366")] + pub const fn as_os_str(&self) -> &OsStr { + self + } } #[stable(feature = "box_from_os_str", since = "1.17.0")] diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 114fcc796c52..b6b899a67d5d 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -3208,6 +3208,17 @@ impl Path { Display { inner: self.inner.display() } } + /// Returns the same path as `&Path`. + /// + /// This method is redundant when used directly on `&Path`, but + /// it helps dereferencing other `PathBuf`-like types to `Path`s, + /// for example references to `Box` or `Arc`. + #[inline] + #[unstable(feature = "str_as_str", issue = "130366")] + pub const fn as_path(&self) -> &Path { + self + } + /// Queries the file system to get information about a file, directory, etc. /// /// This function will traverse symbolic links to query information about the From 4e5ce74da2f36ebc760e24245bb02a9563a30c38 Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Wed, 27 Aug 2025 17:27:05 +0300 Subject: [PATCH 012/489] `[T]::as_[mut_]slice` --- library/core/src/slice/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index f03f2045444d..7b482c751036 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -4906,6 +4906,28 @@ impl [T] { if start <= self.len() && end <= self.len() { Some(start..end) } else { None } } + + /// Returns the same slice `&[T]`. + /// + /// This method is redundant when used directly on `&[T]`, but + /// it helps dereferencing other "container" types to slices, + /// for example `Box<[T]>` or `Arc<[T]>`. + #[inline] + #[unstable(feature = "str_as_str", issue = "130366")] + pub const fn as_slice(&self) -> &[T] { + self + } + + /// Returns the same slice `&mut [T]`. + /// + /// This method is redundant when used directly on `&mut [T]`, but + /// it helps dereferencing other "container" types to slices, + /// for example `Box<[T]>` or `MutexGuard<[T]>`. + #[inline] + #[unstable(feature = "str_as_str", issue = "130366")] + pub const fn as_mut_slice(&mut self) -> &mut [T] { + self + } } impl [MaybeUninit] { From 48f7f312f12340591ab25d0679376f9d3b874d36 Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Wed, 27 Aug 2025 17:27:05 +0300 Subject: [PATCH 013/489] `ByteStr::as_[mut_]byte_str` --- library/core/src/bstr/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/library/core/src/bstr/mod.rs b/library/core/src/bstr/mod.rs index e13dc5cd44d5..34e1ea66c99a 100644 --- a/library/core/src/bstr/mod.rs +++ b/library/core/src/bstr/mod.rs @@ -68,6 +68,30 @@ impl ByteStr { ByteStr::from_bytes(bytes.as_ref()) } + /// Returns the same string as `&ByteStr`. + /// + /// This method is redundant when used directly on `&ByteStr`, but + /// it helps dereferencing other "container" types, + /// for example `Box` or `Arc`. + #[inline] + // #[unstable(feature = "str_as_str", issue = "130366")] + #[unstable(feature = "bstr", issue = "134915")] + pub const fn as_byte_str(&self) -> &ByteStr { + self + } + + /// Returns the same string as `&mut ByteStr`. + /// + /// This method is redundant when used directly on `&mut ByteStr`, but + /// it helps dereferencing other "container" types, + /// for example `Box` or `MutexGuard`. + #[inline] + // #[unstable(feature = "str_as_str", issue = "130366")] + #[unstable(feature = "bstr", issue = "134915")] + pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr { + self + } + #[doc(hidden)] #[unstable(feature = "bstr_internals", issue = "none")] #[inline] From 519785671b6d56dea6b11c4ab41aacaebe4d252e Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Tue, 11 Nov 2025 14:57:22 -0500 Subject: [PATCH 014/489] Set -Cpanic=abort in windows-msvc stack protector tests --- ...otector-heuristics-effect-windows-32bit.rs | 74 +++++++++++------- ...otector-heuristics-effect-windows-64bit.rs | 78 +++++++++++-------- .../stack-protector-target-support.rs | 2 +- 3 files changed, 93 insertions(+), 61 deletions(-) diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs index 3287e018b404..5759c387e3b1 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs @@ -7,7 +7,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort #![crate_type = "lib"] #![allow(internal_features)] @@ -26,6 +26,7 @@ pub fn emptyfn() { // CHECK-LABEL: array_char #[no_mangle] pub fn array_char(f: fn(*const char)) { + // CHECK-DAG: .cv_fpo_endprologue let a = ['c'; 1]; let b = ['d'; 3]; let c = ['e'; 15]; @@ -39,11 +40,14 @@ pub fn array_char(f: fn(*const char)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: array_u8_1 #[no_mangle] pub fn array_u8_1(f: fn(*const u8)) { + // CHECK-DAG: .cv_fpo_endprologue let a = [0u8; 1]; f(&a as *const _); @@ -55,11 +59,14 @@ pub fn array_u8_1(f: fn(*const u8)) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: array_u8_small: #[no_mangle] pub fn array_u8_small(f: fn(*const u8)) { + // CHECK-DAG: .cv_fpo_endprologue let a = [0u8; 2]; let b = [0u8; 7]; f(&a as *const _); @@ -72,11 +79,14 @@ pub fn array_u8_small(f: fn(*const u8)) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: array_u8_large: #[no_mangle] pub fn array_u8_large(f: fn(*const u8)) { + // CHECK-DAG: .cv_fpo_endprologue let a = [0u8; 9]; f(&a as *const _); @@ -88,6 +98,8 @@ pub fn array_u8_large(f: fn(*const u8)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } #[derive(Copy, Clone)] @@ -96,6 +108,7 @@ pub struct ByteSizedNewtype(u8); // CHECK-LABEL: array_bytesizednewtype_9: #[no_mangle] pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { + // CHECK-DAG: .cv_fpo_endprologue let a = [ByteSizedNewtype(0); 9]; f(&a as *const _); @@ -107,11 +120,14 @@ pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: local_var_addr_used_indirectly #[no_mangle] pub fn local_var_addr_used_indirectly(f: fn(bool)) { + // CHECK-DAG: .cv_fpo_endprologue let a = 5; let a_addr = &a as *const _ as usize; f(a_addr & 0x10 == 0); @@ -134,37 +150,27 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: local_string_addr_taken #[no_mangle] pub fn local_string_addr_taken(f: fn(&String)) { + // CHECK-DAG: .cv_fpo_endprologue let x = String::new(); f(&x); // Taking the address of the local variable `x` leads to stack smash - // protection with the `strong` heuristic, but not with the `basic` - // heuristic. It does not matter that the reference is not mut. - // - // An interesting note is that a similar function in C++ *would* be - // protected by the `basic` heuristic, because `std::string` has a char - // array internally as a small object optimization: - // ``` - // cat < - // void f(void (*g)(const std::string&)) { - // std::string x; - // g(x); - // } - // EOF - // ``` - // + // protection. It does not matter that the reference is not mut. // all: __security_check_cookie - // strong-NOT: __security_check_cookie - // basic-NOT: __security_check_cookie + // strong: __security_check_cookie + // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } pub trait SelfByRef { @@ -180,6 +186,7 @@ impl SelfByRef for i32 { // CHECK-LABEL: local_var_addr_taken_used_locally_only #[no_mangle] pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32)) { + // CHECK-DAG: .cv_fpo_endprologue let x = factory(); let g = x.f(); sink(g); @@ -194,6 +201,8 @@ pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32 // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } pub struct Gigastruct { @@ -207,6 +216,7 @@ pub struct Gigastruct { // CHECK-LABEL: local_large_var_moved #[no_mangle] pub fn local_large_var_moved(f: fn(Gigastruct)) { + // CHECK-DAG: .cv_fpo_endprologue let x = Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }; f(x); @@ -231,11 +241,14 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: local_large_var_cloned #[no_mangle] pub fn local_large_var_cloned(f: fn(Gigastruct)) { + // CHECK-DAG: .cv_fpo_endprologue f(Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }); // A new instance of `Gigastruct` is passed to `f()`, without any apparent @@ -260,6 +273,8 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } extern "C" { @@ -293,6 +308,7 @@ extern "C" { // CHECK-LABEL: alloca_small_compile_time_constant_arg #[no_mangle] pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { + // CHECK-DAG: .cv_fpo_endprologue f(unsafe { alloca(8) }); // all: __security_check_cookie @@ -300,11 +316,14 @@ pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: alloca_large_compile_time_constant_arg #[no_mangle] pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { + // CHECK-DAG: .cv_fpo_endprologue f(unsafe { alloca(9) }); // all: __security_check_cookie @@ -312,11 +331,14 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // CHECK-LABEL: alloca_dynamic_arg #[no_mangle] pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { + // CHECK-DAG: .cv_fpo_endprologue f(unsafe { alloca(n) }); // all: __security_check_cookie @@ -324,18 +346,19 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } // The question then is: in what ways can Rust code generate array-`alloca` // LLVM instructions? This appears to only be generated by // rustc_codegen_ssa::traits::Builder::array_alloca() through -// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). FWICT -// this is support for the "unsized locals" unstable feature: -// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. +// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). // CHECK-LABEL: unsized_fn_param #[no_mangle] pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { + // CHECK-DAG: .cv_fpo_endprologue let n = if l { 1 } else { 2 }; f(*Box::<[u8]>::from(&s[0..n])); // slice-copy with Box::from @@ -346,14 +369,11 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { // alloca, and is therefore not protected by the `strong` or `basic` // heuristics. - // We should have a __security_check_cookie call in `all` and `strong` modes but - // LLVM does not support generating stack protectors in functions with funclet - // based EH personalities. - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 // all-NOT: __security_check_cookie // strong-NOT: __security_check_cookie - // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .cv_fpo_endproc } diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs index 9a3dabc74dde..56a6f08da587 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs @@ -7,7 +7,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort #![crate_type = "lib"] #![feature(unsized_fn_params)] @@ -25,6 +25,7 @@ pub fn emptyfn() { // CHECK-LABEL: array_char #[no_mangle] pub fn array_char(f: fn(*const char)) { + // CHECK-DAG: .seh_endprologue let a = ['c'; 1]; let b = ['d'; 3]; let c = ['e'; 15]; @@ -38,11 +39,14 @@ pub fn array_char(f: fn(*const char)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: array_u8_1 #[no_mangle] pub fn array_u8_1(f: fn(*const u8)) { + // CHECK-DAG: .seh_endprologue let a = [0u8; 1]; f(&a as *const _); @@ -54,11 +58,14 @@ pub fn array_u8_1(f: fn(*const u8)) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: array_u8_small: #[no_mangle] pub fn array_u8_small(f: fn(*const u8)) { + // CHECK-DAG: .seh_endprologue let a = [0u8; 2]; let b = [0u8; 7]; f(&a as *const _); @@ -71,11 +78,14 @@ pub fn array_u8_small(f: fn(*const u8)) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: array_u8_large: #[no_mangle] pub fn array_u8_large(f: fn(*const u8)) { + // CHECK-DAG: .seh_endprologue let a = [0u8; 9]; f(&a as *const _); @@ -87,6 +97,8 @@ pub fn array_u8_large(f: fn(*const u8)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } #[derive(Copy, Clone)] @@ -95,6 +107,7 @@ pub struct ByteSizedNewtype(u8); // CHECK-LABEL: array_bytesizednewtype_9: #[no_mangle] pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { + // CHECK-DAG: .seh_endprologue let a = [ByteSizedNewtype(0); 9]; f(&a as *const _); @@ -106,11 +119,14 @@ pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: local_var_addr_used_indirectly #[no_mangle] pub fn local_var_addr_used_indirectly(f: fn(bool)) { + // CHECK-DAG: .seh_endprologue let a = 5; let a_addr = &a as *const _ as usize; f(a_addr & 0x10 == 0); @@ -133,6 +149,8 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: local_string_addr_taken @@ -143,31 +161,11 @@ pub fn local_string_addr_taken(f: fn(&String)) { f(&x); // Taking the address of the local variable `x` leads to stack smash - // protection with the `strong` heuristic, but not with the `basic` - // heuristic. It does not matter that the reference is not mut. - // - // An interesting note is that a similar function in C++ *would* be - // protected by the `basic` heuristic, because `std::string` has a char - // array internally as a small object optimization: - // ``` - // cat < - // void f(void (*g)(const std::string&)) { - // std::string x; - // g(x); - // } - // EOF - // ``` - // + // protection. It does not matter that the reference is not mut. - // We should have a __security_check_cookie call in `all` and `strong` modes but - // LLVM does not support generating stack protectors in functions with funclet - // based EH personalities. - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 - // all-NOT: __security_check_cookie - // strong-NOT: __security_check_cookie - - // basic-NOT: __security_check_cookie + // all: __security_check_cookie + // strong: __security_check_cookie + // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie @@ -187,6 +185,7 @@ impl SelfByRef for i32 { // CHECK-LABEL: local_var_addr_taken_used_locally_only #[no_mangle] pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32)) { + // CHECK-DAG: .seh_endprologue let x = factory(); let g = x.f(); sink(g); @@ -201,6 +200,8 @@ pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32 // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } pub struct Gigastruct { @@ -214,6 +215,7 @@ pub struct Gigastruct { // CHECK-LABEL: local_large_var_moved #[no_mangle] pub fn local_large_var_moved(f: fn(Gigastruct)) { + // CHECK-DAG: .seh_endprologue let x = Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }; f(x); @@ -238,11 +240,14 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: local_large_var_cloned #[no_mangle] pub fn local_large_var_cloned(f: fn(Gigastruct)) { + // CHECK-DAG: .seh_endprologue f(Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }); // A new instance of `Gigastruct` is passed to `f()`, without any apparent @@ -267,6 +272,8 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) { // basic: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } extern "C" { @@ -300,6 +307,7 @@ extern "C" { // CHECK-LABEL: alloca_small_compile_time_constant_arg #[no_mangle] pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { + // CHECK-DAG: .seh_endprologue f(unsafe { alloca(8) }); // all: __security_check_cookie @@ -307,11 +315,14 @@ pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: alloca_large_compile_time_constant_arg #[no_mangle] pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { + // CHECK-DAG: .seh_endprologue f(unsafe { alloca(9) }); // all: __security_check_cookie @@ -319,11 +330,14 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // CHECK-LABEL: alloca_dynamic_arg #[no_mangle] pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { + // CHECK-DAG: .seh_endprologue f(unsafe { alloca(n) }); // all: __security_check_cookie @@ -331,18 +345,19 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } // The question then is: in what ways can Rust code generate array-`alloca` // LLVM instructions? This appears to only be generated by // rustc_codegen_ssa::traits::Builder::array_alloca() through -// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). FWICT -// this is support for the "unsized locals" unstable feature: -// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html. +// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). // CHECK-LABEL: unsized_fn_param #[no_mangle] pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { + // CHECK-DAG: .seh_endprologue let n = if l { 1 } else { 2 }; f(*Box::<[u8]>::from(&s[0..n])); // slice-copy with Box::from @@ -353,14 +368,11 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { // alloca, and is therefore not protected by the `strong` or `basic` // heuristics. - // We should have a __security_check_cookie call in `all` and `strong` modes but - // LLVM does not support generating stack protectors in functions with funclet - // based EH personalities. - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 // all-NOT: __security_check_cookie // strong-NOT: __security_check_cookie - // basic-NOT: __security_check_cookie // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie + + // CHECK-DAG: .seh_endproc } diff --git a/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs b/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs index 0218fe0a52f8..9f182985d157 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-target-support.rs @@ -173,7 +173,7 @@ //@ [r84] needs-llvm-components: x86 //@ [r85] compile-flags: --target x86_64-unknown-redox //@ [r85] needs-llvm-components: x86 -//@ compile-flags: -Z stack-protector=all +//@ compile-flags: -Z stack-protector=all -Cpanic=abort //@ compile-flags: -C opt-level=2 #![crate_type = "lib"] From a5f677b665961956f25e81818b1983687449135d Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 12 Nov 2025 23:40:47 -0500 Subject: [PATCH 015/489] Try to fix i686 --- ...-protector-heuristics-effect-windows-32bit.rs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs index 5759c387e3b1..d1b51068fce5 100644 --- a/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs +++ b/tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs @@ -7,7 +7,7 @@ //@ [strong] compile-flags: -Z stack-protector=strong //@ [basic] compile-flags: -Z stack-protector=basic //@ [none] compile-flags: -Z stack-protector=none -//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort +//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled -Cpanic=abort -Cdebuginfo=1 #![crate_type = "lib"] #![allow(internal_features)] @@ -26,7 +26,6 @@ pub fn emptyfn() { // CHECK-LABEL: array_char #[no_mangle] pub fn array_char(f: fn(*const char)) { - // CHECK-DAG: .cv_fpo_endprologue let a = ['c'; 1]; let b = ['d'; 3]; let c = ['e'; 15]; @@ -47,7 +46,6 @@ pub fn array_char(f: fn(*const char)) { // CHECK-LABEL: array_u8_1 #[no_mangle] pub fn array_u8_1(f: fn(*const u8)) { - // CHECK-DAG: .cv_fpo_endprologue let a = [0u8; 1]; f(&a as *const _); @@ -66,7 +64,6 @@ pub fn array_u8_1(f: fn(*const u8)) { // CHECK-LABEL: array_u8_small: #[no_mangle] pub fn array_u8_small(f: fn(*const u8)) { - // CHECK-DAG: .cv_fpo_endprologue let a = [0u8; 2]; let b = [0u8; 7]; f(&a as *const _); @@ -86,7 +83,6 @@ pub fn array_u8_small(f: fn(*const u8)) { // CHECK-LABEL: array_u8_large: #[no_mangle] pub fn array_u8_large(f: fn(*const u8)) { - // CHECK-DAG: .cv_fpo_endprologue let a = [0u8; 9]; f(&a as *const _); @@ -108,7 +104,6 @@ pub struct ByteSizedNewtype(u8); // CHECK-LABEL: array_bytesizednewtype_9: #[no_mangle] pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { - // CHECK-DAG: .cv_fpo_endprologue let a = [ByteSizedNewtype(0); 9]; f(&a as *const _); @@ -127,7 +122,6 @@ pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) { // CHECK-LABEL: local_var_addr_used_indirectly #[no_mangle] pub fn local_var_addr_used_indirectly(f: fn(bool)) { - // CHECK-DAG: .cv_fpo_endprologue let a = 5; let a_addr = &a as *const _ as usize; f(a_addr & 0x10 == 0); @@ -157,7 +151,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) { // CHECK-LABEL: local_string_addr_taken #[no_mangle] pub fn local_string_addr_taken(f: fn(&String)) { - // CHECK-DAG: .cv_fpo_endprologue let x = String::new(); f(&x); @@ -186,7 +179,6 @@ impl SelfByRef for i32 { // CHECK-LABEL: local_var_addr_taken_used_locally_only #[no_mangle] pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32)) { - // CHECK-DAG: .cv_fpo_endprologue let x = factory(); let g = x.f(); sink(g); @@ -216,7 +208,6 @@ pub struct Gigastruct { // CHECK-LABEL: local_large_var_moved #[no_mangle] pub fn local_large_var_moved(f: fn(Gigastruct)) { - // CHECK-DAG: .cv_fpo_endprologue let x = Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }; f(x); @@ -248,7 +239,6 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) { // CHECK-LABEL: local_large_var_cloned #[no_mangle] pub fn local_large_var_cloned(f: fn(Gigastruct)) { - // CHECK-DAG: .cv_fpo_endprologue f(Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 }); // A new instance of `Gigastruct` is passed to `f()`, without any apparent @@ -308,7 +298,6 @@ extern "C" { // CHECK-LABEL: alloca_small_compile_time_constant_arg #[no_mangle] pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { - // CHECK-DAG: .cv_fpo_endprologue f(unsafe { alloca(8) }); // all: __security_check_cookie @@ -323,7 +312,6 @@ pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) { // CHECK-LABEL: alloca_large_compile_time_constant_arg #[no_mangle] pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { - // CHECK-DAG: .cv_fpo_endprologue f(unsafe { alloca(9) }); // all: __security_check_cookie @@ -338,7 +326,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) { // CHECK-LABEL: alloca_dynamic_arg #[no_mangle] pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { - // CHECK-DAG: .cv_fpo_endprologue f(unsafe { alloca(n) }); // all: __security_check_cookie @@ -358,7 +345,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) { // CHECK-LABEL: unsized_fn_param #[no_mangle] pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { - // CHECK-DAG: .cv_fpo_endprologue let n = if l { 1 } else { 2 }; f(*Box::<[u8]>::from(&s[0..n])); // slice-copy with Box::from From cf7efc3624e9060ac88cbd3381cdc189eb16c2f2 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Thu, 13 Nov 2025 19:08:35 +0800 Subject: [PATCH 016/489] Fix complete unit return semicolon in arg-list Example --- ```rust fn foo() {} fn baz(_: impl FnOnce()) {} fn bar() { baz(fo$0); } ``` **Before this PR** ```rust fn foo() {} fn baz(_: impl FnOnce()) {} fn bar() { baz(foo();$0); } ``` **After this PR** ```rust fn foo() {} fn baz(_: impl FnOnce()) {} fn bar() { baz(foo()$0); } ``` --- .../crates/ide-completion/src/context.rs | 59 +++++-------------- .../ide-completion/src/render/function.rs | 21 +++++++ 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context.rs index 2f166b718451..8051f6d20775 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context.rs @@ -4,7 +4,7 @@ mod analysis; #[cfg(test)] mod tests; -use std::{iter, ops::ControlFlow}; +use std::iter; use base_db::RootQueryDb as _; use hir::{ @@ -21,7 +21,6 @@ use syntax::{ SyntaxKind::{self, *}, SyntaxToken, T, TextRange, TextSize, ast::{self, AttrKind, NameOrNameRef}, - match_ast, }; use crate::{ @@ -818,48 +817,20 @@ impl<'db> CompletionContext<'db> { .extend(exclude_traits.iter().map(|&t| (t.into(), AutoImportExclusionType::Always))); // FIXME: This should be part of `CompletionAnalysis` / `expand_and_analyze` - let complete_semicolon = if config.add_semicolon_to_unit { - let inside_closure_ret = token.parent_ancestors().try_for_each(|ancestor| { - match_ast! { - match ancestor { - ast::BlockExpr(_) => ControlFlow::Break(false), - ast::ClosureExpr(_) => ControlFlow::Break(true), - _ => ControlFlow::Continue(()) - } - } - }); - - if inside_closure_ret == ControlFlow::Break(true) { - CompleteSemicolon::DoNotComplete - } else { - let next_non_trivia_token = - std::iter::successors(token.next_token(), |it| it.next_token()) - .find(|it| !it.kind().is_trivia()); - let in_match_arm = token.parent_ancestors().try_for_each(|ancestor| { - if ast::MatchArm::can_cast(ancestor.kind()) { - ControlFlow::Break(true) - } else if matches!( - ancestor.kind(), - SyntaxKind::EXPR_STMT | SyntaxKind::BLOCK_EXPR - ) { - ControlFlow::Break(false) - } else { - ControlFlow::Continue(()) - } - }); - // FIXME: This will assume expr macros are not inside match, we need to somehow go to the "parent" of the root node. - let in_match_arm = match in_match_arm { - ControlFlow::Continue(()) => false, - ControlFlow::Break(it) => it, - }; - let complete_token = if in_match_arm { T![,] } else { T![;] }; - if next_non_trivia_token.map(|it| it.kind()) == Some(complete_token) { - CompleteSemicolon::DoNotComplete - } else if in_match_arm { - CompleteSemicolon::CompleteComma - } else { - CompleteSemicolon::CompleteSemi - } + let complete_semicolon = if !config.add_semicolon_to_unit { + CompleteSemicolon::DoNotComplete + } else if let Some(term_node) = + sema.token_ancestors_with_macros(token.clone()).find(|node| { + matches!(node.kind(), BLOCK_EXPR | MATCH_ARM | CLOSURE_EXPR | ARG_LIST | PAREN_EXPR) + }) + { + let next_token = iter::successors(token.next_token(), |it| it.next_token()) + .map(|it| it.kind()) + .find(|kind| !kind.is_trivia()); + match term_node.kind() { + MATCH_ARM if next_token != Some(T![,]) => CompleteSemicolon::CompleteComma, + BLOCK_EXPR if next_token != Some(T![;]) => CompleteSemicolon::CompleteSemi, + _ => CompleteSemicolon::DoNotComplete, } } else { CompleteSemicolon::DoNotComplete diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/render/function.rs b/src/tools/rust-analyzer/crates/ide-completion/src/render/function.rs index 3235323b3a59..4713b1f1afa7 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/render/function.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/render/function.rs @@ -884,6 +884,27 @@ fn baz(_: impl FnOnce()) {} fn bar() { baz(|| foo()$0); } +"#, + ); + } + + #[test] + fn no_semicolon_in_arg_list() { + check_edit( + r#"foo"#, + r#" +fn foo() {} +fn baz(_: impl FnOnce()) {} +fn bar() { + baz(fo$0); +} +"#, + r#" +fn foo() {} +fn baz(_: impl FnOnce()) {} +fn bar() { + baz(foo()$0); +} "#, ); } From d707ec1e03b2424507fed49f308b97ac59ba0e19 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Tue, 18 Nov 2025 14:05:03 -0500 Subject: [PATCH 017/489] Allow multiline suggestions in `map-unwrap-or` --- clippy_lints/src/methods/map_unwrap_or.rs | 12 +++------- tests/ui/map_unwrap_or.stderr | 29 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/methods/map_unwrap_or.rs b/clippy_lints/src/methods/map_unwrap_or.rs index 62bdc4a3e411..8eb26fb50747 100644 --- a/clippy_lints/src/methods/map_unwrap_or.rs +++ b/clippy_lints/src/methods/map_unwrap_or.rs @@ -1,4 +1,4 @@ -use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::res::MaybeDef; use clippy_utils::source::snippet; @@ -51,11 +51,8 @@ pub(super) fn check<'tcx>( // get snippets for args to map() and unwrap_or_else() let map_snippet = snippet(cx, map_arg.span, ".."); let unwrap_snippet = snippet(cx, unwrap_arg.span, ".."); - // lint, with note if neither arg is > 1 line and both map() and - // unwrap_or_else() have the same span - let multiline = map_snippet.lines().count() > 1 || unwrap_snippet.lines().count() > 1; - let same_span = map_arg.span.eq_ctxt(unwrap_arg.span); - if same_span && !multiline { + // lint, with note if both map() and unwrap_or_else() have the same span + if map_arg.span.eq_ctxt(unwrap_arg.span) { let var_snippet = snippet(cx, recv.span, ".."); span_lint_and_sugg( cx, @@ -67,9 +64,6 @@ pub(super) fn check<'tcx>( Applicability::MachineApplicable, ); return true; - } else if same_span && multiline { - span_lint(cx, MAP_UNWRAP_OR, expr.span, msg); - return true; } } diff --git a/tests/ui/map_unwrap_or.stderr b/tests/ui/map_unwrap_or.stderr index 0b6c9b7fcf19..99fcf3d77a3b 100644 --- a/tests/ui/map_unwrap_or.stderr +++ b/tests/ui/map_unwrap_or.stderr @@ -123,6 +123,14 @@ LL | | x + 1 LL | | } LL | | ).unwrap_or_else(|| 0); | |__________________________^ + | +help: try + | +LL ~ let _ = opt.map_or_else(|| 0, |x| { +LL + +LL + x + 1 +LL ~ }); + | error: called `map().unwrap_or_else()` on an `Option` value --> tests/ui/map_unwrap_or.rs:63:13 @@ -134,6 +142,12 @@ LL | | .unwrap_or_else(|| LL | | 0 LL | | ); | |_________^ + | +help: try + | +LL ~ let _ = opt.map_or_else(|| +LL ~ 0, |x| x + 1); + | error: called `map().unwrap_or(false)` on an `Option` value --> tests/ui/map_unwrap_or.rs:70:13 @@ -157,6 +171,14 @@ LL | | x + 1 LL | | } LL | | ).unwrap_or_else(|_e| 0); | |____________________________^ + | +help: try + | +LL ~ let _ = res.map_or_else(|_e| 0, |x| { +LL + +LL + x + 1 +LL ~ }); + | error: called `map().unwrap_or_else()` on a `Result` value --> tests/ui/map_unwrap_or.rs:86:13 @@ -168,6 +190,13 @@ LL | | .unwrap_or_else(|_e| { LL | | 0 LL | | }); | |__________^ + | +help: try + | +LL ~ let _ = res.map_or_else(|_e| { +LL + 0 +LL ~ }, |x| x + 1); + | error: called `map().unwrap_or_else()` on a `Result` value --> tests/ui/map_unwrap_or.rs:111:13 From d7860a51079e6b4cee826ade1f9fd0ccb6ba31ad Mon Sep 17 00:00:00 2001 From: reucru01 Date: Fri, 24 Oct 2025 10:15:01 +0100 Subject: [PATCH 018/489] Fixes generator, neon intrinics now build in debug This fixes build issues associated with failing LLVM const param assertions --- .../src/arm_shared/neon/generated.rs | 1144 ++++++----------- .../spec/neon/arm_shared.spec.yml | 333 ++--- .../crates/stdarch-gen-arm/src/expression.rs | 17 + .../crates/stdarch-gen-arm/src/intrinsic.rs | 3 +- 4 files changed, 572 insertions(+), 925 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs index b5ba792b18ae..c1bd70175c4c 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs @@ -15137,268 +15137,104 @@ pub unsafe fn vld1q_f16_x4(a: *const f16) -> float16x8x4_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] pub unsafe fn vld1_f32(ptr: *const f32) -> float32x2_t { - transmute(vld1_v2f32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_f32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] -pub unsafe fn vld1_f32(ptr: *const f32) -> float32x2_t { - let ret_val: float32x2_t = transmute(vld1_v2f32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v2f32::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_f32)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))] pub unsafe fn vld1q_f32(ptr: *const f32) -> float32x4_t { - transmute(vld1q_v4f32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_f32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))] -pub unsafe fn vld1q_f32(ptr: *const f32) -> float32x4_t { - let ret_val: float32x4_t = transmute(vld1q_v4f32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v4f32::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u8)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] pub unsafe fn vld1_u8(ptr: *const u8) -> uint8x8_t { - transmute(vld1_v8i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] -pub unsafe fn vld1_u8(ptr: *const u8) -> uint8x8_t { - let ret_val: uint8x8_t = transmute(vld1_v8i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v8i8::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u8)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] pub unsafe fn vld1q_u8(ptr: *const u8) -> uint8x16_t { - transmute(vld1q_v16i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] -pub unsafe fn vld1q_u8(ptr: *const u8) -> uint8x16_t { - let ret_val: uint8x16_t = transmute(vld1q_v16i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!( - ret_val, - ret_val, - [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v16i8::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u16)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] pub unsafe fn vld1_u16(ptr: *const u16) -> uint16x4_t { - transmute(vld1_v4i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] -pub unsafe fn vld1_u16(ptr: *const u16) -> uint16x4_t { - let ret_val: uint16x4_t = transmute(vld1_v4i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v4i16::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u16)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] pub unsafe fn vld1q_u16(ptr: *const u16) -> uint16x8_t { - transmute(vld1q_v8i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] -pub unsafe fn vld1q_u16(ptr: *const u16) -> uint16x8_t { - let ret_val: uint16x8_t = transmute(vld1q_v8i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v8i16::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u32)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] pub unsafe fn vld1_u32(ptr: *const u32) -> uint32x2_t { - transmute(vld1_v2i32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] -pub unsafe fn vld1_u32(ptr: *const u32) -> uint32x2_t { - let ret_val: uint32x2_t = transmute(vld1_v2i32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v2i32::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u32)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))] pub unsafe fn vld1q_u32(ptr: *const u32) -> uint32x4_t { - transmute(vld1q_v4i32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))] -pub unsafe fn vld1q_u32(ptr: *const u32) -> uint32x4_t { - let ret_val: uint32x4_t = transmute(vld1q_v4i32( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v4i32::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_u64)"] @@ -15410,212 +15246,86 @@ pub unsafe fn vld1q_u32(ptr: *const u32) -> uint32x4_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] pub unsafe fn vld1_u64(ptr: *const u64) -> uint64x1_t { - transmute(vld1_v1i64( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v1i64::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u64)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.64"))] pub unsafe fn vld1q_u64(ptr: *const u64) -> uint64x2_t { - transmute(vld1q_v2i64( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_u64)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.64"))] -pub unsafe fn vld1q_u64(ptr: *const u64) -> uint64x2_t { - let ret_val: uint64x2_t = transmute(vld1q_v2i64( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v2i64::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_p8)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] pub unsafe fn vld1_p8(ptr: *const p8) -> poly8x8_t { - transmute(vld1_v8i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_p8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] -pub unsafe fn vld1_p8(ptr: *const p8) -> poly8x8_t { - let ret_val: poly8x8_t = transmute(vld1_v8i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v8i8::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_p8)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] pub unsafe fn vld1q_p8(ptr: *const p8) -> poly8x16_t { - transmute(vld1q_v16i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_p8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] -pub unsafe fn vld1q_p8(ptr: *const p8) -> poly8x16_t { - let ret_val: poly8x16_t = transmute(vld1q_v16i8( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!( - ret_val, - ret_val, - [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v16i8::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_p16)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] pub unsafe fn vld1_p16(ptr: *const p16) -> poly16x4_t { - transmute(vld1_v4i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_p16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] -pub unsafe fn vld1_p16(ptr: *const p16) -> poly16x4_t { - let ret_val: poly16x4_t = transmute(vld1_v4i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1_v4i16::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_p16)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] pub unsafe fn vld1q_p16(ptr: *const p16) -> poly16x8_t { - transmute(vld1q_v8i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_p16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,v7")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] -pub unsafe fn vld1q_p16(ptr: *const p16) -> poly16x8_t { - let ret_val: poly16x8_t = transmute(vld1q_v8i16( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [7, 6, 5, 4, 3, 2, 1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v8i16::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_p64)"] #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] -#[cfg(target_endian = "little")] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,aes")] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.64"))] pub unsafe fn vld1q_p64(ptr: *const p64) -> poly64x2_t { - transmute(vld1q_v2i64( - ptr as *const i8, - crate::mem::align_of::() as i32, - )) -} -#[doc = "Load multiple single-element structures to one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_p64)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] -#[inline] -#[cfg(target_endian = "big")] -#[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,aes")] -#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.64"))] -pub unsafe fn vld1q_p64(ptr: *const p64) -> poly64x2_t { - let ret_val: poly64x2_t = transmute(vld1q_v2i64( - ptr as *const i8, - crate::mem::align_of::() as i32, - )); - simd_shuffle!(ret_val, ret_val, [1, 0]) + const ALIGN: i32 = crate::mem::align_of::() as i32; + transmute(vld1q_v2i64::(ptr as *const i8)) } #[doc = "Load multiple single-element structures to one, two, three, or four registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_f32_x2)"] @@ -16694,7 +16404,8 @@ pub unsafe fn vld1q_p64_x4(a: *const p64) -> poly64x2x4_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] pub unsafe fn vld1_s8(ptr: *const i8) -> int8x8_t { - vld1_v8i8(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1_v8i8::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_s8)"] @@ -16706,7 +16417,8 @@ pub unsafe fn vld1_s8(ptr: *const i8) -> int8x8_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8"))] pub unsafe fn vld1q_s8(ptr: *const i8) -> int8x16_t { - vld1q_v16i8(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1q_v16i8::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_s16)"] @@ -16718,7 +16430,8 @@ pub unsafe fn vld1q_s8(ptr: *const i8) -> int8x16_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] pub unsafe fn vld1_s16(ptr: *const i16) -> int16x4_t { - vld1_v4i16(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1_v4i16::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_s16)"] @@ -16730,7 +16443,8 @@ pub unsafe fn vld1_s16(ptr: *const i16) -> int16x4_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.16"))] pub unsafe fn vld1q_s16(ptr: *const i16) -> int16x8_t { - vld1q_v8i16(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1q_v8i16::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_s32)"] @@ -16742,7 +16456,8 @@ pub unsafe fn vld1q_s16(ptr: *const i16) -> int16x8_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] pub unsafe fn vld1_s32(ptr: *const i32) -> int32x2_t { - vld1_v2i32(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1_v2i32::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_s32)"] @@ -16754,7 +16469,8 @@ pub unsafe fn vld1_s32(ptr: *const i32) -> int32x2_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))] pub unsafe fn vld1q_s32(ptr: *const i32) -> int32x4_t { - vld1q_v4i32(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1q_v4i32::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_s64)"] @@ -16766,7 +16482,8 @@ pub unsafe fn vld1q_s32(ptr: *const i32) -> int32x4_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vldr))] pub unsafe fn vld1_s64(ptr: *const i64) -> int64x1_t { - vld1_v1i64(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1_v1i64::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_s64)"] @@ -16778,7 +16495,8 @@ pub unsafe fn vld1_s64(ptr: *const i64) -> int64x1_t { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.64"))] pub unsafe fn vld1q_s64(ptr: *const i64) -> int64x2_t { - vld1q_v2i64(ptr as *const i8, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vld1q_v2i64::(ptr as *const i8) } #[doc = "Load multiple single-element structures to one, two, three, or four registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_s8_x2)"] @@ -19417,160 +19135,136 @@ pub unsafe fn vld1q_p16_x4(a: *const p16) -> poly16x8x4_t { ret_val.3 = unsafe { simd_shuffle!(ret_val.3, ret_val.3, [7, 6, 5, 4, 3, 2, 1, 0]) }; ret_val } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_v1i64)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1_v1i64(a: *const i8, b: i32) -> int64x1_t { +unsafe fn vld1_v1i64(a: *const i8) -> int64x1_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v1i64")] fn _vld1_v1i64(a: *const i8, b: i32) -> int64x1_t; } - _vld1_v1i64(a, b) + _vld1_v1i64(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_v2f32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1_v2f32(a: *const i8, b: i32) -> float32x2_t { +unsafe fn vld1_v2f32(a: *const i8) -> float32x2_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v2f32")] fn _vld1_v2f32(a: *const i8, b: i32) -> float32x2_t; } - _vld1_v2f32(a, b) + _vld1_v2f32(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_v2i32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1_v2i32(a: *const i8, b: i32) -> int32x2_t { +unsafe fn vld1_v2i32(a: *const i8) -> int32x2_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v2i32")] fn _vld1_v2i32(a: *const i8, b: i32) -> int32x2_t; } - _vld1_v2i32(a, b) + _vld1_v2i32(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_v4i16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1_v4i16(a: *const i8, b: i32) -> int16x4_t { +unsafe fn vld1_v4i16(a: *const i8) -> int16x4_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v4i16")] fn _vld1_v4i16(a: *const i8, b: i32) -> int16x4_t; } - _vld1_v4i16(a, b) + _vld1_v4i16(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_v8i8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1_v8i8(a: *const i8, b: i32) -> int8x8_t { +unsafe fn vld1_v8i8(a: *const i8) -> int8x8_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v8i8")] fn _vld1_v8i8(a: *const i8, b: i32) -> int8x8_t; } - _vld1_v8i8(a, b) + _vld1_v8i8(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_v16i8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1q_v16i8(a: *const i8, b: i32) -> int8x16_t { +unsafe fn vld1q_v16i8(a: *const i8) -> int8x16_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v16i8")] fn _vld1q_v16i8(a: *const i8, b: i32) -> int8x16_t; } - _vld1q_v16i8(a, b) + _vld1q_v16i8(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_v2i64)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1q_v2i64(a: *const i8, b: i32) -> int64x2_t { +unsafe fn vld1q_v2i64(a: *const i8) -> int64x2_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v2i64")] fn _vld1q_v2i64(a: *const i8, b: i32) -> int64x2_t; } - _vld1q_v2i64(a, b) + _vld1q_v2i64(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_v4f32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1q_v4f32(a: *const i8, b: i32) -> float32x4_t { +unsafe fn vld1q_v4f32(a: *const i8) -> float32x4_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v4f32")] fn _vld1q_v4f32(a: *const i8, b: i32) -> float32x4_t; } - _vld1q_v4f32(a, b) + _vld1q_v4f32(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_v4i32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1q_v4i32(a: *const i8, b: i32) -> int32x4_t { +unsafe fn vld1q_v4i32(a: *const i8) -> int32x4_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v4i32")] fn _vld1q_v4i32(a: *const i8, b: i32) -> int32x4_t; } - _vld1q_v4i32(a, b) + _vld1q_v4i32(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_v8i16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] +#[rustc_legacy_const_generics(1)] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.8", ALIGN = 0))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -unsafe fn vld1q_v8i16(a: *const i8, b: i32) -> int16x8_t { +unsafe fn vld1q_v8i16(a: *const i8) -> int16x8_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v8i16")] fn _vld1q_v8i16(a: *const i8, b: i32) -> int16x8_t; } - _vld1q_v8i16(a, b) + _vld1q_v8i16(a, ALIGN) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1_v4f16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] @@ -19585,10 +19279,6 @@ unsafe fn vld1_v4f16(a: *const i8, b: i32) -> float16x4_t { } _vld1_v4f16(a, b) } -#[doc = "Load multiple single-element structures to one, two, three, or four registers"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld1q_v8f16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[cfg(target_arch = "arm")] #[target_feature(enable = "neon,v7")] @@ -61060,117 +60750,229 @@ pub fn vsha256su1q_u32(tw0_3: uint32x4_t, w8_11: uint32x4_t, w12_15: uint32x4_t) } unsafe { _vsha256su1q_u32(tw0_3, w8_11, w12_15) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v16i8)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v16i8(a: int8x16_t, b: int8x16_t, c: int8x16_t) -> int8x16_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v16i8(a: int8x16_t, b: int8x16_t) -> int8x16_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v16i8")] - fn _vshiftins_v16i8(a: int8x16_t, b: int8x16_t, c: int8x16_t) -> int8x16_t; + fn _vshiftlins_v16i8(a: int8x16_t, b: int8x16_t, c: int8x16_t) -> int8x16_t; } - unsafe { _vshiftins_v16i8(a, b, c) } + unsafe { _vshiftlins_v16i8(a, b, const { int8x16_t([N as i8; 16]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v1i64)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v1i64(a: int64x1_t, b: int64x1_t, c: int64x1_t) -> int64x1_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v1i64(a: int64x1_t, b: int64x1_t) -> int64x1_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v1i64")] - fn _vshiftins_v1i64(a: int64x1_t, b: int64x1_t, c: int64x1_t) -> int64x1_t; + fn _vshiftlins_v1i64(a: int64x1_t, b: int64x1_t, c: int64x1_t) -> int64x1_t; } - unsafe { _vshiftins_v1i64(a, b, c) } + unsafe { _vshiftlins_v1i64(a, b, const { int64x1_t([N as i64; 1]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v2i32)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v2i32(a: int32x2_t, b: int32x2_t, c: int32x2_t) -> int32x2_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v2i32(a: int32x2_t, b: int32x2_t) -> int32x2_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v2i32")] - fn _vshiftins_v2i32(a: int32x2_t, b: int32x2_t, c: int32x2_t) -> int32x2_t; + fn _vshiftlins_v2i32(a: int32x2_t, b: int32x2_t, c: int32x2_t) -> int32x2_t; } - unsafe { _vshiftins_v2i32(a, b, c) } + unsafe { _vshiftlins_v2i32(a, b, const { int32x2_t([N; 2]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v2i64)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v2i64(a: int64x2_t, b: int64x2_t, c: int64x2_t) -> int64x2_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v2i64(a: int64x2_t, b: int64x2_t) -> int64x2_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v2i64")] - fn _vshiftins_v2i64(a: int64x2_t, b: int64x2_t, c: int64x2_t) -> int64x2_t; + fn _vshiftlins_v2i64(a: int64x2_t, b: int64x2_t, c: int64x2_t) -> int64x2_t; } - unsafe { _vshiftins_v2i64(a, b, c) } + unsafe { _vshiftlins_v2i64(a, b, const { int64x2_t([N as i64; 2]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v4i16)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v4i16(a: int16x4_t, b: int16x4_t, c: int16x4_t) -> int16x4_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v4i16(a: int16x4_t, b: int16x4_t) -> int16x4_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v4i16")] - fn _vshiftins_v4i16(a: int16x4_t, b: int16x4_t, c: int16x4_t) -> int16x4_t; + fn _vshiftlins_v4i16(a: int16x4_t, b: int16x4_t, c: int16x4_t) -> int16x4_t; } - unsafe { _vshiftins_v4i16(a, b, c) } + unsafe { _vshiftlins_v4i16(a, b, const { int16x4_t([N as i16; 4]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v4i32)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v4i32(a: int32x4_t, b: int32x4_t, c: int32x4_t) -> int32x4_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v4i32(a: int32x4_t, b: int32x4_t) -> int32x4_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v4i32")] - fn _vshiftins_v4i32(a: int32x4_t, b: int32x4_t, c: int32x4_t) -> int32x4_t; + fn _vshiftlins_v4i32(a: int32x4_t, b: int32x4_t, c: int32x4_t) -> int32x4_t; } - unsafe { _vshiftins_v4i32(a, b, c) } + unsafe { _vshiftlins_v4i32(a, b, const { int32x4_t([N; 4]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v8i16)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v8i16(a: int16x8_t, b: int16x8_t, c: int16x8_t) -> int16x8_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v8i16(a: int16x8_t, b: int16x8_t) -> int16x8_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v8i16")] - fn _vshiftins_v8i16(a: int16x8_t, b: int16x8_t, c: int16x8_t) -> int16x8_t; + fn _vshiftlins_v8i16(a: int16x8_t, b: int16x8_t, c: int16x8_t) -> int16x8_t; } - unsafe { _vshiftins_v8i16(a, b, c) } + unsafe { _vshiftlins_v8i16(a, b, const { int16x8_t([N as i16; 8]) }) } } -#[doc = "Shift Right and Insert (immediate)"] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftins_v8i8)"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -fn vshiftins_v8i8(a: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t { +#[rustc_legacy_const_generics(2)] +fn vshiftlins_v8i8(a: int8x8_t, b: int8x8_t) -> int8x8_t { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v8i8")] - fn _vshiftins_v8i8(a: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t; + fn _vshiftlins_v8i8(a: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t; } - unsafe { _vshiftins_v8i8(a, b, c) } + unsafe { _vshiftlins_v8i8(a, b, const { int8x8_t([N as i8; 8]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v16i8)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v16i8(a: int8x16_t, b: int8x16_t) -> int8x16_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v16i8")] + fn _vshiftrins_v16i8(a: int8x16_t, b: int8x16_t, c: int8x16_t) -> int8x16_t; + } + unsafe { _vshiftrins_v16i8(a, b, const { int8x16_t([-N as i8; 16]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v1i64)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v1i64(a: int64x1_t, b: int64x1_t) -> int64x1_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v1i64")] + fn _vshiftrins_v1i64(a: int64x1_t, b: int64x1_t, c: int64x1_t) -> int64x1_t; + } + unsafe { _vshiftrins_v1i64(a, b, const { int64x1_t([-N as i64; 1]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v2i32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v2i32(a: int32x2_t, b: int32x2_t) -> int32x2_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v2i32")] + fn _vshiftrins_v2i32(a: int32x2_t, b: int32x2_t, c: int32x2_t) -> int32x2_t; + } + unsafe { _vshiftrins_v2i32(a, b, const { int32x2_t([-N; 2]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v2i64)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v2i64(a: int64x2_t, b: int64x2_t) -> int64x2_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v2i64")] + fn _vshiftrins_v2i64(a: int64x2_t, b: int64x2_t, c: int64x2_t) -> int64x2_t; + } + unsafe { _vshiftrins_v2i64(a, b, const { int64x2_t([-N as i64; 2]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v4i16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v4i16(a: int16x4_t, b: int16x4_t) -> int16x4_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v4i16")] + fn _vshiftrins_v4i16(a: int16x4_t, b: int16x4_t, c: int16x4_t) -> int16x4_t; + } + unsafe { _vshiftrins_v4i16(a, b, const { int16x4_t([-N as i16; 4]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v4i32)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v4i32(a: int32x4_t, b: int32x4_t) -> int32x4_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v4i32")] + fn _vshiftrins_v4i32(a: int32x4_t, b: int32x4_t, c: int32x4_t) -> int32x4_t; + } + unsafe { _vshiftrins_v4i32(a, b, const { int32x4_t([-N; 4]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v8i16)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v8i16(a: int16x8_t, b: int16x8_t) -> int16x8_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v8i16")] + fn _vshiftrins_v8i16(a: int16x8_t, b: int16x8_t, c: int16x8_t) -> int16x8_t; + } + unsafe { _vshiftrins_v8i16(a, b, const { int16x8_t([-N as i16; 8]) }) } +} +#[doc = "Shift Right and Insert (immediate)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshiftrins_v8i8)"] +#[inline] +#[target_feature(enable = "neon")] +#[cfg(target_arch = "arm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] +#[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] +#[rustc_legacy_const_generics(2)] +fn vshiftrins_v8i8(a: int8x8_t, b: int8x8_t) -> int8x8_t { + unsafe extern "unadjusted" { + #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vshiftins.v8i8")] + fn _vshiftrins_v8i8(a: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t; + } + unsafe { _vshiftrins_v8i8(a, b, const { int8x8_t([-N as i8; 8]) }) } } #[doc = "Shift left"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vshl_n_s8)"] @@ -62706,7 +62508,7 @@ pub fn vshrn_n_u64(a: uint64x2_t) -> uint32x2_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_s8(a: int8x8_t, b: int8x8_t) -> int8x8_t { static_assert_uimm_bits!(N, 3); - vshiftins_v8i8(a, b, int8x8_t::splat(N as i8)) + vshiftlins_v8i8::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_s8)"] @@ -62718,7 +62520,7 @@ pub fn vsli_n_s8(a: int8x8_t, b: int8x8_t) -> int8x8_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_s8(a: int8x16_t, b: int8x16_t) -> int8x16_t { static_assert_uimm_bits!(N, 3); - vshiftins_v16i8(a, b, int8x16_t::splat(N as i8)) + vshiftlins_v16i8::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_s16)"] @@ -62730,7 +62532,7 @@ pub fn vsliq_n_s8(a: int8x16_t, b: int8x16_t) -> int8x16_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_s16(a: int16x4_t, b: int16x4_t) -> int16x4_t { static_assert_uimm_bits!(N, 4); - vshiftins_v4i16(a, b, int16x4_t::splat(N as i16)) + vshiftlins_v4i16::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_s16)"] @@ -62742,7 +62544,7 @@ pub fn vsli_n_s16(a: int16x4_t, b: int16x4_t) -> int16x4_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_s16(a: int16x8_t, b: int16x8_t) -> int16x8_t { static_assert_uimm_bits!(N, 4); - vshiftins_v8i16(a, b, int16x8_t::splat(N as i16)) + vshiftlins_v8i16::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_s32)"] @@ -62754,7 +62556,7 @@ pub fn vsliq_n_s16(a: int16x8_t, b: int16x8_t) -> int16x8_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_s32(a: int32x2_t, b: int32x2_t) -> int32x2_t { static_assert!(N >= 0 && N <= 31); - vshiftins_v2i32(a, b, int32x2_t::splat(N)) + vshiftlins_v2i32::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_s32)"] @@ -62766,7 +62568,7 @@ pub fn vsli_n_s32(a: int32x2_t, b: int32x2_t) -> int32x2_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_s32(a: int32x4_t, b: int32x4_t) -> int32x4_t { static_assert!(N >= 0 && N <= 31); - vshiftins_v4i32(a, b, int32x4_t::splat(N)) + vshiftlins_v4i32::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_s64)"] @@ -62778,7 +62580,7 @@ pub fn vsliq_n_s32(a: int32x4_t, b: int32x4_t) -> int32x4_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_s64(a: int64x1_t, b: int64x1_t) -> int64x1_t { static_assert!(N >= 0 && N <= 63); - vshiftins_v1i64(a, b, int64x1_t::splat(N as i64)) + vshiftlins_v1i64::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_s64)"] @@ -62790,7 +62592,7 @@ pub fn vsli_n_s64(a: int64x1_t, b: int64x1_t) -> int64x1_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_s64(a: int64x2_t, b: int64x2_t) -> int64x2_t { static_assert!(N >= 0 && N <= 63); - vshiftins_v2i64(a, b, int64x2_t::splat(N as i64)) + vshiftlins_v2i64::(a, b) } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_u8)"] @@ -62802,13 +62604,7 @@ pub fn vsliq_n_s64(a: int64x2_t, b: int64x2_t) -> int64x2_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_u8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t { static_assert_uimm_bits!(N, 3); - unsafe { - transmute(vshiftins_v8i8( - transmute(a), - transmute(b), - int8x8_t::splat(N as i8), - )) - } + unsafe { transmute(vshiftlins_v8i8::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_u8)"] @@ -62820,13 +62616,7 @@ pub fn vsli_n_u8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_u8(a: uint8x16_t, b: uint8x16_t) -> uint8x16_t { static_assert_uimm_bits!(N, 3); - unsafe { - transmute(vshiftins_v16i8( - transmute(a), - transmute(b), - int8x16_t::splat(N as i8), - )) - } + unsafe { transmute(vshiftlins_v16i8::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_u16)"] @@ -62838,13 +62628,7 @@ pub fn vsliq_n_u8(a: uint8x16_t, b: uint8x16_t) -> uint8x16_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_u16(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t { static_assert_uimm_bits!(N, 4); - unsafe { - transmute(vshiftins_v4i16( - transmute(a), - transmute(b), - int16x4_t::splat(N as i16), - )) - } + unsafe { transmute(vshiftlins_v4i16::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_u16)"] @@ -62856,13 +62640,7 @@ pub fn vsli_n_u16(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_u16(a: uint16x8_t, b: uint16x8_t) -> uint16x8_t { static_assert_uimm_bits!(N, 4); - unsafe { - transmute(vshiftins_v8i16( - transmute(a), - transmute(b), - int16x8_t::splat(N as i16), - )) - } + unsafe { transmute(vshiftlins_v8i16::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_u32)"] @@ -62874,13 +62652,7 @@ pub fn vsliq_n_u16(a: uint16x8_t, b: uint16x8_t) -> uint16x8_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_u32(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t { static_assert!(N >= 0 && N <= 31); - unsafe { - transmute(vshiftins_v2i32( - transmute(a), - transmute(b), - int32x2_t::splat(N), - )) - } + unsafe { transmute(vshiftlins_v2i32::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_u32)"] @@ -62892,13 +62664,7 @@ pub fn vsli_n_u32(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { static_assert!(N >= 0 && N <= 31); - unsafe { - transmute(vshiftins_v4i32( - transmute(a), - transmute(b), - int32x4_t::splat(N), - )) - } + unsafe { transmute(vshiftlins_v4i32::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_u64)"] @@ -62910,13 +62676,7 @@ pub fn vsliq_n_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_u64(a: uint64x1_t, b: uint64x1_t) -> uint64x1_t { static_assert!(N >= 0 && N <= 63); - unsafe { - transmute(vshiftins_v1i64( - transmute(a), - transmute(b), - int64x1_t::splat(N as i64), - )) - } + unsafe { transmute(vshiftlins_v1i64::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_u64)"] @@ -62928,13 +62688,7 @@ pub fn vsli_n_u64(a: uint64x1_t, b: uint64x1_t) -> uint64x1_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_u64(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t { static_assert!(N >= 0 && N <= 63); - unsafe { - transmute(vshiftins_v2i64( - transmute(a), - transmute(b), - int64x2_t::splat(N as i64), - )) - } + unsafe { transmute(vshiftlins_v2i64::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_p8)"] @@ -62946,13 +62700,7 @@ pub fn vsliq_n_u64(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_p8(a: poly8x8_t, b: poly8x8_t) -> poly8x8_t { static_assert_uimm_bits!(N, 3); - unsafe { - transmute(vshiftins_v8i8( - transmute(a), - transmute(b), - int8x8_t::splat(N as i8), - )) - } + unsafe { transmute(vshiftlins_v8i8::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_p8)"] @@ -62964,13 +62712,7 @@ pub fn vsli_n_p8(a: poly8x8_t, b: poly8x8_t) -> poly8x8_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_p8(a: poly8x16_t, b: poly8x16_t) -> poly8x16_t { static_assert_uimm_bits!(N, 3); - unsafe { - transmute(vshiftins_v16i8( - transmute(a), - transmute(b), - int8x16_t::splat(N as i8), - )) - } + unsafe { transmute(vshiftlins_v16i8::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsli_n_p16)"] @@ -62982,13 +62724,7 @@ pub fn vsliq_n_p8(a: poly8x16_t, b: poly8x16_t) -> poly8x16_t { #[rustc_legacy_const_generics(2)] pub fn vsli_n_p16(a: poly16x4_t, b: poly16x4_t) -> poly16x4_t { static_assert_uimm_bits!(N, 4); - unsafe { - transmute(vshiftins_v4i16( - transmute(a), - transmute(b), - int16x4_t::splat(N as i16), - )) - } + unsafe { transmute(vshiftlins_v4i16::(transmute(a), transmute(b))) } } #[doc = "Shift Left and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsliq_n_p16)"] @@ -63000,13 +62736,7 @@ pub fn vsli_n_p16(a: poly16x4_t, b: poly16x4_t) -> poly16x4_t { #[rustc_legacy_const_generics(2)] pub fn vsliq_n_p16(a: poly16x8_t, b: poly16x8_t) -> poly16x8_t { static_assert_uimm_bits!(N, 4); - unsafe { - transmute(vshiftins_v8i16( - transmute(a), - transmute(b), - int16x8_t::splat(N as i16), - )) - } + unsafe { transmute(vshiftlins_v8i16::(transmute(a), transmute(b))) } } #[doc = "Signed shift right and accumulate"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsra_n_s8)"] @@ -63386,7 +63116,7 @@ pub fn vsraq_n_u64(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_s8(a: int8x8_t, b: int8x8_t) -> int8x8_t { static_assert!(1 <= N && N <= 8); - vshiftins_v8i8(a, b, int8x8_t::splat(-N as i8)) + vshiftrins_v8i8::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_s8)"] @@ -63398,7 +63128,7 @@ pub fn vsri_n_s8(a: int8x8_t, b: int8x8_t) -> int8x8_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_s8(a: int8x16_t, b: int8x16_t) -> int8x16_t { static_assert!(1 <= N && N <= 8); - vshiftins_v16i8(a, b, int8x16_t::splat(-N as i8)) + vshiftrins_v16i8::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_s16)"] @@ -63410,7 +63140,7 @@ pub fn vsriq_n_s8(a: int8x16_t, b: int8x16_t) -> int8x16_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_s16(a: int16x4_t, b: int16x4_t) -> int16x4_t { static_assert!(1 <= N && N <= 16); - vshiftins_v4i16(a, b, int16x4_t::splat(-N as i16)) + vshiftrins_v4i16::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_s16)"] @@ -63422,7 +63152,7 @@ pub fn vsri_n_s16(a: int16x4_t, b: int16x4_t) -> int16x4_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_s16(a: int16x8_t, b: int16x8_t) -> int16x8_t { static_assert!(1 <= N && N <= 16); - vshiftins_v8i16(a, b, int16x8_t::splat(-N as i16)) + vshiftrins_v8i16::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_s32)"] @@ -63434,7 +63164,7 @@ pub fn vsriq_n_s16(a: int16x8_t, b: int16x8_t) -> int16x8_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_s32(a: int32x2_t, b: int32x2_t) -> int32x2_t { static_assert!(1 <= N && N <= 32); - vshiftins_v2i32(a, b, int32x2_t::splat(-N)) + vshiftrins_v2i32::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_s32)"] @@ -63446,7 +63176,7 @@ pub fn vsri_n_s32(a: int32x2_t, b: int32x2_t) -> int32x2_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_s32(a: int32x4_t, b: int32x4_t) -> int32x4_t { static_assert!(1 <= N && N <= 32); - vshiftins_v4i32(a, b, int32x4_t::splat(-N)) + vshiftrins_v4i32::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_s64)"] @@ -63458,7 +63188,7 @@ pub fn vsriq_n_s32(a: int32x4_t, b: int32x4_t) -> int32x4_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_s64(a: int64x1_t, b: int64x1_t) -> int64x1_t { static_assert!(1 <= N && N <= 64); - vshiftins_v1i64(a, b, int64x1_t::splat(-N as i64)) + vshiftrins_v1i64::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_s64)"] @@ -63470,7 +63200,7 @@ pub fn vsri_n_s64(a: int64x1_t, b: int64x1_t) -> int64x1_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_s64(a: int64x2_t, b: int64x2_t) -> int64x2_t { static_assert!(1 <= N && N <= 64); - vshiftins_v2i64(a, b, int64x2_t::splat(-N as i64)) + vshiftrins_v2i64::(a, b) } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_u8)"] @@ -63482,13 +63212,7 @@ pub fn vsriq_n_s64(a: int64x2_t, b: int64x2_t) -> int64x2_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_u8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t { static_assert!(1 <= N && N <= 8); - unsafe { - transmute(vshiftins_v8i8( - transmute(a), - transmute(b), - int8x8_t::splat(-N as i8), - )) - } + unsafe { transmute(vshiftrins_v8i8::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_u8)"] @@ -63500,13 +63224,7 @@ pub fn vsri_n_u8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_u8(a: uint8x16_t, b: uint8x16_t) -> uint8x16_t { static_assert!(1 <= N && N <= 8); - unsafe { - transmute(vshiftins_v16i8( - transmute(a), - transmute(b), - int8x16_t::splat(-N as i8), - )) - } + unsafe { transmute(vshiftrins_v16i8::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_u16)"] @@ -63518,13 +63236,7 @@ pub fn vsriq_n_u8(a: uint8x16_t, b: uint8x16_t) -> uint8x16_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_u16(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t { static_assert!(1 <= N && N <= 16); - unsafe { - transmute(vshiftins_v4i16( - transmute(a), - transmute(b), - int16x4_t::splat(-N as i16), - )) - } + unsafe { transmute(vshiftrins_v4i16::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_u16)"] @@ -63536,13 +63248,7 @@ pub fn vsri_n_u16(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_u16(a: uint16x8_t, b: uint16x8_t) -> uint16x8_t { static_assert!(1 <= N && N <= 16); - unsafe { - transmute(vshiftins_v8i16( - transmute(a), - transmute(b), - int16x8_t::splat(-N as i16), - )) - } + unsafe { transmute(vshiftrins_v8i16::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_u32)"] @@ -63554,13 +63260,7 @@ pub fn vsriq_n_u16(a: uint16x8_t, b: uint16x8_t) -> uint16x8_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_u32(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t { static_assert!(1 <= N && N <= 32); - unsafe { - transmute(vshiftins_v2i32( - transmute(a), - transmute(b), - int32x2_t::splat(-N), - )) - } + unsafe { transmute(vshiftrins_v2i32::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_u32)"] @@ -63572,13 +63272,7 @@ pub fn vsri_n_u32(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { static_assert!(1 <= N && N <= 32); - unsafe { - transmute(vshiftins_v4i32( - transmute(a), - transmute(b), - int32x4_t::splat(-N), - )) - } + unsafe { transmute(vshiftrins_v4i32::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_u64)"] @@ -63590,13 +63284,7 @@ pub fn vsriq_n_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_u64(a: uint64x1_t, b: uint64x1_t) -> uint64x1_t { static_assert!(1 <= N && N <= 64); - unsafe { - transmute(vshiftins_v1i64( - transmute(a), - transmute(b), - int64x1_t::splat(-N as i64), - )) - } + unsafe { transmute(vshiftrins_v1i64::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_u64)"] @@ -63608,13 +63296,7 @@ pub fn vsri_n_u64(a: uint64x1_t, b: uint64x1_t) -> uint64x1_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_u64(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t { static_assert!(1 <= N && N <= 64); - unsafe { - transmute(vshiftins_v2i64( - transmute(a), - transmute(b), - int64x2_t::splat(-N as i64), - )) - } + unsafe { transmute(vshiftrins_v2i64::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_p8)"] @@ -63626,13 +63308,7 @@ pub fn vsriq_n_u64(a: uint64x2_t, b: uint64x2_t) -> uint64x2_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_p8(a: poly8x8_t, b: poly8x8_t) -> poly8x8_t { static_assert!(1 <= N && N <= 8); - unsafe { - transmute(vshiftins_v8i8( - transmute(a), - transmute(b), - int8x8_t::splat(-N as i8), - )) - } + unsafe { transmute(vshiftrins_v8i8::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_p8)"] @@ -63644,13 +63320,7 @@ pub fn vsri_n_p8(a: poly8x8_t, b: poly8x8_t) -> poly8x8_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_p8(a: poly8x16_t, b: poly8x16_t) -> poly8x16_t { static_assert!(1 <= N && N <= 8); - unsafe { - transmute(vshiftins_v16i8( - transmute(a), - transmute(b), - int8x16_t::splat(-N as i8), - )) - } + unsafe { transmute(vshiftrins_v16i8::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsri_n_p16)"] @@ -63662,13 +63332,7 @@ pub fn vsriq_n_p8(a: poly8x16_t, b: poly8x16_t) -> poly8x16_t { #[rustc_legacy_const_generics(2)] pub fn vsri_n_p16(a: poly16x4_t, b: poly16x4_t) -> poly16x4_t { static_assert!(1 <= N && N <= 16); - unsafe { - transmute(vshiftins_v4i16( - transmute(a), - transmute(b), - int16x4_t::splat(-N as i16), - )) - } + unsafe { transmute(vshiftrins_v4i16::(transmute(a), transmute(b))) } } #[doc = "Shift Right and Insert (immediate)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsriq_n_p16)"] @@ -63680,13 +63344,7 @@ pub fn vsri_n_p16(a: poly16x4_t, b: poly16x4_t) -> poly16x4_t { #[rustc_legacy_const_generics(2)] pub fn vsriq_n_p16(a: poly16x8_t, b: poly16x8_t) -> poly16x8_t { static_assert!(1 <= N && N <= 16); - unsafe { - transmute(vshiftins_v8i16( - transmute(a), - transmute(b), - int16x8_t::splat(-N as i16), - )) - } + unsafe { transmute(vshiftrins_v8i16::(transmute(a), transmute(b))) } } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_f16)"] @@ -63987,11 +63645,8 @@ pub unsafe fn vst1q_f16_x4(a: *mut f16, b: float16x8x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] pub unsafe fn vst1_f32(ptr: *mut f32, a: float32x2_t) { - vst1_v2f32( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v2f32::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_f32)"] @@ -64004,11 +63659,8 @@ pub unsafe fn vst1_f32(ptr: *mut f32, a: float32x2_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] pub unsafe fn vst1q_f32(ptr: *mut f32, a: float32x4_t) { - vst1q_v4f32( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v4f32::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_s8)"] @@ -64021,7 +63673,8 @@ pub unsafe fn vst1q_f32(ptr: *mut f32, a: float32x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] pub unsafe fn vst1_s8(ptr: *mut i8, a: int8x8_t) { - vst1_v8i8(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v8i8::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_s8)"] @@ -64034,7 +63687,8 @@ pub unsafe fn vst1_s8(ptr: *mut i8, a: int8x8_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] pub unsafe fn vst1q_s8(ptr: *mut i8, a: int8x16_t) { - vst1q_v16i8(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v16i8::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_s16)"] @@ -64047,7 +63701,8 @@ pub unsafe fn vst1q_s8(ptr: *mut i8, a: int8x16_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] pub unsafe fn vst1_s16(ptr: *mut i16, a: int16x4_t) { - vst1_v4i16(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v4i16::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_s16)"] @@ -64060,7 +63715,8 @@ pub unsafe fn vst1_s16(ptr: *mut i16, a: int16x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] pub unsafe fn vst1q_s16(ptr: *mut i16, a: int16x8_t) { - vst1q_v8i16(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v8i16::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_s32)"] @@ -64073,7 +63729,8 @@ pub unsafe fn vst1q_s16(ptr: *mut i16, a: int16x8_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] pub unsafe fn vst1_s32(ptr: *mut i32, a: int32x2_t) { - vst1_v2i32(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v2i32::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_s32)"] @@ -64086,7 +63743,8 @@ pub unsafe fn vst1_s32(ptr: *mut i32, a: int32x2_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] pub unsafe fn vst1q_s32(ptr: *mut i32, a: int32x4_t) { - vst1q_v4i32(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v4i32::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_s64)"] @@ -64099,7 +63757,8 @@ pub unsafe fn vst1q_s32(ptr: *mut i32, a: int32x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] pub unsafe fn vst1_s64(ptr: *mut i64, a: int64x1_t) { - vst1_v1i64(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v1i64::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_s64)"] @@ -64112,7 +63771,8 @@ pub unsafe fn vst1_s64(ptr: *mut i64, a: int64x1_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] pub unsafe fn vst1q_s64(ptr: *mut i64, a: int64x2_t) { - vst1q_v2i64(ptr as *const i8, a, crate::mem::align_of::() as i32) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v2i64::(ptr as *const i8, a) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_u8)"] @@ -64125,11 +63785,8 @@ pub unsafe fn vst1q_s64(ptr: *mut i64, a: int64x2_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] pub unsafe fn vst1_u8(ptr: *mut u8, a: uint8x8_t) { - vst1_v8i8( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v8i8::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_u8)"] @@ -64142,11 +63799,8 @@ pub unsafe fn vst1_u8(ptr: *mut u8, a: uint8x8_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] pub unsafe fn vst1q_u8(ptr: *mut u8, a: uint8x16_t) { - vst1q_v16i8( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v16i8::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_u16)"] @@ -64159,11 +63813,8 @@ pub unsafe fn vst1q_u8(ptr: *mut u8, a: uint8x16_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] pub unsafe fn vst1_u16(ptr: *mut u16, a: uint16x4_t) { - vst1_v4i16( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v4i16::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_u16)"] @@ -64176,11 +63827,8 @@ pub unsafe fn vst1_u16(ptr: *mut u16, a: uint16x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] pub unsafe fn vst1q_u16(ptr: *mut u16, a: uint16x8_t) { - vst1q_v8i16( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v8i16::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_u32)"] @@ -64193,11 +63841,8 @@ pub unsafe fn vst1q_u16(ptr: *mut u16, a: uint16x8_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] pub unsafe fn vst1_u32(ptr: *mut u32, a: uint32x2_t) { - vst1_v2i32( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v2i32::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_u32)"] @@ -64210,11 +63855,8 @@ pub unsafe fn vst1_u32(ptr: *mut u32, a: uint32x2_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] pub unsafe fn vst1q_u32(ptr: *mut u32, a: uint32x4_t) { - vst1q_v4i32( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v4i32::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_u64)"] @@ -64227,11 +63869,8 @@ pub unsafe fn vst1q_u32(ptr: *mut u32, a: uint32x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] pub unsafe fn vst1_u64(ptr: *mut u64, a: uint64x1_t) { - vst1_v1i64( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v1i64::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_u64)"] @@ -64244,11 +63883,8 @@ pub unsafe fn vst1_u64(ptr: *mut u64, a: uint64x1_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] pub unsafe fn vst1q_u64(ptr: *mut u64, a: uint64x2_t) { - vst1q_v2i64( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v2i64::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_p8)"] @@ -64261,11 +63897,8 @@ pub unsafe fn vst1q_u64(ptr: *mut u64, a: uint64x2_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] pub unsafe fn vst1_p8(ptr: *mut p8, a: poly8x8_t) { - vst1_v8i8( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v8i8::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_p8)"] @@ -64278,11 +63911,8 @@ pub unsafe fn vst1_p8(ptr: *mut p8, a: poly8x8_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] pub unsafe fn vst1q_p8(ptr: *mut p8, a: poly8x16_t) { - vst1q_v16i8( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v16i8::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_p16)"] @@ -64295,11 +63925,8 @@ pub unsafe fn vst1q_p8(ptr: *mut p8, a: poly8x16_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] pub unsafe fn vst1_p16(ptr: *mut p16, a: poly16x4_t) { - vst1_v4i16( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v4i16::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_p16)"] @@ -64312,11 +63939,8 @@ pub unsafe fn vst1_p16(ptr: *mut p16, a: poly16x4_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] pub unsafe fn vst1q_p16(ptr: *mut p16, a: poly16x8_t) { - vst1q_v8i16( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v8i16::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_p64)"] @@ -64329,11 +63953,8 @@ pub unsafe fn vst1q_p16(ptr: *mut p16, a: poly16x8_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] pub unsafe fn vst1_p64(ptr: *mut p64, a: poly64x1_t) { - vst1_v1i64( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1_v1i64::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_p64)"] @@ -64346,11 +63967,8 @@ pub unsafe fn vst1_p64(ptr: *mut p64, a: poly64x1_t) { #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] pub unsafe fn vst1q_p64(ptr: *mut p64, a: poly64x2_t) { - vst1q_v2i64( - ptr as *const i8, - transmute(a), - crate::mem::align_of::() as i32, - ) + const ALIGN: i32 = crate::mem::align_of::() as i32; + vst1q_v2i64::(ptr as *const i8, transmute(a)) } #[doc = "Store multiple single-element structures to one, two, three, or four registers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_f32_x2)"] @@ -66973,175 +66591,145 @@ pub unsafe fn vst1q_p16_x3(a: *mut p16, b: poly16x8x3_t) { pub unsafe fn vst1q_p16_x4(a: *mut p16, b: poly16x8x4_t) { vst1q_s16_x4(transmute(a), transmute(b)) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_v1i64)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] -unsafe fn vst1_v1i64(addr: *const i8, val: int64x1_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1_v1i64(addr: *const i8, val: int64x1_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v1i64.p0")] fn _vst1_v1i64(addr: *const i8, val: int64x1_t, align: i32); } - _vst1_v1i64(addr, val, align) + _vst1_v1i64(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_v2f32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] -unsafe fn vst1_v2f32(addr: *const i8, val: float32x2_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1_v2f32(addr: *const i8, val: float32x2_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v2f32.p0")] fn _vst1_v2f32(addr: *const i8, val: float32x2_t, align: i32); } - _vst1_v2f32(addr, val, align) + _vst1_v2f32(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_v2i32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] -unsafe fn vst1_v2i32(addr: *const i8, val: int32x2_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1_v2i32(addr: *const i8, val: int32x2_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v2i32.p0")] fn _vst1_v2i32(addr: *const i8, val: int32x2_t, align: i32); } - _vst1_v2i32(addr, val, align) + _vst1_v2i32(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_v4i16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] -unsafe fn vst1_v4i16(addr: *const i8, val: int16x4_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1_v4i16(addr: *const i8, val: int16x4_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v4i16.p0")] fn _vst1_v4i16(addr: *const i8, val: int16x4_t, align: i32); } - _vst1_v4i16(addr, val, align) + _vst1_v4i16(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_v8i8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] -unsafe fn vst1_v8i8(addr: *const i8, val: int8x8_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1_v8i8(addr: *const i8, val: int8x8_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v8i8.p0")] fn _vst1_v8i8(addr: *const i8, val: int8x8_t, align: i32); } - _vst1_v8i8(addr, val, align) + _vst1_v8i8(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_v16i8)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8"))] -unsafe fn vst1q_v16i8(addr: *const i8, val: int8x16_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.8", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1q_v16i8(addr: *const i8, val: int8x16_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v16i8.p0")] fn _vst1q_v16i8(addr: *const i8, val: int8x16_t, align: i32); } - _vst1q_v16i8(addr, val, align) + _vst1q_v16i8(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_v2i64)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64"))] -unsafe fn vst1q_v2i64(addr: *const i8, val: int64x2_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.64", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1q_v2i64(addr: *const i8, val: int64x2_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v2i64.p0")] fn _vst1q_v2i64(addr: *const i8, val: int64x2_t, align: i32); } - _vst1q_v2i64(addr, val, align) + _vst1q_v2i64(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_v4f32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] -unsafe fn vst1q_v4f32(addr: *const i8, val: float32x4_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1q_v4f32(addr: *const i8, val: float32x4_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v4f32.p0")] fn _vst1q_v4f32(addr: *const i8, val: float32x4_t, align: i32); } - _vst1q_v4f32(addr, val, align) + _vst1q_v4f32(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_v4i32)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32"))] -unsafe fn vst1q_v4i32(addr: *const i8, val: int32x4_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.32", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1q_v4i32(addr: *const i8, val: int32x4_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v4i32.p0")] fn _vst1q_v4i32(addr: *const i8, val: int32x4_t, align: i32); } - _vst1q_v4i32(addr, val, align) + _vst1q_v4i32(addr, val, ALIGN) } -#[doc = "Store multiple single-element structures from one, two, three, or four registers."] -#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1q_v8i16)"] -#[doc = "## Safety"] -#[doc = " * Neon instrinsic unsafe"] #[inline] #[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")] -#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16"))] -unsafe fn vst1q_v8i16(addr: *const i8, val: int16x8_t, align: i32) { +#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vst1.16", ALIGN = 0))] +#[rustc_legacy_const_generics(2)] +unsafe fn vst1q_v8i16(addr: *const i8, val: int16x8_t) { unsafe extern "unadjusted" { #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vst1.v8i16.p0")] fn _vst1q_v8i16(addr: *const i8, val: int16x8_t, align: i32); } - _vst1q_v8i16(addr, val, align) + _vst1q_v8i16(addr, val, ALIGN) } #[doc = "Store multiple single-element structures from one, two, three, or four registers."] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vst1_v4f16)"] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml index 43dd3b903150..4816d17bd654 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml @@ -11787,39 +11787,39 @@ intrinsics: - name: "vld1{type[0]}" visibility: private - doc: "Load multiple single-element structures to one, two, three, or four registers" - arguments: ["a: {type[1]}", "b: {type[2]}"] - return_type: "{neon_type[3]}" + arguments: ["a: {type[1]}"] + static_defs: ["const ALIGN: i32"] + return_type: "{neon_type[2]}" attr: + - FnCall: [rustc_legacy_const_generics, ['1']] - *target-is-arm - *enable-v7 - # - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld1]]}]] + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vld1.8"', "ALIGN = 0"]]}]] - *neon-arm-unstable safety: unsafe: [neon] types: - - ["_v8i8", "*const i8", "i32", "int8x8_t"] - - ["q_v16i8", "*const i8", "i32", "int8x16_t"] - - ["_v4i16", "*const i8", "i32", "int16x4_t"] - - ["q_v8i16", "*const i8", "i32", "int16x8_t"] - - ["_v2i32", "*const i8", "i32", "int32x2_t"] - - ["q_v4i32", "*const i8", "i32", "int32x4_t"] - - ["_v1i64", "*const i8", "i32", "int64x1_t"] - - ["q_v2i64", "*const i8", "i32", "int64x2_t"] - - ["_v2f32", "*const i8", "i32", "float32x2_t"] - - ["q_v4f32", "*const i8", "i32", "float32x4_t"] + - ["_v8i8", "*const i8", "int8x8_t" ] + - ["q_v16i8", "*const i8", "int8x16_t" ] + - ["_v4i16", "*const i8", "int16x4_t" ] + - ["q_v8i16", "*const i8", "int16x8_t" ] + - ["_v2i32", "*const i8", "int32x2_t" ] + - ["q_v4i32", "*const i8", "int32x4_t" ] + - ["_v1i64", "*const i8", "int64x1_t" ] + - ["q_v2i64", "*const i8", "int64x2_t" ] + - ["_v2f32", "*const i8", "float32x2_t"] + - ["q_v4f32", "*const i8", "float32x4_t"] compose: - LLVMLink: name: "vld1.{type[0]}" + arguments: ["a: {type[1]}", "b: i32"] links: - - link: "llvm.arm.neon.vld1.{neon_type[3]}" + - link: "llvm.arm.neon.vld1.{neon_type[2]}" arch: arm - - FnCall: ["_vld1{type[0]}", [a, b]] - + - FnCall: ["_vld1{type[0]}", [a, ALIGN]] - name: "vld1{type[0]}" visibility: private - doc: "Load multiple single-element structures to one, two, three, or four registers" arguments: ["a: {type[1]}", "b: {type[2]}"] return_type: "{neon_type[3]}" attr: @@ -11855,19 +11855,23 @@ intrinsics: - *neon-arm-unstable - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['{type[2]}']]}]] types: - - ['*const i8', int8x8_t, '"vld1.8"', 'crate::mem::align_of::() as i32', '_v8i8'] - - ['*const i8', int8x16_t, '"vld1.8"', 'crate::mem::align_of::() as i32', 'q_v16i8'] - - ['*const i16', int16x4_t, '"vld1.16"', 'crate::mem::align_of::() as i32', '_v4i16'] - - ['*const i16', int16x8_t, '"vld1.16"', 'crate::mem::align_of::() as i32', 'q_v8i16'] - - ['*const i32', int32x2_t, 'vldr', 'crate::mem::align_of::() as i32', '_v2i32'] - - ['*const i32', int32x4_t, '"vld1.32"', 'crate::mem::align_of::() as i32', 'q_v4i32'] - - ['*const i64', int64x1_t, 'vldr', 'crate::mem::align_of::() as i32', '_v1i64'] - - ['*const i64', int64x2_t, '"vld1.64"', 'crate::mem::align_of::() as i32', 'q_v2i64'] + - ['*const i8', int8x8_t, '"vld1.8"', 'crate::mem::align_of::()', '_v8i8' ] + - ['*const i8', int8x16_t, '"vld1.8"', 'crate::mem::align_of::()', 'q_v16i8'] + - ['*const i16', int16x4_t, '"vld1.16"', 'crate::mem::align_of::()', '_v4i16' ] + - ['*const i16', int16x8_t, '"vld1.16"', 'crate::mem::align_of::()', 'q_v8i16'] + - ['*const i32', int32x2_t, 'vldr', 'crate::mem::align_of::()', '_v2i32' ] + - ['*const i32', int32x4_t, '"vld1.32"', 'crate::mem::align_of::()', 'q_v4i32'] + - ['*const i64', int64x1_t, 'vldr', 'crate::mem::align_of::()', '_v1i64' ] + - ['*const i64', int64x2_t, '"vld1.64"', 'crate::mem::align_of::()', 'q_v2i64'] compose: + - Const: + - ALIGN + - "i32" + - "{type[3]} as i32" - FnCall: - "vld1{type[4]}" - - - 'ptr as *const i8' - - '{type[3]}' + - ['ptr as *const i8'] + - ['ALIGN'] - name: "vld1{neon_type[1].no}" doc: "Load multiple single-element structures to one, two, three, or four registers." @@ -11881,28 +11885,32 @@ intrinsics: - *neon-arm-unstable - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['{type[2]}']]}]] types: - - ['*const u8', uint8x8_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::() as i32', '_v8i8'] - - ['*const u8', uint8x16_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v16i8'] - - ['*const u16', uint16x4_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::() as i32', '_v4i16'] - - ['*const u16', uint16x8_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v8i16'] - - ['*const u32', uint32x2_t, 'vldr', 'neon,v7', 'crate::mem::align_of::() as i32', '_v2i32'] - - ['*const u32', uint32x4_t, '"vld1.32"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v4i32'] - - ['*const u64', uint64x1_t, 'vldr', 'neon,v7', 'crate::mem::align_of::() as i32', '_v1i64'] - - ['*const u64', uint64x2_t, '"vld1.64"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v2i64'] - - ['*const p8', poly8x8_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::() as i32', '_v8i8'] - - ['*const p8', poly8x16_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v16i8'] - - ['*const p16', poly16x4_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::() as i32', '_v4i16'] - - ['*const p16', poly16x8_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v8i16'] - - ['*const p64', poly64x2_t, '"vld1.64"', 'neon,aes', 'crate::mem::align_of::() as i32', 'q_v2i64'] - - ['*const f32', float32x2_t, 'vldr', 'neon,v7', 'crate::mem::align_of::() as i32', '_v2f32'] - - ['*const f32', float32x4_t, '"vld1.32"', 'neon,v7', 'crate::mem::align_of::() as i32', 'q_v4f32'] + - ['*const u8', uint8x8_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::()', '_v8i8' ] + - ['*const u8', uint8x16_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::()', 'q_v16i8'] + - ['*const u16', uint16x4_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::()', '_v4i16' ] + - ['*const u16', uint16x8_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::()', 'q_v8i16'] + - ['*const u32', uint32x2_t, 'vldr', 'neon,v7', 'crate::mem::align_of::()', '_v2i32' ] + - ['*const u32', uint32x4_t, '"vld1.32"', 'neon,v7', 'crate::mem::align_of::()', 'q_v4i32'] + - ['*const u64', uint64x1_t, 'vldr', 'neon,v7', 'crate::mem::align_of::()', '_v1i64' ] + - ['*const u64', uint64x2_t, '"vld1.64"', 'neon,v7', 'crate::mem::align_of::()', 'q_v2i64'] + - ['*const p8', poly8x8_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::()', '_v8i8' ] + - ['*const p8', poly8x16_t, '"vld1.8"', 'neon,v7', 'crate::mem::align_of::()', 'q_v16i8'] + - ['*const p16', poly16x4_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::()', '_v4i16' ] + - ['*const p16', poly16x8_t, '"vld1.16"', 'neon,v7', 'crate::mem::align_of::()', 'q_v8i16'] + - ['*const p64', poly64x2_t, '"vld1.64"', 'neon,aes', 'crate::mem::align_of::()', 'q_v2i64'] + - ['*const f32', float32x2_t, 'vldr', 'neon,v7', 'crate::mem::align_of::()', '_v2f32' ] + - ['*const f32', float32x4_t, '"vld1.32"', 'neon,v7', 'crate::mem::align_of::()', 'q_v4f32'] compose: + - Const: + - ALIGN + - "i32" + - "{type[4]} as i32" - FnCall: - transmute - - FnCall: - "vld1{type[5]}" - - - 'ptr as *const i8' - - '{type[4]}' + - ['ptr as *const i8'] + - ['ALIGN'] - name: "vld1{neon_type[1].no}" doc: "Load multiple single-element structures to one, two, three, or four registers." @@ -13724,32 +13732,35 @@ intrinsics: - name: "vst1{type[0]}" visibility: private - doc: "Store multiple single-element structures from one, two, three, or four registers." - arguments: ["addr: {type[1]}", "val: {neon_type[2]}", "align: {type[3]}"] + arguments: ["addr: {type[1]}", "val: {neon_type[2]}"] + static_defs: ["const ALIGN: i32"] safety: unsafe: [neon] attr: - *target-is-arm - *neon-v7 - *neon-arm-unstable - - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst1.{type[4]}"']]}]] + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst1.{type[3]}"', "ALIGN = 0"]]}]] + - FnCall: ["rustc_legacy_const_generics", ['2']] types: - - ['_v8i8', '* const i8', int8x8_t, i32, '8'] - - ['q_v16i8', '* const i8', int8x16_t, i32, '8'] - - ['_v4i16', '* const i8', int16x4_t, i32, '16'] - - ['q_v8i16', '* const i8', int16x8_t, i32, '16'] - - ['_v2i32', '* const i8', int32x2_t, i32, '32'] - - ['q_v4i32', '* const i8', int32x4_t, i32, '32'] - - ['_v1i64', '* const i8', int64x1_t, i32, '64'] - - ['q_v2i64', '* const i8', int64x2_t, i32, '64'] - - ['_v2f32', '* const i8', float32x2_t, i32, '32'] - - ['q_v4f32', '* const i8', float32x4_t, i32, '32'] + - ['_v8i8', '* const i8', int8x8_t, '8' ] + - ['q_v16i8', '* const i8', int8x16_t, '8' ] + - ['_v4i16', '* const i8', int16x4_t, '16'] + - ['q_v8i16', '* const i8', int16x8_t, '16'] + - ['_v2i32', '* const i8', int32x2_t, '32'] + - ['q_v4i32', '* const i8', int32x4_t, '32'] + - ['_v1i64', '* const i8', int64x1_t, '64'] + - ['q_v2i64', '* const i8', int64x2_t, '64'] + - ['_v2f32', '* const i8', float32x2_t, '32'] + - ['q_v4f32', '* const i8', float32x4_t, '32'] compose: - LLVMLink: name: "_vst1{type[0]}" + arguments: ["addr: {type[1]}", "val: {neon_type[2]}", "align: i32"] links: - link: "llvm.arm.neon.vst1.{neon_type[2]}.p0" arch: arm + - FnCall: ["_vst1{type[0]}",[addr, val, ALIGN]] - name: "vst1{type[0]}" visibility: private @@ -13785,37 +13796,39 @@ intrinsics: - *neon-arm-unstable - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vst1.{type[2]}"']]}]] types: - - ['*mut i8', int8x8_t, '8', 'a', 'crate::mem::align_of::() as i32', '_v8i8'] - - ['*mut i8', int8x16_t, '8', 'a', 'crate::mem::align_of::() as i32', 'q_v16i8'] - - ['*mut i16', int16x4_t, '16', 'a', 'crate::mem::align_of::() as i32', '_v4i16'] - - ['*mut i16', int16x8_t, '16', 'a', 'crate::mem::align_of::() as i32', 'q_v8i16'] - - ['*mut i32', int32x2_t, '32', 'a', 'crate::mem::align_of::() as i32', '_v2i32'] - - ['*mut i32', int32x4_t, '32', 'a', 'crate::mem::align_of::() as i32', 'q_v4i32'] - - ['*mut i64', int64x1_t, '64', 'a', 'crate::mem::align_of::() as i32', '_v1i64'] - - ['*mut i64', int64x2_t, '64', 'a', 'crate::mem::align_of::() as i32', 'q_v2i64'] - - ['*mut u8', uint8x8_t, '8', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v8i8'] - - ['*mut u8', uint8x16_t, '8', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v16i8'] - - ['*mut u16', uint16x4_t, '16', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v4i16'] - - ['*mut u16', uint16x8_t, '16', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v8i16'] - - ['*mut u32', uint32x2_t, '32', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v2i32'] - - ['*mut u32', uint32x4_t, '32', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v4i32'] - - ['*mut u64', uint64x1_t, '64', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v1i64'] - - ['*mut u64', uint64x2_t, '64', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v2i64'] - - ['*mut p8', poly8x8_t, '8', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v8i8'] - - ['*mut p8', poly8x16_t, '8', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v16i8'] - - ['*mut p16', poly16x4_t, '16', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v4i16'] - - ['*mut p16', poly16x8_t, '16', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v8i16'] - - ['*mut p64', poly64x1_t, '64', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v1i64'] - - ['*mut p64', poly64x2_t, '64', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v2i64'] - - ['*mut f32', float32x2_t, '32', 'transmute(a)', 'crate::mem::align_of::() as i32', '_v2f32'] - - ['*mut f32', float32x4_t, '32', 'transmute(a)', 'crate::mem::align_of::() as i32', 'q_v4f32'] + - ['*mut i8', int8x8_t, '8', 'a', 'crate::mem::align_of::()', '_v8i8' ] + - ['*mut i8', int8x16_t, '8', 'a', 'crate::mem::align_of::()', 'q_v16i8'] + - ['*mut i16', int16x4_t, '16', 'a', 'crate::mem::align_of::()', '_v4i16' ] + - ['*mut i16', int16x8_t, '16', 'a', 'crate::mem::align_of::()', 'q_v8i16'] + - ['*mut i32', int32x2_t, '32', 'a', 'crate::mem::align_of::()', '_v2i32' ] + - ['*mut i32', int32x4_t, '32', 'a', 'crate::mem::align_of::()', 'q_v4i32'] + - ['*mut i64', int64x1_t, '64', 'a', 'crate::mem::align_of::()', '_v1i64' ] + - ['*mut i64', int64x2_t, '64', 'a', 'crate::mem::align_of::()', 'q_v2i64'] + - ['*mut u8', uint8x8_t, '8', 'transmute(a)', 'crate::mem::align_of::()', '_v8i8' ] + - ['*mut u8', uint8x16_t, '8', 'transmute(a)', 'crate::mem::align_of::()', 'q_v16i8'] + - ['*mut u16', uint16x4_t, '16', 'transmute(a)', 'crate::mem::align_of::()', '_v4i16' ] + - ['*mut u16', uint16x8_t, '16', 'transmute(a)', 'crate::mem::align_of::()', 'q_v8i16'] + - ['*mut u32', uint32x2_t, '32', 'transmute(a)', 'crate::mem::align_of::()', '_v2i32' ] + - ['*mut u32', uint32x4_t, '32', 'transmute(a)', 'crate::mem::align_of::()', 'q_v4i32'] + - ['*mut u64', uint64x1_t, '64', 'transmute(a)', 'crate::mem::align_of::()', '_v1i64' ] + - ['*mut u64', uint64x2_t, '64', 'transmute(a)', 'crate::mem::align_of::()', 'q_v2i64'] + - ['*mut p8', poly8x8_t, '8', 'transmute(a)', 'crate::mem::align_of::()', '_v8i8' ] + - ['*mut p8', poly8x16_t, '8', 'transmute(a)', 'crate::mem::align_of::()', 'q_v16i8'] + - ['*mut p16', poly16x4_t, '16', 'transmute(a)', 'crate::mem::align_of::()', '_v4i16' ] + - ['*mut p16', poly16x8_t, '16', 'transmute(a)', 'crate::mem::align_of::()', 'q_v8i16'] + - ['*mut p64', poly64x1_t, '64', 'transmute(a)', 'crate::mem::align_of::()', '_v1i64' ] + - ['*mut p64', poly64x2_t, '64', 'transmute(a)', 'crate::mem::align_of::()', 'q_v2i64'] + - ['*mut f32', float32x2_t, '32', 'transmute(a)', 'crate::mem::align_of::()', '_v2f32' ] + - ['*mut f32', float32x4_t, '32', 'transmute(a)', 'crate::mem::align_of::()', 'q_v4f32'] compose: + - Const: + - ALIGN + - "i32" + - "{type[4]} as i32" - FnCall: - "vst1{type[5]}" - - - 'ptr as *const i8' - - '{type[3]}' - - '{type[4]}' - + - ['ptr as *const i8','{type[3]}'] + - ['ALIGN'] - name: "vst1{neon_type[1].no}" doc: "Store multiple single-element structures from one, two, three, or four registers." @@ -13839,32 +13852,64 @@ intrinsics: - '{type[3]}' - '{type[4]}' - - - name: "vshiftins{type[0]}" + - name: "vshiftlins{type[0]}" visibility: private - doc: "Shift Right and Insert (immediate)" - arguments: ["a: {neon_type[1]}", "b: {neon_type[1]}", "c: {neon_type[1]}"] + arguments: ["a: {neon_type[1]}", "b: {neon_type[1]}"] return_type: "{neon_type[1]}" safety: safe attr: - *target-is-arm - *neon-v7 - *neon-arm-unstable + - FnCall: [rustc_legacy_const_generics, ['2']] + static_defs: ['const N: i32'] types: - - ['_v8i8', "int8x8_t", '8'] - - ['_v16i8', 'int8x16_t', '8'] - - ['_v4i16', 'int16x4_t', '16'] - - ['_v8i16', 'int16x8_t', '16'] - - ['_v2i32', 'int32x2_t', '32'] - - ['_v4i32', 'int32x4_t', '32'] - - ['_v1i64', 'int64x1_t', '64'] - - ['_v2i64', 'int64x2_t', '64'] + - ['_v8i8', 'int8x8_t', '8', 'int8x8_t([N as i8; 8 ])' ] + - ['_v16i8', 'int8x16_t', '8', 'int8x16_t([N as i8; 16])'] + - ['_v4i16', 'int16x4_t', '16', 'int16x4_t([N as i16; 4])'] + - ['_v8i16', 'int16x8_t', '16', 'int16x8_t([N as i16; 8])'] + - ['_v2i32', 'int32x2_t', '32', 'int32x2_t([N; 2])' ] + - ['_v4i32', 'int32x4_t', '32', 'int32x4_t([N; 4])' ] + - ['_v1i64', 'int64x1_t', '64', 'int64x1_t([N as i64; 1])'] + - ['_v2i64', 'int64x2_t', '64', 'int64x2_t([N as i64; 2])'] compose: - LLVMLink: name: "_vshiftins{type[0]}" + arguments: ["a: {type[1]}", "b: {type[1]}", "c: {type[1]}"] links: - link: "llvm.arm.neon.vshiftins.{neon_type[1]}" arch: arm + - FnCall: ["_vshiftlins{type[0]}", [a,b, "const {{ {type[3]} }}"], [], true] + + - name: "vshiftrins{type[0]}" + doc: "Shift Right and Insert (immediate)" + visibility: private + arguments: ["a: {neon_type[1]}", "b: {neon_type[1]}"] + return_type: "{neon_type[1]}" + safety: safe + attr: + - *target-is-arm + - *neon-v7 + - *neon-arm-unstable + - FnCall: [rustc_legacy_const_generics, ['2']] + static_defs: ['const N: i32'] + types: + - ['_v8i8', 'int8x8_t', '8', 'int8x8_t([-N as i8; 8 ])' ] + - ['_v16i8', 'int8x16_t', '8', 'int8x16_t([-N as i8; 16])'] + - ['_v4i16', 'int16x4_t', '16', 'int16x4_t([-N as i16; 4])'] + - ['_v8i16', 'int16x8_t', '16', 'int16x8_t([-N as i16; 8])'] + - ['_v2i32', 'int32x2_t', '32', 'int32x2_t([-N; 2])' ] + - ['_v4i32', 'int32x4_t', '32', 'int32x4_t([-N; 4])' ] + - ['_v1i64', 'int64x1_t', '64', 'int64x1_t([-N as i64; 1])'] + - ['_v2i64', 'int64x2_t', '64', 'int64x2_t([-N as i64; 2])'] + compose: + - LLVMLink: + name: "_vshiftins{type[0]}" + arguments: ["a: {type[1]}", "b: {type[1]}", "c: {type[1]}"] + links: + - link: "llvm.arm.neon.vshiftins.{neon_type[1]}" + arch: arm + - FnCall: ["_vshiftrins{type[0]}", [a,b, "const {{ {type[3]} }}"], [], true] - name: "vsri{neon_type[0].N}" doc: "Shift Right and Insert (immediate)" @@ -13879,18 +13924,18 @@ intrinsics: - FnCall: [rustc_legacy_const_generics, ['2']] static_defs: ['const N: i32'] types: - - [uint8x8_t, "neon,v7", '8', '1 <= N && N <= 8', 'v8i8', 'int8x8_t::splat', '-N as i8'] - - [uint8x16_t, "neon,v7", '8', '1 <= N && N <= 8', 'v16i8', 'int8x16_t::splat', '-N as i8'] - - [uint16x4_t, "neon,v7", '16', '1 <= N && N <= 16', 'v4i16', 'int16x4_t::splat', '-N as i16'] - - [uint16x8_t, "neon,v7", '16', '1 <= N && N <= 16', 'v8i16', 'int16x8_t::splat', '-N as i16'] - - [uint32x2_t, "neon,v7", '32', '1 <= N && N <= 32', 'v2i32', 'int32x2_t::splat', '-N'] - - [uint32x4_t, "neon,v7", '32', '1 <= N && N <= 32', 'v4i32', 'int32x4_t::splat', '-N'] - - [uint64x1_t, "neon,v7", '64', '1 <= N && N <= 64', 'v1i64', 'int64x1_t::splat', '-N as i64'] - - [uint64x2_t, "neon,v7", '64', '1 <= N && N <= 64', 'v2i64', 'int64x2_t::splat', '-N as i64'] - - [poly8x8_t, "neon,v7", '8', '1 <= N && N <= 8', 'v8i8', 'int8x8_t::splat', '-N as i8'] - - [poly8x16_t, "neon,v7", '8', '1 <= N && N <= 8', 'v16i8', 'int8x16_t::splat', '-N as i8'] - - [poly16x4_t, "neon,v7", '16', '1 <= N && N <= 16', 'v4i16', 'int16x4_t::splat', '-N as i16'] - - [poly16x8_t, "neon,v7", '16', '1 <= N && N <= 16', 'v8i16', 'int16x8_t::splat', '-N as i16'] + - [uint8x8_t, "neon,v7", '8', '1 <= N && N <= 8', 'v8i8' ] + - [uint8x16_t, "neon,v7", '8', '1 <= N && N <= 8', 'v16i8'] + - [uint16x4_t, "neon,v7", '16', '1 <= N && N <= 16', 'v4i16'] + - [uint16x8_t, "neon,v7", '16', '1 <= N && N <= 16', 'v8i16'] + - [uint32x2_t, "neon,v7", '32', '1 <= N && N <= 32', 'v2i32'] + - [uint32x4_t, "neon,v7", '32', '1 <= N && N <= 32', 'v4i32'] + - [uint64x1_t, "neon,v7", '64', '1 <= N && N <= 64', 'v1i64'] + - [uint64x2_t, "neon,v7", '64', '1 <= N && N <= 64', 'v2i64'] + - [poly8x8_t, "neon,v7", '8', '1 <= N && N <= 8', 'v8i8' ] + - [poly8x16_t, "neon,v7", '8', '1 <= N && N <= 8', 'v16i8'] + - [poly16x4_t, "neon,v7", '16', '1 <= N && N <= 16', 'v4i16'] + - [poly16x8_t, "neon,v7", '16', '1 <= N && N <= 16', 'v8i16'] ## These live in ./crates/core_arch/src/arm/neon.rs #- [poly64x1_t, "neon,v7,aes", '64', '1 <= N && N <= 64', 'v1i64', 'int64x1_t::splat', '-N as i64'] #- [poly64x2_t, "neon,v7,aes", '64', '1 <= N && N <= 64', 'v2i64', 'int64x2_t::splat', '-N as i64'] @@ -13899,10 +13944,9 @@ intrinsics: - FnCall: - 'transmute' - - FnCall: - - "vshiftins_{type[4]}" + - "vshiftrins_{type[4]}::" - - FnCall: [transmute, [a]] - FnCall: [transmute, [b]] - - FnCall: ["{type[5]}", ["{type[6]}"]] - name: "vsri{neon_type[0].N}" doc: "Shift Right and Insert (immediate)" @@ -13917,21 +13961,20 @@ intrinsics: - FnCall: [rustc_legacy_const_generics, ['2']] safety: safe types: - - [int8x8_t, '8', '1 <= N && N <= 8', 'v8i8', 'int8x8_t::splat', '-N as i8'] - - [int8x16_t, '8', '1 <= N && N <= 8', 'v16i8', 'int8x16_t::splat', '-N as i8'] - - [int16x4_t, '16', '1 <= N && N <= 16', 'v4i16', 'int16x4_t::splat', '-N as i16'] - - [int16x8_t, '16', '1 <= N && N <= 16', 'v8i16', 'int16x8_t::splat', '-N as i16'] - - [int32x2_t, '32', '1 <= N && N <= 32', 'v2i32', 'int32x2_t::splat', '-N'] - - [int32x4_t, '32', '1 <= N && N <= 32', 'v4i32', 'int32x4_t::splat', '-N'] - - [int64x1_t, '64', '1 <= N && N <= 64', 'v1i64', 'int64x1_t::splat', '-N as i64'] - - [int64x2_t, '64', '1 <= N && N <= 64', 'v2i64', 'int64x2_t::splat', '-N as i64'] + - [int8x8_t, '8', '1 <= N && N <= 8', 'v8i8' ] + - [int8x16_t, '8', '1 <= N && N <= 8', 'v16i8'] + - [int16x4_t, '16', '1 <= N && N <= 16', 'v4i16'] + - [int16x8_t, '16', '1 <= N && N <= 16', 'v8i16'] + - [int32x2_t, '32', '1 <= N && N <= 32', 'v2i32'] + - [int32x4_t, '32', '1 <= N && N <= 32', 'v4i32'] + - [int64x1_t, '64', '1 <= N && N <= 64', 'v1i64'] + - [int64x2_t, '64', '1 <= N && N <= 64', 'v2i64'] compose: - FnCall: ["static_assert!", ['{type[2]}']] - FnCall: - - "vshiftins_{type[3]}" + - "vshiftrins_{type[3]}::" - - a - b - - FnCall: ["{type[4]}", ["{type[5]}"]] - name: "vsli{neon_type[0].N}" doc: "Shift Left and Insert (immediate)" @@ -13946,18 +13989,18 @@ intrinsics: - FnCall: [rustc_legacy_const_generics, ['2']] static_defs: ['const N: i32'] types: - - [uint8x8_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v8i8', 'int8x8_t::splat', 'N as i8'] - - [uint8x16_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v16i8', 'int8x16_t::splat', 'N as i8'] - - [uint16x4_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v4i16', 'int16x4_t::splat', 'N as i16'] - - [uint16x8_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v8i16', 'int16x8_t::splat', 'N as i16'] - - [uint32x2_t, "neon,v7", '32', 'static_assert!', 'N >= 0 && N <= 31', 'v2i32', 'int32x2_t::splat', 'N'] - - [uint32x4_t, "neon,v7", '32', 'static_assert!', 'N >= 0 && N <= 31', 'v4i32', 'int32x4_t::splat', 'N'] - - [uint64x1_t, "neon,v7", '64', 'static_assert!', 'N >= 0 && N <= 63', 'v1i64', 'int64x1_t::splat', 'N as i64'] - - [uint64x2_t, "neon,v7", '64', 'static_assert!', 'N >= 0 && N <= 63', 'v2i64', 'int64x2_t::splat', 'N as i64'] - - [poly8x8_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v8i8', 'int8x8_t::splat', 'N as i8'] - - [poly8x16_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v16i8', 'int8x16_t::splat', 'N as i8'] - - [poly16x4_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v4i16', 'int16x4_t::splat', 'N as i16'] - - [poly16x8_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v8i16', 'int16x8_t::splat', 'N as i16'] + - [uint8x8_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v8i8'] + - [uint8x16_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v16i8'] + - [uint16x4_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v4i16'] + - [uint16x8_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v8i16'] + - [uint32x2_t, "neon,v7", '32', 'static_assert!', 'N >= 0 && N <= 31', 'v2i32'] + - [uint32x4_t, "neon,v7", '32', 'static_assert!', 'N >= 0 && N <= 31', 'v4i32'] + - [uint64x1_t, "neon,v7", '64', 'static_assert!', 'N >= 0 && N <= 63', 'v1i64'] + - [uint64x2_t, "neon,v7", '64', 'static_assert!', 'N >= 0 && N <= 63', 'v2i64'] + - [poly8x8_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v8i8'] + - [poly8x16_t, "neon,v7", '8', 'static_assert_uimm_bits!', 'N, 3', 'v16i8'] + - [poly16x4_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v4i16'] + - [poly16x8_t, "neon,v7", '16', 'static_assert_uimm_bits!', 'N, 4', 'v8i16'] ## These live in ./crates/core_arch/src/arm/neon.rs #- [poly64x1_t, "neon,v7,aes", '"vsli.64"', 'static_assert!', '0 <= N && N <= 63', 'v1i64', 'int64x1_t::splat', 'N as i64'] #- [poly64x2_t, "neon,v7,aes", '"vsli.64"', 'static_assert!', '0 <= N && N <= 63', 'v2i64', 'int64x2_t::splat', 'N as i64'] @@ -13966,10 +14009,9 @@ intrinsics: - FnCall: - 'transmute' - - FnCall: - - "vshiftins_{type[5]}" + - "vshiftlins_{type[5]}::" - - FnCall: [transmute, [a]] - FnCall: [transmute, [b]] - - FnCall: ["{type[6]}", ["{type[7]}"]] - name: "vsli{neon_type[0].N}" doc: "Shift Left and Insert (immediate)" @@ -13984,21 +14026,20 @@ intrinsics: - FnCall: [rustc_legacy_const_generics, ['2']] static_defs: ['const N: i32'] types: - - [int8x8_t, '8', 'static_assert_uimm_bits!', 'N, 3', 'v8i8', 'int8x8_t::splat', 'N as i8'] - - [int8x16_t, '8', 'static_assert_uimm_bits!', 'N, 3', 'v16i8', 'int8x16_t::splat', 'N as i8'] - - [int16x4_t, '16', 'static_assert_uimm_bits!', 'N, 4', 'v4i16', 'int16x4_t::splat', 'N as i16'] - - [int16x8_t, '16', 'static_assert_uimm_bits!', 'N, 4', 'v8i16', 'int16x8_t::splat', 'N as i16'] - - [int32x2_t, '32', 'static_assert!', 'N >= 0 && N <= 31', 'v2i32', 'int32x2_t::splat', 'N'] - - [int32x4_t, '32', 'static_assert!', 'N >= 0 && N <= 31', 'v4i32', 'int32x4_t::splat', 'N'] - - [int64x1_t, '64', 'static_assert!', 'N >= 0 && N <= 63', 'v1i64', 'int64x1_t::splat', 'N as i64'] - - [int64x2_t, '64', 'static_assert!', 'N >= 0 && N <= 63', 'v2i64', 'int64x2_t::splat', 'N as i64'] + - [int8x8_t, '8', 'static_assert_uimm_bits!', 'N, 3', 'v8i8' ] + - [int8x16_t, '8', 'static_assert_uimm_bits!', 'N, 3', 'v16i8'] + - [int16x4_t, '16', 'static_assert_uimm_bits!', 'N, 4', 'v4i16'] + - [int16x8_t, '16', 'static_assert_uimm_bits!', 'N, 4', 'v8i16'] + - [int32x2_t, '32', 'static_assert!', 'N >= 0 && N <= 31', 'v2i32'] + - [int32x4_t, '32', 'static_assert!', 'N >= 0 && N <= 31', 'v4i32'] + - [int64x1_t, '64', 'static_assert!', 'N >= 0 && N <= 63', 'v1i64'] + - [int64x2_t, '64', 'static_assert!', 'N >= 0 && N <= 63', 'v2i64'] compose: - FnCall: ["{type[2]}", ['{type[3]}']] - FnCall: - - "vshiftins_{type[4]}" + - "vshiftlins_{type[4]}::" - - a - b - - FnCall: ["{type[5]}", ["{type[6]}"]] - name: "vcombine{neon_type[0].no}" doc: Join two smaller vectors into a single larger vector diff --git a/library/stdarch/crates/stdarch-gen-arm/src/expression.rs b/library/stdarch/crates/stdarch-gen-arm/src/expression.rs index d5644ef27d4b..bf48f0dab749 100644 --- a/library/stdarch/crates/stdarch-gen-arm/src/expression.rs +++ b/library/stdarch/crates/stdarch-gen-arm/src/expression.rs @@ -108,6 +108,8 @@ impl ToTokens for FnCall { pub enum Expression { /// (Re)Defines a variable Let(LetVariant), + /// Defines a const + Const(WildString, TypeKind, Box), /// Performs a variable assignment operation Assign(String, Box), /// Performs a macro call @@ -169,6 +171,7 @@ impl Expression { | LetVariant::WithType(_, _, ex) | LetVariant::MutWithType(_, _, ex), ) => ex.pre_build(ctx), + Self::Const(_, _, ex) => ex.pre_build(ctx), Self::CastAs(ex, _) => ex.pre_build(ctx), Self::Multiply(lhs, rhs) | Self::Xor(lhs, rhs) => { lhs.pre_build(ctx)?; @@ -245,6 +248,15 @@ impl Expression { ); ex.build(intrinsic, ctx) } + Self::Const(var_name, ty, ex) => { + var_name.build_acle(ctx.local)?; + ctx.local.variables.insert( + var_name.to_string(), + (ty.to_owned(), VariableType::Internal), + ); + ex.build(intrinsic, ctx) + } + Self::CastAs(ex, _) => ex.build(intrinsic, ctx), Self::Multiply(lhs, rhs) | Self::Xor(lhs, rhs) => { lhs.build(intrinsic, ctx)?; @@ -303,6 +315,7 @@ impl Expression { | LetVariant::WithType(_, _, exp) | LetVariant::MutWithType(_, _, exp), ) => exp.requires_unsafe_wrapper(ctx_fn), + Self::Const(_, _, exp) => exp.requires_unsafe_wrapper(ctx_fn), Self::Array(exps) => exps.iter().any(|exp| exp.requires_unsafe_wrapper(ctx_fn)), Self::Multiply(lhs, rhs) | Self::Xor(lhs, rhs) => { lhs.requires_unsafe_wrapper(ctx_fn) || rhs.requires_unsafe_wrapper(ctx_fn) @@ -462,6 +475,10 @@ impl ToTokens for Expression { let var_ident = format_ident!("{}", var_name.to_string()); tokens.append_all(quote! { let mut #var_ident: #ty = #exp }) } + Self::Const(var_name, ty, exp) => { + let var_ident = format_ident!("{}", var_name.to_string()); + tokens.append_all(quote! { const #var_ident: #ty = #exp }) + } Self::Assign(var_name, exp) => { /* If we are dereferencing a variable to assign a value \ * the 'format_ident!' macro does not like the asterix */ diff --git a/library/stdarch/crates/stdarch-gen-arm/src/intrinsic.rs b/library/stdarch/crates/stdarch-gen-arm/src/intrinsic.rs index efaa9e141889..0cdff6ff6c39 100644 --- a/library/stdarch/crates/stdarch-gen-arm/src/intrinsic.rs +++ b/library/stdarch/crates/stdarch-gen-arm/src/intrinsic.rs @@ -1730,7 +1730,8 @@ fn create_tokens(intrinsic: &Intrinsic, endianness: Endianness, tokens: &mut Tok "{fn_name} needs to be private, or to have documentation." ); assert!( - !safety.has_doc_comments(), + !safety.has_doc_comments() + || matches!(intrinsic.visibility, FunctionVisibility::Private), "{fn_name} needs a documentation section for its safety comments." ); } From b3f67c73d0830ac071228de41820529c2c113dbf Mon Sep 17 00:00:00 2001 From: valadaptive Date: Mon, 24 Nov 2025 14:08:15 -0500 Subject: [PATCH 019/489] Correct the docs for WASM relaxed_simd's min/max --- .../core_arch/src/wasm32/relaxed_simd.rs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/wasm32/relaxed_simd.rs b/library/stdarch/crates/core_arch/src/wasm32/relaxed_simd.rs index a9b7e9c04d11..8a9d46984dbb 100644 --- a/library/stdarch/crates/core_arch/src/wasm32/relaxed_simd.rs +++ b/library/stdarch/crates/core_arch/src/wasm32/relaxed_simd.rs @@ -248,8 +248,10 @@ pub fn i64x2_relaxed_laneselect(a: v128, b: v128, m: v128) -> v128 { #[stable(feature = "stdarch_wasm_relaxed_simd", since = "1.82.0")] pub use i64x2_relaxed_laneselect as u64x2_relaxed_laneselect; -/// A relaxed version of `f32x4_min` which is either `f32x4_min` or -/// `f32x4_pmin`. +/// A relaxed version of `f32x4_min` which has implementation-specific behavior +/// when its operands are NaN or signed zeroes. For more information, see [the +/// WebAssembly +/// specification](https://webassembly.github.io/spec/core/exec/numerics.html#op-frelaxed-min). #[inline] #[cfg_attr(test, assert_instr(f32x4.relaxed_min))] #[target_feature(enable = "relaxed-simd")] @@ -259,8 +261,10 @@ pub fn f32x4_relaxed_min(a: v128, b: v128) -> v128 { unsafe { llvm_f32x4_relaxed_min(a.as_f32x4(), b.as_f32x4()).v128() } } -/// A relaxed version of `f32x4_max` which is either `f32x4_max` or -/// `f32x4_pmax`. +/// A relaxed version of `f32x4_max` which has implementation-specific behavior +/// when its operands are NaN or signed zeroes. For more information, see [the +/// WebAssembly +/// specification](https://webassembly.github.io/spec/core/exec/numerics.html#op-frelaxed-max). #[inline] #[cfg_attr(test, assert_instr(f32x4.relaxed_max))] #[target_feature(enable = "relaxed-simd")] @@ -270,8 +274,10 @@ pub fn f32x4_relaxed_max(a: v128, b: v128) -> v128 { unsafe { llvm_f32x4_relaxed_max(a.as_f32x4(), b.as_f32x4()).v128() } } -/// A relaxed version of `f64x2_min` which is either `f64x2_min` or -/// `f64x2_pmin`. +/// A relaxed version of `f64x2_min` which has implementation-specific behavior +/// when its operands are NaN or signed zeroes. For more information, see [the +/// WebAssembly +/// specification](https://webassembly.github.io/spec/core/exec/numerics.html#op-frelaxed-min). #[inline] #[cfg_attr(test, assert_instr(f64x2.relaxed_min))] #[target_feature(enable = "relaxed-simd")] @@ -281,8 +287,10 @@ pub fn f64x2_relaxed_min(a: v128, b: v128) -> v128 { unsafe { llvm_f64x2_relaxed_min(a.as_f64x2(), b.as_f64x2()).v128() } } -/// A relaxed version of `f64x2_max` which is either `f64x2_max` or -/// `f64x2_pmax`. +/// A relaxed version of `f64x2_max` which has implementation-specific behavior +/// when its operands are NaN or signed zeroes. For more information, see [the +/// WebAssembly +/// specification](https://webassembly.github.io/spec/core/exec/numerics.html#op-frelaxed-max). #[inline] #[cfg_attr(test, assert_instr(f64x2.relaxed_max))] #[target_feature(enable = "relaxed-simd")] From cbc3860a72bd0675691a7f0ea7678296447b2740 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 21 Nov 2025 10:15:19 +0000 Subject: [PATCH 020/489] Use rust rather than LLVM target features in the target spec This works better with non-LLVM codegen backends. --- src/gcc_util.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gcc_util.rs b/src/gcc_util.rs index e4e2dfdd5643..330b5ff6828d 100644 --- a/src/gcc_util.rs +++ b/src/gcc_util.rs @@ -33,11 +33,7 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec { // should be taken in cases like these. let mut features = vec![]; - // Features implied by an implicit or explicit `--target`. - features.extend(sess.target.features.split(',').filter(|v| !v.is_empty()).map(String::from)); - - // -Ctarget-features - target_features::flag_to_backend_features(sess, |feature, enable| { + let mut extend_backend_features = |feature: &str, enable: bool| { // We run through `to_gcc_features` when // passing requests down to GCC. This means that all in-language // features also work on the command line instead of having two @@ -48,7 +44,13 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec { .flat_map(|feat| to_gcc_features(sess, feat).into_iter()) .map(|feature| if !enable { format!("-{}", feature) } else { feature.to_string() }), ); - }); + }; + + // Features implied by an implicit or explicit `--target`. + target_features::target_spec_to_backend_features(sess, &mut extend_backend_features); + + // -Ctarget-features + target_features::flag_to_backend_features(sess, extend_backend_features); gcc_features_by_flags(sess, &mut features); @@ -66,6 +68,7 @@ pub fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> (&Arch::X86 | &Arch::X86_64, "rdrand") => smallvec!["rdrnd"], (&Arch::X86 | &Arch::X86_64, "bmi1") => smallvec!["bmi"], (&Arch::X86 | &Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"], + (&Arch::X86 | &Arch::X86_64, "lahfsahf") => smallvec!["sahf"], (&Arch::X86 | &Arch::X86_64, "avx512vaes") => smallvec!["vaes"], (&Arch::X86 | &Arch::X86_64, "avx512gfni") => smallvec!["gfni"], (&Arch::X86 | &Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], From e4777322534026b246592d8b80d915085df07cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Tue, 9 Sep 2025 18:45:23 +0200 Subject: [PATCH 021/489] =?UTF-8?q?Don't=20strip=20shebang=20in=20expr-ctx?= =?UTF-8?q?t=20`include!(=E2=80=A6)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rustc_builtin_macros/src/source_util.rs | 4 +-- .../include-macros/auxiliary/shebang-expr.rs | 3 ++ .../include-macros/auxiliary/shebang-items.rs | 3 ++ .../ui/include-macros/shebang-in-expr-ctxt.rs | 16 +++++++++ .../shebang-in-expr-ctxt.stderr | 33 +++++++++++++++++++ .../ui/include-macros/shebang-in-item-ctxt.rs | 4 +++ 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 tests/ui/include-macros/auxiliary/shebang-expr.rs create mode 100644 tests/ui/include-macros/auxiliary/shebang-items.rs create mode 100644 tests/ui/include-macros/shebang-in-expr-ctxt.rs create mode 100644 tests/ui/include-macros/shebang-in-expr-ctxt.stderr create mode 100644 tests/ui/include-macros/shebang-in-item-ctxt.rs diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 16adaab15c52..b063413bce36 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -147,9 +147,7 @@ pub(crate) fn expand_include<'cx>( let mut p = unwrap_or_emit_fatal(new_parser_from_file( self.psess, &self.path, - // Don't strip frontmatter for backward compatibility, `---` may be the start of a - // manifold negation. FIXME: Ideally, we wouldn't strip shebangs here either. - StripTokens::Shebang, + StripTokens::Nothing, Some(self.span), )); let expr = parse_expr(&mut p).ok()?; diff --git a/tests/ui/include-macros/auxiliary/shebang-expr.rs b/tests/ui/include-macros/auxiliary/shebang-expr.rs new file mode 100644 index 000000000000..73e92b5a889e --- /dev/null +++ b/tests/ui/include-macros/auxiliary/shebang-expr.rs @@ -0,0 +1,3 @@ +#!/usr/bin/env my-rust-expr-evaluator + +2 * (1 + 3) diff --git a/tests/ui/include-macros/auxiliary/shebang-items.rs b/tests/ui/include-macros/auxiliary/shebang-items.rs new file mode 100644 index 000000000000..b9011b62cc91 --- /dev/null +++ b/tests/ui/include-macros/auxiliary/shebang-items.rs @@ -0,0 +1,3 @@ +#!/usr/bin/env my-rust-script-runner + +fn main() {} diff --git a/tests/ui/include-macros/shebang-in-expr-ctxt.rs b/tests/ui/include-macros/shebang-in-expr-ctxt.rs new file mode 100644 index 000000000000..b6d3fa9e076f --- /dev/null +++ b/tests/ui/include-macros/shebang-in-expr-ctxt.rs @@ -0,0 +1,16 @@ +// Check that we *don't* strip shebang in files that were `include`d in an expression or +// expression statement context. +// We do that to be consistent with frontmatter (see test `frontmatter/include-in-expr-ctxt.rs`). +// While there could be niche use cases for such shebang, it seems more confusing than beneficial. + +fn main() { + // expr ctxt + _ = include!("auxiliary/shebang-expr.rs"); + //~^ ERROR non-expression macro in expression position + //~? ERROR expected `[`, found `/` + + // stmt ctxt (reuses expr expander) + include!("auxiliary/shebang-expr.rs"); + //~^ ERROR non-statement macro in statement position + //~? ERROR expected `[`, found `/` +} diff --git a/tests/ui/include-macros/shebang-in-expr-ctxt.stderr b/tests/ui/include-macros/shebang-in-expr-ctxt.stderr new file mode 100644 index 000000000000..9e95b02a78dc --- /dev/null +++ b/tests/ui/include-macros/shebang-in-expr-ctxt.stderr @@ -0,0 +1,33 @@ +error: expected `[`, found `/` + --> $DIR/auxiliary/shebang-expr.rs:1:3 + | +LL | #!/usr/bin/env my-rust-expr-evaluator + | ^ expected `[` + | + = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not + = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file + +error: non-expression macro in expression position: include + --> $DIR/shebang-in-expr-ctxt.rs:8:9 + | +LL | _ = include!("auxiliary/shebang-expr.rs"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: expected `[`, found `/` + --> $DIR/auxiliary/shebang-expr.rs:1:3 + | +LL | #!/usr/bin/env my-rust-expr-evaluator + | ^ expected `[` + | + = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not + = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: non-statement macro in statement position: include + --> $DIR/shebang-in-expr-ctxt.rs:13:5 + | +LL | include!("auxiliary/shebang-expr.rs"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/include-macros/shebang-in-item-ctxt.rs b/tests/ui/include-macros/shebang-in-item-ctxt.rs new file mode 100644 index 000000000000..3e0718e287f0 --- /dev/null +++ b/tests/ui/include-macros/shebang-in-item-ctxt.rs @@ -0,0 +1,4 @@ +// Ensure that we strip shebang in files `include`d in item contexts. +//@ check-pass + +include!("auxiliary/shebang-items.rs"); From 2af849a6e5c5706528efdf7ca3507525b64a074b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Nov 2025 19:41:43 +0100 Subject: [PATCH 022/489] Merge commit '55171cfa8b53970e06dcd2f5f2e2b8d82eeb0885' into subtree-update_cg_gcc_2025-11-26 --- .github/workflows/failures.yml | 2 - .github/workflows/gcc12.yml | 6 -- .github/workflows/release.yml | 3 + .github/workflows/stdarch.yml | 9 +- Cargo.lock | 8 +- Cargo.toml | 6 +- build_system/src/build.rs | 24 +++-- build_system/src/config.rs | 13 --- build_system/src/test.rs | 14 +-- doc/tips.md | 8 ++ libgccjit.version | 2 +- rust-toolchain | 2 +- src/attributes.rs | 2 +- src/back/lto.rs | 1 + src/builder.rs | 3 +- src/consts.rs | 3 +- src/context.rs | 4 +- src/declare.rs | 2 +- src/intrinsic/archs.rs | 20 +--- src/intrinsic/llvm.rs | 13 ++- src/intrinsic/simd.rs | 190 ++++++++++++++++++++++++++++++++- src/lib.rs | 59 +++++++--- src/mono_item.rs | 3 +- src/type_.rs | 2 +- tests/failing-lto-tests.txt | 7 ++ tests/failing-ui-tests.txt | 13 ++- tests/lang_tests_common.rs | 26 +---- tools/generate_intrinsics.py | 3 +- 28 files changed, 315 insertions(+), 133 deletions(-) create mode 100644 tests/failing-lto-tests.txt diff --git a/.github/workflows/failures.yml b/.github/workflows/failures.yml index 67b7fbe4478b..aa4b4dc22c3e 100644 --- a/.github/workflows/failures.yml +++ b/.github/workflows/failures.yml @@ -54,8 +54,6 @@ jobs: if: matrix.libgccjit_version.gcc == 'libgccjit12.so' run: | echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml - echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV - name: Download artifact if: matrix.libgccjit_version.gcc != 'libgccjit12.so' diff --git a/.github/workflows/gcc12.yml b/.github/workflows/gcc12.yml index da9a1506855c..55b090894b4a 100644 --- a/.github/workflows/gcc12.yml +++ b/.github/workflows/gcc12.yml @@ -51,12 +51,6 @@ jobs: - name: Setup path to libgccjit run: echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml - - name: Set env - run: | - echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV - echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV - #- name: Cache rust repository ## We only clone the rust repository for rustc tests #if: ${{ contains(matrix.commands, 'rustc') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52f94dc2970a..895d66f9a4ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,6 +72,9 @@ jobs: git config --global user.name "User" ./y.sh prepare + - name: Add more failing tests (some panic and debuginfo tests fail) + run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt + - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. diff --git a/.github/workflows/stdarch.yml b/.github/workflows/stdarch.yml index 184f122cc1c1..c0a0e3344cc2 100644 --- a/.github/workflows/stdarch.yml +++ b/.github/workflows/stdarch.yml @@ -59,9 +59,8 @@ jobs: sudo ln -s /usr/share/intel-sde/sde /usr/bin/sde sudo ln -s /usr/share/intel-sde/sde64 /usr/bin/sde64 - - name: Set env + - name: Set config run: | - echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV echo 'download-gccjit = true' > config.toml - name: Build @@ -69,12 +68,6 @@ jobs: ./y.sh prepare --only-libcore ./y.sh build --sysroot --release --release-sysroot - - name: Set env (part 2) - run: | - # Set the `LD_LIBRARY_PATH` and `LIBRARY_PATH` env variables... - echo "LD_LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV - echo "LIBRARY_PATH="$(./y.sh info | grep -v Using) >> $GITHUB_ENV - - name: Clean if: ${{ !matrix.cargo_runner }} run: | diff --git a/Cargo.lock b/Cargo.lock index 181d3aa89bc8..00bdacaca676 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,18 +56,18 @@ dependencies = [ [[package]] name = "gccjit" -version = "2.10.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60362e038e71e4bdc1a5b23fb45e1aba587b5947fe0db58f4871d95608f89eca" +checksum = "ff80f4d6d0749eab3a69122210b3a1fdd52edb6162781aadd7c4842e26983683" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.9.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb" +checksum = "263da4f60b7bb5d6a5b21efda961741051ebdbf0e380a09118b03cce66a8c77e" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index d3ff2757857b..18847f50d46a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,11 +24,11 @@ default = ["master"] [dependencies] object = { version = "0.37.0", default-features = false, features = ["std", "read"] } tempfile = "3.20" -gccjit = "2.10" -#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" } +gccjit = { version = "3.1.1", features = ["dlopen"] } +#gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] } # Local copy. -#gccjit = { path = "../gccjit.rs" } +#gccjit = { path = "../gccjit.rs", features = ["dlopen"] } [dev-dependencies] boml = "0.3.1" diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 6aa5faec4c81..56503b239a3b 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -1,7 +1,8 @@ use std::collections::HashMap; use std::ffi::OsStr; use std::fs; -use std::path::Path; +use std::os::unix::fs::symlink; +use std::path::{Path, PathBuf}; use crate::config::{Channel, ConfigInfo}; use crate::utils::{ @@ -100,6 +101,18 @@ fn cleanup_sysroot_previous_build(library_dir: &Path) { pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Result<(), String> { let start_dir = get_sysroot_dir(); + // Symlink libgccjit.so to sysroot. + let lib_path = start_dir.join("sysroot").join("lib"); + let libgccjit_path = + PathBuf::from(config.gcc_path.as_ref().expect("libgccjit should be set by this point")) + .join("libgccjit.so"); + let libgccjit_in_sysroot_path = lib_path.join("libgccjit.so"); + // First remove the file to be able to create the symlink even when the file already exists. + let _ = fs::remove_file(&libgccjit_in_sysroot_path); + create_dir(&lib_path)?; + symlink(libgccjit_path, libgccjit_in_sysroot_path) + .map_err(|error| format!("Cannot create symlink for libgccjit.so: {}", error))?; + let library_dir = start_dir.join("sysroot_src").join("library"); cleanup_sysroot_previous_build(&library_dir); @@ -148,7 +161,7 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu run_command_with_output_and_env(&args, Some(&sysroot_dir), Some(&env))?; // Copy files to sysroot - let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple)); + let sysroot_path = lib_path.join(format!("rustlib/{}/lib/", config.target_triple)); // To avoid errors like "multiple candidates for `rmeta` dependency `core` found", we clean the // sysroot directory before copying the sysroot build artifacts. let _ = fs::remove_dir_all(&sysroot_path); @@ -175,13 +188,6 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu fn build_codegen(args: &mut BuildArg) -> Result<(), String> { let mut env = HashMap::new(); - let gcc_path = - args.config_info.gcc_path.clone().expect( - "The config module should have emitted an error if the GCC path wasn't provided", - ); - env.insert("LD_LIBRARY_PATH".to_string(), gcc_path.clone()); - env.insert("LIBRARY_PATH".to_string(), gcc_path); - if args.config_info.no_default_features { env.insert("RUSTFLAGS".to_string(), "-Csymbol-mangling-version=v0".to_string()); } diff --git a/build_system/src/config.rs b/build_system/src/config.rs index a5f802e293a9..19255e1ba2b2 100644 --- a/build_system/src/config.rs +++ b/build_system/src/config.rs @@ -429,19 +429,6 @@ impl ConfigInfo { // display metadata load errors env.insert("RUSTC_LOG".to_string(), "warn".to_string()); - let sysroot = current_dir - .join(get_sysroot_dir()) - .join(format!("sysroot/lib/rustlib/{}/lib", self.target_triple)); - let ld_library_path = format!( - "{target}:{sysroot}:{gcc_path}", - target = self.cargo_target_dir, - sysroot = sysroot.display(), - gcc_path = gcc_path, - ); - env.insert("LIBRARY_PATH".to_string(), ld_library_path.clone()); - env.insert("LD_LIBRARY_PATH".to_string(), ld_library_path.clone()); - env.insert("DYLD_LIBRARY_PATH".to_string(), ld_library_path); - // NOTE: To avoid the -fno-inline errors, use /opt/gcc/bin/gcc instead of cc. // To do so, add a symlink for cc to /opt/gcc/bin/gcc in our PATH. // Another option would be to add the following Rust flag: -Clinker=/opt/gcc/bin/gcc diff --git a/build_system/src/test.rs b/build_system/src/test.rs index dbdaf2a63ef2..8aabfa894ce0 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -214,14 +214,6 @@ fn cargo_tests(test_env: &Env, test_args: &TestArg) -> Result<(), String> { // We don't want to pass things like `RUSTFLAGS`, since they contain the -Zcodegen-backend flag. // That would force `cg_gcc` to *rebuild itself* and only then run tests, which is undesirable. let mut env = HashMap::new(); - env.insert( - "LD_LIBRARY_PATH".into(), - test_env.get("LD_LIBRARY_PATH").expect("LD_LIBRARY_PATH missing!").to_string(), - ); - env.insert( - "LIBRARY_PATH".into(), - test_env.get("LIBRARY_PATH").expect("LIBRARY_PATH missing!").to_string(), - ); env.insert( "CG_RUSTFLAGS".into(), test_env.get("CG_RUSTFLAGS").map(|s| s.as_str()).unwrap_or("").to_string(), @@ -1065,6 +1057,7 @@ where &test_dir, &"--compiletest-rustc-args", &rustc_args, + &"--bypass-ignore-backends", ]; if run_ignored_tests { @@ -1275,11 +1268,6 @@ pub fn run() -> Result<(), String> { if !args.use_system_gcc { args.config_info.setup_gcc_path()?; - let gcc_path = args.config_info.gcc_path.clone().expect( - "The config module should have emitted an error if the GCC path wasn't provided", - ); - env.insert("LIBRARY_PATH".to_string(), gcc_path.clone()); - env.insert("LD_LIBRARY_PATH".to_string(), gcc_path); } build_if_no_backend(&env, &args)?; diff --git a/doc/tips.md b/doc/tips.md index e62c3402a292..38bc98c02d92 100644 --- a/doc/tips.md +++ b/doc/tips.md @@ -9,6 +9,14 @@ be useful. CG_RUSTFLAGS="-Clink-args=-save-temps -v" ../y.sh cargo build ``` +### How to send arguments to GCC + +The `-Cllvm-args` `rustc` flag is repurposed by `rustc_codegen_gcc` to pass arguments directly to the GCC backend. You can use it via the `CG_RUSTFLAGS` environment variable. For example, to pass a `-f` flag to GCC: + +``` +CG_RUSTFLAGS="-Cllvm-args=-fflag-name" ../y.sh cargo build +``` + ### How to see the personality functions in the asm dump ``` diff --git a/libgccjit.version b/libgccjit.version index b8d4166542bc..bab62f642365 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -28b84db392ac0a572f1a2a2a1317aa5f2bc742cb +0081ca6631abdfa02bf42bc85aaf507b8a0e6beb diff --git a/rust-toolchain b/rust-toolchain index 9813bbea00c4..f9645451e964 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-11-04" +channel = "nightly-2025-11-24" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/src/attributes.rs b/src/attributes.rs index 5df1dc41b01d..cd8c1206c821 100644 --- a/src/attributes.rs +++ b/src/attributes.rs @@ -86,7 +86,7 @@ fn inline_attr<'gcc, 'tcx>( /// attributes. pub fn from_fn_attrs<'gcc, 'tcx>( cx: &CodegenCx<'gcc, 'tcx>, - #[cfg_attr(not(feature = "master"), allow(unused_variables))] func: Function<'gcc>, + #[cfg_attr(not(feature = "master"), expect(unused_variables))] func: Function<'gcc>, instance: ty::Instance<'tcx>, ) { let codegen_fn_attrs = cx.tcx.codegen_instance_attrs(instance.def); diff --git a/src/back/lto.rs b/src/back/lto.rs index 404064fb7a06..840f51c0685d 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -633,6 +633,7 @@ pub fn optimize_thin_module( save_temp_bitcode(cgcx, &module, "thin-lto-after-pm"); } }*/ + // FIXME: switch to #[expect] when the clippy bug is fixed. #[allow(clippy::let_and_return)] module } diff --git a/src/builder.rs b/src/builder.rs index 132c43ef3cda..c0519f7a68e2 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1481,7 +1481,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { variable.to_rvalue() } - #[allow(dead_code)] fn va_arg(&mut self, _list: RValue<'gcc>, _ty: Type<'gcc>) -> RValue<'gcc> { unimplemented!(); } @@ -2517,7 +2516,7 @@ impl ToGccComp for RealPredicate { } #[repr(C)] -#[allow(non_camel_case_types)] +#[expect(non_camel_case_types)] enum MemOrdering { __ATOMIC_RELAXED, __ATOMIC_CONSUME, diff --git a/src/consts.rs b/src/consts.rs index ec7d4b285a3f..6fb96f8832b9 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -58,7 +58,6 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> { global_value } - #[cfg_attr(not(feature = "master"), allow(unused_mut))] fn codegen_static(&mut self, def_id: DefId) { let attrs = self.tcx.codegen_fn_attrs(def_id); @@ -162,7 +161,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { // TODO(antoyo) } - #[cfg_attr(not(feature = "master"), allow(unused_variables))] + #[cfg_attr(not(feature = "master"), expect(unused_variables))] pub fn add_used_function(&self, function: Function<'gcc>) { #[cfg(feature = "master")] function.add_attribute(FnAttribute::Used); diff --git a/src/context.rs b/src/context.rs index c9ae96777de4..dbb89a4ff7db 100644 --- a/src/context.rs +++ b/src/context.rs @@ -28,7 +28,7 @@ use crate::abi::conv_to_fn_attribute; use crate::callee::get_fn; use crate::common::SignType; -#[cfg_attr(not(feature = "master"), allow(dead_code))] +#[cfg_attr(not(feature = "master"), expect(dead_code))] pub struct CodegenCx<'gcc, 'tcx> { /// A cache of converted ConstAllocs pub const_cache: RefCell>>, @@ -132,7 +132,7 @@ pub struct CodegenCx<'gcc, 'tcx> { } impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new( context: &'gcc Context<'gcc>, codegen_unit: &'tcx CodegenUnit<'tcx>, diff --git a/src/declare.rs b/src/declare.rs index 691fd8729e39..42d6fb17a88b 100644 --- a/src/declare.rs +++ b/src/declare.rs @@ -156,7 +156,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { /// /// If there’s a value with the same name already declared, the function will /// update the declaration and return existing Value instead. -#[allow(clippy::let_and_return)] +#[expect(clippy::let_and_return)] fn declare_raw_fn<'gcc>( cx: &CodegenCx<'gcc, '_>, name: &str, diff --git a/src/intrinsic/archs.rs b/src/intrinsic/archs.rs index c51bcbcedd67..bb8bcbf66f38 100644 --- a/src/intrinsic/archs.rs +++ b/src/intrinsic/archs.rs @@ -10,7 +10,7 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { }; match arch { "AMDGPU" => { - #[allow(non_snake_case)] + #[expect(non_snake_case)] fn AMDGPU(name: &str, full_name: &str) -> &'static str { match name { // AMDGPU @@ -48,7 +48,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { AMDGPU(name, full_name) } "aarch64" => { - #[allow(non_snake_case)] fn aarch64(name: &str, full_name: &str) -> &'static str { match name { // aarch64 @@ -81,7 +80,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { aarch64(name, full_name) } "amdgcn" => { - #[allow(non_snake_case)] fn amdgcn(name: &str, full_name: &str) -> &'static str { match name { // amdgcn @@ -524,7 +522,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { amdgcn(name, full_name) } "arm" => { - #[allow(non_snake_case)] fn arm(name: &str, full_name: &str) -> &'static str { match name { // arm @@ -633,7 +630,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { arm(name, full_name) } "bpf" => { - #[allow(non_snake_case)] fn bpf(name: &str, full_name: &str) -> &'static str { match name { // bpf @@ -655,7 +651,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { bpf(name, full_name) } "cuda" => { - #[allow(non_snake_case)] fn cuda(name: &str, full_name: &str) -> &'static str { match name { // cuda @@ -666,7 +661,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { cuda(name, full_name) } "hexagon" => { - #[allow(non_snake_case)] fn hexagon(name: &str, full_name: &str) -> &'static str { match name { // hexagon @@ -2653,7 +2647,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { hexagon(name, full_name) } "loongarch" => { - #[allow(non_snake_case)] fn loongarch(name: &str, full_name: &str) -> &'static str { match name { // loongarch @@ -4162,7 +4155,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { loongarch(name, full_name) } "mips" => { - #[allow(non_snake_case)] fn mips(name: &str, full_name: &str) -> &'static str { match name { // mips @@ -4843,7 +4835,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { mips(name, full_name) } "nvvm" => { - #[allow(non_snake_case)] fn nvvm(name: &str, full_name: &str) -> &'static str { match name { // nvvm @@ -5652,7 +5643,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { nvvm(name, full_name) } "ppc" => { - #[allow(non_snake_case)] fn ppc(name: &str, full_name: &str) -> &'static str { match name { // ppc @@ -6245,7 +6235,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { ppc(name, full_name) } "ptx" => { - #[allow(non_snake_case)] fn ptx(name: &str, full_name: &str) -> &'static str { match name { // ptx @@ -6273,7 +6262,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { ptx(name, full_name) } "r600" => { - #[allow(non_snake_case)] fn r600(name: &str, full_name: &str) -> &'static str { match name { // r600 @@ -6298,7 +6286,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { r600(name, full_name) } "riscv" => { - #[allow(non_snake_case)] fn riscv(name: &str, full_name: &str) -> &'static str { match name { // riscv @@ -6332,7 +6319,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { riscv(name, full_name) } "s390" => { - #[allow(non_snake_case)] fn s390(name: &str, full_name: &str) -> &'static str { match name { // s390 @@ -6526,7 +6512,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { s390(name, full_name) } "spv" => { - #[allow(non_snake_case)] fn spv(name: &str, full_name: &str) -> &'static str { match name { // spv @@ -6543,7 +6528,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { spv(name, full_name) } "ve" => { - #[allow(non_snake_case)] fn ve(name: &str, full_name: &str) -> &'static str { match name { // ve @@ -7816,7 +7800,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { ve(name, full_name) } "x86" => { - #[allow(non_snake_case)] fn x86(name: &str, full_name: &str) -> &'static str { match name { // x86 @@ -10384,7 +10367,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { x86(name, full_name) } "xcore" => { - #[allow(non_snake_case)] fn xcore(name: &str, full_name: &str) -> &'static str { match name { // xcore diff --git a/src/intrinsic/llvm.rs b/src/intrinsic/llvm.rs index 39dba28b24c9..e3d189c95ced 100644 --- a/src/intrinsic/llvm.rs +++ b/src/intrinsic/llvm.rs @@ -85,7 +85,7 @@ fn wide_aes_output_type<'a, 'gcc, 'tcx>( (aes_output_type.as_type(), field1, field2) } -#[cfg_attr(not(feature = "master"), allow(unused_variables))] +#[cfg_attr(not(feature = "master"), expect(unused_variables))] pub fn adjust_function<'gcc>( context: &'gcc Context<'gcc>, func_name: &str, @@ -1573,14 +1573,25 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function "llvm.x86.tileloadd64" => "__builtin_trap", "llvm.x86.tilerelease" => "__builtin_trap", "llvm.x86.tilestored64" => "__builtin_trap", + "llvm.x86.tileloaddrs64" => "__builtin_trap", "llvm.x86.tileloaddt164" => "__builtin_trap", + "llvm.x86.tileloaddrst164" => "__builtin_trap", "llvm.x86.tilezero" => "__builtin_trap", + "llvm.x86.tilemovrow" => "__builtin_trap", + "llvm.x86.tdpbhf8ps" => "__builtin_trap", + "llvm.x86.tdphbf8ps" => "__builtin_trap", + "llvm.x86.tdpbf8ps" => "__builtin_trap", + "llvm.x86.tdphf8ps" => "__builtin_trap", "llvm.x86.tdpbf16ps" => "__builtin_trap", "llvm.x86.tdpbssd" => "__builtin_trap", "llvm.x86.tdpbsud" => "__builtin_trap", "llvm.x86.tdpbusd" => "__builtin_trap", "llvm.x86.tdpbuud" => "__builtin_trap", "llvm.x86.tdpfp16ps" => "__builtin_trap", + "llvm.x86.tmmultf32ps" => "__builtin_trap", + "llvm.x86.tcvtrowps2phh" => "__builtin_trap", + "llvm.x86.tcvtrowps2phl" => "__builtin_trap", + "llvm.x86.tcvtrowd2ps" => "__builtin_trap", "llvm.x86.tcmmimfp16ps" => "__builtin_trap", "llvm.x86.tcmmrlfp16ps" => "__builtin_trap", diff --git a/src/intrinsic/simd.rs b/src/intrinsic/simd.rs index 41363d6313d6..c7ed887b30d0 100644 --- a/src/intrinsic/simd.rs +++ b/src/intrinsic/simd.rs @@ -53,6 +53,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( }; } + // TODO(antoyo): refactor with the above require_simd macro that was changed in cg_llvm. + #[cfg(feature = "master")] + macro_rules! require_simd2 { + ($ty: expr, $variant:ident) => {{ + require!($ty.is_simd(), InvalidMonomorphization::$variant { span, name, ty: $ty }); + $ty.simd_size_and_type(bx.tcx()) + }}; + } + if name == sym::simd_select_bitmask { require_simd!( args[1].layout.ty, @@ -464,9 +473,8 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( m_len == v_len, InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len } ); - // TODO: also support unsigned integers. match *m_elem_ty.kind() { - ty::Int(_) => {} + ty::Int(_) | ty::Uint(_) => {} _ => return_error!(InvalidMonomorphization::MaskWrongElementType { span, name, @@ -1454,6 +1462,184 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( bitwise_red!(simd_reduce_all: BinaryOp::BitwiseAnd, true); bitwise_red!(simd_reduce_any: BinaryOp::BitwiseOr, true); + #[cfg(feature = "master")] + if name == sym::simd_masked_load { + // simd_masked_load<_, _, _, const ALIGN: SimdAlign>(mask: , pointer: *_ T, values: ) -> + // * N: number of elements in the input vectors + // * T: type of the element to load + // * M: any integer width is supported, will be truncated to i1 + // Loads contiguous elements from memory behind `pointer`, but only for + // those lanes whose `mask` bit is enabled. + // The memory addresses corresponding to the “off” lanes are not accessed. + + // TODO: handle the alignment. + + // The element type of the "mask" argument must be a signed integer type of any width + let mask_ty = in_ty; + let mask_len = in_len; + + // The second argument must be a pointer matching the element type + let pointer_ty = args[1].layout.ty; + + // The last argument is a passthrough vector providing values for disabled lanes + let values_ty = args[2].layout.ty; + let (values_len, values_elem) = require_simd2!(values_ty, SimdThird); + + require_simd2!(ret_ty, SimdReturn); + + // Of the same length: + require!( + values_len == mask_len, + InvalidMonomorphization::ThirdArgumentLength { + span, + name, + in_len: mask_len, + in_ty: mask_ty, + arg_ty: values_ty, + out_len: values_len + } + ); + + // The return type must match the last argument type + require!( + ret_ty == values_ty, + InvalidMonomorphization::ExpectedReturnType { span, name, in_ty: values_ty, ret_ty } + ); + + require!( + matches!( + *pointer_ty.kind(), + ty::RawPtr(p_ty, _) if p_ty == values_elem && p_ty.kind() == values_elem.kind() + ), + InvalidMonomorphization::ExpectedElementType { + span, + name, + expected_element: values_elem, + second_arg: pointer_ty, + in_elem: values_elem, + in_ty: values_ty, + mutability: ExpectedPointerMutability::Not, + } + ); + + let mask = args[0].immediate(); + + let pointer = args[1].immediate(); + let default = args[2].immediate(); + let default_type = default.get_type(); + let vector_type = default_type.unqualified().dyncast_vector().expect("vector type"); + let value_type = vector_type.get_element_type(); + let new_pointer_type = value_type.make_pointer(); + + let pointer = bx.context.new_cast(None, pointer, new_pointer_type); + + let mask_vector_type = mask.get_type().unqualified().dyncast_vector().expect("vector type"); + let elem_type = mask_vector_type.get_element_type(); + let zero = bx.context.new_rvalue_zero(elem_type); + let mut elements = vec![]; + for i in 0..mask_len { + let i = bx.context.new_rvalue_from_int(bx.int_type, i as i32); + let mask = bx.context.new_vector_access(None, mask, i).to_rvalue(); + let mask = bx.context.new_comparison(None, ComparisonOp::NotEquals, mask, zero); + let then_val = bx.context.new_array_access(None, pointer, i).to_rvalue(); + let else_val = bx.context.new_vector_access(None, default, i).to_rvalue(); + let element = bx.select(mask, then_val, else_val); + elements.push(element); + } + let result = bx.context.new_rvalue_from_vector(None, default_type, &elements); + return Ok(result); + } + + #[cfg(feature = "master")] + if name == sym::simd_masked_store { + // simd_masked_store<_, _, _, const ALIGN: SimdAlign>(mask: , pointer: *mut T, values: ) -> () + // * N: number of elements in the input vectors + // * T: type of the element to load + // * M: any integer width is supported, will be truncated to i1 + // Stores contiguous elements to memory behind `pointer`, but only for + // those lanes whose `mask` bit is enabled. + // The memory addresses corresponding to the “off” lanes are not accessed. + + // TODO: handle the alignment. + + // The element type of the "mask" argument must be a signed integer type of any width + let mask_ty = in_ty; + let mask_len = in_len; + + // The second argument must be a pointer matching the element type + let pointer_ty = args[1].layout.ty; + + // The last argument specifies the values to store to memory + let values_ty = args[2].layout.ty; + let (values_len, values_elem) = require_simd2!(values_ty, SimdThird); + + // Of the same length: + require!( + values_len == mask_len, + InvalidMonomorphization::ThirdArgumentLength { + span, + name, + in_len: mask_len, + in_ty: mask_ty, + arg_ty: values_ty, + out_len: values_len + } + ); + + // The second argument must be a mutable pointer type matching the element type + require!( + matches!( + *pointer_ty.kind(), + ty::RawPtr(p_ty, p_mutbl) + if p_ty == values_elem && p_ty.kind() == values_elem.kind() && p_mutbl.is_mut() + ), + InvalidMonomorphization::ExpectedElementType { + span, + name, + expected_element: values_elem, + second_arg: pointer_ty, + in_elem: values_elem, + in_ty: values_ty, + mutability: ExpectedPointerMutability::Mut, + } + ); + + let mask = args[0].immediate(); + let pointer = args[1].immediate(); + let values = args[2].immediate(); + let values_type = values.get_type(); + let vector_type = values_type.unqualified().dyncast_vector().expect("vector type"); + let value_type = vector_type.get_element_type(); + let new_pointer_type = value_type.make_pointer(); + + let pointer = bx.context.new_cast(None, pointer, new_pointer_type); + + let vector_type = mask.get_type().unqualified().dyncast_vector().expect("vector type"); + let elem_type = vector_type.get_element_type(); + let zero = bx.context.new_rvalue_zero(elem_type); + for i in 0..mask_len { + let i = bx.context.new_rvalue_from_int(bx.int_type, i as i32); + let mask = bx.context.new_vector_access(None, mask, i).to_rvalue(); + let mask = bx.context.new_comparison(None, ComparisonOp::NotEquals, mask, zero); + + let after_block = bx.current_func().new_block("after"); + let then_block = bx.current_func().new_block("then"); + bx.llbb().end_with_conditional(None, mask, then_block, after_block); + + bx.switch_to_block(then_block); + let lvalue = bx.context.new_array_access(None, pointer, i); + let value = bx.context.new_vector_access(None, values, i).to_rvalue(); + bx.llbb().add_assignment(None, lvalue, value); + bx.llbb().end_with_jump(None, after_block); + + bx.switch_to_block(after_block); + } + + let dummy_value = bx.context.new_rvalue_zero(bx.int_type); + + return Ok(dummy_value); + } + unimplemented!("simd {}", name); } diff --git a/src/lib.rs b/src/lib.rs index 409b7886740a..662e303f94f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] #![deny(clippy::pattern_type_mismatch)] -#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)] +#![expect(clippy::uninlined_format_args)] // The rustc crates we need extern crate rustc_abi; @@ -43,7 +43,7 @@ extern crate rustc_target; extern crate rustc_type_ir; // This prevents duplicating functions and statics that are already part of the host rustc process. -#[allow(unused_extern_crates)] +#[expect(unused_extern_crates)] extern crate rustc_driver; mod abi; @@ -69,9 +69,10 @@ mod type_; mod type_of; use std::any::Any; +use std::ffi::CString; use std::fmt::Debug; use std::ops::Deref; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; @@ -142,7 +143,7 @@ impl TargetInfo { #[derive(Clone)] pub struct LockedTargetInfo { - info: Arc>>, + info: Arc>>>, } impl Debug for LockedTargetInfo { @@ -153,11 +154,21 @@ impl Debug for LockedTargetInfo { impl LockedTargetInfo { fn cpu_supports(&self, feature: &str) -> bool { - self.info.lock().expect("lock").cpu_supports(feature) + self.info + .lock() + .expect("lock") + .as_ref() + .expect("target info not initialized") + .cpu_supports(feature) } fn supports_target_dependent_type(&self, typ: CType) -> bool { - self.info.lock().expect("lock").supports_target_dependent_type(typ) + self.info + .lock() + .expect("lock") + .as_ref() + .expect("target info not initialized") + .supports_target_dependent_type(typ) } } @@ -169,6 +180,23 @@ pub struct GccCodegenBackend { static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); +fn load_libgccjit_if_needed(sysroot_path: &Path) { + if gccjit::is_loaded() { + // Do not load a libgccjit second time. + return; + } + + let sysroot_lib_dir = sysroot_path.join("lib"); + let libgccjit_target_lib_file = sysroot_lib_dir.join("libgccjit.so"); + let path = libgccjit_target_lib_file.to_str().expect("libgccjit path"); + + let string = CString::new(path).expect("string to libgccjit path"); + + if let Err(error) = gccjit::load(&string) { + panic!("Cannot load libgccjit.so: {}", error); + } +} + impl CodegenBackend for GccCodegenBackend { fn locale_resource(&self) -> &'static str { crate::DEFAULT_LOCALE_RESOURCE @@ -178,10 +206,12 @@ impl CodegenBackend for GccCodegenBackend { "gcc" } - fn init(&self, _sess: &Session) { + fn init(&self, sess: &Session) { + load_libgccjit_if_needed(sess.opts.sysroot.path()); + #[cfg(feature = "master")] { - let target_cpu = target_cpu(_sess); + let target_cpu = target_cpu(sess); // Get the second TargetInfo with the correct CPU features by setting the arch. let context = Context::default(); @@ -189,7 +219,8 @@ impl CodegenBackend for GccCodegenBackend { context.add_command_line_option(format!("-march={}", target_cpu)); } - **self.target_info.info.lock().expect("lock") = context.get_target_info(); + *self.target_info.info.lock().expect("lock") = + IntoDynSyncSend(Some(context.get_target_info())); } #[cfg(feature = "master")] @@ -217,6 +248,9 @@ impl CodegenBackend for GccCodegenBackend { .info .lock() .expect("lock") + .0 + .as_ref() + .expect("target info not initialized") .supports_128bit_integers .store(check_context.get_last_error() == Ok(None), Ordering::SeqCst); } @@ -438,13 +472,12 @@ pub fn __rustc_codegen_backend() -> Box { let info = { // Check whether the target supports 128-bit integers, and sized floating point types (like // Float16). - let context = Context::default(); - Arc::new(Mutex::new(IntoDynSyncSend(context.get_target_info()))) + Arc::new(Mutex::new(IntoDynSyncSend(None))) }; #[cfg(not(feature = "master"))] - let info = Arc::new(Mutex::new(IntoDynSyncSend(TargetInfo { + let info = Arc::new(Mutex::new(IntoDynSyncSend(Some(TargetInfo { supports_128bit_integers: AtomicBool::new(false), - }))); + })))); Box::new(GccCodegenBackend { lto_supported: Arc::new(AtomicBool::new(false)), diff --git a/src/mono_item.rs b/src/mono_item.rs index 35d44d21bcbf..31c03eddaca5 100644 --- a/src/mono_item.rs +++ b/src/mono_item.rs @@ -15,7 +15,7 @@ use crate::type_of::LayoutGccExt; use crate::{attributes, base}; impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { - #[cfg_attr(not(feature = "master"), allow(unused_variables))] + #[cfg_attr(not(feature = "master"), expect(unused_variables))] fn predefine_static( &mut self, def_id: DefId, @@ -41,7 +41,6 @@ impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { self.instances.borrow_mut().insert(instance, global); } - #[cfg_attr(not(feature = "master"), allow(unused_variables))] fn predefine_fn( &mut self, instance: Instance<'tcx>, diff --git a/src/type_.rs b/src/type_.rs index 15a0206607e1..d356b6af260a 100644 --- a/src/type_.rs +++ b/src/type_.rs @@ -299,7 +299,7 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> { value.get_type() } - #[cfg_attr(feature = "master", allow(unused_mut))] + #[cfg_attr(feature = "master", expect(unused_mut))] fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> { #[cfg(not(feature = "master"))] if let Some(struct_type) = ty.is_struct() diff --git a/tests/failing-lto-tests.txt b/tests/failing-lto-tests.txt new file mode 100644 index 000000000000..c45fc0776588 --- /dev/null +++ b/tests/failing-lto-tests.txt @@ -0,0 +1,7 @@ +tests/ui/lto/all-crates.rs +tests/ui/lto/debuginfo-lto-alloc.rs +tests/ui/panic-runtime/lto-unwind.rs +tests/ui/uninhabited/uninhabited-transparent-return-abi.rs +tests/ui/coroutine/panic-drops-resume.rs +tests/ui/coroutine/panic-drops.rs +tests/ui/coroutine/panic-safe.rs diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index cc00432ceb54..2380bd0fc137 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -8,7 +8,6 @@ tests/ui/iterators/iter-sum-overflow-overflow-checks.rs tests/ui/mir/mir_drop_order.rs tests/ui/mir/mir_let_chains_drop_order.rs tests/ui/mir/mir_match_guard_let_chains_drop_order.rs -tests/ui/panics/oom-panic-unwind.rs tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs tests/ui/panic-runtime/abort.rs tests/ui/panic-runtime/link-to-abort.rs @@ -77,3 +76,15 @@ tests/ui/explicit-tail-calls/recursion-etc.rs tests/ui/explicit-tail-calls/indexer.rs tests/ui/explicit-tail-calls/drop-order.rs tests/ui/c-variadic/valid.rs +tests/ui/c-variadic/inherent-method.rs +tests/ui/c-variadic/trait-method.rs +tests/ui/explicit-tail-calls/become-cast-return.rs +tests/ui/explicit-tail-calls/become-indirect-return.rs +tests/ui/panics/panic-abort-backtrace-without-debuginfo.rs +tests/ui/sanitizer/kcfi-c-variadic.rs +tests/ui/sanitizer/kcfi/fn-trait-objects.rs +tests/ui/statics/const_generics.rs +tests/ui/test-attrs/test-panic-while-printing.rs +tests/ui/thir-print/offset_of.rs +tests/ui/iterators/rangefrom-overflow-debug.rs +tests/ui/iterators/rangefrom-overflow-overflow-checks.rs diff --git a/tests/lang_tests_common.rs b/tests/lang_tests_common.rs index 9abe97b10876..311f256b7600 100644 --- a/tests/lang_tests_common.rs +++ b/tests/lang_tests_common.rs @@ -2,11 +2,10 @@ #![allow(clippy::uninlined_format_args)] -use std::env::{self, current_dir}; +use std::env::current_dir; use std::path::{Path, PathBuf}; use std::process::Command; -use boml::Toml; use lang_tester::LangTester; use tempfile::TempDir; @@ -23,29 +22,6 @@ pub fn main_inner(profile: Profile) { let current_dir = current_dir().expect("current dir"); let current_dir = current_dir.to_str().expect("current dir").to_string(); - let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); - - let gcc_path = std::fs::read_to_string(manifest_dir.join("config.toml")) - .ok() - .and_then(|v| { - let toml = Toml::parse(&v).expect("Failed to parse `config.toml`"); - toml.get_string("gcc-path").map(PathBuf::from).ok() - }) - .unwrap_or_else(|| { - // then we try to retrieve it from the `target` folder. - let commit = include_str!("../libgccjit.version").trim(); - Path::new("build/libgccjit").join(commit) - }); - - let gcc_path = Path::new(&gcc_path) - .canonicalize() - .expect("failed to get absolute path of `gcc-path`") - .display() - .to_string(); - unsafe { - env::set_var("LD_LIBRARY_PATH", gcc_path); - } - fn rust_filter(path: &Path) -> bool { path.is_file() && path.extension().expect("extension").to_str().expect("to_str") == "rs" } diff --git a/tools/generate_intrinsics.py b/tools/generate_intrinsics.py index 88927f39b93e..767082c23cce 100644 --- a/tools/generate_intrinsics.py +++ b/tools/generate_intrinsics.py @@ -183,7 +183,8 @@ def update_intrinsics(llvm_path, llvmint, llvmint2): for arch in archs: if len(intrinsics[arch]) == 0: continue - out.write("\"{}\" => {{ #[allow(non_snake_case)] fn {}(name: &str,full_name:&str) -> &'static str {{ match name {{".format(arch,arch)) + attribute = "#[expect(non_snake_case)]" if arch[0].isupper() else "" + out.write("\"{}\" => {{ {} fn {}(name: &str,full_name:&str) -> &'static str {{ match name {{".format(arch, attribute, arch)) intrinsics[arch].sort(key=lambda x: (x[0], x[2])) out.write(' // {}\n'.format(arch)) for entry in intrinsics[arch]: From a7ea98bf2c8d4688aae2d238d856c14282fbbab6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Nov 2025 11:42:42 +0100 Subject: [PATCH 023/489] Update GCC commit --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index bab62f642365..b8d4166542bc 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -0081ca6631abdfa02bf42bc85aaf507b8a0e6beb +28b84db392ac0a572f1a2a2a1317aa5f2bc742cb From 8059907cef079081bd51d2adddc8769dddd16728 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 26 Nov 2025 20:11:18 +0100 Subject: [PATCH 024/489] Update GCC submodule --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index b8d4166542bc..bab62f642365 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -28b84db392ac0a572f1a2a2a1317aa5f2bc742cb +0081ca6631abdfa02bf42bc85aaf507b8a0e6beb From f83c72f00c7cefecb2bb5d07cfb0de67a0697c7f Mon Sep 17 00:00:00 2001 From: yanglsh Date: Thu, 21 Aug 2025 10:56:14 +0800 Subject: [PATCH 025/489] fix: `branches-sharing-code` suggests wrongly on `const` and `static` --- clippy_lints/src/ifs/branches_sharing_code.rs | 75 +++++-- clippy_utils/src/hir_utils.rs | 209 +++++++++++++++++- .../branches_sharing_code/shared_at_bottom.rs | 62 ++++++ .../shared_at_bottom.stderr | 70 +++++- 4 files changed, 388 insertions(+), 28 deletions(-) diff --git a/clippy_lints/src/ifs/branches_sharing_code.rs b/clippy_lints/src/ifs/branches_sharing_code.rs index b3f597cc8736..b6e8d047c5cd 100644 --- a/clippy_lints/src/ifs/branches_sharing_code.rs +++ b/clippy_lints/src/ifs/branches_sharing_code.rs @@ -9,7 +9,7 @@ use clippy_utils::{ use core::iter; use core::ops::ControlFlow; use rustc_errors::Applicability; -use rustc_hir::{Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Node, Stmt, StmtKind, intravisit}; +use rustc_hir::{Block, Expr, ExprKind, HirId, HirIdSet, ItemKind, LetStmt, Node, Stmt, StmtKind, UseKind, intravisit}; use rustc_lint::LateContext; use rustc_span::hygiene::walk_chain; use rustc_span::source_map::SourceMap; @@ -108,6 +108,7 @@ struct BlockEq { /// The name and id of every local which can be moved at the beginning and the end. moved_locals: Vec<(HirId, Symbol)>, } + impl BlockEq { fn start_span(&self, b: &Block<'_>, sm: &SourceMap) -> Option { match &b.stmts[..self.start_end_eq] { @@ -129,20 +130,33 @@ impl BlockEq { } /// If the statement is a local, checks if the bound names match the expected list of names. -fn eq_binding_names(s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool { - if let StmtKind::Let(l) = s.kind { - let mut i = 0usize; - let mut res = true; - l.pat.each_binding_or_first(&mut |_, _, _, name| { - if names.get(i).is_some_and(|&(_, n)| n == name.name) { - i += 1; - } else { - res = false; - } - }); - res && i == names.len() - } else { - false +fn eq_binding_names(cx: &LateContext<'_>, s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool { + match s.kind { + StmtKind::Let(l) => { + let mut i = 0usize; + let mut res = true; + l.pat.each_binding_or_first(&mut |_, _, _, name| { + if names.get(i).is_some_and(|&(_, n)| n == name.name) { + i += 1; + } else { + res = false; + } + }); + res && i == names.len() + }, + StmtKind::Item(item_id) + if let [(_, name)] = names + && let item = cx.tcx.hir_item(item_id) + && let ItemKind::Static(_, ident, ..) + | ItemKind::Const(ident, ..) + | ItemKind::Fn { ident, .. } + | ItemKind::TyAlias(ident, ..) + | ItemKind::Use(_, UseKind::Single(ident)) + | ItemKind::Mod(ident, _) = item.kind => + { + *name == ident.name + }, + _ => false, } } @@ -164,6 +178,7 @@ fn modifies_any_local<'tcx>(cx: &LateContext<'tcx>, s: &'tcx Stmt<'_>, locals: & /// Checks if the given statement should be considered equal to the statement in the same /// position for each block. fn eq_stmts( + cx: &LateContext<'_>, stmt: &Stmt<'_>, blocks: &[&Block<'_>], get_stmt: impl for<'a> Fn(&'a Block<'a>) -> Option<&'a Stmt<'a>>, @@ -178,7 +193,7 @@ fn eq_stmts( let new_bindings = &moved_bindings[old_count..]; blocks .iter() - .all(|b| get_stmt(b).is_some_and(|s| eq_binding_names(s, new_bindings))) + .all(|b| get_stmt(b).is_some_and(|s| eq_binding_names(cx, s, new_bindings))) } else { true }) && blocks.iter().all(|b| get_stmt(b).is_some_and(|s| eq.eq_stmt(s, stmt))) @@ -218,7 +233,7 @@ fn scan_block_for_eq<'tcx>( return true; } modifies_any_local(cx, stmt, &cond_locals) - || !eq_stmts(stmt, blocks, |b| b.stmts.get(i), &mut eq, &mut moved_locals) + || !eq_stmts(cx, stmt, blocks, |b| b.stmts.get(i), &mut eq, &mut moved_locals) }) .map_or(block.stmts.len(), |(i, stmt)| { adjust_by_closest_callsite(i, stmt, block.stmts[..i].iter().enumerate().rev()) @@ -279,6 +294,7 @@ fn scan_block_for_eq<'tcx>( })) .fold(end_search_start, |init, (stmt, offset)| { if eq_stmts( + cx, stmt, blocks, |b| b.stmts.get(b.stmts.len() - offset), @@ -290,11 +306,26 @@ fn scan_block_for_eq<'tcx>( // Clear out all locals seen at the end so far. None of them can be moved. let stmts = &blocks[0].stmts; for stmt in &stmts[stmts.len() - init..=stmts.len() - offset] { - if let StmtKind::Let(l) = stmt.kind { - l.pat.each_binding_or_first(&mut |_, id, _, _| { - // FIXME(rust/#120456) - is `swap_remove` correct? - eq.locals.swap_remove(&id); - }); + match stmt.kind { + StmtKind::Let(l) => { + l.pat.each_binding_or_first(&mut |_, id, _, _| { + // FIXME(rust/#120456) - is `swap_remove` correct? + eq.locals.swap_remove(&id); + }); + }, + StmtKind::Item(item_id) => { + let item = cx.tcx.hir_item(item_id); + if let ItemKind::Static(..) + | ItemKind::Const(..) + | ItemKind::Fn { .. } + | ItemKind::TyAlias(..) + | ItemKind::Use(..) + | ItemKind::Mod(..) = item.kind + { + eq.local_items.swap_remove(&item.owner_id.to_def_id()); + } + }, + _ => {}, } } moved_locals.truncate(moved_locals_at_start); diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index b286701fbed1..5b55ad2a3f5b 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -4,14 +4,17 @@ use crate::source::{SpanRange, SpanRangeExt, walk_span_to_context}; use crate::tokenize_with_text; use rustc_ast::ast; use rustc_ast::ast::InlineAsmTemplatePiece; -use rustc_data_structures::fx::FxHasher; +use rustc_data_structures::fx::{FxHasher, FxIndexMap}; use rustc_hir::MatchSource::TryDesugar; use rustc_hir::def::{DefKind, Res}; +use rustc_hir::def_id::DefId; use rustc_hir::{ - AssocItemConstraint, BinOpKind, BindingMode, Block, BodyId, ByRef, Closure, ConstArg, ConstArgKind, Expr, - ExprField, ExprKind, FnRetTy, GenericArg, GenericArgs, HirId, HirIdMap, InlineAsmOperand, LetExpr, Lifetime, - LifetimeKind, Node, Pat, PatExpr, PatExprKind, PatField, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, - StructTailExpr, TraitBoundModifiers, Ty, TyKind, TyPat, TyPatKind, + AssocItemConstraint, BinOpKind, BindingMode, Block, BodyId, ByRef, Closure, ConstArg, ConstArgKind, ConstItemRhs, + Expr, ExprField, ExprKind, FnDecl, FnRetTy, FnSig, GenericArg, GenericArgs, GenericBound, GenericBounds, + GenericParam, GenericParamKind, GenericParamSource, Generics, HirId, HirIdMap, InlineAsmOperand, ItemId, ItemKind, + LetExpr, Lifetime, LifetimeKind, LifetimeParamKind, Node, ParamName, Pat, PatExpr, PatExprKind, PatField, PatKind, + Path, PathSegment, PreciseCapturingArgKind, PrimTy, QPath, Stmt, StmtKind, StructTailExpr, TraitBoundModifiers, Ty, + TyKind, TyPat, TyPatKind, UseKind, WherePredicate, WherePredicateKind, }; use rustc_lexer::{FrontmatterAllowed, TokenKind, tokenize}; use rustc_lint::LateContext; @@ -106,6 +109,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { left_ctxt: SyntaxContext::root(), right_ctxt: SyntaxContext::root(), locals: HirIdMap::default(), + local_items: FxIndexMap::default(), } } @@ -144,6 +148,7 @@ pub struct HirEqInterExpr<'a, 'b, 'tcx> { // right. For example, when comparing `{ let x = 1; x + 2 }` and `{ let y = 1; y + 2 }`, // these blocks are considered equal since `x` is mapped to `y`. pub locals: HirIdMap, + pub local_items: FxIndexMap, } impl HirEqInterExpr<'_, '_, '_> { @@ -168,6 +173,189 @@ impl HirEqInterExpr<'_, '_, '_> { && self.eq_pat(l.pat, r.pat) }, (StmtKind::Expr(l), StmtKind::Expr(r)) | (StmtKind::Semi(l), StmtKind::Semi(r)) => self.eq_expr(l, r), + (StmtKind::Item(l), StmtKind::Item(r)) => self.eq_item(*l, *r), + _ => false, + } + } + + pub fn eq_item(&mut self, l: ItemId, r: ItemId) -> bool { + let left = self.inner.cx.tcx.hir_item(l); + let right = self.inner.cx.tcx.hir_item(r); + let eq = match (left.kind, right.kind) { + ( + ItemKind::Const(l_ident, l_generics, l_ty, ConstItemRhs::Body(l_body)), + ItemKind::Const(r_ident, r_generics, r_ty, ConstItemRhs::Body(r_body)), + ) => { + l_ident.name == r_ident.name + && self.eq_generics(l_generics, r_generics) + && self.eq_ty(l_ty, r_ty) + && self.eq_body(l_body, r_body) + }, + (ItemKind::Static(l_mut, l_ident, l_ty, l_body), ItemKind::Static(r_mut, r_ident, r_ty, r_body)) => { + l_mut == r_mut && l_ident.name == r_ident.name && self.eq_ty(l_ty, r_ty) && self.eq_body(l_body, r_body) + }, + ( + ItemKind::Fn { + sig: l_sig, + ident: l_ident, + generics: l_generics, + body: l_body, + has_body: l_has_body, + }, + ItemKind::Fn { + sig: r_sig, + ident: r_ident, + generics: r_generics, + body: r_body, + has_body: r_has_body, + }, + ) => { + l_ident.name == r_ident.name + && (l_has_body == r_has_body) + && self.eq_fn_sig(&l_sig, &r_sig) + && self.eq_generics(l_generics, r_generics) + && self.eq_body(l_body, r_body) + }, + (ItemKind::TyAlias(l_ident, l_generics, l_ty), ItemKind::TyAlias(r_ident, r_generics, r_ty)) => { + l_ident.name == r_ident.name && self.eq_generics(l_generics, r_generics) && self.eq_ty(l_ty, r_ty) + }, + (ItemKind::Use(l_path, l_kind), ItemKind::Use(r_path, r_kind)) => { + self.eq_path_segments(l_path.segments, r_path.segments) + && match (l_kind, r_kind) { + (UseKind::Single(l_ident), UseKind::Single(r_ident)) => l_ident.name == r_ident.name, + (UseKind::Glob, UseKind::Glob) | (UseKind::ListStem, UseKind::ListStem) => true, + _ => false, + } + }, + (ItemKind::Mod(l_ident, l_mod), ItemKind::Mod(r_ident, r_mod)) => { + l_ident.name == r_ident.name && over(l_mod.item_ids, r_mod.item_ids, |l, r| self.eq_item(*l, *r)) + }, + _ => false, + }; + if eq { + self.local_items.insert(l.owner_id.to_def_id(), r.owner_id.to_def_id()); + } + eq + } + + fn eq_fn_sig(&mut self, left: &FnSig<'_>, right: &FnSig<'_>) -> bool { + left.header.safety == right.header.safety + && left.header.constness == right.header.constness + && left.header.asyncness == right.header.asyncness + && left.header.abi == right.header.abi + && self.eq_fn_decl(left.decl, right.decl) + } + + fn eq_fn_decl(&mut self, left: &FnDecl<'_>, right: &FnDecl<'_>) -> bool { + over(left.inputs, right.inputs, |l, r| self.eq_ty(l, r)) + && (match (left.output, right.output) { + (FnRetTy::DefaultReturn(_), FnRetTy::DefaultReturn(_)) => true, + (FnRetTy::Return(l_ty), FnRetTy::Return(r_ty)) => self.eq_ty(l_ty, r_ty), + _ => false, + }) + && left.c_variadic == right.c_variadic + && left.implicit_self == right.implicit_self + && left.lifetime_elision_allowed == right.lifetime_elision_allowed + } + + fn eq_generics(&mut self, left: &Generics<'_>, right: &Generics<'_>) -> bool { + self.eq_generics_param(left.params, right.params) + && self.eq_generics_predicate(left.predicates, right.predicates) + } + + fn eq_generics_predicate(&mut self, left: &[WherePredicate<'_>], right: &[WherePredicate<'_>]) -> bool { + over(left, right, |l, r| match (l.kind, r.kind) { + (WherePredicateKind::BoundPredicate(l_bound), WherePredicateKind::BoundPredicate(r_bound)) => { + l_bound.origin == r_bound.origin + && self.eq_ty(l_bound.bounded_ty, r_bound.bounded_ty) + && self.eq_generics_param(l_bound.bound_generic_params, r_bound.bound_generic_params) + && self.eq_generics_bound(l_bound.bounds, r_bound.bounds) + }, + (WherePredicateKind::RegionPredicate(l_region), WherePredicateKind::RegionPredicate(r_region)) => { + Self::eq_lifetime(l_region.lifetime, r_region.lifetime) + && self.eq_generics_bound(l_region.bounds, r_region.bounds) + }, + (WherePredicateKind::EqPredicate(l_eq), WherePredicateKind::EqPredicate(r_eq)) => { + self.eq_ty(l_eq.lhs_ty, r_eq.lhs_ty) + }, + _ => false, + }) + } + + fn eq_generics_bound(&mut self, left: GenericBounds<'_>, right: GenericBounds<'_>) -> bool { + over(left, right, |l, r| match (l, r) { + (GenericBound::Trait(l_trait), GenericBound::Trait(r_trait)) => { + l_trait.modifiers == r_trait.modifiers + && self.eq_path(l_trait.trait_ref.path, r_trait.trait_ref.path) + && self.eq_generics_param(l_trait.bound_generic_params, r_trait.bound_generic_params) + }, + (GenericBound::Outlives(l_lifetime), GenericBound::Outlives(r_lifetime)) => { + Self::eq_lifetime(l_lifetime, r_lifetime) + }, + (GenericBound::Use(l_capture, _), GenericBound::Use(r_capture, _)) => { + over(l_capture, r_capture, |l, r| match (l, r) { + (PreciseCapturingArgKind::Lifetime(l_lifetime), PreciseCapturingArgKind::Lifetime(r_lifetime)) => { + Self::eq_lifetime(l_lifetime, r_lifetime) + }, + (PreciseCapturingArgKind::Param(l_param), PreciseCapturingArgKind::Param(r_param)) => { + l_param.ident == r_param.ident && l_param.res == r_param.res + }, + _ => false, + }) + }, + _ => false, + }) + } + + fn eq_generics_param(&mut self, left: &[GenericParam<'_>], right: &[GenericParam<'_>]) -> bool { + over(left, right, |l, r| { + (match (l.name, r.name) { + (ParamName::Plain(l_ident), ParamName::Plain(r_ident)) + | (ParamName::Error(l_ident), ParamName::Error(r_ident)) => l_ident.name == r_ident.name, + (ParamName::Fresh, ParamName::Fresh) => true, + _ => false, + }) && l.pure_wrt_drop == r.pure_wrt_drop + && self.eq_generics_param_kind(&l.kind, &r.kind) + && (matches!( + (l.source, r.source), + (GenericParamSource::Generics, GenericParamSource::Generics) + | (GenericParamSource::Binder, GenericParamSource::Binder) + )) + }) + } + + fn eq_generics_param_kind(&mut self, left: &GenericParamKind<'_>, right: &GenericParamKind<'_>) -> bool { + match (left, right) { + (GenericParamKind::Lifetime { kind: l_kind }, GenericParamKind::Lifetime { kind: r_kind }) => { + match (l_kind, r_kind) { + (LifetimeParamKind::Explicit, LifetimeParamKind::Explicit) + | (LifetimeParamKind::Error, LifetimeParamKind::Error) => true, + (LifetimeParamKind::Elided(l_lifetime_kind), LifetimeParamKind::Elided(r_lifetime_kind)) => { + l_lifetime_kind == r_lifetime_kind + }, + _ => false, + } + }, + ( + GenericParamKind::Type { + default: l_default, + synthetic: l_synthetic, + }, + GenericParamKind::Type { + default: r_default, + synthetic: r_synthetic, + }, + ) => both(*l_default, *r_default, |l, r| self.eq_ty(l, r)) && l_synthetic == r_synthetic, + ( + GenericParamKind::Const { + ty: l_ty, + default: l_default, + }, + GenericParamKind::Const { + ty: r_ty, + default: r_default, + }, + ) => self.eq_ty(l_ty, r_ty) && both(*l_default, *r_default, |l, r| self.eq_const_arg(l, r)), _ => false, } } @@ -563,6 +751,17 @@ impl HirEqInterExpr<'_, '_, '_> { match (left.res, right.res) { (Res::Local(l), Res::Local(r)) => l == r || self.locals.get(&l) == Some(&r), (Res::Local(_), _) | (_, Res::Local(_)) => false, + (Res::Def(l_kind, l), Res::Def(r_kind, r)) + if l_kind == r_kind + && let DefKind::Const + | DefKind::Static { .. } + | DefKind::Fn + | DefKind::TyAlias + | DefKind::Use + | DefKind::Mod = l_kind => + { + (l == r || self.local_items.get(&l) == Some(&r)) && self.eq_path_segments(left.segments, right.segments) + }, _ => self.eq_path_segments(left.segments, right.segments), } } diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.rs b/tests/ui/branches_sharing_code/shared_at_bottom.rs index fa322dc28a78..a7f950b44caf 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.rs +++ b/tests/ui/branches_sharing_code/shared_at_bottom.rs @@ -300,3 +300,65 @@ fn issue15004() { //~^ branches_sharing_code }; } + +pub fn issue15347() -> isize { + if false { + static A: isize = 4; + return A; + } else { + static A: isize = 5; + return A; + } + + if false { + //~^ branches_sharing_code + type ISize = isize; + return ISize::MAX; + } else { + type ISize = isize; + return ISize::MAX; + } + + if false { + //~^ branches_sharing_code + fn foo() -> isize { + 4 + } + return foo(); + } else { + fn foo() -> isize { + 4 + } + return foo(); + } + + if false { + //~^ branches_sharing_code + use std::num::NonZeroIsize; + return NonZeroIsize::new(4).unwrap().get(); + } else { + use std::num::NonZeroIsize; + return NonZeroIsize::new(4).unwrap().get(); + } + + if false { + //~^ branches_sharing_code + const B: isize = 5; + return B; + } else { + const B: isize = 5; + return B; + } + + // Should not lint! + const A: isize = 1; + if false { + const B: isize = A; + return B; + } else { + const C: isize = A; + return C; + } + + todo!() +} diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_bottom.stderr index 1c470fb0da5e..4ff3990232a5 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -202,5 +202,73 @@ LL ~ } LL ~ 1; | -error: aborting due to 12 previous errors +error: all if blocks contain the same code at the start + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:313:5 + | +LL | / if false { +LL | | +LL | | type ISize = isize; +LL | | return ISize::MAX; + | |__________________________^ + | +help: consider moving these statements before the if + | +LL ~ type ISize = isize; +LL + return ISize::MAX; +LL + if false { + | + +error: all if blocks contain the same code at the start + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:322:5 + | +LL | / if false { +LL | | +LL | | fn foo() -> isize { +LL | | 4 +LL | | } +LL | | return foo(); + | |_____________________^ + | +help: consider moving these statements before the if + | +LL ~ fn foo() -> isize { +LL + 4 +LL + } +LL + return foo(); +LL + if false { + | + +error: all if blocks contain the same code at the start + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:335:5 + | +LL | / if false { +LL | | +LL | | use std::num::NonZeroIsize; +LL | | return NonZeroIsize::new(4).unwrap().get(); + | |___________________________________________________^ + | +help: consider moving these statements before the if + | +LL ~ use std::num::NonZeroIsize; +LL + return NonZeroIsize::new(4).unwrap().get(); +LL + if false { + | + +error: all if blocks contain the same code at the start + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:344:5 + | +LL | / if false { +LL | | +LL | | const B: isize = 5; +LL | | return B; + | |_________________^ + | +help: consider moving these statements before the if + | +LL ~ const B: isize = 5; +LL + return B; +LL + if false { + | + +error: aborting due to 16 previous errors From 1c2a0aaa313a42af4233108a9a007eae07691cb4 Mon Sep 17 00:00:00 2001 From: reucru01 Date: Thu, 6 Nov 2025 10:01:41 +0000 Subject: [PATCH 026/489] Fixes differences found between clang & rust The intrinsics test was flagging differences in aarch64_be between rust in debug and clang in O2. It was found that rust was correct in debug, but incorrect in release, and in both cases were being compared against clang in O2 which was also incorrect. The vdot intrinsics were fixed and are now correct in rust for both release and debug. However the vcmla ones could not be as the issue lies with LLVM. Both the vdot and vcmla intrinsics were added to the skiplist as clang is still incorrect for both. LLVM issue: https://github.com/llvm/llvm-project/issues/166190 --- library/stdarch/ci/intrinsic-test.sh | 2 +- .../core_arch/src/aarch64/neon/generated.rs | 24 ++-- .../src/arm_shared/neon/generated.rs | 32 +++--- .../intrinsic-test/missing_aarch64_be.txt | 105 ++++++++++++++++++ .../spec/neon/aarch64.spec.yml | 30 ++--- .../spec/neon/arm_shared.spec.yml | 36 +++--- 6 files changed, 171 insertions(+), 58 deletions(-) create mode 100644 library/stdarch/crates/intrinsic-test/missing_aarch64_be.txt diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index be63f0c0c617..a8f96897bc23 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -56,7 +56,7 @@ case ${TARGET} in aarch64_be-unknown-linux-gnu*) TEST_CPPFLAGS="-fuse-ld=lld" - TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt + TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64_be.txt TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}" : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}" diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs index 09cf3818040d..ce864cc7d907 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs @@ -9500,10 +9500,10 @@ pub fn vdivh_f16(a: f16, b: f16) -> f16 { #[unstable(feature = "stdarch_neon_dotprod", issue = "117224")] pub fn vdot_laneq_s32(a: int32x2_t, b: int8x8_t, c: int8x16_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 2); + let c: int32x4_t = vreinterpretq_s32_s8(c); unsafe { - let c: int32x4_t = transmute(c); let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vdot_s32(a, b, transmute(c)) + vdot_s32(a, b, vreinterpret_s8_s32(c)) } } #[doc = "Dot product arithmetic (indexed)"] @@ -9515,11 +9515,11 @@ pub fn vdot_laneq_s32(a: int32x2_t, b: int8x8_t, c: int8x16_t) #[unstable(feature = "stdarch_neon_dotprod", issue = "117224")] pub fn vdotq_laneq_s32(a: int32x4_t, b: int8x16_t, c: int8x16_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 2); + let c: int32x4_t = vreinterpretq_s32_s8(c); unsafe { - let c: int32x4_t = transmute(c); let c: int32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vdotq_s32(a, b, transmute(c)) + vdotq_s32(a, b, vreinterpretq_s8_s32(c)) } } #[doc = "Dot product arithmetic (indexed)"] @@ -9531,10 +9531,10 @@ pub fn vdotq_laneq_s32(a: int32x4_t, b: int8x16_t, c: int8x16_t #[unstable(feature = "stdarch_neon_dotprod", issue = "117224")] pub fn vdot_laneq_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x16_t) -> uint32x2_t { static_assert_uimm_bits!(LANE, 2); + let c: uint32x4_t = vreinterpretq_u32_u8(c); unsafe { - let c: uint32x4_t = transmute(c); let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vdot_u32(a, b, transmute(c)) + vdot_u32(a, b, vreinterpret_u8_u32(c)) } } #[doc = "Dot product arithmetic (indexed)"] @@ -9546,11 +9546,11 @@ pub fn vdot_laneq_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x16_ #[unstable(feature = "stdarch_neon_dotprod", issue = "117224")] pub fn vdotq_laneq_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x16_t) -> uint32x4_t { static_assert_uimm_bits!(LANE, 2); + let c: uint32x4_t = vreinterpretq_u32_u8(c); unsafe { - let c: uint32x4_t = transmute(c); let c: uint32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vdotq_u32(a, b, transmute(c)) + vdotq_u32(a, b, vreinterpretq_u8_u32(c)) } } #[doc = "Set all vector lanes to the same value"] @@ -28283,10 +28283,10 @@ pub fn vuqadds_s32(a: i32, b: u32) -> i32 { #[unstable(feature = "stdarch_neon_i8mm", issue = "117223")] pub fn vusdot_laneq_s32(a: int32x2_t, b: uint8x8_t, c: int8x16_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 2); + let c: int32x4_t = vreinterpretq_s32_s8(c); unsafe { - let c: int32x4_t = transmute(c); let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vusdot_s32(a, b, transmute(c)) + vusdot_s32(a, b, vreinterpret_s8_s32(c)) } } #[doc = "Dot product index form with unsigned and signed integers"] @@ -28298,11 +28298,11 @@ pub fn vusdot_laneq_s32(a: int32x2_t, b: uint8x8_t, c: int8x16_ #[unstable(feature = "stdarch_neon_i8mm", issue = "117223")] pub fn vusdotq_laneq_s32(a: int32x4_t, b: uint8x16_t, c: int8x16_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 2); + let c: int32x4_t = vreinterpretq_s32_s8(c); unsafe { - let c: int32x4_t = transmute(c); let c: int32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vusdotq_s32(a, b, transmute(c)) + vusdotq_s32(a, b, vreinterpretq_s8_s32(c)) } } #[doc = "Unzip vectors"] diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs index c1bd70175c4c..7229f33f6142 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs @@ -9201,10 +9201,10 @@ pub fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t { )] pub fn vdot_lane_s32(a: int32x2_t, b: int8x8_t, c: int8x8_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 1); + let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { - let c: int32x2_t = transmute(c); let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vdot_s32(a, b, transmute(c)) + vdot_s32(a, b, vreinterpret_s8_s32(c)) } } #[doc = "Dot product arithmetic (indexed)"] @@ -9228,11 +9228,11 @@ pub fn vdot_lane_s32(a: int32x2_t, b: int8x8_t, c: int8x8_t) -> )] pub fn vdotq_lane_s32(a: int32x4_t, b: int8x16_t, c: int8x8_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 1); + let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { - let c: int32x2_t = transmute(c); let c: int32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vdotq_s32(a, b, transmute(c)) + vdotq_s32(a, b, vreinterpretq_s8_s32(c)) } } #[doc = "Dot product arithmetic (indexed)"] @@ -9256,10 +9256,10 @@ pub fn vdotq_lane_s32(a: int32x4_t, b: int8x16_t, c: int8x8_t) )] pub fn vdot_lane_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x8_t) -> uint32x2_t { static_assert_uimm_bits!(LANE, 1); + let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { - let c: uint32x2_t = transmute(c); let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vdot_u32(a, b, transmute(c)) + vdot_u32(a, b, vreinterpret_u8_u32(c)) } } #[doc = "Dot product arithmetic (indexed)"] @@ -9283,11 +9283,11 @@ pub fn vdot_lane_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x8_t) )] pub fn vdotq_lane_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x8_t) -> uint32x4_t { static_assert_uimm_bits!(LANE, 1); + let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { - let c: uint32x2_t = transmute(c); let c: uint32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vdotq_u32(a, b, transmute(c)) + vdotq_u32(a, b, vreinterpretq_u8_u32(c)) } } #[doc = "Dot product arithmetic (vector)"] @@ -71710,10 +71710,10 @@ pub fn vsubw_u32(a: uint64x2_t, b: uint32x2_t) -> uint64x2_t { )] pub fn vsudot_lane_s32(a: int32x2_t, b: int8x8_t, c: uint8x8_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 1); + let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { - let c: uint32x2_t = transmute(c); let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vusdot_s32(a, transmute(c), b) + vusdot_s32(a, vreinterpret_u8_u32(c), b) } } #[doc = "Dot product index form with signed and unsigned integers"] @@ -71737,11 +71737,11 @@ pub fn vsudot_lane_s32(a: int32x2_t, b: int8x8_t, c: uint8x8_t) )] pub fn vsudotq_lane_s32(a: int32x4_t, b: int8x16_t, c: uint8x8_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 1); + let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { - let c: uint32x2_t = transmute(c); let c: uint32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vusdotq_s32(a, transmute(c), b) + vusdotq_s32(a, vreinterpretq_u8_u32(c), b) } } #[doc = "Table look-up"] @@ -73630,10 +73630,10 @@ pub fn vtstq_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { )] pub fn vusdot_lane_s32(a: int32x2_t, b: uint8x8_t, c: int8x8_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 1); + let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { - let c: int32x2_t = transmute(c); let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vusdot_s32(a, b, transmute(c)) + vusdot_s32(a, b, vreinterpret_s8_s32(c)) } } #[doc = "Dot product index form with unsigned and signed integers"] @@ -73657,11 +73657,11 @@ pub fn vusdot_lane_s32(a: int32x2_t, b: uint8x8_t, c: int8x8_t) )] pub fn vusdotq_lane_s32(a: int32x4_t, b: uint8x16_t, c: int8x8_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 1); + let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { - let c: int32x2_t = transmute(c); let c: int32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vusdotq_s32(a, b, transmute(c)) + vusdotq_s32(a, b, vreinterpretq_s8_s32(c)) } } #[doc = "Dot product vector form with unsigned and signed integers"] diff --git a/library/stdarch/crates/intrinsic-test/missing_aarch64_be.txt b/library/stdarch/crates/intrinsic-test/missing_aarch64_be.txt new file mode 100644 index 000000000000..28e1d9203ee5 --- /dev/null +++ b/library/stdarch/crates/intrinsic-test/missing_aarch64_be.txt @@ -0,0 +1,105 @@ +# Bad LLVM codegen for BE in O2 in clang, and release in rust (https://github.com/llvm/llvm-project/issues/166190) +vcmla_lane_f16 +vcmla_laneq_f16 +vcmla_rot180_lane_f16 +vcmla_rot180_laneq_f16 +vcmla_rot270_lane_f16 +vcmla_rot270_laneq_f16 +vcmla_rot90_lane_f16 +vcmla_rot90_laneq_f16 +vcmlaq_lane_f16 +vcmlaq_laneq_f16 +vcmlaq_laneq_f32 +vcmlaq_rot180_lane_f16 +vcmlaq_rot180_laneq_f16 +vcmlaq_rot180_laneq_f32 +vcmlaq_rot270_lane_f16 +vcmlaq_rot270_laneq_f16 +vcmlaq_rot270_laneq_f32 +vcmlaq_rot90_lane_f16 +vcmlaq_rot90_laneq_f16 +vcmlaq_rot90_laneq_f32 +# Bad codegen for BE in O2 in clang, correct in rust. Same cause as above issue. +vdot_lane_s32 +vdot_lane_u32 +vdot_laneq_s32 +vdot_laneq_u32 +vdotq_lane_s32 +vdotq_lane_u32 +vdotq_laneq_s32 +vdotq_laneq_u32 +vsudot_lane_s32 +vsudot_laneq_s32 +vsudotq_lane_s32 +vsudotq_laneq_s32 +vusdot_lane_s32 +vusdot_laneq_s32 +vusdotq_lane_s32 +vusdotq_laneq_s32 + +# Below are in common to missing_aarch64.txt + +# Not implemented in stdarch yet +vbfdot_f32 +vbfdot_lane_f32 +vbfdot_laneq_f32 +vbfdotq_f32 +vbfdotq_lane_f32 +vbfdotq_laneq_f32 +vbfmlalbq_f32 +vbfmlalbq_lane_f32 +vbfmlalbq_laneq_f32 +vbfmlaltq_f32 +vbfmlaltq_lane_f32 +vbfmlaltq_laneq_f32 +vbfmmlaq_f32 + + +# Implemented in stdarch, but missing in Clang. +vrnd32xq_f64 +vrnd32zq_f64 +vrnd64xq_f64 +vrnd64zq_f64 +vamin_f32 +vaminq_f32 +vaminq_f64 +vamax_f32 +vamaxq_f32 +vamaxq_f64 +# LLVM select error, and missing in Clang. +vrnd32x_f64 +vrnd32z_f64 +vrnd64x_f64 +vrnd64z_f64 +vluti2_lane_p16 +vluti2_lane_p8 +vluti2_lane_s16 +vluti2_lane_s8 +vluti2_lane_u16 +vluti2_lane_u8 +vluti2q_lane_p16 +vluti2q_lane_p8 +vluti2q_lane_s16 +vluti2q_lane_s8 +vluti2q_lane_u16 +vluti2q_lane_u8 +vluti4q_lane_f16_x2 +vluti4q_lane_p16_x2 +vluti4q_lane_p8 +vluti4q_lane_s16_x2 +vluti4q_lane_s8 +vluti4q_lane_u16_x2 +vluti4q_lane_u8 +vluti4q_laneq_f16_x2 +vluti4q_laneq_p16_x2 +vluti4q_laneq_p8 +vluti4q_laneq_s16_x2 +vluti4q_laneq_s8 +vluti4q_laneq_u16_x2 +vluti4q_laneq_u8 + +# Broken in Clang +vcvth_s16_f16 +# FIXME: Broken output due to missing f16 printing support in Rust +vmulh_lane_f16 +vmulh_laneq_f16 diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml index fe64f9d7869e..48c12779a8c1 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml @@ -5091,13 +5091,13 @@ intrinsics: static_defs: ["const LANE: i32"] safety: safe types: - - [int32x2_t, uint8x8_t, int8x16_t, '[LANE as u32, LANE as u32]'] - - [int32x4_t, uint8x16_t, int8x16_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]'] + - [int32x2_t, uint8x8_t, int8x16_t, '[LANE as u32, LANE as u32]',''] + - [int32x4_t, uint8x16_t, int8x16_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '2']] - - Let: [c, int32x4_t, {FnCall: [transmute, [c]]}] + - Let: [c, int32x4_t, {FnCall: ['vreinterpretq_s32_s8', [c]]}] - Let: [c, "{neon_type[0]}", {FnCall: [simd_shuffle!, [c, c, "{type[3]}"]]}] - - FnCall: ["vusdot{neon_type[0].no}", [a, b, {FnCall: [transmute, [c]]}]] + - FnCall: ["vusdot{neon_type[0].no}", [a, b, {FnCall: ['vreinterpret{type[4]}_s8_s32', [c]]}]] - name: "vsudot{neon_type[0].laneq_nox}" doc: "Dot product index form with signed and unsigned integers" @@ -5123,7 +5123,11 @@ intrinsics: - c - "{type[4]}" - FnCall: [simd_shuffle!, [c, c, "{type[3]}"]] - - FnCall: ["vusdot{neon_type[0].no}", [a, {FnCall: [transmute, [c]]}, b]] + - FnCall: + - "vusdot{neon_type[0].no}" + - - a + - FnCall: [transmute, [c]] + - b - name: "vmul{neon_type.no}" doc: Multiply @@ -6580,14 +6584,14 @@ intrinsics: - FnCall: [unstable, ['feature = "stdarch_neon_dotprod"', 'issue = "117224"']] safety: safe types: - - [int32x2_t, int8x8_t, int8x16_t, int32x4_t, '[LANE as u32, LANE as u32]'] - - [int32x4_t, int8x16_t, int8x16_t, int32x4_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]'] + - [int32x2_t, int8x8_t, int8x16_t, int32x4_t, '[LANE as u32, LANE as u32]', ''] + - [int32x4_t, int8x16_t, int8x16_t, int32x4_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '2']] - Let: - c - "{neon_type[3]}" - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpretq_{neon_type[0]}_{neon_type[1]}', [c]] - Let: - c - "{neon_type[0]}" @@ -6596,7 +6600,7 @@ intrinsics: - "vdot{neon_type[0].no}" - - a - b - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] - name: "vdot{neon_type[0].laneq_nox}" doc: Dot product arithmetic (indexed) @@ -6610,14 +6614,14 @@ intrinsics: - FnCall: [unstable, ['feature = "stdarch_neon_dotprod"', 'issue = "117224"']] safety: safe types: - - [uint32x2_t, uint8x8_t, uint8x16_t, uint32x4_t, '[LANE as u32, LANE as u32]'] - - [uint32x4_t, uint8x16_t, uint8x16_t, uint32x4_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]'] + - [uint32x2_t, uint8x8_t, uint8x16_t, uint32x4_t, '[LANE as u32, LANE as u32]',''] + - [uint32x4_t, uint8x16_t, uint8x16_t, uint32x4_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '2']] - Let: - c - "{neon_type[3]}" - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpretq_{neon_type[0]}_{neon_type[1]}', [c]] - Let: - c - "{neon_type[0]}" @@ -6626,7 +6630,7 @@ intrinsics: - "vdot{neon_type[0].no}" - - a - b - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] - name: "vmax{neon_type.no}" doc: Maximum (vector) diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml index 4816d17bd654..bb44aab66b40 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml @@ -6261,19 +6261,19 @@ intrinsics: static_defs: ["const LANE: i32"] safety: safe types: - - ['_lane_s32', int32x2_t, uint8x8_t, '[LANE as u32, LANE as u32]'] - - ['q_lane_s32', int32x4_t, uint8x16_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]'] + - ['_lane_s32', int32x2_t, uint8x8_t, '[LANE as u32, LANE as u32]',''] + - ['q_lane_s32', int32x4_t, uint8x16_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '1']] - Let: - c - int32x2_t - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret_s32_s8', [c]] - Let: - c - "{type[1]}" - FnCall: [simd_shuffle!, [c, c, "{type[3]}"]] - - FnCall: ["vusdot{neon_type[1].no}", [a, b, {FnCall: [transmute, [c]]}]] + - FnCall: ["vusdot{neon_type[1].no}", [a, b, {FnCall: ['vreinterpret{type[4]}_s8_s32', [c]]}]] - name: "vsudot{neon_type[0].lane_nox}" doc: "Dot product index form with signed and unsigned integers" @@ -6290,19 +6290,23 @@ intrinsics: static_defs: ["const LANE: i32"] safety: safe types: - - [int32x2_t, int8x8_t, uint8x8_t, '[LANE as u32, LANE as u32]', uint32x2_t] - - [int32x4_t, int8x16_t, uint8x8_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]', uint32x4_t] + - [int32x2_t, int8x8_t, uint8x8_t, '[LANE as u32, LANE as u32]', uint32x2_t,''] + - [int32x4_t, int8x16_t, uint8x8_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]', uint32x4_t,'q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '1']] - Let: - c - uint32x2_t - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret_u32_u8', [c]] - Let: - c - "{type[4]}" - FnCall: [simd_shuffle!, [c, c, "{type[3]}"]] - - FnCall: ["vusdot{neon_type[0].no}", [a, {FnCall: [transmute, [c]]}, b]] + - FnCall: + - "vusdot{neon_type[0].no}" + - - a + - FnCall: ['vreinterpret{type[5]}_u8_u32', [c]] + - b - name: "vmul{neon_type[1].no}" doc: Multiply @@ -7113,14 +7117,14 @@ intrinsics: - *neon-cfg-arm-unstable safety: safe types: - - [int32x2_t, int8x8_t, int8x8_t, int32x2_t, '[LANE as u32, LANE as u32]'] - - [int32x4_t, int8x16_t, int8x8_t, int32x2_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]'] + - [int32x2_t, int8x8_t, int8x8_t, int32x2_t, '[LANE as u32, LANE as u32]',''] + - [int32x4_t, int8x16_t, int8x8_t, int32x2_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '1']] - Let: - c - "{neon_type[3]}" - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret_{neon_type[0]}_{neon_type[1]}', [c]] - Let: - c - "{neon_type[0]}" @@ -7129,7 +7133,7 @@ intrinsics: - "vdot{neon_type[0].no}" - - a - b - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] - name: "vdot{neon_type[0].lane_nox}" doc: Dot product arithmetic (indexed) @@ -7146,14 +7150,14 @@ intrinsics: - *neon-cfg-arm-unstable safety: safe types: - - [uint32x2_t, uint8x8_t, uint8x8_t, uint32x2_t, '[LANE as u32, LANE as u32]'] - - [uint32x4_t, uint8x16_t, uint8x8_t, uint32x2_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]'] + - [uint32x2_t, uint8x8_t, uint8x8_t, uint32x2_t, '[LANE as u32, LANE as u32]',''] + - [uint32x4_t, uint8x16_t, uint8x8_t, uint32x2_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] compose: - FnCall: [static_assert_uimm_bits!, [LANE, '1']] - Let: - c - "{neon_type[3]}" - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret_{neon_type[0]}_{neon_type[1]}', [c]] - Let: - c - "{neon_type[0]}" @@ -7162,7 +7166,7 @@ intrinsics: - "vdot{neon_type[0].no}" - - a - b - - FnCall: [transmute, [c]] + - FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] - name: "vmax{neon_type.no}" doc: Maximum (vector) From 73ad94ab862c2bbb17857c3376d5628fb21dd99b Mon Sep 17 00:00:00 2001 From: reucru01 Date: Mon, 24 Nov 2025 14:34:03 +0000 Subject: [PATCH 027/489] Provides work-around for vreinterpret inline fail --- .../src/arm_shared/neon/generated.rs | 304 +++++++++++++++++- .../spec/neon/arm_shared.spec.yml | 20 +- 2 files changed, 300 insertions(+), 24 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs index 7229f33f6142..d45454c696c7 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs @@ -9183,6 +9183,7 @@ pub fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t { #[doc = "Dot product arithmetic (indexed)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdot_lane_s32)"] #[inline] +#[cfg(target_endian = "little")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[target_feature(enable = "neon,dotprod")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsdot, LANE = 0))] @@ -9201,15 +9202,48 @@ pub fn vcvtq_u32_f32(a: float32x4_t) -> uint32x4_t { )] pub fn vdot_lane_s32(a: int32x2_t, b: int8x8_t, c: int8x8_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 1); - let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { + let c: int32x2_t = transmute(c); let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vdot_s32(a, b, vreinterpret_s8_s32(c)) + vdot_s32(a, b, transmute(c)) + } +} +#[doc = "Dot product arithmetic (indexed)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdot_lane_s32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[target_feature(enable = "neon,dotprod")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsdot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(sdot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_dotprod", issue = "117224") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vdot_lane_s32(a: int32x2_t, b: int8x8_t, c: int8x8_t) -> int32x2_t { + static_assert_uimm_bits!(LANE, 1); + let a: int32x2_t = unsafe { simd_shuffle!(a, a, [1, 0]) }; + let b: int8x8_t = unsafe { simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: int8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: int32x2_t = transmute(c); + let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); + let ret_val: int32x2_t = vdot_s32(a, b, transmute(c)); + simd_shuffle!(ret_val, ret_val, [1, 0]) } } #[doc = "Dot product arithmetic (indexed)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdotq_lane_s32)"] #[inline] +#[cfg(target_endian = "little")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[target_feature(enable = "neon,dotprod")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsdot, LANE = 0))] @@ -9228,16 +9262,51 @@ pub fn vdot_lane_s32(a: int32x2_t, b: int8x8_t, c: int8x8_t) -> )] pub fn vdotq_lane_s32(a: int32x4_t, b: int8x16_t, c: int8x8_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 1); - let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { + let c: int32x2_t = transmute(c); let c: int32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vdotq_s32(a, b, vreinterpretq_s8_s32(c)) + vdotq_s32(a, b, transmute(c)) + } +} +#[doc = "Dot product arithmetic (indexed)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdotq_lane_s32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[target_feature(enable = "neon,dotprod")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsdot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(sdot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_dotprod", issue = "117224") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vdotq_lane_s32(a: int32x4_t, b: int8x16_t, c: int8x8_t) -> int32x4_t { + static_assert_uimm_bits!(LANE, 1); + let a: int32x4_t = unsafe { simd_shuffle!(a, a, [3, 2, 1, 0]) }; + let b: int8x16_t = + unsafe { simd_shuffle!(b, b, [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: int8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: int32x2_t = transmute(c); + let c: int32x4_t = + simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); + let ret_val: int32x4_t = vdotq_s32(a, b, transmute(c)); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) } } #[doc = "Dot product arithmetic (indexed)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdot_lane_u32)"] #[inline] +#[cfg(target_endian = "little")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[target_feature(enable = "neon,dotprod")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vudot, LANE = 0))] @@ -9256,15 +9325,48 @@ pub fn vdotq_lane_s32(a: int32x4_t, b: int8x16_t, c: int8x8_t) )] pub fn vdot_lane_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x8_t) -> uint32x2_t { static_assert_uimm_bits!(LANE, 1); - let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { + let c: uint32x2_t = transmute(c); let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vdot_u32(a, b, vreinterpret_u8_u32(c)) + vdot_u32(a, b, transmute(c)) + } +} +#[doc = "Dot product arithmetic (indexed)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdot_lane_u32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[target_feature(enable = "neon,dotprod")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vudot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(udot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_dotprod", issue = "117224") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vdot_lane_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x8_t) -> uint32x2_t { + static_assert_uimm_bits!(LANE, 1); + let a: uint32x2_t = unsafe { simd_shuffle!(a, a, [1, 0]) }; + let b: uint8x8_t = unsafe { simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: uint8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: uint32x2_t = transmute(c); + let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); + let ret_val: uint32x2_t = vdot_u32(a, b, transmute(c)); + simd_shuffle!(ret_val, ret_val, [1, 0]) } } #[doc = "Dot product arithmetic (indexed)"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdotq_lane_u32)"] #[inline] +#[cfg(target_endian = "little")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[target_feature(enable = "neon,dotprod")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vudot, LANE = 0))] @@ -9283,11 +9385,45 @@ pub fn vdot_lane_u32(a: uint32x2_t, b: uint8x8_t, c: uint8x8_t) )] pub fn vdotq_lane_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x8_t) -> uint32x4_t { static_assert_uimm_bits!(LANE, 1); - let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { + let c: uint32x2_t = transmute(c); let c: uint32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vdotq_u32(a, b, vreinterpretq_u8_u32(c)) + vdotq_u32(a, b, transmute(c)) + } +} +#[doc = "Dot product arithmetic (indexed)"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdotq_lane_u32)"] +#[inline] +#[cfg(target_endian = "big")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[target_feature(enable = "neon,dotprod")] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vudot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(udot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_dotprod", issue = "117224") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vdotq_lane_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x8_t) -> uint32x4_t { + static_assert_uimm_bits!(LANE, 1); + let a: uint32x4_t = unsafe { simd_shuffle!(a, a, [3, 2, 1, 0]) }; + let b: uint8x16_t = + unsafe { simd_shuffle!(b, b, [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: uint8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: uint32x2_t = transmute(c); + let c: uint32x4_t = + simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); + let ret_val: uint32x4_t = vdotq_u32(a, b, transmute(c)); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) } } #[doc = "Dot product arithmetic (vector)"] @@ -71692,6 +71828,7 @@ pub fn vsubw_u32(a: uint64x2_t, b: uint32x2_t) -> uint64x2_t { #[doc = "Dot product index form with signed and unsigned integers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsudot_lane_s32)"] #[inline] +#[cfg(target_endian = "little")] #[target_feature(enable = "neon,i8mm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsudot, LANE = 0))] @@ -71710,15 +71847,48 @@ pub fn vsubw_u32(a: uint64x2_t, b: uint32x2_t) -> uint64x2_t { )] pub fn vsudot_lane_s32(a: int32x2_t, b: int8x8_t, c: uint8x8_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 1); - let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { + let c: uint32x2_t = transmute(c); let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vusdot_s32(a, vreinterpret_u8_u32(c), b) + vusdot_s32(a, transmute(c), b) + } +} +#[doc = "Dot product index form with signed and unsigned integers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsudot_lane_s32)"] +#[inline] +#[cfg(target_endian = "big")] +#[target_feature(enable = "neon,i8mm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsudot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(sudot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_i8mm", issue = "117223") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vsudot_lane_s32(a: int32x2_t, b: int8x8_t, c: uint8x8_t) -> int32x2_t { + static_assert_uimm_bits!(LANE, 1); + let a: int32x2_t = unsafe { simd_shuffle!(a, a, [1, 0]) }; + let b: int8x8_t = unsafe { simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: uint8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: uint32x2_t = transmute(c); + let c: uint32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); + let ret_val: int32x2_t = vusdot_s32(a, transmute(c), b); + simd_shuffle!(ret_val, ret_val, [1, 0]) } } #[doc = "Dot product index form with signed and unsigned integers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsudotq_lane_s32)"] #[inline] +#[cfg(target_endian = "little")] #[target_feature(enable = "neon,i8mm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsudot, LANE = 0))] @@ -71737,11 +71907,45 @@ pub fn vsudot_lane_s32(a: int32x2_t, b: int8x8_t, c: uint8x8_t) )] pub fn vsudotq_lane_s32(a: int32x4_t, b: int8x16_t, c: uint8x8_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 1); - let c: uint32x2_t = vreinterpret_u32_u8(c); unsafe { + let c: uint32x2_t = transmute(c); let c: uint32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vusdotq_s32(a, vreinterpretq_u8_u32(c), b) + vusdotq_s32(a, transmute(c), b) + } +} +#[doc = "Dot product index form with signed and unsigned integers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vsudotq_lane_s32)"] +#[inline] +#[cfg(target_endian = "big")] +#[target_feature(enable = "neon,i8mm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vsudot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(sudot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_i8mm", issue = "117223") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vsudotq_lane_s32(a: int32x4_t, b: int8x16_t, c: uint8x8_t) -> int32x4_t { + static_assert_uimm_bits!(LANE, 1); + let a: int32x4_t = unsafe { simd_shuffle!(a, a, [3, 2, 1, 0]) }; + let b: int8x16_t = + unsafe { simd_shuffle!(b, b, [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: uint8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: uint32x2_t = transmute(c); + let c: uint32x4_t = + simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); + let ret_val: int32x4_t = vusdotq_s32(a, transmute(c), b); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) } } #[doc = "Table look-up"] @@ -73612,6 +73816,7 @@ pub fn vtstq_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { #[doc = "Dot product index form with unsigned and signed integers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vusdot_lane_s32)"] #[inline] +#[cfg(target_endian = "little")] #[target_feature(enable = "neon,i8mm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vusdot, LANE = 0))] @@ -73630,15 +73835,48 @@ pub fn vtstq_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { )] pub fn vusdot_lane_s32(a: int32x2_t, b: uint8x8_t, c: int8x8_t) -> int32x2_t { static_assert_uimm_bits!(LANE, 1); - let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { + let c: int32x2_t = transmute(c); let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); - vusdot_s32(a, b, vreinterpret_s8_s32(c)) + vusdot_s32(a, b, transmute(c)) + } +} +#[doc = "Dot product index form with unsigned and signed integers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vusdot_lane_s32)"] +#[inline] +#[cfg(target_endian = "big")] +#[target_feature(enable = "neon,i8mm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vusdot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(usdot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_i8mm", issue = "117223") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vusdot_lane_s32(a: int32x2_t, b: uint8x8_t, c: int8x8_t) -> int32x2_t { + static_assert_uimm_bits!(LANE, 1); + let a: int32x2_t = unsafe { simd_shuffle!(a, a, [1, 0]) }; + let b: uint8x8_t = unsafe { simd_shuffle!(b, b, [7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: int8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: int32x2_t = transmute(c); + let c: int32x2_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32]); + let ret_val: int32x2_t = vusdot_s32(a, b, transmute(c)); + simd_shuffle!(ret_val, ret_val, [1, 0]) } } #[doc = "Dot product index form with unsigned and signed integers"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vusdotq_lane_s32)"] #[inline] +#[cfg(target_endian = "little")] #[target_feature(enable = "neon,i8mm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vusdot, LANE = 0))] @@ -73657,11 +73895,45 @@ pub fn vusdot_lane_s32(a: int32x2_t, b: uint8x8_t, c: int8x8_t) )] pub fn vusdotq_lane_s32(a: int32x4_t, b: uint8x16_t, c: int8x8_t) -> int32x4_t { static_assert_uimm_bits!(LANE, 1); - let c: int32x2_t = vreinterpret_s32_s8(c); unsafe { + let c: int32x2_t = transmute(c); let c: int32x4_t = simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); - vusdotq_s32(a, b, vreinterpretq_s8_s32(c)) + vusdotq_s32(a, b, transmute(c)) + } +} +#[doc = "Dot product index form with unsigned and signed integers"] +#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vusdotq_lane_s32)"] +#[inline] +#[cfg(target_endian = "big")] +#[target_feature(enable = "neon,i8mm")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "v8"))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vusdot, LANE = 0))] +#[cfg_attr( + all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), + assert_instr(usdot, LANE = 0) +)] +#[rustc_legacy_const_generics(3)] +#[cfg_attr( + not(target_arch = "arm"), + unstable(feature = "stdarch_neon_i8mm", issue = "117223") +)] +#[cfg_attr( + target_arch = "arm", + unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") +)] +pub fn vusdotq_lane_s32(a: int32x4_t, b: uint8x16_t, c: int8x8_t) -> int32x4_t { + static_assert_uimm_bits!(LANE, 1); + let a: int32x4_t = unsafe { simd_shuffle!(a, a, [3, 2, 1, 0]) }; + let b: uint8x16_t = + unsafe { simd_shuffle!(b, b, [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) }; + let c: int8x8_t = unsafe { simd_shuffle!(c, c, [7, 6, 5, 4, 3, 2, 1, 0]) }; + unsafe { + let c: int32x2_t = transmute(c); + let c: int32x4_t = + simd_shuffle!(c, c, [LANE as u32, LANE as u32, LANE as u32, LANE as u32]); + let ret_val: int32x4_t = vusdotq_s32(a, b, transmute(c)); + simd_shuffle!(ret_val, ret_val, [3, 2, 1, 0]) } } #[doc = "Dot product vector form with unsigned and signed integers"] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml index bb44aab66b40..9ebdc4334c25 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml @@ -6259,6 +6259,7 @@ intrinsics: - *neon-unstable-i8mm - *neon-cfg-arm-unstable static_defs: ["const LANE: i32"] + big_endian_inverse: true # TODO: Remove this attribute, and replace transmute with vreinterpret when https://github.com/llvm/llvm-project/pull/169337 is merged, LLVM inlining issue causing assertion failure. safety: safe types: - ['_lane_s32', int32x2_t, uint8x8_t, '[LANE as u32, LANE as u32]',''] @@ -6268,12 +6269,12 @@ intrinsics: - Let: - c - int32x2_t - - FnCall: ['vreinterpret_s32_s8', [c]] + - FnCall: [transmute, [c]] #- FnCall: ['vreinterpret_s32_s8', [c]] - Let: - c - "{type[1]}" - FnCall: [simd_shuffle!, [c, c, "{type[3]}"]] - - FnCall: ["vusdot{neon_type[1].no}", [a, b, {FnCall: ['vreinterpret{type[4]}_s8_s32', [c]]}]] + - FnCall: ["vusdot{neon_type[1].no}", [a, b, {FnCall: [transmute, [c]]}]] #'vreinterpret{type[4]}_s8_s32' - name: "vsudot{neon_type[0].lane_nox}" doc: "Dot product index form with signed and unsigned integers" @@ -6288,6 +6289,7 @@ intrinsics: - *neon-unstable-i8mm - *neon-cfg-arm-unstable static_defs: ["const LANE: i32"] + big_endian_inverse: true # TODO: Remove this attribute, and replace transmute with vreinterpret when https://github.com/llvm/llvm-project/pull/169337 is merged, LLVM inlining issue causing assertion failure. safety: safe types: - [int32x2_t, int8x8_t, uint8x8_t, '[LANE as u32, LANE as u32]', uint32x2_t,''] @@ -6297,7 +6299,7 @@ intrinsics: - Let: - c - uint32x2_t - - FnCall: ['vreinterpret_u32_u8', [c]] + - FnCall: [transmute, [c]] #- FnCall: ['vreinterpret_u32_u8', [c]] - Let: - c - "{type[4]}" @@ -6305,7 +6307,7 @@ intrinsics: - FnCall: - "vusdot{neon_type[0].no}" - - a - - FnCall: ['vreinterpret{type[5]}_u8_u32', [c]] + - FnCall: [transmute, [c]] #- FnCall: ['vreinterpret{type[5]}_u8_u32', [c]] - b - name: "vmul{neon_type[1].no}" @@ -7115,6 +7117,7 @@ intrinsics: - FnCall: [rustc_legacy_const_generics, ['3']] - FnCall: [cfg_attr, [{FnCall: [not, ['target_arch = "arm"']]}, {FnCall: [unstable, ['feature = "stdarch_neon_dotprod"', 'issue = "117224"']]}]] - *neon-cfg-arm-unstable + big_endian_inverse: true # TODO: Remove this attribute, and replace transmute with vreinterpret when https://github.com/llvm/llvm-project/pull/169337 is merged, LLVM inlining issue causing assertion failure. safety: safe types: - [int32x2_t, int8x8_t, int8x8_t, int32x2_t, '[LANE as u32, LANE as u32]',''] @@ -7124,7 +7127,7 @@ intrinsics: - Let: - c - "{neon_type[3]}" - - FnCall: ['vreinterpret_{neon_type[0]}_{neon_type[1]}', [c]] + - FnCall: [transmute, [c]] - Let: - c - "{neon_type[0]}" @@ -7133,7 +7136,7 @@ intrinsics: - "vdot{neon_type[0].no}" - - a - b - - FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] + - FnCall: [transmute, [c]] - name: "vdot{neon_type[0].lane_nox}" doc: Dot product arithmetic (indexed) @@ -7149,6 +7152,7 @@ intrinsics: - FnCall: [cfg_attr, [{FnCall: [not, ['target_arch = "arm"']]}, {FnCall: [unstable, ['feature = "stdarch_neon_dotprod"', 'issue = "117224"']]}]] - *neon-cfg-arm-unstable safety: safe + big_endian_inverse: true # TODO: Remove this attribute, and replace transmute with vreinterpret when https://github.com/llvm/llvm-project/pull/169337 is merged, LLVM inlining issue causing assertion failure. types: - [uint32x2_t, uint8x8_t, uint8x8_t, uint32x2_t, '[LANE as u32, LANE as u32]',''] - [uint32x4_t, uint8x16_t, uint8x8_t, uint32x2_t, '[LANE as u32, LANE as u32, LANE as u32, LANE as u32]','q'] @@ -7157,7 +7161,7 @@ intrinsics: - Let: - c - "{neon_type[3]}" - - FnCall: ['vreinterpret_{neon_type[0]}_{neon_type[1]}', [c]] + - FnCall: [transmute, [c]] #- FnCall: ['vreinterpret_{neon_type[0]}_{neon_type[1]}', [c]] - Let: - c - "{neon_type[0]}" @@ -7166,7 +7170,7 @@ intrinsics: - "vdot{neon_type[0].no}" - - a - b - - FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] + - FnCall: [transmute, [c]] #- FnCall: ['vreinterpret{type[5]}_{neon_type[1]}_{neon_type[0]}', [c]] - name: "vmax{neon_type.no}" doc: Maximum (vector) From daa2cd340aa39099914b0459b5d3843eb9d072a4 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 27 Nov 2025 22:36:54 +0100 Subject: [PATCH 028/489] s390x: use `simd_shuffle!` macro --- .../crates/core_arch/src/s390x/vector.rs | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/s390x/vector.rs b/library/stdarch/crates/core_arch/src/s390x/vector.rs index 7208105fb872..1366b5c78273 100644 --- a/library/stdarch/crates/core_arch/src/s390x/vector.rs +++ b/library/stdarch/crates/core_arch/src/s390x/vector.rs @@ -896,7 +896,7 @@ mod sealed { #[cfg_attr(test, assert_instr(vrepb, IMM2 = 1))] unsafe fn vrepb(a: vector_signed_char) -> vector_signed_char { static_assert_uimm_bits!(IMM2, 4); - simd_shuffle(a, a, const { u32x16::from_array([IMM2; 16]) }) + simd_shuffle!(a, a, [IMM2; 16]) } #[inline] @@ -904,7 +904,7 @@ mod sealed { #[cfg_attr(test, assert_instr(vreph, IMM2 = 1))] unsafe fn vreph(a: vector_signed_short) -> vector_signed_short { static_assert_uimm_bits!(IMM2, 3); - simd_shuffle(a, a, const { u32x8::from_array([IMM2; 8]) }) + simd_shuffle!(a, a, [IMM2; 8]) } #[inline] @@ -912,7 +912,7 @@ mod sealed { #[cfg_attr(test, assert_instr(vrepf, IMM2 = 1))] unsafe fn vrepf(a: vector_signed_int) -> vector_signed_int { static_assert_uimm_bits!(IMM2, 2); - simd_shuffle(a, a, const { u32x4::from_array([IMM2; 4]) }) + simd_shuffle!(a, a, [IMM2; 4]) } #[inline] @@ -920,7 +920,7 @@ mod sealed { #[cfg_attr(test, assert_instr(vrepg, IMM2 = 1))] unsafe fn vrepg(a: vector_signed_long_long) -> vector_signed_long_long { static_assert_uimm_bits!(IMM2, 1); - simd_shuffle(a, a, const { u32x2::from_array([IMM2; 2]) }) + simd_shuffle!(a, a, [IMM2; 2]) } macro_rules! impl_vec_splat { @@ -5307,11 +5307,13 @@ pub unsafe fn vec_search_string_until_zero_cc( #[inline] #[target_feature(enable = "vector-enhancements-1")] #[unstable(feature = "stdarch_s390x", issue = "135681")] -// FIXME: this emits `vflls` where `vldeb` is expected -// #[cfg_attr(all(test, target_feature = "vector-enhancements-1"), assert_instr(vldeb))] +// NOTE: `vflls` and `vldeb` are equivalent; our disassmbler prefers vflls. +#[cfg_attr( + all(test, target_feature = "vector-enhancements-1"), + assert_instr(vflls) +)] pub unsafe fn vec_doublee(a: vector_float) -> vector_double { - let even = simd_shuffle::<_, _, f32x2>(a, a, const { u32x2::from_array([0, 2]) }); - simd_as(even) + simd_as::(simd_shuffle!(a, a, [0, 2])) } /// Vector Convert from double to float (even elements) @@ -5322,11 +5324,7 @@ pub unsafe fn vec_doublee(a: vector_float) -> vector_double { // #[cfg_attr(all(test, target_feature = "vector-enhancements-1"), assert_instr(vledb))] pub unsafe fn vec_floate(a: vector_double) -> vector_float { let truncated: f32x2 = simd_as(a); - simd_shuffle( - truncated, - truncated, - const { u32x4::from_array([0, 0, 1, 1]) }, - ) + simd_shuffle!(truncated, truncated, [0, 0, 1, 1]) } /// Vector Convert from int to float From 4c49a7a22f791fad7e3e60f2d8f3c080db3aabd4 Mon Sep 17 00:00:00 2001 From: sayantn Date: Thu, 27 Nov 2025 07:04:37 +0530 Subject: [PATCH 029/489] Refactor max/min intrinsics using a helper function --- library/stdarch/crates/core_arch/src/simd.rs | 12 +++ .../stdarch/crates/core_arch/src/x86/avx2.rs | 72 +++----------- .../crates/core_arch/src/x86/avx512bw.rs | 50 ++-------- .../crates/core_arch/src/x86/avx512f.rs | 96 ++++--------------- .../stdarch/crates/core_arch/src/x86/sse2.rs | 24 +---- .../stdarch/crates/core_arch/src/x86/sse41.rs | 48 ++-------- 6 files changed, 61 insertions(+), 241 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/simd.rs b/library/stdarch/crates/core_arch/src/simd.rs index 25834943f009..9fa8e2502265 100644 --- a/library/stdarch/crates/core_arch/src/simd.rs +++ b/library/stdarch/crates/core_arch/src/simd.rs @@ -2,6 +2,18 @@ #![allow(non_camel_case_types)] +#[inline(always)] +pub(crate) unsafe fn simd_imax(a: T, b: T) -> T { + let mask: T = crate::intrinsics::simd::simd_gt(a, b); + crate::intrinsics::simd::simd_select(mask, a, b) +} + +#[inline(always)] +pub(crate) unsafe fn simd_imin(a: T, b: T) -> T { + let mask: T = crate::intrinsics::simd::simd_lt(a, b); + crate::intrinsics::simd::simd_select(mask, a, b) +} + macro_rules! simd_ty { ($id:ident [$elem_type:ty ; $len:literal]: $($param_name:ident),*) => { #[repr(simd)] diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index 8be302cabc77..3734915b709f 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -1897,11 +1897,7 @@ pub unsafe fn _mm256_maskstore_epi64(mem_addr: *mut i64, mask: __m256i, a: __m25 #[cfg_attr(test, assert_instr(vpmaxsw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_max_epi16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i16x16(); - let b = b.as_i16x16(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i16x16(), b.as_i16x16()).as_m256i() } } /// Compares packed 32-bit integers in `a` and `b`, and returns the packed @@ -1913,11 +1909,7 @@ pub fn _mm256_max_epi16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaxsd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_max_epi32(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i32x8(); - let b = b.as_i32x8(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i32x8(), b.as_i32x8()).as_m256i() } } /// Compares packed 8-bit integers in `a` and `b`, and returns the packed @@ -1929,11 +1921,7 @@ pub fn _mm256_max_epi32(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaxsb))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_max_epi8(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i8x32(); - let b = b.as_i8x32(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i8x32(), b.as_i8x32()).as_m256i() } } /// Compares packed unsigned 16-bit integers in `a` and `b`, and returns @@ -1945,11 +1933,7 @@ pub fn _mm256_max_epi8(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaxuw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_max_epu16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u16x16(); - let b = b.as_u16x16(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u16x16(), b.as_u16x16()).as_m256i() } } /// Compares packed unsigned 32-bit integers in `a` and `b`, and returns @@ -1961,11 +1945,7 @@ pub fn _mm256_max_epu16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaxud))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_max_epu32(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u32x8(); - let b = b.as_u32x8(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u32x8(), b.as_u32x8()).as_m256i() } } /// Compares packed unsigned 8-bit integers in `a` and `b`, and returns @@ -1977,11 +1957,7 @@ pub fn _mm256_max_epu32(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaxub))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_max_epu8(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u8x32(); - let b = b.as_u8x32(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u8x32(), b.as_u8x32()).as_m256i() } } /// Compares packed 16-bit integers in `a` and `b`, and returns the packed @@ -1993,11 +1969,7 @@ pub fn _mm256_max_epu8(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpminsw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_min_epi16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i16x16(); - let b = b.as_i16x16(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i16x16(), b.as_i16x16()).as_m256i() } } /// Compares packed 32-bit integers in `a` and `b`, and returns the packed @@ -2009,11 +1981,7 @@ pub fn _mm256_min_epi16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpminsd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_min_epi32(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i32x8(); - let b = b.as_i32x8(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i32x8(), b.as_i32x8()).as_m256i() } } /// Compares packed 8-bit integers in `a` and `b`, and returns the packed @@ -2025,11 +1993,7 @@ pub fn _mm256_min_epi32(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpminsb))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_min_epi8(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i8x32(); - let b = b.as_i8x32(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i8x32(), b.as_i8x32()).as_m256i() } } /// Compares packed unsigned 16-bit integers in `a` and `b`, and returns @@ -2041,11 +2005,7 @@ pub fn _mm256_min_epi8(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpminuw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_min_epu16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u16x16(); - let b = b.as_u16x16(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u16x16(), b.as_u16x16()).as_m256i() } } /// Compares packed unsigned 32-bit integers in `a` and `b`, and returns @@ -2057,11 +2017,7 @@ pub fn _mm256_min_epu16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpminud))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_min_epu32(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u32x8(); - let b = b.as_u32x8(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u32x8(), b.as_u32x8()).as_m256i() } } /// Compares packed unsigned 8-bit integers in `a` and `b`, and returns @@ -2073,11 +2029,7 @@ pub fn _mm256_min_epu32(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpminub))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_min_epu8(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u8x32(); - let b = b.as_u8x32(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u8x32(), b.as_u8x32()).as_m256i() } } /// Creates mask from the most significant bit of each 8-bit element in `a`, diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 0e2dd3ad4068..4310c3d0ac1b 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -1743,11 +1743,7 @@ pub fn _mm_maskz_mullo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] pub fn _mm512_max_epu16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u16x32(); - let b = b.as_u16x32(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u16x32(), b.as_u16x32()).as_m512i() } } /// Compare packed unsigned 16-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -1842,11 +1838,7 @@ pub fn _mm_maskz_max_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] pub fn _mm512_max_epu8(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u8x64(); - let b = b.as_u8x64(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u8x64(), b.as_u8x64()).as_m512i() } } /// Compare packed unsigned 8-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -1941,11 +1933,7 @@ pub fn _mm_maskz_max_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] pub fn _mm512_max_epi16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i16x32(); - let b = b.as_i16x32(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i16x32(), b.as_i16x32()).as_m512i() } } /// Compare packed signed 16-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2040,11 +2028,7 @@ pub fn _mm_maskz_max_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] pub fn _mm512_max_epi8(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i8x64(); - let b = b.as_i8x64(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i8x64(), b.as_i8x64()).as_m512i() } } /// Compare packed signed 8-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2139,11 +2123,7 @@ pub fn _mm_maskz_max_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] pub fn _mm512_min_epu16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u16x32(); - let b = b.as_u16x32(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u16x32(), b.as_u16x32()).as_m512i() } } /// Compare packed unsigned 16-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2238,11 +2218,7 @@ pub fn _mm_maskz_min_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] pub fn _mm512_min_epu8(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u8x64(); - let b = b.as_u8x64(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u8x64(), b.as_u8x64()).as_m512i() } } /// Compare packed unsigned 8-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2337,11 +2313,7 @@ pub fn _mm_maskz_min_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] pub fn _mm512_min_epi16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i16x32(); - let b = b.as_i16x32(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i16x32(), b.as_i16x32()).as_m512i() } } /// Compare packed signed 16-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2436,11 +2408,7 @@ pub fn _mm_maskz_min_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] pub fn _mm512_min_epi8(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i8x64(); - let b = b.as_i8x64(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i8x64(), b.as_i8x64()).as_m512i() } } /// Compare packed signed 8-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21172,7 +21140,7 @@ mod tests { let e = _mm_set_epi8( 0, 0, 0, 0, 0, 0, 0, 0, - u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, + u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, u8::MAX as i8, ); assert_eq_m128i(r, e); diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index f7bf9178dbb9..8c57fc201161 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -2091,11 +2091,7 @@ pub fn _mm_maskz_div_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] pub fn _mm512_max_epi32(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i32x16(); - let b = b.as_i32x16(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i32x16(), b.as_i32x16()).as_m512i() } } /// Compare packed signed 32-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2190,11 +2186,7 @@ pub fn _mm_maskz_max_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] pub fn _mm512_max_epi64(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i64x8(); - let b = b.as_i64x8(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i64x8(), b.as_i64x8()).as_m512i() } } /// Compare packed signed 64-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2233,11 +2225,7 @@ pub fn _mm512_maskz_max_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] pub fn _mm256_max_epi64(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i64x4(); - let b = b.as_i64x4(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i64x4(), b.as_i64x4()).as_m256i() } } /// Compare packed signed 64-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2276,11 +2264,7 @@ pub fn _mm256_maskz_max_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] pub fn _mm_max_epi64(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i64x2(); - let b = b.as_i64x2(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i64x2(), b.as_i64x2()).as_m128i() } } /// Compare packed signed 64-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2515,11 +2499,7 @@ pub fn _mm_maskz_max_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] pub fn _mm512_max_epu32(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u32x16(); - let b = b.as_u32x16(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u32x16(), b.as_u32x16()).as_m512i() } } /// Compare packed unsigned 32-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2614,11 +2594,7 @@ pub fn _mm_maskz_max_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] pub fn _mm512_max_epu64(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u64x8(); - let b = b.as_u64x8(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u64x8(), b.as_u64x8()).as_m512i() } } /// Compare packed unsigned 64-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2657,11 +2633,7 @@ pub fn _mm512_maskz_max_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] pub fn _mm256_max_epu64(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u64x4(); - let b = b.as_u64x4(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u64x4(), b.as_u64x4()).as_m256i() } } /// Compare packed unsigned 64-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2700,11 +2672,7 @@ pub fn _mm256_maskz_max_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] pub fn _mm_max_epu64(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u64x2(); - let b = b.as_u64x2(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u64x2(), b.as_u64x2()).as_m128i() } } /// Compare packed unsigned 64-bit integers in a and b, and store packed maximum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2743,11 +2711,7 @@ pub fn _mm_maskz_max_epu64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] pub fn _mm512_min_epi32(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i32x16(); - let b = b.as_i32x16(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i32x16(), b.as_i32x16()).as_m512i() } } /// Compare packed signed 32-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2842,11 +2806,7 @@ pub fn _mm_maskz_min_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] pub fn _mm512_min_epi64(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_i64x8(); - let b = b.as_i64x8(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i64x8(), b.as_i64x8()).as_m512i() } } /// Compare packed signed 64-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2885,11 +2845,7 @@ pub fn _mm512_maskz_min_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] pub fn _mm256_min_epi64(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_i64x4(); - let b = b.as_i64x4(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i64x4(), b.as_i64x4()).as_m256i() } } /// Compare packed signed 64-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -2928,11 +2884,7 @@ pub fn _mm256_maskz_min_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] pub fn _mm_min_epi64(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i64x2(); - let b = b.as_i64x2(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i64x2(), b.as_i64x2()).as_m128i() } } /// Compare packed signed 64-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -3167,11 +3119,7 @@ pub fn _mm_maskz_min_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] pub fn _mm512_min_epu32(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u32x16(); - let b = b.as_u32x16(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u32x16(), b.as_u32x16()).as_m512i() } } /// Compare packed unsigned 32-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -3266,11 +3214,7 @@ pub fn _mm_maskz_min_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] pub fn _mm512_min_epu64(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = a.as_u64x8(); - let b = b.as_u64x8(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u64x8(), b.as_u64x8()).as_m512i() } } /// Compare packed unsigned 64-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -3309,11 +3253,7 @@ pub fn _mm512_maskz_min_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] pub fn _mm256_min_epu64(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = a.as_u64x4(); - let b = b.as_u64x4(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u64x4(), b.as_u64x4()).as_m256i() } } /// Compare packed unsigned 64-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -3352,11 +3292,7 @@ pub fn _mm256_maskz_min_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] pub fn _mm_min_epu64(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u64x2(); - let b = b.as_u64x2(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u64x2(), b.as_u64x2()).as_m128i() } } /// Compare packed unsigned 64-bit integers in a and b, and store packed minimum values in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). diff --git a/library/stdarch/crates/core_arch/src/x86/sse2.rs b/library/stdarch/crates/core_arch/src/x86/sse2.rs index 11335856fb22..93fe7a7ae3f4 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse2.rs @@ -218,11 +218,7 @@ pub fn _mm_madd_epi16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pmaxsw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_max_epi16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i16x8(); - let b = b.as_i16x8(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i16x8(), b.as_i16x8()).as_m128i() } } /// Compares packed unsigned 8-bit integers in `a` and `b`, and returns the @@ -234,11 +230,7 @@ pub fn _mm_max_epi16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pmaxub))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_max_epu8(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u8x16(); - let b = b.as_u8x16(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u8x16(), b.as_u8x16()).as_m128i() } } /// Compares packed 16-bit integers in `a` and `b`, and returns the packed @@ -250,11 +242,7 @@ pub fn _mm_max_epu8(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pminsw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_min_epi16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i16x8(); - let b = b.as_i16x8(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i16x8(), b.as_i16x8()).as_m128i() } } /// Compares packed unsigned 8-bit integers in `a` and `b`, and returns the @@ -266,11 +254,7 @@ pub fn _mm_min_epi16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pminub))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_min_epu8(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u8x16(); - let b = b.as_u8x16(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u8x16(), b.as_u8x16()).as_m128i() } } /// Multiplies the packed 16-bit integers in `a` and `b`. diff --git a/library/stdarch/crates/core_arch/src/x86/sse41.rs b/library/stdarch/crates/core_arch/src/x86/sse41.rs index f457c74aa9c1..6c16ee760065 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse41.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse41.rs @@ -312,11 +312,7 @@ pub fn _mm_insert_epi32(a: __m128i, i: i32) -> __m128i { #[cfg_attr(test, assert_instr(pmaxsb))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_max_epi8(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i8x16(); - let b = b.as_i8x16(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i8x16(), b.as_i8x16()).as_m128i() } } /// Compares packed unsigned 16-bit integers in `a` and `b`, and returns packed @@ -328,11 +324,7 @@ pub fn _mm_max_epi8(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pmaxuw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_max_epu16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u16x8(); - let b = b.as_u16x8(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u16x8(), b.as_u16x8()).as_m128i() } } /// Compares packed 32-bit integers in `a` and `b`, and returns packed maximum @@ -344,11 +336,7 @@ pub fn _mm_max_epu16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pmaxsd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_max_epi32(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i32x4(); - let b = b.as_i32x4(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_i32x4(), b.as_i32x4()).as_m128i() } } /// Compares packed unsigned 32-bit integers in `a` and `b`, and returns packed @@ -360,11 +348,7 @@ pub fn _mm_max_epi32(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pmaxud))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_max_epu32(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u32x4(); - let b = b.as_u32x4(); - transmute(simd_select::(simd_gt(a, b), a, b)) - } + unsafe { simd_imax(a.as_u32x4(), b.as_u32x4()).as_m128i() } } /// Compares packed 8-bit integers in `a` and `b` and returns packed minimum @@ -376,11 +360,7 @@ pub fn _mm_max_epu32(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pminsb))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_min_epi8(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i8x16(); - let b = b.as_i8x16(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i8x16(), b.as_i8x16()).as_m128i() } } /// Compares packed unsigned 16-bit integers in `a` and `b`, and returns packed @@ -392,11 +372,7 @@ pub fn _mm_min_epi8(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pminuw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_min_epu16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u16x8(); - let b = b.as_u16x8(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u16x8(), b.as_u16x8()).as_m128i() } } /// Compares packed 32-bit integers in `a` and `b`, and returns packed minimum @@ -408,11 +384,7 @@ pub fn _mm_min_epu16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pminsd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_min_epi32(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_i32x4(); - let b = b.as_i32x4(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_i32x4(), b.as_i32x4()).as_m128i() } } /// Compares packed unsigned 32-bit integers in `a` and `b`, and returns packed @@ -424,11 +396,7 @@ pub fn _mm_min_epi32(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pminud))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_min_epu32(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = a.as_u32x4(); - let b = b.as_u32x4(); - transmute(simd_select::(simd_lt(a, b), a, b)) - } + unsafe { simd_imin(a.as_u32x4(), b.as_u32x4()).as_m128i() } } /// Converts packed 32-bit integers from `a` and `b` to packed 16-bit integers From 98a95454b06bf3f263209bebf7bc983cd9741f45 Mon Sep 17 00:00:00 2001 From: sayantn Date: Fri, 28 Nov 2025 03:31:23 +0530 Subject: [PATCH 030/489] Use generic SIMD intrinsics for AVX512BW cvtepi --- .../crates/core_arch/src/x86/avx512bw.rs | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 4310c3d0ac1b..c7f271d22ef5 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -10735,11 +10735,11 @@ pub fn _mm_maskz_cvtepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpmovswb))] pub fn _mm512_cvtsepi16_epi8(a: __m512i) -> __m256i { unsafe { - transmute(vpmovswb( - a.as_i16x32(), - i8x32::ZERO, - 0b11111111_11111111_11111111_11111111, + simd_cast::<_, i8x32>(simd_imax( + simd_imin(a.as_i16x32(), i16x32::splat(i8::MAX as _)), + i16x32::splat(i8::MIN as _), )) + .as_m256i() } } @@ -10751,7 +10751,9 @@ pub fn _mm512_cvtsepi16_epi8(a: __m512i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] pub fn _mm512_mask_cvtsepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { - unsafe { transmute(vpmovswb(a.as_i16x32(), src.as_i8x32(), k)) } + unsafe { + simd_select_bitmask(k, _mm512_cvtsepi16_epi8(a).as_i8x32(), src.as_i8x32()).as_m256i() + } } /// Convert packed signed 16-bit integers in a to packed 8-bit integers with signed saturation, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set). @@ -10762,7 +10764,7 @@ pub fn _mm512_mask_cvtsepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] pub fn _mm512_maskz_cvtsepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { - unsafe { transmute(vpmovswb(a.as_i16x32(), i8x32::ZERO, k)) } + unsafe { simd_select_bitmask(k, _mm512_cvtsepi16_epi8(a).as_i8x32(), i8x32::ZERO).as_m256i() } } /// Convert packed signed 16-bit integers in a to packed 8-bit integers with signed saturation, and store the results in dst. @@ -10773,7 +10775,13 @@ pub fn _mm512_maskz_cvtsepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] pub fn _mm256_cvtsepi16_epi8(a: __m256i) -> __m128i { - unsafe { transmute(vpmovswb256(a.as_i16x16(), i8x16::ZERO, 0b11111111_11111111)) } + unsafe { + simd_cast::<_, i8x16>(simd_imax( + simd_imin(a.as_i16x16(), i16x16::splat(i8::MAX as _)), + i16x16::splat(i8::MIN as _), + )) + .as_m128i() + } } /// Convert packed signed 16-bit integers in a to packed 8-bit integers with signed saturation, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -10784,7 +10792,9 @@ pub fn _mm256_cvtsepi16_epi8(a: __m256i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] pub fn _mm256_mask_cvtsepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { - unsafe { transmute(vpmovswb256(a.as_i16x16(), src.as_i8x16(), k)) } + unsafe { + simd_select_bitmask(k, _mm256_cvtsepi16_epi8(a).as_i8x16(), src.as_i8x16()).as_m128i() + } } /// Convert packed signed 16-bit integers in a to packed 8-bit integers with signed saturation, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set). @@ -10795,7 +10805,7 @@ pub fn _mm256_mask_cvtsepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] pub fn _mm256_maskz_cvtsepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { - unsafe { transmute(vpmovswb256(a.as_i16x16(), i8x16::ZERO, k)) } + unsafe { simd_select_bitmask(k, _mm256_cvtsepi16_epi8(a).as_i8x16(), i8x16::ZERO).as_m128i() } } /// Convert packed signed 16-bit integers in a to packed 8-bit integers with signed saturation, and store the results in dst. @@ -10840,11 +10850,7 @@ pub fn _mm_maskz_cvtsepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpmovuswb))] pub fn _mm512_cvtusepi16_epi8(a: __m512i) -> __m256i { unsafe { - transmute(vpmovuswb( - a.as_u16x32(), - u8x32::ZERO, - 0b11111111_11111111_11111111_11111111, - )) + simd_cast::<_, u8x32>(simd_imin(a.as_u16x32(), u16x32::splat(u8::MAX as _))).as_m256i() } } @@ -10856,7 +10862,9 @@ pub fn _mm512_cvtusepi16_epi8(a: __m512i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] pub fn _mm512_mask_cvtusepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { - unsafe { transmute(vpmovuswb(a.as_u16x32(), src.as_u8x32(), k)) } + unsafe { + simd_select_bitmask(k, _mm512_cvtusepi16_epi8(a).as_u8x32(), src.as_u8x32()).as_m256i() + } } /// Convert packed unsigned 16-bit integers in a to packed unsigned 8-bit integers with unsigned saturation, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set). @@ -10867,7 +10875,7 @@ pub fn _mm512_mask_cvtusepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] pub fn _mm512_maskz_cvtusepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { - unsafe { transmute(vpmovuswb(a.as_u16x32(), u8x32::ZERO, k)) } + unsafe { simd_select_bitmask(k, _mm512_cvtusepi16_epi8(a).as_u8x32(), u8x32::ZERO).as_m256i() } } /// Convert packed unsigned 16-bit integers in a to packed unsigned 8-bit integers with unsigned saturation, and store the results in dst. @@ -10879,11 +10887,7 @@ pub fn _mm512_maskz_cvtusepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { #[cfg_attr(test, assert_instr(vpmovuswb))] pub fn _mm256_cvtusepi16_epi8(a: __m256i) -> __m128i { unsafe { - transmute(vpmovuswb256( - a.as_u16x16(), - u8x16::ZERO, - 0b11111111_11111111, - )) + simd_cast::<_, u8x16>(simd_imin(a.as_u16x16(), u16x16::splat(u8::MAX as _))).as_m128i() } } @@ -10895,7 +10899,9 @@ pub fn _mm256_cvtusepi16_epi8(a: __m256i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] pub fn _mm256_mask_cvtusepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { - unsafe { transmute(vpmovuswb256(a.as_u16x16(), src.as_u8x16(), k)) } + unsafe { + simd_select_bitmask(k, _mm256_cvtusepi16_epi8(a).as_u8x16(), src.as_u8x16()).as_m128i() + } } /// Convert packed unsigned 16-bit integers in a to packed unsigned 8-bit integers with unsigned saturation, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set). @@ -10906,7 +10912,7 @@ pub fn _mm256_mask_cvtusepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] pub fn _mm256_maskz_cvtusepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { - unsafe { transmute(vpmovuswb256(a.as_u16x16(), u8x16::ZERO, k)) } + unsafe { simd_select_bitmask(k, _mm256_cvtusepi16_epi8(a).as_u8x16(), u8x16::ZERO).as_m128i() } } /// Convert packed unsigned 16-bit integers in a to packed unsigned 8-bit integers with unsigned saturation, and store the results in dst. @@ -11592,7 +11598,9 @@ pub unsafe fn _mm_mask_cvtsepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] pub unsafe fn _mm512_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask32, a: __m512i) { - vpmovwbmem(mem_addr, a.as_i16x32(), k); + let result = _mm512_cvtepi16_epi8(a).as_i8x32(); + let mask = simd_select_bitmask(k, i8x32::splat(!0), i8x32::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, result); } /// Convert packed 16-bit integers in a to packed 8-bit integers with truncation, and store the active results (those with their respective bit set in writemask k) to unaligned memory at base_addr. @@ -11603,7 +11611,9 @@ pub unsafe fn _mm512_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask32, #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] pub unsafe fn _mm256_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask16, a: __m256i) { - vpmovwbmem256(mem_addr, a.as_i16x16(), k); + let result = _mm256_cvtepi16_epi8(a).as_i8x16(); + let mask = simd_select_bitmask(k, i8x16::splat(!0), i8x16::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, result); } /// Convert packed 16-bit integers in a to packed 8-bit integers with truncation, and store the active results (those with their respective bit set in writemask k) to unaligned memory at base_addr. @@ -11614,7 +11624,13 @@ pub unsafe fn _mm256_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask16, #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] pub unsafe fn _mm_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: __m128i) { - vpmovwbmem128(mem_addr, a.as_i16x8(), k); + let result: i8x8 = simd_shuffle!( + _mm_cvtepi16_epi8(a).as_i8x16(), + i8x16::ZERO, + [0, 1, 2, 3, 4, 5, 6, 7] + ); + let mask = simd_select_bitmask(k, i8x8::splat(!0), i8x8::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, result); } /// Convert packed unsigned 16-bit integers in a to packed unsigned 8-bit integers with unsigned saturation, and store the active results (those with their respective bit set in writemask k) to unaligned memory at base_addr. @@ -11703,17 +11719,9 @@ unsafe extern "C" { #[link_name = "llvm.x86.avx512.dbpsadbw.128"] fn vdbpsadbw128(a: u8x16, b: u8x16, imm8: i32) -> u16x8; - #[link_name = "llvm.x86.avx512.mask.pmovs.wb.512"] - fn vpmovswb(a: i16x32, src: i8x32, mask: u32) -> i8x32; - #[link_name = "llvm.x86.avx512.mask.pmovs.wb.256"] - fn vpmovswb256(a: i16x16, src: i8x16, mask: u16) -> i8x16; #[link_name = "llvm.x86.avx512.mask.pmovs.wb.128"] fn vpmovswb128(a: i16x8, src: i8x16, mask: u8) -> i8x16; - #[link_name = "llvm.x86.avx512.mask.pmovus.wb.512"] - fn vpmovuswb(a: u16x32, src: u8x32, mask: u32) -> u8x32; - #[link_name = "llvm.x86.avx512.mask.pmovus.wb.256"] - fn vpmovuswb256(a: u16x16, src: u8x16, mask: u16) -> u8x16; #[link_name = "llvm.x86.avx512.mask.pmovus.wb.128"] fn vpmovuswb128(a: u16x8, src: u8x16, mask: u8) -> u8x16; @@ -11724,13 +11732,6 @@ unsafe extern "C" { #[link_name = "llvm.x86.avx512.mask.pmovs.wb.mem.128"] fn vpmovswbmem128(mem_addr: *mut i8, a: i16x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.pmov.wb.mem.512"] - fn vpmovwbmem(mem_addr: *mut i8, a: i16x32, mask: u32); - #[link_name = "llvm.x86.avx512.mask.pmov.wb.mem.256"] - fn vpmovwbmem256(mem_addr: *mut i8, a: i16x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.pmov.wb.mem.128"] - fn vpmovwbmem128(mem_addr: *mut i8, a: i16x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.pmovus.wb.mem.512"] fn vpmovuswbmem(mem_addr: *mut i8, a: i16x32, mask: u32); #[link_name = "llvm.x86.avx512.mask.pmovus.wb.mem.256"] From 4054d07d38c7c8cdbdc2604cf6268fa52dde0165 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:55:38 +0000 Subject: [PATCH 031/489] Remove -Zoom=panic There are major questions remaining about the reentrancy that this allows. It doesn't have any users on github outside of a single project that uses it in a panic=abort project to show backtraces. It can still be emulated through #[alloc_error_handler] or set_alloc_error_hook depending on if you use the standard library or not. And finally it makes it harder to do various improvements to the allocator shim. --- src/allocator.rs | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 647569694b04..1f464d7e1226 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -1,12 +1,11 @@ #[cfg(feature = "master")] use gccjit::FnAttribute; -use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; +use gccjit::{Context, FunctionType, ToRValue, Type}; use rustc_ast::expand::allocator::{ AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name, }; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; -use rustc_session::config::OomStrategy; use rustc_symbol_mangling::mangle_internal_symbol; use crate::GccContext; @@ -59,14 +58,6 @@ pub(crate) unsafe fn codegen( create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); } - create_const_value_function( - tcx, - context, - &mangle_internal_symbol(tcx, OomStrategy::SYMBOL), - i8, - context.new_rvalue_from_int(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as i32), - ); - create_wrapper_function( tcx, context, @@ -77,34 +68,6 @@ pub(crate) unsafe fn codegen( ); } -fn create_const_value_function( - tcx: TyCtxt<'_>, - context: &Context<'_>, - name: &str, - output: Type<'_>, - value: RValue<'_>, -) { - let func = context.new_function(None, FunctionType::Exported, output, &[], name, false); - - #[cfg(feature = "master")] - { - func.add_attribute(FnAttribute::Visibility(symbol_visibility_to_gcc( - tcx.sess.default_visibility(), - ))); - - // FIXME(antoyo): cg_llvm sets AlwaysInline, but AlwaysInline is different in GCC and using - // it here will causes linking errors when using LTO. - func.add_attribute(FnAttribute::Inline); - } - - if tcx.sess.must_emit_unwind_tables() { - // TODO(antoyo): emit unwind tables. - } - - let block = func.new_block("entry"); - block.end_with_return(None, value); -} - fn create_wrapper_function( tcx: TyCtxt<'_>, context: &Context<'_>, From 4c29d61ec622f9081ee4f6bbe38ee5735d4cfb22 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:55:38 +0000 Subject: [PATCH 032/489] Remove -Zoom=panic There are major questions remaining about the reentrancy that this allows. It doesn't have any users on github outside of a single project that uses it in a panic=abort project to show backtraces. It can still be emulated through #[alloc_error_handler] or set_alloc_error_hook depending on if you use the standard library or not. And finally it makes it harder to do various improvements to the allocator shim. --- src/allocator.rs | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 67b89114356b..4a9b0c0952ff 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -6,7 +6,6 @@ use rustc_ast::expand::allocator::{ AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name, }; use rustc_codegen_ssa::base::{allocator_kind_for_codegen, allocator_shim_contents}; -use rustc_session::config::OomStrategy; use rustc_symbol_mangling::mangle_internal_symbol; use crate::prelude::*; @@ -15,16 +14,11 @@ use crate::prelude::*; pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut dyn Module) -> bool { let Some(kind) = allocator_kind_for_codegen(tcx) else { return false }; let methods = allocator_shim_contents(tcx, kind); - codegen_inner(tcx, module, &methods, tcx.sess.opts.unstable_opts.oom); + codegen_inner(tcx, module, &methods); true } -fn codegen_inner( - tcx: TyCtxt<'_>, - module: &mut dyn Module, - methods: &[AllocatorMethod], - oom_strategy: OomStrategy, -) { +fn codegen_inner(tcx: TyCtxt<'_>, module: &mut dyn Module, methods: &[AllocatorMethod]) { let usize_ty = module.target_config().pointer_type(); for method in methods { @@ -65,35 +59,6 @@ fn codegen_inner( ); } - { - let sig = Signature { - call_conv: module.target_config().default_call_conv, - params: vec![], - returns: vec![AbiParam::new(types::I8)], - }; - let func_id = module - .declare_function( - &mangle_internal_symbol(tcx, OomStrategy::SYMBOL), - Linkage::Export, - &sig, - ) - .unwrap(); - let mut ctx = Context::new(); - ctx.func.signature = sig; - { - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); - - let block = bcx.create_block(); - bcx.switch_to_block(block); - let value = bcx.ins().iconst(types::I8, oom_strategy.should_panic() as i64); - bcx.ins().return_(&[value]); - bcx.seal_all_blocks(); - bcx.finalize(); - } - module.define_function(func_id, &mut ctx).unwrap(); - } - { let sig = Signature { call_conv: module.target_config().default_call_conv, From 1af6474cdfd46fb4c8cc2f5442428000bd83b9af Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sat, 29 Nov 2025 16:32:41 +0800 Subject: [PATCH 033/489] Support undotted-self for `this` param closure Using `this` instead of `self` in a closure is a common pattern Example --- ```rust struct Foo { field: i32 } impl Foo { fn foo(&mut self) { let f: fn(&mut Self) = |this| { $0 }; f(self) } } ``` **Before this PR** ```text fd self.field i32 me self.foo() fn(&mut self) lc self &mut Foo lc this &mut Foo md core sp Self Foo st Foo Foo tt Fn tt FnMut tt FnOnce bt u32 u32 ``` **After this PR** ```text fd this.field i32 me this.foo() fn(&mut self) lc self &mut Foo lc this &mut Foo md core sp Self Foo st Foo Foo tt Fn tt FnMut tt FnOnce bt u32 u32 ``` --- .../ide-completion/src/completions/dot.rs | 108 +++++++++++++++++- .../crates/ide-completion/src/context.rs | 2 +- .../ide-completion/src/context/analysis.rs | 25 +++- .../crates/ide-completion/src/render.rs | 42 +++++++ 4 files changed, 165 insertions(+), 12 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/completions/dot.rs b/src/tools/rust-analyzer/crates/ide-completion/src/completions/dot.rs index 9c2e0dcf1c62..18cfa53f8e96 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/completions/dot.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/completions/dot.rs @@ -4,6 +4,7 @@ use std::ops::ControlFlow; use hir::{Complete, Function, HasContainer, ItemContainer, MethodCandidateCallback}; use ide_db::FxHashSet; +use itertools::Either; use syntax::SmolStr; use crate::{ @@ -146,11 +147,14 @@ pub(crate) fn complete_undotted_self( _ => return, }; - let ty = self_param.ty(ctx.db); + let (param_name, ty) = match self_param { + Either::Left(self_param) => ("self", &self_param.ty(ctx.db)), + Either::Right(this_param) => ("this", this_param.ty()), + }; complete_fields( acc, ctx, - &ty, + ty, |acc, field, ty| { acc.add_field( ctx, @@ -163,15 +167,17 @@ pub(crate) fn complete_undotted_self( in_breakable: expr_ctx.in_breakable, }, }, - Some(SmolStr::new_static("self")), + Some(SmolStr::new_static(param_name)), field, &ty, ) }, - |acc, field, ty| acc.add_tuple_field(ctx, Some(SmolStr::new_static("self")), field, &ty), + |acc, field, ty| { + acc.add_tuple_field(ctx, Some(SmolStr::new_static(param_name)), field, &ty) + }, false, ); - complete_methods(ctx, &ty, &ctx.traits_in_scope(), |func| { + complete_methods(ctx, ty, &ctx.traits_in_scope(), |func| { acc.add_method( ctx, &DotAccess { @@ -184,7 +190,7 @@ pub(crate) fn complete_undotted_self( }, }, func, - Some(SmolStr::new_static("self")), + Some(SmolStr::new_static(param_name)), None, ) }); @@ -1073,6 +1079,96 @@ impl Foo { fn foo(&mut self) { $0 } }"#, ); } + #[test] + fn completes_bare_fields_and_methods_in_this_closure() { + check_no_kw( + r#" +//- minicore: fn +struct Foo { field: i32 } + +impl Foo { fn foo(&mut self) { let _: fn(&mut Self) = |this| { $0 } } }"#, + expect![[r#" + fd this.field i32 + me this.foo() fn(&mut self) + lc self &mut Foo + lc this &mut Foo + md core + sp Self Foo + st Foo Foo + tt Fn + tt FnMut + tt FnOnce + bt u32 u32 + "#]], + ); + } + + #[test] + fn completes_bare_fields_and_methods_in_other_closure() { + check_no_kw( + r#" +//- minicore: fn +struct Foo { field: i32 } + +impl Foo { fn foo(&self) { let _: fn(&Self) = |foo| { $0 } } }"#, + expect![[r#" + fd self.field i32 + me self.foo() fn(&self) + lc foo &Foo + lc self &Foo + md core + sp Self Foo + st Foo Foo + tt Fn + tt FnMut + tt FnOnce + bt u32 u32 + "#]], + ); + + check_no_kw( + r#" +//- minicore: fn +struct Foo { field: i32 } + +impl Foo { fn foo(&self) { let _: fn(&Self) = || { $0 } } }"#, + expect![[r#" + fd self.field i32 + me self.foo() fn(&self) + lc self &Foo + md core + sp Self Foo + st Foo Foo + tt Fn + tt FnMut + tt FnOnce + bt u32 u32 + "#]], + ); + + check_no_kw( + r#" +//- minicore: fn +struct Foo { field: i32 } + +impl Foo { fn foo(&self) { let _: fn(&Self, &Self) = |foo, other| { $0 } } }"#, + expect![[r#" + fd self.field i32 + me self.foo() fn(&self) + lc foo &Foo + lc other &Foo + lc self &Foo + md core + sp Self Foo + st Foo Foo + tt Fn + tt FnMut + tt FnOnce + bt u32 u32 + "#]], + ); + } + #[test] fn macro_completion_after_dot() { check_no_kw( diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context.rs index 23318e1d1991..7502026c6fc2 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context.rs @@ -157,7 +157,7 @@ pub(crate) struct PathExprCtx<'db> { pub(crate) after_amp: bool, /// The surrounding RecordExpression we are completing a functional update pub(crate) is_func_update: Option, - pub(crate) self_param: Option, + pub(crate) self_param: Option>>, pub(crate) innermost_ret_ty: Option>, pub(crate) innermost_breakable_ty: Option>, pub(crate) impl_: Option, diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs index e761da7152c6..71c64a8366a5 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs @@ -1286,10 +1286,26 @@ fn classify_name_ref<'db>( ) } }; - let find_fn_self_param = |it| match it { - ast::Item::Fn(fn_) => Some(sema.to_def(&fn_).and_then(|it| it.self_param(sema.db))), - ast::Item::MacroCall(_) => None, - _ => Some(None), + let fn_self_param = + |fn_: ast::Fn| sema.to_def(&fn_).and_then(|it| it.self_param(sema.db)); + let closure_this_param = |closure: ast::ClosureExpr| { + if closure.param_list()?.params().next()?.pat()?.syntax().text() != "this" { + return None; + } + sema.type_of_expr(&closure.into()) + .and_then(|it| it.original.as_callable(sema.db)) + .and_then(|it| it.params().into_iter().next()) + }; + let find_fn_self_param = |it: SyntaxNode| { + match_ast! { + match it { + ast::Fn(fn_) => Some(fn_self_param(fn_).map(Either::Left)), + ast::ClosureExpr(f) => closure_this_param(f).map(Either::Right).map(Some), + ast::MacroCall(_) => None, + ast::Item(_) => Some(None), + _ => None, + } + } }; match find_node_in_file_compensated(sema, original_file, &expr) { @@ -1302,7 +1318,6 @@ fn classify_name_ref<'db>( let self_param = sema .ancestors_with_macros(it.syntax().clone()) - .filter_map(ast::Item::cast) .find_map(find_fn_self_param) .flatten(); (innermost_ret_ty, self_param) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/render.rs b/src/tools/rust-analyzer/crates/ide-completion/src/render.rs index c0f09e1d950d..aa9b05ecffec 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/render.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/render.rs @@ -3239,6 +3239,48 @@ impl S { ) } + #[test] + fn field_access_includes_closure_this_param() { + check_edit( + "length", + r#" +//- minicore: fn +struct S { + length: i32 +} + +impl S { + fn pack(&mut self, f: impl FnOnce(&mut Self, i32)) { + self.length += 1; + f(self, 3); + self.length -= 1; + } + + fn some_fn(&mut self) { + self.pack(|this, n| len$0); + } +} +"#, + r#" +struct S { + length: i32 +} + +impl S { + fn pack(&mut self, f: impl FnOnce(&mut Self, i32)) { + self.length += 1; + f(self, 3); + self.length -= 1; + } + + fn some_fn(&mut self) { + self.pack(|this, n| this.length); + } +} +"#, + ) + } + #[test] fn notable_traits_method_relevance() { check_kinds( From 5a7ea1d3bffd3e3f268d3b3875d779cee8b93294 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 19 Nov 2025 14:34:00 +0100 Subject: [PATCH 034/489] Count unsafe operations only towards the innermost unsafe block Also, macro calls are counted as at most one unsafe operation. --- .../src/multiple_unsafe_ops_per_block.rs | 70 +++-- tests/ui/multiple_unsafe_ops_per_block.rs | 133 +++++++++ tests/ui/multiple_unsafe_ops_per_block.stderr | 257 ++++++++++++++---- 3 files changed, 392 insertions(+), 68 deletions(-) diff --git a/clippy_lints/src/multiple_unsafe_ops_per_block.rs b/clippy_lints/src/multiple_unsafe_ops_per_block.rs index 80cf081992cc..42dc9f2f1fa8 100644 --- a/clippy_lints/src/multiple_unsafe_ops_per_block.rs +++ b/clippy_lints/src/multiple_unsafe_ops_per_block.rs @@ -3,13 +3,14 @@ use clippy_utils::diagnostics::span_lint_and_then; use hir::def::{DefKind, Res}; use hir::{BlockCheckMode, ExprKind, QPath, UnOp}; use rustc_ast::{BorrowKind, Mutability}; +use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::intravisit::{Visitor, walk_body, walk_expr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, TyCtxt, TypeckResults}; use rustc_session::declare_lint_pass; -use rustc_span::{DesugaringKind, Span}; +use rustc_span::Span; declare_clippy_lint! { /// ### What it does @@ -56,12 +57,16 @@ declare_clippy_lint! { /// } /// ``` /// - /// ### Note + /// ### Notes /// - /// Taking a raw pointer to a union field is always safe and will - /// not be considered unsafe by this lint, even when linting code written - /// with a specified Rust version of 1.91 or earlier (which required - /// using an `unsafe` block). + /// - Unsafe operations only count towards the total for the innermost + /// enclosing `unsafe` block. + /// - Each call to a macro expanding to unsafe operations count for one + /// unsafe operation. + /// - Taking a raw pointer to a union field is always safe and will + /// not be considered unsafe by this lint, even when linting code written + /// with a specified Rust version of 1.91 or earlier (which required + /// using an `unsafe` block). #[clippy::version = "1.69.0"] pub MULTIPLE_UNSAFE_OPS_PER_BLOCK, restriction, @@ -71,10 +76,7 @@ declare_lint_pass!(MultipleUnsafeOpsPerBlock => [MULTIPLE_UNSAFE_OPS_PER_BLOCK]) impl<'tcx> LateLintPass<'tcx> for MultipleUnsafeOpsPerBlock { fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) { - if !matches!(block.rules, BlockCheckMode::UnsafeBlock(_)) - || block.span.in_external_macro(cx.tcx.sess.source_map()) - || block.span.is_desugaring(DesugaringKind::Await) - { + if !matches!(block.rules, BlockCheckMode::UnsafeBlock(_)) || block.span.from_expansion() { return; } let unsafe_ops = UnsafeExprCollector::collect_unsafe_exprs(cx, block); @@ -100,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleUnsafeOpsPerBlock { struct UnsafeExprCollector<'tcx> { tcx: TyCtxt<'tcx>, typeck_results: &'tcx TypeckResults<'tcx>, - unsafe_ops: Vec<(&'static str, Span)>, + unsafe_ops: FxHashMap, } impl<'tcx> UnsafeExprCollector<'tcx> { @@ -108,10 +110,33 @@ impl<'tcx> UnsafeExprCollector<'tcx> { let mut collector = Self { tcx: cx.tcx, typeck_results: cx.typeck_results(), - unsafe_ops: vec![], + unsafe_ops: FxHashMap::default(), }; collector.visit_block(block); - collector.unsafe_ops + #[allow( + rustc::potential_query_instability, + reason = "span ordering only needed inside the one expression being walked" + )] + let mut unsafe_ops = collector + .unsafe_ops + .into_iter() + .map(|(span, msg)| (msg, span)) + .collect::>(); + unsafe_ops.sort_unstable(); + unsafe_ops + } +} + +impl UnsafeExprCollector<'_> { + fn insert_span(&mut self, span: Span, message: &'static str) { + if span.from_expansion() { + self.unsafe_ops.insert( + span.source_callsite(), + "this macro call expands into one or more unsafe operations", + ); + } else { + self.unsafe_ops.insert(span, message); + } } } @@ -126,7 +151,10 @@ impl<'tcx> Visitor<'tcx> for UnsafeExprCollector<'tcx> { return self.visit_expr(e); }, - ExprKind::InlineAsm(_) => self.unsafe_ops.push(("inline assembly used here", expr.span)), + // Do not recurse inside an inner `unsafe` block, it will be checked on its own + ExprKind::Block(block, _) if matches!(block.rules, BlockCheckMode::UnsafeBlock(_)) => return, + + ExprKind::InlineAsm(_) => self.insert_span(expr.span, "inline assembly used here"), ExprKind::AddrOf(BorrowKind::Raw, _, mut inner) => { while let ExprKind::Field(prefix, _) = inner.kind @@ -139,7 +167,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeExprCollector<'tcx> { ExprKind::Field(e, _) => { if self.typeck_results.expr_ty(e).is_union() { - self.unsafe_ops.push(("union field access occurs here", expr.span)); + self.insert_span(expr.span, "union field access occurs here"); } }, @@ -157,12 +185,11 @@ impl<'tcx> Visitor<'tcx> for UnsafeExprCollector<'tcx> { .. }, )) => { - self.unsafe_ops - .push(("access of a mutable static occurs here", expr.span)); + self.insert_span(expr.span, "access of a mutable static occurs here"); }, ExprKind::Unary(UnOp::Deref, e) if self.typeck_results.expr_ty(e).is_raw_ptr() => { - self.unsafe_ops.push(("raw pointer dereference occurs here", expr.span)); + self.insert_span(expr.span, "raw pointer dereference occurs here"); }, ExprKind::Call(path_expr, _) => { @@ -172,7 +199,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeExprCollector<'tcx> { _ => None, }; if opt_sig.is_some_and(|sig| sig.safety().is_unsafe()) { - self.unsafe_ops.push(("unsafe function call occurs here", expr.span)); + self.insert_span(expr.span, "unsafe function call occurs here"); } }, @@ -182,7 +209,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeExprCollector<'tcx> { .type_dependent_def_id(expr.hir_id) .map(|def_id| self.tcx.fn_sig(def_id)); if opt_sig.is_some_and(|sig| sig.skip_binder().safety().is_unsafe()) { - self.unsafe_ops.push(("unsafe method call occurs here", expr.span)); + self.insert_span(expr.span, "unsafe method call occurs here"); } }, @@ -203,8 +230,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeExprCollector<'tcx> { } )) ) { - self.unsafe_ops - .push(("modification of a mutable static occurs here", expr.span)); + self.insert_span(expr.span, "modification of a mutable static occurs here"); return self.visit_expr(rhs); } }, diff --git a/tests/ui/multiple_unsafe_ops_per_block.rs b/tests/ui/multiple_unsafe_ops_per_block.rs index c1512ba3e269..0ff881472cbb 100644 --- a/tests/ui/multiple_unsafe_ops_per_block.rs +++ b/tests/ui/multiple_unsafe_ops_per_block.rs @@ -312,4 +312,137 @@ fn check_closures() { } } +fn issue16116() { + unsafe fn foo() -> u32 { + 0 + } + + // Do not lint even though `format!` expansion + // contains unsafe calls. + unsafe { + let _ = format!("{}", foo()); + } + + unsafe { + //~^ multiple_unsafe_ops_per_block + let _ = format!("{}", foo()); + let _ = format!("{}", foo()); + } + + // Do not lint: only one `assert!()` argument is unsafe + unsafe { + assert_eq!(foo(), 0, "{}", 1 + 2); + } + + // Each argument of a macro call may count as an unsafe operation. + unsafe { + //~^ multiple_unsafe_ops_per_block + assert_eq!(foo(), 0, "{}", foo()); // One unsafe operation + } + + macro_rules! twice { + ($e:expr) => {{ + $e; + $e; + }}; + } + + // Do not lint, a repeated argument used twice by a macro counts + // as at most one unsafe operation. + unsafe { + twice!(foo()); + } + + unsafe { + //~^ multiple_unsafe_ops_per_block + twice!(foo()); + twice!(foo()); + } + + unsafe { + //~^ multiple_unsafe_ops_per_block + assert_eq!(foo(), 0, "{}", 1 + 2); + assert_eq!(foo(), 0, "{}", 1 + 2); + } + + macro_rules! unsafe_twice { + ($e:expr) => { + unsafe { + $e; + $e; + } + }; + }; + + // A macro whose expansion contains unsafe blocks will not + // check inside the blocks. + unsafe { + unsafe_twice!(foo()); + } + + macro_rules! double_non_arg_unsafe { + () => {{ + _ = str::from_utf8_unchecked(&[]); + _ = str::from_utf8_unchecked(&[]); + }}; + } + + // Do not lint: each unsafe expression contained in the + // macro expansion will count towards the macro call. + unsafe { + double_non_arg_unsafe!(); + } + + unsafe { + //~^ multiple_unsafe_ops_per_block + double_non_arg_unsafe!(); + double_non_arg_unsafe!(); + } + + // Do not lint: the inner macro call counts as one unsafe op. + unsafe { + assert_eq!(double_non_arg_unsafe!(), ()); + } + + unsafe { + //~^ multiple_unsafe_ops_per_block + assert_eq!(double_non_arg_unsafe!(), ()); + assert_eq!(double_non_arg_unsafe!(), ()); + } + + unsafe { + //~^ multiple_unsafe_ops_per_block + assert_eq!((double_non_arg_unsafe!(), double_non_arg_unsafe!()), ((), ())); + } + + macro_rules! unsafe_with_arg { + ($e:expr) => {{ + _ = str::from_utf8_unchecked(&[]); + $e; + }}; + } + + // A confusing situation: the macro call counts towards two unsafe calls, + // one coming from inside the macro itself, and one coming from its argument. + // The error message may seem a bit strange as both the macro call and its + // argument will be marked as counting as unsafe ops, but a short investigation + // in those rare situations should sort it out easily. + unsafe { + //~^ multiple_unsafe_ops_per_block + unsafe_with_arg!(foo()); + } + + macro_rules! ignore { + ($e: expr) => {}; + } + + // Another surprising case is when the macro argument is not + // used in the expansion, but in this case we won't see the + // unsafe operation at all. + unsafe { + ignore!(foo()); + ignore!(foo()); + } +} + fn main() {} diff --git a/tests/ui/multiple_unsafe_ops_per_block.stderr b/tests/ui/multiple_unsafe_ops_per_block.stderr index 63f7742b734b..185225bd28c8 100644 --- a/tests/ui/multiple_unsafe_ops_per_block.stderr +++ b/tests/ui/multiple_unsafe_ops_per_block.stderr @@ -31,16 +31,16 @@ LL | | *raw_ptr(); LL | | } | |_____^ | -note: union field access occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:50:14 - | -LL | drop(u.u); - | ^^^ note: raw pointer dereference occurs here --> tests/ui/multiple_unsafe_ops_per_block.rs:51:9 | LL | *raw_ptr(); | ^^^^^^^^^^ +note: union field access occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:50:14 + | +LL | drop(u.u); + | ^^^ error: this `unsafe` block contains 3 unsafe operations, expected only one --> tests/ui/multiple_unsafe_ops_per_block.rs:56:5 @@ -58,16 +58,16 @@ note: inline assembly used here | LL | asm!("nop"); | ^^^^^^^^^^^ -note: unsafe method call occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:59:9 - | -LL | sample.not_very_safe(); - | ^^^^^^^^^^^^^^^^^^^^^^ note: modification of a mutable static occurs here --> tests/ui/multiple_unsafe_ops_per_block.rs:60:9 | LL | STATIC = 0; | ^^^^^^^^^^ +note: unsafe method call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:59:9 + | +LL | sample.not_very_safe(); + | ^^^^^^^^^^^^^^^^^^^^^^ error: this `unsafe` block contains 6 unsafe operations, expected only one --> tests/ui/multiple_unsafe_ops_per_block.rs:66:5 @@ -81,36 +81,36 @@ LL | | asm!("nop"); LL | | } | |_____^ | -note: union field access occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:68:14 - | -LL | drop(u.u); - | ^^^ note: access of a mutable static occurs here --> tests/ui/multiple_unsafe_ops_per_block.rs:69:14 | LL | drop(STATIC); | ^^^^^^ -note: unsafe method call occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:70:9 - | -LL | sample.not_very_safe(); - | ^^^^^^^^^^^^^^^^^^^^^^ -note: unsafe function call occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:71:9 - | -LL | not_very_safe(); - | ^^^^^^^^^^^^^^^ -note: raw pointer dereference occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:72:9 - | -LL | *raw_ptr(); - | ^^^^^^^^^^ note: inline assembly used here --> tests/ui/multiple_unsafe_ops_per_block.rs:73:9 | LL | asm!("nop"); | ^^^^^^^^^^^ +note: raw pointer dereference occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:72:9 + | +LL | *raw_ptr(); + | ^^^^^^^^^^ +note: union field access occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:68:14 + | +LL | drop(u.u); + | ^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:71:9 + | +LL | not_very_safe(); + | ^^^^^^^^^^^^^^^ +note: unsafe method call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:70:9 + | +LL | sample.not_very_safe(); + | ^^^^^^^^^^^^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one --> tests/ui/multiple_unsafe_ops_per_block.rs:109:5 @@ -139,16 +139,16 @@ error: this `unsafe` block contains 2 unsafe operations, expected only one LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: unsafe function call occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:118:18 - | -LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: raw pointer dereference occurs here --> tests/ui/multiple_unsafe_ops_per_block.rs:118:43 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:118:18 + | +LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one --> tests/ui/multiple_unsafe_ops_per_block.rs:139:9 @@ -224,16 +224,16 @@ LL | | foo().await; LL | | } | |_____^ | -note: unsafe function call occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:194:9 - | -LL | not_very_safe(); - | ^^^^^^^^^^^^^^^ note: modification of a mutable static occurs here --> tests/ui/multiple_unsafe_ops_per_block.rs:195:9 | LL | STATIC += 1; | ^^^^^^^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:194:9 + | +LL | not_very_safe(); + | ^^^^^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one --> tests/ui/multiple_unsafe_ops_per_block.rs:207:5 @@ -265,16 +265,16 @@ LL | | Some(foo_unchecked()).unwrap_unchecked().await; LL | | } | |_____^ | -note: unsafe method call occurs here - --> tests/ui/multiple_unsafe_ops_per_block.rs:216:9 - | -LL | Some(foo_unchecked()).unwrap_unchecked().await; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: unsafe function call occurs here --> tests/ui/multiple_unsafe_ops_per_block.rs:216:14 | LL | Some(foo_unchecked()).unwrap_unchecked().await; | ^^^^^^^^^^^^^^^ +note: unsafe method call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:216:9 + | +LL | Some(foo_unchecked()).unwrap_unchecked().await; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one --> tests/ui/multiple_unsafe_ops_per_block.rs:236:5 @@ -359,5 +359,170 @@ note: unsafe function call occurs here LL | apply(|| f(0)); | ^^^^ -error: aborting due to 16 previous errors +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:326:5 + | +LL | / unsafe { +LL | | +LL | | let _ = format!("{}", foo()); +LL | | let _ = format!("{}", foo()); +LL | | } + | |_____^ + | +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:328:31 + | +LL | let _ = format!("{}", foo()); + | ^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:329:31 + | +LL | let _ = format!("{}", foo()); + | ^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:338:5 + | +LL | / unsafe { +LL | | +LL | | assert_eq!(foo(), 0, "{}", foo()); // One unsafe operation +LL | | } + | |_____^ + | +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:340:20 + | +LL | assert_eq!(foo(), 0, "{}", foo()); // One unsafe operation + | ^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:340:36 + | +LL | assert_eq!(foo(), 0, "{}", foo()); // One unsafe operation + | ^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:356:5 + | +LL | / unsafe { +LL | | +LL | | twice!(foo()); +LL | | twice!(foo()); +LL | | } + | |_____^ + | +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:358:16 + | +LL | twice!(foo()); + | ^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:359:16 + | +LL | twice!(foo()); + | ^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:362:5 + | +LL | / unsafe { +LL | | +LL | | assert_eq!(foo(), 0, "{}", 1 + 2); +LL | | assert_eq!(foo(), 0, "{}", 1 + 2); +LL | | } + | |_____^ + | +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:364:20 + | +LL | assert_eq!(foo(), 0, "{}", 1 + 2); + | ^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:365:20 + | +LL | assert_eq!(foo(), 0, "{}", 1 + 2); + | ^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:396:5 + | +LL | / unsafe { +LL | | +LL | | double_non_arg_unsafe!(); +LL | | double_non_arg_unsafe!(); +LL | | } + | |_____^ + | +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:398:9 + | +LL | double_non_arg_unsafe!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:399:9 + | +LL | double_non_arg_unsafe!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:407:5 + | +LL | / unsafe { +LL | | +LL | | assert_eq!(double_non_arg_unsafe!(), ()); +LL | | assert_eq!(double_non_arg_unsafe!(), ()); +LL | | } + | |_____^ + | +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:409:20 + | +LL | assert_eq!(double_non_arg_unsafe!(), ()); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:410:20 + | +LL | assert_eq!(double_non_arg_unsafe!(), ()); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:413:5 + | +LL | / unsafe { +LL | | +LL | | assert_eq!((double_non_arg_unsafe!(), double_non_arg_unsafe!()), ((), ())); +LL | | } + | |_____^ + | +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:415:21 + | +LL | assert_eq!((double_non_arg_unsafe!(), double_non_arg_unsafe!()), ((), ())); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:415:47 + | +LL | assert_eq!((double_non_arg_unsafe!(), double_non_arg_unsafe!()), ((), ())); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this `unsafe` block contains 2 unsafe operations, expected only one + --> tests/ui/multiple_unsafe_ops_per_block.rs:430:5 + | +LL | / unsafe { +LL | | +LL | | unsafe_with_arg!(foo()); +LL | | } + | |_____^ + | +note: this macro call expands into one or more unsafe operations + --> tests/ui/multiple_unsafe_ops_per_block.rs:432:9 + | +LL | unsafe_with_arg!(foo()); + | ^^^^^^^^^^^^^^^^^^^^^^^ +note: unsafe function call occurs here + --> tests/ui/multiple_unsafe_ops_per_block.rs:432:26 + | +LL | unsafe_with_arg!(foo()); + | ^^^^^ + +error: aborting due to 24 previous errors From 1c89fe9d6d8e72c12ad78413465beb8470eca972 Mon Sep 17 00:00:00 2001 From: AudaciousAxiom <179637270+AudaciousAxiom@users.noreply.github.com> Date: Sat, 29 Nov 2025 10:19:56 +0100 Subject: [PATCH 035/489] Remove an unnecessary `unwrap` in `rustc_codegen_gcc` --- src/builder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index c0519f7a68e2..1787415b72e6 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -503,9 +503,9 @@ fn set_rvalue_location<'a, 'gcc, 'tcx>( bx: &mut Builder<'a, 'gcc, 'tcx>, rvalue: RValue<'gcc>, ) -> RValue<'gcc> { - if bx.location.is_some() { + if let Some(location) = bx.location { #[cfg(feature = "master")] - rvalue.set_location(bx.location.unwrap()); + rvalue.set_location(location); } rvalue } From ee84ff9fe5f28de39792f1af195e17be34ca774c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 16 Nov 2025 09:58:03 +0100 Subject: [PATCH 036/489] miri genmc: fix exit() handling --- .../rustc_const_eval/src/interpret/step.rs | 7 +- src/tools/miri/src/shims/foreign_items.rs | 2 +- src/tools/miri/tests/genmc/fail/shims/exit.rs | 9 ++ .../miri/tests/genmc/fail/shims/exit.stderr | 126 ++++++++++++++++++ 4 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 src/tools/miri/tests/genmc/fail/shims/exit.rs create mode 100644 src/tools/miri/tests/genmc/fail/shims/exit.stderr diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 88a116094758..9a4b9786eb15 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -561,8 +561,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { if fn_abi.can_unwind { unwind } else { mir::UnwindAction::Unreachable }, )?; // Sanity-check that `eval_fn_call` either pushed a new frame or - // did a jump to another block. - if self.frame_idx() == old_stack && self.frame().loc == old_loc { + // did a jump to another block. We disable the sanity check for functions that + // can't return, since Miri sometimes does have to keep the location the same + // for those (which is fine since execution will continue on a different thread). + if target.is_some() && self.frame_idx() == old_stack && self.frame().loc == old_loc + { span_bug!(terminator.source_info.span, "evaluating this call made no progress"); } } diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 440388673e7d..39b691bb97d7 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -538,7 +538,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { code, crate::concurrency::ExitType::ExitCalled, )?; - todo!(); // FIXME(genmc): Add a way to return here that is allowed to not do progress (can't use existing EmulateItemResult variants). + return interp_ok(EmulateItemResult::AlreadyJumped); } throw_machine_stop!(TerminationInfo::Exit { code, leak_check: false }); } diff --git a/src/tools/miri/tests/genmc/fail/shims/exit.rs b/src/tools/miri/tests/genmc/fail/shims/exit.rs new file mode 100644 index 000000000000..4138f4e785bb --- /dev/null +++ b/src/tools/miri/tests/genmc/fail/shims/exit.rs @@ -0,0 +1,9 @@ +//@ compile-flags: -Zmiri-genmc -Zmiri-disable-stacked-borrows + +fn main() { + std::thread::spawn(|| { + unsafe { std::hint::unreachable_unchecked() }; //~ERROR: entering unreachable code + }); + // If we exit immediately, we might entirely miss the UB in the other thread. + std::process::exit(0); +} diff --git a/src/tools/miri/tests/genmc/fail/shims/exit.stderr b/src/tools/miri/tests/genmc/fail/shims/exit.stderr new file mode 100644 index 000000000000..dead5faaa514 --- /dev/null +++ b/src/tools/miri/tests/genmc/fail/shims/exit.stderr @@ -0,0 +1,126 @@ +Running GenMC Verification... +warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures. + --> RUSTLIB/std/src/thread/mod.rs:LL:CC + | +LL | match COUNTER.compare_exchange_weak(last, id, Ordering::Relaxed, Ordering::Relaxed) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GenMC might miss possible behaviors of this code + | + = note: BACKTRACE: + = note: inside `std::thread::ThreadId::new` at RUSTLIB/std/src/thread/mod.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC + = note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC + = note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC + = note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC + = note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panicking::catch_unwind::` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC + = note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC + = note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC + +warning: GenMC currently does not model the failure ordering for `compare_exchange`. Due to success ordering 'Acquire', the failure ordering 'Relaxed' is treated like 'Acquire'. Miri with GenMC might miss bugs related to this memory access. + --> RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC + | +LL | || self + | ________________^ +LL | | .state +LL | | .compare_exchange_weak(state, state + READ_LOCKED, Acquire, Relaxed) + | |____________________________________________________________________________________^ GenMC might miss possible behaviors of this code + | + = note: BACKTRACE: + = note: inside `std::sys::sync::PLATFORM::futex::RwLock::read` at RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC + = note: inside `std::sync::RwLock::<()>::read` at RUSTLIB/std/src/sync/poison/rwlock.rs:LL:CC + = note: inside `std::sys::env::PLATFORM::env_read_lock` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC + = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC + = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC + = note: inside `std::sys::env::PLATFORM::getenv` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC + = note: inside `std::env::_var_os` at RUSTLIB/std/src/env.rs:LL:CC + = note: inside `std::env::var_os::<&str>` at RUSTLIB/std/src/env.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/thread/mod.rs:LL:CC +note: inside `main` + --> tests/genmc/fail/shims/exit.rs:LL:CC + | +LL | / std::thread::spawn(|| { +LL | | unsafe { std::hint::unreachable_unchecked() }; +LL | | }); + | |______^ + +warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures. + --> RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC + | +LL | || self + | ________________^ +LL | | .state +LL | | .compare_exchange_weak(state, state + READ_LOCKED, Acquire, Relaxed) + | |____________________________________________________________________________________^ GenMC might miss possible behaviors of this code + | + = note: BACKTRACE: + = note: inside `std::sys::sync::PLATFORM::futex::RwLock::read` at RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC + = note: inside `std::sync::RwLock::<()>::read` at RUSTLIB/std/src/sync/poison/rwlock.rs:LL:CC + = note: inside `std::sys::env::PLATFORM::env_read_lock` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC + = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC + = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC + = note: inside `std::sys::env::PLATFORM::getenv` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC + = note: inside `std::env::_var_os` at RUSTLIB/std/src/env.rs:LL:CC + = note: inside `std::env::var_os::<&str>` at RUSTLIB/std/src/env.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/thread/mod.rs:LL:CC +note: inside `main` + --> tests/genmc/fail/shims/exit.rs:LL:CC + | +LL | / std::thread::spawn(|| { +LL | | unsafe { std::hint::unreachable_unchecked() }; +LL | | }); + | |______^ + +warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures. + --> RUSTLIB/std/src/rt.rs:LL:CC + | +LL | / CLEANUP.call_once(|| unsafe { +LL | | // Flush stdout and disable buffering. +LL | | crate::io::cleanup(); +... | +LL | | }); + | |______^ GenMC might miss possible behaviors of this code + | + = note: BACKTRACE: + = note: inside `std::rt::cleanup` at RUSTLIB/std/src/rt.rs:LL:CC + = note: inside `std::process::exit` at RUSTLIB/std/src/process.rs:LL:CC +note: inside `main` + --> tests/genmc/fail/shims/exit.rs:LL:CC + | +LL | std::process::exit(0); + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: GenMC currently does not model the failure ordering for `compare_exchange`. Due to success ordering 'Acquire', the failure ordering 'Relaxed' is treated like 'Acquire'. Miri with GenMC might miss bugs related to this memory access. + --> RUSTLIB/std/src/sys/exit_guard.rs:LL:CC + | +LL | match EXITING_THREAD_ID.compare_exchange(ptr::null_mut(), this_thread_id, Acquire, Relaxed) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GenMC might miss possible behaviors of this code + | + = note: BACKTRACE: + = note: inside `std::sys::exit_guard::unique_thread_exit` at RUSTLIB/std/src/sys/exit_guard.rs:LL:CC + = note: inside `std::sys::pal::PLATFORM::os::exit` at RUSTLIB/std/src/sys/pal/PLATFORM/os.rs:LL:CC + = note: inside `std::process::exit` at RUSTLIB/std/src/process.rs:LL:CC +note: inside `main` + --> tests/genmc/fail/shims/exit.rs:LL:CC + | +LL | std::process::exit(0); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: Undefined Behavior: entering unreachable code + --> tests/genmc/fail/shims/exit.rs:LL:CC + | +LL | unsafe { std::hint::unreachable_unchecked() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +note: add `-Zmiri-genmc-print-genmc-output` to MIRIFLAGS to see the detailed GenMC error report + +error: aborting due to 1 previous error; 5 warnings emitted + From 783780c25312d0eb78511e33fa572a5c3feb8dfd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 16 Nov 2025 09:57:33 +0100 Subject: [PATCH 037/489] miri tests can always rely on CARGO_BIN_EXE_miri --- src/bootstrap/src/core/build_steps/test.rs | 1 - src/tools/miri/tests/ui.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index d888e63275cd..fbdf0adc76ac 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -679,7 +679,6 @@ impl Step for Miri { // miri tests need to know about the stage sysroot cargo.env("MIRI_SYSROOT", &miri_sysroot); cargo.env("MIRI_HOST_SYSROOT", &host_sysroot); - cargo.env("MIRI", &miri.tool_path); // Set the target. cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg()); diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 1f8d98a4d339..b7f428ff01e0 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -27,7 +27,7 @@ enum Mode { } fn miri_path() -> PathBuf { - PathBuf::from(env::var("MIRI").unwrap_or_else(|_| env!("CARGO_BIN_EXE_miri").into())) + env!("CARGO_BIN_EXE_miri").into() } // Build the shared object file for testing native function calls. From 00ee70d216dcc15e527d1d2384c8a0b4e2f1b0b8 Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 29 Nov 2025 09:20:03 +0530 Subject: [PATCH 038/489] systematically exclude svml, mmx and mpx rather than having an ad-hoc list --- .../crates/intrinsic-test/missing_x86.txt | 873 +----------------- .../src/common/intrinsic_helpers.rs | 2 +- .../crates/intrinsic-test/src/x86/compile.rs | 12 + .../crates/intrinsic-test/src/x86/config.rs | 6 - .../crates/intrinsic-test/src/x86/types.rs | 6 - .../intrinsic-test/src/x86/xml_parser.rs | 14 +- 6 files changed, 49 insertions(+), 864 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/missing_x86.txt b/library/stdarch/crates/intrinsic-test/missing_x86.txt index 58e37b92a1db..11c3eeba9063 100644 --- a/library/stdarch/crates/intrinsic-test/missing_x86.txt +++ b/library/stdarch/crates/intrinsic-test/missing_x86.txt @@ -3,17 +3,9 @@ #__bswap_64 _bswap64 -# Provides pointer to allocated memory, which is difficult to test -_mm_malloc - -# requires target feature 'waitpkg', but would be inlined into function that is compiled without support for 'waitpkg' -_tpause -_umwait - -# `use of undeclared identifier` error in Clang +# not present in Clang and Rust _bit_scan_forward _bit_scan_reverse -_bswap _castf32_u32 _castf64_u64 _castu32_f32 @@ -22,569 +14,6 @@ _lrotl _lrotr _may_i_use_cpu_feature _may_i_use_cpu_feature_ext -_mm256_acos_pd -_mm256_acos_ph -_mm256_acos_ps -_mm256_acosh_pd -_mm256_acosh_ph -_mm256_acosh_ps -_mm256_asin_pd -_mm256_asin_ph -_mm256_asin_ps -_mm256_asinh_pd -_mm256_asinh_ph -_mm256_asinh_ps -_mm256_atan_pd -_mm256_atan_ps -_mm256_atan_ph -_mm256_atan2_pd -_mm256_atan2_ph -_mm256_atan2_ps -_mm256_atanh_pd -_mm256_atanh_ph -_mm256_atanh_ps -_mm256_cbrt_pd -_mm256_cbrt_ph -_mm256_cbrt_ps -_mm256_cdfnorm_pd -_mm256_cdfnorm_ph -_mm256_cdfnorm_ps -_mm256_cdfnorminv_pd -_mm256_cdfnorminv_ph -_mm256_cdfnorminv_ps -_mm256_cexp_ps -_mm256_cos_pd -_mm256_cos_ph -_mm256_cos_ps -_mm256_cosd_pd -_mm256_cosd_ph -_mm256_cosd_ps -_mm256_cosh_pd -_mm256_cosh_ph -_mm256_cosh_ps -_mm256_csqrt_ps -_mm256_div_epi16 -_mm256_div_epi32 -_mm256_div_epi64 -_mm256_div_epi8 -_mm256_div_epu16 -_mm256_div_epu32 -_mm256_div_epu64 -_mm256_div_epu8 -_mm256_dpbssd_epi32 -_mm256_dpbssds_epi32 -_mm256_dpbsud_epi32 -_mm256_dpbsuds_epi32 -_mm256_dpbuud_epi32 -_mm256_dpbuuds_epi32 -_mm256_dpwsud_epi32 -_mm256_dpwsuds_epi32 -_mm256_dpwusd_epi32 -_mm256_dpwusds_epi32 -_mm256_dpwuud_epi32 -_mm256_dpwuuds_epi32 -_mm256_erf_pd -_mm256_erf_ps -_mm256_erfc_pd -_mm256_erfc_ph -_mm256_erfc_ps -_mm256_erfcinv_pd -_mm256_erfcinv_ph -_mm256_erfcinv_ps -_mm256_erfinv_pd -_mm256_erfinv_ph -_mm256_erfinv_ps -_mm256_exp10_pd -_mm256_exp10_ph -_mm256_exp10_ps -_mm256_exp2_pd -_mm256_exp2_ph -_mm256_exp2_ps -_mm256_exp_pd -_mm256_exp_ph -_mm256_exp_ps -_mm256_expm1_pd -_mm256_expm1_ph -_mm256_expm1_ps -_mm256_hypot_pd -_mm256_hypot_ph -_mm256_hypot_ps -_mm256_idiv_epi32 -_mm256_invcbrt_pd -_mm256_invcbrt_ph -_mm256_invcbrt_ps -_mm256_invsqrt_pd -_mm256_invsqrt_ph -_mm256_invsqrt_ps -_mm256_irem_epi32 -_mm256_log10_pd -_mm256_log10_ph -_mm256_log10_ps -_mm256_log1p_pd -_mm256_log1p_ph -_mm256_log1p_ps -_mm256_log2_pd -_mm256_log2_ph -_mm256_log2_ps -_mm256_log_pd -_mm256_log_ph -_mm256_log_ps -_mm256_logb_pd -_mm256_logb_ph -_mm256_logb_ps -_mm256_clog_ps -_mm256_madd52hi_avx_epu64 -_mm256_madd52lo_avx_epu64 -_mm256_erf_ph -_mm256_mask_reduce_add_epi16 -_mm256_mask_reduce_add_epi8 -_mm256_mask_reduce_and_epi16 -_mm256_mask_reduce_and_epi8 -_mm256_mask_reduce_max_epi16 -_mm256_mask_reduce_max_epi8 -_mm256_mask_reduce_max_epu16 -_mm256_mask_reduce_max_epu8 -_mm256_mask_reduce_min_epi16 -_mm256_mask_reduce_min_epi8 -_mm256_mask_reduce_min_epu16 -_mm256_mask_reduce_min_epu8 -_mm256_mask_reduce_mul_epi16 -_mm256_mask_reduce_mul_epi8 -_mm256_mask_reduce_or_epi16 -_mm256_mask_reduce_or_epi8 -_mm512_cosd_ph -_mm512_cosd_ps -_mm512_cosh_pd -_mm512_cosh_ph -_mm512_cosh_ps -_mm512_div_epi16 -_mm512_div_epi32 -_mm512_div_epi64 -_mm512_div_epi8 -_mm512_div_epu16 -_mm512_div_epu32 -_mm512_div_epu64 -_mm512_div_epu8 -_mm512_erf_pd -_mm512_erf_ph -_mm512_erf_ps -_mm512_erfc_pd -_mm512_erfc_ph -_mm512_erfc_ps -_mm512_erfcinv_pd -_mm512_erfcinv_ph -_mm512_erfcinv_ps -_mm512_erfinv_pd -_mm512_erfinv_ph -_mm512_erfinv_ps -_mm512_exp10_pd -_mm512_exp10_ph -_mm512_exp10_ps -_mm512_exp2_pd -_mm512_exp2_ph -_mm512_exp2_ps -_mm512_exp_pd -_mm512_exp_ph -_mm512_exp_ps -_mm512_expm1_pd -_mm512_expm1_ph -_mm512_expm1_ps -_mm512_floor_ph -_mm512_hypot_pd -_mm512_hypot_ph -_mm512_hypot_ps -_mm512_invsqrt_pd -_mm512_invsqrt_ph -_mm512_invsqrt_ps -_mm512_log10_pd -_mm512_log10_ph -_mm512_log10_ps -_mm512_log1p_pd -_mm512_log1p_ph -_mm512_log1p_ps -_mm512_log2_pd -_mm512_log2_ph -_mm512_log2_ps -_mm512_log_pd -_mm512_log_ph -_mm512_log_ps -_mm512_logb_pd -_mm512_logb_ph -_mm512_logb_ps -_mm512_mask_acos_pd -_mm512_mask_acos_ph -_mm512_mask_acos_ps -_mm512_mask_acosh_pd -_mm512_mask_acosh_ph -_mm512_mask_acosh_ps -_mm512_mask_asin_pd -_mm512_mask_asin_ph -_mm512_mask_asin_ps -_mm512_mask_asinh_pd -_mm512_mask_asinh_ph -_mm512_mask_asinh_ps -_mm512_mask_atan2_pd -_mm512_mask_atan2_ps -_mm512_mask_atan_pd -_mm512_mask_atan_ph -_mm512_mask_atan_ph -_mm512_mask_atanh_pd -_mm512_mask_atanh_ph -_mm512_mask_atanh_ps -_mm512_mask_cbrt_pd -_mm512_mask_cbrt_ph -_mm512_mask_cbrt_ps -_mm512_mask_cdfnorm_pd -_mm512_mask_cdfnorm_ph -_mm512_mask_cdfnorm_ps -_mm512_mask_cdfnorminv_pd -_mm512_mask_cdfnorminv_ph -_mm512_mask_cdfnorminv_ps -_mm512_mask_ceil_ph -_mm512_mask_cos_pd -_mm512_mask_cos_ph -_mm512_mask_cos_ps -_mm512_mask_cosd_pd -_mm512_mask_cosd_ph -_mm512_mask_cosd_ps -_mm512_mask_cosh_pd -_mm512_mask_cosh_ph -_mm512_mask_cosh_ps -_mm512_mask_atan_ps -_mm512_cosd_pd -_mm512_cos_ps -_mm512_cos_ph -_mm512_cos_pd -_mm512_mask_div_epi32 -_mm512_mask_div_epu32 -_mm512_mask_erf_pd -_mm512_mask_erf_ph -_mm512_mask_erf_ps -_mm512_mask_erfc_pd -_mm512_mask_erfc_ph -_mm512_mask_erfc_ps -_mm512_mask_erfcinv_pd -_mm512_mask_erfcinv_ph -_mm512_mask_erfcinv_ps -_mm512_mask_erfinv_pd -_mm512_mask_erfinv_ph -_mm512_mask_erfinv_ps -_mm512_mask_exp10_pd -_mm512_mask_exp10_ph -_mm512_mask_exp10_ps -_mm512_mask_exp2_pd -_mm512_mask_exp2_ph -_mm512_mask_exp2_ps -_mm512_mask_exp_pd -_mm512_mask_exp_ph -_mm512_mask_exp_ps -_mm512_mask_expm1_pd -_mm512_mask_expm1_ph -_mm512_mask_expm1_ps -_mm512_mask_floor_ph -_mm512_mask_hypot_pd -_mm512_mask_hypot_ps -_mm512_mask_invsqrt_pd -_mm512_mask_invsqrt_ph -_mm512_mask_invsqrt_ps -_mm512_mask_log10_pd -_mm512_mask_log10_ph -_mm512_mask_log10_ps -_mm512_mask_log1p_pd -_mm512_mask_log1p_ph -_mm512_mask_log1p_ps -_mm512_mask_log2_pd -_mm512_mask_log2_ph -_mm512_mask_log2_ps -_mm512_mask_log_pd -_mm512_mask_log_ph -_mm512_mask_log_ps -_mm512_mask_logb_pd -_mm512_mask_logb_ph -_mm512_mask_logb_ps -_mm512_mask_nearbyint_pd -_mm512_mask_nearbyint_ph -_mm512_mask_nearbyint_ps -_mm512_mask_pow_pd -_mm512_mask_pow_ps -_mm512_mask_recip_pd -_mm512_mask_recip_ph -_mm512_mask_recip_ps -_mm512_mask_rem_epi32 -_mm512_mask_rem_epu32 -_mm512_mask_rint_pd -_mm512_mask_rint_ph -_mm512_mask_rint_ps -_mm512_mask_sin_pd -_mm512_mask_sin_ph -_mm512_mask_sin_ps -_mm512_mask_sind_pd -_mm512_mask_sind_ph -_mm512_mask_sind_ps -_mm512_mask_sinh_pd -_mm512_mask_sinh_ph -_mm512_mask_sinh_ps -_mm512_mask_svml_round_pd -_mm512_mask_svml_round_ph -_mm512_mask_tan_pd -_mm512_mask_tan_ph -_mm512_mask_tan_ps -_mm512_mask_tand_pd -_mm512_mask_tand_ph -_mm512_mask_tand_ps -_mm512_mask_tanh_pd -_mm512_mask_tanh_ph -_mm512_mask_tanh_ps -_mm512_mask_trunc_pd -_mm512_mask_trunc_ph -_mm512_mask_trunc_ps -_mm512_nearbyint_pd -_mm512_nearbyint_ph -_mm512_nearbyint_ps -_mm512_pow_pd -_mm512_pow_ph -_mm512_pow_ps -_mm512_recip_pd -_mm512_recip_ph -_mm512_recip_ps -_mm512_rem_epi16 -_mm512_rem_epi32 -_mm512_rem_epi64 -_mm512_rem_epi8 -_mm512_rem_epu16 -_mm512_rem_epu32 -_mm512_rem_epu64 -_mm512_rem_epu8 -_mm512_rint_pd -_mm512_rint_ph -_mm512_rint_ps -_mm512_sin_pd -_mm512_sin_ph -_mm512_sin_ps -_mm512_sind_pd -_mm512_sind_ph -_mm512_sind_ps -_mm512_sinh_pd -_mm512_sinh_ph -_mm512_sinh_ps -_mm512_svml_round_pd -_mm512_svml_round_ph -_mm512_tan_pd -_mm512_tan_ph -_mm512_tan_ps -_mm512_tand_pd -_mm512_tand_ph -_mm512_tand_ps -_mm512_tanh_pd -_mm512_tanh_ph -_mm512_tanh_ps -_mm512_trunc_pd -_mm512_trunc_ph -_mm512_trunc_ps -_mm_acos_pd -_mm_acos_ph -_mm_acos_ps -_mm_acosh_pd -_mm_acosh_ph -_mm_acosh_ps -_mm_asin_pd -_mm_asin_ph -_mm_asin_ps -_mm_asinh_pd -_mm_asinh_ph -_mm_asinh_ps -_mm_atan2_pd -_mm_atan2_ph -_mm_atan2_ps -_mm_atan_pd -_mm_atan_ph -_mm_atan_ps -_mm_atanh_pd -_mm_atanh_ph -_mm_atanh_ps -_mm_cbrt_pd -_mm_cbrt_ph -_mm_cbrt_ps -_mm_cdfnorm_pd -_mm_cdfnorm_ph -_mm_cdfnorm_ps -_mm_cdfnorminv_pd -_mm_cdfnorminv_ph -_mm_cdfnorminv_ps -_mm_cexp_ps -_mm_clog_ps -_mm_cos_pd -_mm_cos_ph -_mm_cos_ps -_mm_cosd_pd -_mm_cosd_ph -_mm_cosd_ps -_mm_cosh_pd -_mm_cosh_ph -_mm_cosh_ps -_mm_csqrt_ps -_mm_cvtsd_si64x -_mm_cvtsi128_si64x -_mm_cvtsi64x_sd -_mm_cvtsi64x_si128 -_mm_cvttsd_si64x -_mm_div_epi16 -_mm_div_epi32 -_mm_div_epi64 -_mm_div_epi8 -_mm_div_epu16 -_mm_div_epu32 -_mm_div_epu64 -_mm_div_epu8 -_mm_dpbssd_epi32 -_mm_dpbssds_epi32 -_mm_dpbsud_epi32 -_mm_dpbsuds_epi32 -_mm_dpbuud_epi32 -_mm_dpbuuds_epi32 -_mm_dpwsud_epi32 -_mm_dpwsuds_epi32 -_mm_dpwusd_epi32 -_mm_dpwusds_epi32 -_mm_dpwuud_epi32 -_mm_dpwuuds_epi32 -_mm_erf_pd -_mm_erf_ph -_mm_erf_ps -_mm_erfc_pd -_mm_erfc_ph -_mm_erfc_ps -_mm_erfcinv_pd -_mm_erfcinv_ph -_mm_erfcinv_ps -_mm_erfinv_pd -_mm_erfinv_ph -_mm_erfinv_ps -_mm_exp10_pd -_mm_exp10_ph -_mm_exp10_ps -_mm_exp2_pd -_mm_exp2_ph -_mm_exp2_ps -_mm_exp_pd -_mm_exp_ph -_mm_exp_ps -_mm_expm1_pd -_mm_expm1_ph -_mm_expm1_ps -_mm_hypot_pd -_mm_hypot_ph -_mm_hypot_ps -_mm_idiv_epi32 -_mm_invcbrt_pd -_mm_invcbrt_ph -_mm_invcbrt_ps -_mm_invsqrt_pd -_mm_invsqrt_ph -_mm_invsqrt_ps -_mm_irem_epi32 -_mm_log10_pd -_mm_log10_ph -_mm_log10_ps -_mm_log1p_pd -_mm_log1p_ph -_mm_log1p_ps -_mm_log2_pd -_mm_log2_ph -_mm_log2_ps -_mm_log_pd -_mm_log_ph -_mm_log_ps -_mm_logb_pd -_mm_logb_ph -_mm_logb_ps -_mm_madd52hi_avx_epu64 -_mm_madd52lo_avx_epu64 -_mm_mask_reduce_add_epi16 -_mm_mask_reduce_add_epi8 -_mm_mask_reduce_and_epi16 -_mm_mask_reduce_and_epi8 -_mm_mask_reduce_max_epi16 -_mm_mask_reduce_max_epi8 -_mm_mask_reduce_max_epu16 -_mm_mask_reduce_max_epu8 -_mm_mask_reduce_min_epi16 -_mm_mask_reduce_min_epi8 -_mm_mask_reduce_min_epu16 -_mm_mask_reduce_min_epu8 -_mm_mask_reduce_mul_epi16 -_mm_mask_reduce_mul_epi8 -_mm_mask_reduce_or_epi16 -_mm_mask_reduce_or_epi8 -_mm_pow_pd -_mm_pow_ph -_mm_pow_ps -_mm_reduce_add_epi16 -_mm_reduce_add_epi8 -_mm_reduce_and_epi16 -_mm_reduce_and_epi8 -_mm_reduce_max_epi16 -_mm_reduce_max_epi8 -_mm_reduce_max_epu16 -_mm_reduce_max_epu8 -_mm_reduce_min_epi16 -_mm_reduce_min_epi8 -_mm_reduce_min_epu16 -_mm_reduce_min_epu8 -_mm_reduce_mul_epi16 -_mm_reduce_mul_epi8 -_mm_reduce_or_epi16 -_mm_reduce_or_epi8 -_mm_rem_epi16 -_mm_rem_epi32 -_mm_rem_epi64 -_mm_rem_epi8 -_mm_rem_epu16 -_mm_rem_epu32 -_mm_rem_epu64 -_mm_rem_epu8 -_mm_sin_pd -_mm_sin_ph -_mm_sin_ps -_mm_sind_pd -_mm_sind_ph -_mm_sind_ps -_mm_sinh_pd -_mm_sinh_ph -_mm_sinh_ps -_mm_sm3msg1_epi32 -_mm_sm3msg2_epi32 -_mm_sm3rnds2_epi32 -_mm_sm4key4_epi32 -_mm_sm4rnds4_epi32 -_mm_svml_ceil_pd -_mm_svml_ceil_ph -_mm_svml_ceil_ps -_mm_svml_floor_pd -_mm_svml_floor_ph -_mm_svml_floor_ps -_mm_svml_round_pd -_mm_svml_round_ph -_mm_svml_round_ps -_mm_svml_sqrt_pd -_mm_svml_sqrt_ph -_mm_svml_sqrt_ps -_mm_tan_pd -_mm_tan_ph -_mm_tan_ps -_mm_tand_pd -_mm_tand_ph -_mm_tand_ps -_mm_tanh_pd -_mm_tanh_ph -_mm_tanh_ps -_mm_trunc_pd -_mm_trunc_ph -_mm_trunc_ps -_mm_udiv_epi32 -_mm_urem_epi32 -_popcnt32 -_popcnt64 _rdpmc _rotl _rotl64 @@ -594,284 +23,30 @@ _rotwl _rotwr _urdmsr -# Cannot find value in this scope (in Rust testfiles) -_mm512_set1_pch -_mm_abs_pi16 -_mm_abs_pi32 -_mm_abs_pi8 -_mm_add_pi16 -_mm_add_pi32 -_mm_add_pi8 -_mm_add_si64 -_mm_adds_pi16 -_mm_adds_pi8 -_mm_adds_pu16 -_mm_adds_pu8 -_mm_alignr_pi8 -_mm_and_si64 -_mm_andnot_si64 -_mm_avg_pu16 -_mm_avg_pu8 -_mm_cmpeq_pi16 -_mm_cmpeq_pi32 -_mm_cmpeq_pi8 -_mm_cmpgt_pi16 -_mm_cmpgt_pi32 -_mm_cmpgt_pi8 -_mm_cvt_pi2ps -_mm_cvt_ps2pi -_mm_cvtm64_si64 -_mm_cvtpd_pi32 -_mm_cvtpi16_ps -_mm_cvtpi32_pd -_mm_cvtpi32_ps -_mm_cvtpi32x2_ps -_mm_cvtpi8_ps -_mm_cvtps_pi16 -_mm_cvtps_pi32 -_mm_cvtps_pi8 -_mm_cvtpu16_ps -_mm_cvtpu8_ps -_mm_cvtsi32_si64 -_mm_cvtsi64_m64 -_mm_cvtsi64_si32 -_mm_cvtt_ps2pi -_mm_cvttpd_pi32 -_mm512_cbrt_pd -_mm512_cbrt_ph -_mm512_cbrt_ps -_mm512_cdfnorm_pd -_mm512_cdfnorm_ph -_mm512_cdfnorm_ps -_mm512_cdfnorminv_pd -_mm512_cdfnorminv_ph -_mm512_cdfnorminv_ps -_mm512_ceil_pd -_mm512_ceil_ph -_mm512_ceil_ps -_mm512_floor_pd -_mm512_floor_ps -_mm512_mask_ceil_pd -_mm512_mask_ceil_ps -_mm_max_pi16 -_mm_max_pu8 -_mm_min_pi16 -_mm_min_pu8 -_mm_movemask_pi8 -_mm_movepi64_pi64 -_mm_movpi64_epi64 -_mm_mul_su32 -_mm_mulhi_pi16 -_mm_mulhi_pu16 -_mm_mulhrs_pi16 -_mm_mullo_pi16 -_mm_or_si64 -_mm_packs_pi16 -_mm_packs_pi32 -_mm_packs_pu16 -_mm_popcnt_u32 -_mm_popcnt_u64 -_mm_sad_pu8 -_mm_set1_epi64 -_mm_set1_pch -_mm_set1_pi16 -_mm_set1_pi32 -_mm_set1_pi8 -_mm_set_epi64 -_mm_set_pi16 -_mm_set_pi32 -_mm_set_pi8 -_mm_setr_epi64 -_mm_setr_pi16 -_mm_setr_pi32 -_mm_setr_pi8 -_mm_shuffle_pi16 -_mm_shuffle_pi8 -_mm_sign_pi16 -_mm_sign_pi32 -_mm_sign_pi8 -_mm_sll_pi16 -_mm_sll_pi32 -_mm_sll_si64 -_mm_slli_pi16 -_mm_slli_pi32 -_mm_slli_si64 -_mm_sra_pi16 -_mm_sra_pi32 -_mm_srai_pi16 -_mm_srai_pi32 -_mm_srl_pi16 -_mm_srl_pi32 -_mm_srl_si64 -_mm_srli_pi16 -_mm_srli_pi32 -_mm_srli_si64 -_mm_sub_pi16 -_mm_sub_pi32 -_mm_sub_pi8 -_mm_sub_si64 -_mm_subs_pi16 -_mm_subs_pi8 -_mm_subs_pu16 -_mm_subs_pu8 -_mm_unpackhi_pi16 -_mm_unpackhi_pi32 -_mm_unpackhi_pi8 -_mm_unpacklo_pi16 -_mm_unpacklo_pi32 -_mm_unpacklo_pi8 -_mm_xor_si64 -_mm256_pow_pd -_mm256_pow_ph -_mm256_pow_ps -_mm256_rem_epi16 -_mm256_rem_epi32 -_mm256_rem_epi64 -_mm256_rem_epi8 -_mm256_rem_epu16 -_mm256_rem_epu32 -_mm256_rem_epu64 -_mm256_rem_epu8 -_mm256_set1_pch -_mm256_sin_pd -_mm256_sin_ph -_mm256_sin_ps -_mm256_sind_pd -_mm256_sind_ph -_mm256_sind_ps -_mm256_sinh_pd -_mm256_sinh_ph -_mm256_sinh_ps -_mm256_svml_ceil_pd -_mm256_svml_ceil_ph -_mm256_svml_ceil_ps -_mm256_svml_floor_pd -_mm256_svml_floor_ph -_mm256_svml_floor_ps -_mm256_svml_round_pd -_mm256_svml_round_ph -_mm256_svml_round_ps -_mm256_svml_sqrt_pd -_mm256_svml_sqrt_ph -_mm256_svml_sqrt_ps -_mm256_tan_pd -_mm256_tan_ph -_mm256_tan_ps -_mm256_tand_pd -_mm256_tand_ph -_mm256_tand_ps -_mm256_tanh_pd -_mm256_tanh_ph -_mm256_tanh_ps -_mm256_trunc_pd -_mm256_trunc_ph -_mm256_trunc_ps -_mm256_udiv_epi32 -_mm256_urem_epi32 -_mm512_acos_pd -_mm512_acos_ph -_mm512_acos_ps -_mm512_acosh_pd -_mm512_acosh_ph -_mm512_acosh_ps -_mm_cvttps_pi32 -_mm_extract_pi16 -_mm_hadd_pi16 -_mm_hadd_pi32 -_mm_hadds_pi16 -_mm_hsub_pi16 -_mm_hsub_pi32 -_mm_hsubs_pi16 -_mm_insert_pi16 -_mm_madd_pi16 -_mm_maddubs_pi16 -_mm512_asin_pd -_mm512_asin_ph -_mm512_asin_ps -_mm512_asinh_pd -_mm512_asinh_ph -_mm512_asinh_ps -_mm512_atan2_pd -_mm512_atan2_ph -_mm512_atan2_ps -_mm512_atan_pd -_mm512_atan_ph -_mm512_atan_ps -_mm512_atanh_pd -_mm512_atanh_ph -_mm512_atanh_ps +# not present in Clang +_bswap +_mm_cvtsd_si64x +_mm_cvtsi128_si64x +_mm_cvtsi64x_sd +_mm_cvtsi64x_si128 +_mm_cvttsd_si64x +_popcnt32 +_popcnt64 + +# not present in Rust _cvtsh_ss _cvtss_sh -_m_from_int -_m_from_int64 -_m_packssdw -_m_packsswb -_m_packuswb -_m_paddb -_m_paddd -_m_paddsb -_m_paddsw -_m_paddusb -_m_paddusw -_m_paddw -_m_pand -_m_pandn -_m_pavgb -_m_pavgw -_m_pcmpeqb -_m_pcmpeqd -_m_pcmpeqw -_m_pcmpgtb -_m_pcmpgtd -_m_pcmpgtw -_m_pextrw -_m_pinsrw -_m_pmaddwd -_m_pmaxsw -_m_pmaxub -_m_pminsw -_m_pminub -_m_pmovmskb -_m_pmulhuw -_m_pmulhw -_m_pmullw -_m_por -_m_psadbw -_m_pshufw -_m_pslld -_m_pslldi -_m_psllq -_m_psllqi -_m_psllw -_m_psllwi -_m_psrad -_m_psradi -_m_psraw -_m_psrawi -_m_psrld -_m_psrldi -_m_psrlq -_m_psrlqi -_m_psrlw -_m_psrlwi -_m_psubb -_m_psubd -_m_psubsb -_m_psubsw -_m_psubusb -_m_psubusw -_m_psubw -_m_punpckhbw -_m_punpckhdq -_m_punpckhwd -_m_punpcklbw -_m_punpckldq -_m_punpcklwd -_m_pxor -_m_to_int -_m_to_int64 -_mm512_mask_floor_pd -_mm512_mask_floor_ps +_mm256_set1_pch +_mm512_set1_pch +_mm_malloc +_mm_popcnt_u32 +_mm_popcnt_u64 +_mm_set1_pch +_tpause +_umwait + +# IMM8 must be an even number in the range `0..=62` +_mm_sm3rnds2_epi32 # SDE ERROR: Cannot execute XGETBV with ECX != 0 _xgetbv @@ -901,4 +76,4 @@ _mm_extract_epi8 _mm_mask_cvtepi16_epi8 _mm_mask_cvtpd_epi32 _mm_mask_cvtpd_ps -_mm_ucomineq_sh \ No newline at end of file +_mm_ucomineq_sh diff --git a/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs b/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs index c2d66868ceb4..bd943c211e46 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs @@ -42,7 +42,7 @@ impl FromStr for TypeKind { "uint" | "unsigned" | "UI8" | "UI16" | "UI32" | "UI64" => Ok(Self::Int(Sign::Unsigned)), "void" => Ok(Self::Void), "MASK" => Ok(Self::Mask), - "M64" | "M128" | "M256" | "M512" => Ok(Self::Vector), + "M128" | "M256" | "M512" => Ok(Self::Vector), _ => Err(format!("Impossible to parse argument kind {s}")), } } diff --git a/library/stdarch/crates/intrinsic-test/src/x86/compile.rs b/library/stdarch/crates/intrinsic-test/src/x86/compile.rs index 60997a1278a4..65cd291b1b37 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/compile.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/compile.rs @@ -25,14 +25,26 @@ pub fn build_cpp_compilation(config: &ProcessedCli) -> Option { "-mavx512cd", "-mavx512fp16", "-msha512", + "-msm3", "-msm4", "-mavxvnni", + "-mavxvnniint8", + "-mavxneconvert", + "-mavxifma", + "-mavxvnniint16", + "-mavx512bf16", "-mavx512bitalg", "-mavx512ifma", "-mavx512vbmi", "-mavx512vbmi2", "-mavx512vnni", "-mavx512vpopcntdq", + "-mavx512vp2intersect", + "-mbmi", + "-mbmi2", + "-mgfni", + "-mvaes", + "-mvpclmulqdq", "-ferror-limit=1000", "-std=c++23", ]); diff --git a/library/stdarch/crates/intrinsic-test/src/x86/config.rs b/library/stdarch/crates/intrinsic-test/src/x86/config.rs index 7c349e448206..40607d8491d1 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/config.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/config.rs @@ -280,12 +280,6 @@ pub const PLATFORM_C_FORWARD_DECLARATIONS: &str = r#" #define _mm512_extract_intrinsic_test_epi64(m, lane) \ _mm_extract_epi64(_mm512_extracti64x2_epi64((m), (lane) / 2), (lane) % 2) - - #define _mm64_extract_intrinsic_test_epi8(m, lane) \ - ((_mm_extract_pi16((m), (lane) / 2) >> (((lane) % 2) * 8)) & 0xFF) - - #define _mm64_extract_intrinsic_test_epi32(m, lane) \ - _mm_cvtsi64_si32(_mm_srli_si64(m, (lane) * 32)) // Load f16 (__m128h) and cast to integer (__m128i) #define _mm_loadu_ph_to___m128i(mem_addr) _mm_castph_si128(_mm_loadu_ph(mem_addr)) diff --git a/library/stdarch/crates/intrinsic-test/src/x86/types.rs b/library/stdarch/crates/intrinsic-test/src/x86/types.rs index 87932fcb3ec7..d6cb938096a1 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/types.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/types.rs @@ -115,9 +115,6 @@ impl IntrinsicTypeDefinition for X86IntrinsicType { // if "type" starts with __m{h/i/}, // then use either _mm_set1_epi64, // _mm256_set1_epi64 or _mm512_set1_epi64 - if type_value.contains("__m64") { - return String::from("*(__m64*)"); - } let type_val_filtered = type_value .chars() @@ -262,9 +259,6 @@ impl IntrinsicTypeDefinition for X86IntrinsicType { (Some(16), Some(512)) => String::from("(uint16_t)_mm512_extract_intrinsic_test_epi16"), (Some(32), Some(512)) => String::from("(uint32_t)_mm512_extract_intrinsic_test_epi32"), (Some(64), Some(512)) => String::from("(uint64_t)_mm512_extract_intrinsic_test_epi64"), - (Some(8), Some(64)) => String::from("(uint8_t)_mm64_extract_intrinsic_test_epi8"), - (Some(16), Some(64)) => String::from("(uint16_t)_mm_extract_pi16"), - (Some(32), Some(64)) => String::from("(uint32_t)_mm64_extract_intrinsic_test_epi32"), _ => unreachable!( "invalid length for vector argument: {:?}, {:?}", self.bit_len, self.simd_len diff --git a/library/stdarch/crates/intrinsic-test/src/x86/xml_parser.rs b/library/stdarch/crates/intrinsic-test/src/x86/xml_parser.rs index af85118b8aac..681b1a3c5274 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/xml_parser.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/xml_parser.rs @@ -30,8 +30,8 @@ struct XMLIntrinsic { pub return_data: Parameter, #[serde(rename = "@name")] pub name: String, - // #[serde(rename = "@tech")] - // tech: String, + #[serde(rename = "@tech")] + tech: String, #[serde(rename = "CPUID", default)] cpuid: Vec, #[serde(rename = "parameter", default)] @@ -65,6 +65,16 @@ pub fn get_xml_intrinsics( let parsed_intrinsics: Vec> = data .intrinsics .into_iter() + .filter(|intrinsic| { + intrinsic.tech != "SVML" + && intrinsic.tech != "MMX" + && !intrinsic.cpuid.contains(&"MPX".to_string()) + && intrinsic.return_data.type_data != "__m64" + && !intrinsic + .parameters + .iter() + .any(|param| param.type_data.contains("__m64")) + }) .filter_map(|intr| { // Some(xml_to_intrinsic(intr, target).expect("Couldn't parse XML properly!")) xml_to_intrinsic(intr).ok() From 0c0de0742a168294b3b0d3d93ab86ce1c9417cef Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 29 Nov 2025 10:30:15 +0530 Subject: [PATCH 039/489] Format `f16` values normally, rather than use the bit patterns --- .../crates/intrinsic-test/src/arm/config.rs | 93 +------------------ .../src/common/intrinsic_helpers.rs | 13 +-- .../crates/intrinsic-test/src/x86/config.rs | 73 +-------------- .../crates/intrinsic-test/src/x86/types.rs | 44 +++------ 4 files changed, 20 insertions(+), 203 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/arm/config.rs b/library/stdarch/crates/intrinsic-test/src/arm/config.rs index a63464596915..85cb21c2d6c4 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/config.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/config.rs @@ -38,11 +38,7 @@ std::ostream& operator<<(std::ostream& os, poly128_t value) { #endif std::ostream& operator<<(std::ostream& os, float16_t value) { - uint16_t temp = 0; - memcpy(&temp, &value, sizeof(float16_t)); - std::stringstream ss; - ss << "0x" << std::setfill('0') << std::setw(4) << std::hex << temp; - os << ss.str(); + os << static_cast(value); return os; } @@ -52,92 +48,7 @@ std::ostream& operator<<(std::ostream& os, uint8_t value) { } "#; -// Format f16 values (and vectors containing them) in a way that is consistent with C. -pub const PLATFORM_RUST_DEFINITIONS: &str = r#" -/// Used to continue `Debug`ging SIMD types as `MySimd(1, 2, 3, 4)`, as they -/// were before moving to array-based simd. -#[inline] -fn debug_simd_finish( - formatter: &mut core::fmt::Formatter<'_>, - type_name: &str, - array: &[T; N], -) -> core::fmt::Result { - core::fmt::Formatter::debug_tuple_fields_finish( - formatter, - type_name, - &core::array::from_fn::<&dyn core::fmt::Debug, N, _>(|i| &array[i]), - ) -} - -#[repr(transparent)] -struct Hex(T); - -impl core::fmt::Debug for Hex { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - ::fmt(&self.0, f) - } -} - -fn debug_f16(x: T) -> impl core::fmt::Debug { - Hex(x) -} - -trait DebugHexF16 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result; -} - -impl DebugHexF16 for f16 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:#06x?}", self.to_bits()) - } -} - -impl DebugHexF16 for float16x4_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 4]>(*self) }; - debug_simd_finish(f, "float16x4_t", &array) - } -} - -impl DebugHexF16 for float16x8_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 8]>(*self) }; - debug_simd_finish(f, "float16x8_t", &array) - } -} - -impl DebugHexF16 for float16x4x2_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - debug_simd_finish(f, "float16x4x2_t", &[Hex(self.0), Hex(self.1)]) - } -} -impl DebugHexF16 for float16x4x3_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - debug_simd_finish(f, "float16x4x3_t", &[Hex(self.0), Hex(self.1), Hex(self.2)]) - } -} -impl DebugHexF16 for float16x4x4_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - debug_simd_finish(f, "float16x4x4_t", &[Hex(self.0), Hex(self.1), Hex(self.2), Hex(self.3)]) - } -} - -impl DebugHexF16 for float16x8x2_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - debug_simd_finish(f, "float16x8x2_t", &[Hex(self.0), Hex(self.1)]) - } -} -impl DebugHexF16 for float16x8x3_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - debug_simd_finish(f, "float16x8x3_t", &[Hex(self.0), Hex(self.1), Hex(self.2)]) - } -} -impl DebugHexF16 for float16x8x4_t { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - debug_simd_finish(f, "float16x8x4_t", &[Hex(self.0), Hex(self.1), Hex(self.2), Hex(self.3)]) - } -} - "#; +pub const PLATFORM_RUST_DEFINITIONS: &str = ""; pub const PLATFORM_RUST_CFGS: &str = r#" #![cfg_attr(target_arch = "arm", feature(stdarch_arm_neon_intrinsics))] diff --git a/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs b/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs index bd943c211e46..a14d7ef05f53 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/intrinsic_helpers.rs @@ -368,19 +368,8 @@ pub trait IntrinsicTypeDefinition: Deref { /// Generates a std::cout for the intrinsics results that will match the /// rust debug output format for the return type. The generated line assumes /// there is an int i in scope which is the current pass number. - /// - /// The `intrinsic-test` crate compares the output of C and Rust intrinsics. Currently, It uses - /// a string representation of the output value to compare. In C, f16 values are currently printed - /// as hexadecimal integers. Since https://github.com/rust-lang/rust/pull/127013, rust does print - /// them as decimal floating point values. To keep the intrinsics tests working, for now, format - /// vectors containing f16 values like C prints them. fn print_result_rust(&self) -> String { - let return_value = match self.kind() { - TypeKind::Float if self.inner_size() == 16 => "debug_f16(__return_value)", - _ => "format_args!(\"{__return_value:.150?}\")", - }; - - String::from(return_value) + String::from("format_args!(\"{__return_value:.150?}\")") } /// To enable architecture-specific logic diff --git a/library/stdarch/crates/intrinsic-test/src/x86/config.rs b/library/stdarch/crates/intrinsic-test/src/x86/config.rs index 40607d8491d1..bf943b795cd1 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/config.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/config.rs @@ -142,71 +142,6 @@ fn debug_simd_finish( ) } -#[repr(transparent)] -struct Hex(T); - -impl core::fmt::Debug for Hex { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - ::fmt(&self.0, f) - } -} - -fn debug_f16(x: T) -> impl core::fmt::Debug { - Hex(x) -} - -trait DebugHexF16 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result; -} - -impl DebugHexF16 for f16 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:#06x?}", self.to_bits()) - } -} - -impl DebugHexF16 for __m128h { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 8]>(*self) }; - debug_simd_finish(f, "__m128h", &array) - } -} - -impl DebugHexF16 for __m128i { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 8]>(*self) }; - debug_simd_finish(f, "__m128i", &array) - } -} - -impl DebugHexF16 for __m256h { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 16]>(*self) }; - debug_simd_finish(f, "__m256h", &array) - } -} - -impl DebugHexF16 for __m256i { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 16]>(*self) }; - debug_simd_finish(f, "__m256i", &array) - } -} - -impl DebugHexF16 for __m512h { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 32]>(*self) }; - debug_simd_finish(f, "__m512h", &array) - } -} - -impl DebugHexF16 for __m512i { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let array = unsafe { core::mem::transmute::<_, [Hex; 32]>(*self) }; - debug_simd_finish(f, "__m512i", &array) - } -} - trait DebugAs { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result; } @@ -232,7 +167,7 @@ macro_rules! impl_debug_as { }; } -impl_debug_as!(__m128i, "__m128i", 128, [u8, i8, u16, i16, u32, i32, u64, i64]); +impl_debug_as!(__m128i, "__m128i", 128, [u8, i8, u16, i16, u32, i32, u64, i64, f16]); impl_debug_as!(__m256i, "__m256i", 256, [u8, i8, u16, i16, u32, i32, u64, i64]); impl_debug_as!(__m512i, "__m512i", 512, [u8, i8, u16, i16, u32, i32, u64, i64]); impl_debug_as!(__m128h, "__m128h", 128, [f32]); @@ -336,11 +271,7 @@ pub const PLATFORM_C_FORWARD_DECLARATIONS: &str = r#" pub const PLATFORM_C_DEFINITIONS: &str = r#" std::ostream& operator<<(std::ostream& os, _Float16 value) { - uint16_t temp = 0; - memcpy(&temp, &value, sizeof(_Float16)); - std::stringstream ss; - ss << "0x" << std::setfill('0') << std::setw(4) << std::hex << temp; - os << ss.str(); + os << static_cast(value); return os; } diff --git a/library/stdarch/crates/intrinsic-test/src/x86/types.rs b/library/stdarch/crates/intrinsic-test/src/x86/types.rs index d6cb938096a1..2391ee9c2df4 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/types.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/types.rs @@ -172,29 +172,7 @@ impl IntrinsicTypeDefinition for X86IntrinsicType { /// rust debug output format for the return type. The generated line assumes /// there is an int i in scope which is the current pass number. fn print_result_c(&self, indentation: Indentation, additional: &str) -> String { - let lanes = if self.num_vectors() > 1 { - (0..self.num_vectors()) - .map(|vector| { - format!( - r#""{ty}(" << {lanes} << ")""#, - ty = self.c_single_vector_type(), - lanes = (0..self.num_lanes()) - .map(move |idx| -> std::string::String { - format!( - "{cast}{lane_fn}(__return_value.val[{vector}], {lane})", - cast = self.generate_final_type_cast(), - lane_fn = self.get_lane_function(), - lane = idx, - vector = vector, - ) - }) - .collect::>() - .join(r#" << ", " << "#) - ) - }) - .collect::>() - .join(r#" << ", " << "#) - } else if self.num_lanes() > 1 { + let lanes = if self.num_lanes() > 1 { (0..self.num_lanes()) .map(|idx| -> std::string::String { let cast_type = self.c_promotion(); @@ -283,12 +261,9 @@ impl IntrinsicTypeDefinition for X86IntrinsicType { fn print_result_rust(&self) -> String { let return_value = match self.kind() { - TypeKind::Float if self.inner_size() == 16 => "debug_f16(__return_value)".to_string(), - TypeKind::Float - if self.inner_size() == 32 - && ["__m512h"].contains(&self.param.type_data.as_str()) => - { - "debug_as::<_, f32>(__return_value)".to_string() + // `_mm{256}_cvtps_ph` has return type __m128i but contains f16 values + TypeKind::Float if self.param.type_data == "__m128i" => { + "format_args!(\"{:.150?}\", debug_as::<_, f16>(__return_value))".to_string() } TypeKind::Int(_) if ["__m128i", "__m256i", "__m512i"].contains(&self.param.type_data.as_str()) => @@ -463,6 +438,17 @@ impl X86IntrinsicType { } } + // a few intrinsics have wrong `etype` field in the XML + // - _mm512_reduce_add_ph + // - _mm512_reduce_mul_ph + // - _mm512_reduce_min_ph + // - _mm512_reduce_max_ph + // - _mm512_conj_pch + if param.type_data == "__m512h" && param.etype == "FP32" { + data.bit_len = Some(16); + data.simd_len = Some(32); + } + let mut result = X86IntrinsicType { data, param: param.clone(), From 8b35ef74a51fa972c045d09d97f9b71185989802 Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 29 Nov 2025 12:02:48 +0530 Subject: [PATCH 040/489] correct behavior of some intrinsics --- .../stdarch/crates/core_arch/src/x86/avx512bw.rs | 16 ++++++++-------- .../stdarch/crates/core_arch/src/x86/avx512f.rs | 14 ++++++-------- .../crates/core_arch/src/x86/avx512fp16.rs | 4 ++-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index c7f271d22ef5..0073bdeb4acd 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -10705,9 +10705,13 @@ pub fn _mm_cvtepi16_epi8(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpmovwb))] pub fn _mm_mask_cvtepi16_epi8(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { - let convert = _mm_cvtepi16_epi8(a).as_i8x16(); - let k: __mmask16 = 0b11111111_11111111 & k as __mmask16; - transmute(simd_select_bitmask(k, convert, src.as_i8x16())) + let a = _mm_cvtepi16_epi8(a).as_i8x16(); + let src = simd_shuffle!( + src.as_i8x16(), + i8x16::ZERO, + [0, 1, 2, 3, 4, 5, 6, 7, 16, 16, 16, 16, 16, 16, 16, 16] + ); + simd_select_bitmask(k as u16, a, src).as_m128i() } } @@ -10719,11 +10723,7 @@ pub fn _mm_mask_cvtepi16_epi8(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] pub fn _mm_maskz_cvtepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { - unsafe { - let convert = _mm_cvtepi16_epi8(a).as_i8x16(); - let k: __mmask16 = 0b11111111_11111111 & k as __mmask16; - transmute(simd_select_bitmask(k, convert, i8x16::ZERO)) - } + _mm_mask_cvtepi16_epi8(_mm_setzero_si128(), k, a) } /// Convert packed signed 16-bit integers in a to packed 8-bit integers with signed saturation, and store the results in dst. diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index 8c57fc201161..8d3ddbd964bb 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -11149,10 +11149,7 @@ pub fn _mm256_maskz_cvtpd_ps(k: __mmask8, a: __m256d) -> __m128 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtpd2ps))] pub fn _mm_mask_cvtpd_ps(src: __m128, k: __mmask8, a: __m128d) -> __m128 { - unsafe { - let convert = _mm_cvtpd_ps(a); - transmute(simd_select_bitmask(k, convert.as_f32x4(), src.as_f32x4())) - } + unsafe { vcvtpd2ps128(a.as_f64x2(), src.as_f32x4(), k).as_m128() } } /// Convert packed double-precision (64-bit) floating-point elements in a to packed single-precision (32-bit) floating-point elements, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set). @@ -11259,10 +11256,7 @@ pub fn _mm256_maskz_cvtpd_epi32(k: __mmask8, a: __m256d) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtpd2dq))] pub fn _mm_mask_cvtpd_epi32(src: __m128i, k: __mmask8, a: __m128d) -> __m128i { - unsafe { - let convert = _mm_cvtpd_epi32(a); - transmute(simd_select_bitmask(k, convert.as_i32x4(), src.as_i32x4())) - } + unsafe { vcvtpd2dq128(a.as_f64x2(), src.as_i32x4(), k).as_m128i() } } /// Convert packed double-precision (64-bit) floating-point elements in a to packed 32-bit integers, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set). @@ -42483,9 +42477,13 @@ unsafe extern "C" { #[link_name = "llvm.x86.avx512.mask.cvtps2pd.512"] fn vcvtps2pd(a: f32x8, src: f64x8, mask: u8, sae: i32) -> f64x8; + #[link_name = "llvm.x86.avx512.mask.cvtpd2ps"] + fn vcvtpd2ps128(a: f64x2, src: f32x4, mask: u8) -> f32x4; #[link_name = "llvm.x86.avx512.mask.cvtpd2ps.512"] fn vcvtpd2ps(a: f64x8, src: f32x8, mask: u8, rounding: i32) -> f32x8; + #[link_name = "llvm.x86.avx512.mask.cvtpd2dq.128"] + fn vcvtpd2dq128(a: f64x2, src: i32x4, k: u8) -> i32x4; #[link_name = "llvm.x86.avx512.mask.cvtpd2dq.512"] fn vcvtpd2dq(a: f64x8, src: i32x8, mask: u8, rounding: i32) -> i32x8; diff --git a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs index 13cae45d0f81..01b1be364fe5 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs @@ -1007,7 +1007,7 @@ pub fn _mm_comilt_sh(a: __m128h, b: __m128h) -> i32 { #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] pub fn _mm_comineq_sh(a: __m128h, b: __m128h) -> i32 { - _mm_comi_sh::<_CMP_NEQ_OS>(a, b) + _mm_comi_sh::<_CMP_NEQ_US>(a, b) } /// Compare the lower half-precision (16-bit) floating-point elements in a and b for equality, and @@ -1073,7 +1073,7 @@ pub fn _mm_ucomilt_sh(a: __m128h, b: __m128h) -> i32 { #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] pub fn _mm_ucomineq_sh(a: __m128h, b: __m128h) -> i32 { - _mm_comi_sh::<_CMP_NEQ_OQ>(a, b) + _mm_comi_sh::<_CMP_NEQ_UQ>(a, b) } /// Load 128-bits (composed of 8 packed half-precision (16-bit) floating-point elements) from memory into From ae78a301e0332d01c11d89ce531686d9aa7fc92a Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 29 Nov 2025 11:53:23 +0530 Subject: [PATCH 041/489] fix intrinsic-test to use `core_arch::arch` rather than `std::arch` --- .../crates/intrinsic-test/missing_x86.txt | 22 +++++-------------- .../crates/intrinsic-test/src/x86/config.rs | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/missing_x86.txt b/library/stdarch/crates/intrinsic-test/missing_x86.txt index 11c3eeba9063..f88a125bfdff 100644 --- a/library/stdarch/crates/intrinsic-test/missing_x86.txt +++ b/library/stdarch/crates/intrinsic-test/missing_x86.txt @@ -51,29 +51,17 @@ _mm_sm3rnds2_epi32 # SDE ERROR: Cannot execute XGETBV with ECX != 0 _xgetbv -# Miscellaneous issues that can be fixed first -_kshiftli_mask16 -_kshiftli_mask32 -_kshiftli_mask64 -_kshiftli_mask8 -_kshiftri_mask16 -_kshiftri_mask32 -_kshiftri_mask64 -_kshiftri_mask8 +# top bits are undefined, unclear how to test these _mm256_castsi128_si256 -_mm256_extract_epi16 -_mm256_extract_epi8 _mm512_castsi128_si512 _mm512_castsi256_si512 -# _mm512_conj_pch + +# Clang bug +_mm256_extract_epi16 +_mm256_extract_epi8 _mm512_mask_reduce_max_pd _mm512_mask_reduce_max_ps _mm512_mask_reduce_min_pd _mm512_mask_reduce_min_ps -_mm_comineq_sh _mm_extract_epi16 _mm_extract_epi8 -_mm_mask_cvtepi16_epi8 -_mm_mask_cvtpd_epi32 -_mm_mask_cvtpd_ps -_mm_ucomineq_sh diff --git a/library/stdarch/crates/intrinsic-test/src/x86/config.rs b/library/stdarch/crates/intrinsic-test/src/x86/config.rs index bf943b795cd1..491dbb5147bb 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/config.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/config.rs @@ -5,7 +5,7 @@ pub const NOTICE: &str = "\ // Format f16 values (and vectors containing them) in a way that is consistent with C. pub const PLATFORM_RUST_DEFINITIONS: &str = r#" -use std::arch::x86_64::*; +use core_arch::arch::x86_64::*; #[inline] unsafe fn _mm_loadu_ph_to___m128i(mem_addr: *const f16) -> __m128i { From 3e8185f155a0294b201667f2736d9554f5e00e9a Mon Sep 17 00:00:00 2001 From: sayantn Date: Sun, 5 Oct 2025 05:29:09 +0530 Subject: [PATCH 042/489] Make `cpuid` safe and update docs --- .../stdarch/crates/core_arch/src/x86/cpuid.rs | 40 +++++++++++-------- .../stdarch/crates/core_arch/src/x86/xsave.rs | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/cpuid.rs b/library/stdarch/crates/core_arch/src/x86/cpuid.rs index 0634f10a99fd..84dcf75492b3 100644 --- a/library/stdarch/crates/core_arch/src/x86/cpuid.rs +++ b/library/stdarch/crates/core_arch/src/x86/cpuid.rs @@ -28,12 +28,21 @@ pub struct CpuidResult { /// Returns the result of the `cpuid` instruction for a given `leaf` (`EAX`) /// and `sub_leaf` (`ECX`). /// -/// The highest-supported leaf value is returned by the first tuple argument of -/// [`__get_cpuid_max(0)`](fn.__get_cpuid_max.html). For leaves containing -/// sub-leaves, the second tuple argument returns the highest-supported -/// sub-leaf value. +/// There are two types of information leaves - basic leaves (with `leaf < 0x8000000`) +/// and extended leaves (with `leaf >= 0x80000000`). The highest supported basic and +/// extended leaves can be obtained by calling CPUID with `0` and `0x80000000`, +/// respectively, and reading the value in the `EAX` register. If the leaf supports +/// more than one sub-leaf, then the procedure of obtaining the highest supported +/// sub-leaf, as well as the behavior if a invalid sub-leaf value is passed, depends +/// on the specific leaf. /// -/// The [CPUID Wikipedia page][wiki_cpuid] contains how to query which +/// If the `leaf` value is higher than the maximum supported basic or extended leaf +/// for the processor, this returns the information for the highest supported basic +/// information leaf (with the passed `sub_leaf` value). If the `leaf` value is less +/// than or equal to the highest basic or extended leaf value, but the leaf is not +/// supported on the processor, all zeros are returned. +/// +/// The [CPUID Wikipedia page][wiki_cpuid] contains information on how to query which /// information using the `EAX` and `ECX` registers, and the interpretation of /// the results returned in `EAX`, `EBX`, `ECX`, and `EDX`. /// @@ -49,7 +58,7 @@ pub struct CpuidResult { #[inline] #[cfg_attr(test, assert_instr(cpuid))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult { +pub fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult { let eax; let ebx; let ecx; @@ -58,7 +67,7 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult { // LLVM sometimes reserves `ebx` for its internal use, we so we need to use // a scratch register for it instead. #[cfg(target_arch = "x86")] - { + unsafe { asm!( "mov {0}, ebx", "cpuid", @@ -71,7 +80,7 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult { ); } #[cfg(target_arch = "x86_64")] - { + unsafe { asm!( "mov {0:r}, rbx", "cpuid", @@ -86,27 +95,26 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult { CpuidResult { eax, ebx, ecx, edx } } +/// Calls CPUID with the provided `leaf` value, with `sub_leaf` set to 0. /// See [`__cpuid_count`](fn.__cpuid_count.html). #[inline] #[cfg_attr(test, assert_instr(cpuid))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn __cpuid(leaf: u32) -> CpuidResult { +pub fn __cpuid(leaf: u32) -> CpuidResult { __cpuid_count(leaf, 0) } -/// Returns the highest-supported `leaf` (`EAX`) and sub-leaf (`ECX`) `cpuid` -/// values. +/// Returns the EAX and EBX register after calling CPUID with the provided `leaf`, +/// with `sub_leaf` set to 0. /// -/// If `cpuid` is supported, and `leaf` is zero, then the first tuple argument -/// contains the highest `leaf` value that `cpuid` supports. For `leaf`s -/// containing sub-leafs, the second tuple argument contains the -/// highest-supported sub-leaf value. +/// If `leaf` if 0 or `0x80000000`, the first tuple argument contains the maximum +/// supported basic or extended leaf, respectively. /// /// See also [`__cpuid`](fn.__cpuid.html) and /// [`__cpuid_count`](fn.__cpuid_count.html). #[inline] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn __get_cpuid_max(leaf: u32) -> (u32, u32) { +pub fn __get_cpuid_max(leaf: u32) -> (u32, u32) { let CpuidResult { eax, ebx, .. } = __cpuid(leaf); (eax, ebx) } diff --git a/library/stdarch/crates/core_arch/src/x86/xsave.rs b/library/stdarch/crates/core_arch/src/x86/xsave.rs index 190cef929e47..653eb28c4268 100644 --- a/library/stdarch/crates/core_arch/src/x86/xsave.rs +++ b/library/stdarch/crates/core_arch/src/x86/xsave.rs @@ -184,7 +184,7 @@ mod tests { // `CPUID.(EAX=0DH,ECX=0):ECX` contains the size required to hold all supported xsave // components. `EBX` contains the size required to hold all xsave components currently // enabled in `XCR0`. We are using `ECX` to ensure enough space in all scenarios - let CpuidResult { ecx, .. } = unsafe { __cpuid(0x0d) }; + let CpuidResult { ecx, .. } = __cpuid(0x0d); XsaveArea { data: vec![AlignedArray([0; 64]); ecx.div_ceil(64) as usize].into_boxed_slice(), From f242c46a0a423e3b088c6826636394fd21f788a1 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sun, 2 Nov 2025 19:17:30 +0000 Subject: [PATCH 043/489] fix: `set-contains-or-insert` FP when set is mutated before `insert` --- clippy_lints/src/set_contains_or_insert.rs | 21 ++++++++++++++++++--- tests/ui/set_contains_or_insert.rs | 21 +++++++++++++++++++++ tests/ui/set_contains_or_insert.stderr | 11 ++++++++++- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/set_contains_or_insert.rs b/clippy_lints/src/set_contains_or_insert.rs index 688da33a1777..7482bac4c7b4 100644 --- a/clippy_lints/src/set_contains_or_insert.rs +++ b/clippy_lints/src/set_contains_or_insert.rs @@ -112,6 +112,16 @@ fn try_parse_op_call<'tcx>( None } +fn is_set_mutated<'tcx>(cx: &LateContext<'tcx>, contains_expr: &OpExpr<'tcx>, expr: &'tcx Expr<'_>) -> bool { + // Guard on type to avoid useless potentially expansive `SpanlessEq` checks + cx.typeck_results().expr_ty_adjusted(expr).is_mutable_ptr() + && matches!( + cx.typeck_results().expr_ty(expr).peel_refs().opt_diag_name(cx), + Some(sym::HashSet | sym::BTreeSet) + ) + && SpanlessEq::new(cx).eq_expr(contains_expr.receiver, expr.peel_borrows()) +} + fn find_insert_calls<'tcx>( cx: &LateContext<'tcx>, contains_expr: &OpExpr<'tcx>, @@ -122,9 +132,14 @@ fn find_insert_calls<'tcx>( && SpanlessEq::new(cx).eq_expr(contains_expr.receiver, insert_expr.receiver) && SpanlessEq::new(cx).eq_expr(contains_expr.value, insert_expr.value) { - ControlFlow::Break(insert_expr) - } else { - ControlFlow::Continue(()) + return ControlFlow::Break(Some(insert_expr)); } + + if is_set_mutated(cx, contains_expr, e) { + return ControlFlow::Break(None); + } + + ControlFlow::Continue(()) }) + .flatten() } diff --git a/tests/ui/set_contains_or_insert.rs b/tests/ui/set_contains_or_insert.rs index 575cfda139a4..ac1d74f8afa4 100644 --- a/tests/ui/set_contains_or_insert.rs +++ b/tests/ui/set_contains_or_insert.rs @@ -164,3 +164,24 @@ fn main() { should_not_warn_hashset(); should_not_warn_btreeset(); } + +fn issue15990(s: &mut HashSet, v: usize) { + if !s.contains(&v) { + s.clear(); + s.insert(v); + } + + fn borrow_as_mut(v: usize, s: &mut HashSet) { + s.clear(); + } + if !s.contains(&v) { + borrow_as_mut(v, s); + s.insert(v); + } + + if !s.contains(&v) { + //~^ set_contains_or_insert + let _readonly_access = s.contains(&v); + s.insert(v); + } +} diff --git a/tests/ui/set_contains_or_insert.stderr b/tests/ui/set_contains_or_insert.stderr index 3152b1136458..3b06b63182ab 100644 --- a/tests/ui/set_contains_or_insert.stderr +++ b/tests/ui/set_contains_or_insert.stderr @@ -127,5 +127,14 @@ LL | LL | borrow_set.insert(value); | ^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: usage of `HashSet::insert` after `HashSet::contains` + --> tests/ui/set_contains_or_insert.rs:182:11 + | +LL | if !s.contains(&v) { + | ^^^^^^^^^^^^ +... +LL | s.insert(v); + | ^^^^^^^^^ + +error: aborting due to 15 previous errors From bd0a5e4ef372d542b73c30e5fb5404f89aa18946 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sun, 30 Nov 2025 20:52:32 +0000 Subject: [PATCH 044/489] fix: `empty_enum_variants_with_brackets` misses removing brackets in patterns --- clippy_lints/src/empty_with_brackets.rs | 84 +++++++++++++------ .../empty_enum_variants_with_brackets.fixed | 13 +++ tests/ui/empty_enum_variants_with_brackets.rs | 13 +++ .../empty_enum_variants_with_brackets.stderr | 36 ++++++-- 4 files changed, 112 insertions(+), 34 deletions(-) diff --git a/clippy_lints/src/empty_with_brackets.rs b/clippy_lints/src/empty_with_brackets.rs index e7230ebf8cba..5dc1bb96266a 100644 --- a/clippy_lints/src/empty_with_brackets.rs +++ b/clippy_lints/src/empty_with_brackets.rs @@ -2,13 +2,13 @@ use clippy_utils::attrs::span_contains_cfg; use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::Applicability; -use rustc_hir::def::CtorOf; use rustc_hir::def::DefKind::Ctor; use rustc_hir::def::Res::Def; +use rustc_hir::def::{CtorOf, DefKind}; use rustc_hir::def_id::LocalDefId; -use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node, Path, QPath, Variant, VariantData}; +use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node, Pat, PatKind, Path, QPath, Variant, VariantData}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{self, TyCtxt}; use rustc_session::impl_lint_pass; use rustc_span::Span; @@ -177,28 +177,7 @@ impl LateLintPass<'_> for EmptyWithBrackets { if expr.span.from_expansion() { return; } - match self.empty_tuple_enum_variants.get_mut(&def_id) { - Some( - &mut (Usage::Unused { - ref mut redundant_use_sites, - } - | Usage::NoDefinition { - ref mut redundant_use_sites, - }), - ) => { - redundant_use_sites.push(parentheses_span); - }, - None => { - // The variant isn't in the IndexMap which means its definition wasn't encountered yet. - self.empty_tuple_enum_variants.insert( - def_id, - Usage::NoDefinition { - redundant_use_sites: vec![parentheses_span], - }, - ); - }, - _ => {}, - } + self.update_enum_variant_usage(def_id, parentheses_span); } else { // The parentheses are not redundant. self.empty_tuple_enum_variants.insert(def_id, Usage::Used); @@ -206,6 +185,16 @@ impl LateLintPass<'_> for EmptyWithBrackets { } } + fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { + if let Some((def_id, parentheses_span)) = check_pat_for_enum_as_function(cx, pat) { + if pat.span.from_expansion() { + return; + } + + self.update_enum_variant_usage(def_id, parentheses_span); + } + } + fn check_crate_post(&mut self, cx: &LateContext<'_>) { for (local_def_id, usage) in &self.empty_tuple_enum_variants { // Ignore all variants with Usage::Used or Usage::NoDefinition @@ -252,6 +241,33 @@ impl LateLintPass<'_> for EmptyWithBrackets { } } +impl EmptyWithBrackets { + fn update_enum_variant_usage(&mut self, def_id: LocalDefId, parentheses_span: Span) { + match self.empty_tuple_enum_variants.get_mut(&def_id) { + Some( + &mut (Usage::Unused { + ref mut redundant_use_sites, + } + | Usage::NoDefinition { + ref mut redundant_use_sites, + }), + ) => { + redundant_use_sites.push(parentheses_span); + }, + None => { + // The variant isn't in the IndexMap which means its definition wasn't encountered yet. + self.empty_tuple_enum_variants.insert( + def_id, + Usage::NoDefinition { + redundant_use_sites: vec![parentheses_span], + }, + ); + }, + _ => {}, + } + } +} + fn has_brackets(var_data: &VariantData<'_>) -> bool { !matches!(var_data, VariantData::Unit(..)) } @@ -291,3 +307,21 @@ fn check_expr_for_enum_as_function(expr: &Expr<'_>) -> Option { None } } + +fn check_pat_for_enum_as_function(cx: &LateContext<'_>, pat: &Pat<'_>) -> Option<(LocalDefId, Span)> { + match pat.kind { + PatKind::TupleStruct(qpath, ..) + if let Def(Ctor(CtorOf::Variant, _), def_id) = cx.typeck_results().qpath_res(&qpath, pat.hir_id) => + { + def_id.as_local().map(|id| (id, qpath.span().with_lo(pat.span.hi()))) + }, + PatKind::Struct(qpath, ..) + if let Def(DefKind::Variant, def_id) = cx.typeck_results().qpath_res(&qpath, pat.hir_id) + && let ty = cx.tcx.type_of(def_id).instantiate_identity() + && let ty::FnDef(def_id, _) = ty.kind() => + { + def_id.as_local().map(|id| (id, qpath.span().with_lo(pat.span.hi()))) + }, + _ => None, + } +} diff --git a/tests/ui/empty_enum_variants_with_brackets.fixed b/tests/ui/empty_enum_variants_with_brackets.fixed index abdf6ca5cb61..515d5a975944 100644 --- a/tests/ui/empty_enum_variants_with_brackets.fixed +++ b/tests/ui/empty_enum_variants_with_brackets.fixed @@ -1,5 +1,6 @@ #![warn(clippy::empty_enum_variants_with_brackets)] #![allow(dead_code)] +#![feature(more_qualified_paths)] pub enum PublicTestEnum { NonEmptyBraces { x: i32, y: i32 }, // No error @@ -102,4 +103,16 @@ pub enum PubFoo { Variant3(), } +fn issue16157() { + enum E { + V, + //~^ empty_enum_variants_with_brackets + } + + let E::V = E::V; + + ::V = E::V; + ::V = E::V; +} + fn main() {} diff --git a/tests/ui/empty_enum_variants_with_brackets.rs b/tests/ui/empty_enum_variants_with_brackets.rs index 63a5a8e9143e..2c29fc505d3b 100644 --- a/tests/ui/empty_enum_variants_with_brackets.rs +++ b/tests/ui/empty_enum_variants_with_brackets.rs @@ -1,5 +1,6 @@ #![warn(clippy::empty_enum_variants_with_brackets)] #![allow(dead_code)] +#![feature(more_qualified_paths)] pub enum PublicTestEnum { NonEmptyBraces { x: i32, y: i32 }, // No error @@ -102,4 +103,16 @@ pub enum PubFoo { Variant3(), } +fn issue16157() { + enum E { + V(), + //~^ empty_enum_variants_with_brackets + } + + let E::V() = E::V(); + + ::V() = E::V(); + ::V {} = E::V(); +} + fn main() {} diff --git a/tests/ui/empty_enum_variants_with_brackets.stderr b/tests/ui/empty_enum_variants_with_brackets.stderr index 7fe85e829a35..c487cebd21ac 100644 --- a/tests/ui/empty_enum_variants_with_brackets.stderr +++ b/tests/ui/empty_enum_variants_with_brackets.stderr @@ -1,5 +1,5 @@ error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:7:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:8:16 | LL | EmptyBraces {}, | ^^^ @@ -9,7 +9,7 @@ LL | EmptyBraces {}, = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:15:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:16:16 | LL | EmptyBraces {}, | ^^^ @@ -17,7 +17,7 @@ LL | EmptyBraces {}, = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:17:21 + --> tests/ui/empty_enum_variants_with_brackets.rs:18:21 | LL | EmptyParentheses(), | ^^ @@ -25,7 +25,7 @@ LL | EmptyParentheses(), = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:28:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:29:16 | LL | Unknown(), | ^^ @@ -33,7 +33,7 @@ LL | Unknown(), = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:47:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:48:16 | LL | Unknown(), | ^^ @@ -41,7 +41,7 @@ LL | Unknown(), = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:53:20 + --> tests/ui/empty_enum_variants_with_brackets.rs:54:20 | LL | Parentheses(), | ^^ @@ -56,7 +56,7 @@ LL ~ RedundantParenthesesFunctionCall::Parentheses; | error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:76:20 + --> tests/ui/empty_enum_variants_with_brackets.rs:77:20 | LL | Parentheses(), | ^^ @@ -71,12 +71,30 @@ LL ~ Parentheses, | error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:95:13 + --> tests/ui/empty_enum_variants_with_brackets.rs:96:13 | LL | Variant3(), | ^^ | = help: remove the brackets -error: aborting due to 8 previous errors +error: enum variant has empty brackets + --> tests/ui/empty_enum_variants_with_brackets.rs:108:10 + | +LL | V(), + | ^^ + | +help: remove the brackets + | +LL ~ V, +LL | +LL | } +LL | +LL ~ let E::V = E::V; +LL | +LL ~ ::V = E::V; +LL ~ ::V = E::V; + | + +error: aborting due to 9 previous errors From 9f1724d3ac8c3cf07658f973379fe2ccc425c1b3 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 2 Dec 2025 00:22:05 +0530 Subject: [PATCH 045/489] use `wrapping_add` for `_kadd` intrinsics --- library/stdarch/crates/core_arch/src/x86/avx512bw.rs | 4 ++-- library/stdarch/crates/core_arch/src/x86/avx512dq.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 0073bdeb4acd..5d17d42532f1 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -10254,7 +10254,7 @@ pub fn _cvtu32_mask32(a: u32) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _kadd_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { - a + b + a.wrapping_add(b) } /// Add 64-bit masks in a and b, and store the result in k. @@ -10264,7 +10264,7 @@ pub fn _kadd_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _kadd_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { - a + b + a.wrapping_add(b) } /// Compute the bitwise AND of 32-bit masks a and b, and store the result in k. diff --git a/library/stdarch/crates/core_arch/src/x86/avx512dq.rs b/library/stdarch/crates/core_arch/src/x86/avx512dq.rs index afeb548a553c..a69168750283 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512dq.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512dq.rs @@ -4486,7 +4486,7 @@ pub fn _cvtu32_mask8(a: u32) -> __mmask8 { #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _kadd_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { - a + b + a.wrapping_add(b) } /// Add 8-bit masks a and b, and store the result in dst. @@ -4496,7 +4496,7 @@ pub fn _kadd_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _kadd_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { - a + b + a.wrapping_add(b) } /// Bitwise AND of 8-bit masks a and b, and store the result in dst. From f0f0b8b2225ab6694e1cc08ce2d17867d7afe50c Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Tue, 4 Nov 2025 19:54:11 +0530 Subject: [PATCH 046/489] feat: configure test-files to run all intrinsics in the same process --- .../crates/intrinsic-test/src/common/gen_c.rs | 16 ++++------------ .../crates/intrinsic-test/src/common/gen_rust.rs | 12 +++--------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs index 04741e4f8075..30f359a27ef1 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs @@ -147,22 +147,14 @@ pub fn write_main_cpp<'a>( } writeln!(w, "int main(int argc, char **argv) {{")?; - writeln!(w, " std::string intrinsic_name = argv[1];")?; - - writeln!(w, " if (false) {{")?; for intrinsic in intrinsics { - writeln!(w, " }} else if (intrinsic_name == \"{intrinsic}\") {{")?; - writeln!(w, " return run_{intrinsic}();")?; + writeln!(w, " std::cout << \"############\" << std::endl;")?; + writeln!(w, " std::cout << \"{intrinsic}\" << std::endl;")?; + writeln!(w, " run_{intrinsic}();\n")?; } - writeln!(w, " }} else {{")?; - writeln!( - w, - " std::cerr << \"Unknown command: \" << intrinsic_name << \"\\n\";" - )?; - writeln!(w, " return -1;")?; - writeln!(w, " }}")?; + writeln!(w, " return 0;")?; writeln!(w, "}}")?; diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs index c8d815e46eae..afc6ca45561a 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs @@ -86,18 +86,12 @@ pub fn write_main_rs<'a>( writeln!(w, "fn main() {{")?; - writeln!(w, " match std::env::args().nth(1).unwrap().as_str() {{")?; - for binary in intrinsics { - writeln!(w, " \"{binary}\" => run_{binary}(),")?; + writeln!(w, " println!(\"############\");")?; + writeln!(w, " println!(\"{binary}\");")?; + writeln!(w, " run_{binary}();\n")?; } - writeln!( - w, - " other => panic!(\"unknown intrinsic `{{}}`\", other)," - )?; - - writeln!(w, " }}")?; writeln!(w, "}}")?; Ok(()) From 344acad879d8cc84581329fd3c64cfacc9b80888 Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Tue, 4 Nov 2025 21:54:56 +0530 Subject: [PATCH 047/489] feat: modified the compare function to check one huge output stream instead of len(intrinsic) output streams --- .../intrinsic-test/src/common/compare.rs | 149 +++++++++--------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index c0459b743a7f..96a0bb94aab4 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -1,6 +1,7 @@ use super::cli::FailureReason; +use itertools::Itertools; use rayon::prelude::*; -use std::process::Command; +use std::{collections::HashMap, process::Command}; fn runner_command(runner: &str) -> Command { let mut it = runner.split_whitespace(); @@ -11,85 +12,83 @@ fn runner_command(runner: &str) -> Command { } pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: &str) -> bool { - let intrinsics = intrinsic_name_list + let c = runner_command(runner) + .arg("./intrinsic-test-programs") + .current_dir("c_programs") + .output(); + + let rust = runner_command(runner) + .arg(format!("./target/{target}/release/intrinsic-test-programs")) + .current_dir("rust_programs") + .output(); + + let (c, rust) = match (c, rust) { + (Ok(c), Ok(rust)) => (c, rust), + a => panic!("{a:#?}"), + }; + + if !c.status.success() { + error!( + "Failed to run C program.\nstdout: {stdout}\nstderr: {stderr}", + stdout = std::str::from_utf8(&c.stdout).unwrap_or(""), + stderr = std::str::from_utf8(&c.stderr).unwrap_or(""), + ); + } + + if !rust.status.success() { + error!( + "Failed to run Rust program.\nstdout: {stdout}\nstderr: {stderr}", + stdout = std::str::from_utf8(&rust.stdout).unwrap_or(""), + stderr = std::str::from_utf8(&rust.stderr).unwrap_or(""), + ); + } + + let c = std::str::from_utf8(&c.stdout) + .unwrap() + .to_lowercase() + .replace("-nan", "nan"); + let rust = std::str::from_utf8(&rust.stdout) + .unwrap() + .to_lowercase() + .replace("-nan", "nan"); + + let c_output_map = c.split("############") + .filter_map(|output| output.trim().split_once("\n")) + .collect::>(); + let rust_output_map = rust.split("############") + .filter_map(|output| output.trim().split_once("\n")) + .collect::>(); + + let intrinsics = c_output_map.keys().chain(rust_output_map.keys()).unique().collect_vec(); + let intrinsics_diff_count = intrinsics .par_iter() - .filter_map(|intrinsic_name| { - let c = runner_command(runner) - .arg("./intrinsic-test-programs") - .arg(intrinsic_name) - .current_dir("c_programs") - .output(); - - let rust = runner_command(runner) - .arg(format!("./target/{target}/release/intrinsic-test-programs")) - .arg(intrinsic_name) - .current_dir("rust_programs") - .output(); - - let (c, rust) = match (c, rust) { - (Ok(c), Ok(rust)) => (c, rust), - a => panic!("{a:#?}"), - }; - - if !c.status.success() { - error!( - "Failed to run C program for intrinsic `{intrinsic_name}`\nstdout: {stdout}\nstderr: {stderr}", - stdout = std::str::from_utf8(&c.stdout).unwrap_or(""), - stderr = std::str::from_utf8(&c.stderr).unwrap_or(""), - ); - return Some(FailureReason::RunC(intrinsic_name.clone())); - } - - if !rust.status.success() { - error!( - "Failed to run Rust program for intrinsic `{intrinsic_name}`\nstdout: {stdout}\nstderr: {stderr}", - stdout = std::str::from_utf8(&rust.stdout).unwrap_or(""), - stderr = std::str::from_utf8(&rust.stderr).unwrap_or(""), - ); - return Some(FailureReason::RunRust(intrinsic_name.clone())); - } - - info!("Comparing intrinsic: {intrinsic_name}"); - - let c = std::str::from_utf8(&c.stdout) - .unwrap() - .to_lowercase() - .replace("-nan", "nan"); - let rust = std::str::from_utf8(&rust.stdout) - .unwrap() - .to_lowercase() - .replace("-nan", "nan"); - - if c == rust { - None - } else { - Some(FailureReason::Difference(intrinsic_name.clone(), c, rust)) - } - }) - .collect::>(); - - intrinsics.iter().for_each(|reason| match reason { - FailureReason::Difference(intrinsic, c, rust) => { + .filter_map(|&&intrinsic| { println!("Difference for intrinsic: {intrinsic}"); - let diff = diff::lines(c, rust); - diff.iter().for_each(|diff| match diff { - diff::Result::Left(c) => println!("C: {c}"), - diff::Result::Right(rust) => println!("Rust: {rust}"), - diff::Result::Both(_, _) => (), - }); + let c_output = c_output_map.get(intrinsic).unwrap(); + let rust_output = rust_output_map.get(intrinsic).unwrap(); + let diff = diff::lines(c_output, rust_output); + let diff_count = diff.into_iter().filter_map(|diff| match diff { + diff::Result::Left(c) => { + println!("C: {c}"); + Some(c) + } + diff::Result::Right(rust) => { + println!("Rust: {rust}"); + Some(rust) + } + diff::Result::Both(_, _) => None, + }).count(); println!("****************************************************************"); - } - FailureReason::RunC(intrinsic) => { - println!("Failed to run C program for intrinsic {intrinsic}") - } - FailureReason::RunRust(intrinsic) => { - println!("Failed to run rust program for intrinsic {intrinsic}") - } - }); + if diff_count > 0 { + Some(intrinsic) + } else { None } + }).count(); + println!( "{} differences found (tested {} intrinsics)", - intrinsics.len(), + intrinsics_diff_count, intrinsic_name_list.len() ); - intrinsics.is_empty() + + intrinsics_diff_count == 0 } From a472b5dcd904c5dd25b3b84cfe862ccaf134acb0 Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Tue, 4 Nov 2025 22:02:20 +0530 Subject: [PATCH 048/489] chore: formatting checks --- .../crates/intrinsic-test/src/common/cli.rs | 6 --- .../intrinsic-test/src/common/compare.rs | 53 +++++++++++-------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/cli.rs b/library/stdarch/crates/intrinsic-test/src/common/cli.rs index 461ab542ea89..ff34ef3d2d3d 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/cli.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/cli.rs @@ -7,12 +7,6 @@ pub enum Language { C, } -pub enum FailureReason { - RunC(String), - RunRust(String), - Difference(String, String, String), -} - /// Intrinsic test tool #[derive(clap::Parser)] #[command( diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index 96a0bb94aab4..4ab2a3365737 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -1,4 +1,3 @@ -use super::cli::FailureReason; use itertools::Itertools; use rayon::prelude::*; use std::{collections::HashMap, process::Command}; @@ -21,12 +20,12 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: .arg(format!("./target/{target}/release/intrinsic-test-programs")) .current_dir("rust_programs") .output(); - + let (c, rust) = match (c, rust) { (Ok(c), Ok(rust)) => (c, rust), a => panic!("{a:#?}"), }; - + if !c.status.success() { error!( "Failed to run C program.\nstdout: {stdout}\nstderr: {stderr}", @@ -34,7 +33,7 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: stderr = std::str::from_utf8(&c.stderr).unwrap_or(""), ); } - + if !rust.status.success() { error!( "Failed to run Rust program.\nstdout: {stdout}\nstderr: {stderr}", @@ -51,15 +50,21 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: .unwrap() .to_lowercase() .replace("-nan", "nan"); - - let c_output_map = c.split("############") + + let c_output_map = c + .split("############") .filter_map(|output| output.trim().split_once("\n")) .collect::>(); - let rust_output_map = rust.split("############") + let rust_output_map = rust + .split("############") .filter_map(|output| output.trim().split_once("\n")) .collect::>(); - let intrinsics = c_output_map.keys().chain(rust_output_map.keys()).unique().collect_vec(); + let intrinsics = c_output_map + .keys() + .chain(rust_output_map.keys()) + .unique() + .collect_vec(); let intrinsics_diff_count = intrinsics .par_iter() .filter_map(|&&intrinsic| { @@ -67,22 +72,28 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: let c_output = c_output_map.get(intrinsic).unwrap(); let rust_output = rust_output_map.get(intrinsic).unwrap(); let diff = diff::lines(c_output, rust_output); - let diff_count = diff.into_iter().filter_map(|diff| match diff { - diff::Result::Left(c) => { - println!("C: {c}"); - Some(c) - } - diff::Result::Right(rust) => { - println!("Rust: {rust}"); - Some(rust) - } - diff::Result::Both(_, _) => None, - }).count(); + let diff_count = diff + .into_iter() + .filter_map(|diff| match diff { + diff::Result::Left(c) => { + println!("C: {c}"); + Some(c) + } + diff::Result::Right(rust) => { + println!("Rust: {rust}"); + Some(rust) + } + diff::Result::Both(_, _) => None, + }) + .count(); println!("****************************************************************"); if diff_count > 0 { Some(intrinsic) - } else { None } - }).count(); + } else { + None + } + }) + .count(); println!( "{} differences found (tested {} intrinsics)", From 09a67dfab090818158baf8a55ecff88a42531312 Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Tue, 4 Nov 2025 22:09:13 +0530 Subject: [PATCH 049/489] feat: increase TEST_SAMPLE_INTRINSICS_PERCENTAGE of x86_64 to 30% --- library/stdarch/ci/intrinsic-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index a8f96897bc23..2b40044462aa 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -75,7 +75,7 @@ case ${TARGET} in TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER}" TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_x86.txt - : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=5}" + : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=30}" ;; *) ;; From 99fbd39a7d7a84afd3f161df3368480bba9c60dc Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Tue, 4 Nov 2025 22:52:33 +0530 Subject: [PATCH 050/489] fix: update the comparison algorithm for cleaner comparisons --- .../intrinsic-test/src/common/compare.rs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index 4ab2a3365737..38fa8dc0ec99 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -68,31 +68,31 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: let intrinsics_diff_count = intrinsics .par_iter() .filter_map(|&&intrinsic| { - println!("Difference for intrinsic: {intrinsic}"); let c_output = c_output_map.get(intrinsic).unwrap(); let rust_output = rust_output_map.get(intrinsic).unwrap(); let diff = diff::lines(c_output, rust_output); - let diff_count = diff + let diffs = diff .into_iter() .filter_map(|diff| match diff { - diff::Result::Left(c) => { - println!("C: {c}"); - Some(c) - } - diff::Result::Right(rust) => { - println!("Rust: {rust}"); - Some(rust) - } + diff::Result::Left(_) | diff::Result::Right(_) => Some(diff), diff::Result::Both(_, _) => None, }) - .count(); - println!("****************************************************************"); - if diff_count > 0 { - Some(intrinsic) + .collect_vec(); + if diffs.len() > 0 { + Some((intrinsic, diffs)) } else { None } }) + .inspect(|(intrinsic, diffs)| { + println!("Difference for intrinsic: {intrinsic}"); + diffs.into_iter().for_each(|diff| match diff { + diff::Result::Left(c) => println!("C: {c}"), + diff::Result::Right(rust) => println!("Rust: {rust}"), + _ => (), + }); + println!("****************************************************************"); + }) .count(); println!( From 998aff3dc57b4c951291d7ca5316ee74b0e09373 Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Tue, 4 Nov 2025 23:34:33 +0530 Subject: [PATCH 051/489] feat: add equality checks to reduce computation spent on equal outputs --- .../intrinsic-test/src/common/compare.rs | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index 38fa8dc0ec99..b89059f9ebfc 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -11,16 +11,20 @@ fn runner_command(runner: &str) -> Command { } pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: &str) -> bool { - let c = runner_command(runner) - .arg("./intrinsic-test-programs") - .current_dir("c_programs") - .output(); - - let rust = runner_command(runner) - .arg(format!("./target/{target}/release/intrinsic-test-programs")) - .current_dir("rust_programs") - .output(); - + let (c, rust) = rayon::join( + || { + runner_command(runner) + .arg("./intrinsic-test-programs") + .current_dir("c_programs") + .output() + }, + || { + runner_command(runner) + .arg(format!("./target/{target}/release/intrinsic-test-programs")) + .current_dir("rust_programs") + .output() + }, + ); let (c, rust) = match (c, rust) { (Ok(c), Ok(rust)) => (c, rust), a => panic!("{a:#?}"), @@ -70,18 +74,22 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: .filter_map(|&&intrinsic| { let c_output = c_output_map.get(intrinsic).unwrap(); let rust_output = rust_output_map.get(intrinsic).unwrap(); - let diff = diff::lines(c_output, rust_output); - let diffs = diff - .into_iter() - .filter_map(|diff| match diff { - diff::Result::Left(_) | diff::Result::Right(_) => Some(diff), - diff::Result::Both(_, _) => None, - }) - .collect_vec(); - if diffs.len() > 0 { - Some((intrinsic, diffs)) - } else { + if rust_output.to_string() == c_output.to_string() { None + } else { + let diff = diff::lines(c_output, rust_output); + let diffs = diff + .into_iter() + .filter_map(|diff| match diff { + diff::Result::Left(_) | diff::Result::Right(_) => Some(diff), + diff::Result::Both(_, _) => None, + }) + .collect_vec(); + if diffs.len() > 0 { + Some((intrinsic, diffs)) + } else { + None + } } }) .inspect(|(intrinsic, diffs)| { From 7215e078f575aec225aeca06a13999b6cf16f532 Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Wed, 5 Nov 2025 11:20:12 +0530 Subject: [PATCH 052/489] feat: extract the delimiter to a const value for uniformity --- .../stdarch/crates/intrinsic-test/src/common/compare.rs | 9 +++++---- .../stdarch/crates/intrinsic-test/src/common/gen_c.rs | 6 +++++- .../stdarch/crates/intrinsic-test/src/common/gen_rust.rs | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index b89059f9ebfc..7c5d87b51fe3 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -2,6 +2,7 @@ use itertools::Itertools; use rayon::prelude::*; use std::{collections::HashMap, process::Command}; +pub const INTRINSIC_DELIMITER: &str = "############"; fn runner_command(runner: &str) -> Command { let mut it = runner.split_whitespace(); let mut cmd = Command::new(it.next().unwrap()); @@ -27,7 +28,7 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: ); let (c, rust) = match (c, rust) { (Ok(c), Ok(rust)) => (c, rust), - a => panic!("{a:#?}"), + failure => panic!("Failed to run: {failure:#?}"), }; if !c.status.success() { @@ -56,11 +57,11 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: .replace("-nan", "nan"); let c_output_map = c - .split("############") + .split(INTRINSIC_DELIMITER) .filter_map(|output| output.trim().split_once("\n")) .collect::>(); let rust_output_map = rust - .split("############") + .split(INTRINSIC_DELIMITER) .filter_map(|output| output.trim().split_once("\n")) .collect::>(); @@ -74,7 +75,7 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: .filter_map(|&&intrinsic| { let c_output = c_output_map.get(intrinsic).unwrap(); let rust_output = rust_output_map.get(intrinsic).unwrap(); - if rust_output.to_string() == c_output.to_string() { + if rust_output.eq(c_output) { None } else { let diff = diff::lines(c_output, rust_output); diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs index 30f359a27ef1..a95b4c36b7bf 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_c.rs @@ -1,6 +1,7 @@ use crate::common::intrinsic::Intrinsic; use super::argument::Argument; +use super::compare::INTRINSIC_DELIMITER; use super::indentation::Indentation; use super::intrinsic_helpers::IntrinsicTypeDefinition; @@ -149,7 +150,10 @@ pub fn write_main_cpp<'a>( writeln!(w, "int main(int argc, char **argv) {{")?; for intrinsic in intrinsics { - writeln!(w, " std::cout << \"############\" << std::endl;")?; + writeln!( + w, + " std::cout << \"{INTRINSIC_DELIMITER}\" << std::endl;" + )?; writeln!(w, " std::cout << \"{intrinsic}\" << std::endl;")?; writeln!(w, " run_{intrinsic}();\n")?; } diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs index afc6ca45561a..fb047e2612de 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs @@ -1,11 +1,11 @@ use itertools::Itertools; use std::process::Command; -use crate::common::argument::ArgumentList; -use crate::common::intrinsic::Intrinsic; - +use super::compare::INTRINSIC_DELIMITER; use super::indentation::Indentation; use super::intrinsic_helpers::IntrinsicTypeDefinition; +use crate::common::argument::ArgumentList; +use crate::common::intrinsic::Intrinsic; // The number of times each intrinsic will be called. pub(crate) const PASSES: u32 = 20; @@ -87,7 +87,7 @@ pub fn write_main_rs<'a>( writeln!(w, "fn main() {{")?; for binary in intrinsics { - writeln!(w, " println!(\"############\");")?; + writeln!(w, " println!(\"{INTRINSIC_DELIMITER}\");")?; writeln!(w, " println!(\"{binary}\");")?; writeln!(w, " run_{binary}();\n")?; } From 060b4d347c9e63a4388336c61c2963384224214e Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Wed, 5 Nov 2025 11:57:59 +0530 Subject: [PATCH 053/489] feat: reduce the intrinsics coverage for x86_64 intrinsics --- library/stdarch/ci/intrinsic-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index 2b40044462aa..ff76a0c76996 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -75,7 +75,7 @@ case ${TARGET} in TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER}" TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_x86.txt - : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=30}" + : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=20}" ;; *) ;; From d5c259097287375ea8a3f11381d8832d4f4b3eef Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Wed, 5 Nov 2025 12:41:58 +0530 Subject: [PATCH 054/489] chore: logging to trace the time taken by binaries to complete a run --- library/stdarch/crates/intrinsic-test/src/common/compare.rs | 3 +++ library/stdarch/crates/intrinsic-test/src/main.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index 7c5d87b51fe3..c4c2a1e3e482 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -47,6 +47,7 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: ); } + info!("Completed running C++ and Rust test binaries"); let c = std::str::from_utf8(&c.stdout) .unwrap() .to_lowercase() @@ -70,6 +71,8 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: .chain(rust_output_map.keys()) .unique() .collect_vec(); + + info!("Comparing outputs"); let intrinsics_diff_count = intrinsics .par_iter() .filter_map(|&&intrinsic| { diff --git a/library/stdarch/crates/intrinsic-test/src/main.rs b/library/stdarch/crates/intrinsic-test/src/main.rs index 3580d80bd112..e5c846877ce6 100644 --- a/library/stdarch/crates/intrinsic-test/src/main.rs +++ b/library/stdarch/crates/intrinsic-test/src/main.rs @@ -34,7 +34,7 @@ fn run(test_environment: impl SupportedArchitectureTest) { if !test_environment.build_rust_file() { std::process::exit(3); } - info!("comparing outputs"); + info!("Running binaries"); if !test_environment.compare_outputs() { std::process::exit(1); } From b963d298528db5881c1c594bb4aed8ffb1f57cbb Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 11 Nov 2025 03:43:37 +0530 Subject: [PATCH 055/489] Use ordered reduction intrinsics for integer reductions only ordered intrinsics have implementation in rustc-const-eval --- .../crates/core_arch/src/x86/avx512bw.rs | 32 +++++++++---------- .../crates/core_arch/src/x86/avx512f.rs | 30 ++++++++--------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 5d17d42532f1..c76ec3cb290e 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -4778,7 +4778,7 @@ pub fn _mm_mask_cmp_epi8_mask(k1: __mmask16, a: __m128i, b: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_reduce_add_epi16(a: __m256i) -> i16 { - unsafe { simd_reduce_add_unordered(a.as_i16x16()) } + unsafe { simd_reduce_add_ordered(a.as_i16x16(), 0) } } /// Reduce the packed 16-bit integers in a by addition using mask k. Returns the sum of all active elements in a. @@ -4788,7 +4788,7 @@ pub fn _mm256_reduce_add_epi16(a: __m256i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_mask_reduce_add_epi16(k: __mmask16, a: __m256i) -> i16 { - unsafe { simd_reduce_add_unordered(simd_select_bitmask(k, a.as_i16x16(), i16x16::ZERO)) } + unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i16x16(), i16x16::ZERO), 0) } } /// Reduce the packed 16-bit integers in a by addition. Returns the sum of all elements in a. @@ -4798,7 +4798,7 @@ pub fn _mm256_mask_reduce_add_epi16(k: __mmask16, a: __m256i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_reduce_add_epi16(a: __m128i) -> i16 { - unsafe { simd_reduce_add_unordered(a.as_i16x8()) } + unsafe { simd_reduce_add_ordered(a.as_i16x8(), 0) } } /// Reduce the packed 16-bit integers in a by addition using mask k. Returns the sum of all active elements in a. @@ -4808,7 +4808,7 @@ pub fn _mm_reduce_add_epi16(a: __m128i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_mask_reduce_add_epi16(k: __mmask8, a: __m128i) -> i16 { - unsafe { simd_reduce_add_unordered(simd_select_bitmask(k, a.as_i16x8(), i16x8::ZERO)) } + unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i16x8(), i16x8::ZERO), 0) } } /// Reduce the packed 8-bit integers in a by addition. Returns the sum of all elements in a. @@ -4818,7 +4818,7 @@ pub fn _mm_mask_reduce_add_epi16(k: __mmask8, a: __m128i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_reduce_add_epi8(a: __m256i) -> i8 { - unsafe { simd_reduce_add_unordered(a.as_i8x32()) } + unsafe { simd_reduce_add_ordered(a.as_i8x32(), 0) } } /// Reduce the packed 8-bit integers in a by addition using mask k. Returns the sum of all active elements in a. @@ -4828,7 +4828,7 @@ pub fn _mm256_reduce_add_epi8(a: __m256i) -> i8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_mask_reduce_add_epi8(k: __mmask32, a: __m256i) -> i8 { - unsafe { simd_reduce_add_unordered(simd_select_bitmask(k, a.as_i8x32(), i8x32::ZERO)) } + unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i8x32(), i8x32::ZERO), 0) } } /// Reduce the packed 8-bit integers in a by addition. Returns the sum of all elements in a. @@ -4838,7 +4838,7 @@ pub fn _mm256_mask_reduce_add_epi8(k: __mmask32, a: __m256i) -> i8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_reduce_add_epi8(a: __m128i) -> i8 { - unsafe { simd_reduce_add_unordered(a.as_i8x16()) } + unsafe { simd_reduce_add_ordered(a.as_i8x16(), 0) } } /// Reduce the packed 8-bit integers in a by addition using mask k. Returns the sum of all active elements in a. @@ -4848,7 +4848,7 @@ pub fn _mm_reduce_add_epi8(a: __m128i) -> i8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_mask_reduce_add_epi8(k: __mmask16, a: __m128i) -> i8 { - unsafe { simd_reduce_add_unordered(simd_select_bitmask(k, a.as_i8x16(), i8x16::ZERO)) } + unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i8x16(), i8x16::ZERO), 0) } } /// Reduce the packed 16-bit integers in a by bitwise AND. Returns the bitwise AND of all elements in a. @@ -5282,7 +5282,7 @@ pub fn _mm_mask_reduce_min_epu8(k: __mmask16, a: __m128i) -> u8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_reduce_mul_epi16(a: __m256i) -> i16 { - unsafe { simd_reduce_mul_unordered(a.as_i16x16()) } + unsafe { simd_reduce_mul_ordered(a.as_i16x16(), 1) } } /// Reduce the packed 16-bit integers in a by multiplication using mask k. Returns the product of all active elements in a. @@ -5292,7 +5292,7 @@ pub fn _mm256_reduce_mul_epi16(a: __m256i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_mask_reduce_mul_epi16(k: __mmask16, a: __m256i) -> i16 { - unsafe { simd_reduce_mul_unordered(simd_select_bitmask(k, a.as_i16x16(), i16x16::splat(1))) } + unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i16x16(), i16x16::splat(1)), 1) } } /// Reduce the packed 16-bit integers in a by multiplication. Returns the product of all elements in a. @@ -5302,7 +5302,7 @@ pub fn _mm256_mask_reduce_mul_epi16(k: __mmask16, a: __m256i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_reduce_mul_epi16(a: __m128i) -> i16 { - unsafe { simd_reduce_mul_unordered(a.as_i16x8()) } + unsafe { simd_reduce_mul_ordered(a.as_i16x8(), 1) } } /// Reduce the packed 16-bit integers in a by multiplication using mask k. Returns the product of all active elements in a. @@ -5312,7 +5312,7 @@ pub fn _mm_reduce_mul_epi16(a: __m128i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_mask_reduce_mul_epi16(k: __mmask8, a: __m128i) -> i16 { - unsafe { simd_reduce_mul_unordered(simd_select_bitmask(k, a.as_i16x8(), i16x8::splat(1))) } + unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i16x8(), i16x8::splat(1)), 1) } } /// Reduce the packed 8-bit integers in a by multiplication. Returns the product of all elements in a. @@ -5322,7 +5322,7 @@ pub fn _mm_mask_reduce_mul_epi16(k: __mmask8, a: __m128i) -> i16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_reduce_mul_epi8(a: __m256i) -> i8 { - unsafe { simd_reduce_mul_unordered(a.as_i8x32()) } + unsafe { simd_reduce_mul_ordered(a.as_i8x32(), 1) } } /// Reduce the packed 8-bit integers in a by multiplication using mask k. Returns the product of all active elements in a. @@ -5332,7 +5332,7 @@ pub fn _mm256_reduce_mul_epi8(a: __m256i) -> i8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm256_mask_reduce_mul_epi8(k: __mmask32, a: __m256i) -> i8 { - unsafe { simd_reduce_mul_unordered(simd_select_bitmask(k, a.as_i8x32(), i8x32::splat(1))) } + unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i8x32(), i8x32::splat(1)), 1) } } /// Reduce the packed 8-bit integers in a by multiplication. Returns the product of all elements in a. @@ -5342,7 +5342,7 @@ pub fn _mm256_mask_reduce_mul_epi8(k: __mmask32, a: __m256i) -> i8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_reduce_mul_epi8(a: __m128i) -> i8 { - unsafe { simd_reduce_mul_unordered(a.as_i8x16()) } + unsafe { simd_reduce_mul_ordered(a.as_i8x16(), 1) } } /// Reduce the packed 8-bit integers in a by multiplication using mask k. Returns the product of all active elements in a. @@ -5352,7 +5352,7 @@ pub fn _mm_reduce_mul_epi8(a: __m128i) -> i8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm_mask_reduce_mul_epi8(k: __mmask16, a: __m128i) -> i8 { - unsafe { simd_reduce_mul_unordered(simd_select_bitmask(k, a.as_i8x16(), i8x16::splat(1))) } + unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i8x16(), i8x16::splat(1)), 1) } } /// Reduce the packed 16-bit integers in a by bitwise OR. Returns the bitwise OR of all elements in a. diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index 8d3ddbd964bb..d6b30d2d7d86 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -33101,7 +33101,7 @@ pub fn _mm_mask_cmp_epi64_mask( #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_reduce_add_epi32(a: __m512i) -> i32 { - unsafe { simd_reduce_add_unordered(a.as_i32x16()) } + unsafe { simd_reduce_add_ordered(a.as_i32x16(), 0) } } /// Reduce the packed 32-bit integers in a by addition using mask k. Returns the sum of all active elements in a. @@ -33111,7 +33111,7 @@ pub fn _mm512_reduce_add_epi32(a: __m512i) -> i32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_mask_reduce_add_epi32(k: __mmask16, a: __m512i) -> i32 { - unsafe { simd_reduce_add_unordered(simd_select_bitmask(k, a.as_i32x16(), i32x16::ZERO)) } + unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i32x16(), i32x16::ZERO), 0) } } /// Reduce the packed 64-bit integers in a by addition. Returns the sum of all elements in a. @@ -33121,7 +33121,7 @@ pub fn _mm512_mask_reduce_add_epi32(k: __mmask16, a: __m512i) -> i32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_reduce_add_epi64(a: __m512i) -> i64 { - unsafe { simd_reduce_add_unordered(a.as_i64x8()) } + unsafe { simd_reduce_add_ordered(a.as_i64x8(), 0) } } /// Reduce the packed 64-bit integers in a by addition using mask k. Returns the sum of all active elements in a. @@ -33131,7 +33131,7 @@ pub fn _mm512_reduce_add_epi64(a: __m512i) -> i64 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_mask_reduce_add_epi64(k: __mmask8, a: __m512i) -> i64 { - unsafe { simd_reduce_add_unordered(simd_select_bitmask(k, a.as_i64x8(), i64x8::ZERO)) } + unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i64x8(), i64x8::ZERO), 0) } } /// Reduce the packed single-precision (32-bit) floating-point elements in a by addition. Returns the sum of all elements in a. @@ -33197,7 +33197,7 @@ pub fn _mm512_mask_reduce_add_pd(k: __mmask8, a: __m512d) -> f64 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_reduce_mul_epi32(a: __m512i) -> i32 { - unsafe { simd_reduce_mul_unordered(a.as_i32x16()) } + unsafe { simd_reduce_mul_ordered(a.as_i32x16(), 1) } } /// Reduce the packed 32-bit integers in a by multiplication using mask k. Returns the product of all active elements in a. @@ -33208,11 +33208,10 @@ pub fn _mm512_reduce_mul_epi32(a: __m512i) -> i32 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_mask_reduce_mul_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { - simd_reduce_mul_unordered(simd_select_bitmask( - k, - a.as_i32x16(), - _mm512_set1_epi32(1).as_i32x16(), - )) + simd_reduce_mul_ordered( + simd_select_bitmask(k, a.as_i32x16(), _mm512_set1_epi32(1).as_i32x16()), + 1, + ) } } @@ -33223,7 +33222,7 @@ pub fn _mm512_mask_reduce_mul_epi32(k: __mmask16, a: __m512i) -> i32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_reduce_mul_epi64(a: __m512i) -> i64 { - unsafe { simd_reduce_mul_unordered(a.as_i64x8()) } + unsafe { simd_reduce_mul_ordered(a.as_i64x8(), 1) } } /// Reduce the packed 64-bit integers in a by multiplication using mask k. Returns the product of all active elements in a. @@ -33234,11 +33233,10 @@ pub fn _mm512_reduce_mul_epi64(a: __m512i) -> i64 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub fn _mm512_mask_reduce_mul_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { - simd_reduce_mul_unordered(simd_select_bitmask( - k, - a.as_i64x8(), - _mm512_set1_epi64(1).as_i64x8(), - )) + simd_reduce_mul_ordered( + simd_select_bitmask(k, a.as_i64x8(), _mm512_set1_epi64(1).as_i64x8()), + 1, + ) } } From 453377b0ffac4c0f4b70340ee17045faf55f23da Mon Sep 17 00:00:00 2001 From: sayantn Date: Mon, 15 Sep 2025 04:50:49 +0530 Subject: [PATCH 056/489] Make some helpers `const` --- library/stdarch/crates/core_arch/src/lib.rs | 5 +- library/stdarch/crates/core_arch/src/mod.rs | 5 + library/stdarch/crates/core_arch/src/simd.rs | 24 +- library/stdarch/crates/core_arch/src/test.rs | 25 ++ .../crates/core_arch/src/x86/avx512fp16.rs | 9 +- .../stdarch/crates/core_arch/src/x86/mod.rs | 4 +- .../stdarch/crates/core_arch/src/x86/test.rs | 295 +++++++++++------- 7 files changed, 247 insertions(+), 120 deletions(-) create mode 100644 library/stdarch/crates/core_arch/src/test.rs diff --git a/library/stdarch/crates/core_arch/src/lib.rs b/library/stdarch/crates/core_arch/src/lib.rs index a059a9c22570..5bedefe42d6e 100644 --- a/library/stdarch/crates/core_arch/src/lib.rs +++ b/library/stdarch/crates/core_arch/src/lib.rs @@ -34,7 +34,10 @@ aarch64_unstable_target_feature, bigint_helper_methods, funnel_shifts, - avx10_target_feature + avx10_target_feature, + const_trait_impl, + const_cmp, + const_eval_select )] #![cfg_attr(test, feature(test, abi_vectorcall, stdarch_internal))] #![deny(clippy::missing_inline_in_public_items)] diff --git a/library/stdarch/crates/core_arch/src/mod.rs b/library/stdarch/crates/core_arch/src/mod.rs index 2105cca1b438..7fc0ed0fca11 100644 --- a/library/stdarch/crates/core_arch/src/mod.rs +++ b/library/stdarch/crates/core_arch/src/mod.rs @@ -5,6 +5,11 @@ #[macro_use] mod macros; +#[cfg(test)] +mod test; +#[cfg(test)] +use test::assert_eq_const; + #[cfg(any(target_arch = "riscv32", target_arch = "riscv64", doc))] mod riscv_shared; diff --git a/library/stdarch/crates/core_arch/src/simd.rs b/library/stdarch/crates/core_arch/src/simd.rs index 9fa8e2502265..b9dbde75971d 100644 --- a/library/stdarch/crates/core_arch/src/simd.rs +++ b/library/stdarch/crates/core_arch/src/simd.rs @@ -3,13 +3,15 @@ #![allow(non_camel_case_types)] #[inline(always)] -pub(crate) unsafe fn simd_imax(a: T, b: T) -> T { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub(crate) const unsafe fn simd_imax(a: T, b: T) -> T { let mask: T = crate::intrinsics::simd::simd_gt(a, b); crate::intrinsics::simd::simd_select(mask, a, b) } #[inline(always)] -pub(crate) unsafe fn simd_imin(a: T, b: T) -> T { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub(crate) const unsafe fn simd_imin(a: T, b: T) -> T { let mask: T = crate::intrinsics::simd::simd_lt(a, b); crate::intrinsics::simd::simd_select(mask, a, b) } @@ -35,7 +37,8 @@ macro_rules! simd_ty { } // FIXME: Workaround rust@60637 #[inline(always)] - pub(crate) fn splat(value: $elem_type) -> Self { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + pub(crate) const fn splat(value: $elem_type) -> Self { #[derive(Copy, Clone)] #[repr(simd)] struct JustOne([$elem_type; 1]); @@ -50,12 +53,12 @@ macro_rules! simd_ty { /// Use for testing only. // FIXME: Workaround rust@60637 #[inline(always)] - pub(crate) fn extract(&self, index: usize) -> $elem_type { + pub(crate) const fn extract(&self, index: usize) -> $elem_type { self.as_array()[index] } #[inline] - pub(crate) fn as_array(&self) -> &[$elem_type; $len] { + pub(crate) const fn as_array(&self) -> &[$elem_type; $len] { let simd_ptr: *const Self = self; let array_ptr: *const [$elem_type; $len] = simd_ptr.cast(); // SAFETY: We can always read the prefix of a simd type as an array. @@ -65,7 +68,8 @@ macro_rules! simd_ty { } } - impl core::cmp::PartialEq for $id { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const impl core::cmp::PartialEq for $id { #[inline] fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() @@ -101,7 +105,8 @@ macro_rules! simd_m_ty { // FIXME: Workaround rust@60637 #[inline(always)] - pub(crate) fn splat(value: bool) -> Self { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + pub(crate) const fn splat(value: bool) -> Self { #[derive(Copy, Clone)] #[repr(simd)] struct JustOne([$elem_type; 1]); @@ -112,7 +117,7 @@ macro_rules! simd_m_ty { } #[inline] - pub(crate) fn as_array(&self) -> &[$elem_type; $len] { + pub(crate) const fn as_array(&self) -> &[$elem_type; $len] { let simd_ptr: *const Self = self; let array_ptr: *const [$elem_type; $len] = simd_ptr.cast(); // SAFETY: We can always read the prefix of a simd type as an array. @@ -122,7 +127,8 @@ macro_rules! simd_m_ty { } } - impl core::cmp::PartialEq for $id { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const impl core::cmp::PartialEq for $id { #[inline] fn eq(&self, other: &Self) -> bool { self.as_array() == other.as_array() diff --git a/library/stdarch/crates/core_arch/src/test.rs b/library/stdarch/crates/core_arch/src/test.rs new file mode 100644 index 000000000000..976d4ac1b023 --- /dev/null +++ b/library/stdarch/crates/core_arch/src/test.rs @@ -0,0 +1,25 @@ +use crate::fmt::Debug; + +#[track_caller] +#[allow(unused)] +pub(crate) fn assert_eq_rt(a: &T, b: &T) { + std::assert_eq!(a, b) +} + +#[allow(unused)] +macro_rules! assert_eq_const { + ($a:expr, $b:expr $(,)?) => {{ + #[inline(always)] + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const fn assert_eq_ct(a: &T, b: &T) { + assert!(a == b, concat!("`", stringify!($a), "` != `", stringify!($b), "`")); + } + + $crate::intrinsics::const_eval_select((&$a, &$b), assert_eq_ct, $crate::core_arch::test::assert_eq_rt); + }}; + ($a:expr, $b:expr, $($t:tt)+) => { + ::std::assert_eq!($a, $b, $($t)+) + }; +} + +pub(crate) use assert_eq_const; diff --git a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs index 01b1be364fe5..7185531606d2 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs @@ -16714,19 +16714,22 @@ mod tests { use stdarch_test::simd_test; #[target_feature(enable = "avx512fp16")] - unsafe fn _mm_set1_pch(re: f16, im: f16) -> __m128h { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const fn _mm_set1_pch(re: f16, im: f16) -> __m128h { _mm_setr_ph(re, im, re, im, re, im, re, im) } #[target_feature(enable = "avx512fp16")] - unsafe fn _mm256_set1_pch(re: f16, im: f16) -> __m256h { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const fn _mm256_set1_pch(re: f16, im: f16) -> __m256h { _mm256_setr_ph( re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, ) } #[target_feature(enable = "avx512fp16")] - unsafe fn _mm512_set1_pch(re: f16, im: f16) -> __m512h { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const fn _mm512_set1_pch(re: f16, im: f16) -> __m512h { _mm512_setr_ph( re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, diff --git a/library/stdarch/crates/core_arch/src/x86/mod.rs b/library/stdarch/crates/core_arch/src/x86/mod.rs index 79a593e647f1..7612cffd078a 100644 --- a/library/stdarch/crates/core_arch/src/x86/mod.rs +++ b/library/stdarch/crates/core_arch/src/x86/mod.rs @@ -520,14 +520,14 @@ macro_rules! as_transmute { ($from:ty => $as_from:ident, $($as_to:ident -> $to:ident),* $(,)?) => { impl $from {$( #[inline] - pub(crate) fn $as_to(self) -> crate::core_arch::simd::$to { + pub(crate) const fn $as_to(self) -> crate::core_arch::simd::$to { unsafe { transmute(self) } } )*} $( impl crate::core_arch::simd::$to { #[inline] - pub(crate) fn $as_from(self) -> $from { + pub(crate) const fn $as_from(self) -> $from { unsafe { transmute(self) } } } diff --git a/library/stdarch/crates/core_arch/src/x86/test.rs b/library/stdarch/crates/core_arch/src/x86/test.rs index fec25ce2bc7c..9fa88fc98d60 100644 --- a/library/stdarch/crates/core_arch/src/x86/test.rs +++ b/library/stdarch/crates/core_arch/src/x86/test.rs @@ -1,115 +1,228 @@ //! Utilities used in testing the x86 intrinsics +use crate::core_arch::assert_eq_const as assert_eq; use crate::core_arch::x86::*; use std::mem::transmute; #[track_caller] #[target_feature(enable = "sse2")] -pub unsafe fn assert_eq_m128i(a: __m128i, b: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub(crate) const unsafe fn assert_eq_m128i(a: __m128i, b: __m128i) { assert_eq!(transmute::<_, [u64; 2]>(a), transmute::<_, [u64; 2]>(b)) } -#[track_caller] -#[target_feature(enable = "sse2")] -pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { - if _mm_movemask_pd(_mm_cmpeq_pd(a, b)) != 0b11 { - panic!("{:?} != {:?}", a, b); - } -} - -#[target_feature(enable = "sse2")] -pub unsafe fn get_m128d(a: __m128d, idx: usize) -> f64 { - transmute::<_, [f64; 2]>(a)[idx] -} - -#[track_caller] -#[target_feature(enable = "sse")] -pub unsafe fn assert_eq_m128(a: __m128, b: __m128) { - let r = _mm_cmpeq_ps(a, b); - if _mm_movemask_ps(r) != 0b1111 { - panic!("{:?} != {:?}", a, b); - } -} - -#[target_feature(enable = "sse")] -pub unsafe fn get_m128(a: __m128, idx: usize) -> f32 { - transmute::<_, [f32; 4]>(a)[idx] -} - -#[track_caller] -#[target_feature(enable = "avx512fp16,avx512vl")] -pub unsafe fn assert_eq_m128h(a: __m128h, b: __m128h) { - let r = _mm_cmp_ph_mask::<_CMP_EQ_OQ>(a, b); - if r != 0b1111_1111 { - panic!("{:?} != {:?}", a, b); - } -} - -// not actually an intrinsic but useful in various tests as we proted from -// `i64x2::new` which is backwards from `_mm_set_epi64x` -#[target_feature(enable = "sse2")] -pub unsafe fn _mm_setr_epi64x(a: i64, b: i64) -> __m128i { - _mm_set_epi64x(b, a) -} - #[track_caller] #[target_feature(enable = "avx")] -pub unsafe fn assert_eq_m256i(a: __m256i, b: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub(crate) const unsafe fn assert_eq_m256i(a: __m256i, b: __m256i) { assert_eq!(transmute::<_, [u64; 4]>(a), transmute::<_, [u64; 4]>(b)) } #[track_caller] -#[target_feature(enable = "avx")] -pub unsafe fn assert_eq_m256d(a: __m256d, b: __m256d) { - let cmp = _mm256_cmp_pd::<_CMP_EQ_OQ>(a, b); - if _mm256_movemask_pd(cmp) != 0b1111 { - panic!("{:?} != {:?}", a, b); +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub(crate) const unsafe fn assert_eq_m512i(a: __m512i, b: __m512i) { + assert_eq!(transmute::<_, [i32; 16]>(a), transmute::<_, [i32; 16]>(b)) +} + +macro_rules! make_ct_rt { + ($( + $( #[$meta:meta] )* + $vis:vis unsafe fn $name:ident ($($param:ident : $type:ty),* $(,)?) { + ct: $ct:expr; + rt: $rt:expr; + } + )*) => {$( + $( #[$meta] )* + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + $vis const unsafe fn $name ($($param : $type),*) { + #[inline(always)] + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + const fn ct($($param : $type),*) { + $ct + } + #[inline(always)] + fn rt($($param : $type),*) { + $rt + } + + $crate::intrinsics::const_eval_select(($($param),*), ct, rt) + } + )*} +} + +make_ct_rt! { + // SAFETY: we can use simple float equality because when this should only be used in const + // context where Intel peculiarities don't appear + + #[track_caller] + #[target_feature(enable = "sse2")] + pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { + ct: unsafe { + assert_eq!(transmute::<_, [f64; 2]>(a), transmute::<_, [f64; 2]>(b)) + }; + rt: unsafe { + if _mm_movemask_pd(_mm_cmpeq_pd(a, b)) != 0b11 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "sse")] + pub unsafe fn assert_eq_m128(a: __m128, b: __m128) { + ct: unsafe { + assert_eq!(transmute::<_, [f32; 4]>(a), transmute::<_, [f32; 4]>(b)) + }; + rt: unsafe { + let r = _mm_cmpeq_ps(a, b); + if _mm_movemask_ps(r) != 0b1111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx512fp16,avx512vl")] + pub unsafe fn assert_eq_m128h(a: __m128h, b: __m128h) { + ct: unsafe { + assert_eq!(transmute::<_, [f16; 8]>(a), transmute::<_, [f16; 8]>(b)) + }; + rt: unsafe { + let r = _mm_cmp_ph_mask::<_CMP_EQ_OQ>(a, b); + if r != 0b1111_1111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx")] + pub unsafe fn assert_eq_m256d(a: __m256d, b: __m256d) { + ct: unsafe { + assert_eq!(transmute::<_, [f64; 4]>(a), transmute::<_, [f64; 4]>(b)) + }; + rt: unsafe { + let cmp = _mm256_cmp_pd::<_CMP_EQ_OQ>(a, b); + if _mm256_movemask_pd(cmp) != 0b1111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx")] + pub unsafe fn assert_eq_m256(a: __m256, b: __m256) { + ct: unsafe { + assert_eq!(transmute::<_, [f32; 8]>(a), transmute::<_, [f32; 8]>(b)) + }; + rt: unsafe { + let cmp = _mm256_cmp_ps::<_CMP_EQ_OQ>(a, b); + if _mm256_movemask_ps(cmp) != 0b11111111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx512fp16,avx512vl")] + pub unsafe fn assert_eq_m256h(a: __m256h, b: __m256h) { + ct: unsafe { + assert_eq!(transmute::<_, [f16; 16]>(a), transmute::<_, [f16; 16]>(b)) + }; + rt: unsafe { + let r = _mm256_cmp_ph_mask::<_CMP_EQ_OQ>(a, b); + if r != 0b11111111_11111111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx512f")] + pub unsafe fn assert_eq_m512d(a: __m512d, b: __m512d) { + ct: unsafe { + assert_eq!(transmute::<_, [f64; 8]>(a), transmute::<_, [f64; 8]>(b)) + }; + rt: unsafe { + let cmp = _mm512_cmp_pd_mask::<_CMP_EQ_OQ>(a, b); + if cmp != 0b11111111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx512f")] + pub unsafe fn assert_eq_m512(a: __m512, b: __m512) { + ct: unsafe { + assert_eq!(transmute::<_, [f32; 16]>(a), transmute::<_, [f32; 16]>(b)) + }; + rt: unsafe { + let cmp = _mm512_cmp_ps_mask::<_CMP_EQ_OQ>(a, b); + if cmp != 0b11111111_11111111 { + panic!("{:?} != {:?}", a, b); + } + }; + } + + #[track_caller] + #[target_feature(enable = "avx512fp16")] + pub unsafe fn assert_eq_m512h(a: __m512h, b: __m512h) { + ct: unsafe { + assert_eq!(transmute::<_, [f16; 32]>(a), transmute::<_, [f16; 32]>(b)) + }; + rt: unsafe { + let r = _mm512_cmp_ph_mask::<_CMP_EQ_OQ>(a, b); + if r != 0b11111111_11111111_11111111_11111111 { + panic!("{:?} != {:?}", a, b); + } + }; } } +#[target_feature(enable = "sse2")] +pub(crate) const unsafe fn get_m128d(a: __m128d, idx: usize) -> f64 { + transmute::<_, [f64; 2]>(a)[idx] +} + +#[target_feature(enable = "sse")] +pub(crate) const unsafe fn get_m128(a: __m128, idx: usize) -> f32 { + transmute::<_, [f32; 4]>(a)[idx] +} + #[target_feature(enable = "avx")] -pub unsafe fn get_m256d(a: __m256d, idx: usize) -> f64 { +pub(crate) const unsafe fn get_m256d(a: __m256d, idx: usize) -> f64 { transmute::<_, [f64; 4]>(a)[idx] } -#[track_caller] #[target_feature(enable = "avx")] -pub unsafe fn assert_eq_m256(a: __m256, b: __m256) { - let cmp = _mm256_cmp_ps::<_CMP_EQ_OQ>(a, b); - if _mm256_movemask_ps(cmp) != 0b11111111 { - panic!("{:?} != {:?}", a, b); - } -} - -#[target_feature(enable = "avx")] -pub unsafe fn get_m256(a: __m256, idx: usize) -> f32 { +pub(crate) const unsafe fn get_m256(a: __m256, idx: usize) -> f32 { transmute::<_, [f32; 8]>(a)[idx] } -#[track_caller] -#[target_feature(enable = "avx512fp16,avx512vl")] -pub unsafe fn assert_eq_m256h(a: __m256h, b: __m256h) { - let r = _mm256_cmp_ph_mask::<_CMP_EQ_OQ>(a, b); - if r != 0b11111111_11111111 { - panic!("{:?} != {:?}", a, b); - } -} - #[target_feature(enable = "avx512f")] -pub unsafe fn get_m512(a: __m512, idx: usize) -> f32 { +pub(crate) const unsafe fn get_m512(a: __m512, idx: usize) -> f32 { transmute::<_, [f32; 16]>(a)[idx] } #[target_feature(enable = "avx512f")] -pub unsafe fn get_m512d(a: __m512d, idx: usize) -> f64 { +pub(crate) const unsafe fn get_m512d(a: __m512d, idx: usize) -> f64 { transmute::<_, [f64; 8]>(a)[idx] } #[target_feature(enable = "avx512f")] -pub unsafe fn get_m512i(a: __m512i, idx: usize) -> i64 { +pub(crate) const unsafe fn get_m512i(a: __m512i, idx: usize) -> i64 { transmute::<_, [i64; 8]>(a)[idx] } +// not actually an intrinsic but useful in various tests as we ported from +// `i64x2::new` which is backwards from `_mm_set_epi64x` +#[target_feature(enable = "sse2")] +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const unsafe fn _mm_setr_epi64x(a: i64, b: i64) -> __m128i { + _mm_set_epi64x(b, a) +} + // These intrinsics doesn't exist on x86 b/c it requires a 64-bit register, // which doesn't exist on x86! #[cfg(target_arch = "x86")] @@ -118,14 +231,16 @@ mod x86_polyfill { use crate::intrinsics::simd::*; #[rustc_legacy_const_generics(2)] - pub unsafe fn _mm_insert_epi64(a: __m128i, val: i64) -> __m128i { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + pub const unsafe fn _mm_insert_epi64(a: __m128i, val: i64) -> __m128i { static_assert_uimm_bits!(INDEX, 1); transmute(simd_insert!(a.as_i64x2(), INDEX as u32, val)) } #[target_feature(enable = "avx2")] #[rustc_legacy_const_generics(2)] - pub unsafe fn _mm256_insert_epi64(a: __m256i, val: i64) -> __m256i { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + pub const unsafe fn _mm256_insert_epi64(a: __m256i, val: i64) -> __m256i { static_assert_uimm_bits!(INDEX, 2); transmute(simd_insert!(a.as_i64x4(), INDEX as u32, val)) } @@ -136,33 +251,3 @@ mod x86_polyfill { pub use crate::core_arch::x86_64::{_mm_insert_epi64, _mm256_insert_epi64}; } pub use self::x86_polyfill::*; - -#[track_caller] -pub unsafe fn assert_eq_m512i(a: __m512i, b: __m512i) { - assert_eq!(transmute::<_, [i32; 16]>(a), transmute::<_, [i32; 16]>(b)) -} - -#[track_caller] -pub unsafe fn assert_eq_m512(a: __m512, b: __m512) { - let cmp = _mm512_cmp_ps_mask::<_CMP_EQ_OQ>(a, b); - if cmp != 0b11111111_11111111 { - panic!("{:?} != {:?}", a, b); - } -} - -#[track_caller] -pub unsafe fn assert_eq_m512d(a: __m512d, b: __m512d) { - let cmp = _mm512_cmp_pd_mask::<_CMP_EQ_OQ>(a, b); - if cmp != 0b11111111 { - panic!("{:?} != {:?}", a, b); - } -} - -#[track_caller] -#[target_feature(enable = "avx512fp16")] -pub unsafe fn assert_eq_m512h(a: __m512h, b: __m512h) { - let r = _mm512_cmp_ph_mask::<_CMP_EQ_OQ>(a, b); - if r != 0b11111111_11111111_11111111_11111111 { - panic!("{:?} != {:?}", a, b); - } -} From 742e70fe8ff91ca6ac44f098faaed179019064e5 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 25 Nov 2025 09:45:33 +0530 Subject: [PATCH 057/489] Modify `#[simd_test]` to enable const-testing --- .../stdarch/crates/simd-test-macro/src/lib.rs | 70 +++++++++++-------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/library/stdarch/crates/simd-test-macro/src/lib.rs b/library/stdarch/crates/simd-test-macro/src/lib.rs index b18e2d6b63e5..b8bb874480a0 100644 --- a/library/stdarch/crates/simd-test-macro/src/lib.rs +++ b/library/stdarch/crates/simd-test-macro/src/lib.rs @@ -7,43 +7,41 @@ #[macro_use] extern crate quote; -use proc_macro2::{Ident, Literal, Span, TokenStream, TokenTree}; +use proc_macro2::{Ident, Span, TokenStream, TokenTree}; use quote::ToTokens; use std::env; -fn string(s: &str) -> TokenTree { - Literal::string(s).into() -} - #[proc_macro_attribute] pub fn simd_test( attr: proc_macro::TokenStream, item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { let tokens = TokenStream::from(attr).into_iter().collect::>(); - if tokens.len() != 3 { - panic!("expected #[simd_test(enable = \"feature\")]"); - } - match &tokens[0] { - TokenTree::Ident(tt) if *tt == "enable" => {} - _ => panic!("expected #[simd_test(enable = \"feature\")]"), - } - match &tokens[1] { - TokenTree::Punct(tt) if tt.as_char() == '=' => {} - _ => panic!("expected #[simd_test(enable = \"feature\")]"), - } - let enable_feature = match &tokens[2] { - TokenTree::Literal(tt) => tt.to_string(), - _ => panic!("expected #[simd_test(enable = \"feature\")]"), - }; - let enable_feature = enable_feature.trim_start_matches('"').trim_end_matches('"'); - let target_features: Vec = enable_feature - .replace('+', "") - .split(',') - .map(String::from) - .collect(); + let (target_features, target_feature_attr) = match &tokens[..] { + [] => (Vec::new(), TokenStream::new()), + [ + TokenTree::Ident(enable), + TokenTree::Punct(equals), + TokenTree::Literal(literal), + ] if enable == "enable" && equals.as_char() == '=' => { + let enable_feature = literal.to_string(); + let enable_feature = enable_feature.trim_start_matches('"').trim_end_matches('"'); + let target_features: Vec<_> = enable_feature + .replace('+', "") + .split(',') + .map(String::from) + .collect(); + + ( + target_features, + quote! { + #[target_feature(enable = #enable_feature)] + }, + ) + } + _ => panic!("expected #[simd_test(enable = \"feature\")] or #[simd_test]"), + }; - let enable_feature = string(enable_feature); let mut item = syn::parse_macro_input!(item as syn::ItemFn); let item_attrs = std::mem::take(&mut item.attrs); let name = &item.sig.ident; @@ -102,6 +100,19 @@ pub fn simd_test( TokenStream::new() }; + let (const_test, const_stability) = if item.sig.constness.is_some() { + ( + quote! { + const _: () = unsafe { #name() }; + }, + quote! { + #[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] + }, + ) + } else { + (TokenStream::new(), TokenStream::new()) + }; + let ret: TokenStream = quote_spanned! { proc_macro2::Span::call_site() => #[allow(non_snake_case)] @@ -109,6 +120,8 @@ pub fn simd_test( #maybe_ignore #(#item_attrs)* fn #name() { + #const_test + let mut missing_features = ::std::vec::Vec::new(); #detect_missing_features if missing_features.is_empty() { @@ -118,7 +131,8 @@ pub fn simd_test( ::stdarch_test::assert_skip_test_ok(stringify!(#name), &missing_features); } - #[target_feature(enable = #enable_feature)] + #target_feature_attr + #const_stability #item } }; From 233574ace381e79c9bac17cc2d3dfc03346e257c Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:24:10 +0530 Subject: [PATCH 058/489] Make `abm`, `bmi1`, `bmi2`, `bswap` and `tbm` functions const --- .../stdarch/crates/core_arch/src/x86/abm.rs | 11 +++-- .../stdarch/crates/core_arch/src/x86/bmi1.rs | 34 ++++++++------ .../stdarch/crates/core_arch/src/x86/bmi2.rs | 6 ++- .../stdarch/crates/core_arch/src/x86/bswap.rs | 10 ++-- .../stdarch/crates/core_arch/src/x86/tbm.rs | 46 +++++++++++-------- .../crates/core_arch/src/x86_64/abm.rs | 11 +++-- .../crates/core_arch/src/x86_64/bmi.rs | 29 +++++++----- .../crates/core_arch/src/x86_64/bmi2.rs | 6 ++- .../crates/core_arch/src/x86_64/bswap.rs | 10 ++-- .../crates/core_arch/src/x86_64/tbm.rs | 46 +++++++++++-------- 10 files changed, 131 insertions(+), 78 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/abm.rs b/library/stdarch/crates/core_arch/src/x86/abm.rs index e6d551760043..59f3877b4ace 100644 --- a/library/stdarch/crates/core_arch/src/x86/abm.rs +++ b/library/stdarch/crates/core_arch/src/x86/abm.rs @@ -29,7 +29,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "lzcnt")] #[cfg_attr(test, assert_instr(lzcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _lzcnt_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _lzcnt_u32(x: u32) -> u32 { x.leading_zeros() } @@ -40,23 +41,25 @@ pub fn _lzcnt_u32(x: u32) -> u32 { #[target_feature(enable = "popcnt")] #[cfg_attr(test, assert_instr(popcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _popcnt32(x: i32) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _popcnt32(x: i32) -> i32 { x.count_ones() as i32 } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "lzcnt")] - unsafe fn test_lzcnt_u32() { + const unsafe fn test_lzcnt_u32() { assert_eq!(_lzcnt_u32(0b0101_1010), 25); } #[simd_test(enable = "popcnt")] - unsafe fn test_popcnt32() { + const unsafe fn test_popcnt32() { assert_eq!(_popcnt32(0b0101_1010), 4); } } diff --git a/library/stdarch/crates/core_arch/src/x86/bmi1.rs b/library/stdarch/crates/core_arch/src/x86/bmi1.rs index eb7242944abc..08444aaaeddd 100644 --- a/library/stdarch/crates/core_arch/src/x86/bmi1.rs +++ b/library/stdarch/crates/core_arch/src/x86/bmi1.rs @@ -46,7 +46,8 @@ pub fn _bextr2_u32(a: u32, control: u32) -> u32 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(andn))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _andn_u32(a: u32, b: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _andn_u32(a: u32, b: u32) -> u32 { !a & b } @@ -57,7 +58,8 @@ pub fn _andn_u32(a: u32, b: u32) -> u32 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(blsi))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsi_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsi_u32(x: u32) -> u32 { x & x.wrapping_neg() } @@ -68,7 +70,8 @@ pub fn _blsi_u32(x: u32) -> u32 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(blsmsk))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsmsk_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsmsk_u32(x: u32) -> u32 { x ^ (x.wrapping_sub(1_u32)) } @@ -81,7 +84,8 @@ pub fn _blsmsk_u32(x: u32) -> u32 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(blsr))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsr_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsr_u32(x: u32) -> u32 { x & (x.wrapping_sub(1)) } @@ -94,7 +98,8 @@ pub fn _blsr_u32(x: u32) -> u32 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(tzcnt))] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub fn _tzcnt_u16(x: u16) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _tzcnt_u16(x: u16) -> u16 { x.trailing_zeros() as u16 } @@ -107,7 +112,8 @@ pub fn _tzcnt_u16(x: u16) -> u16 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(tzcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _tzcnt_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _tzcnt_u32(x: u32) -> u32 { x.trailing_zeros() } @@ -120,7 +126,8 @@ pub fn _tzcnt_u32(x: u32) -> u32 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(tzcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_tzcnt_32(x: u32) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_tzcnt_32(x: u32) -> i32 { x.trailing_zeros() as i32 } @@ -131,6 +138,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; @@ -142,7 +150,7 @@ mod tests { } #[simd_test(enable = "bmi1")] - unsafe fn test_andn_u32() { + const unsafe fn test_andn_u32() { assert_eq!(_andn_u32(0, 0), 0); assert_eq!(_andn_u32(0, 1), 1); assert_eq!(_andn_u32(1, 0), 0); @@ -165,32 +173,32 @@ mod tests { } #[simd_test(enable = "bmi1")] - unsafe fn test_blsi_u32() { + const unsafe fn test_blsi_u32() { assert_eq!(_blsi_u32(0b1101_0000u32), 0b0001_0000u32); } #[simd_test(enable = "bmi1")] - unsafe fn test_blsmsk_u32() { + const unsafe fn test_blsmsk_u32() { let r = _blsmsk_u32(0b0011_0000u32); assert_eq!(r, 0b0001_1111u32); } #[simd_test(enable = "bmi1")] - unsafe fn test_blsr_u32() { + const unsafe fn test_blsr_u32() { // TODO: test the behavior when the input is `0`. let r = _blsr_u32(0b0011_0000u32); assert_eq!(r, 0b0010_0000u32); } #[simd_test(enable = "bmi1")] - unsafe fn test_tzcnt_u16() { + const unsafe fn test_tzcnt_u16() { assert_eq!(_tzcnt_u16(0b0000_0001u16), 0u16); assert_eq!(_tzcnt_u16(0b0000_0000u16), 16u16); assert_eq!(_tzcnt_u16(0b1001_0000u16), 4u16); } #[simd_test(enable = "bmi1")] - unsafe fn test_tzcnt_u32() { + const unsafe fn test_tzcnt_u32() { assert_eq!(_tzcnt_u32(0b0000_0001u32), 0u32); assert_eq!(_tzcnt_u32(0b0000_0000u32), 32u32); assert_eq!(_tzcnt_u32(0b1001_0000u32), 4u32); diff --git a/library/stdarch/crates/core_arch/src/x86/bmi2.rs b/library/stdarch/crates/core_arch/src/x86/bmi2.rs index 83cf650923f7..b5b7d0f34073 100644 --- a/library/stdarch/crates/core_arch/src/x86/bmi2.rs +++ b/library/stdarch/crates/core_arch/src/x86/bmi2.rs @@ -25,7 +25,8 @@ use stdarch_test::assert_instr; #[cfg_attr(all(test, target_arch = "x86"), assert_instr(mul))] #[target_feature(enable = "bmi2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 { let result: u64 = (a as u64) * (b as u64); *hi = (result >> 32) as u32; result as u32 @@ -77,6 +78,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; @@ -117,7 +119,7 @@ mod tests { } #[simd_test(enable = "bmi2")] - unsafe fn test_mulx_u32() { + const unsafe fn test_mulx_u32() { let a: u32 = 4_294_967_200; let b: u32 = 2; let mut hi = 0; diff --git a/library/stdarch/crates/core_arch/src/x86/bswap.rs b/library/stdarch/crates/core_arch/src/x86/bswap.rs index ea07a7d6229a..f8e177f7c278 100644 --- a/library/stdarch/crates/core_arch/src/x86/bswap.rs +++ b/library/stdarch/crates/core_arch/src/x86/bswap.rs @@ -10,16 +10,20 @@ use stdarch_test::assert_instr; #[inline] #[cfg_attr(test, assert_instr(bswap))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _bswap(x: i32) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _bswap(x: i32) -> i32 { x.swap_bytes() } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; + use stdarch_test::simd_test; + use super::*; - #[test] - fn test_bswap() { + #[simd_test] + const fn test_bswap() { assert_eq!(_bswap(0x0EADBE0F), 0x0FBEAD0E); assert_eq!(_bswap(0x00000000), 0x00000000); } diff --git a/library/stdarch/crates/core_arch/src/x86/tbm.rs b/library/stdarch/crates/core_arch/src/x86/tbm.rs index 5a01752d8ac2..d7769b916d4f 100644 --- a/library/stdarch/crates/core_arch/src/x86/tbm.rs +++ b/library/stdarch/crates/core_arch/src/x86/tbm.rs @@ -42,7 +42,8 @@ pub fn _bextri_u32(a: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcfill))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcfill_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcfill_u32(x: u32) -> u32 { x & (x.wrapping_add(1)) } @@ -53,7 +54,8 @@ pub fn _blcfill_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blci))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blci_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blci_u32(x: u32) -> u32 { x | !x.wrapping_add(1) } @@ -64,7 +66,8 @@ pub fn _blci_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcic))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcic_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcic_u32(x: u32) -> u32 { !x & x.wrapping_add(1) } @@ -76,7 +79,8 @@ pub fn _blcic_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcmsk))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcmsk_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcmsk_u32(x: u32) -> u32 { x ^ x.wrapping_add(1) } @@ -87,7 +91,8 @@ pub fn _blcmsk_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcs))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcs_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcs_u32(x: u32) -> u32 { x | x.wrapping_add(1) } @@ -98,7 +103,8 @@ pub fn _blcs_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blsfill))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsfill_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsfill_u32(x: u32) -> u32 { x | x.wrapping_sub(1) } @@ -109,7 +115,8 @@ pub fn _blsfill_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blsic))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsic_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsic_u32(x: u32) -> u32 { !x | x.wrapping_sub(1) } @@ -121,7 +128,8 @@ pub fn _blsic_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(t1mskc))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _t1mskc_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _t1mskc_u32(x: u32) -> u32 { !x | x.wrapping_add(1) } @@ -133,12 +141,14 @@ pub fn _t1mskc_u32(x: u32) -> u32 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(tzmsk))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _tzmsk_u32(x: u32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _tzmsk_u32(x: u32) -> u32 { !x & x.wrapping_sub(1) } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; @@ -149,13 +159,13 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_blcfill_u32() { + const unsafe fn test_blcfill_u32() { assert_eq!(_blcfill_u32(0b0101_0111u32), 0b0101_0000u32); assert_eq!(_blcfill_u32(0b1111_1111u32), 0u32); } #[simd_test(enable = "tbm")] - unsafe fn test_blci_u32() { + const unsafe fn test_blci_u32() { assert_eq!( _blci_u32(0b0101_0000u32), 0b1111_1111_1111_1111_1111_1111_1111_1110u32 @@ -167,25 +177,25 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_blcic_u32() { + const unsafe fn test_blcic_u32() { assert_eq!(_blcic_u32(0b0101_0001u32), 0b0000_0010u32); assert_eq!(_blcic_u32(0b1111_1111u32), 0b1_0000_0000u32); } #[simd_test(enable = "tbm")] - unsafe fn test_blcmsk_u32() { + const unsafe fn test_blcmsk_u32() { assert_eq!(_blcmsk_u32(0b0101_0001u32), 0b0000_0011u32); assert_eq!(_blcmsk_u32(0b1111_1111u32), 0b1_1111_1111u32); } #[simd_test(enable = "tbm")] - unsafe fn test_blcs_u32() { + const unsafe fn test_blcs_u32() { assert_eq!(_blcs_u32(0b0101_0001u32), 0b0101_0011u32); assert_eq!(_blcs_u32(0b1111_1111u32), 0b1_1111_1111u32); } #[simd_test(enable = "tbm")] - unsafe fn test_blsfill_u32() { + const unsafe fn test_blsfill_u32() { assert_eq!(_blsfill_u32(0b0101_0100u32), 0b0101_0111u32); assert_eq!( _blsfill_u32(0u32), @@ -194,7 +204,7 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_blsic_u32() { + const unsafe fn test_blsic_u32() { assert_eq!( _blsic_u32(0b0101_0100u32), 0b1111_1111_1111_1111_1111_1111_1111_1011u32 @@ -206,7 +216,7 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_t1mskc_u32() { + const unsafe fn test_t1mskc_u32() { assert_eq!( _t1mskc_u32(0b0101_0111u32), 0b1111_1111_1111_1111_1111_1111_1111_1000u32 @@ -218,7 +228,7 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_tzmsk_u32() { + const unsafe fn test_tzmsk_u32() { assert_eq!(_tzmsk_u32(0b0101_1000u32), 0b0000_0111u32); assert_eq!(_tzmsk_u32(0b0101_1001u32), 0b0000_0000u32); } diff --git a/library/stdarch/crates/core_arch/src/x86_64/abm.rs b/library/stdarch/crates/core_arch/src/x86_64/abm.rs index bf59cc463218..63e422864d3b 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/abm.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/abm.rs @@ -29,7 +29,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "lzcnt")] #[cfg_attr(test, assert_instr(lzcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _lzcnt_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _lzcnt_u64(x: u64) -> u64 { x.leading_zeros() as u64 } @@ -40,23 +41,25 @@ pub fn _lzcnt_u64(x: u64) -> u64 { #[target_feature(enable = "popcnt")] #[cfg_attr(test, assert_instr(popcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _popcnt64(x: i64) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _popcnt64(x: i64) -> i32 { x.count_ones() as i32 } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::arch::x86_64::*; #[simd_test(enable = "lzcnt")] - unsafe fn test_lzcnt_u64() { + const unsafe fn test_lzcnt_u64() { assert_eq!(_lzcnt_u64(0b0101_1010), 57); } #[simd_test(enable = "popcnt")] - unsafe fn test_popcnt64() { + const unsafe fn test_popcnt64() { assert_eq!(_popcnt64(0b0101_1010), 4); } } diff --git a/library/stdarch/crates/core_arch/src/x86_64/bmi.rs b/library/stdarch/crates/core_arch/src/x86_64/bmi.rs index 5d204d51ae6d..ee41d4137591 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/bmi.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/bmi.rs @@ -48,7 +48,8 @@ pub fn _bextr2_u64(a: u64, control: u64) -> u64 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(andn))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _andn_u64(a: u64, b: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _andn_u64(a: u64, b: u64) -> u64 { !a & b } @@ -60,7 +61,8 @@ pub fn _andn_u64(a: u64, b: u64) -> u64 { #[cfg_attr(test, assert_instr(blsi))] #[cfg(not(target_arch = "x86"))] // generates lots of instructions #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsi_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsi_u64(x: u64) -> u64 { x & x.wrapping_neg() } @@ -72,7 +74,8 @@ pub fn _blsi_u64(x: u64) -> u64 { #[cfg_attr(test, assert_instr(blsmsk))] #[cfg(not(target_arch = "x86"))] // generates lots of instructions #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsmsk_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsmsk_u64(x: u64) -> u64 { x ^ (x.wrapping_sub(1_u64)) } @@ -86,7 +89,8 @@ pub fn _blsmsk_u64(x: u64) -> u64 { #[cfg_attr(test, assert_instr(blsr))] #[cfg(not(target_arch = "x86"))] // generates lots of instructions #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsr_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsr_u64(x: u64) -> u64 { x & (x.wrapping_sub(1)) } @@ -99,7 +103,8 @@ pub fn _blsr_u64(x: u64) -> u64 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(tzcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _tzcnt_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _tzcnt_u64(x: u64) -> u64 { x.trailing_zeros() as u64 } @@ -112,7 +117,8 @@ pub fn _tzcnt_u64(x: u64) -> u64 { #[target_feature(enable = "bmi1")] #[cfg_attr(test, assert_instr(tzcnt))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_tzcnt_64(x: u64) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_tzcnt_64(x: u64) -> i64 { x.trailing_zeros() as i64 } @@ -123,6 +129,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::{x86::*, x86_64::*}; @@ -134,7 +141,7 @@ mod tests { } #[simd_test(enable = "bmi1")] - unsafe fn test_andn_u64() { + const unsafe fn test_andn_u64() { assert_eq!(_andn_u64(0, 0), 0); assert_eq!(_andn_u64(0, 1), 1); assert_eq!(_andn_u64(1, 0), 0); @@ -157,25 +164,25 @@ mod tests { } #[simd_test(enable = "bmi1")] - unsafe fn test_blsi_u64() { + const unsafe fn test_blsi_u64() { assert_eq!(_blsi_u64(0b1101_0000u64), 0b0001_0000u64); } #[simd_test(enable = "bmi1")] - unsafe fn test_blsmsk_u64() { + const unsafe fn test_blsmsk_u64() { let r = _blsmsk_u64(0b0011_0000u64); assert_eq!(r, 0b0001_1111u64); } #[simd_test(enable = "bmi1")] - unsafe fn test_blsr_u64() { + const unsafe fn test_blsr_u64() { // TODO: test the behavior when the input is `0`. let r = _blsr_u64(0b0011_0000u64); assert_eq!(r, 0b0010_0000u64); } #[simd_test(enable = "bmi1")] - unsafe fn test_tzcnt_u64() { + const unsafe fn test_tzcnt_u64() { assert_eq!(_tzcnt_u64(0b0000_0001u64), 0u64); assert_eq!(_tzcnt_u64(0b0000_0000u64), 64u64); assert_eq!(_tzcnt_u64(0b1001_0000u64), 4u64); diff --git a/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs b/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs index ea9daf88574f..4eb53ed5ea4a 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs @@ -24,7 +24,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "bmi2")] #[cfg(not(target_arch = "x86"))] // calls an intrinsic #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mulx_u64(a: u64, b: u64, hi: &mut u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mulx_u64(a: u64, b: u64, hi: &mut u64) -> u64 { let result: u128 = (a as u128) * (b as u128); *hi = (result >> 64) as u64; result as u64 @@ -79,6 +80,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86_64::*; @@ -120,7 +122,7 @@ mod tests { #[simd_test(enable = "bmi2")] #[rustfmt::skip] - unsafe fn test_mulx_u64() { +const unsafe fn test_mulx_u64() { let a: u64 = 9_223_372_036_854_775_800; let b: u64 = 100; let mut hi = 0; diff --git a/library/stdarch/crates/core_arch/src/x86_64/bswap.rs b/library/stdarch/crates/core_arch/src/x86_64/bswap.rs index 4e2d8b96eade..1b1d739a62c8 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/bswap.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/bswap.rs @@ -11,16 +11,20 @@ use stdarch_test::assert_instr; #[inline] #[cfg_attr(test, assert_instr(bswap))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _bswap64(x: i64) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _bswap64(x: i64) -> i64 { x.swap_bytes() } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; + use stdarch_test::simd_test; + use super::*; - #[test] - fn test_bswap64() { + #[simd_test] + const fn test_bswap64() { assert_eq!(_bswap64(0x0EADBEEFFADECA0E), 0x0ECADEFAEFBEAD0E); assert_eq!(_bswap64(0x0000000000000000), 0x0000000000000000); } diff --git a/library/stdarch/crates/core_arch/src/x86_64/tbm.rs b/library/stdarch/crates/core_arch/src/x86_64/tbm.rs index f4bba709f681..e7d4b8d3e4c9 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/tbm.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/tbm.rs @@ -42,7 +42,8 @@ pub fn _bextri_u64(a: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcfill))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcfill_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcfill_u64(x: u64) -> u64 { x & x.wrapping_add(1) } @@ -53,7 +54,8 @@ pub fn _blcfill_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blci))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blci_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blci_u64(x: u64) -> u64 { x | !x.wrapping_add(1) } @@ -64,7 +66,8 @@ pub fn _blci_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcic))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcic_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcic_u64(x: u64) -> u64 { !x & x.wrapping_add(1) } @@ -76,7 +79,8 @@ pub fn _blcic_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcmsk))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcmsk_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcmsk_u64(x: u64) -> u64 { x ^ x.wrapping_add(1) } @@ -87,7 +91,8 @@ pub fn _blcmsk_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blcs))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blcs_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blcs_u64(x: u64) -> u64 { x | x.wrapping_add(1) } @@ -98,7 +103,8 @@ pub fn _blcs_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blsfill))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsfill_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsfill_u64(x: u64) -> u64 { x | x.wrapping_sub(1) } @@ -109,7 +115,8 @@ pub fn _blsfill_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(blsic))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _blsic_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _blsic_u64(x: u64) -> u64 { !x | x.wrapping_sub(1) } @@ -121,7 +128,8 @@ pub fn _blsic_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(t1mskc))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _t1mskc_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _t1mskc_u64(x: u64) -> u64 { !x | x.wrapping_add(1) } @@ -133,12 +141,14 @@ pub fn _t1mskc_u64(x: u64) -> u64 { #[target_feature(enable = "tbm")] #[cfg_attr(test, assert_instr(tzmsk))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _tzmsk_u64(x: u64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _tzmsk_u64(x: u64) -> u64 { !x & x.wrapping_sub(1) } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86_64::*; @@ -149,13 +159,13 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_blcfill_u64() { + const unsafe fn test_blcfill_u64() { assert_eq!(_blcfill_u64(0b0101_0111u64), 0b0101_0000u64); assert_eq!(_blcfill_u64(0b1111_1111u64), 0u64); } #[simd_test(enable = "tbm")] - unsafe fn test_blci_u64() { + const unsafe fn test_blci_u64() { assert_eq!( _blci_u64(0b0101_0000u64), 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1110u64 @@ -167,25 +177,25 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_blcic_u64() { + const unsafe fn test_blcic_u64() { assert_eq!(_blcic_u64(0b0101_0001u64), 0b0000_0010u64); assert_eq!(_blcic_u64(0b1111_1111u64), 0b1_0000_0000u64); } #[simd_test(enable = "tbm")] - unsafe fn test_blcmsk_u64() { + const unsafe fn test_blcmsk_u64() { assert_eq!(_blcmsk_u64(0b0101_0001u64), 0b0000_0011u64); assert_eq!(_blcmsk_u64(0b1111_1111u64), 0b1_1111_1111u64); } #[simd_test(enable = "tbm")] - unsafe fn test_blcs_u64() { + const unsafe fn test_blcs_u64() { assert_eq!(_blcs_u64(0b0101_0001u64), 0b0101_0011u64); assert_eq!(_blcs_u64(0b1111_1111u64), 0b1_1111_1111u64); } #[simd_test(enable = "tbm")] - unsafe fn test_blsfill_u64() { + const unsafe fn test_blsfill_u64() { assert_eq!(_blsfill_u64(0b0101_0100u64), 0b0101_0111u64); assert_eq!( _blsfill_u64(0u64), @@ -194,7 +204,7 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_blsic_u64() { + const unsafe fn test_blsic_u64() { assert_eq!( _blsic_u64(0b0101_0100u64), 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1011u64 @@ -206,7 +216,7 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_t1mskc_u64() { + const unsafe fn test_t1mskc_u64() { assert_eq!( _t1mskc_u64(0b0101_0111u64), 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1000u64 @@ -218,7 +228,7 @@ mod tests { } #[simd_test(enable = "tbm")] - unsafe fn test_tzmsk_u64() { + const unsafe fn test_tzmsk_u64() { assert_eq!(_tzmsk_u64(0b0101_1000u64), 0b0000_0111u64); assert_eq!(_tzmsk_u64(0b0101_1001u64), 0b0000_0000u64); } From 7d4bcdd3fddbcc04697889e3cde5a5f996cde070 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:11:09 +0530 Subject: [PATCH 059/489] Make `sse` functions const --- .../stdarch/crates/core_arch/src/x86/sse.rs | 361 +++++++++--------- .../crates/core_arch/src/x86_64/sse.rs | 44 ++- 2 files changed, 201 insertions(+), 204 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/sse.rs b/library/stdarch/crates/core_arch/src/x86/sse.rs index 7dd96dd1c9d7..165c61104e1a 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse.rs @@ -18,7 +18,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(addss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_ss(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_ss(a: __m128, b: __m128) -> __m128 { unsafe { simd_insert!(a, 0, _mm_cvtss_f32(a) + _mm_cvtss_f32(b)) } } @@ -30,7 +31,8 @@ pub fn _mm_add_ss(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(addps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_add(a, b) } } @@ -42,7 +44,8 @@ pub fn _mm_add_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(subss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_ss(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_ss(a: __m128, b: __m128) -> __m128 { unsafe { simd_insert!(a, 0, _mm_cvtss_f32(a) - _mm_cvtss_f32(b)) } } @@ -54,7 +57,8 @@ pub fn _mm_sub_ss(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(subps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_sub(a, b) } } @@ -66,7 +70,8 @@ pub fn _mm_sub_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(mulss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mul_ss(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_ss(a: __m128, b: __m128) -> __m128 { unsafe { simd_insert!(a, 0, _mm_cvtss_f32(a) * _mm_cvtss_f32(b)) } } @@ -78,7 +83,8 @@ pub fn _mm_mul_ss(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(mulps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mul_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_mul(a, b) } } @@ -90,7 +96,8 @@ pub fn _mm_mul_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(divss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_div_ss(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_div_ss(a: __m128, b: __m128) -> __m128 { unsafe { simd_insert!(a, 0, _mm_cvtss_f32(a) / _mm_cvtss_f32(b)) } } @@ -102,7 +109,8 @@ pub fn _mm_div_ss(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(divps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_div_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_div_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_div(a, b) } } @@ -241,7 +249,8 @@ pub fn _mm_max_ps(a: __m128, b: __m128) -> __m128 { assert_instr(andps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_and_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_and_ps(a: __m128, b: __m128) -> __m128 { unsafe { let a: __m128i = mem::transmute(a); let b: __m128i = mem::transmute(b); @@ -264,7 +273,8 @@ pub fn _mm_and_ps(a: __m128, b: __m128) -> __m128 { assert_instr(andnps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_andnot_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_andnot_ps(a: __m128, b: __m128) -> __m128 { unsafe { let a: __m128i = mem::transmute(a); let b: __m128i = mem::transmute(b); @@ -284,7 +294,8 @@ pub fn _mm_andnot_ps(a: __m128, b: __m128) -> __m128 { assert_instr(orps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_or_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_or_ps(a: __m128, b: __m128) -> __m128 { unsafe { let a: __m128i = mem::transmute(a); let b: __m128i = mem::transmute(b); @@ -304,7 +315,8 @@ pub fn _mm_or_ps(a: __m128, b: __m128) -> __m128 { assert_instr(xorps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_xor_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_xor_ps(a: __m128, b: __m128) -> __m128 { unsafe { let a: __m128i = mem::transmute(a); let b: __m128i = mem::transmute(b); @@ -866,7 +878,8 @@ pub fn _mm_cvtt_ss2si(a: __m128) -> i32 { // No point in using assert_instrs. In Unix x86_64 calling convention this is a // no-op, and on msvc it's just a `mov`. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtss_f32(a: __m128) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtss_f32(a: __m128) -> f32 { unsafe { simd_extract!(a, 0) } } @@ -881,7 +894,8 @@ pub fn _mm_cvtss_f32(a: __m128) -> f32 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(cvtsi2ss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi32_ss(a: __m128, b: i32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi32_ss(a: __m128, b: i32) -> __m128 { unsafe { simd_insert!(a, 0, b as f32) } } @@ -904,7 +918,8 @@ pub fn _mm_cvt_si2ss(a: __m128, b: i32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_ss(a: f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_ss(a: f32) -> __m128 { __m128([a, 0.0, 0.0, 0.0]) } @@ -915,7 +930,8 @@ pub fn _mm_set_ss(a: f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(shufps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set1_ps(a: f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_ps(a: f32) -> __m128 { __m128([a, a, a, a]) } @@ -926,7 +942,8 @@ pub fn _mm_set1_ps(a: f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(shufps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_ps1(a: f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_ps1(a: f32) -> __m128 { _mm_set1_ps(a) } @@ -953,7 +970,8 @@ pub fn _mm_set_ps1(a: f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(unpcklps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_ps(a: f32, b: f32, c: f32, d: f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_ps(a: f32, b: f32, c: f32, d: f32) -> __m128 { __m128([d, c, b, a]) } @@ -979,7 +997,8 @@ pub fn _mm_set_ps(a: f32, b: f32, c: f32, d: f32) -> __m128 { assert_instr(movaps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setr_ps(a: f32, b: f32, c: f32, d: f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setr_ps(a: f32, b: f32, c: f32, d: f32) -> __m128 { __m128([a, b, c, d]) } @@ -990,7 +1009,8 @@ pub fn _mm_setr_ps(a: f32, b: f32, c: f32, d: f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(xorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setzero_ps() -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setzero_ps() -> __m128 { const { unsafe { mem::zeroed() } } } @@ -1021,7 +1041,8 @@ pub const fn _MM_SHUFFLE(z: u32, y: u32, x: u32, w: u32) -> i32 { #[cfg_attr(test, assert_instr(shufps, MASK = 3))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_shuffle_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shuffle_ps(a: __m128, b: __m128) -> __m128 { static_assert_uimm_bits!(MASK, 8); unsafe { simd_shuffle!( @@ -1045,7 +1066,8 @@ pub fn _mm_shuffle_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(unpckhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpackhi_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpackhi_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_shuffle!(a, b, [2, 6, 3, 7]) } } @@ -1057,7 +1079,8 @@ pub fn _mm_unpackhi_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(unpcklps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpacklo_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpacklo_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_shuffle!(a, b, [0, 4, 1, 5]) } } @@ -1069,7 +1092,8 @@ pub fn _mm_unpacklo_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movhlps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movehl_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movehl_ps(a: __m128, b: __m128) -> __m128 { // TODO; figure why this is a different instruction on msvc? unsafe { simd_shuffle!(a, b, [6, 7, 2, 3]) } } @@ -1082,7 +1106,8 @@ pub fn _mm_movehl_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movlhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movelh_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movelh_ps(a: __m128, b: __m128) -> __m128 { unsafe { simd_shuffle!(a, b, [0, 1, 4, 5]) } } @@ -1096,12 +1121,13 @@ pub fn _mm_movelh_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movmskps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movemask_ps(a: __m128) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movemask_ps(a: __m128) -> i32 { // Propagate the highest bit to the rest, because simd_bitmask // requires all-1 or all-0. unsafe { let mask: i32x4 = simd_lt(transmute(a), i32x4::ZERO); - simd_bitmask::(mask).into() + simd_bitmask::(mask) as i32 } } @@ -1115,7 +1141,8 @@ pub fn _mm_movemask_ps(a: __m128) -> i32 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load_ss(p: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_ss(p: *const f32) -> __m128 { __m128([*p, 0.0, 0.0, 0.0]) } @@ -1130,7 +1157,8 @@ pub unsafe fn _mm_load_ss(p: *const f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load1_ps(p: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load1_ps(p: *const f32) -> __m128 { let a = *p; __m128([a, a, a, a]) } @@ -1142,7 +1170,8 @@ pub unsafe fn _mm_load1_ps(p: *const f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load_ps1(p: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_ps1(p: *const f32) -> __m128 { _mm_load1_ps(p) } @@ -1166,7 +1195,8 @@ pub unsafe fn _mm_load_ps1(p: *const f32) -> __m128 { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_load_ps(p: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_ps(p: *const f32) -> __m128 { *(p as *const __m128) } @@ -1183,7 +1213,8 @@ pub unsafe fn _mm_load_ps(p: *const f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movups))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadu_ps(p: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_ps(p: *const f32) -> __m128 { // Note: Using `*p` would require `f32` alignment, but `movups` has no // alignment restrictions. let mut dst = _mm_undefined_ps(); @@ -1223,7 +1254,8 @@ pub unsafe fn _mm_loadu_ps(p: *const f32) -> __m128 { assert_instr(movaps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadr_ps(p: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadr_ps(p: *const f32) -> __m128 { let a = _mm_load_ps(p); simd_shuffle!(a, a, [3, 2, 1, 0]) } @@ -1237,7 +1269,8 @@ pub unsafe fn _mm_loadr_ps(p: *const f32) -> __m128 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_store_ss(p: *mut f32, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_ss(p: *mut f32, a: __m128) { *p = simd_extract!(a, 0); } @@ -1267,7 +1300,8 @@ pub unsafe fn _mm_store_ss(p: *mut f32, a: __m128) { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_store1_ps(p: *mut f32, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store1_ps(p: *mut f32, a: __m128) { let b: __m128 = simd_shuffle!(a, a, [0, 0, 0, 0]); *(p as *mut __m128) = b; } @@ -1282,7 +1316,8 @@ pub unsafe fn _mm_store1_ps(p: *mut f32, a: __m128) { assert_instr(movaps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_store_ps1(p: *mut f32, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_ps1(p: *mut f32, a: __m128) { _mm_store1_ps(p, a); } @@ -1305,7 +1340,8 @@ pub unsafe fn _mm_store_ps1(p: *mut f32, a: __m128) { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_store_ps(p: *mut f32, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_ps(p: *mut f32, a: __m128) { *(p as *mut __m128) = a; } @@ -1320,7 +1356,8 @@ pub unsafe fn _mm_store_ps(p: *mut f32, a: __m128) { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movups))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_storeu_ps(p: *mut f32, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_ps(p: *mut f32, a: __m128) { ptr::copy_nonoverlapping( ptr::addr_of!(a) as *const u8, p as *mut u8, @@ -1352,7 +1389,8 @@ pub unsafe fn _mm_storeu_ps(p: *mut f32, a: __m128) { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_storer_ps(p: *mut f32, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storer_ps(p: *mut f32, a: __m128) { let b: __m128 = simd_shuffle!(a, a, [3, 2, 1, 0]); *(p as *mut __m128) = b; } @@ -1370,7 +1408,8 @@ pub unsafe fn _mm_storer_ps(p: *mut f32, a: __m128) { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(movss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_move_ss(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_move_ss(a: __m128, b: __m128) -> __m128 { unsafe { simd_shuffle!(a, b, [4, 1, 2, 3]) } } @@ -1917,7 +1956,8 @@ pub fn _mm_prefetch(p: *const i8) { #[inline] #[target_feature(enable = "sse")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_undefined_ps() -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_undefined_ps() -> __m128 { const { unsafe { mem::zeroed() } } } @@ -1928,7 +1968,8 @@ pub fn _mm_undefined_ps() -> __m128 { #[allow(non_snake_case)] #[target_feature(enable = "sse")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _MM_TRANSPOSE4_PS( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _MM_TRANSPOSE4_PS( row0: &mut __m128, row1: &mut __m128, row2: &mut __m128, @@ -2037,6 +2078,7 @@ pub unsafe fn _mm_stream_ps(mem_addr: *mut f32, a: __m128) { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::{hint::black_box, mem::transmute, ptr}; use std::boxed; use stdarch_test::simd_test; @@ -2046,7 +2088,7 @@ mod tests { const NAN: f32 = f32::NAN; #[simd_test(enable = "sse")] - unsafe fn test_mm_add_ps() { + const unsafe fn test_mm_add_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_add_ps(a, b); @@ -2054,7 +2096,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_add_ss() { + const unsafe fn test_mm_add_ss() { let a = _mm_set_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_set_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_add_ss(a, b); @@ -2062,7 +2104,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_sub_ps() { + const unsafe fn test_mm_sub_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_sub_ps(a, b); @@ -2070,7 +2112,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_sub_ss() { + const unsafe fn test_mm_sub_ss() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_sub_ss(a, b); @@ -2078,7 +2120,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_mul_ps() { + const unsafe fn test_mm_mul_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_mul_ps(a, b); @@ -2086,7 +2128,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_mul_ss() { + const unsafe fn test_mm_mul_ss() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_mul_ss(a, b); @@ -2094,7 +2136,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_div_ps() { + const unsafe fn test_mm_div_ps() { let a = _mm_setr_ps(-1.0, 5.0, 2.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.2, -5.0); let r = _mm_div_ps(a, b); @@ -2102,7 +2144,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_div_ss() { + const unsafe fn test_mm_div_ss() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_div_ss(a, b); @@ -2229,7 +2271,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_and_ps() { + const unsafe fn test_mm_and_ps() { let a = transmute(u32x4::splat(0b0011)); let b = transmute(u32x4::splat(0b0101)); let r = _mm_and_ps(*black_box(&a), *black_box(&b)); @@ -2238,7 +2280,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_andnot_ps() { + const unsafe fn test_mm_andnot_ps() { let a = transmute(u32x4::splat(0b0011)); let b = transmute(u32x4::splat(0b0101)); let r = _mm_andnot_ps(*black_box(&a), *black_box(&b)); @@ -2247,7 +2289,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_or_ps() { + const unsafe fn test_mm_or_ps() { let a = transmute(u32x4::splat(0b0011)); let b = transmute(u32x4::splat(0b0101)); let r = _mm_or_ps(*black_box(&a), *black_box(&b)); @@ -2256,7 +2298,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_xor_ps() { + const unsafe fn test_mm_xor_ps() { let a = transmute(u32x4::splat(0b0011)); let b = transmute(u32x4::splat(0b0101)); let r = _mm_xor_ps(*black_box(&a), *black_box(&b)); @@ -2979,36 +3021,40 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_cvtsi32_ss() { - let inputs = &[ - (4555i32, 4555.0f32), - (322223333, 322223330.0), - (-432, -432.0), - (-322223333, -322223330.0), - ]; + const unsafe fn test_mm_cvtsi32_ss() { + let a = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); - for &(x, f) in inputs.iter() { - let a = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); - let r = _mm_cvtsi32_ss(a, x); - let e = _mm_setr_ps(f, 6.0, 7.0, 8.0); - assert_eq_m128(e, r); - } + let r = _mm_cvtsi32_ss(a, 4555); + let e = _mm_setr_ps(4555.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi32_ss(a, 322223333); + let e = _mm_setr_ps(322223333.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi32_ss(a, -432); + let e = _mm_setr_ps(-432.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi32_ss(a, -322223333); + let e = _mm_setr_ps(-322223333.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); } #[simd_test(enable = "sse")] - unsafe fn test_mm_cvtss_f32() { + const unsafe fn test_mm_cvtss_f32() { let a = _mm_setr_ps(312.0134, 5.0, 6.0, 7.0); assert_eq!(_mm_cvtss_f32(a), 312.0134); } #[simd_test(enable = "sse")] - unsafe fn test_mm_set_ss() { + const unsafe fn test_mm_set_ss() { let r = _mm_set_ss(black_box(4.25)); assert_eq_m128(r, _mm_setr_ps(4.25, 0.0, 0.0, 0.0)); } #[simd_test(enable = "sse")] - unsafe fn test_mm_set1_ps() { + const unsafe fn test_mm_set1_ps() { let r1 = _mm_set1_ps(black_box(4.25)); let r2 = _mm_set_ps1(black_box(4.25)); assert_eq!(get_m128(r1, 0), 4.25); @@ -3022,7 +3068,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_set_ps() { + const unsafe fn test_mm_set_ps() { let r = _mm_set_ps( black_box(1.0), black_box(2.0), @@ -3036,7 +3082,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_setr_ps() { + const unsafe fn test_mm_setr_ps() { let r = _mm_setr_ps( black_box(1.0), black_box(2.0), @@ -3047,21 +3093,21 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_setzero_ps() { + const unsafe fn test_mm_setzero_ps() { let r = *black_box(&_mm_setzero_ps()); assert_eq_m128(r, _mm_set1_ps(0.0)); } - #[test] + #[simd_test] #[allow(non_snake_case)] - fn test_MM_SHUFFLE() { + const fn test_MM_SHUFFLE() { assert_eq!(_MM_SHUFFLE(0, 1, 1, 3), 0b00_01_01_11); assert_eq!(_MM_SHUFFLE(3, 1, 1, 0), 0b11_01_01_00); assert_eq!(_MM_SHUFFLE(1, 2, 2, 1), 0b01_10_10_01); } #[simd_test(enable = "sse")] - unsafe fn test_mm_shuffle_ps() { + const unsafe fn test_mm_shuffle_ps() { let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); let r = _mm_shuffle_ps::<0b00_01_01_11>(a, b); @@ -3069,7 +3115,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_unpackhi_ps() { + const unsafe fn test_mm_unpackhi_ps() { let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); let r = _mm_unpackhi_ps(a, b); @@ -3077,7 +3123,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_unpacklo_ps() { + const unsafe fn test_mm_unpacklo_ps() { let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); let r = _mm_unpacklo_ps(a, b); @@ -3085,7 +3131,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_movehl_ps() { + const unsafe fn test_mm_movehl_ps() { let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); let r = _mm_movehl_ps(a, b); @@ -3093,7 +3139,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_movelh_ps() { + const unsafe fn test_mm_movelh_ps() { let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); let r = _mm_movelh_ps(a, b); @@ -3101,43 +3147,35 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_load_ss() { + const unsafe fn test_mm_load_ss() { let a = 42.0f32; let r = _mm_load_ss(ptr::addr_of!(a)); assert_eq_m128(r, _mm_setr_ps(42.0, 0.0, 0.0, 0.0)); } #[simd_test(enable = "sse")] - unsafe fn test_mm_load1_ps() { + const unsafe fn test_mm_load1_ps() { let a = 42.0f32; let r = _mm_load1_ps(ptr::addr_of!(a)); assert_eq_m128(r, _mm_setr_ps(42.0, 42.0, 42.0, 42.0)); } #[simd_test(enable = "sse")] - unsafe fn test_mm_load_ps() { - let vals = &[1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; + const unsafe fn test_mm_load_ps() { + let vals = Memory { + data: [1.0f32, 2.0, 3.0, 4.0], + }; - let mut p = vals.as_ptr(); - let mut fixup = 0.0f32; - - // Make sure p is aligned, otherwise we might get a - // (signal: 11, SIGSEGV: invalid memory reference) - - let unalignment = (p as usize) & 0xf; - if unalignment != 0 { - let delta = (16 - unalignment) >> 2; - fixup = delta as f32; - p = p.add(delta); - } + // guaranteed to be aligned to 16 bytes + let p = vals.data.as_ptr(); let r = _mm_load_ps(p); - let e = _mm_add_ps(_mm_setr_ps(1.0, 2.0, 3.0, 4.0), _mm_set1_ps(fixup)); + let e = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); assert_eq_m128(r, e); } #[simd_test(enable = "sse")] - unsafe fn test_mm_loadu_ps() { + const unsafe fn test_mm_loadu_ps() { let vals = &[1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let p = vals.as_ptr().add(3); let r = _mm_loadu_ps(black_box(p)); @@ -3145,29 +3183,21 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_loadr_ps() { - let vals = &[1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; + const unsafe fn test_mm_loadr_ps() { + let vals = Memory { + data: [1.0f32, 2.0, 3.0, 4.0], + }; - let mut p = vals.as_ptr(); - let mut fixup = 0.0f32; - - // Make sure p is aligned, otherwise we might get a - // (signal: 11, SIGSEGV: invalid memory reference) - - let unalignment = (p as usize) & 0xf; - if unalignment != 0 { - let delta = (16 - unalignment) >> 2; - fixup = delta as f32; - p = p.add(delta); - } + // guaranteed to be aligned to 16 bytes + let p = vals.data.as_ptr(); let r = _mm_loadr_ps(p); - let e = _mm_add_ps(_mm_setr_ps(4.0, 3.0, 2.0, 1.0), _mm_set1_ps(fixup)); + let e = _mm_setr_ps(4.0, 3.0, 2.0, 1.0); assert_eq_m128(r, e); } #[simd_test(enable = "sse")] - unsafe fn test_mm_store_ss() { + const unsafe fn test_mm_store_ss() { let mut vals = [0.0f32; 8]; let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); _mm_store_ss(vals.as_mut_ptr().add(1), a); @@ -3178,110 +3208,65 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_store1_ps() { - let mut vals = [0.0f32; 8]; + const unsafe fn test_mm_store1_ps() { + let mut vals = Memory { data: [0.0f32; 4] }; let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); - let mut ofs = 0; - let mut p = vals.as_mut_ptr(); - - if (p as usize) & 0xf != 0 { - ofs = (16 - ((p as usize) & 0xf)) >> 2; - p = p.add(ofs); - } + // guaranteed to be aligned to 16 bytes + let p = vals.data.as_mut_ptr(); _mm_store1_ps(p, *black_box(&a)); - if ofs > 0 { - assert_eq!(vals[ofs - 1], 0.0); - } - assert_eq!(vals[ofs + 0], 1.0); - assert_eq!(vals[ofs + 1], 1.0); - assert_eq!(vals[ofs + 2], 1.0); - assert_eq!(vals[ofs + 3], 1.0); - assert_eq!(vals[ofs + 4], 0.0); + assert_eq!(vals.data, [1.0, 1.0, 1.0, 1.0]); } #[simd_test(enable = "sse")] - unsafe fn test_mm_store_ps() { - let mut vals = [0.0f32; 8]; + const unsafe fn test_mm_store_ps() { + let mut vals = Memory { data: [0.0f32; 4] }; let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); - let mut ofs = 0; - let mut p = vals.as_mut_ptr(); - - // Align p to 16-byte boundary - if (p as usize) & 0xf != 0 { - ofs = (16 - ((p as usize) & 0xf)) >> 2; - p = p.add(ofs); - } + // guaranteed to be aligned to 16 bytes + let p = vals.data.as_mut_ptr(); _mm_store_ps(p, *black_box(&a)); - if ofs > 0 { - assert_eq!(vals[ofs - 1], 0.0); - } - assert_eq!(vals[ofs + 0], 1.0); - assert_eq!(vals[ofs + 1], 2.0); - assert_eq!(vals[ofs + 2], 3.0); - assert_eq!(vals[ofs + 3], 4.0); - assert_eq!(vals[ofs + 4], 0.0); + assert_eq!(vals.data, [1.0, 2.0, 3.0, 4.0]); } #[simd_test(enable = "sse")] - unsafe fn test_mm_storer_ps() { - let mut vals = [0.0f32; 8]; + const unsafe fn test_mm_storer_ps() { + let mut vals = Memory { data: [0.0f32; 4] }; let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); - let mut ofs = 0; - let mut p = vals.as_mut_ptr(); - - // Align p to 16-byte boundary - if (p as usize) & 0xf != 0 { - ofs = (16 - ((p as usize) & 0xf)) >> 2; - p = p.add(ofs); - } + // guaranteed to be aligned to 16 bytes + let p = vals.data.as_mut_ptr(); _mm_storer_ps(p, *black_box(&a)); - if ofs > 0 { - assert_eq!(vals[ofs - 1], 0.0); - } - assert_eq!(vals[ofs + 0], 4.0); - assert_eq!(vals[ofs + 1], 3.0); - assert_eq!(vals[ofs + 2], 2.0); - assert_eq!(vals[ofs + 3], 1.0); - assert_eq!(vals[ofs + 4], 0.0); + assert_eq!(vals.data, [4.0, 3.0, 2.0, 1.0]); } #[simd_test(enable = "sse")] - unsafe fn test_mm_storeu_ps() { - let mut vals = [0.0f32; 8]; + const unsafe fn test_mm_storeu_ps() { + #[repr(align(16))] + struct Memory8 { + data: [f32; 8], + } + + // guaranteed to be aligned to 16 bytes + let mut vals = Memory8 { data: [0.0f32; 8] }; let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); - let mut ofs = 0; - let mut p = vals.as_mut_ptr(); - - // Make sure p is **not** aligned to 16-byte boundary - if (p as usize) & 0xf == 0 { - ofs = 1; - p = p.add(1); - } + // guaranteed to be *not* aligned to 16 bytes + let p = vals.data.as_mut_ptr().offset(1); _mm_storeu_ps(p, *black_box(&a)); - if ofs > 0 { - assert_eq!(vals[ofs - 1], 0.0); - } - assert_eq!(vals[ofs + 0], 1.0); - assert_eq!(vals[ofs + 1], 2.0); - assert_eq!(vals[ofs + 2], 3.0); - assert_eq!(vals[ofs + 3], 4.0); - assert_eq!(vals[ofs + 4], 0.0); + assert_eq!(vals.data, [0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0]); } #[simd_test(enable = "sse")] - unsafe fn test_mm_move_ss() { + const unsafe fn test_mm_move_ss() { let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); @@ -3291,7 +3276,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_movemask_ps() { + const unsafe fn test_mm_movemask_ps() { let r = _mm_movemask_ps(_mm_setr_ps(-1.0, 5.0, -5.0, 0.0)); assert_eq!(r, 0b0101); @@ -3307,7 +3292,7 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_MM_TRANSPOSE4_PS() { + const unsafe fn test_MM_TRANSPOSE4_PS() { let mut a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let mut b = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); let mut c = _mm_setr_ps(9.0, 10.0, 11.0, 12.0); diff --git a/library/stdarch/crates/core_arch/src/x86_64/sse.rs b/library/stdarch/crates/core_arch/src/x86_64/sse.rs index 6bd7ec83ec99..e5c1f7915342 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/sse.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/sse.rs @@ -62,13 +62,15 @@ pub fn _mm_cvttss_si64(a: __m128) -> i64 { #[target_feature(enable = "sse")] #[cfg_attr(test, assert_instr(cvtsi2ss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi64_ss(a: __m128, b: i64) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi64_ss(a: __m128, b: i64) -> __m128 { unsafe { simd_insert!(a, 0, b as f32) } } #[cfg(test)] mod tests { use crate::core_arch::arch::x86_64::*; + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; #[simd_test(enable = "sse")] @@ -123,21 +125,31 @@ mod tests { } #[simd_test(enable = "sse")] - unsafe fn test_mm_cvtsi64_ss() { - let inputs = &[ - (4555i64, 4555.0f32), - (322223333, 322223330.0), - (-432, -432.0), - (-322223333, -322223330.0), - (9223372036854775807, 9.223372e18), - (-9223372036854775808, -9.223372e18), - ]; + const unsafe fn test_mm_cvtsi64_ss() { + let a = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); - for &(x, f) in inputs { - let a = _mm_setr_ps(5.0, 6.0, 7.0, 8.0); - let r = _mm_cvtsi64_ss(a, x); - let e = _mm_setr_ps(f, 6.0, 7.0, 8.0); - assert_eq_m128(e, r); - } + let r = _mm_cvtsi64_ss(a, 4555); + let e = _mm_setr_ps(4555.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi64_ss(a, 322223333); + let e = _mm_setr_ps(322223333.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi64_ss(a, -432); + let e = _mm_setr_ps(-432.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi64_ss(a, -322223333); + let e = _mm_setr_ps(-322223333.0, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi64_ss(a, 9223372036854775807); + let e = _mm_setr_ps(9.223372e18, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); + + let r = _mm_cvtsi64_ss(a, -9223372036854775808); + let e = _mm_setr_ps(-9.223372e18, 6.0, 7.0, 8.0); + assert_eq_m128(e, r); } } From cd28decba9593f01e87dff024e28c096df550d73 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:11:14 +0530 Subject: [PATCH 060/489] Make `sse2` functions const --- .../stdarch/crates/core_arch/src/x86/sse2.rs | 768 +++++++++++------- .../crates/core_arch/src/x86_64/sse2.rs | 25 +- 2 files changed, 468 insertions(+), 325 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/sse2.rs b/library/stdarch/crates/core_arch/src/x86/sse2.rs index 93fe7a7ae3f4..098cd67c02d0 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse2.rs @@ -76,7 +76,8 @@ pub fn _mm_mfence() { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_add(a.as_i8x16(), b.as_i8x16())) } } @@ -87,7 +88,8 @@ pub fn _mm_add_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_add(a.as_i16x8(), b.as_i16x8())) } } @@ -98,7 +100,8 @@ pub fn _mm_add_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_add(a.as_i32x4(), b.as_i32x4())) } } @@ -109,7 +112,8 @@ pub fn _mm_add_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_add(a.as_i64x2(), b.as_i64x2())) } } @@ -120,7 +124,8 @@ pub fn _mm_add_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_adds_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_adds_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_add(a.as_i8x16(), b.as_i8x16())) } } @@ -131,7 +136,8 @@ pub fn _mm_adds_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_adds_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_adds_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_add(a.as_i16x8(), b.as_i16x8())) } } @@ -142,7 +148,8 @@ pub fn _mm_adds_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddusb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_adds_epu8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_adds_epu8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_add(a.as_u8x16(), b.as_u8x16())) } } @@ -153,7 +160,8 @@ pub fn _mm_adds_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(paddusw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_adds_epu16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_adds_epu16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_add(a.as_u16x8(), b.as_u16x8())) } } @@ -164,7 +172,8 @@ pub fn _mm_adds_epu16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pavgb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i { unsafe { let a = simd_cast::<_, u16x16>(a.as_u8x16()); let b = simd_cast::<_, u16x16>(b.as_u8x16()); @@ -180,7 +189,8 @@ pub fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pavgw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_avg_epu16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_avg_epu16(a: __m128i, b: __m128i) -> __m128i { unsafe { let a = simd_cast::<_, u32x8>(a.as_u16x8()); let b = simd_cast::<_, u32x8>(b.as_u16x8()); @@ -200,7 +210,8 @@ pub fn _mm_avg_epu16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmaddwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_madd_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_madd_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { let r: i32x8 = simd_mul(simd_cast(a.as_i16x8()), simd_cast(b.as_i16x8())); let even: i32x4 = simd_shuffle!(r, r, [0, 2, 4, 6]); @@ -217,7 +228,8 @@ pub fn _mm_madd_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmaxsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_max_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_i16x8(), b.as_i16x8()).as_m128i() } } @@ -229,7 +241,8 @@ pub fn _mm_max_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmaxub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_max_epu8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epu8(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_u8x16(), b.as_u8x16()).as_m128i() } } @@ -241,7 +254,8 @@ pub fn _mm_max_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pminsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_min_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_i16x8(), b.as_i16x8()).as_m128i() } } @@ -253,7 +267,8 @@ pub fn _mm_min_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pminub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_min_epu8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epu8(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_u8x16(), b.as_u8x16()).as_m128i() } } @@ -267,7 +282,8 @@ pub fn _mm_min_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmulhw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { let a = simd_cast::<_, i32x8>(a.as_i16x8()); let b = simd_cast::<_, i32x8>(b.as_i16x8()); @@ -286,7 +302,8 @@ pub fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmulhuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mulhi_epu16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mulhi_epu16(a: __m128i, b: __m128i) -> __m128i { unsafe { let a = simd_cast::<_, u32x8>(a.as_u16x8()); let b = simd_cast::<_, u32x8>(b.as_u16x8()); @@ -305,7 +322,8 @@ pub fn _mm_mulhi_epu16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmullw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mullo_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mullo_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_mul(a.as_i16x8(), b.as_i16x8())) } } @@ -319,11 +337,12 @@ pub fn _mm_mullo_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmuludq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mul_epu32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_epu32(a: __m128i, b: __m128i) -> __m128i { unsafe { let a = a.as_u64x2(); let b = b.as_u64x2(); - let mask = u64x2::splat(u32::MAX.into()); + let mask = u64x2::splat(u32::MAX as u64); transmute(simd_mul(simd_and(a, mask), simd_and(b, mask))) } } @@ -351,7 +370,8 @@ pub fn _mm_sad_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_sub(a.as_i8x16(), b.as_i8x16())) } } @@ -362,7 +382,8 @@ pub fn _mm_sub_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_sub(a.as_i16x8(), b.as_i16x8())) } } @@ -373,7 +394,8 @@ pub fn _mm_sub_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_sub(a.as_i32x4(), b.as_i32x4())) } } @@ -384,7 +406,8 @@ pub fn _mm_sub_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_sub(a.as_i64x2(), b.as_i64x2())) } } @@ -396,7 +419,8 @@ pub fn _mm_sub_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_subs_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_subs_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_sub(a.as_i8x16(), b.as_i8x16())) } } @@ -408,7 +432,8 @@ pub fn _mm_subs_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_subs_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_subs_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_sub(a.as_i16x8(), b.as_i16x8())) } } @@ -420,7 +445,8 @@ pub fn _mm_subs_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubusb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_subs_epu8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_subs_epu8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_sub(a.as_u8x16(), b.as_u8x16())) } } @@ -432,7 +458,8 @@ pub fn _mm_subs_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(psubusw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_subs_epu16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_subs_epu16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_saturating_sub(a.as_u16x8(), b.as_u16x8())) } } @@ -444,7 +471,8 @@ pub fn _mm_subs_epu16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pslldq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_slli_si128(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_slli_si128(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { _mm_slli_si128_impl::(a) } } @@ -453,7 +481,8 @@ pub fn _mm_slli_si128(a: __m128i) -> __m128i { /// `_mm_slli_si128` intrinsic into a compile-time constant. #[inline] #[target_feature(enable = "sse2")] -unsafe fn _mm_slli_si128_impl(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +const unsafe fn _mm_slli_si128_impl(a: __m128i) -> __m128i { const fn mask(shift: i32, i: u32) -> u32 { let shift = shift as u32 & 0xff; if shift > 15 { i } else { 16 - shift + i } @@ -490,7 +519,8 @@ unsafe fn _mm_slli_si128_impl(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pslldq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_bslli_si128(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_bslli_si128(a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); _mm_slli_si128_impl::(a) @@ -505,7 +535,8 @@ pub fn _mm_bslli_si128(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psrldq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_bsrli_si128(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_bsrli_si128(a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); _mm_srli_si128_impl::(a) @@ -520,7 +551,8 @@ pub fn _mm_bsrli_si128(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psllw, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_slli_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_slli_epi16(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 16 { @@ -551,7 +583,8 @@ pub fn _mm_sll_epi16(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pslld, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_slli_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_slli_epi32(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 32 { @@ -582,7 +615,8 @@ pub fn _mm_sll_epi32(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psllq, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_slli_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_slli_epi64(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 64 { @@ -614,7 +648,8 @@ pub fn _mm_sll_epi64(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psraw, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srai_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srai_epi16(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(simd_shr(a.as_i16x8(), i16x8::splat(IMM8.min(15) as i16))) } } @@ -640,7 +675,8 @@ pub fn _mm_sra_epi16(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psrad, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srai_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srai_epi32(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(simd_shr(a.as_i32x4(), i32x4::splat(IMM8.min(31)))) } } @@ -665,7 +701,8 @@ pub fn _mm_sra_epi32(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psrldq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srli_si128(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srli_si128(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { _mm_srli_si128_impl::(a) } } @@ -674,7 +711,8 @@ pub fn _mm_srli_si128(a: __m128i) -> __m128i { /// `_mm_srli_si128` intrinsic into a compile-time constant. #[inline] #[target_feature(enable = "sse2")] -unsafe fn _mm_srli_si128_impl(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +const unsafe fn _mm_srli_si128_impl(a: __m128i) -> __m128i { const fn mask(shift: i32, i: u32) -> u32 { if (shift as u32) > 15 { i + 16 @@ -716,7 +754,8 @@ unsafe fn _mm_srli_si128_impl(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psrlw, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srli_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srli_epi16(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 16 { @@ -748,7 +787,8 @@ pub fn _mm_srl_epi16(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psrld, IMM8 = 8))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srli_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srli_epi32(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 32 { @@ -780,7 +820,8 @@ pub fn _mm_srl_epi32(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(psrlq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srli_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srli_epi64(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 64 { @@ -811,7 +852,8 @@ pub fn _mm_srl_epi64(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(andps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_and_si128(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_and_si128(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_and(a, b) } } @@ -823,7 +865,8 @@ pub fn _mm_and_si128(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(andnps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_andnot_si128(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_andnot_si128(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_and(simd_xor(_mm_set1_epi8(-1), a), b) } } @@ -835,7 +878,8 @@ pub fn _mm_andnot_si128(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(orps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_or_si128(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_or_si128(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_or(a, b) } } @@ -847,7 +891,8 @@ pub fn _mm_or_si128(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(xorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_xor_si128(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_xor_si128(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_xor(a, b) } } @@ -858,7 +903,8 @@ pub fn _mm_xor_si128(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpeqb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpeq_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_eq(a.as_i8x16(), b.as_i8x16())) } } @@ -869,7 +915,8 @@ pub fn _mm_cmpeq_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpeqw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpeq_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_eq(a.as_i16x8(), b.as_i16x8())) } } @@ -880,7 +927,8 @@ pub fn _mm_cmpeq_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpeqd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpeq_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_eq(a.as_i32x4(), b.as_i32x4())) } } @@ -891,7 +939,8 @@ pub fn _mm_cmpeq_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpgtb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpgt_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_gt(a.as_i8x16(), b.as_i8x16())) } } @@ -902,7 +951,8 @@ pub fn _mm_cmpgt_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpgtw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpgt_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_gt(a.as_i16x8(), b.as_i16x8())) } } @@ -913,7 +963,8 @@ pub fn _mm_cmpgt_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpgtd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpgt_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_gt(a.as_i32x4(), b.as_i32x4())) } } @@ -924,7 +975,8 @@ pub fn _mm_cmpgt_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpgtb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmplt_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_lt(a.as_i8x16(), b.as_i8x16())) } } @@ -935,7 +987,8 @@ pub fn _mm_cmplt_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpgtw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmplt_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_lt(a.as_i16x8(), b.as_i16x8())) } } @@ -946,7 +999,8 @@ pub fn _mm_cmplt_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pcmpgtd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmplt_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_lt(a.as_i32x4(), b.as_i32x4())) } } @@ -958,7 +1012,8 @@ pub fn _mm_cmplt_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtdq2pd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi32_pd(a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi32_pd(a: __m128i) -> __m128d { unsafe { let a = a.as_i32x4(); simd_cast::(simd_shuffle!(a, a, [0, 1])) @@ -973,7 +1028,8 @@ pub fn _mm_cvtepi32_pd(a: __m128i) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtsi2sd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi32_sd(a: __m128d, b: i32) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi32_sd(a: __m128d, b: i32) -> __m128d { unsafe { simd_insert!(a, 0, b as f64) } } @@ -985,7 +1041,8 @@ pub fn _mm_cvtsi32_sd(a: __m128d, b: i32) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtdq2ps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi32_ps(a: __m128i) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi32_ps(a: __m128i) -> __m128 { unsafe { transmute(simd_cast::<_, f32x4>(a.as_i32x4())) } } @@ -1008,7 +1065,8 @@ pub fn _mm_cvtps_epi32(a: __m128) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi32_si128(a: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi32_si128(a: i32) -> __m128i { unsafe { transmute(i32x4::new(a, 0, 0, 0)) } } @@ -1018,7 +1076,8 @@ pub fn _mm_cvtsi32_si128(a: i32) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi128_si32(a: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi128_si32(a: __m128i) -> i32 { unsafe { simd_extract!(a.as_i32x4(), 0) } } @@ -1030,7 +1089,8 @@ pub fn _mm_cvtsi128_si32(a: __m128i) -> i32 { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_epi64x(e1: i64, e0: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_epi64x(e1: i64, e0: i64) -> __m128i { unsafe { transmute(i64x2::new(e0, e1)) } } @@ -1041,7 +1101,8 @@ pub fn _mm_set_epi64x(e1: i64, e0: i64) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i { unsafe { transmute(i32x4::new(e0, e1, e2, e3)) } } @@ -1052,7 +1113,8 @@ pub fn _mm_set_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_epi16( e7: i16, e6: i16, e5: i16, @@ -1072,7 +1134,8 @@ pub fn _mm_set_epi16( #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_epi8( e15: i8, e14: i8, e13: i8, @@ -1105,7 +1168,8 @@ pub fn _mm_set_epi8( #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set1_epi64x(a: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_epi64x(a: i64) -> __m128i { _mm_set_epi64x(a, a) } @@ -1116,7 +1180,8 @@ pub fn _mm_set1_epi64x(a: i64) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set1_epi32(a: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_epi32(a: i32) -> __m128i { _mm_set_epi32(a, a, a, a) } @@ -1127,7 +1192,8 @@ pub fn _mm_set1_epi32(a: i32) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set1_epi16(a: i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_epi16(a: i16) -> __m128i { _mm_set_epi16(a, a, a, a, a, a, a, a) } @@ -1138,7 +1204,8 @@ pub fn _mm_set1_epi16(a: i16) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set1_epi8(a: i8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_epi8(a: i8) -> __m128i { _mm_set_epi8(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a) } @@ -1149,7 +1216,8 @@ pub fn _mm_set1_epi8(a: i8) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setr_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setr_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i { _mm_set_epi32(e0, e1, e2, e3) } @@ -1160,7 +1228,8 @@ pub fn _mm_setr_epi32(e3: i32, e2: i32, e1: i32, e0: i32) -> __m128i { #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setr_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setr_epi16( e7: i16, e6: i16, e5: i16, @@ -1180,7 +1249,8 @@ pub fn _mm_setr_epi16( #[target_feature(enable = "sse2")] // no particular instruction to test #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setr_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setr_epi8( e15: i8, e14: i8, e13: i8, @@ -1211,7 +1281,8 @@ pub fn _mm_setr_epi8( #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(xorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setzero_si128() -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setzero_si128() -> __m128i { const { unsafe { mem::zeroed() } } } @@ -1221,7 +1292,8 @@ pub fn _mm_setzero_si128() -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadl_epi64(mem_addr: *const __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadl_epi64(mem_addr: *const __m128i) -> __m128i { _mm_set_epi64x(0, ptr::read_unaligned(mem_addr as *const i64)) } @@ -1237,7 +1309,8 @@ pub unsafe fn _mm_loadl_epi64(mem_addr: *const __m128i) -> __m128i { assert_instr(movaps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load_si128(mem_addr: *const __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_si128(mem_addr: *const __m128i) -> __m128i { *mem_addr } @@ -1250,7 +1323,8 @@ pub unsafe fn _mm_load_si128(mem_addr: *const __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movups))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadu_si128(mem_addr: *const __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_si128(mem_addr: *const __m128i) -> __m128i { let mut dst: __m128i = _mm_undefined_si128(); ptr::copy_nonoverlapping( mem_addr as *const u8, @@ -1299,7 +1373,8 @@ pub unsafe fn _mm_maskmoveu_si128(a: __m128i, mask: __m128i, mem_addr: *mut i8) assert_instr(movaps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_store_si128(mem_addr: *mut __m128i, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_si128(mem_addr: *mut __m128i, a: __m128i) { *mem_addr = a; } @@ -1312,7 +1387,8 @@ pub unsafe fn _mm_store_si128(mem_addr: *mut __m128i, a: __m128i) { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movups))] // FIXME movdqu expected #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_storeu_si128(mem_addr: *mut __m128i, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_si128(mem_addr: *mut __m128i, a: __m128i) { mem_addr.write_unaligned(a); } @@ -1324,7 +1400,8 @@ pub unsafe fn _mm_storeu_si128(mem_addr: *mut __m128i, a: __m128i) { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_storel_epi64(mem_addr: *mut __m128i, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storel_epi64(mem_addr: *mut __m128i, a: __m128i) { ptr::copy_nonoverlapping(ptr::addr_of!(a) as *const u8, mem_addr as *mut u8, 8); } @@ -1393,7 +1470,8 @@ pub unsafe fn _mm_stream_si32(mem_addr: *mut i32, a: i32) { // FIXME movd on msvc, movd on i686 #[cfg_attr(all(test, target_arch = "x86_64"), assert_instr(movq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_move_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_move_epi64(a: __m128i) -> __m128i { unsafe { let r: i64x2 = simd_shuffle!(a.as_i64x2(), i64x2::ZERO, [0, 2]); transmute(r) @@ -1444,7 +1522,8 @@ pub fn _mm_packus_epi16(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pextrw, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_extract_epi16(a: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_extract_epi16(a: __m128i) -> i32 { static_assert_uimm_bits!(IMM8, 3); unsafe { simd_extract!(a.as_u16x8(), IMM8 as u32, u16) as i32 } } @@ -1457,7 +1536,8 @@ pub fn _mm_extract_epi16(a: __m128i) -> i32 { #[cfg_attr(test, assert_instr(pinsrw, IMM8 = 7))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_insert_epi16(a: __m128i, i: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_insert_epi16(a: __m128i, i: i32) -> __m128i { static_assert_uimm_bits!(IMM8, 3); unsafe { transmute(simd_insert!(a.as_i16x8(), IMM8 as u32, i as i16)) } } @@ -1469,7 +1549,8 @@ pub fn _mm_insert_epi16(a: __m128i, i: i32) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmovmskb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movemask_epi8(a: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movemask_epi8(a: __m128i) -> i32 { unsafe { let z = i8x16::ZERO; let m: i8x16 = simd_lt(a.as_i8x16(), z); @@ -1485,7 +1566,8 @@ pub fn _mm_movemask_epi8(a: __m128i) -> i32 { #[cfg_attr(test, assert_instr(pshufd, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_shuffle_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shuffle_epi32(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i32x4(); @@ -1515,7 +1597,8 @@ pub fn _mm_shuffle_epi32(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pshufhw, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_shufflehi_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shufflehi_epi16(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i16x8(); @@ -1549,7 +1632,8 @@ pub fn _mm_shufflehi_epi16(a: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pshuflw, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_shufflelo_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shufflelo_epi16(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i16x8(); @@ -1578,7 +1662,8 @@ pub fn _mm_shufflelo_epi16(a: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(punpckhbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpackhi_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpackhi_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_shuffle!( a.as_i8x16(), @@ -1595,7 +1680,8 @@ pub fn _mm_unpackhi_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(punpckhwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpackhi_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpackhi_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { let x = simd_shuffle!(a.as_i16x8(), b.as_i16x8(), [4, 12, 5, 13, 6, 14, 7, 15]); transmute::(x) @@ -1609,7 +1695,8 @@ pub fn _mm_unpackhi_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(unpckhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpackhi_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpackhi_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_shuffle!(a.as_i32x4(), b.as_i32x4(), [2, 6, 3, 7])) } } @@ -1620,7 +1707,8 @@ pub fn _mm_unpackhi_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(unpckhpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpackhi_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpackhi_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_shuffle!(a.as_i64x2(), b.as_i64x2(), [1, 3])) } } @@ -1631,7 +1719,8 @@ pub fn _mm_unpackhi_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(punpcklbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpacklo_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpacklo_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_shuffle!( a.as_i8x16(), @@ -1648,7 +1737,8 @@ pub fn _mm_unpacklo_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(punpcklwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpacklo_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpacklo_epi16(a: __m128i, b: __m128i) -> __m128i { unsafe { let x = simd_shuffle!(a.as_i16x8(), b.as_i16x8(), [0, 8, 1, 9, 2, 10, 3, 11]); transmute::(x) @@ -1662,7 +1752,8 @@ pub fn _mm_unpacklo_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(unpcklps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpacklo_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpacklo_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_shuffle!(a.as_i32x4(), b.as_i32x4(), [0, 4, 1, 5])) } } @@ -1673,7 +1764,8 @@ pub fn _mm_unpacklo_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movlhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpacklo_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpacklo_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute::(simd_shuffle!(a.as_i64x2(), b.as_i64x2(), [0, 2])) } } @@ -1685,7 +1777,8 @@ pub fn _mm_unpacklo_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(addsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_sd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_sd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) + _mm_cvtsd_f64(b)) } } @@ -1697,7 +1790,8 @@ pub fn _mm_add_sd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(addpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_add_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_add(a, b) } } @@ -1709,7 +1803,8 @@ pub fn _mm_add_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(divsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_div_sd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_div_sd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) / _mm_cvtsd_f64(b)) } } @@ -1721,7 +1816,8 @@ pub fn _mm_div_sd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(divpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_div_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_div_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_div(a, b) } } @@ -1781,7 +1877,8 @@ pub fn _mm_min_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(mulsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mul_sd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_sd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) * _mm_cvtsd_f64(b)) } } @@ -1793,7 +1890,8 @@ pub fn _mm_mul_sd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(mulpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mul_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_mul(a, b) } } @@ -1828,7 +1926,8 @@ pub fn _mm_sqrt_pd(a: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(subsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_sd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_sd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_insert!(a, 0, _mm_cvtsd_f64(a) - _mm_cvtsd_f64(b)) } } @@ -1840,7 +1939,8 @@ pub fn _mm_sub_sd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(subpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sub_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_sub(a, b) } } @@ -1852,7 +1952,8 @@ pub fn _mm_sub_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(andps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_and_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_and_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let a: __m128i = transmute(a); let b: __m128i = transmute(b); @@ -1867,7 +1968,8 @@ pub fn _mm_and_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(andnps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_andnot_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_andnot_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let a: __m128i = transmute(a); let b: __m128i = transmute(b); @@ -1882,7 +1984,8 @@ pub fn _mm_andnot_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(orps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_or_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_or_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let a: __m128i = transmute(a); let b: __m128i = transmute(b); @@ -1897,7 +2000,8 @@ pub fn _mm_or_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(xorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_xor_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_xor_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let a: __m128i = transmute(a); let b: __m128i = transmute(b); @@ -2325,7 +2429,8 @@ pub fn _mm_ucomineq_sd(a: __m128d, b: __m128d) -> i32 { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtpd2ps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtpd_ps(a: __m128d) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtpd_ps(a: __m128d) -> __m128 { unsafe { let r = simd_cast::<_, f32x2>(a.as_f64x2()); let zero = f32x2::ZERO; @@ -2342,7 +2447,8 @@ pub fn _mm_cvtpd_ps(a: __m128d) -> __m128 { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtps2pd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtps_pd(a: __m128) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtps_pd(a: __m128) -> __m128d { unsafe { let a = a.as_f32x4(); transmute(simd_cast::(simd_shuffle!(a, a, [0, 1]))) @@ -2393,7 +2499,8 @@ pub fn _mm_cvtsd_ss(a: __m128, b: __m128d) -> __m128 { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsd_f64(a: __m128d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsd_f64(a: __m128d) -> f64 { unsafe { simd_extract!(a, 0) } } @@ -2407,7 +2514,8 @@ pub fn _mm_cvtsd_f64(a: __m128d) -> f64 { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtss2sd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtss_sd(a: __m128d, b: __m128) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtss_sd(a: __m128d, b: __m128) -> __m128d { unsafe { let elt: f32 = simd_extract!(b, 0); simd_insert!(a, 0, elt as f64) @@ -2457,7 +2565,8 @@ pub fn _mm_cvttps_epi32(a: __m128) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_sd(a: f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_sd(a: f64) -> __m128d { _mm_set_pd(0.0, a) } @@ -2468,7 +2577,8 @@ pub fn _mm_set_sd(a: f64) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set1_pd(a: f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_pd(a: f64) -> __m128d { _mm_set_pd(a, a) } @@ -2479,7 +2589,8 @@ pub fn _mm_set1_pd(a: f64) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_pd1(a: f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_pd1(a: f64) -> __m128d { _mm_set_pd(a, a) } @@ -2490,7 +2601,8 @@ pub fn _mm_set_pd1(a: f64) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_set_pd(a: f64, b: f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_pd(a: f64, b: f64) -> __m128d { __m128d([b, a]) } @@ -2501,7 +2613,8 @@ pub fn _mm_set_pd(a: f64, b: f64) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setr_pd(a: f64, b: f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setr_pd(a: f64, b: f64) -> __m128d { _mm_set_pd(b, a) } @@ -2513,7 +2626,8 @@ pub fn _mm_setr_pd(a: f64, b: f64) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(xorp))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_setzero_pd() -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setzero_pd() -> __m128d { const { unsafe { mem::zeroed() } } } @@ -2527,12 +2641,13 @@ pub fn _mm_setzero_pd() -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movmskpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movemask_pd(a: __m128d) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movemask_pd(a: __m128d) -> i32 { // Propagate the highest bit to the rest, because simd_bitmask // requires all-1 or all-0. unsafe { let mask: i64x2 = simd_lt(transmute(a), i64x2::ZERO); - simd_bitmask::(mask).into() + simd_bitmask::(mask) as i32 } } @@ -2550,7 +2665,8 @@ pub fn _mm_movemask_pd(a: __m128d) -> i32 { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_load_pd(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_pd(mem_addr: *const f64) -> __m128d { *(mem_addr as *const __m128d) } @@ -2562,7 +2678,8 @@ pub unsafe fn _mm_load_pd(mem_addr: *const f64) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load_sd(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_sd(mem_addr: *const f64) -> __m128d { _mm_setr_pd(*mem_addr, 0.) } @@ -2575,7 +2692,8 @@ pub unsafe fn _mm_load_sd(mem_addr: *const f64) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadh_pd(a: __m128d, mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadh_pd(a: __m128d, mem_addr: *const f64) -> __m128d { _mm_setr_pd(simd_extract!(a, 0), *mem_addr) } @@ -2588,7 +2706,8 @@ pub unsafe fn _mm_loadh_pd(a: __m128d, mem_addr: *const f64) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movlps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadl_pd(a: __m128d, mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadl_pd(a: __m128d, mem_addr: *const f64) -> __m128d { _mm_setr_pd(*mem_addr, simd_extract!(a, 1)) } @@ -2630,7 +2749,8 @@ pub unsafe fn _mm_stream_pd(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movlps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_store_sd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_sd(mem_addr: *mut f64, a: __m128d) { *mem_addr = simd_extract!(a, 0) } @@ -2647,7 +2767,8 @@ pub unsafe fn _mm_store_sd(mem_addr: *mut f64, a: __m128d) { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_store_pd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_pd(mem_addr: *mut f64, a: __m128d) { *(mem_addr as *mut __m128d) = a; } @@ -2660,7 +2781,8 @@ pub unsafe fn _mm_store_pd(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movups))] // FIXME movupd expected #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_storeu_pd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_pd(mem_addr: *mut f64, a: __m128d) { mem_addr.cast::<__m128d>().write_unaligned(a); } @@ -2672,7 +2794,8 @@ pub unsafe fn _mm_storeu_pd(mem_addr: *mut f64, a: __m128d) { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub unsafe fn _mm_storeu_si16(mem_addr: *mut u8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_si16(mem_addr: *mut u8, a: __m128i) { ptr::write_unaligned(mem_addr as *mut i16, simd_extract(a.as_i16x8(), 0)) } @@ -2684,7 +2807,8 @@ pub unsafe fn _mm_storeu_si16(mem_addr: *mut u8, a: __m128i) { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub unsafe fn _mm_storeu_si32(mem_addr: *mut u8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_si32(mem_addr: *mut u8, a: __m128i) { ptr::write_unaligned(mem_addr as *mut i32, simd_extract(a.as_i32x4(), 0)) } @@ -2696,7 +2820,8 @@ pub unsafe fn _mm_storeu_si32(mem_addr: *mut u8, a: __m128i) { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub unsafe fn _mm_storeu_si64(mem_addr: *mut u8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_si64(mem_addr: *mut u8, a: __m128i) { ptr::write_unaligned(mem_addr as *mut i64, simd_extract(a.as_i64x2(), 0)) } @@ -2709,7 +2834,8 @@ pub unsafe fn _mm_storeu_si64(mem_addr: *mut u8, a: __m128i) { #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_store1_pd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store1_pd(mem_addr: *mut f64, a: __m128d) { let b: __m128d = simd_shuffle!(a, a, [0, 0]); *(mem_addr as *mut __m128d) = b; } @@ -2723,7 +2849,8 @@ pub unsafe fn _mm_store1_pd(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_store_pd1(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_pd1(mem_addr: *mut f64, a: __m128d) { let b: __m128d = simd_shuffle!(a, a, [0, 0]); *(mem_addr as *mut __m128d) = b; } @@ -2738,7 +2865,8 @@ pub unsafe fn _mm_store_pd1(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm_storer_pd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storer_pd(mem_addr: *mut f64, a: __m128d) { let b: __m128d = simd_shuffle!(a, a, [1, 0]); *(mem_addr as *mut __m128d) = b; } @@ -2751,7 +2879,8 @@ pub unsafe fn _mm_storer_pd(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_storeh_pd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeh_pd(mem_addr: *mut f64, a: __m128d) { *mem_addr = simd_extract!(a, 1); } @@ -2763,7 +2892,8 @@ pub unsafe fn _mm_storeh_pd(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movlps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_storel_pd(mem_addr: *mut f64, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storel_pd(mem_addr: *mut f64, a: __m128d) { *mem_addr = simd_extract!(a, 0); } @@ -2775,7 +2905,8 @@ pub unsafe fn _mm_storel_pd(mem_addr: *mut f64, a: __m128d) { #[target_feature(enable = "sse2")] // #[cfg_attr(test, assert_instr(movapd))] // FIXME LLVM uses different codegen #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load1_pd(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load1_pd(mem_addr: *const f64) -> __m128d { let d = *mem_addr; _mm_setr_pd(d, d) } @@ -2788,7 +2919,8 @@ pub unsafe fn _mm_load1_pd(mem_addr: *const f64) -> __m128d { #[target_feature(enable = "sse2")] // #[cfg_attr(test, assert_instr(movapd))] // FIXME same as _mm_load1_pd #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_load_pd1(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_pd1(mem_addr: *const f64) -> __m128d { _mm_load1_pd(mem_addr) } @@ -2804,7 +2936,8 @@ pub unsafe fn _mm_load_pd1(mem_addr: *const f64) -> __m128d { assert_instr(movaps) )] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadr_pd(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadr_pd(mem_addr: *const f64) -> __m128d { let a = _mm_load_pd(mem_addr); simd_shuffle!(a, a, [1, 0]) } @@ -2818,7 +2951,8 @@ pub unsafe fn _mm_loadr_pd(mem_addr: *const f64) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movups))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loadu_pd(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_pd(mem_addr: *const f64) -> __m128d { let mut dst = _mm_undefined_pd(); ptr::copy_nonoverlapping( mem_addr as *const u8, @@ -2836,7 +2970,8 @@ pub unsafe fn _mm_loadu_pd(mem_addr: *const f64) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub unsafe fn _mm_loadu_si16(mem_addr: *const u8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_si16(mem_addr: *const u8) -> __m128i { transmute(i16x8::new( ptr::read_unaligned(mem_addr as *const i16), 0, @@ -2857,7 +2992,8 @@ pub unsafe fn _mm_loadu_si16(mem_addr: *const u8) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub unsafe fn _mm_loadu_si32(mem_addr: *const u8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_si32(mem_addr: *const u8) -> __m128i { transmute(i32x4::new( ptr::read_unaligned(mem_addr as *const i32), 0, @@ -2874,7 +3010,8 @@ pub unsafe fn _mm_loadu_si32(mem_addr: *const u8) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86_mm_loadu_si64", since = "1.46.0")] -pub unsafe fn _mm_loadu_si64(mem_addr: *const u8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_si64(mem_addr: *const u8) -> __m128i { transmute(i64x2::new(ptr::read_unaligned(mem_addr as *const i64), 0)) } @@ -2888,7 +3025,8 @@ pub unsafe fn _mm_loadu_si64(mem_addr: *const u8) -> __m128i { #[cfg_attr(test, assert_instr(shufps, MASK = 2))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_shuffle_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shuffle_pd(a: __m128d, b: __m128d) -> __m128d { static_assert_uimm_bits!(MASK, 8); unsafe { simd_shuffle!(a, b, [MASK as u32 & 0b1, ((MASK as u32 >> 1) & 0b1) + 2]) } } @@ -2902,7 +3040,8 @@ pub fn _mm_shuffle_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_move_sd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_move_sd(a: __m128d, b: __m128d) -> __m128d { unsafe { _mm_setr_pd(simd_extract!(b, 0), simd_extract!(a, 1)) } } @@ -2913,7 +3052,8 @@ pub fn _mm_move_sd(a: __m128d, b: __m128d) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_castpd_ps(a: __m128d) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castpd_ps(a: __m128d) -> __m128 { unsafe { transmute(a) } } @@ -2924,7 +3064,8 @@ pub fn _mm_castpd_ps(a: __m128d) -> __m128 { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_castpd_si128(a: __m128d) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castpd_si128(a: __m128d) -> __m128i { unsafe { transmute(a) } } @@ -2935,7 +3076,8 @@ pub fn _mm_castpd_si128(a: __m128d) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_castps_pd(a: __m128) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castps_pd(a: __m128) -> __m128d { unsafe { transmute(a) } } @@ -2946,7 +3088,8 @@ pub fn _mm_castps_pd(a: __m128) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_castps_si128(a: __m128) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castps_si128(a: __m128) -> __m128i { unsafe { transmute(a) } } @@ -2957,7 +3100,8 @@ pub fn _mm_castps_si128(a: __m128) -> __m128i { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_castsi128_pd(a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castsi128_pd(a: __m128i) -> __m128d { unsafe { transmute(a) } } @@ -2968,7 +3112,8 @@ pub fn _mm_castsi128_pd(a: __m128i) -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_castsi128_ps(a: __m128i) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castsi128_ps(a: __m128i) -> __m128 { unsafe { transmute(a) } } @@ -2981,7 +3126,8 @@ pub fn _mm_castsi128_ps(a: __m128i) -> __m128 { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_undefined_pd() -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_undefined_pd() -> __m128d { const { unsafe { mem::zeroed() } } } @@ -2994,7 +3140,8 @@ pub fn _mm_undefined_pd() -> __m128d { #[inline] #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_undefined_si128() -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_undefined_si128() -> __m128i { const { unsafe { mem::zeroed() } } } @@ -3009,7 +3156,8 @@ pub fn _mm_undefined_si128() -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(unpckhpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpackhi_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpackhi_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_shuffle!(a, b, [1, 3]) } } @@ -3024,7 +3172,8 @@ pub fn _mm_unpackhi_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movlhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_unpacklo_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_unpacklo_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { simd_shuffle!(a, b, [0, 2]) } } @@ -3118,6 +3267,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::{ core_arch::{simd::*, x86::*}, hint::black_box, @@ -3157,7 +3307,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_add_epi8() { + const unsafe fn test_mm_add_epi8() { let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); #[rustfmt::skip] let b = _mm_setr_epi8( @@ -3180,7 +3330,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_add_epi16() { + const unsafe fn test_mm_add_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_add_epi16(a, b); @@ -3189,7 +3339,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_add_epi32() { + const unsafe fn test_mm_add_epi32() { let a = _mm_setr_epi32(0, 1, 2, 3); let b = _mm_setr_epi32(4, 5, 6, 7); let r = _mm_add_epi32(a, b); @@ -3198,7 +3348,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_add_epi64() { + const unsafe fn test_mm_add_epi64() { let a = _mm_setr_epi64x(0, 1); let b = _mm_setr_epi64x(2, 3); let r = _mm_add_epi64(a, b); @@ -3207,7 +3357,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_adds_epi8() { + const unsafe fn test_mm_adds_epi8() { let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); #[rustfmt::skip] let b = _mm_setr_epi8( @@ -3238,7 +3388,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_adds_epi16() { + const unsafe fn test_mm_adds_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_adds_epi16(a, b); @@ -3263,7 +3413,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_adds_epu8() { + const unsafe fn test_mm_adds_epu8() { let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); #[rustfmt::skip] let b = _mm_setr_epi8( @@ -3286,7 +3436,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_adds_epu16() { + const unsafe fn test_mm_adds_epu16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_adds_epu16(a, b); @@ -3303,21 +3453,21 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_avg_epu8() { + const unsafe fn test_mm_avg_epu8() { let (a, b) = (_mm_set1_epi8(3), _mm_set1_epi8(9)); let r = _mm_avg_epu8(a, b); assert_eq_m128i(r, _mm_set1_epi8(6)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_avg_epu16() { + const unsafe fn test_mm_avg_epu16() { let (a, b) = (_mm_set1_epi16(3), _mm_set1_epi16(9)); let r = _mm_avg_epu16(a, b); assert_eq_m128i(r, _mm_set1_epi16(6)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_madd_epi16() { + const unsafe fn test_mm_madd_epi16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_setr_epi16(9, 10, 11, 12, 13, 14, 15, 16); let r = _mm_madd_epi16(a, b); @@ -3352,7 +3502,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_max_epi16() { + const unsafe fn test_mm_max_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(-1); let r = _mm_max_epi16(a, b); @@ -3360,7 +3510,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_max_epu8() { + const unsafe fn test_mm_max_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(!0); let r = _mm_max_epu8(a, b); @@ -3368,7 +3518,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_min_epi16() { + const unsafe fn test_mm_min_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(-1); let r = _mm_min_epi16(a, b); @@ -3376,7 +3526,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_min_epu8() { + const unsafe fn test_mm_min_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(!0); let r = _mm_min_epu8(a, b); @@ -3384,28 +3534,28 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_mulhi_epi16() { + const unsafe fn test_mm_mulhi_epi16() { let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(-1001)); let r = _mm_mulhi_epi16(a, b); assert_eq_m128i(r, _mm_set1_epi16(-16)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_mulhi_epu16() { + const unsafe fn test_mm_mulhi_epu16() { let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(1001)); let r = _mm_mulhi_epu16(a, b); assert_eq_m128i(r, _mm_set1_epi16(15)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_mullo_epi16() { + const unsafe fn test_mm_mullo_epi16() { let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(-1001)); let r = _mm_mullo_epi16(a, b); assert_eq_m128i(r, _mm_set1_epi16(-17960)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_mul_epu32() { + const unsafe fn test_mm_mul_epu32() { let a = _mm_setr_epi64x(1_000_000_000, 1 << 34); let b = _mm_setr_epi64x(1_000_000_000, 1 << 35); let r = _mm_mul_epu32(a, b); @@ -3429,35 +3579,35 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_sub_epi8() { + const unsafe fn test_mm_sub_epi8() { let (a, b) = (_mm_set1_epi8(5), _mm_set1_epi8(6)); let r = _mm_sub_epi8(a, b); assert_eq_m128i(r, _mm_set1_epi8(-1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_sub_epi16() { + const unsafe fn test_mm_sub_epi16() { let (a, b) = (_mm_set1_epi16(5), _mm_set1_epi16(6)); let r = _mm_sub_epi16(a, b); assert_eq_m128i(r, _mm_set1_epi16(-1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_sub_epi32() { + const unsafe fn test_mm_sub_epi32() { let (a, b) = (_mm_set1_epi32(5), _mm_set1_epi32(6)); let r = _mm_sub_epi32(a, b); assert_eq_m128i(r, _mm_set1_epi32(-1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_sub_epi64() { + const unsafe fn test_mm_sub_epi64() { let (a, b) = (_mm_set1_epi64x(5), _mm_set1_epi64x(6)); let r = _mm_sub_epi64(a, b); assert_eq_m128i(r, _mm_set1_epi64x(-1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_subs_epi8() { + const unsafe fn test_mm_subs_epi8() { let (a, b) = (_mm_set1_epi8(5), _mm_set1_epi8(2)); let r = _mm_subs_epi8(a, b); assert_eq_m128i(r, _mm_set1_epi8(3)); @@ -3480,7 +3630,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_subs_epi16() { + const unsafe fn test_mm_subs_epi16() { let (a, b) = (_mm_set1_epi16(5), _mm_set1_epi16(2)); let r = _mm_subs_epi16(a, b); assert_eq_m128i(r, _mm_set1_epi16(3)); @@ -3503,7 +3653,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_subs_epu8() { + const unsafe fn test_mm_subs_epu8() { let (a, b) = (_mm_set1_epi8(5), _mm_set1_epi8(2)); let r = _mm_subs_epu8(a, b); assert_eq_m128i(r, _mm_set1_epi8(3)); @@ -3518,7 +3668,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_subs_epu16() { + const unsafe fn test_mm_subs_epu16() { let (a, b) = (_mm_set1_epi16(5), _mm_set1_epi16(2)); let r = _mm_subs_epu16(a, b); assert_eq_m128i(r, _mm_set1_epi16(3)); @@ -3533,7 +3683,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_slli_si128() { + const unsafe fn test_mm_slli_si128() { #[rustfmt::skip] let a = _mm_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -3559,7 +3709,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_slli_epi16() { + const unsafe fn test_mm_slli_epi16() { let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF); let r = _mm_slli_epi16::<4>(a); assert_eq_m128i( @@ -3587,7 +3737,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_slli_epi32() { + const unsafe fn test_mm_slli_epi32() { let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF); let r = _mm_slli_epi32::<4>(a); assert_eq_m128i(r, _mm_setr_epi32(0xEEEE0, -0xEEEE0, 0xFFFF0, -0xFFFF0)); @@ -3609,7 +3759,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_slli_epi64() { + const unsafe fn test_mm_slli_epi64() { let a = _mm_set_epi64x(0xFFFFFFFF, -0xFFFFFFFF); let r = _mm_slli_epi64::<4>(a); assert_eq_m128i(r, _mm_set_epi64x(0xFFFFFFFF0, -0xFFFFFFFF0)); @@ -3631,7 +3781,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_srai_epi16() { + const unsafe fn test_mm_srai_epi16() { let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF); let r = _mm_srai_epi16::<4>(a); assert_eq_m128i( @@ -3659,7 +3809,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_srai_epi32() { + const unsafe fn test_mm_srai_epi32() { let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF); let r = _mm_srai_epi32::<4>(a); assert_eq_m128i(r, _mm_setr_epi32(0xEEE, -0xEEF, 0xFFF, -0x1000)); @@ -3681,7 +3831,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_srli_si128() { + const unsafe fn test_mm_srli_si128() { #[rustfmt::skip] let a = _mm_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -3710,7 +3860,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_srli_epi16() { + const unsafe fn test_mm_srli_epi16() { let a = _mm_setr_epi16(0xCC, -0xCC, 0xDD, -0xDD, 0xEE, -0xEE, 0xFF, -0xFF); let r = _mm_srli_epi16::<4>(a); assert_eq_m128i( @@ -3738,7 +3888,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_srli_epi32() { + const unsafe fn test_mm_srli_epi32() { let a = _mm_setr_epi32(0xEEEE, -0xEEEE, 0xFFFF, -0xFFFF); let r = _mm_srli_epi32::<4>(a); assert_eq_m128i(r, _mm_setr_epi32(0xEEE, 0xFFFF111, 0xFFF, 0xFFFF000)); @@ -3760,7 +3910,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_srli_epi64() { + const unsafe fn test_mm_srli_epi64() { let a = _mm_set_epi64x(0xFFFFFFFF, -0xFFFFFFFF); let r = _mm_srli_epi64::<4>(a); assert_eq_m128i(r, _mm_set_epi64x(0xFFFFFFF, 0xFFFFFFFF0000000)); @@ -3782,7 +3932,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_and_si128() { + const unsafe fn test_mm_and_si128() { let a = _mm_set1_epi8(5); let b = _mm_set1_epi8(3); let r = _mm_and_si128(a, b); @@ -3790,7 +3940,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_andnot_si128() { + const unsafe fn test_mm_andnot_si128() { let a = _mm_set1_epi8(5); let b = _mm_set1_epi8(3); let r = _mm_andnot_si128(a, b); @@ -3798,7 +3948,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_or_si128() { + const unsafe fn test_mm_or_si128() { let a = _mm_set1_epi8(5); let b = _mm_set1_epi8(3); let r = _mm_or_si128(a, b); @@ -3806,7 +3956,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_xor_si128() { + const unsafe fn test_mm_xor_si128() { let a = _mm_set1_epi8(5); let b = _mm_set1_epi8(3); let r = _mm_xor_si128(a, b); @@ -3814,7 +3964,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmpeq_epi8() { + const unsafe fn test_mm_cmpeq_epi8() { let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_setr_epi8(15, 14, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_cmpeq_epi8(a, b); @@ -3828,7 +3978,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmpeq_epi16() { + const unsafe fn test_mm_cmpeq_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_setr_epi16(7, 6, 2, 4, 3, 2, 1, 0); let r = _mm_cmpeq_epi16(a, b); @@ -3836,7 +3986,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmpeq_epi32() { + const unsafe fn test_mm_cmpeq_epi32() { let a = _mm_setr_epi32(0, 1, 2, 3); let b = _mm_setr_epi32(3, 2, 2, 0); let r = _mm_cmpeq_epi32(a, b); @@ -3844,7 +3994,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmpgt_epi8() { + const unsafe fn test_mm_cmpgt_epi8() { let a = _mm_set_epi8(5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); let b = _mm_set1_epi8(0); let r = _mm_cmpgt_epi8(a, b); @@ -3853,7 +4003,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmpgt_epi16() { + const unsafe fn test_mm_cmpgt_epi16() { let a = _mm_set_epi16(5, 0, 0, 0, 0, 0, 0, 0); let b = _mm_set1_epi16(0); let r = _mm_cmpgt_epi16(a, b); @@ -3862,7 +4012,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmpgt_epi32() { + const unsafe fn test_mm_cmpgt_epi32() { let a = _mm_set_epi32(5, 0, 0, 0); let b = _mm_set1_epi32(0); let r = _mm_cmpgt_epi32(a, b); @@ -3870,7 +4020,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmplt_epi8() { + const unsafe fn test_mm_cmplt_epi8() { let a = _mm_set1_epi8(0); let b = _mm_set_epi8(5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); let r = _mm_cmplt_epi8(a, b); @@ -3879,7 +4029,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmplt_epi16() { + const unsafe fn test_mm_cmplt_epi16() { let a = _mm_set1_epi16(0); let b = _mm_set_epi16(5, 0, 0, 0, 0, 0, 0, 0); let r = _mm_cmplt_epi16(a, b); @@ -3888,7 +4038,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cmplt_epi32() { + const unsafe fn test_mm_cmplt_epi32() { let a = _mm_set1_epi32(0); let b = _mm_set_epi32(5, 0, 0, 0); let r = _mm_cmplt_epi32(a, b); @@ -3896,21 +4046,21 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtepi32_pd() { + const unsafe fn test_mm_cvtepi32_pd() { let a = _mm_set_epi32(35, 25, 15, 5); let r = _mm_cvtepi32_pd(a); assert_eq_m128d(r, _mm_setr_pd(5.0, 15.0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsi32_sd() { + const unsafe fn test_mm_cvtsi32_sd() { let a = _mm_set1_pd(3.5); let r = _mm_cvtsi32_sd(a, 5); assert_eq_m128d(r, _mm_setr_pd(5.0, 3.5)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtepi32_ps() { + const unsafe fn test_mm_cvtepi32_ps() { let a = _mm_setr_epi32(1, 2, 3, 4); let r = _mm_cvtepi32_ps(a); assert_eq_m128(r, _mm_setr_ps(1.0, 2.0, 3.0, 4.0)); @@ -3924,37 +4074,37 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsi32_si128() { + const unsafe fn test_mm_cvtsi32_si128() { let r = _mm_cvtsi32_si128(5); assert_eq_m128i(r, _mm_setr_epi32(5, 0, 0, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsi128_si32() { + const unsafe fn test_mm_cvtsi128_si32() { let r = _mm_cvtsi128_si32(_mm_setr_epi32(5, 0, 0, 0)); assert_eq!(r, 5); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_epi64x() { + const unsafe fn test_mm_set_epi64x() { let r = _mm_set_epi64x(0, 1); assert_eq_m128i(r, _mm_setr_epi64x(1, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_epi32() { + const unsafe fn test_mm_set_epi32() { let r = _mm_set_epi32(0, 1, 2, 3); assert_eq_m128i(r, _mm_setr_epi32(3, 2, 1, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_epi16() { + const unsafe fn test_mm_set_epi16() { let r = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); assert_eq_m128i(r, _mm_setr_epi16(7, 6, 5, 4, 3, 2, 1, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_epi8() { + const unsafe fn test_mm_set_epi8() { #[rustfmt::skip] let r = _mm_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -3968,43 +4118,43 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set1_epi64x() { + const unsafe fn test_mm_set1_epi64x() { let r = _mm_set1_epi64x(1); assert_eq_m128i(r, _mm_set1_epi64x(1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set1_epi32() { + const unsafe fn test_mm_set1_epi32() { let r = _mm_set1_epi32(1); assert_eq_m128i(r, _mm_set1_epi32(1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set1_epi16() { + const unsafe fn test_mm_set1_epi16() { let r = _mm_set1_epi16(1); assert_eq_m128i(r, _mm_set1_epi16(1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set1_epi8() { + const unsafe fn test_mm_set1_epi8() { let r = _mm_set1_epi8(1); assert_eq_m128i(r, _mm_set1_epi8(1)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_setr_epi32() { + const unsafe fn test_mm_setr_epi32() { let r = _mm_setr_epi32(0, 1, 2, 3); assert_eq_m128i(r, _mm_setr_epi32(0, 1, 2, 3)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_setr_epi16() { + const unsafe fn test_mm_setr_epi16() { let r = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); assert_eq_m128i(r, _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_setr_epi8() { + const unsafe fn test_mm_setr_epi8() { #[rustfmt::skip] let r = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -4018,27 +4168,27 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_setzero_si128() { + const unsafe fn test_mm_setzero_si128() { let r = _mm_setzero_si128(); assert_eq_m128i(r, _mm_set1_epi64x(0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadl_epi64() { + const unsafe fn test_mm_loadl_epi64() { let a = _mm_setr_epi64x(6, 5); let r = _mm_loadl_epi64(ptr::addr_of!(a)); assert_eq_m128i(r, _mm_setr_epi64x(6, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_load_si128() { + const unsafe fn test_mm_load_si128() { let a = _mm_set_epi64x(5, 6); let r = _mm_load_si128(ptr::addr_of!(a) as *const _); assert_eq_m128i(a, r); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadu_si128() { + const unsafe fn test_mm_loadu_si128() { let a = _mm_set_epi64x(5, 6); let r = _mm_loadu_si128(ptr::addr_of!(a) as *const _); assert_eq_m128i(a, r); @@ -4063,7 +4213,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_store_si128() { + const unsafe fn test_mm_store_si128() { let a = _mm_set1_epi8(9); let mut r = _mm_set1_epi8(0); _mm_store_si128(&mut r, a); @@ -4071,7 +4221,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storeu_si128() { + const unsafe fn test_mm_storeu_si128() { let a = _mm_set1_epi8(9); let mut r = _mm_set1_epi8(0); _mm_storeu_si128(&mut r, a); @@ -4079,7 +4229,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storel_epi64() { + const unsafe fn test_mm_storel_epi64() { let a = _mm_setr_epi64x(2, 9); let mut r = _mm_set1_epi8(0); _mm_storel_epi64(&mut r, a); @@ -4111,7 +4261,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_move_epi64() { + const unsafe fn test_mm_move_epi64() { let a = _mm_setr_epi64x(5, 6); let r = _mm_move_epi64(a); assert_eq_m128i(r, _mm_setr_epi64x(5, 0)); @@ -4154,7 +4304,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_extract_epi16() { + const unsafe fn test_mm_extract_epi16() { let a = _mm_setr_epi16(-1, 1, 2, 3, 4, 5, 6, 7); let r1 = _mm_extract_epi16::<0>(a); let r2 = _mm_extract_epi16::<3>(a); @@ -4163,7 +4313,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_insert_epi16() { + const unsafe fn test_mm_insert_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm_insert_epi16::<0>(a, 9); let e = _mm_setr_epi16(9, 1, 2, 3, 4, 5, 6, 7); @@ -4171,7 +4321,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_movemask_epi8() { + const unsafe fn test_mm_movemask_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, 0b01, @@ -4184,7 +4334,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_shuffle_epi32() { + const unsafe fn test_mm_shuffle_epi32() { let a = _mm_setr_epi32(5, 10, 15, 20); let r = _mm_shuffle_epi32::<0b00_01_01_11>(a); let e = _mm_setr_epi32(20, 10, 10, 5); @@ -4192,7 +4342,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_shufflehi_epi16() { + const unsafe fn test_mm_shufflehi_epi16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 10, 15, 20); let r = _mm_shufflehi_epi16::<0b00_01_01_11>(a); let e = _mm_setr_epi16(1, 2, 3, 4, 20, 10, 10, 5); @@ -4200,7 +4350,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_shufflelo_epi16() { + const unsafe fn test_mm_shufflelo_epi16() { let a = _mm_setr_epi16(5, 10, 15, 20, 1, 2, 3, 4); let r = _mm_shufflelo_epi16::<0b00_01_01_11>(a); let e = _mm_setr_epi16(20, 10, 10, 5, 1, 2, 3, 4); @@ -4208,7 +4358,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpackhi_epi8() { + const unsafe fn test_mm_unpackhi_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4227,7 +4377,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpackhi_epi16() { + const unsafe fn test_mm_unpackhi_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_unpackhi_epi16(a, b); @@ -4236,7 +4386,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpackhi_epi32() { + const unsafe fn test_mm_unpackhi_epi32() { let a = _mm_setr_epi32(0, 1, 2, 3); let b = _mm_setr_epi32(4, 5, 6, 7); let r = _mm_unpackhi_epi32(a, b); @@ -4245,7 +4395,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpackhi_epi64() { + const unsafe fn test_mm_unpackhi_epi64() { let a = _mm_setr_epi64x(0, 1); let b = _mm_setr_epi64x(2, 3); let r = _mm_unpackhi_epi64(a, b); @@ -4254,7 +4404,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpacklo_epi8() { + const unsafe fn test_mm_unpacklo_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4274,7 +4424,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpacklo_epi16() { + const unsafe fn test_mm_unpacklo_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_setr_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_unpacklo_epi16(a, b); @@ -4283,7 +4433,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpacklo_epi32() { + const unsafe fn test_mm_unpacklo_epi32() { let a = _mm_setr_epi32(0, 1, 2, 3); let b = _mm_setr_epi32(4, 5, 6, 7); let r = _mm_unpacklo_epi32(a, b); @@ -4292,7 +4442,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpacklo_epi64() { + const unsafe fn test_mm_unpacklo_epi64() { let a = _mm_setr_epi64x(0, 1); let b = _mm_setr_epi64x(2, 3); let r = _mm_unpacklo_epi64(a, b); @@ -4301,7 +4451,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_add_sd() { + const unsafe fn test_mm_add_sd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_add_sd(a, b); @@ -4309,7 +4459,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_add_pd() { + const unsafe fn test_mm_add_pd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_add_pd(a, b); @@ -4317,7 +4467,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_div_sd() { + const unsafe fn test_mm_div_sd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_div_sd(a, b); @@ -4325,7 +4475,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_div_pd() { + const unsafe fn test_mm_div_pd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_div_pd(a, b); @@ -4387,7 +4537,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_mul_sd() { + const unsafe fn test_mm_mul_sd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_mul_sd(a, b); @@ -4395,7 +4545,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_mul_pd() { + const unsafe fn test_mm_mul_pd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_mul_pd(a, b); @@ -4417,7 +4567,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_sub_sd() { + const unsafe fn test_mm_sub_sd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_sub_sd(a, b); @@ -4425,7 +4575,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_sub_pd() { + const unsafe fn test_mm_sub_pd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(5.0, 10.0); let r = _mm_sub_pd(a, b); @@ -4433,7 +4583,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_and_pd() { + const unsafe fn test_mm_and_pd() { let a = transmute(u64x2::splat(5)); let b = transmute(u64x2::splat(3)); let r = _mm_and_pd(a, b); @@ -4442,7 +4592,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_andnot_pd() { + const unsafe fn test_mm_andnot_pd() { let a = transmute(u64x2::splat(5)); let b = transmute(u64x2::splat(3)); let r = _mm_andnot_pd(a, b); @@ -4451,7 +4601,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_or_pd() { + const unsafe fn test_mm_or_pd() { let a = transmute(u64x2::splat(5)); let b = transmute(u64x2::splat(3)); let r = _mm_or_pd(a, b); @@ -4460,7 +4610,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_xor_pd() { + const unsafe fn test_mm_xor_pd() { let a = transmute(u64x2::splat(5)); let b = transmute(u64x2::splat(3)); let r = _mm_xor_pd(a, b); @@ -4739,7 +4889,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_movemask_pd() { + const unsafe fn test_mm_movemask_pd() { let r = _mm_movemask_pd(_mm_setr_pd(-1.0, 5.0)); assert_eq!(r, 0b01); @@ -4753,7 +4903,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_load_pd() { + const unsafe fn test_mm_load_pd() { let mem = Memory { data: [1.0f64, 2.0, 3.0, 4.0], }; @@ -4765,7 +4915,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_load_sd() { + const unsafe fn test_mm_load_sd() { let a = 1.; let expected = _mm_setr_pd(a, 0.); let r = _mm_load_sd(&a); @@ -4773,7 +4923,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadh_pd() { + const unsafe fn test_mm_loadh_pd() { let a = _mm_setr_pd(1., 2.); let b = 3.; let expected = _mm_setr_pd(_mm_cvtsd_f64(a), 3.); @@ -4782,7 +4932,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadl_pd() { + const unsafe fn test_mm_loadl_pd() { let a = _mm_setr_pd(1., 2.); let b = 3.; let expected = _mm_setr_pd(3., get_m128d(a, 1)); @@ -4810,7 +4960,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_store_sd() { + const unsafe fn test_mm_store_sd() { let mut dest = 0.; let a = _mm_setr_pd(1., 2.); _mm_store_sd(&mut dest, a); @@ -4818,7 +4968,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_store_pd() { + const unsafe fn test_mm_store_pd() { let mut mem = Memory { data: [0.0f64; 4] }; let vals = &mut mem.data; let a = _mm_setr_pd(1.0, 2.0); @@ -4830,31 +4980,21 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storeu_pd() { + const unsafe fn test_mm_storeu_pd() { + // guaranteed to be aligned to 16 bytes let mut mem = Memory { data: [0.0f64; 4] }; let vals = &mut mem.data; let a = _mm_setr_pd(1.0, 2.0); - let mut ofs = 0; - let mut p = vals.as_mut_ptr(); - - // Make sure p is **not** aligned to 16-byte boundary - if (p as usize) & 0xf == 0 { - ofs = 1; - p = p.add(1); - } - + // so p is *not* aligned to 16 bytes + let p = vals.as_mut_ptr().offset(1); _mm_storeu_pd(p, *black_box(&a)); - if ofs > 0 { - assert_eq!(vals[ofs - 1], 0.0); - } - assert_eq!(vals[ofs + 0], 1.0); - assert_eq!(vals[ofs + 1], 2.0); + assert_eq!(*vals, [0.0, 1.0, 2.0, 0.0]); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storeu_si16() { + const unsafe fn test_mm_storeu_si16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8); let mut r = _mm_setr_epi16(9, 10, 11, 12, 13, 14, 15, 16); _mm_storeu_si16(ptr::addr_of_mut!(r).cast(), a); @@ -4863,7 +5003,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storeu_si32() { + const unsafe fn test_mm_storeu_si32() { let a = _mm_setr_epi32(1, 2, 3, 4); let mut r = _mm_setr_epi32(5, 6, 7, 8); _mm_storeu_si32(ptr::addr_of_mut!(r).cast(), a); @@ -4872,7 +5012,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storeu_si64() { + const unsafe fn test_mm_storeu_si64() { let a = _mm_setr_epi64x(1, 2); let mut r = _mm_setr_epi64x(3, 4); _mm_storeu_si64(ptr::addr_of_mut!(r).cast(), a); @@ -4881,7 +5021,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_store1_pd() { + const unsafe fn test_mm_store1_pd() { let mut mem = Memory { data: [0.0f64; 4] }; let vals = &mut mem.data; let a = _mm_setr_pd(1.0, 2.0); @@ -4893,7 +5033,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_store_pd1() { + const unsafe fn test_mm_store_pd1() { let mut mem = Memory { data: [0.0f64; 4] }; let vals = &mut mem.data; let a = _mm_setr_pd(1.0, 2.0); @@ -4905,7 +5045,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storer_pd() { + const unsafe fn test_mm_storer_pd() { let mut mem = Memory { data: [0.0f64; 4] }; let vals = &mut mem.data; let a = _mm_setr_pd(1.0, 2.0); @@ -4917,7 +5057,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storeh_pd() { + const unsafe fn test_mm_storeh_pd() { let mut dest = 0.; let a = _mm_setr_pd(1., 2.); _mm_storeh_pd(&mut dest, a); @@ -4925,7 +5065,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_storel_pd() { + const unsafe fn test_mm_storel_pd() { let mut dest = 0.; let a = _mm_setr_pd(1., 2.); _mm_storel_pd(&mut dest, a); @@ -4933,7 +5073,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadr_pd() { + const unsafe fn test_mm_loadr_pd() { let mut mem = Memory { data: [1.0f64, 2.0, 3.0, 4.0], }; @@ -4945,48 +5085,44 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadu_pd() { + const unsafe fn test_mm_loadu_pd() { + // guaranteed to be aligned to 16 bytes let mut mem = Memory { data: [1.0f64, 2.0, 3.0, 4.0], }; let vals = &mut mem.data; - let mut d = vals.as_ptr(); - // make sure d is not aligned to 16-byte boundary - let mut offset = 0; - if (d as usize) & 0xf == 0 { - offset = 1; - d = d.add(offset); - } + // so this will *not* be aligned to 16 bytes + let d = vals.as_ptr().offset(1); let r = _mm_loadu_pd(d); - let e = _mm_add_pd(_mm_setr_pd(1.0, 2.0), _mm_set1_pd(offset as f64)); + let e = _mm_setr_pd(2.0, 3.0); assert_eq_m128d(r, e); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadu_si16() { + const unsafe fn test_mm_loadu_si16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm_loadu_si16(ptr::addr_of!(a) as *const _); assert_eq_m128i(r, _mm_setr_epi16(1, 0, 0, 0, 0, 0, 0, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadu_si32() { + const unsafe fn test_mm_loadu_si32() { let a = _mm_setr_epi32(1, 2, 3, 4); let r = _mm_loadu_si32(ptr::addr_of!(a) as *const _); assert_eq_m128i(r, _mm_setr_epi32(1, 0, 0, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_loadu_si64() { + const unsafe fn test_mm_loadu_si64() { let a = _mm_setr_epi64x(5, 6); let r = _mm_loadu_si64(ptr::addr_of!(a) as *const _); assert_eq_m128i(r, _mm_setr_epi64x(5, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtpd_ps() { + const unsafe fn test_mm_cvtpd_ps() { let r = _mm_cvtpd_ps(_mm_setr_pd(-1.0, 5.0)); assert_eq_m128(r, _mm_setr_ps(-1.0, 5.0, 0.0, 0.0)); @@ -5001,7 +5137,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtps_pd() { + const unsafe fn test_mm_cvtps_pd() { let r = _mm_cvtps_pd(_mm_setr_ps(-1.0, 2.0, -3.0, 5.0)); assert_eq_m128d(r, _mm_setr_pd(-1.0, 2.0)); @@ -5070,13 +5206,13 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsd_f64() { + const unsafe fn test_mm_cvtsd_f64() { let r = _mm_cvtsd_f64(_mm_setr_pd(-1.1, 2.2)); assert_eq!(r, -1.1); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtss_sd() { + const unsafe fn test_mm_cvtss_sd() { let a = _mm_setr_pd(-1.1, 2.2); let b = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); @@ -5124,57 +5260,57 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_sd() { + const unsafe fn test_mm_set_sd() { let r = _mm_set_sd(-1.0_f64); assert_eq_m128d(r, _mm_setr_pd(-1.0_f64, 0_f64)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set1_pd() { + const unsafe fn test_mm_set1_pd() { let r = _mm_set1_pd(-1.0_f64); assert_eq_m128d(r, _mm_setr_pd(-1.0_f64, -1.0_f64)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_pd1() { + const unsafe fn test_mm_set_pd1() { let r = _mm_set_pd1(-2.0_f64); assert_eq_m128d(r, _mm_setr_pd(-2.0_f64, -2.0_f64)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_set_pd() { + const unsafe fn test_mm_set_pd() { let r = _mm_set_pd(1.0_f64, 5.0_f64); assert_eq_m128d(r, _mm_setr_pd(5.0_f64, 1.0_f64)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_setr_pd() { + const unsafe fn test_mm_setr_pd() { let r = _mm_setr_pd(1.0_f64, -5.0_f64); assert_eq_m128d(r, _mm_setr_pd(1.0_f64, -5.0_f64)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_setzero_pd() { + const unsafe fn test_mm_setzero_pd() { let r = _mm_setzero_pd(); assert_eq_m128d(r, _mm_setr_pd(0_f64, 0_f64)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_load1_pd() { + const unsafe fn test_mm_load1_pd() { let d = -5.0; let r = _mm_load1_pd(&d); assert_eq_m128d(r, _mm_setr_pd(d, d)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_load_pd1() { + const unsafe fn test_mm_load_pd1() { let d = -5.0; let r = _mm_load_pd1(&d); assert_eq_m128d(r, _mm_setr_pd(d, d)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpackhi_pd() { + const unsafe fn test_mm_unpackhi_pd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(3.0, 4.0); let r = _mm_unpackhi_pd(a, b); @@ -5182,7 +5318,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_unpacklo_pd() { + const unsafe fn test_mm_unpacklo_pd() { let a = _mm_setr_pd(1.0, 2.0); let b = _mm_setr_pd(3.0, 4.0); let r = _mm_unpacklo_pd(a, b); @@ -5190,7 +5326,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_shuffle_pd() { + const unsafe fn test_mm_shuffle_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(3., 4.); let expected = _mm_setr_pd(1., 3.); @@ -5199,7 +5335,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_move_sd() { + const unsafe fn test_mm_move_sd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(3., 4.); let expected = _mm_setr_pd(3., 2.); @@ -5208,7 +5344,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_castpd_ps() { + const unsafe fn test_mm_castpd_ps() { let a = _mm_set1_pd(0.); let expected = _mm_set1_ps(0.); let r = _mm_castpd_ps(a); @@ -5216,7 +5352,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_castpd_si128() { + const unsafe fn test_mm_castpd_si128() { let a = _mm_set1_pd(0.); let expected = _mm_set1_epi64x(0); let r = _mm_castpd_si128(a); @@ -5224,7 +5360,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_castps_pd() { + const unsafe fn test_mm_castps_pd() { let a = _mm_set1_ps(0.); let expected = _mm_set1_pd(0.); let r = _mm_castps_pd(a); @@ -5232,7 +5368,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_castps_si128() { + const unsafe fn test_mm_castps_si128() { let a = _mm_set1_ps(0.); let expected = _mm_set1_epi32(0); let r = _mm_castps_si128(a); @@ -5240,7 +5376,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_castsi128_pd() { + const unsafe fn test_mm_castsi128_pd() { let a = _mm_set1_epi64x(0); let expected = _mm_set1_pd(0.); let r = _mm_castsi128_pd(a); @@ -5248,7 +5384,7 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_castsi128_ps() { + const unsafe fn test_mm_castsi128_ps() { let a = _mm_set1_epi32(0); let expected = _mm_set1_ps(0.); let r = _mm_castsi128_ps(a); diff --git a/library/stdarch/crates/core_arch/src/x86_64/sse2.rs b/library/stdarch/crates/core_arch/src/x86_64/sse2.rs index 0894aa9810de..9f350f236840 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/sse2.rs @@ -95,7 +95,8 @@ pub unsafe fn _mm_stream_si64(mem_addr: *mut i64, a: i64) { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi64_si128(a: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi64_si128(a: i64) -> __m128i { _mm_set_epi64x(0, a) } @@ -107,7 +108,8 @@ pub fn _mm_cvtsi64_si128(a: i64) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi64x_si128(a: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi64x_si128(a: i64) -> __m128i { _mm_cvtsi64_si128(a) } @@ -118,7 +120,8 @@ pub fn _mm_cvtsi64x_si128(a: i64) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi128_si64(a: __m128i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi128_si64(a: __m128i) -> i64 { unsafe { simd_extract!(a.as_i64x2(), 0) } } @@ -129,7 +132,8 @@ pub fn _mm_cvtsi128_si64(a: __m128i) -> i64 { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(movq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi128_si64x(a: __m128i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi128_si64x(a: __m128i) -> i64 { _mm_cvtsi128_si64(a) } @@ -141,7 +145,8 @@ pub fn _mm_cvtsi128_si64x(a: __m128i) -> i64 { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtsi2sd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi64_sd(a: __m128d, b: i64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi64_sd(a: __m128d, b: i64) -> __m128d { unsafe { simd_insert!(a, 0, b as f64) } } @@ -153,13 +158,15 @@ pub fn _mm_cvtsi64_sd(a: __m128d, b: i64) -> __m128d { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(cvtsi2sd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtsi64x_sd(a: __m128d, b: i64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi64x_sd(a: __m128d, b: i64) -> __m128d { _mm_cvtsi64_sd(a, b) } #[cfg(test)] mod tests { use crate::core_arch::arch::x86_64::*; + use crate::core_arch::assert_eq_const as assert_eq; use std::boxed; use std::ptr; use stdarch_test::simd_test; @@ -206,19 +213,19 @@ mod tests { } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsi64_si128() { + const unsafe fn test_mm_cvtsi64_si128() { let r = _mm_cvtsi64_si128(5); assert_eq_m128i(r, _mm_setr_epi64x(5, 0)); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsi128_si64() { + const unsafe fn test_mm_cvtsi128_si64() { let r = _mm_cvtsi128_si64(_mm_setr_epi64x(5, 0)); assert_eq!(r, 5); } #[simd_test(enable = "sse2")] - unsafe fn test_mm_cvtsi64_sd() { + const unsafe fn test_mm_cvtsi64_sd() { let a = _mm_set1_pd(3.5); let r = _mm_cvtsi64_sd(a, 5); assert_eq_m128d(r, _mm_setr_pd(5.0, 3.5)); From 7b71101c08d8c037b158e5e365a5401ff3fcfcdd Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:21:22 +0530 Subject: [PATCH 061/489] Make `sse3` functions const --- .../stdarch/crates/core_arch/src/x86/sse3.rs | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/sse3.rs b/library/stdarch/crates/core_arch/src/x86/sse3.rs index 79be7a7e9b2c..eebca864f43c 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse3.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse3.rs @@ -14,7 +14,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(addsubps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_addsub_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_addsub_ps(a: __m128, b: __m128) -> __m128 { unsafe { let a = a.as_f32x4(); let b = b.as_f32x4(); @@ -32,7 +33,8 @@ pub fn _mm_addsub_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(addsubpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_addsub_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_addsub_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let a = a.as_f64x2(); let b = b.as_f64x2(); @@ -50,7 +52,8 @@ pub fn _mm_addsub_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(haddpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hadd_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hadd_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let even = simd_shuffle!(a, b, [0, 2]); let odd = simd_shuffle!(a, b, [1, 3]); @@ -66,7 +69,8 @@ pub fn _mm_hadd_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(haddps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hadd_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hadd_ps(a: __m128, b: __m128) -> __m128 { unsafe { let even = simd_shuffle!(a, b, [0, 2, 4, 6]); let odd = simd_shuffle!(a, b, [1, 3, 5, 7]); @@ -82,7 +86,8 @@ pub fn _mm_hadd_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(hsubpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hsub_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hsub_pd(a: __m128d, b: __m128d) -> __m128d { unsafe { let even = simd_shuffle!(a, b, [0, 2]); let odd = simd_shuffle!(a, b, [1, 3]); @@ -98,7 +103,8 @@ pub fn _mm_hsub_pd(a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(hsubps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hsub_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hsub_ps(a: __m128, b: __m128) -> __m128 { unsafe { let even = simd_shuffle!(a, b, [0, 2, 4, 6]); let odd = simd_shuffle!(a, b, [1, 3, 5, 7]); @@ -127,7 +133,8 @@ pub unsafe fn _mm_lddqu_si128(mem_addr: *const __m128i) -> __m128i { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(movddup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movedup_pd(a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movedup_pd(a: __m128d) -> __m128d { unsafe { simd_shuffle!(a, a, [0, 0]) } } @@ -139,7 +146,8 @@ pub fn _mm_movedup_pd(a: __m128d) -> __m128d { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(movddup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> __m128d { _mm_load1_pd(mem_addr) } @@ -151,7 +159,8 @@ pub unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> __m128d { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(movshdup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_movehdup_ps(a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movehdup_ps(a: __m128) -> __m128 { unsafe { simd_shuffle!(a, a, [1, 1, 3, 3]) } } @@ -163,7 +172,8 @@ pub fn _mm_movehdup_ps(a: __m128) -> __m128 { #[target_feature(enable = "sse3")] #[cfg_attr(test, assert_instr(movsldup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_moveldup_ps(a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_moveldup_ps(a: __m128) -> __m128 { unsafe { simd_shuffle!(a, a, [0, 0, 2, 2]) } } @@ -175,12 +185,13 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "sse3")] - unsafe fn test_mm_addsub_ps() { + const unsafe fn test_mm_addsub_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_addsub_ps(a, b); @@ -188,7 +199,7 @@ mod tests { } #[simd_test(enable = "sse3")] - unsafe fn test_mm_addsub_pd() { + const unsafe fn test_mm_addsub_pd() { let a = _mm_setr_pd(-1.0, 5.0); let b = _mm_setr_pd(-100.0, 20.0); let r = _mm_addsub_pd(a, b); @@ -196,7 +207,7 @@ mod tests { } #[simd_test(enable = "sse3")] - unsafe fn test_mm_hadd_pd() { + const unsafe fn test_mm_hadd_pd() { let a = _mm_setr_pd(-1.0, 5.0); let b = _mm_setr_pd(-100.0, 20.0); let r = _mm_hadd_pd(a, b); @@ -204,7 +215,7 @@ mod tests { } #[simd_test(enable = "sse3")] - unsafe fn test_mm_hadd_ps() { + const unsafe fn test_mm_hadd_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_hadd_ps(a, b); @@ -212,7 +223,7 @@ mod tests { } #[simd_test(enable = "sse3")] - unsafe fn test_mm_hsub_pd() { + const unsafe fn test_mm_hsub_pd() { let a = _mm_setr_pd(-1.0, 5.0); let b = _mm_setr_pd(-100.0, 20.0); let r = _mm_hsub_pd(a, b); @@ -220,7 +231,7 @@ mod tests { } #[simd_test(enable = "sse3")] - unsafe fn test_mm_hsub_ps() { + const unsafe fn test_mm_hsub_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let b = _mm_setr_ps(-100.0, 20.0, 0.0, -5.0); let r = _mm_hsub_ps(a, b); @@ -241,28 +252,28 @@ mod tests { } #[simd_test(enable = "sse3")] - unsafe fn test_mm_movedup_pd() { + const unsafe fn test_mm_movedup_pd() { let a = _mm_setr_pd(-1.0, 5.0); let r = _mm_movedup_pd(a); assert_eq_m128d(r, _mm_setr_pd(-1.0, -1.0)); } #[simd_test(enable = "sse3")] - unsafe fn test_mm_movehdup_ps() { + const unsafe fn test_mm_movehdup_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let r = _mm_movehdup_ps(a); assert_eq_m128(r, _mm_setr_ps(5.0, 5.0, -10.0, -10.0)); } #[simd_test(enable = "sse3")] - unsafe fn test_mm_moveldup_ps() { + const unsafe fn test_mm_moveldup_ps() { let a = _mm_setr_ps(-1.0, 5.0, 0.0, -10.0); let r = _mm_moveldup_ps(a); assert_eq_m128(r, _mm_setr_ps(-1.0, -1.0, 0.0, 0.0)); } #[simd_test(enable = "sse3")] - unsafe fn test_mm_loaddup_pd() { + const unsafe fn test_mm_loaddup_pd() { let d = -5.0; let r = _mm_loaddup_pd(&d); assert_eq_m128d(r, _mm_setr_pd(d, d)); From cfe6c04f732e0175af232b3751afcaa9254404fa Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:21:33 +0530 Subject: [PATCH 062/489] Make `ssse3` functions const --- .../stdarch/crates/core_arch/src/x86/ssse3.rs | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/ssse3.rs b/library/stdarch/crates/core_arch/src/x86/ssse3.rs index ac067bd4b5a7..c44da6eb97e4 100644 --- a/library/stdarch/crates/core_arch/src/x86/ssse3.rs +++ b/library/stdarch/crates/core_arch/src/x86/ssse3.rs @@ -16,7 +16,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(pabsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_abs_epi8(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_abs_epi8(a: __m128i) -> __m128i { unsafe { let a = a.as_i8x16(); let zero = i8x16::ZERO; @@ -34,7 +35,8 @@ pub fn _mm_abs_epi8(a: __m128i) -> __m128i { #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(pabsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_abs_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_abs_epi16(a: __m128i) -> __m128i { unsafe { let a = a.as_i16x8(); let zero = i16x8::ZERO; @@ -52,7 +54,8 @@ pub fn _mm_abs_epi16(a: __m128i) -> __m128i { #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(pabsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_abs_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_abs_epi32(a: __m128i) -> __m128i { unsafe { let a = a.as_i32x4(); let zero = i32x4::ZERO; @@ -104,7 +107,8 @@ pub fn _mm_shuffle_epi8(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(palignr, IMM8 = 15))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_alignr_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_alignr_epi8(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); // If palignr is shifting the pair of vectors more than the size of two // lanes, emit zero. @@ -163,7 +167,8 @@ pub fn _mm_alignr_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(phaddw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hadd_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hadd_epi16(a: __m128i, b: __m128i) -> __m128i { let a = a.as_i16x8(); let b = b.as_i16x8(); unsafe { @@ -194,7 +199,8 @@ pub fn _mm_hadds_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(phaddd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hadd_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hadd_epi32(a: __m128i, b: __m128i) -> __m128i { let a = a.as_i32x4(); let b = b.as_i32x4(); unsafe { @@ -212,7 +218,8 @@ pub fn _mm_hadd_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(phsubw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hsub_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hsub_epi16(a: __m128i, b: __m128i) -> __m128i { let a = a.as_i16x8(); let b = b.as_i16x8(); unsafe { @@ -244,7 +251,8 @@ pub fn _mm_hsubs_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "ssse3")] #[cfg_attr(test, assert_instr(phsubd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_hsub_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_hsub_epi32(a: __m128i, b: __m128i) -> __m128i { let a = a.as_i32x4(); let b = b.as_i32x4(); unsafe { @@ -353,24 +361,25 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "ssse3")] - unsafe fn test_mm_abs_epi8() { + const unsafe fn test_mm_abs_epi8() { let r = _mm_abs_epi8(_mm_set1_epi8(-5)); assert_eq_m128i(r, _mm_set1_epi8(5)); } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_abs_epi16() { + const unsafe fn test_mm_abs_epi16() { let r = _mm_abs_epi16(_mm_set1_epi16(-5)); assert_eq_m128i(r, _mm_set1_epi16(5)); } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_abs_epi32() { + const unsafe fn test_mm_abs_epi32() { let r = _mm_abs_epi32(_mm_set1_epi32(-5)); assert_eq_m128i(r, _mm_set1_epi32(5)); } @@ -400,7 +409,7 @@ mod tests { } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_alignr_epi8() { + const unsafe fn test_mm_alignr_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -440,7 +449,7 @@ mod tests { } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_hadd_epi16() { + const unsafe fn test_mm_hadd_epi16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_setr_epi16(4, 128, 4, 3, 24, 12, 6, 19); let expected = _mm_setr_epi16(3, 7, 11, 15, 132, 7, 36, 25); @@ -490,7 +499,7 @@ mod tests { } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_hadd_epi32() { + const unsafe fn test_mm_hadd_epi32() { let a = _mm_setr_epi32(1, 2, 3, 4); let b = _mm_setr_epi32(4, 128, 4, 3); let expected = _mm_setr_epi32(3, 7, 132, 7); @@ -506,7 +515,7 @@ mod tests { } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_hsub_epi16() { + const unsafe fn test_mm_hsub_epi16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_setr_epi16(4, 128, 4, 3, 24, 12, 6, 19); let expected = _mm_setr_epi16(-1, -1, -1, -1, -124, 1, 12, -13); @@ -556,7 +565,7 @@ mod tests { } #[simd_test(enable = "ssse3")] - unsafe fn test_mm_hsub_epi32() { + const unsafe fn test_mm_hsub_epi32() { let a = _mm_setr_epi32(1, 2, 3, 4); let b = _mm_setr_epi32(4, 128, 4, 3); let expected = _mm_setr_epi32(-1, -1, -124, 1); From d8a0ca2e463654c6d7cb6f79fe3b490824fe16e5 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:21:41 +0530 Subject: [PATCH 063/489] Make `sse4.1` functions const --- .../stdarch/crates/core_arch/src/x86/sse41.rs | 211 +++++++++++------- .../crates/core_arch/src/x86_64/sse41.rs | 11 +- 2 files changed, 134 insertions(+), 88 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/sse41.rs b/library/stdarch/crates/core_arch/src/x86/sse41.rs index 6c16ee760065..a83f8cc747a8 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse41.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse41.rs @@ -59,7 +59,8 @@ pub const _MM_FROUND_NEARBYINT: i32 = _MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTI #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pblendvb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blendv_epi8(a: __m128i, b: __m128i, mask: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blendv_epi8(a: __m128i, b: __m128i, mask: __m128i) -> __m128i { unsafe { let mask: i8x16 = simd_lt(mask.as_i8x16(), i8x16::ZERO); transmute(simd_select(mask, b.as_i8x16(), a.as_i8x16())) @@ -78,7 +79,8 @@ pub fn _mm_blendv_epi8(a: __m128i, b: __m128i, mask: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(pblendw, IMM8 = 0xB1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blend_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blend_epi16(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute::(simd_shuffle!( @@ -106,7 +108,8 @@ pub fn _mm_blend_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(blendvpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blendv_pd(a: __m128d, b: __m128d, mask: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blendv_pd(a: __m128d, b: __m128d, mask: __m128d) -> __m128d { unsafe { let mask: i64x2 = simd_lt(transmute::<_, i64x2>(mask), i64x2::ZERO); transmute(simd_select(mask, b.as_f64x2(), a.as_f64x2())) @@ -121,7 +124,8 @@ pub fn _mm_blendv_pd(a: __m128d, b: __m128d, mask: __m128d) -> __m128d { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(blendvps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blendv_ps(a: __m128, b: __m128, mask: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blendv_ps(a: __m128, b: __m128, mask: __m128) -> __m128 { unsafe { let mask: i32x4 = simd_lt(transmute::<_, i32x4>(mask), i32x4::ZERO); transmute(simd_select(mask, b.as_f32x4(), a.as_f32x4())) @@ -140,7 +144,8 @@ pub fn _mm_blendv_ps(a: __m128, b: __m128, mask: __m128) -> __m128 { #[cfg_attr(test, assert_instr(blendps, IMM2 = 0b10))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blend_pd(a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blend_pd(a: __m128d, b: __m128d) -> __m128d { static_assert_uimm_bits!(IMM2, 2); unsafe { transmute::(simd_shuffle!( @@ -160,7 +165,8 @@ pub fn _mm_blend_pd(a: __m128d, b: __m128d) -> __m128d { #[cfg_attr(test, assert_instr(blendps, IMM4 = 0b0101))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blend_ps(a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blend_ps(a: __m128, b: __m128) -> __m128 { static_assert_uimm_bits!(IMM4, 4); unsafe { transmute::(simd_shuffle!( @@ -207,7 +213,8 @@ pub fn _mm_blend_ps(a: __m128, b: __m128) -> __m128 { #[cfg_attr(test, assert_instr(extractps, IMM8 = 0))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_extract_ps(a: __m128) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_extract_ps(a: __m128) -> i32 { static_assert_uimm_bits!(IMM8, 2); unsafe { simd_extract!(a, IMM8 as u32, f32).to_bits() as i32 } } @@ -223,7 +230,8 @@ pub fn _mm_extract_ps(a: __m128) -> i32 { #[cfg_attr(test, assert_instr(pextrb, IMM8 = 0))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_extract_epi8(a: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_extract_epi8(a: __m128i) -> i32 { static_assert_uimm_bits!(IMM8, 4); unsafe { simd_extract!(a.as_u8x16(), IMM8 as u32, u8) as i32 } } @@ -236,7 +244,8 @@ pub fn _mm_extract_epi8(a: __m128i) -> i32 { #[cfg_attr(test, assert_instr(extractps, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_extract_epi32(a: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_extract_epi32(a: __m128i) -> i32 { static_assert_uimm_bits!(IMM8, 2); unsafe { simd_extract!(a.as_i32x4(), IMM8 as u32, i32) } } @@ -284,7 +293,8 @@ pub fn _mm_insert_ps(a: __m128, b: __m128) -> __m128 { #[cfg_attr(test, assert_instr(pinsrb, IMM8 = 0))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_insert_epi8(a: __m128i, i: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_insert_epi8(a: __m128i, i: i32) -> __m128i { static_assert_uimm_bits!(IMM8, 4); unsafe { transmute(simd_insert!(a.as_i8x16(), IMM8 as u32, i as i8)) } } @@ -298,7 +308,8 @@ pub fn _mm_insert_epi8(a: __m128i, i: i32) -> __m128i { #[cfg_attr(test, assert_instr(pinsrd, IMM8 = 0))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_insert_epi32(a: __m128i, i: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_insert_epi32(a: __m128i, i: i32) -> __m128i { static_assert_uimm_bits!(IMM8, 2); unsafe { transmute(simd_insert!(a.as_i32x4(), IMM8 as u32, i)) } } @@ -311,7 +322,8 @@ pub fn _mm_insert_epi32(a: __m128i, i: i32) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmaxsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_max_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_i8x16(), b.as_i8x16()).as_m128i() } } @@ -323,7 +335,8 @@ pub fn _mm_max_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmaxuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_max_epu16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epu16(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_u16x8(), b.as_u16x8()).as_m128i() } } @@ -335,7 +348,8 @@ pub fn _mm_max_epu16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmaxsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_max_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_i32x4(), b.as_i32x4()).as_m128i() } } @@ -347,7 +361,8 @@ pub fn _mm_max_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmaxud))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_max_epu32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epu32(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_u32x4(), b.as_u32x4()).as_m128i() } } @@ -359,7 +374,8 @@ pub fn _mm_max_epu32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pminsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_min_epi8(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epi8(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_i8x16(), b.as_i8x16()).as_m128i() } } @@ -371,7 +387,8 @@ pub fn _mm_min_epi8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pminuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_min_epu16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epu16(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_u16x8(), b.as_u16x8()).as_m128i() } } @@ -383,7 +400,8 @@ pub fn _mm_min_epu16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pminsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_min_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_i32x4(), b.as_i32x4()).as_m128i() } } @@ -395,7 +413,8 @@ pub fn _mm_min_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pminud))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_min_epu32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epu32(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_u32x4(), b.as_u32x4()).as_m128i() } } @@ -418,7 +437,8 @@ pub fn _mm_packus_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pcmpeqq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpeq_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_eq::<_, i64x2>(a.as_i64x2(), b.as_i64x2())) } } @@ -429,7 +449,8 @@ pub fn _mm_cmpeq_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovsxbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi8_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi8_epi16(a: __m128i) -> __m128i { unsafe { let a = a.as_i8x16(); let a: i8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -444,7 +465,8 @@ pub fn _mm_cvtepi8_epi16(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovsxbd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi8_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi8_epi32(a: __m128i) -> __m128i { unsafe { let a = a.as_i8x16(); let a: i8x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -460,7 +482,8 @@ pub fn _mm_cvtepi8_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovsxbq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi8_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi8_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_i8x16(); let a: i8x2 = simd_shuffle!(a, a, [0, 1]); @@ -475,7 +498,8 @@ pub fn _mm_cvtepi8_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovsxwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi16_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi16_epi32(a: __m128i) -> __m128i { unsafe { let a = a.as_i16x8(); let a: i16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -490,7 +514,8 @@ pub fn _mm_cvtepi16_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovsxwq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi16_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi16_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_i16x8(); let a: i16x2 = simd_shuffle!(a, a, [0, 1]); @@ -505,7 +530,8 @@ pub fn _mm_cvtepi16_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovsxdq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepi32_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi32_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_i32x4(); let a: i32x2 = simd_shuffle!(a, a, [0, 1]); @@ -520,7 +546,8 @@ pub fn _mm_cvtepi32_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovzxbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepu8_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu8_epi16(a: __m128i) -> __m128i { unsafe { let a = a.as_u8x16(); let a: u8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -535,7 +562,8 @@ pub fn _mm_cvtepu8_epi16(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovzxbd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepu8_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu8_epi32(a: __m128i) -> __m128i { unsafe { let a = a.as_u8x16(); let a: u8x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -550,7 +578,8 @@ pub fn _mm_cvtepu8_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovzxbq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepu8_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu8_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_u8x16(); let a: u8x2 = simd_shuffle!(a, a, [0, 1]); @@ -566,7 +595,8 @@ pub fn _mm_cvtepu8_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovzxwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepu16_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu16_epi32(a: __m128i) -> __m128i { unsafe { let a = a.as_u16x8(); let a: u16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -582,7 +612,8 @@ pub fn _mm_cvtepu16_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovzxwq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepu16_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu16_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_u16x8(); let a: u16x2 = simd_shuffle!(a, a, [0, 1]); @@ -598,7 +629,8 @@ pub fn _mm_cvtepu16_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmovzxdq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cvtepu32_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu32_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_u32x4(); let a: u32x2 = simd_shuffle!(a, a, [0, 1]); @@ -655,7 +687,8 @@ pub fn _mm_dp_ps(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(roundpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_floor_pd(a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_floor_pd(a: __m128d) -> __m128d { unsafe { simd_floor(a) } } @@ -668,7 +701,8 @@ pub fn _mm_floor_pd(a: __m128d) -> __m128d { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(roundps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_floor_ps(a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_floor_ps(a: __m128) -> __m128 { unsafe { simd_floor(a) } } @@ -711,7 +745,8 @@ pub fn _mm_floor_ss(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(roundpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_ceil_pd(a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_ceil_pd(a: __m128d) -> __m128d { unsafe { simd_ceil(a) } } @@ -724,7 +759,8 @@ pub fn _mm_ceil_pd(a: __m128d) -> __m128d { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(roundps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_ceil_ps(a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_ceil_ps(a: __m128) -> __m128 { unsafe { simd_ceil(a) } } @@ -887,7 +923,8 @@ pub fn _mm_minpos_epu16(a: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmuldq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mul_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { let a = simd_cast::<_, i64x2>(simd_cast::<_, i32x2>(a.as_i64x2())); let b = simd_cast::<_, i64x2>(simd_cast::<_, i32x2>(b.as_i64x2())); @@ -907,7 +944,8 @@ pub fn _mm_mul_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(pmulld))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_mullo_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mullo_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_mul(a.as_i32x4(), b.as_i32x4())) } } @@ -973,7 +1011,8 @@ pub fn _mm_mpsadbw_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(ptest))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_testz_si128(a: __m128i, mask: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testz_si128(a: __m128i, mask: __m128i) -> i32 { unsafe { let r = simd_reduce_or(simd_and(a.as_i64x2(), mask.as_i64x2())); (0i64 == r) as i32 @@ -999,7 +1038,8 @@ pub fn _mm_testz_si128(a: __m128i, mask: __m128i) -> i32 { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(ptest))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_testc_si128(a: __m128i, mask: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testc_si128(a: __m128i, mask: __m128i) -> i32 { unsafe { let r = simd_reduce_or(simd_and( simd_xor(a.as_i64x2(), i64x2::splat(!0)), @@ -1051,7 +1091,8 @@ pub fn _mm_testnzc_si128(a: __m128i, mask: __m128i) -> i32 { #[target_feature(enable = "sse4.1")] #[cfg_attr(test, assert_instr(ptest))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_test_all_zeros(a: __m128i, mask: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_test_all_zeros(a: __m128i, mask: __m128i) -> i32 { _mm_testz_si128(a, mask) } @@ -1073,7 +1114,8 @@ pub fn _mm_test_all_zeros(a: __m128i, mask: __m128i) -> i32 { #[cfg_attr(test, assert_instr(pcmpeqd))] #[cfg_attr(test, assert_instr(ptest))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_test_all_ones(a: __m128i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_test_all_ones(a: __m128i) -> i32 { _mm_testc_si128(a, _mm_cmpeq_epi32(a, a)) } @@ -1148,12 +1190,13 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::core_arch::x86::*; use std::mem; use stdarch_test::simd_test; #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_blendv_epi8() { + const unsafe fn test_mm_blendv_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -1176,7 +1219,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_blendv_pd() { + const unsafe fn test_mm_blendv_pd() { let a = _mm_set1_pd(0.0); let b = _mm_set1_pd(1.0); let mask = transmute(_mm_setr_epi64x(0, -1)); @@ -1186,7 +1229,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_blendv_ps() { + const unsafe fn test_mm_blendv_ps() { let a = _mm_set1_ps(0.0); let b = _mm_set1_ps(1.0); let mask = transmute(_mm_setr_epi32(0, -1, 0, -1)); @@ -1196,7 +1239,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_blend_pd() { + const unsafe fn test_mm_blend_pd() { let a = _mm_set1_pd(0.0); let b = _mm_set1_pd(1.0); let r = _mm_blend_pd::<0b10>(a, b); @@ -1205,7 +1248,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_blend_ps() { + const unsafe fn test_mm_blend_ps() { let a = _mm_set1_ps(0.0); let b = _mm_set1_ps(1.0); let r = _mm_blend_ps::<0b1010>(a, b); @@ -1214,7 +1257,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_blend_epi16() { + const unsafe fn test_mm_blend_epi16() { let a = _mm_set1_epi16(0); let b = _mm_set1_epi16(1); let r = _mm_blend_epi16::<0b1010_1100>(a, b); @@ -1223,7 +1266,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_extract_ps() { + const unsafe fn test_mm_extract_ps() { let a = _mm_setr_ps(0.0, 1.0, 2.0, 3.0); let r: f32 = f32::from_bits(_mm_extract_ps::<1>(a) as u32); assert_eq!(r, 1.0); @@ -1232,7 +1275,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_extract_epi8() { + const unsafe fn test_mm_extract_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( -1, 1, 2, 3, 4, 5, 6, 7, @@ -1245,7 +1288,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_extract_epi32() { + const unsafe fn test_mm_extract_epi32() { let a = _mm_setr_epi32(0, 1, 2, 3); let r = _mm_extract_epi32::<1>(a); assert_eq!(r, 1); @@ -1270,7 +1313,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_insert_epi8() { + const unsafe fn test_mm_insert_epi8() { let a = _mm_set1_epi8(0); let e = _mm_setr_epi8(0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); let r = _mm_insert_epi8::<1>(a, 32); @@ -1281,7 +1324,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_insert_epi32() { + const unsafe fn test_mm_insert_epi32() { let a = _mm_set1_epi32(0); let e = _mm_setr_epi32(0, 32, 0, 0); let r = _mm_insert_epi32::<1>(a, 32); @@ -1292,7 +1335,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_max_epi8() { + const unsafe fn test_mm_max_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 1, 4, 5, 8, 9, 12, 13, 16, @@ -1313,7 +1356,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_max_epu16() { + const unsafe fn test_mm_max_epu16() { let a = _mm_setr_epi16(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm_setr_epi16(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm_max_epu16(a, b); @@ -1322,7 +1365,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_max_epi32() { + const unsafe fn test_mm_max_epi32() { let a = _mm_setr_epi32(1, 4, 5, 8); let b = _mm_setr_epi32(2, 3, 6, 7); let r = _mm_max_epi32(a, b); @@ -1331,7 +1374,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_max_epu32() { + const unsafe fn test_mm_max_epu32() { let a = _mm_setr_epi32(1, 4, 5, 8); let b = _mm_setr_epi32(2, 3, 6, 7); let r = _mm_max_epu32(a, b); @@ -1340,7 +1383,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_min_epi8() { + const unsafe fn test_mm_min_epi8() { #[rustfmt::skip] let a = _mm_setr_epi8( 1, 4, 5, 8, 9, 12, 13, 16, @@ -1379,7 +1422,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_min_epu16() { + const unsafe fn test_mm_min_epu16() { let a = _mm_setr_epi16(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm_setr_epi16(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm_min_epu16(a, b); @@ -1388,7 +1431,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_min_epi32() { + const unsafe fn test_mm_min_epi32() { let a = _mm_setr_epi32(1, 4, 5, 8); let b = _mm_setr_epi32(2, 3, 6, 7); let r = _mm_min_epi32(a, b); @@ -1403,7 +1446,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_min_epu32() { + const unsafe fn test_mm_min_epu32() { let a = _mm_setr_epi32(1, 4, 5, 8); let b = _mm_setr_epi32(2, 3, 6, 7); let r = _mm_min_epu32(a, b); @@ -1421,7 +1464,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cmpeq_epi64() { + const unsafe fn test_mm_cmpeq_epi64() { let a = _mm_setr_epi64x(0, 1); let b = _mm_setr_epi64x(0, 0); let r = _mm_cmpeq_epi64(a, b); @@ -1430,7 +1473,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepi8_epi16() { + const unsafe fn test_mm_cvtepi8_epi16() { let a = _mm_set1_epi8(10); let r = _mm_cvtepi8_epi16(a); let e = _mm_set1_epi16(10); @@ -1442,7 +1485,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepi8_epi32() { + const unsafe fn test_mm_cvtepi8_epi32() { let a = _mm_set1_epi8(10); let r = _mm_cvtepi8_epi32(a); let e = _mm_set1_epi32(10); @@ -1454,7 +1497,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepi8_epi64() { + const unsafe fn test_mm_cvtepi8_epi64() { let a = _mm_set1_epi8(10); let r = _mm_cvtepi8_epi64(a); let e = _mm_set1_epi64x(10); @@ -1466,7 +1509,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepi16_epi32() { + const unsafe fn test_mm_cvtepi16_epi32() { let a = _mm_set1_epi16(10); let r = _mm_cvtepi16_epi32(a); let e = _mm_set1_epi32(10); @@ -1478,7 +1521,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepi16_epi64() { + const unsafe fn test_mm_cvtepi16_epi64() { let a = _mm_set1_epi16(10); let r = _mm_cvtepi16_epi64(a); let e = _mm_set1_epi64x(10); @@ -1490,7 +1533,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepi32_epi64() { + const unsafe fn test_mm_cvtepi32_epi64() { let a = _mm_set1_epi32(10); let r = _mm_cvtepi32_epi64(a); let e = _mm_set1_epi64x(10); @@ -1502,7 +1545,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepu8_epi16() { + const unsafe fn test_mm_cvtepu8_epi16() { let a = _mm_set1_epi8(10); let r = _mm_cvtepu8_epi16(a); let e = _mm_set1_epi16(10); @@ -1510,7 +1553,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepu8_epi32() { + const unsafe fn test_mm_cvtepu8_epi32() { let a = _mm_set1_epi8(10); let r = _mm_cvtepu8_epi32(a); let e = _mm_set1_epi32(10); @@ -1518,7 +1561,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepu8_epi64() { + const unsafe fn test_mm_cvtepu8_epi64() { let a = _mm_set1_epi8(10); let r = _mm_cvtepu8_epi64(a); let e = _mm_set1_epi64x(10); @@ -1526,7 +1569,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepu16_epi32() { + const unsafe fn test_mm_cvtepu16_epi32() { let a = _mm_set1_epi16(10); let r = _mm_cvtepu16_epi32(a); let e = _mm_set1_epi32(10); @@ -1534,7 +1577,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepu16_epi64() { + const unsafe fn test_mm_cvtepu16_epi64() { let a = _mm_set1_epi16(10); let r = _mm_cvtepu16_epi64(a); let e = _mm_set1_epi64x(10); @@ -1542,7 +1585,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_cvtepu32_epi64() { + const unsafe fn test_mm_cvtepu32_epi64() { let a = _mm_set1_epi32(10); let r = _mm_cvtepu32_epi64(a); let e = _mm_set1_epi64x(10); @@ -1566,7 +1609,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_floor_pd() { + const unsafe fn test_mm_floor_pd() { let a = _mm_setr_pd(2.5, 4.5); let r = _mm_floor_pd(a); let e = _mm_setr_pd(2.0, 4.0); @@ -1574,7 +1617,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_floor_ps() { + const unsafe fn test_mm_floor_ps() { let a = _mm_setr_ps(2.5, 4.5, 8.5, 16.5); let r = _mm_floor_ps(a); let e = _mm_setr_ps(2.0, 4.0, 8.0, 16.0); @@ -1600,7 +1643,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_ceil_pd() { + const unsafe fn test_mm_ceil_pd() { let a = _mm_setr_pd(1.5, 3.5); let r = _mm_ceil_pd(a); let e = _mm_setr_pd(2.0, 4.0); @@ -1608,7 +1651,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_ceil_ps() { + const unsafe fn test_mm_ceil_ps() { let a = _mm_setr_ps(1.5, 3.5, 7.5, 15.5); let r = _mm_ceil_ps(a); let e = _mm_setr_ps(2.0, 4.0, 8.0, 16.0); @@ -1729,7 +1772,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_mul_epi32() { + const unsafe fn test_mm_mul_epi32() { { let a = _mm_setr_epi32(1, 1, 1, 1); let b = _mm_setr_epi32(1, 2, 3, 4); @@ -1750,7 +1793,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_mullo_epi32() { + const unsafe fn test_mm_mullo_epi32() { { let a = _mm_setr_epi32(1, 1, 1, 1); let b = _mm_setr_epi32(1, 2, 3, 4); @@ -1808,7 +1851,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_testz_si128() { + const unsafe fn test_mm_testz_si128() { let a = _mm_set1_epi8(1); let mask = _mm_set1_epi8(0); let r = _mm_testz_si128(a, mask); @@ -1824,7 +1867,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_testc_si128() { + const unsafe fn test_mm_testc_si128() { let a = _mm_set1_epi8(-1); let mask = _mm_set1_epi8(0); let r = _mm_testc_si128(a, mask); @@ -1860,7 +1903,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_test_all_zeros() { + const unsafe fn test_mm_test_all_zeros() { let a = _mm_set1_epi8(1); let mask = _mm_set1_epi8(0); let r = _mm_test_all_zeros(a, mask); @@ -1876,7 +1919,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_test_all_ones() { + const unsafe fn test_mm_test_all_ones() { let a = _mm_set1_epi8(-1); let r = _mm_test_all_ones(a); assert_eq!(r, 1); diff --git a/library/stdarch/crates/core_arch/src/x86_64/sse41.rs b/library/stdarch/crates/core_arch/src/x86_64/sse41.rs index 4b7d25f2144b..3b1c88ad8cb2 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/sse41.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/sse41.rs @@ -13,7 +13,8 @@ use stdarch_test::assert_instr; #[cfg_attr(test, assert_instr(pextrq, IMM1 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_extract_epi64(a: __m128i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_extract_epi64(a: __m128i) -> i64 { static_assert_uimm_bits!(IMM1, 1); unsafe { simd_extract!(a.as_i64x2(), IMM1 as u32) } } @@ -27,7 +28,8 @@ pub fn _mm_extract_epi64(a: __m128i) -> i64 { #[cfg_attr(test, assert_instr(pinsrq, IMM1 = 0))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_insert_epi64(a: __m128i, i: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_insert_epi64(a: __m128i, i: i64) -> __m128i { static_assert_uimm_bits!(IMM1, 1); unsafe { transmute(simd_insert!(a.as_i64x2(), IMM1 as u32, i)) } } @@ -35,10 +37,11 @@ pub fn _mm_insert_epi64(a: __m128i, i: i64) -> __m128i { #[cfg(test)] mod tests { use crate::core_arch::arch::x86_64::*; + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_extract_epi64() { + const unsafe fn test_mm_extract_epi64() { let a = _mm_setr_epi64x(0, 1); let r = _mm_extract_epi64::<1>(a); assert_eq!(r, 1); @@ -47,7 +50,7 @@ mod tests { } #[simd_test(enable = "sse4.1")] - unsafe fn test_mm_insert_epi64() { + const unsafe fn test_mm_insert_epi64() { let a = _mm_set1_epi64x(0); let e = _mm_setr_epi64x(0, 32); let r = _mm_insert_epi64::<1>(a, 32); From 96b8e391abd6fd6cc3a20c9c6f4867735c487365 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:21:58 +0530 Subject: [PATCH 064/489] Make `sse4.2` functions const --- library/stdarch/crates/core_arch/src/x86/sse42.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/sse42.rs b/library/stdarch/crates/core_arch/src/x86/sse42.rs index 83c51f2b70eb..4d3c481fe124 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse42.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse42.rs @@ -563,7 +563,8 @@ pub fn _mm_crc32_u32(crc: u32, v: u32) -> u32 { #[target_feature(enable = "sse4.2")] #[cfg_attr(test, assert_instr(pcmpgtq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_cmpgt_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_gt::<_, i64x2>(a.as_i64x2(), b.as_i64x2())) } } @@ -609,6 +610,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; @@ -789,7 +791,7 @@ mod tests { } #[simd_test(enable = "sse4.2")] - unsafe fn test_mm_cmpgt_epi64() { + const unsafe fn test_mm_cmpgt_epi64() { let a = _mm_setr_epi64x(0, 0x2a); let b = _mm_set1_epi64x(0x00); let i = _mm_cmpgt_epi64(a, b); From 0864ad202c54a662460ad11bad86c0797a07d0ce Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:11:22 +0530 Subject: [PATCH 065/489] Make `avx` functions const --- .../stdarch/crates/core_arch/src/x86/avx.rs | 752 +++++++++++------- .../crates/core_arch/src/x86_64/avx.rs | 11 +- 2 files changed, 466 insertions(+), 297 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx.rs b/library/stdarch/crates/core_arch/src/x86/avx.rs index c50c83fcaa8f..acba0a3db7c6 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx.rs @@ -30,7 +30,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vaddpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_add_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { simd_add(a, b) } } @@ -42,7 +43,8 @@ pub fn _mm256_add_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vaddps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_add_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_ps(a: __m256, b: __m256) -> __m256 { unsafe { simd_add(a, b) } } @@ -55,7 +57,8 @@ pub fn _mm256_add_ps(a: __m256, b: __m256) -> __m256 { // See https://github.com/rust-lang/stdarch/issues/71 #[cfg_attr(test, assert_instr(vandp))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_and_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_and_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let a: u64x4 = transmute(a); let b: u64x4 = transmute(b); @@ -71,7 +74,8 @@ pub fn _mm256_and_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_and_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_and_ps(a: __m256, b: __m256) -> __m256 { unsafe { let a: u32x8 = transmute(a); let b: u32x8 = transmute(b); @@ -88,7 +92,8 @@ pub fn _mm256_and_ps(a: __m256, b: __m256) -> __m256 { // See . #[cfg_attr(test, assert_instr(vorp))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_or_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_or_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let a: u64x4 = transmute(a); let b: u64x4 = transmute(b); @@ -104,7 +109,8 @@ pub fn _mm256_or_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_or_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_or_ps(a: __m256, b: __m256) -> __m256 { unsafe { let a: u32x8 = transmute(a); let b: u32x8 = transmute(b); @@ -121,7 +127,8 @@ pub fn _mm256_or_ps(a: __m256, b: __m256) -> __m256 { #[cfg_attr(test, assert_instr(vshufpd, MASK = 3))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_shuffle_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_pd(a: __m256d, b: __m256d) -> __m256d { static_assert_uimm_bits!(MASK, 8); unsafe { simd_shuffle!( @@ -146,7 +153,8 @@ pub fn _mm256_shuffle_pd(a: __m256d, b: __m256d) -> __m256d { #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_shuffle_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_ps(a: __m256, b: __m256) -> __m256 { static_assert_uimm_bits!(MASK, 8); unsafe { simd_shuffle!( @@ -174,7 +182,8 @@ pub fn _mm256_shuffle_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vandnp))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_andnot_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_andnot_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let a: u64x4 = transmute(a); let b: u64x4 = transmute(b); @@ -191,7 +200,8 @@ pub fn _mm256_andnot_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_andnot_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_andnot_ps(a: __m256, b: __m256) -> __m256 { unsafe { let a: u32x8 = transmute(a); let b: u32x8 = transmute(b); @@ -255,7 +265,8 @@ pub fn _mm256_min_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmulpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mul_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mul_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { simd_mul(a, b) } } @@ -267,7 +278,8 @@ pub fn _mm256_mul_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmulps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mul_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mul_ps(a: __m256, b: __m256) -> __m256 { unsafe { simd_mul(a, b) } } @@ -279,7 +291,8 @@ pub fn _mm256_mul_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vaddsubpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_addsub_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_addsub_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let a = a.as_f64x4(); let b = b.as_f64x4(); @@ -297,7 +310,8 @@ pub fn _mm256_addsub_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vaddsubps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_addsub_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_addsub_ps(a: __m256, b: __m256) -> __m256 { unsafe { let a = a.as_f32x8(); let b = b.as_f32x8(); @@ -315,7 +329,8 @@ pub fn _mm256_addsub_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vsubpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sub_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { simd_sub(a, b) } } @@ -327,7 +342,8 @@ pub fn _mm256_sub_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vsubps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sub_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_ps(a: __m256, b: __m256) -> __m256 { unsafe { simd_sub(a, b) } } @@ -339,7 +355,8 @@ pub fn _mm256_sub_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vdivps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_div_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_div_ps(a: __m256, b: __m256) -> __m256 { unsafe { simd_div(a, b) } } @@ -351,7 +368,8 @@ pub fn _mm256_div_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vdivpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_div_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_div_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { simd_div(a, b) } } @@ -386,7 +404,8 @@ pub fn _mm256_round_pd(a: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vroundpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_ceil_pd(a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_ceil_pd(a: __m256d) -> __m256d { unsafe { simd_ceil(a) } } @@ -398,7 +417,8 @@ pub fn _mm256_ceil_pd(a: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vroundpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_floor_pd(a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_floor_pd(a: __m256d) -> __m256d { unsafe { simd_floor(a) } } @@ -433,7 +453,8 @@ pub fn _mm256_round_ps(a: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vroundps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_ceil_ps(a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_ceil_ps(a: __m256) -> __m256 { unsafe { simd_ceil(a) } } @@ -445,7 +466,8 @@ pub fn _mm256_ceil_ps(a: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vroundps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_floor_ps(a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_floor_ps(a: __m256) -> __m256 { unsafe { simd_floor(a) } } @@ -485,7 +507,8 @@ pub fn _mm256_sqrt_pd(a: __m256d) -> __m256d { #[cfg_attr(test, assert_instr(vblendps, IMM4 = 9))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blend_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blend_pd(a: __m256d, b: __m256d) -> __m256d { static_assert_uimm_bits!(IMM4, 4); unsafe { simd_shuffle!( @@ -510,7 +533,8 @@ pub fn _mm256_blend_pd(a: __m256d, b: __m256d) -> __m256d { #[cfg_attr(test, assert_instr(vblendps, IMM8 = 9))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blend_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blend_ps(a: __m256, b: __m256) -> __m256 { static_assert_uimm_bits!(IMM8, 8); unsafe { simd_shuffle!( @@ -538,7 +562,8 @@ pub fn _mm256_blend_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vblendvpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blendv_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blendv_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { let mask: i64x4 = simd_lt(transmute::<_, i64x4>(c), i64x4::ZERO); transmute(simd_select(mask, b.as_f64x4(), a.as_f64x4())) @@ -553,7 +578,8 @@ pub fn _mm256_blendv_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vblendvps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blendv_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blendv_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { let mask: i32x8 = simd_lt(transmute::<_, i32x8>(c), i32x8::ZERO); transmute(simd_select(mask, b.as_f32x8(), a.as_f32x8())) @@ -586,7 +612,8 @@ pub fn _mm256_dp_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vhaddpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hadd_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hadd_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let even = simd_shuffle!(a, b, [0, 4, 2, 6]); let odd = simd_shuffle!(a, b, [1, 5, 3, 7]); @@ -605,7 +632,8 @@ pub fn _mm256_hadd_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vhaddps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hadd_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hadd_ps(a: __m256, b: __m256) -> __m256 { unsafe { let even = simd_shuffle!(a, b, [0, 2, 8, 10, 4, 6, 12, 14]); let odd = simd_shuffle!(a, b, [1, 3, 9, 11, 5, 7, 13, 15]); @@ -623,7 +651,8 @@ pub fn _mm256_hadd_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vhsubpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hsub_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hsub_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let even = simd_shuffle!(a, b, [0, 4, 2, 6]); let odd = simd_shuffle!(a, b, [1, 5, 3, 7]); @@ -642,7 +671,8 @@ pub fn _mm256_hsub_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vhsubps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hsub_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hsub_ps(a: __m256, b: __m256) -> __m256 { unsafe { let even = simd_shuffle!(a, b, [0, 2, 8, 10, 4, 6, 12, 14]); let odd = simd_shuffle!(a, b, [1, 3, 9, 11, 5, 7, 13, 15]); @@ -658,7 +688,8 @@ pub fn _mm256_hsub_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vxorp))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_xor_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_xor_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { let a: u64x4 = transmute(a); let b: u64x4 = transmute(b); @@ -674,7 +705,8 @@ pub fn _mm256_xor_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_xor_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_xor_ps(a: __m256, b: __m256) -> __m256 { unsafe { let a: u32x8 = transmute(a); let b: u32x8 = transmute(b); @@ -881,7 +913,8 @@ pub fn _mm_cmp_ss(a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi32_pd(a: __m128i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi32_pd(a: __m128i) -> __m256d { unsafe { simd_cast(a.as_i32x4()) } } @@ -893,7 +926,8 @@ pub fn _mm256_cvtepi32_pd(a: __m128i) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi32_ps(a: __m256i) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi32_ps(a: __m256i) -> __m256 { unsafe { simd_cast(a.as_i32x8()) } } @@ -905,7 +939,8 @@ pub fn _mm256_cvtepi32_ps(a: __m256i) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vcvtpd2ps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtpd_ps(a: __m256d) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtpd_ps(a: __m256d) -> __m128 { unsafe { simd_cast(a) } } @@ -929,7 +964,8 @@ pub fn _mm256_cvtps_epi32(a: __m256) -> __m256i { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vcvtps2pd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtps_pd(a: __m128) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtps_pd(a: __m128) -> __m256d { unsafe { simd_cast(a) } } @@ -940,7 +976,8 @@ pub fn _mm256_cvtps_pd(a: __m128) -> __m256d { #[target_feature(enable = "avx")] //#[cfg_attr(test, assert_instr(movsd))] FIXME #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtsd_f64(a: __m256d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtsd_f64(a: __m256d) -> f64 { unsafe { simd_extract!(a, 0) } } @@ -989,7 +1026,8 @@ pub fn _mm256_cvttps_epi32(a: __m256) -> __m256i { #[cfg_attr(test, assert_instr(vextractf128, IMM1 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extractf128_ps(a: __m256) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extractf128_ps(a: __m256) -> __m128 { static_assert_uimm_bits!(IMM1, 1); unsafe { simd_shuffle!( @@ -1009,7 +1047,8 @@ pub fn _mm256_extractf128_ps(a: __m256) -> __m128 { #[cfg_attr(test, assert_instr(vextractf128, IMM1 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extractf128_pd(a: __m256d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extractf128_pd(a: __m256d) -> __m128d { static_assert_uimm_bits!(IMM1, 1); unsafe { simd_shuffle!(a, _mm256_undefined_pd(), [[0, 1], [2, 3]][IMM1 as usize]) } } @@ -1022,7 +1061,8 @@ pub fn _mm256_extractf128_pd(a: __m256d) -> __m128d { #[cfg_attr(test, assert_instr(vextractf128, IMM1 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extractf128_si256(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extractf128_si256(a: __m256i) -> __m128i { static_assert_uimm_bits!(IMM1, 1); unsafe { let dst: i64x2 = simd_shuffle!(a.as_i64x4(), i64x4::ZERO, [[0, 1], [2, 3]][IMM1 as usize],); @@ -1038,7 +1078,8 @@ pub fn _mm256_extractf128_si256(a: __m256i) -> __m128i { // This intrinsic has no corresponding instruction. #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extract_epi32(a: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extract_epi32(a: __m256i) -> i32 { static_assert_uimm_bits!(INDEX, 3); unsafe { simd_extract!(a.as_i32x8(), INDEX as u32) } } @@ -1049,7 +1090,8 @@ pub fn _mm256_extract_epi32(a: __m256i) -> i32 { #[inline] #[target_feature(enable = "avx")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtsi256_si32(a: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtsi256_si32(a: __m256i) -> i32 { unsafe { simd_extract!(a.as_i32x8(), 0) } } @@ -1109,7 +1151,8 @@ pub fn _mm_permutevar_ps(a: __m128, b: __m128i) -> __m128 { #[cfg_attr(test, assert_instr(vshufps, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute_ps(a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute_ps(a: __m256) -> __m256 { static_assert_uimm_bits!(IMM8, 8); unsafe { simd_shuffle!( @@ -1138,7 +1181,8 @@ pub fn _mm256_permute_ps(a: __m256) -> __m256 { #[cfg_attr(test, assert_instr(vshufps, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_permute_ps(a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_permute_ps(a: __m128) -> __m128 { static_assert_uimm_bits!(IMM8, 8); unsafe { simd_shuffle!( @@ -1187,7 +1231,8 @@ pub fn _mm_permutevar_pd(a: __m128d, b: __m128i) -> __m128d { #[cfg_attr(test, assert_instr(vshufpd, IMM4 = 0x1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute_pd(a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute_pd(a: __m256d) -> __m256d { static_assert_uimm_bits!(IMM4, 4); unsafe { simd_shuffle!( @@ -1212,7 +1257,8 @@ pub fn _mm256_permute_pd(a: __m256d) -> __m256d { #[cfg_attr(test, assert_instr(vshufpd, IMM2 = 0x1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_permute_pd(a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_permute_pd(a: __m128d) -> __m128d { static_assert_uimm_bits!(IMM2, 2); unsafe { simd_shuffle!( @@ -1232,7 +1278,8 @@ pub fn _mm_permute_pd(a: __m128d) -> __m128d { #[cfg_attr(test, assert_instr(vperm2f128, IMM8 = 0x5))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute2f128_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute2f128_ps(a: __m256, b: __m256) -> __m256 { static_assert_uimm_bits!(IMM8, 8); _mm256_castsi256_ps(_mm256_permute2f128_si256::( _mm256_castps_si256(a), @@ -1249,7 +1296,8 @@ pub fn _mm256_permute2f128_ps(a: __m256, b: __m256) -> __m256 { #[cfg_attr(test, assert_instr(vperm2f128, IMM8 = 0x31))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute2f128_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute2f128_pd(a: __m256d, b: __m256d) -> __m256d { static_assert_uimm_bits!(IMM8, 8); _mm256_castsi256_pd(_mm256_permute2f128_si256::( _mm256_castpd_si256(a), @@ -1266,7 +1314,8 @@ pub fn _mm256_permute2f128_pd(a: __m256d, b: __m256d) -> __m256 #[cfg_attr(test, assert_instr(vperm2f128, IMM8 = 0x31))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute2f128_si256(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute2f128_si256(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); const fn idx(imm8: i32, pos: u32) -> u32 { let part = if pos < 2 { @@ -1308,7 +1357,8 @@ pub fn _mm256_permute2f128_si256(a: __m256i, b: __m256i) -> __m #[cfg_attr(test, assert_instr(vbroadcastss))] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::trivially_copy_pass_by_ref)] -pub fn _mm256_broadcast_ss(f: &f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_ss(f: &f32) -> __m256 { _mm256_set1_ps(*f) } @@ -1321,7 +1371,8 @@ pub fn _mm256_broadcast_ss(f: &f32) -> __m256 { #[cfg_attr(test, assert_instr(vbroadcastss))] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::trivially_copy_pass_by_ref)] -pub fn _mm_broadcast_ss(f: &f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcast_ss(f: &f32) -> __m128 { _mm_set1_ps(*f) } @@ -1334,7 +1385,8 @@ pub fn _mm_broadcast_ss(f: &f32) -> __m128 { #[cfg_attr(test, assert_instr(vbroadcastsd))] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::trivially_copy_pass_by_ref)] -pub fn _mm256_broadcast_sd(f: &f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_sd(f: &f64) -> __m256d { _mm256_set1_pd(*f) } @@ -1346,7 +1398,8 @@ pub fn _mm256_broadcast_sd(f: &f64) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vbroadcastf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcast_ps(a: &__m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_ps(a: &__m128) -> __m256 { unsafe { simd_shuffle!(*a, _mm_setzero_ps(), [0, 1, 2, 3, 0, 1, 2, 3]) } } @@ -1358,7 +1411,8 @@ pub fn _mm256_broadcast_ps(a: &__m128) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vbroadcastf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcast_pd(a: &__m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_pd(a: &__m128d) -> __m256d { unsafe { simd_shuffle!(*a, _mm_setzero_pd(), [0, 1, 0, 1]) } } @@ -1372,7 +1426,8 @@ pub fn _mm256_broadcast_pd(a: &__m128d) -> __m256d { #[cfg_attr(test, assert_instr(vinsertf128, IMM1 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insertf128_ps(a: __m256, b: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insertf128_ps(a: __m256, b: __m128) -> __m256 { static_assert_uimm_bits!(IMM1, 1); unsafe { simd_shuffle!( @@ -1393,7 +1448,8 @@ pub fn _mm256_insertf128_ps(a: __m256, b: __m128) -> __m256 { #[cfg_attr(test, assert_instr(vinsertf128, IMM1 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insertf128_pd(a: __m256d, b: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insertf128_pd(a: __m256d, b: __m128d) -> __m256d { static_assert_uimm_bits!(IMM1, 1); unsafe { simd_shuffle!( @@ -1413,7 +1469,8 @@ pub fn _mm256_insertf128_pd(a: __m256d, b: __m128d) -> __m256d #[cfg_attr(test, assert_instr(vinsertf128, IMM1 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insertf128_si256(a: __m256i, b: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insertf128_si256(a: __m256i, b: __m128i) -> __m256i { static_assert_uimm_bits!(IMM1, 1); unsafe { let dst: i64x4 = simd_shuffle!( @@ -1434,7 +1491,8 @@ pub fn _mm256_insertf128_si256(a: __m256i, b: __m128i) -> __m25 // This intrinsic has no corresponding instruction. #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insert_epi8(a: __m256i, i: i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insert_epi8(a: __m256i, i: i8) -> __m256i { static_assert_uimm_bits!(INDEX, 5); unsafe { transmute(simd_insert!(a.as_i8x32(), INDEX as u32, i)) } } @@ -1448,7 +1506,8 @@ pub fn _mm256_insert_epi8(a: __m256i, i: i8) -> __m256i { // This intrinsic has no corresponding instruction. #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insert_epi16(a: __m256i, i: i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insert_epi16(a: __m256i, i: i16) -> __m256i { static_assert_uimm_bits!(INDEX, 4); unsafe { transmute(simd_insert!(a.as_i16x16(), INDEX as u32, i)) } } @@ -1462,7 +1521,8 @@ pub fn _mm256_insert_epi16(a: __m256i, i: i16) -> __m256i { // This intrinsic has no corresponding instruction. #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insert_epi32(a: __m256i, i: i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insert_epi32(a: __m256i, i: i32) -> __m256i { static_assert_uimm_bits!(INDEX, 3); unsafe { transmute(simd_insert!(a.as_i32x8(), INDEX as u32, i)) } } @@ -1481,7 +1541,8 @@ pub fn _mm256_insert_epi32(a: __m256i, i: i32) -> __m256i { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm256_load_pd(mem_addr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_load_pd(mem_addr: *const f64) -> __m256d { *(mem_addr as *const __m256d) } @@ -1499,7 +1560,8 @@ pub unsafe fn _mm256_load_pd(mem_addr: *const f64) -> __m256d { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm256_store_pd(mem_addr: *mut f64, a: __m256d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_store_pd(mem_addr: *mut f64, a: __m256d) { *(mem_addr as *mut __m256d) = a; } @@ -1517,7 +1579,8 @@ pub unsafe fn _mm256_store_pd(mem_addr: *mut f64, a: __m256d) { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm256_load_ps(mem_addr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_load_ps(mem_addr: *const f32) -> __m256 { *(mem_addr as *const __m256) } @@ -1535,7 +1598,8 @@ pub unsafe fn _mm256_load_ps(mem_addr: *const f32) -> __m256 { )] #[stable(feature = "simd_x86", since = "1.27.0")] #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn _mm256_store_ps(mem_addr: *mut f32, a: __m256) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_store_ps(mem_addr: *mut f32, a: __m256) { *(mem_addr as *mut __m256) = a; } @@ -1548,7 +1612,8 @@ pub unsafe fn _mm256_store_ps(mem_addr: *mut f32, a: __m256) { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_loadu_pd(mem_addr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_pd(mem_addr: *const f64) -> __m256d { let mut dst = _mm256_undefined_pd(); ptr::copy_nonoverlapping( mem_addr as *const u8, @@ -1567,7 +1632,8 @@ pub unsafe fn _mm256_loadu_pd(mem_addr: *const f64) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_storeu_pd(mem_addr: *mut f64, a: __m256d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_pd(mem_addr: *mut f64, a: __m256d) { mem_addr.cast::<__m256d>().write_unaligned(a); } @@ -1580,7 +1646,8 @@ pub unsafe fn _mm256_storeu_pd(mem_addr: *mut f64, a: __m256d) { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_loadu_ps(mem_addr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_ps(mem_addr: *const f32) -> __m256 { let mut dst = _mm256_undefined_ps(); ptr::copy_nonoverlapping( mem_addr as *const u8, @@ -1599,7 +1666,8 @@ pub unsafe fn _mm256_loadu_ps(mem_addr: *const f32) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_storeu_ps(mem_addr: *mut f32, a: __m256) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_ps(mem_addr: *mut f32, a: __m256) { mem_addr.cast::<__m256>().write_unaligned(a); } @@ -1615,7 +1683,8 @@ pub unsafe fn _mm256_storeu_ps(mem_addr: *mut f32, a: __m256) { assert_instr(vmovaps) )] // FIXME vmovdqa expected #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_load_si256(mem_addr: *const __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_load_si256(mem_addr: *const __m256i) -> __m256i { *mem_addr } @@ -1631,7 +1700,8 @@ pub unsafe fn _mm256_load_si256(mem_addr: *const __m256i) -> __m256i { assert_instr(vmovaps) )] // FIXME vmovdqa expected #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_store_si256(mem_addr: *mut __m256i, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_store_si256(mem_addr: *mut __m256i, a: __m256i) { *mem_addr = a; } @@ -1643,7 +1713,8 @@ pub unsafe fn _mm256_store_si256(mem_addr: *mut __m256i, a: __m256i) { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovups))] // FIXME vmovdqu expected #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_loadu_si256(mem_addr: *const __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_si256(mem_addr: *const __m256i) -> __m256i { let mut dst = _mm256_undefined_si256(); ptr::copy_nonoverlapping( mem_addr as *const u8, @@ -1661,7 +1732,8 @@ pub unsafe fn _mm256_loadu_si256(mem_addr: *const __m256i) -> __m256i { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovups))] // FIXME vmovdqu expected #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_storeu_si256(mem_addr: *mut __m256i, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_si256(mem_addr: *mut __m256i, a: __m256i) { mem_addr.write_unaligned(a); } @@ -1674,7 +1746,8 @@ pub unsafe fn _mm256_storeu_si256(mem_addr: *mut __m256i, a: __m256i) { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskload_pd(mem_addr: *const f64, mask: __m256i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskload_pd(mem_addr: *const f64, mask: __m256i) -> __m256d { let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm256_setzero_pd()) } @@ -1687,7 +1760,8 @@ pub unsafe fn _mm256_maskload_pd(mem_addr: *const f64, mask: __m256i) -> __m256d #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskstore_pd(mem_addr: *mut f64, mask: __m256i, a: __m256d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskstore_pd(mem_addr: *mut f64, mask: __m256i, a: __m256d) { let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } @@ -1701,7 +1775,8 @@ pub unsafe fn _mm256_maskstore_pd(mem_addr: *mut f64, mask: __m256i, a: __m256d) #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskload_pd(mem_addr: *const f64, mask: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskload_pd(mem_addr: *const f64, mask: __m128i) -> __m128d { let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm_setzero_pd()) } @@ -1714,7 +1789,8 @@ pub unsafe fn _mm_maskload_pd(mem_addr: *const f64, mask: __m128i) -> __m128d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskstore_pd(mem_addr: *mut f64, mask: __m128i, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskstore_pd(mem_addr: *mut f64, mask: __m128i, a: __m128d) { let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } @@ -1728,7 +1804,8 @@ pub unsafe fn _mm_maskstore_pd(mem_addr: *mut f64, mask: __m128i, a: __m128d) { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskload_ps(mem_addr: *const f32, mask: __m256i) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskload_ps(mem_addr: *const f32, mask: __m256i) -> __m256 { let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm256_setzero_ps()) } @@ -1741,7 +1818,8 @@ pub unsafe fn _mm256_maskload_ps(mem_addr: *const f32, mask: __m256i) -> __m256 #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskstore_ps(mem_addr: *mut f32, mask: __m256i, a: __m256) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskstore_ps(mem_addr: *mut f32, mask: __m256i, a: __m256) { let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } @@ -1755,7 +1833,8 @@ pub unsafe fn _mm256_maskstore_ps(mem_addr: *mut f32, mask: __m256i, a: __m256) #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskload_ps(mem_addr: *const f32, mask: __m128i) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskload_ps(mem_addr: *const f32, mask: __m128i) -> __m128 { let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm_setzero_ps()) } @@ -1768,7 +1847,8 @@ pub unsafe fn _mm_maskload_ps(mem_addr: *const f32, mask: __m128i) -> __m128 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskstore_ps(mem_addr: *mut f32, mask: __m128i, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskstore_ps(mem_addr: *mut f32, mask: __m128i, a: __m128) { let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } @@ -1781,7 +1861,8 @@ pub unsafe fn _mm_maskstore_ps(mem_addr: *mut f32, mask: __m128i, a: __m128) { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovshdup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_movehdup_ps(a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movehdup_ps(a: __m256) -> __m256 { unsafe { simd_shuffle!(a, a, [1, 1, 3, 3, 5, 5, 7, 7]) } } @@ -1793,7 +1874,8 @@ pub fn _mm256_movehdup_ps(a: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovsldup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_moveldup_ps(a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_moveldup_ps(a: __m256) -> __m256 { unsafe { simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6]) } } @@ -1805,7 +1887,8 @@ pub fn _mm256_moveldup_ps(a: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovddup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_movedup_pd(a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movedup_pd(a: __m256d) -> __m256d { unsafe { simd_shuffle!(a, a, [0, 0, 2, 2]) } } @@ -1943,7 +2026,8 @@ pub fn _mm256_rsqrt_ps(a: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vunpckhpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpackhi_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpackhi_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { simd_shuffle!(a, b, [1, 5, 3, 7]) } } @@ -1955,7 +2039,8 @@ pub fn _mm256_unpackhi_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vunpckhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpackhi_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpackhi_ps(a: __m256, b: __m256) -> __m256 { unsafe { simd_shuffle!(a, b, [2, 10, 3, 11, 6, 14, 7, 15]) } } @@ -1967,7 +2052,8 @@ pub fn _mm256_unpackhi_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vunpcklpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpacklo_pd(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpacklo_pd(a: __m256d, b: __m256d) -> __m256d { unsafe { simd_shuffle!(a, b, [0, 4, 2, 6]) } } @@ -1979,7 +2065,8 @@ pub fn _mm256_unpacklo_pd(a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vunpcklps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpacklo_ps(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpacklo_ps(a: __m256, b: __m256) -> __m256 { unsafe { simd_shuffle!(a, b, [0, 8, 1, 9, 4, 12, 5, 13]) } } @@ -1993,7 +2080,8 @@ pub fn _mm256_unpacklo_ps(a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vptest))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_testz_si256(a: __m256i, b: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_testz_si256(a: __m256i, b: __m256i) -> i32 { unsafe { let r = simd_and(a.as_i64x4(), b.as_i64x4()); (0i64 == simd_reduce_or(r)) as i32 @@ -2010,7 +2098,8 @@ pub fn _mm256_testz_si256(a: __m256i, b: __m256i) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vptest))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_testc_si256(a: __m256i, b: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_testc_si256(a: __m256i, b: __m256i) -> i32 { unsafe { let r = simd_and(simd_xor(a.as_i64x4(), i64x4::splat(!0)), b.as_i64x4()); (0i64 == simd_reduce_or(r)) as i32 @@ -2097,7 +2186,8 @@ pub fn _mm256_testnzc_pd(a: __m256d, b: __m256d) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vtestpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_testz_pd(a: __m128d, b: __m128d) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testz_pd(a: __m128d, b: __m128d) -> i32 { unsafe { let r: i64x2 = simd_lt(transmute(_mm_and_pd(a, b)), i64x2::ZERO); (0i64 == simd_reduce_or(r)) as i32 @@ -2117,7 +2207,8 @@ pub fn _mm_testz_pd(a: __m128d, b: __m128d) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vtestpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_testc_pd(a: __m128d, b: __m128d) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testc_pd(a: __m128d, b: __m128d) -> i32 { unsafe { let r: i64x2 = simd_lt(transmute(_mm_andnot_pd(a, b)), i64x2::ZERO); (0i64 == simd_reduce_or(r)) as i32 @@ -2207,7 +2298,8 @@ pub fn _mm256_testnzc_ps(a: __m256, b: __m256) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vtestps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_testz_ps(a: __m128, b: __m128) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testz_ps(a: __m128, b: __m128) -> i32 { unsafe { let r: i32x4 = simd_lt(transmute(_mm_and_ps(a, b)), i32x4::ZERO); (0i32 == simd_reduce_or(r)) as i32 @@ -2227,7 +2319,8 @@ pub fn _mm_testz_ps(a: __m128, b: __m128) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vtestps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_testc_ps(a: __m128, b: __m128) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testc_ps(a: __m128, b: __m128) -> i32 { unsafe { let r: i32x4 = simd_lt(transmute(_mm_andnot_ps(a, b)), i32x4::ZERO); (0i32 == simd_reduce_or(r)) as i32 @@ -2261,12 +2354,13 @@ pub fn _mm_testnzc_ps(a: __m128, b: __m128) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovmskpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_movemask_pd(a: __m256d) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movemask_pd(a: __m256d) -> i32 { // Propagate the highest bit to the rest, because simd_bitmask // requires all-1 or all-0. unsafe { let mask: i64x4 = simd_lt(transmute(a), i64x4::ZERO); - simd_bitmask::(mask).into() + simd_bitmask::(mask) as i32 } } @@ -2279,12 +2373,13 @@ pub fn _mm256_movemask_pd(a: __m256d) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vmovmskps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_movemask_ps(a: __m256) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movemask_ps(a: __m256) -> i32 { // Propagate the highest bit to the rest, because simd_bitmask // requires all-1 or all-0. unsafe { let mask: i32x8 = simd_lt(transmute(a), i32x8::ZERO); - simd_bitmask::(mask).into() + simd_bitmask::(mask) as i32 } } @@ -2295,7 +2390,8 @@ pub fn _mm256_movemask_ps(a: __m256) -> i32 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vxorp))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setzero_pd() -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setzero_pd() -> __m256d { const { unsafe { mem::zeroed() } } } @@ -2306,7 +2402,8 @@ pub fn _mm256_setzero_pd() -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setzero_ps() -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setzero_ps() -> __m256 { const { unsafe { mem::zeroed() } } } @@ -2317,7 +2414,8 @@ pub fn _mm256_setzero_ps() -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vxor))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setzero_si256() -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setzero_si256() -> __m256i { const { unsafe { mem::zeroed() } } } @@ -2330,7 +2428,8 @@ pub fn _mm256_setzero_si256() -> __m256i { // This intrinsic has no corresponding instruction. #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_pd(a: f64, b: f64, c: f64, d: f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_pd(a: f64, b: f64, c: f64, d: f64) -> __m256d { _mm256_setr_pd(d, c, b, a) } @@ -2342,7 +2441,17 @@ pub fn _mm256_set_pd(a: f64, b: f64, c: f64, d: f64) -> __m256d { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_ps(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32, g: f32, h: f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_ps( + a: f32, + b: f32, + c: f32, + d: f32, + e: f32, + f: f32, + g: f32, + h: f32, +) -> __m256 { _mm256_setr_ps(h, g, f, e, d, c, b, a) } @@ -2353,7 +2462,8 @@ pub fn _mm256_set_ps(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32, g: f32, h: #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_epi8( e00: i8, e01: i8, e02: i8, @@ -2403,7 +2513,8 @@ pub fn _mm256_set_epi8( #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_epi16( e00: i16, e01: i16, e02: i16, @@ -2437,7 +2548,8 @@ pub fn _mm256_set_epi16( #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_epi32( e0: i32, e1: i32, e2: i32, @@ -2457,7 +2569,8 @@ pub fn _mm256_set_epi32( #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i { _mm256_setr_epi64x(d, c, b, a) } @@ -2469,7 +2582,8 @@ pub fn _mm256_set_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_pd(a: f64, b: f64, c: f64, d: f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_pd(a: f64, b: f64, c: f64, d: f64) -> __m256d { __m256d([a, b, c, d]) } @@ -2481,7 +2595,17 @@ pub fn _mm256_setr_pd(a: f64, b: f64, c: f64, d: f64) -> __m256d { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_ps(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32, g: f32, h: f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_ps( + a: f32, + b: f32, + c: f32, + d: f32, + e: f32, + f: f32, + g: f32, + h: f32, +) -> __m256 { __m256([a, b, c, d, e, f, g, h]) } @@ -2493,7 +2617,8 @@ pub fn _mm256_setr_ps(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32, g: f32, h: #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_epi8( e00: i8, e01: i8, e02: i8, @@ -2546,7 +2671,8 @@ pub fn _mm256_setr_epi8( #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_epi16( e00: i16, e01: i16, e02: i16, @@ -2583,7 +2709,8 @@ pub fn _mm256_setr_epi16( #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_epi32( e0: i32, e1: i32, e2: i32, @@ -2604,7 +2731,8 @@ pub fn _mm256_setr_epi32( #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i { unsafe { transmute(i64x4::new(a, b, c, d)) } } @@ -2616,7 +2744,8 @@ pub fn _mm256_setr_epi64x(a: i64, b: i64, c: i64, d: i64) -> __m256i { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set1_pd(a: f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_pd(a: f64) -> __m256d { _mm256_setr_pd(a, a, a, a) } @@ -2628,7 +2757,8 @@ pub fn _mm256_set1_pd(a: f64) -> __m256d { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set1_ps(a: f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_ps(a: f32) -> __m256 { _mm256_setr_ps(a, a, a, a, a, a, a, a) } @@ -2640,7 +2770,8 @@ pub fn _mm256_set1_ps(a: f32) -> __m256 { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set1_epi8(a: i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_epi8(a: i8) -> __m256i { #[rustfmt::skip] _mm256_setr_epi8( a, a, a, a, a, a, a, a, @@ -2660,7 +2791,8 @@ pub fn _mm256_set1_epi8(a: i8) -> __m256i { #[cfg_attr(test, assert_instr(vinsertf128))] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set1_epi16(a: i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_epi16(a: i16) -> __m256i { _mm256_setr_epi16(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a) } @@ -2672,7 +2804,8 @@ pub fn _mm256_set1_epi16(a: i16) -> __m256i { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set1_epi32(a: i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_epi32(a: i32) -> __m256i { _mm256_setr_epi32(a, a, a, a, a, a, a, a) } @@ -2686,7 +2819,8 @@ pub fn _mm256_set1_epi32(a: i32) -> __m256i { #[cfg_attr(all(test, target_arch = "x86"), assert_instr(vbroadcastsd))] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set1_epi64x(a: i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_epi64x(a: i64) -> __m256i { _mm256_setr_epi64x(a, a, a, a) } @@ -2698,7 +2832,8 @@ pub fn _mm256_set1_epi64x(a: i64) -> __m256i { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castpd_ps(a: __m256d) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castpd_ps(a: __m256d) -> __m256 { unsafe { transmute(a) } } @@ -2710,7 +2845,8 @@ pub fn _mm256_castpd_ps(a: __m256d) -> __m256 { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castps_pd(a: __m256) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castps_pd(a: __m256) -> __m256d { unsafe { transmute(a) } } @@ -2722,7 +2858,8 @@ pub fn _mm256_castps_pd(a: __m256) -> __m256d { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castps_si256(a: __m256) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castps_si256(a: __m256) -> __m256i { unsafe { transmute(a) } } @@ -2734,7 +2871,8 @@ pub fn _mm256_castps_si256(a: __m256) -> __m256i { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castsi256_ps(a: __m256i) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castsi256_ps(a: __m256i) -> __m256 { unsafe { transmute(a) } } @@ -2746,7 +2884,8 @@ pub fn _mm256_castsi256_ps(a: __m256i) -> __m256 { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castpd_si256(a: __m256d) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castpd_si256(a: __m256d) -> __m256i { unsafe { transmute(a) } } @@ -2758,7 +2897,8 @@ pub fn _mm256_castpd_si256(a: __m256d) -> __m256i { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castsi256_pd(a: __m256i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castsi256_pd(a: __m256i) -> __m256d { unsafe { transmute(a) } } @@ -2770,7 +2910,8 @@ pub fn _mm256_castsi256_pd(a: __m256i) -> __m256d { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castps256_ps128(a: __m256) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castps256_ps128(a: __m256) -> __m128 { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3]) } } @@ -2782,7 +2923,8 @@ pub fn _mm256_castps256_ps128(a: __m256) -> __m128 { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castpd256_pd128(a: __m256d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castpd256_pd128(a: __m256d) -> __m128d { unsafe { simd_shuffle!(a, a, [0, 1]) } } @@ -2794,7 +2936,8 @@ pub fn _mm256_castpd256_pd128(a: __m256d) -> __m128d { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castsi256_si128(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castsi256_si128(a: __m256i) -> __m128i { unsafe { let a = a.as_i64x4(); let dst: i64x2 = simd_shuffle!(a, a, [0, 1]); @@ -2811,7 +2954,8 @@ pub fn _mm256_castsi256_si128(a: __m256i) -> __m128i { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castps128_ps256(a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castps128_ps256(a: __m128) -> __m256 { unsafe { simd_shuffle!(a, _mm_undefined_ps(), [0, 1, 2, 3, 4, 4, 4, 4]) } } @@ -2824,7 +2968,8 @@ pub fn _mm256_castps128_ps256(a: __m128) -> __m256 { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castpd128_pd256(a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castpd128_pd256(a: __m128d) -> __m256d { unsafe { simd_shuffle!(a, _mm_undefined_pd(), [0, 1, 2, 2]) } } @@ -2837,7 +2982,8 @@ pub fn _mm256_castpd128_pd256(a: __m128d) -> __m256d { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_castsi128_si256(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castsi128_si256(a: __m128i) -> __m256i { unsafe { let a = a.as_i64x2(); let undefined = i64x2::ZERO; @@ -2856,7 +3002,8 @@ pub fn _mm256_castsi128_si256(a: __m128i) -> __m256i { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_zextps128_ps256(a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_zextps128_ps256(a: __m128) -> __m256 { unsafe { simd_shuffle!(a, _mm_setzero_ps(), [0, 1, 2, 3, 4, 5, 6, 7]) } } @@ -2870,7 +3017,8 @@ pub fn _mm256_zextps128_ps256(a: __m128) -> __m256 { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_zextsi128_si256(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_zextsi128_si256(a: __m128i) -> __m256i { unsafe { let b = i64x2::ZERO; let dst: i64x4 = simd_shuffle!(a.as_i64x2(), b, [0, 1, 2, 3]); @@ -2889,7 +3037,8 @@ pub fn _mm256_zextsi128_si256(a: __m128i) -> __m256i { // This intrinsic is only used for compilation and does not generate any // instructions, thus it has zero latency. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_zextpd128_pd256(a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_zextpd128_pd256(a: __m128d) -> __m256d { unsafe { simd_shuffle!(a, _mm_setzero_pd(), [0, 1, 2, 3]) } } @@ -2903,7 +3052,8 @@ pub fn _mm256_zextpd128_pd256(a: __m128d) -> __m256d { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_undefined_ps() -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_undefined_ps() -> __m256 { const { unsafe { mem::zeroed() } } } @@ -2917,7 +3067,8 @@ pub fn _mm256_undefined_ps() -> __m256 { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_undefined_pd() -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_undefined_pd() -> __m256d { const { unsafe { mem::zeroed() } } } @@ -2931,7 +3082,8 @@ pub fn _mm256_undefined_pd() -> __m256d { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_undefined_si256() -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_undefined_si256() -> __m256i { const { unsafe { mem::zeroed() } } } @@ -2942,7 +3094,8 @@ pub fn _mm256_undefined_si256() -> __m256i { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_m128(hi: __m128, lo: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_m128(hi: __m128, lo: __m128) -> __m256 { unsafe { simd_shuffle!(lo, hi, [0, 1, 2, 3, 4, 5, 6, 7]) } } @@ -2953,7 +3106,8 @@ pub fn _mm256_set_m128(hi: __m128, lo: __m128) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_m128d(hi: __m128d, lo: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_m128d(hi: __m128d, lo: __m128d) -> __m256d { unsafe { let hi: __m128 = transmute(hi); let lo: __m128 = transmute(lo); @@ -2968,7 +3122,8 @@ pub fn _mm256_set_m128d(hi: __m128d, lo: __m128d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_set_m128i(hi: __m128i, lo: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_m128i(hi: __m128i, lo: __m128i) -> __m256i { unsafe { let hi: __m128 = transmute(hi); let lo: __m128 = transmute(lo); @@ -2983,7 +3138,8 @@ pub fn _mm256_set_m128i(hi: __m128i, lo: __m128i) -> __m256i { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_m128(lo: __m128, hi: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_m128(lo: __m128, hi: __m128) -> __m256 { _mm256_set_m128(hi, lo) } @@ -2994,7 +3150,8 @@ pub fn _mm256_setr_m128(lo: __m128, hi: __m128) -> __m256 { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_m128d(lo: __m128d, hi: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_m128d(lo: __m128d, hi: __m128d) -> __m256d { _mm256_set_m128d(hi, lo) } @@ -3005,7 +3162,8 @@ pub fn _mm256_setr_m128d(lo: __m128d, hi: __m128d) -> __m256d { #[target_feature(enable = "avx")] #[cfg_attr(test, assert_instr(vinsertf128))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_setr_m128i(lo: __m128i, hi: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_m128i(lo: __m128i, hi: __m128i) -> __m256i { _mm256_set_m128i(hi, lo) } @@ -3019,7 +3177,8 @@ pub fn _mm256_setr_m128i(lo: __m128i, hi: __m128i) -> __m256i { #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_loadu2_m128(hiaddr: *const f32, loaddr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu2_m128(hiaddr: *const f32, loaddr: *const f32) -> __m256 { let a = _mm256_castps128_ps256(_mm_loadu_ps(loaddr)); _mm256_insertf128_ps::<1>(a, _mm_loadu_ps(hiaddr)) } @@ -3034,7 +3193,8 @@ pub unsafe fn _mm256_loadu2_m128(hiaddr: *const f32, loaddr: *const f32) -> __m2 #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_loadu2_m128d(hiaddr: *const f64, loaddr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu2_m128d(hiaddr: *const f64, loaddr: *const f64) -> __m256d { let a = _mm256_castpd128_pd256(_mm_loadu_pd(loaddr)); _mm256_insertf128_pd::<1>(a, _mm_loadu_pd(hiaddr)) } @@ -3048,7 +3208,8 @@ pub unsafe fn _mm256_loadu2_m128d(hiaddr: *const f64, loaddr: *const f64) -> __m #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_loadu2_m128i(hiaddr: *const __m128i, loaddr: *const __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu2_m128i(hiaddr: *const __m128i, loaddr: *const __m128i) -> __m256i { let a = _mm256_castsi128_si256(_mm_loadu_si128(loaddr)); _mm256_insertf128_si256::<1>(a, _mm_loadu_si128(hiaddr)) } @@ -3063,7 +3224,8 @@ pub unsafe fn _mm256_loadu2_m128i(hiaddr: *const __m128i, loaddr: *const __m128i #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_storeu2_m128(hiaddr: *mut f32, loaddr: *mut f32, a: __m256) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu2_m128(hiaddr: *mut f32, loaddr: *mut f32, a: __m256) { let lo = _mm256_castps256_ps128(a); _mm_storeu_ps(loaddr, lo); let hi = _mm256_extractf128_ps::<1>(a); @@ -3080,7 +3242,8 @@ pub unsafe fn _mm256_storeu2_m128(hiaddr: *mut f32, loaddr: *mut f32, a: __m256) #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_storeu2_m128d(hiaddr: *mut f64, loaddr: *mut f64, a: __m256d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu2_m128d(hiaddr: *mut f64, loaddr: *mut f64, a: __m256d) { let lo = _mm256_castpd256_pd128(a); _mm_storeu_pd(loaddr, lo); let hi = _mm256_extractf128_pd::<1>(a); @@ -3096,7 +3259,8 @@ pub unsafe fn _mm256_storeu2_m128d(hiaddr: *mut f64, loaddr: *mut f64, a: __m256 #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_storeu2_m128i(hiaddr: *mut __m128i, loaddr: *mut __m128i, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu2_m128i(hiaddr: *mut __m128i, loaddr: *mut __m128i, a: __m256i) { let lo = _mm256_castsi256_si128(a); _mm_storeu_si128(loaddr, lo); let hi = _mm256_extractf128_si256::<1>(a); @@ -3110,7 +3274,8 @@ pub unsafe fn _mm256_storeu2_m128i(hiaddr: *mut __m128i, loaddr: *mut __m128i, a #[target_feature(enable = "avx")] //#[cfg_attr(test, assert_instr(movss))] FIXME #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtss_f32(a: __m256) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtss_f32(a: __m256) -> f32 { unsafe { simd_extract!(a, 0) } } @@ -3191,6 +3356,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::hint::black_box; use crate::ptr; use stdarch_test::simd_test; @@ -3198,7 +3364,7 @@ mod tests { use crate::core_arch::x86::*; #[simd_test(enable = "avx")] - unsafe fn test_mm256_add_pd() { + const unsafe fn test_mm256_add_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_add_pd(a, b); @@ -3207,7 +3373,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_add_ps() { + const unsafe fn test_mm256_add_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_ps(9., 10., 11., 12., 13., 14., 15., 16.); let r = _mm256_add_ps(a, b); @@ -3216,7 +3382,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_and_pd() { + const unsafe fn test_mm256_and_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set1_pd(0.6); let r = _mm256_and_pd(a, b); @@ -3225,7 +3391,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_and_ps() { + const unsafe fn test_mm256_and_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set1_ps(0.6); let r = _mm256_and_ps(a, b); @@ -3234,7 +3400,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_or_pd() { + const unsafe fn test_mm256_or_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set1_pd(0.6); let r = _mm256_or_pd(a, b); @@ -3243,7 +3409,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_or_ps() { + const unsafe fn test_mm256_or_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set1_ps(0.6); let r = _mm256_or_ps(a, b); @@ -3252,7 +3418,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_shuffle_pd() { + const unsafe fn test_mm256_shuffle_pd() { let a = _mm256_setr_pd(1., 4., 5., 8.); let b = _mm256_setr_pd(2., 3., 6., 7.); let r = _mm256_shuffle_pd::<0b11_11_11_11>(a, b); @@ -3261,7 +3427,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_shuffle_ps() { + const unsafe fn test_mm256_shuffle_ps() { let a = _mm256_setr_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_setr_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_shuffle_ps::<0b00_00_11_11>(a, b); @@ -3270,7 +3436,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_andnot_pd() { + const unsafe fn test_mm256_andnot_pd() { let a = _mm256_set1_pd(0.); let b = _mm256_set1_pd(0.6); let r = _mm256_andnot_pd(a, b); @@ -3278,7 +3444,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_andnot_ps() { + const unsafe fn test_mm256_andnot_ps() { let a = _mm256_set1_ps(0.); let b = _mm256_set1_ps(0.6); let r = _mm256_andnot_ps(a, b); @@ -3390,7 +3556,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_mul_pd() { + const unsafe fn test_mm256_mul_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_mul_pd(a, b); @@ -3399,7 +3565,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_mul_ps() { + const unsafe fn test_mm256_mul_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_ps(9., 10., 11., 12., 13., 14., 15., 16.); let r = _mm256_mul_ps(a, b); @@ -3408,7 +3574,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_addsub_pd() { + const unsafe fn test_mm256_addsub_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_addsub_pd(a, b); @@ -3417,7 +3583,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_addsub_ps() { + const unsafe fn test_mm256_addsub_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 1., 2., 3., 4.); let b = _mm256_setr_ps(5., 6., 7., 8., 5., 6., 7., 8.); let r = _mm256_addsub_ps(a, b); @@ -3426,7 +3592,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_sub_pd() { + const unsafe fn test_mm256_sub_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_sub_pd(a, b); @@ -3435,7 +3601,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_sub_ps() { + const unsafe fn test_mm256_sub_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., -1., -2., -3., -4.); let b = _mm256_setr_ps(5., 6., 7., 8., 3., 2., 1., 0.); let r = _mm256_sub_ps(a, b); @@ -3458,7 +3624,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_floor_pd() { + const unsafe fn test_mm256_floor_pd() { let a = _mm256_setr_pd(1.55, 2.2, 3.99, -1.2); let result_down = _mm256_floor_pd(a); let expected_down = _mm256_setr_pd(1., 2., 3., -2.); @@ -3466,7 +3632,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_ceil_pd() { + const unsafe fn test_mm256_ceil_pd() { let a = _mm256_setr_pd(1.55, 2.2, 3.99, -1.2); let result_up = _mm256_ceil_pd(a); let expected_up = _mm256_setr_pd(2., 3., 4., -1.); @@ -3488,7 +3654,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_floor_ps() { + const unsafe fn test_mm256_floor_ps() { let a = _mm256_setr_ps(1.55, 2.2, 3.99, -1.2, 1.55, 2.2, 3.99, -1.2); let result_down = _mm256_floor_ps(a); let expected_down = _mm256_setr_ps(1., 2., 3., -2., 1., 2., 3., -2.); @@ -3496,7 +3662,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_ceil_ps() { + const unsafe fn test_mm256_ceil_ps() { let a = _mm256_setr_ps(1.55, 2.2, 3.99, -1.2, 1.55, 2.2, 3.99, -1.2); let result_up = _mm256_ceil_ps(a); let expected_up = _mm256_setr_ps(2., 3., 4., -1., 2., 3., 4., -1.); @@ -3520,7 +3686,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_div_ps() { + const unsafe fn test_mm256_div_ps() { let a = _mm256_setr_ps(4., 9., 16., 25., 4., 9., 16., 25.); let b = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let r = _mm256_div_ps(a, b); @@ -3529,7 +3695,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_div_pd() { + const unsafe fn test_mm256_div_pd() { let a = _mm256_setr_pd(4., 9., 16., 25.); let b = _mm256_setr_pd(4., 3., 2., 5.); let r = _mm256_div_pd(a, b); @@ -3538,7 +3704,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_blend_pd() { + const unsafe fn test_mm256_blend_pd() { let a = _mm256_setr_pd(4., 9., 16., 25.); let b = _mm256_setr_pd(4., 3., 2., 5.); let r = _mm256_blend_pd::<0x0>(a, b); @@ -3550,7 +3716,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_blend_ps() { + const unsafe fn test_mm256_blend_ps() { let a = _mm256_setr_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_setr_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_blend_ps::<0x0>(a, b); @@ -3562,7 +3728,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_blendv_pd() { + const unsafe fn test_mm256_blendv_pd() { let a = _mm256_setr_pd(4., 9., 16., 25.); let b = _mm256_setr_pd(4., 3., 2., 5.); let c = _mm256_setr_pd(0., 0., !0 as f64, !0 as f64); @@ -3572,7 +3738,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_blendv_ps() { + const unsafe fn test_mm256_blendv_ps() { let a = _mm256_setr_ps(4., 9., 16., 25., 4., 9., 16., 25.); let b = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); #[rustfmt::skip] @@ -3594,7 +3760,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_hadd_pd() { + const unsafe fn test_mm256_hadd_pd() { let a = _mm256_setr_pd(4., 9., 16., 25.); let b = _mm256_setr_pd(4., 3., 2., 5.); let r = _mm256_hadd_pd(a, b); @@ -3609,7 +3775,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_hadd_ps() { + const unsafe fn test_mm256_hadd_ps() { let a = _mm256_setr_ps(4., 9., 16., 25., 4., 9., 16., 25.); let b = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let r = _mm256_hadd_ps(a, b); @@ -3624,7 +3790,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_hsub_pd() { + const unsafe fn test_mm256_hsub_pd() { let a = _mm256_setr_pd(4., 9., 16., 25.); let b = _mm256_setr_pd(4., 3., 2., 5.); let r = _mm256_hsub_pd(a, b); @@ -3639,7 +3805,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_hsub_ps() { + const unsafe fn test_mm256_hsub_ps() { let a = _mm256_setr_ps(4., 9., 16., 25., 4., 9., 16., 25.); let b = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let r = _mm256_hsub_ps(a, b); @@ -3654,7 +3820,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_xor_pd() { + const unsafe fn test_mm256_xor_pd() { let a = _mm256_setr_pd(4., 9., 16., 25.); let b = _mm256_set1_pd(0.); let r = _mm256_xor_pd(a, b); @@ -3662,7 +3828,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_xor_ps() { + const unsafe fn test_mm256_xor_ps() { let a = _mm256_setr_ps(4., 9., 16., 25., 4., 9., 16., 25.); let b = _mm256_set1_ps(0.); let r = _mm256_xor_ps(a, b); @@ -3728,7 +3894,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtepi32_pd() { + const unsafe fn test_mm256_cvtepi32_pd() { let a = _mm_setr_epi32(4, 9, 16, 25); let r = _mm256_cvtepi32_pd(a); let e = _mm256_setr_pd(4., 9., 16., 25.); @@ -3736,7 +3902,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtepi32_ps() { + const unsafe fn test_mm256_cvtepi32_ps() { let a = _mm256_setr_epi32(4, 9, 16, 25, 4, 9, 16, 25); let r = _mm256_cvtepi32_ps(a); let e = _mm256_setr_ps(4., 9., 16., 25., 4., 9., 16., 25.); @@ -3744,7 +3910,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtpd_ps() { + const unsafe fn test_mm256_cvtpd_ps() { let a = _mm256_setr_pd(4., 9., 16., 25.); let r = _mm256_cvtpd_ps(a); let e = _mm_setr_ps(4., 9., 16., 25.); @@ -3760,7 +3926,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtps_pd() { + const unsafe fn test_mm256_cvtps_pd() { let a = _mm_setr_ps(4., 9., 16., 25.); let r = _mm256_cvtps_pd(a); let e = _mm256_setr_pd(4., 9., 16., 25.); @@ -3768,7 +3934,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtsd_f64() { + const unsafe fn test_mm256_cvtsd_f64() { let a = _mm256_setr_pd(1., 2., 3., 4.); let r = _mm256_cvtsd_f64(a); assert_eq!(r, 1.); @@ -3799,7 +3965,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_extractf128_ps() { + const unsafe fn test_mm256_extractf128_ps() { let a = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let r = _mm256_extractf128_ps::<0>(a); let e = _mm_setr_ps(4., 3., 2., 5.); @@ -3807,7 +3973,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_extractf128_pd() { + const unsafe fn test_mm256_extractf128_pd() { let a = _mm256_setr_pd(4., 3., 2., 5.); let r = _mm256_extractf128_pd::<0>(a); let e = _mm_setr_pd(4., 3.); @@ -3815,7 +3981,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_extractf128_si256() { + const unsafe fn test_mm256_extractf128_si256() { let a = _mm256_setr_epi64x(4, 3, 2, 5); let r = _mm256_extractf128_si256::<0>(a); let e = _mm_setr_epi64x(4, 3); @@ -3823,7 +3989,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_extract_epi32() { + const unsafe fn test_mm256_extract_epi32() { let a = _mm256_setr_epi32(-1, 1, 2, 3, 4, 5, 6, 7); let r1 = _mm256_extract_epi32::<0>(a); let r2 = _mm256_extract_epi32::<3>(a); @@ -3832,7 +3998,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtsi256_si32() { + const unsafe fn test_mm256_cvtsi256_si32() { let a = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_cvtsi256_si32(a); assert_eq!(r, 1); @@ -3869,7 +4035,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_permute_ps() { + const unsafe fn test_mm256_permute_ps() { let a = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let r = _mm256_permute_ps::<0x1b>(a); let e = _mm256_setr_ps(5., 2., 3., 4., 50., 64., 9., 8.); @@ -3877,7 +4043,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_permute_ps() { + const unsafe fn test_mm_permute_ps() { let a = _mm_setr_ps(4., 3., 2., 5.); let r = _mm_permute_ps::<0x1b>(a); let e = _mm_setr_ps(5., 2., 3., 4.); @@ -3903,7 +4069,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_permute_pd() { + const unsafe fn test_mm256_permute_pd() { let a = _mm256_setr_pd(4., 3., 2., 5.); let r = _mm256_permute_pd::<5>(a); let e = _mm256_setr_pd(3., 4., 5., 2.); @@ -3911,7 +4077,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_permute_pd() { + const unsafe fn test_mm_permute_pd() { let a = _mm_setr_pd(4., 3.); let r = _mm_permute_pd::<1>(a); let e = _mm_setr_pd(3., 4.); @@ -3919,7 +4085,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_permute2f128_ps() { + const unsafe fn test_mm256_permute2f128_ps() { let a = _mm256_setr_ps(11., 12., 13., 14., 15., 16., 17., 18.); let b = _mm256_setr_ps(21., 22., 23., 24., 25., 26., 27., 28.); let r = _mm256_permute2f128_ps::<0b0001_0011>(a, b); @@ -3933,7 +4099,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_permute2f128_pd() { + const unsafe fn test_mm256_permute2f128_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_permute2f128_pd::<0b0011_0001>(a, b); @@ -3947,7 +4113,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_permute2f128_si256() { + const unsafe fn test_mm256_permute2f128_si256() { let a = _mm256_setr_epi32(11, 12, 13, 14, 15, 16, 17, 18); let b = _mm256_setr_epi32(21, 22, 23, 24, 25, 26, 27, 28); let r = _mm256_permute2f128_si256::<0b0010_0000>(a, b); @@ -3961,28 +4127,28 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_broadcast_ss() { + const unsafe fn test_mm256_broadcast_ss() { let r = _mm256_broadcast_ss(&3.); let e = _mm256_set1_ps(3.); assert_eq_m256(r, e); } #[simd_test(enable = "avx")] - unsafe fn test_mm_broadcast_ss() { + const unsafe fn test_mm_broadcast_ss() { let r = _mm_broadcast_ss(&3.); let e = _mm_set1_ps(3.); assert_eq_m128(r, e); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_broadcast_sd() { + const unsafe fn test_mm256_broadcast_sd() { let r = _mm256_broadcast_sd(&3.); let e = _mm256_set1_pd(3.); assert_eq_m256d(r, e); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_broadcast_ps() { + const unsafe fn test_mm256_broadcast_ps() { let a = _mm_setr_ps(4., 3., 2., 5.); let r = _mm256_broadcast_ps(&a); let e = _mm256_setr_ps(4., 3., 2., 5., 4., 3., 2., 5.); @@ -3990,7 +4156,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_broadcast_pd() { + const unsafe fn test_mm256_broadcast_pd() { let a = _mm_setr_pd(4., 3.); let r = _mm256_broadcast_pd(&a); let e = _mm256_setr_pd(4., 3., 4., 3.); @@ -3998,7 +4164,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_insertf128_ps() { + const unsafe fn test_mm256_insertf128_ps() { let a = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let b = _mm_setr_ps(4., 9., 16., 25.); let r = _mm256_insertf128_ps::<0>(a, b); @@ -4007,7 +4173,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_insertf128_pd() { + const unsafe fn test_mm256_insertf128_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm_setr_pd(5., 6.); let r = _mm256_insertf128_pd::<0>(a, b); @@ -4016,7 +4182,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_insertf128_si256() { + const unsafe fn test_mm256_insertf128_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let b = _mm_setr_epi64x(5, 6); let r = _mm256_insertf128_si256::<0>(a, b); @@ -4025,7 +4191,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_insert_epi8() { + const unsafe fn test_mm256_insert_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -4045,7 +4211,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_insert_epi16() { + const unsafe fn test_mm256_insert_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4061,7 +4227,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_insert_epi32() { + const unsafe fn test_mm256_insert_epi32() { let a = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_insert_epi32::<7>(a, 0); let e = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 0); @@ -4069,7 +4235,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_load_pd() { + const unsafe fn test_mm256_load_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let p = ptr::addr_of!(a) as *const f64; let r = _mm256_load_pd(p); @@ -4078,7 +4244,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_store_pd() { + const unsafe fn test_mm256_store_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let mut r = _mm256_undefined_pd(); _mm256_store_pd(ptr::addr_of_mut!(r) as *mut f64, a); @@ -4086,7 +4252,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_load_ps() { + const unsafe fn test_mm256_load_ps() { let a = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let p = ptr::addr_of!(a) as *const f32; let r = _mm256_load_ps(p); @@ -4095,7 +4261,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_store_ps() { + const unsafe fn test_mm256_store_ps() { let a = _mm256_setr_ps(4., 3., 2., 5., 8., 9., 64., 50.); let mut r = _mm256_undefined_ps(); _mm256_store_ps(ptr::addr_of_mut!(r) as *mut f32, a); @@ -4103,7 +4269,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_loadu_pd() { + const unsafe fn test_mm256_loadu_pd() { let a = &[1.0f64, 2., 3., 4.]; let p = a.as_ptr(); let r = _mm256_loadu_pd(black_box(p)); @@ -4112,7 +4278,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_storeu_pd() { + const unsafe fn test_mm256_storeu_pd() { let a = _mm256_set1_pd(9.); let mut r = _mm256_undefined_pd(); _mm256_storeu_pd(ptr::addr_of_mut!(r) as *mut f64, a); @@ -4120,7 +4286,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_loadu_ps() { + const unsafe fn test_mm256_loadu_ps() { let a = &[4., 3., 2., 5., 8., 9., 64., 50.]; let p = a.as_ptr(); let r = _mm256_loadu_ps(black_box(p)); @@ -4129,7 +4295,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_storeu_ps() { + const unsafe fn test_mm256_storeu_ps() { let a = _mm256_set1_ps(9.); let mut r = _mm256_undefined_ps(); _mm256_storeu_ps(ptr::addr_of_mut!(r) as *mut f32, a); @@ -4137,7 +4303,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_load_si256() { + const unsafe fn test_mm256_load_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let p = ptr::addr_of!(a); let r = _mm256_load_si256(p); @@ -4146,7 +4312,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_store_si256() { + const unsafe fn test_mm256_store_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let mut r = _mm256_undefined_si256(); _mm256_store_si256(ptr::addr_of_mut!(r), a); @@ -4154,7 +4320,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_loadu_si256() { + const unsafe fn test_mm256_loadu_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let p = ptr::addr_of!(a); let r = _mm256_loadu_si256(black_box(p)); @@ -4163,7 +4329,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_storeu_si256() { + const unsafe fn test_mm256_storeu_si256() { let a = _mm256_set1_epi8(9); let mut r = _mm256_undefined_si256(); _mm256_storeu_si256(ptr::addr_of_mut!(r), a); @@ -4171,7 +4337,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_maskload_pd() { + const unsafe fn test_mm256_maskload_pd() { let a = &[1.0f64, 2., 3., 4.]; let p = a.as_ptr(); let mask = _mm256_setr_epi64x(0, !0, 0, !0); @@ -4181,7 +4347,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_maskstore_pd() { + const unsafe fn test_mm256_maskstore_pd() { let mut r = _mm256_set1_pd(0.); let mask = _mm256_setr_epi64x(0, !0, 0, !0); let a = _mm256_setr_pd(1., 2., 3., 4.); @@ -4191,7 +4357,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_maskload_pd() { + const unsafe fn test_mm_maskload_pd() { let a = &[1.0f64, 2.]; let p = a.as_ptr(); let mask = _mm_setr_epi64x(0, !0); @@ -4201,7 +4367,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_maskstore_pd() { + const unsafe fn test_mm_maskstore_pd() { let mut r = _mm_set1_pd(0.); let mask = _mm_setr_epi64x(0, !0); let a = _mm_setr_pd(1., 2.); @@ -4211,7 +4377,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_maskload_ps() { + const unsafe fn test_mm256_maskload_ps() { let a = &[1.0f32, 2., 3., 4., 5., 6., 7., 8.]; let p = a.as_ptr(); let mask = _mm256_setr_epi32(0, !0, 0, !0, 0, !0, 0, !0); @@ -4221,7 +4387,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_maskstore_ps() { + const unsafe fn test_mm256_maskstore_ps() { let mut r = _mm256_set1_ps(0.); let mask = _mm256_setr_epi32(0, !0, 0, !0, 0, !0, 0, !0); let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); @@ -4231,7 +4397,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_maskload_ps() { + const unsafe fn test_mm_maskload_ps() { let a = &[1.0f32, 2., 3., 4.]; let p = a.as_ptr(); let mask = _mm_setr_epi32(0, !0, 0, !0); @@ -4241,7 +4407,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_maskstore_ps() { + const unsafe fn test_mm_maskstore_ps() { let mut r = _mm_set1_ps(0.); let mask = _mm_setr_epi32(0, !0, 0, !0); let a = _mm_setr_ps(1., 2., 3., 4.); @@ -4251,7 +4417,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_movehdup_ps() { + const unsafe fn test_mm256_movehdup_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_movehdup_ps(a); let e = _mm256_setr_ps(2., 2., 4., 4., 6., 6., 8., 8.); @@ -4259,7 +4425,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_moveldup_ps() { + const unsafe fn test_mm256_moveldup_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_moveldup_ps(a); let e = _mm256_setr_ps(1., 1., 3., 3., 5., 5., 7., 7.); @@ -4267,7 +4433,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_movedup_pd() { + const unsafe fn test_mm256_movedup_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let r = _mm256_movedup_pd(a); let e = _mm256_setr_pd(1., 1., 3., 3.); @@ -4370,7 +4536,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_unpackhi_pd() { + const unsafe fn test_mm256_unpackhi_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_unpackhi_pd(a, b); @@ -4379,7 +4545,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_unpackhi_ps() { + const unsafe fn test_mm256_unpackhi_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_ps(9., 10., 11., 12., 13., 14., 15., 16.); let r = _mm256_unpackhi_ps(a, b); @@ -4388,7 +4554,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_unpacklo_pd() { + const unsafe fn test_mm256_unpacklo_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); let r = _mm256_unpacklo_pd(a, b); @@ -4397,7 +4563,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_unpacklo_ps() { + const unsafe fn test_mm256_unpacklo_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_ps(9., 10., 11., 12., 13., 14., 15., 16.); let r = _mm256_unpacklo_ps(a, b); @@ -4406,7 +4572,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_testz_si256() { + const unsafe fn test_mm256_testz_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let b = _mm256_setr_epi64x(5, 6, 7, 8); let r = _mm256_testz_si256(a, b); @@ -4417,7 +4583,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_testc_si256() { + const unsafe fn test_mm256_testc_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let b = _mm256_setr_epi64x(5, 6, 7, 8); let r = _mm256_testc_si256(a, b); @@ -4475,7 +4641,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_testz_pd() { + const unsafe fn test_mm_testz_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 6.); let r = _mm_testz_pd(a, b); @@ -4486,7 +4652,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_testc_pd() { + const unsafe fn test_mm_testc_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 6.); let r = _mm_testc_pd(a, b); @@ -4541,7 +4707,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_testz_ps() { + const unsafe fn test_mm_testz_ps() { let a = _mm_set1_ps(1.); let r = _mm_testz_ps(a, a); assert_eq!(r, 1); @@ -4551,7 +4717,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm_testc_ps() { + const unsafe fn test_mm_testc_ps() { let a = _mm_set1_ps(1.); let r = _mm_testc_ps(a, a); assert_eq!(r, 1); @@ -4572,51 +4738,51 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_movemask_pd() { + const unsafe fn test_mm256_movemask_pd() { let a = _mm256_setr_pd(1., -2., 3., -4.); let r = _mm256_movemask_pd(a); assert_eq!(r, 0xA); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_movemask_ps() { + const unsafe fn test_mm256_movemask_ps() { let a = _mm256_setr_ps(1., -2., 3., -4., 1., -2., 3., -4.); let r = _mm256_movemask_ps(a); assert_eq!(r, 0xAA); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setzero_pd() { + const unsafe fn test_mm256_setzero_pd() { let r = _mm256_setzero_pd(); assert_eq_m256d(r, _mm256_set1_pd(0.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setzero_ps() { + const unsafe fn test_mm256_setzero_ps() { let r = _mm256_setzero_ps(); assert_eq_m256(r, _mm256_set1_ps(0.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setzero_si256() { + const unsafe fn test_mm256_setzero_si256() { let r = _mm256_setzero_si256(); assert_eq_m256i(r, _mm256_set1_epi8(0)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_pd() { + const unsafe fn test_mm256_set_pd() { let r = _mm256_set_pd(1., 2., 3., 4.); assert_eq_m256d(r, _mm256_setr_pd(4., 3., 2., 1.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_ps() { + const unsafe fn test_mm256_set_ps() { let r = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); assert_eq_m256(r, _mm256_setr_ps(8., 7., 6., 5., 4., 3., 2., 1.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_epi8() { + const unsafe fn test_mm256_set_epi8() { #[rustfmt::skip] let r = _mm256_set_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -4635,7 +4801,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_epi16() { + const unsafe fn test_mm256_set_epi16() { #[rustfmt::skip] let r = _mm256_set_epi16( 1, 2, 3, 4, 5, 6, 7, 8, @@ -4650,31 +4816,31 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_epi32() { + const unsafe fn test_mm256_set_epi32() { let r = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); assert_eq_m256i(r, _mm256_setr_epi32(8, 7, 6, 5, 4, 3, 2, 1)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_epi64x() { + const unsafe fn test_mm256_set_epi64x() { let r = _mm256_set_epi64x(1, 2, 3, 4); assert_eq_m256i(r, _mm256_setr_epi64x(4, 3, 2, 1)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_pd() { + const unsafe fn test_mm256_setr_pd() { let r = _mm256_setr_pd(1., 2., 3., 4.); assert_eq_m256d(r, _mm256_setr_pd(1., 2., 3., 4.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_ps() { + const unsafe fn test_mm256_setr_ps() { let r = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); assert_eq_m256(r, _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_epi8() { + const unsafe fn test_mm256_setr_epi8() { #[rustfmt::skip] let r = _mm256_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -4694,7 +4860,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_epi16() { + const unsafe fn test_mm256_setr_epi16() { #[rustfmt::skip] let r = _mm256_setr_epi16( 1, 2, 3, 4, 5, 6, 7, 8, @@ -4709,55 +4875,55 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_epi32() { + const unsafe fn test_mm256_setr_epi32() { let r = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); assert_eq_m256i(r, _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_epi64x() { + const unsafe fn test_mm256_setr_epi64x() { let r = _mm256_setr_epi64x(1, 2, 3, 4); assert_eq_m256i(r, _mm256_setr_epi64x(1, 2, 3, 4)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set1_pd() { + const unsafe fn test_mm256_set1_pd() { let r = _mm256_set1_pd(1.); assert_eq_m256d(r, _mm256_set1_pd(1.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set1_ps() { + const unsafe fn test_mm256_set1_ps() { let r = _mm256_set1_ps(1.); assert_eq_m256(r, _mm256_set1_ps(1.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set1_epi8() { + const unsafe fn test_mm256_set1_epi8() { let r = _mm256_set1_epi8(1); assert_eq_m256i(r, _mm256_set1_epi8(1)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set1_epi16() { + const unsafe fn test_mm256_set1_epi16() { let r = _mm256_set1_epi16(1); assert_eq_m256i(r, _mm256_set1_epi16(1)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set1_epi32() { + const unsafe fn test_mm256_set1_epi32() { let r = _mm256_set1_epi32(1); assert_eq_m256i(r, _mm256_set1_epi32(1)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set1_epi64x() { + const unsafe fn test_mm256_set1_epi64x() { let r = _mm256_set1_epi64x(1); assert_eq_m256i(r, _mm256_set1_epi64x(1)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castpd_ps() { + const unsafe fn test_mm256_castpd_ps() { let a = _mm256_setr_pd(1., 2., 3., 4.); let r = _mm256_castpd_ps(a); let e = _mm256_setr_ps(0., 1.875, 0., 2., 0., 2.125, 0., 2.25); @@ -4765,7 +4931,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castps_pd() { + const unsafe fn test_mm256_castps_pd() { let a = _mm256_setr_ps(0., 1.875, 0., 2., 0., 2.125, 0., 2.25); let r = _mm256_castps_pd(a); let e = _mm256_setr_pd(1., 2., 3., 4.); @@ -4773,7 +4939,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castps_si256() { + const unsafe fn test_mm256_castps_si256() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_castps_si256(a); #[rustfmt::skip] @@ -4787,7 +4953,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castsi256_ps() { + const unsafe fn test_mm256_castsi256_ps() { #[rustfmt::skip] let a = _mm256_setr_epi8( 0, 0, -128, 63, 0, 0, 0, 64, @@ -4801,63 +4967,63 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castpd_si256() { + const unsafe fn test_mm256_castpd_si256() { let a = _mm256_setr_pd(1., 2., 3., 4.); let r = _mm256_castpd_si256(a); assert_eq_m256d(transmute(r), a); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castsi256_pd() { + const unsafe fn test_mm256_castsi256_pd() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let r = _mm256_castsi256_pd(a); assert_eq_m256d(r, transmute(a)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castps256_ps128() { + const unsafe fn test_mm256_castps256_ps128() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_castps256_ps128(a); assert_eq_m128(r, _mm_setr_ps(1., 2., 3., 4.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castpd256_pd128() { + const unsafe fn test_mm256_castpd256_pd128() { let a = _mm256_setr_pd(1., 2., 3., 4.); let r = _mm256_castpd256_pd128(a); assert_eq_m128d(r, _mm_setr_pd(1., 2.)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castsi256_si128() { + const unsafe fn test_mm256_castsi256_si128() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let r = _mm256_castsi256_si128(a); assert_eq_m128i(r, _mm_setr_epi64x(1, 2)); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castps128_ps256() { + const unsafe fn test_mm256_castps128_ps256() { let a = _mm_setr_ps(1., 2., 3., 4.); let r = _mm256_castps128_ps256(a); assert_eq_m128(_mm256_castps256_ps128(r), a); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castpd128_pd256() { + const unsafe fn test_mm256_castpd128_pd256() { let a = _mm_setr_pd(1., 2.); let r = _mm256_castpd128_pd256(a); assert_eq_m128d(_mm256_castpd256_pd128(r), a); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_castsi128_si256() { + const unsafe fn test_mm256_castsi128_si256() { let a = _mm_setr_epi32(1, 2, 3, 4); let r = _mm256_castsi128_si256(a); assert_eq_m128i(_mm256_castsi256_si128(r), a); } #[simd_test(enable = "avx")] - unsafe fn test_mm256_zextps128_ps256() { + const unsafe fn test_mm256_zextps128_ps256() { let a = _mm_setr_ps(1., 2., 3., 4.); let r = _mm256_zextps128_ps256(a); let e = _mm256_setr_ps(1., 2., 3., 4., 0., 0., 0., 0.); @@ -4865,7 +5031,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_zextsi128_si256() { + const unsafe fn test_mm256_zextsi128_si256() { let a = _mm_setr_epi64x(1, 2); let r = _mm256_zextsi128_si256(a); let e = _mm256_setr_epi64x(1, 2, 0, 0); @@ -4873,7 +5039,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_zextpd128_pd256() { + const unsafe fn test_mm256_zextpd128_pd256() { let a = _mm_setr_pd(1., 2.); let r = _mm256_zextpd128_pd256(a); let e = _mm256_setr_pd(1., 2., 0., 0.); @@ -4881,7 +5047,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_m128() { + const unsafe fn test_mm256_set_m128() { let hi = _mm_setr_ps(5., 6., 7., 8.); let lo = _mm_setr_ps(1., 2., 3., 4.); let r = _mm256_set_m128(hi, lo); @@ -4890,7 +5056,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_m128d() { + const unsafe fn test_mm256_set_m128d() { let hi = _mm_setr_pd(3., 4.); let lo = _mm_setr_pd(1., 2.); let r = _mm256_set_m128d(hi, lo); @@ -4899,7 +5065,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_set_m128i() { + const unsafe fn test_mm256_set_m128i() { #[rustfmt::skip] let hi = _mm_setr_epi8( 17, 18, 19, 20, @@ -4926,7 +5092,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_m128() { + const unsafe fn test_mm256_setr_m128() { let lo = _mm_setr_ps(1., 2., 3., 4.); let hi = _mm_setr_ps(5., 6., 7., 8.); let r = _mm256_setr_m128(lo, hi); @@ -4935,7 +5101,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_m128d() { + const unsafe fn test_mm256_setr_m128d() { let lo = _mm_setr_pd(1., 2.); let hi = _mm_setr_pd(3., 4.); let r = _mm256_setr_m128d(lo, hi); @@ -4944,7 +5110,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_setr_m128i() { + const unsafe fn test_mm256_setr_m128i() { #[rustfmt::skip] let lo = _mm_setr_epi8( 1, 2, 3, 4, @@ -4969,7 +5135,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_loadu2_m128() { + const unsafe fn test_mm256_loadu2_m128() { let hi = &[5., 6., 7., 8.]; let hiaddr = hi.as_ptr(); let lo = &[1., 2., 3., 4.]; @@ -4980,7 +5146,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_loadu2_m128d() { + const unsafe fn test_mm256_loadu2_m128d() { let hi = &[3., 4.]; let hiaddr = hi.as_ptr(); let lo = &[1., 2.]; @@ -4991,7 +5157,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_loadu2_m128i() { + const unsafe fn test_mm256_loadu2_m128i() { #[rustfmt::skip] let hi = _mm_setr_epi8( 17, 18, 19, 20, 21, 22, 23, 24, @@ -5014,7 +5180,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_storeu2_m128() { + const unsafe fn test_mm256_storeu2_m128() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let mut hi = _mm_undefined_ps(); let mut lo = _mm_undefined_ps(); @@ -5028,7 +5194,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_storeu2_m128d() { + const unsafe fn test_mm256_storeu2_m128d() { let a = _mm256_setr_pd(1., 2., 3., 4.); let mut hi = _mm_undefined_pd(); let mut lo = _mm_undefined_pd(); @@ -5042,7 +5208,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_storeu2_m128i() { + const unsafe fn test_mm256_storeu2_m128i() { #[rustfmt::skip] let a = _mm256_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -5069,7 +5235,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_cvtss_f32() { + const unsafe fn test_mm256_cvtss_f32() { let a = _mm256_setr_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_cvtss_f32(a); assert_eq!(r, 1.); diff --git a/library/stdarch/crates/core_arch/src/x86_64/avx.rs b/library/stdarch/crates/core_arch/src/x86_64/avx.rs index b494385e4a61..bb8d25620714 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/avx.rs @@ -24,7 +24,8 @@ use crate::{core_arch::x86::*, mem::transmute}; #[target_feature(enable = "avx")] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_insert_epi64(a: __m256i, i: i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insert_epi64(a: __m256i, i: i64) -> __m256i { static_assert_uimm_bits!(INDEX, 2); unsafe { transmute(simd_insert!(a.as_i64x4(), INDEX as u32, i)) } } @@ -37,19 +38,21 @@ pub fn _mm256_insert_epi64(a: __m256i, i: i64) -> __m256i { #[rustc_legacy_const_generics(1)] // This intrinsic has no corresponding instruction. #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extract_epi64(a: __m256i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extract_epi64(a: __m256i) -> i64 { static_assert_uimm_bits!(INDEX, 2); unsafe { simd_extract!(a.as_i64x4(), INDEX as u32) } } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::arch::x86_64::*; #[simd_test(enable = "avx")] - unsafe fn test_mm256_insert_epi64() { + const unsafe fn test_mm256_insert_epi64() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let r = _mm256_insert_epi64::<3>(a, 0); let e = _mm256_setr_epi64x(1, 2, 3, 0); @@ -57,7 +60,7 @@ mod tests { } #[simd_test(enable = "avx")] - unsafe fn test_mm256_extract_epi64() { + const unsafe fn test_mm256_extract_epi64() { let a = _mm256_setr_epi64x(0, 1, 2, 3); let r = _mm256_extract_epi64::<3>(a); assert_eq!(r, 3); From 2d768ea921132aca1dcb9eb13a1dcc449ece2b80 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:13:18 +0530 Subject: [PATCH 066/489] Make `avx2` functions const --- .../stdarch/crates/core_arch/src/x86/avx2.rs | 661 +++++++++++------- 1 file changed, 399 insertions(+), 262 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index 3734915b709f..b3b2accd7338 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -31,7 +31,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpabsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_abs_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_abs_epi32(a: __m256i) -> __m256i { unsafe { let a = a.as_i32x8(); let r = simd_select::(simd_lt(a, i32x8::ZERO), simd_neg(a), a); @@ -46,7 +47,8 @@ pub fn _mm256_abs_epi32(a: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpabsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_abs_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_abs_epi16(a: __m256i) -> __m256i { unsafe { let a = a.as_i16x16(); let r = simd_select::(simd_lt(a, i16x16::ZERO), simd_neg(a), a); @@ -61,7 +63,8 @@ pub fn _mm256_abs_epi16(a: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpabsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_abs_epi8(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_abs_epi8(a: __m256i) -> __m256i { unsafe { let a = a.as_i8x32(); let r = simd_select::(simd_lt(a, i8x32::ZERO), simd_neg(a), a); @@ -76,7 +79,8 @@ pub fn _mm256_abs_epi8(a: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_add_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_add(a.as_i64x4(), b.as_i64x4())) } } @@ -87,7 +91,8 @@ pub fn _mm256_add_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_add_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_add(a.as_i32x8(), b.as_i32x8())) } } @@ -98,7 +103,8 @@ pub fn _mm256_add_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_add_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_add(a.as_i16x16(), b.as_i16x16())) } } @@ -109,7 +115,8 @@ pub fn _mm256_add_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_add_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_add(a.as_i8x32(), b.as_i8x32())) } } @@ -120,7 +127,8 @@ pub fn _mm256_add_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_adds_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_adds_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_add(a.as_i8x32(), b.as_i8x32())) } } @@ -131,7 +139,8 @@ pub fn _mm256_adds_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_adds_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_adds_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_add(a.as_i16x16(), b.as_i16x16())) } } @@ -142,7 +151,8 @@ pub fn _mm256_adds_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddusb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_adds_epu8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_adds_epu8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_add(a.as_u8x32(), b.as_u8x32())) } } @@ -153,7 +163,8 @@ pub fn _mm256_adds_epu8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpaddusw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_adds_epu16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_adds_epu16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_add(a.as_u16x16(), b.as_u16x16())) } } @@ -166,7 +177,8 @@ pub fn _mm256_adds_epu16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 7))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_alignr_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_alignr_epi8(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); // If palignr is shifting the pair of vectors more than the size of two @@ -247,7 +259,8 @@ pub fn _mm256_alignr_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_and_si256(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_and_si256(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_and(a.as_i64x4(), b.as_i64x4())) } } @@ -259,7 +272,8 @@ pub fn _mm256_and_si256(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_andnot_si256(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_andnot_si256(a: __m256i, b: __m256i) -> __m256i { unsafe { let all_ones = _mm256_set1_epi8(-1); transmute(simd_and( @@ -276,7 +290,8 @@ pub fn _mm256_andnot_si256(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpavgw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i { unsafe { let a = simd_cast::<_, u32x16>(a.as_u16x16()); let b = simd_cast::<_, u32x16>(b.as_u16x16()); @@ -292,7 +307,8 @@ pub fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpavgb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_avg_epu8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_avg_epu8(a: __m256i, b: __m256i) -> __m256i { unsafe { let a = simd_cast::<_, u16x32>(a.as_u8x32()); let b = simd_cast::<_, u16x32>(b.as_u8x32()); @@ -309,7 +325,8 @@ pub fn _mm256_avg_epu8(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vblendps, IMM4 = 9))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_blend_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_blend_epi32(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM4, 4); unsafe { let a = a.as_i32x4(); @@ -336,7 +353,8 @@ pub fn _mm_blend_epi32(a: __m128i, b: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vblendps, IMM8 = 9))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blend_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blend_epi32(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i32x8(); @@ -367,7 +385,8 @@ pub fn _mm256_blend_epi32(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpblendw, IMM8 = 9))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blend_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blend_epi16(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i16x16(); @@ -406,7 +425,8 @@ pub fn _mm256_blend_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpblendvb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_blendv_epi8(a: __m256i, b: __m256i, mask: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_blendv_epi8(a: __m256i, b: __m256i, mask: __m256i) -> __m256i { unsafe { let mask: i8x32 = simd_lt(mask.as_i8x32(), i8x32::ZERO); transmute(simd_select(mask, b.as_i8x32(), a.as_i8x32())) @@ -421,7 +441,8 @@ pub fn _mm256_blendv_epi8(a: __m256i, b: __m256i, mask: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpbroadcastb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_broadcastb_epi8(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastb_epi8(a: __m128i) -> __m128i { unsafe { let ret = simd_shuffle!(a.as_i8x16(), i8x16::ZERO, [0_u32; 16]); transmute::(ret) @@ -436,7 +457,8 @@ pub fn _mm_broadcastb_epi8(a: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpbroadcastb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastb_epi8(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastb_epi8(a: __m128i) -> __m256i { unsafe { let ret = simd_shuffle!(a.as_i8x16(), i8x16::ZERO, [0_u32; 32]); transmute::(ret) @@ -453,7 +475,8 @@ pub fn _mm256_broadcastb_epi8(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vbroadcastss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_broadcastd_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastd_epi32(a: __m128i) -> __m128i { unsafe { let ret = simd_shuffle!(a.as_i32x4(), i32x4::ZERO, [0_u32; 4]); transmute::(ret) @@ -470,7 +493,8 @@ pub fn _mm_broadcastd_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vbroadcastss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastd_epi32(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastd_epi32(a: __m128i) -> __m256i { unsafe { let ret = simd_shuffle!(a.as_i32x4(), i32x4::ZERO, [0_u32; 8]); transmute::(ret) @@ -487,7 +511,8 @@ pub fn _mm256_broadcastd_epi32(a: __m128i) -> __m256i { // See https://github.com/rust-lang/stdarch/issues/791 #[cfg_attr(test, assert_instr(vmovddup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_broadcastq_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastq_epi64(a: __m128i) -> __m128i { unsafe { let ret = simd_shuffle!(a.as_i64x2(), a.as_i64x2(), [0_u32; 2]); transmute::(ret) @@ -502,7 +527,8 @@ pub fn _mm_broadcastq_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vbroadcastsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastq_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastq_epi64(a: __m128i) -> __m256i { unsafe { let ret = simd_shuffle!(a.as_i64x2(), a.as_i64x2(), [0_u32; 4]); transmute::(ret) @@ -517,7 +543,8 @@ pub fn _mm256_broadcastq_epi64(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vmovddup))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_broadcastsd_pd(a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastsd_pd(a: __m128d) -> __m128d { unsafe { simd_shuffle!(a, _mm_setzero_pd(), [0_u32; 2]) } } @@ -529,7 +556,8 @@ pub fn _mm_broadcastsd_pd(a: __m128d) -> __m128d { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vbroadcastsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastsd_pd(a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastsd_pd(a: __m128d) -> __m256d { unsafe { simd_shuffle!(a, _mm_setzero_pd(), [0_u32; 4]) } } @@ -540,7 +568,8 @@ pub fn _mm256_broadcastsd_pd(a: __m128d) -> __m256d { #[inline] #[target_feature(enable = "avx2")] #[stable(feature = "simd_x86_updates", since = "1.82.0")] -pub fn _mm_broadcastsi128_si256(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastsi128_si256(a: __m128i) -> __m256i { unsafe { let ret = simd_shuffle!(a.as_i64x2(), i64x2::ZERO, [0, 1, 0, 1]); transmute::(ret) @@ -556,7 +585,8 @@ pub fn _mm_broadcastsi128_si256(a: __m128i) -> __m256i { #[inline] #[target_feature(enable = "avx2")] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastsi128_si256(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastsi128_si256(a: __m128i) -> __m256i { unsafe { let ret = simd_shuffle!(a.as_i64x2(), i64x2::ZERO, [0, 1, 0, 1]); transmute::(ret) @@ -571,7 +601,8 @@ pub fn _mm256_broadcastsi128_si256(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vbroadcastss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_broadcastss_ps(a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastss_ps(a: __m128) -> __m128 { unsafe { simd_shuffle!(a, _mm_setzero_ps(), [0_u32; 4]) } } @@ -583,7 +614,8 @@ pub fn _mm_broadcastss_ps(a: __m128) -> __m128 { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vbroadcastss))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastss_ps(a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastss_ps(a: __m128) -> __m256 { unsafe { simd_shuffle!(a, _mm_setzero_ps(), [0_u32; 8]) } } @@ -595,7 +627,8 @@ pub fn _mm256_broadcastss_ps(a: __m128) -> __m256 { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpbroadcastw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_broadcastw_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastw_epi16(a: __m128i) -> __m128i { unsafe { let ret = simd_shuffle!(a.as_i16x8(), i16x8::ZERO, [0_u32; 8]); transmute::(ret) @@ -610,7 +643,8 @@ pub fn _mm_broadcastw_epi16(a: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpbroadcastw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_broadcastw_epi16(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastw_epi16(a: __m128i) -> __m256i { unsafe { let ret = simd_shuffle!(a.as_i16x8(), i16x8::ZERO, [0_u32; 16]); transmute::(ret) @@ -624,7 +658,8 @@ pub fn _mm256_broadcastw_epi16(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpeqq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpeq_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_eq(a.as_i64x4(), b.as_i64x4())) } } @@ -635,7 +670,8 @@ pub fn _mm256_cmpeq_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpeqd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpeq_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_eq(a.as_i32x8(), b.as_i32x8())) } } @@ -646,7 +682,8 @@ pub fn _mm256_cmpeq_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpeqw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpeq_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_eq(a.as_i16x16(), b.as_i16x16())) } } @@ -657,7 +694,8 @@ pub fn _mm256_cmpeq_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpeqb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpeq_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_eq(a.as_i8x32(), b.as_i8x32())) } } @@ -668,7 +706,8 @@ pub fn _mm256_cmpeq_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpgtq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpgt_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_gt(a.as_i64x4(), b.as_i64x4())) } } @@ -679,7 +718,8 @@ pub fn _mm256_cmpgt_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpgtd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpgt_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_gt(a.as_i32x8(), b.as_i32x8())) } } @@ -690,7 +730,8 @@ pub fn _mm256_cmpgt_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpgtw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpgt_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_gt(a.as_i16x16(), b.as_i16x16())) } } @@ -701,7 +742,8 @@ pub fn _mm256_cmpgt_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpcmpgtb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cmpgt_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute::(simd_gt(a.as_i8x32(), b.as_i8x32())) } } @@ -712,7 +754,8 @@ pub fn _mm256_cmpgt_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovsxwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi16_epi32(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi16_epi32(a: __m128i) -> __m256i { unsafe { transmute::(simd_cast(a.as_i16x8())) } } @@ -723,7 +766,8 @@ pub fn _mm256_cvtepi16_epi32(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovsxwq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi16_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi16_epi64(a: __m128i) -> __m256i { unsafe { let a = a.as_i16x8(); let v64: i16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -738,7 +782,8 @@ pub fn _mm256_cvtepi16_epi64(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovsxdq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi32_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi32_epi64(a: __m128i) -> __m256i { unsafe { transmute::(simd_cast(a.as_i32x4())) } } @@ -749,7 +794,8 @@ pub fn _mm256_cvtepi32_epi64(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovsxbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi8_epi16(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi8_epi16(a: __m128i) -> __m256i { unsafe { transmute::(simd_cast(a.as_i8x16())) } } @@ -760,7 +806,8 @@ pub fn _mm256_cvtepi8_epi16(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovsxbd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi8_epi32(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi8_epi32(a: __m128i) -> __m256i { unsafe { let a = a.as_i8x16(); let v64: i8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -775,7 +822,8 @@ pub fn _mm256_cvtepi8_epi32(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovsxbq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepi8_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi8_epi64(a: __m128i) -> __m256i { unsafe { let a = a.as_i8x16(); let v32: i8x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -791,7 +839,8 @@ pub fn _mm256_cvtepi8_epi64(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovzxwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepu16_epi32(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu16_epi32(a: __m128i) -> __m256i { unsafe { transmute::(simd_cast(a.as_u16x8())) } } @@ -803,7 +852,8 @@ pub fn _mm256_cvtepu16_epi32(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovzxwq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepu16_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu16_epi64(a: __m128i) -> __m256i { unsafe { let a = a.as_u16x8(); let v64: u16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -818,7 +868,8 @@ pub fn _mm256_cvtepu16_epi64(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovzxdq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepu32_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu32_epi64(a: __m128i) -> __m256i { unsafe { transmute::(simd_cast(a.as_u32x4())) } } @@ -829,7 +880,8 @@ pub fn _mm256_cvtepu32_epi64(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovzxbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepu8_epi16(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu8_epi16(a: __m128i) -> __m256i { unsafe { transmute::(simd_cast(a.as_u8x16())) } } @@ -841,7 +893,8 @@ pub fn _mm256_cvtepu8_epi16(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovzxbd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepu8_epi32(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu8_epi32(a: __m128i) -> __m256i { unsafe { let a = a.as_u8x16(); let v64: u8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -857,7 +910,8 @@ pub fn _mm256_cvtepu8_epi32(a: __m128i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovzxbq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_cvtepu8_epi64(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu8_epi64(a: __m128i) -> __m256i { unsafe { let a = a.as_u8x16(); let v32: u8x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -873,7 +927,8 @@ pub fn _mm256_cvtepu8_epi64(a: __m128i) -> __m256i { #[cfg_attr(test, assert_instr(vextractf128, IMM1 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extracti128_si256(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extracti128_si256(a: __m256i) -> __m128i { static_assert_uimm_bits!(IMM1, 1); unsafe { let a = a.as_i64x4(); @@ -890,7 +945,8 @@ pub fn _mm256_extracti128_si256(a: __m256i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vphaddw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hadd_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hadd_epi16(a: __m256i, b: __m256i) -> __m256i { let a = a.as_i16x16(); let b = b.as_i16x16(); unsafe { @@ -915,7 +971,8 @@ pub fn _mm256_hadd_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vphaddd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hadd_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hadd_epi32(a: __m256i, b: __m256i) -> __m256i { let a = a.as_i32x8(); let b = b.as_i32x8(); unsafe { @@ -944,7 +1001,8 @@ pub fn _mm256_hadds_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vphsubw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hsub_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hsub_epi16(a: __m256i, b: __m256i) -> __m256i { let a = a.as_i16x16(); let b = b.as_i16x16(); unsafe { @@ -969,7 +1027,8 @@ pub fn _mm256_hsub_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vphsubd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_hsub_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_hsub_epi32(a: __m256i, b: __m256i) -> __m256i { let a = a.as_i32x8(); let b = b.as_i32x8(); unsafe { @@ -1734,7 +1793,8 @@ pub unsafe fn _mm256_mask_i64gather_pd( #[cfg_attr(test, assert_instr(vinsertf128, IMM1 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_inserti128_si256(a: __m256i, b: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_inserti128_si256(a: __m256i, b: __m128i) -> __m256i { static_assert_uimm_bits!(IMM1, 1); unsafe { let a = a.as_i64x4(); @@ -1753,7 +1813,8 @@ pub fn _mm256_inserti128_si256(a: __m256i, b: __m128i) -> __m25 #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaddwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_madd_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_madd_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i32x16 = simd_mul(simd_cast(a.as_i16x16()), simd_cast(b.as_i16x16())); let even: i32x8 = simd_shuffle!(r, r, [0, 2, 4, 6, 8, 10, 12, 14]); @@ -1785,7 +1846,8 @@ pub fn _mm256_maddubs_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskload_epi32(mem_addr: *const i32, mask: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskload_epi32(mem_addr: *const i32, mask: __m128i) -> __m128i { let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i32x4::ZERO).as_m128i() } @@ -1799,7 +1861,8 @@ pub unsafe fn _mm_maskload_epi32(mem_addr: *const i32, mask: __m128i) -> __m128i #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskload_epi32(mem_addr: *const i32, mask: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskload_epi32(mem_addr: *const i32, mask: __m256i) -> __m256i { let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i32x8::ZERO).as_m256i() } @@ -1813,7 +1876,8 @@ pub unsafe fn _mm256_maskload_epi32(mem_addr: *const i32, mask: __m256i) -> __m2 #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskload_epi64(mem_addr: *const i64, mask: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskload_epi64(mem_addr: *const i64, mask: __m128i) -> __m128i { let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i64x2::ZERO).as_m128i() } @@ -1827,7 +1891,8 @@ pub unsafe fn _mm_maskload_epi64(mem_addr: *const i64, mask: __m128i) -> __m128i #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskload_epi64(mem_addr: *const i64, mask: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskload_epi64(mem_addr: *const i64, mask: __m256i) -> __m256i { let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i64x4::ZERO).as_m256i() } @@ -1841,7 +1906,8 @@ pub unsafe fn _mm256_maskload_epi64(mem_addr: *const i64, mask: __m256i) -> __m2 #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskstore_epi32(mem_addr: *mut i32, mask: __m128i, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskstore_epi32(mem_addr: *mut i32, mask: __m128i, a: __m128i) { let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x4()) } @@ -1855,7 +1921,8 @@ pub unsafe fn _mm_maskstore_epi32(mem_addr: *mut i32, mask: __m128i, a: __m128i) #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskstore_epi32(mem_addr: *mut i32, mask: __m256i, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskstore_epi32(mem_addr: *mut i32, mask: __m256i, a: __m256i) { let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x8()) } @@ -1869,7 +1936,8 @@ pub unsafe fn _mm256_maskstore_epi32(mem_addr: *mut i32, mask: __m256i, a: __m25 #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm_maskstore_epi64(mem_addr: *mut i64, mask: __m128i, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskstore_epi64(mem_addr: *mut i64, mask: __m128i, a: __m128i) { let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x2()) } @@ -1883,7 +1951,8 @@ pub unsafe fn _mm_maskstore_epi64(mem_addr: *mut i64, mask: __m128i, a: __m128i) #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub unsafe fn _mm256_maskstore_epi64(mem_addr: *mut i64, mask: __m256i, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskstore_epi64(mem_addr: *mut i64, mask: __m256i, a: __m256i) { let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x4()) } @@ -1896,7 +1965,8 @@ pub unsafe fn _mm256_maskstore_epi64(mem_addr: *mut i64, mask: __m256i, a: __m25 #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaxsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_max_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_i16x16(), b.as_i16x16()).as_m256i() } } @@ -1908,7 +1978,8 @@ pub fn _mm256_max_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaxsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_max_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_i32x8(), b.as_i32x8()).as_m256i() } } @@ -1920,7 +1991,8 @@ pub fn _mm256_max_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaxsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_max_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_i8x32(), b.as_i8x32()).as_m256i() } } @@ -1932,7 +2004,8 @@ pub fn _mm256_max_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaxuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_max_epu16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epu16(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_u16x16(), b.as_u16x16()).as_m256i() } } @@ -1944,7 +2017,8 @@ pub fn _mm256_max_epu16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaxud))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_max_epu32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epu32(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_u32x8(), b.as_u32x8()).as_m256i() } } @@ -1956,7 +2030,8 @@ pub fn _mm256_max_epu32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmaxub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_max_epu8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epu8(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_u8x32(), b.as_u8x32()).as_m256i() } } @@ -1968,7 +2043,8 @@ pub fn _mm256_max_epu8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpminsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_min_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_i16x16(), b.as_i16x16()).as_m256i() } } @@ -1980,7 +2056,8 @@ pub fn _mm256_min_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpminsd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_min_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_i32x8(), b.as_i32x8()).as_m256i() } } @@ -1992,7 +2069,8 @@ pub fn _mm256_min_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpminsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_min_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_i8x32(), b.as_i8x32()).as_m256i() } } @@ -2004,7 +2082,8 @@ pub fn _mm256_min_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpminuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_min_epu16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epu16(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_u16x16(), b.as_u16x16()).as_m256i() } } @@ -2016,7 +2095,8 @@ pub fn _mm256_min_epu16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpminud))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_min_epu32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epu32(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_u32x8(), b.as_u32x8()).as_m256i() } } @@ -2028,7 +2108,8 @@ pub fn _mm256_min_epu32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpminub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_min_epu8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epu8(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_u8x32(), b.as_u8x32()).as_m256i() } } @@ -2040,7 +2121,8 @@ pub fn _mm256_min_epu8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmovmskb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_movemask_epi8(a: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movemask_epi8(a: __m256i) -> i32 { unsafe { let z = i8x32::ZERO; let m: i8x32 = simd_lt(a.as_i8x32(), z); @@ -2077,7 +2159,8 @@ pub fn _mm256_mpsadbw_epu8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmuldq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mul_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mul_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { let a = simd_cast::<_, i64x4>(simd_cast::<_, i32x4>(a.as_i64x4())); let b = simd_cast::<_, i64x4>(simd_cast::<_, i32x4>(b.as_i64x4())); @@ -2095,11 +2178,12 @@ pub fn _mm256_mul_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmuludq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mul_epu32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mul_epu32(a: __m256i, b: __m256i) -> __m256i { unsafe { let a = a.as_u64x4(); let b = b.as_u64x4(); - let mask = u64x4::splat(u32::MAX.into()); + let mask = u64x4::splat(u32::MAX as u64); transmute(simd_mul(simd_and(a, mask), simd_and(b, mask))) } } @@ -2113,7 +2197,8 @@ pub fn _mm256_mul_epu32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmulhw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { let a = simd_cast::<_, i32x16>(a.as_i16x16()); let b = simd_cast::<_, i32x16>(b.as_i16x16()); @@ -2131,7 +2216,8 @@ pub fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmulhuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mulhi_epu16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mulhi_epu16(a: __m256i, b: __m256i) -> __m256i { unsafe { let a = simd_cast::<_, u32x16>(a.as_u16x16()); let b = simd_cast::<_, u32x16>(b.as_u16x16()); @@ -2149,7 +2235,8 @@ pub fn _mm256_mulhi_epu16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmullw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mullo_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mullo_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_mul(a.as_i16x16(), b.as_i16x16())) } } @@ -2162,7 +2249,8 @@ pub fn _mm256_mullo_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmulld))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_mullo_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mullo_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_mul(a.as_i32x8(), b.as_i32x8())) } } @@ -2188,7 +2276,8 @@ pub fn _mm256_mulhrs_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_or_si256(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_or_si256(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_or(a.as_i32x8(), b.as_i32x8())) } } @@ -2262,7 +2351,8 @@ pub fn _mm256_permutevar8x32_epi32(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpermpd, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute4x64_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute4x64_epi64(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { let zero = i64x4::ZERO; @@ -2288,7 +2378,8 @@ pub fn _mm256_permute4x64_epi64(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vperm2f128, IMM8 = 9))] #[rustc_legacy_const_generics(2)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute2x128_si256(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute2x128_si256(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_permute2f128_si256::(a, b) } @@ -2302,7 +2393,8 @@ pub fn _mm256_permute2x128_si256(a: __m256i, b: __m256i) -> __m #[cfg_attr(test, assert_instr(vpermpd, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_permute4x64_pd(a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permute4x64_pd(a: __m256d) -> __m256d { static_assert_uimm_bits!(IMM8, 8); unsafe { simd_shuffle!( @@ -2417,7 +2509,8 @@ pub fn _mm256_shuffle_epi8(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vshufps, MASK = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_shuffle_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_epi32(a: __m256i) -> __m256i { static_assert_uimm_bits!(MASK, 8); unsafe { let r: i32x8 = simd_shuffle!( @@ -2448,7 +2541,8 @@ pub fn _mm256_shuffle_epi32(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_shufflehi_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shufflehi_epi16(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i16x16(); @@ -2488,7 +2582,8 @@ pub fn _mm256_shufflehi_epi16(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 9))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_shufflelo_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shufflelo_epi16(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { let a = a.as_i16x16(); @@ -2602,7 +2697,8 @@ pub fn _mm256_sll_epi64(a: __m256i, count: __m128i) -> __m256i { #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_slli_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_slli_epi16(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 16 { @@ -2622,7 +2718,8 @@ pub fn _mm256_slli_epi16(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpslld, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_slli_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_slli_epi32(a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -2642,7 +2739,8 @@ pub fn _mm256_slli_epi32(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_slli_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_slli_epi64(a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -2661,7 +2759,8 @@ pub fn _mm256_slli_epi64(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpslldq, IMM8 = 3))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_slli_si256(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_slli_si256(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_bslli_epi128::(a) } @@ -2674,7 +2773,8 @@ pub fn _mm256_slli_si256(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpslldq, IMM8 = 3))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_bslli_epi128(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_bslli_epi128(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); const fn mask(shift: i32, i: u32) -> u32 { let shift = shift as u32 & 0xff; @@ -2737,7 +2837,8 @@ pub fn _mm256_bslli_epi128(a: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsllvd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u32x4(); let no_overflow: u32x4 = simd_lt(count, u32x4::splat(u32::BITS)); @@ -2755,7 +2856,8 @@ pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsllvd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u32x8(); let no_overflow: u32x8 = simd_lt(count, u32x8::splat(u32::BITS)); @@ -2773,7 +2875,8 @@ pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsllvq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u64x2(); let no_overflow: u64x2 = simd_lt(count, u64x2::splat(u64::BITS as u64)); @@ -2791,7 +2894,8 @@ pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsllvq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sllv_epi64(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sllv_epi64(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u64x4(); let no_overflow: u64x4 = simd_lt(count, u64x4::splat(u64::BITS as u64)); @@ -2833,7 +2937,8 @@ pub fn _mm256_sra_epi32(a: __m256i, count: __m128i) -> __m256i { #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srai_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srai_epi16(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(simd_shr(a.as_i16x16(), i16x16::splat(IMM8.min(15) as i16))) } } @@ -2847,7 +2952,8 @@ pub fn _mm256_srai_epi16(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srai_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srai_epi32(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { transmute(simd_shr(a.as_i32x8(), i32x8::splat(IMM8.min(31)))) } } @@ -2860,7 +2966,8 @@ pub fn _mm256_srai_epi32(a: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsravd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u32x4(); let no_overflow: u32x4 = simd_lt(count, u32x4::splat(u32::BITS)); @@ -2877,7 +2984,8 @@ pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsravd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u32x8(); let no_overflow: u32x8 = simd_lt(count, u32x8::splat(u32::BITS)); @@ -2894,7 +3002,8 @@ pub fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrldq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srli_si256(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srli_si256(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_bsrli_epi128::(a) } @@ -2907,7 +3016,8 @@ pub fn _mm256_srli_si256(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrldq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_bsrli_epi128(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_bsrli_epi128(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); const fn mask(shift: i32, i: u32) -> u32 { let shift = shift as u32 & 0xff; @@ -3006,7 +3116,8 @@ pub fn _mm256_srl_epi64(a: __m256i, count: __m128i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srli_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srli_epi16(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 16 { @@ -3026,7 +3137,8 @@ pub fn _mm256_srli_epi16(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srli_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srli_epi32(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 32 { @@ -3046,7 +3158,8 @@ pub fn _mm256_srli_epi32(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 7))] #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srli_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srli_epi64(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); unsafe { if IMM8 >= 64 { @@ -3065,7 +3178,8 @@ pub fn _mm256_srli_epi64(a: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsrlvd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u32x4(); let no_overflow: u32x4 = simd_lt(count, u32x4::splat(u32::BITS)); @@ -3082,7 +3196,8 @@ pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsrlvd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u32x8(); let no_overflow: u32x8 = simd_lt(count, u32x8::splat(u32::BITS)); @@ -3099,7 +3214,8 @@ pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsrlvq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u64x2(); let no_overflow: u64x2 = simd_lt(count, u64x2::splat(u64::BITS as u64)); @@ -3116,7 +3232,8 @@ pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsrlvq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_srlv_epi64(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srlv_epi64(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u64x4(); let no_overflow: u64x4 = simd_lt(count, u64x4::splat(u64::BITS as u64)); @@ -3152,7 +3269,8 @@ pub unsafe fn _mm256_stream_load_si256(mem_addr: *const __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sub_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_sub(a.as_i16x16(), b.as_i16x16())) } } @@ -3163,7 +3281,8 @@ pub fn _mm256_sub_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sub_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_sub(a.as_i32x8(), b.as_i32x8())) } } @@ -3174,7 +3293,8 @@ pub fn _mm256_sub_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubq))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sub_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_sub(a.as_i64x4(), b.as_i64x4())) } } @@ -3185,7 +3305,8 @@ pub fn _mm256_sub_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_sub_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_sub(a.as_i8x32(), b.as_i8x32())) } } @@ -3197,7 +3318,8 @@ pub fn _mm256_sub_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubsw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_subs_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_subs_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_sub(a.as_i16x16(), b.as_i16x16())) } } @@ -3209,7 +3331,8 @@ pub fn _mm256_subs_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubsb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_subs_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_subs_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_sub(a.as_i8x32(), b.as_i8x32())) } } @@ -3221,7 +3344,8 @@ pub fn _mm256_subs_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubusw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_subs_epu16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_subs_epu16(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_sub(a.as_u16x16(), b.as_u16x16())) } } @@ -3233,7 +3357,8 @@ pub fn _mm256_subs_epu16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpsubusb))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_subs_epu8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_subs_epu8(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_saturating_sub(a.as_u8x32(), b.as_u8x32())) } } @@ -3280,7 +3405,8 @@ pub fn _mm256_subs_epu8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpunpckhbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpackhi_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpackhi_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { #[rustfmt::skip] let r: i8x32 = simd_shuffle!(a.as_i8x32(), b.as_i8x32(), [ @@ -3335,7 +3461,8 @@ pub fn _mm256_unpackhi_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpunpcklbw))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpacklo_epi8(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpacklo_epi8(a: __m256i, b: __m256i) -> __m256i { unsafe { #[rustfmt::skip] let r: i8x32 = simd_shuffle!(a.as_i8x32(), b.as_i8x32(), [ @@ -3386,7 +3513,8 @@ pub fn _mm256_unpacklo_epi8(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpunpckhwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpackhi_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpackhi_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i16x16 = simd_shuffle!( a.as_i16x16(), @@ -3436,7 +3564,8 @@ pub fn _mm256_unpackhi_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpunpcklwd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpacklo_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpacklo_epi16(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i16x16 = simd_shuffle!( a.as_i16x16(), @@ -3479,7 +3608,8 @@ pub fn _mm256_unpacklo_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vunpckhps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpackhi_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpackhi_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i32x8 = simd_shuffle!(a.as_i32x8(), b.as_i32x8(), [2, 10, 3, 11, 6, 14, 7, 15]); transmute(r) @@ -3518,7 +3648,8 @@ pub fn _mm256_unpackhi_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vunpcklps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpacklo_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpacklo_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i32x8 = simd_shuffle!(a.as_i32x8(), b.as_i32x8(), [0, 8, 1, 9, 4, 12, 5, 13]); transmute(r) @@ -3557,7 +3688,8 @@ pub fn _mm256_unpacklo_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vunpckhpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpackhi_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpackhi_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i64x4 = simd_shuffle!(a.as_i64x4(), b.as_i64x4(), [1, 5, 3, 7]); transmute(r) @@ -3596,7 +3728,8 @@ pub fn _mm256_unpackhi_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vunpcklpd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_unpacklo_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_unpacklo_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { let r: i64x4 = simd_shuffle!(a.as_i64x4(), b.as_i64x4(), [0, 4, 2, 6]); transmute(r) @@ -3611,7 +3744,8 @@ pub fn _mm256_unpacklo_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_xor(a.as_i64x4(), b.as_i64x4())) } } @@ -3626,7 +3760,8 @@ pub fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i { // This intrinsic has no corresponding instruction. #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extract_epi8(a: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extract_epi8(a: __m256i) -> i32 { static_assert_uimm_bits!(INDEX, 5); unsafe { simd_extract!(a.as_u8x32(), INDEX as u32, u8) as i32 } } @@ -3642,7 +3777,8 @@ pub fn _mm256_extract_epi8(a: __m256i) -> i32 { // This intrinsic has no corresponding instruction. #[rustc_legacy_const_generics(1)] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_extract_epi16(a: __m256i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extract_epi16(a: __m256i) -> i32 { static_assert_uimm_bits!(INDEX, 4); unsafe { simd_extract!(a.as_u16x16(), INDEX as u32, u16) as i32 } } @@ -3771,13 +3907,14 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "avx2")] - unsafe fn test_mm256_abs_epi32() { + const unsafe fn test_mm256_abs_epi32() { #[rustfmt::skip] let a = _mm256_setr_epi32( 0, 1, -1, i32::MAX, @@ -3793,7 +3930,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_abs_epi16() { + const unsafe fn test_mm256_abs_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, -1, 2, -2, 3, -3, 4, @@ -3809,7 +3946,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_abs_epi8() { + const unsafe fn test_mm256_abs_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 0, 1, -1, 2, -2, 3, -3, 4, @@ -3829,7 +3966,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_add_epi64() { + const unsafe fn test_mm256_add_epi64() { let a = _mm256_setr_epi64x(-10, 0, 100, 1_000_000_000); let b = _mm256_setr_epi64x(-1, 0, 1, 2); let r = _mm256_add_epi64(a, b); @@ -3838,7 +3975,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_add_epi32() { + const unsafe fn test_mm256_add_epi32() { let a = _mm256_setr_epi32(-1, 0, 1, 2, 3, 4, 5, 6); let b = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_add_epi32(a, b); @@ -3847,7 +3984,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_add_epi16() { + const unsafe fn test_mm256_add_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, 2, 3, 4, 5, 6, 7, @@ -3868,7 +4005,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_add_epi8() { + const unsafe fn test_mm256_add_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -3895,7 +4032,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_adds_epi8() { + const unsafe fn test_mm256_adds_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -3938,7 +4075,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_adds_epi16() { + const unsafe fn test_mm256_adds_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, 2, 3, 4, 5, 6, 7, @@ -3976,7 +4113,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_adds_epu8() { + const unsafe fn test_mm256_adds_epu8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4011,7 +4148,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_adds_epu16() { + const unsafe fn test_mm256_adds_epu16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4041,7 +4178,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_and_si256() { + const unsafe fn test_mm256_and_si256() { let a = _mm256_set1_epi8(5); let b = _mm256_set1_epi8(3); let got = _mm256_and_si256(a, b); @@ -4049,7 +4186,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_andnot_si256() { + const unsafe fn test_mm256_andnot_si256() { let a = _mm256_set1_epi8(5); let b = _mm256_set1_epi8(3); let got = _mm256_andnot_si256(a, b); @@ -4057,21 +4194,21 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_avg_epu8() { + const unsafe fn test_mm256_avg_epu8() { let (a, b) = (_mm256_set1_epi8(3), _mm256_set1_epi8(9)); let r = _mm256_avg_epu8(a, b); assert_eq_m256i(r, _mm256_set1_epi8(6)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_avg_epu16() { + const unsafe fn test_mm256_avg_epu16() { let (a, b) = (_mm256_set1_epi16(3), _mm256_set1_epi16(9)); let r = _mm256_avg_epu16(a, b); assert_eq_m256i(r, _mm256_set1_epi16(6)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_blend_epi32() { + const unsafe fn test_mm_blend_epi32() { let (a, b) = (_mm_set1_epi32(3), _mm_set1_epi32(9)); let e = _mm_setr_epi32(9, 3, 3, 3); let r = _mm_blend_epi32::<0x01>(a, b); @@ -4082,7 +4219,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_blend_epi32() { + const unsafe fn test_mm256_blend_epi32() { let (a, b) = (_mm256_set1_epi32(3), _mm256_set1_epi32(9)); let e = _mm256_setr_epi32(9, 3, 3, 3, 3, 3, 3, 3); let r = _mm256_blend_epi32::<0x01>(a, b); @@ -4098,7 +4235,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_blend_epi16() { + const unsafe fn test_mm256_blend_epi16() { let (a, b) = (_mm256_set1_epi16(3), _mm256_set1_epi16(9)); let e = _mm256_setr_epi16(9, 3, 3, 3, 3, 3, 3, 3, 9, 3, 3, 3, 3, 3, 3, 3); let r = _mm256_blend_epi16::<0x01>(a, b); @@ -4109,7 +4246,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_blendv_epi8() { + const unsafe fn test_mm256_blendv_epi8() { let (a, b) = (_mm256_set1_epi8(4), _mm256_set1_epi8(2)); let mask = _mm256_insert_epi8::<2>(_mm256_set1_epi8(0), -1); let e = _mm256_insert_epi8::<2>(_mm256_set1_epi8(4), 2); @@ -4118,63 +4255,63 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastb_epi8() { + const unsafe fn test_mm_broadcastb_epi8() { let a = _mm_insert_epi8::<0>(_mm_set1_epi8(0x00), 0x2a); let res = _mm_broadcastb_epi8(a); assert_eq_m128i(res, _mm_set1_epi8(0x2a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastb_epi8() { + const unsafe fn test_mm256_broadcastb_epi8() { let a = _mm_insert_epi8::<0>(_mm_set1_epi8(0x00), 0x2a); let res = _mm256_broadcastb_epi8(a); assert_eq_m256i(res, _mm256_set1_epi8(0x2a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastd_epi32() { + const unsafe fn test_mm_broadcastd_epi32() { let a = _mm_setr_epi32(0x2a, 0x8000000, 0, 0); let res = _mm_broadcastd_epi32(a); assert_eq_m128i(res, _mm_set1_epi32(0x2a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastd_epi32() { + const unsafe fn test_mm256_broadcastd_epi32() { let a = _mm_setr_epi32(0x2a, 0x8000000, 0, 0); let res = _mm256_broadcastd_epi32(a); assert_eq_m256i(res, _mm256_set1_epi32(0x2a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastq_epi64() { + const unsafe fn test_mm_broadcastq_epi64() { let a = _mm_setr_epi64x(0x1ffffffff, 0); let res = _mm_broadcastq_epi64(a); assert_eq_m128i(res, _mm_set1_epi64x(0x1ffffffff)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastq_epi64() { + const unsafe fn test_mm256_broadcastq_epi64() { let a = _mm_setr_epi64x(0x1ffffffff, 0); let res = _mm256_broadcastq_epi64(a); assert_eq_m256i(res, _mm256_set1_epi64x(0x1ffffffff)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastsd_pd() { + const unsafe fn test_mm_broadcastsd_pd() { let a = _mm_setr_pd(6.88, 3.44); let res = _mm_broadcastsd_pd(a); assert_eq_m128d(res, _mm_set1_pd(6.88)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastsd_pd() { + const unsafe fn test_mm256_broadcastsd_pd() { let a = _mm_setr_pd(6.88, 3.44); let res = _mm256_broadcastsd_pd(a); assert_eq_m256d(res, _mm256_set1_pd(6.88f64)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastsi128_si256() { + const unsafe fn test_mm_broadcastsi128_si256() { let a = _mm_setr_epi64x(0x0987654321012334, 0x5678909876543210); let res = _mm_broadcastsi128_si256(a); let retval = _mm256_setr_epi64x( @@ -4187,7 +4324,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastsi128_si256() { + const unsafe fn test_mm256_broadcastsi128_si256() { let a = _mm_setr_epi64x(0x0987654321012334, 0x5678909876543210); let res = _mm256_broadcastsi128_si256(a); let retval = _mm256_setr_epi64x( @@ -4200,35 +4337,35 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastss_ps() { + const unsafe fn test_mm_broadcastss_ps() { let a = _mm_setr_ps(6.88, 3.44, 0.0, 0.0); let res = _mm_broadcastss_ps(a); assert_eq_m128(res, _mm_set1_ps(6.88)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastss_ps() { + const unsafe fn test_mm256_broadcastss_ps() { let a = _mm_setr_ps(6.88, 3.44, 0.0, 0.0); let res = _mm256_broadcastss_ps(a); assert_eq_m256(res, _mm256_set1_ps(6.88)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_broadcastw_epi16() { + const unsafe fn test_mm_broadcastw_epi16() { let a = _mm_insert_epi16::<0>(_mm_set1_epi16(0x2a), 0x22b); let res = _mm_broadcastw_epi16(a); assert_eq_m128i(res, _mm_set1_epi16(0x22b)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_broadcastw_epi16() { + const unsafe fn test_mm256_broadcastw_epi16() { let a = _mm_insert_epi16::<0>(_mm_set1_epi16(0x2a), 0x22b); let res = _mm256_broadcastw_epi16(a); assert_eq_m256i(res, _mm256_set1_epi16(0x22b)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpeq_epi8() { + const unsafe fn test_mm256_cmpeq_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4248,7 +4385,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpeq_epi16() { + const unsafe fn test_mm256_cmpeq_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4264,7 +4401,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpeq_epi32() { + const unsafe fn test_mm256_cmpeq_epi32() { let a = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_setr_epi32(7, 6, 2, 4, 3, 2, 1, 0); let r = _mm256_cmpeq_epi32(a, b); @@ -4274,7 +4411,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpeq_epi64() { + const unsafe fn test_mm256_cmpeq_epi64() { let a = _mm256_setr_epi64x(0, 1, 2, 3); let b = _mm256_setr_epi64x(3, 2, 2, 0); let r = _mm256_cmpeq_epi64(a, b); @@ -4282,7 +4419,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpgt_epi8() { + const unsafe fn test_mm256_cmpgt_epi8() { let a = _mm256_insert_epi8::<0>(_mm256_set1_epi8(0), 5); let b = _mm256_set1_epi8(0); let r = _mm256_cmpgt_epi8(a, b); @@ -4290,7 +4427,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpgt_epi16() { + const unsafe fn test_mm256_cmpgt_epi16() { let a = _mm256_insert_epi16::<0>(_mm256_set1_epi16(0), 5); let b = _mm256_set1_epi16(0); let r = _mm256_cmpgt_epi16(a, b); @@ -4298,7 +4435,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpgt_epi32() { + const unsafe fn test_mm256_cmpgt_epi32() { let a = _mm256_insert_epi32::<0>(_mm256_set1_epi32(0), 5); let b = _mm256_set1_epi32(0); let r = _mm256_cmpgt_epi32(a, b); @@ -4306,7 +4443,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cmpgt_epi64() { + const unsafe fn test_mm256_cmpgt_epi64() { let a = _mm256_insert_epi64::<0>(_mm256_set1_epi64x(0), 5); let b = _mm256_set1_epi64x(0); let r = _mm256_cmpgt_epi64(a, b); @@ -4314,7 +4451,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepi8_epi16() { + const unsafe fn test_mm256_cvtepi8_epi16() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 0, -1, 1, -2, 2, -3, 3, @@ -4329,7 +4466,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepi8_epi32() { + const unsafe fn test_mm256_cvtepi8_epi32() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 0, -1, 1, -2, 2, -3, 3, @@ -4340,7 +4477,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepi8_epi64() { + const unsafe fn test_mm256_cvtepi8_epi64() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 0, -1, 1, -2, 2, -3, 3, @@ -4351,49 +4488,49 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepi16_epi32() { + const unsafe fn test_mm256_cvtepi16_epi32() { let a = _mm_setr_epi16(0, 0, -1, 1, -2, 2, -3, 3); let r = _mm256_setr_epi32(0, 0, -1, 1, -2, 2, -3, 3); assert_eq_m256i(r, _mm256_cvtepi16_epi32(a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepi16_epi64() { + const unsafe fn test_mm256_cvtepi16_epi64() { let a = _mm_setr_epi16(0, 0, -1, 1, -2, 2, -3, 3); let r = _mm256_setr_epi64x(0, 0, -1, 1); assert_eq_m256i(r, _mm256_cvtepi16_epi64(a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepi32_epi64() { + const unsafe fn test_mm256_cvtepi32_epi64() { let a = _mm_setr_epi32(0, 0, -1, 1); let r = _mm256_setr_epi64x(0, 0, -1, 1); assert_eq_m256i(r, _mm256_cvtepi32_epi64(a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepu16_epi32() { + const unsafe fn test_mm256_cvtepu16_epi32() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7); assert_eq_m256i(r, _mm256_cvtepu16_epi32(a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepu16_epi64() { + const unsafe fn test_mm256_cvtepu16_epi64() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm256_setr_epi64x(0, 1, 2, 3); assert_eq_m256i(r, _mm256_cvtepu16_epi64(a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepu32_epi64() { + const unsafe fn test_mm256_cvtepu32_epi64() { let a = _mm_setr_epi32(0, 1, 2, 3); let r = _mm256_setr_epi64x(0, 1, 2, 3); assert_eq_m256i(r, _mm256_cvtepu32_epi64(a)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepu8_epi16() { + const unsafe fn test_mm256_cvtepu8_epi16() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4408,7 +4545,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepu8_epi32() { + const unsafe fn test_mm256_cvtepu8_epi32() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4419,7 +4556,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_cvtepu8_epi64() { + const unsafe fn test_mm256_cvtepu8_epi64() { #[rustfmt::skip] let a = _mm_setr_epi8( 0, 1, 2, 3, 4, 5, 6, 7, @@ -4430,7 +4567,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_extracti128_si256() { + const unsafe fn test_mm256_extracti128_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let r = _mm256_extracti128_si256::<1>(a); let e = _mm_setr_epi64x(3, 4); @@ -4438,7 +4575,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_hadd_epi16() { + const unsafe fn test_mm256_hadd_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_hadd_epi16(a, b); @@ -4447,7 +4584,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_hadd_epi32() { + const unsafe fn test_mm256_hadd_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_hadd_epi32(a, b); @@ -4471,7 +4608,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_hsub_epi16() { + const unsafe fn test_mm256_hsub_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_hsub_epi16(a, b); @@ -4480,7 +4617,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_hsub_epi32() { + const unsafe fn test_mm256_hsub_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_hsub_epi32(a, b); @@ -4500,7 +4637,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_madd_epi16() { + const unsafe fn test_mm256_madd_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_madd_epi16(a, b); @@ -4509,7 +4646,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_inserti128_si256() { + const unsafe fn test_mm256_inserti128_si256() { let a = _mm256_setr_epi64x(1, 2, 3, 4); let b = _mm_setr_epi64x(7, 8); let r = _mm256_inserti128_si256::<1>(a, b); @@ -4527,7 +4664,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_maskload_epi32() { + const unsafe fn test_mm_maskload_epi32() { let nums = [1, 2, 3, 4]; let a = &nums as *const i32; let mask = _mm_setr_epi32(-1, 0, 0, -1); @@ -4537,7 +4674,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_maskload_epi32() { + const unsafe fn test_mm256_maskload_epi32() { let nums = [1, 2, 3, 4, 5, 6, 7, 8]; let a = &nums as *const i32; let mask = _mm256_setr_epi32(-1, 0, 0, -1, 0, -1, -1, 0); @@ -4547,7 +4684,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_maskload_epi64() { + const unsafe fn test_mm_maskload_epi64() { let nums = [1_i64, 2_i64]; let a = &nums as *const i64; let mask = _mm_setr_epi64x(0, -1); @@ -4557,7 +4694,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_maskload_epi64() { + const unsafe fn test_mm256_maskload_epi64() { let nums = [1_i64, 2_i64, 3_i64, 4_i64]; let a = &nums as *const i64; let mask = _mm256_setr_epi64x(0, -1, -1, 0); @@ -4567,7 +4704,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_maskstore_epi32() { + const unsafe fn test_mm_maskstore_epi32() { let a = _mm_setr_epi32(1, 2, 3, 4); let mut arr = [-1, -1, -1, -1]; let mask = _mm_setr_epi32(-1, 0, 0, -1); @@ -4577,7 +4714,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_maskstore_epi32() { + const unsafe fn test_mm256_maskstore_epi32() { let a = _mm256_setr_epi32(1, 0x6d726f, 3, 42, 0x777161, 6, 7, 8); let mut arr = [-1, -1, -1, 0x776173, -1, 0x68657265, -1, -1]; let mask = _mm256_setr_epi32(-1, 0, 0, -1, 0, -1, -1, 0); @@ -4587,7 +4724,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_maskstore_epi64() { + const unsafe fn test_mm_maskstore_epi64() { let a = _mm_setr_epi64x(1_i64, 2_i64); let mut arr = [-1_i64, -1_i64]; let mask = _mm_setr_epi64x(0, -1); @@ -4597,7 +4734,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_maskstore_epi64() { + const unsafe fn test_mm256_maskstore_epi64() { let a = _mm256_setr_epi64x(1_i64, 2_i64, 3_i64, 4_i64); let mut arr = [-1_i64, -1_i64, -1_i64, -1_i64]; let mask = _mm256_setr_epi64x(0, -1, -1, 0); @@ -4607,7 +4744,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_max_epi16() { + const unsafe fn test_mm256_max_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_max_epi16(a, b); @@ -4615,7 +4752,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_max_epi32() { + const unsafe fn test_mm256_max_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_max_epi32(a, b); @@ -4623,7 +4760,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_max_epi8() { + const unsafe fn test_mm256_max_epi8() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(4); let r = _mm256_max_epi8(a, b); @@ -4631,7 +4768,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_max_epu16() { + const unsafe fn test_mm256_max_epu16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_max_epu16(a, b); @@ -4639,7 +4776,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_max_epu32() { + const unsafe fn test_mm256_max_epu32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_max_epu32(a, b); @@ -4647,7 +4784,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_max_epu8() { + const unsafe fn test_mm256_max_epu8() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(4); let r = _mm256_max_epu8(a, b); @@ -4655,7 +4792,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_min_epi16() { + const unsafe fn test_mm256_min_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_min_epi16(a, b); @@ -4663,7 +4800,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_min_epi32() { + const unsafe fn test_mm256_min_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_min_epi32(a, b); @@ -4671,7 +4808,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_min_epi8() { + const unsafe fn test_mm256_min_epi8() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(4); let r = _mm256_min_epi8(a, b); @@ -4679,7 +4816,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_min_epu16() { + const unsafe fn test_mm256_min_epu16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_min_epu16(a, b); @@ -4687,7 +4824,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_min_epu32() { + const unsafe fn test_mm256_min_epu32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_min_epu32(a, b); @@ -4695,7 +4832,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_min_epu8() { + const unsafe fn test_mm256_min_epu8() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(4); let r = _mm256_min_epu8(a, b); @@ -4703,7 +4840,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_movemask_epi8() { + const unsafe fn test_mm256_movemask_epi8() { let a = _mm256_set1_epi8(-1); let r = _mm256_movemask_epi8(a); let e = -1; @@ -4720,7 +4857,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_mul_epi32() { + const unsafe fn test_mm256_mul_epi32() { let a = _mm256_setr_epi32(0, 0, 0, 0, 2, 2, 2, 2); let b = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_mul_epi32(a, b); @@ -4729,7 +4866,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_mul_epu32() { + const unsafe fn test_mm256_mul_epu32() { let a = _mm256_setr_epi32(0, 0, 0, 0, 2, 2, 2, 2); let b = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_mul_epu32(a, b); @@ -4738,7 +4875,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_mulhi_epi16() { + const unsafe fn test_mm256_mulhi_epi16() { let a = _mm256_set1_epi16(6535); let b = _mm256_set1_epi16(6535); let r = _mm256_mulhi_epi16(a, b); @@ -4747,7 +4884,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_mulhi_epu16() { + const unsafe fn test_mm256_mulhi_epu16() { let a = _mm256_set1_epi16(6535); let b = _mm256_set1_epi16(6535); let r = _mm256_mulhi_epu16(a, b); @@ -4756,7 +4893,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_mullo_epi16() { + const unsafe fn test_mm256_mullo_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(4); let r = _mm256_mullo_epi16(a, b); @@ -4765,7 +4902,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_mullo_epi32() { + const unsafe fn test_mm256_mullo_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(4); let r = _mm256_mullo_epi32(a, b); @@ -4783,7 +4920,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_or_si256() { + const unsafe fn test_mm256_or_si256() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(0); let r = _mm256_or_si256(a, b); @@ -4852,7 +4989,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_shufflehi_epi16() { + const unsafe fn test_mm256_shufflehi_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 0, 1, 2, 3, 11, 22, 33, 44, @@ -4868,7 +5005,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_shufflelo_epi16() { + const unsafe fn test_mm256_shufflelo_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( 11, 22, 33, 44, 0, 1, 2, 3, @@ -4935,7 +5072,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_slli_epi16() { + const unsafe fn test_mm256_slli_epi16() { assert_eq_m256i( _mm256_slli_epi16::<4>(_mm256_set1_epi16(0xFF)), _mm256_set1_epi16(0xFF0), @@ -4943,7 +5080,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_slli_epi32() { + const unsafe fn test_mm256_slli_epi32() { assert_eq_m256i( _mm256_slli_epi32::<4>(_mm256_set1_epi32(0xFFFF)), _mm256_set1_epi32(0xFFFF0), @@ -4951,7 +5088,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_slli_epi64() { + const unsafe fn test_mm256_slli_epi64() { assert_eq_m256i( _mm256_slli_epi64::<4>(_mm256_set1_epi64x(0xFFFFFFFF)), _mm256_set1_epi64x(0xFFFFFFFF0), @@ -4959,14 +5096,14 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_slli_si256() { + const unsafe fn test_mm256_slli_si256() { let a = _mm256_set1_epi64x(0xFFFFFFFF); let r = _mm256_slli_si256::<3>(a); assert_eq_m256i(r, _mm256_set1_epi64x(0xFFFFFFFF000000)); } #[simd_test(enable = "avx2")] - unsafe fn test_mm_sllv_epi32() { + const unsafe fn test_mm_sllv_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(1); let r = _mm_sllv_epi32(a, b); @@ -4975,7 +5112,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_sllv_epi32() { + const unsafe fn test_mm256_sllv_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(1); let r = _mm256_sllv_epi32(a, b); @@ -4984,7 +5121,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_sllv_epi64() { + const unsafe fn test_mm_sllv_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(1); let r = _mm_sllv_epi64(a, b); @@ -4993,7 +5130,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_sllv_epi64() { + const unsafe fn test_mm256_sllv_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(1); let r = _mm256_sllv_epi64(a, b); @@ -5018,7 +5155,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srai_epi16() { + const unsafe fn test_mm256_srai_epi16() { assert_eq_m256i( _mm256_srai_epi16::<1>(_mm256_set1_epi16(-1)), _mm256_set1_epi16(-1), @@ -5026,7 +5163,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srai_epi32() { + const unsafe fn test_mm256_srai_epi32() { assert_eq_m256i( _mm256_srai_epi32::<1>(_mm256_set1_epi32(-1)), _mm256_set1_epi32(-1), @@ -5034,7 +5171,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_srav_epi32() { + const unsafe fn test_mm_srav_epi32() { let a = _mm_set1_epi32(4); let count = _mm_set1_epi32(1); let r = _mm_srav_epi32(a, count); @@ -5043,7 +5180,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srav_epi32() { + const unsafe fn test_mm256_srav_epi32() { let a = _mm256_set1_epi32(4); let count = _mm256_set1_epi32(1); let r = _mm256_srav_epi32(a, count); @@ -5052,7 +5189,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srli_si256() { + const unsafe fn test_mm256_srli_si256() { #[rustfmt::skip] let a = _mm256_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -5096,7 +5233,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srli_epi16() { + const unsafe fn test_mm256_srli_epi16() { assert_eq_m256i( _mm256_srli_epi16::<4>(_mm256_set1_epi16(0xFF)), _mm256_set1_epi16(0xF), @@ -5104,7 +5241,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srli_epi32() { + const unsafe fn test_mm256_srli_epi32() { assert_eq_m256i( _mm256_srli_epi32::<4>(_mm256_set1_epi32(0xFFFF)), _mm256_set1_epi32(0xFFF), @@ -5112,7 +5249,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srli_epi64() { + const unsafe fn test_mm256_srli_epi64() { assert_eq_m256i( _mm256_srli_epi64::<4>(_mm256_set1_epi64x(0xFFFFFFFF)), _mm256_set1_epi64x(0xFFFFFFF), @@ -5120,7 +5257,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_srlv_epi32() { + const unsafe fn test_mm_srlv_epi32() { let a = _mm_set1_epi32(2); let count = _mm_set1_epi32(1); let r = _mm_srlv_epi32(a, count); @@ -5129,7 +5266,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srlv_epi32() { + const unsafe fn test_mm256_srlv_epi32() { let a = _mm256_set1_epi32(2); let count = _mm256_set1_epi32(1); let r = _mm256_srlv_epi32(a, count); @@ -5138,7 +5275,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm_srlv_epi64() { + const unsafe fn test_mm_srlv_epi64() { let a = _mm_set1_epi64x(2); let count = _mm_set1_epi64x(1); let r = _mm_srlv_epi64(a, count); @@ -5147,7 +5284,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_srlv_epi64() { + const unsafe fn test_mm256_srlv_epi64() { let a = _mm256_set1_epi64x(2); let count = _mm256_set1_epi64x(1); let r = _mm256_srlv_epi64(a, count); @@ -5163,7 +5300,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_sub_epi16() { + const unsafe fn test_mm256_sub_epi16() { let a = _mm256_set1_epi16(4); let b = _mm256_set1_epi16(2); let r = _mm256_sub_epi16(a, b); @@ -5171,7 +5308,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_sub_epi32() { + const unsafe fn test_mm256_sub_epi32() { let a = _mm256_set1_epi32(4); let b = _mm256_set1_epi32(2); let r = _mm256_sub_epi32(a, b); @@ -5179,7 +5316,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_sub_epi64() { + const unsafe fn test_mm256_sub_epi64() { let a = _mm256_set1_epi64x(4); let b = _mm256_set1_epi64x(2); let r = _mm256_sub_epi64(a, b); @@ -5187,7 +5324,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_sub_epi8() { + const unsafe fn test_mm256_sub_epi8() { let a = _mm256_set1_epi8(4); let b = _mm256_set1_epi8(2); let r = _mm256_sub_epi8(a, b); @@ -5195,7 +5332,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_subs_epi16() { + const unsafe fn test_mm256_subs_epi16() { let a = _mm256_set1_epi16(4); let b = _mm256_set1_epi16(2); let r = _mm256_subs_epi16(a, b); @@ -5203,7 +5340,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_subs_epi8() { + const unsafe fn test_mm256_subs_epi8() { let a = _mm256_set1_epi8(4); let b = _mm256_set1_epi8(2); let r = _mm256_subs_epi8(a, b); @@ -5211,7 +5348,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_subs_epu16() { + const unsafe fn test_mm256_subs_epu16() { let a = _mm256_set1_epi16(4); let b = _mm256_set1_epi16(2); let r = _mm256_subs_epu16(a, b); @@ -5219,7 +5356,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_subs_epu8() { + const unsafe fn test_mm256_subs_epu8() { let a = _mm256_set1_epi8(4); let b = _mm256_set1_epi8(2); let r = _mm256_subs_epu8(a, b); @@ -5227,7 +5364,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_xor_si256() { + const unsafe fn test_mm256_xor_si256() { let a = _mm256_set1_epi8(5); let b = _mm256_set1_epi8(3); let r = _mm256_xor_si256(a, b); @@ -5235,7 +5372,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_alignr_epi8() { + const unsafe fn test_mm256_alignr_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, @@ -5327,7 +5464,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_permute4x64_epi64() { + const unsafe fn test_mm256_permute4x64_epi64() { let a = _mm256_setr_epi64x(100, 200, 300, 400); let expected = _mm256_setr_epi64x(400, 100, 200, 100); let r = _mm256_permute4x64_epi64::<0b00010011>(a); @@ -5335,7 +5472,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_permute2x128_si256() { + const unsafe fn test_mm256_permute2x128_si256() { let a = _mm256_setr_epi64x(100, 200, 500, 600); let b = _mm256_setr_epi64x(300, 400, 700, 800); let r = _mm256_permute2x128_si256::<0b00_01_00_11>(a, b); @@ -5344,7 +5481,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_permute4x64_pd() { + const unsafe fn test_mm256_permute4x64_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let r = _mm256_permute4x64_pd::<0b00_01_00_11>(a); let e = _mm256_setr_pd(4., 1., 2., 1.); @@ -5702,7 +5839,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_extract_epi8() { + const unsafe fn test_mm256_extract_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( -1, 1, 2, 3, 4, 5, 6, 7, @@ -5717,7 +5854,7 @@ mod tests { } #[simd_test(enable = "avx2")] - unsafe fn test_mm256_extract_epi16() { + const unsafe fn test_mm256_extract_epi16() { #[rustfmt::skip] let a = _mm256_setr_epi16( -1, 1, 2, 3, 4, 5, 6, 7, From 5b046698643bf47790e8a540b010f52a911b59c7 Mon Sep 17 00:00:00 2001 From: sayantn Date: Wed, 1 Oct 2025 11:31:19 +0530 Subject: [PATCH 067/489] Make `fma` functions const --- .../stdarch/crates/core_arch/src/x86/fma.rs | 161 +++++++++++------- 1 file changed, 97 insertions(+), 64 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/fma.rs b/library/stdarch/crates/core_arch/src/x86/fma.rs index d3988422b9a4..abf79f4904fe 100644 --- a/library/stdarch/crates/core_arch/src/x86/fma.rs +++ b/library/stdarch/crates/core_arch/src/x86/fma.rs @@ -33,7 +33,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_fma(a, b, c) } } @@ -45,7 +46,8 @@ pub fn _mm_fmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_fma(a, b, c) } } @@ -57,7 +59,8 @@ pub fn _mm256_fmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_fma(a, b, c) } } @@ -69,7 +72,8 @@ pub fn _mm_fmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_fma(a, b, c) } } @@ -83,7 +87,8 @@ pub fn _mm256_fmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_insert!( a, @@ -103,7 +108,8 @@ pub fn _mm_fmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_insert!( a, @@ -122,7 +128,8 @@ pub fn _mm_fmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -139,7 +146,8 @@ pub fn _mm_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -156,7 +164,8 @@ pub fn _mm256_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmaddsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmaddsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -173,7 +182,8 @@ pub fn _mm_fmaddsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmaddsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmaddsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -189,7 +199,8 @@ pub fn _mm256_fmaddsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -201,7 +212,8 @@ pub fn _mm_fmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -213,7 +225,8 @@ pub fn _mm256_fmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsub213ps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -225,7 +238,8 @@ pub fn _mm_fmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsub213ps))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -239,7 +253,8 @@ pub fn _mm256_fmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_insert!( a, @@ -259,7 +274,8 @@ pub fn _mm_fmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_insert!( a, @@ -278,7 +294,8 @@ pub fn _mm_fmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -295,7 +312,8 @@ pub fn _mm_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -312,7 +330,8 @@ pub fn _mm256_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fmsubadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsubadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -329,7 +348,8 @@ pub fn _mm_fmsubadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fmsubadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmsubadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -345,7 +365,8 @@ pub fn _mm256_fmsubadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -357,7 +378,8 @@ pub fn _mm_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -369,7 +391,8 @@ pub fn _mm256_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -381,7 +404,8 @@ pub fn _mm_fnmadd_ps(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fnmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fnmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -395,7 +419,8 @@ pub fn _mm256_fnmadd_ps(a: __m256, b: __m256, c: __m256) -> __m256 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_insert!( a, @@ -415,7 +440,8 @@ pub fn _mm_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmadd))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_insert!( a, @@ -434,7 +460,8 @@ pub fn _mm_fnmadd_ss(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -447,7 +474,8 @@ pub fn _mm_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -460,7 +488,8 @@ pub fn _mm256_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -473,7 +502,8 @@ pub fn _mm_fnmsub_ps(a: __m128, b: __m128, c: __m128) -> __m128 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm256_fnmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fnmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -488,7 +518,8 @@ pub fn _mm256_fnmsub_ps(a: __m256, b: __m256, c: __m256) -> __m256 { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_insert!( a, @@ -509,7 +540,8 @@ pub fn _mm_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d) -> __m128d { #[target_feature(enable = "fma")] #[cfg_attr(test, assert_instr(vfnmsub))] #[stable(feature = "simd_x86", since = "1.27.0")] -pub fn _mm_fnmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_insert!( a, @@ -521,13 +553,14 @@ pub fn _mm_fnmsub_ss(a: __m128, b: __m128, c: __m128) -> __m128 { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "fma")] - unsafe fn test_mm_fmadd_pd() { + const unsafe fn test_mm_fmadd_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -536,7 +569,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmadd_pd() { + const unsafe fn test_mm256_fmadd_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 3., 7., 2.); let c = _mm256_setr_pd(4., 9., 1., 7.); @@ -545,7 +578,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmadd_ps() { + const unsafe fn test_mm_fmadd_ps() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -554,7 +587,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmadd_ps() { + const unsafe fn test_mm256_fmadd_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 0., 10., -1., -2.); let b = _mm256_setr_ps(5., 3., 7., 2., 4., -6., 0., 14.); let c = _mm256_setr_ps(4., 9., 1., 7., -5., 11., -2., -3.); @@ -563,7 +596,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmadd_sd() { + const unsafe fn test_mm_fmadd_sd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -572,7 +605,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmadd_ss() { + const unsafe fn test_mm_fmadd_ss() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -581,7 +614,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmaddsub_pd() { + const unsafe fn test_mm_fmaddsub_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -590,7 +623,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmaddsub_pd() { + const unsafe fn test_mm256_fmaddsub_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 3., 7., 2.); let c = _mm256_setr_pd(4., 9., 1., 7.); @@ -599,7 +632,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmaddsub_ps() { + const unsafe fn test_mm_fmaddsub_ps() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -608,7 +641,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmaddsub_ps() { + const unsafe fn test_mm256_fmaddsub_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 0., 10., -1., -2.); let b = _mm256_setr_ps(5., 3., 7., 2., 4., -6., 0., 14.); let c = _mm256_setr_ps(4., 9., 1., 7., -5., 11., -2., -3.); @@ -617,7 +650,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmsub_pd() { + const unsafe fn test_mm_fmsub_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -626,7 +659,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmsub_pd() { + const unsafe fn test_mm256_fmsub_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 3., 7., 2.); let c = _mm256_setr_pd(4., 9., 1., 7.); @@ -635,7 +668,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmsub_ps() { + const unsafe fn test_mm_fmsub_ps() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -644,7 +677,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmsub_ps() { + const unsafe fn test_mm256_fmsub_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 0., 10., -1., -2.); let b = _mm256_setr_ps(5., 3., 7., 2., 4., -6., 0., 14.); let c = _mm256_setr_ps(4., 9., 1., 7., -5., 11., -2., -3.); @@ -653,7 +686,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmsub_sd() { + const unsafe fn test_mm_fmsub_sd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -662,7 +695,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmsub_ss() { + const unsafe fn test_mm_fmsub_ss() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -671,7 +704,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmsubadd_pd() { + const unsafe fn test_mm_fmsubadd_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -680,7 +713,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmsubadd_pd() { + const unsafe fn test_mm256_fmsubadd_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 3., 7., 2.); let c = _mm256_setr_pd(4., 9., 1., 7.); @@ -689,7 +722,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fmsubadd_ps() { + const unsafe fn test_mm_fmsubadd_ps() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -698,7 +731,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fmsubadd_ps() { + const unsafe fn test_mm256_fmsubadd_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 0., 10., -1., -2.); let b = _mm256_setr_ps(5., 3., 7., 2., 4., -6., 0., 14.); let c = _mm256_setr_ps(4., 9., 1., 7., -5., 11., -2., -3.); @@ -707,7 +740,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmadd_pd() { + const unsafe fn test_mm_fnmadd_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -716,7 +749,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fnmadd_pd() { + const unsafe fn test_mm256_fnmadd_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 3., 7., 2.); let c = _mm256_setr_pd(4., 9., 1., 7.); @@ -725,7 +758,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmadd_ps() { + const unsafe fn test_mm_fnmadd_ps() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -734,7 +767,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fnmadd_ps() { + const unsafe fn test_mm256_fnmadd_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 0., 10., -1., -2.); let b = _mm256_setr_ps(5., 3., 7., 2., 4., -6., 0., 14.); let c = _mm256_setr_ps(4., 9., 1., 7., -5., 11., -2., -3.); @@ -743,7 +776,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmadd_sd() { + const unsafe fn test_mm_fnmadd_sd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -752,7 +785,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmadd_ss() { + const unsafe fn test_mm_fnmadd_ss() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -761,7 +794,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmsub_pd() { + const unsafe fn test_mm_fnmsub_pd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -770,7 +803,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fnmsub_pd() { + const unsafe fn test_mm256_fnmsub_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 3., 7., 2.); let c = _mm256_setr_pd(4., 9., 1., 7.); @@ -779,7 +812,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmsub_ps() { + const unsafe fn test_mm_fnmsub_ps() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); @@ -788,7 +821,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm256_fnmsub_ps() { + const unsafe fn test_mm256_fnmsub_ps() { let a = _mm256_setr_ps(1., 2., 3., 4., 0., 10., -1., -2.); let b = _mm256_setr_ps(5., 3., 7., 2., 4., -6., 0., 14.); let c = _mm256_setr_ps(4., 9., 1., 7., -5., 11., -2., -3.); @@ -797,7 +830,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmsub_sd() { + const unsafe fn test_mm_fnmsub_sd() { let a = _mm_setr_pd(1., 2.); let b = _mm_setr_pd(5., 3.); let c = _mm_setr_pd(4., 9.); @@ -806,7 +839,7 @@ mod tests { } #[simd_test(enable = "fma")] - unsafe fn test_mm_fnmsub_ss() { + const unsafe fn test_mm_fnmsub_ss() { let a = _mm_setr_ps(1., 2., 3., 4.); let b = _mm_setr_ps(5., 3., 7., 2.); let c = _mm_setr_ps(4., 9., 1., 7.); From df6119fd3e92ed9fafdbe9f355804d09270aeedb Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:11:28 +0530 Subject: [PATCH 068/489] Make `avx512f` functions const --- .../crates/core_arch/src/x86/avx512f.rs | 6306 +++++++++++------ .../crates/core_arch/src/x86_64/avx512f.rs | 1305 ++-- 2 files changed, 4751 insertions(+), 2860 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index d6b30d2d7d86..f300bf48ef6d 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -17,7 +17,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm512_abs_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_epi32(a: __m512i) -> __m512i { unsafe { let a = a.as_i32x16(); let r = simd_select::(simd_lt(a, i32x16::ZERO), simd_neg(a), a); @@ -34,7 +35,8 @@ pub fn _mm512_abs_epi32(a: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm512_mask_abs_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_abs_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, abs, src.as_i32x16())) @@ -50,7 +52,8 @@ pub fn _mm512_mask_abs_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm512_maskz_abs_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_abs_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, abs, i32x16::ZERO)) @@ -64,7 +67,8 @@ pub fn _mm512_maskz_abs_epi32(k: __mmask16, a: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm256_mask_abs_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_abs_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, abs, src.as_i32x8())) @@ -78,7 +82,8 @@ pub fn _mm256_mask_abs_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm256_maskz_abs_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_abs_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, abs, i32x8::ZERO)) @@ -92,7 +97,8 @@ pub fn _mm256_maskz_abs_epi32(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm_mask_abs_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_abs_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, abs, src.as_i32x4())) @@ -106,7 +112,8 @@ pub fn _mm_mask_abs_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsd))] -pub fn _mm_maskz_abs_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_abs_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, abs, i32x4::ZERO)) @@ -120,7 +127,8 @@ pub fn _mm_maskz_abs_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm512_abs_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_epi64(a: __m512i) -> __m512i { unsafe { let a = a.as_i64x8(); let r = simd_select::(simd_lt(a, i64x8::ZERO), simd_neg(a), a); @@ -135,7 +143,8 @@ pub fn _mm512_abs_epi64(a: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm512_mask_abs_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_abs_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, abs, src.as_i64x8())) @@ -149,7 +158,8 @@ pub fn _mm512_mask_abs_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm512_maskz_abs_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_abs_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, abs, i64x8::ZERO)) @@ -163,7 +173,8 @@ pub fn _mm512_maskz_abs_epi64(k: __mmask8, a: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm256_abs_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_abs_epi64(a: __m256i) -> __m256i { unsafe { let a = a.as_i64x4(); let r = simd_select::(simd_lt(a, i64x4::ZERO), simd_neg(a), a); @@ -178,7 +189,8 @@ pub fn _mm256_abs_epi64(a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm256_mask_abs_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_abs_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, abs, src.as_i64x4())) @@ -192,7 +204,8 @@ pub fn _mm256_mask_abs_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm256_maskz_abs_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_abs_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, abs, i64x4::ZERO)) @@ -206,7 +219,8 @@ pub fn _mm256_maskz_abs_epi64(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm_abs_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_abs_epi64(a: __m128i) -> __m128i { unsafe { let a = a.as_i64x2(); let r = simd_select::(simd_lt(a, i64x2::ZERO), simd_neg(a), a); @@ -221,7 +235,8 @@ pub fn _mm_abs_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm_mask_abs_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_abs_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, abs, src.as_i64x2())) @@ -235,7 +250,8 @@ pub fn _mm_mask_abs_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsq))] -pub fn _mm_maskz_abs_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_abs_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, abs, i64x2::ZERO)) @@ -249,7 +265,8 @@ pub fn _mm_maskz_abs_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm512_abs_ps(v2: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_ps(v2: __m512) -> __m512 { unsafe { simd_fabs(v2) } } @@ -260,7 +277,8 @@ pub fn _mm512_abs_ps(v2: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm512_mask_abs_ps(src: __m512, k: __mmask16, v2: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_abs_ps(src: __m512, k: __mmask16, v2: __m512) -> __m512 { unsafe { simd_select_bitmask(k, simd_fabs(v2), src) } } @@ -271,7 +289,8 @@ pub fn _mm512_mask_abs_ps(src: __m512, k: __mmask16, v2: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm512_abs_pd(v2: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_pd(v2: __m512d) -> __m512d { unsafe { simd_fabs(v2) } } @@ -282,7 +301,8 @@ pub fn _mm512_abs_pd(v2: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm512_mask_abs_pd(src: __m512d, k: __mmask8, v2: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_abs_pd(src: __m512d, k: __mmask8, v2: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, simd_fabs(v2), src) } } @@ -293,7 +313,8 @@ pub fn _mm512_mask_abs_pd(src: __m512d, k: __mmask8, v2: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] -pub fn _mm512_mask_mov_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mov_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { unsafe { let mov = a.as_i32x16(); transmute(simd_select_bitmask(k, mov, src.as_i32x16())) @@ -307,7 +328,8 @@ pub fn _mm512_mask_mov_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] -pub fn _mm512_maskz_mov_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mov_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { let mov = a.as_i32x16(); transmute(simd_select_bitmask(k, mov, i32x16::ZERO)) @@ -321,7 +343,8 @@ pub fn _mm512_maskz_mov_epi32(k: __mmask16, a: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] -pub fn _mm256_mask_mov_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mov_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { let mov = a.as_i32x8(); transmute(simd_select_bitmask(k, mov, src.as_i32x8())) @@ -335,7 +358,8 @@ pub fn _mm256_mask_mov_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] -pub fn _mm256_maskz_mov_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mov_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { let mov = a.as_i32x8(); transmute(simd_select_bitmask(k, mov, i32x8::ZERO)) @@ -349,7 +373,8 @@ pub fn _mm256_maskz_mov_epi32(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] -pub fn _mm_mask_mov_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mov_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let mov = a.as_i32x4(); transmute(simd_select_bitmask(k, mov, src.as_i32x4())) @@ -363,7 +388,8 @@ pub fn _mm_mask_mov_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] -pub fn _mm_maskz_mov_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mov_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let mov = a.as_i32x4(); transmute(simd_select_bitmask(k, mov, i32x4::ZERO)) @@ -377,7 +403,8 @@ pub fn _mm_maskz_mov_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] -pub fn _mm512_mask_mov_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mov_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { unsafe { let mov = a.as_i64x8(); transmute(simd_select_bitmask(k, mov, src.as_i64x8())) @@ -391,7 +418,8 @@ pub fn _mm512_mask_mov_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] -pub fn _mm512_maskz_mov_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mov_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { let mov = a.as_i64x8(); transmute(simd_select_bitmask(k, mov, i64x8::ZERO)) @@ -405,7 +433,8 @@ pub fn _mm512_maskz_mov_epi64(k: __mmask8, a: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] -pub fn _mm256_mask_mov_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mov_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { let mov = a.as_i64x4(); transmute(simd_select_bitmask(k, mov, src.as_i64x4())) @@ -419,7 +448,8 @@ pub fn _mm256_mask_mov_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] -pub fn _mm256_maskz_mov_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mov_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { let mov = a.as_i64x4(); transmute(simd_select_bitmask(k, mov, i64x4::ZERO)) @@ -433,7 +463,8 @@ pub fn _mm256_maskz_mov_epi64(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] -pub fn _mm_mask_mov_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mov_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let mov = a.as_i64x2(); transmute(simd_select_bitmask(k, mov, src.as_i64x2())) @@ -447,7 +478,8 @@ pub fn _mm_mask_mov_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] -pub fn _mm_maskz_mov_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mov_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let mov = a.as_i64x2(); transmute(simd_select_bitmask(k, mov, i64x2::ZERO)) @@ -461,7 +493,8 @@ pub fn _mm_maskz_mov_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] -pub fn _mm512_mask_mov_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mov_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { unsafe { let mov = a.as_f32x16(); transmute(simd_select_bitmask(k, mov, src.as_f32x16())) @@ -475,7 +508,8 @@ pub fn _mm512_mask_mov_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] -pub fn _mm512_maskz_mov_ps(k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mov_ps(k: __mmask16, a: __m512) -> __m512 { unsafe { let mov = a.as_f32x16(); transmute(simd_select_bitmask(k, mov, f32x16::ZERO)) @@ -489,7 +523,8 @@ pub fn _mm512_maskz_mov_ps(k: __mmask16, a: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] -pub fn _mm256_mask_mov_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mov_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { unsafe { let mov = a.as_f32x8(); transmute(simd_select_bitmask(k, mov, src.as_f32x8())) @@ -503,7 +538,8 @@ pub fn _mm256_mask_mov_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] -pub fn _mm256_maskz_mov_ps(k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mov_ps(k: __mmask8, a: __m256) -> __m256 { unsafe { let mov = a.as_f32x8(); transmute(simd_select_bitmask(k, mov, f32x8::ZERO)) @@ -517,7 +553,8 @@ pub fn _mm256_maskz_mov_ps(k: __mmask8, a: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] -pub fn _mm_mask_mov_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mov_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { unsafe { let mov = a.as_f32x4(); transmute(simd_select_bitmask(k, mov, src.as_f32x4())) @@ -531,7 +568,8 @@ pub fn _mm_mask_mov_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] -pub fn _mm_maskz_mov_ps(k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mov_ps(k: __mmask8, a: __m128) -> __m128 { unsafe { let mov = a.as_f32x4(); transmute(simd_select_bitmask(k, mov, f32x4::ZERO)) @@ -545,7 +583,8 @@ pub fn _mm_maskz_mov_ps(k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] -pub fn _mm512_mask_mov_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mov_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { unsafe { let mov = a.as_f64x8(); transmute(simd_select_bitmask(k, mov, src.as_f64x8())) @@ -559,7 +598,8 @@ pub fn _mm512_mask_mov_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] -pub fn _mm512_maskz_mov_pd(k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mov_pd(k: __mmask8, a: __m512d) -> __m512d { unsafe { let mov = a.as_f64x8(); transmute(simd_select_bitmask(k, mov, f64x8::ZERO)) @@ -573,7 +613,8 @@ pub fn _mm512_maskz_mov_pd(k: __mmask8, a: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] -pub fn _mm256_mask_mov_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mov_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { unsafe { let mov = a.as_f64x4(); transmute(simd_select_bitmask(k, mov, src.as_f64x4())) @@ -587,7 +628,8 @@ pub fn _mm256_mask_mov_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] -pub fn _mm256_maskz_mov_pd(k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mov_pd(k: __mmask8, a: __m256d) -> __m256d { unsafe { let mov = a.as_f64x4(); transmute(simd_select_bitmask(k, mov, f64x4::ZERO)) @@ -601,7 +643,8 @@ pub fn _mm256_maskz_mov_pd(k: __mmask8, a: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] -pub fn _mm_mask_mov_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mov_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { unsafe { let mov = a.as_f64x2(); transmute(simd_select_bitmask(k, mov, src.as_f64x2())) @@ -615,7 +658,8 @@ pub fn _mm_mask_mov_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] -pub fn _mm_maskz_mov_pd(k: __mmask8, a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mov_pd(k: __mmask8, a: __m128d) -> __m128d { unsafe { let mov = a.as_f64x2(); transmute(simd_select_bitmask(k, mov, f64x2::ZERO)) @@ -629,7 +673,8 @@ pub fn _mm_maskz_mov_pd(k: __mmask8, a: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm512_add_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_add(a.as_i32x16(), b.as_i32x16())) } } @@ -640,7 +685,8 @@ pub fn _mm512_add_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm512_mask_add_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, add, src.as_i32x16())) @@ -654,7 +700,8 @@ pub fn _mm512_mask_add_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm512_maskz_add_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, add, i32x16::ZERO)) @@ -668,7 +715,8 @@ pub fn _mm512_maskz_add_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm256_mask_add_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, add, src.as_i32x8())) @@ -682,7 +730,8 @@ pub fn _mm256_mask_add_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm256_maskz_add_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, add, i32x8::ZERO)) @@ -696,7 +745,8 @@ pub fn _mm256_maskz_add_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm_mask_add_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, add, src.as_i32x4())) @@ -710,7 +760,8 @@ pub fn _mm_mask_add_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddd))] -pub fn _mm_maskz_add_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, add, i32x4::ZERO)) @@ -724,7 +775,8 @@ pub fn _mm_maskz_add_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm512_add_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_add(a.as_i64x8(), b.as_i64x8())) } } @@ -735,7 +787,8 @@ pub fn _mm512_add_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm512_mask_add_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, add, src.as_i64x8())) @@ -749,7 +802,8 @@ pub fn _mm512_mask_add_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm512_maskz_add_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, add, i64x8::ZERO)) @@ -763,7 +817,8 @@ pub fn _mm512_maskz_add_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm256_mask_add_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, add, src.as_i64x4())) @@ -777,7 +832,8 @@ pub fn _mm256_mask_add_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm256_maskz_add_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, add, i64x4::ZERO)) @@ -791,7 +847,8 @@ pub fn _mm256_maskz_add_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm_mask_add_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, add, src.as_i64x2())) @@ -805,7 +862,8 @@ pub fn _mm_mask_add_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddq))] -pub fn _mm_maskz_add_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, add, i64x2::ZERO)) @@ -819,7 +877,8 @@ pub fn _mm_maskz_add_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm512_add_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_add(a.as_f32x16(), b.as_f32x16())) } } @@ -830,7 +889,8 @@ pub fn _mm512_add_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm512_mask_add_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let add = _mm512_add_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, add, src.as_f32x16())) @@ -844,7 +904,8 @@ pub fn _mm512_mask_add_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm512_maskz_add_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let add = _mm512_add_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, add, f32x16::ZERO)) @@ -858,7 +919,8 @@ pub fn _mm512_maskz_add_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm256_mask_add_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let add = _mm256_add_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, add, src.as_f32x8())) @@ -872,7 +934,8 @@ pub fn _mm256_mask_add_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm256_maskz_add_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let add = _mm256_add_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, add, f32x8::ZERO)) @@ -886,7 +949,8 @@ pub fn _mm256_maskz_add_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm_mask_add_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let add = _mm_add_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, add, src.as_f32x4())) @@ -900,7 +964,8 @@ pub fn _mm_mask_add_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddps))] -pub fn _mm_maskz_add_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let add = _mm_add_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, add, f32x4::ZERO)) @@ -914,7 +979,8 @@ pub fn _mm_maskz_add_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm512_add_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_add(a.as_f64x8(), b.as_f64x8())) } } @@ -925,7 +991,8 @@ pub fn _mm512_add_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm512_mask_add_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let add = _mm512_add_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, add, src.as_f64x8())) @@ -939,7 +1006,8 @@ pub fn _mm512_mask_add_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm512_maskz_add_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let add = _mm512_add_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, add, f64x8::ZERO)) @@ -953,7 +1021,8 @@ pub fn _mm512_maskz_add_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm256_mask_add_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let add = _mm256_add_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, add, src.as_f64x4())) @@ -967,7 +1036,8 @@ pub fn _mm256_mask_add_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm256_maskz_add_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let add = _mm256_add_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, add, f64x4::ZERO)) @@ -981,7 +1051,8 @@ pub fn _mm256_maskz_add_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm_mask_add_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let add = _mm_add_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, add, src.as_f64x2())) @@ -995,7 +1066,8 @@ pub fn _mm_mask_add_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddpd))] -pub fn _mm_maskz_add_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let add = _mm_add_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, add, f64x2::ZERO)) @@ -1009,7 +1081,8 @@ pub fn _mm_maskz_add_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm512_sub_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_sub(a.as_i32x16(), b.as_i32x16())) } } @@ -1020,7 +1093,8 @@ pub fn _mm512_sub_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm512_mask_sub_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, sub, src.as_i32x16())) @@ -1034,7 +1108,8 @@ pub fn _mm512_mask_sub_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm512_maskz_sub_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, sub, i32x16::ZERO)) @@ -1048,7 +1123,8 @@ pub fn _mm512_maskz_sub_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm256_mask_sub_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, sub, src.as_i32x8())) @@ -1062,7 +1138,8 @@ pub fn _mm256_mask_sub_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm256_maskz_sub_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, sub, i32x8::ZERO)) @@ -1076,7 +1153,8 @@ pub fn _mm256_maskz_sub_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm_mask_sub_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, sub, src.as_i32x4())) @@ -1090,7 +1168,8 @@ pub fn _mm_mask_sub_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubd))] -pub fn _mm_maskz_sub_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, sub, i32x4::ZERO)) @@ -1104,7 +1183,8 @@ pub fn _mm_maskz_sub_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm512_sub_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_sub(a.as_i64x8(), b.as_i64x8())) } } @@ -1115,7 +1195,8 @@ pub fn _mm512_sub_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm512_mask_sub_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, sub, src.as_i64x8())) @@ -1129,7 +1210,8 @@ pub fn _mm512_mask_sub_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm512_maskz_sub_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, sub, i64x8::ZERO)) @@ -1143,7 +1225,8 @@ pub fn _mm512_maskz_sub_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm256_mask_sub_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, sub, src.as_i64x4())) @@ -1157,7 +1240,8 @@ pub fn _mm256_mask_sub_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm256_maskz_sub_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, sub, i64x4::ZERO)) @@ -1171,7 +1255,8 @@ pub fn _mm256_maskz_sub_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm_mask_sub_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, sub, src.as_i64x2())) @@ -1185,7 +1270,8 @@ pub fn _mm_mask_sub_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubq))] -pub fn _mm_maskz_sub_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, sub, i64x2::ZERO)) @@ -1199,7 +1285,8 @@ pub fn _mm_maskz_sub_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm512_sub_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_sub(a.as_f32x16(), b.as_f32x16())) } } @@ -1210,7 +1297,8 @@ pub fn _mm512_sub_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm512_mask_sub_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let sub = _mm512_sub_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, sub, src.as_f32x16())) @@ -1224,7 +1312,8 @@ pub fn _mm512_mask_sub_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm512_maskz_sub_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let sub = _mm512_sub_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, sub, f32x16::ZERO)) @@ -1238,7 +1327,8 @@ pub fn _mm512_maskz_sub_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm256_mask_sub_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let sub = _mm256_sub_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, sub, src.as_f32x8())) @@ -1252,7 +1342,8 @@ pub fn _mm256_mask_sub_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm256_maskz_sub_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let sub = _mm256_sub_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, sub, f32x8::ZERO)) @@ -1266,7 +1357,8 @@ pub fn _mm256_maskz_sub_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm_mask_sub_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let sub = _mm_sub_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, sub, src.as_f32x4())) @@ -1280,7 +1372,8 @@ pub fn _mm_mask_sub_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubps))] -pub fn _mm_maskz_sub_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let sub = _mm_sub_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, sub, f32x4::ZERO)) @@ -1294,7 +1387,8 @@ pub fn _mm_maskz_sub_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm512_sub_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_sub(a.as_f64x8(), b.as_f64x8())) } } @@ -1305,7 +1399,8 @@ pub fn _mm512_sub_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm512_mask_sub_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let sub = _mm512_sub_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, sub, src.as_f64x8())) @@ -1319,7 +1414,8 @@ pub fn _mm512_mask_sub_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm512_maskz_sub_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let sub = _mm512_sub_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, sub, f64x8::ZERO)) @@ -1333,7 +1429,8 @@ pub fn _mm512_maskz_sub_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm256_mask_sub_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let sub = _mm256_sub_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, sub, src.as_f64x4())) @@ -1347,7 +1444,8 @@ pub fn _mm256_mask_sub_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm256_maskz_sub_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let sub = _mm256_sub_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, sub, f64x4::ZERO)) @@ -1361,7 +1459,8 @@ pub fn _mm256_maskz_sub_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm_mask_sub_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let sub = _mm_sub_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, sub, src.as_f64x2())) @@ -1375,7 +1474,8 @@ pub fn _mm_mask_sub_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubpd))] -pub fn _mm_maskz_sub_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let sub = _mm_sub_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, sub, f64x2::ZERO)) @@ -1389,7 +1489,8 @@ pub fn _mm_maskz_sub_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm512_mul_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mul_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = simd_cast::<_, i64x8>(simd_cast::<_, i32x8>(a.as_i64x8())); let b = simd_cast::<_, i64x8>(simd_cast::<_, i32x8>(b.as_i64x8())); @@ -1404,7 +1505,8 @@ pub fn _mm512_mul_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm512_mask_mul_epi32(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mul_epi32(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mul_epi32(a, b).as_i64x8(); transmute(simd_select_bitmask(k, mul, src.as_i64x8())) @@ -1418,7 +1520,8 @@ pub fn _mm512_mask_mul_epi32(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm512_maskz_mul_epi32(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mul_epi32(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mul_epi32(a, b).as_i64x8(); transmute(simd_select_bitmask(k, mul, i64x8::ZERO)) @@ -1432,7 +1535,8 @@ pub fn _mm512_maskz_mul_epi32(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm256_mask_mul_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mul_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mul_epi32(a, b).as_i64x4(); transmute(simd_select_bitmask(k, mul, src.as_i64x4())) @@ -1446,7 +1550,8 @@ pub fn _mm256_mask_mul_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm256_maskz_mul_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mul_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mul_epi32(a, b).as_i64x4(); transmute(simd_select_bitmask(k, mul, i64x4::ZERO)) @@ -1460,7 +1565,8 @@ pub fn _mm256_maskz_mul_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm_mask_mul_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mul_epi32(a, b).as_i64x2(); transmute(simd_select_bitmask(k, mul, src.as_i64x2())) @@ -1474,7 +1580,8 @@ pub fn _mm_mask_mul_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuldq))] -pub fn _mm_maskz_mul_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mul_epi32(a, b).as_i64x2(); transmute(simd_select_bitmask(k, mul, i64x2::ZERO)) @@ -1488,7 +1595,8 @@ pub fn _mm_maskz_mul_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm512_mullo_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mullo_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_mul(a.as_i32x16(), b.as_i32x16())) } } @@ -1499,7 +1607,13 @@ pub fn _mm512_mullo_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm512_mask_mullo_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mullo_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let mul = _mm512_mullo_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, mul, src.as_i32x16())) @@ -1513,7 +1627,8 @@ pub fn _mm512_mask_mullo_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm512_maskz_mullo_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mullo_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mullo_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, mul, i32x16::ZERO)) @@ -1527,7 +1642,8 @@ pub fn _mm512_maskz_mullo_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm256_mask_mullo_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mullo_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mullo_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, mul, src.as_i32x8())) @@ -1541,7 +1657,8 @@ pub fn _mm256_mask_mullo_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm256_maskz_mullo_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mullo_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mullo_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, mul, i32x8::ZERO)) @@ -1555,7 +1672,8 @@ pub fn _mm256_maskz_mullo_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm_mask_mullo_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mullo_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mullo_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, mul, src.as_i32x4())) @@ -1569,7 +1687,8 @@ pub fn _mm_mask_mullo_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulld))] -pub fn _mm_maskz_mullo_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mullo_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mullo_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, mul, i32x4::ZERO)) @@ -1584,7 +1703,8 @@ pub fn _mm_maskz_mullo_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mullox_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mullox_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_mul(a.as_i64x8(), b.as_i64x8())) } } @@ -1596,7 +1716,13 @@ pub fn _mm512_mullox_epi64(a: __m512i, b: __m512i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_mullox_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mullox_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let mul = _mm512_mullox_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, mul, src.as_i64x8())) @@ -1610,11 +1736,12 @@ pub fn _mm512_mask_mullox_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm512_mul_epu32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mul_epu32(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_u64x8(); let b = b.as_u64x8(); - let mask = u64x8::splat(u32::MAX.into()); + let mask = u64x8::splat(u32::MAX as u64); transmute(simd_mul(simd_and(a, mask), simd_and(b, mask))) } } @@ -1626,7 +1753,8 @@ pub fn _mm512_mul_epu32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm512_mask_mul_epu32(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mul_epu32(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mul_epu32(a, b).as_u64x8(); transmute(simd_select_bitmask(k, mul, src.as_u64x8())) @@ -1640,7 +1768,8 @@ pub fn _mm512_mask_mul_epu32(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm512_maskz_mul_epu32(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mul_epu32(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mul_epu32(a, b).as_u64x8(); transmute(simd_select_bitmask(k, mul, u64x8::ZERO)) @@ -1654,7 +1783,8 @@ pub fn _mm512_maskz_mul_epu32(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm256_mask_mul_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mul_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mul_epu32(a, b).as_u64x4(); transmute(simd_select_bitmask(k, mul, src.as_u64x4())) @@ -1668,7 +1798,8 @@ pub fn _mm256_mask_mul_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm256_maskz_mul_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mul_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mul_epu32(a, b).as_u64x4(); transmute(simd_select_bitmask(k, mul, u64x4::ZERO)) @@ -1682,7 +1813,8 @@ pub fn _mm256_maskz_mul_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm_mask_mul_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mul_epu32(a, b).as_u64x2(); transmute(simd_select_bitmask(k, mul, src.as_u64x2())) @@ -1696,7 +1828,8 @@ pub fn _mm_mask_mul_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmuludq))] -pub fn _mm_maskz_mul_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mul_epu32(a, b).as_u64x2(); transmute(simd_select_bitmask(k, mul, u64x2::ZERO)) @@ -1710,7 +1843,8 @@ pub fn _mm_maskz_mul_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm512_mul_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mul_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_mul(a.as_f32x16(), b.as_f32x16())) } } @@ -1721,7 +1855,8 @@ pub fn _mm512_mul_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm512_mask_mul_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mul_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let mul = _mm512_mul_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, mul, src.as_f32x16())) @@ -1735,7 +1870,8 @@ pub fn _mm512_mask_mul_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm512_maskz_mul_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mul_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let mul = _mm512_mul_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, mul, f32x16::ZERO)) @@ -1749,7 +1885,8 @@ pub fn _mm512_maskz_mul_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm256_mask_mul_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mul_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let mul = _mm256_mul_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, mul, src.as_f32x8())) @@ -1763,7 +1900,8 @@ pub fn _mm256_mask_mul_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm256_maskz_mul_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mul_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let mul = _mm256_mul_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, mul, f32x8::ZERO)) @@ -1777,7 +1915,8 @@ pub fn _mm256_maskz_mul_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm_mask_mul_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mul = _mm_mul_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, mul, src.as_f32x4())) @@ -1791,7 +1930,8 @@ pub fn _mm_mask_mul_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulps))] -pub fn _mm_maskz_mul_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mul = _mm_mul_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, mul, f32x4::ZERO)) @@ -1805,7 +1945,8 @@ pub fn _mm_maskz_mul_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm512_mul_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mul_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_mul(a.as_f64x8(), b.as_f64x8())) } } @@ -1816,7 +1957,8 @@ pub fn _mm512_mul_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm512_mask_mul_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mul_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let mul = _mm512_mul_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, mul, src.as_f64x8())) @@ -1830,7 +1972,8 @@ pub fn _mm512_mask_mul_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm512_maskz_mul_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mul_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let mul = _mm512_mul_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, mul, f64x8::ZERO)) @@ -1844,7 +1987,8 @@ pub fn _mm512_maskz_mul_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm256_mask_mul_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mul_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let mul = _mm256_mul_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, mul, src.as_f64x4())) @@ -1858,7 +2002,8 @@ pub fn _mm256_mask_mul_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm256_maskz_mul_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mul_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let mul = _mm256_mul_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, mul, f64x4::ZERO)) @@ -1872,7 +2017,8 @@ pub fn _mm256_maskz_mul_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm_mask_mul_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mul = _mm_mul_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, mul, src.as_f64x2())) @@ -1886,7 +2032,8 @@ pub fn _mm_mask_mul_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulpd))] -pub fn _mm_maskz_mul_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mul = _mm_mul_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, mul, f64x2::ZERO)) @@ -1900,7 +2047,8 @@ pub fn _mm_maskz_mul_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm512_div_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_div_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_div(a.as_f32x16(), b.as_f32x16())) } } @@ -1911,7 +2059,8 @@ pub fn _mm512_div_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm512_mask_div_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_div_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let div = _mm512_div_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, div, src.as_f32x16())) @@ -1925,7 +2074,8 @@ pub fn _mm512_mask_div_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm512_maskz_div_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_div_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let div = _mm512_div_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, div, f32x16::ZERO)) @@ -1939,7 +2089,8 @@ pub fn _mm512_maskz_div_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm256_mask_div_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_div_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let div = _mm256_div_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, div, src.as_f32x8())) @@ -1953,7 +2104,8 @@ pub fn _mm256_mask_div_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm256_maskz_div_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_div_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let div = _mm256_div_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, div, f32x8::ZERO)) @@ -1967,7 +2119,8 @@ pub fn _mm256_maskz_div_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm_mask_div_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_div_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let div = _mm_div_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, div, src.as_f32x4())) @@ -1981,7 +2134,8 @@ pub fn _mm_mask_div_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivps))] -pub fn _mm_maskz_div_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_div_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let div = _mm_div_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, div, f32x4::ZERO)) @@ -1995,7 +2149,8 @@ pub fn _mm_maskz_div_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm512_div_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_div_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_div(a.as_f64x8(), b.as_f64x8())) } } @@ -2006,7 +2161,8 @@ pub fn _mm512_div_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm512_mask_div_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_div_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let div = _mm512_div_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, div, src.as_f64x8())) @@ -2020,7 +2176,8 @@ pub fn _mm512_mask_div_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm512_maskz_div_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_div_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let div = _mm512_div_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, div, f64x8::ZERO)) @@ -2034,7 +2191,8 @@ pub fn _mm512_maskz_div_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm256_mask_div_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_div_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let div = _mm256_div_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, div, src.as_f64x4())) @@ -2048,7 +2206,8 @@ pub fn _mm256_mask_div_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm256_maskz_div_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_div_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let div = _mm256_div_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, div, f64x4::ZERO)) @@ -2062,7 +2221,8 @@ pub fn _mm256_maskz_div_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm_mask_div_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_div_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let div = _mm_div_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, div, src.as_f64x2())) @@ -2076,7 +2236,8 @@ pub fn _mm_mask_div_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivpd))] -pub fn _mm_maskz_div_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_div_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let div = _mm_div_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, div, f64x2::ZERO)) @@ -2090,7 +2251,8 @@ pub fn _mm_maskz_div_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm512_max_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_i32x16(), b.as_i32x16()).as_m512i() } } @@ -2101,7 +2263,8 @@ pub fn _mm512_max_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm512_mask_max_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, max, src.as_i32x16())) @@ -2115,7 +2278,8 @@ pub fn _mm512_mask_max_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm512_maskz_max_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, max, i32x16::ZERO)) @@ -2129,7 +2293,8 @@ pub fn _mm512_maskz_max_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm256_mask_max_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, max, src.as_i32x8())) @@ -2143,7 +2308,8 @@ pub fn _mm256_mask_max_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm256_maskz_max_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, max, i32x8::ZERO)) @@ -2157,7 +2323,8 @@ pub fn _mm256_maskz_max_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm_mask_max_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, max, src.as_i32x4())) @@ -2171,7 +2338,8 @@ pub fn _mm_mask_max_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsd))] -pub fn _mm_maskz_max_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, max, i32x4::ZERO)) @@ -2185,7 +2353,8 @@ pub fn _mm_maskz_max_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm512_max_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_i64x8(), b.as_i64x8()).as_m512i() } } @@ -2196,7 +2365,8 @@ pub fn _mm512_max_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm512_mask_max_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, max, src.as_i64x8())) @@ -2210,7 +2380,8 @@ pub fn _mm512_mask_max_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm512_maskz_max_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, max, i64x8::ZERO)) @@ -2224,7 +2395,8 @@ pub fn _mm512_maskz_max_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm256_max_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_i64x4(), b.as_i64x4()).as_m256i() } } @@ -2235,7 +2407,8 @@ pub fn _mm256_max_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm256_mask_max_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, max, src.as_i64x4())) @@ -2249,7 +2422,8 @@ pub fn _mm256_mask_max_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm256_maskz_max_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, max, i64x4::ZERO)) @@ -2263,7 +2437,8 @@ pub fn _mm256_maskz_max_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm_max_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_i64x2(), b.as_i64x2()).as_m128i() } } @@ -2274,7 +2449,8 @@ pub fn _mm_max_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm_mask_max_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, max, src.as_i64x2())) @@ -2288,7 +2464,8 @@ pub fn _mm_mask_max_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsq))] -pub fn _mm_maskz_max_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, max, i64x2::ZERO)) @@ -2498,7 +2675,8 @@ pub fn _mm_maskz_max_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm512_max_epu32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epu32(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_u32x16(), b.as_u32x16()).as_m512i() } } @@ -2509,7 +2687,8 @@ pub fn _mm512_max_epu32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm512_mask_max_epu32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epu32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu32(a, b).as_u32x16(); transmute(simd_select_bitmask(k, max, src.as_u32x16())) @@ -2523,7 +2702,8 @@ pub fn _mm512_mask_max_epu32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm512_maskz_max_epu32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epu32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu32(a, b).as_u32x16(); transmute(simd_select_bitmask(k, max, u32x16::ZERO)) @@ -2537,7 +2717,8 @@ pub fn _mm512_maskz_max_epu32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm256_mask_max_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu32(a, b).as_u32x8(); transmute(simd_select_bitmask(k, max, src.as_u32x8())) @@ -2551,7 +2732,8 @@ pub fn _mm256_mask_max_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm256_maskz_max_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu32(a, b).as_u32x8(); transmute(simd_select_bitmask(k, max, u32x8::ZERO)) @@ -2565,7 +2747,8 @@ pub fn _mm256_maskz_max_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm_mask_max_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu32(a, b).as_u32x4(); transmute(simd_select_bitmask(k, max, src.as_u32x4())) @@ -2579,7 +2762,8 @@ pub fn _mm_mask_max_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxud))] -pub fn _mm_maskz_max_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu32(a, b).as_u32x4(); transmute(simd_select_bitmask(k, max, u32x4::ZERO)) @@ -2593,7 +2777,8 @@ pub fn _mm_maskz_max_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm512_max_epu64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epu64(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_u64x8(), b.as_u64x8()).as_m512i() } } @@ -2604,7 +2789,8 @@ pub fn _mm512_max_epu64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm512_mask_max_epu64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epu64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu64(a, b).as_u64x8(); transmute(simd_select_bitmask(k, max, src.as_u64x8())) @@ -2618,7 +2804,8 @@ pub fn _mm512_mask_max_epu64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm512_maskz_max_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu64(a, b).as_u64x8(); transmute(simd_select_bitmask(k, max, u64x8::ZERO)) @@ -2632,7 +2819,8 @@ pub fn _mm512_maskz_max_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm256_max_epu64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_max_epu64(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imax(a.as_u64x4(), b.as_u64x4()).as_m256i() } } @@ -2643,7 +2831,8 @@ pub fn _mm256_max_epu64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm256_mask_max_epu64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epu64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu64(a, b).as_u64x4(); transmute(simd_select_bitmask(k, max, src.as_u64x4())) @@ -2657,7 +2846,8 @@ pub fn _mm256_mask_max_epu64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm256_maskz_max_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu64(a, b).as_u64x4(); transmute(simd_select_bitmask(k, max, u64x4::ZERO)) @@ -2671,7 +2861,8 @@ pub fn _mm256_maskz_max_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm_max_epu64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_max_epu64(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imax(a.as_u64x2(), b.as_u64x2()).as_m128i() } } @@ -2682,7 +2873,8 @@ pub fn _mm_max_epu64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm_mask_max_epu64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epu64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu64(a, b).as_u64x2(); transmute(simd_select_bitmask(k, max, src.as_u64x2())) @@ -2696,7 +2888,8 @@ pub fn _mm_mask_max_epu64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuq))] -pub fn _mm_maskz_max_epu64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epu64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu64(a, b).as_u64x2(); transmute(simd_select_bitmask(k, max, u64x2::ZERO)) @@ -2710,7 +2903,8 @@ pub fn _mm_maskz_max_epu64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm512_min_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_i32x16(), b.as_i32x16()).as_m512i() } } @@ -2721,7 +2915,8 @@ pub fn _mm512_min_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm512_mask_min_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, min, src.as_i32x16())) @@ -2735,7 +2930,8 @@ pub fn _mm512_mask_min_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm512_maskz_min_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, min, i32x16::ZERO)) @@ -2749,7 +2945,8 @@ pub fn _mm512_maskz_min_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm256_mask_min_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, min, src.as_i32x8())) @@ -2763,7 +2960,8 @@ pub fn _mm256_mask_min_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm256_maskz_min_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, min, i32x8::ZERO)) @@ -2777,7 +2975,8 @@ pub fn _mm256_maskz_min_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm_mask_min_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, min, src.as_i32x4())) @@ -2791,7 +2990,8 @@ pub fn _mm_mask_min_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsd))] -pub fn _mm_maskz_min_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, min, i32x4::ZERO)) @@ -2805,7 +3005,8 @@ pub fn _mm_maskz_min_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm512_min_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_i64x8(), b.as_i64x8()).as_m512i() } } @@ -2816,7 +3017,8 @@ pub fn _mm512_min_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm512_mask_min_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, min, src.as_i64x8())) @@ -2830,7 +3032,8 @@ pub fn _mm512_mask_min_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm512_maskz_min_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, min, i64x8::ZERO)) @@ -2844,7 +3047,8 @@ pub fn _mm512_maskz_min_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm256_min_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_i64x4(), b.as_i64x4()).as_m256i() } } @@ -2855,7 +3059,8 @@ pub fn _mm256_min_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm256_mask_min_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, min, src.as_i64x4())) @@ -2869,7 +3074,8 @@ pub fn _mm256_mask_min_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm256_maskz_min_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, min, i64x4::ZERO)) @@ -2883,7 +3089,8 @@ pub fn _mm256_maskz_min_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm_min_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_i64x2(), b.as_i64x2()).as_m128i() } } @@ -2894,7 +3101,8 @@ pub fn _mm_min_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm_mask_min_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, min, src.as_i64x2())) @@ -2908,7 +3116,8 @@ pub fn _mm_mask_min_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsq))] -pub fn _mm_maskz_min_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, min, i64x2::ZERO)) @@ -3118,7 +3327,8 @@ pub fn _mm_maskz_min_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm512_min_epu32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epu32(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_u32x16(), b.as_u32x16()).as_m512i() } } @@ -3129,7 +3339,8 @@ pub fn _mm512_min_epu32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm512_mask_min_epu32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epu32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu32(a, b).as_u32x16(); transmute(simd_select_bitmask(k, min, src.as_u32x16())) @@ -3143,7 +3354,8 @@ pub fn _mm512_mask_min_epu32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm512_maskz_min_epu32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epu32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu32(a, b).as_u32x16(); transmute(simd_select_bitmask(k, min, u32x16::ZERO)) @@ -3157,7 +3369,8 @@ pub fn _mm512_maskz_min_epu32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm256_mask_min_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu32(a, b).as_u32x8(); transmute(simd_select_bitmask(k, min, src.as_u32x8())) @@ -3171,7 +3384,8 @@ pub fn _mm256_mask_min_epu32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm256_maskz_min_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu32(a, b).as_u32x8(); transmute(simd_select_bitmask(k, min, u32x8::ZERO)) @@ -3185,7 +3399,8 @@ pub fn _mm256_maskz_min_epu32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm_mask_min_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu32(a, b).as_u32x4(); transmute(simd_select_bitmask(k, min, src.as_u32x4())) @@ -3199,7 +3414,8 @@ pub fn _mm_mask_min_epu32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminud))] -pub fn _mm_maskz_min_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu32(a, b).as_u32x4(); transmute(simd_select_bitmask(k, min, u32x4::ZERO)) @@ -3213,7 +3429,8 @@ pub fn _mm_maskz_min_epu32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm512_min_epu64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epu64(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_u64x8(), b.as_u64x8()).as_m512i() } } @@ -3224,7 +3441,8 @@ pub fn _mm512_min_epu64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm512_mask_min_epu64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epu64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu64(a, b).as_u64x8(); transmute(simd_select_bitmask(k, min, src.as_u64x8())) @@ -3238,7 +3456,8 @@ pub fn _mm512_mask_min_epu64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm512_maskz_min_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu64(a, b).as_u64x8(); transmute(simd_select_bitmask(k, min, u64x8::ZERO)) @@ -3252,7 +3471,8 @@ pub fn _mm512_maskz_min_epu64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm256_min_epu64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_min_epu64(a: __m256i, b: __m256i) -> __m256i { unsafe { simd_imin(a.as_u64x4(), b.as_u64x4()).as_m256i() } } @@ -3263,7 +3483,8 @@ pub fn _mm256_min_epu64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm256_mask_min_epu64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epu64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu64(a, b).as_u64x4(); transmute(simd_select_bitmask(k, min, src.as_u64x4())) @@ -3277,7 +3498,8 @@ pub fn _mm256_mask_min_epu64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm256_maskz_min_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu64(a, b).as_u64x4(); transmute(simd_select_bitmask(k, min, u64x4::ZERO)) @@ -3291,7 +3513,8 @@ pub fn _mm256_maskz_min_epu64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm_min_epu64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_min_epu64(a: __m128i, b: __m128i) -> __m128i { unsafe { simd_imin(a.as_u64x2(), b.as_u64x2()).as_m128i() } } @@ -3302,7 +3525,8 @@ pub fn _mm_min_epu64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm_mask_min_epu64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epu64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu64(a, b).as_u64x2(); transmute(simd_select_bitmask(k, min, src.as_u64x2())) @@ -3316,7 +3540,8 @@ pub fn _mm_mask_min_epu64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuq))] -pub fn _mm_maskz_min_epu64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epu64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu64(a, b).as_u64x2(); transmute(simd_select_bitmask(k, min, u64x2::ZERO)) @@ -3484,7 +3709,8 @@ pub fn _mm_maskz_sqrt_pd(k: __mmask8, a: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm512_fmadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_fma(a, b, c) } } @@ -3495,7 +3721,8 @@ pub fn _mm512_fmadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm512_mask_fmadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmadd_ps(a, b, c), a) } } @@ -3506,7 +3733,8 @@ pub fn _mm512_mask_fmadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm512_maskz_fmadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmadd_ps(a, b, c), _mm512_setzero_ps()) } } @@ -3517,7 +3745,8 @@ pub fn _mm512_maskz_fmadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm512_mask3_fmadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmadd_ps(a, b, c), c) } } @@ -3528,7 +3757,8 @@ pub fn _mm512_mask3_fmadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm256_mask_fmadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmadd_ps(a, b, c), a) } } @@ -3539,7 +3769,8 @@ pub fn _mm256_mask_fmadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm256_maskz_fmadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmadd_ps(a, b, c), _mm256_setzero_ps()) } } @@ -3550,7 +3781,8 @@ pub fn _mm256_maskz_fmadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm256_mask3_fmadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmadd_ps(a, b, c), c) } } @@ -3561,7 +3793,8 @@ pub fn _mm256_mask3_fmadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm_mask_fmadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmadd_ps(a, b, c), a) } } @@ -3572,7 +3805,8 @@ pub fn _mm_mask_fmadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm_maskz_fmadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmadd_ps(a, b, c), _mm_setzero_ps()) } } @@ -3583,7 +3817,8 @@ pub fn _mm_maskz_fmadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132ps or vfmadd213ps or vfmadd231ps -pub fn _mm_mask3_fmadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmadd_ps(a, b, c), c) } } @@ -3594,7 +3829,8 @@ pub fn _mm_mask3_fmadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm512_fmadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_fma(a, b, c) } } @@ -3605,7 +3841,8 @@ pub fn _mm512_fmadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm512_mask_fmadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmadd_pd(a, b, c), a) } } @@ -3616,7 +3853,8 @@ pub fn _mm512_mask_fmadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm512_maskz_fmadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmadd_pd(a, b, c), _mm512_setzero_pd()) } } @@ -3627,7 +3865,8 @@ pub fn _mm512_maskz_fmadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm512_mask3_fmadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmadd_pd(a, b, c), c) } } @@ -3638,7 +3877,8 @@ pub fn _mm512_mask3_fmadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm256_mask_fmadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmadd_pd(a, b, c), a) } } @@ -3649,7 +3889,8 @@ pub fn _mm256_mask_fmadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm256_maskz_fmadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmadd_pd(a, b, c), _mm256_setzero_pd()) } } @@ -3660,7 +3901,8 @@ pub fn _mm256_maskz_fmadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm256_mask3_fmadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmadd_pd(a, b, c), c) } } @@ -3671,7 +3913,8 @@ pub fn _mm256_mask3_fmadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm_mask_fmadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmadd_pd(a, b, c), a) } } @@ -3682,7 +3925,8 @@ pub fn _mm_mask_fmadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm_maskz_fmadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmadd_pd(a, b, c), _mm_setzero_pd()) } } @@ -3693,7 +3937,8 @@ pub fn _mm_maskz_fmadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] //vfmadd132pd or vfmadd213pd or vfmadd231pd -pub fn _mm_mask3_fmadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmadd_pd(a, b, c), c) } } @@ -3704,7 +3949,8 @@ pub fn _mm_mask3_fmadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm512_fmsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -3715,7 +3961,8 @@ pub fn _mm512_fmsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm512_mask_fmsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmsub_ps(a, b, c), a) } } @@ -3726,7 +3973,8 @@ pub fn _mm512_mask_fmsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm512_maskz_fmsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmsub_ps(a, b, c), _mm512_setzero_ps()) } } @@ -3737,7 +3985,8 @@ pub fn _mm512_maskz_fmsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm512_mask3_fmsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmsub_ps(a, b, c), c) } } @@ -3748,7 +3997,8 @@ pub fn _mm512_mask3_fmsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm256_mask_fmsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmsub_ps(a, b, c), a) } } @@ -3759,7 +4009,8 @@ pub fn _mm256_mask_fmsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm256_maskz_fmsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmsub_ps(a, b, c), _mm256_setzero_ps()) } } @@ -3770,7 +4021,8 @@ pub fn _mm256_maskz_fmsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm256_mask3_fmsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmsub_ps(a, b, c), c) } } @@ -3781,7 +4033,8 @@ pub fn _mm256_mask3_fmsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm_mask_fmsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmsub_ps(a, b, c), a) } } @@ -3792,7 +4045,8 @@ pub fn _mm_mask_fmsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm_maskz_fmsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmsub_ps(a, b, c), _mm_setzero_ps()) } } @@ -3803,7 +4057,8 @@ pub fn _mm_maskz_fmsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132ps or vfmsub213ps or vfmsub231ps, clang generate vfmadd, gcc generate vfmsub -pub fn _mm_mask3_fmsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmsub_ps(a, b, c), c) } } @@ -3814,7 +4069,8 @@ pub fn _mm_mask3_fmsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm512_fmsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -3825,7 +4081,8 @@ pub fn _mm512_fmsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm512_mask_fmsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmsub_pd(a, b, c), a) } } @@ -3836,7 +4093,8 @@ pub fn _mm512_mask_fmsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm512_maskz_fmsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmsub_pd(a, b, c), _mm512_setzero_pd()) } } @@ -3847,7 +4105,8 @@ pub fn _mm512_maskz_fmsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm512_mask3_fmsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmsub_pd(a, b, c), c) } } @@ -3858,7 +4117,8 @@ pub fn _mm512_mask3_fmsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm256_mask_fmsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmsub_pd(a, b, c), a) } } @@ -3869,7 +4129,8 @@ pub fn _mm256_mask_fmsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm256_maskz_fmsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmsub_pd(a, b, c), _mm256_setzero_pd()) } } @@ -3880,7 +4141,8 @@ pub fn _mm256_maskz_fmsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm256_mask3_fmsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmsub_pd(a, b, c), c) } } @@ -3891,7 +4153,8 @@ pub fn _mm256_mask3_fmsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm_mask_fmsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmsub_pd(a, b, c), a) } } @@ -3902,7 +4165,8 @@ pub fn _mm_mask_fmsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm_maskz_fmsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmsub_pd(a, b, c), _mm_setzero_pd()) } } @@ -3913,7 +4177,8 @@ pub fn _mm_maskz_fmsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] //vfmsub132pd or vfmsub213pd or vfmsub231pd. clang fmadd, gcc fmsub -pub fn _mm_mask3_fmsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmsub_pd(a, b, c), c) } } @@ -3924,7 +4189,8 @@ pub fn _mm_mask3_fmsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm512_fmaddsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmaddsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -3943,7 +4209,8 @@ pub fn _mm512_fmaddsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm512_mask_fmaddsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmaddsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_ps(a, b, c), a) } } @@ -3954,7 +4221,8 @@ pub fn _mm512_mask_fmaddsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm512_maskz_fmaddsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmaddsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_ps(a, b, c), _mm512_setzero_ps()) } } @@ -3965,7 +4233,8 @@ pub fn _mm512_maskz_fmaddsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) - #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm512_mask3_fmaddsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmaddsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_ps(a, b, c), c) } } @@ -3976,7 +4245,8 @@ pub fn _mm512_mask3_fmaddsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm256_mask_fmaddsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmaddsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_ps(a, b, c), a) } } @@ -3987,7 +4257,8 @@ pub fn _mm256_mask_fmaddsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm256_maskz_fmaddsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmaddsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_ps(a, b, c), _mm256_setzero_ps()) } } @@ -3998,7 +4269,8 @@ pub fn _mm256_maskz_fmaddsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm256_mask3_fmaddsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmaddsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_ps(a, b, c), c) } } @@ -4009,7 +4281,8 @@ pub fn _mm256_mask3_fmaddsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm_mask_fmaddsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmaddsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmaddsub_ps(a, b, c), a) } } @@ -4020,7 +4293,8 @@ pub fn _mm_mask_fmaddsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm_maskz_fmaddsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmaddsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmaddsub_ps(a, b, c), _mm_setzero_ps()) } } @@ -4031,7 +4305,8 @@ pub fn _mm_maskz_fmaddsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132ps or vfmaddsub213ps or vfmaddsub231ps -pub fn _mm_mask3_fmaddsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmaddsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmaddsub_ps(a, b, c), c) } } @@ -4042,7 +4317,8 @@ pub fn _mm_mask3_fmaddsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm512_fmaddsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmaddsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -4057,7 +4333,8 @@ pub fn _mm512_fmaddsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm512_mask_fmaddsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmaddsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_pd(a, b, c), a) } } @@ -4068,7 +4345,8 @@ pub fn _mm512_mask_fmaddsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm512_maskz_fmaddsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmaddsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_pd(a, b, c), _mm512_setzero_pd()) } } @@ -4079,7 +4357,8 @@ pub fn _mm512_maskz_fmaddsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm512_mask3_fmaddsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmaddsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_pd(a, b, c), c) } } @@ -4090,7 +4369,8 @@ pub fn _mm512_mask3_fmaddsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm256_mask_fmaddsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmaddsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_pd(a, b, c), a) } } @@ -4101,7 +4381,8 @@ pub fn _mm256_mask_fmaddsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm256_maskz_fmaddsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmaddsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_pd(a, b, c), _mm256_setzero_pd()) } } @@ -4112,7 +4393,8 @@ pub fn _mm256_maskz_fmaddsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm256_mask3_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_pd(a, b, c), c) } } @@ -4123,7 +4405,8 @@ pub fn _mm256_mask3_fmaddsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm_mask_fmaddsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmaddsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmaddsub_pd(a, b, c), a) } } @@ -4134,7 +4417,8 @@ pub fn _mm_mask_fmaddsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm_maskz_fmaddsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmaddsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmaddsub_pd(a, b, c), _mm_setzero_pd()) } } @@ -4145,7 +4429,8 @@ pub fn _mm_maskz_fmaddsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmaddsub))] //vfmaddsub132pd or vfmaddsub213pd or vfmaddsub231pd -pub fn _mm_mask3_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmaddsub_pd(a, b, c), c) } } @@ -4156,7 +4441,8 @@ pub fn _mm_mask3_fmaddsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm512_fmsubadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmsubadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -4175,7 +4461,8 @@ pub fn _mm512_fmsubadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm512_mask_fmsubadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmsubadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_ps(a, b, c), a) } } @@ -4186,7 +4473,8 @@ pub fn _mm512_mask_fmsubadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm512_maskz_fmsubadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmsubadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_ps(a, b, c), _mm512_setzero_ps()) } } @@ -4197,7 +4485,8 @@ pub fn _mm512_maskz_fmsubadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) - #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm512_mask3_fmsubadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmsubadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_ps(a, b, c), c) } } @@ -4208,7 +4497,8 @@ pub fn _mm512_mask3_fmsubadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm256_mask_fmsubadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmsubadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_ps(a, b, c), a) } } @@ -4219,7 +4509,8 @@ pub fn _mm256_mask_fmsubadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm256_maskz_fmsubadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmsubadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_ps(a, b, c), _mm256_setzero_ps()) } } @@ -4230,7 +4521,8 @@ pub fn _mm256_maskz_fmsubadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm256_mask3_fmsubadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmsubadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_ps(a, b, c), c) } } @@ -4241,7 +4533,8 @@ pub fn _mm256_mask3_fmsubadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm_mask_fmsubadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsubadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmsubadd_ps(a, b, c), a) } } @@ -4252,7 +4545,8 @@ pub fn _mm_mask_fmsubadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm_maskz_fmsubadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsubadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmsubadd_ps(a, b, c), _mm_setzero_ps()) } } @@ -4263,7 +4557,8 @@ pub fn _mm_maskz_fmsubadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132ps or vfmsubadd213ps or vfmsubadd231ps -pub fn _mm_mask3_fmsubadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsubadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fmsubadd_ps(a, b, c), c) } } @@ -4274,7 +4569,8 @@ pub fn _mm_mask3_fmsubadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm512_fmsubadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmsubadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -4289,7 +4585,8 @@ pub fn _mm512_fmsubadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm512_mask_fmsubadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmsubadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_pd(a, b, c), a) } } @@ -4300,7 +4597,8 @@ pub fn _mm512_mask_fmsubadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm512_maskz_fmsubadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmsubadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_pd(a, b, c), _mm512_setzero_pd()) } } @@ -4311,7 +4609,8 @@ pub fn _mm512_maskz_fmsubadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm512_mask3_fmsubadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmsubadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_pd(a, b, c), c) } } @@ -4322,7 +4621,8 @@ pub fn _mm512_mask3_fmsubadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm256_mask_fmsubadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmsubadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_pd(a, b, c), a) } } @@ -4333,7 +4633,8 @@ pub fn _mm256_mask_fmsubadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm256_maskz_fmsubadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmsubadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_pd(a, b, c), _mm256_setzero_pd()) } } @@ -4344,7 +4645,8 @@ pub fn _mm256_maskz_fmsubadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm256_mask3_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_pd(a, b, c), c) } } @@ -4355,7 +4657,8 @@ pub fn _mm256_mask3_fmsubadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm_mask_fmsubadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsubadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmsubadd_pd(a, b, c), a) } } @@ -4366,7 +4669,8 @@ pub fn _mm_mask_fmsubadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm_maskz_fmsubadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsubadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmsubadd_pd(a, b, c), _mm_setzero_pd()) } } @@ -4377,7 +4681,8 @@ pub fn _mm_maskz_fmsubadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsubadd))] //vfmsubadd132pd or vfmsubadd213pd or vfmsubadd231pd -pub fn _mm_mask3_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fmsubadd_pd(a, b, c), c) } } @@ -4388,7 +4693,8 @@ pub fn _mm_mask3_fmsubadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm512_fnmadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fnmadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -4399,7 +4705,8 @@ pub fn _mm512_fnmadd_ps(a: __m512, b: __m512, c: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm512_mask_fnmadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fnmadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fnmadd_ps(a, b, c), a) } } @@ -4410,7 +4717,8 @@ pub fn _mm512_mask_fnmadd_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm512_maskz_fnmadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fnmadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fnmadd_ps(a, b, c), _mm512_setzero_ps()) } } @@ -4421,7 +4729,8 @@ pub fn _mm512_maskz_fnmadd_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm512_mask3_fnmadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fnmadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fnmadd_ps(a, b, c), c) } } @@ -4432,7 +4741,8 @@ pub fn _mm512_mask3_fnmadd_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm256_mask_fnmadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fnmadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fnmadd_ps(a, b, c), a) } } @@ -4443,7 +4753,8 @@ pub fn _mm256_mask_fnmadd_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm256_maskz_fnmadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fnmadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fnmadd_ps(a, b, c), _mm256_setzero_ps()) } } @@ -4454,7 +4765,8 @@ pub fn _mm256_maskz_fnmadd_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm256_mask3_fnmadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fnmadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fnmadd_ps(a, b, c), c) } } @@ -4465,7 +4777,8 @@ pub fn _mm256_mask3_fnmadd_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm_mask_fnmadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fnmadd_ps(a, b, c), a) } } @@ -4476,7 +4789,8 @@ pub fn _mm_mask_fnmadd_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm_maskz_fnmadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fnmadd_ps(a, b, c), _mm_setzero_ps()) } } @@ -4487,7 +4801,8 @@ pub fn _mm_maskz_fnmadd_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m1 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132ps or vfnmadd213ps or vfnmadd231ps -pub fn _mm_mask3_fnmadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fnmadd_ps(a, b, c), c) } } @@ -4498,7 +4813,8 @@ pub fn _mm_mask3_fnmadd_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm512_fnmadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fnmadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -4509,7 +4825,8 @@ pub fn _mm512_fnmadd_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm512_mask_fnmadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fnmadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fnmadd_pd(a, b, c), a) } } @@ -4520,7 +4837,8 @@ pub fn _mm512_mask_fnmadd_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm512_maskz_fnmadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fnmadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fnmadd_pd(a, b, c), _mm512_setzero_pd()) } } @@ -4531,7 +4849,8 @@ pub fn _mm512_maskz_fnmadd_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) - #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm512_mask3_fnmadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fnmadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fnmadd_pd(a, b, c), c) } } @@ -4542,7 +4861,8 @@ pub fn _mm512_mask3_fnmadd_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm256_mask_fnmadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fnmadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fnmadd_pd(a, b, c), a) } } @@ -4553,7 +4873,8 @@ pub fn _mm256_mask_fnmadd_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm256_maskz_fnmadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fnmadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fnmadd_pd(a, b, c), _mm256_setzero_pd()) } } @@ -4564,7 +4885,8 @@ pub fn _mm256_maskz_fnmadd_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm256_mask3_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fnmadd_pd(a, b, c), c) } } @@ -4575,7 +4897,8 @@ pub fn _mm256_mask3_fnmadd_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm_mask_fnmadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fnmadd_pd(a, b, c), a) } } @@ -4586,7 +4909,8 @@ pub fn _mm_mask_fnmadd_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm_maskz_fnmadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fnmadd_pd(a, b, c), _mm_setzero_pd()) } } @@ -4597,7 +4921,8 @@ pub fn _mm_maskz_fnmadd_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] //vfnmadd132pd or vfnmadd213pd or vfnmadd231pd -pub fn _mm_mask3_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fnmadd_pd(a, b, c), c) } } @@ -4608,7 +4933,8 @@ pub fn _mm_mask3_fnmadd_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm512_fnmsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fnmsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -4619,7 +4945,8 @@ pub fn _mm512_fnmsub_ps(a: __m512, b: __m512, c: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm512_mask_fnmsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fnmsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fnmsub_ps(a, b, c), a) } } @@ -4630,7 +4957,8 @@ pub fn _mm512_mask_fnmsub_ps(a: __m512, k: __mmask16, b: __m512, c: __m512) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm512_maskz_fnmsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fnmsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fnmsub_ps(a, b, c), _mm512_setzero_ps()) } } @@ -4641,7 +4969,8 @@ pub fn _mm512_maskz_fnmsub_ps(k: __mmask16, a: __m512, b: __m512, c: __m512) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm512_mask3_fnmsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fnmsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> __m512 { unsafe { simd_select_bitmask(k, _mm512_fnmsub_ps(a, b, c), c) } } @@ -4652,7 +4981,8 @@ pub fn _mm512_mask3_fnmsub_ps(a: __m512, b: __m512, c: __m512, k: __mmask16) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm256_mask_fnmsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fnmsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fnmsub_ps(a, b, c), a) } } @@ -4663,7 +4993,8 @@ pub fn _mm256_mask_fnmsub_ps(a: __m256, k: __mmask8, b: __m256, c: __m256) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm256_maskz_fnmsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fnmsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fnmsub_ps(a, b, c), _mm256_setzero_ps()) } } @@ -4674,7 +5005,8 @@ pub fn _mm256_maskz_fnmsub_ps(k: __mmask8, a: __m256, b: __m256, c: __m256) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm256_mask3_fnmsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fnmsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> __m256 { unsafe { simd_select_bitmask(k, _mm256_fnmsub_ps(a, b, c), c) } } @@ -4685,7 +5017,8 @@ pub fn _mm256_mask3_fnmsub_ps(a: __m256, b: __m256, c: __m256, k: __mmask8) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm_mask_fnmsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fnmsub_ps(a, b, c), a) } } @@ -4696,7 +5029,8 @@ pub fn _mm_mask_fnmsub_ps(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm_maskz_fnmsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fnmsub_ps(a, b, c), _mm_setzero_ps()) } } @@ -4707,7 +5041,8 @@ pub fn _mm_maskz_fnmsub_ps(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m1 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132ps or vfnmsub213ps or vfnmsub231ps -pub fn _mm_mask3_fnmsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { simd_select_bitmask(k, _mm_fnmsub_ps(a, b, c), c) } } @@ -4718,7 +5053,8 @@ pub fn _mm_mask3_fnmsub_ps(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm512_fnmsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fnmsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -4729,7 +5065,8 @@ pub fn _mm512_fnmsub_pd(a: __m512d, b: __m512d, c: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm512_mask_fnmsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fnmsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fnmsub_pd(a, b, c), a) } } @@ -4740,7 +5077,8 @@ pub fn _mm512_mask_fnmsub_pd(a: __m512d, k: __mmask8, b: __m512d, c: __m512d) -> #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm512_maskz_fnmsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fnmsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fnmsub_pd(a, b, c), _mm512_setzero_pd()) } } @@ -4751,7 +5089,8 @@ pub fn _mm512_maskz_fnmsub_pd(k: __mmask8, a: __m512d, b: __m512d, c: __m512d) - #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm512_mask3_fnmsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fnmsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) -> __m512d { unsafe { simd_select_bitmask(k, _mm512_fnmsub_pd(a, b, c), c) } } @@ -4762,7 +5101,8 @@ pub fn _mm512_mask3_fnmsub_pd(a: __m512d, b: __m512d, c: __m512d, k: __mmask8) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm256_mask_fnmsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fnmsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fnmsub_pd(a, b, c), a) } } @@ -4773,7 +5113,8 @@ pub fn _mm256_mask_fnmsub_pd(a: __m256d, k: __mmask8, b: __m256d, c: __m256d) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm256_maskz_fnmsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fnmsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fnmsub_pd(a, b, c), _mm256_setzero_pd()) } } @@ -4784,7 +5125,8 @@ pub fn _mm256_maskz_fnmsub_pd(k: __mmask8, a: __m256d, b: __m256d, c: __m256d) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm256_mask3_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) -> __m256d { unsafe { simd_select_bitmask(k, _mm256_fnmsub_pd(a, b, c), c) } } @@ -4795,7 +5137,8 @@ pub fn _mm256_mask3_fnmsub_pd(a: __m256d, b: __m256d, c: __m256d, k: __mmask8) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm_mask_fnmsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fnmsub_pd(a, b, c), a) } } @@ -4806,7 +5149,8 @@ pub fn _mm_mask_fnmsub_pd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm_maskz_fnmsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fnmsub_pd(a, b, c), _mm_setzero_pd()) } } @@ -4817,7 +5161,8 @@ pub fn _mm_maskz_fnmsub_pd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] //vfnmsub132pd or vfnmsub213pd or vfnmsub231pd -pub fn _mm_mask3_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmsub_pd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { simd_select_bitmask(k, _mm_fnmsub_pd(a, b, c), c) } } @@ -11446,7 +11791,8 @@ pub fn _mm512_mask_cvtpd_pslo(src: __m512, k: __mmask8, v2: __m512d) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm512_cvtepi8_epi32(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi8_epi32(a: __m128i) -> __m512i { unsafe { let a = a.as_i8x16(); transmute::(simd_cast(a)) @@ -11460,7 +11806,8 @@ pub fn _mm512_cvtepi8_epi32(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm512_mask_cvtepi8_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi8_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepi8_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, src.as_i32x16())) @@ -11474,7 +11821,8 @@ pub fn _mm512_mask_cvtepi8_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm512_maskz_cvtepi8_epi32(k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi8_epi32(k: __mmask16, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepi8_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, i32x16::ZERO)) @@ -11488,7 +11836,8 @@ pub fn _mm512_maskz_cvtepi8_epi32(k: __mmask16, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm256_mask_cvtepi8_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi8_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi8_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, src.as_i32x8())) @@ -11502,7 +11851,8 @@ pub fn _mm256_mask_cvtepi8_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm256_maskz_cvtepi8_epi32(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi8_epi32(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi8_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, i32x8::ZERO)) @@ -11516,7 +11866,8 @@ pub fn _mm256_maskz_cvtepi8_epi32(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm_mask_cvtepi8_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi8_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi8_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, src.as_i32x4())) @@ -11530,7 +11881,8 @@ pub fn _mm_mask_cvtepi8_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbd))] -pub fn _mm_maskz_cvtepi8_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi8_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi8_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, i32x4::ZERO)) @@ -11544,7 +11896,8 @@ pub fn _mm_maskz_cvtepi8_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm512_cvtepi8_epi64(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi8_epi64(a: __m128i) -> __m512i { unsafe { let a = a.as_i8x16(); let v64: i8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -11559,7 +11912,8 @@ pub fn _mm512_cvtepi8_epi64(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm512_mask_cvtepi8_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi8_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepi8_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, src.as_i64x8())) @@ -11573,7 +11927,8 @@ pub fn _mm512_mask_cvtepi8_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m51 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm512_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepi8_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, i64x8::ZERO)) @@ -11587,7 +11942,8 @@ pub fn _mm512_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm256_mask_cvtepi8_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi8_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi8_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, src.as_i64x4())) @@ -11601,7 +11957,8 @@ pub fn _mm256_mask_cvtepi8_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm256_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi8_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, i64x4::ZERO)) @@ -11615,7 +11972,8 @@ pub fn _mm256_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm_mask_cvtepi8_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi8_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi8_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, src.as_i64x2())) @@ -11629,7 +11987,8 @@ pub fn _mm_mask_cvtepi8_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbq))] -pub fn _mm_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi8_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, i64x2::ZERO)) @@ -11643,7 +12002,8 @@ pub fn _mm_maskz_cvtepi8_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm512_cvtepu8_epi32(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu8_epi32(a: __m128i) -> __m512i { unsafe { let a = a.as_u8x16(); transmute::(simd_cast(a)) @@ -11657,7 +12017,8 @@ pub fn _mm512_cvtepu8_epi32(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm512_mask_cvtepu8_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu8_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepu8_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, src.as_i32x16())) @@ -11671,7 +12032,8 @@ pub fn _mm512_mask_cvtepu8_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm512_maskz_cvtepu8_epi32(k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu8_epi32(k: __mmask16, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepu8_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, i32x16::ZERO)) @@ -11685,7 +12047,8 @@ pub fn _mm512_maskz_cvtepu8_epi32(k: __mmask16, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm256_mask_cvtepu8_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu8_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu8_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, src.as_i32x8())) @@ -11699,7 +12062,8 @@ pub fn _mm256_mask_cvtepu8_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm256_maskz_cvtepu8_epi32(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu8_epi32(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu8_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, i32x8::ZERO)) @@ -11713,7 +12077,8 @@ pub fn _mm256_maskz_cvtepu8_epi32(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm_mask_cvtepu8_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu8_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu8_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, src.as_i32x4())) @@ -11727,7 +12092,8 @@ pub fn _mm_mask_cvtepu8_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbd))] -pub fn _mm_maskz_cvtepu8_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu8_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu8_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, i32x4::ZERO)) @@ -11741,7 +12107,8 @@ pub fn _mm_maskz_cvtepu8_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm512_cvtepu8_epi64(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu8_epi64(a: __m128i) -> __m512i { unsafe { let a = a.as_u8x16(); let v64: u8x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -11756,7 +12123,8 @@ pub fn _mm512_cvtepu8_epi64(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm512_mask_cvtepu8_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu8_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepu8_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, src.as_i64x8())) @@ -11770,7 +12138,8 @@ pub fn _mm512_mask_cvtepu8_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m51 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm512_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepu8_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, i64x8::ZERO)) @@ -11784,7 +12153,8 @@ pub fn _mm512_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm256_mask_cvtepu8_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu8_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu8_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, src.as_i64x4())) @@ -11798,7 +12168,8 @@ pub fn _mm256_mask_cvtepu8_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm256_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu8_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, i64x4::ZERO)) @@ -11812,7 +12183,8 @@ pub fn _mm256_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm_mask_cvtepu8_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu8_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu8_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, src.as_i64x2())) @@ -11826,7 +12198,8 @@ pub fn _mm_mask_cvtepu8_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbq))] -pub fn _mm_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu8_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, i64x2::ZERO)) @@ -11840,7 +12213,8 @@ pub fn _mm_maskz_cvtepu8_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm512_cvtepi16_epi32(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi16_epi32(a: __m256i) -> __m512i { unsafe { let a = a.as_i16x16(); transmute::(simd_cast(a)) @@ -11854,7 +12228,8 @@ pub fn _mm512_cvtepi16_epi32(a: __m256i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm512_mask_cvtepi16_epi32(src: __m512i, k: __mmask16, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi16_epi32(src: __m512i, k: __mmask16, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepi16_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, src.as_i32x16())) @@ -11868,7 +12243,8 @@ pub fn _mm512_mask_cvtepi16_epi32(src: __m512i, k: __mmask16, a: __m256i) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm512_maskz_cvtepi16_epi32(k: __mmask16, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi16_epi32(k: __mmask16, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepi16_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, i32x16::ZERO)) @@ -11882,7 +12258,8 @@ pub fn _mm512_maskz_cvtepi16_epi32(k: __mmask16, a: __m256i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm256_mask_cvtepi16_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi16_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi16_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, src.as_i32x8())) @@ -11896,7 +12273,8 @@ pub fn _mm256_mask_cvtepi16_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm256_maskz_cvtepi16_epi32(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi16_epi32(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi16_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, i32x8::ZERO)) @@ -11910,7 +12288,8 @@ pub fn _mm256_maskz_cvtepi16_epi32(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm_mask_cvtepi16_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi16_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi16_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, src.as_i32x4())) @@ -11924,7 +12303,8 @@ pub fn _mm_mask_cvtepi16_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwd))] -pub fn _mm_maskz_cvtepi16_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi16_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi16_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, i32x4::ZERO)) @@ -11938,7 +12318,8 @@ pub fn _mm_maskz_cvtepi16_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm512_cvtepi16_epi64(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi16_epi64(a: __m128i) -> __m512i { unsafe { let a = a.as_i16x8(); transmute::(simd_cast(a)) @@ -11952,7 +12333,8 @@ pub fn _mm512_cvtepi16_epi64(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm512_mask_cvtepi16_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi16_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepi16_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, src.as_i64x8())) @@ -11966,7 +12348,8 @@ pub fn _mm512_mask_cvtepi16_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm512_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepi16_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, i64x8::ZERO)) @@ -11980,7 +12363,8 @@ pub fn _mm512_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm256_mask_cvtepi16_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi16_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi16_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, src.as_i64x4())) @@ -11994,7 +12378,8 @@ pub fn _mm256_mask_cvtepi16_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm256_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi16_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, i64x4::ZERO)) @@ -12008,7 +12393,8 @@ pub fn _mm256_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm_mask_cvtepi16_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi16_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi16_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, src.as_i64x2())) @@ -12022,7 +12408,8 @@ pub fn _mm_mask_cvtepi16_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxwq))] -pub fn _mm_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi16_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, i64x2::ZERO)) @@ -12036,7 +12423,8 @@ pub fn _mm_maskz_cvtepi16_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm512_cvtepu16_epi32(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu16_epi32(a: __m256i) -> __m512i { unsafe { let a = a.as_u16x16(); transmute::(simd_cast(a)) @@ -12050,7 +12438,8 @@ pub fn _mm512_cvtepu16_epi32(a: __m256i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm512_mask_cvtepu16_epi32(src: __m512i, k: __mmask16, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu16_epi32(src: __m512i, k: __mmask16, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepu16_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, src.as_i32x16())) @@ -12064,7 +12453,8 @@ pub fn _mm512_mask_cvtepu16_epi32(src: __m512i, k: __mmask16, a: __m256i) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm512_maskz_cvtepu16_epi32(k: __mmask16, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu16_epi32(k: __mmask16, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepu16_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, convert, i32x16::ZERO)) @@ -12078,7 +12468,8 @@ pub fn _mm512_maskz_cvtepu16_epi32(k: __mmask16, a: __m256i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm256_mask_cvtepu16_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu16_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu16_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, src.as_i32x8())) @@ -12092,7 +12483,8 @@ pub fn _mm256_mask_cvtepu16_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm256_maskz_cvtepu16_epi32(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu16_epi32(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu16_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, i32x8::ZERO)) @@ -12106,7 +12498,8 @@ pub fn _mm256_maskz_cvtepu16_epi32(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm_mask_cvtepu16_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu16_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu16_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, src.as_i32x4())) @@ -12120,7 +12513,8 @@ pub fn _mm_mask_cvtepu16_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwd))] -pub fn _mm_maskz_cvtepu16_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu16_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu16_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, i32x4::ZERO)) @@ -12134,7 +12528,8 @@ pub fn _mm_maskz_cvtepu16_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm512_cvtepu16_epi64(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu16_epi64(a: __m128i) -> __m512i { unsafe { let a = a.as_u16x8(); transmute::(simd_cast(a)) @@ -12148,7 +12543,8 @@ pub fn _mm512_cvtepu16_epi64(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm512_mask_cvtepu16_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu16_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepu16_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, src.as_i64x8())) @@ -12162,7 +12558,8 @@ pub fn _mm512_mask_cvtepu16_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm512_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m512i { unsafe { let convert = _mm512_cvtepu16_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, i64x8::ZERO)) @@ -12176,7 +12573,8 @@ pub fn _mm512_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm256_mask_cvtepu16_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu16_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu16_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, src.as_i64x4())) @@ -12190,7 +12588,8 @@ pub fn _mm256_mask_cvtepu16_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm256_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu16_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, i64x4::ZERO)) @@ -12204,7 +12603,8 @@ pub fn _mm256_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm_mask_cvtepu16_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu16_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu16_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, src.as_i64x2())) @@ -12218,7 +12618,8 @@ pub fn _mm_mask_cvtepu16_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxwq))] -pub fn _mm_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu16_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, i64x2::ZERO)) @@ -12232,7 +12633,8 @@ pub fn _mm_maskz_cvtepu16_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm512_cvtepi32_epi64(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi32_epi64(a: __m256i) -> __m512i { unsafe { let a = a.as_i32x8(); transmute::(simd_cast(a)) @@ -12246,7 +12648,8 @@ pub fn _mm512_cvtepi32_epi64(a: __m256i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm512_mask_cvtepi32_epi64(src: __m512i, k: __mmask8, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi32_epi64(src: __m512i, k: __mmask8, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepi32_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, src.as_i64x8())) @@ -12260,7 +12663,8 @@ pub fn _mm512_mask_cvtepi32_epi64(src: __m512i, k: __mmask8, a: __m256i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm512_maskz_cvtepi32_epi64(k: __mmask8, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi32_epi64(k: __mmask8, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepi32_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, i64x8::ZERO)) @@ -12274,7 +12678,8 @@ pub fn _mm512_maskz_cvtepi32_epi64(k: __mmask8, a: __m256i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm256_mask_cvtepi32_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi32_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi32_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, src.as_i64x4())) @@ -12288,7 +12693,8 @@ pub fn _mm256_mask_cvtepi32_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm256_maskz_cvtepi32_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi32_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi32_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, i64x4::ZERO)) @@ -12302,7 +12708,8 @@ pub fn _mm256_maskz_cvtepi32_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm_mask_cvtepi32_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi32_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi32_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, src.as_i64x2())) @@ -12316,7 +12723,8 @@ pub fn _mm_mask_cvtepi32_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxdq))] -pub fn _mm_maskz_cvtepi32_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi32_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi32_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, i64x2::ZERO)) @@ -12330,7 +12738,8 @@ pub fn _mm_maskz_cvtepi32_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm512_cvtepu32_epi64(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu32_epi64(a: __m256i) -> __m512i { unsafe { let a = a.as_u32x8(); transmute::(simd_cast(a)) @@ -12344,7 +12753,8 @@ pub fn _mm512_cvtepu32_epi64(a: __m256i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm512_mask_cvtepu32_epi64(src: __m512i, k: __mmask8, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu32_epi64(src: __m512i, k: __mmask8, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepu32_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, src.as_i64x8())) @@ -12358,7 +12768,8 @@ pub fn _mm512_mask_cvtepu32_epi64(src: __m512i, k: __mmask8, a: __m256i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm512_maskz_cvtepu32_epi64(k: __mmask8, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu32_epi64(k: __mmask8, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepu32_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, convert, i64x8::ZERO)) @@ -12372,7 +12783,8 @@ pub fn _mm512_maskz_cvtepu32_epi64(k: __mmask8, a: __m256i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm256_mask_cvtepu32_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu32_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu32_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, src.as_i64x4())) @@ -12386,7 +12798,8 @@ pub fn _mm256_mask_cvtepu32_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm256_maskz_cvtepu32_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu32_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu32_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, convert, i64x4::ZERO)) @@ -12400,7 +12813,8 @@ pub fn _mm256_maskz_cvtepu32_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm_mask_cvtepu32_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu32_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu32_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, src.as_i64x2())) @@ -12414,7 +12828,8 @@ pub fn _mm_mask_cvtepu32_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxdq))] -pub fn _mm_maskz_cvtepu32_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu32_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu32_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, convert, i64x2::ZERO)) @@ -12428,7 +12843,8 @@ pub fn _mm_maskz_cvtepu32_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm512_cvtepi32_ps(a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi32_ps(a: __m512i) -> __m512 { unsafe { let a = a.as_i32x16(); transmute::(simd_cast(a)) @@ -12442,7 +12858,8 @@ pub fn _mm512_cvtepi32_ps(a: __m512i) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm512_mask_cvtepi32_ps(src: __m512, k: __mmask16, a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi32_ps(src: __m512, k: __mmask16, a: __m512i) -> __m512 { unsafe { let convert = _mm512_cvtepi32_ps(a).as_f32x16(); transmute(simd_select_bitmask(k, convert, src.as_f32x16())) @@ -12456,7 +12873,8 @@ pub fn _mm512_mask_cvtepi32_ps(src: __m512, k: __mmask16, a: __m512i) -> __m512 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm512_maskz_cvtepi32_ps(k: __mmask16, a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi32_ps(k: __mmask16, a: __m512i) -> __m512 { unsafe { let convert = _mm512_cvtepi32_ps(a).as_f32x16(); transmute(simd_select_bitmask(k, convert, f32x16::ZERO)) @@ -12470,7 +12888,8 @@ pub fn _mm512_maskz_cvtepi32_ps(k: __mmask16, a: __m512i) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm256_mask_cvtepi32_ps(src: __m256, k: __mmask8, a: __m256i) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi32_ps(src: __m256, k: __mmask8, a: __m256i) -> __m256 { unsafe { let convert = _mm256_cvtepi32_ps(a).as_f32x8(); transmute(simd_select_bitmask(k, convert, src.as_f32x8())) @@ -12484,7 +12903,8 @@ pub fn _mm256_mask_cvtepi32_ps(src: __m256, k: __mmask8, a: __m256i) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm256_maskz_cvtepi32_ps(k: __mmask8, a: __m256i) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi32_ps(k: __mmask8, a: __m256i) -> __m256 { unsafe { let convert = _mm256_cvtepi32_ps(a).as_f32x8(); transmute(simd_select_bitmask(k, convert, f32x8::ZERO)) @@ -12498,7 +12918,8 @@ pub fn _mm256_maskz_cvtepi32_ps(k: __mmask8, a: __m256i) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm_mask_cvtepi32_ps(src: __m128, k: __mmask8, a: __m128i) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi32_ps(src: __m128, k: __mmask8, a: __m128i) -> __m128 { unsafe { let convert = _mm_cvtepi32_ps(a).as_f32x4(); transmute(simd_select_bitmask(k, convert, src.as_f32x4())) @@ -12512,7 +12933,8 @@ pub fn _mm_mask_cvtepi32_ps(src: __m128, k: __mmask8, a: __m128i) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2ps))] -pub fn _mm_maskz_cvtepi32_ps(k: __mmask8, a: __m128i) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi32_ps(k: __mmask8, a: __m128i) -> __m128 { unsafe { let convert = _mm_cvtepi32_ps(a).as_f32x4(); transmute(simd_select_bitmask(k, convert, f32x4::ZERO)) @@ -12526,7 +12948,8 @@ pub fn _mm_maskz_cvtepi32_ps(k: __mmask8, a: __m128i) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm512_cvtepi32_pd(a: __m256i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi32_pd(a: __m256i) -> __m512d { unsafe { let a = a.as_i32x8(); transmute::(simd_cast(a)) @@ -12540,7 +12963,8 @@ pub fn _mm512_cvtepi32_pd(a: __m256i) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm512_mask_cvtepi32_pd(src: __m512d, k: __mmask8, a: __m256i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi32_pd(src: __m512d, k: __mmask8, a: __m256i) -> __m512d { unsafe { let convert = _mm512_cvtepi32_pd(a).as_f64x8(); transmute(simd_select_bitmask(k, convert, src.as_f64x8())) @@ -12554,7 +12978,8 @@ pub fn _mm512_mask_cvtepi32_pd(src: __m512d, k: __mmask8, a: __m256i) -> __m512d #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm512_maskz_cvtepi32_pd(k: __mmask8, a: __m256i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi32_pd(k: __mmask8, a: __m256i) -> __m512d { unsafe { let convert = _mm512_cvtepi32_pd(a).as_f64x8(); transmute(simd_select_bitmask(k, convert, f64x8::ZERO)) @@ -12568,7 +12993,8 @@ pub fn _mm512_maskz_cvtepi32_pd(k: __mmask8, a: __m256i) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm256_mask_cvtepi32_pd(src: __m256d, k: __mmask8, a: __m128i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi32_pd(src: __m256d, k: __mmask8, a: __m128i) -> __m256d { unsafe { let convert = _mm256_cvtepi32_pd(a).as_f64x4(); transmute(simd_select_bitmask(k, convert, src.as_f64x4())) @@ -12582,7 +13008,8 @@ pub fn _mm256_mask_cvtepi32_pd(src: __m256d, k: __mmask8, a: __m128i) -> __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm256_maskz_cvtepi32_pd(k: __mmask8, a: __m128i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi32_pd(k: __mmask8, a: __m128i) -> __m256d { unsafe { let convert = _mm256_cvtepi32_pd(a).as_f64x4(); transmute(simd_select_bitmask(k, convert, f64x4::ZERO)) @@ -12596,7 +13023,8 @@ pub fn _mm256_maskz_cvtepi32_pd(k: __mmask8, a: __m128i) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm_mask_cvtepi32_pd(src: __m128d, k: __mmask8, a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi32_pd(src: __m128d, k: __mmask8, a: __m128i) -> __m128d { unsafe { let convert = _mm_cvtepi32_pd(a).as_f64x2(); transmute(simd_select_bitmask(k, convert, src.as_f64x2())) @@ -12610,7 +13038,8 @@ pub fn _mm_mask_cvtepi32_pd(src: __m128d, k: __mmask8, a: __m128i) -> __m128d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm_maskz_cvtepi32_pd(k: __mmask8, a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi32_pd(k: __mmask8, a: __m128i) -> __m128d { unsafe { let convert = _mm_cvtepi32_pd(a).as_f64x2(); transmute(simd_select_bitmask(k, convert, f64x2::ZERO)) @@ -12624,7 +13053,8 @@ pub fn _mm_maskz_cvtepi32_pd(k: __mmask8, a: __m128i) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2ps))] -pub fn _mm512_cvtepu32_ps(a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu32_ps(a: __m512i) -> __m512 { unsafe { let a = a.as_u32x16(); transmute::(simd_cast(a)) @@ -12638,7 +13068,8 @@ pub fn _mm512_cvtepu32_ps(a: __m512i) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2ps))] -pub fn _mm512_mask_cvtepu32_ps(src: __m512, k: __mmask16, a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu32_ps(src: __m512, k: __mmask16, a: __m512i) -> __m512 { unsafe { let convert = _mm512_cvtepu32_ps(a).as_f32x16(); transmute(simd_select_bitmask(k, convert, src.as_f32x16())) @@ -12652,7 +13083,8 @@ pub fn _mm512_mask_cvtepu32_ps(src: __m512, k: __mmask16, a: __m512i) -> __m512 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2ps))] -pub fn _mm512_maskz_cvtepu32_ps(k: __mmask16, a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu32_ps(k: __mmask16, a: __m512i) -> __m512 { unsafe { let convert = _mm512_cvtepu32_ps(a).as_f32x16(); transmute(simd_select_bitmask(k, convert, f32x16::ZERO)) @@ -12666,7 +13098,8 @@ pub fn _mm512_maskz_cvtepu32_ps(k: __mmask16, a: __m512i) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm512_cvtepu32_pd(a: __m256i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu32_pd(a: __m256i) -> __m512d { unsafe { let a = a.as_u32x8(); transmute::(simd_cast(a)) @@ -12680,7 +13113,8 @@ pub fn _mm512_cvtepu32_pd(a: __m256i) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm512_mask_cvtepu32_pd(src: __m512d, k: __mmask8, a: __m256i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu32_pd(src: __m512d, k: __mmask8, a: __m256i) -> __m512d { unsafe { let convert = _mm512_cvtepu32_pd(a).as_f64x8(); transmute(simd_select_bitmask(k, convert, src.as_f64x8())) @@ -12694,7 +13128,8 @@ pub fn _mm512_mask_cvtepu32_pd(src: __m512d, k: __mmask8, a: __m256i) -> __m512d #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm512_maskz_cvtepu32_pd(k: __mmask8, a: __m256i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu32_pd(k: __mmask8, a: __m256i) -> __m512d { unsafe { let convert = _mm512_cvtepu32_pd(a).as_f64x8(); transmute(simd_select_bitmask(k, convert, f64x8::ZERO)) @@ -12708,7 +13143,8 @@ pub fn _mm512_maskz_cvtepu32_pd(k: __mmask8, a: __m256i) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm256_cvtepu32_pd(a: __m128i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepu32_pd(a: __m128i) -> __m256d { unsafe { let a = a.as_u32x4(); transmute::(simd_cast(a)) @@ -12722,7 +13158,8 @@ pub fn _mm256_cvtepu32_pd(a: __m128i) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm256_mask_cvtepu32_pd(src: __m256d, k: __mmask8, a: __m128i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu32_pd(src: __m256d, k: __mmask8, a: __m128i) -> __m256d { unsafe { let convert = _mm256_cvtepu32_pd(a).as_f64x4(); transmute(simd_select_bitmask(k, convert, src.as_f64x4())) @@ -12736,7 +13173,8 @@ pub fn _mm256_mask_cvtepu32_pd(src: __m256d, k: __mmask8, a: __m128i) -> __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm256_maskz_cvtepu32_pd(k: __mmask8, a: __m128i) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu32_pd(k: __mmask8, a: __m128i) -> __m256d { unsafe { let convert = _mm256_cvtepu32_pd(a).as_f64x4(); transmute(simd_select_bitmask(k, convert, f64x4::ZERO)) @@ -12750,7 +13188,8 @@ pub fn _mm256_maskz_cvtepu32_pd(k: __mmask8, a: __m128i) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm_cvtepu32_pd(a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepu32_pd(a: __m128i) -> __m128d { unsafe { let a = a.as_u32x4(); let u64: u32x2 = simd_shuffle!(a, a, [0, 1]); @@ -12765,7 +13204,8 @@ pub fn _mm_cvtepu32_pd(a: __m128i) -> __m128d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm_mask_cvtepu32_pd(src: __m128d, k: __mmask8, a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu32_pd(src: __m128d, k: __mmask8, a: __m128i) -> __m128d { unsafe { let convert = _mm_cvtepu32_pd(a).as_f64x2(); transmute(simd_select_bitmask(k, convert, src.as_f64x2())) @@ -12779,7 +13219,8 @@ pub fn _mm_mask_cvtepu32_pd(src: __m128d, k: __mmask8, a: __m128i) -> __m128d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm_maskz_cvtepu32_pd(k: __mmask8, a: __m128i) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu32_pd(k: __mmask8, a: __m128i) -> __m128d { unsafe { let convert = _mm_cvtepu32_pd(a).as_f64x2(); transmute(simd_select_bitmask(k, convert, f64x2::ZERO)) @@ -12793,7 +13234,8 @@ pub fn _mm_maskz_cvtepu32_pd(k: __mmask8, a: __m128i) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm512_cvtepi32lo_pd(v2: __m512i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi32lo_pd(v2: __m512i) -> __m512d { unsafe { let v2 = v2.as_i32x16(); let v256: i32x8 = simd_shuffle!(v2, v2, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -12808,7 +13250,8 @@ pub fn _mm512_cvtepi32lo_pd(v2: __m512i) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtdq2pd))] -pub fn _mm512_mask_cvtepi32lo_pd(src: __m512d, k: __mmask8, v2: __m512i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi32lo_pd(src: __m512d, k: __mmask8, v2: __m512i) -> __m512d { unsafe { let convert = _mm512_cvtepi32lo_pd(v2).as_f64x8(); transmute(simd_select_bitmask(k, convert, src.as_f64x8())) @@ -12822,7 +13265,8 @@ pub fn _mm512_mask_cvtepi32lo_pd(src: __m512d, k: __mmask8, v2: __m512i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm512_cvtepu32lo_pd(v2: __m512i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu32lo_pd(v2: __m512i) -> __m512d { unsafe { let v2 = v2.as_u32x16(); let v256: u32x8 = simd_shuffle!(v2, v2, [0, 1, 2, 3, 4, 5, 6, 7]); @@ -12837,7 +13281,8 @@ pub fn _mm512_cvtepu32lo_pd(v2: __m512i) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtudq2pd))] -pub fn _mm512_mask_cvtepu32lo_pd(src: __m512d, k: __mmask8, v2: __m512i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu32lo_pd(src: __m512d, k: __mmask8, v2: __m512i) -> __m512d { unsafe { let convert = _mm512_cvtepu32lo_pd(v2).as_f64x8(); transmute(simd_select_bitmask(k, convert, src.as_f64x8())) @@ -12851,7 +13296,8 @@ pub fn _mm512_mask_cvtepu32lo_pd(src: __m512d, k: __mmask8, v2: __m512i) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdw))] -pub fn _mm512_cvtepi32_epi16(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi32_epi16(a: __m512i) -> __m256i { unsafe { let a = a.as_i32x16(); transmute::(simd_cast(a)) @@ -12865,7 +13311,8 @@ pub fn _mm512_cvtepi32_epi16(a: __m512i) -> __m256i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdw))] -pub fn _mm512_mask_cvtepi32_epi16(src: __m256i, k: __mmask16, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi32_epi16(src: __m256i, k: __mmask16, a: __m512i) -> __m256i { unsafe { let convert = _mm512_cvtepi32_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, convert, src.as_i16x16())) @@ -12879,7 +13326,8 @@ pub fn _mm512_mask_cvtepi32_epi16(src: __m256i, k: __mmask16, a: __m512i) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdw))] -pub fn _mm512_maskz_cvtepi32_epi16(k: __mmask16, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi32_epi16(k: __mmask16, a: __m512i) -> __m256i { unsafe { let convert = _mm512_cvtepi32_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, convert, i16x16::ZERO)) @@ -12893,7 +13341,8 @@ pub fn _mm512_maskz_cvtepi32_epi16(k: __mmask16, a: __m512i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdw))] -pub fn _mm256_cvtepi32_epi16(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi32_epi16(a: __m256i) -> __m128i { unsafe { let a = a.as_i32x8(); transmute::(simd_cast(a)) @@ -12907,7 +13356,8 @@ pub fn _mm256_cvtepi32_epi16(a: __m256i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdw))] -pub fn _mm256_mask_cvtepi32_epi16(src: __m128i, k: __mmask8, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi32_epi16(src: __m128i, k: __mmask8, a: __m256i) -> __m128i { unsafe { let convert = _mm256_cvtepi32_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, src.as_i16x8())) @@ -12921,7 +13371,8 @@ pub fn _mm256_mask_cvtepi32_epi16(src: __m128i, k: __mmask8, a: __m256i) -> __m1 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdw))] -pub fn _mm256_maskz_cvtepi32_epi16(k: __mmask8, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi32_epi16(k: __mmask8, a: __m256i) -> __m128i { unsafe { let convert = _mm256_cvtepi32_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, i16x8::ZERO)) @@ -12968,7 +13419,8 @@ pub fn _mm_maskz_cvtepi32_epi16(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdb))] -pub fn _mm512_cvtepi32_epi8(a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi32_epi8(a: __m512i) -> __m128i { unsafe { let a = a.as_i32x16(); transmute::(simd_cast(a)) @@ -12982,7 +13434,8 @@ pub fn _mm512_cvtepi32_epi8(a: __m512i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdb))] -pub fn _mm512_mask_cvtepi32_epi8(src: __m128i, k: __mmask16, a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi32_epi8(src: __m128i, k: __mmask16, a: __m512i) -> __m128i { unsafe { let convert = _mm512_cvtepi32_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, convert, src.as_i8x16())) @@ -12996,7 +13449,8 @@ pub fn _mm512_mask_cvtepi32_epi8(src: __m128i, k: __mmask16, a: __m512i) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovdb))] -pub fn _mm512_maskz_cvtepi32_epi8(k: __mmask16, a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi32_epi8(k: __mmask16, a: __m512i) -> __m128i { unsafe { let convert = _mm512_cvtepi32_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, convert, i8x16::ZERO)) @@ -13076,7 +13530,8 @@ pub fn _mm_maskz_cvtepi32_epi8(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqd))] -pub fn _mm512_cvtepi64_epi32(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi64_epi32(a: __m512i) -> __m256i { unsafe { let a = a.as_i64x8(); transmute::(simd_cast(a)) @@ -13090,7 +13545,8 @@ pub fn _mm512_cvtepi64_epi32(a: __m512i) -> __m256i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqd))] -pub fn _mm512_mask_cvtepi64_epi32(src: __m256i, k: __mmask8, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi64_epi32(src: __m256i, k: __mmask8, a: __m512i) -> __m256i { unsafe { let convert = _mm512_cvtepi64_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, src.as_i32x8())) @@ -13104,7 +13560,8 @@ pub fn _mm512_mask_cvtepi64_epi32(src: __m256i, k: __mmask8, a: __m512i) -> __m2 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqd))] -pub fn _mm512_maskz_cvtepi64_epi32(k: __mmask8, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi64_epi32(k: __mmask8, a: __m512i) -> __m256i { unsafe { let convert = _mm512_cvtepi64_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, convert, i32x8::ZERO)) @@ -13118,7 +13575,8 @@ pub fn _mm512_maskz_cvtepi64_epi32(k: __mmask8, a: __m512i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqd))] -pub fn _mm256_cvtepi64_epi32(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi64_epi32(a: __m256i) -> __m128i { unsafe { let a = a.as_i64x4(); transmute::(simd_cast(a)) @@ -13132,7 +13590,8 @@ pub fn _mm256_cvtepi64_epi32(a: __m256i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqd))] -pub fn _mm256_mask_cvtepi64_epi32(src: __m128i, k: __mmask8, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi64_epi32(src: __m128i, k: __mmask8, a: __m256i) -> __m128i { unsafe { let convert = _mm256_cvtepi64_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, src.as_i32x4())) @@ -13146,7 +13605,8 @@ pub fn _mm256_mask_cvtepi64_epi32(src: __m128i, k: __mmask8, a: __m256i) -> __m1 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqd))] -pub fn _mm256_maskz_cvtepi64_epi32(k: __mmask8, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi64_epi32(k: __mmask8, a: __m256i) -> __m128i { unsafe { let convert = _mm256_cvtepi64_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, convert, i32x4::ZERO)) @@ -13193,7 +13653,8 @@ pub fn _mm_maskz_cvtepi64_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqw))] -pub fn _mm512_cvtepi64_epi16(a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi64_epi16(a: __m512i) -> __m128i { unsafe { let a = a.as_i64x8(); transmute::(simd_cast(a)) @@ -13207,7 +13668,8 @@ pub fn _mm512_cvtepi64_epi16(a: __m512i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqw))] -pub fn _mm512_mask_cvtepi64_epi16(src: __m128i, k: __mmask8, a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi64_epi16(src: __m128i, k: __mmask8, a: __m512i) -> __m128i { unsafe { let convert = _mm512_cvtepi64_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, src.as_i16x8())) @@ -13221,7 +13683,8 @@ pub fn _mm512_mask_cvtepi64_epi16(src: __m128i, k: __mmask8, a: __m512i) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovqw))] -pub fn _mm512_maskz_cvtepi64_epi16(k: __mmask8, a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi64_epi16(k: __mmask8, a: __m512i) -> __m128i { unsafe { let convert = _mm512_cvtepi64_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, i16x8::ZERO)) @@ -16178,7 +16641,8 @@ pub fn _mm_maskz_cvttpd_epu32(k: __mmask8, a: __m128d) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxorps))] -pub fn _mm512_setzero_pd() -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setzero_pd() -> __m512d { // All-0 is a properly initialized __m512d unsafe { const { mem::zeroed() } } } @@ -16190,7 +16654,8 @@ pub fn _mm512_setzero_pd() -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxorps))] -pub fn _mm512_setzero_ps() -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setzero_ps() -> __m512 { // All-0 is a properly initialized __m512 unsafe { const { mem::zeroed() } } } @@ -16202,7 +16667,8 @@ pub fn _mm512_setzero_ps() -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxorps))] -pub fn _mm512_setzero() -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setzero() -> __m512 { // All-0 is a properly initialized __m512 unsafe { const { mem::zeroed() } } } @@ -16214,7 +16680,8 @@ pub fn _mm512_setzero() -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxorps))] -pub fn _mm512_setzero_si512() -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setzero_si512() -> __m512i { // All-0 is a properly initialized __m512i unsafe { const { mem::zeroed() } } } @@ -16226,7 +16693,8 @@ pub fn _mm512_setzero_si512() -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxorps))] -pub fn _mm512_setzero_epi32() -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setzero_epi32() -> __m512i { // All-0 is a properly initialized __m512i unsafe { const { mem::zeroed() } } } @@ -16238,7 +16706,8 @@ pub fn _mm512_setzero_epi32() -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr_epi32( e15: i32, e14: i32, e13: i32, @@ -16270,7 +16739,8 @@ pub fn _mm512_setr_epi32( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_epi8( e63: i8, e62: i8, e61: i8, @@ -16353,7 +16823,8 @@ pub fn _mm512_set_epi8( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_epi16( e31: i16, e30: i16, e29: i16, @@ -16402,7 +16873,8 @@ pub fn _mm512_set_epi16( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set4_epi32(d: i32, c: i32, b: i32, a: i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set4_epi32(d: i32, c: i32, b: i32, a: i32) -> __m512i { _mm512_set_epi32(d, c, b, a, d, c, b, a, d, c, b, a, d, c, b, a) } @@ -16412,7 +16884,8 @@ pub fn _mm512_set4_epi32(d: i32, c: i32, b: i32, a: i32) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set4_ps(d: f32, c: f32, b: f32, a: f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set4_ps(d: f32, c: f32, b: f32, a: f32) -> __m512 { _mm512_set_ps(d, c, b, a, d, c, b, a, d, c, b, a, d, c, b, a) } @@ -16422,7 +16895,8 @@ pub fn _mm512_set4_ps(d: f32, c: f32, b: f32, a: f32) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set4_pd(d: f64, c: f64, b: f64, a: f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set4_pd(d: f64, c: f64, b: f64, a: f64) -> __m512d { _mm512_set_pd(d, c, b, a, d, c, b, a) } @@ -16432,7 +16906,8 @@ pub fn _mm512_set4_pd(d: f64, c: f64, b: f64, a: f64) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr4_epi32(d: i32, c: i32, b: i32, a: i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr4_epi32(d: i32, c: i32, b: i32, a: i32) -> __m512i { _mm512_set_epi32(a, b, c, d, a, b, c, d, a, b, c, d, a, b, c, d) } @@ -16442,7 +16917,8 @@ pub fn _mm512_setr4_epi32(d: i32, c: i32, b: i32, a: i32) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr4_ps(d: f32, c: f32, b: f32, a: f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr4_ps(d: f32, c: f32, b: f32, a: f32) -> __m512 { _mm512_set_ps(a, b, c, d, a, b, c, d, a, b, c, d, a, b, c, d) } @@ -16452,7 +16928,8 @@ pub fn _mm512_setr4_ps(d: f32, c: f32, b: f32, a: f32) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr4_pd(d: f64, c: f64, b: f64, a: f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr4_pd(d: f64, c: f64, b: f64, a: f64) -> __m512d { _mm512_set_pd(a, b, c, d, a, b, c, d) } @@ -16462,7 +16939,8 @@ pub fn _mm512_setr4_pd(d: f64, c: f64, b: f64, a: f64) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_epi64( e0: i64, e1: i64, e2: i64, @@ -16481,7 +16959,8 @@ pub fn _mm512_set_epi64( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr_epi64( e0: i64, e1: i64, e2: i64, @@ -19006,7 +19485,8 @@ pub fn _mm_maskz_expand_pd(k: __mmask8, a: __m128d) -> __m128d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_rol_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_rol_epi32(a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_rolv_epi32(a, _mm512_set1_epi32(IMM8)) } @@ -19019,7 +19499,12 @@ pub fn _mm512_rol_epi32(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_rol_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_rol_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, +) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_mask_rolv_epi32(src, k, a, _mm512_set1_epi32(IMM8)) } @@ -19032,7 +19517,8 @@ pub fn _mm512_mask_rol_epi32(src: __m512i, k: __mmask16, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_rol_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_rol_epi32(k: __mmask16, a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_maskz_rolv_epi32(k, a, _mm512_set1_epi32(IMM8)) } @@ -19045,7 +19531,8 @@ pub fn _mm512_maskz_rol_epi32(k: __mmask16, a: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm256_rol_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_rol_epi32(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_rolv_epi32(a, _mm256_set1_epi32(IMM8)) } @@ -19058,7 +19545,12 @@ pub fn _mm256_rol_epi32(a: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_rol_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_rol_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_mask_rolv_epi32(src, k, a, _mm256_set1_epi32(IMM8)) } @@ -19071,7 +19563,8 @@ pub fn _mm256_mask_rol_epi32(src: __m256i, k: __mmask8, a: __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_rol_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_rol_epi32(k: __mmask8, a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_maskz_rolv_epi32(k, a, _mm256_set1_epi32(IMM8)) } @@ -19084,7 +19577,8 @@ pub fn _mm256_maskz_rol_epi32(k: __mmask8, a: __m256i) -> __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm_rol_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_rol_epi32(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_rolv_epi32(a, _mm_set1_epi32(IMM8)) } @@ -19097,7 +19591,8 @@ pub fn _mm_rol_epi32(a: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_rol_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_rol_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_mask_rolv_epi32(src, k, a, _mm_set1_epi32(IMM8)) } @@ -19110,7 +19605,8 @@ pub fn _mm_mask_rol_epi32(src: __m128i, k: __mmask8, a: __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_rol_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_rol_epi32(k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_maskz_rolv_epi32(k, a, _mm_set1_epi32(IMM8)) } @@ -19123,7 +19619,8 @@ pub fn _mm_maskz_rol_epi32(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_ror_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_ror_epi32(a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_rorv_epi32(a, _mm512_set1_epi32(IMM8)) } @@ -19136,7 +19633,12 @@ pub fn _mm512_ror_epi32(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 123))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_ror_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_ror_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, +) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_mask_rorv_epi32(src, k, a, _mm512_set1_epi32(IMM8)) } @@ -19149,7 +19651,8 @@ pub fn _mm512_mask_ror_epi32(src: __m512i, k: __mmask16, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 123))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_ror_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_ror_epi32(k: __mmask16, a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_maskz_rorv_epi32(k, a, _mm512_set1_epi32(IMM8)) } @@ -19162,7 +19665,8 @@ pub fn _mm512_maskz_ror_epi32(k: __mmask16, a: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm256_ror_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_ror_epi32(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_rorv_epi32(a, _mm256_set1_epi32(IMM8)) } @@ -19175,7 +19679,12 @@ pub fn _mm256_ror_epi32(a: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 123))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_ror_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_ror_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_mask_rorv_epi32(src, k, a, _mm256_set1_epi32(IMM8)) } @@ -19188,7 +19697,8 @@ pub fn _mm256_mask_ror_epi32(src: __m256i, k: __mmask8, a: __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 123))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_ror_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_ror_epi32(k: __mmask8, a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_maskz_rorv_epi32(k, a, _mm256_set1_epi32(IMM8)) } @@ -19201,7 +19711,8 @@ pub fn _mm256_maskz_ror_epi32(k: __mmask8, a: __m256i) -> __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm_ror_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_ror_epi32(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_rorv_epi32(a, _mm_set1_epi32(IMM8)) } @@ -19214,7 +19725,8 @@ pub fn _mm_ror_epi32(a: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 123))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_ror_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_ror_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_mask_rorv_epi32(src, k, a, _mm_set1_epi32(IMM8)) } @@ -19227,7 +19739,8 @@ pub fn _mm_mask_ror_epi32(src: __m128i, k: __mmask8, a: __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprold, IMM8 = 123))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_ror_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_ror_epi32(k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_maskz_rorv_epi32(k, a, _mm_set1_epi32(IMM8)) } @@ -19240,7 +19753,8 @@ pub fn _mm_maskz_ror_epi32(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_rol_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_rol_epi64(a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_rolv_epi64(a, _mm512_set1_epi64(IMM8 as i64)) } @@ -19253,7 +19767,12 @@ pub fn _mm512_rol_epi64(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_rol_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_rol_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, +) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_mask_rolv_epi64(src, k, a, _mm512_set1_epi64(IMM8 as i64)) } @@ -19266,7 +19785,8 @@ pub fn _mm512_mask_rol_epi64(src: __m512i, k: __mmask8, a: __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_rol_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_rol_epi64(k: __mmask8, a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_maskz_rolv_epi64(k, a, _mm512_set1_epi64(IMM8 as i64)) } @@ -19279,7 +19799,8 @@ pub fn _mm512_maskz_rol_epi64(k: __mmask8, a: __m512i) -> __m51 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm256_rol_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_rol_epi64(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_rolv_epi64(a, _mm256_set1_epi64x(IMM8 as i64)) } @@ -19292,7 +19813,12 @@ pub fn _mm256_rol_epi64(a: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_rol_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_rol_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_mask_rolv_epi64(src, k, a, _mm256_set1_epi64x(IMM8 as i64)) } @@ -19305,7 +19831,8 @@ pub fn _mm256_mask_rol_epi64(src: __m256i, k: __mmask8, a: __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_rol_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_rol_epi64(k: __mmask8, a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_maskz_rolv_epi64(k, a, _mm256_set1_epi64x(IMM8 as i64)) } @@ -19318,7 +19845,8 @@ pub fn _mm256_maskz_rol_epi64(k: __mmask8, a: __m256i) -> __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm_rol_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_rol_epi64(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_rolv_epi64(a, _mm_set1_epi64x(IMM8 as i64)) } @@ -19331,7 +19859,8 @@ pub fn _mm_rol_epi64(a: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_rol_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_rol_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_mask_rolv_epi64(src, k, a, _mm_set1_epi64x(IMM8 as i64)) } @@ -19344,7 +19873,8 @@ pub fn _mm_mask_rol_epi64(src: __m128i, k: __mmask8, a: __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_rol_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_rol_epi64(k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_maskz_rolv_epi64(k, a, _mm_set1_epi64x(IMM8 as i64)) } @@ -19357,7 +19887,8 @@ pub fn _mm_maskz_rol_epi64(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_ror_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_ror_epi64(a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_rorv_epi64(a, _mm512_set1_epi64(IMM8 as i64)) } @@ -19370,7 +19901,12 @@ pub fn _mm512_ror_epi64(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_ror_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_ror_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, +) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_mask_rorv_epi64(src, k, a, _mm512_set1_epi64(IMM8 as i64)) } @@ -19383,7 +19919,8 @@ pub fn _mm512_mask_ror_epi64(src: __m512i, k: __mmask8, a: __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_ror_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_ror_epi64(k: __mmask8, a: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_maskz_rorv_epi64(k, a, _mm512_set1_epi64(IMM8 as i64)) } @@ -19396,7 +19933,8 @@ pub fn _mm512_maskz_ror_epi64(k: __mmask8, a: __m512i) -> __m51 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(1)] -pub fn _mm256_ror_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_ror_epi64(a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_rorv_epi64(a, _mm256_set1_epi64x(IMM8 as i64)) } @@ -19409,7 +19947,12 @@ pub fn _mm256_ror_epi64(a: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_ror_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_ror_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_mask_rorv_epi64(src, k, a, _mm256_set1_epi64x(IMM8 as i64)) } @@ -19422,7 +19965,8 @@ pub fn _mm256_mask_ror_epi64(src: __m256i, k: __mmask8, a: __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_ror_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_ror_epi64(k: __mmask8, a: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_maskz_rorv_epi64(k, a, _mm256_set1_epi64x(IMM8 as i64)) } @@ -19435,7 +19979,8 @@ pub fn _mm256_maskz_ror_epi64(k: __mmask8, a: __m256i) -> __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(1)] -pub fn _mm_ror_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_ror_epi64(a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_rorv_epi64(a, _mm_set1_epi64x(IMM8 as i64)) } @@ -19448,7 +19993,8 @@ pub fn _mm_ror_epi64(a: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_ror_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_ror_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_mask_rorv_epi64(src, k, a, _mm_set1_epi64x(IMM8 as i64)) } @@ -19461,7 +20007,8 @@ pub fn _mm_mask_ror_epi64(src: __m128i, k: __mmask8, a: __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolq, IMM8 = 15))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_ror_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_ror_epi64(k: __mmask8, a: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_maskz_rorv_epi64(k, a, _mm_set1_epi64x(IMM8 as i64)) } @@ -19474,7 +20021,8 @@ pub fn _mm_maskz_ror_epi64(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_slli_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_slli_epi32(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19493,7 +20041,12 @@ pub fn _mm512_slli_epi32(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_slli_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_slli_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 32 { @@ -19513,7 +20066,8 @@ pub fn _mm512_mask_slli_epi32(src: __m512i, k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_slli_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_slli_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19533,7 +20087,12 @@ pub fn _mm512_maskz_slli_epi32(k: __mmask16, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_slli_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_slli_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 32 { @@ -19553,7 +20112,8 @@ pub fn _mm256_mask_slli_epi32(src: __m256i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_slli_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_slli_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19573,7 +20133,12 @@ pub fn _mm256_maskz_slli_epi32(k: __mmask8, a: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_slli_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_slli_epi32( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 32 { @@ -19593,7 +20158,8 @@ pub fn _mm_mask_slli_epi32(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslld, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_slli_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_slli_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19613,7 +20179,8 @@ pub fn _mm_maskz_slli_epi32(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_srli_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srli_epi32(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19632,7 +20199,12 @@ pub fn _mm512_srli_epi32(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_srli_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srli_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 32 { @@ -19652,7 +20224,8 @@ pub fn _mm512_mask_srli_epi32(src: __m512i, k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_srli_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srli_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19672,7 +20245,12 @@ pub fn _mm512_maskz_srli_epi32(k: __mmask16, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_srli_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srli_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 32 { @@ -19692,7 +20270,8 @@ pub fn _mm256_mask_srli_epi32(src: __m256i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_srli_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srli_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19712,7 +20291,12 @@ pub fn _mm256_maskz_srli_epi32(k: __mmask8, a: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_srli_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srli_epi32( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 32 { @@ -19732,7 +20316,8 @@ pub fn _mm_mask_srli_epi32(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrld, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_srli_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srli_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 32 { @@ -19752,7 +20337,8 @@ pub fn _mm_maskz_srli_epi32(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_slli_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_slli_epi64(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19771,7 +20357,12 @@ pub fn _mm512_slli_epi64(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_slli_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_slli_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 64 { @@ -19791,7 +20382,8 @@ pub fn _mm512_mask_slli_epi64(src: __m512i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_slli_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_slli_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19811,7 +20403,12 @@ pub fn _mm512_maskz_slli_epi64(k: __mmask8, a: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_slli_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_slli_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 64 { @@ -19831,7 +20428,8 @@ pub fn _mm256_mask_slli_epi64(src: __m256i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_slli_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_slli_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19851,7 +20449,12 @@ pub fn _mm256_maskz_slli_epi64(k: __mmask8, a: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_slli_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_slli_epi64( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 64 { @@ -19871,7 +20474,8 @@ pub fn _mm_mask_slli_epi64(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllq, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_slli_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_slli_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19891,7 +20495,8 @@ pub fn _mm_maskz_slli_epi64(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_srli_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srli_epi64(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19910,7 +20515,12 @@ pub fn _mm512_srli_epi64(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_srli_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srli_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 64 { @@ -19930,7 +20540,8 @@ pub fn _mm512_mask_srli_epi64(src: __m512i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_srli_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srli_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19950,7 +20561,12 @@ pub fn _mm512_maskz_srli_epi64(k: __mmask8, a: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_srli_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srli_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 64 { @@ -19970,7 +20586,8 @@ pub fn _mm256_mask_srli_epi64(src: __m256i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_srli_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srli_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -19990,7 +20607,12 @@ pub fn _mm256_maskz_srli_epi64(k: __mmask8, a: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_srli_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srli_epi64( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = if IMM8 >= 64 { @@ -20010,7 +20632,8 @@ pub fn _mm_mask_srli_epi64(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_srli_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srli_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 64 { @@ -20622,7 +21245,8 @@ pub fn _mm_maskz_sra_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_srai_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srai_epi32(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); transmute(simd_shr(a.as_i32x16(), i32x16::splat(IMM8.min(31) as i32))) @@ -20637,7 +21261,12 @@ pub fn _mm512_srai_epi32(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_srai_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srai_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = simd_shr(a.as_i32x16(), i32x16::splat(IMM8.min(31) as i32)); @@ -20653,7 +21282,8 @@ pub fn _mm512_mask_srai_epi32(src: __m512i, k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_srai_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srai_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = simd_shr(a.as_i32x16(), i32x16::splat(IMM8.min(31) as i32)); @@ -20669,7 +21299,12 @@ pub fn _mm512_maskz_srai_epi32(k: __mmask16, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_srai_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srai_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { let r = simd_shr(a.as_i32x8(), i32x8::splat(IMM8.min(31) as i32)); transmute(simd_select_bitmask(k, r, src.as_i32x8())) @@ -20684,7 +21319,8 @@ pub fn _mm256_mask_srai_epi32(src: __m256i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_srai_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srai_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { let r = simd_shr(a.as_i32x8(), i32x8::splat(IMM8.min(31) as i32)); transmute(simd_select_bitmask(k, r, i32x8::ZERO)) @@ -20699,7 +21335,12 @@ pub fn _mm256_maskz_srai_epi32(k: __mmask8, a: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_srai_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srai_epi32( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { let r = simd_shr(a.as_i32x4(), i32x4::splat(IMM8.min(31) as i32)); transmute(simd_select_bitmask(k, r, src.as_i32x4())) @@ -20714,7 +21355,8 @@ pub fn _mm_mask_srai_epi32(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrad, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_srai_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srai_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let r = simd_shr(a.as_i32x4(), i32x4::splat(IMM8.min(31) as i32)); transmute(simd_select_bitmask(k, r, i32x4::ZERO)) @@ -20729,7 +21371,8 @@ pub fn _mm_maskz_srai_epi32(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_srai_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srai_epi64(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); transmute(simd_shr(a.as_i64x8(), i64x8::splat(IMM8.min(63) as i64))) @@ -20744,7 +21387,12 @@ pub fn _mm512_srai_epi64(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_srai_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srai_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i64x8(), i64x8::splat(IMM8.min(63) as i64)); @@ -20760,7 +21408,8 @@ pub fn _mm512_mask_srai_epi64(src: __m512i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_srai_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srai_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i64x8(), i64x8::splat(IMM8.min(63) as i64)); @@ -20776,7 +21425,8 @@ pub fn _mm512_maskz_srai_epi64(k: __mmask8, a: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm256_srai_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srai_epi64(a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); transmute(simd_shr(a.as_i64x4(), i64x4::splat(IMM8.min(63) as i64))) @@ -20791,7 +21441,12 @@ pub fn _mm256_srai_epi64(a: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_srai_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srai_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i64x4(), i64x4::splat(IMM8.min(63) as i64)); @@ -20807,7 +21462,8 @@ pub fn _mm256_mask_srai_epi64(src: __m256i, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_srai_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srai_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i64x4(), i64x4::splat(IMM8.min(63) as i64)); @@ -20823,7 +21479,8 @@ pub fn _mm256_maskz_srai_epi64(k: __mmask8, a: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm_srai_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srai_epi64(a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); transmute(simd_shr(a.as_i64x2(), i64x2::splat(IMM8.min(63) as i64))) @@ -20838,7 +21495,12 @@ pub fn _mm_srai_epi64(a: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_srai_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srai_epi64( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i64x2(), i64x2::splat(IMM8.min(63) as i64)); @@ -20854,7 +21516,8 @@ pub fn _mm_mask_srai_epi64(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_srai_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srai_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i64x2(), i64x2::splat(IMM8.min(63) as i64)); @@ -20869,7 +21532,8 @@ pub fn _mm_maskz_srai_epi64(k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm512_srav_epi32(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srav_epi32(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u32x16(); let no_overflow: u32x16 = simd_lt(count, u32x16::splat(u32::BITS)); @@ -20885,7 +21549,13 @@ pub fn _mm512_srav_epi32(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm512_mask_srav_epi32(src: __m512i, k: __mmask16, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srav_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_srav_epi32(a, count).as_i32x16(); transmute(simd_select_bitmask(k, shf, src.as_i32x16())) @@ -20899,7 +21569,8 @@ pub fn _mm512_mask_srav_epi32(src: __m512i, k: __mmask16, a: __m512i, count: __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm512_maskz_srav_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srav_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_srav_epi32(a, count).as_i32x16(); transmute(simd_select_bitmask(k, shf, i32x16::ZERO)) @@ -20913,7 +21584,13 @@ pub fn _mm512_maskz_srav_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m5 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm256_mask_srav_epi32(src: __m256i, k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srav_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_srav_epi32(a, count).as_i32x8(); transmute(simd_select_bitmask(k, shf, src.as_i32x8())) @@ -20927,7 +21604,8 @@ pub fn _mm256_mask_srav_epi32(src: __m256i, k: __mmask8, a: __m256i, count: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm256_maskz_srav_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srav_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_srav_epi32(a, count).as_i32x8(); transmute(simd_select_bitmask(k, shf, i32x8::ZERO)) @@ -20941,7 +21619,8 @@ pub fn _mm256_maskz_srav_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm_mask_srav_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srav_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srav_epi32(a, count).as_i32x4(); transmute(simd_select_bitmask(k, shf, src.as_i32x4())) @@ -20955,7 +21634,8 @@ pub fn _mm_mask_srav_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] -pub fn _mm_maskz_srav_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srav_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srav_epi32(a, count).as_i32x4(); transmute(simd_select_bitmask(k, shf, i32x4::ZERO)) @@ -20969,7 +21649,8 @@ pub fn _mm_maskz_srav_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm512_srav_epi64(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srav_epi64(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u64x8(); let no_overflow: u64x8 = simd_lt(count, u64x8::splat(u64::BITS as u64)); @@ -20985,7 +21666,13 @@ pub fn _mm512_srav_epi64(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm512_mask_srav_epi64(src: __m512i, k: __mmask8, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srav_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_srav_epi64(a, count).as_i64x8(); transmute(simd_select_bitmask(k, shf, src.as_i64x8())) @@ -20999,7 +21686,8 @@ pub fn _mm512_mask_srav_epi64(src: __m512i, k: __mmask8, a: __m512i, count: __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm512_maskz_srav_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srav_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_srav_epi64(a, count).as_i64x8(); transmute(simd_select_bitmask(k, shf, i64x8::ZERO)) @@ -21013,7 +21701,8 @@ pub fn _mm512_maskz_srav_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m51 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm256_srav_epi64(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srav_epi64(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u64x4(); let no_overflow: u64x4 = simd_lt(count, u64x4::splat(u64::BITS as u64)); @@ -21029,7 +21718,13 @@ pub fn _mm256_srav_epi64(a: __m256i, count: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm256_mask_srav_epi64(src: __m256i, k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srav_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_srav_epi64(a, count).as_i64x4(); transmute(simd_select_bitmask(k, shf, src.as_i64x4())) @@ -21043,7 +21738,8 @@ pub fn _mm256_mask_srav_epi64(src: __m256i, k: __mmask8, a: __m256i, count: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm256_maskz_srav_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srav_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_srav_epi64(a, count).as_i64x4(); transmute(simd_select_bitmask(k, shf, i64x4::ZERO)) @@ -21057,7 +21753,8 @@ pub fn _mm256_maskz_srav_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm_srav_epi64(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srav_epi64(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u64x2(); let no_overflow: u64x2 = simd_lt(count, u64x2::splat(u64::BITS as u64)); @@ -21073,7 +21770,8 @@ pub fn _mm_srav_epi64(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm_mask_srav_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srav_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srav_epi64(a, count).as_i64x2(); transmute(simd_select_bitmask(k, shf, src.as_i64x2())) @@ -21087,7 +21785,8 @@ pub fn _mm_mask_srav_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] -pub fn _mm_maskz_srav_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srav_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srav_epi64(a, count).as_i64x2(); transmute(simd_select_bitmask(k, shf, i64x2::ZERO)) @@ -21101,7 +21800,8 @@ pub fn _mm_maskz_srav_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm512_rolv_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_rolv_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shl( a.as_u32x16(), @@ -21118,7 +21818,8 @@ pub fn _mm512_rolv_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm512_mask_rolv_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_rolv_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let rol = _mm512_rolv_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, rol, src.as_i32x16())) @@ -21132,7 +21833,8 @@ pub fn _mm512_mask_rolv_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm512_maskz_rolv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_rolv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let rol = _mm512_rolv_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, rol, i32x16::ZERO)) @@ -21146,7 +21848,8 @@ pub fn _mm512_maskz_rolv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm256_rolv_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_rolv_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shl( a.as_u32x8(), @@ -21163,7 +21866,8 @@ pub fn _mm256_rolv_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm256_mask_rolv_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_rolv_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let rol = _mm256_rolv_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, rol, src.as_i32x8())) @@ -21177,7 +21881,8 @@ pub fn _mm256_mask_rolv_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm256_maskz_rolv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_rolv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let rol = _mm256_rolv_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, rol, i32x8::ZERO)) @@ -21191,7 +21896,8 @@ pub fn _mm256_maskz_rolv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm_rolv_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_rolv_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shl( a.as_u32x4(), @@ -21208,7 +21914,8 @@ pub fn _mm_rolv_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm_mask_rolv_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_rolv_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let rol = _mm_rolv_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, rol, src.as_i32x4())) @@ -21222,7 +21929,8 @@ pub fn _mm_mask_rolv_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvd))] -pub fn _mm_maskz_rolv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_rolv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let rol = _mm_rolv_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, rol, i32x4::ZERO)) @@ -21236,7 +21944,8 @@ pub fn _mm_maskz_rolv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm512_rorv_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_rorv_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shr( a.as_u32x16(), @@ -21253,7 +21962,8 @@ pub fn _mm512_rorv_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm512_mask_rorv_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_rorv_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let ror = _mm512_rorv_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, ror, src.as_i32x16())) @@ -21267,7 +21977,8 @@ pub fn _mm512_mask_rorv_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm512_maskz_rorv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_rorv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let ror = _mm512_rorv_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, ror, i32x16::ZERO)) @@ -21281,7 +21992,8 @@ pub fn _mm512_maskz_rorv_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm256_rorv_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_rorv_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shr( a.as_u32x8(), @@ -21298,7 +22010,8 @@ pub fn _mm256_rorv_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm256_mask_rorv_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_rorv_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let ror = _mm256_rorv_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, ror, src.as_i32x8())) @@ -21312,7 +22025,8 @@ pub fn _mm256_mask_rorv_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm256_maskz_rorv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_rorv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let ror = _mm256_rorv_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, ror, i32x8::ZERO)) @@ -21326,7 +22040,8 @@ pub fn _mm256_maskz_rorv_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm_rorv_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_rorv_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shr( a.as_u32x4(), @@ -21343,7 +22058,8 @@ pub fn _mm_rorv_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm_mask_rorv_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_rorv_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let ror = _mm_rorv_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, ror, src.as_i32x4())) @@ -21357,7 +22073,8 @@ pub fn _mm_mask_rorv_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvd))] -pub fn _mm_maskz_rorv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_rorv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let ror = _mm_rorv_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, ror, i32x4::ZERO)) @@ -21371,7 +22088,8 @@ pub fn _mm_maskz_rorv_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm512_rolv_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_rolv_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shl( a.as_u64x8(), @@ -21388,7 +22106,8 @@ pub fn _mm512_rolv_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm512_mask_rolv_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_rolv_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let rol = _mm512_rolv_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, rol, src.as_i64x8())) @@ -21402,7 +22121,8 @@ pub fn _mm512_mask_rolv_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm512_maskz_rolv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_rolv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let rol = _mm512_rolv_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, rol, i64x8::ZERO)) @@ -21416,7 +22136,8 @@ pub fn _mm512_maskz_rolv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm256_rolv_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_rolv_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shl( a.as_u64x4(), @@ -21433,7 +22154,8 @@ pub fn _mm256_rolv_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm256_mask_rolv_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_rolv_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let rol = _mm256_rolv_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, rol, src.as_i64x4())) @@ -21447,7 +22169,8 @@ pub fn _mm256_mask_rolv_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm256_maskz_rolv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_rolv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let rol = _mm256_rolv_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, rol, i64x4::ZERO)) @@ -21461,7 +22184,8 @@ pub fn _mm256_maskz_rolv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm_rolv_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_rolv_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shl( a.as_u64x2(), @@ -21478,7 +22202,8 @@ pub fn _mm_rolv_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm_mask_rolv_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_rolv_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let rol = _mm_rolv_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, rol, src.as_i64x2())) @@ -21492,7 +22217,8 @@ pub fn _mm_mask_rolv_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprolvq))] -pub fn _mm_maskz_rolv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_rolv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let rol = _mm_rolv_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, rol, i64x2::ZERO)) @@ -21506,7 +22232,8 @@ pub fn _mm_maskz_rolv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm512_rorv_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_rorv_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shr( a.as_u64x8(), @@ -21523,7 +22250,8 @@ pub fn _mm512_rorv_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm512_mask_rorv_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_rorv_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let ror = _mm512_rorv_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, ror, src.as_i64x8())) @@ -21537,7 +22265,8 @@ pub fn _mm512_mask_rorv_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm512_maskz_rorv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_rorv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let ror = _mm512_rorv_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, ror, i64x8::ZERO)) @@ -21551,7 +22280,8 @@ pub fn _mm512_maskz_rorv_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm256_rorv_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_rorv_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shr( a.as_u64x4(), @@ -21568,7 +22298,8 @@ pub fn _mm256_rorv_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm256_mask_rorv_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_rorv_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let ror = _mm256_rorv_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, ror, src.as_i64x4())) @@ -21582,7 +22313,8 @@ pub fn _mm256_mask_rorv_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm256_maskz_rorv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_rorv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let ror = _mm256_rorv_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, ror, i64x4::ZERO)) @@ -21596,7 +22328,8 @@ pub fn _mm256_maskz_rorv_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm_rorv_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_rorv_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shr( a.as_u64x2(), @@ -21613,7 +22346,8 @@ pub fn _mm_rorv_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm_mask_rorv_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_rorv_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let ror = _mm_rorv_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, ror, src.as_i64x2())) @@ -21627,7 +22361,8 @@ pub fn _mm_mask_rorv_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vprorvq))] -pub fn _mm_maskz_rorv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_rorv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let ror = _mm_rorv_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, ror, i64x2::ZERO)) @@ -21641,7 +22376,8 @@ pub fn _mm_maskz_rorv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm512_sllv_epi32(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sllv_epi32(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u32x16(); let no_overflow: u32x16 = simd_lt(count, u32x16::splat(u32::BITS)); @@ -21657,7 +22393,13 @@ pub fn _mm512_sllv_epi32(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm512_mask_sllv_epi32(src: __m512i, k: __mmask16, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sllv_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_sllv_epi32(a, count).as_i32x16(); transmute(simd_select_bitmask(k, shf, src.as_i32x16())) @@ -21671,7 +22413,8 @@ pub fn _mm512_mask_sllv_epi32(src: __m512i, k: __mmask16, a: __m512i, count: __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm512_maskz_sllv_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sllv_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_sllv_epi32(a, count).as_i32x16(); transmute(simd_select_bitmask(k, shf, i32x16::ZERO)) @@ -21685,7 +22428,13 @@ pub fn _mm512_maskz_sllv_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m5 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm256_mask_sllv_epi32(src: __m256i, k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sllv_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_sllv_epi32(a, count).as_i32x8(); transmute(simd_select_bitmask(k, shf, src.as_i32x8())) @@ -21699,7 +22448,8 @@ pub fn _mm256_mask_sllv_epi32(src: __m256i, k: __mmask8, a: __m256i, count: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm256_maskz_sllv_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sllv_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_sllv_epi32(a, count).as_i32x8(); transmute(simd_select_bitmask(k, shf, i32x8::ZERO)) @@ -21713,7 +22463,8 @@ pub fn _mm256_maskz_sllv_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm_mask_sllv_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sllv_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_sllv_epi32(a, count).as_i32x4(); transmute(simd_select_bitmask(k, shf, src.as_i32x4())) @@ -21727,7 +22478,8 @@ pub fn _mm_mask_sllv_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] -pub fn _mm_maskz_sllv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sllv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_sllv_epi32(a, count).as_i32x4(); transmute(simd_select_bitmask(k, shf, i32x4::ZERO)) @@ -21741,7 +22493,8 @@ pub fn _mm_maskz_sllv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm512_srlv_epi32(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srlv_epi32(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u32x16(); let no_overflow: u32x16 = simd_lt(count, u32x16::splat(u32::BITS)); @@ -21757,7 +22510,13 @@ pub fn _mm512_srlv_epi32(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm512_mask_srlv_epi32(src: __m512i, k: __mmask16, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srlv_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_srlv_epi32(a, count).as_i32x16(); transmute(simd_select_bitmask(k, shf, src.as_i32x16())) @@ -21771,7 +22530,8 @@ pub fn _mm512_mask_srlv_epi32(src: __m512i, k: __mmask16, a: __m512i, count: __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm512_maskz_srlv_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srlv_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_srlv_epi32(a, count).as_i32x16(); transmute(simd_select_bitmask(k, shf, i32x16::ZERO)) @@ -21785,7 +22545,13 @@ pub fn _mm512_maskz_srlv_epi32(k: __mmask16, a: __m512i, count: __m512i) -> __m5 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm256_mask_srlv_epi32(src: __m256i, k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srlv_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_srlv_epi32(a, count).as_i32x8(); transmute(simd_select_bitmask(k, shf, src.as_i32x8())) @@ -21799,7 +22565,8 @@ pub fn _mm256_mask_srlv_epi32(src: __m256i, k: __mmask8, a: __m256i, count: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm256_maskz_srlv_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srlv_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_srlv_epi32(a, count).as_i32x8(); transmute(simd_select_bitmask(k, shf, i32x8::ZERO)) @@ -21813,7 +22580,8 @@ pub fn _mm256_maskz_srlv_epi32(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm_mask_srlv_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srlv_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srlv_epi32(a, count).as_i32x4(); transmute(simd_select_bitmask(k, shf, src.as_i32x4())) @@ -21827,7 +22595,8 @@ pub fn _mm_mask_srlv_epi32(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] -pub fn _mm_maskz_srlv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srlv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srlv_epi32(a, count).as_i32x4(); transmute(simd_select_bitmask(k, shf, i32x4::ZERO)) @@ -21841,7 +22610,8 @@ pub fn _mm_maskz_srlv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm512_sllv_epi64(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sllv_epi64(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u64x8(); let no_overflow: u64x8 = simd_lt(count, u64x8::splat(u64::BITS as u64)); @@ -21857,7 +22627,13 @@ pub fn _mm512_sllv_epi64(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm512_mask_sllv_epi64(src: __m512i, k: __mmask8, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sllv_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_sllv_epi64(a, count).as_i64x8(); transmute(simd_select_bitmask(k, shf, src.as_i64x8())) @@ -21871,7 +22647,8 @@ pub fn _mm512_mask_sllv_epi64(src: __m512i, k: __mmask8, a: __m512i, count: __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm512_maskz_sllv_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sllv_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_sllv_epi64(a, count).as_i64x8(); transmute(simd_select_bitmask(k, shf, i64x8::ZERO)) @@ -21885,7 +22662,13 @@ pub fn _mm512_maskz_sllv_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m51 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm256_mask_sllv_epi64(src: __m256i, k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sllv_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_sllv_epi64(a, count).as_i64x4(); transmute(simd_select_bitmask(k, shf, src.as_i64x4())) @@ -21899,7 +22682,8 @@ pub fn _mm256_mask_sllv_epi64(src: __m256i, k: __mmask8, a: __m256i, count: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm256_maskz_sllv_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sllv_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_sllv_epi64(a, count).as_i64x4(); transmute(simd_select_bitmask(k, shf, i64x4::ZERO)) @@ -21913,7 +22697,8 @@ pub fn _mm256_maskz_sllv_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm_mask_sllv_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sllv_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_sllv_epi64(a, count).as_i64x2(); transmute(simd_select_bitmask(k, shf, src.as_i64x2())) @@ -21927,7 +22712,8 @@ pub fn _mm_mask_sllv_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] -pub fn _mm_maskz_sllv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sllv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_sllv_epi64(a, count).as_i64x2(); transmute(simd_select_bitmask(k, shf, i64x2::ZERO)) @@ -21941,7 +22727,8 @@ pub fn _mm_maskz_sllv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm512_srlv_epi64(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srlv_epi64(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u64x8(); let no_overflow: u64x8 = simd_lt(count, u64x8::splat(u64::BITS as u64)); @@ -21957,7 +22744,13 @@ pub fn _mm512_srlv_epi64(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm512_mask_srlv_epi64(src: __m512i, k: __mmask8, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srlv_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_srlv_epi64(a, count).as_i64x8(); transmute(simd_select_bitmask(k, shf, src.as_i64x8())) @@ -21971,7 +22764,8 @@ pub fn _mm512_mask_srlv_epi64(src: __m512i, k: __mmask8, a: __m512i, count: __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm512_maskz_srlv_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srlv_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_srlv_epi64(a, count).as_i64x8(); transmute(simd_select_bitmask(k, shf, i64x8::ZERO)) @@ -21985,7 +22779,13 @@ pub fn _mm512_maskz_srlv_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m51 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm256_mask_srlv_epi64(src: __m256i, k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srlv_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_srlv_epi64(a, count).as_i64x4(); transmute(simd_select_bitmask(k, shf, src.as_i64x4())) @@ -21999,7 +22799,8 @@ pub fn _mm256_mask_srlv_epi64(src: __m256i, k: __mmask8, a: __m256i, count: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm256_maskz_srlv_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srlv_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_srlv_epi64(a, count).as_i64x4(); transmute(simd_select_bitmask(k, shf, i64x4::ZERO)) @@ -22013,7 +22814,8 @@ pub fn _mm256_maskz_srlv_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm_mask_srlv_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srlv_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srlv_epi64(a, count).as_i64x2(); transmute(simd_select_bitmask(k, shf, src.as_i64x2())) @@ -22027,7 +22829,8 @@ pub fn _mm_mask_srlv_epi64(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] -pub fn _mm_maskz_srlv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srlv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srlv_epi64(a, count).as_i64x2(); transmute(simd_select_bitmask(k, shf, i64x2::ZERO)) @@ -22042,7 +22845,8 @@ pub fn _mm_maskz_srlv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_permute_ps(a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_permute_ps(a: __m512) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -22078,7 +22882,12 @@ pub fn _mm512_permute_ps(a: __m512) -> __m512 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_permute_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_permute_ps( + src: __m512, + k: __mmask16, + a: __m512, +) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_permute_ps::(a); @@ -22094,7 +22903,8 @@ pub fn _mm512_mask_permute_ps(src: __m512, k: __mmask16, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_permute_ps(k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_permute_ps(k: __mmask16, a: __m512) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_permute_ps::(a); @@ -22110,7 +22920,12 @@ pub fn _mm512_maskz_permute_ps(k: __mmask16, a: __m512) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_permute_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_permute_ps( + src: __m256, + k: __mmask8, + a: __m256, +) -> __m256 { unsafe { let r = _mm256_permute_ps::(a); transmute(simd_select_bitmask(k, r.as_f32x8(), src.as_f32x8())) @@ -22125,7 +22940,8 @@ pub fn _mm256_mask_permute_ps(src: __m256, k: __mmask8, a: __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_permute_ps(k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_permute_ps(k: __mmask8, a: __m256) -> __m256 { unsafe { let r = _mm256_permute_ps::(a); transmute(simd_select_bitmask(k, r.as_f32x8(), f32x8::ZERO)) @@ -22140,7 +22956,8 @@ pub fn _mm256_maskz_permute_ps(k: __mmask8, a: __m256) -> __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_permute_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_permute_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { unsafe { let r = _mm_permute_ps::(a); transmute(simd_select_bitmask(k, r.as_f32x4(), src.as_f32x4())) @@ -22155,7 +22972,8 @@ pub fn _mm_mask_permute_ps(src: __m128, k: __mmask8, a: __m128) #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 0b11_00_01_11))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_permute_ps(k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_permute_ps(k: __mmask8, a: __m128) -> __m128 { unsafe { let r = _mm_permute_ps::(a); transmute(simd_select_bitmask(k, r.as_f32x4(), f32x4::ZERO)) @@ -22170,7 +22988,8 @@ pub fn _mm_maskz_permute_ps(k: __mmask8, a: __m128) -> __m128 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 0b11_01_10_01))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_permute_pd(a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_permute_pd(a: __m512d) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -22198,7 +23017,12 @@ pub fn _mm512_permute_pd(a: __m512d) -> __m512d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 0b11_01_10_01))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_permute_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_permute_pd( + src: __m512d, + k: __mmask8, + a: __m512d, +) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_permute_pd::(a); @@ -22214,7 +23038,8 @@ pub fn _mm512_mask_permute_pd(src: __m512d, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 0b11_01_10_01))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_permute_pd(k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_permute_pd(k: __mmask8, a: __m512d) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_permute_pd::(a); @@ -22230,7 +23055,12 @@ pub fn _mm512_maskz_permute_pd(k: __mmask8, a: __m512d) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 0b11_01))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_permute_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_permute_pd( + src: __m256d, + k: __mmask8, + a: __m256d, +) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 4); let r = _mm256_permute_pd::(a); @@ -22246,7 +23076,8 @@ pub fn _mm256_mask_permute_pd(src: __m256d, k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 0b11_01))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_permute_pd(k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_permute_pd(k: __mmask8, a: __m256d) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 4); let r = _mm256_permute_pd::(a); @@ -22262,7 +23093,12 @@ pub fn _mm256_maskz_permute_pd(k: __mmask8, a: __m256d) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, IMM2 = 0b01))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_permute_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_permute_pd( + src: __m128d, + k: __mmask8, + a: __m128d, +) -> __m128d { unsafe { static_assert_uimm_bits!(IMM2, 2); let r = _mm_permute_pd::(a); @@ -22278,7 +23114,8 @@ pub fn _mm_mask_permute_pd(src: __m128d, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, IMM2 = 0b01))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_permute_pd(k: __mmask8, a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_permute_pd(k: __mmask8, a: __m128d) -> __m128d { unsafe { static_assert_uimm_bits!(IMM2, 2); let r = _mm_permute_pd::(a); @@ -22294,7 +23131,8 @@ pub fn _mm_maskz_permute_pd(k: __mmask8, a: __m128d) -> __m128d #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermq #[rustc_legacy_const_generics(1)] -pub fn _mm512_permutex_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_permutex_epi64(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -22322,7 +23160,8 @@ pub fn _mm512_permutex_epi64(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermq #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_permutex_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_permutex_epi64( src: __m512i, k: __mmask8, a: __m512i, @@ -22342,7 +23181,8 @@ pub fn _mm512_mask_permutex_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermq #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_permutex_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_permutex_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_permutex_epi64::(a); @@ -22358,7 +23198,8 @@ pub fn _mm512_maskz_permutex_epi64(k: __mmask8, a: __m512i) -> #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermq #[rustc_legacy_const_generics(1)] -pub fn _mm256_permutex_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permutex_epi64(a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -22382,7 +23223,8 @@ pub fn _mm256_permutex_epi64(a: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermq #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_permutex_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_permutex_epi64( src: __m256i, k: __mmask8, a: __m256i, @@ -22402,7 +23244,8 @@ pub fn _mm256_mask_permutex_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermq #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_permutex_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_permutex_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_permutex_epi64::(a); @@ -22418,7 +23261,8 @@ pub fn _mm256_maskz_permutex_epi64(k: __mmask8, a: __m256i) -> #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermpd #[rustc_legacy_const_generics(1)] -pub fn _mm512_permutex_pd(a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_permutex_pd(a: __m512d) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -22446,7 +23290,12 @@ pub fn _mm512_permutex_pd(a: __m512d) -> __m512d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermpd #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_permutex_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_permutex_pd( + src: __m512d, + k: __mmask8, + a: __m512d, +) -> __m512d { unsafe { let r = _mm512_permutex_pd::(a); transmute(simd_select_bitmask(k, r.as_f64x8(), src.as_f64x8())) @@ -22461,7 +23310,8 @@ pub fn _mm512_mask_permutex_pd(src: __m512d, k: __mmask8, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermpd #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_permutex_pd(k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_permutex_pd(k: __mmask8, a: __m512d) -> __m512d { unsafe { let r = _mm512_permutex_pd::(a); transmute(simd_select_bitmask(k, r.as_f64x8(), f64x8::ZERO)) @@ -22476,7 +23326,8 @@ pub fn _mm512_maskz_permutex_pd(k: __mmask8, a: __m512d) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermpd #[rustc_legacy_const_generics(1)] -pub fn _mm256_permutex_pd(a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_permutex_pd(a: __m256d) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -22500,7 +23351,12 @@ pub fn _mm256_permutex_pd(a: __m256d) -> __m256d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermpd #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_permutex_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_permutex_pd( + src: __m256d, + k: __mmask8, + a: __m256d, +) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_permutex_pd::(a); @@ -22516,7 +23372,8 @@ pub fn _mm256_mask_permutex_pd(src: __m256d, k: __mmask8, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b10_01_10_11))] //should be vpermpd #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_permutex_pd(k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_permutex_pd(k: __mmask8, a: __m256d) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_permutex_pd::(a); @@ -23786,7 +24643,8 @@ pub fn _mm_mask2_permutex2var_pd(a: __m128d, idx: __m128i, k: __mmask8, b: __m12 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 9))] //should be vpshufd #[rustc_legacy_const_generics(1)] -pub fn _mm512_shuffle_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_epi32(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); let r: i32x16 = simd_shuffle!( @@ -23823,7 +24681,8 @@ pub fn _mm512_shuffle_epi32(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufd, MASK = 9))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_shuffle_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_epi32( src: __m512i, k: __mmask16, a: __m512i, @@ -23843,7 +24702,11 @@ pub fn _mm512_mask_shuffle_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufd, MASK = 9))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_shuffle_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_epi32( + k: __mmask16, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_shuffle_epi32::(a); @@ -23859,7 +24722,8 @@ pub fn _mm512_maskz_shuffle_epi32(k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufd, MASK = 9))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_shuffle_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_epi32( src: __m256i, k: __mmask8, a: __m256i, @@ -23879,7 +24743,11 @@ pub fn _mm256_mask_shuffle_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufd, MASK = 9))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_shuffle_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_epi32( + k: __mmask8, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_epi32::(a); @@ -23895,7 +24763,8 @@ pub fn _mm256_maskz_shuffle_epi32(k: __mmask8, a: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufd, MASK = 9))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_shuffle_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shuffle_epi32( src: __m128i, k: __mmask8, a: __m128i, @@ -23915,7 +24784,11 @@ pub fn _mm_mask_shuffle_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufd, MASK = 9))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_shuffle_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shuffle_epi32( + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm_shuffle_epi32::(a); @@ -23931,7 +24804,8 @@ pub fn _mm_maskz_shuffle_epi32(k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shuffle_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_ps(a: __m512, b: __m512) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -23967,7 +24841,8 @@ pub fn _mm512_shuffle_ps(a: __m512, b: __m512) -> __m512 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shuffle_ps( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_ps( src: __m512, k: __mmask16, a: __m512, @@ -23988,7 +24863,12 @@ pub fn _mm512_mask_shuffle_ps( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shuffle_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_ps( + k: __mmask16, + a: __m512, + b: __m512, +) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_shuffle_ps::(a, b); @@ -24004,7 +24884,8 @@ pub fn _mm512_maskz_shuffle_ps(k: __mmask16, a: __m512, b: __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shuffle_ps( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_ps( src: __m256, k: __mmask8, a: __m256, @@ -24025,7 +24906,8 @@ pub fn _mm256_mask_shuffle_ps( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shuffle_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_ps::(a, b); @@ -24041,7 +24923,8 @@ pub fn _mm256_maskz_shuffle_ps(k: __mmask8, a: __m256, b: __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shuffle_ps( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shuffle_ps( src: __m128, k: __mmask8, a: __m128, @@ -24062,7 +24945,8 @@ pub fn _mm_mask_shuffle_ps( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufps, MASK = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shuffle_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shuffle_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm_shuffle_ps::(a, b); @@ -24078,7 +24962,8 @@ pub fn _mm_maskz_shuffle_ps(k: __mmask8, a: __m128, b: __m128) #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 3))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shuffle_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); simd_shuffle!( @@ -24106,7 +24991,8 @@ pub fn _mm512_shuffle_pd(a: __m512d, b: __m512d) -> __m512d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 3))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shuffle_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_pd( src: __m512d, k: __mmask8, a: __m512d, @@ -24127,7 +25013,12 @@ pub fn _mm512_mask_shuffle_pd( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shuffle_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_pd( + k: __mmask8, + a: __m512d, + b: __m512d, +) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_shuffle_pd::(a, b); @@ -24143,7 +25034,8 @@ pub fn _mm512_maskz_shuffle_pd(k: __mmask8, a: __m512d, b: __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 3))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shuffle_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_pd( src: __m256d, k: __mmask8, a: __m256d, @@ -24164,7 +25056,12 @@ pub fn _mm256_mask_shuffle_pd( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shuffle_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_pd( + k: __mmask8, + a: __m256d, + b: __m256d, +) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_pd::(a, b); @@ -24180,7 +25077,8 @@ pub fn _mm256_maskz_shuffle_pd(k: __mmask8, a: __m256d, b: __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shuffle_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shuffle_pd( src: __m128d, k: __mmask8, a: __m128d, @@ -24201,7 +25099,8 @@ pub fn _mm_mask_shuffle_pd( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufpd, MASK = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shuffle_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shuffle_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm_shuffle_pd::(a, b); @@ -24217,7 +25116,8 @@ pub fn _mm_maskz_shuffle_pd(k: __mmask8, a: __m128d, b: __m128d #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi64x2, MASK = 0b10_01_01_01))] //should be vshufi32x4 #[rustc_legacy_const_generics(2)] -pub fn _mm512_shuffle_i32x4(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_i32x4(a: __m512i, b: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_i32x16(); @@ -24256,7 +25156,8 @@ pub fn _mm512_shuffle_i32x4(a: __m512i, b: __m512i) -> __m512i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi32x4, MASK = 0b10_11_01_01))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shuffle_i32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_i32x4( src: __m512i, k: __mmask16, a: __m512i, @@ -24277,7 +25178,8 @@ pub fn _mm512_mask_shuffle_i32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi32x4, MASK = 0b10_11_01_01))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shuffle_i32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_i32x4( k: __mmask16, a: __m512i, b: __m512i, @@ -24297,7 +25199,8 @@ pub fn _mm512_maskz_shuffle_i32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b11))] //should be vshufi32x4 #[rustc_legacy_const_generics(2)] -pub fn _mm256_shuffle_i32x4(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_i32x4(a: __m256i, b: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_i32x8(); @@ -24328,7 +25231,8 @@ pub fn _mm256_shuffle_i32x4(a: __m256i, b: __m256i) -> __m256i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi32x4, MASK = 0b11))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shuffle_i32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_i32x4( src: __m256i, k: __mmask8, a: __m256i, @@ -24349,7 +25253,12 @@ pub fn _mm256_mask_shuffle_i32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi32x4, MASK = 0b11))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shuffle_i32x4(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_i32x4( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_i32x4::(a, b); @@ -24365,7 +25274,8 @@ pub fn _mm256_maskz_shuffle_i32x4(k: __mmask8, a: __m256i, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi64x2, MASK = 0b10_11_11_11))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shuffle_i64x2(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_i64x2(a: __m512i, b: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_i64x8(); @@ -24396,7 +25306,8 @@ pub fn _mm512_shuffle_i64x2(a: __m512i, b: __m512i) -> __m512i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi64x2, MASK = 0b10_11_11_11))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shuffle_i64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_i64x2( src: __m512i, k: __mmask8, a: __m512i, @@ -24417,7 +25328,12 @@ pub fn _mm512_mask_shuffle_i64x2( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi64x2, MASK = 0b10_11_11_11))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shuffle_i64x2(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_i64x2( + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_shuffle_i64x2::(a, b); @@ -24433,7 +25349,8 @@ pub fn _mm512_maskz_shuffle_i64x2(k: __mmask8, a: __m512i, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b01))] //should be vshufi64x2 #[rustc_legacy_const_generics(2)] -pub fn _mm256_shuffle_i64x2(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_i64x2(a: __m256i, b: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_i64x4(); @@ -24460,7 +25377,8 @@ pub fn _mm256_shuffle_i64x2(a: __m256i, b: __m256i) -> __m256i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi64x2, MASK = 0b11))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shuffle_i64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_i64x2( src: __m256i, k: __mmask8, a: __m256i, @@ -24481,7 +25399,12 @@ pub fn _mm256_mask_shuffle_i64x2( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshufi64x2, MASK = 0b11))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shuffle_i64x2(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_i64x2( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_i64x2::(a, b); @@ -24497,7 +25420,8 @@ pub fn _mm256_maskz_shuffle_i64x2(k: __mmask8, a: __m256i, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff64x2, MASK = 0b1011))] //should be vshuff32x4, but generate vshuff64x2 #[rustc_legacy_const_generics(2)] -pub fn _mm512_shuffle_f32x4(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_f32x4(a: __m512, b: __m512) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_f32x16(); @@ -24536,7 +25460,8 @@ pub fn _mm512_shuffle_f32x4(a: __m512, b: __m512) -> __m512 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff32x4, MASK = 0b1011))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shuffle_f32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_f32x4( src: __m512, k: __mmask16, a: __m512, @@ -24557,7 +25482,12 @@ pub fn _mm512_mask_shuffle_f32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff32x4, MASK = 0b1011))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shuffle_f32x4(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_f32x4( + k: __mmask16, + a: __m512, + b: __m512, +) -> __m512 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_shuffle_f32x4::(a, b); @@ -24573,7 +25503,8 @@ pub fn _mm512_maskz_shuffle_f32x4(k: __mmask16, a: __m512, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b01))] //should be vshuff32x4 #[rustc_legacy_const_generics(2)] -pub fn _mm256_shuffle_f32x4(a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_f32x4(a: __m256, b: __m256) -> __m256 { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_f32x8(); @@ -24604,7 +25535,8 @@ pub fn _mm256_shuffle_f32x4(a: __m256, b: __m256) -> __m256 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff32x4, MASK = 0b11))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shuffle_f32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_f32x4( src: __m256, k: __mmask8, a: __m256, @@ -24625,7 +25557,12 @@ pub fn _mm256_mask_shuffle_f32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff32x4, MASK = 0b11))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shuffle_f32x4(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_f32x4( + k: __mmask8, + a: __m256, + b: __m256, +) -> __m256 { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_f32x4::(a, b); @@ -24641,7 +25578,8 @@ pub fn _mm256_maskz_shuffle_f32x4(k: __mmask8, a: __m256, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff64x2, MASK = 0b10_11_11_11))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shuffle_f64x2(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shuffle_f64x2(a: __m512d, b: __m512d) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_f64x8(); @@ -24672,7 +25610,8 @@ pub fn _mm512_shuffle_f64x2(a: __m512d, b: __m512d) -> __m512d #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff64x2, MASK = 0b10_11_11_11))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shuffle_f64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shuffle_f64x2( src: __m512d, k: __mmask8, a: __m512d, @@ -24693,7 +25632,12 @@ pub fn _mm512_mask_shuffle_f64x2( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff64x2, MASK = 0b10_11_11_11))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shuffle_f64x2(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shuffle_f64x2( + k: __mmask8, + a: __m512d, + b: __m512d, +) -> __m512d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm512_shuffle_f64x2::(a, b); @@ -24709,7 +25653,8 @@ pub fn _mm512_maskz_shuffle_f64x2(k: __mmask8, a: __m512d, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vperm, MASK = 0b01))] //should be vshuff64x2 #[rustc_legacy_const_generics(2)] -pub fn _mm256_shuffle_f64x2(a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shuffle_f64x2(a: __m256d, b: __m256d) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 8); let a = a.as_f64x4(); @@ -24736,7 +25681,8 @@ pub fn _mm256_shuffle_f64x2(a: __m256d, b: __m256d) -> __m256d #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff64x2, MASK = 0b11))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shuffle_f64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shuffle_f64x2( src: __m256d, k: __mmask8, a: __m256d, @@ -24757,7 +25703,12 @@ pub fn _mm256_mask_shuffle_f64x2( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vshuff64x2, MASK = 0b11))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shuffle_f64x2(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shuffle_f64x2( + k: __mmask8, + a: __m256d, + b: __m256d, +) -> __m256d { unsafe { static_assert_uimm_bits!(MASK, 8); let r = _mm256_shuffle_f64x2::(a, b); @@ -24773,7 +25724,8 @@ pub fn _mm256_maskz_shuffle_f64x2(k: __mmask8, a: __m256d, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf32x4, IMM8 = 3))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_extractf32x4_ps(a: __m512) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extractf32x4_ps(a: __m512) -> __m128 { unsafe { static_assert_uimm_bits!(IMM8, 2); match IMM8 & 0x3 { @@ -24793,7 +25745,12 @@ pub fn _mm512_extractf32x4_ps(a: __m512) -> __m128 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf32x4, IMM8 = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_extractf32x4_ps(src: __m128, k: __mmask8, a: __m512) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extractf32x4_ps( + src: __m128, + k: __mmask8, + a: __m512, +) -> __m128 { unsafe { static_assert_uimm_bits!(IMM8, 2); let r = _mm512_extractf32x4_ps::(a); @@ -24809,7 +25766,8 @@ pub fn _mm512_mask_extractf32x4_ps(src: __m128, k: __mmask8, a: #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf32x4, IMM8 = 3))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_extractf32x4_ps(k: __mmask8, a: __m512) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extractf32x4_ps(k: __mmask8, a: __m512) -> __m128 { unsafe { static_assert_uimm_bits!(IMM8, 2); let r = _mm512_extractf32x4_ps::(a); @@ -24828,7 +25786,8 @@ pub fn _mm512_maskz_extractf32x4_ps(k: __mmask8, a: __m512) -> assert_instr(vextract, IMM8 = 1) //should be vextractf32x4 )] #[rustc_legacy_const_generics(1)] -pub fn _mm256_extractf32x4_ps(a: __m256) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extractf32x4_ps(a: __m256) -> __m128 { unsafe { static_assert_uimm_bits!(IMM8, 1); match IMM8 & 0x1 { @@ -24846,7 +25805,12 @@ pub fn _mm256_extractf32x4_ps(a: __m256) -> __m128 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf32x4, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_extractf32x4_ps(src: __m128, k: __mmask8, a: __m256) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_extractf32x4_ps( + src: __m128, + k: __mmask8, + a: __m256, +) -> __m128 { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm256_extractf32x4_ps::(a); @@ -24862,7 +25826,8 @@ pub fn _mm256_mask_extractf32x4_ps(src: __m128, k: __mmask8, a: #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf32x4, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_extractf32x4_ps(k: __mmask8, a: __m256) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_extractf32x4_ps(k: __mmask8, a: __m256) -> __m128 { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm256_extractf32x4_ps::(a); @@ -24881,7 +25846,8 @@ pub fn _mm256_maskz_extractf32x4_ps(k: __mmask8, a: __m256) -> assert_instr(vextractf64x4, IMM1 = 1) //should be vextracti64x4 )] #[rustc_legacy_const_generics(1)] -pub fn _mm512_extracti64x4_epi64(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extracti64x4_epi64(a: __m512i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM1, 1); match IMM1 { @@ -24899,7 +25865,8 @@ pub fn _mm512_extracti64x4_epi64(a: __m512i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextracti64x4, IMM1 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_extracti64x4_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extracti64x4_epi64( src: __m256i, k: __mmask8, a: __m512i, @@ -24919,7 +25886,8 @@ pub fn _mm512_mask_extracti64x4_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextracti64x4, IMM1 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_extracti64x4_epi64(k: __mmask8, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extracti64x4_epi64(k: __mmask8, a: __m512i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM1, 1); let r = _mm512_extracti64x4_epi64::(a); @@ -24935,7 +25903,8 @@ pub fn _mm512_maskz_extracti64x4_epi64(k: __mmask8, a: __m512i) #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf64x4, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_extractf64x4_pd(a: __m512d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extractf64x4_pd(a: __m512d) -> __m256d { unsafe { static_assert_uimm_bits!(IMM8, 1); match IMM8 & 0x1 { @@ -24953,7 +25922,8 @@ pub fn _mm512_extractf64x4_pd(a: __m512d) -> __m256d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf64x4, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_extractf64x4_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extractf64x4_pd( src: __m256d, k: __mmask8, a: __m512d, @@ -24973,7 +25943,8 @@ pub fn _mm512_mask_extractf64x4_pd( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextractf64x4, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_extractf64x4_pd(k: __mmask8, a: __m512d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extractf64x4_pd(k: __mmask8, a: __m512d) -> __m256d { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm512_extractf64x4_pd::(a); @@ -24992,7 +25963,8 @@ pub fn _mm512_maskz_extractf64x4_pd(k: __mmask8, a: __m512d) -> assert_instr(vextractf32x4, IMM2 = 3) //should be vextracti32x4 )] #[rustc_legacy_const_generics(1)] -pub fn _mm512_extracti32x4_epi32(a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extracti32x4_epi32(a: __m512i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM2, 2); let a = a.as_i32x16(); @@ -25015,7 +25987,8 @@ pub fn _mm512_extracti32x4_epi32(a: __m512i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextracti32x4, IMM2 = 3))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_extracti32x4_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extracti32x4_epi32( src: __m128i, k: __mmask8, a: __m512i, @@ -25035,7 +26008,8 @@ pub fn _mm512_mask_extracti32x4_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextracti32x4, IMM2 = 3))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_extracti32x4_epi32(k: __mmask8, a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extracti32x4_epi32(k: __mmask8, a: __m512i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM2, 2); let r = _mm512_extracti32x4_epi32::(a); @@ -25054,7 +26028,8 @@ pub fn _mm512_maskz_extracti32x4_epi32(k: __mmask8, a: __m512i) assert_instr(vextract, IMM1 = 1) //should be vextracti32x4 )] #[rustc_legacy_const_generics(1)] -pub fn _mm256_extracti32x4_epi32(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extracti32x4_epi32(a: __m256i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM1, 1); let a = a.as_i32x8(); @@ -25075,7 +26050,8 @@ pub fn _mm256_extracti32x4_epi32(a: __m256i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextracti32x4, IMM1 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_extracti32x4_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_extracti32x4_epi32( src: __m128i, k: __mmask8, a: __m256i, @@ -25095,7 +26071,8 @@ pub fn _mm256_mask_extracti32x4_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vextracti32x4, IMM1 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_extracti32x4_epi32(k: __mmask8, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_extracti32x4_epi32(k: __mmask8, a: __m256i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM1, 1); let r = _mm256_extracti32x4_epi32::(a); @@ -25110,7 +26087,8 @@ pub fn _mm256_maskz_extracti32x4_epi32(k: __mmask8, a: __m256i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm512_moveldup_ps(a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_moveldup_ps(a: __m512) -> __m512 { unsafe { let r: f32x16 = simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14]); transmute(r) @@ -25124,7 +26102,8 @@ pub fn _mm512_moveldup_ps(a: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm512_mask_moveldup_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_moveldup_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { unsafe { let mov: f32x16 = simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14]); @@ -25139,7 +26118,8 @@ pub fn _mm512_mask_moveldup_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm512_maskz_moveldup_ps(k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_moveldup_ps(k: __mmask16, a: __m512) -> __m512 { unsafe { let mov: f32x16 = simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14]); @@ -25154,7 +26134,8 @@ pub fn _mm512_maskz_moveldup_ps(k: __mmask16, a: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm256_mask_moveldup_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_moveldup_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { unsafe { let mov = _mm256_moveldup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x8(), src.as_f32x8())) @@ -25168,7 +26149,8 @@ pub fn _mm256_mask_moveldup_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm256_maskz_moveldup_ps(k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_moveldup_ps(k: __mmask8, a: __m256) -> __m256 { unsafe { let mov = _mm256_moveldup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x8(), f32x8::ZERO)) @@ -25182,7 +26164,8 @@ pub fn _mm256_maskz_moveldup_ps(k: __mmask8, a: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm_mask_moveldup_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_moveldup_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { unsafe { let mov = _mm_moveldup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x4(), src.as_f32x4())) @@ -25196,7 +26179,8 @@ pub fn _mm_mask_moveldup_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsldup))] -pub fn _mm_maskz_moveldup_ps(k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_moveldup_ps(k: __mmask8, a: __m128) -> __m128 { unsafe { let mov = _mm_moveldup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x4(), f32x4::ZERO)) @@ -25210,7 +26194,8 @@ pub fn _mm_maskz_moveldup_ps(k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm512_movehdup_ps(a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movehdup_ps(a: __m512) -> __m512 { unsafe { let r: f32x16 = simd_shuffle!(a, a, [1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15]); transmute(r) @@ -25224,7 +26209,8 @@ pub fn _mm512_movehdup_ps(a: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm512_mask_movehdup_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_movehdup_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { unsafe { let mov: f32x16 = simd_shuffle!(a, a, [1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15]); @@ -25239,7 +26225,8 @@ pub fn _mm512_mask_movehdup_ps(src: __m512, k: __mmask16, a: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm512_maskz_movehdup_ps(k: __mmask16, a: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_movehdup_ps(k: __mmask16, a: __m512) -> __m512 { unsafe { let mov: f32x16 = simd_shuffle!(a, a, [1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15]); @@ -25254,7 +26241,8 @@ pub fn _mm512_maskz_movehdup_ps(k: __mmask16, a: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm256_mask_movehdup_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_movehdup_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { unsafe { let mov = _mm256_movehdup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x8(), src.as_f32x8())) @@ -25268,7 +26256,8 @@ pub fn _mm256_mask_movehdup_ps(src: __m256, k: __mmask8, a: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm256_maskz_movehdup_ps(k: __mmask8, a: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_movehdup_ps(k: __mmask8, a: __m256) -> __m256 { unsafe { let mov = _mm256_movehdup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x8(), f32x8::ZERO)) @@ -25282,7 +26271,8 @@ pub fn _mm256_maskz_movehdup_ps(k: __mmask8, a: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm_mask_movehdup_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_movehdup_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { unsafe { let mov = _mm_movehdup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x4(), src.as_f32x4())) @@ -25296,7 +26286,8 @@ pub fn _mm_mask_movehdup_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovshdup))] -pub fn _mm_maskz_movehdup_ps(k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_movehdup_ps(k: __mmask8, a: __m128) -> __m128 { unsafe { let mov = _mm_movehdup_ps(a); transmute(simd_select_bitmask(k, mov.as_f32x4(), f32x4::ZERO)) @@ -25310,7 +26301,8 @@ pub fn _mm_maskz_movehdup_ps(k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm512_movedup_pd(a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movedup_pd(a: __m512d) -> __m512d { unsafe { let r: f64x8 = simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6]); transmute(r) @@ -25324,7 +26316,8 @@ pub fn _mm512_movedup_pd(a: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm512_mask_movedup_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_movedup_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d { unsafe { let mov: f64x8 = simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6]); transmute(simd_select_bitmask(k, mov, src.as_f64x8())) @@ -25338,7 +26331,8 @@ pub fn _mm512_mask_movedup_pd(src: __m512d, k: __mmask8, a: __m512d) -> __m512d #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm512_maskz_movedup_pd(k: __mmask8, a: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_movedup_pd(k: __mmask8, a: __m512d) -> __m512d { unsafe { let mov: f64x8 = simd_shuffle!(a, a, [0, 0, 2, 2, 4, 4, 6, 6]); transmute(simd_select_bitmask(k, mov, f64x8::ZERO)) @@ -25352,7 +26346,8 @@ pub fn _mm512_maskz_movedup_pd(k: __mmask8, a: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm256_mask_movedup_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_movedup_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d { unsafe { let mov = _mm256_movedup_pd(a); transmute(simd_select_bitmask(k, mov.as_f64x4(), src.as_f64x4())) @@ -25366,7 +26361,8 @@ pub fn _mm256_mask_movedup_pd(src: __m256d, k: __mmask8, a: __m256d) -> __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm256_maskz_movedup_pd(k: __mmask8, a: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_movedup_pd(k: __mmask8, a: __m256d) -> __m256d { unsafe { let mov = _mm256_movedup_pd(a); transmute(simd_select_bitmask(k, mov.as_f64x4(), f64x4::ZERO)) @@ -25380,7 +26376,8 @@ pub fn _mm256_maskz_movedup_pd(k: __mmask8, a: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm_mask_movedup_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_movedup_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { unsafe { let mov = _mm_movedup_pd(a); transmute(simd_select_bitmask(k, mov.as_f64x2(), src.as_f64x2())) @@ -25394,7 +26391,8 @@ pub fn _mm_mask_movedup_pd(src: __m128d, k: __mmask8, a: __m128d) -> __m128d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovddup))] -pub fn _mm_maskz_movedup_pd(k: __mmask8, a: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_movedup_pd(k: __mmask8, a: __m128d) -> __m128d { unsafe { let mov = _mm_movedup_pd(a); transmute(simd_select_bitmask(k, mov.as_f64x2(), f64x2::ZERO)) @@ -25409,7 +26407,8 @@ pub fn _mm_maskz_movedup_pd(k: __mmask8, a: __m128d) -> __m128d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf32x4, IMM8 = 2))] //should be vinserti32x4 #[rustc_legacy_const_generics(2)] -pub fn _mm512_inserti32x4(a: __m512i, b: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_inserti32x4(a: __m512i, b: __m128i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 2); let a = a.as_i32x16(); @@ -25452,7 +26451,8 @@ pub fn _mm512_inserti32x4(a: __m512i, b: __m128i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinserti32x4, IMM8 = 2))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_inserti32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_inserti32x4( src: __m512i, k: __mmask16, a: __m512i, @@ -25473,7 +26473,12 @@ pub fn _mm512_mask_inserti32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinserti32x4, IMM8 = 2))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_inserti32x4(k: __mmask16, a: __m512i, b: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_inserti32x4( + k: __mmask16, + a: __m512i, + b: __m128i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 2); let r = _mm512_inserti32x4::(a, b); @@ -25492,7 +26497,8 @@ pub fn _mm512_maskz_inserti32x4(k: __mmask16, a: __m512i, b: __ assert_instr(vinsert, IMM8 = 1) //should be vinserti32x4 )] #[rustc_legacy_const_generics(2)] -pub fn _mm256_inserti32x4(a: __m256i, b: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_inserti32x4(a: __m256i, b: __m128i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 1); let a = a.as_i32x8(); @@ -25513,7 +26519,8 @@ pub fn _mm256_inserti32x4(a: __m256i, b: __m128i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinserti32x4, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_inserti32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_inserti32x4( src: __m256i, k: __mmask8, a: __m256i, @@ -25534,7 +26541,12 @@ pub fn _mm256_mask_inserti32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinserti32x4, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_inserti32x4(k: __mmask8, a: __m256i, b: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_inserti32x4( + k: __mmask8, + a: __m256i, + b: __m128i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm256_inserti32x4::(a, b); @@ -25550,7 +26562,8 @@ pub fn _mm256_maskz_inserti32x4(k: __mmask8, a: __m256i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf64x4, IMM8 = 1))] //should be vinserti64x4 #[rustc_legacy_const_generics(2)] -pub fn _mm512_inserti64x4(a: __m512i, b: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_inserti64x4(a: __m512i, b: __m256i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm512_castsi256_si512(b); @@ -25569,7 +26582,8 @@ pub fn _mm512_inserti64x4(a: __m512i, b: __m256i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinserti64x4, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_inserti64x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_inserti64x4( src: __m512i, k: __mmask8, a: __m512i, @@ -25590,7 +26604,12 @@ pub fn _mm512_mask_inserti64x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinserti64x4, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_inserti64x4(k: __mmask8, a: __m512i, b: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_inserti64x4( + k: __mmask8, + a: __m512i, + b: __m256i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm512_inserti64x4::(a, b); @@ -25606,7 +26625,8 @@ pub fn _mm512_maskz_inserti64x4(k: __mmask8, a: __m512i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf32x4, IMM8 = 2))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_insertf32x4(a: __m512, b: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_insertf32x4(a: __m512, b: __m128) -> __m512 { unsafe { static_assert_uimm_bits!(IMM8, 2); let b = _mm512_castps128_ps512(b); @@ -25647,7 +26667,8 @@ pub fn _mm512_insertf32x4(a: __m512, b: __m128) -> __m512 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf32x4, IMM8 = 2))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_insertf32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_insertf32x4( src: __m512, k: __mmask16, a: __m512, @@ -25668,7 +26689,12 @@ pub fn _mm512_mask_insertf32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf32x4, IMM8 = 2))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_insertf32x4(k: __mmask16, a: __m512, b: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_insertf32x4( + k: __mmask16, + a: __m512, + b: __m128, +) -> __m512 { unsafe { static_assert_uimm_bits!(IMM8, 2); let r = _mm512_insertf32x4::(a, b); @@ -25687,7 +26713,8 @@ pub fn _mm512_maskz_insertf32x4(k: __mmask16, a: __m512, b: __m assert_instr(vinsert, IMM8 = 1) //should be vinsertf32x4 )] #[rustc_legacy_const_generics(2)] -pub fn _mm256_insertf32x4(a: __m256, b: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insertf32x4(a: __m256, b: __m128) -> __m256 { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm256_castps128_ps256(b); @@ -25706,7 +26733,8 @@ pub fn _mm256_insertf32x4(a: __m256, b: __m128) -> __m256 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf32x4, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_insertf32x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_insertf32x4( src: __m256, k: __mmask8, a: __m256, @@ -25727,7 +26755,12 @@ pub fn _mm256_mask_insertf32x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf32x4, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_insertf32x4(k: __mmask8, a: __m256, b: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_insertf32x4( + k: __mmask8, + a: __m256, + b: __m128, +) -> __m256 { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm256_insertf32x4::(a, b); @@ -25743,7 +26776,8 @@ pub fn _mm256_maskz_insertf32x4(k: __mmask8, a: __m256, b: __m1 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf64x4, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_insertf64x4(a: __m512d, b: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_insertf64x4(a: __m512d, b: __m256d) -> __m512d { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm512_castpd256_pd512(b); @@ -25762,7 +26796,8 @@ pub fn _mm512_insertf64x4(a: __m512d, b: __m256d) -> __m512d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf64x4, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_insertf64x4( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_insertf64x4( src: __m512d, k: __mmask8, a: __m512d, @@ -25783,7 +26818,12 @@ pub fn _mm512_mask_insertf64x4( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vinsertf64x4, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_insertf64x4(k: __mmask8, a: __m512d, b: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_insertf64x4( + k: __mmask8, + a: __m512d, + b: __m256d, +) -> __m512d { unsafe { static_assert_uimm_bits!(IMM8, 1); let r = _mm512_insertf64x4::(a, b); @@ -25798,7 +26838,8 @@ pub fn _mm512_maskz_insertf64x4(k: __mmask8, a: __m512d, b: __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] //should be vpunpckhdq -pub fn _mm512_unpackhi_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpackhi_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_i32x16(); let b = b.as_i32x16(); @@ -25821,7 +26862,13 @@ pub fn _mm512_unpackhi_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhdq))] -pub fn _mm512_mask_unpackhi_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpackhi_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, unpackhi, src.as_i32x16())) @@ -25835,7 +26882,8 @@ pub fn _mm512_mask_unpackhi_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhdq))] -pub fn _mm512_maskz_unpackhi_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpackhi_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, unpackhi, i32x16::ZERO)) @@ -25849,7 +26897,13 @@ pub fn _mm512_maskz_unpackhi_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m5 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhdq))] -pub fn _mm256_mask_unpackhi_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpackhi_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, unpackhi, src.as_i32x8())) @@ -25863,7 +26917,8 @@ pub fn _mm256_mask_unpackhi_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhdq))] -pub fn _mm256_maskz_unpackhi_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpackhi_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, unpackhi, i32x8::ZERO)) @@ -25877,7 +26932,8 @@ pub fn _mm256_maskz_unpackhi_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhdq))] -pub fn _mm_mask_unpackhi_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpackhi_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, unpackhi, src.as_i32x4())) @@ -25891,7 +26947,8 @@ pub fn _mm_mask_unpackhi_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhdq))] -pub fn _mm_maskz_unpackhi_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpackhi_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, unpackhi, i32x4::ZERO)) @@ -25905,7 +26962,8 @@ pub fn _mm_maskz_unpackhi_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] //should be vpunpckhqdq -pub fn _mm512_unpackhi_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpackhi_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_shuffle!(a, b, [1, 9, 1 + 2, 9 + 2, 1 + 4, 9 + 4, 1 + 6, 9 + 6]) } } @@ -25916,7 +26974,13 @@ pub fn _mm512_unpackhi_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhqdq))] -pub fn _mm512_mask_unpackhi_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpackhi_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, unpackhi, src.as_i64x8())) @@ -25930,7 +26994,8 @@ pub fn _mm512_mask_unpackhi_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhqdq))] -pub fn _mm512_maskz_unpackhi_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpackhi_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, unpackhi, i64x8::ZERO)) @@ -25944,7 +27009,13 @@ pub fn _mm512_maskz_unpackhi_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m51 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhqdq))] -pub fn _mm256_mask_unpackhi_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpackhi_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, unpackhi, src.as_i64x4())) @@ -25958,7 +27029,8 @@ pub fn _mm256_mask_unpackhi_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhqdq))] -pub fn _mm256_maskz_unpackhi_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpackhi_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, unpackhi, i64x4::ZERO)) @@ -25972,7 +27044,8 @@ pub fn _mm256_maskz_unpackhi_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhqdq))] -pub fn _mm_mask_unpackhi_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpackhi_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, unpackhi, src.as_i64x2())) @@ -25986,7 +27059,8 @@ pub fn _mm_mask_unpackhi_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhqdq))] -pub fn _mm_maskz_unpackhi_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpackhi_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, unpackhi, i64x2::ZERO)) @@ -26000,7 +27074,8 @@ pub fn _mm_maskz_unpackhi_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm512_unpackhi_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpackhi_ps(a: __m512, b: __m512) -> __m512 { unsafe { #[rustfmt::skip] simd_shuffle!( @@ -26020,7 +27095,8 @@ pub fn _mm512_unpackhi_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm512_mask_unpackhi_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpackhi_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let unpackhi = _mm512_unpackhi_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, unpackhi, src.as_f32x16())) @@ -26034,7 +27110,8 @@ pub fn _mm512_mask_unpackhi_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm512_maskz_unpackhi_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpackhi_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let unpackhi = _mm512_unpackhi_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, unpackhi, f32x16::ZERO)) @@ -26048,7 +27125,8 @@ pub fn _mm512_maskz_unpackhi_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm256_mask_unpackhi_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpackhi_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let unpackhi = _mm256_unpackhi_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, unpackhi, src.as_f32x8())) @@ -26062,7 +27140,8 @@ pub fn _mm256_mask_unpackhi_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm256_maskz_unpackhi_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpackhi_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let unpackhi = _mm256_unpackhi_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, unpackhi, f32x8::ZERO)) @@ -26076,7 +27155,8 @@ pub fn _mm256_maskz_unpackhi_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm_mask_unpackhi_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpackhi_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let unpackhi = _mm_unpackhi_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, unpackhi, src.as_f32x4())) @@ -26090,7 +27170,8 @@ pub fn _mm_mask_unpackhi_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhps))] -pub fn _mm_maskz_unpackhi_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpackhi_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let unpackhi = _mm_unpackhi_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, unpackhi, f32x4::ZERO)) @@ -26104,7 +27185,8 @@ pub fn _mm_maskz_unpackhi_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm512_unpackhi_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpackhi_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { simd_shuffle!(a, b, [1, 9, 1 + 2, 9 + 2, 1 + 4, 9 + 4, 1 + 6, 9 + 6]) } } @@ -26115,7 +27197,8 @@ pub fn _mm512_unpackhi_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm512_mask_unpackhi_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpackhi_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let unpackhi = _mm512_unpackhi_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, unpackhi, src.as_f64x8())) @@ -26129,7 +27212,8 @@ pub fn _mm512_mask_unpackhi_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm512_maskz_unpackhi_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpackhi_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let unpackhi = _mm512_unpackhi_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, unpackhi, f64x8::ZERO)) @@ -26143,7 +27227,8 @@ pub fn _mm512_maskz_unpackhi_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm256_mask_unpackhi_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpackhi_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let unpackhi = _mm256_unpackhi_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, unpackhi, src.as_f64x4())) @@ -26157,7 +27242,8 @@ pub fn _mm256_mask_unpackhi_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm256_maskz_unpackhi_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpackhi_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let unpackhi = _mm256_unpackhi_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, unpackhi, f64x4::ZERO)) @@ -26171,7 +27257,8 @@ pub fn _mm256_maskz_unpackhi_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm_mask_unpackhi_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpackhi_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let unpackhi = _mm_unpackhi_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, unpackhi, src.as_f64x2())) @@ -26185,7 +27272,8 @@ pub fn _mm_mask_unpackhi_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpckhpd))] -pub fn _mm_maskz_unpackhi_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpackhi_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let unpackhi = _mm_unpackhi_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, unpackhi, f64x2::ZERO)) @@ -26199,7 +27287,8 @@ pub fn _mm_maskz_unpackhi_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] //should be vpunpckldq -pub fn _mm512_unpacklo_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpacklo_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_i32x16(); let b = b.as_i32x16(); @@ -26222,7 +27311,13 @@ pub fn _mm512_unpacklo_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckldq))] -pub fn _mm512_mask_unpacklo_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpacklo_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, unpacklo, src.as_i32x16())) @@ -26236,7 +27331,8 @@ pub fn _mm512_mask_unpacklo_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckldq))] -pub fn _mm512_maskz_unpacklo_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpacklo_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, unpacklo, i32x16::ZERO)) @@ -26250,7 +27346,13 @@ pub fn _mm512_maskz_unpacklo_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m5 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckldq))] -pub fn _mm256_mask_unpacklo_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpacklo_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, unpacklo, src.as_i32x8())) @@ -26264,7 +27366,8 @@ pub fn _mm256_mask_unpacklo_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckldq))] -pub fn _mm256_maskz_unpacklo_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpacklo_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, unpacklo, i32x8::ZERO)) @@ -26278,7 +27381,8 @@ pub fn _mm256_maskz_unpacklo_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckldq))] -pub fn _mm_mask_unpacklo_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpacklo_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, unpacklo, src.as_i32x4())) @@ -26292,7 +27396,8 @@ pub fn _mm_mask_unpacklo_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckldq))] -pub fn _mm_maskz_unpacklo_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpacklo_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, unpacklo, i32x4::ZERO)) @@ -26306,7 +27411,8 @@ pub fn _mm_maskz_unpacklo_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] //should be vpunpcklqdq -pub fn _mm512_unpacklo_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpacklo_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_shuffle!(a, b, [0, 8, 0 + 2, 8 + 2, 0 + 4, 8 + 4, 0 + 6, 8 + 6]) } } @@ -26317,7 +27423,13 @@ pub fn _mm512_unpacklo_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklqdq))] -pub fn _mm512_mask_unpacklo_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpacklo_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, unpacklo, src.as_i64x8())) @@ -26331,7 +27443,8 @@ pub fn _mm512_mask_unpacklo_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklqdq))] -pub fn _mm512_maskz_unpacklo_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpacklo_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, unpacklo, i64x8::ZERO)) @@ -26345,7 +27458,13 @@ pub fn _mm512_maskz_unpacklo_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m51 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklqdq))] -pub fn _mm256_mask_unpacklo_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpacklo_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, unpacklo, src.as_i64x4())) @@ -26359,7 +27478,8 @@ pub fn _mm256_mask_unpacklo_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklqdq))] -pub fn _mm256_maskz_unpacklo_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpacklo_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, unpacklo, i64x4::ZERO)) @@ -26373,7 +27493,8 @@ pub fn _mm256_maskz_unpacklo_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m25 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklqdq))] -pub fn _mm_mask_unpacklo_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpacklo_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, unpacklo, src.as_i64x2())) @@ -26387,7 +27508,8 @@ pub fn _mm_mask_unpacklo_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklqdq))] -pub fn _mm_maskz_unpacklo_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpacklo_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, unpacklo, i64x2::ZERO)) @@ -26401,7 +27523,8 @@ pub fn _mm_maskz_unpacklo_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm512_unpacklo_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpacklo_ps(a: __m512, b: __m512) -> __m512 { unsafe { #[rustfmt::skip] simd_shuffle!(a, b, @@ -26420,7 +27543,8 @@ pub fn _mm512_unpacklo_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm512_mask_unpacklo_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpacklo_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let unpacklo = _mm512_unpacklo_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, unpacklo, src.as_f32x16())) @@ -26434,7 +27558,8 @@ pub fn _mm512_mask_unpacklo_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm512_maskz_unpacklo_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpacklo_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let unpacklo = _mm512_unpacklo_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, unpacklo, f32x16::ZERO)) @@ -26448,7 +27573,8 @@ pub fn _mm512_maskz_unpacklo_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm256_mask_unpacklo_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpacklo_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let unpacklo = _mm256_unpacklo_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, unpacklo, src.as_f32x8())) @@ -26462,7 +27588,8 @@ pub fn _mm256_mask_unpacklo_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm256_maskz_unpacklo_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpacklo_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let unpacklo = _mm256_unpacklo_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, unpacklo, f32x8::ZERO)) @@ -26476,7 +27603,8 @@ pub fn _mm256_maskz_unpacklo_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm_mask_unpacklo_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpacklo_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let unpacklo = _mm_unpacklo_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, unpacklo, src.as_f32x4())) @@ -26490,7 +27618,8 @@ pub fn _mm_mask_unpacklo_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklps))] -pub fn _mm_maskz_unpacklo_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpacklo_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let unpacklo = _mm_unpacklo_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, unpacklo, f32x4::ZERO)) @@ -26504,7 +27633,8 @@ pub fn _mm_maskz_unpacklo_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm512_unpacklo_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpacklo_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { simd_shuffle!(a, b, [0, 8, 0 + 2, 8 + 2, 0 + 4, 8 + 4, 0 + 6, 8 + 6]) } } @@ -26515,7 +27645,8 @@ pub fn _mm512_unpacklo_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm512_mask_unpacklo_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpacklo_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let unpacklo = _mm512_unpacklo_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, unpacklo, src.as_f64x8())) @@ -26529,7 +27660,8 @@ pub fn _mm512_mask_unpacklo_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm512_maskz_unpacklo_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpacklo_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let unpacklo = _mm512_unpacklo_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, unpacklo, f64x8::ZERO)) @@ -26543,7 +27675,8 @@ pub fn _mm512_maskz_unpacklo_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm256_mask_unpacklo_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpacklo_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let unpacklo = _mm256_unpacklo_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, unpacklo, src.as_f64x4())) @@ -26557,7 +27690,8 @@ pub fn _mm256_mask_unpacklo_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm256_maskz_unpacklo_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpacklo_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let unpacklo = _mm256_unpacklo_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, unpacklo, f64x4::ZERO)) @@ -26571,7 +27705,8 @@ pub fn _mm256_maskz_unpacklo_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm_mask_unpacklo_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpacklo_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let unpacklo = _mm_unpacklo_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, unpacklo, src.as_f64x2())) @@ -26585,7 +27720,8 @@ pub fn _mm_mask_unpacklo_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vunpcklpd))] -pub fn _mm_maskz_unpacklo_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpacklo_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let unpacklo = _mm_unpacklo_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, unpacklo, f64x2::ZERO)) @@ -26598,7 +27734,8 @@ pub fn _mm_maskz_unpacklo_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castps128_ps512(a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps128_ps512(a: __m128) -> __m512 { unsafe { simd_shuffle!( a, @@ -26614,7 +27751,8 @@ pub fn _mm512_castps128_ps512(a: __m128) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castps256_ps512(a: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps256_ps512(a: __m256) -> __m512 { unsafe { simd_shuffle!( a, @@ -26630,7 +27768,8 @@ pub fn _mm512_castps256_ps512(a: __m256) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_zextps128_ps512(a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextps128_ps512(a: __m128) -> __m512 { unsafe { simd_shuffle!( a, @@ -26646,7 +27785,8 @@ pub fn _mm512_zextps128_ps512(a: __m128) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_zextps256_ps512(a: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextps256_ps512(a: __m256) -> __m512 { unsafe { simd_shuffle!( a, @@ -26662,7 +27802,8 @@ pub fn _mm512_zextps256_ps512(a: __m256) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castps512_ps128(a: __m512) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps512_ps128(a: __m512) -> __m128 { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3]) } } @@ -26672,7 +27813,8 @@ pub fn _mm512_castps512_ps128(a: __m512) -> __m128 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castps512_ps256(a: __m512) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps512_ps256(a: __m512) -> __m256 { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]) } } @@ -26682,7 +27824,8 @@ pub fn _mm512_castps512_ps256(a: __m512) -> __m256 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castps_pd(a: __m512) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps_pd(a: __m512) -> __m512d { unsafe { transmute(a) } } @@ -26692,7 +27835,8 @@ pub fn _mm512_castps_pd(a: __m512) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castps_si512(a: __m512) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps_si512(a: __m512) -> __m512i { unsafe { transmute(a) } } @@ -26702,7 +27846,8 @@ pub fn _mm512_castps_si512(a: __m512) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castpd128_pd512(a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd128_pd512(a: __m128d) -> __m512d { unsafe { simd_shuffle!(a, _mm_undefined_pd(), [0, 1, 2, 2, 2, 2, 2, 2]) } } @@ -26712,7 +27857,8 @@ pub fn _mm512_castpd128_pd512(a: __m128d) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castpd256_pd512(a: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd256_pd512(a: __m256d) -> __m512d { unsafe { simd_shuffle!(a, _mm256_undefined_pd(), [0, 1, 2, 3, 4, 4, 4, 4]) } } @@ -26722,7 +27868,8 @@ pub fn _mm512_castpd256_pd512(a: __m256d) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_zextpd128_pd512(a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextpd128_pd512(a: __m128d) -> __m512d { unsafe { simd_shuffle!(a, _mm_set1_pd(0.), [0, 1, 2, 2, 2, 2, 2, 2]) } } @@ -26732,7 +27879,8 @@ pub fn _mm512_zextpd128_pd512(a: __m128d) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_zextpd256_pd512(a: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextpd256_pd512(a: __m256d) -> __m512d { unsafe { simd_shuffle!(a, _mm256_set1_pd(0.), [0, 1, 2, 3, 4, 4, 4, 4]) } } @@ -26742,7 +27890,8 @@ pub fn _mm512_zextpd256_pd512(a: __m256d) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castpd512_pd128(a: __m512d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd512_pd128(a: __m512d) -> __m128d { unsafe { simd_shuffle!(a, a, [0, 1]) } } @@ -26752,7 +27901,8 @@ pub fn _mm512_castpd512_pd128(a: __m512d) -> __m128d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castpd512_pd256(a: __m512d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd512_pd256(a: __m512d) -> __m256d { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3]) } } @@ -26762,7 +27912,8 @@ pub fn _mm512_castpd512_pd256(a: __m512d) -> __m256d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castpd_ps(a: __m512d) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd_ps(a: __m512d) -> __m512 { unsafe { transmute(a) } } @@ -26772,7 +27923,8 @@ pub fn _mm512_castpd_ps(a: __m512d) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castpd_si512(a: __m512d) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd_si512(a: __m512d) -> __m512i { unsafe { transmute(a) } } @@ -26782,7 +27934,8 @@ pub fn _mm512_castpd_si512(a: __m512d) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castsi128_si512(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi128_si512(a: __m128i) -> __m512i { unsafe { simd_shuffle!(a, _mm_undefined_si128(), [0, 1, 2, 2, 2, 2, 2, 2]) } } @@ -26792,7 +27945,8 @@ pub fn _mm512_castsi128_si512(a: __m128i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castsi256_si512(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi256_si512(a: __m256i) -> __m512i { unsafe { simd_shuffle!(a, _mm256_undefined_si256(), [0, 1, 2, 3, 4, 4, 4, 4]) } } @@ -26802,7 +27956,8 @@ pub fn _mm512_castsi256_si512(a: __m256i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_zextsi128_si512(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextsi128_si512(a: __m128i) -> __m512i { unsafe { simd_shuffle!(a, _mm_setzero_si128(), [0, 1, 2, 2, 2, 2, 2, 2]) } } @@ -26812,7 +27967,8 @@ pub fn _mm512_zextsi128_si512(a: __m128i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_zextsi256_si512(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextsi256_si512(a: __m256i) -> __m512i { unsafe { simd_shuffle!(a, _mm256_setzero_si256(), [0, 1, 2, 3, 4, 4, 4, 4]) } } @@ -26822,7 +27978,8 @@ pub fn _mm512_zextsi256_si512(a: __m256i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castsi512_si128(a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi512_si128(a: __m512i) -> __m128i { unsafe { simd_shuffle!(a, a, [0, 1]) } } @@ -26832,7 +27989,8 @@ pub fn _mm512_castsi512_si128(a: __m512i) -> __m128i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castsi512_si256(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi512_si256(a: __m512i) -> __m256i { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3]) } } @@ -26842,7 +28000,8 @@ pub fn _mm512_castsi512_si256(a: __m512i) -> __m256i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castsi512_ps(a: __m512i) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi512_ps(a: __m512i) -> __m512 { unsafe { transmute(a) } } @@ -26852,7 +28011,8 @@ pub fn _mm512_castsi512_ps(a: __m512i) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_castsi512_pd(a: __m512i) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi512_pd(a: __m512i) -> __m512d { unsafe { transmute(a) } } @@ -26863,7 +28023,8 @@ pub fn _mm512_castsi512_pd(a: __m512i) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovd))] -pub fn _mm512_cvtsi512_si32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtsi512_si32(a: __m512i) -> i32 { unsafe { simd_extract!(a.as_i32x16(), 0) } } @@ -26873,7 +28034,8 @@ pub fn _mm512_cvtsi512_si32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_cvtss_f32(a: __m512) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtss_f32(a: __m512) -> f32 { unsafe { simd_extract!(a, 0) } } @@ -26883,7 +28045,8 @@ pub fn _mm512_cvtss_f32(a: __m512) -> f32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_cvtsd_f64(a: __m512d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtsd_f64(a: __m512d) -> f64 { unsafe { simd_extract!(a, 0) } } @@ -26894,7 +28057,8 @@ pub fn _mm512_cvtsd_f64(a: __m512d) -> f64 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcast))] //should be vpbroadcastd -pub fn _mm512_broadcastd_epi32(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastd_epi32(a: __m128i) -> __m512i { unsafe { let a = _mm512_castsi128_si512(a).as_i32x16(); let ret: i32x16 = simd_shuffle!(a, a, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); @@ -26909,7 +28073,8 @@ pub fn _mm512_broadcastd_epi32(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastd -pub fn _mm512_mask_broadcastd_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcastd_epi32(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastd_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, broadcast, src.as_i32x16())) @@ -26923,7 +28088,8 @@ pub fn _mm512_mask_broadcastd_epi32(src: __m512i, k: __mmask16, a: __m128i) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastd -pub fn _mm512_maskz_broadcastd_epi32(k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcastd_epi32(k: __mmask16, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastd_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, broadcast, i32x16::ZERO)) @@ -26937,7 +28103,8 @@ pub fn _mm512_maskz_broadcastd_epi32(k: __mmask16, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastd -pub fn _mm256_mask_broadcastd_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcastd_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastd_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, broadcast, src.as_i32x8())) @@ -26951,7 +28118,8 @@ pub fn _mm256_mask_broadcastd_epi32(src: __m256i, k: __mmask8, a: __m128i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastd -pub fn _mm256_maskz_broadcastd_epi32(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcastd_epi32(k: __mmask8, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastd_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, broadcast, i32x8::ZERO)) @@ -26965,7 +28133,8 @@ pub fn _mm256_maskz_broadcastd_epi32(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastd -pub fn _mm_mask_broadcastd_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_broadcastd_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastd_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, broadcast, src.as_i32x4())) @@ -26979,7 +28148,8 @@ pub fn _mm_mask_broadcastd_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m12 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastd -pub fn _mm_maskz_broadcastd_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_broadcastd_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastd_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, broadcast, i32x4::ZERO)) @@ -26993,7 +28163,8 @@ pub fn _mm_maskz_broadcastd_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcast))] //should be vpbroadcastq -pub fn _mm512_broadcastq_epi64(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastq_epi64(a: __m128i) -> __m512i { unsafe { simd_shuffle!(a, a, [0, 0, 0, 0, 0, 0, 0, 0]) } } @@ -27004,7 +28175,8 @@ pub fn _mm512_broadcastq_epi64(a: __m128i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastq -pub fn _mm512_mask_broadcastq_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcastq_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastq_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, broadcast, src.as_i64x8())) @@ -27018,7 +28190,8 @@ pub fn _mm512_mask_broadcastq_epi64(src: __m512i, k: __mmask8, a: __m128i) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastq -pub fn _mm512_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastq_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, broadcast, i64x8::ZERO)) @@ -27032,7 +28205,8 @@ pub fn _mm512_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastq -pub fn _mm256_mask_broadcastq_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcastq_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastq_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, broadcast, src.as_i64x4())) @@ -27046,7 +28220,8 @@ pub fn _mm256_mask_broadcastq_epi64(src: __m256i, k: __mmask8, a: __m128i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastq -pub fn _mm256_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastq_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, broadcast, i64x4::ZERO)) @@ -27060,7 +28235,8 @@ pub fn _mm256_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastq -pub fn _mm_mask_broadcastq_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_broadcastq_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastq_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, broadcast, src.as_i64x2())) @@ -27074,7 +28250,8 @@ pub fn _mm_mask_broadcastq_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m12 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] //should be vpbroadcastq -pub fn _mm_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastq_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, broadcast, i64x2::ZERO)) @@ -27088,7 +28265,8 @@ pub fn _mm_maskz_broadcastq_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm512_broadcastss_ps(a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastss_ps(a: __m128) -> __m512 { unsafe { simd_shuffle!(a, a, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) } } @@ -27099,7 +28277,8 @@ pub fn _mm512_broadcastss_ps(a: __m128) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm512_mask_broadcastss_ps(src: __m512, k: __mmask16, a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcastss_ps(src: __m512, k: __mmask16, a: __m128) -> __m512 { unsafe { let broadcast = _mm512_broadcastss_ps(a).as_f32x16(); transmute(simd_select_bitmask(k, broadcast, src.as_f32x16())) @@ -27113,7 +28292,8 @@ pub fn _mm512_mask_broadcastss_ps(src: __m512, k: __mmask16, a: __m128) -> __m51 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm512_maskz_broadcastss_ps(k: __mmask16, a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcastss_ps(k: __mmask16, a: __m128) -> __m512 { unsafe { let broadcast = _mm512_broadcastss_ps(a).as_f32x16(); transmute(simd_select_bitmask(k, broadcast, f32x16::ZERO)) @@ -27127,7 +28307,8 @@ pub fn _mm512_maskz_broadcastss_ps(k: __mmask16, a: __m128) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm256_mask_broadcastss_ps(src: __m256, k: __mmask8, a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcastss_ps(src: __m256, k: __mmask8, a: __m128) -> __m256 { unsafe { let broadcast = _mm256_broadcastss_ps(a).as_f32x8(); transmute(simd_select_bitmask(k, broadcast, src.as_f32x8())) @@ -27141,7 +28322,8 @@ pub fn _mm256_mask_broadcastss_ps(src: __m256, k: __mmask8, a: __m128) -> __m256 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm256_maskz_broadcastss_ps(k: __mmask8, a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcastss_ps(k: __mmask8, a: __m128) -> __m256 { unsafe { let broadcast = _mm256_broadcastss_ps(a).as_f32x8(); transmute(simd_select_bitmask(k, broadcast, f32x8::ZERO)) @@ -27155,7 +28337,8 @@ pub fn _mm256_maskz_broadcastss_ps(k: __mmask8, a: __m128) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm_mask_broadcastss_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_broadcastss_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { unsafe { let broadcast = _mm_broadcastss_ps(a).as_f32x4(); transmute(simd_select_bitmask(k, broadcast, src.as_f32x4())) @@ -27169,7 +28352,8 @@ pub fn _mm_mask_broadcastss_ps(src: __m128, k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastss))] -pub fn _mm_maskz_broadcastss_ps(k: __mmask8, a: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_broadcastss_ps(k: __mmask8, a: __m128) -> __m128 { unsafe { let broadcast = _mm_broadcastss_ps(a).as_f32x4(); transmute(simd_select_bitmask(k, broadcast, f32x4::ZERO)) @@ -27183,7 +28367,8 @@ pub fn _mm_maskz_broadcastss_ps(k: __mmask8, a: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastsd))] -pub fn _mm512_broadcastsd_pd(a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastsd_pd(a: __m128d) -> __m512d { unsafe { simd_shuffle!(a, a, [0, 0, 0, 0, 0, 0, 0, 0]) } } @@ -27194,7 +28379,8 @@ pub fn _mm512_broadcastsd_pd(a: __m128d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastsd))] -pub fn _mm512_mask_broadcastsd_pd(src: __m512d, k: __mmask8, a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcastsd_pd(src: __m512d, k: __mmask8, a: __m128d) -> __m512d { unsafe { let broadcast = _mm512_broadcastsd_pd(a).as_f64x8(); transmute(simd_select_bitmask(k, broadcast, src.as_f64x8())) @@ -27208,7 +28394,8 @@ pub fn _mm512_mask_broadcastsd_pd(src: __m512d, k: __mmask8, a: __m128d) -> __m5 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastsd))] -pub fn _mm512_maskz_broadcastsd_pd(k: __mmask8, a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcastsd_pd(k: __mmask8, a: __m128d) -> __m512d { unsafe { let broadcast = _mm512_broadcastsd_pd(a).as_f64x8(); transmute(simd_select_bitmask(k, broadcast, f64x8::ZERO)) @@ -27222,7 +28409,8 @@ pub fn _mm512_maskz_broadcastsd_pd(k: __mmask8, a: __m128d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastsd))] -pub fn _mm256_mask_broadcastsd_pd(src: __m256d, k: __mmask8, a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcastsd_pd(src: __m256d, k: __mmask8, a: __m128d) -> __m256d { unsafe { let broadcast = _mm256_broadcastsd_pd(a).as_f64x4(); transmute(simd_select_bitmask(k, broadcast, src.as_f64x4())) @@ -27236,7 +28424,8 @@ pub fn _mm256_mask_broadcastsd_pd(src: __m256d, k: __mmask8, a: __m128d) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vbroadcastsd))] -pub fn _mm256_maskz_broadcastsd_pd(k: __mmask8, a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcastsd_pd(k: __mmask8, a: __m128d) -> __m256d { unsafe { let broadcast = _mm256_broadcastsd_pd(a).as_f64x4(); transmute(simd_select_bitmask(k, broadcast, f64x4::ZERO)) @@ -27249,7 +28438,8 @@ pub fn _mm256_maskz_broadcastsd_pd(k: __mmask8, a: __m128d) -> __m256d { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcasti32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_i32x4(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_i32x4(a: __m128i) -> __m512i { unsafe { let a = a.as_i32x4(); let ret: i32x16 = simd_shuffle!(a, a, [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]); @@ -27263,7 +28453,8 @@ pub fn _mm512_broadcast_i32x4(a: __m128i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcasti32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_i32x4(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_i32x4(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcast_i32x4(a).as_i32x16(); transmute(simd_select_bitmask(k, broadcast, src.as_i32x16())) @@ -27276,7 +28467,8 @@ pub fn _mm512_mask_broadcast_i32x4(src: __m512i, k: __mmask16, a: __m128i) -> __ #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcasti32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_i32x4(k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_i32x4(k: __mmask16, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcast_i32x4(a).as_i32x16(); transmute(simd_select_bitmask(k, broadcast, i32x16::ZERO)) @@ -27289,7 +28481,8 @@ pub fn _mm512_maskz_broadcast_i32x4(k: __mmask16, a: __m128i) -> __m512i { #[inline] #[target_feature(enable = "avx512f,avx512vl")] //msvc: vbroadcasti32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_broadcast_i32x4(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_i32x4(a: __m128i) -> __m256i { unsafe { let a = a.as_i32x4(); let ret: i32x8 = simd_shuffle!(a, a, [0, 1, 2, 3, 0, 1, 2, 3]); @@ -27303,7 +28496,8 @@ pub fn _mm256_broadcast_i32x4(a: __m128i) -> __m256i { #[inline] #[target_feature(enable = "avx512f,avx512vl")] //msvc: vbroadcasti32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_broadcast_i32x4(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcast_i32x4(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcast_i32x4(a).as_i32x8(); transmute(simd_select_bitmask(k, broadcast, src.as_i32x8())) @@ -27316,7 +28510,8 @@ pub fn _mm256_mask_broadcast_i32x4(src: __m256i, k: __mmask8, a: __m128i) -> __m #[inline] #[target_feature(enable = "avx512f,avx512vl")] //msvc: vbroadcasti32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_broadcast_i32x4(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcast_i32x4(k: __mmask8, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcast_i32x4(a).as_i32x8(); transmute(simd_select_bitmask(k, broadcast, i32x8::ZERO)) @@ -27329,7 +28524,8 @@ pub fn _mm256_maskz_broadcast_i32x4(k: __mmask8, a: __m128i) -> __m256i { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcasti64x4, linux: vperm #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_i64x4(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_i64x4(a: __m256i) -> __m512i { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 0, 1, 2, 3]) } } @@ -27339,7 +28535,8 @@ pub fn _mm512_broadcast_i64x4(a: __m256i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcasti64x4, linux: vperm #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_i64x4(src: __m512i, k: __mmask8, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_i64x4(src: __m512i, k: __mmask8, a: __m256i) -> __m512i { unsafe { let broadcast = _mm512_broadcast_i64x4(a).as_i64x8(); transmute(simd_select_bitmask(k, broadcast, src.as_i64x8())) @@ -27352,7 +28549,8 @@ pub fn _mm512_mask_broadcast_i64x4(src: __m512i, k: __mmask8, a: __m256i) -> __m #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcasti64x4, linux: vperm #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_i64x4(k: __mmask8, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_i64x4(k: __mmask8, a: __m256i) -> __m512i { unsafe { let broadcast = _mm512_broadcast_i64x4(a).as_i64x8(); transmute(simd_select_bitmask(k, broadcast, i64x8::ZERO)) @@ -27365,7 +28563,8 @@ pub fn _mm512_maskz_broadcast_i64x4(k: __mmask8, a: __m256i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcastf32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_f32x4(a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_f32x4(a: __m128) -> __m512 { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]) } } @@ -27375,7 +28574,8 @@ pub fn _mm512_broadcast_f32x4(a: __m128) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcastf32x4, linux: vshu #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_f32x4(src: __m512, k: __mmask16, a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_f32x4(src: __m512, k: __mmask16, a: __m128) -> __m512 { unsafe { let broadcast = _mm512_broadcast_f32x4(a).as_f32x16(); transmute(simd_select_bitmask(k, broadcast, src.as_f32x16())) @@ -27388,7 +28588,8 @@ pub fn _mm512_mask_broadcast_f32x4(src: __m512, k: __mmask16, a: __m128) -> __m5 #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcastf32x4, linux: vshu #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_f32x4(k: __mmask16, a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_f32x4(k: __mmask16, a: __m128) -> __m512 { unsafe { let broadcast = _mm512_broadcast_f32x4(a).as_f32x16(); transmute(simd_select_bitmask(k, broadcast, f32x16::ZERO)) @@ -27401,7 +28602,8 @@ pub fn _mm512_maskz_broadcast_f32x4(k: __mmask16, a: __m128) -> __m512 { #[inline] #[target_feature(enable = "avx512f,avx512vl")] //msvc: vbroadcastf32x4, linux: vshuf #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_broadcast_f32x4(a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_f32x4(a: __m128) -> __m256 { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 0, 1, 2, 3]) } } @@ -27411,7 +28613,8 @@ pub fn _mm256_broadcast_f32x4(a: __m128) -> __m256 { #[inline] #[target_feature(enable = "avx512f,avx512vl")] //msvc: vbroadcastf32x4, linux: vshu #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_broadcast_f32x4(src: __m256, k: __mmask8, a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcast_f32x4(src: __m256, k: __mmask8, a: __m128) -> __m256 { unsafe { let broadcast = _mm256_broadcast_f32x4(a).as_f32x8(); transmute(simd_select_bitmask(k, broadcast, src.as_f32x8())) @@ -27424,7 +28627,8 @@ pub fn _mm256_mask_broadcast_f32x4(src: __m256, k: __mmask8, a: __m128) -> __m25 #[inline] #[target_feature(enable = "avx512f,avx512vl")] //msvc: vbroadcastf32x4, linux: vshu #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_broadcast_f32x4(k: __mmask8, a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcast_f32x4(k: __mmask8, a: __m128) -> __m256 { unsafe { let broadcast = _mm256_broadcast_f32x4(a).as_f32x8(); transmute(simd_select_bitmask(k, broadcast, f32x8::ZERO)) @@ -27437,7 +28641,8 @@ pub fn _mm256_maskz_broadcast_f32x4(k: __mmask8, a: __m128) -> __m256 { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcastf64x4, linux: vperm #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_f64x4(a: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_f64x4(a: __m256d) -> __m512d { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 0, 1, 2, 3]) } } @@ -27447,7 +28652,8 @@ pub fn _mm512_broadcast_f64x4(a: __m256d) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcastf64x4, linux: vper #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_f64x4(src: __m512d, k: __mmask8, a: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_f64x4(src: __m512d, k: __mmask8, a: __m256d) -> __m512d { unsafe { let broadcast = _mm512_broadcast_f64x4(a).as_f64x8(); transmute(simd_select_bitmask(k, broadcast, src.as_f64x8())) @@ -27460,7 +28666,8 @@ pub fn _mm512_mask_broadcast_f64x4(src: __m512d, k: __mmask8, a: __m256d) -> __m #[inline] #[target_feature(enable = "avx512f")] //msvc: vbroadcastf64x4, linux: vper #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_f64x4(k: __mmask8, a: __m256d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_f64x4(k: __mmask8, a: __m256d) -> __m512d { unsafe { let broadcast = _mm512_broadcast_f64x4(a).as_f64x8(); transmute(simd_select_bitmask(k, broadcast, f64x8::ZERO)) @@ -27474,7 +28681,8 @@ pub fn _mm512_maskz_broadcast_f64x4(k: __mmask8, a: __m256d) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] //should be vpblendmd -pub fn _mm512_mask_blend_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask(k, b.as_i32x16(), a.as_i32x16())) } } @@ -27485,7 +28693,8 @@ pub fn _mm512_mask_blend_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] //should be vpblendmd -pub fn _mm256_mask_blend_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask(k, b.as_i32x8(), a.as_i32x8())) } } @@ -27496,7 +28705,8 @@ pub fn _mm256_mask_blend_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa32))] //should be vpblendmd -pub fn _mm_mask_blend_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask(k, b.as_i32x4(), a.as_i32x4())) } } @@ -27507,7 +28717,8 @@ pub fn _mm_mask_blend_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] //should be vpblendmq -pub fn _mm512_mask_blend_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask(k, b.as_i64x8(), a.as_i64x8())) } } @@ -27518,7 +28729,8 @@ pub fn _mm512_mask_blend_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] //should be vpblendmq -pub fn _mm256_mask_blend_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask(k, b.as_i64x4(), a.as_i64x4())) } } @@ -27529,7 +28741,8 @@ pub fn _mm256_mask_blend_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqa64))] //should be vpblendmq -pub fn _mm_mask_blend_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask(k, b.as_i64x2(), a.as_i64x2())) } } @@ -27540,7 +28753,8 @@ pub fn _mm_mask_blend_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] //should be vpblendmps -pub fn _mm512_mask_blend_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_select_bitmask(k, b.as_f32x16(), a.as_f32x16())) } } @@ -27551,7 +28765,8 @@ pub fn _mm512_mask_blend_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] //should be vpblendmps -pub fn _mm256_mask_blend_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { transmute(simd_select_bitmask(k, b.as_f32x8(), a.as_f32x8())) } } @@ -27562,7 +28777,8 @@ pub fn _mm256_mask_blend_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovaps))] //should be vpblendmps -pub fn _mm_mask_blend_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { transmute(simd_select_bitmask(k, b.as_f32x4(), a.as_f32x4())) } } @@ -27573,7 +28789,8 @@ pub fn _mm_mask_blend_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] //should be vpblendmpd -pub fn _mm512_mask_blend_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_select_bitmask(k, b.as_f64x8(), a.as_f64x8())) } } @@ -27584,7 +28801,8 @@ pub fn _mm512_mask_blend_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] //should be vpblendmpd -pub fn _mm256_mask_blend_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { transmute(simd_select_bitmask(k, b.as_f64x4(), a.as_f64x4())) } } @@ -27595,7 +28813,8 @@ pub fn _mm256_mask_blend_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovapd))] //should be vpblendmpd -pub fn _mm_mask_blend_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { transmute(simd_select_bitmask(k, b.as_f64x2(), a.as_f64x2())) } } @@ -27609,7 +28828,8 @@ pub fn _mm_mask_blend_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_alignr_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_alignr_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let a = a.as_i32x16(); @@ -27690,7 +28910,8 @@ pub fn _mm512_alignr_epi32(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_alignr_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_alignr_epi32( src: __m512i, k: __mmask16, a: __m512i, @@ -27711,7 +28932,12 @@ pub fn _mm512_mask_alignr_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_alignr_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_alignr_epi32( + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm512_alignr_epi32::(a, b); @@ -27729,7 +28955,8 @@ pub fn _mm512_maskz_alignr_epi32(k: __mmask16, a: __m512i, b: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_alignr_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_alignr_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let a = a.as_i32x8(); @@ -27758,7 +28985,8 @@ pub fn _mm256_alignr_epi32(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_alignr_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_alignr_epi32( src: __m256i, k: __mmask8, a: __m256i, @@ -27779,7 +29007,12 @@ pub fn _mm256_mask_alignr_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_alignr_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_alignr_epi32( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm256_alignr_epi32::(a, b); @@ -27797,7 +29030,8 @@ pub fn _mm256_maskz_alignr_epi32(k: __mmask8, a: __m256i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 1))] //should be valignd #[rustc_legacy_const_generics(2)] -pub fn _mm_alignr_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_alignr_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let a = a.as_i32x4(); @@ -27822,7 +29056,8 @@ pub fn _mm_alignr_epi32(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_alignr_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_alignr_epi32( src: __m128i, k: __mmask8, a: __m128i, @@ -27843,7 +29078,12 @@ pub fn _mm_mask_alignr_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignd, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_alignr_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_alignr_epi32( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm_alignr_epi32::(a, b); @@ -27861,7 +29101,8 @@ pub fn _mm_maskz_alignr_epi32(k: __mmask8, a: __m128i, b: __m12 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_alignr_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_alignr_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let imm8: i32 = IMM8 % 8; @@ -27888,7 +29129,8 @@ pub fn _mm512_alignr_epi64(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_alignr_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_alignr_epi64( src: __m512i, k: __mmask8, a: __m512i, @@ -27909,7 +29151,12 @@ pub fn _mm512_mask_alignr_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_alignr_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_alignr_epi64( + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm512_alignr_epi64::(a, b); @@ -27927,7 +29174,8 @@ pub fn _mm512_maskz_alignr_epi64(k: __mmask8, a: __m512i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_alignr_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_alignr_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let imm8: i32 = IMM8 % 4; @@ -27950,7 +29198,8 @@ pub fn _mm256_alignr_epi64(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_alignr_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_alignr_epi64( src: __m256i, k: __mmask8, a: __m256i, @@ -27971,7 +29220,12 @@ pub fn _mm256_mask_alignr_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_alignr_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_alignr_epi64( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm256_alignr_epi64::(a, b); @@ -27989,7 +29243,8 @@ pub fn _mm256_maskz_alignr_epi64(k: __mmask8, a: __m256i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 1))] //should be valignq #[rustc_legacy_const_generics(2)] -pub fn _mm_alignr_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_alignr_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let imm8: i32 = IMM8 % 2; @@ -28010,7 +29265,8 @@ pub fn _mm_alignr_epi64(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_alignr_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_alignr_epi64( src: __m128i, k: __mmask8, a: __m128i, @@ -28031,7 +29287,12 @@ pub fn _mm_mask_alignr_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(valignq, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_alignr_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_alignr_epi64( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm_alignr_epi64::(a, b); @@ -28046,7 +29307,8 @@ pub fn _mm_maskz_alignr_epi64(k: __mmask8, a: __m128i, b: __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] //should be vpandd, but generate vpandq -pub fn _mm512_and_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_and_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_and(a.as_i32x16(), b.as_i32x16())) } } @@ -28057,7 +29319,8 @@ pub fn _mm512_and_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm512_mask_and_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_and_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let and = _mm512_and_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, and, src.as_i32x16())) @@ -28071,7 +29334,8 @@ pub fn _mm512_mask_and_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm512_maskz_and_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_and_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let and = _mm512_and_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, and, i32x16::ZERO)) @@ -28085,7 +29349,8 @@ pub fn _mm512_maskz_and_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm256_mask_and_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_and_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let and = simd_and(a.as_i32x8(), b.as_i32x8()); transmute(simd_select_bitmask(k, and, src.as_i32x8())) @@ -28099,7 +29364,8 @@ pub fn _mm256_mask_and_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm256_maskz_and_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_and_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let and = simd_and(a.as_i32x8(), b.as_i32x8()); transmute(simd_select_bitmask(k, and, i32x8::ZERO)) @@ -28113,7 +29379,8 @@ pub fn _mm256_maskz_and_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm_mask_and_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_and_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let and = simd_and(a.as_i32x4(), b.as_i32x4()); transmute(simd_select_bitmask(k, and, src.as_i32x4())) @@ -28127,7 +29394,8 @@ pub fn _mm_mask_and_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandd))] -pub fn _mm_maskz_and_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_and_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let and = simd_and(a.as_i32x4(), b.as_i32x4()); transmute(simd_select_bitmask(k, and, i32x4::ZERO)) @@ -28141,7 +29409,8 @@ pub fn _mm_maskz_and_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm512_and_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_and_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_and(a.as_i64x8(), b.as_i64x8())) } } @@ -28152,7 +29421,8 @@ pub fn _mm512_and_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm512_mask_and_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_and_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let and = _mm512_and_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, and, src.as_i64x8())) @@ -28166,7 +29436,8 @@ pub fn _mm512_mask_and_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm512_maskz_and_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_and_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let and = _mm512_and_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, and, i64x8::ZERO)) @@ -28180,7 +29451,8 @@ pub fn _mm512_maskz_and_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm256_mask_and_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_and_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let and = simd_and(a.as_i64x4(), b.as_i64x4()); transmute(simd_select_bitmask(k, and, src.as_i64x4())) @@ -28194,7 +29466,8 @@ pub fn _mm256_mask_and_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm256_maskz_and_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_and_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let and = simd_and(a.as_i64x4(), b.as_i64x4()); transmute(simd_select_bitmask(k, and, i64x4::ZERO)) @@ -28208,7 +29481,8 @@ pub fn _mm256_maskz_and_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm_mask_and_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_and_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let and = simd_and(a.as_i64x2(), b.as_i64x2()); transmute(simd_select_bitmask(k, and, src.as_i64x2())) @@ -28222,7 +29496,8 @@ pub fn _mm_mask_and_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm_maskz_and_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_and_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let and = simd_and(a.as_i64x2(), b.as_i64x2()); transmute(simd_select_bitmask(k, and, i64x2::ZERO)) @@ -28236,7 +29511,8 @@ pub fn _mm_maskz_and_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandq))] -pub fn _mm512_and_si512(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_and_si512(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_and(a.as_i32x16(), b.as_i32x16())) } } @@ -28247,7 +29523,8 @@ pub fn _mm512_and_si512(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm512_or_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_or_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_or(a.as_i32x16(), b.as_i32x16())) } } @@ -28258,7 +29535,8 @@ pub fn _mm512_or_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpord))] -pub fn _mm512_mask_or_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_or_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let or = _mm512_or_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, or, src.as_i32x16())) @@ -28272,7 +29550,8 @@ pub fn _mm512_mask_or_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpord))] -pub fn _mm512_maskz_or_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_or_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let or = _mm512_or_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, or, i32x16::ZERO)) @@ -28286,7 +29565,8 @@ pub fn _mm512_maskz_or_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vor))] //should be vpord -pub fn _mm256_or_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_or_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_or(a.as_i32x8(), b.as_i32x8())) } } @@ -28297,7 +29577,8 @@ pub fn _mm256_or_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpord))] -pub fn _mm256_mask_or_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_or_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let or = _mm256_or_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, or, src.as_i32x8())) @@ -28311,7 +29592,8 @@ pub fn _mm256_mask_or_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpord))] -pub fn _mm256_maskz_or_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_or_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let or = _mm256_or_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, or, i32x8::ZERO)) @@ -28325,7 +29607,8 @@ pub fn _mm256_maskz_or_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vor))] //should be vpord -pub fn _mm_or_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_or_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_or(a.as_i32x4(), b.as_i32x4())) } } @@ -28336,7 +29619,8 @@ pub fn _mm_or_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpord))] -pub fn _mm_mask_or_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_or_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let or = _mm_or_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, or, src.as_i32x4())) @@ -28350,7 +29634,8 @@ pub fn _mm_mask_or_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpord))] -pub fn _mm_maskz_or_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_or_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let or = _mm_or_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, or, i32x4::ZERO)) @@ -28364,7 +29649,8 @@ pub fn _mm_maskz_or_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm512_or_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_or_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_or(a.as_i64x8(), b.as_i64x8())) } } @@ -28375,7 +29661,8 @@ pub fn _mm512_or_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm512_mask_or_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_or_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let or = _mm512_or_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, or, src.as_i64x8())) @@ -28389,7 +29676,8 @@ pub fn _mm512_mask_or_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) - #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm512_maskz_or_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_or_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let or = _mm512_or_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, or, i64x8::ZERO)) @@ -28403,7 +29691,8 @@ pub fn _mm512_maskz_or_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vor))] //should be vporq -pub fn _mm256_or_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_or_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_or(a.as_i64x4(), b.as_i64x4())) } } @@ -28414,7 +29703,8 @@ pub fn _mm256_or_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm256_mask_or_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_or_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let or = _mm256_or_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, or, src.as_i64x4())) @@ -28428,7 +29718,8 @@ pub fn _mm256_mask_or_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) - #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm256_maskz_or_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_or_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let or = _mm256_or_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, or, i64x4::ZERO)) @@ -28442,7 +29733,8 @@ pub fn _mm256_maskz_or_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vor))] //should be vporq -pub fn _mm_or_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_or_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_or(a.as_i64x2(), b.as_i64x2())) } } @@ -28453,7 +29745,8 @@ pub fn _mm_or_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm_mask_or_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_or_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let or = _mm_or_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, or, src.as_i64x2())) @@ -28467,7 +29760,8 @@ pub fn _mm_mask_or_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm_maskz_or_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_or_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let or = _mm_or_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, or, i64x2::ZERO)) @@ -28481,7 +29775,8 @@ pub fn _mm_maskz_or_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vporq))] -pub fn _mm512_or_si512(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_or_si512(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_or(a.as_i32x16(), b.as_i32x16())) } } @@ -28492,7 +29787,8 @@ pub fn _mm512_or_si512(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] //should be vpxord -pub fn _mm512_xor_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_xor_epi32(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_xor(a.as_i32x16(), b.as_i32x16())) } } @@ -28503,7 +29799,8 @@ pub fn _mm512_xor_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxord))] -pub fn _mm512_mask_xor_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_xor_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let xor = _mm512_xor_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, xor, src.as_i32x16())) @@ -28517,7 +29814,8 @@ pub fn _mm512_mask_xor_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxord))] -pub fn _mm512_maskz_xor_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_xor_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let xor = _mm512_xor_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, xor, i32x16::ZERO)) @@ -28531,7 +29829,8 @@ pub fn _mm512_maskz_xor_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxor))] //should be vpxord -pub fn _mm256_xor_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_xor_epi32(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_xor(a.as_i32x8(), b.as_i32x8())) } } @@ -28542,7 +29841,8 @@ pub fn _mm256_xor_epi32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxord))] -pub fn _mm256_mask_xor_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_xor_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let xor = _mm256_xor_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, xor, src.as_i32x8())) @@ -28556,7 +29856,8 @@ pub fn _mm256_mask_xor_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxord))] -pub fn _mm256_maskz_xor_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_xor_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let xor = _mm256_xor_epi32(a, b).as_i32x8(); transmute(simd_select_bitmask(k, xor, i32x8::ZERO)) @@ -28570,7 +29871,8 @@ pub fn _mm256_maskz_xor_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxor))] //should be vpxord -pub fn _mm_xor_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_xor_epi32(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_xor(a.as_i32x4(), b.as_i32x4())) } } @@ -28581,7 +29883,8 @@ pub fn _mm_xor_epi32(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxord))] -pub fn _mm_mask_xor_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_xor_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let xor = _mm_xor_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, xor, src.as_i32x4())) @@ -28595,7 +29898,8 @@ pub fn _mm_mask_xor_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxord))] -pub fn _mm_maskz_xor_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_xor_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let xor = _mm_xor_epi32(a, b).as_i32x4(); transmute(simd_select_bitmask(k, xor, i32x4::ZERO)) @@ -28609,7 +29913,8 @@ pub fn _mm_maskz_xor_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm512_xor_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_xor_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_xor(a.as_i64x8(), b.as_i64x8())) } } @@ -28620,7 +29925,8 @@ pub fn _mm512_xor_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm512_mask_xor_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_xor_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let xor = _mm512_xor_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, xor, src.as_i64x8())) @@ -28634,7 +29940,8 @@ pub fn _mm512_mask_xor_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm512_maskz_xor_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_xor_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let xor = _mm512_xor_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, xor, i64x8::ZERO)) @@ -28648,7 +29955,8 @@ pub fn _mm512_maskz_xor_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxor))] //should be vpxorq -pub fn _mm256_xor_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_xor_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_xor(a.as_i64x4(), b.as_i64x4())) } } @@ -28659,7 +29967,8 @@ pub fn _mm256_xor_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm256_mask_xor_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_xor_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let xor = _mm256_xor_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, xor, src.as_i64x4())) @@ -28673,7 +29982,8 @@ pub fn _mm256_mask_xor_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm256_maskz_xor_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_xor_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let xor = _mm256_xor_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, xor, i64x4::ZERO)) @@ -28687,7 +29997,8 @@ pub fn _mm256_maskz_xor_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vxor))] //should be vpxorq -pub fn _mm_xor_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_xor_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_xor(a.as_i64x2(), b.as_i64x2())) } } @@ -28698,7 +30009,8 @@ pub fn _mm_xor_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm_mask_xor_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_xor_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let xor = _mm_xor_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, xor, src.as_i64x2())) @@ -28712,7 +30024,8 @@ pub fn _mm_mask_xor_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm_maskz_xor_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_xor_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let xor = _mm_xor_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, xor, i64x2::ZERO)) @@ -28726,7 +30039,8 @@ pub fn _mm_maskz_xor_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpxorq))] -pub fn _mm512_xor_si512(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_xor_si512(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_xor(a.as_i32x16(), b.as_i32x16())) } } @@ -28737,7 +30051,8 @@ pub fn _mm512_xor_si512(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] //should be vpandnd -pub fn _mm512_andnot_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_andnot_epi32(a: __m512i, b: __m512i) -> __m512i { _mm512_and_epi32(_mm512_xor_epi32(a, _mm512_set1_epi32(u32::MAX as i32)), b) } @@ -28748,7 +30063,13 @@ pub fn _mm512_andnot_epi32(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnd))] -pub fn _mm512_mask_andnot_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_andnot_epi32( + src: __m512i, + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let andnot = _mm512_andnot_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, andnot, src.as_i32x16())) @@ -28762,7 +30083,8 @@ pub fn _mm512_mask_andnot_epi32(src: __m512i, k: __mmask16, a: __m512i, b: __m51 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnd))] -pub fn _mm512_maskz_andnot_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_andnot_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let andnot = _mm512_andnot_epi32(a, b).as_i32x16(); transmute(simd_select_bitmask(k, andnot, i32x16::ZERO)) @@ -28776,7 +30098,13 @@ pub fn _mm512_maskz_andnot_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnd))] -pub fn _mm256_mask_andnot_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_andnot_epi32( + src: __m256i, + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let not = _mm256_xor_epi32(a, _mm256_set1_epi32(u32::MAX as i32)); let andnot = simd_and(not.as_i32x8(), b.as_i32x8()); @@ -28791,7 +30119,8 @@ pub fn _mm256_mask_andnot_epi32(src: __m256i, k: __mmask8, a: __m256i, b: __m256 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnd))] -pub fn _mm256_maskz_andnot_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_andnot_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let not = _mm256_xor_epi32(a, _mm256_set1_epi32(u32::MAX as i32)); let andnot = simd_and(not.as_i32x8(), b.as_i32x8()); @@ -28806,7 +30135,8 @@ pub fn _mm256_maskz_andnot_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnd))] -pub fn _mm_mask_andnot_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_andnot_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let not = _mm_xor_epi32(a, _mm_set1_epi32(u32::MAX as i32)); let andnot = simd_and(not.as_i32x4(), b.as_i32x4()); @@ -28821,7 +30151,8 @@ pub fn _mm_mask_andnot_epi32(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnd))] -pub fn _mm_maskz_andnot_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_andnot_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let not = _mm_xor_epi32(a, _mm_set1_epi32(u32::MAX as i32)); let andnot = simd_and(not.as_i32x4(), b.as_i32x4()); @@ -28836,7 +30167,8 @@ pub fn _mm_maskz_andnot_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] //should be vpandnd -pub fn _mm512_andnot_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_andnot_epi64(a: __m512i, b: __m512i) -> __m512i { _mm512_and_epi64(_mm512_xor_epi64(a, _mm512_set1_epi64(u64::MAX as i64)), b) } @@ -28847,7 +30179,13 @@ pub fn _mm512_andnot_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm512_mask_andnot_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_andnot_epi64( + src: __m512i, + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let andnot = _mm512_andnot_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, andnot, src.as_i64x8())) @@ -28861,7 +30199,8 @@ pub fn _mm512_mask_andnot_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm512_maskz_andnot_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_andnot_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let andnot = _mm512_andnot_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, andnot, i64x8::ZERO)) @@ -28875,7 +30214,13 @@ pub fn _mm512_maskz_andnot_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm256_mask_andnot_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_andnot_epi64( + src: __m256i, + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let not = _mm256_xor_epi64(a, _mm256_set1_epi64x(u64::MAX as i64)); let andnot = simd_and(not.as_i64x4(), b.as_i64x4()); @@ -28890,7 +30235,8 @@ pub fn _mm256_mask_andnot_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256 #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm256_maskz_andnot_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_andnot_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let not = _mm256_xor_epi64(a, _mm256_set1_epi64x(u64::MAX as i64)); let andnot = simd_and(not.as_i64x4(), b.as_i64x4()); @@ -28905,7 +30251,8 @@ pub fn _mm256_maskz_andnot_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm_mask_andnot_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_andnot_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let not = _mm_xor_epi64(a, _mm_set1_epi64x(u64::MAX as i64)); let andnot = simd_and(not.as_i64x2(), b.as_i64x2()); @@ -28920,7 +30267,8 @@ pub fn _mm_mask_andnot_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm_maskz_andnot_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_andnot_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let not = _mm_xor_epi64(a, _mm_set1_epi64x(u64::MAX as i64)); let andnot = simd_and(not.as_i64x2(), b.as_i64x2()); @@ -28935,7 +30283,8 @@ pub fn _mm_maskz_andnot_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpandnq))] -pub fn _mm512_andnot_si512(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_andnot_si512(a: __m512i, b: __m512i) -> __m512i { _mm512_and_epi64(_mm512_xor_epi64(a, _mm512_set1_epi64(u64::MAX as i64)), b) } @@ -28945,7 +30294,8 @@ pub fn _mm512_andnot_si512(a: __m512i, b: __m512i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtmask16_u32(a: __mmask16) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtmask16_u32(a: __mmask16) -> u32 { a as u32 } @@ -28955,7 +30305,8 @@ pub fn _cvtmask16_u32(a: __mmask16) -> u32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtu32_mask16(a: u32) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtu32_mask16(a: u32) -> __mmask16 { a as __mmask16 } @@ -28966,7 +30317,8 @@ pub fn _cvtu32_mask16(a: u32) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(and))] // generate normal and code instead of kandw -pub fn _kand_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kand_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { a & b } @@ -28977,7 +30329,8 @@ pub fn _kand_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(and))] // generate normal and code instead of kandw -pub fn _mm512_kand(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kand(a: __mmask16, b: __mmask16) -> __mmask16 { a & b } @@ -28988,7 +30341,8 @@ pub fn _mm512_kand(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(or))] // generate normal or code instead of korw -pub fn _kor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { a | b } @@ -28999,7 +30353,8 @@ pub fn _kor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(or))] // generate normal or code instead of korw -pub fn _mm512_kor(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kor(a: __mmask16, b: __mmask16) -> __mmask16 { a | b } @@ -29010,7 +30365,8 @@ pub fn _mm512_kor(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(xor))] // generate normal xor code instead of kxorw -pub fn _kxor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { a ^ b } @@ -29021,7 +30377,8 @@ pub fn _kxor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(xor))] // generate normal xor code instead of kxorw -pub fn _mm512_kxor(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kxor(a: __mmask16, b: __mmask16) -> __mmask16 { a ^ b } @@ -29031,7 +30388,8 @@ pub fn _mm512_kxor(a: __mmask16, b: __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _knot_mask16(a: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _knot_mask16(a: __mmask16) -> __mmask16 { a ^ 0b11111111_11111111 } @@ -29041,7 +30399,8 @@ pub fn _knot_mask16(a: __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_knot(a: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_knot(a: __mmask16) -> __mmask16 { a ^ 0b11111111_11111111 } @@ -29052,7 +30411,8 @@ pub fn _mm512_knot(a: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(not))] // generate normal and, not code instead of kandnw -pub fn _kandn_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kandn_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { _mm512_kand(_mm512_knot(a), b) } @@ -29063,7 +30423,8 @@ pub fn _kandn_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(not))] // generate normal and code instead of kandw -pub fn _mm512_kandn(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kandn(a: __mmask16, b: __mmask16) -> __mmask16 { _mm512_kand(_mm512_knot(a), b) } @@ -29074,7 +30435,8 @@ pub fn _mm512_kandn(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(xor))] // generate normal xor, not code instead of kxnorw -pub fn _kxnor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxnor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { _mm512_knot(_mm512_kxor(a, b)) } @@ -29085,7 +30447,8 @@ pub fn _kxnor_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(xor))] // generate normal and code instead of kandw -pub fn _mm512_kxnor(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kxnor(a: __mmask16, b: __mmask16) -> __mmask16 { _mm512_knot(_mm512_kxor(a, b)) } @@ -29096,7 +30459,8 @@ pub fn _mm512_kxnor(a: __mmask16, b: __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _kortest_mask16_u8(a: __mmask16, b: __mmask16, all_ones: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _kortest_mask16_u8(a: __mmask16, b: __mmask16, all_ones: *mut u8) -> u8 { let tmp = _kor_mask16(a, b); *all_ones = (tmp == 0xffff) as u8; (tmp == 0) as u8 @@ -29109,7 +30473,8 @@ pub unsafe fn _kortest_mask16_u8(a: __mmask16, b: __mmask16, all_ones: *mut u8) #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestc_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestc_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { (_kor_mask16(a, b) == 0xffff) as u8 } @@ -29120,7 +30485,8 @@ pub fn _kortestc_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { (_kor_mask16(a, b) == 0) as u8 } @@ -29131,7 +30497,8 @@ pub fn _kortestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { #[target_feature(enable = "avx512f")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftli_mask16(a: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftli_mask16(a: __mmask16) -> __mmask16 { a.unbounded_shl(COUNT) } @@ -29142,7 +30509,8 @@ pub fn _kshiftli_mask16(a: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftri_mask16(a: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftri_mask16(a: __mmask16) -> __mmask16 { a.unbounded_shr(COUNT) } @@ -29152,7 +30520,8 @@ pub fn _kshiftri_mask16(a: __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _load_mask16(mem_addr: *const __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _load_mask16(mem_addr: *const __mmask16) -> __mmask16 { *mem_addr } @@ -29162,7 +30531,8 @@ pub unsafe fn _load_mask16(mem_addr: *const __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _store_mask16(mem_addr: *mut __mmask16, a: __mmask16) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _store_mask16(mem_addr: *mut __mmask16, a: __mmask16) { *mem_addr = a; } @@ -29173,7 +30543,8 @@ pub unsafe fn _store_mask16(mem_addr: *mut __mmask16, a: __mmask16) { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] // generate normal and code instead of kmovw -pub fn _mm512_kmov(a: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kmov(a: __mmask16) -> __mmask16 { a } @@ -29183,7 +30554,8 @@ pub fn _mm512_kmov(a: __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512f")] // generate normal and code instead of kmovw #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_int2mask(mask: i32) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_int2mask(mask: i32) -> __mmask16 { mask as u16 } @@ -29194,7 +30566,8 @@ pub fn _mm512_int2mask(mask: i32) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] // generate normal and code instead of kmovw -pub fn _mm512_mask2int(k1: __mmask16) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask2int(k1: __mmask16) -> i32 { k1 as i32 } @@ -29205,7 +30578,8 @@ pub fn _mm512_mask2int(k1: __mmask16) -> i32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] // generate normal and code instead of kunpckbw -pub fn _mm512_kunpackb(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kunpackb(a: __mmask16, b: __mmask16) -> __mmask16 { ((a & 0xff) << 8) | (b & 0xff) } @@ -29216,7 +30590,8 @@ pub fn _mm512_kunpackb(a: __mmask16, b: __mmask16) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(cmp))] // generate normal and code instead of kortestw -pub fn _mm512_kortestc(a: __mmask16, b: __mmask16) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kortestc(a: __mmask16, b: __mmask16) -> i32 { let r = (a | b) == 0b11111111_11111111; r as i32 } @@ -29228,7 +30603,8 @@ pub fn _mm512_kortestc(a: __mmask16, b: __mmask16) -> i32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(xor))] // generate normal and code instead of kortestw -pub fn _mm512_kortestz(a: __mmask16, b: __mmask16) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kortestz(a: __mmask16, b: __mmask16) -> i32 { let r = (a | b) == 0; r as i32 } @@ -29240,7 +30616,8 @@ pub fn _mm512_kortestz(a: __mmask16, b: __mmask16) -> i32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmd))] -pub fn _mm512_test_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_test_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { let and = _mm512_and_epi32(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpneq_epi32_mask(and, zero) @@ -29253,7 +30630,8 @@ pub fn _mm512_test_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmd))] -pub fn _mm512_mask_test_epi32_mask(k: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_test_epi32_mask(k: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { let and = _mm512_and_epi32(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpneq_epi32_mask(k, and, zero) @@ -29266,7 +30644,8 @@ pub fn _mm512_mask_test_epi32_mask(k: __mmask16, a: __m512i, b: __m512i) -> __mm #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmd))] -pub fn _mm256_test_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_test_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpneq_epi32_mask(and, zero) @@ -29279,7 +30658,8 @@ pub fn _mm256_test_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmd))] -pub fn _mm256_mask_test_epi32_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_test_epi32_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpneq_epi32_mask(k, and, zero) @@ -29292,7 +30672,8 @@ pub fn _mm256_mask_test_epi32_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mma #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmd))] -pub fn _mm_test_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_test_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpneq_epi32_mask(and, zero) @@ -29305,7 +30686,8 @@ pub fn _mm_test_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmd))] -pub fn _mm_mask_test_epi32_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_test_epi32_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpneq_epi32_mask(k, and, zero) @@ -29318,7 +30700,8 @@ pub fn _mm_mask_test_epi32_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmq))] -pub fn _mm512_test_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_test_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { let and = _mm512_and_epi64(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpneq_epi64_mask(and, zero) @@ -29331,7 +30714,8 @@ pub fn _mm512_test_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmq))] -pub fn _mm512_mask_test_epi64_mask(k: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_test_epi64_mask(k: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { let and = _mm512_and_epi64(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpneq_epi64_mask(k, and, zero) @@ -29344,7 +30728,8 @@ pub fn _mm512_mask_test_epi64_mask(k: __mmask8, a: __m512i, b: __m512i) -> __mma #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmq))] -pub fn _mm256_test_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_test_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpneq_epi64_mask(and, zero) @@ -29357,7 +30742,8 @@ pub fn _mm256_test_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmq))] -pub fn _mm256_mask_test_epi64_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_test_epi64_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpneq_epi64_mask(k, and, zero) @@ -29370,7 +30756,8 @@ pub fn _mm256_mask_test_epi64_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mma #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmq))] -pub fn _mm_test_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_test_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpneq_epi64_mask(and, zero) @@ -29383,7 +30770,8 @@ pub fn _mm_test_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmq))] -pub fn _mm_mask_test_epi64_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_test_epi64_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpneq_epi64_mask(k, and, zero) @@ -29396,7 +30784,8 @@ pub fn _mm_mask_test_epi64_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmd))] -pub fn _mm512_testn_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_testn_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { let and = _mm512_and_epi32(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpeq_epi32_mask(and, zero) @@ -29409,7 +30798,8 @@ pub fn _mm512_testn_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmd))] -pub fn _mm512_mask_testn_epi32_mask(k: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_testn_epi32_mask(k: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { let and = _mm512_and_epi32(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpeq_epi32_mask(k, and, zero) @@ -29422,7 +30812,8 @@ pub fn _mm512_mask_testn_epi32_mask(k: __mmask16, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmd))] -pub fn _mm256_testn_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_testn_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpeq_epi32_mask(and, zero) @@ -29435,7 +30826,8 @@ pub fn _mm256_testn_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmd))] -pub fn _mm256_mask_testn_epi32_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_testn_epi32_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpeq_epi32_mask(k, and, zero) @@ -29448,7 +30840,8 @@ pub fn _mm256_mask_testn_epi32_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mm #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmd))] -pub fn _mm_testn_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testn_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpeq_epi32_mask(and, zero) @@ -29461,7 +30854,8 @@ pub fn _mm_testn_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmd))] -pub fn _mm_mask_testn_epi32_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_testn_epi32_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpeq_epi32_mask(k, and, zero) @@ -29474,7 +30868,8 @@ pub fn _mm_mask_testn_epi32_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmq))] -pub fn _mm512_testn_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_testn_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { let and = _mm512_and_epi64(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpeq_epi64_mask(and, zero) @@ -29487,7 +30882,8 @@ pub fn _mm512_testn_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmq))] -pub fn _mm512_mask_testn_epi64_mask(k: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_testn_epi64_mask(k: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { let and = _mm512_and_epi64(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpeq_epi64_mask(k, and, zero) @@ -29500,7 +30896,8 @@ pub fn _mm512_mask_testn_epi64_mask(k: __mmask8, a: __m512i, b: __m512i) -> __mm #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmq))] -pub fn _mm256_testn_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_testn_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpeq_epi64_mask(and, zero) @@ -29513,7 +30910,8 @@ pub fn _mm256_testn_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmq))] -pub fn _mm256_mask_testn_epi64_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_testn_epi64_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpeq_epi64_mask(k, and, zero) @@ -29526,7 +30924,8 @@ pub fn _mm256_mask_testn_epi64_mask(k: __mmask8, a: __m256i, b: __m256i) -> __mm #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmq))] -pub fn _mm_testn_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testn_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpeq_epi64_mask(and, zero) @@ -29539,7 +30938,8 @@ pub fn _mm_testn_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmq))] -pub fn _mm_mask_testn_epi64_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_testn_epi64_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpeq_epi64_mask(k, and, zero) @@ -29651,7 +31051,8 @@ pub unsafe fn _mm512_stream_load_si512(mem_addr: *const __m512i) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set_ps( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_ps( e0: f32, e1: f32, e2: f32, @@ -29681,7 +31082,8 @@ pub fn _mm512_set_ps( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr_ps( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr_ps( e0: f32, e1: f32, e2: f32, @@ -29713,7 +31115,8 @@ pub fn _mm512_setr_ps( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set1_pd(a: f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_pd(a: f64) -> __m512d { unsafe { transmute(f64x8::splat(a)) } } @@ -29723,7 +31126,8 @@ pub fn _mm512_set1_pd(a: f64) -> __m512d { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set1_ps(a: f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_ps(a: f32) -> __m512 { unsafe { transmute(f32x16::splat(a)) } } @@ -29733,7 +31137,8 @@ pub fn _mm512_set1_ps(a: f32) -> __m512 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_epi32( e15: i32, e14: i32, e13: i32, @@ -29762,7 +31167,8 @@ pub fn _mm512_set_epi32( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set1_epi8(a: i8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_epi8(a: i8) -> __m512i { unsafe { transmute(i8x64::splat(a)) } } @@ -29772,7 +31178,8 @@ pub fn _mm512_set1_epi8(a: i8) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set1_epi16(a: i16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_epi16(a: i16) -> __m512i { unsafe { transmute(i16x32::splat(a)) } } @@ -29782,7 +31189,8 @@ pub fn _mm512_set1_epi16(a: i16) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set1_epi32(a: i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_epi32(a: i32) -> __m512i { unsafe { transmute(i32x16::splat(a)) } } @@ -29793,7 +31201,8 @@ pub fn _mm512_set1_epi32(a: i32) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastd))] -pub fn _mm512_mask_set1_epi32(src: __m512i, k: __mmask16, a: i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_set1_epi32(src: __m512i, k: __mmask16, a: i32) -> __m512i { unsafe { let r = _mm512_set1_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, r, src.as_i32x16())) @@ -29807,7 +31216,8 @@ pub fn _mm512_mask_set1_epi32(src: __m512i, k: __mmask16, a: i32) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastd))] -pub fn _mm512_maskz_set1_epi32(k: __mmask16, a: i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_set1_epi32(k: __mmask16, a: i32) -> __m512i { unsafe { let r = _mm512_set1_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, r, i32x16::ZERO)) @@ -29821,7 +31231,8 @@ pub fn _mm512_maskz_set1_epi32(k: __mmask16, a: i32) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastd))] -pub fn _mm256_mask_set1_epi32(src: __m256i, k: __mmask8, a: i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_set1_epi32(src: __m256i, k: __mmask8, a: i32) -> __m256i { unsafe { let r = _mm256_set1_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, r, src.as_i32x8())) @@ -29835,7 +31246,8 @@ pub fn _mm256_mask_set1_epi32(src: __m256i, k: __mmask8, a: i32) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastd))] -pub fn _mm256_maskz_set1_epi32(k: __mmask8, a: i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_set1_epi32(k: __mmask8, a: i32) -> __m256i { unsafe { let r = _mm256_set1_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, r, i32x8::ZERO)) @@ -29849,7 +31261,8 @@ pub fn _mm256_maskz_set1_epi32(k: __mmask8, a: i32) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastd))] -pub fn _mm_mask_set1_epi32(src: __m128i, k: __mmask8, a: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_set1_epi32(src: __m128i, k: __mmask8, a: i32) -> __m128i { unsafe { let r = _mm_set1_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, r, src.as_i32x4())) @@ -29863,7 +31276,8 @@ pub fn _mm_mask_set1_epi32(src: __m128i, k: __mmask8, a: i32) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastd))] -pub fn _mm_maskz_set1_epi32(k: __mmask8, a: i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_set1_epi32(k: __mmask8, a: i32) -> __m128i { unsafe { let r = _mm_set1_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, r, i32x4::ZERO)) @@ -29876,7 +31290,8 @@ pub fn _mm_maskz_set1_epi32(k: __mmask8, a: i32) -> __m128i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set1_epi64(a: i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_epi64(a: i64) -> __m512i { unsafe { transmute(i64x8::splat(a)) } } @@ -29887,7 +31302,8 @@ pub fn _mm512_set1_epi64(a: i64) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastq))] -pub fn _mm512_mask_set1_epi64(src: __m512i, k: __mmask8, a: i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_set1_epi64(src: __m512i, k: __mmask8, a: i64) -> __m512i { unsafe { let r = _mm512_set1_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, r, src.as_i64x8())) @@ -29901,7 +31317,8 @@ pub fn _mm512_mask_set1_epi64(src: __m512i, k: __mmask8, a: i64) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastq))] -pub fn _mm512_maskz_set1_epi64(k: __mmask8, a: i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_set1_epi64(k: __mmask8, a: i64) -> __m512i { unsafe { let r = _mm512_set1_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, r, i64x8::ZERO)) @@ -29915,7 +31332,8 @@ pub fn _mm512_maskz_set1_epi64(k: __mmask8, a: i64) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastq))] -pub fn _mm256_mask_set1_epi64(src: __m256i, k: __mmask8, a: i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_set1_epi64(src: __m256i, k: __mmask8, a: i64) -> __m256i { unsafe { let r = _mm256_set1_epi64x(a).as_i64x4(); transmute(simd_select_bitmask(k, r, src.as_i64x4())) @@ -29929,7 +31347,8 @@ pub fn _mm256_mask_set1_epi64(src: __m256i, k: __mmask8, a: i64) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastq))] -pub fn _mm256_maskz_set1_epi64(k: __mmask8, a: i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_set1_epi64(k: __mmask8, a: i64) -> __m256i { unsafe { let r = _mm256_set1_epi64x(a).as_i64x4(); transmute(simd_select_bitmask(k, r, i64x4::ZERO)) @@ -29943,7 +31362,8 @@ pub fn _mm256_maskz_set1_epi64(k: __mmask8, a: i64) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastq))] -pub fn _mm_mask_set1_epi64(src: __m128i, k: __mmask8, a: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_set1_epi64(src: __m128i, k: __mmask8, a: i64) -> __m128i { unsafe { let r = _mm_set1_epi64x(a).as_i64x2(); transmute(simd_select_bitmask(k, r, src.as_i64x2())) @@ -29957,7 +31377,8 @@ pub fn _mm_mask_set1_epi64(src: __m128i, k: __mmask8, a: i64) -> __m128i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastq))] -pub fn _mm_maskz_set1_epi64(k: __mmask8, a: i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_set1_epi64(k: __mmask8, a: i64) -> __m128i { unsafe { let r = _mm_set1_epi64x(a).as_i64x2(); transmute(simd_select_bitmask(k, r, i64x2::ZERO)) @@ -29970,7 +31391,8 @@ pub fn _mm_maskz_set1_epi64(k: __mmask8, a: i64) -> __m128i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set4_epi64(d: i64, c: i64, b: i64, a: i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set4_epi64(d: i64, c: i64, b: i64, a: i64) -> __m512i { _mm512_set_epi64(d, c, b, a, d, c, b, a) } @@ -29980,7 +31402,8 @@ pub fn _mm512_set4_epi64(d: i64, c: i64, b: i64, a: i64) -> __m512i { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr4_epi64(d: i64, c: i64, b: i64, a: i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr4_epi64(d: i64, c: i64, b: i64, a: i64) -> __m512i { _mm512_set_epi64(a, b, c, d, a, b, c, d) } @@ -30809,7 +32232,8 @@ pub fn _mm_mask_cmp_round_sd_mask( #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_cmplt_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_lt(a.as_u32x16(), b.as_u32x16())) } } @@ -30820,7 +32244,8 @@ pub fn _mm512_cmplt_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_mask_cmplt_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epu32_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -30831,7 +32256,8 @@ pub fn _mm512_mask_cmplt_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_cmplt_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_lt(a.as_u32x8(), b.as_u32x8())) } } @@ -30842,7 +32268,8 @@ pub fn _mm256_cmplt_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_mask_cmplt_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu32_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -30853,7 +32280,8 @@ pub fn _mm256_mask_cmplt_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_cmplt_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_lt(a.as_u32x4(), b.as_u32x4())) } } @@ -30864,7 +32292,8 @@ pub fn _mm_cmplt_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_mask_cmplt_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu32_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -30875,7 +32304,8 @@ pub fn _mm_mask_cmplt_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_cmpgt_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_gt(a.as_u32x16(), b.as_u32x16())) } } @@ -30886,7 +32316,8 @@ pub fn _mm512_cmpgt_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_mask_cmpgt_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epu32_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -30897,7 +32328,8 @@ pub fn _mm512_mask_cmpgt_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_cmpgt_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_gt(a.as_u32x8(), b.as_u32x8())) } } @@ -30908,7 +32340,8 @@ pub fn _mm256_cmpgt_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_mask_cmpgt_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu32_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -30919,7 +32352,8 @@ pub fn _mm256_mask_cmpgt_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_cmpgt_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_gt(a.as_u32x4(), b.as_u32x4())) } } @@ -30930,7 +32364,8 @@ pub fn _mm_cmpgt_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_mask_cmpgt_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu32_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -30941,7 +32376,8 @@ pub fn _mm_mask_cmpgt_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_cmple_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_le(a.as_u32x16(), b.as_u32x16())) } } @@ -30952,7 +32388,8 @@ pub fn _mm512_cmple_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_mask_cmple_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epu32_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -30963,7 +32400,8 @@ pub fn _mm512_mask_cmple_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_cmple_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_le(a.as_u32x8(), b.as_u32x8())) } } @@ -30974,7 +32412,8 @@ pub fn _mm256_cmple_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_mask_cmple_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu32_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -30985,7 +32424,8 @@ pub fn _mm256_mask_cmple_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_cmple_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_le(a.as_u32x4(), b.as_u32x4())) } } @@ -30996,7 +32436,8 @@ pub fn _mm_cmple_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_mask_cmple_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu32_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -31007,7 +32448,8 @@ pub fn _mm_mask_cmple_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_cmpge_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_ge(a.as_u32x16(), b.as_u32x16())) } } @@ -31018,7 +32460,8 @@ pub fn _mm512_cmpge_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_mask_cmpge_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epu32_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -31029,7 +32472,8 @@ pub fn _mm512_mask_cmpge_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_cmpge_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_ge(a.as_u32x8(), b.as_u32x8())) } } @@ -31040,7 +32484,8 @@ pub fn _mm256_cmpge_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_mask_cmpge_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu32_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -31051,7 +32496,8 @@ pub fn _mm256_mask_cmpge_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_cmpge_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ge(a.as_u32x4(), b.as_u32x4())) } } @@ -31062,7 +32508,8 @@ pub fn _mm_cmpge_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_mask_cmpge_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu32_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -31073,7 +32520,8 @@ pub fn _mm_mask_cmpge_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_cmpeq_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_eq(a.as_u32x16(), b.as_u32x16())) } } @@ -31084,7 +32532,8 @@ pub fn _mm512_cmpeq_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_mask_cmpeq_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epu32_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -31095,7 +32544,8 @@ pub fn _mm512_mask_cmpeq_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_cmpeq_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_eq(a.as_u32x8(), b.as_u32x8())) } } @@ -31106,7 +32556,8 @@ pub fn _mm256_cmpeq_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_mask_cmpeq_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu32_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -31117,7 +32568,8 @@ pub fn _mm256_mask_cmpeq_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_cmpeq_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_eq(a.as_u32x4(), b.as_u32x4())) } } @@ -31128,7 +32580,8 @@ pub fn _mm_cmpeq_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_mask_cmpeq_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu32_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -31139,7 +32592,8 @@ pub fn _mm_mask_cmpeq_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_cmpneq_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_ne(a.as_u32x16(), b.as_u32x16())) } } @@ -31150,7 +32604,8 @@ pub fn _mm512_cmpneq_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm512_mask_cmpneq_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epu32_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -31161,7 +32616,8 @@ pub fn _mm512_mask_cmpneq_epu32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_cmpneq_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_ne(a.as_u32x8(), b.as_u32x8())) } } @@ -31172,7 +32628,8 @@ pub fn _mm256_cmpneq_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm256_mask_cmpneq_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu32_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -31183,7 +32640,8 @@ pub fn _mm256_mask_cmpneq_epu32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_cmpneq_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ne(a.as_u32x4(), b.as_u32x4())) } } @@ -31194,7 +32652,8 @@ pub fn _mm_cmpneq_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpud -pub fn _mm_mask_cmpneq_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu32_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -31206,7 +32665,11 @@ pub fn _mm_mask_cmpneq_epu32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mma #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_cmp_epu32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epu32_mask( + a: __m512i, + b: __m512i, +) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_u32x16(); @@ -31233,7 +32696,8 @@ pub fn _mm512_cmp_epu32_mask(a: __m512i, b: __m512i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_mask_cmp_epu32_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epu32_mask( k1: __mmask16, a: __m512i, b: __m512i, @@ -31265,7 +32729,11 @@ pub fn _mm512_mask_cmp_epu32_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_cmp_epu32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epu32_mask( + a: __m256i, + b: __m256i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_u32x8(); @@ -31292,7 +32760,8 @@ pub fn _mm256_cmp_epu32_mask(a: __m256i, b: __m256i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_mask_cmp_epu32_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epu32_mask( k1: __mmask8, a: __m256i, b: __m256i, @@ -31324,7 +32793,8 @@ pub fn _mm256_mask_cmp_epu32_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_cmp_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epu32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_u32x4(); @@ -31351,7 +32821,8 @@ pub fn _mm_cmp_epu32_mask(a: __m128i, b: __m128i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_mask_cmp_epu32_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epu32_mask( k1: __mmask8, a: __m128i, b: __m128i, @@ -31382,7 +32853,8 @@ pub fn _mm_mask_cmp_epu32_mask( #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_cmplt_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_lt(a.as_i32x16(), b.as_i32x16())) } } @@ -31393,7 +32865,8 @@ pub fn _mm512_cmplt_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_mask_cmplt_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epi32_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -31404,7 +32877,8 @@ pub fn _mm512_mask_cmplt_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_cmplt_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_lt(a.as_i32x8(), b.as_i32x8())) } } @@ -31415,7 +32889,8 @@ pub fn _mm256_cmplt_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_mask_cmplt_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi32_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -31426,7 +32901,8 @@ pub fn _mm256_mask_cmplt_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_cmplt_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_lt(a.as_i32x4(), b.as_i32x4())) } } @@ -31437,7 +32913,8 @@ pub fn _mm_cmplt_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_mask_cmplt_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi32_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -31448,7 +32925,8 @@ pub fn _mm_mask_cmplt_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_cmpgt_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_gt(a.as_i32x16(), b.as_i32x16())) } } @@ -31459,7 +32937,8 @@ pub fn _mm512_cmpgt_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_mask_cmpgt_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epi32_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -31470,7 +32949,8 @@ pub fn _mm512_mask_cmpgt_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_cmpgt_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_gt(a.as_i32x8(), b.as_i32x8())) } } @@ -31481,7 +32961,8 @@ pub fn _mm256_cmpgt_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_mask_cmpgt_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi32_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -31492,7 +32973,8 @@ pub fn _mm256_mask_cmpgt_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_cmpgt_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_gt(a.as_i32x4(), b.as_i32x4())) } } @@ -31503,7 +32985,8 @@ pub fn _mm_cmpgt_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_mask_cmpgt_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi32_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -31514,7 +32997,8 @@ pub fn _mm_mask_cmpgt_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_cmple_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_le(a.as_i32x16(), b.as_i32x16())) } } @@ -31525,7 +33009,8 @@ pub fn _mm512_cmple_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_mask_cmple_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epi32_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -31536,7 +33021,8 @@ pub fn _mm512_mask_cmple_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_cmple_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_le(a.as_i32x8(), b.as_i32x8())) } } @@ -31547,7 +33033,8 @@ pub fn _mm256_cmple_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_mask_cmple_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi32_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -31558,7 +33045,8 @@ pub fn _mm256_mask_cmple_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_cmple_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_le(a.as_i32x4(), b.as_i32x4())) } } @@ -31569,7 +33057,8 @@ pub fn _mm_cmple_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_mask_cmple_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi32_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -31580,7 +33069,8 @@ pub fn _mm_mask_cmple_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_cmpge_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_ge(a.as_i32x16(), b.as_i32x16())) } } @@ -31591,7 +33081,8 @@ pub fn _mm512_cmpge_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_mask_cmpge_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epi32_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -31602,7 +33093,8 @@ pub fn _mm512_mask_cmpge_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_cmpge_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_ge(a.as_i32x8(), b.as_i32x8())) } } @@ -31613,7 +33105,8 @@ pub fn _mm256_cmpge_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_mask_cmpge_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi32_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -31624,7 +33117,8 @@ pub fn _mm256_mask_cmpge_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_cmpge_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ge(a.as_i32x4(), b.as_i32x4())) } } @@ -31635,7 +33129,8 @@ pub fn _mm_cmpge_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_mask_cmpge_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi32_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -31646,7 +33141,8 @@ pub fn _mm_mask_cmpge_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_cmpeq_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_eq(a.as_i32x16(), b.as_i32x16())) } } @@ -31657,7 +33153,8 @@ pub fn _mm512_cmpeq_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_mask_cmpeq_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epi32_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -31668,7 +33165,8 @@ pub fn _mm512_mask_cmpeq_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_cmpeq_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_eq(a.as_i32x8(), b.as_i32x8())) } } @@ -31679,7 +33177,8 @@ pub fn _mm256_cmpeq_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_mask_cmpeq_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi32_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -31690,7 +33189,8 @@ pub fn _mm256_mask_cmpeq_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_cmpeq_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_eq(a.as_i32x4(), b.as_i32x4())) } } @@ -31701,7 +33201,8 @@ pub fn _mm_cmpeq_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_mask_cmpeq_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi32_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -31712,7 +33213,8 @@ pub fn _mm_mask_cmpeq_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_cmpneq_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { unsafe { simd_bitmask::(simd_ne(a.as_i32x16(), b.as_i32x16())) } } @@ -31723,7 +33225,8 @@ pub fn _mm512_cmpneq_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm512_mask_cmpneq_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> __mmask16 { _mm512_mask_cmp_epi32_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -31734,7 +33237,8 @@ pub fn _mm512_mask_cmpneq_epi32_mask(k1: __mmask16, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_cmpneq_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::(simd_ne(a.as_i32x8(), b.as_i32x8())) } } @@ -31745,7 +33249,8 @@ pub fn _mm256_cmpneq_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm256_mask_cmpneq_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi32_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -31756,7 +33261,8 @@ pub fn _mm256_mask_cmpneq_epi32_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_cmpneq_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ne(a.as_i32x4(), b.as_i32x4())) } } @@ -31767,7 +33273,8 @@ pub fn _mm_cmpneq_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpd -pub fn _mm_mask_cmpneq_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi32_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -31779,7 +33286,11 @@ pub fn _mm_mask_cmpneq_epi32_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mma #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_cmp_epi32_mask(a: __m512i, b: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epi32_mask( + a: __m512i, + b: __m512i, +) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_i32x16(); @@ -31806,7 +33317,8 @@ pub fn _mm512_cmp_epi32_mask(a: __m512i, b: __m512i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_mask_cmp_epi32_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epi32_mask( k1: __mmask16, a: __m512i, b: __m512i, @@ -31838,7 +33350,11 @@ pub fn _mm512_mask_cmp_epi32_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_cmp_epi32_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epi32_mask( + a: __m256i, + b: __m256i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_i32x8(); @@ -31865,7 +33381,8 @@ pub fn _mm256_cmp_epi32_mask(a: __m256i, b: __m256i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_mask_cmp_epi32_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epi32_mask( k1: __mmask8, a: __m256i, b: __m256i, @@ -31897,7 +33414,8 @@ pub fn _mm256_mask_cmp_epi32_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_cmp_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epi32_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_i32x4(); @@ -31924,7 +33442,8 @@ pub fn _mm_cmp_epi32_mask(a: __m128i, b: __m128i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_mask_cmp_epi32_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epi32_mask( k1: __mmask8, a: __m128i, b: __m128i, @@ -31955,7 +33474,8 @@ pub fn _mm_mask_cmp_epi32_mask( #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_cmplt_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_lt(a.as_u64x8(), b.as_u64x8())) } } @@ -31966,7 +33486,8 @@ pub fn _mm512_cmplt_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_mask_cmplt_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epu64_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -31977,7 +33498,8 @@ pub fn _mm512_mask_cmplt_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_cmplt_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_lt(a.as_u64x4(), b.as_u64x4())) } } @@ -31988,7 +33510,8 @@ pub fn _mm256_cmplt_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_mask_cmplt_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu64_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -31999,7 +33522,8 @@ pub fn _mm256_mask_cmplt_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_cmplt_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_lt(a.as_u64x2(), b.as_u64x2())) } } @@ -32010,7 +33534,8 @@ pub fn _mm_cmplt_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_mask_cmplt_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu64_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -32021,7 +33546,8 @@ pub fn _mm_mask_cmplt_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_cmpgt_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_gt(a.as_u64x8(), b.as_u64x8())) } } @@ -32032,7 +33558,8 @@ pub fn _mm512_cmpgt_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epu64_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -32043,7 +33570,8 @@ pub fn _mm512_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_cmpgt_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_gt(a.as_u64x4(), b.as_u64x4())) } } @@ -32054,7 +33582,8 @@ pub fn _mm256_cmpgt_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu64_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -32065,7 +33594,8 @@ pub fn _mm256_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_cmpgt_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_gt(a.as_u64x2(), b.as_u64x2())) } } @@ -32076,7 +33606,8 @@ pub fn _mm_cmpgt_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu64_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -32087,7 +33618,8 @@ pub fn _mm_mask_cmpgt_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_cmple_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_le(a.as_u64x8(), b.as_u64x8())) } } @@ -32098,7 +33630,8 @@ pub fn _mm512_cmple_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_mask_cmple_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epu64_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -32109,7 +33642,8 @@ pub fn _mm512_mask_cmple_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_cmple_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_le(a.as_u64x4(), b.as_u64x4())) } } @@ -32120,7 +33654,8 @@ pub fn _mm256_cmple_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_mask_cmple_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu64_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -32131,7 +33666,8 @@ pub fn _mm256_mask_cmple_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_cmple_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_le(a.as_u64x2(), b.as_u64x2())) } } @@ -32142,7 +33678,8 @@ pub fn _mm_cmple_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_mask_cmple_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu64_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -32153,7 +33690,8 @@ pub fn _mm_mask_cmple_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_cmpge_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_ge(a.as_u64x8(), b.as_u64x8())) } } @@ -32164,7 +33702,8 @@ pub fn _mm512_cmpge_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_mask_cmpge_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epu64_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -32175,7 +33714,8 @@ pub fn _mm512_mask_cmpge_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_cmpge_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_ge(a.as_u64x4(), b.as_u64x4())) } } @@ -32186,7 +33726,8 @@ pub fn _mm256_cmpge_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_mask_cmpge_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu64_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -32197,7 +33738,8 @@ pub fn _mm256_mask_cmpge_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_cmpge_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_ge(a.as_u64x2(), b.as_u64x2())) } } @@ -32208,7 +33750,8 @@ pub fn _mm_cmpge_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_mask_cmpge_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu64_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -32219,7 +33762,8 @@ pub fn _mm_mask_cmpge_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_cmpeq_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_eq(a.as_u64x8(), b.as_u64x8())) } } @@ -32230,7 +33774,8 @@ pub fn _mm512_cmpeq_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epu64_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -32241,7 +33786,8 @@ pub fn _mm512_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_cmpeq_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_eq(a.as_u64x4(), b.as_u64x4())) } } @@ -32252,7 +33798,8 @@ pub fn _mm256_cmpeq_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu64_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -32263,7 +33810,8 @@ pub fn _mm256_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_cmpeq_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_eq(a.as_u64x2(), b.as_u64x2())) } } @@ -32274,7 +33822,8 @@ pub fn _mm_cmpeq_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu64_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -32285,7 +33834,8 @@ pub fn _mm_mask_cmpeq_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_cmpneq_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_ne(a.as_u64x8(), b.as_u64x8())) } } @@ -32296,7 +33846,8 @@ pub fn _mm512_cmpneq_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm512_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epu64_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -32307,7 +33858,8 @@ pub fn _mm512_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_cmpneq_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_ne(a.as_u64x4(), b.as_u64x4())) } } @@ -32318,7 +33870,8 @@ pub fn _mm256_cmpneq_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm256_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epu64_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -32329,7 +33882,8 @@ pub fn _mm256_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_cmpneq_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_ne(a.as_u64x2(), b.as_u64x2())) } } @@ -32340,7 +33894,8 @@ pub fn _mm_cmpneq_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpuq -pub fn _mm_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu64_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -32352,7 +33907,11 @@ pub fn _mm_mask_cmpneq_epu64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mma #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_cmp_epu64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epu64_mask( + a: __m512i, + b: __m512i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_u64x8(); @@ -32379,7 +33938,8 @@ pub fn _mm512_cmp_epu64_mask(a: __m512i, b: __m512i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_mask_cmp_epu64_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epu64_mask( k1: __mmask8, a: __m512i, b: __m512i, @@ -32411,7 +33971,11 @@ pub fn _mm512_mask_cmp_epu64_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_cmp_epu64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epu64_mask( + a: __m256i, + b: __m256i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_u64x4(); @@ -32438,7 +34002,8 @@ pub fn _mm256_cmp_epu64_mask(a: __m256i, b: __m256i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_mask_cmp_epu64_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epu64_mask( k1: __mmask8, a: __m256i, b: __m256i, @@ -32470,7 +34035,8 @@ pub fn _mm256_mask_cmp_epu64_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_cmp_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epu64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_u64x2(); @@ -32497,7 +34063,8 @@ pub fn _mm_cmp_epu64_mask(a: __m128i, b: __m128i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_mask_cmp_epu64_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epu64_mask( k1: __mmask8, a: __m128i, b: __m128i, @@ -32528,7 +34095,8 @@ pub fn _mm_mask_cmp_epu64_mask( #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_cmplt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_lt(a.as_i64x8(), b.as_i64x8())) } } @@ -32539,7 +34107,8 @@ pub fn _mm512_cmplt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_mask_cmplt_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epi64_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -32550,7 +34119,8 @@ pub fn _mm512_mask_cmplt_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_cmplt_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_lt(a.as_i64x4(), b.as_i64x4())) } } @@ -32561,7 +34131,8 @@ pub fn _mm256_cmplt_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_mask_cmplt_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi64_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -32572,7 +34143,8 @@ pub fn _mm256_mask_cmplt_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_cmplt_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_lt(a.as_i64x2(), b.as_i64x2())) } } @@ -32583,7 +34155,8 @@ pub fn _mm_cmplt_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_mask_cmplt_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi64_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -32594,7 +34167,8 @@ pub fn _mm_mask_cmplt_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_cmpgt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_gt(a.as_i64x8(), b.as_i64x8())) } } @@ -32605,7 +34179,8 @@ pub fn _mm512_cmpgt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epi64_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -32616,7 +34191,8 @@ pub fn _mm512_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_cmpgt_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_gt(a.as_i64x4(), b.as_i64x4())) } } @@ -32627,7 +34203,8 @@ pub fn _mm256_cmpgt_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi64_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -32638,7 +34215,8 @@ pub fn _mm256_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_cmpgt_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_gt(a.as_i64x2(), b.as_i64x2())) } } @@ -32649,7 +34227,8 @@ pub fn _mm_cmpgt_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi64_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -32660,7 +34239,8 @@ pub fn _mm_mask_cmpgt_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_cmple_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_le(a.as_i64x8(), b.as_i64x8())) } } @@ -32671,7 +34251,8 @@ pub fn _mm512_cmple_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_mask_cmple_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epi64_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -32682,7 +34263,8 @@ pub fn _mm512_mask_cmple_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_cmple_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_le(a.as_i64x4(), b.as_i64x4())) } } @@ -32693,7 +34275,8 @@ pub fn _mm256_cmple_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_mask_cmple_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi64_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -32704,7 +34287,8 @@ pub fn _mm256_mask_cmple_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_cmple_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_le(a.as_i64x2(), b.as_i64x2())) } } @@ -32715,7 +34299,8 @@ pub fn _mm_cmple_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_mask_cmple_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi64_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -32726,7 +34311,8 @@ pub fn _mm_mask_cmple_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_cmpge_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_ge(a.as_i64x8(), b.as_i64x8())) } } @@ -32737,7 +34323,8 @@ pub fn _mm512_cmpge_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_mask_cmpge_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epi64_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -32748,7 +34335,8 @@ pub fn _mm512_mask_cmpge_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_cmpge_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_ge(a.as_i64x4(), b.as_i64x4())) } } @@ -32759,7 +34347,8 @@ pub fn _mm256_cmpge_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_mask_cmpge_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi64_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -32770,7 +34359,8 @@ pub fn _mm256_mask_cmpge_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_cmpge_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_ge(a.as_i64x2(), b.as_i64x2())) } } @@ -32781,7 +34371,8 @@ pub fn _mm_cmpge_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_mask_cmpge_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi64_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -32792,7 +34383,8 @@ pub fn _mm_mask_cmpge_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_cmpeq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_eq(a.as_i64x8(), b.as_i64x8())) } } @@ -32803,7 +34395,8 @@ pub fn _mm512_cmpeq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epi64_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -32814,7 +34407,8 @@ pub fn _mm512_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_cmpeq_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_eq(a.as_i64x4(), b.as_i64x4())) } } @@ -32825,7 +34419,8 @@ pub fn _mm256_cmpeq_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi64_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -32836,7 +34431,8 @@ pub fn _mm256_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_cmpeq_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_eq(a.as_i64x2(), b.as_i64x2())) } } @@ -32847,7 +34443,8 @@ pub fn _mm_cmpeq_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi64_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -32858,7 +34455,8 @@ pub fn _mm_mask_cmpeq_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_cmpneq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { unsafe { simd_bitmask::<__m512i, _>(simd_ne(a.as_i64x8(), b.as_i64x8())) } } @@ -32869,7 +34467,8 @@ pub fn _mm512_cmpneq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm512_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __mmask8 { _mm512_mask_cmp_epi64_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -32880,7 +34479,8 @@ pub fn _mm512_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_cmpneq_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { unsafe { simd_bitmask::<__m256i, _>(simd_ne(a.as_i64x4(), b.as_i64x4())) } } @@ -32891,7 +34491,8 @@ pub fn _mm256_cmpneq_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm256_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __mmask8 { _mm256_mask_cmp_epi64_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -32902,7 +34503,8 @@ pub fn _mm256_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_cmpneq_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::<__m128i, _>(simd_ne(a.as_i64x2(), b.as_i64x2())) } } @@ -32913,7 +34515,8 @@ pub fn _mm_cmpneq_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] //should be vpcmpq -pub fn _mm_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi64_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -32925,7 +34528,11 @@ pub fn _mm_mask_cmpneq_epi64_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mma #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_cmp_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epi64_mask( + a: __m512i, + b: __m512i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_i64x8(); @@ -32952,7 +34559,8 @@ pub fn _mm512_cmp_epi64_mask(a: __m512i, b: __m512i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm512_mask_cmp_epi64_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epi64_mask( k1: __mmask8, a: __m512i, b: __m512i, @@ -32984,7 +34592,11 @@ pub fn _mm512_mask_cmp_epi64_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_cmp_epi64_mask(a: __m256i, b: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epi64_mask( + a: __m256i, + b: __m256i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_i64x4(); @@ -33011,7 +34623,8 @@ pub fn _mm256_cmp_epi64_mask(a: __m256i, b: __m256i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm256_mask_cmp_epi64_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epi64_mask( k1: __mmask8, a: __m256i, b: __m256i, @@ -33043,7 +34656,8 @@ pub fn _mm256_mask_cmp_epi64_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_cmp_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epi64_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM3, 3); let a = a.as_i64x2(); @@ -33070,7 +34684,8 @@ pub fn _mm_cmp_epi64_mask(a: __m128i, b: __m128i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM3 = 0))] -pub fn _mm_mask_cmp_epi64_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epi64_mask( k1: __mmask8, a: __m128i, b: __m128i, @@ -33100,7 +34715,8 @@ pub fn _mm_mask_cmp_epi64_mask( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_add_epi32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_add_epi32(a: __m512i) -> i32 { unsafe { simd_reduce_add_ordered(a.as_i32x16(), 0) } } @@ -33110,7 +34726,8 @@ pub fn _mm512_reduce_add_epi32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_add_epi32(k: __mmask16, a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_add_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i32x16(), i32x16::ZERO), 0) } } @@ -33120,7 +34737,8 @@ pub fn _mm512_mask_reduce_add_epi32(k: __mmask16, a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_add_epi64(a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_add_epi64(a: __m512i) -> i64 { unsafe { simd_reduce_add_ordered(a.as_i64x8(), 0) } } @@ -33130,7 +34748,8 @@ pub fn _mm512_reduce_add_epi64(a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_add_epi64(k: __mmask8, a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_add_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i64x8(), i64x8::ZERO), 0) } } @@ -33140,7 +34759,8 @@ pub fn _mm512_mask_reduce_add_epi64(k: __mmask8, a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_add_ps(a: __m512) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_add_ps(a: __m512) -> f32 { unsafe { // we have to use `simd_shuffle` here because `_mm512_extractf32x8_ps` is in AVX512DQ let a = _mm256_add_ps( @@ -33159,7 +34779,8 @@ pub fn _mm512_reduce_add_ps(a: __m512) -> f32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_add_ps(k: __mmask16, a: __m512) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_add_ps(k: __mmask16, a: __m512) -> f32 { unsafe { _mm512_reduce_add_ps(simd_select_bitmask(k, a, _mm512_setzero_ps())) } } @@ -33169,7 +34790,8 @@ pub fn _mm512_mask_reduce_add_ps(k: __mmask16, a: __m512) -> f32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_add_pd(a: __m512d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_add_pd(a: __m512d) -> f64 { unsafe { let a = _mm256_add_pd( _mm512_extractf64x4_pd::<0>(a), @@ -33186,7 +34808,8 @@ pub fn _mm512_reduce_add_pd(a: __m512d) -> f64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_add_pd(k: __mmask8, a: __m512d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_add_pd(k: __mmask8, a: __m512d) -> f64 { unsafe { _mm512_reduce_add_pd(simd_select_bitmask(k, a, _mm512_setzero_pd())) } } @@ -33196,7 +34819,8 @@ pub fn _mm512_mask_reduce_add_pd(k: __mmask8, a: __m512d) -> f64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_mul_epi32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_mul_epi32(a: __m512i) -> i32 { unsafe { simd_reduce_mul_ordered(a.as_i32x16(), 1) } } @@ -33206,7 +34830,8 @@ pub fn _mm512_reduce_mul_epi32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_mul_epi32(k: __mmask16, a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_mul_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { simd_reduce_mul_ordered( simd_select_bitmask(k, a.as_i32x16(), _mm512_set1_epi32(1).as_i32x16()), @@ -33221,7 +34846,8 @@ pub fn _mm512_mask_reduce_mul_epi32(k: __mmask16, a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_mul_epi64(a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_mul_epi64(a: __m512i) -> i64 { unsafe { simd_reduce_mul_ordered(a.as_i64x8(), 1) } } @@ -33231,7 +34857,8 @@ pub fn _mm512_reduce_mul_epi64(a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_mul_epi64(k: __mmask8, a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_mul_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { simd_reduce_mul_ordered( simd_select_bitmask(k, a.as_i64x8(), _mm512_set1_epi64(1).as_i64x8()), @@ -33246,7 +34873,8 @@ pub fn _mm512_mask_reduce_mul_epi64(k: __mmask8, a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_mul_ps(a: __m512) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_mul_ps(a: __m512) -> f32 { unsafe { // we have to use `simd_shuffle` here because `_mm512_extractf32x8_ps` is in AVX512DQ let a = _mm256_mul_ps( @@ -33265,7 +34893,8 @@ pub fn _mm512_reduce_mul_ps(a: __m512) -> f32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_mul_ps(k: __mmask16, a: __m512) -> f32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_mul_ps(k: __mmask16, a: __m512) -> f32 { unsafe { _mm512_reduce_mul_ps(simd_select_bitmask(k, a, _mm512_set1_ps(1.))) } } @@ -33275,7 +34904,8 @@ pub fn _mm512_mask_reduce_mul_ps(k: __mmask16, a: __m512) -> f32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_mul_pd(a: __m512d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_mul_pd(a: __m512d) -> f64 { unsafe { let a = _mm256_mul_pd( _mm512_extractf64x4_pd::<0>(a), @@ -33292,7 +34922,8 @@ pub fn _mm512_reduce_mul_pd(a: __m512d) -> f64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_mul_pd(k: __mmask8, a: __m512d) -> f64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_mul_pd(k: __mmask8, a: __m512d) -> f64 { unsafe { _mm512_reduce_mul_pd(simd_select_bitmask(k, a, _mm512_set1_pd(1.))) } } @@ -33302,7 +34933,8 @@ pub fn _mm512_mask_reduce_mul_pd(k: __mmask8, a: __m512d) -> f64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_max_epi32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_max_epi32(a: __m512i) -> i32 { unsafe { simd_reduce_max(a.as_i32x16()) } } @@ -33312,7 +34944,8 @@ pub fn _mm512_reduce_max_epi32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_max_epi32(k: __mmask16, a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_max_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { simd_reduce_max(simd_select_bitmask( k, @@ -33328,7 +34961,8 @@ pub fn _mm512_mask_reduce_max_epi32(k: __mmask16, a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_max_epi64(a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_max_epi64(a: __m512i) -> i64 { unsafe { simd_reduce_max(a.as_i64x8()) } } @@ -33338,7 +34972,8 @@ pub fn _mm512_reduce_max_epi64(a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_max_epi64(k: __mmask8, a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_max_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_i64x8(), i64x8::splat(i64::MIN))) } } @@ -33348,7 +34983,8 @@ pub fn _mm512_mask_reduce_max_epi64(k: __mmask8, a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_max_epu32(a: __m512i) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_max_epu32(a: __m512i) -> u32 { unsafe { simd_reduce_max(a.as_u32x16()) } } @@ -33358,7 +34994,8 @@ pub fn _mm512_reduce_max_epu32(a: __m512i) -> u32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_max_epu32(k: __mmask16, a: __m512i) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_max_epu32(k: __mmask16, a: __m512i) -> u32 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_u32x16(), u32x16::ZERO)) } } @@ -33368,7 +35005,8 @@ pub fn _mm512_mask_reduce_max_epu32(k: __mmask16, a: __m512i) -> u32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_max_epu64(a: __m512i) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_max_epu64(a: __m512i) -> u64 { unsafe { simd_reduce_max(a.as_u64x8()) } } @@ -33378,7 +35016,8 @@ pub fn _mm512_reduce_max_epu64(a: __m512i) -> u64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_max_epu64(k: __mmask8, a: __m512i) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_max_epu64(k: __mmask8, a: __m512i) -> u64 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_u64x8(), u64x8::ZERO)) } } @@ -33443,7 +35082,8 @@ pub fn _mm512_mask_reduce_max_pd(k: __mmask8, a: __m512d) -> f64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_min_epi32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_min_epi32(a: __m512i) -> i32 { unsafe { simd_reduce_min(a.as_i32x16()) } } @@ -33453,7 +35093,8 @@ pub fn _mm512_reduce_min_epi32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_min_epi32(k: __mmask16, a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_min_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { simd_reduce_min(simd_select_bitmask( k, @@ -33469,7 +35110,8 @@ pub fn _mm512_mask_reduce_min_epi32(k: __mmask16, a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_min_epi64(a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_min_epi64(a: __m512i) -> i64 { unsafe { simd_reduce_min(a.as_i64x8()) } } @@ -33479,7 +35121,8 @@ pub fn _mm512_reduce_min_epi64(a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_min_epi64(k: __mmask8, a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_min_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_i64x8(), i64x8::splat(i64::MAX))) } } @@ -33489,7 +35132,8 @@ pub fn _mm512_mask_reduce_min_epi64(k: __mmask8, a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_min_epu32(a: __m512i) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_min_epu32(a: __m512i) -> u32 { unsafe { simd_reduce_min(a.as_u32x16()) } } @@ -33499,7 +35143,8 @@ pub fn _mm512_reduce_min_epu32(a: __m512i) -> u32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_min_epu32(k: __mmask16, a: __m512i) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_min_epu32(k: __mmask16, a: __m512i) -> u32 { unsafe { simd_reduce_min(simd_select_bitmask( k, @@ -33515,7 +35160,8 @@ pub fn _mm512_mask_reduce_min_epu32(k: __mmask16, a: __m512i) -> u32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_min_epu64(a: __m512i) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_min_epu64(a: __m512i) -> u64 { unsafe { simd_reduce_min(a.as_u64x8()) } } @@ -33525,7 +35171,8 @@ pub fn _mm512_reduce_min_epu64(a: __m512i) -> u64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_min_epu64(k: __mmask8, a: __m512i) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_min_epu64(k: __mmask8, a: __m512i) -> u64 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_u64x8(), u64x8::splat(u64::MAX))) } } @@ -33590,7 +35237,8 @@ pub fn _mm512_mask_reduce_min_pd(k: __mmask8, a: __m512d) -> f64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_and_epi32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_and_epi32(a: __m512i) -> i32 { unsafe { simd_reduce_and(a.as_i32x16()) } } @@ -33600,7 +35248,8 @@ pub fn _mm512_reduce_and_epi32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_and_epi32(k: __mmask16, a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_and_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { simd_reduce_and(simd_select_bitmask(k, a.as_i32x16(), i32x16::splat(-1))) } } @@ -33610,7 +35259,8 @@ pub fn _mm512_mask_reduce_and_epi32(k: __mmask16, a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_and_epi64(a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_and_epi64(a: __m512i) -> i64 { unsafe { simd_reduce_and(a.as_i64x8()) } } @@ -33620,7 +35270,8 @@ pub fn _mm512_reduce_and_epi64(a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_and_epi64(k: __mmask8, a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_and_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { simd_reduce_and(simd_select_bitmask(k, a.as_i64x8(), i64x8::splat(-1))) } } @@ -33630,7 +35281,8 @@ pub fn _mm512_mask_reduce_and_epi64(k: __mmask8, a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_or_epi32(a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_or_epi32(a: __m512i) -> i32 { unsafe { simd_reduce_or(a.as_i32x16()) } } @@ -33640,7 +35292,8 @@ pub fn _mm512_reduce_or_epi32(a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_or_epi32(k: __mmask16, a: __m512i) -> i32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_or_epi32(k: __mmask16, a: __m512i) -> i32 { unsafe { simd_reduce_or(simd_select_bitmask(k, a.as_i32x16(), i32x16::ZERO)) } } @@ -33650,7 +35303,8 @@ pub fn _mm512_mask_reduce_or_epi32(k: __mmask16, a: __m512i) -> i32 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_reduce_or_epi64(a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_or_epi64(a: __m512i) -> i64 { unsafe { simd_reduce_or(a.as_i64x8()) } } @@ -33660,7 +35314,8 @@ pub fn _mm512_reduce_or_epi64(a: __m512i) -> i64 { #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_reduce_or_epi64(k: __mmask8, a: __m512i) -> i64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_reduce_or_epi64(k: __mmask8, a: __m512i) -> i64 { unsafe { simd_reduce_or(simd_select_bitmask(k, a.as_i64x8(), i64x8::ZERO)) } } @@ -33674,7 +35329,8 @@ pub fn _mm512_mask_reduce_or_epi64(k: __mmask8, a: __m512i) -> i64 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] // This intrinsic has no corresponding instruction. -pub fn _mm512_undefined_pd() -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_undefined_pd() -> __m512d { unsafe { const { mem::zeroed() } } } @@ -33688,7 +35344,8 @@ pub fn _mm512_undefined_pd() -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] // This intrinsic has no corresponding instruction. -pub fn _mm512_undefined_ps() -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_undefined_ps() -> __m512 { unsafe { const { mem::zeroed() } } } @@ -33702,7 +35359,8 @@ pub fn _mm512_undefined_ps() -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] // This intrinsic has no corresponding instruction. -pub fn _mm512_undefined_epi32() -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_undefined_epi32() -> __m512i { unsafe { const { mem::zeroed() } } } @@ -33716,7 +35374,8 @@ pub fn _mm512_undefined_epi32() -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] // This intrinsic has no corresponding instruction. -pub fn _mm512_undefined() -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_undefined() -> __m512 { unsafe { const { mem::zeroed() } } } @@ -33727,7 +35386,8 @@ pub fn _mm512_undefined() -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm512_loadu_epi32(mem_addr: *const i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_epi32(mem_addr: *const i32) -> __m512i { ptr::read_unaligned(mem_addr as *const __m512i) } @@ -33738,7 +35398,8 @@ pub unsafe fn _mm512_loadu_epi32(mem_addr: *const i32) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm256_loadu_epi32(mem_addr: *const i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_epi32(mem_addr: *const i32) -> __m256i { ptr::read_unaligned(mem_addr as *const __m256i) } @@ -33749,7 +35410,8 @@ pub unsafe fn _mm256_loadu_epi32(mem_addr: *const i32) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm_loadu_epi32(mem_addr: *const i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_epi32(mem_addr: *const i32) -> __m128i { ptr::read_unaligned(mem_addr as *const __m128i) } @@ -34255,7 +35917,8 @@ pub unsafe fn _mm_mask_cvtusepi64_storeu_epi32(mem_addr: *mut i32, k: __mmask8, #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm512_storeu_epi32(mem_addr: *mut i32, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_epi32(mem_addr: *mut i32, a: __m512i) { ptr::write_unaligned(mem_addr as *mut __m512i, a); } @@ -34266,7 +35929,8 @@ pub unsafe fn _mm512_storeu_epi32(mem_addr: *mut i32, a: __m512i) { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm256_storeu_epi32(mem_addr: *mut i32, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_epi32(mem_addr: *mut i32, a: __m256i) { ptr::write_unaligned(mem_addr as *mut __m256i, a); } @@ -34277,7 +35941,8 @@ pub unsafe fn _mm256_storeu_epi32(mem_addr: *mut i32, a: __m256i) { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm_storeu_epi32(mem_addr: *mut i32, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_epi32(mem_addr: *mut i32, a: __m128i) { ptr::write_unaligned(mem_addr as *mut __m128i, a); } @@ -34288,7 +35953,8 @@ pub unsafe fn _mm_storeu_epi32(mem_addr: *mut i32, a: __m128i) { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu64 -pub unsafe fn _mm512_loadu_epi64(mem_addr: *const i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_epi64(mem_addr: *const i64) -> __m512i { ptr::read_unaligned(mem_addr as *const __m512i) } @@ -34299,7 +35965,8 @@ pub unsafe fn _mm512_loadu_epi64(mem_addr: *const i64) -> __m512i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu64 -pub unsafe fn _mm256_loadu_epi64(mem_addr: *const i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_epi64(mem_addr: *const i64) -> __m256i { ptr::read_unaligned(mem_addr as *const __m256i) } @@ -34310,7 +35977,8 @@ pub unsafe fn _mm256_loadu_epi64(mem_addr: *const i64) -> __m256i { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu64 -pub unsafe fn _mm_loadu_epi64(mem_addr: *const i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_epi64(mem_addr: *const i64) -> __m128i { ptr::read_unaligned(mem_addr as *const __m128i) } @@ -34321,7 +35989,8 @@ pub unsafe fn _mm_loadu_epi64(mem_addr: *const i64) -> __m128i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu64 -pub unsafe fn _mm512_storeu_epi64(mem_addr: *mut i64, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_epi64(mem_addr: *mut i64, a: __m512i) { ptr::write_unaligned(mem_addr as *mut __m512i, a); } @@ -34332,7 +36001,8 @@ pub unsafe fn _mm512_storeu_epi64(mem_addr: *mut i64, a: __m512i) { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu64 -pub unsafe fn _mm256_storeu_epi64(mem_addr: *mut i64, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_epi64(mem_addr: *mut i64, a: __m256i) { ptr::write_unaligned(mem_addr as *mut __m256i, a); } @@ -34343,7 +36013,8 @@ pub unsafe fn _mm256_storeu_epi64(mem_addr: *mut i64, a: __m256i) { #[target_feature(enable = "avx512f,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu64 -pub unsafe fn _mm_storeu_epi64(mem_addr: *mut i64, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_epi64(mem_addr: *mut i64, a: __m128i) { ptr::write_unaligned(mem_addr as *mut __m128i, a); } @@ -34354,7 +36025,8 @@ pub unsafe fn _mm_storeu_epi64(mem_addr: *mut i64, a: __m128i) { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm512_loadu_si512(mem_addr: *const __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_si512(mem_addr: *const __m512i) -> __m512i { ptr::read_unaligned(mem_addr) } @@ -34365,7 +36037,8 @@ pub unsafe fn _mm512_loadu_si512(mem_addr: *const __m512i) -> __m512i { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu32 -pub unsafe fn _mm512_storeu_si512(mem_addr: *mut __m512i, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_si512(mem_addr: *mut __m512i, a: __m512i) { ptr::write_unaligned(mem_addr, a); } @@ -34378,7 +36051,8 @@ pub unsafe fn _mm512_storeu_si512(mem_addr: *mut __m512i, a: __m512i) { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] -pub unsafe fn _mm512_loadu_pd(mem_addr: *const f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_pd(mem_addr: *const f64) -> __m512d { ptr::read_unaligned(mem_addr as *const __m512d) } @@ -34391,7 +36065,8 @@ pub unsafe fn _mm512_loadu_pd(mem_addr: *const f64) -> __m512d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] -pub unsafe fn _mm512_storeu_pd(mem_addr: *mut f64, a: __m512d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_pd(mem_addr: *mut f64, a: __m512d) { ptr::write_unaligned(mem_addr as *mut __m512d, a); } @@ -34404,7 +36079,8 @@ pub unsafe fn _mm512_storeu_pd(mem_addr: *mut f64, a: __m512d) { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] -pub unsafe fn _mm512_loadu_ps(mem_addr: *const f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_ps(mem_addr: *const f32) -> __m512 { ptr::read_unaligned(mem_addr as *const __m512) } @@ -34417,7 +36093,8 @@ pub unsafe fn _mm512_loadu_ps(mem_addr: *const f32) -> __m512 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] -pub unsafe fn _mm512_storeu_ps(mem_addr: *mut f32, a: __m512) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_ps(mem_addr: *mut f32, a: __m512) { ptr::write_unaligned(mem_addr as *mut __m512, a); } @@ -34431,7 +36108,8 @@ pub unsafe fn _mm512_storeu_ps(mem_addr: *mut f32, a: __m512) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm512_load_si512(mem_addr: *const __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_load_si512(mem_addr: *const __m512i) -> __m512i { ptr::read(mem_addr) } @@ -34445,7 +36123,8 @@ pub unsafe fn _mm512_load_si512(mem_addr: *const __m512i) -> __m512i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm512_store_si512(mem_addr: *mut __m512i, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_store_si512(mem_addr: *mut __m512i, a: __m512i) { ptr::write(mem_addr, a); } @@ -34459,7 +36138,8 @@ pub unsafe fn _mm512_store_si512(mem_addr: *mut __m512i, a: __m512i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm512_load_epi32(mem_addr: *const i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_load_epi32(mem_addr: *const i32) -> __m512i { ptr::read(mem_addr as *const __m512i) } @@ -34473,7 +36153,8 @@ pub unsafe fn _mm512_load_epi32(mem_addr: *const i32) -> __m512i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm256_load_epi32(mem_addr: *const i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_load_epi32(mem_addr: *const i32) -> __m256i { ptr::read(mem_addr as *const __m256i) } @@ -34487,7 +36168,8 @@ pub unsafe fn _mm256_load_epi32(mem_addr: *const i32) -> __m256i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm_load_epi32(mem_addr: *const i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_epi32(mem_addr: *const i32) -> __m128i { ptr::read(mem_addr as *const __m128i) } @@ -34501,7 +36183,8 @@ pub unsafe fn _mm_load_epi32(mem_addr: *const i32) -> __m128i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm512_store_epi32(mem_addr: *mut i32, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_store_epi32(mem_addr: *mut i32, a: __m512i) { ptr::write(mem_addr as *mut __m512i, a); } @@ -34515,7 +36198,8 @@ pub unsafe fn _mm512_store_epi32(mem_addr: *mut i32, a: __m512i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm256_store_epi32(mem_addr: *mut i32, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_store_epi32(mem_addr: *mut i32, a: __m256i) { ptr::write(mem_addr as *mut __m256i, a); } @@ -34529,7 +36213,8 @@ pub unsafe fn _mm256_store_epi32(mem_addr: *mut i32, a: __m256i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa32 -pub unsafe fn _mm_store_epi32(mem_addr: *mut i32, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_epi32(mem_addr: *mut i32, a: __m128i) { ptr::write(mem_addr as *mut __m128i, a); } @@ -34543,7 +36228,8 @@ pub unsafe fn _mm_store_epi32(mem_addr: *mut i32, a: __m128i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa64 -pub unsafe fn _mm512_load_epi64(mem_addr: *const i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_load_epi64(mem_addr: *const i64) -> __m512i { ptr::read(mem_addr as *const __m512i) } @@ -34557,7 +36243,8 @@ pub unsafe fn _mm512_load_epi64(mem_addr: *const i64) -> __m512i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa64 -pub unsafe fn _mm256_load_epi64(mem_addr: *const i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_load_epi64(mem_addr: *const i64) -> __m256i { ptr::read(mem_addr as *const __m256i) } @@ -34571,7 +36258,8 @@ pub unsafe fn _mm256_load_epi64(mem_addr: *const i64) -> __m256i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa64 -pub unsafe fn _mm_load_epi64(mem_addr: *const i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_epi64(mem_addr: *const i64) -> __m128i { ptr::read(mem_addr as *const __m128i) } @@ -34585,7 +36273,8 @@ pub unsafe fn _mm_load_epi64(mem_addr: *const i64) -> __m128i { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa64 -pub unsafe fn _mm512_store_epi64(mem_addr: *mut i64, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_store_epi64(mem_addr: *mut i64, a: __m512i) { ptr::write(mem_addr as *mut __m512i, a); } @@ -34599,7 +36288,8 @@ pub unsafe fn _mm512_store_epi64(mem_addr: *mut i64, a: __m512i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa64 -pub unsafe fn _mm256_store_epi64(mem_addr: *mut i64, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_store_epi64(mem_addr: *mut i64, a: __m256i) { ptr::write(mem_addr as *mut __m256i, a); } @@ -34613,7 +36303,8 @@ pub unsafe fn _mm256_store_epi64(mem_addr: *mut i64, a: __m256i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovdqa64 -pub unsafe fn _mm_store_epi64(mem_addr: *mut i64, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_epi64(mem_addr: *mut i64, a: __m128i) { ptr::write(mem_addr as *mut __m128i, a); } @@ -34627,7 +36318,8 @@ pub unsafe fn _mm_store_epi64(mem_addr: *mut i64, a: __m128i) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] -pub unsafe fn _mm512_load_ps(mem_addr: *const f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_load_ps(mem_addr: *const f32) -> __m512 { ptr::read(mem_addr as *const __m512) } @@ -34641,7 +36333,8 @@ pub unsafe fn _mm512_load_ps(mem_addr: *const f32) -> __m512 { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] -pub unsafe fn _mm512_store_ps(mem_addr: *mut f32, a: __m512) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_store_ps(mem_addr: *mut f32, a: __m512) { ptr::write(mem_addr as *mut __m512, a); } @@ -34655,7 +36348,8 @@ pub unsafe fn _mm512_store_ps(mem_addr: *mut f32, a: __m512) { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovapd -pub unsafe fn _mm512_load_pd(mem_addr: *const f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_load_pd(mem_addr: *const f64) -> __m512d { ptr::read(mem_addr as *const __m512d) } @@ -34669,7 +36363,8 @@ pub unsafe fn _mm512_load_pd(mem_addr: *const f64) -> __m512d { all(test, not(all(target_arch = "x86", target_env = "msvc"))), assert_instr(vmovaps) )] //should be vmovapd -pub unsafe fn _mm512_store_pd(mem_addr: *mut f64, a: __m512d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_store_pd(mem_addr: *mut f64, a: __m512d) { ptr::write(mem_addr as *mut __m512d, a); } @@ -34682,7 +36377,12 @@ pub unsafe fn _mm512_store_pd(mem_addr: *mut f64, a: __m512d) { #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_loadu_epi32(src: __m512i, k: __mmask16, mem_addr: *const i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_loadu_epi32( + src: __m512i, + k: __mmask16, + mem_addr: *const i32, +) -> __m512i { let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i32x16()).as_m512i() } @@ -34696,7 +36396,8 @@ pub unsafe fn _mm512_mask_loadu_epi32(src: __m512i, k: __mmask16, mem_addr: *con #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_loadu_epi32(k: __mmask16, mem_addr: *const i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_loadu_epi32(k: __mmask16, mem_addr: *const i32) -> __m512i { _mm512_mask_loadu_epi32(_mm512_setzero_si512(), k, mem_addr) } @@ -34709,7 +36410,12 @@ pub unsafe fn _mm512_maskz_loadu_epi32(k: __mmask16, mem_addr: *const i32) -> __ #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_loadu_epi64(src: __m512i, k: __mmask8, mem_addr: *const i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_loadu_epi64( + src: __m512i, + k: __mmask8, + mem_addr: *const i64, +) -> __m512i { let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i64x8()).as_m512i() } @@ -34723,7 +36429,8 @@ pub unsafe fn _mm512_mask_loadu_epi64(src: __m512i, k: __mmask8, mem_addr: *cons #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m512i { _mm512_mask_loadu_epi64(_mm512_setzero_si512(), k, mem_addr) } @@ -34736,7 +36443,12 @@ pub unsafe fn _mm512_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_loadu_ps(src: __m512, k: __mmask16, mem_addr: *const f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_loadu_ps( + src: __m512, + k: __mmask16, + mem_addr: *const f32, +) -> __m512 { let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f32x16()).as_m512() } @@ -34750,7 +36462,8 @@ pub unsafe fn _mm512_mask_loadu_ps(src: __m512, k: __mmask16, mem_addr: *const f #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_loadu_ps(k: __mmask16, mem_addr: *const f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_loadu_ps(k: __mmask16, mem_addr: *const f32) -> __m512 { _mm512_mask_loadu_ps(_mm512_setzero_ps(), k, mem_addr) } @@ -34763,7 +36476,12 @@ pub unsafe fn _mm512_maskz_loadu_ps(k: __mmask16, mem_addr: *const f32) -> __m51 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_loadu_pd(src: __m512d, k: __mmask8, mem_addr: *const f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_loadu_pd( + src: __m512d, + k: __mmask8, + mem_addr: *const f64, +) -> __m512d { let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f64x8()).as_m512d() } @@ -34777,7 +36495,8 @@ pub unsafe fn _mm512_mask_loadu_pd(src: __m512d, k: __mmask8, mem_addr: *const f #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m512d { _mm512_mask_loadu_pd(_mm512_setzero_pd(), k, mem_addr) } @@ -34790,7 +36509,12 @@ pub unsafe fn _mm512_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m512 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_loadu_epi32(src: __m256i, k: __mmask8, mem_addr: *const i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_loadu_epi32( + src: __m256i, + k: __mmask8, + mem_addr: *const i32, +) -> __m256i { let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i32x8()).as_m256i() } @@ -34804,7 +36528,8 @@ pub unsafe fn _mm256_mask_loadu_epi32(src: __m256i, k: __mmask8, mem_addr: *cons #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m256i { _mm256_mask_loadu_epi32(_mm256_setzero_si256(), k, mem_addr) } @@ -34817,7 +36542,12 @@ pub unsafe fn _mm256_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_loadu_epi64(src: __m256i, k: __mmask8, mem_addr: *const i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_loadu_epi64( + src: __m256i, + k: __mmask8, + mem_addr: *const i64, +) -> __m256i { let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i64x4()).as_m256i() } @@ -34831,7 +36561,8 @@ pub unsafe fn _mm256_mask_loadu_epi64(src: __m256i, k: __mmask8, mem_addr: *cons #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m256i { _mm256_mask_loadu_epi64(_mm256_setzero_si256(), k, mem_addr) } @@ -34844,7 +36575,8 @@ pub unsafe fn _mm256_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_loadu_ps(src: __m256, k: __mmask8, mem_addr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_loadu_ps(src: __m256, k: __mmask8, mem_addr: *const f32) -> __m256 { let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f32x8()).as_m256() } @@ -34858,7 +36590,8 @@ pub unsafe fn _mm256_mask_loadu_ps(src: __m256, k: __mmask8, mem_addr: *const f3 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m256 { _mm256_mask_loadu_ps(_mm256_setzero_ps(), k, mem_addr) } @@ -34871,7 +36604,12 @@ pub unsafe fn _mm256_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m256 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_loadu_pd(src: __m256d, k: __mmask8, mem_addr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_loadu_pd( + src: __m256d, + k: __mmask8, + mem_addr: *const f64, +) -> __m256d { let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f64x4()).as_m256d() } @@ -34885,7 +36623,8 @@ pub unsafe fn _mm256_mask_loadu_pd(src: __m256d, k: __mmask8, mem_addr: *const f #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m256d { _mm256_mask_loadu_pd(_mm256_setzero_pd(), k, mem_addr) } @@ -34898,7 +36637,12 @@ pub unsafe fn _mm256_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m256 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_loadu_epi32(src: __m128i, k: __mmask8, mem_addr: *const i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_loadu_epi32( + src: __m128i, + k: __mmask8, + mem_addr: *const i32, +) -> __m128i { let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i32x4()).as_m128i() } @@ -34912,7 +36656,8 @@ pub unsafe fn _mm_mask_loadu_epi32(src: __m128i, k: __mmask8, mem_addr: *const i #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m128i { _mm_mask_loadu_epi32(_mm_setzero_si128(), k, mem_addr) } @@ -34925,7 +36670,12 @@ pub unsafe fn _mm_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_loadu_epi64(src: __m128i, k: __mmask8, mem_addr: *const i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_loadu_epi64( + src: __m128i, + k: __mmask8, + mem_addr: *const i64, +) -> __m128i { let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i64x2()).as_m128i() } @@ -34939,7 +36689,8 @@ pub unsafe fn _mm_mask_loadu_epi64(src: __m128i, k: __mmask8, mem_addr: *const i #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m128i { _mm_mask_loadu_epi64(_mm_setzero_si128(), k, mem_addr) } @@ -34952,7 +36703,8 @@ pub unsafe fn _mm_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m128 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_loadu_ps(src: __m128, k: __mmask8, mem_addr: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_loadu_ps(src: __m128, k: __mmask8, mem_addr: *const f32) -> __m128 { let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f32x4()).as_m128() } @@ -34966,7 +36718,8 @@ pub unsafe fn _mm_mask_loadu_ps(src: __m128, k: __mmask8, mem_addr: *const f32) #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { _mm_mask_loadu_ps(_mm_setzero_ps(), k, mem_addr) } @@ -34979,7 +36732,8 @@ pub unsafe fn _mm_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_loadu_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_loadu_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) -> __m128d { let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f64x2()).as_m128d() } @@ -34993,7 +36747,8 @@ pub unsafe fn _mm_mask_loadu_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m128d { _mm_mask_loadu_pd(_mm_setzero_pd(), k, mem_addr) } @@ -35006,7 +36761,12 @@ pub unsafe fn _mm_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m128d { #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_load_epi32(src: __m512i, k: __mmask16, mem_addr: *const i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_load_epi32( + src: __m512i, + k: __mmask16, + mem_addr: *const i32, +) -> __m512i { let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i32x16()).as_m512i() } @@ -35020,7 +36780,8 @@ pub unsafe fn _mm512_mask_load_epi32(src: __m512i, k: __mmask16, mem_addr: *cons #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_load_epi32(k: __mmask16, mem_addr: *const i32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_load_epi32(k: __mmask16, mem_addr: *const i32) -> __m512i { _mm512_mask_load_epi32(_mm512_setzero_si512(), k, mem_addr) } @@ -35033,7 +36794,12 @@ pub unsafe fn _mm512_maskz_load_epi32(k: __mmask16, mem_addr: *const i32) -> __m #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_load_epi64(src: __m512i, k: __mmask8, mem_addr: *const i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_load_epi64( + src: __m512i, + k: __mmask8, + mem_addr: *const i64, +) -> __m512i { let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i64x8()).as_m512i() } @@ -35047,7 +36813,8 @@ pub unsafe fn _mm512_mask_load_epi64(src: __m512i, k: __mmask8, mem_addr: *const #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m512i { _mm512_mask_load_epi64(_mm512_setzero_si512(), k, mem_addr) } @@ -35060,7 +36827,8 @@ pub unsafe fn _mm512_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m5 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_load_ps(src: __m512, k: __mmask16, mem_addr: *const f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_load_ps(src: __m512, k: __mmask16, mem_addr: *const f32) -> __m512 { let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f32x16()).as_m512() } @@ -35074,7 +36842,8 @@ pub unsafe fn _mm512_mask_load_ps(src: __m512, k: __mmask16, mem_addr: *const f3 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_load_ps(k: __mmask16, mem_addr: *const f32) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_load_ps(k: __mmask16, mem_addr: *const f32) -> __m512 { _mm512_mask_load_ps(_mm512_setzero_ps(), k, mem_addr) } @@ -35087,7 +36856,12 @@ pub unsafe fn _mm512_maskz_load_ps(k: __mmask16, mem_addr: *const f32) -> __m512 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_load_pd(src: __m512d, k: __mmask8, mem_addr: *const f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_load_pd( + src: __m512d, + k: __mmask8, + mem_addr: *const f64, +) -> __m512d { let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f64x8()).as_m512d() } @@ -35101,7 +36875,8 @@ pub unsafe fn _mm512_mask_load_pd(src: __m512d, k: __mmask8, mem_addr: *const f6 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m512d { _mm512_mask_load_pd(_mm512_setzero_pd(), k, mem_addr) } @@ -35114,7 +36889,12 @@ pub unsafe fn _mm512_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m512d #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_load_epi32(src: __m256i, k: __mmask8, mem_addr: *const i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_load_epi32( + src: __m256i, + k: __mmask8, + mem_addr: *const i32, +) -> __m256i { let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i32x8()).as_m256i() } @@ -35128,7 +36908,8 @@ pub unsafe fn _mm256_mask_load_epi32(src: __m256i, k: __mmask8, mem_addr: *const #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m256i { _mm256_mask_load_epi32(_mm256_setzero_si256(), k, mem_addr) } @@ -35141,7 +36922,12 @@ pub unsafe fn _mm256_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_load_epi64(src: __m256i, k: __mmask8, mem_addr: *const i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_load_epi64( + src: __m256i, + k: __mmask8, + mem_addr: *const i64, +) -> __m256i { let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i64x4()).as_m256i() } @@ -35155,7 +36941,8 @@ pub unsafe fn _mm256_mask_load_epi64(src: __m256i, k: __mmask8, mem_addr: *const #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m256i { _mm256_mask_load_epi64(_mm256_setzero_si256(), k, mem_addr) } @@ -35168,7 +36955,8 @@ pub unsafe fn _mm256_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m2 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_load_ps(src: __m256, k: __mmask8, mem_addr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_load_ps(src: __m256, k: __mmask8, mem_addr: *const f32) -> __m256 { let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f32x8()).as_m256() } @@ -35182,7 +36970,8 @@ pub unsafe fn _mm256_mask_load_ps(src: __m256, k: __mmask8, mem_addr: *const f32 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m256 { _mm256_mask_load_ps(_mm256_setzero_ps(), k, mem_addr) } @@ -35195,7 +36984,12 @@ pub unsafe fn _mm256_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m256 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_load_pd(src: __m256d, k: __mmask8, mem_addr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_load_pd( + src: __m256d, + k: __mmask8, + mem_addr: *const f64, +) -> __m256d { let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f64x4()).as_m256d() } @@ -35209,7 +37003,8 @@ pub unsafe fn _mm256_mask_load_pd(src: __m256d, k: __mmask8, mem_addr: *const f6 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m256d { _mm256_mask_load_pd(_mm256_setzero_pd(), k, mem_addr) } @@ -35222,7 +37017,12 @@ pub unsafe fn _mm256_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m256d #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_load_epi32(src: __m128i, k: __mmask8, mem_addr: *const i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_load_epi32( + src: __m128i, + k: __mmask8, + mem_addr: *const i32, +) -> __m128i { let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i32x4()).as_m128i() } @@ -35236,7 +37036,8 @@ pub unsafe fn _mm_mask_load_epi32(src: __m128i, k: __mmask8, mem_addr: *const i3 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m128i { _mm_mask_load_epi32(_mm_setzero_si128(), k, mem_addr) } @@ -35249,7 +37050,12 @@ pub unsafe fn _mm_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_load_epi64(src: __m128i, k: __mmask8, mem_addr: *const i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_load_epi64( + src: __m128i, + k: __mmask8, + mem_addr: *const i64, +) -> __m128i { let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i64x2()).as_m128i() } @@ -35263,7 +37069,8 @@ pub unsafe fn _mm_mask_load_epi64(src: __m128i, k: __mmask8, mem_addr: *const i6 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m128i { _mm_mask_load_epi64(_mm_setzero_si128(), k, mem_addr) } @@ -35276,7 +37083,8 @@ pub unsafe fn _mm_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m128i #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_load_ps(src: __m128, k: __mmask8, mem_addr: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_load_ps(src: __m128, k: __mmask8, mem_addr: *const f32) -> __m128 { let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f32x4()).as_m128() } @@ -35290,7 +37098,8 @@ pub unsafe fn _mm_mask_load_ps(src: __m128, k: __mmask8, mem_addr: *const f32) - #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { _mm_mask_load_ps(_mm_setzero_ps(), k, mem_addr) } @@ -35303,7 +37112,8 @@ pub unsafe fn _mm_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_load_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_load_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) -> __m128d { let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f64x2()).as_m128d() } @@ -35317,7 +37127,8 @@ pub unsafe fn _mm_mask_load_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m128d { _mm_mask_load_pd(_mm_setzero_pd(), k, mem_addr) } @@ -35417,7 +37228,8 @@ pub unsafe fn _mm_maskz_load_sd(k: __mmask8, mem_addr: *const f64) -> __m128d { #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask16, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask16, a: __m512i) { let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x16()); } @@ -35430,7 +37242,8 @@ pub unsafe fn _mm512_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask16, a: _ #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m512i) { let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x8()); } @@ -35443,7 +37256,8 @@ pub unsafe fn _mm512_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __ #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask16, a: __m512) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask16, a: __m512) { let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f32x16()); } @@ -35456,7 +37270,8 @@ pub unsafe fn _mm512_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask16, a: __m5 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512d) { let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f64x8()); } @@ -35469,7 +37284,8 @@ pub unsafe fn _mm512_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m51 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m256i) { let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x8()); } @@ -35482,7 +37298,8 @@ pub unsafe fn _mm256_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __ #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m256i) { let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x4()); } @@ -35495,7 +37312,8 @@ pub unsafe fn _mm256_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __ #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256) { let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f32x8()); } @@ -35508,7 +37326,8 @@ pub unsafe fn _mm256_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m25 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256d) { let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f64x4()); } @@ -35521,7 +37340,8 @@ pub unsafe fn _mm256_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m25 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128i) { let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x4()); } @@ -35534,7 +37354,8 @@ pub unsafe fn _mm_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m12 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128i) { let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x2()); } @@ -35547,7 +37368,8 @@ pub unsafe fn _mm_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m12 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f32x4()); } @@ -35560,7 +37382,8 @@ pub unsafe fn _mm_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) { let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f64x2()); } @@ -35573,7 +37396,8 @@ pub unsafe fn _mm_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_store_epi32(mem_addr: *mut i32, mask: __mmask16, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_store_epi32(mem_addr: *mut i32, mask: __mmask16, a: __m512i) { let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i32x16()); } @@ -35586,7 +37410,8 @@ pub unsafe fn _mm512_mask_store_epi32(mem_addr: *mut i32, mask: __mmask16, a: __ #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m512i) { let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i64x8()); } @@ -35599,7 +37424,8 @@ pub unsafe fn _mm512_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_store_ps(mem_addr: *mut f32, mask: __mmask16, a: __m512) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_store_ps(mem_addr: *mut f32, mask: __mmask16, a: __m512) { let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f32x16()); } @@ -35612,7 +37438,8 @@ pub unsafe fn _mm512_mask_store_ps(mem_addr: *mut f32, mask: __mmask16, a: __m51 #[target_feature(enable = "avx512f")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512d) { let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f64x8()); } @@ -35625,7 +37452,8 @@ pub unsafe fn _mm512_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m256i) { let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i32x8()); } @@ -35638,7 +37466,8 @@ pub unsafe fn _mm256_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m256i) { let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i64x4()); } @@ -35651,7 +37480,8 @@ pub unsafe fn _mm256_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256) { let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f32x8()); } @@ -35664,7 +37494,8 @@ pub unsafe fn _mm256_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256d) { let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f64x4()); } @@ -35677,7 +37508,8 @@ pub unsafe fn _mm256_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128i) { let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i32x4()); } @@ -35690,7 +37522,8 @@ pub unsafe fn _mm_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128i) { let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i64x2()); } @@ -35703,7 +37536,8 @@ pub unsafe fn _mm_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128 #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f32x4()); } @@ -35716,7 +37550,8 @@ pub unsafe fn _mm_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { #[target_feature(enable = "avx512f,avx512vl")] #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) { let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f64x2()); } @@ -36063,7 +37898,8 @@ pub unsafe fn _mm_maskz_expandloadu_pd(k: __mmask8, mem_addr: *const f64) -> __m #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_setr_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr_pd( e0: f64, e1: f64, e2: f64, @@ -36085,7 +37921,8 @@ pub fn _mm512_setr_pd( #[inline] #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_set_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_pd( e0: f64, e1: f64, e2: f64, @@ -36105,7 +37942,8 @@ pub fn _mm512_set_pd( #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovss))] -pub fn _mm_mask_move_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_move_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let extractsrc: f32 = simd_extract!(src, 0); let mut mov: f32 = extractsrc; @@ -36123,7 +37961,8 @@ pub fn _mm_mask_move_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovss))] -pub fn _mm_maskz_move_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_move_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mut mov: f32 = 0.; if (k & 0b00000001) != 0 { @@ -36140,7 +37979,8 @@ pub fn _mm_maskz_move_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsd))] -pub fn _mm_mask_move_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_move_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let extractsrc: f64 = simd_extract!(src, 0); let mut mov: f64 = extractsrc; @@ -36158,7 +37998,8 @@ pub fn _mm_mask_move_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovsd))] -pub fn _mm_maskz_move_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_move_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mut mov: f64 = 0.; if (k & 0b00000001) != 0 { @@ -36175,7 +38016,8 @@ pub fn _mm_maskz_move_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddss))] -pub fn _mm_mask_add_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let extractsrc: f32 = simd_extract!(src, 0); let mut add: f32 = extractsrc; @@ -36195,7 +38037,8 @@ pub fn _mm_mask_add_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddss))] -pub fn _mm_maskz_add_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mut add: f32 = 0.; if (k & 0b00000001) != 0 { @@ -36214,7 +38057,8 @@ pub fn _mm_maskz_add_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddsd))] -pub fn _mm_mask_add_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let extractsrc: f64 = simd_extract!(src, 0); let mut add: f64 = extractsrc; @@ -36234,7 +38078,8 @@ pub fn _mm_mask_add_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vaddsd))] -pub fn _mm_maskz_add_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mut add: f64 = 0.; if (k & 0b00000001) != 0 { @@ -36253,7 +38098,8 @@ pub fn _mm_maskz_add_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubss))] -pub fn _mm_mask_sub_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let extractsrc: f32 = simd_extract!(src, 0); let mut add: f32 = extractsrc; @@ -36273,7 +38119,8 @@ pub fn _mm_mask_sub_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubss))] -pub fn _mm_maskz_sub_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mut add: f32 = 0.; if (k & 0b00000001) != 0 { @@ -36292,7 +38139,8 @@ pub fn _mm_maskz_sub_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubsd))] -pub fn _mm_mask_sub_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let extractsrc: f64 = simd_extract!(src, 0); let mut add: f64 = extractsrc; @@ -36312,7 +38160,8 @@ pub fn _mm_mask_sub_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vsubsd))] -pub fn _mm_maskz_sub_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mut add: f64 = 0.; if (k & 0b00000001) != 0 { @@ -36331,7 +38180,8 @@ pub fn _mm_maskz_sub_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulss))] -pub fn _mm_mask_mul_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let extractsrc: f32 = simd_extract!(src, 0); let mut add: f32 = extractsrc; @@ -36351,7 +38201,8 @@ pub fn _mm_mask_mul_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulss))] -pub fn _mm_maskz_mul_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mut add: f32 = 0.; if (k & 0b00000001) != 0 { @@ -36370,7 +38221,8 @@ pub fn _mm_maskz_mul_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulsd))] -pub fn _mm_mask_mul_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let extractsrc: f64 = simd_extract!(src, 0); let mut add: f64 = extractsrc; @@ -36390,7 +38242,8 @@ pub fn _mm_mask_mul_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmulsd))] -pub fn _mm_maskz_mul_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mut add: f64 = 0.; if (k & 0b00000001) != 0 { @@ -36409,7 +38262,8 @@ pub fn _mm_maskz_mul_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivss))] -pub fn _mm_mask_div_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_div_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let extractsrc: f32 = simd_extract!(src, 0); let mut add: f32 = extractsrc; @@ -36429,7 +38283,8 @@ pub fn _mm_mask_div_ss(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivss))] -pub fn _mm_maskz_div_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_div_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let mut add: f32 = 0.; if (k & 0b00000001) != 0 { @@ -36448,7 +38303,8 @@ pub fn _mm_maskz_div_ss(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivsd))] -pub fn _mm_mask_div_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_div_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let extractsrc: f64 = simd_extract!(src, 0); let mut add: f64 = extractsrc; @@ -36468,7 +38324,8 @@ pub fn _mm_mask_div_sd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vdivsd))] -pub fn _mm_maskz_div_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_div_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let mut add: f64 = 0.; if (k & 0b00000001) != 0 { @@ -37452,7 +39309,8 @@ pub fn _mm_maskz_scalef_sd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] -pub fn _mm_mask_fmadd_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmadd_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { let mut fmadd: f32 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37471,7 +39329,8 @@ pub fn _mm_mask_fmadd_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] -pub fn _mm_maskz_fmadd_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmadd_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { let mut fmadd: f32 = 0.; if (k & 0b00000001) != 0 { @@ -37491,7 +39350,8 @@ pub fn _mm_maskz_fmadd_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] -pub fn _mm_mask3_fmadd_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmadd_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { let mut fmadd: f32 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37510,7 +39370,8 @@ pub fn _mm_mask3_fmadd_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] -pub fn _mm_mask_fmadd_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmadd_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fmadd: f64 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37529,7 +39390,8 @@ pub fn _mm_mask_fmadd_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] -pub fn _mm_maskz_fmadd_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmadd_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fmadd: f64 = 0.; if (k & 0b00000001) != 0 { @@ -37549,7 +39411,8 @@ pub fn _mm_maskz_fmadd_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmadd))] -pub fn _mm_mask3_fmadd_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmadd_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { let mut fmadd: f64 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37568,7 +39431,8 @@ pub fn _mm_mask3_fmadd_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] -pub fn _mm_mask_fmsub_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsub_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { let mut fmsub: f32 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37588,7 +39452,8 @@ pub fn _mm_mask_fmsub_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] -pub fn _mm_maskz_fmsub_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsub_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { let mut fmsub: f32 = 0.; if (k & 0b00000001) != 0 { @@ -37609,7 +39474,8 @@ pub fn _mm_maskz_fmsub_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] -pub fn _mm_mask3_fmsub_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsub_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { let mut fmsub: f32 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37629,7 +39495,8 @@ pub fn _mm_mask3_fmsub_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] -pub fn _mm_mask_fmsub_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsub_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fmsub: f64 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37649,7 +39516,8 @@ pub fn _mm_mask_fmsub_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] -pub fn _mm_maskz_fmsub_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsub_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fmsub: f64 = 0.; if (k & 0b00000001) != 0 { @@ -37670,7 +39538,8 @@ pub fn _mm_maskz_fmsub_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfmsub))] -pub fn _mm_mask3_fmsub_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsub_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { let mut fmsub: f64 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37690,7 +39559,8 @@ pub fn _mm_mask3_fmsub_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] -pub fn _mm_mask_fnmadd_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmadd_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { let mut fnmadd: f32 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37710,7 +39580,8 @@ pub fn _mm_mask_fnmadd_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] -pub fn _mm_maskz_fnmadd_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmadd_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { let mut fnmadd: f32 = 0.; if (k & 0b00000001) != 0 { @@ -37731,7 +39602,8 @@ pub fn _mm_maskz_fnmadd_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] -pub fn _mm_mask3_fnmadd_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmadd_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { let mut fnmadd: f32 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37751,7 +39623,8 @@ pub fn _mm_mask3_fnmadd_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] -pub fn _mm_mask_fnmadd_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmadd_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fnmadd: f64 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37771,7 +39644,8 @@ pub fn _mm_mask_fnmadd_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] -pub fn _mm_maskz_fnmadd_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmadd_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fnmadd: f64 = 0.; if (k & 0b00000001) != 0 { @@ -37792,7 +39666,8 @@ pub fn _mm_maskz_fnmadd_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmadd))] -pub fn _mm_mask3_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { let mut fnmadd: f64 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37812,7 +39687,8 @@ pub fn _mm_mask3_fnmadd_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] -pub fn _mm_mask_fnmsub_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmsub_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m128 { unsafe { let mut fnmsub: f32 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37833,7 +39709,8 @@ pub fn _mm_mask_fnmsub_ss(a: __m128, k: __mmask8, b: __m128, c: __m128) -> __m12 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] -pub fn _mm_maskz_fnmsub_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmsub_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m128 { unsafe { let mut fnmsub: f32 = 0.; if (k & 0b00000001) != 0 { @@ -37855,7 +39732,8 @@ pub fn _mm_maskz_fnmsub_ss(k: __mmask8, a: __m128, b: __m128, c: __m128) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] -pub fn _mm_mask3_fnmsub_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmsub_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m128 { unsafe { let mut fnmsub: f32 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -37876,7 +39754,8 @@ pub fn _mm_mask3_fnmsub_ss(a: __m128, b: __m128, c: __m128, k: __mmask8) -> __m1 #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] -pub fn _mm_mask_fnmsub_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmsub_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fnmsub: f64 = simd_extract!(a, 0); if (k & 0b00000001) != 0 { @@ -37897,7 +39776,8 @@ pub fn _mm_mask_fnmsub_sd(a: __m128d, k: __mmask8, b: __m128d, c: __m128d) -> __ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] -pub fn _mm_maskz_fnmsub_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmsub_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> __m128d { unsafe { let mut fnmsub: f64 = 0.; if (k & 0b00000001) != 0 { @@ -37919,7 +39799,8 @@ pub fn _mm_maskz_fnmsub_sd(k: __mmask8, a: __m128d, b: __m128d, c: __m128d) -> _ #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vfnmsub))] -pub fn _mm_mask3_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmsub_sd(a: __m128d, b: __m128d, c: __m128d, k: __mmask8) -> __m128d { unsafe { let mut fnmsub: f64 = simd_extract!(c, 0); if (k & 0b00000001) != 0 { @@ -41499,7 +43380,8 @@ pub fn _mm_cvt_roundu32_ss(a: __m128, b: u32) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtsi2ss))] -pub fn _mm_cvti32_ss(a: __m128, b: i32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvti32_ss(a: __m128, b: i32) -> __m128 { unsafe { let b = b as f32; simd_insert!(a, 0, b) @@ -41513,7 +43395,8 @@ pub fn _mm_cvti32_ss(a: __m128, b: i32) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtsi2sd))] -pub fn _mm_cvti32_sd(a: __m128d, b: i32) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvti32_sd(a: __m128d, b: i32) -> __m128d { unsafe { let b = b as f64; simd_insert!(a, 0, b) @@ -41673,7 +43556,8 @@ pub fn _mm_cvttsd_u32(a: __m128d) -> u32 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtusi2ss))] -pub fn _mm_cvtu32_ss(a: __m128, b: u32) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtu32_ss(a: __m128, b: u32) -> __m128 { unsafe { let b = b as f32; simd_insert!(a, 0, b) @@ -41687,7 +43571,8 @@ pub fn _mm_cvtu32_ss(a: __m128, b: u32) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtusi2sd))] -pub fn _mm_cvtu32_sd(a: __m128d, b: u32) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtu32_sd(a: __m128d, b: u32) -> __m128d { unsafe { let b = b as f64; simd_insert!(a, 0, b) @@ -43139,6 +45024,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; @@ -43147,7 +45033,7 @@ mod tests { use crate::mem::{self}; #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_abs_epi32() { + const unsafe fn test_mm512_abs_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43167,7 +45053,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_abs_epi32() { + const unsafe fn test_mm512_mask_abs_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43189,7 +45075,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_abs_epi32() { + const unsafe fn test_mm512_maskz_abs_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43211,7 +45097,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_abs_epi32() { + const unsafe fn test_mm256_mask_abs_epi32() { #[rustfmt::skip] let a = _mm256_setr_epi32( 0, 1, -1, i32::MAX, @@ -43229,7 +45115,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_abs_epi32() { + const unsafe fn test_mm256_maskz_abs_epi32() { #[rustfmt::skip] let a = _mm256_setr_epi32( 0, 1, -1, i32::MAX, @@ -43247,7 +45133,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_abs_epi32() { + const unsafe fn test_mm_mask_abs_epi32() { let a = _mm_setr_epi32(i32::MIN, 100, -100, -32); let r = _mm_mask_abs_epi32(a, 0, a); assert_eq_m128i(r, a); @@ -43257,7 +45143,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_abs_epi32() { + const unsafe fn test_mm_maskz_abs_epi32() { let a = _mm_setr_epi32(i32::MIN, 100, -100, -32); let r = _mm_maskz_abs_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -43267,7 +45153,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_abs_ps() { + const unsafe fn test_mm512_abs_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43287,7 +45173,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_abs_ps() { + const unsafe fn test_mm512_mask_abs_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43309,7 +45195,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mov_epi32() { + const unsafe fn test_mm512_mask_mov_epi32() { let src = _mm512_set1_epi32(1); let a = _mm512_set1_epi32(2); let r = _mm512_mask_mov_epi32(src, 0, a); @@ -43319,7 +45205,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mov_epi32() { + const unsafe fn test_mm512_maskz_mov_epi32() { let a = _mm512_set1_epi32(2); let r = _mm512_maskz_mov_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -43328,7 +45214,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mov_epi32() { + const unsafe fn test_mm256_mask_mov_epi32() { let src = _mm256_set1_epi32(1); let a = _mm256_set1_epi32(2); let r = _mm256_mask_mov_epi32(src, 0, a); @@ -43338,7 +45224,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mov_epi32() { + const unsafe fn test_mm256_maskz_mov_epi32() { let a = _mm256_set1_epi32(2); let r = _mm256_maskz_mov_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -43347,7 +45233,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mov_epi32() { + const unsafe fn test_mm_mask_mov_epi32() { let src = _mm_set1_epi32(1); let a = _mm_set1_epi32(2); let r = _mm_mask_mov_epi32(src, 0, a); @@ -43357,7 +45243,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mov_epi32() { + const unsafe fn test_mm_maskz_mov_epi32() { let a = _mm_set1_epi32(2); let r = _mm_maskz_mov_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -43366,7 +45252,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mov_ps() { + const unsafe fn test_mm512_mask_mov_ps() { let src = _mm512_set1_ps(1.); let a = _mm512_set1_ps(2.); let r = _mm512_mask_mov_ps(src, 0, a); @@ -43376,7 +45262,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mov_ps() { + const unsafe fn test_mm512_maskz_mov_ps() { let a = _mm512_set1_ps(2.); let r = _mm512_maskz_mov_ps(0, a); assert_eq_m512(r, _mm512_setzero_ps()); @@ -43385,7 +45271,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mov_ps() { + const unsafe fn test_mm256_mask_mov_ps() { let src = _mm256_set1_ps(1.); let a = _mm256_set1_ps(2.); let r = _mm256_mask_mov_ps(src, 0, a); @@ -43395,7 +45281,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mov_ps() { + const unsafe fn test_mm256_maskz_mov_ps() { let a = _mm256_set1_ps(2.); let r = _mm256_maskz_mov_ps(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -43404,7 +45290,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mov_ps() { + const unsafe fn test_mm_mask_mov_ps() { let src = _mm_set1_ps(1.); let a = _mm_set1_ps(2.); let r = _mm_mask_mov_ps(src, 0, a); @@ -43414,7 +45300,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mov_ps() { + const unsafe fn test_mm_maskz_mov_ps() { let a = _mm_set1_ps(2.); let r = _mm_maskz_mov_ps(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -43423,7 +45309,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_add_epi32() { + const unsafe fn test_mm512_add_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43444,7 +45330,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_add_epi32() { + const unsafe fn test_mm512_mask_add_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43467,7 +45353,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_add_epi32() { + const unsafe fn test_mm512_maskz_add_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43490,7 +45376,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_add_epi32() { + const unsafe fn test_mm256_mask_add_epi32() { let a = _mm256_set_epi32(0, 1, -1, i32::MAX, i32::MIN, 100, -100, -32); let b = _mm256_set1_epi32(1); let r = _mm256_mask_add_epi32(a, 0, a, b); @@ -43501,7 +45387,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_add_epi32() { + const unsafe fn test_mm256_maskz_add_epi32() { let a = _mm256_setr_epi32(0, 1, -1, i32::MAX, i32::MIN, 100, -100, -32); let b = _mm256_set1_epi32(1); let r = _mm256_maskz_add_epi32(0, a, b); @@ -43512,7 +45398,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_add_epi32() { + const unsafe fn test_mm_mask_add_epi32() { let a = _mm_set_epi32(1, -1, i32::MAX, i32::MIN); let b = _mm_set1_epi32(1); let r = _mm_mask_add_epi32(a, 0, a, b); @@ -43523,7 +45409,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_add_epi32() { + const unsafe fn test_mm_maskz_add_epi32() { let a = _mm_setr_epi32(1, -1, i32::MAX, i32::MIN); let b = _mm_set1_epi32(1); let r = _mm_maskz_add_epi32(0, a, b); @@ -43534,7 +45420,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_add_ps() { + const unsafe fn test_mm512_add_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43555,7 +45441,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_add_ps() { + const unsafe fn test_mm512_mask_add_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43578,7 +45464,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_add_ps() { + const unsafe fn test_mm512_maskz_add_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43601,7 +45487,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_add_ps() { + const unsafe fn test_mm256_mask_add_ps() { let a = _mm256_set_ps(0., 1., -1., f32::MAX, f32::MIN, 100., -100., -32.); let b = _mm256_set1_ps(1.); let r = _mm256_mask_add_ps(a, 0, a, b); @@ -43612,7 +45498,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_add_ps() { + const unsafe fn test_mm256_maskz_add_ps() { let a = _mm256_set_ps(0., 1., -1., f32::MAX, f32::MIN, 100., -100., -32.); let b = _mm256_set1_ps(1.); let r = _mm256_maskz_add_ps(0, a, b); @@ -43623,7 +45509,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_add_ps() { + const unsafe fn test_mm_mask_add_ps() { let a = _mm_set_ps(1., -1., f32::MAX, f32::MIN); let b = _mm_set1_ps(1.); let r = _mm_mask_add_ps(a, 0, a, b); @@ -43634,7 +45520,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_add_ps() { + const unsafe fn test_mm_maskz_add_ps() { let a = _mm_set_ps(1., -1., f32::MAX, f32::MIN); let b = _mm_set1_ps(1.); let r = _mm_maskz_add_ps(0, a, b); @@ -43645,7 +45531,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_sub_epi32() { + const unsafe fn test_mm512_sub_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43666,7 +45552,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_sub_epi32() { + const unsafe fn test_mm512_mask_sub_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43689,7 +45575,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_sub_epi32() { + const unsafe fn test_mm512_maskz_sub_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43712,7 +45598,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_sub_epi32() { + const unsafe fn test_mm256_mask_sub_epi32() { let a = _mm256_set_epi32(0, 1, -1, i32::MAX, i32::MIN, 100, -100, -32); let b = _mm256_set1_epi32(1); let r = _mm256_mask_sub_epi32(a, 0, a, b); @@ -43723,7 +45609,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_sub_epi32() { + const unsafe fn test_mm256_maskz_sub_epi32() { let a = _mm256_set_epi32(0, 1, -1, i32::MAX, i32::MIN, 100, -100, -32); let b = _mm256_set1_epi32(1); let r = _mm256_maskz_sub_epi32(0, a, b); @@ -43734,7 +45620,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_sub_epi32() { + const unsafe fn test_mm_mask_sub_epi32() { let a = _mm_set_epi32(1, -1, i32::MAX, i32::MIN); let b = _mm_set1_epi32(1); let r = _mm_mask_sub_epi32(a, 0, a, b); @@ -43745,7 +45631,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_sub_epi32() { + const unsafe fn test_mm_maskz_sub_epi32() { let a = _mm_set_epi32(1, -1, i32::MAX, i32::MIN); let b = _mm_set1_epi32(1); let r = _mm_maskz_sub_epi32(0, a, b); @@ -43756,7 +45642,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_sub_ps() { + const unsafe fn test_mm512_sub_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43777,7 +45663,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_sub_ps() { + const unsafe fn test_mm512_mask_sub_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43800,7 +45686,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_sub_ps() { + const unsafe fn test_mm512_maskz_sub_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43823,7 +45709,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_sub_ps() { + const unsafe fn test_mm256_mask_sub_ps() { let a = _mm256_set_ps(0., 1., -1., f32::MAX, f32::MIN, 100., -100., -32.); let b = _mm256_set1_ps(1.); let r = _mm256_mask_sub_ps(a, 0, a, b); @@ -43834,7 +45720,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_sub_ps() { + const unsafe fn test_mm256_maskz_sub_ps() { let a = _mm256_set_ps(0., 1., -1., f32::MAX, f32::MIN, 100., -100., -32.); let b = _mm256_set1_ps(1.); let r = _mm256_maskz_sub_ps(0, a, b); @@ -43845,7 +45731,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_sub_ps() { + const unsafe fn test_mm_mask_sub_ps() { let a = _mm_set_ps(1., -1., f32::MAX, f32::MIN); let b = _mm_set1_ps(1.); let r = _mm_mask_sub_ps(a, 0, a, b); @@ -43856,7 +45742,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_sub_ps() { + const unsafe fn test_mm_maskz_sub_ps() { let a = _mm_set_ps(1., -1., f32::MAX, f32::MIN); let b = _mm_set1_ps(1.); let r = _mm_maskz_sub_ps(0, a, b); @@ -43867,7 +45753,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mullo_epi32() { + const unsafe fn test_mm512_mullo_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43884,7 +45770,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mullo_epi32() { + const unsafe fn test_mm512_mask_mullo_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43907,7 +45793,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mullo_epi32() { + const unsafe fn test_mm512_maskz_mullo_epi32() { #[rustfmt::skip] let a = _mm512_setr_epi32( 0, 1, -1, i32::MAX, @@ -43924,7 +45810,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mullo_epi32() { + const unsafe fn test_mm256_mask_mullo_epi32() { let a = _mm256_set_epi32(0, 1, -1, i32::MAX, i32::MIN, 100, -100, -32); let b = _mm256_set1_epi32(2); let r = _mm256_mask_mullo_epi32(a, 0, a, b); @@ -43935,7 +45821,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mullo_epi32() { + const unsafe fn test_mm256_maskz_mullo_epi32() { let a = _mm256_set_epi32(0, 1, -1, i32::MAX, i32::MIN, 100, -100, -32); let b = _mm256_set1_epi32(2); let r = _mm256_maskz_mullo_epi32(0, a, b); @@ -43946,7 +45832,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mullo_epi32() { + const unsafe fn test_mm_mask_mullo_epi32() { let a = _mm_set_epi32(1, -1, i32::MAX, i32::MIN); let b = _mm_set1_epi32(2); let r = _mm_mask_mullo_epi32(a, 0, a, b); @@ -43957,7 +45843,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mullo_epi32() { + const unsafe fn test_mm_maskz_mullo_epi32() { let a = _mm_set_epi32(1, -1, i32::MAX, i32::MIN); let b = _mm_set1_epi32(2); let r = _mm_maskz_mullo_epi32(0, a, b); @@ -43968,7 +45854,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mul_ps() { + const unsafe fn test_mm512_mul_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -43990,7 +45876,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mul_ps() { + const unsafe fn test_mm512_mask_mul_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -44013,7 +45899,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mul_ps() { + const unsafe fn test_mm512_maskz_mul_ps() { #[rustfmt::skip] let a = _mm512_setr_ps( 0., 1., -1., f32::MAX, @@ -44036,7 +45922,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mul_ps() { + const unsafe fn test_mm256_mask_mul_ps() { let a = _mm256_set_ps(0., 1., -1., f32::MAX, f32::MIN, 100., -100., -32.); let b = _mm256_set1_ps(2.); let r = _mm256_mask_mul_ps(a, 0, a, b); @@ -44051,7 +45937,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mul_ps() { + const unsafe fn test_mm256_maskz_mul_ps() { let a = _mm256_set_ps(0., 1., -1., f32::MAX, f32::MIN, 100., -100., -32.); let b = _mm256_set1_ps(2.); let r = _mm256_maskz_mul_ps(0, a, b); @@ -44066,7 +45952,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mul_ps() { + const unsafe fn test_mm_mask_mul_ps() { let a = _mm_set_ps(1., -1., f32::MAX, f32::MIN); let b = _mm_set1_ps(2.); let r = _mm_mask_mul_ps(a, 0, a, b); @@ -44077,7 +45963,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mul_ps() { + const unsafe fn test_mm_maskz_mul_ps() { let a = _mm_set_ps(1., -1., f32::MAX, f32::MIN); let b = _mm_set1_ps(2.); let r = _mm_maskz_mul_ps(0, a, b); @@ -44088,7 +45974,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_div_ps() { + const unsafe fn test_mm512_div_ps() { let a = _mm512_setr_ps( 0., 1., -1., -2., 100., 100., -100., -32., 0., 1., -1., 1000., -131., 100., -100., -32., ); @@ -44107,7 +45993,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_div_ps() { + const unsafe fn test_mm512_mask_div_ps() { let a = _mm512_setr_ps( 0., 1., -1., -2., 100., 100., -100., -32., 0., 1., -1., 1000., -131., 100., -100., -32., ); @@ -44128,7 +46014,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_div_ps() { + const unsafe fn test_mm512_maskz_div_ps() { let a = _mm512_setr_ps( 0., 1., -1., -2., 100., 100., -100., -32., 0., 1., -1., 1000., -131., 100., -100., -32., ); @@ -44149,7 +46035,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_div_ps() { + const unsafe fn test_mm256_mask_div_ps() { let a = _mm256_set_ps(0., 1., -1., -2., 100., 100., -100., -32.); let b = _mm256_set_ps(2., 2., 2., 2., 2., 0., 2., 2.); let r = _mm256_mask_div_ps(a, 0, a, b); @@ -44160,7 +46046,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_div_ps() { + const unsafe fn test_mm256_maskz_div_ps() { let a = _mm256_set_ps(0., 1., -1., -2., 100., 100., -100., -32.); let b = _mm256_set_ps(2., 2., 2., 2., 2., 0., 2., 2.); let r = _mm256_maskz_div_ps(0, a, b); @@ -44171,7 +46057,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_div_ps() { + const unsafe fn test_mm_mask_div_ps() { let a = _mm_set_ps(100., 100., -100., -32.); let b = _mm_set_ps(2., 0., 2., 2.); let r = _mm_mask_div_ps(a, 0, a, b); @@ -44182,7 +46068,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_div_ps() { + const unsafe fn test_mm_maskz_div_ps() { let a = _mm_set_ps(100., 100., -100., -32.); let b = _mm_set_ps(2., 0., 2., 2.); let r = _mm_maskz_div_ps(0, a, b); @@ -44193,7 +46079,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_max_epi32() { + const unsafe fn test_mm512_max_epi32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_max_epi32(a, b); @@ -44202,7 +46088,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_max_epi32() { + const unsafe fn test_mm512_mask_max_epi32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_max_epi32(a, 0, a, b); @@ -44213,7 +46099,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_max_epi32() { + const unsafe fn test_mm512_maskz_max_epi32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_max_epi32(0, a, b); @@ -44224,7 +46110,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_max_epi32() { + const unsafe fn test_mm256_mask_max_epi32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_max_epi32(a, 0, a, b); @@ -44235,7 +46121,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_max_epi32() { + const unsafe fn test_mm256_maskz_max_epi32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_max_epi32(0, a, b); @@ -44246,7 +46132,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_max_epi32() { + const unsafe fn test_mm_mask_max_epi32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_mask_max_epi32(a, 0, a, b); @@ -44257,7 +46143,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_max_epi32() { + const unsafe fn test_mm_maskz_max_epi32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_maskz_max_epi32(0, a, b); @@ -44361,7 +46247,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_max_epu32() { + const unsafe fn test_mm512_max_epu32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_max_epu32(a, b); @@ -44370,7 +46256,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_max_epu32() { + const unsafe fn test_mm512_mask_max_epu32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_max_epu32(a, 0, a, b); @@ -44381,7 +46267,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_max_epu32() { + const unsafe fn test_mm512_maskz_max_epu32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_max_epu32(0, a, b); @@ -44392,7 +46278,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_max_epu32() { + const unsafe fn test_mm256_mask_max_epu32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_max_epu32(a, 0, a, b); @@ -44403,7 +46289,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_max_epu32() { + const unsafe fn test_mm256_maskz_max_epu32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_max_epu32(0, a, b); @@ -44414,7 +46300,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_max_epu32() { + const unsafe fn test_mm_mask_max_epu32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_mask_max_epu32(a, 0, a, b); @@ -44425,7 +46311,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_max_epu32() { + const unsafe fn test_mm_maskz_max_epu32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_maskz_max_epu32(0, a, b); @@ -44436,7 +46322,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_min_epi32() { + const unsafe fn test_mm512_min_epi32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_min_epi32(a, b); @@ -44445,7 +46331,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_min_epi32() { + const unsafe fn test_mm512_mask_min_epi32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_min_epi32(a, 0, a, b); @@ -44456,7 +46342,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_min_epi32() { + const unsafe fn test_mm512_maskz_min_epi32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_min_epi32(0, a, b); @@ -44467,7 +46353,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_min_epi32() { + const unsafe fn test_mm256_mask_min_epi32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_min_epi32(a, 0, a, b); @@ -44478,7 +46364,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_min_epi32() { + const unsafe fn test_mm256_maskz_min_epi32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_min_epi32(0, a, b); @@ -44489,7 +46375,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_min_epi32() { + const unsafe fn test_mm_mask_min_epi32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_mask_min_epi32(a, 0, a, b); @@ -44500,7 +46386,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_min_epi32() { + const unsafe fn test_mm_maskz_min_epi32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_maskz_min_epi32(0, a, b); @@ -44604,7 +46490,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_min_epu32() { + const unsafe fn test_mm512_min_epu32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_min_epu32(a, b); @@ -44613,7 +46499,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_min_epu32() { + const unsafe fn test_mm512_mask_min_epu32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_min_epu32(a, 0, a, b); @@ -44624,7 +46510,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_min_epu32() { + const unsafe fn test_mm512_maskz_min_epu32() { let a = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm512_setr_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_min_epu32(0, a, b); @@ -44635,7 +46521,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_min_epu32() { + const unsafe fn test_mm256_mask_min_epu32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_min_epu32(a, 0, a, b); @@ -44646,7 +46532,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_min_epu32() { + const unsafe fn test_mm256_maskz_min_epu32() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_min_epu32(0, a, b); @@ -44657,7 +46543,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_min_epu32() { + const unsafe fn test_mm_mask_min_epu32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_mask_min_epu32(a, 0, a, b); @@ -44668,7 +46554,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_min_epu32() { + const unsafe fn test_mm_maskz_min_epu32() { let a = _mm_set_epi32(0, 1, 2, 3); let b = _mm_set_epi32(3, 2, 1, 0); let r = _mm_maskz_min_epu32(0, a, b); @@ -44759,7 +46645,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmadd_ps() { + const unsafe fn test_mm512_fmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44773,7 +46659,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmadd_ps() { + const unsafe fn test_mm512_mask_fmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44789,7 +46675,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmadd_ps() { + const unsafe fn test_mm512_maskz_fmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44805,7 +46691,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmadd_ps() { + const unsafe fn test_mm512_mask3_fmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44821,7 +46707,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmadd_ps() { + const unsafe fn test_mm256_mask_fmadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -44833,7 +46719,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmadd_ps() { + const unsafe fn test_mm256_maskz_fmadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -44845,7 +46731,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmadd_ps() { + const unsafe fn test_mm256_mask3_fmadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -44857,7 +46743,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmadd_ps() { + const unsafe fn test_mm_mask_fmadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -44869,7 +46755,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmadd_ps() { + const unsafe fn test_mm_maskz_fmadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -44881,7 +46767,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmadd_ps() { + const unsafe fn test_mm_mask3_fmadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -44893,7 +46779,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmsub_ps() { + const unsafe fn test_mm512_fmsub_ps() { let a = _mm512_setr_ps( 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., ); @@ -44911,7 +46797,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmsub_ps() { + const unsafe fn test_mm512_mask_fmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44927,7 +46813,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmsub_ps() { + const unsafe fn test_mm512_maskz_fmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44943,7 +46829,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmsub_ps() { + const unsafe fn test_mm512_mask3_fmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -44961,7 +46847,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmsub_ps() { + const unsafe fn test_mm256_mask_fmsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -44973,7 +46859,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmsub_ps() { + const unsafe fn test_mm256_maskz_fmsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -44985,7 +46871,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmsub_ps() { + const unsafe fn test_mm256_mask3_fmsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -44997,7 +46883,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmsub_ps() { + const unsafe fn test_mm_mask_fmsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45009,7 +46895,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmsub_ps() { + const unsafe fn test_mm_maskz_fmsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45021,7 +46907,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmsub_ps() { + const unsafe fn test_mm_mask3_fmsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45033,7 +46919,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmaddsub_ps() { + const unsafe fn test_mm512_fmaddsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45047,7 +46933,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmaddsub_ps() { + const unsafe fn test_mm512_mask_fmaddsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45063,7 +46949,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmaddsub_ps() { + const unsafe fn test_mm512_maskz_fmaddsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45079,7 +46965,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmaddsub_ps() { + const unsafe fn test_mm512_mask3_fmaddsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45097,7 +46983,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmaddsub_ps() { + const unsafe fn test_mm256_mask_fmaddsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45109,7 +46995,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmaddsub_ps() { + const unsafe fn test_mm256_maskz_fmaddsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45121,7 +47007,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmaddsub_ps() { + const unsafe fn test_mm256_mask3_fmaddsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45133,7 +47019,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmaddsub_ps() { + const unsafe fn test_mm_mask_fmaddsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45145,7 +47031,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmaddsub_ps() { + const unsafe fn test_mm_maskz_fmaddsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45157,7 +47043,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmaddsub_ps() { + const unsafe fn test_mm_mask3_fmaddsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45169,7 +47055,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmsubadd_ps() { + const unsafe fn test_mm512_fmsubadd_ps() { let a = _mm512_setr_ps( 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., ); @@ -45187,7 +47073,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmsubadd_ps() { + const unsafe fn test_mm512_mask_fmsubadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45203,7 +47089,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmsubadd_ps() { + const unsafe fn test_mm512_maskz_fmsubadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45219,7 +47105,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmsubadd_ps() { + const unsafe fn test_mm512_mask3_fmsubadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45237,7 +47123,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmsubadd_ps() { + const unsafe fn test_mm256_mask_fmsubadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45249,7 +47135,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmsubadd_ps() { + const unsafe fn test_mm256_maskz_fmsubadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45261,7 +47147,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmsubadd_ps() { + const unsafe fn test_mm256_mask3_fmsubadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45273,7 +47159,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmsubadd_ps() { + const unsafe fn test_mm_mask_fmsubadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45285,7 +47171,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmsubadd_ps() { + const unsafe fn test_mm_maskz_fmsubadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45297,7 +47183,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmsubadd_ps() { + const unsafe fn test_mm_mask3_fmsubadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45309,7 +47195,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fnmadd_ps() { + const unsafe fn test_mm512_fnmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45323,7 +47209,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fnmadd_ps() { + const unsafe fn test_mm512_mask_fnmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45339,7 +47225,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fnmadd_ps() { + const unsafe fn test_mm512_maskz_fnmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45355,7 +47241,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fnmadd_ps() { + const unsafe fn test_mm512_mask3_fnmadd_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45373,7 +47259,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fnmadd_ps() { + const unsafe fn test_mm256_mask_fnmadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45385,7 +47271,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fnmadd_ps() { + const unsafe fn test_mm256_maskz_fnmadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45397,7 +47283,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fnmadd_ps() { + const unsafe fn test_mm256_mask3_fnmadd_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45409,7 +47295,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fnmadd_ps() { + const unsafe fn test_mm_mask_fnmadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45421,7 +47307,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fnmadd_ps() { + const unsafe fn test_mm_maskz_fnmadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45433,7 +47319,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fnmadd_ps() { + const unsafe fn test_mm_mask3_fnmadd_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45445,7 +47331,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fnmsub_ps() { + const unsafe fn test_mm512_fnmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45459,7 +47345,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fnmsub_ps() { + const unsafe fn test_mm512_mask_fnmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45475,7 +47361,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fnmsub_ps() { + const unsafe fn test_mm512_maskz_fnmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45491,7 +47377,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fnmsub_ps() { + const unsafe fn test_mm512_mask3_fnmsub_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., @@ -45509,7 +47395,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fnmsub_ps() { + const unsafe fn test_mm256_mask_fnmsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45521,7 +47407,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fnmsub_ps() { + const unsafe fn test_mm256_maskz_fnmsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45533,7 +47419,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fnmsub_ps() { + const unsafe fn test_mm256_mask3_fnmsub_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm256_set1_ps(1.); @@ -45545,7 +47431,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fnmsub_ps() { + const unsafe fn test_mm_mask_fnmsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45557,7 +47443,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fnmsub_ps() { + const unsafe fn test_mm_maskz_fnmsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -45569,7 +47455,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fnmsub_ps() { + const unsafe fn test_mm_mask3_fnmsub_ps() { let a = _mm_set1_ps(1.); let b = _mm_set_ps(0., 1., 2., 3.); let c = _mm_set1_ps(1.); @@ -47731,7 +49617,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi8_epi32() { + const unsafe fn test_mm512_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi8_epi32(a); let e = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -47739,7 +49625,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi8_epi32() { + const unsafe fn test_mm512_mask_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi32(-1); let r = _mm512_mask_cvtepi8_epi32(src, 0, a); @@ -47750,7 +49636,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi8_epi32() { + const unsafe fn test_mm512_maskz_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi8_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -47760,7 +49646,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi8_epi32() { + const unsafe fn test_mm256_mask_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi32(-1); let r = _mm256_mask_cvtepi8_epi32(src, 0, a); @@ -47771,7 +49657,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi8_epi32() { + const unsafe fn test_mm256_maskz_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepi8_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -47781,7 +49667,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi8_epi32() { + const unsafe fn test_mm_mask_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi32(-1); let r = _mm_mask_cvtepi8_epi32(src, 0, a); @@ -47792,7 +49678,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi8_epi32() { + const unsafe fn test_mm_maskz_cvtepi8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepi8_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -47802,7 +49688,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu8_epi32() { + const unsafe fn test_mm512_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu8_epi32(a); let e = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -47810,7 +49696,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu8_epi32() { + const unsafe fn test_mm512_mask_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi32(-1); let r = _mm512_mask_cvtepu8_epi32(src, 0, a); @@ -47821,7 +49707,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu8_epi32() { + const unsafe fn test_mm512_maskz_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu8_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -47831,7 +49717,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepu8_epi32() { + const unsafe fn test_mm256_mask_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi32(-1); let r = _mm256_mask_cvtepu8_epi32(src, 0, a); @@ -47842,7 +49728,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu8_epi32() { + const unsafe fn test_mm256_maskz_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepu8_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -47852,7 +49738,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepu8_epi32() { + const unsafe fn test_mm_mask_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi32(-1); let r = _mm_mask_cvtepu8_epi32(src, 0, a); @@ -47863,7 +49749,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepu8_epi32() { + const unsafe fn test_mm_maskz_cvtepu8_epi32() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepu8_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -47873,7 +49759,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi16_epi32() { + const unsafe fn test_mm512_cvtepi16_epi32() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi16_epi32(a); let e = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -47881,7 +49767,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi16_epi32() { + const unsafe fn test_mm512_mask_cvtepi16_epi32() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi32(-1); let r = _mm512_mask_cvtepi16_epi32(src, 0, a); @@ -47892,7 +49778,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi16_epi32() { + const unsafe fn test_mm512_maskz_cvtepi16_epi32() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi16_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -47902,7 +49788,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi16_epi32() { + const unsafe fn test_mm256_mask_cvtepi16_epi32() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let src = _mm256_set1_epi32(-1); let r = _mm256_mask_cvtepi16_epi32(src, 0, a); @@ -47913,7 +49799,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi16_epi32() { + const unsafe fn test_mm256_maskz_cvtepi16_epi32() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm256_maskz_cvtepi16_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -47923,7 +49809,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi16_epi32() { + const unsafe fn test_mm_mask_cvtepi16_epi32() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let src = _mm_set1_epi32(-1); let r = _mm_mask_cvtepi16_epi32(src, 0, a); @@ -47934,7 +49820,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi16_epi32() { + const unsafe fn test_mm_maskz_cvtepi16_epi32() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm_maskz_cvtepi16_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -47944,7 +49830,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu16_epi32() { + const unsafe fn test_mm512_cvtepu16_epi32() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu16_epi32(a); let e = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -47952,7 +49838,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu16_epi32() { + const unsafe fn test_mm512_mask_cvtepu16_epi32() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi32(-1); let r = _mm512_mask_cvtepu16_epi32(src, 0, a); @@ -47963,7 +49849,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu16_epi32() { + const unsafe fn test_mm512_maskz_cvtepu16_epi32() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu16_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -47973,7 +49859,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepu16_epi32() { + const unsafe fn test_mm256_mask_cvtepu16_epi32() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi32(-1); let r = _mm256_mask_cvtepu16_epi32(src, 0, a); @@ -47984,7 +49870,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu16_epi32() { + const unsafe fn test_mm256_maskz_cvtepu16_epi32() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepu16_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -47994,7 +49880,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepu16_epi32() { + const unsafe fn test_mm_mask_cvtepu16_epi32() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi32(-1); let r = _mm_mask_cvtepu16_epi32(src, 0, a); @@ -48005,7 +49891,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepu16_epi32() { + const unsafe fn test_mm_maskz_cvtepu16_epi32() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepu16_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -48015,7 +49901,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi32_ps() { + const unsafe fn test_mm512_cvtepi32_ps() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi32_ps(a); let e = _mm512_set_ps( @@ -48025,7 +49911,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi32_ps() { + const unsafe fn test_mm512_mask_cvtepi32_ps() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_ps(-1.); let r = _mm512_mask_cvtepi32_ps(src, 0, a); @@ -48038,7 +49924,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi32_ps() { + const unsafe fn test_mm512_maskz_cvtepi32_ps() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi32_ps(0, a); assert_eq_m512(r, _mm512_setzero_ps()); @@ -48050,7 +49936,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi32_ps() { + const unsafe fn test_mm256_mask_cvtepi32_ps() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let src = _mm256_set1_ps(-1.); let r = _mm256_mask_cvtepi32_ps(src, 0, a); @@ -48061,7 +49947,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi32_ps() { + const unsafe fn test_mm256_maskz_cvtepi32_ps() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_maskz_cvtepi32_ps(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -48071,7 +49957,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi32_ps() { + const unsafe fn test_mm_mask_cvtepi32_ps() { let a = _mm_set_epi32(1, 2, 3, 4); let src = _mm_set1_ps(-1.); let r = _mm_mask_cvtepi32_ps(src, 0, a); @@ -48082,7 +49968,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi32_ps() { + const unsafe fn test_mm_maskz_cvtepi32_ps() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm_maskz_cvtepi32_ps(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -48092,7 +49978,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu32_ps() { + const unsafe fn test_mm512_cvtepu32_ps() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu32_ps(a); let e = _mm512_set_ps( @@ -48102,7 +49988,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu32_ps() { + const unsafe fn test_mm512_mask_cvtepu32_ps() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_ps(-1.); let r = _mm512_mask_cvtepu32_ps(src, 0, a); @@ -48115,7 +50001,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu32_ps() { + const unsafe fn test_mm512_maskz_cvtepu32_ps() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu32_ps(0, a); assert_eq_m512(r, _mm512_setzero_ps()); @@ -48127,7 +50013,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi32_epi16() { + const unsafe fn test_mm512_cvtepi32_epi16() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi32_epi16(a); let e = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -48135,7 +50021,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi32_epi16() { + const unsafe fn test_mm512_mask_cvtepi32_epi16() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi16(-1); let r = _mm512_mask_cvtepi32_epi16(src, 0, a); @@ -48146,7 +50032,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi32_epi16() { + const unsafe fn test_mm512_maskz_cvtepi32_epi16() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi32_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -48156,7 +50042,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cvtepi32_epi16() { + const unsafe fn test_mm256_cvtepi32_epi16() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm256_cvtepi32_epi16(a); let e = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); @@ -48164,7 +50050,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi32_epi16() { + const unsafe fn test_mm256_mask_cvtepi32_epi16() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let src = _mm_set1_epi16(-1); let r = _mm256_mask_cvtepi32_epi16(src, 0, a); @@ -48175,7 +50061,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi32_epi16() { + const unsafe fn test_mm256_maskz_cvtepi32_epi16() { let a = _mm256_set_epi32(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm256_maskz_cvtepi32_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -48214,7 +50100,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi32_epi8() { + const unsafe fn test_mm512_cvtepi32_epi8() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi32_epi8(a); let e = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -48222,7 +50108,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi32_epi8() { + const unsafe fn test_mm512_mask_cvtepi32_epi8() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi8(-1); let r = _mm512_mask_cvtepi32_epi8(src, 0, a); @@ -48233,7 +50119,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi32_epi8() { + const unsafe fn test_mm512_maskz_cvtepi32_epi8() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi32_epi8(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -49982,7 +51868,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmplt_epu32_mask() { + const unsafe fn test_mm512_cmplt_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -49992,7 +51878,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmplt_epu32_mask() { + const unsafe fn test_mm512_mask_cmplt_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50003,7 +51889,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmplt_epu32_mask() { + const unsafe fn test_mm256_cmplt_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 101, 100, 99); let b = _mm256_set1_epi32(1); let r = _mm256_cmplt_epu32_mask(a, b); @@ -50011,7 +51897,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epu32_mask() { + const unsafe fn test_mm256_mask_cmplt_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 101, 100, 99); let b = _mm256_set1_epi32(1); let mask = 0b11111111; @@ -50020,7 +51906,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmplt_epu32_mask() { + const unsafe fn test_mm_cmplt_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let r = _mm_cmplt_epu32_mask(a, b); @@ -50028,7 +51914,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmplt_epu32_mask() { + const unsafe fn test_mm_mask_cmplt_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let mask = 0b11111111; @@ -50037,7 +51923,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpgt_epu32_mask() { + const unsafe fn test_mm512_cmpgt_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50047,7 +51933,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpgt_epu32_mask() { + const unsafe fn test_mm512_mask_cmpgt_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50058,7 +51944,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpgt_epu32_mask() { + const unsafe fn test_mm256_cmpgt_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 99, 100, 101); let b = _mm256_set1_epi32(1); let r = _mm256_cmpgt_epu32_mask(a, b); @@ -50066,7 +51952,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epu32_mask() { + const unsafe fn test_mm256_mask_cmpgt_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 99, 100, 101); let b = _mm256_set1_epi32(1); let mask = 0b11111111; @@ -50075,7 +51961,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpgt_epu32_mask() { + const unsafe fn test_mm_cmpgt_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let r = _mm_cmpgt_epu32_mask(a, b); @@ -50083,7 +51969,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epu32_mask() { + const unsafe fn test_mm_mask_cmpgt_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let mask = 0b11111111; @@ -50092,7 +51978,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmple_epu32_mask() { + const unsafe fn test_mm512_cmple_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50104,7 +51990,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmple_epu32_mask() { + const unsafe fn test_mm512_mask_cmple_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50117,7 +52003,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmple_epu32_mask() { + const unsafe fn test_mm256_cmple_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 200, 100, 101); let b = _mm256_set1_epi32(1); let r = _mm256_cmple_epu32_mask(a, b); @@ -50125,7 +52011,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmple_epu32_mask() { + const unsafe fn test_mm256_mask_cmple_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 200, 100, 101); let b = _mm256_set1_epi32(1); let mask = 0b11111111; @@ -50134,7 +52020,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmple_epu32_mask() { + const unsafe fn test_mm_cmple_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let r = _mm_cmple_epu32_mask(a, b); @@ -50142,7 +52028,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmple_epu32_mask() { + const unsafe fn test_mm_mask_cmple_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let mask = 0b11111111; @@ -50151,7 +52037,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpge_epu32_mask() { + const unsafe fn test_mm512_cmpge_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50163,7 +52049,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpge_epu32_mask() { + const unsafe fn test_mm512_mask_cmpge_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50173,7 +52059,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpge_epu32_mask() { + const unsafe fn test_mm256_cmpge_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 300, 100, 200); let b = _mm256_set1_epi32(1); let r = _mm256_cmpge_epu32_mask(a, b); @@ -50181,7 +52067,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epu32_mask() { + const unsafe fn test_mm256_mask_cmpge_epu32_mask() { let a = _mm256_set_epi32(0, 1, 2, u32::MAX as i32, i32::MAX, 300, 100, 200); let b = _mm256_set1_epi32(1); let mask = 0b11111111; @@ -50190,7 +52076,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpge_epu32_mask() { + const unsafe fn test_mm_cmpge_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let r = _mm_cmpge_epu32_mask(a, b); @@ -50198,7 +52084,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpge_epu32_mask() { + const unsafe fn test_mm_mask_cmpge_epu32_mask() { let a = _mm_set_epi32(0, 1, 2, u32::MAX as i32); let b = _mm_set1_epi32(1); let mask = 0b11111111; @@ -50207,7 +52093,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpeq_epu32_mask() { + const unsafe fn test_mm512_cmpeq_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50219,7 +52105,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpeq_epu32_mask() { + const unsafe fn test_mm512_mask_cmpeq_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50232,7 +52118,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpeq_epu32_mask() { + const unsafe fn test_mm256_cmpeq_epu32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, 100, -100); let m = _mm256_cmpeq_epu32_mask(b, a); @@ -50240,7 +52126,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epu32_mask() { + const unsafe fn test_mm256_mask_cmpeq_epu32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, 100, -100); let mask = 0b01111010; @@ -50249,7 +52135,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpeq_epu32_mask() { + const unsafe fn test_mm_cmpeq_epu32_mask() { let a = _mm_set_epi32(0, 1, -1, u32::MAX as i32); let b = _mm_set_epi32(0, 1, 13, 42); let m = _mm_cmpeq_epu32_mask(b, a); @@ -50257,7 +52143,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epu32_mask() { + const unsafe fn test_mm_mask_cmpeq_epu32_mask() { let a = _mm_set_epi32(0, 1, -1, u32::MAX as i32); let b = _mm_set_epi32(0, 1, 13, 42); let mask = 0b11111111; @@ -50266,7 +52152,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpneq_epu32_mask() { + const unsafe fn test_mm512_cmpneq_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50278,7 +52164,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpneq_epu32_mask() { + const unsafe fn test_mm512_mask_cmpneq_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, -100, 100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, -100, 100); @@ -50291,7 +52177,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpneq_epu32_mask() { + const unsafe fn test_mm256_cmpneq_epu32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, -100, 100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, -100, 100); let r = _mm256_cmpneq_epu32_mask(b, a); @@ -50299,7 +52185,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epu32_mask() { + const unsafe fn test_mm256_mask_cmpneq_epu32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, -100, 100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, -100, 100); let mask = 0b11111111; @@ -50308,7 +52194,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpneq_epu32_mask() { + const unsafe fn test_mm_cmpneq_epu32_mask() { let a = _mm_set_epi32(0, 1, -1, u32::MAX as i32); let b = _mm_set_epi32(0, 1, 13, 42); let r = _mm_cmpneq_epu32_mask(b, a); @@ -50316,7 +52202,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epu32_mask() { + const unsafe fn test_mm_mask_cmpneq_epu32_mask() { let a = _mm_set_epi32(0, 1, -1, u32::MAX as i32); let b = _mm_set_epi32(0, 1, 13, 42); let mask = 0b11111111; @@ -50325,7 +52211,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmp_epu32_mask() { + const unsafe fn test_mm512_cmp_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50335,7 +52221,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmp_epu32_mask() { + const unsafe fn test_mm512_mask_cmp_epu32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50346,7 +52232,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmp_epu32_mask() { + const unsafe fn test_mm256_cmp_epu32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let m = _mm256_cmp_epu32_mask::<_MM_CMPINT_LT>(a, b); @@ -50354,7 +52240,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmp_epu32_mask() { + const unsafe fn test_mm256_mask_cmp_epu32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let mask = 0b11111111; @@ -50363,7 +52249,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmp_epu32_mask() { + const unsafe fn test_mm_cmp_epu32_mask() { let a = _mm_set_epi32(0, 1, -1, i32::MAX); let b = _mm_set1_epi32(1); let m = _mm_cmp_epu32_mask::<_MM_CMPINT_LT>(a, b); @@ -50371,7 +52257,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmp_epu32_mask() { + const unsafe fn test_mm_mask_cmp_epu32_mask() { let a = _mm_set_epi32(0, 1, -1, i32::MAX); let b = _mm_set1_epi32(1); let mask = 0b11111111; @@ -50380,7 +52266,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmplt_epi32_mask() { + const unsafe fn test_mm512_cmplt_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50390,7 +52276,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmplt_epi32_mask() { + const unsafe fn test_mm512_mask_cmplt_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50401,7 +52287,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmplt_epi32_mask() { + const unsafe fn test_mm256_cmplt_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 101, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let r = _mm256_cmplt_epi32_mask(a, b); @@ -50409,7 +52295,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epi32_mask() { + const unsafe fn test_mm256_mask_cmplt_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 101, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let mask = 0b11111111; @@ -50418,7 +52304,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmplt_epi32_mask() { + const unsafe fn test_mm_cmplt_epi32_mask() { let a = _mm_set_epi32(i32::MAX, i32::MIN, 100, -100); let b = _mm_set1_epi32(-1); let r = _mm_cmplt_epi32_mask(a, b); @@ -50426,7 +52312,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmplt_epi32_mask() { + const unsafe fn test_mm_mask_cmplt_epi32_mask() { let a = _mm_set_epi32(i32::MAX, i32::MIN, 100, -100); let b = _mm_set1_epi32(-1); let mask = 0b11111111; @@ -50435,7 +52321,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpgt_epi32_mask() { + const unsafe fn test_mm512_cmpgt_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50445,7 +52331,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpgt_epi32_mask() { + const unsafe fn test_mm512_mask_cmpgt_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50456,7 +52342,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpgt_epi32_mask() { + const unsafe fn test_mm256_cmpgt_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let r = _mm256_cmpgt_epi32_mask(a, b); @@ -50464,7 +52350,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epi32_mask() { + const unsafe fn test_mm256_mask_cmpgt_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let mask = 0b11111111; @@ -50473,7 +52359,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpgt_epi32_mask() { + const unsafe fn test_mm_cmpgt_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set1_epi32(-1); let r = _mm_cmpgt_epi32_mask(a, b); @@ -50481,7 +52367,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epi32_mask() { + const unsafe fn test_mm_mask_cmpgt_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set1_epi32(-1); let mask = 0b11111111; @@ -50490,7 +52376,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmple_epi32_mask() { + const unsafe fn test_mm512_cmple_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50502,7 +52388,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmple_epi32_mask() { + const unsafe fn test_mm512_mask_cmple_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50512,7 +52398,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmple_epi32_mask() { + const unsafe fn test_mm256_cmple_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 200, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let r = _mm256_cmple_epi32_mask(a, b); @@ -50520,7 +52406,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmple_epi32_mask() { + const unsafe fn test_mm256_mask_cmple_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 200, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let mask = 0b11111111; @@ -50529,7 +52415,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmple_epi32_mask() { + const unsafe fn test_mm_cmple_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 200); let b = _mm_set1_epi32(-1); let r = _mm_cmple_epi32_mask(a, b); @@ -50537,7 +52423,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmple_epi32_mask() { + const unsafe fn test_mm_mask_cmple_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 200); let b = _mm_set1_epi32(-1); let mask = 0b11111111; @@ -50546,7 +52432,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpge_epi32_mask() { + const unsafe fn test_mm512_cmpge_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50558,7 +52444,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpge_epi32_mask() { + const unsafe fn test_mm512_mask_cmpge_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); @@ -50571,7 +52457,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpge_epi32_mask() { + const unsafe fn test_mm256_cmpge_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let r = _mm256_cmpge_epi32_mask(a, b); @@ -50579,7 +52465,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epi32_mask() { + const unsafe fn test_mm256_mask_cmpge_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, u32::MAX as i32, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let mask = 0b11111111; @@ -50588,7 +52474,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpge_epi32_mask() { + const unsafe fn test_mm_cmpge_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, u32::MAX as i32); let b = _mm_set1_epi32(-1); let r = _mm_cmpge_epi32_mask(a, b); @@ -50596,7 +52482,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpge_epi32_mask() { + const unsafe fn test_mm_mask_cmpge_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, u32::MAX as i32); let b = _mm_set1_epi32(-1); let mask = 0b11111111; @@ -50605,7 +52491,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpeq_epi32_mask() { + const unsafe fn test_mm512_cmpeq_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50617,7 +52503,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpeq_epi32_mask() { + const unsafe fn test_mm512_mask_cmpeq_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50630,7 +52516,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpeq_epi32_mask() { + const unsafe fn test_mm256_cmpeq_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, 100, -100); let m = _mm256_cmpeq_epi32_mask(b, a); @@ -50638,7 +52524,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epi32_mask() { + const unsafe fn test_mm256_mask_cmpeq_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, 100, -100); let mask = 0b01111010; @@ -50647,7 +52533,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpeq_epi32_mask() { + const unsafe fn test_mm_cmpeq_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set_epi32(0, 1, 13, 42); let m = _mm_cmpeq_epi32_mask(b, a); @@ -50655,7 +52541,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epi32_mask() { + const unsafe fn test_mm_mask_cmpeq_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set_epi32(0, 1, 13, 42); let mask = 0b11111111; @@ -50664,7 +52550,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpneq_epi32_mask() { + const unsafe fn test_mm512_cmpneq_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50676,7 +52562,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpneq_epi32_mask() { + const unsafe fn test_mm512_mask_cmpneq_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, -100, 100, 0, 1, -1, 13, i32::MAX, i32::MIN, -100, 100); @@ -50689,7 +52575,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpneq_epi32_mask() { + const unsafe fn test_mm256_cmpneq_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, 100, -100); let m = _mm256_cmpneq_epi32_mask(b, a); @@ -50697,7 +52583,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epi32_mask() { + const unsafe fn test_mm256_mask_cmpneq_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, -100, 100); let b = _mm256_set_epi32(0, 1, 13, 42, i32::MAX, i32::MIN, 100, -100); let mask = 0b11111111; @@ -50706,7 +52592,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpneq_epi32_mask() { + const unsafe fn test_mm_cmpneq_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set_epi32(0, 1, 13, 42); let r = _mm_cmpneq_epi32_mask(b, a); @@ -50714,7 +52600,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epi32_mask() { + const unsafe fn test_mm_mask_cmpneq_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set_epi32(0, 1, 13, 42); let mask = 0b11111111; @@ -50723,7 +52609,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmp_epi32_mask() { + const unsafe fn test_mm512_cmp_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50733,7 +52619,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmp_epi32_mask() { + const unsafe fn test_mm512_mask_cmp_epi32_mask() { #[rustfmt::skip] let a = _mm512_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100, 0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); @@ -50744,7 +52630,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmp_epi32_mask() { + const unsafe fn test_mm256_cmp_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let m = _mm256_cmp_epi32_mask::<_MM_CMPINT_LT>(a, b); @@ -50752,7 +52638,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmp_epi32_mask() { + const unsafe fn test_mm256_mask_cmp_epi32_mask() { let a = _mm256_set_epi32(0, 1, -1, 13, i32::MAX, i32::MIN, 100, -100); let b = _mm256_set1_epi32(-1); let mask = 0b01100110; @@ -50761,7 +52647,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmp_epi32_mask() { + const unsafe fn test_mm_cmp_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set1_epi32(1); let m = _mm_cmp_epi32_mask::<_MM_CMPINT_LT>(a, b); @@ -50769,7 +52655,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmp_epi32_mask() { + const unsafe fn test_mm_mask_cmp_epi32_mask() { let a = _mm_set_epi32(0, 1, -1, 13); let b = _mm_set1_epi32(1); let mask = 0b11111111; @@ -50778,7 +52664,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set_epi8() { + const unsafe fn test_mm512_set_epi8() { let r = _mm512_set1_epi8(2); assert_eq_m512i( r, @@ -50791,7 +52677,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set_epi16() { + const unsafe fn test_mm512_set_epi16() { let r = _mm512_set1_epi16(2); assert_eq_m512i( r, @@ -50803,7 +52689,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set_epi32() { + const unsafe fn test_mm512_set_epi32() { let r = _mm512_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); assert_eq_m512i( r, @@ -50812,7 +52698,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr_epi32() { + const unsafe fn test_mm512_setr_epi32() { let r = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); assert_eq_m512i( r, @@ -50821,7 +52707,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set1_epi8() { + const unsafe fn test_mm512_set1_epi8() { let r = _mm512_set_epi8( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -50831,7 +52717,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set1_epi16() { + const unsafe fn test_mm512_set1_epi16() { let r = _mm512_set_epi16( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -50840,23 +52726,23 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set1_epi32() { + const unsafe fn test_mm512_set1_epi32() { let r = _mm512_set_epi32(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); assert_eq_m512i(r, _mm512_set1_epi32(2)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setzero_si512() { + const unsafe fn test_mm512_setzero_si512() { assert_eq_m512i(_mm512_set1_epi32(0), _mm512_setzero_si512()); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setzero_epi32() { + const unsafe fn test_mm512_setzero_epi32() { assert_eq_m512i(_mm512_set1_epi32(0), _mm512_setzero_epi32()); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set_ps() { + const unsafe fn test_mm512_set_ps() { let r = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., ); @@ -50869,7 +52755,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr_ps() { + const unsafe fn test_mm512_setr_ps() { let r = _mm512_set_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., ); @@ -50882,7 +52768,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set1_ps() { + const unsafe fn test_mm512_set1_ps() { #[rustfmt::skip] let expected = _mm512_set_ps(2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.); @@ -50890,13 +52776,13 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set4_epi32() { + const unsafe fn test_mm512_set4_epi32() { let r = _mm512_set_epi32(4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1); assert_eq_m512i(r, _mm512_set4_epi32(4, 3, 2, 1)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set4_ps() { + const unsafe fn test_mm512_set4_ps() { let r = _mm512_set_ps( 4., 3., 2., 1., 4., 3., 2., 1., 4., 3., 2., 1., 4., 3., 2., 1., ); @@ -50904,13 +52790,13 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr4_epi32() { + const unsafe fn test_mm512_setr4_epi32() { let r = _mm512_set_epi32(4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1); assert_eq_m512i(r, _mm512_setr4_epi32(1, 2, 3, 4)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr4_ps() { + const unsafe fn test_mm512_setr4_ps() { let r = _mm512_set_ps( 4., 3., 2., 1., 4., 3., 2., 1., 4., 3., 2., 1., 4., 3., 2., 1., ); @@ -50918,17 +52804,17 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setzero_ps() { + const unsafe fn test_mm512_setzero_ps() { assert_eq_m512(_mm512_setzero_ps(), _mm512_set1_ps(0.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setzero() { + const unsafe fn test_mm512_setzero() { assert_eq_m512(_mm512_setzero(), _mm512_set1_ps(0.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_loadu_pd() { + const unsafe fn test_mm512_loadu_pd() { let a = &[4., 3., 2., 5., 8., 9., 64., 50.]; let p = a.as_ptr(); let r = _mm512_loadu_pd(black_box(p)); @@ -50937,7 +52823,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_storeu_pd() { + const unsafe fn test_mm512_storeu_pd() { let a = _mm512_set1_pd(9.); let mut r = _mm512_undefined_pd(); _mm512_storeu_pd(&mut r as *mut _ as *mut f64, a); @@ -50945,7 +52831,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_loadu_ps() { + const unsafe fn test_mm512_loadu_ps() { let a = &[ 4., 3., 2., 5., 8., 9., 64., 50., -4., -3., -2., -5., -8., -9., -64., -50., ]; @@ -50958,7 +52844,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_storeu_ps() { + const unsafe fn test_mm512_storeu_ps() { let a = _mm512_set1_ps(9.); let mut r = _mm512_undefined_ps(); _mm512_storeu_ps(&mut r as *mut _ as *mut f32, a); @@ -50966,7 +52852,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_loadu_epi32() { + const unsafe fn test_mm512_mask_loadu_epi32() { let src = _mm512_set1_epi32(42); let a = &[1_i32, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); @@ -50977,7 +52863,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_loadu_epi32() { + const unsafe fn test_mm512_maskz_loadu_epi32() { let a = &[1_i32, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); let m = 0b11101000_11001010; @@ -50987,7 +52873,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_load_epi32() { + const unsafe fn test_mm512_mask_load_epi32() { #[repr(align(64))] struct Align { data: [i32; 16], // 64 bytes @@ -51004,7 +52890,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_load_epi32() { + const unsafe fn test_mm512_maskz_load_epi32() { #[repr(align(64))] struct Align { data: [i32; 16], // 64 bytes @@ -51020,7 +52906,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_storeu_epi32() { + const unsafe fn test_mm512_mask_storeu_epi32() { let mut r = [42_i32; 16]; let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let m = 0b11101000_11001010; @@ -51030,7 +52916,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_store_epi32() { + const unsafe fn test_mm512_mask_store_epi32() { #[repr(align(64))] struct Align { data: [i32; 16], @@ -51044,7 +52930,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_loadu_epi64() { + const unsafe fn test_mm512_mask_loadu_epi64() { let src = _mm512_set1_epi64(42); let a = &[1_i64, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); @@ -51055,7 +52941,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_loadu_epi64() { + const unsafe fn test_mm512_maskz_loadu_epi64() { let a = &[1_i64, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); let m = 0b11001010; @@ -51065,7 +52951,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_load_epi64() { + const unsafe fn test_mm512_mask_load_epi64() { #[repr(align(64))] struct Align { data: [i64; 8], // 64 bytes @@ -51082,7 +52968,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_load_epi64() { + const unsafe fn test_mm512_maskz_load_epi64() { #[repr(align(64))] struct Align { data: [i64; 8], // 64 bytes @@ -51098,7 +52984,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_storeu_epi64() { + const unsafe fn test_mm512_mask_storeu_epi64() { let mut r = [42_i64; 8]; let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let m = 0b11001010; @@ -51108,7 +52994,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_store_epi64() { + const unsafe fn test_mm512_mask_store_epi64() { #[repr(align(64))] struct Align { data: [i64; 8], @@ -51123,7 +53009,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_loadu_ps() { + const unsafe fn test_mm512_mask_loadu_ps() { let src = _mm512_set1_ps(42.0); let a = &[ 1.0_f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, @@ -51140,7 +53026,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_loadu_ps() { + const unsafe fn test_mm512_maskz_loadu_ps() { let a = &[ 1.0_f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -51155,7 +53041,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_load_ps() { + const unsafe fn test_mm512_mask_load_ps() { #[repr(align(64))] struct Align { data: [f32; 16], // 64 bytes @@ -51178,7 +53064,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_load_ps() { + const unsafe fn test_mm512_maskz_load_ps() { #[repr(align(64))] struct Align { data: [f32; 16], // 64 bytes @@ -51199,7 +53085,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_storeu_ps() { + const unsafe fn test_mm512_mask_storeu_ps() { let mut r = [42_f32; 16]; let a = _mm512_setr_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -51214,7 +53100,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_store_ps() { + const unsafe fn test_mm512_mask_store_ps() { #[repr(align(64))] struct Align { data: [f32; 16], @@ -51233,7 +53119,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_loadu_pd() { + const unsafe fn test_mm512_mask_loadu_pd() { let src = _mm512_set1_pd(42.0); let a = &[1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let p = a.as_ptr(); @@ -51244,7 +53130,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_loadu_pd() { + const unsafe fn test_mm512_maskz_loadu_pd() { let a = &[1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let p = a.as_ptr(); let m = 0b11001010; @@ -51254,7 +53140,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_load_pd() { + const unsafe fn test_mm512_mask_load_pd() { #[repr(align(64))] struct Align { data: [f64; 8], // 64 bytes @@ -51271,7 +53157,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_load_pd() { + const unsafe fn test_mm512_maskz_load_pd() { #[repr(align(64))] struct Align { data: [f64; 8], // 64 bytes @@ -51287,7 +53173,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_storeu_pd() { + const unsafe fn test_mm512_mask_storeu_pd() { let mut r = [42_f64; 8]; let a = _mm512_setr_pd(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let m = 0b11001010; @@ -51297,7 +53183,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_store_pd() { + const unsafe fn test_mm512_mask_store_pd() { #[repr(align(64))] struct Align { data: [f64; 8], @@ -51311,7 +53197,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_loadu_epi32() { + const unsafe fn test_mm256_mask_loadu_epi32() { let src = _mm256_set1_epi32(42); let a = &[1_i32, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); @@ -51322,7 +53208,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_loadu_epi32() { + const unsafe fn test_mm256_maskz_loadu_epi32() { let a = &[1_i32, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); let m = 0b11001010; @@ -51332,7 +53218,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_load_epi32() { + const unsafe fn test_mm256_mask_load_epi32() { #[repr(align(32))] struct Align { data: [i32; 8], // 32 bytes @@ -51349,7 +53235,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_load_epi32() { + const unsafe fn test_mm256_maskz_load_epi32() { #[repr(align(32))] struct Align { data: [i32; 8], // 32 bytes @@ -51365,7 +53251,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_storeu_epi32() { + const unsafe fn test_mm256_mask_storeu_epi32() { let mut r = [42_i32; 8]; let a = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); let m = 0b11001010; @@ -51375,7 +53261,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_store_epi32() { + const unsafe fn test_mm256_mask_store_epi32() { #[repr(align(64))] struct Align { data: [i32; 8], @@ -51389,7 +53275,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_loadu_epi64() { + const unsafe fn test_mm256_mask_loadu_epi64() { let src = _mm256_set1_epi64x(42); let a = &[1_i64, 2, 3, 4]; let p = a.as_ptr(); @@ -51400,7 +53286,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_loadu_epi64() { + const unsafe fn test_mm256_maskz_loadu_epi64() { let a = &[1_i64, 2, 3, 4]; let p = a.as_ptr(); let m = 0b1010; @@ -51410,7 +53296,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_load_epi64() { + const unsafe fn test_mm256_mask_load_epi64() { #[repr(align(32))] struct Align { data: [i64; 4], // 32 bytes @@ -51427,7 +53313,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_load_epi64() { + const unsafe fn test_mm256_maskz_load_epi64() { #[repr(align(32))] struct Align { data: [i64; 4], // 32 bytes @@ -51443,7 +53329,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_storeu_epi64() { + const unsafe fn test_mm256_mask_storeu_epi64() { let mut r = [42_i64; 4]; let a = _mm256_setr_epi64x(1, 2, 3, 4); let m = 0b1010; @@ -51453,7 +53339,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_store_epi64() { + const unsafe fn test_mm256_mask_store_epi64() { #[repr(align(32))] struct Align { data: [i64; 4], @@ -51467,7 +53353,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_loadu_ps() { + const unsafe fn test_mm256_mask_loadu_ps() { let src = _mm256_set1_ps(42.0); let a = &[1.0_f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let p = a.as_ptr(); @@ -51478,7 +53364,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_loadu_ps() { + const unsafe fn test_mm256_maskz_loadu_ps() { let a = &[1.0_f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let p = a.as_ptr(); let m = 0b11001010; @@ -51488,7 +53374,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_load_ps() { + const unsafe fn test_mm256_mask_load_ps() { #[repr(align(32))] struct Align { data: [f32; 8], // 32 bytes @@ -51505,7 +53391,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_load_ps() { + const unsafe fn test_mm256_maskz_load_ps() { #[repr(align(32))] struct Align { data: [f32; 8], // 32 bytes @@ -51521,7 +53407,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_storeu_ps() { + const unsafe fn test_mm256_mask_storeu_ps() { let mut r = [42_f32; 8]; let a = _mm256_setr_ps(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let m = 0b11001010; @@ -51531,7 +53417,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_store_ps() { + const unsafe fn test_mm256_mask_store_ps() { #[repr(align(32))] struct Align { data: [f32; 8], @@ -51545,7 +53431,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_loadu_pd() { + const unsafe fn test_mm256_mask_loadu_pd() { let src = _mm256_set1_pd(42.0); let a = &[1.0_f64, 2.0, 3.0, 4.0]; let p = a.as_ptr(); @@ -51556,7 +53442,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_loadu_pd() { + const unsafe fn test_mm256_maskz_loadu_pd() { let a = &[1.0_f64, 2.0, 3.0, 4.0]; let p = a.as_ptr(); let m = 0b1010; @@ -51566,7 +53452,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_load_pd() { + const unsafe fn test_mm256_mask_load_pd() { #[repr(align(32))] struct Align { data: [f64; 4], // 32 bytes @@ -51583,7 +53469,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_load_pd() { + const unsafe fn test_mm256_maskz_load_pd() { #[repr(align(32))] struct Align { data: [f64; 4], // 32 bytes @@ -51599,7 +53485,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_storeu_pd() { + const unsafe fn test_mm256_mask_storeu_pd() { let mut r = [42_f64; 4]; let a = _mm256_setr_pd(1.0, 2.0, 3.0, 4.0); let m = 0b1010; @@ -51609,7 +53495,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_store_pd() { + const unsafe fn test_mm256_mask_store_pd() { #[repr(align(32))] struct Align { data: [f64; 4], @@ -51623,7 +53509,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_loadu_epi32() { + const unsafe fn test_mm_mask_loadu_epi32() { let src = _mm_set1_epi32(42); let a = &[1_i32, 2, 3, 4]; let p = a.as_ptr(); @@ -51634,7 +53520,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_loadu_epi32() { + const unsafe fn test_mm_maskz_loadu_epi32() { let a = &[1_i32, 2, 3, 4]; let p = a.as_ptr(); let m = 0b1010; @@ -51644,7 +53530,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_load_epi32() { + const unsafe fn test_mm_mask_load_epi32() { #[repr(align(16))] struct Align { data: [i32; 4], // 32 bytes @@ -51661,7 +53547,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_load_epi32() { + const unsafe fn test_mm_maskz_load_epi32() { #[repr(align(16))] struct Align { data: [i32; 4], // 16 bytes @@ -51677,7 +53563,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_storeu_epi32() { + const unsafe fn test_mm_mask_storeu_epi32() { let mut r = [42_i32; 4]; let a = _mm_setr_epi32(1, 2, 3, 4); let m = 0b1010; @@ -51687,7 +53573,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_store_epi32() { + const unsafe fn test_mm_mask_store_epi32() { #[repr(align(16))] struct Align { data: [i32; 4], // 16 bytes @@ -51701,7 +53587,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_loadu_epi64() { + const unsafe fn test_mm_mask_loadu_epi64() { let src = _mm_set1_epi64x(42); let a = &[1_i64, 2]; let p = a.as_ptr(); @@ -51712,7 +53598,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_loadu_epi64() { + const unsafe fn test_mm_maskz_loadu_epi64() { let a = &[1_i64, 2]; let p = a.as_ptr(); let m = 0b10; @@ -51722,7 +53608,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_load_epi64() { + const unsafe fn test_mm_mask_load_epi64() { #[repr(align(16))] struct Align { data: [i64; 2], // 16 bytes @@ -51737,7 +53623,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_load_epi64() { + const unsafe fn test_mm_maskz_load_epi64() { #[repr(align(16))] struct Align { data: [i64; 2], // 16 bytes @@ -51751,7 +53637,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_storeu_epi64() { + const unsafe fn test_mm_mask_storeu_epi64() { let mut r = [42_i64; 2]; let a = _mm_setr_epi64x(1, 2); let m = 0b10; @@ -51761,7 +53647,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_store_epi64() { + const unsafe fn test_mm_mask_store_epi64() { #[repr(align(16))] struct Align { data: [i64; 2], // 16 bytes @@ -51775,7 +53661,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_loadu_ps() { + const unsafe fn test_mm_mask_loadu_ps() { let src = _mm_set1_ps(42.0); let a = &[1.0_f32, 2.0, 3.0, 4.0]; let p = a.as_ptr(); @@ -51786,7 +53672,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_loadu_ps() { + const unsafe fn test_mm_maskz_loadu_ps() { let a = &[1.0_f32, 2.0, 3.0, 4.0]; let p = a.as_ptr(); let m = 0b1010; @@ -51796,7 +53682,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_load_ps() { + const unsafe fn test_mm_mask_load_ps() { #[repr(align(16))] struct Align { data: [f32; 4], // 16 bytes @@ -51813,7 +53699,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_load_ps() { + const unsafe fn test_mm_maskz_load_ps() { #[repr(align(16))] struct Align { data: [f32; 4], // 16 bytes @@ -51829,7 +53715,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_storeu_ps() { + const unsafe fn test_mm_mask_storeu_ps() { let mut r = [42_f32; 4]; let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0); let m = 0b1010; @@ -51839,7 +53725,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_store_ps() { + const unsafe fn test_mm_mask_store_ps() { #[repr(align(16))] struct Align { data: [f32; 4], // 16 bytes @@ -51853,7 +53739,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_loadu_pd() { + const unsafe fn test_mm_mask_loadu_pd() { let src = _mm_set1_pd(42.0); let a = &[1.0_f64, 2.0]; let p = a.as_ptr(); @@ -51864,7 +53750,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_loadu_pd() { + const unsafe fn test_mm_maskz_loadu_pd() { let a = &[1.0_f64, 2.0]; let p = a.as_ptr(); let m = 0b10; @@ -51874,7 +53760,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_load_pd() { + const unsafe fn test_mm_mask_load_pd() { #[repr(align(16))] struct Align { data: [f64; 2], // 16 bytes @@ -51891,7 +53777,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_load_pd() { + const unsafe fn test_mm_maskz_load_pd() { #[repr(align(16))] struct Align { data: [f64; 2], // 16 bytes @@ -51961,7 +53847,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_storeu_pd() { + const unsafe fn test_mm_mask_storeu_pd() { let mut r = [42_f64; 2]; let a = _mm_setr_pd(1.0, 2.0); let m = 0b10; @@ -51971,7 +53857,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_store_pd() { + const unsafe fn test_mm_mask_store_pd() { #[repr(align(16))] struct Align { data: [f64; 2], // 16 bytes @@ -52013,19 +53899,19 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr_pd() { + const unsafe fn test_mm512_setr_pd() { let r = _mm512_set_pd(0., 1., 2., 3., 4., 5., 6., 7.); assert_eq_m512d(r, _mm512_setr_pd(7., 6., 5., 4., 3., 2., 1., 0.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set_pd() { + const unsafe fn test_mm512_set_pd() { let r = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); assert_eq_m512d(r, _mm512_set_pd(7., 6., 5., 4., 3., 2., 1., 0.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_rol_epi32() { + const unsafe fn test_mm512_rol_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let r = _mm512_rol_epi32::<1>(a); let e = _mm512_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); @@ -52033,7 +53919,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_rol_epi32() { + const unsafe fn test_mm512_mask_rol_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let r = _mm512_mask_rol_epi32::<1>(a, 0, a); assert_eq_m512i(r, a); @@ -52043,7 +53929,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_rol_epi32() { + const unsafe fn test_mm512_maskz_rol_epi32() { let a = _mm512_set_epi32(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 << 31); let r = _mm512_maskz_rol_epi32::<1>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -52053,7 +53939,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_rol_epi32() { + const unsafe fn test_mm256_rol_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let r = _mm256_rol_epi32::<1>(a); let e = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); @@ -52061,7 +53947,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_rol_epi32() { + const unsafe fn test_mm256_mask_rol_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let r = _mm256_mask_rol_epi32::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -52071,7 +53957,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_rol_epi32() { + const unsafe fn test_mm256_maskz_rol_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let r = _mm256_maskz_rol_epi32::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -52081,7 +53967,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_rol_epi32() { + const unsafe fn test_mm_rol_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let r = _mm_rol_epi32::<1>(a); let e = _mm_set_epi32(1 << 0, 2, 2, 2); @@ -52089,7 +53975,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_rol_epi32() { + const unsafe fn test_mm_mask_rol_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let r = _mm_mask_rol_epi32::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -52099,7 +53985,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_rol_epi32() { + const unsafe fn test_mm_maskz_rol_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let r = _mm_maskz_rol_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -52109,7 +53995,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_ror_epi32() { + const unsafe fn test_mm512_ror_epi32() { let a = _mm512_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let r = _mm512_ror_epi32::<1>(a); let e = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); @@ -52117,7 +54003,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_ror_epi32() { + const unsafe fn test_mm512_mask_ror_epi32() { let a = _mm512_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let r = _mm512_mask_ror_epi32::<1>(a, 0, a); assert_eq_m512i(r, a); @@ -52127,7 +54013,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_ror_epi32() { + const unsafe fn test_mm512_maskz_ror_epi32() { let a = _mm512_set_epi32(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 << 0); let r = _mm512_maskz_ror_epi32::<1>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -52137,7 +54023,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_ror_epi32() { + const unsafe fn test_mm256_ror_epi32() { let a = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); let r = _mm256_ror_epi32::<1>(a); let e = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); @@ -52145,7 +54031,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_ror_epi32() { + const unsafe fn test_mm256_mask_ror_epi32() { let a = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); let r = _mm256_mask_ror_epi32::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -52155,7 +54041,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_ror_epi32() { + const unsafe fn test_mm256_maskz_ror_epi32() { let a = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); let r = _mm256_maskz_ror_epi32::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -52165,7 +54051,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_ror_epi32() { + const unsafe fn test_mm_ror_epi32() { let a = _mm_set_epi32(1 << 0, 2, 2, 2); let r = _mm_ror_epi32::<1>(a); let e = _mm_set_epi32(1 << 31, 1, 1, 1); @@ -52173,7 +54059,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_ror_epi32() { + const unsafe fn test_mm_mask_ror_epi32() { let a = _mm_set_epi32(1 << 0, 2, 2, 2); let r = _mm_mask_ror_epi32::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -52183,7 +54069,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_ror_epi32() { + const unsafe fn test_mm_maskz_ror_epi32() { let a = _mm_set_epi32(1 << 0, 2, 2, 2); let r = _mm_maskz_ror_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -52193,7 +54079,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_slli_epi32() { + const unsafe fn test_mm512_slli_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let r = _mm512_slli_epi32::<1>(a); let e = _mm512_set_epi32(0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); @@ -52201,7 +54087,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_slli_epi32() { + const unsafe fn test_mm512_mask_slli_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let r = _mm512_mask_slli_epi32::<1>(a, 0, a); assert_eq_m512i(r, a); @@ -52211,7 +54097,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_slli_epi32() { + const unsafe fn test_mm512_maskz_slli_epi32() { let a = _mm512_set_epi32(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 << 31); let r = _mm512_maskz_slli_epi32::<1>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -52221,7 +54107,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_slli_epi32() { + const unsafe fn test_mm256_mask_slli_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let r = _mm256_mask_slli_epi32::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -52231,7 +54117,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_slli_epi32() { + const unsafe fn test_mm256_maskz_slli_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let r = _mm256_maskz_slli_epi32::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -52241,7 +54127,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_slli_epi32() { + const unsafe fn test_mm_mask_slli_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let r = _mm_mask_slli_epi32::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -52251,7 +54137,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_slli_epi32() { + const unsafe fn test_mm_maskz_slli_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let r = _mm_maskz_slli_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -52261,7 +54147,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srli_epi32() { + const unsafe fn test_mm512_srli_epi32() { let a = _mm512_set_epi32(0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let r = _mm512_srli_epi32::<1>(a); let e = _mm512_set_epi32(0 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); @@ -52269,7 +54155,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srli_epi32() { + const unsafe fn test_mm512_mask_srli_epi32() { let a = _mm512_set_epi32(0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let r = _mm512_mask_srli_epi32::<1>(a, 0, a); assert_eq_m512i(r, a); @@ -52279,7 +54165,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srli_epi32() { + const unsafe fn test_mm512_maskz_srli_epi32() { let a = _mm512_set_epi32(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0); let r = _mm512_maskz_srli_epi32::<1>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -52289,7 +54175,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srli_epi32() { + const unsafe fn test_mm256_mask_srli_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let r = _mm256_mask_srli_epi32::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -52299,7 +54185,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srli_epi32() { + const unsafe fn test_mm256_maskz_srli_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let r = _mm256_maskz_srli_epi32::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -52309,7 +54195,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srli_epi32() { + const unsafe fn test_mm_mask_srli_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let r = _mm_mask_srli_epi32::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -52319,7 +54205,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srli_epi32() { + const unsafe fn test_mm_maskz_srli_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let r = _mm_maskz_srli_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -52329,7 +54215,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_rolv_epi32() { + const unsafe fn test_mm512_rolv_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let b = _mm512_set1_epi32(1); let r = _mm512_rolv_epi32(a, b); @@ -52338,7 +54224,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_rolv_epi32() { + const unsafe fn test_mm512_mask_rolv_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let b = _mm512_set1_epi32(1); let r = _mm512_mask_rolv_epi32(a, 0, a, b); @@ -52349,7 +54235,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_rolv_epi32() { + const unsafe fn test_mm512_maskz_rolv_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 << 31); let b = _mm512_set1_epi32(1); let r = _mm512_maskz_rolv_epi32(0, a, b); @@ -52360,7 +54246,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_rolv_epi32() { + const unsafe fn test_mm256_rolv_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let b = _mm256_set1_epi32(1); let r = _mm256_rolv_epi32(a, b); @@ -52369,7 +54255,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_rolv_epi32() { + const unsafe fn test_mm256_mask_rolv_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let b = _mm256_set1_epi32(1); let r = _mm256_mask_rolv_epi32(a, 0, a, b); @@ -52380,7 +54266,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_rolv_epi32() { + const unsafe fn test_mm256_maskz_rolv_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let b = _mm256_set1_epi32(1); let r = _mm256_maskz_rolv_epi32(0, a, b); @@ -52391,7 +54277,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_rolv_epi32() { + const unsafe fn test_mm_rolv_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let b = _mm_set1_epi32(1); let r = _mm_rolv_epi32(a, b); @@ -52400,7 +54286,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_rolv_epi32() { + const unsafe fn test_mm_mask_rolv_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let b = _mm_set1_epi32(1); let r = _mm_mask_rolv_epi32(a, 0, a, b); @@ -52411,7 +54297,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_rolv_epi32() { + const unsafe fn test_mm_maskz_rolv_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let b = _mm_set1_epi32(1); let r = _mm_maskz_rolv_epi32(0, a, b); @@ -52422,7 +54308,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_rorv_epi32() { + const unsafe fn test_mm512_rorv_epi32() { let a = _mm512_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let b = _mm512_set1_epi32(1); let r = _mm512_rorv_epi32(a, b); @@ -52431,7 +54317,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_rorv_epi32() { + const unsafe fn test_mm512_mask_rorv_epi32() { let a = _mm512_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let b = _mm512_set1_epi32(1); let r = _mm512_mask_rorv_epi32(a, 0, a, b); @@ -52442,7 +54328,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_rorv_epi32() { + const unsafe fn test_mm512_maskz_rorv_epi32() { let a = _mm512_set_epi32(3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 << 0); let b = _mm512_set1_epi32(1); let r = _mm512_maskz_rorv_epi32(0, a, b); @@ -52453,7 +54339,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_rorv_epi32() { + const unsafe fn test_mm256_rorv_epi32() { let a = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); let b = _mm256_set1_epi32(1); let r = _mm256_rorv_epi32(a, b); @@ -52462,7 +54348,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_rorv_epi32() { + const unsafe fn test_mm256_mask_rorv_epi32() { let a = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); let b = _mm256_set1_epi32(1); let r = _mm256_mask_rorv_epi32(a, 0, a, b); @@ -52473,7 +54359,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_rorv_epi32() { + const unsafe fn test_mm256_maskz_rorv_epi32() { let a = _mm256_set_epi32(1 << 0, 2, 2, 2, 2, 2, 2, 2); let b = _mm256_set1_epi32(1); let r = _mm256_maskz_rorv_epi32(0, a, b); @@ -52484,7 +54370,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_rorv_epi32() { + const unsafe fn test_mm_rorv_epi32() { let a = _mm_set_epi32(1 << 0, 2, 2, 2); let b = _mm_set1_epi32(1); let r = _mm_rorv_epi32(a, b); @@ -52493,7 +54379,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_rorv_epi32() { + const unsafe fn test_mm_mask_rorv_epi32() { let a = _mm_set_epi32(1 << 0, 2, 2, 2); let b = _mm_set1_epi32(1); let r = _mm_mask_rorv_epi32(a, 0, a, b); @@ -52504,7 +54390,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_rorv_epi32() { + const unsafe fn test_mm_maskz_rorv_epi32() { let a = _mm_set_epi32(1 << 0, 2, 2, 2); let b = _mm_set1_epi32(1); let r = _mm_maskz_rorv_epi32(0, a, b); @@ -52515,7 +54401,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_sllv_epi32() { + const unsafe fn test_mm512_sllv_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let count = _mm512_set1_epi32(1); let r = _mm512_sllv_epi32(a, count); @@ -52524,7 +54410,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_sllv_epi32() { + const unsafe fn test_mm512_mask_sllv_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let count = _mm512_set1_epi32(1); let r = _mm512_mask_sllv_epi32(a, 0, a, count); @@ -52535,7 +54421,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_sllv_epi32() { + const unsafe fn test_mm512_maskz_sllv_epi32() { let a = _mm512_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 << 31); let count = _mm512_set_epi32(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let r = _mm512_maskz_sllv_epi32(0, a, count); @@ -52546,7 +54432,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_sllv_epi32() { + const unsafe fn test_mm256_mask_sllv_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let count = _mm256_set1_epi32(1); let r = _mm256_mask_sllv_epi32(a, 0, a, count); @@ -52557,7 +54443,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_sllv_epi32() { + const unsafe fn test_mm256_maskz_sllv_epi32() { let a = _mm256_set_epi32(1 << 31, 1, 1, 1, 1, 1, 1, 1); let count = _mm256_set1_epi32(1); let r = _mm256_maskz_sllv_epi32(0, a, count); @@ -52568,7 +54454,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_sllv_epi32() { + const unsafe fn test_mm_mask_sllv_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let count = _mm_set1_epi32(1); let r = _mm_mask_sllv_epi32(a, 0, a, count); @@ -52579,7 +54465,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_sllv_epi32() { + const unsafe fn test_mm_maskz_sllv_epi32() { let a = _mm_set_epi32(1 << 31, 1, 1, 1); let count = _mm_set1_epi32(1); let r = _mm_maskz_sllv_epi32(0, a, count); @@ -52590,7 +54476,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srlv_epi32() { + const unsafe fn test_mm512_srlv_epi32() { let a = _mm512_set_epi32(0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let count = _mm512_set1_epi32(1); let r = _mm512_srlv_epi32(a, count); @@ -52599,7 +54485,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srlv_epi32() { + const unsafe fn test_mm512_mask_srlv_epi32() { let a = _mm512_set_epi32(0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2); let count = _mm512_set1_epi32(1); let r = _mm512_mask_srlv_epi32(a, 0, a, count); @@ -52610,7 +54496,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srlv_epi32() { + const unsafe fn test_mm512_maskz_srlv_epi32() { let a = _mm512_set_epi32(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0); let count = _mm512_set_epi32(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); let r = _mm512_maskz_srlv_epi32(0, a, count); @@ -52621,7 +54507,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srlv_epi32() { + const unsafe fn test_mm256_mask_srlv_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let count = _mm256_set1_epi32(1); let r = _mm256_mask_srlv_epi32(a, 0, a, count); @@ -52632,7 +54518,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srlv_epi32() { + const unsafe fn test_mm256_maskz_srlv_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let count = _mm256_set1_epi32(1); let r = _mm256_maskz_srlv_epi32(0, a, count); @@ -52643,7 +54529,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srlv_epi32() { + const unsafe fn test_mm_mask_srlv_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let count = _mm_set1_epi32(1); let r = _mm_mask_srlv_epi32(a, 0, a, count); @@ -52654,7 +54540,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srlv_epi32() { + const unsafe fn test_mm_maskz_srlv_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let count = _mm_set1_epi32(1); let r = _mm_maskz_srlv_epi32(0, a, count); @@ -52938,7 +54824,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srav_epi32() { + const unsafe fn test_mm512_srav_epi32() { let a = _mm512_set_epi32(8, -8, 16, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); let count = _mm512_set_epi32(2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); let r = _mm512_srav_epi32(a, count); @@ -52947,7 +54833,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srav_epi32() { + const unsafe fn test_mm512_mask_srav_epi32() { let a = _mm512_set_epi32(8, -8, 16, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16); let count = _mm512_set_epi32(2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); let r = _mm512_mask_srav_epi32(a, 0, a, count); @@ -52958,7 +54844,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srav_epi32() { + const unsafe fn test_mm512_maskz_srav_epi32() { let a = _mm512_set_epi32(8, -8, 16, -15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -15, -14); let count = _mm512_set_epi32(2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2); let r = _mm512_maskz_srav_epi32(0, a, count); @@ -52969,7 +54855,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srav_epi32() { + const unsafe fn test_mm256_mask_srav_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let count = _mm256_set1_epi32(1); let r = _mm256_mask_srav_epi32(a, 0, a, count); @@ -52980,7 +54866,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srav_epi32() { + const unsafe fn test_mm256_maskz_srav_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let count = _mm256_set1_epi32(1); let r = _mm256_maskz_srav_epi32(0, a, count); @@ -52991,7 +54877,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srav_epi32() { + const unsafe fn test_mm_mask_srav_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let count = _mm_set1_epi32(1); let r = _mm_mask_srav_epi32(a, 0, a, count); @@ -53002,7 +54888,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srav_epi32() { + const unsafe fn test_mm_maskz_srav_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let count = _mm_set1_epi32(1); let r = _mm_maskz_srav_epi32(0, a, count); @@ -53013,7 +54899,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srai_epi32() { + const unsafe fn test_mm512_srai_epi32() { let a = _mm512_set_epi32(8, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, -15); let r = _mm512_srai_epi32::<2>(a); let e = _mm512_set_epi32(2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, -4); @@ -53021,7 +54907,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srai_epi32() { + const unsafe fn test_mm512_mask_srai_epi32() { let a = _mm512_set_epi32(8, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, -15); let r = _mm512_mask_srai_epi32::<2>(a, 0, a); assert_eq_m512i(r, a); @@ -53031,7 +54917,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srai_epi32() { + const unsafe fn test_mm512_maskz_srai_epi32() { let a = _mm512_set_epi32(8, -8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, -15); let r = _mm512_maskz_srai_epi32::<2>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -53041,7 +54927,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srai_epi32() { + const unsafe fn test_mm256_mask_srai_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let r = _mm256_mask_srai_epi32::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -53051,7 +54937,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srai_epi32() { + const unsafe fn test_mm256_maskz_srai_epi32() { let a = _mm256_set_epi32(1 << 5, 0, 0, 0, 0, 0, 0, 0); let r = _mm256_maskz_srai_epi32::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -53061,7 +54947,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srai_epi32() { + const unsafe fn test_mm_mask_srai_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let r = _mm_mask_srai_epi32::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -53071,7 +54957,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srai_epi32() { + const unsafe fn test_mm_maskz_srai_epi32() { let a = _mm_set_epi32(1 << 5, 0, 0, 0); let r = _mm_maskz_srai_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -53081,7 +54967,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_permute_ps() { + const unsafe fn test_mm512_permute_ps() { let a = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., ); @@ -53093,7 +54979,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_permute_ps() { + const unsafe fn test_mm512_mask_permute_ps() { let a = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., ); @@ -53107,7 +54993,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_permute_ps() { + const unsafe fn test_mm512_maskz_permute_ps() { let a = _mm512_setr_ps( 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., ); @@ -53121,7 +55007,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_permute_ps() { + const unsafe fn test_mm256_mask_permute_ps() { let a = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm256_mask_permute_ps::<0b11_11_11_11>(a, 0, a); assert_eq_m256(r, a); @@ -53131,7 +55017,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_permute_ps() { + const unsafe fn test_mm256_maskz_permute_ps() { let a = _mm256_set_ps(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm256_maskz_permute_ps::<0b11_11_11_11>(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -53141,7 +55027,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_permute_ps() { + const unsafe fn test_mm_mask_permute_ps() { let a = _mm_set_ps(0., 1., 2., 3.); let r = _mm_mask_permute_ps::<0b11_11_11_11>(a, 0, a); assert_eq_m128(r, a); @@ -53151,7 +55037,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_permute_ps() { + const unsafe fn test_mm_maskz_permute_ps() { let a = _mm_set_ps(0., 1., 2., 3.); let r = _mm_maskz_permute_ps::<0b11_11_11_11>(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -53750,7 +55636,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_epi32() { + const unsafe fn test_mm512_shuffle_epi32() { let a = _mm512_setr_epi32(1, 4, 5, 8, 9, 12, 13, 16, 1, 4, 5, 8, 9, 12, 13, 16); let r = _mm512_shuffle_epi32::<_MM_PERM_AADD>(a); let e = _mm512_setr_epi32(8, 8, 1, 1, 16, 16, 9, 9, 8, 8, 1, 1, 16, 16, 9, 9); @@ -53758,7 +55644,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_epi32() { + const unsafe fn test_mm512_mask_shuffle_epi32() { let a = _mm512_setr_epi32(1, 4, 5, 8, 9, 12, 13, 16, 1, 4, 5, 8, 9, 12, 13, 16); let r = _mm512_mask_shuffle_epi32::<_MM_PERM_AADD>(a, 0, a); assert_eq_m512i(r, a); @@ -53768,7 +55654,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_epi32() { + const unsafe fn test_mm512_maskz_shuffle_epi32() { let a = _mm512_setr_epi32(1, 4, 5, 8, 9, 12, 13, 16, 1, 4, 5, 8, 9, 12, 13, 16); let r = _mm512_maskz_shuffle_epi32::<_MM_PERM_AADD>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -53778,7 +55664,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_epi32() { + const unsafe fn test_mm256_mask_shuffle_epi32() { let a = _mm256_set_epi32(1, 4, 5, 8, 9, 12, 13, 16); let r = _mm256_mask_shuffle_epi32::<_MM_PERM_AADD>(a, 0, a); assert_eq_m256i(r, a); @@ -53788,7 +55674,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_epi32() { + const unsafe fn test_mm256_maskz_shuffle_epi32() { let a = _mm256_set_epi32(1, 4, 5, 8, 9, 12, 13, 16); let r = _mm256_maskz_shuffle_epi32::<_MM_PERM_AADD>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -53798,7 +55684,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_shuffle_epi32() { + const unsafe fn test_mm_mask_shuffle_epi32() { let a = _mm_set_epi32(1, 4, 5, 8); let r = _mm_mask_shuffle_epi32::<_MM_PERM_AADD>(a, 0, a); assert_eq_m128i(r, a); @@ -53808,7 +55694,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_shuffle_epi32() { + const unsafe fn test_mm_maskz_shuffle_epi32() { let a = _mm_set_epi32(1, 4, 5, 8); let r = _mm_maskz_shuffle_epi32::<_MM_PERM_AADD>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -53818,7 +55704,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_ps() { + const unsafe fn test_mm512_shuffle_ps() { let a = _mm512_setr_ps( 1., 4., 5., 8., 9., 12., 13., 16., 1., 4., 5., 8., 9., 12., 13., 16., ); @@ -53833,7 +55719,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_ps() { + const unsafe fn test_mm512_mask_shuffle_ps() { let a = _mm512_setr_ps( 1., 4., 5., 8., 9., 12., 13., 16., 1., 4., 5., 8., 9., 12., 13., 16., ); @@ -53850,7 +55736,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_ps() { + const unsafe fn test_mm512_maskz_shuffle_ps() { let a = _mm512_setr_ps( 1., 4., 5., 8., 9., 12., 13., 16., 1., 4., 5., 8., 9., 12., 13., 16., ); @@ -53867,7 +55753,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_ps() { + const unsafe fn test_mm256_mask_shuffle_ps() { let a = _mm256_set_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_set_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_mask_shuffle_ps::<0b11_11_11_11>(a, 0, a, b); @@ -53878,7 +55764,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_ps() { + const unsafe fn test_mm256_maskz_shuffle_ps() { let a = _mm256_set_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_set_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_maskz_shuffle_ps::<0b11_11_11_11>(0, a, b); @@ -53889,7 +55775,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_shuffle_ps() { + const unsafe fn test_mm_mask_shuffle_ps() { let a = _mm_set_ps(1., 4., 5., 8.); let b = _mm_set_ps(2., 3., 6., 7.); let r = _mm_mask_shuffle_ps::<0b11_11_11_11>(a, 0, a, b); @@ -53900,7 +55786,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_shuffle_ps() { + const unsafe fn test_mm_maskz_shuffle_ps() { let a = _mm_set_ps(1., 4., 5., 8.); let b = _mm_set_ps(2., 3., 6., 7.); let r = _mm_maskz_shuffle_ps::<0b11_11_11_11>(0, a, b); @@ -53911,7 +55797,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_i32x4() { + const unsafe fn test_mm512_shuffle_i32x4() { let a = _mm512_setr_epi32(1, 4, 5, 8, 9, 12, 13, 16, 1, 4, 5, 8, 9, 12, 13, 16); let b = _mm512_setr_epi32(2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15); let r = _mm512_shuffle_i32x4::<0b00_00_00_00>(a, b); @@ -53920,7 +55806,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_i32x4() { + const unsafe fn test_mm512_mask_shuffle_i32x4() { let a = _mm512_setr_epi32(1, 4, 5, 8, 9, 12, 13, 16, 1, 4, 5, 8, 9, 12, 13, 16); let b = _mm512_setr_epi32(2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15); let r = _mm512_mask_shuffle_i32x4::<0b00_00_00_00>(a, 0, a, b); @@ -53931,7 +55817,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_i32x4() { + const unsafe fn test_mm512_maskz_shuffle_i32x4() { let a = _mm512_setr_epi32(1, 4, 5, 8, 9, 12, 13, 16, 1, 4, 5, 8, 9, 12, 13, 16); let b = _mm512_setr_epi32(2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15); let r = _mm512_maskz_shuffle_i32x4::<0b00_00_00_00>(0, a, b); @@ -53942,7 +55828,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_shuffle_i32x4() { + const unsafe fn test_mm256_shuffle_i32x4() { let a = _mm256_set_epi32(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm256_set_epi32(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm256_shuffle_i32x4::<0b00>(a, b); @@ -53951,7 +55837,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_i32x4() { + const unsafe fn test_mm256_mask_shuffle_i32x4() { let a = _mm256_set_epi32(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm256_set_epi32(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm256_mask_shuffle_i32x4::<0b00>(a, 0, a, b); @@ -53962,7 +55848,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_i32x4() { + const unsafe fn test_mm256_maskz_shuffle_i32x4() { let a = _mm256_set_epi32(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm256_set_epi32(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm256_maskz_shuffle_i32x4::<0b00>(0, a, b); @@ -53973,7 +55859,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_f32x4() { + const unsafe fn test_mm512_shuffle_f32x4() { let a = _mm512_setr_ps( 1., 4., 5., 8., 9., 12., 13., 16., 1., 4., 5., 8., 9., 12., 13., 16., ); @@ -53988,7 +55874,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_f32x4() { + const unsafe fn test_mm512_mask_shuffle_f32x4() { let a = _mm512_setr_ps( 1., 4., 5., 8., 9., 12., 13., 16., 1., 4., 5., 8., 9., 12., 13., 16., ); @@ -54005,7 +55891,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_f32x4() { + const unsafe fn test_mm512_maskz_shuffle_f32x4() { let a = _mm512_setr_ps( 1., 4., 5., 8., 9., 12., 13., 16., 1., 4., 5., 8., 9., 12., 13., 16., ); @@ -54022,7 +55908,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_shuffle_f32x4() { + const unsafe fn test_mm256_shuffle_f32x4() { let a = _mm256_set_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_set_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_shuffle_f32x4::<0b00>(a, b); @@ -54031,7 +55917,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_f32x4() { + const unsafe fn test_mm256_mask_shuffle_f32x4() { let a = _mm256_set_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_set_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_mask_shuffle_f32x4::<0b00>(a, 0, a, b); @@ -54042,7 +55928,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_f32x4() { + const unsafe fn test_mm256_maskz_shuffle_f32x4() { let a = _mm256_set_ps(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm256_set_ps(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm256_maskz_shuffle_f32x4::<0b00>(0, a, b); @@ -54053,7 +55939,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_extractf32x4_ps() { + const unsafe fn test_mm512_extractf32x4_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54063,7 +55949,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_extractf32x4_ps() { + const unsafe fn test_mm512_mask_extractf32x4_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54076,7 +55962,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_extractf32x4_ps() { + const unsafe fn test_mm512_maskz_extractf32x4_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54088,7 +55974,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_extractf32x4_ps() { + const unsafe fn test_mm256_extractf32x4_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_extractf32x4_ps::<1>(a); let e = _mm_set_ps(1., 2., 3., 4.); @@ -54096,7 +55982,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_extractf32x4_ps() { + const unsafe fn test_mm256_mask_extractf32x4_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let src = _mm_set1_ps(100.); let r = _mm256_mask_extractf32x4_ps::<1>(src, 0, a); @@ -54107,7 +55993,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_extractf32x4_ps() { + const unsafe fn test_mm256_maskz_extractf32x4_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_maskz_extractf32x4_ps::<1>(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -54117,7 +56003,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_extracti32x4_epi32() { + const unsafe fn test_mm512_extracti32x4_epi32() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_extracti32x4_epi32::<1>(a); let e = _mm_setr_epi32(5, 6, 7, 8); @@ -54125,7 +56011,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_extracti32x4_epi32() { + const unsafe fn test_mm512_mask_extracti32x4_epi32() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let src = _mm_set1_epi32(100); let r = _mm512_mask_extracti32x4_epi32::<1>(src, 0, a); @@ -54136,7 +56022,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm512_maskz_extracti32x4_epi32() { + const unsafe fn test_mm512_maskz_extracti32x4_epi32() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_extracti32x4_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -54146,7 +56032,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_extracti32x4_epi32() { + const unsafe fn test_mm256_extracti32x4_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_extracti32x4_epi32::<1>(a); let e = _mm_set_epi32(1, 2, 3, 4); @@ -54154,7 +56040,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_extracti32x4_epi32() { + const unsafe fn test_mm256_mask_extracti32x4_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let src = _mm_set1_epi32(100); let r = _mm256_mask_extracti32x4_epi32::<1>(src, 0, a); @@ -54165,7 +56051,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_extracti32x4_epi32() { + const unsafe fn test_mm256_maskz_extracti32x4_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_maskz_extracti32x4_epi32::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -54175,7 +56061,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_moveldup_ps() { + const unsafe fn test_mm512_moveldup_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54187,7 +56073,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_moveldup_ps() { + const unsafe fn test_mm512_mask_moveldup_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54201,7 +56087,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_moveldup_ps() { + const unsafe fn test_mm512_maskz_moveldup_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54215,7 +56101,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_moveldup_ps() { + const unsafe fn test_mm256_mask_moveldup_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_mask_moveldup_ps(a, 0, a); assert_eq_m256(r, a); @@ -54225,7 +56111,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_moveldup_ps() { + const unsafe fn test_mm256_maskz_moveldup_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_maskz_moveldup_ps(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -54235,7 +56121,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_moveldup_ps() { + const unsafe fn test_mm_mask_moveldup_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm_mask_moveldup_ps(a, 0, a); assert_eq_m128(r, a); @@ -54245,7 +56131,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_moveldup_ps() { + const unsafe fn test_mm_maskz_moveldup_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm_maskz_moveldup_ps(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -54255,7 +56141,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_movehdup_ps() { + const unsafe fn test_mm512_movehdup_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54267,7 +56153,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_movehdup_ps() { + const unsafe fn test_mm512_mask_movehdup_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54281,7 +56167,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_movehdup_ps() { + const unsafe fn test_mm512_maskz_movehdup_ps() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54295,7 +56181,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_movehdup_ps() { + const unsafe fn test_mm256_mask_movehdup_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_mask_movehdup_ps(a, 0, a); assert_eq_m256(r, a); @@ -54305,7 +56191,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_movehdup_ps() { + const unsafe fn test_mm256_maskz_movehdup_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_maskz_movehdup_ps(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -54315,7 +56201,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_movehdup_ps() { + const unsafe fn test_mm_mask_movehdup_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm_mask_movehdup_ps(a, 0, a); assert_eq_m128(r, a); @@ -54325,7 +56211,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_movehdup_ps() { + const unsafe fn test_mm_maskz_movehdup_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm_maskz_movehdup_ps(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -54335,7 +56221,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_inserti32x4() { + const unsafe fn test_mm512_inserti32x4() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_setr_epi32(17, 18, 19, 20); let r = _mm512_inserti32x4::<0>(a, b); @@ -54344,7 +56230,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_inserti32x4() { + const unsafe fn test_mm512_mask_inserti32x4() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_setr_epi32(17, 18, 19, 20); let r = _mm512_mask_inserti32x4::<0>(a, 0, a, b); @@ -54355,7 +56241,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_inserti32x4() { + const unsafe fn test_mm512_maskz_inserti32x4() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_setr_epi32(17, 18, 19, 20); let r = _mm512_maskz_inserti32x4::<0>(0, a, b); @@ -54366,7 +56252,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_inserti32x4() { + const unsafe fn test_mm256_inserti32x4() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_inserti32x4::<1>(a, b); @@ -54375,7 +56261,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_inserti32x4() { + const unsafe fn test_mm256_mask_inserti32x4() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_mask_inserti32x4::<0>(a, 0, a, b); @@ -54386,7 +56272,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_inserti32x4() { + const unsafe fn test_mm256_maskz_inserti32x4() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_maskz_inserti32x4::<0>(0, a, b); @@ -54397,7 +56283,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_insertf32x4() { + const unsafe fn test_mm512_insertf32x4() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54410,7 +56296,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_insertf32x4() { + const unsafe fn test_mm512_mask_insertf32x4() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54425,7 +56311,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_insertf32x4() { + const unsafe fn test_mm512_maskz_insertf32x4() { let a = _mm512_setr_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54440,7 +56326,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_insertf32x4() { + const unsafe fn test_mm256_insertf32x4() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_insertf32x4::<1>(a, b); @@ -54449,7 +56335,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_insertf32x4() { + const unsafe fn test_mm256_mask_insertf32x4() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_mask_insertf32x4::<0>(a, 0, a, b); @@ -54460,7 +56346,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_insertf32x4() { + const unsafe fn test_mm256_maskz_insertf32x4() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_maskz_insertf32x4::<0>(0, a, b); @@ -54471,21 +56357,21 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castps128_ps512() { + const unsafe fn test_mm512_castps128_ps512() { let a = _mm_setr_ps(17., 18., 19., 20.); let r = _mm512_castps128_ps512(a); assert_eq_m128(_mm512_castps512_ps128(r), a); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castps256_ps512() { + const unsafe fn test_mm512_castps256_ps512() { let a = _mm256_setr_ps(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_castps256_ps512(a); assert_eq_m256(_mm512_castps512_ps256(r), a); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_zextps128_ps512() { + const unsafe fn test_mm512_zextps128_ps512() { let a = _mm_setr_ps(17., 18., 19., 20.); let r = _mm512_zextps128_ps512(a); let e = _mm512_setr_ps( @@ -54495,7 +56381,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_zextps256_ps512() { + const unsafe fn test_mm512_zextps256_ps512() { let a = _mm256_setr_ps(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_zextps256_ps512(a); let e = _mm512_setr_ps( @@ -54505,7 +56391,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castps512_ps128() { + const unsafe fn test_mm512_castps512_ps128() { let a = _mm512_setr_ps( 17., 18., 19., 20., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., ); @@ -54515,7 +56401,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castps512_ps256() { + const unsafe fn test_mm512_castps512_ps256() { let a = _mm512_setr_ps( 17., 18., 19., 20., 21., 22., 23., 24., -1., -1., -1., -1., -1., -1., -1., -1., ); @@ -54525,7 +56411,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castps_pd() { + const unsafe fn test_mm512_castps_pd() { let a = _mm512_set1_ps(1.); let r = _mm512_castps_pd(a); let e = _mm512_set1_pd(0.007812501848093234); @@ -54533,7 +56419,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castps_si512() { + const unsafe fn test_mm512_castps_si512() { let a = _mm512_set1_ps(1.); let r = _mm512_castps_si512(a); let e = _mm512_set1_epi32(1065353216); @@ -54541,7 +56427,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcastd_epi32() { + const unsafe fn test_mm512_broadcastd_epi32() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm512_broadcastd_epi32(a); let e = _mm512_set1_epi32(20); @@ -54549,7 +56435,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcastd_epi32() { + const unsafe fn test_mm512_mask_broadcastd_epi32() { let src = _mm512_set1_epi32(20); let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm512_mask_broadcastd_epi32(src, 0, a); @@ -54560,7 +56446,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcastd_epi32() { + const unsafe fn test_mm512_maskz_broadcastd_epi32() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm512_maskz_broadcastd_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -54570,7 +56456,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_broadcastd_epi32() { + const unsafe fn test_mm256_mask_broadcastd_epi32() { let src = _mm256_set1_epi32(20); let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_mask_broadcastd_epi32(src, 0, a); @@ -54581,7 +56467,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_broadcastd_epi32() { + const unsafe fn test_mm256_maskz_broadcastd_epi32() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_maskz_broadcastd_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -54591,7 +56477,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_broadcastd_epi32() { + const unsafe fn test_mm_mask_broadcastd_epi32() { let src = _mm_set1_epi32(20); let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm_mask_broadcastd_epi32(src, 0, a); @@ -54602,7 +56488,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_broadcastd_epi32() { + const unsafe fn test_mm_maskz_broadcastd_epi32() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm_maskz_broadcastd_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -54612,7 +56498,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcastss_ps() { + const unsafe fn test_mm512_broadcastss_ps() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm512_broadcastss_ps(a); let e = _mm512_set1_ps(20.); @@ -54620,7 +56506,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcastss_ps() { + const unsafe fn test_mm512_mask_broadcastss_ps() { let src = _mm512_set1_ps(20.); let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm512_mask_broadcastss_ps(src, 0, a); @@ -54631,7 +56517,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcastss_ps() { + const unsafe fn test_mm512_maskz_broadcastss_ps() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm512_maskz_broadcastss_ps(0, a); assert_eq_m512(r, _mm512_setzero_ps()); @@ -54643,7 +56529,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_broadcastss_ps() { + const unsafe fn test_mm256_mask_broadcastss_ps() { let src = _mm256_set1_ps(20.); let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_mask_broadcastss_ps(src, 0, a); @@ -54654,7 +56540,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_broadcastss_ps() { + const unsafe fn test_mm256_maskz_broadcastss_ps() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_maskz_broadcastss_ps(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -54664,7 +56550,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_broadcastss_ps() { + const unsafe fn test_mm_mask_broadcastss_ps() { let src = _mm_set1_ps(20.); let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm_mask_broadcastss_ps(src, 0, a); @@ -54675,7 +56561,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_broadcastss_ps() { + const unsafe fn test_mm_maskz_broadcastss_ps() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm_maskz_broadcastss_ps(0, a); assert_eq_m128(r, _mm_setzero_ps()); @@ -54685,7 +56571,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcast_i32x4() { + const unsafe fn test_mm512_broadcast_i32x4() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm512_broadcast_i32x4(a); let e = _mm512_set_epi32( @@ -54695,7 +56581,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcast_i32x4() { + const unsafe fn test_mm512_mask_broadcast_i32x4() { let src = _mm512_set1_epi32(20); let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm512_mask_broadcast_i32x4(src, 0, a); @@ -54708,7 +56594,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcast_i32x4() { + const unsafe fn test_mm512_maskz_broadcast_i32x4() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm512_maskz_broadcast_i32x4(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -54718,7 +56604,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_broadcast_i32x4() { + const unsafe fn test_mm256_broadcast_i32x4() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_broadcast_i32x4(a); let e = _mm256_set_epi32(17, 18, 19, 20, 17, 18, 19, 20); @@ -54726,7 +56612,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_broadcast_i32x4() { + const unsafe fn test_mm256_mask_broadcast_i32x4() { let src = _mm256_set1_epi32(20); let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_mask_broadcast_i32x4(src, 0, a); @@ -54737,7 +56623,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_broadcast_i32x4() { + const unsafe fn test_mm256_maskz_broadcast_i32x4() { let a = _mm_set_epi32(17, 18, 19, 20); let r = _mm256_maskz_broadcast_i32x4(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -54747,7 +56633,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcast_f32x4() { + const unsafe fn test_mm512_broadcast_f32x4() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm512_broadcast_f32x4(a); let e = _mm512_set_ps( @@ -54757,7 +56643,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcast_f32x4() { + const unsafe fn test_mm512_mask_broadcast_f32x4() { let src = _mm512_set1_ps(20.); let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm512_mask_broadcast_f32x4(src, 0, a); @@ -54770,7 +56656,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcast_f32x4() { + const unsafe fn test_mm512_maskz_broadcast_f32x4() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm512_maskz_broadcast_f32x4(0, a); assert_eq_m512(r, _mm512_setzero_ps()); @@ -54782,7 +56668,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_broadcast_f32x4() { + const unsafe fn test_mm256_broadcast_f32x4() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_broadcast_f32x4(a); let e = _mm256_set_ps(17., 18., 19., 20., 17., 18., 19., 20.); @@ -54790,7 +56676,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_broadcast_f32x4() { + const unsafe fn test_mm256_mask_broadcast_f32x4() { let src = _mm256_set1_ps(20.); let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_mask_broadcast_f32x4(src, 0, a); @@ -54801,7 +56687,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_broadcast_f32x4() { + const unsafe fn test_mm256_maskz_broadcast_f32x4() { let a = _mm_set_ps(17., 18., 19., 20.); let r = _mm256_maskz_broadcast_f32x4(0, a); assert_eq_m256(r, _mm256_setzero_ps()); @@ -54811,7 +56697,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_blend_epi32() { + const unsafe fn test_mm512_mask_blend_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(2); let r = _mm512_mask_blend_epi32(0b11111111_00000000, a, b); @@ -54820,7 +56706,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_blend_epi32() { + const unsafe fn test_mm256_mask_blend_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(2); let r = _mm256_mask_blend_epi32(0b11111111, a, b); @@ -54829,7 +56715,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_blend_epi32() { + const unsafe fn test_mm_mask_blend_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(2); let r = _mm_mask_blend_epi32(0b00001111, a, b); @@ -54838,7 +56724,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_blend_ps() { + const unsafe fn test_mm512_mask_blend_ps() { let a = _mm512_set1_ps(1.); let b = _mm512_set1_ps(2.); let r = _mm512_mask_blend_ps(0b11111111_00000000, a, b); @@ -54849,7 +56735,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_blend_ps() { + const unsafe fn test_mm256_mask_blend_ps() { let a = _mm256_set1_ps(1.); let b = _mm256_set1_ps(2.); let r = _mm256_mask_blend_ps(0b11111111, a, b); @@ -54858,7 +56744,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_blend_ps() { + const unsafe fn test_mm_mask_blend_ps() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let r = _mm_mask_blend_ps(0b00001111, a, b); @@ -54867,7 +56753,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpackhi_epi32() { + const unsafe fn test_mm512_unpackhi_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm512_set_epi32( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -54878,7 +56764,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpackhi_epi32() { + const unsafe fn test_mm512_mask_unpackhi_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm512_set_epi32( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -54891,7 +56777,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpackhi_epi32() { + const unsafe fn test_mm512_maskz_unpackhi_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm512_set_epi32( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -54904,7 +56790,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpackhi_epi32() { + const unsafe fn test_mm256_mask_unpackhi_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm256_mask_unpackhi_epi32(a, 0, a, b); @@ -54915,7 +56801,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpackhi_epi32() { + const unsafe fn test_mm256_maskz_unpackhi_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm256_maskz_unpackhi_epi32(0, a, b); @@ -54926,7 +56812,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpackhi_epi32() { + const unsafe fn test_mm_mask_unpackhi_epi32() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm_mask_unpackhi_epi32(a, 0, a, b); @@ -54937,7 +56823,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpackhi_epi32() { + const unsafe fn test_mm_maskz_unpackhi_epi32() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm_maskz_unpackhi_epi32(0, a, b); @@ -54948,7 +56834,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpackhi_ps() { + const unsafe fn test_mm512_unpackhi_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54963,7 +56849,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpackhi_ps() { + const unsafe fn test_mm512_mask_unpackhi_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54980,7 +56866,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpackhi_ps() { + const unsafe fn test_mm512_maskz_unpackhi_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -54997,7 +56883,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpackhi_ps() { + const unsafe fn test_mm256_mask_unpackhi_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_set_ps(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm256_mask_unpackhi_ps(a, 0, a, b); @@ -55008,7 +56894,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpackhi_ps() { + const unsafe fn test_mm256_maskz_unpackhi_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_set_ps(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm256_maskz_unpackhi_ps(0, a, b); @@ -55019,7 +56905,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpackhi_ps() { + const unsafe fn test_mm_mask_unpackhi_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm_mask_unpackhi_ps(a, 0, a, b); @@ -55030,7 +56916,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpackhi_ps() { + const unsafe fn test_mm_maskz_unpackhi_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm_maskz_unpackhi_ps(0, a, b); @@ -55041,7 +56927,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpacklo_epi32() { + const unsafe fn test_mm512_unpacklo_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm512_set_epi32( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -55052,7 +56938,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpacklo_epi32() { + const unsafe fn test_mm512_mask_unpacklo_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm512_set_epi32( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -55065,7 +56951,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpacklo_epi32() { + const unsafe fn test_mm512_maskz_unpacklo_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm512_set_epi32( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -55078,7 +56964,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpacklo_epi32() { + const unsafe fn test_mm256_mask_unpacklo_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm256_mask_unpacklo_epi32(a, 0, a, b); @@ -55089,7 +56975,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpacklo_epi32() { + const unsafe fn test_mm256_maskz_unpacklo_epi32() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm256_maskz_unpacklo_epi32(0, a, b); @@ -55100,7 +56986,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpacklo_epi32() { + const unsafe fn test_mm_mask_unpacklo_epi32() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm_mask_unpacklo_epi32(a, 0, a, b); @@ -55111,7 +56997,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpacklo_epi32() { + const unsafe fn test_mm_maskz_unpacklo_epi32() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm_set_epi32(17, 18, 19, 20); let r = _mm_maskz_unpacklo_epi32(0, a, b); @@ -55122,7 +57008,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpacklo_ps() { + const unsafe fn test_mm512_unpacklo_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -55137,7 +57023,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpacklo_ps() { + const unsafe fn test_mm512_mask_unpacklo_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -55154,7 +57040,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpacklo_ps() { + const unsafe fn test_mm512_maskz_unpacklo_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -55171,7 +57057,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpacklo_ps() { + const unsafe fn test_mm256_mask_unpacklo_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_set_ps(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm256_mask_unpacklo_ps(a, 0, a, b); @@ -55182,7 +57068,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpacklo_ps() { + const unsafe fn test_mm256_maskz_unpacklo_ps() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_set_ps(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm256_maskz_unpacklo_ps(0, a, b); @@ -55193,7 +57079,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpacklo_ps() { + const unsafe fn test_mm_mask_unpacklo_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm_mask_unpacklo_ps(a, 0, a, b); @@ -55204,7 +57090,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpacklo_ps() { + const unsafe fn test_mm_maskz_unpacklo_ps() { let a = _mm_set_ps(1., 2., 3., 4.); let b = _mm_set_ps(17., 18., 19., 20.); let r = _mm_maskz_unpacklo_ps(0, a, b); @@ -55215,7 +57101,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_alignr_epi32() { + const unsafe fn test_mm512_alignr_epi32() { let a = _mm512_set_epi32(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); let b = _mm512_set_epi32( 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, @@ -55232,7 +57118,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_alignr_epi32() { + const unsafe fn test_mm512_mask_alignr_epi32() { let a = _mm512_set_epi32(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); let b = _mm512_set_epi32( 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, @@ -55247,7 +57133,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_alignr_epi32() { + const unsafe fn test_mm512_maskz_alignr_epi32() { let a = _mm512_set_epi32(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); let b = _mm512_set_epi32( 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, @@ -55260,7 +57146,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_alignr_epi32() { + const unsafe fn test_mm256_alignr_epi32() { let a = _mm256_set_epi32(8, 7, 6, 5, 4, 3, 2, 1); let b = _mm256_set_epi32(16, 15, 14, 13, 12, 11, 10, 9); let r = _mm256_alignr_epi32::<0>(a, b); @@ -55271,7 +57157,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_alignr_epi32() { + const unsafe fn test_mm256_mask_alignr_epi32() { let a = _mm256_set_epi32(8, 7, 6, 5, 4, 3, 2, 1); let b = _mm256_set_epi32(16, 15, 14, 13, 12, 11, 10, 9); let r = _mm256_mask_alignr_epi32::<1>(a, 0, a, b); @@ -55282,7 +57168,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_alignr_epi32() { + const unsafe fn test_mm256_maskz_alignr_epi32() { let a = _mm256_set_epi32(8, 7, 6, 5, 4, 3, 2, 1); let b = _mm256_set_epi32(16, 15, 14, 13, 12, 11, 10, 9); let r = _mm256_maskz_alignr_epi32::<1>(0, a, b); @@ -55293,7 +57179,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_alignr_epi32() { + const unsafe fn test_mm_alignr_epi32() { let a = _mm_set_epi32(4, 3, 2, 1); let b = _mm_set_epi32(8, 7, 6, 5); let r = _mm_alignr_epi32::<0>(a, b); @@ -55304,7 +57190,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_alignr_epi32() { + const unsafe fn test_mm_mask_alignr_epi32() { let a = _mm_set_epi32(4, 3, 2, 1); let b = _mm_set_epi32(8, 7, 6, 5); let r = _mm_mask_alignr_epi32::<1>(a, 0, a, b); @@ -55315,7 +57201,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_alignr_epi32() { + const unsafe fn test_mm_maskz_alignr_epi32() { let a = _mm_set_epi32(4, 3, 2, 1); let b = _mm_set_epi32(8, 7, 6, 5); let r = _mm_maskz_alignr_epi32::<1>(0, a, b); @@ -55326,7 +57212,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_and_epi32() { + const unsafe fn test_mm512_and_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55347,7 +57233,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_and_epi32() { + const unsafe fn test_mm512_mask_and_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55376,7 +57262,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_and_epi32() { + const unsafe fn test_mm512_maskz_and_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55399,7 +57285,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_and_epi32() { + const unsafe fn test_mm256_mask_and_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_mask_and_epi32(a, 0, a, b); @@ -55410,7 +57296,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_and_epi32() { + const unsafe fn test_mm256_maskz_and_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_maskz_and_epi32(0, a, b); @@ -55421,7 +57307,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_and_epi32() { + const unsafe fn test_mm_mask_and_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_mask_and_epi32(a, 0, a, b); @@ -55432,7 +57318,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_and_epi32() { + const unsafe fn test_mm_maskz_and_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_maskz_and_epi32(0, a, b); @@ -55443,7 +57329,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_and_si512() { + const unsafe fn test_mm512_and_si512() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55464,7 +57350,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_or_epi32() { + const unsafe fn test_mm512_or_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55491,7 +57377,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_or_epi32() { + const unsafe fn test_mm512_mask_or_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55520,7 +57406,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_or_epi32() { + const unsafe fn test_mm512_maskz_or_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55549,7 +57435,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_or_epi32() { + const unsafe fn test_mm256_or_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_or_epi32(a, b); @@ -55558,7 +57444,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_or_epi32() { + const unsafe fn test_mm256_mask_or_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_mask_or_epi32(a, 0, a, b); @@ -55569,7 +57455,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_or_epi32() { + const unsafe fn test_mm256_maskz_or_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_maskz_or_epi32(0, a, b); @@ -55580,7 +57466,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_or_epi32() { + const unsafe fn test_mm_or_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_or_epi32(a, b); @@ -55589,7 +57475,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_or_epi32() { + const unsafe fn test_mm_mask_or_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_mask_or_epi32(a, 0, a, b); @@ -55600,7 +57486,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_or_epi32() { + const unsafe fn test_mm_maskz_or_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_maskz_or_epi32(0, a, b); @@ -55611,7 +57497,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_or_si512() { + const unsafe fn test_mm512_or_si512() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55638,7 +57524,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_xor_epi32() { + const unsafe fn test_mm512_xor_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55665,7 +57551,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_xor_epi32() { + const unsafe fn test_mm512_mask_xor_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55694,7 +57580,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_xor_epi32() { + const unsafe fn test_mm512_maskz_xor_epi32() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55717,7 +57603,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_xor_epi32() { + const unsafe fn test_mm256_xor_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_xor_epi32(a, b); @@ -55726,7 +57612,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_xor_epi32() { + const unsafe fn test_mm256_mask_xor_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_mask_xor_epi32(a, 0, a, b); @@ -55737,7 +57623,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_xor_epi32() { + const unsafe fn test_mm256_maskz_xor_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_maskz_xor_epi32(0, a, b); @@ -55748,7 +57634,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_xor_epi32() { + const unsafe fn test_mm_xor_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_xor_epi32(a, b); @@ -55757,7 +57643,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_xor_epi32() { + const unsafe fn test_mm_mask_xor_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_mask_xor_epi32(a, 0, a, b); @@ -55768,7 +57654,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_xor_epi32() { + const unsafe fn test_mm_maskz_xor_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 1); let r = _mm_maskz_xor_epi32(0, a, b); @@ -55779,7 +57665,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_xor_si512() { + const unsafe fn test_mm512_xor_si512() { #[rustfmt::skip] let a = _mm512_set_epi32( 1 << 1 | 1 << 2, 0, 0, 0, @@ -55806,7 +57692,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_andnot_epi32() { + const unsafe fn test_mm512_andnot_epi32() { let a = _mm512_set1_epi32(0); let b = _mm512_set1_epi32(1 << 3 | 1 << 4); let r = _mm512_andnot_epi32(a, b); @@ -55815,7 +57701,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_andnot_epi32() { + const unsafe fn test_mm512_mask_andnot_epi32() { let a = _mm512_set1_epi32(1 << 1 | 1 << 2); let b = _mm512_set1_epi32(1 << 3 | 1 << 4); let r = _mm512_mask_andnot_epi32(a, 0, a, b); @@ -55826,7 +57712,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_andnot_epi32() { + const unsafe fn test_mm512_maskz_andnot_epi32() { let a = _mm512_set1_epi32(1 << 1 | 1 << 2); let b = _mm512_set1_epi32(1 << 3 | 1 << 4); let r = _mm512_maskz_andnot_epi32(0, a, b); @@ -55843,7 +57729,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_andnot_epi32() { + const unsafe fn test_mm256_mask_andnot_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 3 | 1 << 4); let r = _mm256_mask_andnot_epi32(a, 0, a, b); @@ -55854,7 +57740,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_andnot_epi32() { + const unsafe fn test_mm256_maskz_andnot_epi32() { let a = _mm256_set1_epi32(1 << 1 | 1 << 2); let b = _mm256_set1_epi32(1 << 3 | 1 << 4); let r = _mm256_maskz_andnot_epi32(0, a, b); @@ -55865,7 +57751,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_andnot_epi32() { + const unsafe fn test_mm_mask_andnot_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 3 | 1 << 4); let r = _mm_mask_andnot_epi32(a, 0, a, b); @@ -55876,7 +57762,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_andnot_epi32() { + const unsafe fn test_mm_maskz_andnot_epi32() { let a = _mm_set1_epi32(1 << 1 | 1 << 2); let b = _mm_set1_epi32(1 << 3 | 1 << 4); let r = _mm_maskz_andnot_epi32(0, a, b); @@ -55887,7 +57773,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_cvtmask16_u32() { + const unsafe fn test_cvtmask16_u32() { let a: __mmask16 = 0b11001100_00110011; let r = _cvtmask16_u32(a); let e: u32 = 0b11001100_00110011; @@ -55895,7 +57781,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_cvtu32_mask16() { + const unsafe fn test_cvtu32_mask16() { let a: u32 = 0b11001100_00110011; let r = _cvtu32_mask16(a); let e: __mmask16 = 0b11001100_00110011; @@ -55903,7 +57789,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kand() { + const unsafe fn test_mm512_kand() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b11001100_00110011; let r = _mm512_kand(a, b); @@ -55912,7 +57798,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kand_mask16() { + const unsafe fn test_kand_mask16() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b11001100_00110011; let r = _kand_mask16(a, b); @@ -55921,7 +57807,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kor() { + const unsafe fn test_mm512_kor() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kor(a, b); @@ -55930,7 +57816,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kor_mask16() { + const unsafe fn test_kor_mask16() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _kor_mask16(a, b); @@ -55939,7 +57825,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kxor() { + const unsafe fn test_mm512_kxor() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kxor(a, b); @@ -55948,7 +57834,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kxor_mask16() { + const unsafe fn test_kxor_mask16() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _kxor_mask16(a, b); @@ -55957,7 +57843,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_knot() { + const unsafe fn test_mm512_knot() { let a: u16 = 0b11001100_00110011; let r = _mm512_knot(a); let e: u16 = 0b00110011_11001100; @@ -55965,7 +57851,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_knot_mask16() { + const unsafe fn test_knot_mask16() { let a: u16 = 0b11001100_00110011; let r = _knot_mask16(a); let e: u16 = 0b00110011_11001100; @@ -55973,7 +57859,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kandn() { + const unsafe fn test_mm512_kandn() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kandn(a, b); @@ -55982,7 +57868,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kandn_mask16() { + const unsafe fn test_kandn_mask16() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _kandn_mask16(a, b); @@ -55991,7 +57877,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kxnor() { + const unsafe fn test_mm512_kxnor() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kxnor(a, b); @@ -56000,7 +57886,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kxnor_mask16() { + const unsafe fn test_kxnor_mask16() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _kxnor_mask16(a, b); @@ -56009,7 +57895,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kortest_mask16_u8() { + const unsafe fn test_kortest_mask16_u8() { let a: __mmask16 = 0b0110100101101001; let b: __mmask16 = 0b1011011010110110; let mut all_ones: u8 = 0; @@ -56019,7 +57905,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kortestc_mask16_u8() { + const unsafe fn test_kortestc_mask16_u8() { let a: __mmask16 = 0b0110100101101001; let b: __mmask16 = 0b1011011010110110; let r = _kortestc_mask16_u8(a, b); @@ -56027,7 +57913,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kortestz_mask16_u8() { + const unsafe fn test_kortestz_mask16_u8() { let a: __mmask16 = 0b0110100101101001; let b: __mmask16 = 0b1011011010110110; let r = _kortestz_mask16_u8(a, b); @@ -56035,7 +57921,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kshiftli_mask16() { + const unsafe fn test_kshiftli_mask16() { let a: __mmask16 = 0b1001011011000011; let r = _kshiftli_mask16::<3>(a); let e: __mmask16 = 0b1011011000011000; @@ -56055,7 +57941,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_kshiftri_mask16() { + const unsafe fn test_kshiftri_mask16() { let a: __mmask16 = 0b1010100100111100; let r = _kshiftri_mask16::<3>(a); let e: __mmask16 = 0b0001010100100111; @@ -56075,7 +57961,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_load_mask16() { + const unsafe fn test_load_mask16() { let a: __mmask16 = 0b1001011011000011; let r = _load_mask16(&a); let e: __mmask16 = 0b1001011011000011; @@ -56083,7 +57969,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_store_mask16() { + const unsafe fn test_store_mask16() { let a: __mmask16 = 0b0110100100111100; let mut r = 0; _store_mask16(&mut r, a); @@ -56092,7 +57978,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kmov() { + const unsafe fn test_mm512_kmov() { let a: u16 = 0b11001100_00110011; let r = _mm512_kmov(a); let e: u16 = 0b11001100_00110011; @@ -56100,7 +57986,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_int2mask() { + const unsafe fn test_mm512_int2mask() { let a: i32 = 0b11001100_00110011; let r = _mm512_int2mask(a); let e: u16 = 0b11001100_00110011; @@ -56108,7 +57994,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask2int() { + const unsafe fn test_mm512_mask2int() { let k1: __mmask16 = 0b11001100_00110011; let r = _mm512_mask2int(k1); let e: i32 = 0b11001100_00110011; @@ -56116,7 +58002,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kunpackb() { + const unsafe fn test_mm512_kunpackb() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kunpackb(a, b); @@ -56125,7 +58011,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kortestc() { + const unsafe fn test_mm512_kortestc() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kortestc(a, b); @@ -56136,7 +58022,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_kortestz() { + const unsafe fn test_mm512_kortestz() { let a: u16 = 0b11001100_00110011; let b: u16 = 0b00101110_00001011; let r = _mm512_kortestz(a, b); @@ -56146,7 +58032,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_test_epi32_mask() { + const unsafe fn test_mm512_test_epi32_mask() { let a = _mm512_set1_epi32(1 << 0); let b = _mm512_set1_epi32(1 << 0 | 1 << 1); let r = _mm512_test_epi32_mask(a, b); @@ -56155,7 +58041,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_test_epi32_mask() { + const unsafe fn test_mm512_mask_test_epi32_mask() { let a = _mm512_set1_epi32(1 << 0); let b = _mm512_set1_epi32(1 << 0 | 1 << 1); let r = _mm512_mask_test_epi32_mask(0, a, b); @@ -56166,7 +58052,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_test_epi32_mask() { + const unsafe fn test_mm256_test_epi32_mask() { let a = _mm256_set1_epi32(1 << 0); let b = _mm256_set1_epi32(1 << 0 | 1 << 1); let r = _mm256_test_epi32_mask(a, b); @@ -56175,7 +58061,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_test_epi32_mask() { + const unsafe fn test_mm256_mask_test_epi32_mask() { let a = _mm256_set1_epi32(1 << 0); let b = _mm256_set1_epi32(1 << 0 | 1 << 1); let r = _mm256_mask_test_epi32_mask(0, a, b); @@ -56186,7 +58072,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_test_epi32_mask() { + const unsafe fn test_mm_test_epi32_mask() { let a = _mm_set1_epi32(1 << 0); let b = _mm_set1_epi32(1 << 0 | 1 << 1); let r = _mm_test_epi32_mask(a, b); @@ -56195,7 +58081,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_test_epi32_mask() { + const unsafe fn test_mm_mask_test_epi32_mask() { let a = _mm_set1_epi32(1 << 0); let b = _mm_set1_epi32(1 << 0 | 1 << 1); let r = _mm_mask_test_epi32_mask(0, a, b); @@ -56206,7 +58092,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_testn_epi32_mask() { + const unsafe fn test_mm512_testn_epi32_mask() { let a = _mm512_set1_epi32(1 << 0); let b = _mm512_set1_epi32(1 << 0 | 1 << 1); let r = _mm512_testn_epi32_mask(a, b); @@ -56215,7 +58101,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_testn_epi32_mask() { + const unsafe fn test_mm512_mask_testn_epi32_mask() { let a = _mm512_set1_epi32(1 << 0); let b = _mm512_set1_epi32(1 << 1); let r = _mm512_mask_test_epi32_mask(0, a, b); @@ -56226,7 +58112,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_testn_epi32_mask() { + const unsafe fn test_mm256_testn_epi32_mask() { let a = _mm256_set1_epi32(1 << 0); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_testn_epi32_mask(a, b); @@ -56235,7 +58121,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_testn_epi32_mask() { + const unsafe fn test_mm256_mask_testn_epi32_mask() { let a = _mm256_set1_epi32(1 << 0); let b = _mm256_set1_epi32(1 << 1); let r = _mm256_mask_test_epi32_mask(0, a, b); @@ -56246,7 +58132,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_testn_epi32_mask() { + const unsafe fn test_mm_testn_epi32_mask() { let a = _mm_set1_epi32(1 << 0); let b = _mm_set1_epi32(1 << 1); let r = _mm_testn_epi32_mask(a, b); @@ -56255,7 +58141,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_testn_epi32_mask() { + const unsafe fn test_mm_mask_testn_epi32_mask() { let a = _mm_set1_epi32(1 << 0); let b = _mm_set1_epi32(1 << 1); let r = _mm_mask_test_epi32_mask(0, a, b); @@ -56324,84 +58210,84 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_add_epi32() { + const unsafe fn test_mm512_reduce_add_epi32() { let a = _mm512_set1_epi32(1); let e: i32 = _mm512_reduce_add_epi32(a); assert_eq!(16, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_add_epi32() { + const unsafe fn test_mm512_mask_reduce_add_epi32() { let a = _mm512_set1_epi32(1); let e: i32 = _mm512_mask_reduce_add_epi32(0b11111111_00000000, a); assert_eq!(8, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_add_ps() { + const unsafe fn test_mm512_reduce_add_ps() { let a = _mm512_set1_ps(1.); let e: f32 = _mm512_reduce_add_ps(a); assert_eq!(16., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_add_ps() { + const unsafe fn test_mm512_mask_reduce_add_ps() { let a = _mm512_set1_ps(1.); let e: f32 = _mm512_mask_reduce_add_ps(0b11111111_00000000, a); assert_eq!(8., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_mul_epi32() { + const unsafe fn test_mm512_reduce_mul_epi32() { let a = _mm512_set1_epi32(2); let e: i32 = _mm512_reduce_mul_epi32(a); assert_eq!(65536, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_mul_epi32() { + const unsafe fn test_mm512_mask_reduce_mul_epi32() { let a = _mm512_set1_epi32(2); let e: i32 = _mm512_mask_reduce_mul_epi32(0b11111111_00000000, a); assert_eq!(256, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_mul_ps() { + const unsafe fn test_mm512_reduce_mul_ps() { let a = _mm512_set1_ps(2.); let e: f32 = _mm512_reduce_mul_ps(a); assert_eq!(65536., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_mul_ps() { + const unsafe fn test_mm512_mask_reduce_mul_ps() { let a = _mm512_set1_ps(2.); let e: f32 = _mm512_mask_reduce_mul_ps(0b11111111_00000000, a); assert_eq!(256., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_max_epi32() { + const unsafe fn test_mm512_reduce_max_epi32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i32 = _mm512_reduce_max_epi32(a); assert_eq!(15, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_max_epi32() { + const unsafe fn test_mm512_mask_reduce_max_epi32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i32 = _mm512_mask_reduce_max_epi32(0b11111111_00000000, a); assert_eq!(7, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_max_epu32() { + const unsafe fn test_mm512_reduce_max_epu32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u32 = _mm512_reduce_max_epu32(a); assert_eq!(15, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_max_epu32() { + const unsafe fn test_mm512_mask_reduce_max_epu32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u32 = _mm512_mask_reduce_max_epu32(0b11111111_00000000, a); assert_eq!(7, e); @@ -56426,28 +58312,28 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_min_epi32() { + const unsafe fn test_mm512_reduce_min_epi32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i32 = _mm512_reduce_min_epi32(a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_min_epi32() { + const unsafe fn test_mm512_mask_reduce_min_epi32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i32 = _mm512_mask_reduce_min_epi32(0b11111111_00000000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_min_epu32() { + const unsafe fn test_mm512_reduce_min_epu32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u32 = _mm512_reduce_min_epu32(a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_min_epu32() { + const unsafe fn test_mm512_mask_reduce_min_epu32() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u32 = _mm512_mask_reduce_min_epu32(0b11111111_00000000, a); assert_eq!(0, e); @@ -56472,28 +58358,28 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_and_epi32() { + const unsafe fn test_mm512_reduce_and_epi32() { let a = _mm512_set_epi32(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e: i32 = _mm512_reduce_and_epi32(a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_and_epi32() { + const unsafe fn test_mm512_mask_reduce_and_epi32() { let a = _mm512_set_epi32(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e: i32 = _mm512_mask_reduce_and_epi32(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_or_epi32() { + const unsafe fn test_mm512_reduce_or_epi32() { let a = _mm512_set_epi32(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e: i32 = _mm512_reduce_or_epi32(a); assert_eq!(3, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_or_epi32() { + const unsafe fn test_mm512_mask_reduce_or_epi32() { let a = _mm512_set_epi32(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e: i32 = _mm512_mask_reduce_and_epi32(0b11111111_00000000, a); assert_eq!(1, e); @@ -56904,7 +58790,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_loadu_epi32() { + const unsafe fn test_mm512_loadu_epi32() { let a = &[4, 3, 2, 5, 8, 9, 64, 50, -4, -3, -2, -5, -8, -9, -64, -50]; let p = a.as_ptr(); let r = _mm512_loadu_epi32(black_box(p)); @@ -56913,7 +58799,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_loadu_epi32() { + const unsafe fn test_mm256_loadu_epi32() { let a = &[4, 3, 2, 5, 8, 9, 64, 50]; let p = a.as_ptr(); let r = _mm256_loadu_epi32(black_box(p)); @@ -56922,7 +58808,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_loadu_epi32() { + const unsafe fn test_mm_loadu_epi32() { let a = &[4, 3, 2, 5]; let p = a.as_ptr(); let r = _mm_loadu_epi32(black_box(p)); @@ -57126,7 +59012,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_storeu_epi32() { + const unsafe fn test_mm512_storeu_epi32() { let a = _mm512_set1_epi32(9); let mut r = _mm512_undefined_epi32(); _mm512_storeu_epi32(&mut r as *mut _ as *mut i32, a); @@ -57134,7 +59020,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_storeu_epi32() { + const unsafe fn test_mm256_storeu_epi32() { let a = _mm256_set1_epi32(9); let mut r = _mm256_undefined_si256(); _mm256_storeu_epi32(&mut r as *mut _ as *mut i32, a); @@ -57142,7 +59028,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_storeu_epi32() { + const unsafe fn test_mm_storeu_epi32() { let a = _mm_set1_epi32(9); let mut r = _mm_undefined_si128(); _mm_storeu_epi32(&mut r as *mut _ as *mut i32, a); @@ -57150,7 +59036,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_loadu_si512() { + const unsafe fn test_mm512_loadu_si512() { let a = &[4, 3, 2, 5, 8, 9, 64, 50, -4, -3, -2, -5, -8, -9, -64, -50]; let p = a.as_ptr().cast(); let r = _mm512_loadu_si512(black_box(p)); @@ -57159,7 +59045,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_storeu_si512() { + const unsafe fn test_mm512_storeu_si512() { let a = _mm512_set1_epi32(9); let mut r = _mm512_undefined_epi32(); _mm512_storeu_si512(&mut r as *mut _, a); @@ -57167,7 +59053,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_load_si512() { + const unsafe fn test_mm512_load_si512() { #[repr(align(64))] struct Align { data: [i32; 16], // 64 bytes @@ -57182,7 +59068,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_store_si512() { + const unsafe fn test_mm512_store_si512() { let a = _mm512_set1_epi32(9); let mut r = _mm512_undefined_epi32(); _mm512_store_si512(&mut r as *mut _, a); @@ -57190,7 +59076,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_load_epi32() { + const unsafe fn test_mm512_load_epi32() { #[repr(align(64))] struct Align { data: [i32; 16], // 64 bytes @@ -57205,7 +59091,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_load_epi32() { + const unsafe fn test_mm256_load_epi32() { #[repr(align(64))] struct Align { data: [i32; 8], @@ -57220,7 +59106,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_load_epi32() { + const unsafe fn test_mm_load_epi32() { #[repr(align(64))] struct Align { data: [i32; 4], @@ -57233,7 +59119,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_store_epi32() { + const unsafe fn test_mm512_store_epi32() { let a = _mm512_set1_epi32(9); let mut r = _mm512_undefined_epi32(); _mm512_store_epi32(&mut r as *mut _ as *mut i32, a); @@ -57241,7 +59127,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_store_epi32() { + const unsafe fn test_mm256_store_epi32() { let a = _mm256_set1_epi32(9); let mut r = _mm256_undefined_si256(); _mm256_store_epi32(&mut r as *mut _ as *mut i32, a); @@ -57249,7 +59135,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_store_epi32() { + const unsafe fn test_mm_store_epi32() { let a = _mm_set1_epi32(9); let mut r = _mm_undefined_si128(); _mm_store_epi32(&mut r as *mut _ as *mut i32, a); @@ -57257,7 +59143,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_load_ps() { + const unsafe fn test_mm512_load_ps() { #[repr(align(64))] struct Align { data: [f32; 16], // 64 bytes @@ -57276,7 +59162,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_store_ps() { + const unsafe fn test_mm512_store_ps() { let a = _mm512_set1_ps(9.); let mut r = _mm512_undefined_ps(); _mm512_store_ps(&mut r as *mut _ as *mut f32, a); @@ -57284,7 +59170,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_set1_epi32() { + const unsafe fn test_mm512_mask_set1_epi32() { let src = _mm512_set1_epi32(2); let a: i32 = 11; let r = _mm512_mask_set1_epi32(src, 0, a); @@ -57295,7 +59181,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_set1_epi32() { + const unsafe fn test_mm512_maskz_set1_epi32() { let a: i32 = 11; let r = _mm512_maskz_set1_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -57305,7 +59191,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_set1_epi32() { + const unsafe fn test_mm256_mask_set1_epi32() { let src = _mm256_set1_epi32(2); let a: i32 = 11; let r = _mm256_mask_set1_epi32(src, 0, a); @@ -57316,7 +59202,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_set1_epi32() { + const unsafe fn test_mm256_maskz_set1_epi32() { let a: i32 = 11; let r = _mm256_maskz_set1_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -57326,7 +59212,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_set1_epi32() { + const unsafe fn test_mm_mask_set1_epi32() { let src = _mm_set1_epi32(2); let a: i32 = 11; let r = _mm_mask_set1_epi32(src, 0, a); @@ -57337,7 +59223,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_set1_epi32() { + const unsafe fn test_mm_maskz_set1_epi32() { let a: i32 = 11; let r = _mm_maskz_set1_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -57347,7 +59233,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_move_ss() { + const unsafe fn test_mm_mask_move_ss() { let src = _mm_set_ps(10., 11., 100., 110.); let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); @@ -57360,7 +59246,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_move_ss() { + const unsafe fn test_mm_maskz_move_ss() { let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); let r = _mm_maskz_move_ss(0, a, b); @@ -57372,7 +59258,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_move_sd() { + const unsafe fn test_mm_mask_move_sd() { let src = _mm_set_pd(10., 11.); let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); @@ -57385,7 +59271,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_move_sd() { + const unsafe fn test_mm_maskz_move_sd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); let r = _mm_maskz_move_sd(0, a, b); @@ -57397,7 +59283,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_add_ss() { + const unsafe fn test_mm_mask_add_ss() { let src = _mm_set_ps(10., 11., 100., 110.); let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); @@ -57410,7 +59296,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_add_ss() { + const unsafe fn test_mm_maskz_add_ss() { let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); let r = _mm_maskz_add_ss(0, a, b); @@ -57422,7 +59308,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_add_sd() { + const unsafe fn test_mm_mask_add_sd() { let src = _mm_set_pd(10., 11.); let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); @@ -57435,7 +59321,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_add_sd() { + const unsafe fn test_mm_maskz_add_sd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); let r = _mm_maskz_add_sd(0, a, b); @@ -57447,7 +59333,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_sub_ss() { + const unsafe fn test_mm_mask_sub_ss() { let src = _mm_set_ps(10., 11., 100., 110.); let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); @@ -57460,7 +59346,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_sub_ss() { + const unsafe fn test_mm_maskz_sub_ss() { let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); let r = _mm_maskz_sub_ss(0, a, b); @@ -57472,7 +59358,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_sub_sd() { + const unsafe fn test_mm_mask_sub_sd() { let src = _mm_set_pd(10., 11.); let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); @@ -57485,7 +59371,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_sub_sd() { + const unsafe fn test_mm_maskz_sub_sd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); let r = _mm_maskz_sub_sd(0, a, b); @@ -57497,7 +59383,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_mul_ss() { + const unsafe fn test_mm_mask_mul_ss() { let src = _mm_set_ps(10., 11., 100., 110.); let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); @@ -57510,7 +59396,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_mul_ss() { + const unsafe fn test_mm_maskz_mul_ss() { let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); let r = _mm_maskz_mul_ss(0, a, b); @@ -57522,7 +59408,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_mul_sd() { + const unsafe fn test_mm_mask_mul_sd() { let src = _mm_set_pd(10., 11.); let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); @@ -57535,7 +59421,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_mul_sd() { + const unsafe fn test_mm_maskz_mul_sd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); let r = _mm_maskz_mul_sd(0, a, b); @@ -57547,7 +59433,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_div_ss() { + const unsafe fn test_mm_mask_div_ss() { let src = _mm_set_ps(10., 11., 100., 110.); let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); @@ -57560,7 +59446,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_div_ss() { + const unsafe fn test_mm_maskz_div_ss() { let a = _mm_set_ps(1., 2., 10., 20.); let b = _mm_set_ps(3., 4., 30., 40.); let r = _mm_maskz_div_ss(0, a, b); @@ -57572,7 +59458,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_div_sd() { + const unsafe fn test_mm_mask_div_sd() { let src = _mm_set_pd(10., 11.); let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); @@ -57585,7 +59471,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_div_sd() { + const unsafe fn test_mm_maskz_div_sd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(3., 4.); let r = _mm_maskz_div_sd(0, a, b); @@ -58143,7 +60029,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fmadd_ss() { + const unsafe fn test_mm_mask_fmadd_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58155,7 +60041,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fmadd_ss() { + const unsafe fn test_mm_maskz_fmadd_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58168,7 +60054,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fmadd_ss() { + const unsafe fn test_mm_mask3_fmadd_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58180,7 +60066,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fmadd_sd() { + const unsafe fn test_mm_mask_fmadd_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58192,7 +60078,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fmadd_sd() { + const unsafe fn test_mm_maskz_fmadd_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58205,7 +60091,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fmadd_sd() { + const unsafe fn test_mm_mask3_fmadd_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58217,7 +60103,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fmsub_ss() { + const unsafe fn test_mm_mask_fmsub_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58229,7 +60115,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fmsub_ss() { + const unsafe fn test_mm_maskz_fmsub_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58242,7 +60128,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fmsub_ss() { + const unsafe fn test_mm_mask3_fmsub_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58254,7 +60140,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fmsub_sd() { + const unsafe fn test_mm_mask_fmsub_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58266,7 +60152,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fmsub_sd() { + const unsafe fn test_mm_maskz_fmsub_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58279,7 +60165,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fmsub_sd() { + const unsafe fn test_mm_mask3_fmsub_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58291,7 +60177,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fnmadd_ss() { + const unsafe fn test_mm_mask_fnmadd_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58303,7 +60189,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fnmadd_ss() { + const unsafe fn test_mm_maskz_fnmadd_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58316,7 +60202,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fnmadd_ss() { + const unsafe fn test_mm_mask3_fnmadd_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58328,7 +60214,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fnmadd_sd() { + const unsafe fn test_mm_mask_fnmadd_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58340,7 +60226,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fnmadd_sd() { + const unsafe fn test_mm_maskz_fnmadd_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58353,7 +60239,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fnmadd_sd() { + const unsafe fn test_mm_mask3_fnmadd_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58365,7 +60251,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fnmsub_ss() { + const unsafe fn test_mm_mask_fnmsub_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58377,7 +60263,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fnmsub_ss() { + const unsafe fn test_mm_maskz_fnmsub_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58390,7 +60276,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fnmsub_ss() { + const unsafe fn test_mm_mask3_fnmsub_ss() { let a = _mm_set1_ps(1.); let b = _mm_set1_ps(2.); let c = _mm_set1_ps(3.); @@ -58402,7 +60288,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask_fnmsub_sd() { + const unsafe fn test_mm_mask_fnmsub_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58414,7 +60300,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_maskz_fnmsub_sd() { + const unsafe fn test_mm_maskz_fnmsub_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -58427,7 +60313,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_mask3_fnmsub_sd() { + const unsafe fn test_mm_mask3_fnmsub_sd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let c = _mm_set1_pd(3.); @@ -60082,7 +61968,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvti32_ss() { + const unsafe fn test_mm_cvti32_ss() { let a = _mm_set_ps(0., -0.5, 1., -1.5); let b: i32 = 9; let r = _mm_cvti32_ss(a, b); @@ -60091,7 +61977,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvti32_sd() { + const unsafe fn test_mm_cvti32_sd() { let a = _mm_set_pd(1., -1.5); let b: i32 = 9; let r = _mm_cvti32_sd(a, b); @@ -60180,7 +62066,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvtu32_ss() { + const unsafe fn test_mm_cvtu32_ss() { let a = _mm_set_ps(0., -0.5, 1., -1.5); let b: u32 = 9; let r = _mm_cvtu32_ss(a, b); @@ -60189,7 +62075,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvtu32_sd() { + const unsafe fn test_mm_cvtu32_sd() { let a = _mm_set_pd(1., -1.5); let b: u32 = 9; let r = _mm_cvtu32_sd(a, b); @@ -60216,7 +62102,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtsi512_si32() { + const unsafe fn test_mm512_cvtsi512_si32() { let a = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_cvtsi512_si32(a); let e: i32 = 1; @@ -60224,7 +62110,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtss_f32() { + const unsafe fn test_mm512_cvtss_f32() { let a = _mm512_setr_ps( 312.0134, 3., 2., 5., 8., 9., 64., 50., -4., -3., -2., -5., -8., -9., -64., -50., ); @@ -60232,13 +62118,13 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtsd_f64() { + const unsafe fn test_mm512_cvtsd_f64() { let r = _mm512_cvtsd_f64(_mm512_setr_pd(-1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8)); assert_eq!(r, -1.1); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_pd() { + const unsafe fn test_mm512_shuffle_pd() { let a = _mm512_setr_pd(1., 4., 5., 8., 1., 4., 5., 8.); let b = _mm512_setr_pd(2., 3., 6., 7., 2., 3., 6., 7.); let r = _mm512_shuffle_pd::<0b11_11_11_11>(a, b); @@ -60247,7 +62133,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_pd() { + const unsafe fn test_mm512_mask_shuffle_pd() { let a = _mm512_setr_pd(1., 4., 5., 8., 1., 4., 5., 8.); let b = _mm512_setr_pd(2., 3., 6., 7., 2., 3., 6., 7.); let r = _mm512_mask_shuffle_pd::<0b11_11_11_11>(a, 0, a, b); @@ -60258,7 +62144,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_pd() { + const unsafe fn test_mm512_maskz_shuffle_pd() { let a = _mm512_setr_pd(1., 4., 5., 8., 1., 4., 5., 8.); let b = _mm512_setr_pd(2., 3., 6., 7., 2., 3., 6., 7.); let r = _mm512_maskz_shuffle_pd::<0b11_11_11_11>(0, a, b); diff --git a/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs b/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs index a2656c853563..c85a5580c864 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs @@ -57,7 +57,8 @@ pub fn _mm_cvtsd_u64(a: __m128d) -> u64 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtsi2ss))] -pub fn _mm_cvti64_ss(a: __m128, b: i64) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvti64_ss(a: __m128, b: i64) -> __m128 { unsafe { let b = b as f32; simd_insert!(a, 0, b) @@ -71,7 +72,8 @@ pub fn _mm_cvti64_ss(a: __m128, b: i64) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtsi2sd))] -pub fn _mm_cvti64_sd(a: __m128d, b: i64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvti64_sd(a: __m128d, b: i64) -> __m128d { unsafe { let b = b as f64; simd_insert!(a, 0, b) @@ -85,7 +87,8 @@ pub fn _mm_cvti64_sd(a: __m128d, b: i64) -> __m128d { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtusi2ss))] -pub fn _mm_cvtu64_ss(a: __m128, b: u64) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtu64_ss(a: __m128, b: u64) -> __m128 { unsafe { let b = b as f32; simd_insert!(a, 0, b) @@ -99,7 +102,8 @@ pub fn _mm_cvtu64_ss(a: __m128, b: u64) -> __m128 { #[target_feature(enable = "avx512f")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vcvtusi2sd))] -pub fn _mm_cvtu64_sd(a: __m128d, b: u64) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtu64_sd(a: __m128d, b: u64) -> __m128d { unsafe { let b = b as f64; simd_insert!(a, 0, b) @@ -554,6 +558,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; @@ -562,7 +567,7 @@ mod tests { use crate::hint::black_box; #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_abs_epi64() { + const unsafe fn test_mm512_abs_epi64() { let a = _mm512_set_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let r = _mm512_abs_epi64(a); let e = _mm512_set_epi64(0, 1, 1, i64::MAX, i64::MAX.wrapping_add(1), 100, 100, 32); @@ -570,7 +575,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_abs_epi64() { + const unsafe fn test_mm512_mask_abs_epi64() { let a = _mm512_set_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let r = _mm512_mask_abs_epi64(a, 0, a); assert_eq_m512i(r, a); @@ -580,7 +585,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_abs_epi64() { + const unsafe fn test_mm512_maskz_abs_epi64() { let a = _mm512_set_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let r = _mm512_maskz_abs_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -590,7 +595,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_abs_epi64() { + const unsafe fn test_mm256_abs_epi64() { let a = _mm256_set_epi64x(i64::MAX, i64::MIN, 100, -100); let r = _mm256_abs_epi64(a); let e = _mm256_set_epi64x(i64::MAX, i64::MAX.wrapping_add(1), 100, 100); @@ -598,7 +603,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_abs_epi64() { + const unsafe fn test_mm256_mask_abs_epi64() { let a = _mm256_set_epi64x(i64::MAX, i64::MIN, 100, -100); let r = _mm256_mask_abs_epi64(a, 0, a); assert_eq_m256i(r, a); @@ -608,7 +613,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_abs_epi64() { + const unsafe fn test_mm256_maskz_abs_epi64() { let a = _mm256_set_epi64x(i64::MAX, i64::MIN, 100, -100); let r = _mm256_maskz_abs_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -618,7 +623,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_abs_epi64() { + const unsafe fn test_mm_abs_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let r = _mm_abs_epi64(a); let e = _mm_set_epi64x(i64::MAX, i64::MAX.wrapping_add(1)); @@ -630,7 +635,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_abs_epi64() { + const unsafe fn test_mm_mask_abs_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let r = _mm_mask_abs_epi64(a, 0, a); assert_eq_m128i(r, a); @@ -644,7 +649,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_abs_epi64() { + const unsafe fn test_mm_maskz_abs_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let r = _mm_maskz_abs_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -658,7 +663,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_abs_pd() { + const unsafe fn test_mm512_abs_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let r = _mm512_abs_pd(a); let e = _mm512_setr_pd(0., 1., 1., f64::MAX, f64::MAX, 100., 100., 32.); @@ -666,7 +671,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_abs_pd() { + const unsafe fn test_mm512_mask_abs_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let r = _mm512_mask_abs_pd(a, 0, a); assert_eq_m512d(r, a); @@ -676,7 +681,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mov_epi64() { + const unsafe fn test_mm512_mask_mov_epi64() { let src = _mm512_set1_epi64(1); let a = _mm512_set1_epi64(2); let r = _mm512_mask_mov_epi64(src, 0, a); @@ -686,7 +691,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mov_epi64() { + const unsafe fn test_mm512_maskz_mov_epi64() { let a = _mm512_set1_epi64(2); let r = _mm512_maskz_mov_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -695,7 +700,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mov_epi64() { + const unsafe fn test_mm256_mask_mov_epi64() { let src = _mm256_set1_epi64x(1); let a = _mm256_set1_epi64x(2); let r = _mm256_mask_mov_epi64(src, 0, a); @@ -705,7 +710,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mov_epi64() { + const unsafe fn test_mm256_maskz_mov_epi64() { let a = _mm256_set1_epi64x(2); let r = _mm256_maskz_mov_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -714,7 +719,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mov_epi64() { + const unsafe fn test_mm_mask_mov_epi64() { let src = _mm_set1_epi64x(1); let a = _mm_set1_epi64x(2); let r = _mm_mask_mov_epi64(src, 0, a); @@ -724,7 +729,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mov_epi64() { + const unsafe fn test_mm_maskz_mov_epi64() { let a = _mm_set1_epi64x(2); let r = _mm_maskz_mov_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -733,7 +738,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mov_pd() { + const unsafe fn test_mm512_mask_mov_pd() { let src = _mm512_set1_pd(1.); let a = _mm512_set1_pd(2.); let r = _mm512_mask_mov_pd(src, 0, a); @@ -743,7 +748,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mov_pd() { + const unsafe fn test_mm512_maskz_mov_pd() { let a = _mm512_set1_pd(2.); let r = _mm512_maskz_mov_pd(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -752,7 +757,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mov_pd() { + const unsafe fn test_mm256_mask_mov_pd() { let src = _mm256_set1_pd(1.); let a = _mm256_set1_pd(2.); let r = _mm256_mask_mov_pd(src, 0, a); @@ -762,7 +767,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mov_pd() { + const unsafe fn test_mm256_maskz_mov_pd() { let a = _mm256_set1_pd(2.); let r = _mm256_maskz_mov_pd(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -771,7 +776,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mov_pd() { + const unsafe fn test_mm_mask_mov_pd() { let src = _mm_set1_pd(1.); let a = _mm_set1_pd(2.); let r = _mm_mask_mov_pd(src, 0, a); @@ -781,7 +786,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mov_pd() { + const unsafe fn test_mm_maskz_mov_pd() { let a = _mm_set1_pd(2.); let r = _mm_maskz_mov_pd(0, a); assert_eq_m128d(r, _mm_setzero_pd()); @@ -790,7 +795,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_add_epi64() { + const unsafe fn test_mm512_add_epi64() { let a = _mm512_setr_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let b = _mm512_set1_epi64(1); let r = _mm512_add_epi64(a, b); @@ -799,7 +804,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_add_epi64() { + const unsafe fn test_mm512_mask_add_epi64() { let a = _mm512_setr_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let b = _mm512_set1_epi64(1); let r = _mm512_mask_add_epi64(a, 0, a, b); @@ -810,7 +815,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_add_epi64() { + const unsafe fn test_mm512_maskz_add_epi64() { let a = _mm512_setr_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let b = _mm512_set1_epi64(1); let r = _mm512_maskz_add_epi64(0, a, b); @@ -821,7 +826,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_add_epi64() { + const unsafe fn test_mm256_mask_add_epi64() { let a = _mm256_set_epi64x(1, -1, i64::MAX, i64::MIN); let b = _mm256_set1_epi64x(1); let r = _mm256_mask_add_epi64(a, 0, a, b); @@ -832,7 +837,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_add_epi64() { + const unsafe fn test_mm256_maskz_add_epi64() { let a = _mm256_set_epi64x(1, -1, i64::MAX, i64::MIN); let b = _mm256_set1_epi64x(1); let r = _mm256_maskz_add_epi64(0, a, b); @@ -843,7 +848,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_add_epi64() { + const unsafe fn test_mm_mask_add_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let b = _mm_set1_epi64x(1); let r = _mm_mask_add_epi64(a, 0, a, b); @@ -854,7 +859,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_add_epi64() { + const unsafe fn test_mm_maskz_add_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let b = _mm_set1_epi64x(1); let r = _mm_maskz_add_epi64(0, a, b); @@ -865,7 +870,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_add_pd() { + const unsafe fn test_mm512_add_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let b = _mm512_set1_pd(1.); let r = _mm512_add_pd(a, b); @@ -874,7 +879,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_add_pd() { + const unsafe fn test_mm512_mask_add_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let b = _mm512_set1_pd(1.); let r = _mm512_mask_add_pd(a, 0, a, b); @@ -885,7 +890,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_add_pd() { + const unsafe fn test_mm512_maskz_add_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let b = _mm512_set1_pd(1.); let r = _mm512_maskz_add_pd(0, a, b); @@ -896,7 +901,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_add_pd() { + const unsafe fn test_mm256_mask_add_pd() { let a = _mm256_set_pd(1., -1., f64::MAX, f64::MIN); let b = _mm256_set1_pd(1.); let r = _mm256_mask_add_pd(a, 0, a, b); @@ -907,7 +912,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_add_pd() { + const unsafe fn test_mm256_maskz_add_pd() { let a = _mm256_set_pd(1., -1., f64::MAX, f64::MIN); let b = _mm256_set1_pd(1.); let r = _mm256_maskz_add_pd(0, a, b); @@ -918,7 +923,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_add_pd() { + const unsafe fn test_mm_mask_add_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set1_pd(1.); let r = _mm_mask_add_pd(a, 0, a, b); @@ -929,7 +934,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_add_pd() { + const unsafe fn test_mm_maskz_add_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set1_pd(1.); let r = _mm_maskz_add_pd(0, a, b); @@ -940,7 +945,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_sub_epi64() { + const unsafe fn test_mm512_sub_epi64() { let a = _mm512_setr_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let b = _mm512_set1_epi64(1); let r = _mm512_sub_epi64(a, b); @@ -949,7 +954,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_sub_epi64() { + const unsafe fn test_mm512_mask_sub_epi64() { let a = _mm512_setr_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let b = _mm512_set1_epi64(1); let r = _mm512_mask_sub_epi64(a, 0, a, b); @@ -960,7 +965,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_sub_epi64() { + const unsafe fn test_mm512_maskz_sub_epi64() { let a = _mm512_setr_epi64(0, 1, -1, i64::MAX, i64::MIN, 100, -100, -32); let b = _mm512_set1_epi64(1); let r = _mm512_maskz_sub_epi64(0, a, b); @@ -971,7 +976,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_sub_epi64() { + const unsafe fn test_mm256_mask_sub_epi64() { let a = _mm256_set_epi64x(1, -1, i64::MAX, i64::MIN); let b = _mm256_set1_epi64x(1); let r = _mm256_mask_sub_epi64(a, 0, a, b); @@ -982,7 +987,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_sub_epi64() { + const unsafe fn test_mm256_maskz_sub_epi64() { let a = _mm256_set_epi64x(1, -1, i64::MAX, i64::MIN); let b = _mm256_set1_epi64x(1); let r = _mm256_maskz_sub_epi64(0, a, b); @@ -993,7 +998,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_sub_epi64() { + const unsafe fn test_mm_mask_sub_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let b = _mm_set1_epi64x(1); let r = _mm_mask_sub_epi64(a, 0, a, b); @@ -1004,7 +1009,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_sub_epi64() { + const unsafe fn test_mm_maskz_sub_epi64() { let a = _mm_set_epi64x(i64::MAX, i64::MIN); let b = _mm_set1_epi64x(1); let r = _mm_maskz_sub_epi64(0, a, b); @@ -1015,7 +1020,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_sub_pd() { + const unsafe fn test_mm512_sub_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let b = _mm512_set1_pd(1.); let r = _mm512_sub_pd(a, b); @@ -1024,7 +1029,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_sub_pd() { + const unsafe fn test_mm512_mask_sub_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let b = _mm512_set1_pd(1.); let r = _mm512_mask_sub_pd(a, 0, a, b); @@ -1035,7 +1040,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_sub_pd() { + const unsafe fn test_mm512_maskz_sub_pd() { let a = _mm512_setr_pd(0., 1., -1., f64::MAX, f64::MIN, 100., -100., -32.); let b = _mm512_set1_pd(1.); let r = _mm512_maskz_sub_pd(0, a, b); @@ -1046,7 +1051,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_sub_pd() { + const unsafe fn test_mm256_mask_sub_pd() { let a = _mm256_set_pd(1., -1., f64::MAX, f64::MIN); let b = _mm256_set1_pd(1.); let r = _mm256_mask_sub_pd(a, 0, a, b); @@ -1057,7 +1062,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_sub_pd() { + const unsafe fn test_mm256_maskz_sub_pd() { let a = _mm256_set_pd(1., -1., f64::MAX, f64::MIN); let b = _mm256_set1_pd(1.); let r = _mm256_maskz_sub_pd(0, a, b); @@ -1068,7 +1073,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_sub_pd() { + const unsafe fn test_mm_mask_sub_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set1_pd(1.); let r = _mm_mask_sub_pd(a, 0, a, b); @@ -1079,7 +1084,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_sub_pd() { + const unsafe fn test_mm_maskz_sub_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set1_pd(1.); let r = _mm_maskz_sub_pd(0, a, b); @@ -1090,7 +1095,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mul_epi32() { + const unsafe fn test_mm512_mul_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_mul_epi32(a, b); @@ -1099,7 +1104,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mul_epi32() { + const unsafe fn test_mm512_mask_mul_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_mask_mul_epi32(a, 0, a, b); @@ -1114,7 +1119,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mul_epi32() { + const unsafe fn test_mm512_maskz_mul_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_mul_epi32(0, a, b); @@ -1125,7 +1130,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mul_epi32() { + const unsafe fn test_mm256_mask_mul_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_mask_mul_epi32(a, 0, a, b); @@ -1136,7 +1141,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mul_epi32() { + const unsafe fn test_mm256_maskz_mul_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_maskz_mul_epi32(0, a, b); @@ -1147,7 +1152,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mul_epi32() { + const unsafe fn test_mm_mask_mul_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set_epi32(1, 2, 3, 4); let r = _mm_mask_mul_epi32(a, 0, a, b); @@ -1158,7 +1163,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mul_epi32() { + const unsafe fn test_mm_maskz_mul_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set_epi32(1, 2, 3, 4); let r = _mm_maskz_mul_epi32(0, a, b); @@ -1169,7 +1174,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mul_epu32() { + const unsafe fn test_mm512_mul_epu32() { let a = _mm512_set1_epi32(1); let b = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_mul_epu32(a, b); @@ -1178,7 +1183,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mul_epu32() { + const unsafe fn test_mm512_mask_mul_epu32() { let a = _mm512_set1_epi32(1); let b = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_mask_mul_epu32(a, 0, a, b); @@ -1193,7 +1198,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mul_epu32() { + const unsafe fn test_mm512_maskz_mul_epu32() { let a = _mm512_set1_epi32(1); let b = _mm512_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_mul_epu32(0, a, b); @@ -1204,7 +1209,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mul_epu32() { + const unsafe fn test_mm256_mask_mul_epu32() { let a = _mm256_set1_epi32(1); let b = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_mask_mul_epu32(a, 0, a, b); @@ -1215,7 +1220,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mul_epu32() { + const unsafe fn test_mm256_maskz_mul_epu32() { let a = _mm256_set1_epi32(1); let b = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm256_maskz_mul_epu32(0, a, b); @@ -1226,7 +1231,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mul_epu32() { + const unsafe fn test_mm_mask_mul_epu32() { let a = _mm_set1_epi32(1); let b = _mm_set_epi32(1, 2, 3, 4); let r = _mm_mask_mul_epu32(a, 0, a, b); @@ -1237,7 +1242,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mul_epu32() { + const unsafe fn test_mm_maskz_mul_epu32() { let a = _mm_set1_epi32(1); let b = _mm_set_epi32(1, 2, 3, 4); let r = _mm_maskz_mul_epu32(0, a, b); @@ -1248,7 +1253,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mullox_epi64() { + const unsafe fn test_mm512_mullox_epi64() { let a = _mm512_setr_epi64(0, 1, i64::MAX, i64::MIN, i64::MAX, 100, -100, -32); let b = _mm512_set1_epi64(2); let r = _mm512_mullox_epi64(a, b); @@ -1257,7 +1262,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mullox_epi64() { + const unsafe fn test_mm512_mask_mullox_epi64() { let a = _mm512_setr_epi64(0, 1, i64::MAX, i64::MIN, i64::MAX, 100, -100, -32); let b = _mm512_set1_epi64(2); let r = _mm512_mask_mullox_epi64(a, 0, a, b); @@ -1268,7 +1273,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mul_pd() { + const unsafe fn test_mm512_mul_pd() { let a = _mm512_setr_pd(0., 1., f64::MAX, f64::MIN, f64::MAX, f64::MIN, -100., -32.); let b = _mm512_set1_pd(2.); let r = _mm512_mul_pd(a, b); @@ -1281,7 +1286,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_mul_pd() { + const unsafe fn test_mm512_mask_mul_pd() { let a = _mm512_setr_pd(0., 1., f64::MAX, f64::MIN, f64::MAX, f64::MIN, -100., -32.); let b = _mm512_set1_pd(2.); let r = _mm512_mask_mul_pd(a, 0, a, b); @@ -1296,7 +1301,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_mul_pd() { + const unsafe fn test_mm512_maskz_mul_pd() { let a = _mm512_setr_pd(0., 1., f64::MAX, f64::MIN, f64::MAX, f64::MIN, -100., -32.); let b = _mm512_set1_pd(2.); let r = _mm512_maskz_mul_pd(0, a, b); @@ -1307,7 +1312,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_mul_pd() { + const unsafe fn test_mm256_mask_mul_pd() { let a = _mm256_set_pd(0., 1., f64::MAX, f64::MIN); let b = _mm256_set1_pd(2.); let r = _mm256_mask_mul_pd(a, 0, a, b); @@ -1318,7 +1323,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_mul_pd() { + const unsafe fn test_mm256_maskz_mul_pd() { let a = _mm256_set_pd(0., 1., f64::MAX, f64::MIN); let b = _mm256_set1_pd(2.); let r = _mm256_maskz_mul_pd(0, a, b); @@ -1329,7 +1334,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_mul_pd() { + const unsafe fn test_mm_mask_mul_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set1_pd(2.); let r = _mm_mask_mul_pd(a, 0, a, b); @@ -1340,7 +1345,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_mul_pd() { + const unsafe fn test_mm_maskz_mul_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set1_pd(2.); let r = _mm_maskz_mul_pd(0, a, b); @@ -1351,7 +1356,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_div_pd() { + const unsafe fn test_mm512_div_pd() { let a = _mm512_setr_pd(0., 1., f64::MAX, f64::MIN, f64::MAX, f64::MIN, -100., -32.); let b = _mm512_setr_pd(2., 2., 0., 0., 0., 0., 2., 2.); let r = _mm512_div_pd(a, b); @@ -1364,7 +1369,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_div_pd() { + const unsafe fn test_mm512_mask_div_pd() { let a = _mm512_setr_pd(0., 1., f64::MAX, f64::MIN, f64::MAX, f64::MIN, -100., -32.); let b = _mm512_setr_pd(2., 2., 0., 0., 0., 0., 2., 2.); let r = _mm512_mask_div_pd(a, 0, a, b); @@ -1379,7 +1384,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_div_pd() { + const unsafe fn test_mm512_maskz_div_pd() { let a = _mm512_setr_pd(0., 1., f64::MAX, f64::MIN, f64::MAX, f64::MIN, -100., -32.); let b = _mm512_setr_pd(2., 2., 0., 0., 0., 0., 2., 2.); let r = _mm512_maskz_div_pd(0, a, b); @@ -1390,7 +1395,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_div_pd() { + const unsafe fn test_mm256_mask_div_pd() { let a = _mm256_set_pd(0., 1., f64::MAX, f64::MIN); let b = _mm256_set_pd(2., 2., 0., 0.); let r = _mm256_mask_div_pd(a, 0, a, b); @@ -1401,7 +1406,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_div_pd() { + const unsafe fn test_mm256_maskz_div_pd() { let a = _mm256_set_pd(0., 1., f64::MAX, f64::MIN); let b = _mm256_set_pd(2., 2., 0., 0.); let r = _mm256_maskz_div_pd(0, a, b); @@ -1412,7 +1417,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_div_pd() { + const unsafe fn test_mm_mask_div_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set_pd(0., 0.); let r = _mm_mask_div_pd(a, 0, a, b); @@ -1423,7 +1428,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_div_pd() { + const unsafe fn test_mm_maskz_div_pd() { let a = _mm_set_pd(f64::MAX, f64::MIN); let b = _mm_set_pd(0., 0.); let r = _mm_maskz_div_pd(0, a, b); @@ -1434,7 +1439,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_max_epi64() { + const unsafe fn test_mm512_max_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_max_epi64(a, b); @@ -1443,7 +1448,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_max_epi64() { + const unsafe fn test_mm512_mask_max_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_max_epi64(a, 0, a, b); @@ -1454,7 +1459,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_max_epi64() { + const unsafe fn test_mm512_maskz_max_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_max_epi64(0, a, b); @@ -1465,7 +1470,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_max_epi64() { + const unsafe fn test_mm256_max_epi64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_max_epi64(a, b); @@ -1474,7 +1479,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_max_epi64() { + const unsafe fn test_mm256_mask_max_epi64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_mask_max_epi64(a, 0, a, b); @@ -1485,7 +1490,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_max_epi64() { + const unsafe fn test_mm256_maskz_max_epi64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_maskz_max_epi64(0, a, b); @@ -1496,7 +1501,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_max_epi64() { + const unsafe fn test_mm_max_epi64() { let a = _mm_set_epi64x(2, 3); let b = _mm_set_epi64x(3, 2); let r = _mm_max_epi64(a, b); @@ -1505,7 +1510,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_max_epi64() { + const unsafe fn test_mm_mask_max_epi64() { let a = _mm_set_epi64x(2, 3); let b = _mm_set_epi64x(3, 2); let r = _mm_mask_max_epi64(a, 0, a, b); @@ -1516,7 +1521,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_max_epi64() { + const unsafe fn test_mm_maskz_max_epi64() { let a = _mm_set_epi64x(2, 3); let b = _mm_set_epi64x(3, 2); let r = _mm_maskz_max_epi64(0, a, b); @@ -1602,7 +1607,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_max_epu64() { + const unsafe fn test_mm512_max_epu64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_max_epu64(a, b); @@ -1611,7 +1616,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_max_epu64() { + const unsafe fn test_mm512_mask_max_epu64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_max_epu64(a, 0, a, b); @@ -1622,7 +1627,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_max_epu64() { + const unsafe fn test_mm512_maskz_max_epu64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_max_epu64(0, a, b); @@ -1633,7 +1638,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_max_epu64() { + const unsafe fn test_mm256_max_epu64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_max_epu64(a, b); @@ -1642,7 +1647,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_max_epu64() { + const unsafe fn test_mm256_mask_max_epu64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_mask_max_epu64(a, 0, a, b); @@ -1653,7 +1658,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_max_epu64() { + const unsafe fn test_mm256_maskz_max_epu64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_maskz_max_epu64(0, a, b); @@ -1664,7 +1669,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_max_epu64() { + const unsafe fn test_mm_max_epu64() { let a = _mm_set_epi64x(2, 3); let b = _mm_set_epi64x(3, 2); let r = _mm_max_epu64(a, b); @@ -1673,7 +1678,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_max_epu64() { + const unsafe fn test_mm_mask_max_epu64() { let a = _mm_set_epi64x(2, 3); let b = _mm_set_epi64x(3, 2); let r = _mm_mask_max_epu64(a, 0, a, b); @@ -1684,7 +1689,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_max_epu64() { + const unsafe fn test_mm_maskz_max_epu64() { let a = _mm_set_epi64x(2, 3); let b = _mm_set_epi64x(3, 2); let r = _mm_maskz_max_epu64(0, a, b); @@ -1695,7 +1700,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_min_epi64() { + const unsafe fn test_mm512_min_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_min_epi64(a, b); @@ -1704,7 +1709,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_min_epi64() { + const unsafe fn test_mm512_mask_min_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_min_epi64(a, 0, a, b); @@ -1715,7 +1720,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_min_epi64() { + const unsafe fn test_mm512_maskz_min_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_min_epi64(0, a, b); @@ -1726,7 +1731,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_min_epi64() { + const unsafe fn test_mm256_min_epi64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_min_epi64(a, b); @@ -1735,7 +1740,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_min_epi64() { + const unsafe fn test_mm256_mask_min_epi64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_mask_min_epi64(a, 0, a, b); @@ -1746,7 +1751,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_min_epi64() { + const unsafe fn test_mm256_maskz_min_epi64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_maskz_min_epi64(0, a, b); @@ -1757,7 +1762,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_min_epi64() { + const unsafe fn test_mm_min_epi64() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(3, 2); let r = _mm_min_epi64(a, b); @@ -1771,7 +1776,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_min_epi64() { + const unsafe fn test_mm_mask_min_epi64() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(3, 2); let r = _mm_mask_min_epi64(a, 0, a, b); @@ -1782,7 +1787,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_min_epi64() { + const unsafe fn test_mm_maskz_min_epi64() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(3, 2); let r = _mm_maskz_min_epi64(0, a, b); @@ -1868,7 +1873,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_min_epu64() { + const unsafe fn test_mm512_min_epu64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_min_epu64(a, b); @@ -1877,7 +1882,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_min_epu64() { + const unsafe fn test_mm512_mask_min_epu64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_mask_min_epu64(a, 0, a, b); @@ -1888,7 +1893,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_min_epu64() { + const unsafe fn test_mm512_maskz_min_epu64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm512_maskz_min_epu64(0, a, b); @@ -1899,7 +1904,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_min_epu64() { + const unsafe fn test_mm256_min_epu64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_min_epu64(a, b); @@ -1908,7 +1913,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_min_epu64() { + const unsafe fn test_mm256_mask_min_epu64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_mask_min_epu64(a, 0, a, b); @@ -1919,7 +1924,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_min_epu64() { + const unsafe fn test_mm256_maskz_min_epu64() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_maskz_min_epu64(0, a, b); @@ -1930,7 +1935,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_min_epu64() { + const unsafe fn test_mm_min_epu64() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(1, 0); let r = _mm_min_epu64(a, b); @@ -1939,7 +1944,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_min_epu64() { + const unsafe fn test_mm_mask_min_epu64() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(1, 0); let r = _mm_mask_min_epu64(a, 0, a, b); @@ -1950,7 +1955,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_min_epu64() { + const unsafe fn test_mm_maskz_min_epu64() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(1, 0); let r = _mm_maskz_min_epu64(0, a, b); @@ -2029,7 +2034,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmadd_pd() { + const unsafe fn test_mm512_fmadd_pd() { let a = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); @@ -2039,7 +2044,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmadd_pd() { + const unsafe fn test_mm512_mask_fmadd_pd() { let a = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); @@ -2051,7 +2056,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmadd_pd() { + const unsafe fn test_mm512_maskz_fmadd_pd() { let a = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); @@ -2063,7 +2068,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmadd_pd() { + const unsafe fn test_mm512_mask3_fmadd_pd() { let a = _mm512_setr_pd(1., 1., 1., 1., 1., 1., 1., 1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 2., 2., 2., 2.); @@ -2075,7 +2080,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmadd_pd() { + const unsafe fn test_mm256_mask_fmadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2087,7 +2092,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmadd_pd() { + const unsafe fn test_mm256_maskz_fmadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2099,7 +2104,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmadd_pd() { + const unsafe fn test_mm256_mask3_fmadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2111,7 +2116,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmadd_pd() { + const unsafe fn test_mm_mask_fmadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2123,7 +2128,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmadd_pd() { + const unsafe fn test_mm_maskz_fmadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2135,7 +2140,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmadd_pd() { + const unsafe fn test_mm_mask3_fmadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2147,7 +2152,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmsub_pd() { + const unsafe fn test_mm512_fmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2157,7 +2162,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmsub_pd() { + const unsafe fn test_mm512_mask_fmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2169,7 +2174,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmsub_pd() { + const unsafe fn test_mm512_maskz_fmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2181,7 +2186,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmsub_pd() { + const unsafe fn test_mm512_mask3_fmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 2., 2., 2., 2.); @@ -2193,7 +2198,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmsub_pd() { + const unsafe fn test_mm256_mask_fmsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2205,7 +2210,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmsub_pd() { + const unsafe fn test_mm256_maskz_fmsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2217,7 +2222,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmsub_pd() { + const unsafe fn test_mm256_mask3_fmsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2229,7 +2234,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmsub_pd() { + const unsafe fn test_mm_mask_fmsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2241,7 +2246,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmsub_pd() { + const unsafe fn test_mm_maskz_fmsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2253,7 +2258,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmsub_pd() { + const unsafe fn test_mm_mask3_fmsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2265,7 +2270,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmaddsub_pd() { + const unsafe fn test_mm512_fmaddsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2275,7 +2280,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmaddsub_pd() { + const unsafe fn test_mm512_mask_fmaddsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2287,7 +2292,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmaddsub_pd() { + const unsafe fn test_mm512_maskz_fmaddsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2299,7 +2304,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmaddsub_pd() { + const unsafe fn test_mm512_mask3_fmaddsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 2., 2., 2., 2.); @@ -2311,7 +2316,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmaddsub_pd() { + const unsafe fn test_mm256_mask_fmaddsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2323,7 +2328,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmaddsub_pd() { + const unsafe fn test_mm256_maskz_fmaddsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2335,7 +2340,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmaddsub_pd() { + const unsafe fn test_mm256_mask3_fmaddsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2347,7 +2352,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmaddsub_pd() { + const unsafe fn test_mm_mask_fmaddsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2359,7 +2364,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmaddsub_pd() { + const unsafe fn test_mm_maskz_fmaddsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2371,7 +2376,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmaddsub_pd() { + const unsafe fn test_mm_mask3_fmaddsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2383,7 +2388,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fmsubadd_pd() { + const unsafe fn test_mm512_fmsubadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2393,7 +2398,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fmsubadd_pd() { + const unsafe fn test_mm512_mask_fmsubadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2405,7 +2410,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fmsubadd_pd() { + const unsafe fn test_mm512_maskz_fmsubadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2417,7 +2422,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fmsubadd_pd() { + const unsafe fn test_mm512_mask3_fmsubadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 2., 2., 2., 2.); @@ -2429,7 +2434,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fmsubadd_pd() { + const unsafe fn test_mm256_mask_fmsubadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2441,7 +2446,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fmsubadd_pd() { + const unsafe fn test_mm256_maskz_fmsubadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2453,7 +2458,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fmsubadd_pd() { + const unsafe fn test_mm256_mask3_fmsubadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2465,7 +2470,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fmsubadd_pd() { + const unsafe fn test_mm_mask_fmsubadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2477,7 +2482,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fmsubadd_pd() { + const unsafe fn test_mm_maskz_fmsubadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2489,7 +2494,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fmsubadd_pd() { + const unsafe fn test_mm_mask3_fmsubadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2501,7 +2506,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fnmadd_pd() { + const unsafe fn test_mm512_fnmadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2511,7 +2516,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fnmadd_pd() { + const unsafe fn test_mm512_mask_fnmadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2523,7 +2528,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fnmadd_pd() { + const unsafe fn test_mm512_maskz_fnmadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2535,7 +2540,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fnmadd_pd() { + const unsafe fn test_mm512_mask3_fnmadd_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 2., 2., 2., 2.); @@ -2547,7 +2552,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fnmadd_pd() { + const unsafe fn test_mm256_mask_fnmadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2559,7 +2564,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fnmadd_pd() { + const unsafe fn test_mm256_maskz_fnmadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2571,7 +2576,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fnmadd_pd() { + const unsafe fn test_mm256_mask3_fnmadd_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2583,7 +2588,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fnmadd_pd() { + const unsafe fn test_mm_mask_fnmadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2595,7 +2600,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fnmadd_pd() { + const unsafe fn test_mm_maskz_fnmadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2607,7 +2612,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fnmadd_pd() { + const unsafe fn test_mm_mask3_fnmadd_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2619,7 +2624,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_fnmsub_pd() { + const unsafe fn test_mm512_fnmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2629,7 +2634,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_fnmsub_pd() { + const unsafe fn test_mm512_mask_fnmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2641,7 +2646,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_fnmsub_pd() { + const unsafe fn test_mm512_maskz_fnmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_set1_pd(1.); @@ -2653,7 +2658,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask3_fnmsub_pd() { + const unsafe fn test_mm512_mask3_fnmsub_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let c = _mm512_setr_pd(1., 1., 1., 1., 2., 2., 2., 2.); @@ -2665,7 +2670,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_fnmsub_pd() { + const unsafe fn test_mm256_mask_fnmsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2677,7 +2682,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_fnmsub_pd() { + const unsafe fn test_mm256_maskz_fnmsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2689,7 +2694,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask3_fnmsub_pd() { + const unsafe fn test_mm256_mask3_fnmsub_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set_pd(0., 1., 2., 3.); let c = _mm256_set1_pd(1.); @@ -2701,7 +2706,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_fnmsub_pd() { + const unsafe fn test_mm_mask_fnmsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2713,7 +2718,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_fnmsub_pd() { + const unsafe fn test_mm_maskz_fnmsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -2725,7 +2730,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask3_fnmsub_pd() { + const unsafe fn test_mm_mask3_fnmsub_pd() { let a = _mm_set1_pd(1.); let b = _mm_set_pd(0., 1.); let c = _mm_set1_pd(1.); @@ -3764,7 +3769,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi8_epi64() { + const unsafe fn test_mm512_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi8_epi64(a); let e = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); @@ -3772,7 +3777,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi8_epi64() { + const unsafe fn test_mm512_mask_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi64(-1); let r = _mm512_mask_cvtepi8_epi64(src, 0, a); @@ -3783,7 +3788,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi8_epi64() { + const unsafe fn test_mm512_maskz_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi8_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -3793,7 +3798,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi8_epi64() { + const unsafe fn test_mm256_mask_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi64x(-1); let r = _mm256_mask_cvtepi8_epi64(src, 0, a); @@ -3804,7 +3809,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi8_epi64() { + const unsafe fn test_mm256_maskz_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepi8_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -3814,7 +3819,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi8_epi64() { + const unsafe fn test_mm_mask_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi64x(-1); let r = _mm_mask_cvtepi8_epi64(src, 0, a); @@ -3825,7 +3830,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi8_epi64() { + const unsafe fn test_mm_maskz_cvtepi8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepi8_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -3835,7 +3840,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu8_epi64() { + const unsafe fn test_mm512_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu8_epi64(a); let e = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); @@ -3843,7 +3848,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu8_epi64() { + const unsafe fn test_mm512_mask_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi64(-1); let r = _mm512_mask_cvtepu8_epi64(src, 0, a); @@ -3854,7 +3859,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu8_epi64() { + const unsafe fn test_mm512_maskz_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu8_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -3864,7 +3869,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepu8_epi64() { + const unsafe fn test_mm256_mask_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi64x(-1); let r = _mm256_mask_cvtepu8_epi64(src, 0, a); @@ -3875,7 +3880,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu8_epi64() { + const unsafe fn test_mm256_maskz_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepu8_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -3885,7 +3890,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepu8_epi64() { + const unsafe fn test_mm_mask_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi64x(-1); let r = _mm_mask_cvtepu8_epi64(src, 0, a); @@ -3896,7 +3901,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepu8_epi64() { + const unsafe fn test_mm_maskz_cvtepu8_epi64() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepu8_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -3906,7 +3911,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi16_epi64() { + const unsafe fn test_mm512_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi16_epi64(a); let e = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); @@ -3914,7 +3919,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi16_epi64() { + const unsafe fn test_mm512_mask_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi64(-1); let r = _mm512_mask_cvtepi16_epi64(src, 0, a); @@ -3925,7 +3930,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi16_epi64() { + const unsafe fn test_mm512_maskz_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi16_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -3935,7 +3940,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi16_epi64() { + const unsafe fn test_mm256_mask_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi64x(-1); let r = _mm256_mask_cvtepi16_epi64(src, 0, a); @@ -3946,7 +3951,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi16_epi64() { + const unsafe fn test_mm256_maskz_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepi16_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -3956,7 +3961,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi16_epi64() { + const unsafe fn test_mm_mask_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi64x(-1); let r = _mm_mask_cvtepi16_epi64(src, 0, a); @@ -3967,7 +3972,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi16_epi64() { + const unsafe fn test_mm_maskz_cvtepi16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepi16_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -3977,7 +3982,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu16_epi64() { + const unsafe fn test_mm512_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu16_epi64(a); let e = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); @@ -3985,7 +3990,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu16_epi64() { + const unsafe fn test_mm512_mask_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi64(-1); let r = _mm512_mask_cvtepu16_epi64(src, 0, a); @@ -3996,7 +4001,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu16_epi64() { + const unsafe fn test_mm512_maskz_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu16_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -4006,7 +4011,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepu16_epi64() { + const unsafe fn test_mm256_mask_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi64x(-1); let r = _mm256_mask_cvtepu16_epi64(src, 0, a); @@ -4017,7 +4022,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu16_epi64() { + const unsafe fn test_mm256_maskz_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_cvtepu16_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -4027,7 +4032,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepu16_epi64() { + const unsafe fn test_mm_mask_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi64x(-1); let r = _mm_mask_cvtepu16_epi64(src, 0, a); @@ -4038,7 +4043,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepu16_epi64() { + const unsafe fn test_mm_maskz_cvtepu16_epi64() { let a = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm_maskz_cvtepu16_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -4048,7 +4053,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi32_epi64() { + const unsafe fn test_mm512_cvtepi32_epi64() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi32_epi64(a); let e = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); @@ -4056,7 +4061,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi32_epi64() { + const unsafe fn test_mm512_mask_cvtepi32_epi64() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi64(-1); let r = _mm512_mask_cvtepi32_epi64(src, 0, a); @@ -4067,7 +4072,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi32_epi64() { + const unsafe fn test_mm512_maskz_cvtepi32_epi64() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi32_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -4077,7 +4082,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi32_epi64() { + const unsafe fn test_mm256_mask_cvtepi32_epi64() { let a = _mm_set_epi32(8, 9, 10, 11); let src = _mm256_set1_epi64x(-1); let r = _mm256_mask_cvtepi32_epi64(src, 0, a); @@ -4088,7 +4093,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi32_epi64() { + const unsafe fn test_mm256_maskz_cvtepi32_epi64() { let a = _mm_set_epi32(8, 9, 10, 11); let r = _mm256_maskz_cvtepi32_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -4098,7 +4103,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi32_epi64() { + const unsafe fn test_mm_mask_cvtepi32_epi64() { let a = _mm_set_epi32(8, 9, 10, 11); let src = _mm_set1_epi64x(0); let r = _mm_mask_cvtepi32_epi64(src, 0, a); @@ -4109,7 +4114,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi32_epi64() { + const unsafe fn test_mm_maskz_cvtepi32_epi64() { let a = _mm_set_epi32(8, 9, 10, 11); let r = _mm_maskz_cvtepi32_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -4119,7 +4124,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu32_epi64() { + const unsafe fn test_mm512_cvtepu32_epi64() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu32_epi64(a); let e = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); @@ -4127,7 +4132,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu32_epi64() { + const unsafe fn test_mm512_mask_cvtepu32_epi64() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_epi64(-1); let r = _mm512_mask_cvtepu32_epi64(src, 0, a); @@ -4138,7 +4143,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu32_epi64() { + const unsafe fn test_mm512_maskz_cvtepu32_epi64() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu32_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -4148,7 +4153,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepu32_epi64() { + const unsafe fn test_mm256_mask_cvtepu32_epi64() { let a = _mm_set_epi32(12, 13, 14, 15); let src = _mm256_set1_epi64x(-1); let r = _mm256_mask_cvtepu32_epi64(src, 0, a); @@ -4159,7 +4164,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu32_epi64() { + const unsafe fn test_mm256_maskz_cvtepu32_epi64() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm256_maskz_cvtepu32_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -4169,7 +4174,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepu32_epi64() { + const unsafe fn test_mm_mask_cvtepu32_epi64() { let a = _mm_set_epi32(12, 13, 14, 15); let src = _mm_set1_epi64x(-1); let r = _mm_mask_cvtepu32_epi64(src, 0, a); @@ -4180,7 +4185,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepu32_epi64() { + const unsafe fn test_mm_maskz_cvtepu32_epi64() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm_maskz_cvtepu32_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -4190,7 +4195,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi32_pd() { + const unsafe fn test_mm512_cvtepi32_pd() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi32_pd(a); let e = _mm512_set_pd(8., 9., 10., 11., 12., 13., 14., 15.); @@ -4198,7 +4203,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi32_pd() { + const unsafe fn test_mm512_mask_cvtepi32_pd() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_pd(-1.); let r = _mm512_mask_cvtepi32_pd(src, 0, a); @@ -4209,7 +4214,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi32_pd() { + const unsafe fn test_mm512_maskz_cvtepi32_pd() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi32_pd(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -4219,7 +4224,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi32_pd() { + const unsafe fn test_mm256_mask_cvtepi32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let src = _mm256_set1_pd(-1.); let r = _mm256_mask_cvtepi32_pd(src, 0, a); @@ -4230,7 +4235,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi32_pd() { + const unsafe fn test_mm256_maskz_cvtepi32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm256_maskz_cvtepi32_pd(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -4240,7 +4245,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepi32_pd() { + const unsafe fn test_mm_mask_cvtepi32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let src = _mm_set1_pd(-1.); let r = _mm_mask_cvtepi32_pd(src, 0, a); @@ -4251,7 +4256,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepi32_pd() { + const unsafe fn test_mm_maskz_cvtepi32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm_maskz_cvtepi32_pd(0, a); assert_eq_m128d(r, _mm_setzero_pd()); @@ -4261,7 +4266,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu32_pd() { + const unsafe fn test_mm512_cvtepu32_pd() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu32_pd(a); let e = _mm512_set_pd(8., 9., 10., 11., 12., 13., 14., 15.); @@ -4269,7 +4274,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu32_pd() { + const unsafe fn test_mm512_mask_cvtepu32_pd() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_pd(-1.); let r = _mm512_mask_cvtepu32_pd(src, 0, a); @@ -4280,7 +4285,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepu32_pd() { + const unsafe fn test_mm512_maskz_cvtepu32_pd() { let a = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepu32_pd(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -4290,7 +4295,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cvtepu32_pd() { + const unsafe fn test_mm256_cvtepu32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm256_cvtepu32_pd(a); let e = _mm256_set_pd(12., 13., 14., 15.); @@ -4298,7 +4303,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepu32_pd() { + const unsafe fn test_mm256_mask_cvtepu32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let src = _mm256_set1_pd(-1.); let r = _mm256_mask_cvtepu32_pd(src, 0, a); @@ -4309,7 +4314,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu32_pd() { + const unsafe fn test_mm256_maskz_cvtepu32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm256_maskz_cvtepu32_pd(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -4319,7 +4324,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cvtepu32_pd() { + const unsafe fn test_mm_cvtepu32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm_cvtepu32_pd(a); let e = _mm_set_pd(14., 15.); @@ -4327,7 +4332,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cvtepu32_pd() { + const unsafe fn test_mm_mask_cvtepu32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let src = _mm_set1_pd(-1.); let r = _mm_mask_cvtepu32_pd(src, 0, a); @@ -4338,7 +4343,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_cvtepu32_pd() { + const unsafe fn test_mm_maskz_cvtepu32_pd() { let a = _mm_set_epi32(12, 13, 14, 15); let r = _mm_maskz_cvtepu32_pd(0, a); assert_eq_m128d(r, _mm_setzero_pd()); @@ -4348,7 +4353,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi32lo_pd() { + const unsafe fn test_mm512_cvtepi32lo_pd() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi32lo_pd(a); let e = _mm512_set_pd(8., 9., 10., 11., 12., 13., 14., 15.); @@ -4356,7 +4361,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi32lo_pd() { + const unsafe fn test_mm512_mask_cvtepi32lo_pd() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_pd(-1.); let r = _mm512_mask_cvtepi32lo_pd(src, 0, a); @@ -4367,7 +4372,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepu32lo_pd() { + const unsafe fn test_mm512_cvtepu32lo_pd() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepu32lo_pd(a); let e = _mm512_set_pd(8., 9., 10., 11., 12., 13., 14., 15.); @@ -4375,7 +4380,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepu32lo_pd() { + const unsafe fn test_mm512_mask_cvtepu32lo_pd() { let a = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let src = _mm512_set1_pd(-1.); let r = _mm512_mask_cvtepu32lo_pd(src, 0, a); @@ -4386,7 +4391,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi64_epi32() { + const unsafe fn test_mm512_cvtepi64_epi32() { let a = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi64_epi32(a); let e = _mm256_set_epi32(8, 9, 10, 11, 12, 13, 14, 15); @@ -4394,7 +4399,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi64_epi32() { + const unsafe fn test_mm512_mask_cvtepi64_epi32() { let a = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm256_set1_epi32(-1); let r = _mm512_mask_cvtepi64_epi32(src, 0, a); @@ -4405,7 +4410,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi64_epi32() { + const unsafe fn test_mm512_maskz_cvtepi64_epi32() { let a = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi64_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -4415,7 +4420,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cvtepi64_epi32() { + const unsafe fn test_mm256_cvtepi64_epi32() { let a = _mm256_set_epi64x(1, 2, 3, 4); let r = _mm256_cvtepi64_epi32(a); let e = _mm_set_epi32(1, 2, 3, 4); @@ -4423,7 +4428,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cvtepi64_epi32() { + const unsafe fn test_mm256_mask_cvtepi64_epi32() { let a = _mm256_set_epi64x(1, 2, 3, 4); let src = _mm_set1_epi32(0); let r = _mm256_mask_cvtepi64_epi32(src, 0, a); @@ -4434,7 +4439,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi64_epi32() { + const unsafe fn test_mm256_maskz_cvtepi64_epi32() { let a = _mm256_set_epi64x(1, 2, 3, 4); let r = _mm256_maskz_cvtepi64_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -4473,7 +4478,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cvtepi64_epi16() { + const unsafe fn test_mm512_cvtepi64_epi16() { let a = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_cvtepi64_epi16(a); let e = _mm_set_epi16(8, 9, 10, 11, 12, 13, 14, 15); @@ -4481,7 +4486,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cvtepi64_epi16() { + const unsafe fn test_mm512_mask_cvtepi64_epi16() { let a = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); let src = _mm_set1_epi16(-1); let r = _mm512_mask_cvtepi64_epi16(src, 0, a); @@ -4492,7 +4497,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_cvtepi64_epi16() { + const unsafe fn test_mm512_maskz_cvtepi64_epi16() { let a = _mm512_set_epi64(8, 9, 10, 11, 12, 13, 14, 15); let r = _mm512_maskz_cvtepi64_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -6449,42 +6454,42 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setzero_pd() { + const unsafe fn test_mm512_setzero_pd() { assert_eq_m512d(_mm512_setzero_pd(), _mm512_set1_pd(0.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set1_epi64() { + const unsafe fn test_mm512_set1_epi64() { let r = _mm512_set_epi64(2, 2, 2, 2, 2, 2, 2, 2); assert_eq_m512i(r, _mm512_set1_epi64(2)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set1_pd() { + const unsafe fn test_mm512_set1_pd() { let expected = _mm512_set_pd(2., 2., 2., 2., 2., 2., 2., 2.); assert_eq_m512d(expected, _mm512_set1_pd(2.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set4_epi64() { + const unsafe fn test_mm512_set4_epi64() { let r = _mm512_set_epi64(4, 3, 2, 1, 4, 3, 2, 1); assert_eq_m512i(r, _mm512_set4_epi64(4, 3, 2, 1)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set4_pd() { + const unsafe fn test_mm512_set4_pd() { let r = _mm512_set_pd(4., 3., 2., 1., 4., 3., 2., 1.); assert_eq_m512d(r, _mm512_set4_pd(4., 3., 2., 1.)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr4_epi64() { + const unsafe fn test_mm512_setr4_epi64() { let r = _mm512_set_epi64(4, 3, 2, 1, 4, 3, 2, 1); assert_eq_m512i(r, _mm512_setr4_epi64(1, 2, 3, 4)); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr4_pd() { + const unsafe fn test_mm512_setr4_pd() { let r = _mm512_set_pd(4., 3., 2., 1., 4., 3., 2., 1.); assert_eq_m512d(r, _mm512_setr4_pd(1., 2., 3., 4.)); } @@ -6709,7 +6714,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmplt_epu64_mask() { + const unsafe fn test_mm512_cmplt_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let m = _mm512_cmplt_epu64_mask(a, b); @@ -6717,7 +6722,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmplt_epu64_mask() { + const unsafe fn test_mm512_mask_cmplt_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01111010; @@ -6726,7 +6731,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmplt_epu64_mask() { + const unsafe fn test_mm256_cmplt_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, 100); let b = _mm256_set1_epi64x(2); let r = _mm256_cmplt_epu64_mask(a, b); @@ -6734,7 +6739,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epu64_mask() { + const unsafe fn test_mm256_mask_cmplt_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, 100); let b = _mm256_set1_epi64x(2); let mask = 0b11111111; @@ -6743,7 +6748,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmplt_epu64_mask() { + const unsafe fn test_mm_cmplt_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(2); let r = _mm_cmplt_epu64_mask(a, b); @@ -6751,7 +6756,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmplt_epu64_mask() { + const unsafe fn test_mm_mask_cmplt_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(2); let mask = 0b11111111; @@ -6760,7 +6765,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpgt_epu64_mask() { + const unsafe fn test_mm512_cmpgt_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let m = _mm512_cmpgt_epu64_mask(b, a); @@ -6768,7 +6773,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpgt_epu64_mask() { + const unsafe fn test_mm512_mask_cmpgt_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01111010; @@ -6777,7 +6782,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpgt_epu64_mask() { + const unsafe fn test_mm256_cmpgt_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set1_epi64x(1); let r = _mm256_cmpgt_epu64_mask(a, b); @@ -6785,7 +6790,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epu64_mask() { + const unsafe fn test_mm256_mask_cmpgt_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, 3); let b = _mm256_set1_epi64x(1); let mask = 0b11111111; @@ -6794,7 +6799,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpgt_epu64_mask() { + const unsafe fn test_mm_cmpgt_epu64_mask() { let a = _mm_set_epi64x(1, 2); let b = _mm_set1_epi64x(1); let r = _mm_cmpgt_epu64_mask(a, b); @@ -6802,7 +6807,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epu64_mask() { + const unsafe fn test_mm_mask_cmpgt_epu64_mask() { let a = _mm_set_epi64x(1, 2); let b = _mm_set1_epi64x(1); let mask = 0b11111111; @@ -6811,7 +6816,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmple_epu64_mask() { + const unsafe fn test_mm512_cmple_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); assert_eq!( @@ -6821,7 +6826,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmple_epu64_mask() { + const unsafe fn test_mm512_mask_cmple_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01111010; @@ -6829,7 +6834,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmple_epu64_mask() { + const unsafe fn test_mm256_cmple_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, 1); let b = _mm256_set1_epi64x(1); let r = _mm256_cmple_epu64_mask(a, b); @@ -6837,7 +6842,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmple_epu64_mask() { + const unsafe fn test_mm256_mask_cmple_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, 1); let b = _mm256_set1_epi64x(1); let mask = 0b11111111; @@ -6846,7 +6851,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmple_epu64_mask() { + const unsafe fn test_mm_cmple_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let r = _mm_cmple_epu64_mask(a, b); @@ -6854,7 +6859,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmple_epu64_mask() { + const unsafe fn test_mm_mask_cmple_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let mask = 0b11111111; @@ -6863,7 +6868,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpge_epu64_mask() { + const unsafe fn test_mm512_cmpge_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); assert_eq!( @@ -6873,7 +6878,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpge_epu64_mask() { + const unsafe fn test_mm512_mask_cmpge_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b11111111; @@ -6882,7 +6887,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpge_epu64_mask() { + const unsafe fn test_mm256_cmpge_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, u64::MAX as i64); let b = _mm256_set1_epi64x(1); let r = _mm256_cmpge_epu64_mask(a, b); @@ -6890,7 +6895,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epu64_mask() { + const unsafe fn test_mm256_mask_cmpge_epu64_mask() { let a = _mm256_set_epi64x(0, 1, 2, u64::MAX as i64); let b = _mm256_set1_epi64x(1); let mask = 0b11111111; @@ -6899,7 +6904,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpge_epu64_mask() { + const unsafe fn test_mm_cmpge_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let r = _mm_cmpge_epu64_mask(a, b); @@ -6907,7 +6912,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpge_epu64_mask() { + const unsafe fn test_mm_mask_cmpge_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let mask = 0b11111111; @@ -6916,7 +6921,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpeq_epu64_mask() { + const unsafe fn test_mm512_cmpeq_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let m = _mm512_cmpeq_epu64_mask(b, a); @@ -6924,7 +6929,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpeq_epu64_mask() { + const unsafe fn test_mm512_mask_cmpeq_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let mask = 0b01111010; @@ -6933,7 +6938,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpeq_epu64_mask() { + const unsafe fn test_mm256_cmpeq_epu64_mask() { let a = _mm256_set_epi64x(0, 1, -1, u64::MAX as i64); let b = _mm256_set_epi64x(0, 1, 13, 42); let m = _mm256_cmpeq_epu64_mask(b, a); @@ -6941,7 +6946,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epu64_mask() { + const unsafe fn test_mm256_mask_cmpeq_epu64_mask() { let a = _mm256_set_epi64x(0, 1, -1, u64::MAX as i64); let b = _mm256_set_epi64x(0, 1, 13, 42); let mask = 0b11111111; @@ -6950,7 +6955,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpeq_epu64_mask() { + const unsafe fn test_mm_cmpeq_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(0, 1); let m = _mm_cmpeq_epu64_mask(b, a); @@ -6958,7 +6963,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epu64_mask() { + const unsafe fn test_mm_mask_cmpeq_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(0, 1); let mask = 0b11111111; @@ -6967,7 +6972,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpneq_epu64_mask() { + const unsafe fn test_mm512_cmpneq_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let m = _mm512_cmpneq_epu64_mask(b, a); @@ -6975,7 +6980,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpneq_epu64_mask() { + const unsafe fn test_mm512_mask_cmpneq_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, -100, 100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let mask = 0b01111010; @@ -6984,7 +6989,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpneq_epu64_mask() { + const unsafe fn test_mm256_cmpneq_epu64_mask() { let a = _mm256_set_epi64x(0, 1, -1, u64::MAX as i64); let b = _mm256_set_epi64x(0, 1, 13, 42); let r = _mm256_cmpneq_epu64_mask(b, a); @@ -6992,7 +6997,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epu64_mask() { + const unsafe fn test_mm256_mask_cmpneq_epu64_mask() { let a = _mm256_set_epi64x(0, 1, -1, u64::MAX as i64); let b = _mm256_set_epi64x(0, 1, 13, 42); let mask = 0b11111111; @@ -7001,7 +7006,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpneq_epu64_mask() { + const unsafe fn test_mm_cmpneq_epu64_mask() { let a = _mm_set_epi64x(-1, u64::MAX as i64); let b = _mm_set_epi64x(13, 42); let r = _mm_cmpneq_epu64_mask(b, a); @@ -7009,7 +7014,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epu64_mask() { + const unsafe fn test_mm_mask_cmpneq_epu64_mask() { let a = _mm_set_epi64x(-1, u64::MAX as i64); let b = _mm_set_epi64x(13, 42); let mask = 0b11111111; @@ -7018,7 +7023,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmp_epu64_mask() { + const unsafe fn test_mm512_cmp_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let m = _mm512_cmp_epu64_mask::<_MM_CMPINT_LT>(a, b); @@ -7026,7 +7031,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmp_epu64_mask() { + const unsafe fn test_mm512_mask_cmp_epu64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01111010; @@ -7035,7 +7040,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmp_epu64_mask() { + const unsafe fn test_mm256_cmp_epu64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 100); let b = _mm256_set1_epi64x(1); let m = _mm256_cmp_epu64_mask::<_MM_CMPINT_LT>(a, b); @@ -7043,7 +7048,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmp_epu64_mask() { + const unsafe fn test_mm256_mask_cmp_epu64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 100); let b = _mm256_set1_epi64x(1); let mask = 0b11111111; @@ -7052,7 +7057,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmp_epu64_mask() { + const unsafe fn test_mm_cmp_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let m = _mm_cmp_epu64_mask::<_MM_CMPINT_LT>(a, b); @@ -7060,7 +7065,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmp_epu64_mask() { + const unsafe fn test_mm_mask_cmp_epu64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let mask = 0b11111111; @@ -7069,7 +7074,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmplt_epi64_mask() { + const unsafe fn test_mm512_cmplt_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let m = _mm512_cmplt_epi64_mask(a, b); @@ -7077,7 +7082,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmplt_epi64_mask() { + const unsafe fn test_mm512_mask_cmplt_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01100110; @@ -7086,7 +7091,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmplt_epi64_mask() { + const unsafe fn test_mm256_cmplt_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, -13); let b = _mm256_set1_epi64x(-1); let r = _mm256_cmplt_epi64_mask(a, b); @@ -7094,7 +7099,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epi64_mask() { + const unsafe fn test_mm256_mask_cmplt_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, -13); let b = _mm256_set1_epi64x(-1); let mask = 0b11111111; @@ -7103,7 +7108,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmplt_epi64_mask() { + const unsafe fn test_mm_cmplt_epi64_mask() { let a = _mm_set_epi64x(-1, -13); let b = _mm_set1_epi64x(-1); let r = _mm_cmplt_epi64_mask(a, b); @@ -7111,7 +7116,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmplt_epi64_mask() { + const unsafe fn test_mm_mask_cmplt_epi64_mask() { let a = _mm_set_epi64x(-1, -13); let b = _mm_set1_epi64x(-1); let mask = 0b11111111; @@ -7120,7 +7125,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpgt_epi64_mask() { + const unsafe fn test_mm512_cmpgt_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let m = _mm512_cmpgt_epi64_mask(b, a); @@ -7128,7 +7133,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpgt_epi64_mask() { + const unsafe fn test_mm512_mask_cmpgt_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01100110; @@ -7137,7 +7142,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpgt_epi64_mask() { + const unsafe fn test_mm256_cmpgt_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set1_epi64x(-1); let r = _mm256_cmpgt_epi64_mask(a, b); @@ -7145,7 +7150,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epi64_mask() { + const unsafe fn test_mm256_mask_cmpgt_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set1_epi64x(-1); let mask = 0b11111111; @@ -7154,7 +7159,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpgt_epi64_mask() { + const unsafe fn test_mm_cmpgt_epi64_mask() { let a = _mm_set_epi64x(0, -1); let b = _mm_set1_epi64x(-1); let r = _mm_cmpgt_epi64_mask(a, b); @@ -7162,7 +7167,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epi64_mask() { + const unsafe fn test_mm_mask_cmpgt_epi64_mask() { let a = _mm_set_epi64x(0, -1); let b = _mm_set1_epi64x(-1); let mask = 0b11111111; @@ -7171,7 +7176,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmple_epi64_mask() { + const unsafe fn test_mm512_cmple_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); assert_eq!( @@ -7181,7 +7186,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmple_epi64_mask() { + const unsafe fn test_mm512_mask_cmple_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01111010; @@ -7189,7 +7194,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmple_epi64_mask() { + const unsafe fn test_mm256_cmple_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, i64::MAX); let b = _mm256_set1_epi64x(-1); let r = _mm256_cmple_epi64_mask(a, b); @@ -7197,7 +7202,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmple_epi64_mask() { + const unsafe fn test_mm256_mask_cmple_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, i64::MAX); let b = _mm256_set1_epi64x(-1); let mask = 0b11111111; @@ -7206,7 +7211,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmple_epi64_mask() { + const unsafe fn test_mm_cmple_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let r = _mm_cmple_epi64_mask(a, b); @@ -7214,7 +7219,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmple_epi64_mask() { + const unsafe fn test_mm_mask_cmple_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let mask = 0b11111111; @@ -7223,7 +7228,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpge_epi64_mask() { + const unsafe fn test_mm512_cmpge_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); assert_eq!( @@ -7233,7 +7238,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpge_epi64_mask() { + const unsafe fn test_mm512_mask_cmpge_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, u64::MAX as i64, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b11111111; @@ -7242,7 +7247,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpge_epi64_mask() { + const unsafe fn test_mm256_cmpge_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, i64::MAX); let b = _mm256_set1_epi64x(-1); let r = _mm256_cmpge_epi64_mask(a, b); @@ -7250,7 +7255,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epi64_mask() { + const unsafe fn test_mm256_mask_cmpge_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, i64::MAX); let b = _mm256_set1_epi64x(-1); let mask = 0b11111111; @@ -7259,7 +7264,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpge_epi64_mask() { + const unsafe fn test_mm_cmpge_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(-1); let r = _mm_cmpge_epi64_mask(a, b); @@ -7267,7 +7272,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpge_epi64_mask() { + const unsafe fn test_mm_mask_cmpge_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(-1); let mask = 0b11111111; @@ -7276,7 +7281,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpeq_epi64_mask() { + const unsafe fn test_mm512_cmpeq_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let m = _mm512_cmpeq_epi64_mask(b, a); @@ -7284,7 +7289,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpeq_epi64_mask() { + const unsafe fn test_mm512_mask_cmpeq_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let mask = 0b01111010; @@ -7293,7 +7298,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpeq_epi64_mask() { + const unsafe fn test_mm256_cmpeq_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set_epi64x(0, 1, 13, 42); let m = _mm256_cmpeq_epi64_mask(b, a); @@ -7301,7 +7306,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epi64_mask() { + const unsafe fn test_mm256_mask_cmpeq_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set_epi64x(0, 1, 13, 42); let mask = 0b11111111; @@ -7310,7 +7315,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpeq_epi64_mask() { + const unsafe fn test_mm_cmpeq_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(0, 1); let m = _mm_cmpeq_epi64_mask(b, a); @@ -7318,7 +7323,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epi64_mask() { + const unsafe fn test_mm_mask_cmpeq_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set_epi64x(0, 1); let mask = 0b11111111; @@ -7327,19 +7332,19 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_set_epi64() { + const unsafe fn test_mm512_set_epi64() { let r = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); assert_eq_m512i(r, _mm512_set_epi64(7, 6, 5, 4, 3, 2, 1, 0)) } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_setr_epi64() { + const unsafe fn test_mm512_setr_epi64() { let r = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); assert_eq_m512i(r, _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0)) } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmpneq_epi64_mask() { + const unsafe fn test_mm512_cmpneq_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let m = _mm512_cmpneq_epi64_mask(b, a); @@ -7347,7 +7352,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmpneq_epi64_mask() { + const unsafe fn test_mm512_mask_cmpneq_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, -100, 100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); let mask = 0b01111010; @@ -7356,7 +7361,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmpneq_epi64_mask() { + const unsafe fn test_mm256_cmpneq_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set_epi64x(0, 1, 13, 42); let r = _mm256_cmpneq_epi64_mask(b, a); @@ -7364,7 +7369,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epi64_mask() { + const unsafe fn test_mm256_mask_cmpneq_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set_epi64x(0, 1, 13, 42); let mask = 0b11111111; @@ -7373,7 +7378,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmpneq_epi64_mask() { + const unsafe fn test_mm_cmpneq_epi64_mask() { let a = _mm_set_epi64x(-1, 13); let b = _mm_set_epi64x(13, 42); let r = _mm_cmpneq_epi64_mask(b, a); @@ -7381,7 +7386,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epi64_mask() { + const unsafe fn test_mm_mask_cmpneq_epi64_mask() { let a = _mm_set_epi64x(-1, 13); let b = _mm_set_epi64x(13, 42); let mask = 0b11111111; @@ -7390,7 +7395,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_cmp_epi64_mask() { + const unsafe fn test_mm512_cmp_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let m = _mm512_cmp_epi64_mask::<_MM_CMPINT_LT>(a, b); @@ -7398,7 +7403,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_cmp_epi64_mask() { + const unsafe fn test_mm512_mask_cmp_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set1_epi64(-1); let mask = 0b01100110; @@ -7407,7 +7412,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_cmp_epi64_mask() { + const unsafe fn test_mm256_cmp_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set1_epi64x(1); let m = _mm256_cmp_epi64_mask::<_MM_CMPINT_LT>(a, b); @@ -7415,7 +7420,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_cmp_epi64_mask() { + const unsafe fn test_mm256_mask_cmp_epi64_mask() { let a = _mm256_set_epi64x(0, 1, -1, 13); let b = _mm256_set1_epi64x(1); let mask = 0b11111111; @@ -7424,7 +7429,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_cmp_epi64_mask() { + const unsafe fn test_mm_cmp_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let m = _mm_cmp_epi64_mask::<_MM_CMPINT_LT>(a, b); @@ -7432,7 +7437,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_cmp_epi64_mask() { + const unsafe fn test_mm_mask_cmp_epi64_mask() { let a = _mm_set_epi64x(0, 1); let b = _mm_set1_epi64x(1); let mask = 0b11111111; @@ -8313,7 +8318,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_rol_epi64() { + const unsafe fn test_mm512_rol_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 63, 1 << 32, 1 << 32, 1 << 32, @@ -8329,7 +8334,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_rol_epi64() { + const unsafe fn test_mm512_mask_rol_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 63, 1 << 32, 1 << 32, 1 << 32, @@ -8347,7 +8352,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_rol_epi64() { + const unsafe fn test_mm512_maskz_rol_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8361,7 +8366,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_rol_epi64() { + const unsafe fn test_mm256_rol_epi64() { let a = _mm256_set_epi64x(1 << 63, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_rol_epi64::<1>(a); let e = _mm256_set_epi64x(1 << 0, 1 << 33, 1 << 33, 1 << 33); @@ -8369,7 +8374,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_rol_epi64() { + const unsafe fn test_mm256_mask_rol_epi64() { let a = _mm256_set_epi64x(1 << 63, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_mask_rol_epi64::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -8379,7 +8384,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_rol_epi64() { + const unsafe fn test_mm256_maskz_rol_epi64() { let a = _mm256_set_epi64x(1 << 63, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_maskz_rol_epi64::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -8389,7 +8394,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_rol_epi64() { + const unsafe fn test_mm_rol_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let r = _mm_rol_epi64::<1>(a); let e = _mm_set_epi64x(1 << 0, 1 << 33); @@ -8397,7 +8402,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_rol_epi64() { + const unsafe fn test_mm_mask_rol_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let r = _mm_mask_rol_epi64::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -8407,7 +8412,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_rol_epi64() { + const unsafe fn test_mm_maskz_rol_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let r = _mm_maskz_rol_epi64::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -8417,7 +8422,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_ror_epi64() { + const unsafe fn test_mm512_ror_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 0, 1 << 32, 1 << 32, 1 << 32, @@ -8433,7 +8438,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_ror_epi64() { + const unsafe fn test_mm512_mask_ror_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 0, 1 << 32, 1 << 32, 1 << 32, @@ -8451,7 +8456,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_ror_epi64() { + const unsafe fn test_mm512_maskz_ror_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8465,7 +8470,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_ror_epi64() { + const unsafe fn test_mm256_ror_epi64() { let a = _mm256_set_epi64x(1 << 0, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_ror_epi64::<1>(a); let e = _mm256_set_epi64x(1 << 63, 1 << 31, 1 << 31, 1 << 31); @@ -8473,7 +8478,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_ror_epi64() { + const unsafe fn test_mm256_mask_ror_epi64() { let a = _mm256_set_epi64x(1 << 0, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_mask_ror_epi64::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -8483,7 +8488,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_ror_epi64() { + const unsafe fn test_mm256_maskz_ror_epi64() { let a = _mm256_set_epi64x(1 << 0, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_maskz_ror_epi64::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -8493,7 +8498,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_ror_epi64() { + const unsafe fn test_mm_ror_epi64() { let a = _mm_set_epi64x(1 << 0, 1 << 32); let r = _mm_ror_epi64::<1>(a); let e = _mm_set_epi64x(1 << 63, 1 << 31); @@ -8501,7 +8506,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_ror_epi64() { + const unsafe fn test_mm_mask_ror_epi64() { let a = _mm_set_epi64x(1 << 0, 1 << 32); let r = _mm_mask_ror_epi64::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -8511,7 +8516,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_ror_epi64() { + const unsafe fn test_mm_maskz_ror_epi64() { let a = _mm_set_epi64x(1 << 0, 1 << 32); let r = _mm_maskz_ror_epi64::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -8521,7 +8526,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_slli_epi64() { + const unsafe fn test_mm512_slli_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 63, 1 << 32, 1 << 32, 1 << 32, @@ -8537,7 +8542,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_slli_epi64() { + const unsafe fn test_mm512_mask_slli_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 63, 1 << 32, 1 << 32, 1 << 32, @@ -8555,7 +8560,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_slli_epi64() { + const unsafe fn test_mm512_maskz_slli_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8569,7 +8574,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_slli_epi64() { + const unsafe fn test_mm256_mask_slli_epi64() { let a = _mm256_set_epi64x(1 << 63, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_mask_slli_epi64::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -8579,7 +8584,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_slli_epi64() { + const unsafe fn test_mm256_maskz_slli_epi64() { let a = _mm256_set_epi64x(1 << 63, 1 << 32, 1 << 32, 1 << 32); let r = _mm256_maskz_slli_epi64::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -8589,7 +8594,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_slli_epi64() { + const unsafe fn test_mm_mask_slli_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let r = _mm_mask_slli_epi64::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -8599,7 +8604,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_slli_epi64() { + const unsafe fn test_mm_maskz_slli_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let r = _mm_maskz_slli_epi64::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -8609,7 +8614,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srli_epi64() { + const unsafe fn test_mm512_srli_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 0, 1 << 32, 1 << 32, 1 << 32, @@ -8625,7 +8630,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srli_epi64() { + const unsafe fn test_mm512_mask_srli_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 0, 1 << 32, 1 << 32, 1 << 32, @@ -8643,7 +8648,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srli_epi64() { + const unsafe fn test_mm512_maskz_srli_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8657,7 +8662,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srli_epi64() { + const unsafe fn test_mm256_mask_srli_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let r = _mm256_mask_srli_epi64::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -8667,7 +8672,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srli_epi64() { + const unsafe fn test_mm256_maskz_srli_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let r = _mm256_maskz_srli_epi64::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -8677,7 +8682,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srli_epi64() { + const unsafe fn test_mm_mask_srli_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let r = _mm_mask_srli_epi64::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -8687,7 +8692,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srli_epi64() { + const unsafe fn test_mm_maskz_srli_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let r = _mm_maskz_srli_epi64::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -8697,7 +8702,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_rolv_epi64() { + const unsafe fn test_mm512_rolv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 63, 1 << 32, 1 << 32, @@ -8714,7 +8719,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_rolv_epi64() { + const unsafe fn test_mm512_mask_rolv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 63, 1 << 32, 1 << 32, @@ -8733,7 +8738,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_rolv_epi64() { + const unsafe fn test_mm512_maskz_rolv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8748,7 +8753,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_rolv_epi64() { + const unsafe fn test_mm256_rolv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 63, 1 << 32, 1 << 32); let b = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_rolv_epi64(a, b); @@ -8757,7 +8762,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_rolv_epi64() { + const unsafe fn test_mm256_mask_rolv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 63, 1 << 32, 1 << 32); let b = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_mask_rolv_epi64(a, 0, a, b); @@ -8768,7 +8773,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_rolv_epi64() { + const unsafe fn test_mm256_maskz_rolv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 63, 1 << 32, 1 << 32); let b = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_maskz_rolv_epi64(0, a, b); @@ -8779,7 +8784,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_rolv_epi64() { + const unsafe fn test_mm_rolv_epi64() { let a = _mm_set_epi64x(1 << 32, 1 << 63); let b = _mm_set_epi64x(0, 1); let r = _mm_rolv_epi64(a, b); @@ -8788,7 +8793,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_rolv_epi64() { + const unsafe fn test_mm_mask_rolv_epi64() { let a = _mm_set_epi64x(1 << 32, 1 << 63); let b = _mm_set_epi64x(0, 1); let r = _mm_mask_rolv_epi64(a, 0, a, b); @@ -8799,7 +8804,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_rolv_epi64() { + const unsafe fn test_mm_maskz_rolv_epi64() { let a = _mm_set_epi64x(1 << 32, 1 << 63); let b = _mm_set_epi64x(0, 1); let r = _mm_maskz_rolv_epi64(0, a, b); @@ -8810,7 +8815,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_rorv_epi64() { + const unsafe fn test_mm512_rorv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 0, 1 << 32, 1 << 32, @@ -8827,7 +8832,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_rorv_epi64() { + const unsafe fn test_mm512_mask_rorv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 0, 1 << 32, 1 << 32, @@ -8846,7 +8851,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_rorv_epi64() { + const unsafe fn test_mm512_maskz_rorv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8861,7 +8866,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_rorv_epi64() { + const unsafe fn test_mm256_rorv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 0, 1 << 32, 1 << 32); let b = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_rorv_epi64(a, b); @@ -8870,7 +8875,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_rorv_epi64() { + const unsafe fn test_mm256_mask_rorv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 0, 1 << 32, 1 << 32); let b = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_mask_rorv_epi64(a, 0, a, b); @@ -8881,7 +8886,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_rorv_epi64() { + const unsafe fn test_mm256_maskz_rorv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 0, 1 << 32, 1 << 32); let b = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_maskz_rorv_epi64(0, a, b); @@ -8892,7 +8897,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_rorv_epi64() { + const unsafe fn test_mm_rorv_epi64() { let a = _mm_set_epi64x(1 << 32, 1 << 0); let b = _mm_set_epi64x(0, 1); let r = _mm_rorv_epi64(a, b); @@ -8901,7 +8906,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_rorv_epi64() { + const unsafe fn test_mm_mask_rorv_epi64() { let a = _mm_set_epi64x(1 << 32, 1 << 0); let b = _mm_set_epi64x(0, 1); let r = _mm_mask_rorv_epi64(a, 0, a, b); @@ -8912,7 +8917,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_rorv_epi64() { + const unsafe fn test_mm_maskz_rorv_epi64() { let a = _mm_set_epi64x(1 << 32, 1 << 0); let b = _mm_set_epi64x(0, 1); let r = _mm_maskz_rorv_epi64(0, a, b); @@ -8923,7 +8928,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_sllv_epi64() { + const unsafe fn test_mm512_sllv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 63, 1 << 32, 1 << 32, @@ -8940,7 +8945,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_sllv_epi64() { + const unsafe fn test_mm512_mask_sllv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 63, 1 << 32, @@ -8959,7 +8964,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_sllv_epi64() { + const unsafe fn test_mm512_maskz_sllv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -8974,7 +8979,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_sllv_epi64() { + const unsafe fn test_mm256_mask_sllv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 32, 1 << 63, 1 << 32); let count = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_mask_sllv_epi64(a, 0, a, count); @@ -8985,7 +8990,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_sllv_epi64() { + const unsafe fn test_mm256_maskz_sllv_epi64() { let a = _mm256_set_epi64x(1 << 32, 1 << 32, 1 << 63, 1 << 32); let count = _mm256_set_epi64x(0, 1, 2, 3); let r = _mm256_maskz_sllv_epi64(0, a, count); @@ -8996,7 +9001,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_sllv_epi64() { + const unsafe fn test_mm_mask_sllv_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let count = _mm_set_epi64x(2, 3); let r = _mm_mask_sllv_epi64(a, 0, a, count); @@ -9007,7 +9012,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_sllv_epi64() { + const unsafe fn test_mm_maskz_sllv_epi64() { let a = _mm_set_epi64x(1 << 63, 1 << 32); let count = _mm_set_epi64x(2, 3); let r = _mm_maskz_sllv_epi64(0, a, count); @@ -9018,7 +9023,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srlv_epi64() { + const unsafe fn test_mm512_srlv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 0, 1 << 32, 1 << 32, @@ -9035,7 +9040,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srlv_epi64() { + const unsafe fn test_mm512_mask_srlv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 0, 1 << 32, 1 << 32, @@ -9054,7 +9059,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srlv_epi64() { + const unsafe fn test_mm512_maskz_srlv_epi64() { #[rustfmt::skip] let a = _mm512_set_epi64( 1 << 32, 1 << 32, 1 << 32, 1 << 32, @@ -9069,7 +9074,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srlv_epi64() { + const unsafe fn test_mm256_mask_srlv_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let count = _mm256_set1_epi64x(1); let r = _mm256_mask_srlv_epi64(a, 0, a, count); @@ -9080,7 +9085,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srlv_epi64() { + const unsafe fn test_mm256_maskz_srlv_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let count = _mm256_set1_epi64x(1); let r = _mm256_maskz_srlv_epi64(0, a, count); @@ -9091,7 +9096,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srlv_epi64() { + const unsafe fn test_mm_mask_srlv_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let count = _mm_set1_epi64x(1); let r = _mm_mask_srlv_epi64(a, 0, a, count); @@ -9102,7 +9107,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srlv_epi64() { + const unsafe fn test_mm_maskz_srlv_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let count = _mm_set1_epi64x(1); let r = _mm_maskz_srlv_epi64(0, a, count); @@ -9399,7 +9404,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srav_epi64() { + const unsafe fn test_mm512_srav_epi64() { let a = _mm512_set_epi64(1, -8, 0, 0, 0, 0, 15, -16); let count = _mm512_set_epi64(2, 2, 0, 0, 0, 0, 2, 1); let r = _mm512_srav_epi64(a, count); @@ -9408,7 +9413,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srav_epi64() { + const unsafe fn test_mm512_mask_srav_epi64() { let a = _mm512_set_epi64(1, -8, 0, 0, 0, 0, 15, -16); let count = _mm512_set_epi64(2, 2, 0, 0, 0, 0, 2, 1); let r = _mm512_mask_srav_epi64(a, 0, a, count); @@ -9419,7 +9424,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srav_epi64() { + const unsafe fn test_mm512_maskz_srav_epi64() { let a = _mm512_set_epi64(1, -8, 0, 0, 0, 0, 15, -16); let count = _mm512_set_epi64(2, 2, 0, 0, 0, 0, 2, 1); let r = _mm512_maskz_srav_epi64(0, a, count); @@ -9430,7 +9435,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_srav_epi64() { + const unsafe fn test_mm256_srav_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let count = _mm256_set1_epi64x(1); let r = _mm256_srav_epi64(a, count); @@ -9439,7 +9444,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srav_epi64() { + const unsafe fn test_mm256_mask_srav_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let count = _mm256_set1_epi64x(1); let r = _mm256_mask_srav_epi64(a, 0, a, count); @@ -9450,7 +9455,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srav_epi64() { + const unsafe fn test_mm256_maskz_srav_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let count = _mm256_set1_epi64x(1); let r = _mm256_maskz_srav_epi64(0, a, count); @@ -9461,7 +9466,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_srav_epi64() { + const unsafe fn test_mm_srav_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let count = _mm_set1_epi64x(1); let r = _mm_srav_epi64(a, count); @@ -9470,7 +9475,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srav_epi64() { + const unsafe fn test_mm_mask_srav_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let count = _mm_set1_epi64x(1); let r = _mm_mask_srav_epi64(a, 0, a, count); @@ -9481,7 +9486,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srav_epi64() { + const unsafe fn test_mm_maskz_srav_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let count = _mm_set1_epi64x(1); let r = _mm_maskz_srav_epi64(0, a, count); @@ -9492,7 +9497,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_srai_epi64() { + const unsafe fn test_mm512_srai_epi64() { let a = _mm512_set_epi64(1, -4, 15, 0, 0, 0, 0, -16); let r = _mm512_srai_epi64::<2>(a); let e = _mm512_set_epi64(0, -1, 3, 0, 0, 0, 0, -4); @@ -9500,7 +9505,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_srai_epi64() { + const unsafe fn test_mm512_mask_srai_epi64() { let a = _mm512_set_epi64(1, -4, 15, 0, 0, 0, 0, -16); let r = _mm512_mask_srai_epi64::<2>(a, 0, a); assert_eq_m512i(r, a); @@ -9510,7 +9515,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_srai_epi64() { + const unsafe fn test_mm512_maskz_srai_epi64() { let a = _mm512_set_epi64(1, -4, 15, 0, 0, 0, 0, -16); let r = _mm512_maskz_srai_epi64::<2>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -9520,7 +9525,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_srai_epi64() { + const unsafe fn test_mm256_srai_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let r = _mm256_srai_epi64::<1>(a); let e = _mm256_set_epi64x(1 << 4, 0, 0, 0); @@ -9528,7 +9533,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_srai_epi64() { + const unsafe fn test_mm256_mask_srai_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let r = _mm256_mask_srai_epi64::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -9538,7 +9543,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_srai_epi64() { + const unsafe fn test_mm256_maskz_srai_epi64() { let a = _mm256_set_epi64x(1 << 5, 0, 0, 0); let r = _mm256_maskz_srai_epi64::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -9548,7 +9553,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_srai_epi64() { + const unsafe fn test_mm_srai_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let r = _mm_srai_epi64::<1>(a); let e = _mm_set_epi64x(1 << 4, 0); @@ -9556,7 +9561,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_srai_epi64() { + const unsafe fn test_mm_mask_srai_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let r = _mm_mask_srai_epi64::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -9566,7 +9571,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_srai_epi64() { + const unsafe fn test_mm_maskz_srai_epi64() { let a = _mm_set_epi64x(1 << 5, 0); let r = _mm_maskz_srai_epi64::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -9576,7 +9581,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_permute_pd() { + const unsafe fn test_mm512_permute_pd() { let a = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm512_permute_pd::<0b11_11_11_11>(a); let e = _mm512_setr_pd(1., 1., 3., 3., 5., 5., 7., 7.); @@ -9584,7 +9589,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_permute_pd() { + const unsafe fn test_mm512_mask_permute_pd() { let a = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm512_mask_permute_pd::<0b11_11_11_11>(a, 0, a); assert_eq_m512d(r, a); @@ -9594,7 +9599,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_permute_pd() { + const unsafe fn test_mm512_maskz_permute_pd() { let a = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm512_maskz_permute_pd::<0b11_11_11_11>(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -9604,7 +9609,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_permute_pd() { + const unsafe fn test_mm256_mask_permute_pd() { let a = _mm256_set_pd(3., 2., 1., 0.); let r = _mm256_mask_permute_pd::<0b11_11>(a, 0, a); assert_eq_m256d(r, a); @@ -9614,7 +9619,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_permute_pd() { + const unsafe fn test_mm256_maskz_permute_pd() { let a = _mm256_set_pd(3., 2., 1., 0.); let r = _mm256_maskz_permute_pd::<0b11_11>(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -9624,7 +9629,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_permute_pd() { + const unsafe fn test_mm_mask_permute_pd() { let a = _mm_set_pd(1., 0.); let r = _mm_mask_permute_pd::<0b11>(a, 0, a); assert_eq_m128d(r, a); @@ -9634,7 +9639,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_permute_pd() { + const unsafe fn test_mm_maskz_permute_pd() { let a = _mm_set_pd(1., 0.); let r = _mm_maskz_permute_pd::<0b11>(0, a); assert_eq_m128d(r, _mm_setzero_pd()); @@ -9644,7 +9649,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_permutex_epi64() { + const unsafe fn test_mm512_permutex_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm512_permutex_epi64::<0b11_11_11_11>(a); let e = _mm512_setr_epi64(3, 3, 3, 3, 7, 7, 7, 7); @@ -9652,7 +9657,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_permutex_epi64() { + const unsafe fn test_mm512_mask_permutex_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm512_mask_permutex_epi64::<0b11_11_11_11>(a, 0, a); assert_eq_m512i(r, a); @@ -9662,7 +9667,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_permutex_epi64() { + const unsafe fn test_mm512_maskz_permutex_epi64() { let a = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm512_maskz_permutex_epi64::<0b11_11_11_11>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -9672,7 +9677,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_permutex_epi64() { + const unsafe fn test_mm256_permutex_epi64() { let a = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_permutex_epi64::<0b11_11_11_11>(a); let e = _mm256_set_epi64x(3, 3, 3, 3); @@ -9680,7 +9685,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_permutex_epi64() { + const unsafe fn test_mm256_mask_permutex_epi64() { let a = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_mask_permutex_epi64::<0b11_11_11_11>(a, 0, a); assert_eq_m256i(r, a); @@ -9690,7 +9695,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_permutex_epi64() { + const unsafe fn test_mm256_maskz_permutex_epi64() { let a = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_maskz_permutex_epi64::<0b11_11_11_11>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -9700,7 +9705,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_permutex_pd() { + const unsafe fn test_mm512_permutex_pd() { let a = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm512_permutex_pd::<0b11_11_11_11>(a); let e = _mm512_setr_pd(3., 3., 3., 3., 7., 7., 7., 7.); @@ -9708,7 +9713,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_permutex_pd() { + const unsafe fn test_mm512_mask_permutex_pd() { let a = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm512_mask_permutex_pd::<0b11_11_11_11>(a, 0, a); assert_eq_m512d(r, a); @@ -9718,7 +9723,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_permutex_pd() { + const unsafe fn test_mm512_maskz_permutex_pd() { let a = _mm512_setr_pd(0., 1., 2., 3., 4., 5., 6., 7.); let r = _mm512_maskz_permutex_pd::<0b11_11_11_11>(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -9728,7 +9733,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_permutex_pd() { + const unsafe fn test_mm256_permutex_pd() { let a = _mm256_set_pd(0., 1., 2., 3.); let r = _mm256_permutex_pd::<0b11_11_11_11>(a); let e = _mm256_set_pd(0., 0., 0., 0.); @@ -9736,7 +9741,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_permutex_pd() { + const unsafe fn test_mm256_mask_permutex_pd() { let a = _mm256_set_pd(0., 1., 2., 3.); let r = _mm256_mask_permutex_pd::<0b11_11_11_11>(a, 0, a); assert_eq_m256d(r, a); @@ -9746,7 +9751,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_permutex_pd() { + const unsafe fn test_mm256_maskz_permutex_pd() { let a = _mm256_set_pd(0., 1., 2., 3.); let r = _mm256_maskz_permutex_pd::<0b11_11_11_11>(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -10231,7 +10236,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_pd() { + const unsafe fn test_mm256_mask_shuffle_pd() { let a = _mm256_set_pd(1., 4., 5., 8.); let b = _mm256_set_pd(2., 3., 6., 7.); let r = _mm256_mask_shuffle_pd::<0b11_11_11_11>(a, 0, a, b); @@ -10242,7 +10247,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_pd() { + const unsafe fn test_mm256_maskz_shuffle_pd() { let a = _mm256_set_pd(1., 4., 5., 8.); let b = _mm256_set_pd(2., 3., 6., 7.); let r = _mm256_maskz_shuffle_pd::<0b11_11_11_11>(0, a, b); @@ -10253,7 +10258,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_shuffle_pd() { + const unsafe fn test_mm_mask_shuffle_pd() { let a = _mm_set_pd(1., 4.); let b = _mm_set_pd(2., 3.); let r = _mm_mask_shuffle_pd::<0b11_11_11_11>(a, 0, a, b); @@ -10264,7 +10269,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_shuffle_pd() { + const unsafe fn test_mm_maskz_shuffle_pd() { let a = _mm_set_pd(1., 4.); let b = _mm_set_pd(2., 3.); let r = _mm_maskz_shuffle_pd::<0b11_11_11_11>(0, a, b); @@ -10275,7 +10280,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_i64x2() { + const unsafe fn test_mm512_shuffle_i64x2() { let a = _mm512_setr_epi64(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm512_setr_epi64(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm512_shuffle_i64x2::<0b00_00_00_00>(a, b); @@ -10284,7 +10289,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_i64x2() { + const unsafe fn test_mm512_mask_shuffle_i64x2() { let a = _mm512_setr_epi64(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm512_setr_epi64(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm512_mask_shuffle_i64x2::<0b00_00_00_00>(a, 0, a, b); @@ -10295,7 +10300,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_i64x2() { + const unsafe fn test_mm512_maskz_shuffle_i64x2() { let a = _mm512_setr_epi64(1, 4, 5, 8, 9, 12, 13, 16); let b = _mm512_setr_epi64(2, 3, 6, 7, 10, 11, 14, 15); let r = _mm512_maskz_shuffle_i64x2::<0b00_00_00_00>(0, a, b); @@ -10306,7 +10311,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_shuffle_i64x2() { + const unsafe fn test_mm256_shuffle_i64x2() { let a = _mm256_set_epi64x(1, 4, 5, 8); let b = _mm256_set_epi64x(2, 3, 6, 7); let r = _mm256_shuffle_i64x2::<0b00>(a, b); @@ -10315,7 +10320,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_i64x2() { + const unsafe fn test_mm256_mask_shuffle_i64x2() { let a = _mm256_set_epi64x(1, 4, 5, 8); let b = _mm256_set_epi64x(2, 3, 6, 7); let r = _mm256_mask_shuffle_i64x2::<0b00>(a, 0, a, b); @@ -10326,7 +10331,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_i64x2() { + const unsafe fn test_mm256_maskz_shuffle_i64x2() { let a = _mm256_set_epi64x(1, 4, 5, 8); let b = _mm256_set_epi64x(2, 3, 6, 7); let r = _mm256_maskz_shuffle_i64x2::<0b00>(0, a, b); @@ -10337,7 +10342,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_shuffle_f64x2() { + const unsafe fn test_mm512_shuffle_f64x2() { let a = _mm512_setr_pd(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm512_setr_pd(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm512_shuffle_f64x2::<0b00_00_00_00>(a, b); @@ -10346,7 +10351,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_shuffle_f64x2() { + const unsafe fn test_mm512_mask_shuffle_f64x2() { let a = _mm512_setr_pd(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm512_setr_pd(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm512_mask_shuffle_f64x2::<0b00_00_00_00>(a, 0, a, b); @@ -10357,7 +10362,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_shuffle_f64x2() { + const unsafe fn test_mm512_maskz_shuffle_f64x2() { let a = _mm512_setr_pd(1., 4., 5., 8., 9., 12., 13., 16.); let b = _mm512_setr_pd(2., 3., 6., 7., 10., 11., 14., 15.); let r = _mm512_maskz_shuffle_f64x2::<0b00_00_00_00>(0, a, b); @@ -10368,7 +10373,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_shuffle_f64x2() { + const unsafe fn test_mm256_shuffle_f64x2() { let a = _mm256_set_pd(1., 4., 5., 8.); let b = _mm256_set_pd(2., 3., 6., 7.); let r = _mm256_shuffle_f64x2::<0b00>(a, b); @@ -10377,7 +10382,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_shuffle_f64x2() { + const unsafe fn test_mm256_mask_shuffle_f64x2() { let a = _mm256_set_pd(1., 4., 5., 8.); let b = _mm256_set_pd(2., 3., 6., 7.); let r = _mm256_mask_shuffle_f64x2::<0b00>(a, 0, a, b); @@ -10388,7 +10393,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_shuffle_f64x2() { + const unsafe fn test_mm256_maskz_shuffle_f64x2() { let a = _mm256_set_pd(1., 4., 5., 8.); let b = _mm256_set_pd(2., 3., 6., 7.); let r = _mm256_maskz_shuffle_f64x2::<0b00>(0, a, b); @@ -10399,7 +10404,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_movedup_pd() { + const unsafe fn test_mm512_movedup_pd() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_movedup_pd(a); let e = _mm512_setr_pd(1., 1., 3., 3., 5., 5., 7., 7.); @@ -10407,7 +10412,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_movedup_pd() { + const unsafe fn test_mm512_mask_movedup_pd() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_mask_movedup_pd(a, 0, a); assert_eq_m512d(r, a); @@ -10417,7 +10422,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_movedup_pd() { + const unsafe fn test_mm512_maskz_movedup_pd() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_maskz_movedup_pd(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -10427,7 +10432,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_movedup_pd() { + const unsafe fn test_mm256_mask_movedup_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let r = _mm256_mask_movedup_pd(a, 0, a); assert_eq_m256d(r, a); @@ -10437,7 +10442,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_movedup_pd() { + const unsafe fn test_mm256_maskz_movedup_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let r = _mm256_maskz_movedup_pd(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -10447,7 +10452,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_movedup_pd() { + const unsafe fn test_mm_mask_movedup_pd() { let a = _mm_set_pd(1., 2.); let r = _mm_mask_movedup_pd(a, 0, a); assert_eq_m128d(r, a); @@ -10457,7 +10462,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_movedup_pd() { + const unsafe fn test_mm_maskz_movedup_pd() { let a = _mm_set_pd(1., 2.); let r = _mm_maskz_movedup_pd(0, a); assert_eq_m128d(r, _mm_setzero_pd()); @@ -10467,7 +10472,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_inserti64x4() { + const unsafe fn test_mm512_inserti64x4() { let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_setr_epi64x(17, 18, 19, 20); let r = _mm512_inserti64x4::<1>(a, b); @@ -10476,7 +10481,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_inserti64x4() { + const unsafe fn test_mm512_mask_inserti64x4() { let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_setr_epi64x(17, 18, 19, 20); let r = _mm512_mask_inserti64x4::<1>(a, 0, a, b); @@ -10487,7 +10492,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_inserti64x4() { + const unsafe fn test_mm512_maskz_inserti64x4() { let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm256_setr_epi64x(17, 18, 19, 20); let r = _mm512_maskz_inserti64x4::<1>(0, a, b); @@ -10498,7 +10503,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_insertf64x4() { + const unsafe fn test_mm512_insertf64x4() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_pd(17., 18., 19., 20.); let r = _mm512_insertf64x4::<1>(a, b); @@ -10507,7 +10512,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_insertf64x4() { + const unsafe fn test_mm512_mask_insertf64x4() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_pd(17., 18., 19., 20.); let r = _mm512_mask_insertf64x4::<1>(a, 0, a, b); @@ -10518,7 +10523,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_insertf64x4() { + const unsafe fn test_mm512_maskz_insertf64x4() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm256_setr_pd(17., 18., 19., 20.); let r = _mm512_maskz_insertf64x4::<1>(0, a, b); @@ -10529,21 +10534,21 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castpd128_pd512() { + const unsafe fn test_mm512_castpd128_pd512() { let a = _mm_setr_pd(17., 18.); let r = _mm512_castpd128_pd512(a); assert_eq_m128d(_mm512_castpd512_pd128(r), a); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castpd256_pd512() { + const unsafe fn test_mm512_castpd256_pd512() { let a = _mm256_setr_pd(17., 18., 19., 20.); let r = _mm512_castpd256_pd512(a); assert_eq_m256d(_mm512_castpd512_pd256(r), a); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_zextpd128_pd512() { + const unsafe fn test_mm512_zextpd128_pd512() { let a = _mm_setr_pd(17., 18.); let r = _mm512_zextpd128_pd512(a); let e = _mm512_setr_pd(17., 18., 0., 0., 0., 0., 0., 0.); @@ -10551,7 +10556,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_zextpd256_pd512() { + const unsafe fn test_mm512_zextpd256_pd512() { let a = _mm256_setr_pd(17., 18., 19., 20.); let r = _mm512_zextpd256_pd512(a); let e = _mm512_setr_pd(17., 18., 19., 20., 0., 0., 0., 0.); @@ -10559,7 +10564,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castpd512_pd128() { + const unsafe fn test_mm512_castpd512_pd128() { let a = _mm512_setr_pd(17., 18., -1., -1., -1., -1., -1., -1.); let r = _mm512_castpd512_pd128(a); let e = _mm_setr_pd(17., 18.); @@ -10567,7 +10572,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castpd512_pd256() { + const unsafe fn test_mm512_castpd512_pd256() { let a = _mm512_setr_pd(17., 18., 19., 20., -1., -1., -1., -1.); let r = _mm512_castpd512_pd256(a); let e = _mm256_setr_pd(17., 18., 19., 20.); @@ -10575,7 +10580,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castpd_ps() { + const unsafe fn test_mm512_castpd_ps() { let a = _mm512_set1_pd(1.); let r = _mm512_castpd_ps(a); let e = _mm512_set_ps( @@ -10586,7 +10591,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castpd_si512() { + const unsafe fn test_mm512_castpd_si512() { let a = _mm512_set1_pd(1.); let r = _mm512_castpd_si512(a); let e = _mm512_set_epi32( @@ -10597,21 +10602,21 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castsi128_si512() { + const unsafe fn test_mm512_castsi128_si512() { let a = _mm_setr_epi64x(17, 18); let r = _mm512_castsi128_si512(a); assert_eq_m128i(_mm512_castsi512_si128(r), a); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castsi256_si512() { + const unsafe fn test_mm512_castsi256_si512() { let a = _mm256_setr_epi64x(17, 18, 19, 20); let r = _mm512_castsi256_si512(a); assert_eq_m256i(_mm512_castsi512_si256(r), a); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_zextsi128_si512() { + const unsafe fn test_mm512_zextsi128_si512() { let a = _mm_setr_epi64x(17, 18); let r = _mm512_zextsi128_si512(a); let e = _mm512_setr_epi64(17, 18, 0, 0, 0, 0, 0, 0); @@ -10619,7 +10624,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_zextsi256_si512() { + const unsafe fn test_mm512_zextsi256_si512() { let a = _mm256_setr_epi64x(17, 18, 19, 20); let r = _mm512_zextsi256_si512(a); let e = _mm512_setr_epi64(17, 18, 19, 20, 0, 0, 0, 0); @@ -10627,7 +10632,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castsi512_si128() { + const unsafe fn test_mm512_castsi512_si128() { let a = _mm512_setr_epi64(17, 18, -1, -1, -1, -1, -1, -1); let r = _mm512_castsi512_si128(a); let e = _mm_setr_epi64x(17, 18); @@ -10635,7 +10640,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castsi512_si256() { + const unsafe fn test_mm512_castsi512_si256() { let a = _mm512_setr_epi64(17, 18, 19, 20, -1, -1, -1, -1); let r = _mm512_castsi512_si256(a); let e = _mm256_setr_epi64x(17, 18, 19, 20); @@ -10643,7 +10648,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castsi512_ps() { + const unsafe fn test_mm512_castsi512_ps() { let a = _mm512_set1_epi64(1 << 62); let r = _mm512_castsi512_ps(a); let e = _mm512_set_ps( @@ -10653,7 +10658,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_castsi512_pd() { + const unsafe fn test_mm512_castsi512_pd() { let a = _mm512_set1_epi64(1 << 62); let r = _mm512_castsi512_pd(a); let e = _mm512_set_pd(2., 2., 2., 2., 2., 2., 2., 2.); @@ -10661,7 +10666,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcastq_epi64() { + const unsafe fn test_mm512_broadcastq_epi64() { let a = _mm_setr_epi64x(17, 18); let r = _mm512_broadcastq_epi64(a); let e = _mm512_set1_epi64(17); @@ -10669,7 +10674,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcastq_epi64() { + const unsafe fn test_mm512_mask_broadcastq_epi64() { let src = _mm512_set1_epi64(18); let a = _mm_setr_epi64x(17, 18); let r = _mm512_mask_broadcastq_epi64(src, 0, a); @@ -10680,7 +10685,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcastq_epi64() { + const unsafe fn test_mm512_maskz_broadcastq_epi64() { let a = _mm_setr_epi64x(17, 18); let r = _mm512_maskz_broadcastq_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -10690,7 +10695,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_broadcastq_epi64() { + const unsafe fn test_mm256_mask_broadcastq_epi64() { let src = _mm256_set1_epi64x(18); let a = _mm_set_epi64x(17, 18); let r = _mm256_mask_broadcastq_epi64(src, 0, a); @@ -10701,7 +10706,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_broadcastq_epi64() { + const unsafe fn test_mm256_maskz_broadcastq_epi64() { let a = _mm_set_epi64x(17, 18); let r = _mm256_maskz_broadcastq_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -10711,7 +10716,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_broadcastq_epi64() { + const unsafe fn test_mm_mask_broadcastq_epi64() { let src = _mm_set1_epi64x(18); let a = _mm_set_epi64x(17, 18); let r = _mm_mask_broadcastq_epi64(src, 0, a); @@ -10722,7 +10727,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_broadcastq_epi64() { + const unsafe fn test_mm_maskz_broadcastq_epi64() { let a = _mm_set_epi64x(17, 18); let r = _mm_maskz_broadcastq_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -10732,7 +10737,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcastsd_pd() { + const unsafe fn test_mm512_broadcastsd_pd() { let a = _mm_set_pd(17., 18.); let r = _mm512_broadcastsd_pd(a); let e = _mm512_set1_pd(18.); @@ -10740,7 +10745,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcastsd_pd() { + const unsafe fn test_mm512_mask_broadcastsd_pd() { let src = _mm512_set1_pd(18.); let a = _mm_set_pd(17., 18.); let r = _mm512_mask_broadcastsd_pd(src, 0, a); @@ -10751,7 +10756,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcastsd_pd() { + const unsafe fn test_mm512_maskz_broadcastsd_pd() { let a = _mm_set_pd(17., 18.); let r = _mm512_maskz_broadcastsd_pd(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -10761,7 +10766,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_broadcastsd_pd() { + const unsafe fn test_mm256_mask_broadcastsd_pd() { let src = _mm256_set1_pd(18.); let a = _mm_set_pd(17., 18.); let r = _mm256_mask_broadcastsd_pd(src, 0, a); @@ -10772,7 +10777,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_broadcastsd_pd() { + const unsafe fn test_mm256_maskz_broadcastsd_pd() { let a = _mm_set_pd(17., 18.); let r = _mm256_maskz_broadcastsd_pd(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -10782,7 +10787,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcast_i64x4() { + const unsafe fn test_mm512_broadcast_i64x4() { let a = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm512_broadcast_i64x4(a); let e = _mm512_set_epi64(17, 18, 19, 20, 17, 18, 19, 20); @@ -10790,7 +10795,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcast_i64x4() { + const unsafe fn test_mm512_mask_broadcast_i64x4() { let src = _mm512_set1_epi64(18); let a = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm512_mask_broadcast_i64x4(src, 0, a); @@ -10801,7 +10806,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcast_i64x4() { + const unsafe fn test_mm512_maskz_broadcast_i64x4() { let a = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm512_maskz_broadcast_i64x4(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -10811,7 +10816,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_broadcast_f64x4() { + const unsafe fn test_mm512_broadcast_f64x4() { let a = _mm256_set_pd(17., 18., 19., 20.); let r = _mm512_broadcast_f64x4(a); let e = _mm512_set_pd(17., 18., 19., 20., 17., 18., 19., 20.); @@ -10819,7 +10824,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_broadcast_f64x4() { + const unsafe fn test_mm512_mask_broadcast_f64x4() { let src = _mm512_set1_pd(18.); let a = _mm256_set_pd(17., 18., 19., 20.); let r = _mm512_mask_broadcast_f64x4(src, 0, a); @@ -10830,7 +10835,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_broadcast_f64x4() { + const unsafe fn test_mm512_maskz_broadcast_f64x4() { let a = _mm256_set_pd(17., 18., 19., 20.); let r = _mm512_maskz_broadcast_f64x4(0, a); assert_eq_m512d(r, _mm512_setzero_pd()); @@ -10840,7 +10845,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_blend_epi64() { + const unsafe fn test_mm512_mask_blend_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(2); let r = _mm512_mask_blend_epi64(0b11110000, a, b); @@ -10849,7 +10854,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_blend_epi64() { + const unsafe fn test_mm256_mask_blend_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(2); let r = _mm256_mask_blend_epi64(0b00001111, a, b); @@ -10858,7 +10863,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_blend_epi64() { + const unsafe fn test_mm_mask_blend_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(2); let r = _mm_mask_blend_epi64(0b00000011, a, b); @@ -10867,7 +10872,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_blend_pd() { + const unsafe fn test_mm512_mask_blend_pd() { let a = _mm512_set1_pd(1.); let b = _mm512_set1_pd(2.); let r = _mm512_mask_blend_pd(0b11110000, a, b); @@ -10876,7 +10881,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_blend_pd() { + const unsafe fn test_mm256_mask_blend_pd() { let a = _mm256_set1_pd(1.); let b = _mm256_set1_pd(2.); let r = _mm256_mask_blend_pd(0b00001111, a, b); @@ -10885,7 +10890,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_blend_pd() { + const unsafe fn test_mm_mask_blend_pd() { let a = _mm_set1_pd(1.); let b = _mm_set1_pd(2.); let r = _mm_mask_blend_pd(0b00000011, a, b); @@ -10894,7 +10899,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpackhi_epi64() { + const unsafe fn test_mm512_unpackhi_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_unpackhi_epi64(a, b); @@ -10903,7 +10908,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpackhi_epi64() { + const unsafe fn test_mm512_mask_unpackhi_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_mask_unpackhi_epi64(a, 0, a, b); @@ -10914,7 +10919,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpackhi_epi64() { + const unsafe fn test_mm512_maskz_unpackhi_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_maskz_unpackhi_epi64(0, a, b); @@ -10925,7 +10930,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpackhi_epi64() { + const unsafe fn test_mm256_mask_unpackhi_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm256_mask_unpackhi_epi64(a, 0, a, b); @@ -10936,7 +10941,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpackhi_epi64() { + const unsafe fn test_mm256_maskz_unpackhi_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm256_maskz_unpackhi_epi64(0, a, b); @@ -10947,7 +10952,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpackhi_epi64() { + const unsafe fn test_mm_mask_unpackhi_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(17, 18); let r = _mm_mask_unpackhi_epi64(a, 0, a, b); @@ -10958,7 +10963,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpackhi_epi64() { + const unsafe fn test_mm_maskz_unpackhi_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(17, 18); let r = _mm_maskz_unpackhi_epi64(0, a, b); @@ -10969,7 +10974,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpackhi_pd() { + const unsafe fn test_mm512_unpackhi_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_pd(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_unpackhi_pd(a, b); @@ -10978,7 +10983,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpackhi_pd() { + const unsafe fn test_mm512_mask_unpackhi_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_pd(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_mask_unpackhi_pd(a, 0, a, b); @@ -10989,7 +10994,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpackhi_pd() { + const unsafe fn test_mm512_maskz_unpackhi_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_pd(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_maskz_unpackhi_pd(0, a, b); @@ -11000,7 +11005,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpackhi_pd() { + const unsafe fn test_mm256_mask_unpackhi_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm256_set_pd(17., 18., 19., 20.); let r = _mm256_mask_unpackhi_pd(a, 0, a, b); @@ -11011,7 +11016,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpackhi_pd() { + const unsafe fn test_mm256_maskz_unpackhi_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm256_set_pd(17., 18., 19., 20.); let r = _mm256_maskz_unpackhi_pd(0, a, b); @@ -11022,7 +11027,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpackhi_pd() { + const unsafe fn test_mm_mask_unpackhi_pd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(17., 18.); let r = _mm_mask_unpackhi_pd(a, 0, a, b); @@ -11033,7 +11038,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpackhi_pd() { + const unsafe fn test_mm_maskz_unpackhi_pd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(17., 18.); let r = _mm_maskz_unpackhi_pd(0, a, b); @@ -11044,7 +11049,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpacklo_epi64() { + const unsafe fn test_mm512_unpacklo_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_unpacklo_epi64(a, b); @@ -11053,7 +11058,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpacklo_epi64() { + const unsafe fn test_mm512_mask_unpacklo_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_mask_unpacklo_epi64(a, 0, a, b); @@ -11064,7 +11069,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpacklo_epi64() { + const unsafe fn test_mm512_maskz_unpacklo_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_maskz_unpacklo_epi64(0, a, b); @@ -11075,7 +11080,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpacklo_epi64() { + const unsafe fn test_mm256_mask_unpacklo_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm256_mask_unpacklo_epi64(a, 0, a, b); @@ -11086,7 +11091,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpacklo_epi64() { + const unsafe fn test_mm256_maskz_unpacklo_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(17, 18, 19, 20); let r = _mm256_maskz_unpacklo_epi64(0, a, b); @@ -11097,7 +11102,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpacklo_epi64() { + const unsafe fn test_mm_mask_unpacklo_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(17, 18); let r = _mm_mask_unpacklo_epi64(a, 0, a, b); @@ -11108,7 +11113,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpacklo_epi64() { + const unsafe fn test_mm_maskz_unpacklo_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(17, 18); let r = _mm_maskz_unpacklo_epi64(0, a, b); @@ -11119,7 +11124,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_unpacklo_pd() { + const unsafe fn test_mm512_unpacklo_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_pd(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_unpacklo_pd(a, b); @@ -11128,7 +11133,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_unpacklo_pd() { + const unsafe fn test_mm512_mask_unpacklo_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_pd(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_mask_unpacklo_pd(a, 0, a, b); @@ -11139,7 +11144,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_unpacklo_pd() { + const unsafe fn test_mm512_maskz_unpacklo_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_pd(17., 18., 19., 20., 21., 22., 23., 24.); let r = _mm512_maskz_unpacklo_pd(0, a, b); @@ -11150,7 +11155,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_unpacklo_pd() { + const unsafe fn test_mm256_mask_unpacklo_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm256_set_pd(17., 18., 19., 20.); let r = _mm256_mask_unpacklo_pd(a, 0, a, b); @@ -11161,7 +11166,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_unpacklo_pd() { + const unsafe fn test_mm256_maskz_unpacklo_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm256_set_pd(17., 18., 19., 20.); let r = _mm256_maskz_unpacklo_pd(0, a, b); @@ -11172,7 +11177,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_unpacklo_pd() { + const unsafe fn test_mm_mask_unpacklo_pd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(17., 18.); let r = _mm_mask_unpacklo_pd(a, 0, a, b); @@ -11183,7 +11188,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_unpacklo_pd() { + const unsafe fn test_mm_maskz_unpacklo_pd() { let a = _mm_set_pd(1., 2.); let b = _mm_set_pd(17., 18.); let r = _mm_maskz_unpacklo_pd(0, a, b); @@ -11194,7 +11199,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_alignr_epi64() { + const unsafe fn test_mm512_alignr_epi64() { let a = _mm512_set_epi64(8, 7, 6, 5, 4, 3, 2, 1); let b = _mm512_set_epi64(16, 15, 14, 13, 12, 11, 10, 9); let r = _mm512_alignr_epi64::<0>(a, b); @@ -11207,7 +11212,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_alignr_epi64() { + const unsafe fn test_mm512_mask_alignr_epi64() { let a = _mm512_set_epi64(8, 7, 6, 5, 4, 3, 2, 1); let b = _mm512_set_epi64(16, 15, 14, 13, 12, 11, 10, 9); let r = _mm512_mask_alignr_epi64::<1>(a, 0, a, b); @@ -11218,7 +11223,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_alignr_epi64() { + const unsafe fn test_mm512_maskz_alignr_epi64() { let a = _mm512_set_epi64(8, 7, 6, 5, 4, 3, 2, 1); let b = _mm512_set_epi64(16, 15, 14, 13, 12, 11, 10, 9); let r = _mm512_maskz_alignr_epi64::<1>(0, a, b); @@ -11229,7 +11234,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_alignr_epi64() { + const unsafe fn test_mm256_alignr_epi64() { let a = _mm256_set_epi64x(4, 3, 2, 1); let b = _mm256_set_epi64x(8, 7, 6, 5); let r = _mm256_alignr_epi64::<0>(a, b); @@ -11244,7 +11249,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_alignr_epi64() { + const unsafe fn test_mm256_mask_alignr_epi64() { let a = _mm256_set_epi64x(4, 3, 2, 1); let b = _mm256_set_epi64x(8, 7, 6, 5); let r = _mm256_mask_alignr_epi64::<1>(a, 0, a, b); @@ -11255,7 +11260,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_alignr_epi64() { + const unsafe fn test_mm256_maskz_alignr_epi64() { let a = _mm256_set_epi64x(4, 3, 2, 1); let b = _mm256_set_epi64x(8, 7, 6, 5); let r = _mm256_maskz_alignr_epi64::<1>(0, a, b); @@ -11266,7 +11271,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_alignr_epi64() { + const unsafe fn test_mm_alignr_epi64() { let a = _mm_set_epi64x(2, 1); let b = _mm_set_epi64x(4, 3); let r = _mm_alignr_epi64::<0>(a, b); @@ -11275,7 +11280,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_alignr_epi64() { + const unsafe fn test_mm_mask_alignr_epi64() { let a = _mm_set_epi64x(2, 1); let b = _mm_set_epi64x(4, 3); let r = _mm_mask_alignr_epi64::<1>(a, 0, a, b); @@ -11286,7 +11291,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_alignr_epi64() { + const unsafe fn test_mm_maskz_alignr_epi64() { let a = _mm_set_epi64x(2, 1); let b = _mm_set_epi64x(4, 3); let r = _mm_maskz_alignr_epi64::<1>(0, a, b); @@ -11297,7 +11302,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_and_epi64() { + const unsafe fn test_mm512_and_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_and_epi64(a, b); @@ -11306,7 +11311,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_and_epi64() { + const unsafe fn test_mm512_mask_and_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_mask_and_epi64(a, 0, a, b); @@ -11317,7 +11322,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_and_epi64() { + const unsafe fn test_mm512_maskz_and_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_maskz_and_epi64(0, a, b); @@ -11328,7 +11333,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_and_epi64() { + const unsafe fn test_mm256_mask_and_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 0); let r = _mm256_mask_and_epi64(a, 0, a, b); @@ -11339,7 +11344,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_and_epi64() { + const unsafe fn test_mm256_maskz_and_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 0); let r = _mm256_maskz_and_epi64(0, a, b); @@ -11350,7 +11355,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_and_epi64() { + const unsafe fn test_mm_mask_and_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 0); let r = _mm_mask_and_epi64(a, 0, a, b); @@ -11361,7 +11366,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_and_epi64() { + const unsafe fn test_mm_maskz_and_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 0); let r = _mm_maskz_and_epi64(0, a, b); @@ -11372,7 +11377,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_and_si512() { + const unsafe fn test_mm512_and_si512() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_and_epi64(a, b); @@ -11381,7 +11386,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_or_epi64() { + const unsafe fn test_mm512_or_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_or_epi64(a, b); @@ -11394,7 +11399,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_or_epi64() { + const unsafe fn test_mm512_mask_or_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_mask_or_epi64(a, 0, a, b); @@ -11409,7 +11414,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_or_epi64() { + const unsafe fn test_mm512_maskz_or_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_maskz_or_epi64(0, a, b); @@ -11420,7 +11425,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_or_epi64() { + const unsafe fn test_mm256_or_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 13); let r = _mm256_or_epi64(a, b); @@ -11429,7 +11434,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_or_epi64() { + const unsafe fn test_mm256_mask_or_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 13); let r = _mm256_mask_or_epi64(a, 0, a, b); @@ -11440,7 +11445,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_or_epi64() { + const unsafe fn test_mm256_maskz_or_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 13); let r = _mm256_maskz_or_epi64(0, a, b); @@ -11451,7 +11456,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_or_epi64() { + const unsafe fn test_mm_or_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 13); let r = _mm_or_epi64(a, b); @@ -11460,7 +11465,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_or_epi64() { + const unsafe fn test_mm_mask_or_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 13); let r = _mm_mask_or_epi64(a, 0, a, b); @@ -11471,7 +11476,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_or_epi64() { + const unsafe fn test_mm_maskz_or_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 13); let r = _mm_maskz_or_epi64(0, a, b); @@ -11482,7 +11487,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_or_si512() { + const unsafe fn test_mm512_or_si512() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_or_epi64(a, b); @@ -11495,7 +11500,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_xor_epi64() { + const unsafe fn test_mm512_xor_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_xor_epi64(a, b); @@ -11504,7 +11509,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_xor_epi64() { + const unsafe fn test_mm512_mask_xor_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_mask_xor_epi64(a, 0, a, b); @@ -11515,7 +11520,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_xor_epi64() { + const unsafe fn test_mm512_maskz_xor_epi64() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_maskz_xor_epi64(0, a, b); @@ -11526,7 +11531,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_xor_epi64() { + const unsafe fn test_mm256_xor_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 13); let r = _mm256_xor_epi64(a, b); @@ -11535,7 +11540,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_xor_epi64() { + const unsafe fn test_mm256_mask_xor_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 13); let r = _mm256_mask_xor_epi64(a, 0, a, b); @@ -11546,7 +11551,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_xor_epi64() { + const unsafe fn test_mm256_maskz_xor_epi64() { let a = _mm256_set1_epi64x(1 << 0 | 1 << 15); let b = _mm256_set1_epi64x(1 << 13); let r = _mm256_maskz_xor_epi64(0, a, b); @@ -11557,7 +11562,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_xor_epi64() { + const unsafe fn test_mm_xor_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 13); let r = _mm_xor_epi64(a, b); @@ -11566,7 +11571,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_xor_epi64() { + const unsafe fn test_mm_mask_xor_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 13); let r = _mm_mask_xor_epi64(a, 0, a, b); @@ -11577,7 +11582,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_xor_epi64() { + const unsafe fn test_mm_maskz_xor_epi64() { let a = _mm_set1_epi64x(1 << 0 | 1 << 15); let b = _mm_set1_epi64x(1 << 13); let r = _mm_maskz_xor_epi64(0, a, b); @@ -11588,7 +11593,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_xor_si512() { + const unsafe fn test_mm512_xor_si512() { let a = _mm512_set_epi64(1 << 0 | 1 << 15, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let b = _mm512_set_epi64(1 << 13, 0, 0, 0, 0, 0, 0, 1 << 1 | 1 << 2 | 1 << 3); let r = _mm512_xor_epi64(a, b); @@ -11597,7 +11602,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_andnot_epi64() { + const unsafe fn test_mm512_andnot_epi64() { let a = _mm512_set1_epi64(0); let b = _mm512_set1_epi64(1 << 3 | 1 << 4); let r = _mm512_andnot_epi64(a, b); @@ -11606,7 +11611,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_andnot_epi64() { + const unsafe fn test_mm512_mask_andnot_epi64() { let a = _mm512_set1_epi64(1 << 1 | 1 << 2); let b = _mm512_set1_epi64(1 << 3 | 1 << 4); let r = _mm512_mask_andnot_epi64(a, 0, a, b); @@ -11617,7 +11622,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_andnot_epi64() { + const unsafe fn test_mm512_maskz_andnot_epi64() { let a = _mm512_set1_epi64(1 << 1 | 1 << 2); let b = _mm512_set1_epi64(1 << 3 | 1 << 4); let r = _mm512_maskz_andnot_epi64(0, a, b); @@ -11632,7 +11637,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_andnot_epi64() { + const unsafe fn test_mm256_mask_andnot_epi64() { let a = _mm256_set1_epi64x(1 << 1 | 1 << 2); let b = _mm256_set1_epi64x(1 << 3 | 1 << 4); let r = _mm256_mask_andnot_epi64(a, 0, a, b); @@ -11643,7 +11648,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_andnot_epi64() { + const unsafe fn test_mm256_maskz_andnot_epi64() { let a = _mm256_set1_epi64x(1 << 1 | 1 << 2); let b = _mm256_set1_epi64x(1 << 3 | 1 << 4); let r = _mm256_maskz_andnot_epi64(0, a, b); @@ -11654,7 +11659,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_andnot_epi64() { + const unsafe fn test_mm_mask_andnot_epi64() { let a = _mm_set1_epi64x(1 << 1 | 1 << 2); let b = _mm_set1_epi64x(1 << 3 | 1 << 4); let r = _mm_mask_andnot_epi64(a, 0, a, b); @@ -11665,7 +11670,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_andnot_epi64() { + const unsafe fn test_mm_maskz_andnot_epi64() { let a = _mm_set1_epi64x(1 << 1 | 1 << 2); let b = _mm_set1_epi64x(1 << 3 | 1 << 4); let r = _mm_maskz_andnot_epi64(0, a, b); @@ -11676,7 +11681,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_andnot_si512() { + const unsafe fn test_mm512_andnot_si512() { let a = _mm512_set1_epi64(0); let b = _mm512_set1_epi64(1 << 3 | 1 << 4); let r = _mm512_andnot_si512(a, b); @@ -11685,84 +11690,84 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_add_epi64() { + const unsafe fn test_mm512_reduce_add_epi64() { let a = _mm512_set1_epi64(1); let e: i64 = _mm512_reduce_add_epi64(a); assert_eq!(8, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_add_epi64() { + const unsafe fn test_mm512_mask_reduce_add_epi64() { let a = _mm512_set1_epi64(1); let e: i64 = _mm512_mask_reduce_add_epi64(0b11110000, a); assert_eq!(4, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_add_pd() { + const unsafe fn test_mm512_reduce_add_pd() { let a = _mm512_set1_pd(1.); let e: f64 = _mm512_reduce_add_pd(a); assert_eq!(8., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_add_pd() { + const unsafe fn test_mm512_mask_reduce_add_pd() { let a = _mm512_set1_pd(1.); let e: f64 = _mm512_mask_reduce_add_pd(0b11110000, a); assert_eq!(4., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_mul_epi64() { + const unsafe fn test_mm512_reduce_mul_epi64() { let a = _mm512_set1_epi64(2); let e: i64 = _mm512_reduce_mul_epi64(a); assert_eq!(256, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_mul_epi64() { + const unsafe fn test_mm512_mask_reduce_mul_epi64() { let a = _mm512_set1_epi64(2); let e: i64 = _mm512_mask_reduce_mul_epi64(0b11110000, a); assert_eq!(16, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_mul_pd() { + const unsafe fn test_mm512_reduce_mul_pd() { let a = _mm512_set1_pd(2.); let e: f64 = _mm512_reduce_mul_pd(a); assert_eq!(256., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_mul_pd() { + const unsafe fn test_mm512_mask_reduce_mul_pd() { let a = _mm512_set1_pd(2.); let e: f64 = _mm512_mask_reduce_mul_pd(0b11110000, a); assert_eq!(16., e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_max_epi64() { + const unsafe fn test_mm512_reduce_max_epi64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: i64 = _mm512_reduce_max_epi64(a); assert_eq!(7, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_max_epi64() { + const unsafe fn test_mm512_mask_reduce_max_epi64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: i64 = _mm512_mask_reduce_max_epi64(0b11110000, a); assert_eq!(3, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_max_epu64() { + const unsafe fn test_mm512_reduce_max_epu64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: u64 = _mm512_reduce_max_epu64(a); assert_eq!(7, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_max_epu64() { + const unsafe fn test_mm512_mask_reduce_max_epu64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: u64 = _mm512_mask_reduce_max_epu64(0b11110000, a); assert_eq!(3, e); @@ -11783,28 +11788,28 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_min_epi64() { + const unsafe fn test_mm512_reduce_min_epi64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: i64 = _mm512_reduce_min_epi64(a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_min_epi64() { + const unsafe fn test_mm512_mask_reduce_min_epi64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: i64 = _mm512_mask_reduce_min_epi64(0b11110000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_min_epu64() { + const unsafe fn test_mm512_reduce_min_epu64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: u64 = _mm512_reduce_min_epu64(a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_min_epu64() { + const unsafe fn test_mm512_mask_reduce_min_epu64() { let a = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); let e: u64 = _mm512_mask_reduce_min_epu64(0b11110000, a); assert_eq!(0, e); @@ -11825,35 +11830,35 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_and_epi64() { + const unsafe fn test_mm512_reduce_and_epi64() { let a = _mm512_set_epi64(1, 1, 1, 1, 2, 2, 2, 2); let e: i64 = _mm512_reduce_and_epi64(a); assert_eq!(0, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_and_epi64() { + const unsafe fn test_mm512_mask_reduce_and_epi64() { let a = _mm512_set_epi64(1, 1, 1, 1, 2, 2, 2, 2); let e: i64 = _mm512_mask_reduce_and_epi64(0b11110000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_reduce_or_epi64() { + const unsafe fn test_mm512_reduce_or_epi64() { let a = _mm512_set_epi64(1, 1, 1, 1, 2, 2, 2, 2); let e: i64 = _mm512_reduce_or_epi64(a); assert_eq!(3, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_reduce_or_epi64() { + const unsafe fn test_mm512_mask_reduce_or_epi64() { let a = _mm512_set_epi64(1, 1, 1, 1, 2, 2, 2, 2); let e: i64 = _mm512_mask_reduce_or_epi64(0b11110000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_extractf64x4_pd() { + const unsafe fn test_mm512_extractf64x4_pd() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_extractf64x4_pd::<1>(a); let e = _mm256_setr_pd(5., 6., 7., 8.); @@ -11861,7 +11866,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_extractf64x4_pd() { + const unsafe fn test_mm512_mask_extractf64x4_pd() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let src = _mm256_set1_pd(100.); let r = _mm512_mask_extractf64x4_pd::<1>(src, 0, a); @@ -11872,7 +11877,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_extractf64x4_pd() { + const unsafe fn test_mm512_maskz_extractf64x4_pd() { let a = _mm512_setr_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_maskz_extractf64x4_pd::<1>(0, a); assert_eq_m256d(r, _mm256_setzero_pd()); @@ -11882,7 +11887,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_extracti64x4_epi64() { + const unsafe fn test_mm512_extracti64x4_epi64() { let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm512_extracti64x4_epi64::<0x1>(a); let e = _mm256_setr_epi64x(5, 6, 7, 8); @@ -11890,7 +11895,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_extracti64x4_epi64() { + const unsafe fn test_mm512_mask_extracti64x4_epi64() { let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let src = _mm256_set1_epi64x(100); let r = _mm512_mask_extracti64x4_epi64::<0x1>(src, 0, a); @@ -11901,7 +11906,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_extracti64x4_epi64() { + const unsafe fn test_mm512_maskz_extracti64x4_epi64() { let a = _mm512_setr_epi64(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm512_maskz_extracti64x4_epi64::<0x1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -12163,7 +12168,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_loadu_epi64() { + const unsafe fn test_mm512_loadu_epi64() { let a = &[4, 3, 2, 5, -8, -9, -64, -50]; let p = a.as_ptr(); let r = _mm512_loadu_epi64(black_box(p)); @@ -12172,7 +12177,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_loadu_epi64() { + const unsafe fn test_mm256_loadu_epi64() { let a = &[4, 3, 2, 5]; let p = a.as_ptr(); let r = _mm256_loadu_epi64(black_box(p)); @@ -12181,7 +12186,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_loadu_epi64() { + const unsafe fn test_mm_loadu_epi64() { let a = &[4, 3]; let p = a.as_ptr(); let r = _mm_loadu_epi64(black_box(p)); @@ -12472,7 +12477,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_storeu_epi64() { + const unsafe fn test_mm512_storeu_epi64() { let a = _mm512_set1_epi64(9); let mut r = _mm512_set1_epi64(0); _mm512_storeu_epi64(&mut r as *mut _ as *mut i64, a); @@ -12480,7 +12485,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_storeu_epi64() { + const unsafe fn test_mm256_storeu_epi64() { let a = _mm256_set1_epi64x(9); let mut r = _mm256_set1_epi64x(0); _mm256_storeu_epi64(&mut r as *mut _ as *mut i64, a); @@ -12488,7 +12493,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_storeu_epi64() { + const unsafe fn test_mm_storeu_epi64() { let a = _mm_set1_epi64x(9); let mut r = _mm_set1_epi64x(0); _mm_storeu_epi64(&mut r as *mut _ as *mut i64, a); @@ -12496,7 +12501,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_load_epi64() { + const unsafe fn test_mm512_load_epi64() { #[repr(align(64))] struct Align { data: [i64; 8], // 64 bytes @@ -12511,7 +12516,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_load_epi64() { + const unsafe fn test_mm256_load_epi64() { #[repr(align(64))] struct Align { data: [i64; 4], @@ -12524,7 +12529,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_load_epi64() { + const unsafe fn test_mm_load_epi64() { #[repr(align(64))] struct Align { data: [i64; 2], @@ -12537,7 +12542,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_store_epi64() { + const unsafe fn test_mm512_store_epi64() { let a = _mm512_set1_epi64(9); let mut r = _mm512_set1_epi64(0); _mm512_store_epi64(&mut r as *mut _ as *mut i64, a); @@ -12545,7 +12550,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_store_epi64() { + const unsafe fn test_mm256_store_epi64() { let a = _mm256_set1_epi64x(9); let mut r = _mm256_set1_epi64x(0); _mm256_store_epi64(&mut r as *mut _ as *mut i64, a); @@ -12553,7 +12558,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_store_epi64() { + const unsafe fn test_mm_store_epi64() { let a = _mm_set1_epi64x(9); let mut r = _mm_set1_epi64x(0); _mm_store_epi64(&mut r as *mut _ as *mut i64, a); @@ -12561,7 +12566,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_load_pd() { + const unsafe fn test_mm512_load_pd() { #[repr(align(64))] struct Align { data: [f64; 8], // 64 bytes @@ -12576,7 +12581,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_store_pd() { + const unsafe fn test_mm512_store_pd() { let a = _mm512_set1_pd(9.); let mut r = _mm512_undefined_pd(); _mm512_store_pd(&mut r as *mut _ as *mut f64, a); @@ -12584,7 +12589,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_test_epi64_mask() { + const unsafe fn test_mm512_test_epi64_mask() { let a = _mm512_set1_epi64(1 << 0); let b = _mm512_set1_epi64(1 << 0 | 1 << 1); let r = _mm512_test_epi64_mask(a, b); @@ -12593,7 +12598,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_test_epi64_mask() { + const unsafe fn test_mm512_mask_test_epi64_mask() { let a = _mm512_set1_epi64(1 << 0); let b = _mm512_set1_epi64(1 << 0 | 1 << 1); let r = _mm512_mask_test_epi64_mask(0, a, b); @@ -12604,7 +12609,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_test_epi64_mask() { + const unsafe fn test_mm256_test_epi64_mask() { let a = _mm256_set1_epi64x(1 << 0); let b = _mm256_set1_epi64x(1 << 0 | 1 << 1); let r = _mm256_test_epi64_mask(a, b); @@ -12613,7 +12618,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_test_epi64_mask() { + const unsafe fn test_mm256_mask_test_epi64_mask() { let a = _mm256_set1_epi64x(1 << 0); let b = _mm256_set1_epi64x(1 << 0 | 1 << 1); let r = _mm256_mask_test_epi64_mask(0, a, b); @@ -12624,7 +12629,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_test_epi64_mask() { + const unsafe fn test_mm_test_epi64_mask() { let a = _mm_set1_epi64x(1 << 0); let b = _mm_set1_epi64x(1 << 0 | 1 << 1); let r = _mm_test_epi64_mask(a, b); @@ -12633,7 +12638,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_test_epi64_mask() { + const unsafe fn test_mm_mask_test_epi64_mask() { let a = _mm_set1_epi64x(1 << 0); let b = _mm_set1_epi64x(1 << 0 | 1 << 1); let r = _mm_mask_test_epi64_mask(0, a, b); @@ -12644,7 +12649,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_testn_epi64_mask() { + const unsafe fn test_mm512_testn_epi64_mask() { let a = _mm512_set1_epi64(1 << 0); let b = _mm512_set1_epi64(1 << 0 | 1 << 1); let r = _mm512_testn_epi64_mask(a, b); @@ -12653,7 +12658,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_testn_epi64_mask() { + const unsafe fn test_mm512_mask_testn_epi64_mask() { let a = _mm512_set1_epi64(1 << 0); let b = _mm512_set1_epi64(1 << 1); let r = _mm512_mask_testn_epi64_mask(0, a, b); @@ -12664,7 +12669,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_testn_epi64_mask() { + const unsafe fn test_mm256_testn_epi64_mask() { let a = _mm256_set1_epi64x(1 << 0); let b = _mm256_set1_epi64x(1 << 1); let r = _mm256_testn_epi64_mask(a, b); @@ -12673,7 +12678,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_testn_epi64_mask() { + const unsafe fn test_mm256_mask_testn_epi64_mask() { let a = _mm256_set1_epi64x(1 << 0); let b = _mm256_set1_epi64x(1 << 1); let r = _mm256_mask_testn_epi64_mask(0, a, b); @@ -12684,7 +12689,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_testn_epi64_mask() { + const unsafe fn test_mm_testn_epi64_mask() { let a = _mm_set1_epi64x(1 << 0); let b = _mm_set1_epi64x(1 << 1); let r = _mm_testn_epi64_mask(a, b); @@ -12693,7 +12698,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_testn_epi64_mask() { + const unsafe fn test_mm_mask_testn_epi64_mask() { let a = _mm_set1_epi64x(1 << 0); let b = _mm_set1_epi64x(1 << 1); let r = _mm_mask_testn_epi64_mask(0, a, b); @@ -12704,7 +12709,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_mask_set1_epi64() { + const unsafe fn test_mm512_mask_set1_epi64() { let src = _mm512_set1_epi64(2); let a: i64 = 11; let r = _mm512_mask_set1_epi64(src, 0, a); @@ -12715,7 +12720,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm512_maskz_set1_epi64() { + const unsafe fn test_mm512_maskz_set1_epi64() { let a: i64 = 11; let r = _mm512_maskz_set1_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -12725,7 +12730,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_mask_set1_epi64() { + const unsafe fn test_mm256_mask_set1_epi64() { let src = _mm256_set1_epi64x(2); let a: i64 = 11; let r = _mm256_mask_set1_epi64(src, 0, a); @@ -12736,7 +12741,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm256_maskz_set1_epi64() { + const unsafe fn test_mm256_maskz_set1_epi64() { let a: i64 = 11; let r = _mm256_maskz_set1_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -12746,7 +12751,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_mask_set1_epi64() { + const unsafe fn test_mm_mask_set1_epi64() { let src = _mm_set1_epi64x(2); let a: i64 = 11; let r = _mm_mask_set1_epi64(src, 0, a); @@ -12757,7 +12762,7 @@ mod tests { } #[simd_test(enable = "avx512f,avx512vl")] - unsafe fn test_mm_maskz_set1_epi64() { + const unsafe fn test_mm_maskz_set1_epi64() { let a: i64 = 11; let r = _mm_maskz_set1_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -12801,7 +12806,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvti64_ss() { + const unsafe fn test_mm_cvti64_ss() { let a = _mm_set_ps(0., -0.5, 1., -1.5); let b: i64 = 9; let r = _mm_cvti64_ss(a, b); @@ -12810,7 +12815,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvti64_sd() { + const unsafe fn test_mm_cvti64_sd() { let a = _mm_set_pd(1., -1.5); let b: i64 = 9; let r = _mm_cvti64_sd(a, b); @@ -12963,7 +12968,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvtu64_ss() { + const unsafe fn test_mm_cvtu64_ss() { let a = _mm_set_ps(0., -0.5, 1., -1.5); let b: u64 = 9; let r = _mm_cvtu64_ss(a, b); @@ -12972,7 +12977,7 @@ mod tests { } #[simd_test(enable = "avx512f")] - unsafe fn test_mm_cvtu64_sd() { + const unsafe fn test_mm_cvtu64_sd() { let a = _mm_set_pd(1., -1.5); let b: u64 = 9; let r = _mm_cvtu64_sd(a, b); From b2db9ab8b5d1b60603b843249398304638d4ac0b Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:23:10 +0530 Subject: [PATCH 069/489] Make `avx512bw` functions const --- .../crates/core_arch/src/x86/avx512bw.rs | 3738 ++++++++++------- .../crates/core_arch/src/x86_64/avx512bw.rs | 11 +- 2 files changed, 2332 insertions(+), 1417 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index c76ec3cb290e..b6e941908a76 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -14,7 +14,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm512_abs_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_epi16(a: __m512i) -> __m512i { unsafe { let a = a.as_i16x32(); let cmp: i16x32 = simd_gt(a, i16x32::ZERO); @@ -29,7 +30,8 @@ pub fn _mm512_abs_epi16(a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm512_mask_abs_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_abs_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, abs, src.as_i16x32())) @@ -43,7 +45,8 @@ pub fn _mm512_mask_abs_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm512_maskz_abs_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_abs_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, abs, i16x32::ZERO)) @@ -57,7 +60,8 @@ pub fn _mm512_maskz_abs_epi16(k: __mmask32, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm256_mask_abs_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_abs_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, abs, src.as_i16x16())) @@ -71,7 +75,8 @@ pub fn _mm256_mask_abs_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm256_maskz_abs_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_abs_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, abs, i16x16::ZERO)) @@ -85,7 +90,8 @@ pub fn _mm256_maskz_abs_epi16(k: __mmask16, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm_mask_abs_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_abs_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, abs, src.as_i16x8())) @@ -99,7 +105,8 @@ pub fn _mm_mask_abs_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsw))] -pub fn _mm_maskz_abs_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_abs_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, abs, i16x8::ZERO)) @@ -113,7 +120,8 @@ pub fn _mm_maskz_abs_epi16(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm512_abs_epi8(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_epi8(a: __m512i) -> __m512i { unsafe { let a = a.as_i8x64(); let cmp: i8x64 = simd_gt(a, i8x64::ZERO); @@ -128,7 +136,8 @@ pub fn _mm512_abs_epi8(a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm512_mask_abs_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_abs_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi8(a).as_i8x64(); transmute(simd_select_bitmask(k, abs, src.as_i8x64())) @@ -142,7 +151,8 @@ pub fn _mm512_mask_abs_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm512_maskz_abs_epi8(k: __mmask64, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_abs_epi8(k: __mmask64, a: __m512i) -> __m512i { unsafe { let abs = _mm512_abs_epi8(a).as_i8x64(); transmute(simd_select_bitmask(k, abs, i8x64::ZERO)) @@ -156,7 +166,8 @@ pub fn _mm512_maskz_abs_epi8(k: __mmask64, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm256_mask_abs_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_abs_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, abs, src.as_i8x32())) @@ -170,7 +181,8 @@ pub fn _mm256_mask_abs_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm256_maskz_abs_epi8(k: __mmask32, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_abs_epi8(k: __mmask32, a: __m256i) -> __m256i { unsafe { let abs = _mm256_abs_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, abs, i8x32::ZERO)) @@ -184,7 +196,8 @@ pub fn _mm256_maskz_abs_epi8(k: __mmask32, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm_mask_abs_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_abs_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, abs, src.as_i8x16())) @@ -198,7 +211,8 @@ pub fn _mm_mask_abs_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpabsb))] -pub fn _mm_maskz_abs_epi8(k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_abs_epi8(k: __mmask16, a: __m128i) -> __m128i { unsafe { let abs = _mm_abs_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, abs, i8x16::ZERO)) @@ -212,7 +226,8 @@ pub fn _mm_maskz_abs_epi8(k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm512_add_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_add(a.as_i16x32(), b.as_i16x32())) } } @@ -223,7 +238,8 @@ pub fn _mm512_add_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm512_mask_add_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, add, src.as_i16x32())) @@ -237,7 +253,8 @@ pub fn _mm512_mask_add_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm512_maskz_add_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, add, i16x32::ZERO)) @@ -251,7 +268,8 @@ pub fn _mm512_maskz_add_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm256_mask_add_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, add, src.as_i16x16())) @@ -265,7 +283,8 @@ pub fn _mm256_mask_add_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm256_maskz_add_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, add, i16x16::ZERO)) @@ -279,7 +298,8 @@ pub fn _mm256_maskz_add_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm_mask_add_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, add, src.as_i16x8())) @@ -293,7 +313,8 @@ pub fn _mm_mask_add_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddw))] -pub fn _mm_maskz_add_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, add, i16x8::ZERO)) @@ -307,7 +328,8 @@ pub fn _mm_maskz_add_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm512_add_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_add(a.as_i8x64(), b.as_i8x64())) } } @@ -318,7 +340,8 @@ pub fn _mm512_add_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm512_mask_add_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, add, src.as_i8x64())) @@ -332,7 +355,8 @@ pub fn _mm512_mask_add_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm512_maskz_add_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_add_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, add, i8x64::ZERO)) @@ -346,7 +370,8 @@ pub fn _mm512_maskz_add_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm256_mask_add_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, add, src.as_i8x32())) @@ -360,7 +385,8 @@ pub fn _mm256_mask_add_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm256_maskz_add_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_add_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, add, i8x32::ZERO)) @@ -374,7 +400,8 @@ pub fn _mm256_maskz_add_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm_mask_add_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, add, src.as_i8x16())) @@ -388,7 +415,8 @@ pub fn _mm_mask_add_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddb))] -pub fn _mm_maskz_add_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_add_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, add, i8x16::ZERO)) @@ -402,7 +430,8 @@ pub fn _mm_maskz_add_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm512_adds_epu16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_adds_epu16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_add(a.as_u16x32(), b.as_u16x32())) } } @@ -413,7 +442,8 @@ pub fn _mm512_adds_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm512_mask_adds_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_adds_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, add, src.as_u16x32())) @@ -427,7 +457,8 @@ pub fn _mm512_mask_adds_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm512_maskz_adds_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_adds_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, add, u16x32::ZERO)) @@ -441,7 +472,8 @@ pub fn _mm512_maskz_adds_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm256_mask_adds_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_adds_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, add, src.as_u16x16())) @@ -455,7 +487,8 @@ pub fn _mm256_mask_adds_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm256_maskz_adds_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_adds_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, add, u16x16::ZERO)) @@ -469,7 +502,8 @@ pub fn _mm256_maskz_adds_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm_mask_adds_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_adds_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, add, src.as_u16x8())) @@ -483,7 +517,8 @@ pub fn _mm_mask_adds_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusw))] -pub fn _mm_maskz_adds_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_adds_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, add, u16x8::ZERO)) @@ -497,7 +532,8 @@ pub fn _mm_maskz_adds_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm512_adds_epu8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_adds_epu8(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_add(a.as_u8x64(), b.as_u8x64())) } } @@ -508,7 +544,8 @@ pub fn _mm512_adds_epu8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm512_mask_adds_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_adds_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, add, src.as_u8x64())) @@ -522,7 +559,8 @@ pub fn _mm512_mask_adds_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm512_maskz_adds_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_adds_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, add, u8x64::ZERO)) @@ -536,7 +574,8 @@ pub fn _mm512_maskz_adds_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm256_mask_adds_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_adds_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, add, src.as_u8x32())) @@ -550,7 +589,8 @@ pub fn _mm256_mask_adds_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm256_maskz_adds_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_adds_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, add, u8x32::ZERO)) @@ -564,7 +604,8 @@ pub fn _mm256_maskz_adds_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm_mask_adds_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_adds_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, add, src.as_u8x16())) @@ -578,7 +619,8 @@ pub fn _mm_mask_adds_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddusb))] -pub fn _mm_maskz_adds_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_adds_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, add, u8x16::ZERO)) @@ -592,7 +634,8 @@ pub fn _mm_maskz_adds_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm512_adds_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_adds_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_add(a.as_i16x32(), b.as_i16x32())) } } @@ -603,7 +646,8 @@ pub fn _mm512_adds_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm512_mask_adds_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_adds_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, add, src.as_i16x32())) @@ -617,7 +661,8 @@ pub fn _mm512_mask_adds_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm512_maskz_adds_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_adds_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, add, i16x32::ZERO)) @@ -631,7 +676,8 @@ pub fn _mm512_maskz_adds_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm256_mask_adds_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_adds_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, add, src.as_i16x16())) @@ -645,7 +691,8 @@ pub fn _mm256_mask_adds_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm256_maskz_adds_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_adds_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, add, i16x16::ZERO)) @@ -659,7 +706,8 @@ pub fn _mm256_maskz_adds_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm_mask_adds_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_adds_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, add, src.as_i16x8())) @@ -673,7 +721,8 @@ pub fn _mm_mask_adds_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsw))] -pub fn _mm_maskz_adds_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_adds_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, add, i16x8::ZERO)) @@ -687,7 +736,8 @@ pub fn _mm_maskz_adds_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm512_adds_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_adds_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_add(a.as_i8x64(), b.as_i8x64())) } } @@ -698,7 +748,8 @@ pub fn _mm512_adds_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm512_mask_adds_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_adds_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, add, src.as_i8x64())) @@ -712,7 +763,8 @@ pub fn _mm512_mask_adds_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm512_maskz_adds_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_adds_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let add = _mm512_adds_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, add, i8x64::ZERO)) @@ -726,7 +778,8 @@ pub fn _mm512_maskz_adds_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm256_mask_adds_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_adds_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, add, src.as_i8x32())) @@ -740,7 +793,8 @@ pub fn _mm256_mask_adds_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm256_maskz_adds_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_adds_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let add = _mm256_adds_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, add, i8x32::ZERO)) @@ -754,7 +808,8 @@ pub fn _mm256_maskz_adds_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm_mask_adds_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_adds_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, add, src.as_i8x16())) @@ -768,7 +823,8 @@ pub fn _mm_mask_adds_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpaddsb))] -pub fn _mm_maskz_adds_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_adds_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let add = _mm_adds_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, add, i8x16::ZERO)) @@ -782,7 +838,8 @@ pub fn _mm_maskz_adds_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm512_sub_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_sub(a.as_i16x32(), b.as_i16x32())) } } @@ -793,7 +850,8 @@ pub fn _mm512_sub_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm512_mask_sub_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, sub, src.as_i16x32())) @@ -807,7 +865,8 @@ pub fn _mm512_mask_sub_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm512_maskz_sub_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, sub, i16x32::ZERO)) @@ -821,7 +880,8 @@ pub fn _mm512_maskz_sub_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm256_mask_sub_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, sub, src.as_i16x16())) @@ -835,7 +895,8 @@ pub fn _mm256_mask_sub_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm256_maskz_sub_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, sub, i16x16::ZERO)) @@ -849,7 +910,8 @@ pub fn _mm256_maskz_sub_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm_mask_sub_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, sub, src.as_i16x8())) @@ -863,7 +925,8 @@ pub fn _mm_mask_sub_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubw))] -pub fn _mm_maskz_sub_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, sub, i16x8::ZERO)) @@ -877,7 +940,8 @@ pub fn _mm_maskz_sub_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm512_sub_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_sub(a.as_i8x64(), b.as_i8x64())) } } @@ -888,7 +952,8 @@ pub fn _mm512_sub_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm512_mask_sub_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, sub, src.as_i8x64())) @@ -902,7 +967,8 @@ pub fn _mm512_mask_sub_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm512_maskz_sub_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_sub_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, sub, i8x64::ZERO)) @@ -916,7 +982,8 @@ pub fn _mm512_maskz_sub_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm256_mask_sub_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, sub, src.as_i8x32())) @@ -930,7 +997,8 @@ pub fn _mm256_mask_sub_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm256_maskz_sub_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_sub_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, sub, i8x32::ZERO)) @@ -944,7 +1012,8 @@ pub fn _mm256_maskz_sub_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm_mask_sub_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, sub, src.as_i8x16())) @@ -958,7 +1027,8 @@ pub fn _mm_mask_sub_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubb))] -pub fn _mm_maskz_sub_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_sub_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, sub, i8x16::ZERO)) @@ -972,7 +1042,8 @@ pub fn _mm_maskz_sub_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm512_subs_epu16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_subs_epu16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_sub(a.as_u16x32(), b.as_u16x32())) } } @@ -983,7 +1054,8 @@ pub fn _mm512_subs_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm512_mask_subs_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_subs_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, sub, src.as_u16x32())) @@ -997,7 +1069,8 @@ pub fn _mm512_mask_subs_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm512_maskz_subs_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_subs_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, sub, u16x32::ZERO)) @@ -1011,7 +1084,8 @@ pub fn _mm512_maskz_subs_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm256_mask_subs_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_subs_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, sub, src.as_u16x16())) @@ -1025,7 +1099,8 @@ pub fn _mm256_mask_subs_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm256_maskz_subs_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_subs_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, sub, u16x16::ZERO)) @@ -1039,7 +1114,8 @@ pub fn _mm256_maskz_subs_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm_mask_subs_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_subs_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, sub, src.as_u16x8())) @@ -1053,7 +1129,8 @@ pub fn _mm_mask_subs_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusw))] -pub fn _mm_maskz_subs_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_subs_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, sub, u16x8::ZERO)) @@ -1067,7 +1144,8 @@ pub fn _mm_maskz_subs_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm512_subs_epu8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_subs_epu8(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_sub(a.as_u8x64(), b.as_u8x64())) } } @@ -1078,7 +1156,8 @@ pub fn _mm512_subs_epu8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm512_mask_subs_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_subs_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, sub, src.as_u8x64())) @@ -1092,7 +1171,8 @@ pub fn _mm512_mask_subs_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm512_maskz_subs_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_subs_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, sub, u8x64::ZERO)) @@ -1106,7 +1186,8 @@ pub fn _mm512_maskz_subs_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm256_mask_subs_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_subs_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, sub, src.as_u8x32())) @@ -1120,7 +1201,8 @@ pub fn _mm256_mask_subs_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm256_maskz_subs_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_subs_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, sub, u8x32::ZERO)) @@ -1134,7 +1216,8 @@ pub fn _mm256_maskz_subs_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm_mask_subs_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_subs_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, sub, src.as_u8x16())) @@ -1148,7 +1231,8 @@ pub fn _mm_mask_subs_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubusb))] -pub fn _mm_maskz_subs_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_subs_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, sub, u8x16::ZERO)) @@ -1162,7 +1246,8 @@ pub fn _mm_maskz_subs_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm512_subs_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_subs_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_sub(a.as_i16x32(), b.as_i16x32())) } } @@ -1173,7 +1258,8 @@ pub fn _mm512_subs_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm512_mask_subs_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_subs_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, sub, src.as_i16x32())) @@ -1187,7 +1273,8 @@ pub fn _mm512_mask_subs_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm512_maskz_subs_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_subs_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, sub, i16x32::ZERO)) @@ -1201,7 +1288,8 @@ pub fn _mm512_maskz_subs_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm256_mask_subs_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_subs_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, sub, src.as_i16x16())) @@ -1215,7 +1303,8 @@ pub fn _mm256_mask_subs_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm256_maskz_subs_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_subs_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, sub, i16x16::ZERO)) @@ -1229,7 +1318,8 @@ pub fn _mm256_maskz_subs_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm_mask_subs_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_subs_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, sub, src.as_i16x8())) @@ -1243,7 +1333,8 @@ pub fn _mm_mask_subs_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsw))] -pub fn _mm_maskz_subs_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_subs_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, sub, i16x8::ZERO)) @@ -1257,7 +1348,8 @@ pub fn _mm_maskz_subs_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm512_subs_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_subs_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_saturating_sub(a.as_i8x64(), b.as_i8x64())) } } @@ -1268,7 +1360,8 @@ pub fn _mm512_subs_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm512_mask_subs_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_subs_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, sub, src.as_i8x64())) @@ -1282,7 +1375,8 @@ pub fn _mm512_mask_subs_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm512_maskz_subs_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_subs_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let sub = _mm512_subs_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, sub, i8x64::ZERO)) @@ -1296,7 +1390,8 @@ pub fn _mm512_maskz_subs_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm256_mask_subs_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_subs_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, sub, src.as_i8x32())) @@ -1310,7 +1405,8 @@ pub fn _mm256_mask_subs_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm256_maskz_subs_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_subs_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let sub = _mm256_subs_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, sub, i8x32::ZERO)) @@ -1324,7 +1420,8 @@ pub fn _mm256_maskz_subs_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm_mask_subs_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_subs_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, sub, src.as_i8x16())) @@ -1338,7 +1435,8 @@ pub fn _mm_mask_subs_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsubsb))] -pub fn _mm_maskz_subs_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_subs_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let sub = _mm_subs_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, sub, i8x16::ZERO)) @@ -1352,7 +1450,8 @@ pub fn _mm_maskz_subs_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm512_mulhi_epu16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mulhi_epu16(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = simd_cast::<_, u32x32>(a.as_u16x32()); let b = simd_cast::<_, u32x32>(b.as_u16x32()); @@ -1368,7 +1467,13 @@ pub fn _mm512_mulhi_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm512_mask_mulhi_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mulhi_epu16( + src: __m512i, + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let mul = _mm512_mulhi_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, mul, src.as_u16x32())) @@ -1382,7 +1487,8 @@ pub fn _mm512_mask_mulhi_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mulhi_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, mul, u16x32::ZERO)) @@ -1396,7 +1502,13 @@ pub fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm256_mask_mulhi_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mulhi_epu16( + src: __m256i, + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let mul = _mm256_mulhi_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, mul, src.as_u16x16())) @@ -1410,7 +1522,8 @@ pub fn _mm256_mask_mulhi_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm256_maskz_mulhi_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mulhi_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mulhi_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, mul, u16x16::ZERO)) @@ -1424,7 +1537,8 @@ pub fn _mm256_maskz_mulhi_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm_mask_mulhi_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mulhi_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, mul, src.as_u16x8())) @@ -1438,7 +1552,8 @@ pub fn _mm_mask_mulhi_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) - #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm_maskz_mulhi_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mulhi_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, mul, u16x8::ZERO)) @@ -1452,7 +1567,8 @@ pub fn _mm_maskz_mulhi_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm512_mulhi_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mulhi_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = simd_cast::<_, i32x32>(a.as_i16x32()); let b = simd_cast::<_, i32x32>(b.as_i16x32()); @@ -1468,7 +1584,13 @@ pub fn _mm512_mulhi_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm512_mask_mulhi_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mulhi_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let mul = _mm512_mulhi_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, mul, src.as_i16x32())) @@ -1482,7 +1604,8 @@ pub fn _mm512_mask_mulhi_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mulhi_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, mul, i16x32::ZERO)) @@ -1496,7 +1619,13 @@ pub fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm256_mask_mulhi_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mulhi_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let mul = _mm256_mulhi_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, mul, src.as_i16x16())) @@ -1510,7 +1639,8 @@ pub fn _mm256_mask_mulhi_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm256_maskz_mulhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mulhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mulhi_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, mul, i16x16::ZERO)) @@ -1524,7 +1654,8 @@ pub fn _mm256_maskz_mulhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm_mask_mulhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mulhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, mul, src.as_i16x8())) @@ -1538,7 +1669,8 @@ pub fn _mm_mask_mulhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) - #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm_maskz_mulhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mulhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, mul, i16x8::ZERO)) @@ -1647,7 +1779,8 @@ pub fn _mm_maskz_mulhrs_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm512_mullo_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mullo_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_mul(a.as_i16x32(), b.as_i16x32())) } } @@ -1658,7 +1791,13 @@ pub fn _mm512_mullo_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm512_mask_mullo_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mullo_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let mul = _mm512_mullo_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, mul, src.as_i16x32())) @@ -1672,7 +1811,8 @@ pub fn _mm512_mask_mullo_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm512_maskz_mullo_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mullo_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mullo_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, mul, i16x32::ZERO)) @@ -1686,7 +1826,13 @@ pub fn _mm512_maskz_mullo_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm256_mask_mullo_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mullo_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let mul = _mm256_mullo_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, mul, src.as_i16x16())) @@ -1700,7 +1846,8 @@ pub fn _mm256_mask_mullo_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm256_maskz_mullo_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mullo_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mullo_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, mul, i16x16::ZERO)) @@ -1714,7 +1861,8 @@ pub fn _mm256_maskz_mullo_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm_mask_mullo_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mullo_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mullo_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, mul, src.as_i16x8())) @@ -1728,7 +1876,8 @@ pub fn _mm_mask_mullo_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) - #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmullw))] -pub fn _mm_maskz_mullo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mullo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mullo_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, mul, i16x8::ZERO)) @@ -1742,7 +1891,8 @@ pub fn _mm_maskz_mullo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm512_max_epu16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epu16(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_u16x32(), b.as_u16x32()).as_m512i() } } @@ -1753,7 +1903,8 @@ pub fn _mm512_max_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm512_mask_max_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, max, src.as_u16x32())) @@ -1767,7 +1918,8 @@ pub fn _mm512_mask_max_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm512_maskz_max_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, max, u16x32::ZERO)) @@ -1781,7 +1933,8 @@ pub fn _mm512_maskz_max_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm256_mask_max_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, max, src.as_u16x16())) @@ -1795,7 +1948,8 @@ pub fn _mm256_mask_max_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm256_maskz_max_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, max, u16x16::ZERO)) @@ -1809,7 +1963,8 @@ pub fn _mm256_maskz_max_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm_mask_max_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, max, src.as_u16x8())) @@ -1823,7 +1978,8 @@ pub fn _mm_mask_max_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxuw))] -pub fn _mm_maskz_max_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, max, u16x8::ZERO)) @@ -1837,7 +1993,8 @@ pub fn _mm_maskz_max_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm512_max_epu8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epu8(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_u8x64(), b.as_u8x64()).as_m512i() } } @@ -1848,7 +2005,8 @@ pub fn _mm512_max_epu8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm512_mask_max_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, max, src.as_u8x64())) @@ -1862,7 +2020,8 @@ pub fn _mm512_mask_max_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm512_maskz_max_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, max, u8x64::ZERO)) @@ -1876,7 +2035,8 @@ pub fn _mm512_maskz_max_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm256_mask_max_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, max, src.as_u8x32())) @@ -1890,7 +2050,8 @@ pub fn _mm256_mask_max_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm256_maskz_max_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, max, u8x32::ZERO)) @@ -1904,7 +2065,8 @@ pub fn _mm256_maskz_max_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm_mask_max_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, max, src.as_u8x16())) @@ -1918,7 +2080,8 @@ pub fn _mm_mask_max_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxub))] -pub fn _mm_maskz_max_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, max, u8x16::ZERO)) @@ -1932,7 +2095,8 @@ pub fn _mm_maskz_max_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm512_max_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_i16x32(), b.as_i16x32()).as_m512i() } } @@ -1943,7 +2107,8 @@ pub fn _mm512_max_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm512_mask_max_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, max, src.as_i16x32())) @@ -1957,7 +2122,8 @@ pub fn _mm512_mask_max_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm512_maskz_max_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, max, i16x32::ZERO)) @@ -1971,7 +2137,8 @@ pub fn _mm512_maskz_max_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm256_mask_max_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, max, src.as_i16x16())) @@ -1985,7 +2152,8 @@ pub fn _mm256_mask_max_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm256_maskz_max_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, max, i16x16::ZERO)) @@ -1999,7 +2167,8 @@ pub fn _mm256_maskz_max_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm_mask_max_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, max, src.as_i16x8())) @@ -2013,7 +2182,8 @@ pub fn _mm_mask_max_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsw))] -pub fn _mm_maskz_max_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, max, i16x8::ZERO)) @@ -2027,7 +2197,8 @@ pub fn _mm_maskz_max_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm512_max_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_max_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imax(a.as_i8x64(), b.as_i8x64()).as_m512i() } } @@ -2038,7 +2209,8 @@ pub fn _mm512_max_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm512_mask_max_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_max_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, max, src.as_i8x64())) @@ -2052,7 +2224,8 @@ pub fn _mm512_mask_max_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm512_maskz_max_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_max_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let max = _mm512_max_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, max, i8x64::ZERO)) @@ -2066,7 +2239,8 @@ pub fn _mm512_maskz_max_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm256_mask_max_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_max_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, max, src.as_i8x32())) @@ -2080,7 +2254,8 @@ pub fn _mm256_mask_max_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm256_maskz_max_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_max_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let max = _mm256_max_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, max, i8x32::ZERO)) @@ -2094,7 +2269,8 @@ pub fn _mm256_maskz_max_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm_mask_max_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_max_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, max, src.as_i8x16())) @@ -2108,7 +2284,8 @@ pub fn _mm_mask_max_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaxsb))] -pub fn _mm_maskz_max_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_max_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let max = _mm_max_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, max, i8x16::ZERO)) @@ -2122,7 +2299,8 @@ pub fn _mm_maskz_max_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm512_min_epu16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epu16(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_u16x32(), b.as_u16x32()).as_m512i() } } @@ -2133,7 +2311,8 @@ pub fn _mm512_min_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm512_mask_min_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, min, src.as_u16x32())) @@ -2147,7 +2326,8 @@ pub fn _mm512_mask_min_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm512_maskz_min_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, min, u16x32::ZERO)) @@ -2161,7 +2341,8 @@ pub fn _mm512_maskz_min_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm256_mask_min_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, min, src.as_u16x16())) @@ -2175,7 +2356,8 @@ pub fn _mm256_mask_min_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm256_maskz_min_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, min, u16x16::ZERO)) @@ -2189,7 +2371,8 @@ pub fn _mm256_maskz_min_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm_mask_min_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, min, src.as_u16x8())) @@ -2203,7 +2386,8 @@ pub fn _mm_mask_min_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminuw))] -pub fn _mm_maskz_min_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, min, u16x8::ZERO)) @@ -2217,7 +2401,8 @@ pub fn _mm_maskz_min_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm512_min_epu8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epu8(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_u8x64(), b.as_u8x64()).as_m512i() } } @@ -2228,7 +2413,8 @@ pub fn _mm512_min_epu8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm512_mask_min_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, min, src.as_u8x64())) @@ -2242,7 +2428,8 @@ pub fn _mm512_mask_min_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm512_maskz_min_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, min, u8x64::ZERO)) @@ -2256,7 +2443,8 @@ pub fn _mm512_maskz_min_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm256_mask_min_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, min, src.as_u8x32())) @@ -2270,7 +2458,8 @@ pub fn _mm256_mask_min_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm256_maskz_min_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, min, u8x32::ZERO)) @@ -2284,7 +2473,8 @@ pub fn _mm256_maskz_min_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm_mask_min_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, min, src.as_u8x16())) @@ -2298,7 +2488,8 @@ pub fn _mm_mask_min_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminub))] -pub fn _mm_maskz_min_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, min, u8x16::ZERO)) @@ -2312,7 +2503,8 @@ pub fn _mm_maskz_min_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm512_min_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_i16x32(), b.as_i16x32()).as_m512i() } } @@ -2323,7 +2515,8 @@ pub fn _mm512_min_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm512_mask_min_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, min, src.as_i16x32())) @@ -2337,7 +2530,8 @@ pub fn _mm512_mask_min_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm512_maskz_min_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, min, i16x32::ZERO)) @@ -2351,7 +2545,8 @@ pub fn _mm512_maskz_min_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm256_mask_min_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, min, src.as_i16x16())) @@ -2365,7 +2560,8 @@ pub fn _mm256_mask_min_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm256_maskz_min_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, min, i16x16::ZERO)) @@ -2379,7 +2575,8 @@ pub fn _mm256_maskz_min_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm_mask_min_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, min, src.as_i16x8())) @@ -2393,7 +2590,8 @@ pub fn _mm_mask_min_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsw))] -pub fn _mm_maskz_min_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, min, i16x8::ZERO)) @@ -2407,7 +2605,8 @@ pub fn _mm_maskz_min_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm512_min_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_min_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { simd_imin(a.as_i8x64(), b.as_i8x64()).as_m512i() } } @@ -2418,7 +2617,8 @@ pub fn _mm512_min_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm512_mask_min_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_min_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, min, src.as_i8x64())) @@ -2432,7 +2632,8 @@ pub fn _mm512_mask_min_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm512_maskz_min_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_min_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let min = _mm512_min_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, min, i8x64::ZERO)) @@ -2446,7 +2647,8 @@ pub fn _mm512_maskz_min_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm256_mask_min_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_min_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, min, src.as_i8x32())) @@ -2460,7 +2662,8 @@ pub fn _mm256_mask_min_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm256_maskz_min_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_min_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let min = _mm256_min_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, min, i8x32::ZERO)) @@ -2474,7 +2677,8 @@ pub fn _mm256_maskz_min_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm_mask_min_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_min_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, min, src.as_i8x16())) @@ -2488,7 +2692,8 @@ pub fn _mm_mask_min_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpminsb))] -pub fn _mm_maskz_min_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_min_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let min = _mm_min_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, min, i8x16::ZERO)) @@ -2502,7 +2707,8 @@ pub fn _mm_maskz_min_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmplt_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_lt(a.as_u16x32(), b.as_u16x32())) } } @@ -2513,7 +2719,8 @@ pub fn _mm512_cmplt_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmplt_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epu16_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2524,7 +2731,8 @@ pub fn _mm512_mask_cmplt_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmplt_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_lt(a.as_u16x16(), b.as_u16x16())) } } @@ -2535,7 +2743,8 @@ pub fn _mm256_cmplt_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmplt_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epu16_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2546,7 +2755,8 @@ pub fn _mm256_mask_cmplt_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmplt_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_lt(a.as_u16x8(), b.as_u16x8())) } } @@ -2557,7 +2767,8 @@ pub fn _mm_cmplt_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmplt_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu16_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2568,7 +2779,8 @@ pub fn _mm_mask_cmplt_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmplt_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_lt(a.as_u8x64(), b.as_u8x64())) } } @@ -2579,7 +2791,8 @@ pub fn _mm512_cmplt_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmplt_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epu8_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2590,7 +2803,8 @@ pub fn _mm512_mask_cmplt_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmplt_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_lt(a.as_u8x32(), b.as_u8x32())) } } @@ -2601,7 +2815,8 @@ pub fn _mm256_cmplt_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmplt_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epu8_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2612,7 +2827,8 @@ pub fn _mm256_mask_cmplt_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmplt_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_lt(a.as_u8x16(), b.as_u8x16())) } } @@ -2623,7 +2839,8 @@ pub fn _mm_cmplt_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmplt_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epu8_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2634,7 +2851,8 @@ pub fn _mm_mask_cmplt_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmplt_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_lt(a.as_i16x32(), b.as_i16x32())) } } @@ -2645,7 +2863,8 @@ pub fn _mm512_cmplt_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmplt_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epi16_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2656,7 +2875,8 @@ pub fn _mm512_mask_cmplt_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmplt_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_lt(a.as_i16x16(), b.as_i16x16())) } } @@ -2667,7 +2887,8 @@ pub fn _mm256_cmplt_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmplt_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epi16_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2678,7 +2899,8 @@ pub fn _mm256_mask_cmplt_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmplt_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_lt(a.as_i16x8(), b.as_i16x8())) } } @@ -2689,7 +2911,8 @@ pub fn _mm_cmplt_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmplt_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi16_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2700,7 +2923,8 @@ pub fn _mm_mask_cmplt_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmplt_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmplt_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_lt(a.as_i8x64(), b.as_i8x64())) } } @@ -2711,7 +2935,8 @@ pub fn _mm512_cmplt_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmplt_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmplt_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epi8_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2722,7 +2947,8 @@ pub fn _mm512_mask_cmplt_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmplt_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmplt_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_lt(a.as_i8x32(), b.as_i8x32())) } } @@ -2733,7 +2959,8 @@ pub fn _mm256_cmplt_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmplt_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmplt_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epi8_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2744,7 +2971,8 @@ pub fn _mm256_mask_cmplt_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmplt_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmplt_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_lt(a.as_i8x16(), b.as_i8x16())) } } @@ -2755,7 +2983,8 @@ pub fn _mm_cmplt_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmplt_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmplt_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epi8_mask::<_MM_CMPINT_LT>(k1, a, b) } @@ -2766,7 +2995,8 @@ pub fn _mm_mask_cmplt_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpgt_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_gt(a.as_u16x32(), b.as_u16x32())) } } @@ -2777,7 +3007,8 @@ pub fn _mm512_cmpgt_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpgt_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epu16_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2788,7 +3019,8 @@ pub fn _mm512_mask_cmpgt_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpgt_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_gt(a.as_u16x16(), b.as_u16x16())) } } @@ -2799,7 +3031,8 @@ pub fn _mm256_cmpgt_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpgt_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epu16_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2810,7 +3043,8 @@ pub fn _mm256_mask_cmpgt_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpgt_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_gt(a.as_u16x8(), b.as_u16x8())) } } @@ -2821,7 +3055,8 @@ pub fn _mm_cmpgt_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpgt_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu16_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2832,7 +3067,8 @@ pub fn _mm_mask_cmpgt_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpgt_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_gt(a.as_u8x64(), b.as_u8x64())) } } @@ -2843,7 +3079,8 @@ pub fn _mm512_cmpgt_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpgt_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epu8_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2854,7 +3091,8 @@ pub fn _mm512_mask_cmpgt_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpgt_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_gt(a.as_u8x32(), b.as_u8x32())) } } @@ -2865,7 +3103,8 @@ pub fn _mm256_cmpgt_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpgt_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epu8_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2876,7 +3115,8 @@ pub fn _mm256_mask_cmpgt_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpgt_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_gt(a.as_u8x16(), b.as_u8x16())) } } @@ -2887,7 +3127,8 @@ pub fn _mm_cmpgt_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpgt_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epu8_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2898,7 +3139,8 @@ pub fn _mm_mask_cmpgt_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpgt_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_gt(a.as_i16x32(), b.as_i16x32())) } } @@ -2909,7 +3151,8 @@ pub fn _mm512_cmpgt_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpgt_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epi16_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2920,7 +3163,8 @@ pub fn _mm512_mask_cmpgt_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpgt_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_gt(a.as_i16x16(), b.as_i16x16())) } } @@ -2931,7 +3175,8 @@ pub fn _mm256_cmpgt_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpgt_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epi16_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2942,7 +3187,8 @@ pub fn _mm256_mask_cmpgt_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpgt_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_gt(a.as_i16x8(), b.as_i16x8())) } } @@ -2953,7 +3199,8 @@ pub fn _mm_cmpgt_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpgt_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi16_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2964,7 +3211,8 @@ pub fn _mm_mask_cmpgt_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpgt_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpgt_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_gt(a.as_i8x64(), b.as_i8x64())) } } @@ -2975,7 +3223,8 @@ pub fn _mm512_cmpgt_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpgt_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpgt_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epi8_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -2986,7 +3235,8 @@ pub fn _mm512_mask_cmpgt_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpgt_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpgt_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_gt(a.as_i8x32(), b.as_i8x32())) } } @@ -2997,7 +3247,8 @@ pub fn _mm256_cmpgt_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpgt_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpgt_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epi8_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -3008,7 +3259,8 @@ pub fn _mm256_mask_cmpgt_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpgt_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpgt_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_gt(a.as_i8x16(), b.as_i8x16())) } } @@ -3019,7 +3271,8 @@ pub fn _mm_cmpgt_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpgt_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpgt_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epi8_mask::<_MM_CMPINT_NLE>(k1, a, b) } @@ -3030,7 +3283,8 @@ pub fn _mm_mask_cmpgt_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmple_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_le(a.as_u16x32(), b.as_u16x32())) } } @@ -3041,7 +3295,8 @@ pub fn _mm512_cmple_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmple_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epu16_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3052,7 +3307,8 @@ pub fn _mm512_mask_cmple_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmple_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_le(a.as_u16x16(), b.as_u16x16())) } } @@ -3063,7 +3319,8 @@ pub fn _mm256_cmple_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmple_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epu16_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3074,7 +3331,8 @@ pub fn _mm256_mask_cmple_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmple_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_le(a.as_u16x8(), b.as_u16x8())) } } @@ -3085,7 +3343,8 @@ pub fn _mm_cmple_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmple_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu16_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3096,7 +3355,8 @@ pub fn _mm_mask_cmple_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmple_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_le(a.as_u8x64(), b.as_u8x64())) } } @@ -3107,7 +3367,8 @@ pub fn _mm512_cmple_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmple_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epu8_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3118,7 +3379,8 @@ pub fn _mm512_mask_cmple_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmple_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_le(a.as_u8x32(), b.as_u8x32())) } } @@ -3129,7 +3391,8 @@ pub fn _mm256_cmple_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmple_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epu8_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3140,7 +3403,8 @@ pub fn _mm256_mask_cmple_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmple_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_le(a.as_u8x16(), b.as_u8x16())) } } @@ -3151,7 +3415,8 @@ pub fn _mm_cmple_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmple_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epu8_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3162,7 +3427,8 @@ pub fn _mm_mask_cmple_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmple_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_le(a.as_i16x32(), b.as_i16x32())) } } @@ -3173,7 +3439,8 @@ pub fn _mm512_cmple_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmple_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epi16_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3184,7 +3451,8 @@ pub fn _mm512_mask_cmple_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmple_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_le(a.as_i16x16(), b.as_i16x16())) } } @@ -3195,7 +3463,8 @@ pub fn _mm256_cmple_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmple_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epi16_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3206,7 +3475,8 @@ pub fn _mm256_mask_cmple_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmple_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_le(a.as_i16x8(), b.as_i16x8())) } } @@ -3217,7 +3487,8 @@ pub fn _mm_cmple_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmple_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi16_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3228,7 +3499,8 @@ pub fn _mm_mask_cmple_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmple_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmple_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_le(a.as_i8x64(), b.as_i8x64())) } } @@ -3239,7 +3511,8 @@ pub fn _mm512_cmple_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmple_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmple_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epi8_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3250,7 +3523,8 @@ pub fn _mm512_mask_cmple_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmple_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmple_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_le(a.as_i8x32(), b.as_i8x32())) } } @@ -3261,7 +3535,8 @@ pub fn _mm256_cmple_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmple_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmple_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epi8_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3272,7 +3547,8 @@ pub fn _mm256_mask_cmple_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmple_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmple_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_le(a.as_i8x16(), b.as_i8x16())) } } @@ -3283,7 +3559,8 @@ pub fn _mm_cmple_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmple_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmple_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epi8_mask::<_MM_CMPINT_LE>(k1, a, b) } @@ -3294,7 +3571,8 @@ pub fn _mm_mask_cmple_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpge_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_ge(a.as_u16x32(), b.as_u16x32())) } } @@ -3305,7 +3583,8 @@ pub fn _mm512_cmpge_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpge_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epu16_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3316,7 +3595,8 @@ pub fn _mm512_mask_cmpge_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpge_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_ge(a.as_u16x16(), b.as_u16x16())) } } @@ -3327,7 +3607,8 @@ pub fn _mm256_cmpge_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpge_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epu16_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3338,7 +3619,8 @@ pub fn _mm256_mask_cmpge_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpge_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ge(a.as_u16x8(), b.as_u16x8())) } } @@ -3349,7 +3631,8 @@ pub fn _mm_cmpge_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpge_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu16_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3360,7 +3643,8 @@ pub fn _mm_mask_cmpge_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpge_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_ge(a.as_u8x64(), b.as_u8x64())) } } @@ -3371,7 +3655,8 @@ pub fn _mm512_cmpge_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpge_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epu8_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3382,7 +3667,8 @@ pub fn _mm512_mask_cmpge_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpge_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_ge(a.as_u8x32(), b.as_u8x32())) } } @@ -3393,7 +3679,8 @@ pub fn _mm256_cmpge_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpge_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epu8_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3404,7 +3691,8 @@ pub fn _mm256_mask_cmpge_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpge_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_ge(a.as_u8x16(), b.as_u8x16())) } } @@ -3415,7 +3703,8 @@ pub fn _mm_cmpge_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpge_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epu8_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3426,7 +3715,8 @@ pub fn _mm_mask_cmpge_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpge_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_ge(a.as_i16x32(), b.as_i16x32())) } } @@ -3437,7 +3727,8 @@ pub fn _mm512_cmpge_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpge_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epi16_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3448,7 +3739,8 @@ pub fn _mm512_mask_cmpge_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpge_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_ge(a.as_i16x16(), b.as_i16x16())) } } @@ -3459,7 +3751,8 @@ pub fn _mm256_cmpge_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpge_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epi16_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3470,7 +3763,8 @@ pub fn _mm256_mask_cmpge_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpge_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ge(a.as_i16x8(), b.as_i16x8())) } } @@ -3481,7 +3775,8 @@ pub fn _mm_cmpge_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpge_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi16_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3492,7 +3787,8 @@ pub fn _mm_mask_cmpge_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpge_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpge_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_ge(a.as_i8x64(), b.as_i8x64())) } } @@ -3503,7 +3799,8 @@ pub fn _mm512_cmpge_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpge_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpge_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epi8_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3514,7 +3811,8 @@ pub fn _mm512_mask_cmpge_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpge_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpge_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_ge(a.as_i8x32(), b.as_i8x32())) } } @@ -3525,7 +3823,8 @@ pub fn _mm256_cmpge_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpge_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpge_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epi8_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3536,7 +3835,8 @@ pub fn _mm256_mask_cmpge_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpge_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpge_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_ge(a.as_i8x16(), b.as_i8x16())) } } @@ -3547,7 +3847,8 @@ pub fn _mm_cmpge_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpge_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpge_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epi8_mask::<_MM_CMPINT_NLT>(k1, a, b) } @@ -3558,7 +3859,8 @@ pub fn _mm_mask_cmpge_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpeq_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_eq(a.as_u16x32(), b.as_u16x32())) } } @@ -3569,7 +3871,8 @@ pub fn _mm512_cmpeq_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpeq_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epu16_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3580,7 +3883,8 @@ pub fn _mm512_mask_cmpeq_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpeq_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_eq(a.as_u16x16(), b.as_u16x16())) } } @@ -3591,7 +3895,8 @@ pub fn _mm256_cmpeq_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpeq_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epu16_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3602,7 +3907,8 @@ pub fn _mm256_mask_cmpeq_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpeq_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_eq(a.as_u16x8(), b.as_u16x8())) } } @@ -3613,7 +3919,8 @@ pub fn _mm_cmpeq_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpeq_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu16_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3624,7 +3931,8 @@ pub fn _mm_mask_cmpeq_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpeq_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_eq(a.as_u8x64(), b.as_u8x64())) } } @@ -3635,7 +3943,8 @@ pub fn _mm512_cmpeq_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpeq_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epu8_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3646,7 +3955,8 @@ pub fn _mm512_mask_cmpeq_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpeq_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_eq(a.as_u8x32(), b.as_u8x32())) } } @@ -3657,7 +3967,8 @@ pub fn _mm256_cmpeq_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpeq_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epu8_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3668,7 +3979,8 @@ pub fn _mm256_mask_cmpeq_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpeq_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_eq(a.as_u8x16(), b.as_u8x16())) } } @@ -3679,7 +3991,8 @@ pub fn _mm_cmpeq_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpeq_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epu8_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3690,7 +4003,8 @@ pub fn _mm_mask_cmpeq_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpeq_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_eq(a.as_i16x32(), b.as_i16x32())) } } @@ -3701,7 +4015,8 @@ pub fn _mm512_cmpeq_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpeq_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epi16_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3712,7 +4027,8 @@ pub fn _mm512_mask_cmpeq_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpeq_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_eq(a.as_i16x16(), b.as_i16x16())) } } @@ -3723,7 +4039,8 @@ pub fn _mm256_cmpeq_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpeq_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epi16_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3734,7 +4051,8 @@ pub fn _mm256_mask_cmpeq_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpeq_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_eq(a.as_i16x8(), b.as_i16x8())) } } @@ -3745,7 +4063,8 @@ pub fn _mm_cmpeq_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpeq_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi16_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3756,7 +4075,8 @@ pub fn _mm_mask_cmpeq_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpeq_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpeq_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_eq(a.as_i8x64(), b.as_i8x64())) } } @@ -3767,7 +4087,8 @@ pub fn _mm512_cmpeq_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpeq_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpeq_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epi8_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3778,7 +4099,8 @@ pub fn _mm512_mask_cmpeq_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpeq_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpeq_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_eq(a.as_i8x32(), b.as_i8x32())) } } @@ -3789,7 +4111,8 @@ pub fn _mm256_cmpeq_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpeq_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpeq_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epi8_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3800,7 +4123,8 @@ pub fn _mm256_mask_cmpeq_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpeq_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpeq_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_eq(a.as_i8x16(), b.as_i8x16())) } } @@ -3811,7 +4135,8 @@ pub fn _mm_cmpeq_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpeq_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpeq_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epi8_mask::<_MM_CMPINT_EQ>(k1, a, b) } @@ -3822,7 +4147,8 @@ pub fn _mm_mask_cmpeq_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmas #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpneq_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_ne(a.as_u16x32(), b.as_u16x32())) } } @@ -3833,7 +4159,8 @@ pub fn _mm512_cmpneq_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpneq_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epu16_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3844,7 +4171,8 @@ pub fn _mm512_mask_cmpneq_epu16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpneq_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_ne(a.as_u16x16(), b.as_u16x16())) } } @@ -3855,7 +4183,8 @@ pub fn _mm256_cmpneq_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpneq_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epu16_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3866,7 +4195,8 @@ pub fn _mm256_mask_cmpneq_epu16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpneq_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ne(a.as_u16x8(), b.as_u16x8())) } } @@ -3877,7 +4207,8 @@ pub fn _mm_cmpneq_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpneq_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epu16_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3888,7 +4219,8 @@ pub fn _mm_mask_cmpneq_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mma #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpneq_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_ne(a.as_u8x64(), b.as_u8x64())) } } @@ -3899,7 +4231,8 @@ pub fn _mm512_cmpneq_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpneq_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epu8_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3910,7 +4243,8 @@ pub fn _mm512_mask_cmpneq_epu8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpneq_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_ne(a.as_u8x32(), b.as_u8x32())) } } @@ -3921,7 +4255,8 @@ pub fn _mm256_cmpneq_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpneq_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epu8_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3932,7 +4267,8 @@ pub fn _mm256_mask_cmpneq_epu8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpneq_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_ne(a.as_u8x16(), b.as_u8x16())) } } @@ -3943,7 +4279,8 @@ pub fn _mm_cmpneq_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpneq_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epu8_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3954,7 +4291,8 @@ pub fn _mm_mask_cmpneq_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mma #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpneq_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { simd_bitmask::(simd_ne(a.as_i16x32(), b.as_i16x32())) } } @@ -3965,7 +4303,8 @@ pub fn _mm512_cmpneq_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpneq_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { _mm512_mask_cmp_epi16_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3976,7 +4315,8 @@ pub fn _mm512_mask_cmpneq_epi16_mask(k1: __mmask32, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpneq_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { simd_bitmask::(simd_ne(a.as_i16x16(), b.as_i16x16())) } } @@ -3987,7 +4327,8 @@ pub fn _mm256_cmpneq_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpneq_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { _mm256_mask_cmp_epi16_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -3998,7 +4339,8 @@ pub fn _mm256_mask_cmpneq_epi16_mask(k1: __mmask16, a: __m256i, b: __m256i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpneq_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { simd_bitmask::(simd_ne(a.as_i16x8(), b.as_i16x8())) } } @@ -4009,7 +4351,8 @@ pub fn _mm_cmpneq_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpneq_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { _mm_mask_cmp_epi16_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -4020,7 +4363,8 @@ pub fn _mm_mask_cmpneq_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mma #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_cmpneq_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmpneq_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { simd_bitmask::(simd_ne(a.as_i8x64(), b.as_i8x64())) } } @@ -4031,7 +4375,8 @@ pub fn _mm512_cmpneq_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm512_mask_cmpneq_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmpneq_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { _mm512_mask_cmp_epi8_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -4042,7 +4387,8 @@ pub fn _mm512_mask_cmpneq_epi8_mask(k1: __mmask64, a: __m512i, b: __m512i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_cmpneq_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmpneq_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { simd_bitmask::(simd_ne(a.as_i8x32(), b.as_i8x32())) } } @@ -4053,7 +4399,8 @@ pub fn _mm256_cmpneq_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm256_mask_cmpneq_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmpneq_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { _mm256_mask_cmp_epi8_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -4064,7 +4411,8 @@ pub fn _mm256_mask_cmpneq_epi8_mask(k1: __mmask32, a: __m256i, b: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_cmpneq_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmpneq_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { simd_bitmask::(simd_ne(a.as_i8x16(), b.as_i8x16())) } } @@ -4075,7 +4423,8 @@ pub fn _mm_cmpneq_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpcmp))] -pub fn _mm_mask_cmpneq_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmpneq_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { _mm_mask_cmp_epi8_mask::<_MM_CMPINT_NE>(k1, a, b) } @@ -4087,7 +4436,8 @@ pub fn _mm_mask_cmpneq_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mma #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_cmp_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epu16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u16x32(); @@ -4114,7 +4464,8 @@ pub fn _mm512_cmp_epu16_mask(a: __m512i, b: __m512i) -> __mmask #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_mask_cmp_epu16_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epu16_mask( k1: __mmask32, a: __m512i, b: __m512i, @@ -4146,7 +4497,8 @@ pub fn _mm512_mask_cmp_epu16_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_cmp_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epu16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u16x16(); @@ -4173,7 +4525,8 @@ pub fn _mm256_cmp_epu16_mask(a: __m256i, b: __m256i) -> __mmask #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_mask_cmp_epu16_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epu16_mask( k1: __mmask16, a: __m256i, b: __m256i, @@ -4205,7 +4558,8 @@ pub fn _mm256_mask_cmp_epu16_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_cmp_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u16x8(); @@ -4232,7 +4586,12 @@ pub fn _mm_cmp_epu16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_mask_cmp_epu16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epu16_mask( + k1: __mmask8, + a: __m128i, + b: __m128i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u16x8(); @@ -4260,7 +4619,8 @@ pub fn _mm_mask_cmp_epu16_mask(k1: __mmask8, a: __m128i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_cmp_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epu8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u8x64(); @@ -4287,7 +4647,8 @@ pub fn _mm512_cmp_epu8_mask(a: __m512i, b: __m512i) -> __mmask6 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_mask_cmp_epu8_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epu8_mask( k1: __mmask64, a: __m512i, b: __m512i, @@ -4319,7 +4680,8 @@ pub fn _mm512_mask_cmp_epu8_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_cmp_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epu8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u8x32(); @@ -4346,7 +4708,8 @@ pub fn _mm256_cmp_epu8_mask(a: __m256i, b: __m256i) -> __mmask3 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_mask_cmp_epu8_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epu8_mask( k1: __mmask32, a: __m256i, b: __m256i, @@ -4378,7 +4741,8 @@ pub fn _mm256_mask_cmp_epu8_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_cmp_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u8x16(); @@ -4405,7 +4769,12 @@ pub fn _mm_cmp_epu8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_mask_cmp_epu8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epu8_mask( + k1: __mmask16, + a: __m128i, + b: __m128i, +) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_u8x16(); @@ -4433,7 +4802,8 @@ pub fn _mm_mask_cmp_epu8_mask(k1: __mmask16, a: __m128i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_cmp_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i16x32(); @@ -4460,7 +4830,8 @@ pub fn _mm512_cmp_epi16_mask(a: __m512i, b: __m512i) -> __mmask #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_mask_cmp_epi16_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epi16_mask( k1: __mmask32, a: __m512i, b: __m512i, @@ -4492,7 +4863,8 @@ pub fn _mm512_mask_cmp_epi16_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_cmp_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i16x16(); @@ -4519,7 +4891,8 @@ pub fn _mm256_cmp_epi16_mask(a: __m256i, b: __m256i) -> __mmask #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_mask_cmp_epi16_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epi16_mask( k1: __mmask16, a: __m256i, b: __m256i, @@ -4551,7 +4924,8 @@ pub fn _mm256_mask_cmp_epi16_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_cmp_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i16x8(); @@ -4578,7 +4952,12 @@ pub fn _mm_cmp_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_mask_cmp_epi16_mask(k1: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epi16_mask( + k1: __mmask8, + a: __m128i, + b: __m128i, +) -> __mmask8 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i16x8(); @@ -4606,7 +4985,8 @@ pub fn _mm_mask_cmp_epi16_mask(k1: __mmask8, a: __m128i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_cmp_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cmp_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i8x64(); @@ -4633,7 +5013,8 @@ pub fn _mm512_cmp_epi8_mask(a: __m512i, b: __m512i) -> __mmask6 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm512_mask_cmp_epi8_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cmp_epi8_mask( k1: __mmask64, a: __m512i, b: __m512i, @@ -4665,7 +5046,8 @@ pub fn _mm512_mask_cmp_epi8_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_cmp_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cmp_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i8x32(); @@ -4692,7 +5074,8 @@ pub fn _mm256_cmp_epi8_mask(a: __m256i, b: __m256i) -> __mmask3 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm256_mask_cmp_epi8_mask( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cmp_epi8_mask( k1: __mmask32, a: __m256i, b: __m256i, @@ -4724,7 +5107,8 @@ pub fn _mm256_mask_cmp_epi8_mask( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_cmp_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cmp_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i8x16(); @@ -4751,7 +5135,12 @@ pub fn _mm_cmp_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpcmp, IMM8 = 0))] -pub fn _mm_mask_cmp_epi8_mask(k1: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cmp_epi8_mask( + k1: __mmask16, + a: __m128i, + b: __m128i, +) -> __mmask16 { unsafe { static_assert_uimm_bits!(IMM8, 3); let a = a.as_i8x16(); @@ -4777,7 +5166,8 @@ pub fn _mm_mask_cmp_epi8_mask(k1: __mmask16, a: __m128i, b: __m #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_add_epi16(a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_add_epi16(a: __m256i) -> i16 { unsafe { simd_reduce_add_ordered(a.as_i16x16(), 0) } } @@ -4787,7 +5177,8 @@ pub fn _mm256_reduce_add_epi16(a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_add_epi16(k: __mmask16, a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_add_epi16(k: __mmask16, a: __m256i) -> i16 { unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i16x16(), i16x16::ZERO), 0) } } @@ -4797,7 +5188,8 @@ pub fn _mm256_mask_reduce_add_epi16(k: __mmask16, a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_add_epi16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_add_epi16(a: __m128i) -> i16 { unsafe { simd_reduce_add_ordered(a.as_i16x8(), 0) } } @@ -4807,7 +5199,8 @@ pub fn _mm_reduce_add_epi16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_add_epi16(k: __mmask8, a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_add_epi16(k: __mmask8, a: __m128i) -> i16 { unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i16x8(), i16x8::ZERO), 0) } } @@ -4817,7 +5210,8 @@ pub fn _mm_mask_reduce_add_epi16(k: __mmask8, a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_add_epi8(a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_add_epi8(a: __m256i) -> i8 { unsafe { simd_reduce_add_ordered(a.as_i8x32(), 0) } } @@ -4827,7 +5221,8 @@ pub fn _mm256_reduce_add_epi8(a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_add_epi8(k: __mmask32, a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_add_epi8(k: __mmask32, a: __m256i) -> i8 { unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i8x32(), i8x32::ZERO), 0) } } @@ -4837,7 +5232,8 @@ pub fn _mm256_mask_reduce_add_epi8(k: __mmask32, a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_add_epi8(a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_add_epi8(a: __m128i) -> i8 { unsafe { simd_reduce_add_ordered(a.as_i8x16(), 0) } } @@ -4847,7 +5243,8 @@ pub fn _mm_reduce_add_epi8(a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_add_epi8(k: __mmask16, a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_add_epi8(k: __mmask16, a: __m128i) -> i8 { unsafe { simd_reduce_add_ordered(simd_select_bitmask(k, a.as_i8x16(), i8x16::ZERO), 0) } } @@ -4857,7 +5254,8 @@ pub fn _mm_mask_reduce_add_epi8(k: __mmask16, a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_and_epi16(a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_and_epi16(a: __m256i) -> i16 { unsafe { simd_reduce_and(a.as_i16x16()) } } @@ -4867,7 +5265,8 @@ pub fn _mm256_reduce_and_epi16(a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_and_epi16(k: __mmask16, a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_and_epi16(k: __mmask16, a: __m256i) -> i16 { unsafe { simd_reduce_and(simd_select_bitmask( k, @@ -4883,7 +5282,8 @@ pub fn _mm256_mask_reduce_and_epi16(k: __mmask16, a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_and_epi16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_and_epi16(a: __m128i) -> i16 { unsafe { simd_reduce_and(a.as_i16x8()) } } @@ -4893,7 +5293,8 @@ pub fn _mm_reduce_and_epi16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_and_epi16(k: __mmask8, a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_and_epi16(k: __mmask8, a: __m128i) -> i16 { unsafe { simd_reduce_and(simd_select_bitmask( k, @@ -4909,7 +5310,8 @@ pub fn _mm_mask_reduce_and_epi16(k: __mmask8, a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_and_epi8(a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_and_epi8(a: __m256i) -> i8 { unsafe { simd_reduce_and(a.as_i8x32()) } } @@ -4919,7 +5321,8 @@ pub fn _mm256_reduce_and_epi8(a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_and_epi8(k: __mmask32, a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_and_epi8(k: __mmask32, a: __m256i) -> i8 { unsafe { simd_reduce_and(simd_select_bitmask( k, @@ -4935,7 +5338,8 @@ pub fn _mm256_mask_reduce_and_epi8(k: __mmask32, a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_and_epi8(a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_and_epi8(a: __m128i) -> i8 { unsafe { simd_reduce_and(a.as_i8x16()) } } @@ -4945,7 +5349,8 @@ pub fn _mm_reduce_and_epi8(a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_and_epi8(k: __mmask16, a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_and_epi8(k: __mmask16, a: __m128i) -> i8 { unsafe { simd_reduce_and(simd_select_bitmask( k, @@ -4961,7 +5366,8 @@ pub fn _mm_mask_reduce_and_epi8(k: __mmask16, a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_max_epi16(a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_max_epi16(a: __m256i) -> i16 { unsafe { simd_reduce_max(a.as_i16x16()) } } @@ -4971,7 +5377,8 @@ pub fn _mm256_reduce_max_epi16(a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_max_epi16(k: __mmask16, a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_max_epi16(k: __mmask16, a: __m256i) -> i16 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_i16x16(), i16x16::splat(-32768))) } } @@ -4981,7 +5388,8 @@ pub fn _mm256_mask_reduce_max_epi16(k: __mmask16, a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_max_epi16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_max_epi16(a: __m128i) -> i16 { unsafe { simd_reduce_max(a.as_i16x8()) } } @@ -4991,7 +5399,8 @@ pub fn _mm_reduce_max_epi16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_max_epi16(k: __mmask8, a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_max_epi16(k: __mmask8, a: __m128i) -> i16 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_i16x8(), i16x8::splat(-32768))) } } @@ -5001,7 +5410,8 @@ pub fn _mm_mask_reduce_max_epi16(k: __mmask8, a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_max_epi8(a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_max_epi8(a: __m256i) -> i8 { unsafe { simd_reduce_max(a.as_i8x32()) } } @@ -5011,7 +5421,8 @@ pub fn _mm256_reduce_max_epi8(a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_max_epi8(k: __mmask32, a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_max_epi8(k: __mmask32, a: __m256i) -> i8 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_i8x32(), i8x32::splat(-128))) } } @@ -5021,7 +5432,8 @@ pub fn _mm256_mask_reduce_max_epi8(k: __mmask32, a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_max_epi8(a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_max_epi8(a: __m128i) -> i8 { unsafe { simd_reduce_max(a.as_i8x16()) } } @@ -5031,7 +5443,8 @@ pub fn _mm_reduce_max_epi8(a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_max_epi8(k: __mmask16, a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_max_epi8(k: __mmask16, a: __m128i) -> i8 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_i8x16(), i8x16::splat(-128))) } } @@ -5041,7 +5454,8 @@ pub fn _mm_mask_reduce_max_epi8(k: __mmask16, a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_max_epu16(a: __m256i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_max_epu16(a: __m256i) -> u16 { unsafe { simd_reduce_max(a.as_u16x16()) } } @@ -5051,7 +5465,8 @@ pub fn _mm256_reduce_max_epu16(a: __m256i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_max_epu16(k: __mmask16, a: __m256i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_max_epu16(k: __mmask16, a: __m256i) -> u16 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_u16x16(), u16x16::ZERO)) } } @@ -5061,7 +5476,8 @@ pub fn _mm256_mask_reduce_max_epu16(k: __mmask16, a: __m256i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_max_epu16(a: __m128i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_max_epu16(a: __m128i) -> u16 { unsafe { simd_reduce_max(a.as_u16x8()) } } @@ -5071,7 +5487,8 @@ pub fn _mm_reduce_max_epu16(a: __m128i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_max_epu16(k: __mmask8, a: __m128i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_max_epu16(k: __mmask8, a: __m128i) -> u16 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_u16x8(), u16x8::ZERO)) } } @@ -5081,7 +5498,8 @@ pub fn _mm_mask_reduce_max_epu16(k: __mmask8, a: __m128i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_max_epu8(a: __m256i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_max_epu8(a: __m256i) -> u8 { unsafe { simd_reduce_max(a.as_u8x32()) } } @@ -5091,7 +5509,8 @@ pub fn _mm256_reduce_max_epu8(a: __m256i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_max_epu8(k: __mmask32, a: __m256i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_max_epu8(k: __mmask32, a: __m256i) -> u8 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_u8x32(), u8x32::ZERO)) } } @@ -5101,7 +5520,8 @@ pub fn _mm256_mask_reduce_max_epu8(k: __mmask32, a: __m256i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_max_epu8(a: __m128i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_max_epu8(a: __m128i) -> u8 { unsafe { simd_reduce_max(a.as_u8x16()) } } @@ -5111,7 +5531,8 @@ pub fn _mm_reduce_max_epu8(a: __m128i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_max_epu8(k: __mmask16, a: __m128i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_max_epu8(k: __mmask16, a: __m128i) -> u8 { unsafe { simd_reduce_max(simd_select_bitmask(k, a.as_u8x16(), u8x16::ZERO)) } } @@ -5121,7 +5542,8 @@ pub fn _mm_mask_reduce_max_epu8(k: __mmask16, a: __m128i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_min_epi16(a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_min_epi16(a: __m256i) -> i16 { unsafe { simd_reduce_min(a.as_i16x16()) } } @@ -5131,7 +5553,8 @@ pub fn _mm256_reduce_min_epi16(a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_min_epi16(k: __mmask16, a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_min_epi16(k: __mmask16, a: __m256i) -> i16 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_i16x16(), i16x16::splat(0x7fff))) } } @@ -5141,7 +5564,8 @@ pub fn _mm256_mask_reduce_min_epi16(k: __mmask16, a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_min_epi16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_min_epi16(a: __m128i) -> i16 { unsafe { simd_reduce_min(a.as_i16x8()) } } @@ -5151,7 +5575,8 @@ pub fn _mm_reduce_min_epi16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_min_epi16(k: __mmask8, a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_min_epi16(k: __mmask8, a: __m128i) -> i16 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_i16x8(), i16x8::splat(0x7fff))) } } @@ -5161,7 +5586,8 @@ pub fn _mm_mask_reduce_min_epi16(k: __mmask8, a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_min_epi8(a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_min_epi8(a: __m256i) -> i8 { unsafe { simd_reduce_min(a.as_i8x32()) } } @@ -5171,7 +5597,8 @@ pub fn _mm256_reduce_min_epi8(a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_min_epi8(k: __mmask32, a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_min_epi8(k: __mmask32, a: __m256i) -> i8 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_i8x32(), i8x32::splat(0x7f))) } } @@ -5181,7 +5608,8 @@ pub fn _mm256_mask_reduce_min_epi8(k: __mmask32, a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_min_epi8(a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_min_epi8(a: __m128i) -> i8 { unsafe { simd_reduce_min(a.as_i8x16()) } } @@ -5191,7 +5619,8 @@ pub fn _mm_reduce_min_epi8(a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_min_epi8(k: __mmask16, a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_min_epi8(k: __mmask16, a: __m128i) -> i8 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_i8x16(), i8x16::splat(0x7f))) } } @@ -5201,7 +5630,8 @@ pub fn _mm_mask_reduce_min_epi8(k: __mmask16, a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_min_epu16(a: __m256i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_min_epu16(a: __m256i) -> u16 { unsafe { simd_reduce_min(a.as_u16x16()) } } @@ -5211,7 +5641,8 @@ pub fn _mm256_reduce_min_epu16(a: __m256i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_min_epu16(k: __mmask16, a: __m256i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_min_epu16(k: __mmask16, a: __m256i) -> u16 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_u16x16(), u16x16::splat(0xffff))) } } @@ -5221,7 +5652,8 @@ pub fn _mm256_mask_reduce_min_epu16(k: __mmask16, a: __m256i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_min_epu16(a: __m128i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_min_epu16(a: __m128i) -> u16 { unsafe { simd_reduce_min(a.as_u16x8()) } } @@ -5231,7 +5663,8 @@ pub fn _mm_reduce_min_epu16(a: __m128i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_min_epu16(k: __mmask8, a: __m128i) -> u16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_min_epu16(k: __mmask8, a: __m128i) -> u16 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_u16x8(), u16x8::splat(0xffff))) } } @@ -5241,7 +5674,8 @@ pub fn _mm_mask_reduce_min_epu16(k: __mmask8, a: __m128i) -> u16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_min_epu8(a: __m256i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_min_epu8(a: __m256i) -> u8 { unsafe { simd_reduce_min(a.as_u8x32()) } } @@ -5251,7 +5685,8 @@ pub fn _mm256_reduce_min_epu8(a: __m256i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_min_epu8(k: __mmask32, a: __m256i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_min_epu8(k: __mmask32, a: __m256i) -> u8 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_u8x32(), u8x32::splat(0xff))) } } @@ -5261,7 +5696,8 @@ pub fn _mm256_mask_reduce_min_epu8(k: __mmask32, a: __m256i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_min_epu8(a: __m128i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_min_epu8(a: __m128i) -> u8 { unsafe { simd_reduce_min(a.as_u8x16()) } } @@ -5271,7 +5707,8 @@ pub fn _mm_reduce_min_epu8(a: __m128i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_min_epu8(k: __mmask16, a: __m128i) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_min_epu8(k: __mmask16, a: __m128i) -> u8 { unsafe { simd_reduce_min(simd_select_bitmask(k, a.as_u8x16(), u8x16::splat(0xff))) } } @@ -5281,7 +5718,8 @@ pub fn _mm_mask_reduce_min_epu8(k: __mmask16, a: __m128i) -> u8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_mul_epi16(a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_mul_epi16(a: __m256i) -> i16 { unsafe { simd_reduce_mul_ordered(a.as_i16x16(), 1) } } @@ -5291,7 +5729,8 @@ pub fn _mm256_reduce_mul_epi16(a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_mul_epi16(k: __mmask16, a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_mul_epi16(k: __mmask16, a: __m256i) -> i16 { unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i16x16(), i16x16::splat(1)), 1) } } @@ -5301,7 +5740,8 @@ pub fn _mm256_mask_reduce_mul_epi16(k: __mmask16, a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_mul_epi16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_mul_epi16(a: __m128i) -> i16 { unsafe { simd_reduce_mul_ordered(a.as_i16x8(), 1) } } @@ -5311,7 +5751,8 @@ pub fn _mm_reduce_mul_epi16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_mul_epi16(k: __mmask8, a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_mul_epi16(k: __mmask8, a: __m128i) -> i16 { unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i16x8(), i16x8::splat(1)), 1) } } @@ -5321,7 +5762,8 @@ pub fn _mm_mask_reduce_mul_epi16(k: __mmask8, a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_mul_epi8(a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_mul_epi8(a: __m256i) -> i8 { unsafe { simd_reduce_mul_ordered(a.as_i8x32(), 1) } } @@ -5331,7 +5773,8 @@ pub fn _mm256_reduce_mul_epi8(a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_mul_epi8(k: __mmask32, a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_mul_epi8(k: __mmask32, a: __m256i) -> i8 { unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i8x32(), i8x32::splat(1)), 1) } } @@ -5341,7 +5784,8 @@ pub fn _mm256_mask_reduce_mul_epi8(k: __mmask32, a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_mul_epi8(a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_mul_epi8(a: __m128i) -> i8 { unsafe { simd_reduce_mul_ordered(a.as_i8x16(), 1) } } @@ -5351,7 +5795,8 @@ pub fn _mm_reduce_mul_epi8(a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_mul_epi8(k: __mmask16, a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_mul_epi8(k: __mmask16, a: __m128i) -> i8 { unsafe { simd_reduce_mul_ordered(simd_select_bitmask(k, a.as_i8x16(), i8x16::splat(1)), 1) } } @@ -5361,7 +5806,8 @@ pub fn _mm_mask_reduce_mul_epi8(k: __mmask16, a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_or_epi16(a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_or_epi16(a: __m256i) -> i16 { unsafe { simd_reduce_or(a.as_i16x16()) } } @@ -5371,7 +5817,8 @@ pub fn _mm256_reduce_or_epi16(a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_or_epi16(k: __mmask16, a: __m256i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_or_epi16(k: __mmask16, a: __m256i) -> i16 { unsafe { simd_reduce_or(simd_select_bitmask(k, a.as_i16x16(), i16x16::ZERO)) } } @@ -5381,7 +5828,8 @@ pub fn _mm256_mask_reduce_or_epi16(k: __mmask16, a: __m256i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_or_epi16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_or_epi16(a: __m128i) -> i16 { unsafe { simd_reduce_or(a.as_i16x8()) } } @@ -5391,7 +5839,8 @@ pub fn _mm_reduce_or_epi16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_or_epi16(k: __mmask8, a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_or_epi16(k: __mmask8, a: __m128i) -> i16 { unsafe { simd_reduce_or(simd_select_bitmask(k, a.as_i16x8(), i16x8::ZERO)) } } @@ -5401,7 +5850,8 @@ pub fn _mm_mask_reduce_or_epi16(k: __mmask8, a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_reduce_or_epi8(a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_or_epi8(a: __m256i) -> i8 { unsafe { simd_reduce_or(a.as_i8x32()) } } @@ -5411,7 +5861,8 @@ pub fn _mm256_reduce_or_epi8(a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_reduce_or_epi8(k: __mmask32, a: __m256i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_reduce_or_epi8(k: __mmask32, a: __m256i) -> i8 { unsafe { simd_reduce_or(simd_select_bitmask(k, a.as_i8x32(), i8x32::ZERO)) } } @@ -5421,7 +5872,8 @@ pub fn _mm256_mask_reduce_or_epi8(k: __mmask32, a: __m256i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_reduce_or_epi8(a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_or_epi8(a: __m128i) -> i8 { unsafe { simd_reduce_or(a.as_i8x16()) } } @@ -5431,7 +5883,8 @@ pub fn _mm_reduce_or_epi8(a: __m128i) -> i8 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_reduce_or_epi8(k: __mmask16, a: __m128i) -> i8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_reduce_or_epi8(k: __mmask16, a: __m128i) -> i8 { unsafe { simd_reduce_or(simd_select_bitmask(k, a.as_i8x16(), i8x16::ZERO)) } } @@ -5442,7 +5895,8 @@ pub fn _mm_mask_reduce_or_epi8(k: __mmask16, a: __m128i) -> i8 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu16 -pub unsafe fn _mm512_loadu_epi16(mem_addr: *const i16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_epi16(mem_addr: *const i16) -> __m512i { ptr::read_unaligned(mem_addr as *const __m512i) } @@ -5453,7 +5907,8 @@ pub unsafe fn _mm512_loadu_epi16(mem_addr: *const i16) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu16 -pub unsafe fn _mm256_loadu_epi16(mem_addr: *const i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_epi16(mem_addr: *const i16) -> __m256i { ptr::read_unaligned(mem_addr as *const __m256i) } @@ -5464,7 +5919,8 @@ pub unsafe fn _mm256_loadu_epi16(mem_addr: *const i16) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu16 -pub unsafe fn _mm_loadu_epi16(mem_addr: *const i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_epi16(mem_addr: *const i16) -> __m128i { ptr::read_unaligned(mem_addr as *const __m128i) } @@ -5475,7 +5931,8 @@ pub unsafe fn _mm_loadu_epi16(mem_addr: *const i16) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu8 -pub unsafe fn _mm512_loadu_epi8(mem_addr: *const i8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_epi8(mem_addr: *const i8) -> __m512i { ptr::read_unaligned(mem_addr as *const __m512i) } @@ -5486,7 +5943,8 @@ pub unsafe fn _mm512_loadu_epi8(mem_addr: *const i8) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu8 -pub unsafe fn _mm256_loadu_epi8(mem_addr: *const i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_epi8(mem_addr: *const i8) -> __m256i { ptr::read_unaligned(mem_addr as *const __m256i) } @@ -5497,7 +5955,8 @@ pub unsafe fn _mm256_loadu_epi8(mem_addr: *const i8) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu8 -pub unsafe fn _mm_loadu_epi8(mem_addr: *const i8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_epi8(mem_addr: *const i8) -> __m128i { ptr::read_unaligned(mem_addr as *const __m128i) } @@ -5508,7 +5967,8 @@ pub unsafe fn _mm_loadu_epi8(mem_addr: *const i8) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu16 -pub unsafe fn _mm512_storeu_epi16(mem_addr: *mut i16, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_epi16(mem_addr: *mut i16, a: __m512i) { ptr::write_unaligned(mem_addr as *mut __m512i, a); } @@ -5519,7 +5979,8 @@ pub unsafe fn _mm512_storeu_epi16(mem_addr: *mut i16, a: __m512i) { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu16 -pub unsafe fn _mm256_storeu_epi16(mem_addr: *mut i16, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_epi16(mem_addr: *mut i16, a: __m256i) { ptr::write_unaligned(mem_addr as *mut __m256i, a); } @@ -5530,7 +5991,8 @@ pub unsafe fn _mm256_storeu_epi16(mem_addr: *mut i16, a: __m256i) { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu16 -pub unsafe fn _mm_storeu_epi16(mem_addr: *mut i16, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_epi16(mem_addr: *mut i16, a: __m128i) { ptr::write_unaligned(mem_addr as *mut __m128i, a); } @@ -5541,7 +6003,8 @@ pub unsafe fn _mm_storeu_epi16(mem_addr: *mut i16, a: __m128i) { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu8 -pub unsafe fn _mm512_storeu_epi8(mem_addr: *mut i8, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_epi8(mem_addr: *mut i8, a: __m512i) { ptr::write_unaligned(mem_addr as *mut __m512i, a); } @@ -5552,7 +6015,8 @@ pub unsafe fn _mm512_storeu_epi8(mem_addr: *mut i8, a: __m512i) { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu8 -pub unsafe fn _mm256_storeu_epi8(mem_addr: *mut i8, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_epi8(mem_addr: *mut i8, a: __m256i) { ptr::write_unaligned(mem_addr as *mut __m256i, a); } @@ -5563,7 +6027,8 @@ pub unsafe fn _mm256_storeu_epi8(mem_addr: *mut i8, a: __m256i) { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovups))] //should be vmovdqu8 -pub unsafe fn _mm_storeu_epi8(mem_addr: *mut i8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_epi8(mem_addr: *mut i8, a: __m128i) { ptr::write_unaligned(mem_addr as *mut __m128i, a); } @@ -5576,7 +6041,12 @@ pub unsafe fn _mm_storeu_epi8(mem_addr: *mut i8, a: __m128i) { #[target_feature(enable = "avx512bw")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_loadu_epi16(src: __m512i, k: __mmask32, mem_addr: *const i16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_loadu_epi16( + src: __m512i, + k: __mmask32, + mem_addr: *const i16, +) -> __m512i { let mask = simd_select_bitmask(k, i16x32::splat(!0), i16x32::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i16x32()).as_m512i() } @@ -5590,7 +6060,8 @@ pub unsafe fn _mm512_mask_loadu_epi16(src: __m512i, k: __mmask32, mem_addr: *con #[target_feature(enable = "avx512bw")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_loadu_epi16(k: __mmask32, mem_addr: *const i16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_loadu_epi16(k: __mmask32, mem_addr: *const i16) -> __m512i { _mm512_mask_loadu_epi16(_mm512_setzero_si512(), k, mem_addr) } @@ -5603,7 +6074,12 @@ pub unsafe fn _mm512_maskz_loadu_epi16(k: __mmask32, mem_addr: *const i16) -> __ #[target_feature(enable = "avx512bw")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_loadu_epi8(src: __m512i, k: __mmask64, mem_addr: *const i8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_loadu_epi8( + src: __m512i, + k: __mmask64, + mem_addr: *const i8, +) -> __m512i { let mask = simd_select_bitmask(k, i8x64::splat(!0), i8x64::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i8x64()).as_m512i() } @@ -5617,7 +6093,8 @@ pub unsafe fn _mm512_mask_loadu_epi8(src: __m512i, k: __mmask64, mem_addr: *cons #[target_feature(enable = "avx512bw")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_maskz_loadu_epi8(k: __mmask64, mem_addr: *const i8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_maskz_loadu_epi8(k: __mmask64, mem_addr: *const i8) -> __m512i { _mm512_mask_loadu_epi8(_mm512_setzero_si512(), k, mem_addr) } @@ -5630,7 +6107,12 @@ pub unsafe fn _mm512_maskz_loadu_epi8(k: __mmask64, mem_addr: *const i8) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_loadu_epi16(src: __m256i, k: __mmask16, mem_addr: *const i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_loadu_epi16( + src: __m256i, + k: __mmask16, + mem_addr: *const i16, +) -> __m256i { let mask = simd_select_bitmask(k, i16x16::splat(!0), i16x16::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i16x16()).as_m256i() } @@ -5644,7 +6126,8 @@ pub unsafe fn _mm256_mask_loadu_epi16(src: __m256i, k: __mmask16, mem_addr: *con #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_loadu_epi16(k: __mmask16, mem_addr: *const i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_loadu_epi16(k: __mmask16, mem_addr: *const i16) -> __m256i { _mm256_mask_loadu_epi16(_mm256_setzero_si256(), k, mem_addr) } @@ -5657,7 +6140,12 @@ pub unsafe fn _mm256_maskz_loadu_epi16(k: __mmask16, mem_addr: *const i16) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_loadu_epi8(src: __m256i, k: __mmask32, mem_addr: *const i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_loadu_epi8( + src: __m256i, + k: __mmask32, + mem_addr: *const i8, +) -> __m256i { let mask = simd_select_bitmask(k, i8x32::splat(!0), i8x32::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i8x32()).as_m256i() } @@ -5671,7 +6159,8 @@ pub unsafe fn _mm256_mask_loadu_epi8(src: __m256i, k: __mmask32, mem_addr: *cons #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_maskz_loadu_epi8(k: __mmask32, mem_addr: *const i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_maskz_loadu_epi8(k: __mmask32, mem_addr: *const i8) -> __m256i { _mm256_mask_loadu_epi8(_mm256_setzero_si256(), k, mem_addr) } @@ -5684,7 +6173,12 @@ pub unsafe fn _mm256_maskz_loadu_epi8(k: __mmask32, mem_addr: *const i8) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_loadu_epi16(src: __m128i, k: __mmask8, mem_addr: *const i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_loadu_epi16( + src: __m128i, + k: __mmask8, + mem_addr: *const i16, +) -> __m128i { let mask = simd_select_bitmask(k, i16x8::splat(!0), i16x8::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i16x8()).as_m128i() } @@ -5698,7 +6192,8 @@ pub unsafe fn _mm_mask_loadu_epi16(src: __m128i, k: __mmask8, mem_addr: *const i #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_loadu_epi16(k: __mmask8, mem_addr: *const i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_loadu_epi16(k: __mmask8, mem_addr: *const i16) -> __m128i { _mm_mask_loadu_epi16(_mm_setzero_si128(), k, mem_addr) } @@ -5711,7 +6206,12 @@ pub unsafe fn _mm_maskz_loadu_epi16(k: __mmask8, mem_addr: *const i16) -> __m128 #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_loadu_epi8(src: __m128i, k: __mmask16, mem_addr: *const i8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_loadu_epi8( + src: __m128i, + k: __mmask16, + mem_addr: *const i8, +) -> __m128i { let mask = simd_select_bitmask(k, i8x16::splat(!0), i8x16::ZERO); simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i8x16()).as_m128i() } @@ -5725,7 +6225,8 @@ pub unsafe fn _mm_mask_loadu_epi8(src: __m128i, k: __mmask16, mem_addr: *const i #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_maskz_loadu_epi8(k: __mmask16, mem_addr: *const i8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_maskz_loadu_epi8(k: __mmask16, mem_addr: *const i8) -> __m128i { _mm_mask_loadu_epi8(_mm_setzero_si128(), k, mem_addr) } @@ -5737,7 +6238,8 @@ pub unsafe fn _mm_maskz_loadu_epi8(k: __mmask16, mem_addr: *const i8) -> __m128i #[target_feature(enable = "avx512bw")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask32, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask32, a: __m512i) { let mask = simd_select_bitmask(mask, i16x32::splat(!0), i16x32::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i16x32()); } @@ -5750,7 +6252,8 @@ pub unsafe fn _mm512_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask32, a: _ #[target_feature(enable = "avx512bw")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm512_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask64, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask64, a: __m512i) { let mask = simd_select_bitmask(mask, i8x64::splat(!0), i8x64::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i8x64()); } @@ -5763,7 +6266,8 @@ pub unsafe fn _mm512_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask64, a: __m #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask16, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask16, a: __m256i) { let mask = simd_select_bitmask(mask, i16x16::splat(!0), i16x16::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i16x16()); } @@ -5776,7 +6280,8 @@ pub unsafe fn _mm256_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask16, a: _ #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm256_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask32, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask32, a: __m256i) { let mask = simd_select_bitmask(mask, i8x32::splat(!0), i8x32::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i8x32()); } @@ -5789,7 +6294,8 @@ pub unsafe fn _mm256_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask32, a: __m #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask8, a: __m128i) { let mask = simd_select_bitmask(mask, i16x8::splat(!0), i16x8::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i16x8()); } @@ -5802,7 +6308,8 @@ pub unsafe fn _mm_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask8, a: __m12 #[target_feature(enable = "avx512bw,avx512vl")] #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _mm_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask16, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask16, a: __m128i) { let mask = simd_select_bitmask(mask, i8x16::splat(!0), i8x16::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i8x16()); } @@ -5814,7 +6321,8 @@ pub unsafe fn _mm_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask16, a: __m128 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm512_madd_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_madd_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { let r: i32x32 = simd_mul(simd_cast(a.as_i16x32()), simd_cast(b.as_i16x32())); let even: i32x16 = simd_shuffle!( @@ -5838,7 +6346,8 @@ pub fn _mm512_madd_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm512_mask_madd_epi16(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_madd_epi16(src: __m512i, k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let madd = _mm512_madd_epi16(a, b).as_i32x16(); transmute(simd_select_bitmask(k, madd, src.as_i32x16())) @@ -5852,7 +6361,8 @@ pub fn _mm512_mask_madd_epi16(src: __m512i, k: __mmask16, a: __m512i, b: __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm512_maskz_madd_epi16(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_madd_epi16(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { unsafe { let madd = _mm512_madd_epi16(a, b).as_i32x16(); transmute(simd_select_bitmask(k, madd, i32x16::ZERO)) @@ -5866,7 +6376,8 @@ pub fn _mm512_maskz_madd_epi16(k: __mmask16, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm256_mask_madd_epi16(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_madd_epi16(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let madd = _mm256_madd_epi16(a, b).as_i32x8(); transmute(simd_select_bitmask(k, madd, src.as_i32x8())) @@ -5880,7 +6391,8 @@ pub fn _mm256_mask_madd_epi16(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm256_maskz_madd_epi16(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_madd_epi16(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let madd = _mm256_madd_epi16(a, b).as_i32x8(); transmute(simd_select_bitmask(k, madd, i32x8::ZERO)) @@ -5894,7 +6406,8 @@ pub fn _mm256_maskz_madd_epi16(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm_mask_madd_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_madd_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let madd = _mm_madd_epi16(a, b).as_i32x4(); transmute(simd_select_bitmask(k, madd, src.as_i32x4())) @@ -5908,7 +6421,8 @@ pub fn _mm_mask_madd_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddwd))] -pub fn _mm_maskz_madd_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_madd_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let madd = _mm_madd_epi16(a, b).as_i32x4(); transmute(simd_select_bitmask(k, madd, i32x4::ZERO)) @@ -6397,7 +6911,8 @@ pub fn _mm_maskz_packus_epi16(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm512_avg_epu16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_avg_epu16(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = simd_cast::<_, u32x32>(a.as_u16x32()); let b = simd_cast::<_, u32x32>(b.as_u16x32()); @@ -6413,7 +6928,8 @@ pub fn _mm512_avg_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm512_mask_avg_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_avg_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, avg, src.as_u16x32())) @@ -6427,7 +6943,8 @@ pub fn _mm512_mask_avg_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm512_maskz_avg_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_avg_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, avg, u16x32::ZERO)) @@ -6441,7 +6958,8 @@ pub fn _mm512_maskz_avg_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm256_mask_avg_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_avg_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, avg, src.as_u16x16())) @@ -6455,7 +6973,8 @@ pub fn _mm256_mask_avg_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm256_maskz_avg_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_avg_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, avg, u16x16::ZERO)) @@ -6469,7 +6988,8 @@ pub fn _mm256_maskz_avg_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm_mask_avg_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_avg_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, avg, src.as_u16x8())) @@ -6483,7 +7003,8 @@ pub fn _mm_mask_avg_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -pub fn _mm_maskz_avg_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_avg_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, avg, u16x8::ZERO)) @@ -6497,7 +7018,8 @@ pub fn _mm_maskz_avg_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm512_avg_epu8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_avg_epu8(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = simd_cast::<_, u16x64>(a.as_u8x64()); let b = simd_cast::<_, u16x64>(b.as_u8x64()); @@ -6513,7 +7035,8 @@ pub fn _mm512_avg_epu8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm512_mask_avg_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_avg_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, avg, src.as_u8x64())) @@ -6527,7 +7050,8 @@ pub fn _mm512_mask_avg_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm512_maskz_avg_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_avg_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, avg, u8x64::ZERO)) @@ -6541,7 +7065,8 @@ pub fn _mm512_maskz_avg_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm256_mask_avg_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_avg_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, avg, src.as_u8x32())) @@ -6555,7 +7080,8 @@ pub fn _mm256_mask_avg_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm256_maskz_avg_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_avg_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, avg, u8x32::ZERO)) @@ -6569,7 +7095,8 @@ pub fn _mm256_maskz_avg_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm_mask_avg_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_avg_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, avg, src.as_u8x16())) @@ -6583,7 +7110,8 @@ pub fn _mm_mask_avg_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -pub fn _mm_maskz_avg_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_avg_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, avg, u8x16::ZERO)) @@ -6693,7 +7221,8 @@ pub fn _mm_maskz_sll_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_slli_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_slli_epi16(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 16 { @@ -6712,7 +7241,12 @@ pub fn _mm512_slli_epi16(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_slli_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_slli_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 16 { @@ -6732,7 +7266,8 @@ pub fn _mm512_mask_slli_epi16(src: __m512i, k: __mmask32, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_slli_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_slli_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 16 { @@ -6752,7 +7287,12 @@ pub fn _mm512_maskz_slli_epi16(k: __mmask32, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_slli_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_slli_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 16 { @@ -6772,7 +7312,8 @@ pub fn _mm256_mask_slli_epi16(src: __m256i, k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_slli_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_slli_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 16 { @@ -6792,7 +7333,12 @@ pub fn _mm256_maskz_slli_epi16(k: __mmask16, a: __m256i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_slli_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_slli_epi16( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 16 { @@ -6812,7 +7358,8 @@ pub fn _mm_mask_slli_epi16(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_slli_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_slli_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 16 { @@ -6831,7 +7378,8 @@ pub fn _mm_maskz_slli_epi16(k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm512_sllv_epi16(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sllv_epi16(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u16x32(); let no_overflow: u16x32 = simd_lt(count, u16x32::splat(u16::BITS as u16)); @@ -6847,7 +7395,13 @@ pub fn _mm512_sllv_epi16(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm512_mask_sllv_epi16(src: __m512i, k: __mmask32, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sllv_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_sllv_epi16(a, count).as_i16x32(); transmute(simd_select_bitmask(k, shf, src.as_i16x32())) @@ -6861,7 +7415,8 @@ pub fn _mm512_mask_sllv_epi16(src: __m512i, k: __mmask32, a: __m512i, count: __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm512_maskz_sllv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sllv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_sllv_epi16(a, count).as_i16x32(); transmute(simd_select_bitmask(k, shf, i16x32::ZERO)) @@ -6875,7 +7430,8 @@ pub fn _mm512_maskz_sllv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm256_sllv_epi16(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sllv_epi16(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u16x16(); let no_overflow: u16x16 = simd_lt(count, u16x16::splat(u16::BITS as u16)); @@ -6891,7 +7447,13 @@ pub fn _mm256_sllv_epi16(a: __m256i, count: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm256_mask_sllv_epi16(src: __m256i, k: __mmask16, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sllv_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_sllv_epi16(a, count).as_i16x16(); transmute(simd_select_bitmask(k, shf, src.as_i16x16())) @@ -6905,7 +7467,8 @@ pub fn _mm256_mask_sllv_epi16(src: __m256i, k: __mmask16, a: __m256i, count: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm256_maskz_sllv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sllv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_sllv_epi16(a, count).as_i16x16(); transmute(simd_select_bitmask(k, shf, i16x16::ZERO)) @@ -6919,7 +7482,8 @@ pub fn _mm256_maskz_sllv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm_sllv_epi16(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sllv_epi16(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u16x8(); let no_overflow: u16x8 = simd_lt(count, u16x8::splat(u16::BITS as u16)); @@ -6935,7 +7499,8 @@ pub fn _mm_sllv_epi16(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm_mask_sllv_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sllv_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_sllv_epi16(a, count).as_i16x8(); transmute(simd_select_bitmask(k, shf, src.as_i16x8())) @@ -6949,7 +7514,8 @@ pub fn _mm_mask_sllv_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] -pub fn _mm_maskz_sllv_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sllv_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_sllv_epi16(a, count).as_i16x8(); transmute(simd_select_bitmask(k, shf, i16x8::ZERO)) @@ -7059,7 +7625,8 @@ pub fn _mm_maskz_srl_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_srli_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srli_epi16(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); if IMM8 >= 16 { @@ -7078,7 +7645,12 @@ pub fn _mm512_srli_epi16(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_srli_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srli_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = if IMM8 >= 16 { @@ -7098,7 +7670,8 @@ pub fn _mm512_mask_srli_epi16(src: __m512i, k: __mmask32, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_srli_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srli_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); //imm8 should be u32, it seems the document to verify is incorrect @@ -7119,7 +7692,12 @@ pub fn _mm512_maskz_srli_epi16(k: __mmask32, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_srli_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srli_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_srli_epi16::(a); @@ -7135,7 +7713,8 @@ pub fn _mm256_mask_srli_epi16(src: __m256i, k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_srli_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srli_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_srli_epi16::(a); @@ -7151,7 +7730,12 @@ pub fn _mm256_maskz_srli_epi16(k: __mmask16, a: __m256i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_srli_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srli_epi16( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_srli_epi16::(a); @@ -7167,7 +7751,8 @@ pub fn _mm_mask_srli_epi16(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_srli_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srli_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_srli_epi16::(a); @@ -7182,7 +7767,8 @@ pub fn _mm_maskz_srli_epi16(k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm512_srlv_epi16(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srlv_epi16(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u16x32(); let no_overflow: u16x32 = simd_lt(count, u16x32::splat(u16::BITS as u16)); @@ -7198,7 +7784,13 @@ pub fn _mm512_srlv_epi16(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm512_mask_srlv_epi16(src: __m512i, k: __mmask32, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srlv_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_srlv_epi16(a, count).as_i16x32(); transmute(simd_select_bitmask(k, shf, src.as_i16x32())) @@ -7212,7 +7804,8 @@ pub fn _mm512_mask_srlv_epi16(src: __m512i, k: __mmask32, a: __m512i, count: __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm512_maskz_srlv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srlv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_srlv_epi16(a, count).as_i16x32(); transmute(simd_select_bitmask(k, shf, i16x32::ZERO)) @@ -7226,7 +7819,8 @@ pub fn _mm512_maskz_srlv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm256_srlv_epi16(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srlv_epi16(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u16x16(); let no_overflow: u16x16 = simd_lt(count, u16x16::splat(u16::BITS as u16)); @@ -7242,7 +7836,13 @@ pub fn _mm256_srlv_epi16(a: __m256i, count: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm256_mask_srlv_epi16(src: __m256i, k: __mmask16, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srlv_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_srlv_epi16(a, count).as_i16x16(); transmute(simd_select_bitmask(k, shf, src.as_i16x16())) @@ -7256,7 +7856,8 @@ pub fn _mm256_mask_srlv_epi16(src: __m256i, k: __mmask16, a: __m256i, count: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm256_maskz_srlv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srlv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_srlv_epi16(a, count).as_i16x16(); transmute(simd_select_bitmask(k, shf, i16x16::ZERO)) @@ -7270,7 +7871,8 @@ pub fn _mm256_maskz_srlv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm_srlv_epi16(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srlv_epi16(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u16x8(); let no_overflow: u16x8 = simd_lt(count, u16x8::splat(u16::BITS as u16)); @@ -7286,7 +7888,8 @@ pub fn _mm_srlv_epi16(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm_mask_srlv_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srlv_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srlv_epi16(a, count).as_i16x8(); transmute(simd_select_bitmask(k, shf, src.as_i16x8())) @@ -7300,7 +7903,8 @@ pub fn _mm_mask_srlv_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] -pub fn _mm_maskz_srlv_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srlv_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srlv_epi16(a, count).as_i16x8(); transmute(simd_select_bitmask(k, shf, i16x8::ZERO)) @@ -7410,7 +8014,8 @@ pub fn _mm_maskz_sra_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_srai_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srai_epi16(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); transmute(simd_shr(a.as_i16x32(), i16x32::splat(IMM8.min(15) as i16))) @@ -7425,7 +8030,12 @@ pub fn _mm512_srai_epi16(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_srai_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srai_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i16x32(), i16x32::splat(IMM8.min(15) as i16)); @@ -7441,7 +8051,8 @@ pub fn _mm512_mask_srai_epi16(src: __m512i, k: __mmask32, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_srai_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srai_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = simd_shr(a.as_i16x32(), i16x32::splat(IMM8.min(15) as i16)); @@ -7457,7 +8068,12 @@ pub fn _mm512_maskz_srai_epi16(k: __mmask32, a: __m512i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_srai_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srai_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = simd_shr(a.as_i16x16(), i16x16::splat(IMM8.min(15) as i16)); @@ -7473,7 +8089,8 @@ pub fn _mm256_mask_srai_epi16(src: __m256i, k: __mmask16, a: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_srai_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srai_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = simd_shr(a.as_i16x16(), i16x16::splat(IMM8.min(15) as i16)); @@ -7489,7 +8106,12 @@ pub fn _mm256_maskz_srai_epi16(k: __mmask16, a: __m256i) -> __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_srai_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srai_epi16( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = simd_shr(a.as_i16x8(), i16x8::splat(IMM8.min(15) as i16)); @@ -7505,7 +8127,8 @@ pub fn _mm_mask_srai_epi16(src: __m128i, k: __mmask8, a: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsraw, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_srai_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srai_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = simd_shr(a.as_i16x8(), i16x8::splat(IMM8.min(15) as i16)); @@ -7520,7 +8143,8 @@ pub fn _mm_maskz_srai_epi16(k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm512_srav_epi16(a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_srav_epi16(a: __m512i, count: __m512i) -> __m512i { unsafe { let count = count.as_u16x32(); let no_overflow: u16x32 = simd_lt(count, u16x32::splat(u16::BITS as u16)); @@ -7536,7 +8160,13 @@ pub fn _mm512_srav_epi16(a: __m512i, count: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm512_mask_srav_epi16(src: __m512i, k: __mmask32, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_srav_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + count: __m512i, +) -> __m512i { unsafe { let shf = _mm512_srav_epi16(a, count).as_i16x32(); transmute(simd_select_bitmask(k, shf, src.as_i16x32())) @@ -7550,7 +8180,8 @@ pub fn _mm512_mask_srav_epi16(src: __m512i, k: __mmask32, a: __m512i, count: __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm512_maskz_srav_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_srav_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m512i { unsafe { let shf = _mm512_srav_epi16(a, count).as_i16x32(); transmute(simd_select_bitmask(k, shf, i16x32::ZERO)) @@ -7564,7 +8195,8 @@ pub fn _mm512_maskz_srav_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm256_srav_epi16(a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_srav_epi16(a: __m256i, count: __m256i) -> __m256i { unsafe { let count = count.as_u16x16(); let no_overflow: u16x16 = simd_lt(count, u16x16::splat(u16::BITS as u16)); @@ -7580,7 +8212,13 @@ pub fn _mm256_srav_epi16(a: __m256i, count: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm256_mask_srav_epi16(src: __m256i, k: __mmask16, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_srav_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + count: __m256i, +) -> __m256i { unsafe { let shf = _mm256_srav_epi16(a, count).as_i16x16(); transmute(simd_select_bitmask(k, shf, src.as_i16x16())) @@ -7594,7 +8232,8 @@ pub fn _mm256_mask_srav_epi16(src: __m256i, k: __mmask16, a: __m256i, count: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm256_maskz_srav_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_srav_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m256i { unsafe { let shf = _mm256_srav_epi16(a, count).as_i16x16(); transmute(simd_select_bitmask(k, shf, i16x16::ZERO)) @@ -7608,7 +8247,8 @@ pub fn _mm256_maskz_srav_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm_srav_epi16(a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_srav_epi16(a: __m128i, count: __m128i) -> __m128i { unsafe { let count = count.as_u16x8(); let no_overflow: u16x8 = simd_lt(count, u16x8::splat(u16::BITS as u16)); @@ -7624,7 +8264,8 @@ pub fn _mm_srav_epi16(a: __m128i, count: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm_mask_srav_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_srav_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srav_epi16(a, count).as_i16x8(); transmute(simd_select_bitmask(k, shf, src.as_i16x8())) @@ -7638,7 +8279,8 @@ pub fn _mm_mask_srav_epi16(src: __m128i, k: __mmask8, a: __m128i, count: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] -pub fn _mm_maskz_srav_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_srav_epi16(k: __mmask8, a: __m128i, count: __m128i) -> __m128i { unsafe { let shf = _mm_srav_epi16(a, count).as_i16x8(); transmute(simd_select_bitmask(k, shf, i16x8::ZERO)) @@ -7968,7 +8610,8 @@ pub fn _mm_maskz_permutexvar_epi16(k: __mmask8, idx: __m128i, a: __m128i) -> __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] //should be vpblendmw -pub fn _mm512_mask_blend_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask(k, b.as_i16x32(), a.as_i16x32())) } } @@ -7979,7 +8622,8 @@ pub fn _mm512_mask_blend_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] //should be vpblendmw -pub fn _mm256_mask_blend_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask(k, b.as_i16x16(), a.as_i16x16())) } } @@ -7990,7 +8634,8 @@ pub fn _mm256_mask_blend_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] //should be vpblendmw -pub fn _mm_mask_blend_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask(k, b.as_i16x8(), a.as_i16x8())) } } @@ -8001,7 +8646,8 @@ pub fn _mm_mask_blend_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] //should be vpblendmb -pub fn _mm512_mask_blend_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask(k, b.as_i8x64(), a.as_i8x64())) } } @@ -8012,7 +8658,8 @@ pub fn _mm512_mask_blend_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] //should be vpblendmb -pub fn _mm256_mask_blend_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask(k, b.as_i8x32(), a.as_i8x32())) } } @@ -8023,7 +8670,8 @@ pub fn _mm256_mask_blend_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] //should be vpblendmb -pub fn _mm_mask_blend_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask(k, b.as_i8x16(), a.as_i8x16())) } } @@ -8034,7 +8682,8 @@ pub fn _mm_mask_blend_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm512_broadcastw_epi16(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastw_epi16(a: __m128i) -> __m512i { unsafe { let a = _mm512_castsi128_si512(a).as_i16x32(); let ret: i16x32 = simd_shuffle!( @@ -8056,7 +8705,8 @@ pub fn _mm512_broadcastw_epi16(a: __m128i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm512_mask_broadcastw_epi16(src: __m512i, k: __mmask32, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcastw_epi16(src: __m512i, k: __mmask32, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastw_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, broadcast, src.as_i16x32())) @@ -8070,7 +8720,8 @@ pub fn _mm512_mask_broadcastw_epi16(src: __m512i, k: __mmask32, a: __m128i) -> _ #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm512_maskz_broadcastw_epi16(k: __mmask32, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcastw_epi16(k: __mmask32, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastw_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, broadcast, i16x32::ZERO)) @@ -8084,7 +8735,8 @@ pub fn _mm512_maskz_broadcastw_epi16(k: __mmask32, a: __m128i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm256_mask_broadcastw_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcastw_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastw_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, broadcast, src.as_i16x16())) @@ -8098,7 +8750,8 @@ pub fn _mm256_mask_broadcastw_epi16(src: __m256i, k: __mmask16, a: __m128i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm256_maskz_broadcastw_epi16(k: __mmask16, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcastw_epi16(k: __mmask16, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastw_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, broadcast, i16x16::ZERO)) @@ -8112,7 +8765,8 @@ pub fn _mm256_maskz_broadcastw_epi16(k: __mmask16, a: __m128i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm_mask_broadcastw_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_broadcastw_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastw_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, broadcast, src.as_i16x8())) @@ -8126,7 +8780,8 @@ pub fn _mm_mask_broadcastw_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m12 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm_maskz_broadcastw_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_broadcastw_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastw_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, broadcast, i16x8::ZERO)) @@ -8140,7 +8795,8 @@ pub fn _mm_maskz_broadcastw_epi16(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm512_broadcastb_epi8(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastb_epi8(a: __m128i) -> __m512i { unsafe { let a = _mm512_castsi128_si512(a).as_i8x64(); let ret: i8x64 = simd_shuffle!( @@ -8163,7 +8819,8 @@ pub fn _mm512_broadcastb_epi8(a: __m128i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm512_mask_broadcastb_epi8(src: __m512i, k: __mmask64, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcastb_epi8(src: __m512i, k: __mmask64, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastb_epi8(a).as_i8x64(); transmute(simd_select_bitmask(k, broadcast, src.as_i8x64())) @@ -8177,7 +8834,8 @@ pub fn _mm512_mask_broadcastb_epi8(src: __m512i, k: __mmask64, a: __m128i) -> __ #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm512_maskz_broadcastb_epi8(k: __mmask64, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcastb_epi8(k: __mmask64, a: __m128i) -> __m512i { unsafe { let broadcast = _mm512_broadcastb_epi8(a).as_i8x64(); transmute(simd_select_bitmask(k, broadcast, i8x64::ZERO)) @@ -8191,7 +8849,8 @@ pub fn _mm512_maskz_broadcastb_epi8(k: __mmask64, a: __m128i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm256_mask_broadcastb_epi8(src: __m256i, k: __mmask32, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcastb_epi8(src: __m256i, k: __mmask32, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastb_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, broadcast, src.as_i8x32())) @@ -8205,7 +8864,8 @@ pub fn _mm256_mask_broadcastb_epi8(src: __m256i, k: __mmask32, a: __m128i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm256_maskz_broadcastb_epi8(k: __mmask32, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcastb_epi8(k: __mmask32, a: __m128i) -> __m256i { unsafe { let broadcast = _mm256_broadcastb_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, broadcast, i8x32::ZERO)) @@ -8219,7 +8879,8 @@ pub fn _mm256_maskz_broadcastb_epi8(k: __mmask32, a: __m128i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm_mask_broadcastb_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_broadcastb_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastb_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, broadcast, src.as_i8x16())) @@ -8233,7 +8894,8 @@ pub fn _mm_mask_broadcastb_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m12 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastb))] -pub fn _mm_maskz_broadcastb_epi8(k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_broadcastb_epi8(k: __mmask16, a: __m128i) -> __m128i { unsafe { let broadcast = _mm_broadcastb_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, broadcast, i8x16::ZERO)) @@ -8247,7 +8909,8 @@ pub fn _mm_maskz_broadcastb_epi8(k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm512_unpackhi_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpackhi_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_i16x32(); let b = b.as_i16x32(); @@ -8277,7 +8940,13 @@ pub fn _mm512_unpackhi_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm512_mask_unpackhi_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpackhi_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, unpackhi, src.as_i16x32())) @@ -8291,7 +8960,8 @@ pub fn _mm512_mask_unpackhi_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm512_maskz_unpackhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpackhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, unpackhi, i16x32::ZERO)) @@ -8305,7 +8975,13 @@ pub fn _mm512_maskz_unpackhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm256_mask_unpackhi_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpackhi_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, unpackhi, src.as_i16x16())) @@ -8319,7 +8995,8 @@ pub fn _mm256_mask_unpackhi_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm256_maskz_unpackhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpackhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, unpackhi, i16x16::ZERO)) @@ -8333,7 +9010,8 @@ pub fn _mm256_maskz_unpackhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm_mask_unpackhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpackhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, unpackhi, src.as_i16x8())) @@ -8347,7 +9025,8 @@ pub fn _mm_mask_unpackhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhwd))] -pub fn _mm_maskz_unpackhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpackhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, unpackhi, i16x8::ZERO)) @@ -8361,7 +9040,8 @@ pub fn _mm_maskz_unpackhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm512_unpackhi_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpackhi_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_i8x64(); let b = b.as_i8x64(); @@ -8399,7 +9079,13 @@ pub fn _mm512_unpackhi_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm512_mask_unpackhi_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpackhi_epi8( + src: __m512i, + k: __mmask64, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, unpackhi, src.as_i8x64())) @@ -8413,7 +9099,8 @@ pub fn _mm512_mask_unpackhi_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m5 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm512_maskz_unpackhi_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpackhi_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpackhi = _mm512_unpackhi_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, unpackhi, i8x64::ZERO)) @@ -8427,7 +9114,13 @@ pub fn _mm512_maskz_unpackhi_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m51 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm256_mask_unpackhi_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpackhi_epi8( + src: __m256i, + k: __mmask32, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, unpackhi, src.as_i8x32())) @@ -8441,7 +9134,8 @@ pub fn _mm256_mask_unpackhi_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm256_maskz_unpackhi_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpackhi_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpackhi = _mm256_unpackhi_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, unpackhi, i8x32::ZERO)) @@ -8455,7 +9149,8 @@ pub fn _mm256_maskz_unpackhi_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m25 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm_mask_unpackhi_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpackhi_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, unpackhi, src.as_i8x16())) @@ -8469,7 +9164,8 @@ pub fn _mm_mask_unpackhi_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpckhbw))] -pub fn _mm_maskz_unpackhi_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpackhi_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpackhi = _mm_unpackhi_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, unpackhi, i8x16::ZERO)) @@ -8483,7 +9179,8 @@ pub fn _mm_maskz_unpackhi_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm512_unpacklo_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpacklo_epi16(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_i16x32(); let b = b.as_i16x32(); @@ -8513,7 +9210,13 @@ pub fn _mm512_unpacklo_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm512_mask_unpacklo_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpacklo_epi16( + src: __m512i, + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, unpacklo, src.as_i16x32())) @@ -8527,7 +9230,8 @@ pub fn _mm512_mask_unpacklo_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm512_maskz_unpacklo_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpacklo_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, unpacklo, i16x32::ZERO)) @@ -8541,7 +9245,13 @@ pub fn _mm512_maskz_unpacklo_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm256_mask_unpacklo_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpacklo_epi16( + src: __m256i, + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, unpacklo, src.as_i16x16())) @@ -8555,7 +9265,8 @@ pub fn _mm256_mask_unpacklo_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm256_maskz_unpacklo_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpacklo_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, unpacklo, i16x16::ZERO)) @@ -8569,7 +9280,8 @@ pub fn _mm256_maskz_unpacklo_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm_mask_unpacklo_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpacklo_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, unpacklo, src.as_i16x8())) @@ -8583,7 +9295,8 @@ pub fn _mm_mask_unpacklo_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklwd))] -pub fn _mm_maskz_unpacklo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpacklo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, unpacklo, i16x8::ZERO)) @@ -8597,7 +9310,8 @@ pub fn _mm_maskz_unpacklo_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm512_unpacklo_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_unpacklo_epi8(a: __m512i, b: __m512i) -> __m512i { unsafe { let a = a.as_i8x64(); let b = b.as_i8x64(); @@ -8635,7 +9349,13 @@ pub fn _mm512_unpacklo_epi8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm512_mask_unpacklo_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_unpacklo_epi8( + src: __m512i, + k: __mmask64, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, unpacklo, src.as_i8x64())) @@ -8649,7 +9369,8 @@ pub fn _mm512_mask_unpacklo_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m5 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm512_maskz_unpacklo_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_unpacklo_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let unpacklo = _mm512_unpacklo_epi8(a, b).as_i8x64(); transmute(simd_select_bitmask(k, unpacklo, i8x64::ZERO)) @@ -8663,7 +9384,13 @@ pub fn _mm512_maskz_unpacklo_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m51 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm256_mask_unpacklo_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_unpacklo_epi8( + src: __m256i, + k: __mmask32, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, unpacklo, src.as_i8x32())) @@ -8677,7 +9404,8 @@ pub fn _mm256_mask_unpacklo_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm256_maskz_unpacklo_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_unpacklo_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let unpacklo = _mm256_unpacklo_epi8(a, b).as_i8x32(); transmute(simd_select_bitmask(k, unpacklo, i8x32::ZERO)) @@ -8691,7 +9419,8 @@ pub fn _mm256_maskz_unpacklo_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m25 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm_mask_unpacklo_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_unpacklo_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, unpacklo, src.as_i8x16())) @@ -8705,7 +9434,8 @@ pub fn _mm_mask_unpacklo_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpunpcklbw))] -pub fn _mm_maskz_unpacklo_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_unpacklo_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let unpacklo = _mm_unpacklo_epi8(a, b).as_i8x16(); transmute(simd_select_bitmask(k, unpacklo, i8x16::ZERO)) @@ -8719,7 +9449,8 @@ pub fn _mm_maskz_unpacklo_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] -pub fn _mm512_mask_mov_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mov_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { unsafe { let mov = a.as_i16x32(); transmute(simd_select_bitmask(k, mov, src.as_i16x32())) @@ -8733,7 +9464,8 @@ pub fn _mm512_mask_mov_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] -pub fn _mm512_maskz_mov_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mov_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { let mov = a.as_i16x32(); transmute(simd_select_bitmask(k, mov, i16x32::ZERO)) @@ -8747,7 +9479,8 @@ pub fn _mm512_maskz_mov_epi16(k: __mmask32, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] -pub fn _mm256_mask_mov_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mov_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { unsafe { let mov = a.as_i16x16(); transmute(simd_select_bitmask(k, mov, src.as_i16x16())) @@ -8761,7 +9494,8 @@ pub fn _mm256_mask_mov_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] -pub fn _mm256_maskz_mov_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mov_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { let mov = a.as_i16x16(); transmute(simd_select_bitmask(k, mov, i16x16::ZERO)) @@ -8775,7 +9509,8 @@ pub fn _mm256_maskz_mov_epi16(k: __mmask16, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] -pub fn _mm_mask_mov_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mov_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let mov = a.as_i16x8(); transmute(simd_select_bitmask(k, mov, src.as_i16x8())) @@ -8789,7 +9524,8 @@ pub fn _mm_mask_mov_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu16))] -pub fn _mm_maskz_mov_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mov_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { let mov = a.as_i16x8(); transmute(simd_select_bitmask(k, mov, i16x8::ZERO)) @@ -8803,7 +9539,8 @@ pub fn _mm_maskz_mov_epi16(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] -pub fn _mm512_mask_mov_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mov_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { unsafe { let mov = a.as_i8x64(); transmute(simd_select_bitmask(k, mov, src.as_i8x64())) @@ -8817,7 +9554,8 @@ pub fn _mm512_mask_mov_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] -pub fn _mm512_maskz_mov_epi8(k: __mmask64, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mov_epi8(k: __mmask64, a: __m512i) -> __m512i { unsafe { let mov = a.as_i8x64(); transmute(simd_select_bitmask(k, mov, i8x64::ZERO)) @@ -8831,7 +9569,8 @@ pub fn _mm512_maskz_mov_epi8(k: __mmask64, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] -pub fn _mm256_mask_mov_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mov_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { unsafe { let mov = a.as_i8x32(); transmute(simd_select_bitmask(k, mov, src.as_i8x32())) @@ -8845,7 +9584,8 @@ pub fn _mm256_mask_mov_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] -pub fn _mm256_maskz_mov_epi8(k: __mmask32, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mov_epi8(k: __mmask32, a: __m256i) -> __m256i { unsafe { let mov = a.as_i8x32(); transmute(simd_select_bitmask(k, mov, i8x32::ZERO)) @@ -8859,7 +9599,8 @@ pub fn _mm256_maskz_mov_epi8(k: __mmask32, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] -pub fn _mm_mask_mov_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mov_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { unsafe { let mov = a.as_i8x16(); transmute(simd_select_bitmask(k, mov, src.as_i8x16())) @@ -8873,7 +9614,8 @@ pub fn _mm_mask_mov_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vmovdqu8))] -pub fn _mm_maskz_mov_epi8(k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mov_epi8(k: __mmask16, a: __m128i) -> __m128i { unsafe { let mov = a.as_i8x16(); transmute(simd_select_bitmask(k, mov, i8x16::ZERO)) @@ -8887,7 +9629,8 @@ pub fn _mm_maskz_mov_epi8(k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm512_mask_set1_epi16(src: __m512i, k: __mmask32, a: i16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_set1_epi16(src: __m512i, k: __mmask32, a: i16) -> __m512i { unsafe { let r = _mm512_set1_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, r, src.as_i16x32())) @@ -8901,7 +9644,8 @@ pub fn _mm512_mask_set1_epi16(src: __m512i, k: __mmask32, a: i16) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm512_maskz_set1_epi16(k: __mmask32, a: i16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_set1_epi16(k: __mmask32, a: i16) -> __m512i { unsafe { let r = _mm512_set1_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, r, i16x32::ZERO)) @@ -8915,7 +9659,8 @@ pub fn _mm512_maskz_set1_epi16(k: __mmask32, a: i16) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm256_mask_set1_epi16(src: __m256i, k: __mmask16, a: i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_set1_epi16(src: __m256i, k: __mmask16, a: i16) -> __m256i { unsafe { let r = _mm256_set1_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, r, src.as_i16x16())) @@ -8929,7 +9674,8 @@ pub fn _mm256_mask_set1_epi16(src: __m256i, k: __mmask16, a: i16) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm256_maskz_set1_epi16(k: __mmask16, a: i16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_set1_epi16(k: __mmask16, a: i16) -> __m256i { unsafe { let r = _mm256_set1_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, r, i16x16::ZERO)) @@ -8943,7 +9689,8 @@ pub fn _mm256_maskz_set1_epi16(k: __mmask16, a: i16) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm_mask_set1_epi16(src: __m128i, k: __mmask8, a: i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_set1_epi16(src: __m128i, k: __mmask8, a: i16) -> __m128i { unsafe { let r = _mm_set1_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, r, src.as_i16x8())) @@ -8957,7 +9704,8 @@ pub fn _mm_mask_set1_epi16(src: __m128i, k: __mmask8, a: i16) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcastw))] -pub fn _mm_maskz_set1_epi16(k: __mmask8, a: i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_set1_epi16(k: __mmask8, a: i16) -> __m128i { unsafe { let r = _mm_set1_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, r, i16x8::ZERO)) @@ -8971,7 +9719,8 @@ pub fn _mm_maskz_set1_epi16(k: __mmask8, a: i16) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] -pub fn _mm512_mask_set1_epi8(src: __m512i, k: __mmask64, a: i8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_set1_epi8(src: __m512i, k: __mmask64, a: i8) -> __m512i { unsafe { let r = _mm512_set1_epi8(a).as_i8x64(); transmute(simd_select_bitmask(k, r, src.as_i8x64())) @@ -8985,7 +9734,8 @@ pub fn _mm512_mask_set1_epi8(src: __m512i, k: __mmask64, a: i8) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] -pub fn _mm512_maskz_set1_epi8(k: __mmask64, a: i8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_set1_epi8(k: __mmask64, a: i8) -> __m512i { unsafe { let r = _mm512_set1_epi8(a).as_i8x64(); transmute(simd_select_bitmask(k, r, i8x64::ZERO)) @@ -8999,7 +9749,8 @@ pub fn _mm512_maskz_set1_epi8(k: __mmask64, a: i8) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] -pub fn _mm256_mask_set1_epi8(src: __m256i, k: __mmask32, a: i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_set1_epi8(src: __m256i, k: __mmask32, a: i8) -> __m256i { unsafe { let r = _mm256_set1_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, r, src.as_i8x32())) @@ -9013,7 +9764,8 @@ pub fn _mm256_mask_set1_epi8(src: __m256i, k: __mmask32, a: i8) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] -pub fn _mm256_maskz_set1_epi8(k: __mmask32, a: i8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_set1_epi8(k: __mmask32, a: i8) -> __m256i { unsafe { let r = _mm256_set1_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, r, i8x32::ZERO)) @@ -9027,7 +9779,8 @@ pub fn _mm256_maskz_set1_epi8(k: __mmask32, a: i8) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] -pub fn _mm_mask_set1_epi8(src: __m128i, k: __mmask16, a: i8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_set1_epi8(src: __m128i, k: __mmask16, a: i8) -> __m128i { unsafe { let r = _mm_set1_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, r, src.as_i8x16())) @@ -9041,7 +9794,8 @@ pub fn _mm_mask_set1_epi8(src: __m128i, k: __mmask16, a: i8) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] -pub fn _mm_maskz_set1_epi8(k: __mmask16, a: i8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_set1_epi8(k: __mmask16, a: i8) -> __m128i { unsafe { let r = _mm_set1_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, r, i8x16::ZERO)) @@ -9056,7 +9810,8 @@ pub fn _mm_maskz_set1_epi8(k: __mmask16, a: i8) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 0))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_shufflelo_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shufflelo_epi16(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let a = a.as_i16x32(); @@ -9110,7 +9865,8 @@ pub fn _mm512_shufflelo_epi16(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 0))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_shufflelo_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shufflelo_epi16( src: __m512i, k: __mmask32, a: __m512i, @@ -9130,7 +9886,8 @@ pub fn _mm512_mask_shufflelo_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 0))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_shufflelo_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shufflelo_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm512_shufflelo_epi16::(a); @@ -9146,7 +9903,8 @@ pub fn _mm512_maskz_shufflelo_epi16(k: __mmask32, a: __m512i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_shufflelo_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shufflelo_epi16( src: __m256i, k: __mmask16, a: __m256i, @@ -9166,7 +9924,8 @@ pub fn _mm256_mask_shufflelo_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_shufflelo_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shufflelo_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shuffle = _mm256_shufflelo_epi16::(a); @@ -9182,7 +9941,12 @@ pub fn _mm256_maskz_shufflelo_epi16(k: __mmask16, a: __m256i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_shufflelo_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shufflelo_epi16( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shuffle = _mm_shufflelo_epi16::(a); @@ -9198,7 +9962,8 @@ pub fn _mm_mask_shufflelo_epi16(src: __m128i, k: __mmask8, a: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshuflw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_shufflelo_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shufflelo_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shuffle = _mm_shufflelo_epi16::(a); @@ -9214,7 +9979,8 @@ pub fn _mm_maskz_shufflelo_epi16(k: __mmask8, a: __m128i) -> __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 0))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_shufflehi_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shufflehi_epi16(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let a = a.as_i16x32(); @@ -9268,7 +10034,8 @@ pub fn _mm512_shufflehi_epi16(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 0))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_mask_shufflehi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shufflehi_epi16( src: __m512i, k: __mmask32, a: __m512i, @@ -9288,7 +10055,8 @@ pub fn _mm512_mask_shufflehi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 0))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_maskz_shufflehi_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shufflehi_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm512_shufflehi_epi16::(a); @@ -9304,7 +10072,8 @@ pub fn _mm512_maskz_shufflehi_epi16(k: __mmask32, a: __m512i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_mask_shufflehi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shufflehi_epi16( src: __m256i, k: __mmask16, a: __m256i, @@ -9324,7 +10093,8 @@ pub fn _mm256_mask_shufflehi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_maskz_shufflehi_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shufflehi_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shuffle = _mm256_shufflehi_epi16::(a); @@ -9340,7 +10110,12 @@ pub fn _mm256_maskz_shufflehi_epi16(k: __mmask16, a: __m256i) - #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_mask_shufflehi_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shufflehi_epi16( + src: __m128i, + k: __mmask8, + a: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shuffle = _mm_shufflehi_epi16::(a); @@ -9356,7 +10131,8 @@ pub fn _mm_mask_shufflehi_epi16(src: __m128i, k: __mmask8, a: _ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshufhw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_maskz_shufflehi_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shufflehi_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shuffle = _mm_shufflehi_epi16::(a); @@ -9466,7 +10242,8 @@ pub fn _mm_maskz_shuffle_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmw))] -pub fn _mm512_test_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_test_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpneq_epi16_mask(and, zero) @@ -9479,7 +10256,8 @@ pub fn _mm512_test_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmw))] -pub fn _mm512_mask_test_epi16_mask(k: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_test_epi16_mask(k: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpneq_epi16_mask(k, and, zero) @@ -9492,7 +10270,8 @@ pub fn _mm512_mask_test_epi16_mask(k: __mmask32, a: __m512i, b: __m512i) -> __mm #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmw))] -pub fn _mm256_test_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_test_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpneq_epi16_mask(and, zero) @@ -9505,7 +10284,8 @@ pub fn _mm256_test_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmw))] -pub fn _mm256_mask_test_epi16_mask(k: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_test_epi16_mask(k: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpneq_epi16_mask(k, and, zero) @@ -9518,7 +10298,8 @@ pub fn _mm256_mask_test_epi16_mask(k: __mmask16, a: __m256i, b: __m256i) -> __mm #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmw))] -pub fn _mm_test_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_test_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpneq_epi16_mask(and, zero) @@ -9531,7 +10312,8 @@ pub fn _mm_test_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmw))] -pub fn _mm_mask_test_epi16_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_test_epi16_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpneq_epi16_mask(k, and, zero) @@ -9544,7 +10326,8 @@ pub fn _mm_mask_test_epi16_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmb))] -pub fn _mm512_test_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_test_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpneq_epi8_mask(and, zero) @@ -9557,7 +10340,8 @@ pub fn _mm512_test_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmb))] -pub fn _mm512_mask_test_epi8_mask(k: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_test_epi8_mask(k: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpneq_epi8_mask(k, and, zero) @@ -9570,7 +10354,8 @@ pub fn _mm512_mask_test_epi8_mask(k: __mmask64, a: __m512i, b: __m512i) -> __mma #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmb))] -pub fn _mm256_test_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_test_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpneq_epi8_mask(and, zero) @@ -9583,7 +10368,8 @@ pub fn _mm256_test_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmb))] -pub fn _mm256_mask_test_epi8_mask(k: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_test_epi8_mask(k: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpneq_epi8_mask(k, and, zero) @@ -9596,7 +10382,8 @@ pub fn _mm256_mask_test_epi8_mask(k: __mmask32, a: __m256i, b: __m256i) -> __mma #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmb))] -pub fn _mm_test_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_test_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpneq_epi8_mask(and, zero) @@ -9609,7 +10396,8 @@ pub fn _mm_test_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestmb))] -pub fn _mm_mask_test_epi8_mask(k: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_test_epi8_mask(k: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpneq_epi8_mask(k, and, zero) @@ -9622,7 +10410,8 @@ pub fn _mm_mask_test_epi8_mask(k: __mmask16, a: __m128i, b: __m128i) -> __mmask1 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmw))] -pub fn _mm512_testn_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_testn_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpeq_epi16_mask(and, zero) @@ -9635,7 +10424,8 @@ pub fn _mm512_testn_epi16_mask(a: __m512i, b: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmw))] -pub fn _mm512_mask_testn_epi16_mask(k: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_testn_epi16_mask(k: __mmask32, a: __m512i, b: __m512i) -> __mmask32 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpeq_epi16_mask(k, and, zero) @@ -9648,7 +10438,8 @@ pub fn _mm512_mask_testn_epi16_mask(k: __mmask32, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmw))] -pub fn _mm256_testn_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_testn_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpeq_epi16_mask(and, zero) @@ -9661,7 +10452,8 @@ pub fn _mm256_testn_epi16_mask(a: __m256i, b: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmw))] -pub fn _mm256_mask_testn_epi16_mask(k: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_testn_epi16_mask(k: __mmask16, a: __m256i, b: __m256i) -> __mmask16 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpeq_epi16_mask(k, and, zero) @@ -9674,7 +10466,8 @@ pub fn _mm256_mask_testn_epi16_mask(k: __mmask16, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmw))] -pub fn _mm_testn_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testn_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpeq_epi16_mask(and, zero) @@ -9687,7 +10480,8 @@ pub fn _mm_testn_epi16_mask(a: __m128i, b: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmw))] -pub fn _mm_mask_testn_epi16_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_testn_epi16_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask8 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpeq_epi16_mask(k, and, zero) @@ -9700,7 +10494,8 @@ pub fn _mm_mask_testn_epi16_mask(k: __mmask8, a: __m128i, b: __m128i) -> __mmask #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmb))] -pub fn _mm512_testn_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_testn_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_cmpeq_epi8_mask(and, zero) @@ -9713,7 +10508,8 @@ pub fn _mm512_testn_epi8_mask(a: __m512i, b: __m512i) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmb))] -pub fn _mm512_mask_testn_epi8_mask(k: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_testn_epi8_mask(k: __mmask64, a: __m512i, b: __m512i) -> __mmask64 { let and = _mm512_and_si512(a, b); let zero = _mm512_setzero_si512(); _mm512_mask_cmpeq_epi8_mask(k, and, zero) @@ -9726,7 +10522,8 @@ pub fn _mm512_mask_testn_epi8_mask(k: __mmask64, a: __m512i, b: __m512i) -> __mm #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmb))] -pub fn _mm256_testn_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_testn_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_cmpeq_epi8_mask(and, zero) @@ -9739,7 +10536,8 @@ pub fn _mm256_testn_epi8_mask(a: __m256i, b: __m256i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmb))] -pub fn _mm256_mask_testn_epi8_mask(k: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_testn_epi8_mask(k: __mmask32, a: __m256i, b: __m256i) -> __mmask32 { let and = _mm256_and_si256(a, b); let zero = _mm256_setzero_si256(); _mm256_mask_cmpeq_epi8_mask(k, and, zero) @@ -9752,7 +10550,8 @@ pub fn _mm256_mask_testn_epi8_mask(k: __mmask32, a: __m256i, b: __m256i) -> __mm #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmb))] -pub fn _mm_testn_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_testn_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_cmpeq_epi8_mask(and, zero) @@ -9765,7 +10564,8 @@ pub fn _mm_testn_epi8_mask(a: __m128i, b: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vptestnmb))] -pub fn _mm_mask_testn_epi8_mask(k: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_testn_epi8_mask(k: __mmask16, a: __m128i, b: __m128i) -> __mmask16 { let and = _mm_and_si128(a, b); let zero = _mm_setzero_si128(); _mm_mask_cmpeq_epi8_mask(k, and, zero) @@ -9778,7 +10578,8 @@ pub fn _mm_mask_testn_epi8_mask(k: __mmask16, a: __m128i, b: __m128i) -> __mmask #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] //should be kmovq -pub unsafe fn _store_mask64(mem_addr: *mut __mmask64, a: __mmask64) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _store_mask64(mem_addr: *mut __mmask64, a: __mmask64) { ptr::write(mem_addr as *mut __mmask64, a); } @@ -9789,7 +10590,8 @@ pub unsafe fn _store_mask64(mem_addr: *mut __mmask64, a: __mmask64) { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] //should be kmovd -pub unsafe fn _store_mask32(mem_addr: *mut __mmask32, a: __mmask32) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _store_mask32(mem_addr: *mut __mmask32, a: __mmask32) { ptr::write(mem_addr as *mut __mmask32, a); } @@ -9800,7 +10602,8 @@ pub unsafe fn _store_mask32(mem_addr: *mut __mmask32, a: __mmask32) { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] //should be kmovq -pub unsafe fn _load_mask64(mem_addr: *const __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _load_mask64(mem_addr: *const __mmask64) -> __mmask64 { ptr::read(mem_addr as *const __mmask64) } @@ -9811,7 +10614,8 @@ pub unsafe fn _load_mask64(mem_addr: *const __mmask64) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] //should be kmovd -pub unsafe fn _load_mask32(mem_addr: *const __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _load_mask32(mem_addr: *const __mmask32) -> __mmask32 { ptr::read(mem_addr as *const __mmask32) } @@ -10010,7 +10814,8 @@ pub fn _mm_maskz_dbsad_epu8(k: __mmask8, a: __m128i, b: __m128i #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovw2m))] -pub fn _mm512_movepi16_mask(a: __m512i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movepi16_mask(a: __m512i) -> __mmask32 { let filter = _mm512_set1_epi16(1 << 15); let a = _mm512_and_si512(a, filter); _mm512_cmpeq_epi16_mask(a, filter) @@ -10023,7 +10828,8 @@ pub fn _mm512_movepi16_mask(a: __m512i) -> __mmask32 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovw2m))] -pub fn _mm256_movepi16_mask(a: __m256i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movepi16_mask(a: __m256i) -> __mmask16 { let filter = _mm256_set1_epi16(1 << 15); let a = _mm256_and_si256(a, filter); _mm256_cmpeq_epi16_mask(a, filter) @@ -10036,7 +10842,8 @@ pub fn _mm256_movepi16_mask(a: __m256i) -> __mmask16 { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovw2m))] -pub fn _mm_movepi16_mask(a: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movepi16_mask(a: __m128i) -> __mmask8 { let filter = _mm_set1_epi16(1 << 15); let a = _mm_and_si128(a, filter); _mm_cmpeq_epi16_mask(a, filter) @@ -10049,7 +10856,8 @@ pub fn _mm_movepi16_mask(a: __m128i) -> __mmask8 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovb2m))] -pub fn _mm512_movepi8_mask(a: __m512i) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movepi8_mask(a: __m512i) -> __mmask64 { let filter = _mm512_set1_epi8(1 << 7); let a = _mm512_and_si512(a, filter); _mm512_cmpeq_epi8_mask(a, filter) @@ -10061,9 +10869,11 @@ pub fn _mm512_movepi8_mask(a: __m512i) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -#[cfg_attr(test, assert_instr(vpmovmskb))] // should be vpmovb2m but compiled to vpmovmskb in the test shim because that takes less cycles than +#[cfg_attr(test, assert_instr(vpmovmskb))] +// should be vpmovb2m but compiled to vpmovmskb in the test shim because that takes less cycles than // using vpmovb2m plus converting the mask register to a standard register. -pub fn _mm256_movepi8_mask(a: __m256i) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movepi8_mask(a: __m256i) -> __mmask32 { let filter = _mm256_set1_epi8(1 << 7); let a = _mm256_and_si256(a, filter); _mm256_cmpeq_epi8_mask(a, filter) @@ -10075,9 +10885,11 @@ pub fn _mm256_movepi8_mask(a: __m256i) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -#[cfg_attr(test, assert_instr(vpmovmskb))] // should be vpmovb2m but compiled to vpmovmskb in the test shim because that takes less cycles than +#[cfg_attr(test, assert_instr(vpmovmskb))] +// should be vpmovb2m but compiled to vpmovmskb in the test shim because that takes less cycles than // using vpmovb2m plus converting the mask register to a standard register. -pub fn _mm_movepi8_mask(a: __m128i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movepi8_mask(a: __m128i) -> __mmask16 { let filter = _mm_set1_epi8(1 << 7); let a = _mm_and_si128(a, filter); _mm_cmpeq_epi8_mask(a, filter) @@ -10090,7 +10902,8 @@ pub fn _mm_movepi8_mask(a: __m128i) -> __mmask16 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovm2w))] -pub fn _mm512_movm_epi16(k: __mmask32) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movm_epi16(k: __mmask32) -> __m512i { unsafe { let one = _mm512_set1_epi16( 1 << 15 @@ -10122,7 +10935,8 @@ pub fn _mm512_movm_epi16(k: __mmask32) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovm2w))] -pub fn _mm256_movm_epi16(k: __mmask16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movm_epi16(k: __mmask16) -> __m256i { unsafe { let one = _mm256_set1_epi16( 1 << 15 @@ -10154,7 +10968,8 @@ pub fn _mm256_movm_epi16(k: __mmask16) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovm2w))] -pub fn _mm_movm_epi16(k: __mmask8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movm_epi16(k: __mmask8) -> __m128i { unsafe { let one = _mm_set1_epi16( 1 << 15 @@ -10186,7 +11001,8 @@ pub fn _mm_movm_epi16(k: __mmask8) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovm2b))] -pub fn _mm512_movm_epi8(k: __mmask64) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movm_epi8(k: __mmask64) -> __m512i { unsafe { let one = _mm512_set1_epi8(1 << 7 | 1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0) @@ -10202,7 +11018,8 @@ pub fn _mm512_movm_epi8(k: __mmask64) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovm2b))] -pub fn _mm256_movm_epi8(k: __mmask32) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movm_epi8(k: __mmask32) -> __m256i { unsafe { let one = _mm256_set1_epi8(1 << 7 | 1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0) @@ -10218,7 +11035,8 @@ pub fn _mm256_movm_epi8(k: __mmask32) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovm2b))] -pub fn _mm_movm_epi8(k: __mmask16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movm_epi8(k: __mmask16) -> __m128i { unsafe { let one = _mm_set1_epi8(1 << 7 | 1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0) @@ -10233,7 +11051,8 @@ pub fn _mm_movm_epi8(k: __mmask16) -> __m128i { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtmask32_u32(a: __mmask32) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtmask32_u32(a: __mmask32) -> u32 { a } @@ -10243,7 +11062,8 @@ pub fn _cvtmask32_u32(a: __mmask32) -> u32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtu32_mask32(a: u32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtu32_mask32(a: u32) -> __mmask32 { a } @@ -10253,7 +11073,8 @@ pub fn _cvtu32_mask32(a: u32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kadd_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kadd_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { a.wrapping_add(b) } @@ -10263,7 +11084,8 @@ pub fn _kadd_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kadd_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kadd_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { a.wrapping_add(b) } @@ -10273,7 +11095,8 @@ pub fn _kadd_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kand_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kand_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { a & b } @@ -10283,7 +11106,8 @@ pub fn _kand_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kand_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kand_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { a & b } @@ -10293,7 +11117,8 @@ pub fn _kand_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _knot_mask32(a: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _knot_mask32(a: __mmask32) -> __mmask32 { !a } @@ -10303,7 +11128,8 @@ pub fn _knot_mask32(a: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _knot_mask64(a: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _knot_mask64(a: __mmask64) -> __mmask64 { !a } @@ -10313,7 +11139,8 @@ pub fn _knot_mask64(a: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kandn_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kandn_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { _knot_mask32(a) & b } @@ -10323,7 +11150,8 @@ pub fn _kandn_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kandn_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kandn_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { _knot_mask64(a) & b } @@ -10333,7 +11161,8 @@ pub fn _kandn_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { a | b } @@ -10343,7 +11172,8 @@ pub fn _kor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { a | b } @@ -10353,7 +11183,8 @@ pub fn _kor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kxor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { a ^ b } @@ -10363,7 +11194,8 @@ pub fn _kxor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kxor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { a ^ b } @@ -10373,7 +11205,8 @@ pub fn _kxor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kxnor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxnor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { _knot_mask32(a ^ b) } @@ -10383,7 +11216,8 @@ pub fn _kxnor_mask32(a: __mmask32, b: __mmask32) -> __mmask32 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kxnor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxnor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { _knot_mask64(a ^ b) } @@ -10394,7 +11228,8 @@ pub fn _kxnor_mask64(a: __mmask64, b: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _kortest_mask32_u8(a: __mmask32, b: __mmask32, all_ones: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _kortest_mask32_u8(a: __mmask32, b: __mmask32, all_ones: *mut u8) -> u8 { let tmp = _kor_mask32(a, b); *all_ones = (tmp == 0xffffffff) as u8; (tmp == 0) as u8 @@ -10407,7 +11242,8 @@ pub unsafe fn _kortest_mask32_u8(a: __mmask32, b: __mmask32, all_ones: *mut u8) #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _kortest_mask64_u8(a: __mmask64, b: __mmask64, all_ones: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _kortest_mask64_u8(a: __mmask64, b: __mmask64, all_ones: *mut u8) -> u8 { let tmp = _kor_mask64(a, b); *all_ones = (tmp == 0xffffffff_ffffffff) as u8; (tmp == 0) as u8 @@ -10420,7 +11256,8 @@ pub unsafe fn _kortest_mask64_u8(a: __mmask64, b: __mmask64, all_ones: *mut u8) #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestc_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestc_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { (_kor_mask32(a, b) == 0xffffffff) as u8 } @@ -10431,7 +11268,8 @@ pub fn _kortestc_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestc_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestc_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { (_kor_mask64(a, b) == 0xffffffff_ffffffff) as u8 } @@ -10442,7 +11280,8 @@ pub fn _kortestc_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestz_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestz_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { (_kor_mask32(a, b) == 0) as u8 } @@ -10453,7 +11292,8 @@ pub fn _kortestz_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestz_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestz_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { (_kor_mask64(a, b) == 0) as u8 } @@ -10464,7 +11304,8 @@ pub fn _kortestz_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { #[target_feature(enable = "avx512bw")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftli_mask32(a: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftli_mask32(a: __mmask32) -> __mmask32 { a.unbounded_shl(COUNT) } @@ -10475,7 +11316,8 @@ pub fn _kshiftli_mask32(a: __mmask32) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftli_mask64(a: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftli_mask64(a: __mmask64) -> __mmask64 { a.unbounded_shl(COUNT) } @@ -10486,7 +11328,8 @@ pub fn _kshiftli_mask64(a: __mmask64) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftri_mask32(a: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftri_mask32(a: __mmask32) -> __mmask32 { a.unbounded_shr(COUNT) } @@ -10497,7 +11340,8 @@ pub fn _kshiftri_mask32(a: __mmask32) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftri_mask64(a: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftri_mask64(a: __mmask64) -> __mmask64 { a.unbounded_shr(COUNT) } @@ -10509,7 +11353,8 @@ pub fn _kshiftri_mask64(a: __mmask64) -> __mmask64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _ktest_mask32_u8(a: __mmask32, b: __mmask32, and_not: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _ktest_mask32_u8(a: __mmask32, b: __mmask32, and_not: *mut u8) -> u8 { *and_not = (_kandn_mask32(a, b) == 0) as u8; (_kand_mask32(a, b) == 0) as u8 } @@ -10522,7 +11367,8 @@ pub unsafe fn _ktest_mask32_u8(a: __mmask32, b: __mmask32, and_not: *mut u8) -> #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _ktest_mask64_u8(a: __mmask64, b: __mmask64, and_not: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _ktest_mask64_u8(a: __mmask64, b: __mmask64, and_not: *mut u8) -> u8 { *and_not = (_kandn_mask64(a, b) == 0) as u8; (_kand_mask64(a, b) == 0) as u8 } @@ -10534,7 +11380,8 @@ pub unsafe fn _ktest_mask64_u8(a: __mmask64, b: __mmask64, and_not: *mut u8) -> #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestc_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestc_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { (_kandn_mask32(a, b) == 0) as u8 } @@ -10545,7 +11392,8 @@ pub fn _ktestc_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestc_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestc_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { (_kandn_mask64(a, b) == 0) as u8 } @@ -10556,7 +11404,8 @@ pub fn _ktestc_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestz_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestz_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { (_kand_mask32(a, b) == 0) as u8 } @@ -10567,7 +11416,8 @@ pub fn _ktestz_mask32_u8(a: __mmask32, b: __mmask32) -> u8 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestz_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestz_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { (_kand_mask64(a, b) == 0) as u8 } @@ -10578,7 +11428,8 @@ pub fn _ktestz_mask64_u8(a: __mmask64, b: __mmask64) -> u8 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] // generate normal and code instead of kunpckwd -pub fn _mm512_kunpackw(a: __mmask32, b: __mmask32) -> __mmask32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kunpackw(a: __mmask32, b: __mmask32) -> __mmask32 { ((a & 0xffff) << 16) | (b & 0xffff) } @@ -10589,7 +11440,8 @@ pub fn _mm512_kunpackw(a: __mmask32, b: __mmask32) -> __mmask32 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(mov))] // generate normal and code instead of kunpckdq -pub fn _mm512_kunpackd(a: __mmask64, b: __mmask64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_kunpackd(a: __mmask64, b: __mmask64) -> __mmask64 { ((a & 0xffffffff) << 32) | (b & 0xffffffff) } @@ -10600,7 +11452,8 @@ pub fn _mm512_kunpackd(a: __mmask64, b: __mmask64) -> __mmask64 { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm512_cvtepi16_epi8(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi16_epi8(a: __m512i) -> __m256i { unsafe { let a = a.as_i16x32(); transmute::(simd_cast(a)) @@ -10614,7 +11467,8 @@ pub fn _mm512_cvtepi16_epi8(a: __m512i) -> __m256i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm512_mask_cvtepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { unsafe { let convert = _mm512_cvtepi16_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, convert, src.as_i8x32())) @@ -10628,7 +11482,8 @@ pub fn _mm512_mask_cvtepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m2 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm512_maskz_cvtepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { unsafe { let convert = _mm512_cvtepi16_epi8(a).as_i8x32(); transmute(simd_select_bitmask(k, convert, i8x32::ZERO)) @@ -10642,7 +11497,8 @@ pub fn _mm512_maskz_cvtepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm256_cvtepi16_epi8(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtepi16_epi8(a: __m256i) -> __m128i { unsafe { let a = a.as_i16x16(); transmute::(simd_cast(a)) @@ -10656,7 +11512,8 @@ pub fn _mm256_cvtepi16_epi8(a: __m256i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm256_mask_cvtepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { unsafe { let convert = _mm256_cvtepi16_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, convert, src.as_i8x16())) @@ -10670,7 +11527,8 @@ pub fn _mm256_mask_cvtepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m1 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm256_maskz_cvtepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { unsafe { let convert = _mm256_cvtepi16_epi8(a).as_i8x16(); transmute(simd_select_bitmask(k, convert, i8x16::ZERO)) @@ -10684,7 +11542,8 @@ pub fn _mm256_maskz_cvtepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm_cvtepi16_epi8(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtepi16_epi8(a: __m128i) -> __m128i { unsafe { let a = a.as_i16x8(); let v256: i16x16 = simd_shuffle!( @@ -10703,7 +11562,8 @@ pub fn _mm_cvtepi16_epi8(a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm_mask_cvtepi16_epi8(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi16_epi8(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let a = _mm_cvtepi16_epi8(a).as_i8x16(); let src = simd_shuffle!( @@ -10722,7 +11582,8 @@ pub fn _mm_mask_cvtepi16_epi8(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub fn _mm_maskz_cvtepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { _mm_mask_cvtepi16_epi8(_mm_setzero_si128(), k, a) } @@ -10733,7 +11594,8 @@ pub fn _mm_maskz_cvtepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] -pub fn _mm512_cvtsepi16_epi8(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm512_cvtsepi16_epi8(a: __m512i) -> __m256i { unsafe { simd_cast::<_, i8x32>(simd_imax( simd_imin(a.as_i16x32(), i16x32::splat(i8::MAX as _)), @@ -10750,7 +11612,8 @@ pub fn _mm512_cvtsepi16_epi8(a: __m512i) -> __m256i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] -pub fn _mm512_mask_cvtsepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm512_mask_cvtsepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { unsafe { simd_select_bitmask(k, _mm512_cvtsepi16_epi8(a).as_i8x32(), src.as_i8x32()).as_m256i() } @@ -10763,7 +11626,8 @@ pub fn _mm512_mask_cvtsepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] -pub fn _mm512_maskz_cvtsepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm512_maskz_cvtsepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { unsafe { simd_select_bitmask(k, _mm512_cvtsepi16_epi8(a).as_i8x32(), i8x32::ZERO).as_m256i() } } @@ -10774,7 +11638,8 @@ pub fn _mm512_maskz_cvtsepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] -pub fn _mm256_cvtsepi16_epi8(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm256_cvtsepi16_epi8(a: __m256i) -> __m128i { unsafe { simd_cast::<_, i8x16>(simd_imax( simd_imin(a.as_i16x16(), i16x16::splat(i8::MAX as _)), @@ -10791,7 +11656,8 @@ pub fn _mm256_cvtsepi16_epi8(a: __m256i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] -pub fn _mm256_mask_cvtsepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm256_mask_cvtsepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { unsafe { simd_select_bitmask(k, _mm256_cvtsepi16_epi8(a).as_i8x16(), src.as_i8x16()).as_m128i() } @@ -10804,7 +11670,8 @@ pub fn _mm256_mask_cvtsepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovswb))] -pub fn _mm256_maskz_cvtsepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm256_maskz_cvtsepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { unsafe { simd_select_bitmask(k, _mm256_cvtsepi16_epi8(a).as_i8x16(), i8x16::ZERO).as_m128i() } } @@ -10848,7 +11715,8 @@ pub fn _mm_maskz_cvtsepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] -pub fn _mm512_cvtusepi16_epi8(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm512_cvtusepi16_epi8(a: __m512i) -> __m256i { unsafe { simd_cast::<_, u8x32>(simd_imin(a.as_u16x32(), u16x32::splat(u8::MAX as _))).as_m256i() } @@ -10861,7 +11729,8 @@ pub fn _mm512_cvtusepi16_epi8(a: __m512i) -> __m256i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] -pub fn _mm512_mask_cvtusepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm512_mask_cvtusepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __m256i { unsafe { simd_select_bitmask(k, _mm512_cvtusepi16_epi8(a).as_u8x32(), src.as_u8x32()).as_m256i() } @@ -10874,7 +11743,8 @@ pub fn _mm512_mask_cvtusepi16_epi8(src: __m256i, k: __mmask32, a: __m512i) -> __ #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] -pub fn _mm512_maskz_cvtusepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm512_maskz_cvtusepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { unsafe { simd_select_bitmask(k, _mm512_cvtusepi16_epi8(a).as_u8x32(), u8x32::ZERO).as_m256i() } } @@ -10885,7 +11755,8 @@ pub fn _mm512_maskz_cvtusepi16_epi8(k: __mmask32, a: __m512i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] -pub fn _mm256_cvtusepi16_epi8(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm256_cvtusepi16_epi8(a: __m256i) -> __m128i { unsafe { simd_cast::<_, u8x16>(simd_imin(a.as_u16x16(), u16x16::splat(u8::MAX as _))).as_m128i() } @@ -10898,7 +11769,8 @@ pub fn _mm256_cvtusepi16_epi8(a: __m256i) -> __m128i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] -pub fn _mm256_mask_cvtusepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm256_mask_cvtusepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __m128i { unsafe { simd_select_bitmask(k, _mm256_cvtusepi16_epi8(a).as_u8x16(), src.as_u8x16()).as_m128i() } @@ -10911,7 +11783,8 @@ pub fn _mm256_mask_cvtusepi16_epi8(src: __m128i, k: __mmask16, a: __m256i) -> __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovuswb))] -pub fn _mm256_maskz_cvtusepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const fn _mm256_maskz_cvtusepi16_epi8(k: __mmask16, a: __m256i) -> __m128i { unsafe { simd_select_bitmask(k, _mm256_cvtusepi16_epi8(a).as_u8x16(), u8x16::ZERO).as_m128i() } } @@ -10955,7 +11828,8 @@ pub fn _mm_maskz_cvtusepi16_epi8(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm512_cvtepi8_epi16(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepi8_epi16(a: __m256i) -> __m512i { unsafe { let a = a.as_i8x32(); transmute::(simd_cast(a)) @@ -10969,7 +11843,8 @@ pub fn _mm512_cvtepi8_epi16(a: __m256i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm512_mask_cvtepi8_epi16(src: __m512i, k: __mmask32, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepi8_epi16(src: __m512i, k: __mmask32, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepi8_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, convert, src.as_i16x32())) @@ -10983,7 +11858,8 @@ pub fn _mm512_mask_cvtepi8_epi16(src: __m512i, k: __mmask32, a: __m256i) -> __m5 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm512_maskz_cvtepi8_epi16(k: __mmask32, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepi8_epi16(k: __mmask32, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepi8_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, convert, i16x32::ZERO)) @@ -10997,7 +11873,8 @@ pub fn _mm512_maskz_cvtepi8_epi16(k: __mmask32, a: __m256i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm256_mask_cvtepi8_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepi8_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi8_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, convert, src.as_i16x16())) @@ -11011,7 +11888,8 @@ pub fn _mm256_mask_cvtepi8_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm256_maskz_cvtepi8_epi16(k: __mmask16, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepi8_epi16(k: __mmask16, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepi8_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, convert, i16x16::ZERO)) @@ -11025,7 +11903,8 @@ pub fn _mm256_maskz_cvtepi8_epi16(k: __mmask16, a: __m128i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm_mask_cvtepi8_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepi8_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi8_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, src.as_i16x8())) @@ -11039,7 +11918,8 @@ pub fn _mm_mask_cvtepi8_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovsxbw))] -pub fn _mm_maskz_cvtepi8_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepi8_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepi8_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, i16x8::ZERO)) @@ -11053,7 +11933,8 @@ pub fn _mm_maskz_cvtepi8_epi16(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm512_cvtepu8_epi16(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtepu8_epi16(a: __m256i) -> __m512i { unsafe { let a = a.as_u8x32(); transmute::(simd_cast(a)) @@ -11067,7 +11948,8 @@ pub fn _mm512_cvtepu8_epi16(a: __m256i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm512_mask_cvtepu8_epi16(src: __m512i, k: __mmask32, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_cvtepu8_epi16(src: __m512i, k: __mmask32, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepu8_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, convert, src.as_i16x32())) @@ -11081,7 +11963,8 @@ pub fn _mm512_mask_cvtepu8_epi16(src: __m512i, k: __mmask32, a: __m256i) -> __m5 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm512_maskz_cvtepu8_epi16(k: __mmask32, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_cvtepu8_epi16(k: __mmask32, a: __m256i) -> __m512i { unsafe { let convert = _mm512_cvtepu8_epi16(a).as_i16x32(); transmute(simd_select_bitmask(k, convert, i16x32::ZERO)) @@ -11095,7 +11978,8 @@ pub fn _mm512_maskz_cvtepu8_epi16(k: __mmask32, a: __m256i) -> __m512i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm256_mask_cvtepu8_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_cvtepu8_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu8_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, convert, src.as_i16x16())) @@ -11109,7 +11993,8 @@ pub fn _mm256_mask_cvtepu8_epi16(src: __m256i, k: __mmask16, a: __m128i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm256_maskz_cvtepu8_epi16(k: __mmask16, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_cvtepu8_epi16(k: __mmask16, a: __m128i) -> __m256i { unsafe { let convert = _mm256_cvtepu8_epi16(a).as_i16x16(); transmute(simd_select_bitmask(k, convert, i16x16::ZERO)) @@ -11123,7 +12008,8 @@ pub fn _mm256_maskz_cvtepu8_epi16(k: __mmask16, a: __m128i) -> __m256i { #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm_mask_cvtepu8_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_cvtepu8_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu8_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, src.as_i16x8())) @@ -11137,7 +12023,8 @@ pub fn _mm_mask_cvtepu8_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovzxbw))] -pub fn _mm_maskz_cvtepu8_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_cvtepu8_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { let convert = _mm_cvtepu8_epi16(a).as_i16x8(); transmute(simd_select_bitmask(k, convert, i16x8::ZERO)) @@ -11152,7 +12039,8 @@ pub fn _mm_maskz_cvtepu8_epi16(k: __mmask8, a: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpslldq, IMM8 = 3))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_bslli_epi128(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_bslli_epi128(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); const fn mask(shift: i32, i: u32) -> u32 { @@ -11247,7 +12135,8 @@ pub fn _mm512_bslli_epi128(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrldq, IMM8 = 3))] #[rustc_legacy_const_generics(1)] -pub fn _mm512_bsrli_epi128(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_bsrli_epi128(a: __m512i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); const fn mask(shift: i32, i: u32) -> u32 { @@ -11344,7 +12233,8 @@ pub fn _mm512_bsrli_epi128(a: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 1))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_alignr_epi8(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_alignr_epi8(a: __m512i, b: __m512i) -> __m512i { const fn mask(shift: u32, i: u32) -> u32 { let shift = shift % 16; let mod_i = i % 16; @@ -11454,7 +12344,8 @@ pub fn _mm512_alignr_epi8(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 1))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_alignr_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_alignr_epi8( src: __m512i, k: __mmask64, a: __m512i, @@ -11475,7 +12366,12 @@ pub fn _mm512_mask_alignr_epi8( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 1))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_alignr_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_alignr_epi8( + k: __mmask64, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm512_alignr_epi8::(a, b); @@ -11491,7 +12387,8 @@ pub fn _mm512_maskz_alignr_epi8(k: __mmask64, a: __m512i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(4)] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 5))] -pub fn _mm256_mask_alignr_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_alignr_epi8( src: __m256i, k: __mmask32, a: __m256i, @@ -11512,7 +12409,12 @@ pub fn _mm256_mask_alignr_epi8( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 5))] -pub fn _mm256_maskz_alignr_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_alignr_epi8( + k: __mmask32, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm256_alignr_epi8::(a, b); @@ -11528,7 +12430,8 @@ pub fn _mm256_maskz_alignr_epi8(k: __mmask32, a: __m256i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(4)] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 5))] -pub fn _mm_mask_alignr_epi8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_alignr_epi8( src: __m128i, k: __mmask16, a: __m128i, @@ -11549,7 +12452,12 @@ pub fn _mm_mask_alignr_epi8( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[rustc_legacy_const_generics(3)] #[cfg_attr(test, assert_instr(vpalignr, IMM8 = 5))] -pub fn _mm_maskz_alignr_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_alignr_epi8( + k: __mmask16, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let r = _mm_alignr_epi8::(a, b); @@ -11597,7 +12505,8 @@ pub unsafe fn _mm_mask_cvtsepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub unsafe fn _mm512_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask32, a: __m512i) { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const unsafe fn _mm512_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask32, a: __m512i) { let result = _mm512_cvtepi16_epi8(a).as_i8x32(); let mask = simd_select_bitmask(k, i8x32::splat(!0), i8x32::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, result); @@ -11610,7 +12519,8 @@ pub unsafe fn _mm512_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask32, #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub unsafe fn _mm256_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask16, a: __m256i) { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const unsafe fn _mm256_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask16, a: __m256i) { let result = _mm256_cvtepi16_epi8(a).as_i8x16(); let mask = simd_select_bitmask(k, i8x16::splat(!0), i8x16::ZERO); simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, result); @@ -11623,7 +12533,8 @@ pub unsafe fn _mm256_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask16, #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmovwb))] -pub unsafe fn _mm_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: __m128i) { +#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")] +pub const unsafe fn _mm_mask_cvtepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: __m128i) { let result: i8x8 = simd_shuffle!( _mm_cvtepi16_epi8(a).as_i8x16(), i8x16::ZERO, @@ -11742,6 +12653,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; @@ -11750,7 +12662,7 @@ mod tests { use crate::mem::{self}; #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_abs_epi16() { + const unsafe fn test_mm512_abs_epi16() { let a = _mm512_set1_epi16(-1); let r = _mm512_abs_epi16(a); let e = _mm512_set1_epi16(1); @@ -11758,7 +12670,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_abs_epi16() { + const unsafe fn test_mm512_mask_abs_epi16() { let a = _mm512_set1_epi16(-1); let r = _mm512_mask_abs_epi16(a, 0, a); assert_eq_m512i(r, a); @@ -11770,7 +12682,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_abs_epi16() { + const unsafe fn test_mm512_maskz_abs_epi16() { let a = _mm512_set1_epi16(-1); let r = _mm512_maskz_abs_epi16(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -11782,7 +12694,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_abs_epi16() { + const unsafe fn test_mm256_mask_abs_epi16() { let a = _mm256_set1_epi16(-1); let r = _mm256_mask_abs_epi16(a, 0, a); assert_eq_m256i(r, a); @@ -11792,7 +12704,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_abs_epi16() { + const unsafe fn test_mm256_maskz_abs_epi16() { let a = _mm256_set1_epi16(-1); let r = _mm256_maskz_abs_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -11802,7 +12714,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_abs_epi16() { + const unsafe fn test_mm_mask_abs_epi16() { let a = _mm_set1_epi16(-1); let r = _mm_mask_abs_epi16(a, 0, a); assert_eq_m128i(r, a); @@ -11812,7 +12724,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_abs_epi16() { + const unsafe fn test_mm_maskz_abs_epi16() { let a = _mm_set1_epi16(-1); let r = _mm_maskz_abs_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -11822,7 +12734,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_abs_epi8() { + const unsafe fn test_mm512_abs_epi8() { let a = _mm512_set1_epi8(-1); let r = _mm512_abs_epi8(a); let e = _mm512_set1_epi8(1); @@ -11830,7 +12742,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_abs_epi8() { + const unsafe fn test_mm512_mask_abs_epi8() { let a = _mm512_set1_epi8(-1); let r = _mm512_mask_abs_epi8(a, 0, a); assert_eq_m512i(r, a); @@ -11848,7 +12760,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_abs_epi8() { + const unsafe fn test_mm512_maskz_abs_epi8() { let a = _mm512_set1_epi8(-1); let r = _mm512_maskz_abs_epi8(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -11865,7 +12777,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_abs_epi8() { + const unsafe fn test_mm256_mask_abs_epi8() { let a = _mm256_set1_epi8(-1); let r = _mm256_mask_abs_epi8(a, 0, a); assert_eq_m256i(r, a); @@ -11877,7 +12789,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_abs_epi8() { + const unsafe fn test_mm256_maskz_abs_epi8() { let a = _mm256_set1_epi8(-1); let r = _mm256_maskz_abs_epi8(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -11889,7 +12801,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_abs_epi8() { + const unsafe fn test_mm_mask_abs_epi8() { let a = _mm_set1_epi8(-1); let r = _mm_mask_abs_epi8(a, 0, a); assert_eq_m128i(r, a); @@ -11899,7 +12811,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_abs_epi8() { + const unsafe fn test_mm_maskz_abs_epi8() { let a = _mm_set1_epi8(-1); let r = _mm_maskz_abs_epi8(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -11910,7 +12822,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_add_epi16() { + const unsafe fn test_mm512_add_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_add_epi16(a, b); @@ -11919,7 +12831,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_add_epi16() { + const unsafe fn test_mm512_mask_add_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_mask_add_epi16(a, 0, a, b); @@ -11932,7 +12844,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_add_epi16() { + const unsafe fn test_mm512_maskz_add_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_maskz_add_epi16(0, a, b); @@ -11945,7 +12857,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_add_epi16() { + const unsafe fn test_mm256_mask_add_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(2); let r = _mm256_mask_add_epi16(a, 0, a, b); @@ -11956,7 +12868,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_add_epi16() { + const unsafe fn test_mm256_maskz_add_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(2); let r = _mm256_maskz_add_epi16(0, a, b); @@ -11967,7 +12879,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_add_epi16() { + const unsafe fn test_mm_mask_add_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(2); let r = _mm_mask_add_epi16(a, 0, a, b); @@ -11978,7 +12890,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_add_epi16() { + const unsafe fn test_mm_maskz_add_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(2); let r = _mm_maskz_add_epi16(0, a, b); @@ -11989,7 +12901,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_add_epi8() { + const unsafe fn test_mm512_add_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_add_epi8(a, b); @@ -11998,7 +12910,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_add_epi8() { + const unsafe fn test_mm512_mask_add_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_mask_add_epi8(a, 0, a, b); @@ -12018,7 +12930,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_add_epi8() { + const unsafe fn test_mm512_maskz_add_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_maskz_add_epi8(0, a, b); @@ -12037,7 +12949,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_add_epi8() { + const unsafe fn test_mm256_mask_add_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(2); let r = _mm256_mask_add_epi8(a, 0, a, b); @@ -12050,7 +12962,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_add_epi8() { + const unsafe fn test_mm256_maskz_add_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(2); let r = _mm256_maskz_add_epi8(0, a, b); @@ -12063,7 +12975,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_add_epi8() { + const unsafe fn test_mm_mask_add_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(2); let r = _mm_mask_add_epi8(a, 0, a, b); @@ -12074,7 +12986,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_add_epi8() { + const unsafe fn test_mm_maskz_add_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(2); let r = _mm_maskz_add_epi8(0, a, b); @@ -12085,7 +12997,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_adds_epu16() { + const unsafe fn test_mm512_adds_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(u16::MAX as i16); let r = _mm512_adds_epu16(a, b); @@ -12094,7 +13006,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_adds_epu16() { + const unsafe fn test_mm512_mask_adds_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(u16::MAX as i16); let r = _mm512_mask_adds_epu16(a, 0, a, b); @@ -12107,7 +13019,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_adds_epu16() { + const unsafe fn test_mm512_maskz_adds_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(u16::MAX as i16); let r = _mm512_maskz_adds_epu16(0, a, b); @@ -12120,7 +13032,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_adds_epu16() { + const unsafe fn test_mm256_mask_adds_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(u16::MAX as i16); let r = _mm256_mask_adds_epu16(a, 0, a, b); @@ -12132,7 +13044,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_adds_epu16() { + const unsafe fn test_mm256_maskz_adds_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(u16::MAX as i16); let r = _mm256_maskz_adds_epu16(0, a, b); @@ -12144,7 +13056,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_adds_epu16() { + const unsafe fn test_mm_mask_adds_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(u16::MAX as i16); let r = _mm_mask_adds_epu16(a, 0, a, b); @@ -12156,7 +13068,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_adds_epu16() { + const unsafe fn test_mm_maskz_adds_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(u16::MAX as i16); let r = _mm_maskz_adds_epu16(0, a, b); @@ -12168,7 +13080,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_adds_epu8() { + const unsafe fn test_mm512_adds_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(u8::MAX as i8); let r = _mm512_adds_epu8(a, b); @@ -12177,7 +13089,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_adds_epu8() { + const unsafe fn test_mm512_mask_adds_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(u8::MAX as i8); let r = _mm512_mask_adds_epu8(a, 0, a, b); @@ -12197,7 +13109,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_adds_epu8() { + const unsafe fn test_mm512_maskz_adds_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(u8::MAX as i8); let r = _mm512_maskz_adds_epu8(0, a, b); @@ -12216,7 +13128,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_adds_epu8() { + const unsafe fn test_mm256_mask_adds_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(u8::MAX as i8); let r = _mm256_mask_adds_epu8(a, 0, a, b); @@ -12229,7 +13141,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_adds_epu8() { + const unsafe fn test_mm256_maskz_adds_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(u8::MAX as i8); let r = _mm256_maskz_adds_epu8(0, a, b); @@ -12242,7 +13154,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_adds_epu8() { + const unsafe fn test_mm_mask_adds_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(u8::MAX as i8); let r = _mm_mask_adds_epu8(a, 0, a, b); @@ -12254,7 +13166,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_adds_epu8() { + const unsafe fn test_mm_maskz_adds_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(u8::MAX as i8); let r = _mm_maskz_adds_epu8(0, a, b); @@ -12266,7 +13178,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_adds_epi16() { + const unsafe fn test_mm512_adds_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(i16::MAX); let r = _mm512_adds_epi16(a, b); @@ -12275,7 +13187,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_adds_epi16() { + const unsafe fn test_mm512_mask_adds_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(i16::MAX); let r = _mm512_mask_adds_epi16(a, 0, a, b); @@ -12288,7 +13200,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_adds_epi16() { + const unsafe fn test_mm512_maskz_adds_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(i16::MAX); let r = _mm512_maskz_adds_epi16(0, a, b); @@ -12301,7 +13213,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_adds_epi16() { + const unsafe fn test_mm256_mask_adds_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(i16::MAX); let r = _mm256_mask_adds_epi16(a, 0, a, b); @@ -12313,7 +13225,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_adds_epi16() { + const unsafe fn test_mm256_maskz_adds_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(i16::MAX); let r = _mm256_maskz_adds_epi16(0, a, b); @@ -12325,7 +13237,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_adds_epi16() { + const unsafe fn test_mm_mask_adds_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(i16::MAX); let r = _mm_mask_adds_epi16(a, 0, a, b); @@ -12336,7 +13248,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_adds_epi16() { + const unsafe fn test_mm_maskz_adds_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(i16::MAX); let r = _mm_maskz_adds_epi16(0, a, b); @@ -12347,7 +13259,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_adds_epi8() { + const unsafe fn test_mm512_adds_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(i8::MAX); let r = _mm512_adds_epi8(a, b); @@ -12356,7 +13268,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_adds_epi8() { + const unsafe fn test_mm512_mask_adds_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(i8::MAX); let r = _mm512_mask_adds_epi8(a, 0, a, b); @@ -12376,7 +13288,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_adds_epi8() { + const unsafe fn test_mm512_maskz_adds_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(i8::MAX); let r = _mm512_maskz_adds_epi8(0, a, b); @@ -12395,7 +13307,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_adds_epi8() { + const unsafe fn test_mm256_mask_adds_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(i8::MAX); let r = _mm256_mask_adds_epi8(a, 0, a, b); @@ -12408,7 +13320,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_adds_epi8() { + const unsafe fn test_mm256_maskz_adds_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(i8::MAX); let r = _mm256_maskz_adds_epi8(0, a, b); @@ -12421,7 +13333,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_adds_epi8() { + const unsafe fn test_mm_mask_adds_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(i8::MAX); let r = _mm_mask_adds_epi8(a, 0, a, b); @@ -12433,7 +13345,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_adds_epi8() { + const unsafe fn test_mm_maskz_adds_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(i8::MAX); let r = _mm_maskz_adds_epi8(0, a, b); @@ -12445,7 +13357,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_sub_epi16() { + const unsafe fn test_mm512_sub_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_sub_epi16(a, b); @@ -12454,7 +13366,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_sub_epi16() { + const unsafe fn test_mm512_mask_sub_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_mask_sub_epi16(a, 0, a, b); @@ -12467,7 +13379,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_sub_epi16() { + const unsafe fn test_mm512_maskz_sub_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_maskz_sub_epi16(0, a, b); @@ -12480,7 +13392,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_sub_epi16() { + const unsafe fn test_mm256_mask_sub_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(2); let r = _mm256_mask_sub_epi16(a, 0, a, b); @@ -12491,7 +13403,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_sub_epi16() { + const unsafe fn test_mm256_maskz_sub_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(2); let r = _mm256_maskz_sub_epi16(0, a, b); @@ -12502,7 +13414,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_sub_epi16() { + const unsafe fn test_mm_mask_sub_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(2); let r = _mm_mask_sub_epi16(a, 0, a, b); @@ -12513,7 +13425,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_sub_epi16() { + const unsafe fn test_mm_maskz_sub_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(2); let r = _mm_maskz_sub_epi16(0, a, b); @@ -12524,7 +13436,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_sub_epi8() { + const unsafe fn test_mm512_sub_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_sub_epi8(a, b); @@ -12533,7 +13445,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_sub_epi8() { + const unsafe fn test_mm512_mask_sub_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_mask_sub_epi8(a, 0, a, b); @@ -12553,7 +13465,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_sub_epi8() { + const unsafe fn test_mm512_maskz_sub_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_maskz_sub_epi8(0, a, b); @@ -12572,7 +13484,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_sub_epi8() { + const unsafe fn test_mm256_mask_sub_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(2); let r = _mm256_mask_sub_epi8(a, 0, a, b); @@ -12585,7 +13497,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_sub_epi8() { + const unsafe fn test_mm256_maskz_sub_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(2); let r = _mm256_maskz_sub_epi8(0, a, b); @@ -12598,7 +13510,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_sub_epi8() { + const unsafe fn test_mm_mask_sub_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(2); let r = _mm_mask_sub_epi8(a, 0, a, b); @@ -12609,7 +13521,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_sub_epi8() { + const unsafe fn test_mm_maskz_sub_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(2); let r = _mm_maskz_sub_epi8(0, a, b); @@ -12620,7 +13532,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_subs_epu16() { + const unsafe fn test_mm512_subs_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(u16::MAX as i16); let r = _mm512_subs_epu16(a, b); @@ -12629,7 +13541,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_subs_epu16() { + const unsafe fn test_mm512_mask_subs_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(u16::MAX as i16); let r = _mm512_mask_subs_epu16(a, 0, a, b); @@ -12642,7 +13554,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_subs_epu16() { + const unsafe fn test_mm512_maskz_subs_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(u16::MAX as i16); let r = _mm512_maskz_subs_epu16(0, a, b); @@ -12655,7 +13567,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_subs_epu16() { + const unsafe fn test_mm256_mask_subs_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(u16::MAX as i16); let r = _mm256_mask_subs_epu16(a, 0, a, b); @@ -12666,7 +13578,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_subs_epu16() { + const unsafe fn test_mm256_maskz_subs_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(u16::MAX as i16); let r = _mm256_maskz_subs_epu16(0, a, b); @@ -12677,7 +13589,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_subs_epu16() { + const unsafe fn test_mm_mask_subs_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(u16::MAX as i16); let r = _mm_mask_subs_epu16(a, 0, a, b); @@ -12688,7 +13600,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_subs_epu16() { + const unsafe fn test_mm_maskz_subs_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(u16::MAX as i16); let r = _mm_maskz_subs_epu16(0, a, b); @@ -12699,7 +13611,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_subs_epu8() { + const unsafe fn test_mm512_subs_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(u8::MAX as i8); let r = _mm512_subs_epu8(a, b); @@ -12708,7 +13620,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_subs_epu8() { + const unsafe fn test_mm512_mask_subs_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(u8::MAX as i8); let r = _mm512_mask_subs_epu8(a, 0, a, b); @@ -12728,7 +13640,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_subs_epu8() { + const unsafe fn test_mm512_maskz_subs_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(u8::MAX as i8); let r = _mm512_maskz_subs_epu8(0, a, b); @@ -12747,7 +13659,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_subs_epu8() { + const unsafe fn test_mm256_mask_subs_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(u8::MAX as i8); let r = _mm256_mask_subs_epu8(a, 0, a, b); @@ -12760,7 +13672,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_subs_epu8() { + const unsafe fn test_mm256_maskz_subs_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(u8::MAX as i8); let r = _mm256_maskz_subs_epu8(0, a, b); @@ -12773,7 +13685,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_subs_epu8() { + const unsafe fn test_mm_mask_subs_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(u8::MAX as i8); let r = _mm_mask_subs_epu8(a, 0, a, b); @@ -12784,7 +13696,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_subs_epu8() { + const unsafe fn test_mm_maskz_subs_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(u8::MAX as i8); let r = _mm_maskz_subs_epu8(0, a, b); @@ -12795,7 +13707,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_subs_epi16() { + const unsafe fn test_mm512_subs_epi16() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(i16::MAX); let r = _mm512_subs_epi16(a, b); @@ -12804,7 +13716,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_subs_epi16() { + const unsafe fn test_mm512_mask_subs_epi16() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(i16::MAX); let r = _mm512_mask_subs_epi16(a, 0, a, b); @@ -12817,7 +13729,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_subs_epi16() { + const unsafe fn test_mm512_maskz_subs_epi16() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(i16::MAX); let r = _mm512_maskz_subs_epi16(0, a, b); @@ -12830,7 +13742,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_subs_epi16() { + const unsafe fn test_mm256_mask_subs_epi16() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(i16::MAX); let r = _mm256_mask_subs_epi16(a, 0, a, b); @@ -12842,7 +13754,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_subs_epi16() { + const unsafe fn test_mm256_maskz_subs_epi16() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(i16::MAX); let r = _mm256_maskz_subs_epi16(0, a, b); @@ -12854,7 +13766,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_subs_epi16() { + const unsafe fn test_mm_mask_subs_epi16() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(i16::MAX); let r = _mm_mask_subs_epi16(a, 0, a, b); @@ -12865,7 +13777,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_subs_epi16() { + const unsafe fn test_mm_maskz_subs_epi16() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(i16::MAX); let r = _mm_maskz_subs_epi16(0, a, b); @@ -12876,7 +13788,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_subs_epi8() { + const unsafe fn test_mm512_subs_epi8() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(i8::MAX); let r = _mm512_subs_epi8(a, b); @@ -12885,7 +13797,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_subs_epi8() { + const unsafe fn test_mm512_mask_subs_epi8() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(i8::MAX); let r = _mm512_mask_subs_epi8(a, 0, a, b); @@ -12905,7 +13817,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_subs_epi8() { + const unsafe fn test_mm512_maskz_subs_epi8() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(i8::MAX); let r = _mm512_maskz_subs_epi8(0, a, b); @@ -12924,7 +13836,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_subs_epi8() { + const unsafe fn test_mm256_mask_subs_epi8() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(i8::MAX); let r = _mm256_mask_subs_epi8(a, 0, a, b); @@ -12937,7 +13849,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_subs_epi8() { + const unsafe fn test_mm256_maskz_subs_epi8() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(i8::MAX); let r = _mm256_maskz_subs_epi8(0, a, b); @@ -12950,7 +13862,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_subs_epi8() { + const unsafe fn test_mm_mask_subs_epi8() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(i8::MAX); let r = _mm_mask_subs_epi8(a, 0, a, b); @@ -12962,7 +13874,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_subs_epi8() { + const unsafe fn test_mm_maskz_subs_epi8() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(i8::MAX); let r = _mm_maskz_subs_epi8(0, a, b); @@ -12974,7 +13886,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mulhi_epu16() { + const unsafe fn test_mm512_mulhi_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mulhi_epu16(a, b); @@ -12983,7 +13895,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_mulhi_epu16() { + const unsafe fn test_mm512_mask_mulhi_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_mulhi_epu16(a, 0, a, b); @@ -12996,7 +13908,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_mulhi_epu16() { + const unsafe fn test_mm512_maskz_mulhi_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_mulhi_epu16(0, a, b); @@ -13009,7 +13921,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_mulhi_epu16() { + const unsafe fn test_mm256_mask_mulhi_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_mulhi_epu16(a, 0, a, b); @@ -13020,7 +13932,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_mulhi_epu16() { + const unsafe fn test_mm256_maskz_mulhi_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_mulhi_epu16(0, a, b); @@ -13031,7 +13943,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_mulhi_epu16() { + const unsafe fn test_mm_mask_mulhi_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_mulhi_epu16(a, 0, a, b); @@ -13042,7 +13954,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_mulhi_epu16() { + const unsafe fn test_mm_maskz_mulhi_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_mulhi_epu16(0, a, b); @@ -13053,7 +13965,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mulhi_epi16() { + const unsafe fn test_mm512_mulhi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mulhi_epi16(a, b); @@ -13062,7 +13974,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_mulhi_epi16() { + const unsafe fn test_mm512_mask_mulhi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_mulhi_epi16(a, 0, a, b); @@ -13075,7 +13987,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_mulhi_epi16() { + const unsafe fn test_mm512_maskz_mulhi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_mulhi_epi16(0, a, b); @@ -13088,7 +14000,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_mulhi_epi16() { + const unsafe fn test_mm256_mask_mulhi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_mulhi_epi16(a, 0, a, b); @@ -13099,7 +14011,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_mulhi_epi16() { + const unsafe fn test_mm256_maskz_mulhi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_mulhi_epi16(0, a, b); @@ -13110,7 +14022,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_mulhi_epi16() { + const unsafe fn test_mm_mask_mulhi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_mulhi_epi16(a, 0, a, b); @@ -13121,7 +14033,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_mulhi_epi16() { + const unsafe fn test_mm_maskz_mulhi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_mulhi_epi16(0, a, b); @@ -13211,7 +14123,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mullo_epi16() { + const unsafe fn test_mm512_mullo_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mullo_epi16(a, b); @@ -13220,7 +14132,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_mullo_epi16() { + const unsafe fn test_mm512_mask_mullo_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_mullo_epi16(a, 0, a, b); @@ -13233,7 +14145,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_mullo_epi16() { + const unsafe fn test_mm512_maskz_mullo_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_mullo_epi16(0, a, b); @@ -13246,7 +14158,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_mullo_epi16() { + const unsafe fn test_mm256_mask_mullo_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_mullo_epi16(a, 0, a, b); @@ -13257,7 +14169,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_mullo_epi16() { + const unsafe fn test_mm256_maskz_mullo_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_mullo_epi16(0, a, b); @@ -13268,7 +14180,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_mullo_epi16() { + const unsafe fn test_mm_mask_mullo_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_mullo_epi16(a, 0, a, b); @@ -13279,7 +14191,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_mullo_epi16() { + const unsafe fn test_mm_maskz_mullo_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_mullo_epi16(0, a, b); @@ -13290,7 +14202,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_max_epu16() { + const unsafe fn test_mm512_max_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13305,7 +14217,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_max_epu16() { + const unsafe fn test_mm512_mask_max_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13322,7 +14234,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_max_epu16() { + const unsafe fn test_mm512_maskz_max_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13339,7 +14251,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_max_epu16() { + const unsafe fn test_mm256_mask_max_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_max_epu16(a, 0, a, b); @@ -13350,7 +14262,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_max_epu16() { + const unsafe fn test_mm256_maskz_max_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_max_epu16(0, a, b); @@ -13361,7 +14273,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_max_epu16() { + const unsafe fn test_mm_mask_max_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_max_epu16(a, 0, a, b); @@ -13372,7 +14284,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_max_epu16() { + const unsafe fn test_mm_maskz_max_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_max_epu16(0, a, b); @@ -13383,7 +14295,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_max_epu8() { + const unsafe fn test_mm512_max_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13404,7 +14316,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_max_epu8() { + const unsafe fn test_mm512_mask_max_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13432,7 +14344,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_max_epu8() { + const unsafe fn test_mm512_maskz_max_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13459,7 +14371,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_max_epu8() { + const unsafe fn test_mm256_mask_max_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13476,7 +14388,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_max_epu8() { + const unsafe fn test_mm256_maskz_max_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13493,7 +14405,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_max_epu8() { + const unsafe fn test_mm_mask_max_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_max_epu8(a, 0, a, b); @@ -13504,7 +14416,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_max_epu8() { + const unsafe fn test_mm_maskz_max_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_max_epu8(0, a, b); @@ -13515,7 +14427,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_max_epi16() { + const unsafe fn test_mm512_max_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13530,7 +14442,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_max_epi16() { + const unsafe fn test_mm512_mask_max_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13547,7 +14459,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_max_epi16() { + const unsafe fn test_mm512_maskz_max_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13564,7 +14476,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_max_epi16() { + const unsafe fn test_mm256_mask_max_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_max_epi16(a, 0, a, b); @@ -13575,7 +14487,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_max_epi16() { + const unsafe fn test_mm256_maskz_max_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_max_epi16(0, a, b); @@ -13586,7 +14498,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_max_epi16() { + const unsafe fn test_mm_mask_max_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_max_epi16(a, 0, a, b); @@ -13597,7 +14509,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_max_epi16() { + const unsafe fn test_mm_maskz_max_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_max_epi16(0, a, b); @@ -13608,7 +14520,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_max_epi8() { + const unsafe fn test_mm512_max_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13629,7 +14541,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_max_epi8() { + const unsafe fn test_mm512_mask_max_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13657,7 +14569,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_max_epi8() { + const unsafe fn test_mm512_maskz_max_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13684,7 +14596,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_max_epi8() { + const unsafe fn test_mm256_mask_max_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13701,7 +14613,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_max_epi8() { + const unsafe fn test_mm256_maskz_max_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13718,7 +14630,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_max_epi8() { + const unsafe fn test_mm_mask_max_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_max_epi8(a, 0, a, b); @@ -13729,7 +14641,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_max_epi8() { + const unsafe fn test_mm_maskz_max_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_max_epi8(0, a, b); @@ -13740,7 +14652,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_min_epu16() { + const unsafe fn test_mm512_min_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13755,7 +14667,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_min_epu16() { + const unsafe fn test_mm512_mask_min_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13772,7 +14684,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_min_epu16() { + const unsafe fn test_mm512_maskz_min_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13789,7 +14701,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_min_epu16() { + const unsafe fn test_mm256_mask_min_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_min_epu16(a, 0, a, b); @@ -13800,7 +14712,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_min_epu16() { + const unsafe fn test_mm256_maskz_min_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_min_epu16(0, a, b); @@ -13811,7 +14723,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_min_epu16() { + const unsafe fn test_mm_mask_min_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_min_epu16(a, 0, a, b); @@ -13822,7 +14734,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_min_epu16() { + const unsafe fn test_mm_maskz_min_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_min_epu16(0, a, b); @@ -13833,7 +14745,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_min_epu8() { + const unsafe fn test_mm512_min_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13854,7 +14766,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_min_epu8() { + const unsafe fn test_mm512_mask_min_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13882,7 +14794,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_min_epu8() { + const unsafe fn test_mm512_maskz_min_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13909,7 +14821,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_min_epu8() { + const unsafe fn test_mm256_mask_min_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13926,7 +14838,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_min_epu8() { + const unsafe fn test_mm256_maskz_min_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13943,7 +14855,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_min_epu8() { + const unsafe fn test_mm_mask_min_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_min_epu8(a, 0, a, b); @@ -13954,7 +14866,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_min_epu8() { + const unsafe fn test_mm_maskz_min_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_min_epu8(0, a, b); @@ -13965,7 +14877,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_min_epi16() { + const unsafe fn test_mm512_min_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13980,7 +14892,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_min_epi16() { + const unsafe fn test_mm512_mask_min_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -13997,7 +14909,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_min_epi16() { + const unsafe fn test_mm512_maskz_min_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -14014,7 +14926,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_min_epi16() { + const unsafe fn test_mm256_mask_min_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_mask_min_epi16(a, 0, a, b); @@ -14025,7 +14937,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_min_epi16() { + const unsafe fn test_mm256_maskz_min_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm256_maskz_min_epi16(0, a, b); @@ -14036,7 +14948,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_min_epi16() { + const unsafe fn test_mm_mask_min_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_min_epi16(a, 0, a, b); @@ -14047,7 +14959,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_min_epi16() { + const unsafe fn test_mm_maskz_min_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_min_epi16(0, a, b); @@ -14058,7 +14970,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_min_epi8() { + const unsafe fn test_mm512_min_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14079,7 +14991,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_min_epi8() { + const unsafe fn test_mm512_mask_min_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14107,7 +15019,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_min_epi8() { + const unsafe fn test_mm512_maskz_min_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14134,7 +15046,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_min_epi8() { + const unsafe fn test_mm256_mask_min_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -14151,7 +15063,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_min_epi8() { + const unsafe fn test_mm256_maskz_min_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -14168,7 +15080,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_min_epi8() { + const unsafe fn test_mm_mask_min_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_mask_min_epi8(a, 0, a, b); @@ -14179,7 +15091,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_min_epi8() { + const unsafe fn test_mm_maskz_min_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); let r = _mm_maskz_min_epi8(0, a, b); @@ -14190,7 +15102,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmplt_epu16_mask() { + const unsafe fn test_mm512_cmplt_epu16_mask() { let a = _mm512_set1_epi16(-2); let b = _mm512_set1_epi16(-1); let m = _mm512_cmplt_epu16_mask(a, b); @@ -14198,7 +15110,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmplt_epu16_mask() { + const unsafe fn test_mm512_mask_cmplt_epu16_mask() { let a = _mm512_set1_epi16(-2); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14207,7 +15119,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmplt_epu16_mask() { + const unsafe fn test_mm256_cmplt_epu16_mask() { let a = _mm256_set1_epi16(-2); let b = _mm256_set1_epi16(-1); let m = _mm256_cmplt_epu16_mask(a, b); @@ -14215,7 +15127,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epu16_mask() { + const unsafe fn test_mm256_mask_cmplt_epu16_mask() { let a = _mm256_set1_epi16(-2); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -14224,7 +15136,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmplt_epu16_mask() { + const unsafe fn test_mm_cmplt_epu16_mask() { let a = _mm_set1_epi16(-2); let b = _mm_set1_epi16(-1); let m = _mm_cmplt_epu16_mask(a, b); @@ -14232,7 +15144,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmplt_epu16_mask() { + const unsafe fn test_mm_mask_cmplt_epu16_mask() { let a = _mm_set1_epi16(-2); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -14241,7 +15153,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmplt_epu8_mask() { + const unsafe fn test_mm512_cmplt_epu8_mask() { let a = _mm512_set1_epi8(-2); let b = _mm512_set1_epi8(-1); let m = _mm512_cmplt_epu8_mask(a, b); @@ -14252,7 +15164,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmplt_epu8_mask() { + const unsafe fn test_mm512_mask_cmplt_epu8_mask() { let a = _mm512_set1_epi8(-2); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14264,7 +15176,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmplt_epu8_mask() { + const unsafe fn test_mm256_cmplt_epu8_mask() { let a = _mm256_set1_epi8(-2); let b = _mm256_set1_epi8(-1); let m = _mm256_cmplt_epu8_mask(a, b); @@ -14272,7 +15184,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epu8_mask() { + const unsafe fn test_mm256_mask_cmplt_epu8_mask() { let a = _mm256_set1_epi8(-2); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14281,7 +15193,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmplt_epu8_mask() { + const unsafe fn test_mm_cmplt_epu8_mask() { let a = _mm_set1_epi8(-2); let b = _mm_set1_epi8(-1); let m = _mm_cmplt_epu8_mask(a, b); @@ -14289,7 +15201,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmplt_epu8_mask() { + const unsafe fn test_mm_mask_cmplt_epu8_mask() { let a = _mm_set1_epi8(-2); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -14298,7 +15210,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmplt_epi16_mask() { + const unsafe fn test_mm512_cmplt_epi16_mask() { let a = _mm512_set1_epi16(-2); let b = _mm512_set1_epi16(-1); let m = _mm512_cmplt_epi16_mask(a, b); @@ -14306,7 +15218,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmplt_epi16_mask() { + const unsafe fn test_mm512_mask_cmplt_epi16_mask() { let a = _mm512_set1_epi16(-2); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14315,7 +15227,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmplt_epi16_mask() { + const unsafe fn test_mm256_cmplt_epi16_mask() { let a = _mm256_set1_epi16(-2); let b = _mm256_set1_epi16(-1); let m = _mm256_cmplt_epi16_mask(a, b); @@ -14323,7 +15235,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epi16_mask() { + const unsafe fn test_mm256_mask_cmplt_epi16_mask() { let a = _mm256_set1_epi16(-2); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -14332,7 +15244,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmplt_epi16_mask() { + const unsafe fn test_mm_cmplt_epi16_mask() { let a = _mm_set1_epi16(-2); let b = _mm_set1_epi16(-1); let m = _mm_cmplt_epi16_mask(a, b); @@ -14340,7 +15252,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmplt_epi16_mask() { + const unsafe fn test_mm_mask_cmplt_epi16_mask() { let a = _mm_set1_epi16(-2); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -14349,7 +15261,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmplt_epi8_mask() { + const unsafe fn test_mm512_cmplt_epi8_mask() { let a = _mm512_set1_epi8(-2); let b = _mm512_set1_epi8(-1); let m = _mm512_cmplt_epi8_mask(a, b); @@ -14360,7 +15272,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmplt_epi8_mask() { + const unsafe fn test_mm512_mask_cmplt_epi8_mask() { let a = _mm512_set1_epi8(-2); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14372,7 +15284,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmplt_epi8_mask() { + const unsafe fn test_mm256_cmplt_epi8_mask() { let a = _mm256_set1_epi8(-2); let b = _mm256_set1_epi8(-1); let m = _mm256_cmplt_epi8_mask(a, b); @@ -14380,7 +15292,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmplt_epi8_mask() { + const unsafe fn test_mm256_mask_cmplt_epi8_mask() { let a = _mm256_set1_epi8(-2); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14389,7 +15301,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmplt_epi8_mask() { + const unsafe fn test_mm_cmplt_epi8_mask() { let a = _mm_set1_epi8(-2); let b = _mm_set1_epi8(-1); let m = _mm_cmplt_epi8_mask(a, b); @@ -14397,7 +15309,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmplt_epi8_mask() { + const unsafe fn test_mm_mask_cmplt_epi8_mask() { let a = _mm_set1_epi8(-2); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -14406,7 +15318,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpgt_epu16_mask() { + const unsafe fn test_mm512_cmpgt_epu16_mask() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(1); let m = _mm512_cmpgt_epu16_mask(a, b); @@ -14414,7 +15326,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpgt_epu16_mask() { + const unsafe fn test_mm512_mask_cmpgt_epu16_mask() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14423,7 +15335,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpgt_epu16_mask() { + const unsafe fn test_mm256_cmpgt_epu16_mask() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(1); let m = _mm256_cmpgt_epu16_mask(a, b); @@ -14431,7 +15343,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epu16_mask() { + const unsafe fn test_mm256_mask_cmpgt_epu16_mask() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(1); let mask = 0b01010101_01010101; @@ -14440,7 +15352,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpgt_epu16_mask() { + const unsafe fn test_mm_cmpgt_epu16_mask() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(1); let m = _mm_cmpgt_epu16_mask(a, b); @@ -14448,7 +15360,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epu16_mask() { + const unsafe fn test_mm_mask_cmpgt_epu16_mask() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(1); let mask = 0b01010101; @@ -14457,7 +15369,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpgt_epu8_mask() { + const unsafe fn test_mm512_cmpgt_epu8_mask() { let a = _mm512_set1_epi8(2); let b = _mm512_set1_epi8(1); let m = _mm512_cmpgt_epu8_mask(a, b); @@ -14468,7 +15380,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpgt_epu8_mask() { + const unsafe fn test_mm512_mask_cmpgt_epu8_mask() { let a = _mm512_set1_epi8(2); let b = _mm512_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14480,7 +15392,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpgt_epu8_mask() { + const unsafe fn test_mm256_cmpgt_epu8_mask() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(1); let m = _mm256_cmpgt_epu8_mask(a, b); @@ -14488,7 +15400,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epu8_mask() { + const unsafe fn test_mm256_mask_cmpgt_epu8_mask() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14497,7 +15409,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpgt_epu8_mask() { + const unsafe fn test_mm_cmpgt_epu8_mask() { let a = _mm_set1_epi8(2); let b = _mm_set1_epi8(1); let m = _mm_cmpgt_epu8_mask(a, b); @@ -14505,7 +15417,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epu8_mask() { + const unsafe fn test_mm_mask_cmpgt_epu8_mask() { let a = _mm_set1_epi8(2); let b = _mm_set1_epi8(1); let mask = 0b01010101_01010101; @@ -14514,7 +15426,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpgt_epi16_mask() { + const unsafe fn test_mm512_cmpgt_epi16_mask() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(-1); let m = _mm512_cmpgt_epi16_mask(a, b); @@ -14522,7 +15434,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpgt_epi16_mask() { + const unsafe fn test_mm512_mask_cmpgt_epi16_mask() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14531,7 +15443,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpgt_epi16_mask() { + const unsafe fn test_mm256_cmpgt_epi16_mask() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(-1); let m = _mm256_cmpgt_epi16_mask(a, b); @@ -14539,7 +15451,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epi16_mask() { + const unsafe fn test_mm256_mask_cmpgt_epi16_mask() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(-1); let mask = 0b001010101_01010101; @@ -14548,7 +15460,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpgt_epi16_mask() { + const unsafe fn test_mm_cmpgt_epi16_mask() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(-1); let m = _mm_cmpgt_epi16_mask(a, b); @@ -14556,7 +15468,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epi16_mask() { + const unsafe fn test_mm_mask_cmpgt_epi16_mask() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -14565,7 +15477,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpgt_epi8_mask() { + const unsafe fn test_mm512_cmpgt_epi8_mask() { let a = _mm512_set1_epi8(2); let b = _mm512_set1_epi8(-1); let m = _mm512_cmpgt_epi8_mask(a, b); @@ -14576,7 +15488,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpgt_epi8_mask() { + const unsafe fn test_mm512_mask_cmpgt_epi8_mask() { let a = _mm512_set1_epi8(2); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14588,7 +15500,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpgt_epi8_mask() { + const unsafe fn test_mm256_cmpgt_epi8_mask() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(-1); let m = _mm256_cmpgt_epi8_mask(a, b); @@ -14596,7 +15508,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpgt_epi8_mask() { + const unsafe fn test_mm256_mask_cmpgt_epi8_mask() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14605,7 +15517,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpgt_epi8_mask() { + const unsafe fn test_mm_cmpgt_epi8_mask() { let a = _mm_set1_epi8(2); let b = _mm_set1_epi8(-1); let m = _mm_cmpgt_epi8_mask(a, b); @@ -14613,7 +15525,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpgt_epi8_mask() { + const unsafe fn test_mm_mask_cmpgt_epi8_mask() { let a = _mm_set1_epi8(2); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -14622,7 +15534,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmple_epu16_mask() { + const unsafe fn test_mm512_cmple_epu16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let m = _mm512_cmple_epu16_mask(a, b); @@ -14630,7 +15542,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmple_epu16_mask() { + const unsafe fn test_mm512_mask_cmple_epu16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14639,7 +15551,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmple_epu16_mask() { + const unsafe fn test_mm256_cmple_epu16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let m = _mm256_cmple_epu16_mask(a, b); @@ -14647,7 +15559,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmple_epu16_mask() { + const unsafe fn test_mm256_mask_cmple_epu16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -14656,7 +15568,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmple_epu16_mask() { + const unsafe fn test_mm_cmple_epu16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let m = _mm_cmple_epu16_mask(a, b); @@ -14664,7 +15576,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmple_epu16_mask() { + const unsafe fn test_mm_mask_cmple_epu16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -14673,7 +15585,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmple_epu8_mask() { + const unsafe fn test_mm512_cmple_epu8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let m = _mm512_cmple_epu8_mask(a, b); @@ -14684,7 +15596,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmple_epu8_mask() { + const unsafe fn test_mm512_mask_cmple_epu8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14696,7 +15608,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmple_epu8_mask() { + const unsafe fn test_mm256_cmple_epu8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let m = _mm256_cmple_epu8_mask(a, b); @@ -14704,7 +15616,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmple_epu8_mask() { + const unsafe fn test_mm256_mask_cmple_epu8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14713,7 +15625,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmple_epu8_mask() { + const unsafe fn test_mm_cmple_epu8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let m = _mm_cmple_epu8_mask(a, b); @@ -14721,7 +15633,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmple_epu8_mask() { + const unsafe fn test_mm_mask_cmple_epu8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -14730,7 +15642,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmple_epi16_mask() { + const unsafe fn test_mm512_cmple_epi16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let m = _mm512_cmple_epi16_mask(a, b); @@ -14738,7 +15650,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmple_epi16_mask() { + const unsafe fn test_mm512_mask_cmple_epi16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14747,7 +15659,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmple_epi16_mask() { + const unsafe fn test_mm256_cmple_epi16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let m = _mm256_cmple_epi16_mask(a, b); @@ -14755,7 +15667,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmple_epi16_mask() { + const unsafe fn test_mm256_mask_cmple_epi16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -14764,7 +15676,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmple_epi16_mask() { + const unsafe fn test_mm_cmple_epi16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let m = _mm_cmple_epi16_mask(a, b); @@ -14772,7 +15684,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmple_epi16_mask() { + const unsafe fn test_mm_mask_cmple_epi16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -14781,7 +15693,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmple_epi8_mask() { + const unsafe fn test_mm512_cmple_epi8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let m = _mm512_cmple_epi8_mask(a, b); @@ -14792,7 +15704,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmple_epi8_mask() { + const unsafe fn test_mm512_mask_cmple_epi8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14804,7 +15716,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmple_epi8_mask() { + const unsafe fn test_mm256_cmple_epi8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let m = _mm256_cmple_epi8_mask(a, b); @@ -14812,7 +15724,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmple_epi8_mask() { + const unsafe fn test_mm256_mask_cmple_epi8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14821,7 +15733,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmple_epi8_mask() { + const unsafe fn test_mm_cmple_epi8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let m = _mm_cmple_epi8_mask(a, b); @@ -14829,7 +15741,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmple_epi8_mask() { + const unsafe fn test_mm_mask_cmple_epi8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -14838,7 +15750,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpge_epu16_mask() { + const unsafe fn test_mm512_cmpge_epu16_mask() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let m = _mm512_cmpge_epu16_mask(a, b); @@ -14846,7 +15758,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpge_epu16_mask() { + const unsafe fn test_mm512_mask_cmpge_epu16_mask() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14855,7 +15767,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpge_epu16_mask() { + const unsafe fn test_mm256_cmpge_epu16_mask() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let m = _mm256_cmpge_epu16_mask(a, b); @@ -14863,7 +15775,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epu16_mask() { + const unsafe fn test_mm256_mask_cmpge_epu16_mask() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let mask = 0b01010101_01010101; @@ -14872,7 +15784,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpge_epu16_mask() { + const unsafe fn test_mm_cmpge_epu16_mask() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let m = _mm_cmpge_epu16_mask(a, b); @@ -14880,7 +15792,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpge_epu16_mask() { + const unsafe fn test_mm_mask_cmpge_epu16_mask() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let mask = 0b01010101; @@ -14889,7 +15801,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpge_epu8_mask() { + const unsafe fn test_mm512_cmpge_epu8_mask() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let m = _mm512_cmpge_epu8_mask(a, b); @@ -14900,7 +15812,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpge_epu8_mask() { + const unsafe fn test_mm512_mask_cmpge_epu8_mask() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -14912,7 +15824,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpge_epu8_mask() { + const unsafe fn test_mm256_cmpge_epu8_mask() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let m = _mm256_cmpge_epu8_mask(a, b); @@ -14920,7 +15832,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epu8_mask() { + const unsafe fn test_mm256_mask_cmpge_epu8_mask() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14929,7 +15841,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpge_epu8_mask() { + const unsafe fn test_mm_cmpge_epu8_mask() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let m = _mm_cmpge_epu8_mask(a, b); @@ -14937,7 +15849,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpge_epu8_mask() { + const unsafe fn test_mm_mask_cmpge_epu8_mask() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let mask = 0b01010101_01010101; @@ -14946,7 +15858,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpge_epi16_mask() { + const unsafe fn test_mm512_cmpge_epi16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let m = _mm512_cmpge_epi16_mask(a, b); @@ -14954,7 +15866,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpge_epi16_mask() { + const unsafe fn test_mm512_mask_cmpge_epi16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -14963,7 +15875,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpge_epi16_mask() { + const unsafe fn test_mm256_cmpge_epi16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let m = _mm256_cmpge_epi16_mask(a, b); @@ -14971,7 +15883,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epi16_mask() { + const unsafe fn test_mm256_mask_cmpge_epi16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -14980,7 +15892,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpge_epi16_mask() { + const unsafe fn test_mm_cmpge_epi16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let m = _mm_cmpge_epi16_mask(a, b); @@ -14988,7 +15900,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpge_epi16_mask() { + const unsafe fn test_mm_mask_cmpge_epi16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -14997,7 +15909,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpge_epi8_mask() { + const unsafe fn test_mm512_cmpge_epi8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let m = _mm512_cmpge_epi8_mask(a, b); @@ -15008,7 +15920,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpge_epi8_mask() { + const unsafe fn test_mm512_mask_cmpge_epi8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15020,7 +15932,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpge_epi8_mask() { + const unsafe fn test_mm256_cmpge_epi8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let m = _mm256_cmpge_epi8_mask(a, b); @@ -15028,7 +15940,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpge_epi8_mask() { + const unsafe fn test_mm256_mask_cmpge_epi8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15037,7 +15949,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpge_epi8_mask() { + const unsafe fn test_mm_cmpge_epi8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let m = _mm_cmpge_epi8_mask(a, b); @@ -15045,7 +15957,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpge_epi8_mask() { + const unsafe fn test_mm_mask_cmpge_epi8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -15054,7 +15966,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpeq_epu16_mask() { + const unsafe fn test_mm512_cmpeq_epu16_mask() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let m = _mm512_cmpeq_epu16_mask(a, b); @@ -15062,7 +15974,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpeq_epu16_mask() { + const unsafe fn test_mm512_mask_cmpeq_epu16_mask() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15071,7 +15983,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpeq_epu16_mask() { + const unsafe fn test_mm256_cmpeq_epu16_mask() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let m = _mm256_cmpeq_epu16_mask(a, b); @@ -15079,7 +15991,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epu16_mask() { + const unsafe fn test_mm256_mask_cmpeq_epu16_mask() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let mask = 0b01010101_01010101; @@ -15088,7 +16000,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpeq_epu16_mask() { + const unsafe fn test_mm_cmpeq_epu16_mask() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let m = _mm_cmpeq_epu16_mask(a, b); @@ -15096,7 +16008,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epu16_mask() { + const unsafe fn test_mm_mask_cmpeq_epu16_mask() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let mask = 0b01010101; @@ -15105,7 +16017,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpeq_epu8_mask() { + const unsafe fn test_mm512_cmpeq_epu8_mask() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let m = _mm512_cmpeq_epu8_mask(a, b); @@ -15116,7 +16028,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpeq_epu8_mask() { + const unsafe fn test_mm512_mask_cmpeq_epu8_mask() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15128,7 +16040,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpeq_epu8_mask() { + const unsafe fn test_mm256_cmpeq_epu8_mask() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let m = _mm256_cmpeq_epu8_mask(a, b); @@ -15136,7 +16048,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epu8_mask() { + const unsafe fn test_mm256_mask_cmpeq_epu8_mask() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15145,7 +16057,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpeq_epu8_mask() { + const unsafe fn test_mm_cmpeq_epu8_mask() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let m = _mm_cmpeq_epu8_mask(a, b); @@ -15153,7 +16065,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epu8_mask() { + const unsafe fn test_mm_mask_cmpeq_epu8_mask() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let mask = 0b01010101_01010101; @@ -15162,7 +16074,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpeq_epi16_mask() { + const unsafe fn test_mm512_cmpeq_epi16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let m = _mm512_cmpeq_epi16_mask(a, b); @@ -15170,7 +16082,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpeq_epi16_mask() { + const unsafe fn test_mm512_mask_cmpeq_epi16_mask() { let a = _mm512_set1_epi16(-1); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15179,7 +16091,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpeq_epi16_mask() { + const unsafe fn test_mm256_cmpeq_epi16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let m = _mm256_cmpeq_epi16_mask(a, b); @@ -15187,7 +16099,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epi16_mask() { + const unsafe fn test_mm256_mask_cmpeq_epi16_mask() { let a = _mm256_set1_epi16(-1); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -15196,7 +16108,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpeq_epi16_mask() { + const unsafe fn test_mm_cmpeq_epi16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let m = _mm_cmpeq_epi16_mask(a, b); @@ -15204,7 +16116,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epi16_mask() { + const unsafe fn test_mm_mask_cmpeq_epi16_mask() { let a = _mm_set1_epi16(-1); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -15213,7 +16125,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpeq_epi8_mask() { + const unsafe fn test_mm512_cmpeq_epi8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let m = _mm512_cmpeq_epi8_mask(a, b); @@ -15224,7 +16136,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpeq_epi8_mask() { + const unsafe fn test_mm512_mask_cmpeq_epi8_mask() { let a = _mm512_set1_epi8(-1); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15236,7 +16148,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpeq_epi8_mask() { + const unsafe fn test_mm256_cmpeq_epi8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let m = _mm256_cmpeq_epi8_mask(a, b); @@ -15244,7 +16156,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpeq_epi8_mask() { + const unsafe fn test_mm256_mask_cmpeq_epi8_mask() { let a = _mm256_set1_epi8(-1); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15253,7 +16165,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpeq_epi8_mask() { + const unsafe fn test_mm_cmpeq_epi8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let m = _mm_cmpeq_epi8_mask(a, b); @@ -15261,7 +16173,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpeq_epi8_mask() { + const unsafe fn test_mm_mask_cmpeq_epi8_mask() { let a = _mm_set1_epi8(-1); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -15270,7 +16182,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpneq_epu16_mask() { + const unsafe fn test_mm512_cmpneq_epu16_mask() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(1); let m = _mm512_cmpneq_epu16_mask(a, b); @@ -15278,7 +16190,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpneq_epu16_mask() { + const unsafe fn test_mm512_mask_cmpneq_epu16_mask() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15287,7 +16199,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpneq_epu16_mask() { + const unsafe fn test_mm256_cmpneq_epu16_mask() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(1); let m = _mm256_cmpneq_epu16_mask(a, b); @@ -15295,7 +16207,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epu16_mask() { + const unsafe fn test_mm256_mask_cmpneq_epu16_mask() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(1); let mask = 0b01010101_01010101; @@ -15304,7 +16216,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpneq_epu16_mask() { + const unsafe fn test_mm_cmpneq_epu16_mask() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(1); let m = _mm_cmpneq_epu16_mask(a, b); @@ -15312,7 +16224,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epu16_mask() { + const unsafe fn test_mm_mask_cmpneq_epu16_mask() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(1); let mask = 0b01010101; @@ -15321,7 +16233,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpneq_epu8_mask() { + const unsafe fn test_mm512_cmpneq_epu8_mask() { let a = _mm512_set1_epi8(2); let b = _mm512_set1_epi8(1); let m = _mm512_cmpneq_epu8_mask(a, b); @@ -15332,7 +16244,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpneq_epu8_mask() { + const unsafe fn test_mm512_mask_cmpneq_epu8_mask() { let a = _mm512_set1_epi8(2); let b = _mm512_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15344,7 +16256,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpneq_epu8_mask() { + const unsafe fn test_mm256_cmpneq_epu8_mask() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(1); let m = _mm256_cmpneq_epu8_mask(a, b); @@ -15352,7 +16264,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epu8_mask() { + const unsafe fn test_mm256_mask_cmpneq_epu8_mask() { let a = _mm256_set1_epi8(2); let b = _mm256_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15361,7 +16273,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpneq_epu8_mask() { + const unsafe fn test_mm_cmpneq_epu8_mask() { let a = _mm_set1_epi8(2); let b = _mm_set1_epi8(1); let m = _mm_cmpneq_epu8_mask(a, b); @@ -15369,7 +16281,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epu8_mask() { + const unsafe fn test_mm_mask_cmpneq_epu8_mask() { let a = _mm_set1_epi8(2); let b = _mm_set1_epi8(1); let mask = 0b01010101_01010101; @@ -15378,7 +16290,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpneq_epi16_mask() { + const unsafe fn test_mm512_cmpneq_epi16_mask() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(-1); let m = _mm512_cmpneq_epi16_mask(a, b); @@ -15386,7 +16298,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpneq_epi16_mask() { + const unsafe fn test_mm512_mask_cmpneq_epi16_mask() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15395,7 +16307,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpneq_epi16_mask() { + const unsafe fn test_mm256_cmpneq_epi16_mask() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(-1); let m = _mm256_cmpneq_epi16_mask(a, b); @@ -15403,7 +16315,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epi16_mask() { + const unsafe fn test_mm256_mask_cmpneq_epi16_mask() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(-1); let mask = 0b01010101_01010101; @@ -15412,7 +16324,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpneq_epi16_mask() { + const unsafe fn test_mm_cmpneq_epi16_mask() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(-1); let m = _mm_cmpneq_epi16_mask(a, b); @@ -15420,7 +16332,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epi16_mask() { + const unsafe fn test_mm_mask_cmpneq_epi16_mask() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(-1); let mask = 0b01010101; @@ -15429,7 +16341,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmpneq_epi8_mask() { + const unsafe fn test_mm512_cmpneq_epi8_mask() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(-1); let m = _mm512_cmpneq_epi8_mask(a, b); @@ -15440,7 +16352,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmpneq_epi8_mask() { + const unsafe fn test_mm512_mask_cmpneq_epi8_mask() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15452,7 +16364,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmpneq_epi8_mask() { + const unsafe fn test_mm256_cmpneq_epi8_mask() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(-1); let m = _mm256_cmpneq_epi8_mask(a, b); @@ -15460,7 +16372,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmpneq_epi8_mask() { + const unsafe fn test_mm256_mask_cmpneq_epi8_mask() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(-1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15469,7 +16381,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmpneq_epi8_mask() { + const unsafe fn test_mm_cmpneq_epi8_mask() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(-1); let m = _mm_cmpneq_epi8_mask(a, b); @@ -15477,7 +16389,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmpneq_epi8_mask() { + const unsafe fn test_mm_mask_cmpneq_epi8_mask() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(-1); let mask = 0b01010101_01010101; @@ -15486,7 +16398,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmp_epu16_mask() { + const unsafe fn test_mm512_cmp_epu16_mask() { let a = _mm512_set1_epi16(0); let b = _mm512_set1_epi16(1); let m = _mm512_cmp_epu16_mask::<_MM_CMPINT_LT>(a, b); @@ -15494,7 +16406,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmp_epu16_mask() { + const unsafe fn test_mm512_mask_cmp_epu16_mask() { let a = _mm512_set1_epi16(0); let b = _mm512_set1_epi16(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15503,7 +16415,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmp_epu16_mask() { + const unsafe fn test_mm256_cmp_epu16_mask() { let a = _mm256_set1_epi16(0); let b = _mm256_set1_epi16(1); let m = _mm256_cmp_epu16_mask::<_MM_CMPINT_LT>(a, b); @@ -15511,7 +16423,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmp_epu16_mask() { + const unsafe fn test_mm256_mask_cmp_epu16_mask() { let a = _mm256_set1_epi16(0); let b = _mm256_set1_epi16(1); let mask = 0b01010101_01010101; @@ -15520,7 +16432,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmp_epu16_mask() { + const unsafe fn test_mm_cmp_epu16_mask() { let a = _mm_set1_epi16(0); let b = _mm_set1_epi16(1); let m = _mm_cmp_epu16_mask::<_MM_CMPINT_LT>(a, b); @@ -15528,7 +16440,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmp_epu16_mask() { + const unsafe fn test_mm_mask_cmp_epu16_mask() { let a = _mm_set1_epi16(0); let b = _mm_set1_epi16(1); let mask = 0b01010101; @@ -15537,7 +16449,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmp_epu8_mask() { + const unsafe fn test_mm512_cmp_epu8_mask() { let a = _mm512_set1_epi8(0); let b = _mm512_set1_epi8(1); let m = _mm512_cmp_epu8_mask::<_MM_CMPINT_LT>(a, b); @@ -15548,7 +16460,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmp_epu8_mask() { + const unsafe fn test_mm512_mask_cmp_epu8_mask() { let a = _mm512_set1_epi8(0); let b = _mm512_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15560,7 +16472,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmp_epu8_mask() { + const unsafe fn test_mm256_cmp_epu8_mask() { let a = _mm256_set1_epi8(0); let b = _mm256_set1_epi8(1); let m = _mm256_cmp_epu8_mask::<_MM_CMPINT_LT>(a, b); @@ -15568,7 +16480,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmp_epu8_mask() { + const unsafe fn test_mm256_mask_cmp_epu8_mask() { let a = _mm256_set1_epi8(0); let b = _mm256_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15577,7 +16489,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmp_epu8_mask() { + const unsafe fn test_mm_cmp_epu8_mask() { let a = _mm_set1_epi8(0); let b = _mm_set1_epi8(1); let m = _mm_cmp_epu8_mask::<_MM_CMPINT_LT>(a, b); @@ -15585,7 +16497,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmp_epu8_mask() { + const unsafe fn test_mm_mask_cmp_epu8_mask() { let a = _mm_set1_epi8(0); let b = _mm_set1_epi8(1); let mask = 0b01010101_01010101; @@ -15594,7 +16506,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmp_epi16_mask() { + const unsafe fn test_mm512_cmp_epi16_mask() { let a = _mm512_set1_epi16(0); let b = _mm512_set1_epi16(1); let m = _mm512_cmp_epi16_mask::<_MM_CMPINT_LT>(a, b); @@ -15602,7 +16514,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmp_epi16_mask() { + const unsafe fn test_mm512_mask_cmp_epi16_mask() { let a = _mm512_set1_epi16(0); let b = _mm512_set1_epi16(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15611,7 +16523,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmp_epi16_mask() { + const unsafe fn test_mm256_cmp_epi16_mask() { let a = _mm256_set1_epi16(0); let b = _mm256_set1_epi16(1); let m = _mm256_cmp_epi16_mask::<_MM_CMPINT_LT>(a, b); @@ -15619,7 +16531,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmp_epi16_mask() { + const unsafe fn test_mm256_mask_cmp_epi16_mask() { let a = _mm256_set1_epi16(0); let b = _mm256_set1_epi16(1); let mask = 0b01010101_01010101; @@ -15628,7 +16540,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmp_epi16_mask() { + const unsafe fn test_mm_cmp_epi16_mask() { let a = _mm_set1_epi16(0); let b = _mm_set1_epi16(1); let m = _mm_cmp_epi16_mask::<_MM_CMPINT_LT>(a, b); @@ -15636,7 +16548,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmp_epi16_mask() { + const unsafe fn test_mm_mask_cmp_epi16_mask() { let a = _mm_set1_epi16(0); let b = _mm_set1_epi16(1); let mask = 0b01010101; @@ -15645,7 +16557,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cmp_epi8_mask() { + const unsafe fn test_mm512_cmp_epi8_mask() { let a = _mm512_set1_epi8(0); let b = _mm512_set1_epi8(1); let m = _mm512_cmp_epi8_mask::<_MM_CMPINT_LT>(a, b); @@ -15656,7 +16568,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cmp_epi8_mask() { + const unsafe fn test_mm512_mask_cmp_epi8_mask() { let a = _mm512_set1_epi8(0); let b = _mm512_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101; @@ -15668,7 +16580,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cmp_epi8_mask() { + const unsafe fn test_mm256_cmp_epi8_mask() { let a = _mm256_set1_epi8(0); let b = _mm256_set1_epi8(1); let m = _mm256_cmp_epi8_mask::<_MM_CMPINT_LT>(a, b); @@ -15676,7 +16588,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cmp_epi8_mask() { + const unsafe fn test_mm256_mask_cmp_epi8_mask() { let a = _mm256_set1_epi8(0); let b = _mm256_set1_epi8(1); let mask = 0b01010101_01010101_01010101_01010101; @@ -15685,7 +16597,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cmp_epi8_mask() { + const unsafe fn test_mm_cmp_epi8_mask() { let a = _mm_set1_epi8(0); let b = _mm_set1_epi8(1); let m = _mm_cmp_epi8_mask::<_MM_CMPINT_LT>(a, b); @@ -15693,7 +16605,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cmp_epi8_mask() { + const unsafe fn test_mm_mask_cmp_epi8_mask() { let a = _mm_set1_epi8(0); let b = _mm_set1_epi8(1); let mask = 0b01010101_01010101; @@ -15702,91 +16614,91 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_add_epi16() { + const unsafe fn test_mm256_reduce_add_epi16() { let a = _mm256_set1_epi16(1); let e = _mm256_reduce_add_epi16(a); assert_eq!(16, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_add_epi16() { + const unsafe fn test_mm256_mask_reduce_add_epi16() { let a = _mm256_set1_epi16(1); let e = _mm256_mask_reduce_add_epi16(0b11111111_00000000, a); assert_eq!(8, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_add_epi16() { + const unsafe fn test_mm_reduce_add_epi16() { let a = _mm_set1_epi16(1); let e = _mm_reduce_add_epi16(a); assert_eq!(8, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_add_epi16() { + const unsafe fn test_mm_mask_reduce_add_epi16() { let a = _mm_set1_epi16(1); let e = _mm_mask_reduce_add_epi16(0b11110000, a); assert_eq!(4, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_add_epi8() { + const unsafe fn test_mm256_reduce_add_epi8() { let a = _mm256_set1_epi8(1); let e = _mm256_reduce_add_epi8(a); assert_eq!(32, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_add_epi8() { + const unsafe fn test_mm256_mask_reduce_add_epi8() { let a = _mm256_set1_epi8(1); let e = _mm256_mask_reduce_add_epi8(0b11111111_00000000_11111111_00000000, a); assert_eq!(16, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_add_epi8() { + const unsafe fn test_mm_reduce_add_epi8() { let a = _mm_set1_epi8(1); let e = _mm_reduce_add_epi8(a); assert_eq!(16, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_add_epi8() { + const unsafe fn test_mm_mask_reduce_add_epi8() { let a = _mm_set1_epi8(1); let e = _mm_mask_reduce_add_epi8(0b11111111_00000000, a); assert_eq!(8, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_and_epi16() { + const unsafe fn test_mm256_reduce_and_epi16() { let a = _mm256_set_epi16(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm256_reduce_and_epi16(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_and_epi16() { + const unsafe fn test_mm256_mask_reduce_and_epi16() { let a = _mm256_set_epi16(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm256_mask_reduce_and_epi16(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_and_epi16() { + const unsafe fn test_mm_reduce_and_epi16() { let a = _mm_set_epi16(1, 1, 1, 1, 2, 2, 2, 2); let e = _mm_reduce_and_epi16(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_and_epi16() { + const unsafe fn test_mm_mask_reduce_and_epi16() { let a = _mm_set_epi16(1, 1, 1, 1, 2, 2, 2, 2); let e = _mm_mask_reduce_and_epi16(0b11110000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_and_epi8() { + const unsafe fn test_mm256_reduce_and_epi8() { let a = _mm256_set_epi8( 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, @@ -15796,7 +16708,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_and_epi8() { + const unsafe fn test_mm256_mask_reduce_and_epi8() { let a = _mm256_set_epi8( 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, @@ -15806,49 +16718,49 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_and_epi8() { + const unsafe fn test_mm_reduce_and_epi8() { let a = _mm_set_epi8(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm_reduce_and_epi8(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_and_epi8() { + const unsafe fn test_mm_mask_reduce_and_epi8() { let a = _mm_set_epi8(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm_mask_reduce_and_epi8(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_mul_epi16() { + const unsafe fn test_mm256_reduce_mul_epi16() { let a = _mm256_set_epi16(2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1); let e = _mm256_reduce_mul_epi16(a); assert_eq!(256, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_mul_epi16() { + const unsafe fn test_mm256_mask_reduce_mul_epi16() { let a = _mm256_set_epi16(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm256_mask_reduce_mul_epi16(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_mul_epi16() { + const unsafe fn test_mm_reduce_mul_epi16() { let a = _mm_set_epi16(2, 2, 2, 2, 1, 1, 1, 1); let e = _mm_reduce_mul_epi16(a); assert_eq!(16, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_mul_epi16() { + const unsafe fn test_mm_mask_reduce_mul_epi16() { let a = _mm_set_epi16(1, 1, 1, 1, 2, 2, 2, 2); let e = _mm_mask_reduce_mul_epi16(0b11110000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_mul_epi8() { + const unsafe fn test_mm256_reduce_mul_epi8() { let a = _mm256_set_epi8( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, @@ -15858,7 +16770,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_mul_epi8() { + const unsafe fn test_mm256_mask_reduce_mul_epi8() { let a = _mm256_set_epi8( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, @@ -15868,49 +16780,49 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_mul_epi8() { + const unsafe fn test_mm_reduce_mul_epi8() { let a = _mm_set_epi8(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2); let e = _mm_reduce_mul_epi8(a); assert_eq!(8, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_mul_epi8() { + const unsafe fn test_mm_mask_reduce_mul_epi8() { let a = _mm_set_epi8(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2); let e = _mm_mask_reduce_mul_epi8(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_max_epi16() { + const unsafe fn test_mm256_reduce_max_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i16 = _mm256_reduce_max_epi16(a); assert_eq!(15, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_max_epi16() { + const unsafe fn test_mm256_mask_reduce_max_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i16 = _mm256_mask_reduce_max_epi16(0b11111111_00000000, a); assert_eq!(7, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_max_epi16() { + const unsafe fn test_mm_reduce_max_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: i16 = _mm_reduce_max_epi16(a); assert_eq!(7, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_max_epi16() { + const unsafe fn test_mm_mask_reduce_max_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: i16 = _mm_mask_reduce_max_epi16(0b11110000, a); assert_eq!(3, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_max_epi8() { + const unsafe fn test_mm256_reduce_max_epi8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -15920,7 +16832,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_max_epi8() { + const unsafe fn test_mm256_mask_reduce_max_epi8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -15930,49 +16842,49 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_max_epi8() { + const unsafe fn test_mm_reduce_max_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i8 = _mm_reduce_max_epi8(a); assert_eq!(15, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_max_epi8() { + const unsafe fn test_mm_mask_reduce_max_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i8 = _mm_mask_reduce_max_epi8(0b11111111_00000000, a); assert_eq!(7, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_max_epu16() { + const unsafe fn test_mm256_reduce_max_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u16 = _mm256_reduce_max_epu16(a); assert_eq!(15, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_max_epu16() { + const unsafe fn test_mm256_mask_reduce_max_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u16 = _mm256_mask_reduce_max_epu16(0b11111111_00000000, a); assert_eq!(7, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_max_epu16() { + const unsafe fn test_mm_reduce_max_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: u16 = _mm_reduce_max_epu16(a); assert_eq!(7, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_max_epu16() { + const unsafe fn test_mm_mask_reduce_max_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: u16 = _mm_mask_reduce_max_epu16(0b11110000, a); assert_eq!(3, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_max_epu8() { + const unsafe fn test_mm256_reduce_max_epu8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -15982,7 +16894,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_max_epu8() { + const unsafe fn test_mm256_mask_reduce_max_epu8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -15992,49 +16904,49 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_max_epu8() { + const unsafe fn test_mm_reduce_max_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u8 = _mm_reduce_max_epu8(a); assert_eq!(15, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_max_epu8() { + const unsafe fn test_mm_mask_reduce_max_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u8 = _mm_mask_reduce_max_epu8(0b11111111_00000000, a); assert_eq!(7, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_min_epi16() { + const unsafe fn test_mm256_reduce_min_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i16 = _mm256_reduce_min_epi16(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_min_epi16() { + const unsafe fn test_mm256_mask_reduce_min_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i16 = _mm256_mask_reduce_min_epi16(0b11111111_00000000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_min_epi16() { + const unsafe fn test_mm_reduce_min_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: i16 = _mm_reduce_min_epi16(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_min_epi16() { + const unsafe fn test_mm_mask_reduce_min_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: i16 = _mm_mask_reduce_min_epi16(0b11110000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_min_epi8() { + const unsafe fn test_mm256_reduce_min_epi8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -16044,7 +16956,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_min_epi8() { + const unsafe fn test_mm256_mask_reduce_min_epi8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -16054,49 +16966,49 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_min_epi8() { + const unsafe fn test_mm_reduce_min_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i8 = _mm_reduce_min_epi8(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_min_epi8() { + const unsafe fn test_mm_mask_reduce_min_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: i8 = _mm_mask_reduce_min_epi8(0b11111111_00000000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_min_epu16() { + const unsafe fn test_mm256_reduce_min_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u16 = _mm256_reduce_min_epu16(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_min_epu16() { + const unsafe fn test_mm256_mask_reduce_min_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u16 = _mm256_mask_reduce_min_epu16(0b11111111_00000000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_min_epu16() { + const unsafe fn test_mm_reduce_min_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: u16 = _mm_reduce_min_epu16(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_min_epu16() { + const unsafe fn test_mm_mask_reduce_min_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let e: u16 = _mm_mask_reduce_min_epu16(0b11110000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_min_epu8() { + const unsafe fn test_mm256_reduce_min_epu8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -16106,7 +17018,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_min_epu8() { + const unsafe fn test_mm256_mask_reduce_min_epu8() { let a = _mm256_set_epi8( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -16116,49 +17028,49 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_min_epu8() { + const unsafe fn test_mm_reduce_min_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u8 = _mm_reduce_min_epu8(a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_min_epu8() { + const unsafe fn test_mm_mask_reduce_min_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let e: u8 = _mm_mask_reduce_min_epu8(0b11111111_00000000, a); assert_eq!(0, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_or_epi16() { + const unsafe fn test_mm256_reduce_or_epi16() { let a = _mm256_set_epi16(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm256_reduce_or_epi16(a); assert_eq!(3, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_or_epi16() { + const unsafe fn test_mm256_mask_reduce_or_epi16() { let a = _mm256_set_epi16(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm256_mask_reduce_or_epi16(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_or_epi16() { + const unsafe fn test_mm_reduce_or_epi16() { let a = _mm_set_epi16(1, 1, 1, 1, 2, 2, 2, 2); let e = _mm_reduce_or_epi16(a); assert_eq!(3, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_or_epi16() { + const unsafe fn test_mm_mask_reduce_or_epi16() { let a = _mm_set_epi16(1, 1, 1, 1, 2, 2, 2, 2); let e = _mm_mask_reduce_or_epi16(0b11110000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_reduce_or_epi8() { + const unsafe fn test_mm256_reduce_or_epi8() { let a = _mm256_set_epi8( 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, @@ -16168,7 +17080,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_reduce_or_epi8() { + const unsafe fn test_mm256_mask_reduce_or_epi8() { let a = _mm256_set_epi8( 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, @@ -16178,21 +17090,21 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_reduce_or_epi8() { + const unsafe fn test_mm_reduce_or_epi8() { let a = _mm_set_epi8(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm_reduce_or_epi8(a); assert_eq!(3, e); } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_reduce_or_epi8() { + const unsafe fn test_mm_mask_reduce_or_epi8() { let a = _mm_set_epi8(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2); let e = _mm_mask_reduce_or_epi8(0b11111111_00000000, a); assert_eq!(1, e); } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_loadu_epi16() { + const unsafe fn test_mm512_loadu_epi16() { #[rustfmt::skip] let a: [i16; 32] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]; let r = _mm512_loadu_epi16(&a[0]); @@ -16202,7 +17114,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_loadu_epi16() { + const unsafe fn test_mm256_loadu_epi16() { let a: [i16; 16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let r = _mm256_loadu_epi16(&a[0]); let e = _mm256_set_epi16(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); @@ -16210,7 +17122,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_loadu_epi16() { + const unsafe fn test_mm_loadu_epi16() { let a: [i16; 8] = [1, 2, 3, 4, 5, 6, 7, 8]; let r = _mm_loadu_epi16(&a[0]); let e = _mm_set_epi16(8, 7, 6, 5, 4, 3, 2, 1); @@ -16218,7 +17130,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_loadu_epi8() { + const unsafe fn test_mm512_loadu_epi8() { #[rustfmt::skip] let a: [i8; 64] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]; @@ -16230,7 +17142,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_loadu_epi8() { + const unsafe fn test_mm256_loadu_epi8() { #[rustfmt::skip] let a: [i8; 32] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]; let r = _mm256_loadu_epi8(&a[0]); @@ -16240,7 +17152,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_loadu_epi8() { + const unsafe fn test_mm_loadu_epi8() { let a: [i8; 16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let r = _mm_loadu_epi8(&a[0]); let e = _mm_set_epi8(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); @@ -16248,7 +17160,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_storeu_epi16() { + const unsafe fn test_mm512_storeu_epi16() { let a = _mm512_set1_epi16(9); let mut r = _mm512_undefined_epi32(); _mm512_storeu_epi16(&mut r as *mut _ as *mut i16, a); @@ -16256,7 +17168,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_storeu_epi16() { + const unsafe fn test_mm256_storeu_epi16() { let a = _mm256_set1_epi16(9); let mut r = _mm256_set1_epi32(0); _mm256_storeu_epi16(&mut r as *mut _ as *mut i16, a); @@ -16264,7 +17176,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_storeu_epi16() { + const unsafe fn test_mm_storeu_epi16() { let a = _mm_set1_epi16(9); let mut r = _mm_set1_epi32(0); _mm_storeu_epi16(&mut r as *mut _ as *mut i16, a); @@ -16272,7 +17184,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_storeu_epi8() { + const unsafe fn test_mm512_storeu_epi8() { let a = _mm512_set1_epi8(9); let mut r = _mm512_undefined_epi32(); _mm512_storeu_epi8(&mut r as *mut _ as *mut i8, a); @@ -16280,7 +17192,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_storeu_epi8() { + const unsafe fn test_mm256_storeu_epi8() { let a = _mm256_set1_epi8(9); let mut r = _mm256_set1_epi32(0); _mm256_storeu_epi8(&mut r as *mut _ as *mut i8, a); @@ -16288,7 +17200,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_storeu_epi8() { + const unsafe fn test_mm_storeu_epi8() { let a = _mm_set1_epi8(9); let mut r = _mm_set1_epi32(0); _mm_storeu_epi8(&mut r as *mut _ as *mut i8, a); @@ -16296,7 +17208,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_loadu_epi16() { + const unsafe fn test_mm512_mask_loadu_epi16() { let src = _mm512_set1_epi16(42); let a = &[ 1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16314,7 +17226,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_loadu_epi16() { + const unsafe fn test_mm512_maskz_loadu_epi16() { let a = &[ 1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -16331,7 +17243,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_storeu_epi16() { + const unsafe fn test_mm512_mask_storeu_epi16() { let mut r = [42_i16; 32]; let a = &[ 1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16349,7 +17261,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_loadu_epi8() { + const unsafe fn test_mm512_mask_loadu_epi8() { let src = _mm512_set1_epi8(42); let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16369,7 +17281,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_loadu_epi8() { + const unsafe fn test_mm512_maskz_loadu_epi8() { let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, @@ -16388,7 +17300,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_storeu_epi8() { + const unsafe fn test_mm512_mask_storeu_epi8() { let mut r = [42_i8; 64]; let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16408,7 +17320,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_loadu_epi16() { + const unsafe fn test_mm256_mask_loadu_epi16() { let src = _mm256_set1_epi16(42); let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); @@ -16422,7 +17334,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_loadu_epi16() { + const unsafe fn test_mm256_maskz_loadu_epi16() { let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); let m = 0b11101000_11001010; @@ -16433,7 +17345,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_storeu_epi16() { + const unsafe fn test_mm256_mask_storeu_epi16() { let mut r = [42_i16; 16]; let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let a = _mm256_loadu_epi16(a.as_ptr()); @@ -16447,7 +17359,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_loadu_epi8() { + const unsafe fn test_mm256_mask_loadu_epi8() { let src = _mm256_set1_epi8(42); let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16465,7 +17377,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_loadu_epi8() { + const unsafe fn test_mm256_maskz_loadu_epi8() { let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -16482,7 +17394,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_storeu_epi8() { + const unsafe fn test_mm256_mask_storeu_epi8() { let mut r = [42_i8; 32]; let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16500,7 +17412,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_loadu_epi16() { + const unsafe fn test_mm_mask_loadu_epi16() { let src = _mm_set1_epi16(42); let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); @@ -16512,7 +17424,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_loadu_epi16() { + const unsafe fn test_mm_maskz_loadu_epi16() { let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); let m = 0b11001010; @@ -16523,7 +17435,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_storeu_epi16() { + const unsafe fn test_mm_mask_storeu_epi16() { let mut r = [42_i16; 8]; let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8]; let a = _mm_loadu_epi16(a.as_ptr()); @@ -16535,7 +17447,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_loadu_epi8() { + const unsafe fn test_mm_mask_loadu_epi8() { let src = _mm_set1_epi8(42); let a = &[1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); @@ -16549,7 +17461,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_loadu_epi8() { + const unsafe fn test_mm_maskz_loadu_epi8() { let a = &[1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); let m = 0b11101000_11001010; @@ -16560,7 +17472,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_storeu_epi8() { + const unsafe fn test_mm_mask_storeu_epi8() { let mut r = [42_i8; 16]; let a = &[1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let a = _mm_loadu_epi8(a.as_ptr()); @@ -16574,7 +17486,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_madd_epi16() { + const unsafe fn test_mm512_madd_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_madd_epi16(a, b); @@ -16583,7 +17495,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_madd_epi16() { + const unsafe fn test_mm512_mask_madd_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_madd_epi16(a, 0, a, b); @@ -16611,7 +17523,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_madd_epi16() { + const unsafe fn test_mm512_maskz_madd_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_madd_epi16(0, a, b); @@ -16622,7 +17534,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_madd_epi16() { + const unsafe fn test_mm256_mask_madd_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_madd_epi16(a, 0, a, b); @@ -16642,7 +17554,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_madd_epi16() { + const unsafe fn test_mm256_maskz_madd_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_madd_epi16(0, a, b); @@ -16653,7 +17565,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_madd_epi16() { + const unsafe fn test_mm_mask_madd_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_madd_epi16(a, 0, a, b); @@ -16664,7 +17576,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_madd_epi16() { + const unsafe fn test_mm_maskz_madd_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_madd_epi16(0, a, b); @@ -17123,7 +18035,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_avg_epu16() { + const unsafe fn test_mm512_avg_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_avg_epu16(a, b); @@ -17132,7 +18044,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_avg_epu16() { + const unsafe fn test_mm512_mask_avg_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_avg_epu16(a, 0, a, b); @@ -17145,7 +18057,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_avg_epu16() { + const unsafe fn test_mm512_maskz_avg_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_avg_epu16(0, a, b); @@ -17158,7 +18070,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_avg_epu16() { + const unsafe fn test_mm256_mask_avg_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_avg_epu16(a, 0, a, b); @@ -17169,7 +18081,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_avg_epu16() { + const unsafe fn test_mm256_maskz_avg_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_avg_epu16(0, a, b); @@ -17180,7 +18092,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_avg_epu16() { + const unsafe fn test_mm_mask_avg_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_avg_epu16(a, 0, a, b); @@ -17191,7 +18103,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_avg_epu16() { + const unsafe fn test_mm_maskz_avg_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_avg_epu16(0, a, b); @@ -17202,7 +18114,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_avg_epu8() { + const unsafe fn test_mm512_avg_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let r = _mm512_avg_epu8(a, b); @@ -17211,7 +18123,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_avg_epu8() { + const unsafe fn test_mm512_mask_avg_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let r = _mm512_mask_avg_epu8(a, 0, a, b); @@ -17231,7 +18143,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_avg_epu8() { + const unsafe fn test_mm512_maskz_avg_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let r = _mm512_maskz_avg_epu8(0, a, b); @@ -17250,7 +18162,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_avg_epu8() { + const unsafe fn test_mm256_mask_avg_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let r = _mm256_mask_avg_epu8(a, 0, a, b); @@ -17263,7 +18175,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_avg_epu8() { + const unsafe fn test_mm256_maskz_avg_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let r = _mm256_maskz_avg_epu8(0, a, b); @@ -17276,7 +18188,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_avg_epu8() { + const unsafe fn test_mm_mask_avg_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let r = _mm_mask_avg_epu8(a, 0, a, b); @@ -17287,7 +18199,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_avg_epu8() { + const unsafe fn test_mm_maskz_avg_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let r = _mm_maskz_avg_epu8(0, a, b); @@ -17373,7 +18285,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_slli_epi16() { + const unsafe fn test_mm512_slli_epi16() { let a = _mm512_set1_epi16(1 << 15); let r = _mm512_slli_epi16::<1>(a); let e = _mm512_set1_epi16(0); @@ -17381,7 +18293,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_slli_epi16() { + const unsafe fn test_mm512_mask_slli_epi16() { let a = _mm512_set1_epi16(1 << 15); let r = _mm512_mask_slli_epi16::<1>(a, 0, a); assert_eq_m512i(r, a); @@ -17391,7 +18303,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_slli_epi16() { + const unsafe fn test_mm512_maskz_slli_epi16() { let a = _mm512_set1_epi16(1 << 15); let r = _mm512_maskz_slli_epi16::<1>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -17401,7 +18313,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_slli_epi16() { + const unsafe fn test_mm256_mask_slli_epi16() { let a = _mm256_set1_epi16(1 << 15); let r = _mm256_mask_slli_epi16::<1>(a, 0, a); assert_eq_m256i(r, a); @@ -17411,7 +18323,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_slli_epi16() { + const unsafe fn test_mm256_maskz_slli_epi16() { let a = _mm256_set1_epi16(1 << 15); let r = _mm256_maskz_slli_epi16::<1>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -17421,7 +18333,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_slli_epi16() { + const unsafe fn test_mm_mask_slli_epi16() { let a = _mm_set1_epi16(1 << 15); let r = _mm_mask_slli_epi16::<1>(a, 0, a); assert_eq_m128i(r, a); @@ -17431,7 +18343,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_slli_epi16() { + const unsafe fn test_mm_maskz_slli_epi16() { let a = _mm_set1_epi16(1 << 15); let r = _mm_maskz_slli_epi16::<1>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -17441,7 +18353,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_sllv_epi16() { + const unsafe fn test_mm512_sllv_epi16() { let a = _mm512_set1_epi16(1 << 15); let count = _mm512_set1_epi16(2); let r = _mm512_sllv_epi16(a, count); @@ -17450,7 +18362,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_sllv_epi16() { + const unsafe fn test_mm512_mask_sllv_epi16() { let a = _mm512_set1_epi16(1 << 15); let count = _mm512_set1_epi16(2); let r = _mm512_mask_sllv_epi16(a, 0, a, count); @@ -17461,7 +18373,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_sllv_epi16() { + const unsafe fn test_mm512_maskz_sllv_epi16() { let a = _mm512_set1_epi16(1 << 15); let count = _mm512_set1_epi16(2); let r = _mm512_maskz_sllv_epi16(0, a, count); @@ -17472,7 +18384,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_sllv_epi16() { + const unsafe fn test_mm256_sllv_epi16() { let a = _mm256_set1_epi16(1 << 15); let count = _mm256_set1_epi16(2); let r = _mm256_sllv_epi16(a, count); @@ -17481,7 +18393,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_sllv_epi16() { + const unsafe fn test_mm256_mask_sllv_epi16() { let a = _mm256_set1_epi16(1 << 15); let count = _mm256_set1_epi16(2); let r = _mm256_mask_sllv_epi16(a, 0, a, count); @@ -17492,7 +18404,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_sllv_epi16() { + const unsafe fn test_mm256_maskz_sllv_epi16() { let a = _mm256_set1_epi16(1 << 15); let count = _mm256_set1_epi16(2); let r = _mm256_maskz_sllv_epi16(0, a, count); @@ -17503,7 +18415,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_sllv_epi16() { + const unsafe fn test_mm_sllv_epi16() { let a = _mm_set1_epi16(1 << 15); let count = _mm_set1_epi16(2); let r = _mm_sllv_epi16(a, count); @@ -17512,7 +18424,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_sllv_epi16() { + const unsafe fn test_mm_mask_sllv_epi16() { let a = _mm_set1_epi16(1 << 15); let count = _mm_set1_epi16(2); let r = _mm_mask_sllv_epi16(a, 0, a, count); @@ -17523,7 +18435,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_sllv_epi16() { + const unsafe fn test_mm_maskz_sllv_epi16() { let a = _mm_set1_epi16(1 << 15); let count = _mm_set1_epi16(2); let r = _mm_maskz_sllv_epi16(0, a, count); @@ -17609,7 +18521,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_srli_epi16() { + const unsafe fn test_mm512_srli_epi16() { let a = _mm512_set1_epi16(1 << 1); let r = _mm512_srli_epi16::<2>(a); let e = _mm512_set1_epi16(0); @@ -17617,7 +18529,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_srli_epi16() { + const unsafe fn test_mm512_mask_srli_epi16() { let a = _mm512_set1_epi16(1 << 1); let r = _mm512_mask_srli_epi16::<2>(a, 0, a); assert_eq_m512i(r, a); @@ -17627,7 +18539,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_srli_epi16() { + const unsafe fn test_mm512_maskz_srli_epi16() { let a = _mm512_set1_epi16(1 << 1); let r = _mm512_maskz_srli_epi16::<2>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -17637,7 +18549,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_srli_epi16() { + const unsafe fn test_mm256_mask_srli_epi16() { let a = _mm256_set1_epi16(1 << 1); let r = _mm256_mask_srli_epi16::<2>(a, 0, a); assert_eq_m256i(r, a); @@ -17647,7 +18559,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_srli_epi16() { + const unsafe fn test_mm256_maskz_srli_epi16() { let a = _mm256_set1_epi16(1 << 1); let r = _mm256_maskz_srli_epi16::<2>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -17657,7 +18569,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_srli_epi16() { + const unsafe fn test_mm_mask_srli_epi16() { let a = _mm_set1_epi16(1 << 1); let r = _mm_mask_srli_epi16::<2>(a, 0, a); assert_eq_m128i(r, a); @@ -17667,7 +18579,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_srli_epi16() { + const unsafe fn test_mm_maskz_srli_epi16() { let a = _mm_set1_epi16(1 << 1); let r = _mm_maskz_srli_epi16::<2>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -17677,7 +18589,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_srlv_epi16() { + const unsafe fn test_mm512_srlv_epi16() { let a = _mm512_set1_epi16(1 << 1); let count = _mm512_set1_epi16(2); let r = _mm512_srlv_epi16(a, count); @@ -17686,7 +18598,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_srlv_epi16() { + const unsafe fn test_mm512_mask_srlv_epi16() { let a = _mm512_set1_epi16(1 << 1); let count = _mm512_set1_epi16(2); let r = _mm512_mask_srlv_epi16(a, 0, a, count); @@ -17697,7 +18609,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_srlv_epi16() { + const unsafe fn test_mm512_maskz_srlv_epi16() { let a = _mm512_set1_epi16(1 << 1); let count = _mm512_set1_epi16(2); let r = _mm512_maskz_srlv_epi16(0, a, count); @@ -17708,7 +18620,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_srlv_epi16() { + const unsafe fn test_mm256_srlv_epi16() { let a = _mm256_set1_epi16(1 << 1); let count = _mm256_set1_epi16(2); let r = _mm256_srlv_epi16(a, count); @@ -17717,7 +18629,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_srlv_epi16() { + const unsafe fn test_mm256_mask_srlv_epi16() { let a = _mm256_set1_epi16(1 << 1); let count = _mm256_set1_epi16(2); let r = _mm256_mask_srlv_epi16(a, 0, a, count); @@ -17728,7 +18640,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_srlv_epi16() { + const unsafe fn test_mm256_maskz_srlv_epi16() { let a = _mm256_set1_epi16(1 << 1); let count = _mm256_set1_epi16(2); let r = _mm256_maskz_srlv_epi16(0, a, count); @@ -17739,7 +18651,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_srlv_epi16() { + const unsafe fn test_mm_srlv_epi16() { let a = _mm_set1_epi16(1 << 1); let count = _mm_set1_epi16(2); let r = _mm_srlv_epi16(a, count); @@ -17748,7 +18660,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_srlv_epi16() { + const unsafe fn test_mm_mask_srlv_epi16() { let a = _mm_set1_epi16(1 << 1); let count = _mm_set1_epi16(2); let r = _mm_mask_srlv_epi16(a, 0, a, count); @@ -17759,7 +18671,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_srlv_epi16() { + const unsafe fn test_mm_maskz_srlv_epi16() { let a = _mm_set1_epi16(1 << 1); let count = _mm_set1_epi16(2); let r = _mm_maskz_srlv_epi16(0, a, count); @@ -17845,7 +18757,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_srai_epi16() { + const unsafe fn test_mm512_srai_epi16() { let a = _mm512_set1_epi16(8); let r = _mm512_srai_epi16::<2>(a); let e = _mm512_set1_epi16(2); @@ -17853,7 +18765,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_srai_epi16() { + const unsafe fn test_mm512_mask_srai_epi16() { let a = _mm512_set1_epi16(8); let r = _mm512_mask_srai_epi16::<2>(a, 0, a); assert_eq_m512i(r, a); @@ -17863,7 +18775,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_srai_epi16() { + const unsafe fn test_mm512_maskz_srai_epi16() { let a = _mm512_set1_epi16(8); let r = _mm512_maskz_srai_epi16::<2>(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -17873,7 +18785,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_srai_epi16() { + const unsafe fn test_mm256_mask_srai_epi16() { let a = _mm256_set1_epi16(8); let r = _mm256_mask_srai_epi16::<2>(a, 0, a); assert_eq_m256i(r, a); @@ -17883,7 +18795,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_srai_epi16() { + const unsafe fn test_mm256_maskz_srai_epi16() { let a = _mm256_set1_epi16(8); let r = _mm256_maskz_srai_epi16::<2>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -17893,7 +18805,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_srai_epi16() { + const unsafe fn test_mm_mask_srai_epi16() { let a = _mm_set1_epi16(8); let r = _mm_mask_srai_epi16::<2>(a, 0, a); assert_eq_m128i(r, a); @@ -17903,7 +18815,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_srai_epi16() { + const unsafe fn test_mm_maskz_srai_epi16() { let a = _mm_set1_epi16(8); let r = _mm_maskz_srai_epi16::<2>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -17913,7 +18825,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_srav_epi16() { + const unsafe fn test_mm512_srav_epi16() { let a = _mm512_set1_epi16(8); let count = _mm512_set1_epi16(2); let r = _mm512_srav_epi16(a, count); @@ -17922,7 +18834,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_srav_epi16() { + const unsafe fn test_mm512_mask_srav_epi16() { let a = _mm512_set1_epi16(8); let count = _mm512_set1_epi16(2); let r = _mm512_mask_srav_epi16(a, 0, a, count); @@ -17933,7 +18845,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_srav_epi16() { + const unsafe fn test_mm512_maskz_srav_epi16() { let a = _mm512_set1_epi16(8); let count = _mm512_set1_epi16(2); let r = _mm512_maskz_srav_epi16(0, a, count); @@ -17944,7 +18856,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_srav_epi16() { + const unsafe fn test_mm256_srav_epi16() { let a = _mm256_set1_epi16(8); let count = _mm256_set1_epi16(2); let r = _mm256_srav_epi16(a, count); @@ -17953,7 +18865,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_srav_epi16() { + const unsafe fn test_mm256_mask_srav_epi16() { let a = _mm256_set1_epi16(8); let count = _mm256_set1_epi16(2); let r = _mm256_mask_srav_epi16(a, 0, a, count); @@ -17964,7 +18876,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_srav_epi16() { + const unsafe fn test_mm256_maskz_srav_epi16() { let a = _mm256_set1_epi16(8); let count = _mm256_set1_epi16(2); let r = _mm256_maskz_srav_epi16(0, a, count); @@ -17975,7 +18887,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_srav_epi16() { + const unsafe fn test_mm_srav_epi16() { let a = _mm_set1_epi16(8); let count = _mm_set1_epi16(2); let r = _mm_srav_epi16(a, count); @@ -17984,7 +18896,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_srav_epi16() { + const unsafe fn test_mm_mask_srav_epi16() { let a = _mm_set1_epi16(8); let count = _mm_set1_epi16(2); let r = _mm_mask_srav_epi16(a, 0, a, count); @@ -17995,7 +18907,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_srav_epi16() { + const unsafe fn test_mm_maskz_srav_epi16() { let a = _mm_set1_epi16(8); let count = _mm_set1_epi16(2); let r = _mm_maskz_srav_epi16(0, a, count); @@ -18288,7 +19200,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_blend_epi16() { + const unsafe fn test_mm512_mask_blend_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(2); let r = _mm512_mask_blend_epi16(0b11111111_00000000_11111111_00000000, a, b); @@ -18299,7 +19211,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_blend_epi16() { + const unsafe fn test_mm256_mask_blend_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(2); let r = _mm256_mask_blend_epi16(0b11111111_00000000, a, b); @@ -18308,7 +19220,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_blend_epi16() { + const unsafe fn test_mm_mask_blend_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(2); let r = _mm_mask_blend_epi16(0b11110000, a, b); @@ -18317,7 +19229,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_blend_epi8() { + const unsafe fn test_mm512_mask_blend_epi8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(2); let r = _mm512_mask_blend_epi8( @@ -18334,7 +19246,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_blend_epi8() { + const unsafe fn test_mm256_mask_blend_epi8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(2); let r = _mm256_mask_blend_epi8(0b11111111_00000000_11111111_00000000, a, b); @@ -18345,7 +19257,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_blend_epi8() { + const unsafe fn test_mm_mask_blend_epi8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(2); let r = _mm_mask_blend_epi8(0b11111111_00000000, a, b); @@ -18354,7 +19266,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_broadcastw_epi16() { + const unsafe fn test_mm512_broadcastw_epi16() { let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_broadcastw_epi16(a); let e = _mm512_set1_epi16(24); @@ -18362,7 +19274,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_broadcastw_epi16() { + const unsafe fn test_mm512_mask_broadcastw_epi16() { let src = _mm512_set1_epi16(1); let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_mask_broadcastw_epi16(src, 0, a); @@ -18373,7 +19285,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_broadcastw_epi16() { + const unsafe fn test_mm512_maskz_broadcastw_epi16() { let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_maskz_broadcastw_epi16(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -18383,7 +19295,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_broadcastw_epi16() { + const unsafe fn test_mm256_mask_broadcastw_epi16() { let src = _mm256_set1_epi16(1); let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm256_mask_broadcastw_epi16(src, 0, a); @@ -18394,7 +19306,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_broadcastw_epi16() { + const unsafe fn test_mm256_maskz_broadcastw_epi16() { let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm256_maskz_broadcastw_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -18404,7 +19316,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_broadcastw_epi16() { + const unsafe fn test_mm_mask_broadcastw_epi16() { let src = _mm_set1_epi16(1); let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm_mask_broadcastw_epi16(src, 0, a); @@ -18415,7 +19327,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_broadcastw_epi16() { + const unsafe fn test_mm_maskz_broadcastw_epi16() { let a = _mm_set_epi16(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm_maskz_broadcastw_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -18425,7 +19337,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_broadcastb_epi8() { + const unsafe fn test_mm512_broadcastb_epi8() { let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ); @@ -18435,7 +19347,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_broadcastb_epi8() { + const unsafe fn test_mm512_mask_broadcastb_epi8() { let src = _mm512_set1_epi8(1); let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18452,7 +19364,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_broadcastb_epi8() { + const unsafe fn test_mm512_maskz_broadcastb_epi8() { let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ); @@ -18467,7 +19379,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_broadcastb_epi8() { + const unsafe fn test_mm256_mask_broadcastb_epi8() { let src = _mm256_set1_epi8(1); let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18480,7 +19392,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_broadcastb_epi8() { + const unsafe fn test_mm256_maskz_broadcastb_epi8() { let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ); @@ -18492,7 +19404,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_broadcastb_epi8() { + const unsafe fn test_mm_mask_broadcastb_epi8() { let src = _mm_set1_epi8(1); let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18505,7 +19417,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_broadcastb_epi8() { + const unsafe fn test_mm_maskz_broadcastb_epi8() { let a = _mm_set_epi8( 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ); @@ -18517,7 +19429,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_unpackhi_epi16() { + const unsafe fn test_mm512_unpackhi_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18532,7 +19444,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_unpackhi_epi16() { + const unsafe fn test_mm512_mask_unpackhi_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18549,7 +19461,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_unpackhi_epi16() { + const unsafe fn test_mm512_maskz_unpackhi_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18566,7 +19478,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_unpackhi_epi16() { + const unsafe fn test_mm256_mask_unpackhi_epi16() { let a = _mm256_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi16( 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, @@ -18579,7 +19491,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_unpackhi_epi16() { + const unsafe fn test_mm256_maskz_unpackhi_epi16() { let a = _mm256_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi16( 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, @@ -18592,7 +19504,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_unpackhi_epi16() { + const unsafe fn test_mm_mask_unpackhi_epi16() { let a = _mm_set_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi16(33, 34, 35, 36, 37, 38, 39, 40); let r = _mm_mask_unpackhi_epi16(a, 0, a, b); @@ -18603,7 +19515,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_unpackhi_epi16() { + const unsafe fn test_mm_maskz_unpackhi_epi16() { let a = _mm_set_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi16(33, 34, 35, 36, 37, 38, 39, 40); let r = _mm_maskz_unpackhi_epi16(0, a, b); @@ -18614,7 +19526,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_unpackhi_epi8() { + const unsafe fn test_mm512_unpackhi_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18635,7 +19547,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_unpackhi_epi8() { + const unsafe fn test_mm512_mask_unpackhi_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18663,7 +19575,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_unpackhi_epi8() { + const unsafe fn test_mm512_maskz_unpackhi_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18690,7 +19602,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_unpackhi_epi8() { + const unsafe fn test_mm256_mask_unpackhi_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18707,7 +19619,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_unpackhi_epi8() { + const unsafe fn test_mm256_maskz_unpackhi_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18724,7 +19636,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_unpackhi_epi8() { + const unsafe fn test_mm_mask_unpackhi_epi8() { let a = _mm_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_set_epi8( 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, @@ -18737,7 +19649,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_unpackhi_epi8() { + const unsafe fn test_mm_maskz_unpackhi_epi8() { let a = _mm_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_set_epi8( 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, @@ -18750,7 +19662,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_unpacklo_epi16() { + const unsafe fn test_mm512_unpacklo_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18765,7 +19677,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_unpacklo_epi16() { + const unsafe fn test_mm512_mask_unpacklo_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18782,7 +19694,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_unpacklo_epi16() { + const unsafe fn test_mm512_maskz_unpacklo_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18799,7 +19711,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_unpacklo_epi16() { + const unsafe fn test_mm256_mask_unpacklo_epi16() { let a = _mm256_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi16( 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, @@ -18812,7 +19724,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_unpacklo_epi16() { + const unsafe fn test_mm256_maskz_unpacklo_epi16() { let a = _mm256_set_epi16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi16( 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, @@ -18825,7 +19737,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_unpacklo_epi16() { + const unsafe fn test_mm_mask_unpacklo_epi16() { let a = _mm_set_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi16(33, 34, 35, 36, 37, 38, 39, 40); let r = _mm_mask_unpacklo_epi16(a, 0, a, b); @@ -18836,7 +19748,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_unpacklo_epi16() { + const unsafe fn test_mm_maskz_unpacklo_epi16() { let a = _mm_set_epi16(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi16(33, 34, 35, 36, 37, 38, 39, 40); let r = _mm_maskz_unpacklo_epi16(0, a, b); @@ -18847,7 +19759,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_unpacklo_epi8() { + const unsafe fn test_mm512_unpacklo_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18868,7 +19780,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_unpacklo_epi8() { + const unsafe fn test_mm512_mask_unpacklo_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18896,7 +19808,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_unpacklo_epi8() { + const unsafe fn test_mm512_maskz_unpacklo_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, @@ -18923,7 +19835,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_unpacklo_epi8() { + const unsafe fn test_mm256_mask_unpacklo_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18940,7 +19852,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_unpacklo_epi8() { + const unsafe fn test_mm256_maskz_unpacklo_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32); @@ -18957,7 +19869,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_unpacklo_epi8() { + const unsafe fn test_mm_mask_unpacklo_epi8() { let a = _mm_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_set_epi8( 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, @@ -18972,7 +19884,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_unpacklo_epi8() { + const unsafe fn test_mm_maskz_unpacklo_epi8() { let a = _mm_set_epi8(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm_set_epi8( 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, @@ -18987,7 +19899,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_mov_epi16() { + const unsafe fn test_mm512_mask_mov_epi16() { let src = _mm512_set1_epi16(1); let a = _mm512_set1_epi16(2); let r = _mm512_mask_mov_epi16(src, 0, a); @@ -18997,7 +19909,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_mov_epi16() { + const unsafe fn test_mm512_maskz_mov_epi16() { let a = _mm512_set1_epi16(2); let r = _mm512_maskz_mov_epi16(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -19006,7 +19918,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_mov_epi16() { + const unsafe fn test_mm256_mask_mov_epi16() { let src = _mm256_set1_epi16(1); let a = _mm256_set1_epi16(2); let r = _mm256_mask_mov_epi16(src, 0, a); @@ -19016,7 +19928,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_mov_epi16() { + const unsafe fn test_mm256_maskz_mov_epi16() { let a = _mm256_set1_epi16(2); let r = _mm256_maskz_mov_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -19025,7 +19937,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_mov_epi16() { + const unsafe fn test_mm_mask_mov_epi16() { let src = _mm_set1_epi16(1); let a = _mm_set1_epi16(2); let r = _mm_mask_mov_epi16(src, 0, a); @@ -19035,7 +19947,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_mov_epi16() { + const unsafe fn test_mm_maskz_mov_epi16() { let a = _mm_set1_epi16(2); let r = _mm_maskz_mov_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -19044,7 +19956,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_mov_epi8() { + const unsafe fn test_mm512_mask_mov_epi8() { let src = _mm512_set1_epi8(1); let a = _mm512_set1_epi8(2); let r = _mm512_mask_mov_epi8(src, 0, a); @@ -19058,7 +19970,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_mov_epi8() { + const unsafe fn test_mm512_maskz_mov_epi8() { let a = _mm512_set1_epi8(2); let r = _mm512_maskz_mov_epi8(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -19070,7 +19982,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_mov_epi8() { + const unsafe fn test_mm256_mask_mov_epi8() { let src = _mm256_set1_epi8(1); let a = _mm256_set1_epi8(2); let r = _mm256_mask_mov_epi8(src, 0, a); @@ -19080,7 +19992,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_mov_epi8() { + const unsafe fn test_mm256_maskz_mov_epi8() { let a = _mm256_set1_epi8(2); let r = _mm256_maskz_mov_epi8(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -19089,7 +20001,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_mov_epi8() { + const unsafe fn test_mm_mask_mov_epi8() { let src = _mm_set1_epi8(1); let a = _mm_set1_epi8(2); let r = _mm_mask_mov_epi8(src, 0, a); @@ -19099,7 +20011,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_mov_epi8() { + const unsafe fn test_mm_maskz_mov_epi8() { let a = _mm_set1_epi8(2); let r = _mm_maskz_mov_epi8(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -19108,7 +20020,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_set1_epi16() { + const unsafe fn test_mm512_mask_set1_epi16() { let src = _mm512_set1_epi16(2); let a: i16 = 11; let r = _mm512_mask_set1_epi16(src, 0, a); @@ -19119,7 +20031,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_set1_epi16() { + const unsafe fn test_mm512_maskz_set1_epi16() { let a: i16 = 11; let r = _mm512_maskz_set1_epi16(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -19129,7 +20041,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_set1_epi16() { + const unsafe fn test_mm256_mask_set1_epi16() { let src = _mm256_set1_epi16(2); let a: i16 = 11; let r = _mm256_mask_set1_epi16(src, 0, a); @@ -19140,7 +20052,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_set1_epi16() { + const unsafe fn test_mm256_maskz_set1_epi16() { let a: i16 = 11; let r = _mm256_maskz_set1_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -19150,7 +20062,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_set1_epi16() { + const unsafe fn test_mm_mask_set1_epi16() { let src = _mm_set1_epi16(2); let a: i16 = 11; let r = _mm_mask_set1_epi16(src, 0, a); @@ -19161,7 +20073,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_set1_epi16() { + const unsafe fn test_mm_maskz_set1_epi16() { let a: i16 = 11; let r = _mm_maskz_set1_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -19171,7 +20083,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_set1_epi8() { + const unsafe fn test_mm512_mask_set1_epi8() { let src = _mm512_set1_epi8(2); let a: i8 = 11; let r = _mm512_mask_set1_epi8(src, 0, a); @@ -19186,7 +20098,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_set1_epi8() { + const unsafe fn test_mm512_maskz_set1_epi8() { let a: i8 = 11; let r = _mm512_maskz_set1_epi8(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -19199,7 +20111,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_set1_epi8() { + const unsafe fn test_mm256_mask_set1_epi8() { let src = _mm256_set1_epi8(2); let a: i8 = 11; let r = _mm256_mask_set1_epi8(src, 0, a); @@ -19210,7 +20122,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_set1_epi8() { + const unsafe fn test_mm256_maskz_set1_epi8() { let a: i8 = 11; let r = _mm256_maskz_set1_epi8(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -19220,7 +20132,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_set1_epi8() { + const unsafe fn test_mm_mask_set1_epi8() { let src = _mm_set1_epi8(2); let a: i8 = 11; let r = _mm_mask_set1_epi8(src, 0, a); @@ -19231,7 +20143,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_set1_epi8() { + const unsafe fn test_mm_maskz_set1_epi8() { let a: i8 = 11; let r = _mm_maskz_set1_epi8(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -19241,7 +20153,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_shufflelo_epi16() { + const unsafe fn test_mm512_shufflelo_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -19257,7 +20169,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_shufflelo_epi16() { + const unsafe fn test_mm512_mask_shufflelo_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -19279,7 +20191,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_shufflelo_epi16() { + const unsafe fn test_mm512_maskz_shufflelo_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -19298,7 +20210,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_shufflelo_epi16() { + const unsafe fn test_mm256_mask_shufflelo_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_mask_shufflelo_epi16::<0b00_01_01_11>(a, 0, a); assert_eq_m256i(r, a); @@ -19308,7 +20220,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_shufflelo_epi16() { + const unsafe fn test_mm256_maskz_shufflelo_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_shufflelo_epi16::<0b00_01_01_11>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -19318,7 +20230,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_shufflelo_epi16() { + const unsafe fn test_mm_mask_shufflelo_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm_mask_shufflelo_epi16::<0b00_01_01_11>(a, 0, a); assert_eq_m128i(r, a); @@ -19328,7 +20240,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_shufflelo_epi16() { + const unsafe fn test_mm_maskz_shufflelo_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm_maskz_shufflelo_epi16::<0b00_01_01_11>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -19338,7 +20250,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_shufflehi_epi16() { + const unsafe fn test_mm512_shufflehi_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -19354,7 +20266,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_shufflehi_epi16() { + const unsafe fn test_mm512_mask_shufflehi_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -19376,7 +20288,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_shufflehi_epi16() { + const unsafe fn test_mm512_maskz_shufflehi_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -19395,7 +20307,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_shufflehi_epi16() { + const unsafe fn test_mm256_mask_shufflehi_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_mask_shufflehi_epi16::<0b00_01_01_11>(a, 0, a); assert_eq_m256i(r, a); @@ -19405,7 +20317,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_shufflehi_epi16() { + const unsafe fn test_mm256_maskz_shufflehi_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let r = _mm256_maskz_shufflehi_epi16::<0b00_01_01_11>(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -19415,7 +20327,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_shufflehi_epi16() { + const unsafe fn test_mm_mask_shufflehi_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm_mask_shufflehi_epi16::<0b00_01_01_11>(a, 0, a); assert_eq_m128i(r, a); @@ -19425,7 +20337,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_shufflehi_epi16() { + const unsafe fn test_mm_maskz_shufflehi_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let r = _mm_maskz_shufflehi_epi16::<0b00_01_01_11>(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -19556,7 +20468,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_test_epi16_mask() { + const unsafe fn test_mm512_test_epi16_mask() { let a = _mm512_set1_epi16(1 << 0); let b = _mm512_set1_epi16(1 << 0 | 1 << 1); let r = _mm512_test_epi16_mask(a, b); @@ -19565,7 +20477,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_test_epi16_mask() { + const unsafe fn test_mm512_mask_test_epi16_mask() { let a = _mm512_set1_epi16(1 << 0); let b = _mm512_set1_epi16(1 << 0 | 1 << 1); let r = _mm512_mask_test_epi16_mask(0, a, b); @@ -19576,7 +20488,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_test_epi16_mask() { + const unsafe fn test_mm256_test_epi16_mask() { let a = _mm256_set1_epi16(1 << 0); let b = _mm256_set1_epi16(1 << 0 | 1 << 1); let r = _mm256_test_epi16_mask(a, b); @@ -19585,7 +20497,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_test_epi16_mask() { + const unsafe fn test_mm256_mask_test_epi16_mask() { let a = _mm256_set1_epi16(1 << 0); let b = _mm256_set1_epi16(1 << 0 | 1 << 1); let r = _mm256_mask_test_epi16_mask(0, a, b); @@ -19596,7 +20508,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_test_epi16_mask() { + const unsafe fn test_mm_test_epi16_mask() { let a = _mm_set1_epi16(1 << 0); let b = _mm_set1_epi16(1 << 0 | 1 << 1); let r = _mm_test_epi16_mask(a, b); @@ -19605,7 +20517,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_test_epi16_mask() { + const unsafe fn test_mm_mask_test_epi16_mask() { let a = _mm_set1_epi16(1 << 0); let b = _mm_set1_epi16(1 << 0 | 1 << 1); let r = _mm_mask_test_epi16_mask(0, a, b); @@ -19616,7 +20528,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_test_epi8_mask() { + const unsafe fn test_mm512_test_epi8_mask() { let a = _mm512_set1_epi8(1 << 0); let b = _mm512_set1_epi8(1 << 0 | 1 << 1); let r = _mm512_test_epi8_mask(a, b); @@ -19626,7 +20538,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_test_epi8_mask() { + const unsafe fn test_mm512_mask_test_epi8_mask() { let a = _mm512_set1_epi8(1 << 0); let b = _mm512_set1_epi8(1 << 0 | 1 << 1); let r = _mm512_mask_test_epi8_mask(0, a, b); @@ -19642,7 +20554,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_test_epi8_mask() { + const unsafe fn test_mm256_test_epi8_mask() { let a = _mm256_set1_epi8(1 << 0); let b = _mm256_set1_epi8(1 << 0 | 1 << 1); let r = _mm256_test_epi8_mask(a, b); @@ -19651,7 +20563,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_test_epi8_mask() { + const unsafe fn test_mm256_mask_test_epi8_mask() { let a = _mm256_set1_epi8(1 << 0); let b = _mm256_set1_epi8(1 << 0 | 1 << 1); let r = _mm256_mask_test_epi8_mask(0, a, b); @@ -19662,7 +20574,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_test_epi8_mask() { + const unsafe fn test_mm_test_epi8_mask() { let a = _mm_set1_epi8(1 << 0); let b = _mm_set1_epi8(1 << 0 | 1 << 1); let r = _mm_test_epi8_mask(a, b); @@ -19671,7 +20583,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_test_epi8_mask() { + const unsafe fn test_mm_mask_test_epi8_mask() { let a = _mm_set1_epi8(1 << 0); let b = _mm_set1_epi8(1 << 0 | 1 << 1); let r = _mm_mask_test_epi8_mask(0, a, b); @@ -19682,7 +20594,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_testn_epi16_mask() { + const unsafe fn test_mm512_testn_epi16_mask() { let a = _mm512_set1_epi16(1 << 0); let b = _mm512_set1_epi16(1 << 0 | 1 << 1); let r = _mm512_testn_epi16_mask(a, b); @@ -19691,7 +20603,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_testn_epi16_mask() { + const unsafe fn test_mm512_mask_testn_epi16_mask() { let a = _mm512_set1_epi16(1 << 0); let b = _mm512_set1_epi16(1 << 0 | 1 << 1); let r = _mm512_mask_testn_epi16_mask(0, a, b); @@ -19702,7 +20614,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_testn_epi16_mask() { + const unsafe fn test_mm256_testn_epi16_mask() { let a = _mm256_set1_epi16(1 << 0); let b = _mm256_set1_epi16(1 << 0 | 1 << 1); let r = _mm256_testn_epi16_mask(a, b); @@ -19711,7 +20623,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_testn_epi16_mask() { + const unsafe fn test_mm256_mask_testn_epi16_mask() { let a = _mm256_set1_epi16(1 << 0); let b = _mm256_set1_epi16(1 << 0 | 1 << 1); let r = _mm256_mask_testn_epi16_mask(0, a, b); @@ -19722,7 +20634,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_testn_epi16_mask() { + const unsafe fn test_mm_testn_epi16_mask() { let a = _mm_set1_epi16(1 << 0); let b = _mm_set1_epi16(1 << 0 | 1 << 1); let r = _mm_testn_epi16_mask(a, b); @@ -19731,7 +20643,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_testn_epi16_mask() { + const unsafe fn test_mm_mask_testn_epi16_mask() { let a = _mm_set1_epi16(1 << 0); let b = _mm_set1_epi16(1 << 0 | 1 << 1); let r = _mm_mask_testn_epi16_mask(0, a, b); @@ -19742,7 +20654,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_testn_epi8_mask() { + const unsafe fn test_mm512_testn_epi8_mask() { let a = _mm512_set1_epi8(1 << 0); let b = _mm512_set1_epi8(1 << 0 | 1 << 1); let r = _mm512_testn_epi8_mask(a, b); @@ -19752,7 +20664,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_testn_epi8_mask() { + const unsafe fn test_mm512_mask_testn_epi8_mask() { let a = _mm512_set1_epi8(1 << 0); let b = _mm512_set1_epi8(1 << 0 | 1 << 1); let r = _mm512_mask_testn_epi8_mask(0, a, b); @@ -19768,7 +20680,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_testn_epi8_mask() { + const unsafe fn test_mm256_testn_epi8_mask() { let a = _mm256_set1_epi8(1 << 0); let b = _mm256_set1_epi8(1 << 0 | 1 << 1); let r = _mm256_testn_epi8_mask(a, b); @@ -19777,7 +20689,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_testn_epi8_mask() { + const unsafe fn test_mm256_mask_testn_epi8_mask() { let a = _mm256_set1_epi8(1 << 0); let b = _mm256_set1_epi8(1 << 0 | 1 << 1); let r = _mm256_mask_testn_epi8_mask(0, a, b); @@ -19788,7 +20700,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_testn_epi8_mask() { + const unsafe fn test_mm_testn_epi8_mask() { let a = _mm_set1_epi8(1 << 0); let b = _mm_set1_epi8(1 << 0 | 1 << 1); let r = _mm_testn_epi8_mask(a, b); @@ -19797,7 +20709,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_testn_epi8_mask() { + const unsafe fn test_mm_mask_testn_epi8_mask() { let a = _mm_set1_epi8(1 << 0); let b = _mm_set1_epi8(1 << 0 | 1 << 1); let r = _mm_mask_testn_epi8_mask(0, a, b); @@ -19808,7 +20720,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_store_mask64() { + const unsafe fn test_store_mask64() { let a: __mmask64 = 0b11111111_00000000_11111111_00000000_11111111_00000000_11111111_00000000; let mut r = 0; @@ -19817,7 +20729,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_store_mask32() { + const unsafe fn test_store_mask32() { let a: __mmask32 = 0b11111111_00000000_11111111_00000000; let mut r = 0; _store_mask32(&mut r, a); @@ -19825,7 +20737,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_load_mask64() { + const unsafe fn test_load_mask64() { let p: __mmask64 = 0b11111111_00000000_11111111_00000000_11111111_00000000_11111111_00000000; let r = _load_mask64(&p); @@ -19835,7 +20747,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_load_mask32() { + const unsafe fn test_load_mask32() { let p: __mmask32 = 0b11111111_00000000_11111111_00000000; let r = _load_mask32(&p); let e: __mmask32 = 0b11111111_00000000_11111111_00000000; @@ -19948,7 +20860,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_movepi16_mask() { + const unsafe fn test_mm512_movepi16_mask() { let a = _mm512_set1_epi16(1 << 15); let r = _mm512_movepi16_mask(a); let e: __mmask32 = 0b11111111_11111111_11111111_11111111; @@ -19956,7 +20868,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_movepi16_mask() { + const unsafe fn test_mm256_movepi16_mask() { let a = _mm256_set1_epi16(1 << 15); let r = _mm256_movepi16_mask(a); let e: __mmask16 = 0b11111111_11111111; @@ -19964,7 +20876,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_movepi16_mask() { + const unsafe fn test_mm_movepi16_mask() { let a = _mm_set1_epi16(1 << 15); let r = _mm_movepi16_mask(a); let e: __mmask8 = 0b11111111; @@ -19972,7 +20884,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_movepi8_mask() { + const unsafe fn test_mm512_movepi8_mask() { let a = _mm512_set1_epi8(1 << 7); let r = _mm512_movepi8_mask(a); let e: __mmask64 = @@ -19981,7 +20893,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_movepi8_mask() { + const unsafe fn test_mm256_movepi8_mask() { let a = _mm256_set1_epi8(1 << 7); let r = _mm256_movepi8_mask(a); let e: __mmask32 = 0b11111111_11111111_11111111_11111111; @@ -19989,7 +20901,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_movepi8_mask() { + const unsafe fn test_mm_movepi8_mask() { let a = _mm_set1_epi8(1 << 7); let r = _mm_movepi8_mask(a); let e: __mmask16 = 0b11111111_11111111; @@ -19997,7 +20909,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_movm_epi16() { + const unsafe fn test_mm512_movm_epi16() { let a: __mmask32 = 0b11111111_11111111_11111111_11111111; let r = _mm512_movm_epi16(a); let e = _mm512_set1_epi16( @@ -20022,7 +20934,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_movm_epi16() { + const unsafe fn test_mm256_movm_epi16() { let a: __mmask16 = 0b11111111_11111111; let r = _mm256_movm_epi16(a); let e = _mm256_set1_epi16( @@ -20047,7 +20959,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_movm_epi16() { + const unsafe fn test_mm_movm_epi16() { let a: __mmask8 = 0b11111111; let r = _mm_movm_epi16(a); let e = _mm_set1_epi16( @@ -20072,7 +20984,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_movm_epi8() { + const unsafe fn test_mm512_movm_epi8() { let a: __mmask64 = 0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111; let r = _mm512_movm_epi8(a); @@ -20082,7 +20994,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_movm_epi8() { + const unsafe fn test_mm256_movm_epi8() { let a: __mmask32 = 0b11111111_11111111_11111111_11111111; let r = _mm256_movm_epi8(a); let e = @@ -20091,7 +21003,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_movm_epi8() { + const unsafe fn test_mm_movm_epi8() { let a: __mmask16 = 0b11111111_11111111; let r = _mm_movm_epi8(a); let e = @@ -20100,7 +21012,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_cvtmask32_u32() { + const unsafe fn test_cvtmask32_u32() { let a: __mmask32 = 0b11001100_00110011_01100110_10011001; let r = _cvtmask32_u32(a); let e: u32 = 0b11001100_00110011_01100110_10011001; @@ -20108,7 +21020,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_cvtu32_mask32() { + const unsafe fn test_cvtu32_mask32() { let a: u32 = 0b11001100_00110011_01100110_10011001; let r = _cvtu32_mask32(a); let e: __mmask32 = 0b11001100_00110011_01100110_10011001; @@ -20116,7 +21028,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kadd_mask32() { + const unsafe fn test_kadd_mask32() { let a: __mmask32 = 11; let b: __mmask32 = 22; let r = _kadd_mask32(a, b); @@ -20125,7 +21037,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kadd_mask64() { + const unsafe fn test_kadd_mask64() { let a: __mmask64 = 11; let b: __mmask64 = 22; let r = _kadd_mask64(a, b); @@ -20134,7 +21046,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kand_mask32() { + const unsafe fn test_kand_mask32() { let a: __mmask32 = 0b11001100_00110011_11001100_00110011; let b: __mmask32 = 0b11001100_00110011_11001100_00110011; let r = _kand_mask32(a, b); @@ -20143,7 +21055,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kand_mask64() { + const unsafe fn test_kand_mask64() { let a: __mmask64 = 0b11001100_00110011_11001100_00110011_11001100_00110011_11001100_00110011; let b: __mmask64 = @@ -20155,7 +21067,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_knot_mask32() { + const unsafe fn test_knot_mask32() { let a: __mmask32 = 0b11001100_00110011_11001100_00110011; let r = _knot_mask32(a); let e: __mmask32 = 0b00110011_11001100_00110011_11001100; @@ -20163,7 +21075,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_knot_mask64() { + const unsafe fn test_knot_mask64() { let a: __mmask64 = 0b11001100_00110011_11001100_00110011_11001100_00110011_11001100_00110011; let r = _knot_mask64(a); @@ -20173,7 +21085,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kandn_mask32() { + const unsafe fn test_kandn_mask32() { let a: __mmask32 = 0b11001100_00110011_11001100_00110011; let b: __mmask32 = 0b11001100_00110011_11001100_00110011; let r = _kandn_mask32(a, b); @@ -20182,7 +21094,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kandn_mask64() { + const unsafe fn test_kandn_mask64() { let a: __mmask64 = 0b11001100_00110011_11001100_00110011_11001100_00110011_11001100_00110011; let b: __mmask64 = @@ -20194,7 +21106,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kor_mask32() { + const unsafe fn test_kor_mask32() { let a: __mmask32 = 0b00110011_11001100_00110011_11001100; let b: __mmask32 = 0b11001100_00110011_11001100_00110011; let r = _kor_mask32(a, b); @@ -20203,7 +21115,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kor_mask64() { + const unsafe fn test_kor_mask64() { let a: __mmask64 = 0b00110011_11001100_00110011_11001100_00110011_11001100_00110011_11001100; let b: __mmask64 = @@ -20215,7 +21127,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kxor_mask32() { + const unsafe fn test_kxor_mask32() { let a: __mmask32 = 0b00110011_11001100_00110011_11001100; let b: __mmask32 = 0b11001100_00110011_11001100_00110011; let r = _kxor_mask32(a, b); @@ -20224,7 +21136,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kxor_mask64() { + const unsafe fn test_kxor_mask64() { let a: __mmask64 = 0b00110011_11001100_00110011_11001100_00110011_11001100_00110011_11001100; let b: __mmask64 = @@ -20236,7 +21148,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kxnor_mask32() { + const unsafe fn test_kxnor_mask32() { let a: __mmask32 = 0b00110011_11001100_00110011_11001100; let b: __mmask32 = 0b11001100_00110011_11001100_00110011; let r = _kxnor_mask32(a, b); @@ -20245,7 +21157,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kxnor_mask64() { + const unsafe fn test_kxnor_mask64() { let a: __mmask64 = 0b00110011_11001100_00110011_11001100_00110011_11001100_00110011_11001100; let b: __mmask64 = @@ -20257,7 +21169,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kortest_mask32_u8() { + const unsafe fn test_kortest_mask32_u8() { let a: __mmask32 = 0b0110100101101001_0110100101101001; let b: __mmask32 = 0b1011011010110110_1011011010110110; let mut all_ones: u8 = 0; @@ -20267,7 +21179,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kortest_mask64_u8() { + const unsafe fn test_kortest_mask64_u8() { let a: __mmask64 = 0b0110100101101001_0110100101101001; let b: __mmask64 = 0b1011011010110110_1011011010110110; let mut all_ones: u8 = 0; @@ -20277,7 +21189,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kortestc_mask32_u8() { + const unsafe fn test_kortestc_mask32_u8() { let a: __mmask32 = 0b0110100101101001_0110100101101001; let b: __mmask32 = 0b1011011010110110_1011011010110110; let r = _kortestc_mask32_u8(a, b); @@ -20285,7 +21197,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kortestc_mask64_u8() { + const unsafe fn test_kortestc_mask64_u8() { let a: __mmask64 = 0b0110100101101001_0110100101101001; let b: __mmask64 = 0b1011011010110110_1011011010110110; let r = _kortestc_mask64_u8(a, b); @@ -20293,7 +21205,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kortestz_mask32_u8() { + const unsafe fn test_kortestz_mask32_u8() { let a: __mmask32 = 0b0110100101101001_0110100101101001; let b: __mmask32 = 0b1011011010110110_1011011010110110; let r = _kortestz_mask32_u8(a, b); @@ -20301,7 +21213,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kortestz_mask64_u8() { + const unsafe fn test_kortestz_mask64_u8() { let a: __mmask64 = 0b0110100101101001_0110100101101001; let b: __mmask64 = 0b1011011010110110_1011011010110110; let r = _kortestz_mask64_u8(a, b); @@ -20309,7 +21221,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kshiftli_mask32() { + const unsafe fn test_kshiftli_mask32() { let a: __mmask32 = 0b0110100101101001_0110100101101001; let r = _kshiftli_mask32::<3>(a); let e: __mmask32 = 0b0100101101001011_0100101101001000; @@ -20329,7 +21241,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kshiftli_mask64() { + const unsafe fn test_kshiftli_mask64() { let a: __mmask64 = 0b0110100101101001_0110100101101001; let r = _kshiftli_mask64::<3>(a); let e: __mmask64 = 0b0110100101101001011_0100101101001000; @@ -20349,7 +21261,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kshiftri_mask32() { + const unsafe fn test_kshiftri_mask32() { let a: __mmask32 = 0b1010100101101001_0110100101101001; let r = _kshiftri_mask32::<3>(a); let e: __mmask32 = 0b0001010100101101_0010110100101101; @@ -20369,7 +21281,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_kshiftri_mask64() { + const unsafe fn test_kshiftri_mask64() { let a: __mmask64 = 0b1010100101101001011_0100101101001000; let r = _kshiftri_mask64::<3>(a); let e: __mmask64 = 0b1010100101101001_0110100101101001; @@ -20393,7 +21305,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_ktest_mask32_u8() { + const unsafe fn test_ktest_mask32_u8() { let a: __mmask32 = 0b0110100100111100_0110100100111100; let b: __mmask32 = 0b1001011011000011_1001011011000011; let mut and_not: u8 = 0; @@ -20403,7 +21315,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_ktestc_mask32_u8() { + const unsafe fn test_ktestc_mask32_u8() { let a: __mmask32 = 0b0110100100111100_0110100100111100; let b: __mmask32 = 0b1001011011000011_1001011011000011; let r = _ktestc_mask32_u8(a, b); @@ -20411,7 +21323,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_ktestz_mask32_u8() { + const unsafe fn test_ktestz_mask32_u8() { let a: __mmask32 = 0b0110100100111100_0110100100111100; let b: __mmask32 = 0b1001011011000011_1001011011000011; let r = _ktestz_mask32_u8(a, b); @@ -20419,7 +21331,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_ktest_mask64_u8() { + const unsafe fn test_ktest_mask64_u8() { let a: __mmask64 = 0b0110100100111100_0110100100111100; let b: __mmask64 = 0b1001011011000011_1001011011000011; let mut and_not: u8 = 0; @@ -20429,7 +21341,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_ktestc_mask64_u8() { + const unsafe fn test_ktestc_mask64_u8() { let a: __mmask64 = 0b0110100100111100_0110100100111100; let b: __mmask64 = 0b1001011011000011_1001011011000011; let r = _ktestc_mask64_u8(a, b); @@ -20437,7 +21349,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_ktestz_mask64_u8() { + const unsafe fn test_ktestz_mask64_u8() { let a: __mmask64 = 0b0110100100111100_0110100100111100; let b: __mmask64 = 0b1001011011000011_1001011011000011; let r = _ktestz_mask64_u8(a, b); @@ -20445,7 +21357,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_kunpackw() { + const unsafe fn test_mm512_kunpackw() { let a: u32 = 0x00110011; let b: u32 = 0x00001011; let r = _mm512_kunpackw(a, b); @@ -20454,7 +21366,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_kunpackd() { + const unsafe fn test_mm512_kunpackd() { let a: u64 = 0x11001100_00110011; let b: u64 = 0x00101110_00001011; let r = _mm512_kunpackd(a, b); @@ -20463,7 +21375,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cvtepi16_epi8() { + const unsafe fn test_mm512_cvtepi16_epi8() { let a = _mm512_set1_epi16(2); let r = _mm512_cvtepi16_epi8(a); let e = _mm256_set1_epi8(2); @@ -20471,7 +21383,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cvtepi16_epi8() { + const unsafe fn test_mm512_mask_cvtepi16_epi8() { let src = _mm256_set1_epi8(1); let a = _mm512_set1_epi16(2); let r = _mm512_mask_cvtepi16_epi8(src, 0, a); @@ -20482,7 +21394,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_cvtepi16_epi8() { + const unsafe fn test_mm512_maskz_cvtepi16_epi8() { let a = _mm512_set1_epi16(2); let r = _mm512_maskz_cvtepi16_epi8(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -20492,7 +21404,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_cvtepi16_epi8() { + const unsafe fn test_mm256_cvtepi16_epi8() { let a = _mm256_set1_epi16(2); let r = _mm256_cvtepi16_epi8(a); let e = _mm_set1_epi8(2); @@ -20500,7 +21412,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cvtepi16_epi8() { + const unsafe fn test_mm256_mask_cvtepi16_epi8() { let src = _mm_set1_epi8(1); let a = _mm256_set1_epi16(2); let r = _mm256_mask_cvtepi16_epi8(src, 0, a); @@ -20511,7 +21423,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi16_epi8() { + const unsafe fn test_mm256_maskz_cvtepi16_epi8() { let a = _mm256_set1_epi16(2); let r = _mm256_maskz_cvtepi16_epi8(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -20521,7 +21433,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_cvtepi16_epi8() { + const unsafe fn test_mm_cvtepi16_epi8() { let a = _mm_set1_epi16(2); let r = _mm_cvtepi16_epi8(a); let e = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2); @@ -20529,7 +21441,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cvtepi16_epi8() { + const unsafe fn test_mm_mask_cvtepi16_epi8() { let src = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1); let a = _mm_set1_epi16(2); let r = _mm_mask_cvtepi16_epi8(src, 0, a); @@ -20540,7 +21452,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_cvtepi16_epi8() { + const unsafe fn test_mm_maskz_cvtepi16_epi8() { let a = _mm_set1_epi16(2); let r = _mm_maskz_cvtepi16_epi8(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -20727,7 +21639,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cvtepi8_epi16() { + const unsafe fn test_mm512_cvtepi8_epi16() { let a = _mm256_set1_epi8(2); let r = _mm512_cvtepi8_epi16(a); let e = _mm512_set1_epi16(2); @@ -20735,7 +21647,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cvtepi8_epi16() { + const unsafe fn test_mm512_mask_cvtepi8_epi16() { let src = _mm512_set1_epi16(1); let a = _mm256_set1_epi8(2); let r = _mm512_mask_cvtepi8_epi16(src, 0, a); @@ -20746,7 +21658,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_cvtepi8_epi16() { + const unsafe fn test_mm512_maskz_cvtepi8_epi16() { let a = _mm256_set1_epi8(2); let r = _mm512_maskz_cvtepi8_epi16(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -20756,7 +21668,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cvtepi8_epi16() { + const unsafe fn test_mm256_mask_cvtepi8_epi16() { let src = _mm256_set1_epi16(1); let a = _mm_set1_epi8(2); let r = _mm256_mask_cvtepi8_epi16(src, 0, a); @@ -20767,7 +21679,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_cvtepi8_epi16() { + const unsafe fn test_mm256_maskz_cvtepi8_epi16() { let a = _mm_set1_epi8(2); let r = _mm256_maskz_cvtepi8_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -20777,7 +21689,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cvtepi8_epi16() { + const unsafe fn test_mm_mask_cvtepi8_epi16() { let src = _mm_set1_epi16(1); let a = _mm_set1_epi8(2); let r = _mm_mask_cvtepi8_epi16(src, 0, a); @@ -20788,7 +21700,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_cvtepi8_epi16() { + const unsafe fn test_mm_maskz_cvtepi8_epi16() { let a = _mm_set1_epi8(2); let r = _mm_maskz_cvtepi8_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -20798,7 +21710,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_cvtepu8_epi16() { + const unsafe fn test_mm512_cvtepu8_epi16() { let a = _mm256_set1_epi8(2); let r = _mm512_cvtepu8_epi16(a); let e = _mm512_set1_epi16(2); @@ -20806,7 +21718,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_cvtepu8_epi16() { + const unsafe fn test_mm512_mask_cvtepu8_epi16() { let src = _mm512_set1_epi16(1); let a = _mm256_set1_epi8(2); let r = _mm512_mask_cvtepu8_epi16(src, 0, a); @@ -20817,7 +21729,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_cvtepu8_epi16() { + const unsafe fn test_mm512_maskz_cvtepu8_epi16() { let a = _mm256_set1_epi8(2); let r = _mm512_maskz_cvtepu8_epi16(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -20827,7 +21739,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_cvtepu8_epi16() { + const unsafe fn test_mm256_mask_cvtepu8_epi16() { let src = _mm256_set1_epi16(1); let a = _mm_set1_epi8(2); let r = _mm256_mask_cvtepu8_epi16(src, 0, a); @@ -20838,7 +21750,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_cvtepu8_epi16() { + const unsafe fn test_mm256_maskz_cvtepu8_epi16() { let a = _mm_set1_epi8(2); let r = _mm256_maskz_cvtepu8_epi16(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -20848,7 +21760,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_cvtepu8_epi16() { + const unsafe fn test_mm_mask_cvtepu8_epi16() { let src = _mm_set1_epi16(1); let a = _mm_set1_epi8(2); let r = _mm_mask_cvtepu8_epi16(src, 0, a); @@ -20859,7 +21771,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_cvtepu8_epi16() { + const unsafe fn test_mm_maskz_cvtepu8_epi16() { let a = _mm_set1_epi8(2); let r = _mm_maskz_cvtepu8_epi16(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -20869,7 +21781,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_bslli_epi128() { + const unsafe fn test_mm512_bslli_epi128() { #[rustfmt::skip] let a = _mm512_set_epi8( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, @@ -20889,7 +21801,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_bsrli_epi128() { + const unsafe fn test_mm512_bsrli_epi128() { #[rustfmt::skip] let a = _mm512_set_epi8( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -20909,7 +21821,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_alignr_epi8() { + const unsafe fn test_mm512_alignr_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, @@ -20930,7 +21842,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_mask_alignr_epi8() { + const unsafe fn test_mm512_mask_alignr_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, @@ -20958,7 +21870,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_mm512_maskz_alignr_epi8() { + const unsafe fn test_mm512_maskz_alignr_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, @@ -20985,7 +21897,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_mask_alignr_epi8() { + const unsafe fn test_mm256_mask_alignr_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, @@ -21004,7 +21916,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm256_maskz_alignr_epi8() { + const unsafe fn test_mm256_maskz_alignr_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, @@ -21023,7 +21935,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_mask_alignr_epi8() { + const unsafe fn test_mm_mask_alignr_epi8() { let a = _mm_set_epi8(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); let b = _mm_set1_epi8(1); let r = _mm_mask_alignr_epi8::<14>(a, 0, a, b); @@ -21034,7 +21946,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - unsafe fn test_mm_maskz_alignr_epi8() { + const unsafe fn test_mm_maskz_alignr_epi8() { let a = _mm_set_epi8(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0); let b = _mm_set1_epi8(1); let r = _mm_maskz_alignr_epi8::<14>(0, a, b); diff --git a/library/stdarch/crates/core_arch/src/x86_64/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86_64/avx512bw.rs index 466c36ef31e5..a8e5183e0c2f 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/avx512bw.rs @@ -6,7 +6,8 @@ use crate::core_arch::x86::*; #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtmask64_u64(a: __mmask64) -> u64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtmask64_u64(a: __mmask64) -> u64 { a } @@ -16,19 +17,21 @@ pub fn _cvtmask64_u64(a: __mmask64) -> u64 { #[inline] #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtu64_mask64(a: u64) -> __mmask64 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtu64_mask64(a: u64) -> __mmask64 { a } #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::{x86::*, x86_64::*}; #[simd_test(enable = "avx512bw")] - unsafe fn test_cvtmask64_u64() { + const unsafe fn test_cvtmask64_u64() { let a: __mmask64 = 0b11001100_00110011_01100110_10011001; let r = _cvtmask64_u64(a); let e: u64 = 0b11001100_00110011_01100110_10011001; @@ -36,7 +39,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - unsafe fn test_cvtu64_mask64() { + const unsafe fn test_cvtu64_mask64() { let a: u64 = 0b11001100_00110011_01100110_10011001; let r = _cvtu64_mask64(a); let e: __mmask64 = 0b11001100_00110011_01100110_10011001; From 3516ef11e421af4bffef72b2d53ff6e530dccad1 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:23:20 +0530 Subject: [PATCH 070/489] Make `avx512cd` functions const --- .../crates/core_arch/src/x86/avx512cd.rs | 121 +++++++++++------- 1 file changed, 73 insertions(+), 48 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512cd.rs b/library/stdarch/crates/core_arch/src/x86/avx512cd.rs index 78735fcc90f5..b163698b56c4 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512cd.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512cd.rs @@ -11,7 +11,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] // should be vpbroadcastmw2d -pub fn _mm512_broadcastmw_epi32(k: __mmask16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastmw_epi32(k: __mmask16) -> __m512i { _mm512_set1_epi32(k as i32) } @@ -22,7 +23,8 @@ pub fn _mm512_broadcastmw_epi32(k: __mmask16) -> __m512i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] // should be vpbroadcastmw2d -pub fn _mm256_broadcastmw_epi32(k: __mmask16) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastmw_epi32(k: __mmask16) -> __m256i { _mm256_set1_epi32(k as i32) } @@ -33,7 +35,8 @@ pub fn _mm256_broadcastmw_epi32(k: __mmask16) -> __m256i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] // should be vpbroadcastmw2d -pub fn _mm_broadcastmw_epi32(k: __mmask16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastmw_epi32(k: __mmask16) -> __m128i { _mm_set1_epi32(k as i32) } @@ -44,7 +47,8 @@ pub fn _mm_broadcastmw_epi32(k: __mmask16) -> __m128i { #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] // should be vpbroadcastmb2q -pub fn _mm512_broadcastmb_epi64(k: __mmask8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcastmb_epi64(k: __mmask8) -> __m512i { _mm512_set1_epi64(k as i64) } @@ -55,7 +59,8 @@ pub fn _mm512_broadcastmb_epi64(k: __mmask8) -> __m512i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] // should be vpbroadcastmb2q -pub fn _mm256_broadcastmb_epi64(k: __mmask8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcastmb_epi64(k: __mmask8) -> __m256i { _mm256_set1_epi64x(k as i64) } @@ -66,7 +71,8 @@ pub fn _mm256_broadcastmb_epi64(k: __mmask8) -> __m256i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpbroadcast))] // should be vpbroadcastmb2q -pub fn _mm_broadcastmb_epi64(k: __mmask8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcastmb_epi64(k: __mmask8) -> __m128i { _mm_set1_epi64x(k as i64) } @@ -311,7 +317,8 @@ pub fn _mm_maskz_conflict_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm512_lzcnt_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_lzcnt_epi32(a: __m512i) -> __m512i { unsafe { transmute(simd_ctlz(a.as_i32x16())) } } @@ -322,7 +329,8 @@ pub fn _mm512_lzcnt_epi32(a: __m512i) -> __m512i { #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm512_mask_lzcnt_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_lzcnt_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { unsafe { let zerocount = _mm512_lzcnt_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, zerocount, src.as_i32x16())) @@ -336,7 +344,8 @@ pub fn _mm512_mask_lzcnt_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512 #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm512_maskz_lzcnt_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_lzcnt_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { let zerocount = _mm512_lzcnt_epi32(a).as_i32x16(); transmute(simd_select_bitmask(k, zerocount, i32x16::ZERO)) @@ -350,7 +359,8 @@ pub fn _mm512_maskz_lzcnt_epi32(k: __mmask16, a: __m512i) -> __m512i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm256_lzcnt_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_lzcnt_epi32(a: __m256i) -> __m256i { unsafe { transmute(simd_ctlz(a.as_i32x8())) } } @@ -361,7 +371,8 @@ pub fn _mm256_lzcnt_epi32(a: __m256i) -> __m256i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm256_mask_lzcnt_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_lzcnt_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { let zerocount = _mm256_lzcnt_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, zerocount, src.as_i32x8())) @@ -375,7 +386,8 @@ pub fn _mm256_mask_lzcnt_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm256_maskz_lzcnt_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_lzcnt_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { let zerocount = _mm256_lzcnt_epi32(a).as_i32x8(); transmute(simd_select_bitmask(k, zerocount, i32x8::ZERO)) @@ -389,7 +401,8 @@ pub fn _mm256_maskz_lzcnt_epi32(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm_lzcnt_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_lzcnt_epi32(a: __m128i) -> __m128i { unsafe { transmute(simd_ctlz(a.as_i32x4())) } } @@ -400,7 +413,8 @@ pub fn _mm_lzcnt_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm_mask_lzcnt_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_lzcnt_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let zerocount = _mm_lzcnt_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, zerocount, src.as_i32x4())) @@ -414,7 +428,8 @@ pub fn _mm_mask_lzcnt_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntd))] -pub fn _mm_maskz_lzcnt_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_lzcnt_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { let zerocount = _mm_lzcnt_epi32(a).as_i32x4(); transmute(simd_select_bitmask(k, zerocount, i32x4::ZERO)) @@ -428,7 +443,8 @@ pub fn _mm_maskz_lzcnt_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm512_lzcnt_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_lzcnt_epi64(a: __m512i) -> __m512i { unsafe { transmute(simd_ctlz(a.as_i64x8())) } } @@ -439,7 +455,8 @@ pub fn _mm512_lzcnt_epi64(a: __m512i) -> __m512i { #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm512_mask_lzcnt_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_lzcnt_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { unsafe { let zerocount = _mm512_lzcnt_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, zerocount, src.as_i64x8())) @@ -453,7 +470,8 @@ pub fn _mm512_mask_lzcnt_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i #[target_feature(enable = "avx512cd")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm512_maskz_lzcnt_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_lzcnt_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { let zerocount = _mm512_lzcnt_epi64(a).as_i64x8(); transmute(simd_select_bitmask(k, zerocount, i64x8::ZERO)) @@ -467,7 +485,8 @@ pub fn _mm512_maskz_lzcnt_epi64(k: __mmask8, a: __m512i) -> __m512i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm256_lzcnt_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_lzcnt_epi64(a: __m256i) -> __m256i { unsafe { transmute(simd_ctlz(a.as_i64x4())) } } @@ -478,7 +497,8 @@ pub fn _mm256_lzcnt_epi64(a: __m256i) -> __m256i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm256_mask_lzcnt_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_lzcnt_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { let zerocount = _mm256_lzcnt_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, zerocount, src.as_i64x4())) @@ -492,7 +512,8 @@ pub fn _mm256_mask_lzcnt_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm256_maskz_lzcnt_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_lzcnt_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { let zerocount = _mm256_lzcnt_epi64(a).as_i64x4(); transmute(simd_select_bitmask(k, zerocount, i64x4::ZERO)) @@ -506,7 +527,8 @@ pub fn _mm256_maskz_lzcnt_epi64(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm_lzcnt_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_lzcnt_epi64(a: __m128i) -> __m128i { unsafe { transmute(simd_ctlz(a.as_i64x2())) } } @@ -517,7 +539,8 @@ pub fn _mm_lzcnt_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm_mask_lzcnt_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_lzcnt_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let zerocount = _mm_lzcnt_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, zerocount, src.as_i64x2())) @@ -531,7 +554,8 @@ pub fn _mm_mask_lzcnt_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512cd,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vplzcntq))] -pub fn _mm_maskz_lzcnt_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_lzcnt_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { let zerocount = _mm_lzcnt_epi64(a).as_i64x2(); transmute(simd_select_bitmask(k, zerocount, i64x2::ZERO)) @@ -557,12 +581,13 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::core_arch::x86::*; use stdarch_test::simd_test; #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_broadcastmw_epi32() { + const unsafe fn test_mm512_broadcastmw_epi32() { let a: __mmask16 = 2; let r = _mm512_broadcastmw_epi32(a); let e = _mm512_set1_epi32(2); @@ -570,7 +595,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_broadcastmw_epi32() { + const unsafe fn test_mm256_broadcastmw_epi32() { let a: __mmask16 = 2; let r = _mm256_broadcastmw_epi32(a); let e = _mm256_set1_epi32(2); @@ -578,7 +603,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_broadcastmw_epi32() { + const unsafe fn test_mm_broadcastmw_epi32() { let a: __mmask16 = 2; let r = _mm_broadcastmw_epi32(a); let e = _mm_set1_epi32(2); @@ -586,7 +611,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_broadcastmb_epi64() { + const unsafe fn test_mm512_broadcastmb_epi64() { let a: __mmask8 = 2; let r = _mm512_broadcastmb_epi64(a); let e = _mm512_set1_epi64(2); @@ -594,7 +619,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_broadcastmb_epi64() { + const unsafe fn test_mm256_broadcastmb_epi64() { let a: __mmask8 = 2; let r = _mm256_broadcastmb_epi64(a); let e = _mm256_set1_epi64x(2); @@ -602,7 +627,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_broadcastmb_epi64() { + const unsafe fn test_mm_broadcastmb_epi64() { let a: __mmask8 = 2; let r = _mm_broadcastmb_epi64(a); let e = _mm_set1_epi64x(2); @@ -1063,7 +1088,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_lzcnt_epi32() { + const unsafe fn test_mm512_lzcnt_epi32() { let a = _mm512_set1_epi32(1); let r = _mm512_lzcnt_epi32(a); let e = _mm512_set1_epi32(31); @@ -1071,7 +1096,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_mask_lzcnt_epi32() { + const unsafe fn test_mm512_mask_lzcnt_epi32() { let a = _mm512_set1_epi32(1); let r = _mm512_mask_lzcnt_epi32(a, 0, a); assert_eq_m512i(r, a); @@ -1081,7 +1106,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_maskz_lzcnt_epi32() { + const unsafe fn test_mm512_maskz_lzcnt_epi32() { let a = _mm512_set1_epi32(2); let r = _mm512_maskz_lzcnt_epi32(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -1091,7 +1116,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_lzcnt_epi32() { + const unsafe fn test_mm256_lzcnt_epi32() { let a = _mm256_set1_epi32(1); let r = _mm256_lzcnt_epi32(a); let e = _mm256_set1_epi32(31); @@ -1099,7 +1124,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_mask_lzcnt_epi32() { + const unsafe fn test_mm256_mask_lzcnt_epi32() { let a = _mm256_set1_epi32(1); let r = _mm256_mask_lzcnt_epi32(a, 0, a); assert_eq_m256i(r, a); @@ -1109,7 +1134,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_maskz_lzcnt_epi32() { + const unsafe fn test_mm256_maskz_lzcnt_epi32() { let a = _mm256_set1_epi32(1); let r = _mm256_maskz_lzcnt_epi32(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -1119,7 +1144,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_lzcnt_epi32() { + const unsafe fn test_mm_lzcnt_epi32() { let a = _mm_set1_epi32(1); let r = _mm_lzcnt_epi32(a); let e = _mm_set1_epi32(31); @@ -1127,7 +1152,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_mask_lzcnt_epi32() { + const unsafe fn test_mm_mask_lzcnt_epi32() { let a = _mm_set1_epi32(1); let r = _mm_mask_lzcnt_epi32(a, 0, a); assert_eq_m128i(r, a); @@ -1137,7 +1162,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_maskz_lzcnt_epi32() { + const unsafe fn test_mm_maskz_lzcnt_epi32() { let a = _mm_set1_epi32(1); let r = _mm_maskz_lzcnt_epi32(0, a); assert_eq_m128i(r, _mm_setzero_si128()); @@ -1147,7 +1172,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_lzcnt_epi64() { + const unsafe fn test_mm512_lzcnt_epi64() { let a = _mm512_set1_epi64(1); let r = _mm512_lzcnt_epi64(a); let e = _mm512_set1_epi64(63); @@ -1155,7 +1180,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_mask_lzcnt_epi64() { + const unsafe fn test_mm512_mask_lzcnt_epi64() { let a = _mm512_set1_epi64(1); let r = _mm512_mask_lzcnt_epi64(a, 0, a); assert_eq_m512i(r, a); @@ -1165,7 +1190,7 @@ mod tests { } #[simd_test(enable = "avx512cd")] - unsafe fn test_mm512_maskz_lzcnt_epi64() { + const unsafe fn test_mm512_maskz_lzcnt_epi64() { let a = _mm512_set1_epi64(2); let r = _mm512_maskz_lzcnt_epi64(0, a); assert_eq_m512i(r, _mm512_setzero_si512()); @@ -1175,7 +1200,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_lzcnt_epi64() { + const unsafe fn test_mm256_lzcnt_epi64() { let a = _mm256_set1_epi64x(1); let r = _mm256_lzcnt_epi64(a); let e = _mm256_set1_epi64x(63); @@ -1183,7 +1208,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_mask_lzcnt_epi64() { + const unsafe fn test_mm256_mask_lzcnt_epi64() { let a = _mm256_set1_epi64x(1); let r = _mm256_mask_lzcnt_epi64(a, 0, a); assert_eq_m256i(r, a); @@ -1193,7 +1218,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm256_maskz_lzcnt_epi64() { + const unsafe fn test_mm256_maskz_lzcnt_epi64() { let a = _mm256_set1_epi64x(1); let r = _mm256_maskz_lzcnt_epi64(0, a); assert_eq_m256i(r, _mm256_setzero_si256()); @@ -1203,7 +1228,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_lzcnt_epi64() { + const unsafe fn test_mm_lzcnt_epi64() { let a = _mm_set1_epi64x(1); let r = _mm_lzcnt_epi64(a); let e = _mm_set1_epi64x(63); @@ -1211,7 +1236,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_mask_lzcnt_epi64() { + const unsafe fn test_mm_mask_lzcnt_epi64() { let a = _mm_set1_epi64x(1); let r = _mm_mask_lzcnt_epi64(a, 0, a); assert_eq_m128i(r, a); @@ -1221,7 +1246,7 @@ mod tests { } #[simd_test(enable = "avx512cd,avx512vl")] - unsafe fn test_mm_maskz_lzcnt_epi64() { + const unsafe fn test_mm_maskz_lzcnt_epi64() { let a = _mm_set1_epi64x(1); let r = _mm_maskz_lzcnt_epi64(0, a); assert_eq_m128i(r, _mm_setzero_si128()); From e7f6d4928b270af4caac73a10293ee85cd7e70a5 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:24:24 +0530 Subject: [PATCH 071/489] Make `avx512dq` functions const --- .../crates/core_arch/src/x86/avx512dq.rs | 874 +++++++++++------- 1 file changed, 536 insertions(+), 338 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512dq.rs b/library/stdarch/crates/core_arch/src/x86/avx512dq.rs index a69168750283..4ab5880c55d0 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512dq.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512dq.rs @@ -15,7 +15,8 @@ use crate::{ #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_and_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_and_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let and = _mm_and_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, and, src.as_f64x2())) @@ -30,7 +31,8 @@ pub fn _mm_mask_and_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_and_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_and_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let and = _mm_and_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, and, f64x2::ZERO)) @@ -46,7 +48,8 @@ pub fn _mm_maskz_and_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_and_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_and_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let and = _mm256_and_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, and, src.as_f64x4())) @@ -61,7 +64,8 @@ pub fn _mm256_mask_and_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_and_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_and_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let and = _mm256_and_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, and, f64x4::ZERO)) @@ -76,7 +80,8 @@ pub fn _mm256_maskz_and_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandp))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_and_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_and_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_and(transmute::<_, u64x8>(a), transmute::<_, u64x8>(b))) } } @@ -89,7 +94,8 @@ pub fn _mm512_and_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_and_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_and_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let and = _mm512_and_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, and, src.as_f64x8())) @@ -104,7 +110,8 @@ pub fn _mm512_mask_and_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_and_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_and_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let and = _mm512_and_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, and, f64x8::ZERO)) @@ -120,7 +127,8 @@ pub fn _mm512_maskz_and_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_and_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_and_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let and = _mm_and_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, and, src.as_f32x4())) @@ -135,7 +143,8 @@ pub fn _mm_mask_and_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_and_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_and_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let and = _mm_and_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, and, f32x4::ZERO)) @@ -151,7 +160,8 @@ pub fn _mm_maskz_and_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_and_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_and_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let and = _mm256_and_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, and, src.as_f32x8())) @@ -166,7 +176,8 @@ pub fn _mm256_mask_and_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_and_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_and_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let and = _mm256_and_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, and, f32x8::ZERO)) @@ -181,7 +192,8 @@ pub fn _mm256_maskz_and_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_and_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_and_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_and( transmute::<_, u32x16>(a), @@ -199,7 +211,8 @@ pub fn _mm512_and_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_and_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_and_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let and = _mm512_and_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, and, src.as_f32x16())) @@ -214,7 +227,8 @@ pub fn _mm512_mask_and_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __ #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_and_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_and_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let and = _mm512_and_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, and, f32x16::ZERO)) @@ -232,7 +246,8 @@ pub fn _mm512_maskz_and_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_andnot_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_andnot_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let andnot = _mm_andnot_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, andnot, src.as_f64x2())) @@ -248,7 +263,8 @@ pub fn _mm_mask_andnot_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_andnot_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_andnot_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let andnot = _mm_andnot_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, andnot, f64x2::ZERO)) @@ -264,7 +280,8 @@ pub fn _mm_maskz_andnot_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_andnot_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_andnot_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let andnot = _mm256_andnot_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, andnot, src.as_f64x4())) @@ -280,7 +297,8 @@ pub fn _mm256_mask_andnot_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_andnot_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_andnot_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let andnot = _mm256_andnot_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, andnot, f64x4::ZERO)) @@ -295,7 +313,8 @@ pub fn _mm256_maskz_andnot_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandnp))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_andnot_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_andnot_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { _mm512_and_pd(_mm512_xor_pd(a, transmute(_mm512_set1_epi64(-1))), b) } } @@ -308,7 +327,8 @@ pub fn _mm512_andnot_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandnpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_andnot_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_andnot_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let andnot = _mm512_andnot_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, andnot, src.as_f64x8())) @@ -324,7 +344,8 @@ pub fn _mm512_mask_andnot_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandnpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_andnot_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_andnot_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let andnot = _mm512_andnot_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, andnot, f64x8::ZERO)) @@ -340,7 +361,8 @@ pub fn _mm512_maskz_andnot_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_andnot_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_andnot_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let andnot = _mm_andnot_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, andnot, src.as_f32x4())) @@ -356,7 +378,8 @@ pub fn _mm_mask_andnot_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_andnot_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_andnot_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let andnot = _mm_andnot_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, andnot, f32x4::ZERO)) @@ -372,7 +395,8 @@ pub fn _mm_maskz_andnot_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_andnot_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_andnot_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let andnot = _mm256_andnot_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, andnot, src.as_f32x8())) @@ -388,7 +412,8 @@ pub fn _mm256_mask_andnot_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_andnot_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_andnot_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let andnot = _mm256_andnot_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, andnot, f32x8::ZERO)) @@ -403,7 +428,8 @@ pub fn _mm256_maskz_andnot_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_andnot_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_andnot_ps(a: __m512, b: __m512) -> __m512 { unsafe { _mm512_and_ps(_mm512_xor_ps(a, transmute(_mm512_set1_epi32(-1))), b) } } @@ -416,7 +442,8 @@ pub fn _mm512_andnot_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_andnot_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_andnot_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let andnot = _mm512_andnot_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, andnot, src.as_f32x16())) @@ -432,7 +459,8 @@ pub fn _mm512_mask_andnot_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vandnps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_andnot_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_andnot_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let andnot = _mm512_andnot_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, andnot, f32x16::ZERO)) @@ -450,7 +478,8 @@ pub fn _mm512_maskz_andnot_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_or_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_or_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let or = _mm_or_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, or, src.as_f64x2())) @@ -465,7 +494,8 @@ pub fn _mm_mask_or_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m1 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_or_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_or_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let or = _mm_or_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, or, f64x2::ZERO)) @@ -481,7 +511,8 @@ pub fn _mm_maskz_or_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_or_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_or_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let or = _mm256_or_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, or, src.as_f64x4())) @@ -496,7 +527,8 @@ pub fn _mm256_mask_or_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> _ #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_or_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_or_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let or = _mm256_or_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, or, f64x4::ZERO)) @@ -511,7 +543,8 @@ pub fn _mm256_maskz_or_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vorp))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_or_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_or_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_or(transmute::<_, u64x8>(a), transmute::<_, u64x8>(b))) } } @@ -524,7 +557,8 @@ pub fn _mm512_or_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_or_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_or_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let or = _mm512_or_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, or, src.as_f64x8())) @@ -539,7 +573,8 @@ pub fn _mm512_mask_or_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> _ #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_or_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_or_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let or = _mm512_or_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, or, f64x8::ZERO)) @@ -555,7 +590,8 @@ pub fn _mm512_maskz_or_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_or_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_or_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let or = _mm_or_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, or, src.as_f32x4())) @@ -570,7 +606,8 @@ pub fn _mm_mask_or_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_or_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_or_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let or = _mm_or_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, or, f32x4::ZERO)) @@ -586,7 +623,8 @@ pub fn _mm_maskz_or_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_or_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_or_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let or = _mm256_or_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, or, src.as_f32x8())) @@ -601,7 +639,8 @@ pub fn _mm256_mask_or_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m2 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_or_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_or_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let or = _mm256_or_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, or, f32x8::ZERO)) @@ -616,7 +655,8 @@ pub fn _mm256_maskz_or_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_or_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_or_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_or( transmute::<_, u32x16>(a), @@ -634,7 +674,8 @@ pub fn _mm512_or_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_or_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_or_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let or = _mm512_or_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, or, src.as_f32x16())) @@ -649,7 +690,8 @@ pub fn _mm512_mask_or_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_or_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_or_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let or = _mm512_or_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, or, f32x16::ZERO)) @@ -667,7 +709,8 @@ pub fn _mm512_maskz_or_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_xor_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_xor_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let xor = _mm_xor_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, xor, src.as_f64x2())) @@ -682,7 +725,8 @@ pub fn _mm_mask_xor_pd(src: __m128d, k: __mmask8, a: __m128d, b: __m128d) -> __m #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_xor_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_xor_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { unsafe { let xor = _mm_xor_pd(a, b).as_f64x2(); transmute(simd_select_bitmask(k, xor, f64x2::ZERO)) @@ -698,7 +742,8 @@ pub fn _mm_maskz_xor_pd(k: __mmask8, a: __m128d, b: __m128d) -> __m128d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_xor_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_xor_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let xor = _mm256_xor_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, xor, src.as_f64x4())) @@ -713,7 +758,8 @@ pub fn _mm256_mask_xor_pd(src: __m256d, k: __mmask8, a: __m256d, b: __m256d) -> #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_xor_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_xor_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { unsafe { let xor = _mm256_xor_pd(a, b).as_f64x4(); transmute(simd_select_bitmask(k, xor, f64x4::ZERO)) @@ -728,7 +774,8 @@ pub fn _mm256_maskz_xor_pd(k: __mmask8, a: __m256d, b: __m256d) -> __m256d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vxorp))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_xor_pd(a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_xor_pd(a: __m512d, b: __m512d) -> __m512d { unsafe { transmute(simd_xor(transmute::<_, u64x8>(a), transmute::<_, u64x8>(b))) } } @@ -741,7 +788,8 @@ pub fn _mm512_xor_pd(a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vxorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_xor_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_xor_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let xor = _mm512_xor_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, xor, src.as_f64x8())) @@ -756,7 +804,8 @@ pub fn _mm512_mask_xor_pd(src: __m512d, k: __mmask8, a: __m512d, b: __m512d) -> #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vxorpd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_xor_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_xor_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { unsafe { let xor = _mm512_xor_pd(a, b).as_f64x8(); transmute(simd_select_bitmask(k, xor, f64x8::ZERO)) @@ -772,7 +821,8 @@ pub fn _mm512_maskz_xor_pd(k: __mmask8, a: __m512d, b: __m512d) -> __m512d { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_xor_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_xor_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let xor = _mm_xor_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, xor, src.as_f32x4())) @@ -787,7 +837,8 @@ pub fn _mm_mask_xor_ps(src: __m128, k: __mmask8, a: __m128, b: __m128) -> __m128 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_xor_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_xor_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { unsafe { let xor = _mm_xor_ps(a, b).as_f32x4(); transmute(simd_select_bitmask(k, xor, f32x4::ZERO)) @@ -803,7 +854,8 @@ pub fn _mm_maskz_xor_ps(k: __mmask8, a: __m128, b: __m128) -> __m128 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_xor_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_xor_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let xor = _mm256_xor_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, xor, src.as_f32x8())) @@ -818,7 +870,8 @@ pub fn _mm256_mask_xor_ps(src: __m256, k: __mmask8, a: __m256, b: __m256) -> __m #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_xor_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_xor_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { unsafe { let xor = _mm256_xor_ps(a, b).as_f32x8(); transmute(simd_select_bitmask(k, xor, f32x8::ZERO)) @@ -833,7 +886,8 @@ pub fn _mm256_maskz_xor_ps(k: __mmask8, a: __m256, b: __m256) -> __m256 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_xor_ps(a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_xor_ps(a: __m512, b: __m512) -> __m512 { unsafe { transmute(simd_xor( transmute::<_, u32x16>(a), @@ -851,7 +905,8 @@ pub fn _mm512_xor_ps(a: __m512, b: __m512) -> __m512 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_xor_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_xor_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let xor = _mm512_xor_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, xor, src.as_f32x16())) @@ -866,7 +921,8 @@ pub fn _mm512_mask_xor_ps(src: __m512, k: __mmask16, a: __m512, b: __m512) -> __ #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vxorps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_xor_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_xor_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { unsafe { let xor = _mm512_xor_ps(a, b).as_f32x16(); transmute(simd_select_bitmask(k, xor, f32x16::ZERO)) @@ -882,7 +938,8 @@ pub fn _mm512_maskz_xor_ps(k: __mmask16, a: __m512, b: __m512) -> __m512 { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_broadcast_f32x2(a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_f32x2(a: __m128) -> __m256 { unsafe { let b: f32x8 = simd_shuffle!(a, a, [0, 1, 0, 1, 0, 1, 0, 1]); transmute(b) @@ -897,7 +954,8 @@ pub fn _mm256_broadcast_f32x2(a: __m128) -> __m256 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vbroadcastf32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_broadcast_f32x2(src: __m256, k: __mmask8, a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcast_f32x2(src: __m256, k: __mmask8, a: __m128) -> __m256 { unsafe { let b = _mm256_broadcast_f32x2(a).as_f32x8(); transmute(simd_select_bitmask(k, b, src.as_f32x8())) @@ -912,7 +970,8 @@ pub fn _mm256_mask_broadcast_f32x2(src: __m256, k: __mmask8, a: __m128) -> __m25 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vbroadcastf32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_broadcast_f32x2(k: __mmask8, a: __m128) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcast_f32x2(k: __mmask8, a: __m128) -> __m256 { unsafe { let b = _mm256_broadcast_f32x2(a).as_f32x8(); transmute(simd_select_bitmask(k, b, f32x8::ZERO)) @@ -926,7 +985,8 @@ pub fn _mm256_maskz_broadcast_f32x2(k: __mmask8, a: __m128) -> __m256 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_f32x2(a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_f32x2(a: __m128) -> __m512 { unsafe { let b: f32x16 = simd_shuffle!(a, a, [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]); transmute(b) @@ -941,7 +1001,8 @@ pub fn _mm512_broadcast_f32x2(a: __m128) -> __m512 { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vbroadcastf32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_f32x2(src: __m512, k: __mmask16, a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_f32x2(src: __m512, k: __mmask16, a: __m128) -> __m512 { unsafe { let b = _mm512_broadcast_f32x2(a).as_f32x16(); transmute(simd_select_bitmask(k, b, src.as_f32x16())) @@ -956,7 +1017,8 @@ pub fn _mm512_mask_broadcast_f32x2(src: __m512, k: __mmask16, a: __m128) -> __m5 #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vbroadcastf32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_f32x2(k: __mmask16, a: __m128) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_f32x2(k: __mmask16, a: __m128) -> __m512 { unsafe { let b = _mm512_broadcast_f32x2(a).as_f32x16(); transmute(simd_select_bitmask(k, b, f32x16::ZERO)) @@ -970,7 +1032,8 @@ pub fn _mm512_maskz_broadcast_f32x2(k: __mmask16, a: __m128) -> __m512 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_f32x8(a: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_f32x8(a: __m256) -> __m512 { unsafe { let b: f32x16 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]); transmute(b) @@ -984,7 +1047,8 @@ pub fn _mm512_broadcast_f32x8(a: __m256) -> __m512 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_f32x8(src: __m512, k: __mmask16, a: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_f32x8(src: __m512, k: __mmask16, a: __m256) -> __m512 { unsafe { let b = _mm512_broadcast_f32x8(a).as_f32x16(); transmute(simd_select_bitmask(k, b, src.as_f32x16())) @@ -998,7 +1062,8 @@ pub fn _mm512_mask_broadcast_f32x8(src: __m512, k: __mmask16, a: __m256) -> __m5 #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_f32x8(k: __mmask16, a: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_f32x8(k: __mmask16, a: __m256) -> __m512 { unsafe { let b = _mm512_broadcast_f32x8(a).as_f32x16(); transmute(simd_select_bitmask(k, b, f32x16::ZERO)) @@ -1012,7 +1077,8 @@ pub fn _mm512_maskz_broadcast_f32x8(k: __mmask16, a: __m256) -> __m512 { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_broadcast_f64x2(a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_f64x2(a: __m128d) -> __m256d { unsafe { let b: f64x4 = simd_shuffle!(a, a, [0, 1, 0, 1]); transmute(b) @@ -1026,7 +1092,8 @@ pub fn _mm256_broadcast_f64x2(a: __m128d) -> __m256d { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_broadcast_f64x2(src: __m256d, k: __mmask8, a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcast_f64x2(src: __m256d, k: __mmask8, a: __m128d) -> __m256d { unsafe { let b = _mm256_broadcast_f64x2(a).as_f64x4(); transmute(simd_select_bitmask(k, b, src.as_f64x4())) @@ -1040,7 +1107,8 @@ pub fn _mm256_mask_broadcast_f64x2(src: __m256d, k: __mmask8, a: __m128d) -> __m #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_broadcast_f64x2(k: __mmask8, a: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcast_f64x2(k: __mmask8, a: __m128d) -> __m256d { unsafe { let b = _mm256_broadcast_f64x2(a).as_f64x4(); transmute(simd_select_bitmask(k, b, f64x4::ZERO)) @@ -1054,7 +1122,8 @@ pub fn _mm256_maskz_broadcast_f64x2(k: __mmask8, a: __m128d) -> __m256d { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_f64x2(a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_f64x2(a: __m128d) -> __m512d { unsafe { let b: f64x8 = simd_shuffle!(a, a, [0, 1, 0, 1, 0, 1, 0, 1]); transmute(b) @@ -1068,7 +1137,8 @@ pub fn _mm512_broadcast_f64x2(a: __m128d) -> __m512d { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_f64x2(src: __m512d, k: __mmask8, a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_f64x2(src: __m512d, k: __mmask8, a: __m128d) -> __m512d { unsafe { let b = _mm512_broadcast_f64x2(a).as_f64x8(); transmute(simd_select_bitmask(k, b, src.as_f64x8())) @@ -1082,7 +1152,8 @@ pub fn _mm512_mask_broadcast_f64x2(src: __m512d, k: __mmask8, a: __m128d) -> __m #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_f64x2(k: __mmask8, a: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_f64x2(k: __mmask8, a: __m128d) -> __m512d { unsafe { let b = _mm512_broadcast_f64x2(a).as_f64x8(); transmute(simd_select_bitmask(k, b, f64x8::ZERO)) @@ -1095,7 +1166,8 @@ pub fn _mm512_maskz_broadcast_f64x2(k: __mmask8, a: __m128d) -> __m512d { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_broadcast_i32x2(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_broadcast_i32x2(a: __m128i) -> __m128i { unsafe { let a = a.as_i32x4(); let b: i32x4 = simd_shuffle!(a, a, [0, 1, 0, 1]); @@ -1111,7 +1183,8 @@ pub fn _mm_broadcast_i32x2(a: __m128i) -> __m128i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vbroadcasti32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_broadcast_i32x2(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_broadcast_i32x2(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { let b = _mm_broadcast_i32x2(a).as_i32x4(); transmute(simd_select_bitmask(k, b, src.as_i32x4())) @@ -1126,7 +1199,8 @@ pub fn _mm_mask_broadcast_i32x2(src: __m128i, k: __mmask8, a: __m128i) -> __m128 #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vbroadcasti32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_broadcast_i32x2(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_broadcast_i32x2(k: __mmask8, a: __m128i) -> __m128i { unsafe { let b = _mm_broadcast_i32x2(a).as_i32x4(); transmute(simd_select_bitmask(k, b, i32x4::ZERO)) @@ -1139,7 +1213,8 @@ pub fn _mm_maskz_broadcast_i32x2(k: __mmask8, a: __m128i) -> __m128i { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_broadcast_i32x2(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_i32x2(a: __m128i) -> __m256i { unsafe { let a = a.as_i32x4(); let b: i32x8 = simd_shuffle!(a, a, [0, 1, 0, 1, 0, 1, 0, 1]); @@ -1155,7 +1230,8 @@ pub fn _mm256_broadcast_i32x2(a: __m128i) -> __m256i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vbroadcasti32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_broadcast_i32x2(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcast_i32x2(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let b = _mm256_broadcast_i32x2(a).as_i32x8(); transmute(simd_select_bitmask(k, b, src.as_i32x8())) @@ -1170,7 +1246,8 @@ pub fn _mm256_mask_broadcast_i32x2(src: __m256i, k: __mmask8, a: __m128i) -> __m #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vbroadcasti32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_broadcast_i32x2(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcast_i32x2(k: __mmask8, a: __m128i) -> __m256i { unsafe { let b = _mm256_broadcast_i32x2(a).as_i32x8(); transmute(simd_select_bitmask(k, b, i32x8::ZERO)) @@ -1183,7 +1260,8 @@ pub fn _mm256_maskz_broadcast_i32x2(k: __mmask8, a: __m128i) -> __m256i { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_i32x2(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_i32x2(a: __m128i) -> __m512i { unsafe { let a = a.as_i32x4(); let b: i32x16 = simd_shuffle!(a, a, [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]); @@ -1199,7 +1277,8 @@ pub fn _mm512_broadcast_i32x2(a: __m128i) -> __m512i { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vbroadcasti32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_i32x2(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_i32x2(src: __m512i, k: __mmask16, a: __m128i) -> __m512i { unsafe { let b = _mm512_broadcast_i32x2(a).as_i32x16(); transmute(simd_select_bitmask(k, b, src.as_i32x16())) @@ -1214,7 +1293,8 @@ pub fn _mm512_mask_broadcast_i32x2(src: __m512i, k: __mmask16, a: __m128i) -> __ #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vbroadcasti32x2))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_i32x2(k: __mmask16, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_i32x2(k: __mmask16, a: __m128i) -> __m512i { unsafe { let b = _mm512_broadcast_i32x2(a).as_i32x16(); transmute(simd_select_bitmask(k, b, i32x16::ZERO)) @@ -1227,7 +1307,8 @@ pub fn _mm512_maskz_broadcast_i32x2(k: __mmask16, a: __m128i) -> __m512i { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_i32x8(a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_i32x8(a: __m256i) -> __m512i { unsafe { let a = a.as_i32x8(); let b: i32x16 = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]); @@ -1242,7 +1323,8 @@ pub fn _mm512_broadcast_i32x8(a: __m256i) -> __m512i { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_i32x8(src: __m512i, k: __mmask16, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_i32x8(src: __m512i, k: __mmask16, a: __m256i) -> __m512i { unsafe { let b = _mm512_broadcast_i32x8(a).as_i32x16(); transmute(simd_select_bitmask(k, b, src.as_i32x16())) @@ -1256,7 +1338,8 @@ pub fn _mm512_mask_broadcast_i32x8(src: __m512i, k: __mmask16, a: __m256i) -> __ #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_i32x8(k: __mmask16, a: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_i32x8(k: __mmask16, a: __m256i) -> __m512i { unsafe { let b = _mm512_broadcast_i32x8(a).as_i32x16(); transmute(simd_select_bitmask(k, b, i32x16::ZERO)) @@ -1269,7 +1352,8 @@ pub fn _mm512_maskz_broadcast_i32x8(k: __mmask16, a: __m256i) -> __m512i { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_broadcast_i64x2(a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_broadcast_i64x2(a: __m128i) -> __m256i { unsafe { let a = a.as_i64x2(); let b: i64x4 = simd_shuffle!(a, a, [0, 1, 0, 1]); @@ -1284,7 +1368,8 @@ pub fn _mm256_broadcast_i64x2(a: __m128i) -> __m256i { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_broadcast_i64x2(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_broadcast_i64x2(src: __m256i, k: __mmask8, a: __m128i) -> __m256i { unsafe { let b = _mm256_broadcast_i64x2(a).as_i64x4(); transmute(simd_select_bitmask(k, b, src.as_i64x4())) @@ -1298,7 +1383,8 @@ pub fn _mm256_mask_broadcast_i64x2(src: __m256i, k: __mmask8, a: __m128i) -> __m #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_broadcast_i64x2(k: __mmask8, a: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_broadcast_i64x2(k: __mmask8, a: __m128i) -> __m256i { unsafe { let b = _mm256_broadcast_i64x2(a).as_i64x4(); transmute(simd_select_bitmask(k, b, i64x4::ZERO)) @@ -1311,7 +1397,8 @@ pub fn _mm256_maskz_broadcast_i64x2(k: __mmask8, a: __m128i) -> __m256i { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_broadcast_i64x2(a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_broadcast_i64x2(a: __m128i) -> __m512i { unsafe { let a = a.as_i64x2(); let b: i64x8 = simd_shuffle!(a, a, [0, 1, 0, 1, 0, 1, 0, 1]); @@ -1326,7 +1413,8 @@ pub fn _mm512_broadcast_i64x2(a: __m128i) -> __m512i { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_broadcast_i64x2(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_broadcast_i64x2(src: __m512i, k: __mmask8, a: __m128i) -> __m512i { unsafe { let b = _mm512_broadcast_i64x2(a).as_i64x8(); transmute(simd_select_bitmask(k, b, src.as_i64x8())) @@ -1340,7 +1428,8 @@ pub fn _mm512_mask_broadcast_i64x2(src: __m512i, k: __mmask8, a: __m128i) -> __m #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_broadcast_i64x2(k: __mmask8, a: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_broadcast_i64x2(k: __mmask8, a: __m128i) -> __m512i { unsafe { let b = _mm512_broadcast_i64x2(a).as_i64x8(); transmute(simd_select_bitmask(k, b, i64x8::ZERO)) @@ -1357,7 +1446,8 @@ pub fn _mm512_maskz_broadcast_i64x2(k: __mmask8, a: __m128i) -> __m512i { #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_extractf32x8_ps(a: __m512) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extractf32x8_ps(a: __m512) -> __m256 { unsafe { static_assert_uimm_bits!(IMM8, 1); match IMM8 & 1 { @@ -1377,7 +1467,12 @@ pub fn _mm512_extractf32x8_ps(a: __m512) -> __m256 { #[cfg_attr(test, assert_instr(vextractf32x8, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_extractf32x8_ps(src: __m256, k: __mmask8, a: __m512) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extractf32x8_ps( + src: __m256, + k: __mmask8, + a: __m512, +) -> __m256 { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm512_extractf32x8_ps::(a); @@ -1395,7 +1490,8 @@ pub fn _mm512_mask_extractf32x8_ps(src: __m256, k: __mmask8, a: #[cfg_attr(test, assert_instr(vextractf32x8, IMM8 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_extractf32x8_ps(k: __mmask8, a: __m512) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extractf32x8_ps(k: __mmask8, a: __m512) -> __m256 { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm512_extractf32x8_ps::(a); @@ -1411,7 +1507,8 @@ pub fn _mm512_maskz_extractf32x8_ps(k: __mmask8, a: __m512) -> #[target_feature(enable = "avx512dq,avx512vl")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_extractf64x2_pd(a: __m256d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extractf64x2_pd(a: __m256d) -> __m128d { unsafe { static_assert_uimm_bits!(IMM8, 1); match IMM8 & 1 { @@ -1431,7 +1528,8 @@ pub fn _mm256_extractf64x2_pd(a: __m256d) -> __m128d { #[cfg_attr(test, assert_instr(vextractf64x2, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_extractf64x2_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_extractf64x2_pd( src: __m128d, k: __mmask8, a: __m256d, @@ -1453,7 +1551,8 @@ pub fn _mm256_mask_extractf64x2_pd( #[cfg_attr(test, assert_instr(vextractf64x2, IMM8 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_extractf64x2_pd(k: __mmask8, a: __m256d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_extractf64x2_pd(k: __mmask8, a: __m256d) -> __m128d { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm256_extractf64x2_pd::(a); @@ -1469,7 +1568,8 @@ pub fn _mm256_maskz_extractf64x2_pd(k: __mmask8, a: __m256d) -> #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_extractf64x2_pd(a: __m512d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extractf64x2_pd(a: __m512d) -> __m128d { unsafe { static_assert_uimm_bits!(IMM8, 2); match IMM8 & 3 { @@ -1491,7 +1591,8 @@ pub fn _mm512_extractf64x2_pd(a: __m512d) -> __m128d { #[cfg_attr(test, assert_instr(vextractf64x2, IMM8 = 3))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_extractf64x2_pd( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extractf64x2_pd( src: __m128d, k: __mmask8, a: __m512d, @@ -1513,7 +1614,8 @@ pub fn _mm512_mask_extractf64x2_pd( #[cfg_attr(test, assert_instr(vextractf64x2, IMM8 = 3))] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_extractf64x2_pd(k: __mmask8, a: __m512d) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extractf64x2_pd(k: __mmask8, a: __m512d) -> __m128d { unsafe { static_assert_uimm_bits!(IMM8, 2); let b = _mm512_extractf64x2_pd::(a).as_f64x2(); @@ -1529,7 +1631,8 @@ pub fn _mm512_maskz_extractf64x2_pd(k: __mmask8, a: __m512d) -> #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_extracti32x8_epi32(a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extracti32x8_epi32(a: __m512i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 1); let a = a.as_i32x16(); @@ -1550,7 +1653,8 @@ pub fn _mm512_extracti32x8_epi32(a: __m512i) -> __m256i { #[cfg_attr(test, assert_instr(vextracti32x8, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_extracti32x8_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extracti32x8_epi32( src: __m256i, k: __mmask8, a: __m512i, @@ -1571,7 +1675,8 @@ pub fn _mm512_mask_extracti32x8_epi32( #[cfg_attr(test, assert_instr(vextracti32x8, IMM8 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_extracti32x8_epi32(k: __mmask8, a: __m512i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extracti32x8_epi32(k: __mmask8, a: __m512i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm512_extracti32x8_epi32::(a).as_i32x8(); @@ -1587,7 +1692,8 @@ pub fn _mm512_maskz_extracti32x8_epi32(k: __mmask8, a: __m512i) #[target_feature(enable = "avx512dq,avx512vl")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_extracti64x2_epi64(a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_extracti64x2_epi64(a: __m256i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 1); let a = a.as_i64x4(); @@ -1607,7 +1713,8 @@ pub fn _mm256_extracti64x2_epi64(a: __m256i) -> __m128i { #[cfg_attr(test, assert_instr(vextracti64x2, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_extracti64x2_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_extracti64x2_epi64( src: __m128i, k: __mmask8, a: __m256i, @@ -1628,7 +1735,8 @@ pub fn _mm256_mask_extracti64x2_epi64( #[cfg_attr(test, assert_instr(vextracti64x2, IMM8 = 1))] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_extracti64x2_epi64(k: __mmask8, a: __m256i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_extracti64x2_epi64(k: __mmask8, a: __m256i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm256_extracti64x2_epi64::(a).as_i64x2(); @@ -1644,7 +1752,8 @@ pub fn _mm256_maskz_extracti64x2_epi64(k: __mmask8, a: __m256i) #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_extracti64x2_epi64(a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_extracti64x2_epi64(a: __m512i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 2); let a = a.as_i64x8(); @@ -1666,7 +1775,8 @@ pub fn _mm512_extracti64x2_epi64(a: __m512i) -> __m128i { #[cfg_attr(test, assert_instr(vextracti64x2, IMM8 = 3))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_extracti64x2_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_extracti64x2_epi64( src: __m128i, k: __mmask8, a: __m512i, @@ -1687,7 +1797,8 @@ pub fn _mm512_mask_extracti64x2_epi64( #[cfg_attr(test, assert_instr(vextracti64x2, IMM8 = 3))] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_extracti64x2_epi64(k: __mmask8, a: __m512i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_extracti64x2_epi64(k: __mmask8, a: __m512i) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 2); let b = _mm512_extracti64x2_epi64::(a).as_i64x2(); @@ -1705,7 +1816,8 @@ pub fn _mm512_maskz_extracti64x2_epi64(k: __mmask8, a: __m512i) #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_insertf32x8(a: __m512, b: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_insertf32x8(a: __m512, b: __m256) -> __m512 { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm512_castps256_ps512(b); @@ -1738,7 +1850,8 @@ pub fn _mm512_insertf32x8(a: __m512, b: __m256) -> __m512 { #[cfg_attr(test, assert_instr(vinsertf32x8, IMM8 = 1))] #[rustc_legacy_const_generics(4)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_insertf32x8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_insertf32x8( src: __m512, k: __mmask16, a: __m512, @@ -1761,7 +1874,12 @@ pub fn _mm512_mask_insertf32x8( #[cfg_attr(test, assert_instr(vinsertf32x8, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_insertf32x8(k: __mmask16, a: __m512, b: __m256) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_insertf32x8( + k: __mmask16, + a: __m512, + b: __m256, +) -> __m512 { unsafe { static_assert_uimm_bits!(IMM8, 1); let c = _mm512_insertf32x8::(a, b).as_f32x16(); @@ -1777,7 +1895,8 @@ pub fn _mm512_maskz_insertf32x8(k: __mmask16, a: __m512, b: __m #[target_feature(enable = "avx512dq,avx512vl")] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_insertf64x2(a: __m256d, b: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_insertf64x2(a: __m256d, b: __m128d) -> __m256d { unsafe { static_assert_uimm_bits!(IMM8, 1); let b = _mm256_castpd128_pd256(b); @@ -1798,7 +1917,8 @@ pub fn _mm256_insertf64x2(a: __m256d, b: __m128d) -> __m256d { #[cfg_attr(test, assert_instr(vinsertf64x2, IMM8 = 1))] #[rustc_legacy_const_generics(4)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_insertf64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_insertf64x2( src: __m256d, k: __mmask8, a: __m256d, @@ -1821,7 +1941,12 @@ pub fn _mm256_mask_insertf64x2( #[cfg_attr(test, assert_instr(vinsertf64x2, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_insertf64x2(k: __mmask8, a: __m256d, b: __m128d) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_insertf64x2( + k: __mmask8, + a: __m256d, + b: __m128d, +) -> __m256d { unsafe { static_assert_uimm_bits!(IMM8, 1); let c = _mm256_insertf64x2::(a, b).as_f64x4(); @@ -1837,7 +1962,8 @@ pub fn _mm256_maskz_insertf64x2(k: __mmask8, a: __m256d, b: __m #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_insertf64x2(a: __m512d, b: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_insertf64x2(a: __m512d, b: __m128d) -> __m512d { unsafe { static_assert_uimm_bits!(IMM8, 2); let b = _mm512_castpd128_pd512(b); @@ -1860,7 +1986,8 @@ pub fn _mm512_insertf64x2(a: __m512d, b: __m128d) -> __m512d { #[cfg_attr(test, assert_instr(vinsertf64x2, IMM8 = 3))] #[rustc_legacy_const_generics(4)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_insertf64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_insertf64x2( src: __m512d, k: __mmask8, a: __m512d, @@ -1883,7 +2010,12 @@ pub fn _mm512_mask_insertf64x2( #[cfg_attr(test, assert_instr(vinsertf64x2, IMM8 = 3))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_insertf64x2(k: __mmask8, a: __m512d, b: __m128d) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_insertf64x2( + k: __mmask8, + a: __m512d, + b: __m128d, +) -> __m512d { unsafe { static_assert_uimm_bits!(IMM8, 2); let c = _mm512_insertf64x2::(a, b).as_f64x8(); @@ -1899,7 +2031,8 @@ pub fn _mm512_maskz_insertf64x2(k: __mmask8, a: __m512d, b: __m #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_inserti32x8(a: __m512i, b: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_inserti32x8(a: __m512i, b: __m256i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 1); let a = a.as_i32x16(); @@ -1934,7 +2067,8 @@ pub fn _mm512_inserti32x8(a: __m512i, b: __m256i) -> __m512i { #[cfg_attr(test, assert_instr(vinserti32x8, IMM8 = 1))] #[rustc_legacy_const_generics(4)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_inserti32x8( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_inserti32x8( src: __m512i, k: __mmask16, a: __m512i, @@ -1957,7 +2091,12 @@ pub fn _mm512_mask_inserti32x8( #[cfg_attr(test, assert_instr(vinserti32x8, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_inserti32x8(k: __mmask16, a: __m512i, b: __m256i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_inserti32x8( + k: __mmask16, + a: __m512i, + b: __m256i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 1); let c = _mm512_inserti32x8::(a, b).as_i32x16(); @@ -1973,7 +2112,8 @@ pub fn _mm512_maskz_inserti32x8(k: __mmask16, a: __m512i, b: __ #[target_feature(enable = "avx512dq,avx512vl")] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_inserti64x2(a: __m256i, b: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_inserti64x2(a: __m256i, b: __m128i) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 1); let a = a.as_i64x4(); @@ -1995,7 +2135,8 @@ pub fn _mm256_inserti64x2(a: __m256i, b: __m128i) -> __m256i { #[cfg_attr(test, assert_instr(vinserti64x2, IMM8 = 1))] #[rustc_legacy_const_generics(4)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_inserti64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_inserti64x2( src: __m256i, k: __mmask8, a: __m256i, @@ -2018,7 +2159,12 @@ pub fn _mm256_mask_inserti64x2( #[cfg_attr(test, assert_instr(vinserti64x2, IMM8 = 1))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_inserti64x2(k: __mmask8, a: __m256i, b: __m128i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_inserti64x2( + k: __mmask8, + a: __m256i, + b: __m128i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 1); let c = _mm256_inserti64x2::(a, b).as_i64x4(); @@ -2034,7 +2180,8 @@ pub fn _mm256_maskz_inserti64x2(k: __mmask8, a: __m256i, b: __m #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(2)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_inserti64x2(a: __m512i, b: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_inserti64x2(a: __m512i, b: __m128i) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 2); let a = a.as_i64x8(); @@ -2058,7 +2205,8 @@ pub fn _mm512_inserti64x2(a: __m512i, b: __m128i) -> __m512i { #[cfg_attr(test, assert_instr(vinserti64x2, IMM8 = 3))] #[rustc_legacy_const_generics(4)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_inserti64x2( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_inserti64x2( src: __m512i, k: __mmask8, a: __m512i, @@ -2081,7 +2229,12 @@ pub fn _mm512_mask_inserti64x2( #[cfg_attr(test, assert_instr(vinserti64x2, IMM8 = 3))] #[rustc_legacy_const_generics(3)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_inserti64x2(k: __mmask8, a: __m512i, b: __m128i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_inserti64x2( + k: __mmask8, + a: __m512i, + b: __m128i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 2); let c = _mm512_inserti64x2::(a, b).as_i64x8(); @@ -4333,7 +4486,8 @@ pub fn _mm512_maskz_cvttps_epu64(k: __mmask8, a: __m256) -> __m512i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mullo_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mullo_epi64(a: __m128i, b: __m128i) -> __m128i { unsafe { transmute(simd_mul(a.as_i64x2(), b.as_i64x2())) } } @@ -4346,7 +4500,8 @@ pub fn _mm_mullo_epi64(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_mask_mullo_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mullo_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let b = _mm_mullo_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, b, src.as_i64x2())) @@ -4362,7 +4517,8 @@ pub fn _mm_mask_mullo_epi64(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) - #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_maskz_mullo_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mullo_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let b = _mm_mullo_epi64(a, b).as_i64x2(); transmute(simd_select_bitmask(k, b, i64x2::ZERO)) @@ -4377,7 +4533,8 @@ pub fn _mm_maskz_mullo_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mullo_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mullo_epi64(a: __m256i, b: __m256i) -> __m256i { unsafe { transmute(simd_mul(a.as_i64x4(), b.as_i64x4())) } } @@ -4390,7 +4547,8 @@ pub fn _mm256_mullo_epi64(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_mask_mullo_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mullo_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let b = _mm256_mullo_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, b, src.as_i64x4())) @@ -4406,7 +4564,8 @@ pub fn _mm256_mask_mullo_epi64(src: __m256i, k: __mmask8, a: __m256i, b: __m256i #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_maskz_mullo_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mullo_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { unsafe { let b = _mm256_mullo_epi64(a, b).as_i64x4(); transmute(simd_select_bitmask(k, b, i64x4::ZERO)) @@ -4421,7 +4580,8 @@ pub fn _mm256_maskz_mullo_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mullo_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mullo_epi64(a: __m512i, b: __m512i) -> __m512i { unsafe { transmute(simd_mul(a.as_i64x8(), b.as_i64x8())) } } @@ -4434,7 +4594,8 @@ pub fn _mm512_mullo_epi64(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_mask_mullo_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mullo_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let b = _mm512_mullo_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, b, src.as_i64x8())) @@ -4450,7 +4611,8 @@ pub fn _mm512_mask_mullo_epi64(src: __m512i, k: __mmask8, a: __m512i, b: __m512i #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vpmullq))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_maskz_mullo_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mullo_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { unsafe { let b = _mm512_mullo_epi64(a, b).as_i64x8(); transmute(simd_select_bitmask(k, b, i64x8::ZERO)) @@ -4465,7 +4627,8 @@ pub fn _mm512_maskz_mullo_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtmask8_u32(a: __mmask8) -> u32 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtmask8_u32(a: __mmask8) -> u32 { a as u32 } @@ -4475,7 +4638,8 @@ pub fn _cvtmask8_u32(a: __mmask8) -> u32 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _cvtu32_mask8(a: u32) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _cvtu32_mask8(a: u32) -> __mmask8 { a as __mmask8 } @@ -4485,7 +4649,8 @@ pub fn _cvtu32_mask8(a: u32) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kadd_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kadd_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { a.wrapping_add(b) } @@ -4495,7 +4660,8 @@ pub fn _kadd_mask16(a: __mmask16, b: __mmask16) -> __mmask16 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kadd_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kadd_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { a.wrapping_add(b) } @@ -4505,7 +4671,8 @@ pub fn _kadd_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kand_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kand_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { a & b } @@ -4515,7 +4682,8 @@ pub fn _kand_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kandn_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kandn_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { _knot_mask8(a) & b } @@ -4525,7 +4693,8 @@ pub fn _kandn_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _knot_mask8(a: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _knot_mask8(a: __mmask8) -> __mmask8 { a ^ 0b11111111 } @@ -4535,7 +4704,8 @@ pub fn _knot_mask8(a: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { a | b } @@ -4545,7 +4715,8 @@ pub fn _kor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kxnor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxnor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { _knot_mask8(_kxor_mask8(a, b)) } @@ -4555,7 +4726,8 @@ pub fn _kxnor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kxor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kxor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { a ^ b } @@ -4566,7 +4738,8 @@ pub fn _kxor_mask8(a: __mmask8, b: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _kortest_mask8_u8(a: __mmask8, b: __mmask8, all_ones: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _kortest_mask8_u8(a: __mmask8, b: __mmask8, all_ones: *mut u8) -> u8 { let tmp = _kor_mask8(a, b); *all_ones = (tmp == 0xff) as u8; (tmp == 0) as u8 @@ -4579,7 +4752,8 @@ pub unsafe fn _kortest_mask8_u8(a: __mmask8, b: __mmask8, all_ones: *mut u8) -> #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestc_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestc_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { (_kor_mask8(a, b) == 0xff) as u8 } @@ -4590,7 +4764,8 @@ pub fn _kortestc_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kortestz_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kortestz_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { (_kor_mask8(a, b) == 0) as u8 } @@ -4601,7 +4776,8 @@ pub fn _kortestz_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftli_mask8(a: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftli_mask8(a: __mmask8) -> __mmask8 { a.unbounded_shl(COUNT) } @@ -4612,7 +4788,8 @@ pub fn _kshiftli_mask8(a: __mmask8) -> __mmask8 { #[target_feature(enable = "avx512dq")] #[rustc_legacy_const_generics(1)] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _kshiftri_mask8(a: __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _kshiftri_mask8(a: __mmask8) -> __mmask8 { a.unbounded_shr(COUNT) } @@ -4624,7 +4801,8 @@ pub fn _kshiftri_mask8(a: __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _ktest_mask16_u8(a: __mmask16, b: __mmask16, and_not: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _ktest_mask16_u8(a: __mmask16, b: __mmask16, and_not: *mut u8) -> u8 { *and_not = (_kandn_mask16(a, b) == 0) as u8; (_kand_mask16(a, b) == 0) as u8 } @@ -4637,7 +4815,8 @@ pub unsafe fn _ktest_mask16_u8(a: __mmask16, b: __mmask16, and_not: *mut u8) -> #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _ktest_mask8_u8(a: __mmask8, b: __mmask8, and_not: *mut u8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _ktest_mask8_u8(a: __mmask8, b: __mmask8, and_not: *mut u8) -> u8 { *and_not = (_kandn_mask8(a, b) == 0) as u8; (_kand_mask8(a, b) == 0) as u8 } @@ -4649,7 +4828,8 @@ pub unsafe fn _ktest_mask8_u8(a: __mmask8, b: __mmask8, and_not: *mut u8) -> u8 #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestc_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestc_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { (_kandn_mask16(a, b) == 0) as u8 } @@ -4660,7 +4840,8 @@ pub fn _ktestc_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestc_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestc_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { (_kandn_mask8(a, b) == 0) as u8 } @@ -4671,7 +4852,8 @@ pub fn _ktestc_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { (_kand_mask16(a, b) == 0) as u8 } @@ -4682,7 +4864,8 @@ pub fn _ktestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _ktestz_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _ktestz_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { (_kand_mask8(a, b) == 0) as u8 } @@ -4692,7 +4875,8 @@ pub fn _ktestz_mask8_u8(a: __mmask8, b: __mmask8) -> u8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _load_mask8(mem_addr: *const __mmask8) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _load_mask8(mem_addr: *const __mmask8) -> __mmask8 { *mem_addr } @@ -4702,7 +4886,8 @@ pub unsafe fn _load_mask8(mem_addr: *const __mmask8) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub unsafe fn _store_mask8(mem_addr: *mut __mmask8, a: __mmask8) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _store_mask8(mem_addr: *mut __mmask8, a: __mmask8) { *mem_addr = a; } @@ -4713,7 +4898,8 @@ pub unsafe fn _store_mask8(mem_addr: *mut __mmask8, a: __mmask8) { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_movepi32_mask(a: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movepi32_mask(a: __m128i) -> __mmask8 { let zero = _mm_setzero_si128(); _mm_cmplt_epi32_mask(a, zero) } @@ -4725,7 +4911,8 @@ pub fn _mm_movepi32_mask(a: __m128i) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_movepi32_mask(a: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movepi32_mask(a: __m256i) -> __mmask8 { let zero = _mm256_setzero_si256(); _mm256_cmplt_epi32_mask(a, zero) } @@ -4737,7 +4924,8 @@ pub fn _mm256_movepi32_mask(a: __m256i) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_movepi32_mask(a: __m512i) -> __mmask16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movepi32_mask(a: __m512i) -> __mmask16 { let zero = _mm512_setzero_si512(); _mm512_cmplt_epi32_mask(a, zero) } @@ -4749,7 +4937,8 @@ pub fn _mm512_movepi32_mask(a: __m512i) -> __mmask16 { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_movepi64_mask(a: __m128i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movepi64_mask(a: __m128i) -> __mmask8 { let zero = _mm_setzero_si128(); _mm_cmplt_epi64_mask(a, zero) } @@ -4761,7 +4950,8 @@ pub fn _mm_movepi64_mask(a: __m128i) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_movepi64_mask(a: __m256i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movepi64_mask(a: __m256i) -> __mmask8 { let zero = _mm256_setzero_si256(); _mm256_cmplt_epi64_mask(a, zero) } @@ -4773,7 +4963,8 @@ pub fn _mm256_movepi64_mask(a: __m256i) -> __mmask8 { #[inline] #[target_feature(enable = "avx512dq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_movepi64_mask(a: __m512i) -> __mmask8 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movepi64_mask(a: __m512i) -> __mmask8 { let zero = _mm512_setzero_si512(); _mm512_cmplt_epi64_mask(a, zero) } @@ -4786,7 +4977,8 @@ pub fn _mm512_movepi64_mask(a: __m512i) -> __mmask8 { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmovm2d))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_movm_epi32(k: __mmask8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movm_epi32(k: __mmask8) -> __m128i { let ones = _mm_set1_epi32(-1); _mm_maskz_mov_epi32(k, ones) } @@ -4799,7 +4991,8 @@ pub fn _mm_movm_epi32(k: __mmask8) -> __m128i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmovm2d))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_movm_epi32(k: __mmask8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movm_epi32(k: __mmask8) -> __m256i { let ones = _mm256_set1_epi32(-1); _mm256_maskz_mov_epi32(k, ones) } @@ -4812,7 +5005,8 @@ pub fn _mm256_movm_epi32(k: __mmask8) -> __m256i { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vpmovm2d))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_movm_epi32(k: __mmask16) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movm_epi32(k: __mmask16) -> __m512i { let ones = _mm512_set1_epi32(-1); _mm512_maskz_mov_epi32(k, ones) } @@ -4825,7 +5019,8 @@ pub fn _mm512_movm_epi32(k: __mmask16) -> __m512i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmovm2q))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm_movm_epi64(k: __mmask8) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_movm_epi64(k: __mmask8) -> __m128i { let ones = _mm_set1_epi64x(-1); _mm_maskz_mov_epi64(k, ones) } @@ -4838,7 +5033,8 @@ pub fn _mm_movm_epi64(k: __mmask8) -> __m128i { #[target_feature(enable = "avx512dq,avx512vl")] #[cfg_attr(test, assert_instr(vpmovm2q))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm256_movm_epi64(k: __mmask8) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_movm_epi64(k: __mmask8) -> __m256i { let ones = _mm256_set1_epi64x(-1); _mm256_maskz_mov_epi64(k, ones) } @@ -4851,7 +5047,8 @@ pub fn _mm256_movm_epi64(k: __mmask8) -> __m256i { #[target_feature(enable = "avx512dq")] #[cfg_attr(test, assert_instr(vpmovm2q))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] -pub fn _mm512_movm_epi64(k: __mmask8) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_movm_epi64(k: __mmask8) -> __m512i { let ones = _mm512_set1_epi64(-1); _mm512_maskz_mov_epi64(k, ones) } @@ -7203,6 +7400,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { use super::*; + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; @@ -7226,7 +7424,7 @@ mod tests { const XOR_32: f32 = unsafe { transmute(0x66666666_u32) }; #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_and_pd() { + const unsafe fn test_mm_mask_and_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let src = _mm_set_pd(1., 2.); @@ -7236,7 +7434,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_and_pd() { + const unsafe fn test_mm_maskz_and_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let r = _mm_maskz_and_pd(0b01, a, b); @@ -7245,7 +7443,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_and_pd() { + const unsafe fn test_mm256_mask_and_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let src = _mm256_set_pd(1., 2., 3., 4.); @@ -7255,7 +7453,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_and_pd() { + const unsafe fn test_mm256_maskz_and_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let r = _mm256_maskz_and_pd(0b0101, a, b); @@ -7264,7 +7462,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_and_pd() { + const unsafe fn test_mm512_and_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_and_pd(a, b); @@ -7273,7 +7471,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_and_pd() { + const unsafe fn test_mm512_mask_and_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let src = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7283,7 +7481,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_and_pd() { + const unsafe fn test_mm512_maskz_and_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_maskz_and_pd(0b01010101, a, b); @@ -7292,7 +7490,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_and_ps() { + const unsafe fn test_mm_mask_and_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let src = _mm_set_ps(1., 2., 3., 4.); @@ -7302,7 +7500,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_and_ps() { + const unsafe fn test_mm_maskz_and_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let r = _mm_maskz_and_ps(0b0101, a, b); @@ -7311,7 +7509,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_and_ps() { + const unsafe fn test_mm256_mask_and_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let src = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7321,7 +7519,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_and_ps() { + const unsafe fn test_mm256_maskz_and_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let r = _mm256_maskz_and_ps(0b01010101, a, b); @@ -7330,7 +7528,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_and_ps() { + const unsafe fn test_mm512_and_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_and_ps(a, b); @@ -7339,7 +7537,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_and_ps() { + const unsafe fn test_mm512_mask_and_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let src = _mm512_set_ps( @@ -7354,7 +7552,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_and_ps() { + const unsafe fn test_mm512_maskz_and_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_maskz_and_ps(0b0101010101010101, a, b); @@ -7366,7 +7564,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_andnot_pd() { + const unsafe fn test_mm_mask_andnot_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let src = _mm_set_pd(1., 2.); @@ -7376,7 +7574,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_andnot_pd() { + const unsafe fn test_mm_maskz_andnot_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let r = _mm_maskz_andnot_pd(0b01, a, b); @@ -7385,7 +7583,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_andnot_pd() { + const unsafe fn test_mm256_mask_andnot_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let src = _mm256_set_pd(1., 2., 3., 4.); @@ -7395,7 +7593,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_andnot_pd() { + const unsafe fn test_mm256_maskz_andnot_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let r = _mm256_maskz_andnot_pd(0b0101, a, b); @@ -7404,7 +7602,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_andnot_pd() { + const unsafe fn test_mm512_andnot_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_andnot_pd(a, b); @@ -7413,7 +7611,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_andnot_pd() { + const unsafe fn test_mm512_mask_andnot_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let src = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7423,7 +7621,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_andnot_pd() { + const unsafe fn test_mm512_maskz_andnot_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_maskz_andnot_pd(0b01010101, a, b); @@ -7432,7 +7630,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_andnot_ps() { + const unsafe fn test_mm_mask_andnot_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let src = _mm_set_ps(1., 2., 3., 4.); @@ -7442,7 +7640,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_andnot_ps() { + const unsafe fn test_mm_maskz_andnot_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let r = _mm_maskz_andnot_ps(0b0101, a, b); @@ -7451,7 +7649,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_andnot_ps() { + const unsafe fn test_mm256_mask_andnot_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let src = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7461,7 +7659,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_andnot_ps() { + const unsafe fn test_mm256_maskz_andnot_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let r = _mm256_maskz_andnot_ps(0b01010101, a, b); @@ -7470,7 +7668,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_andnot_ps() { + const unsafe fn test_mm512_andnot_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_andnot_ps(a, b); @@ -7479,7 +7677,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_andnot_ps() { + const unsafe fn test_mm512_mask_andnot_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let src = _mm512_set_ps( @@ -7494,7 +7692,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_andnot_ps() { + const unsafe fn test_mm512_maskz_andnot_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_maskz_andnot_ps(0b0101010101010101, a, b); @@ -7506,7 +7704,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_or_pd() { + const unsafe fn test_mm_mask_or_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let src = _mm_set_pd(1., 2.); @@ -7516,7 +7714,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_or_pd() { + const unsafe fn test_mm_maskz_or_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let r = _mm_maskz_or_pd(0b01, a, b); @@ -7525,7 +7723,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_or_pd() { + const unsafe fn test_mm256_mask_or_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let src = _mm256_set_pd(1., 2., 3., 4.); @@ -7535,7 +7733,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_or_pd() { + const unsafe fn test_mm256_maskz_or_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let r = _mm256_maskz_or_pd(0b0101, a, b); @@ -7544,7 +7742,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_or_pd() { + const unsafe fn test_mm512_or_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_or_pd(a, b); @@ -7553,7 +7751,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_or_pd() { + const unsafe fn test_mm512_mask_or_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let src = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7563,7 +7761,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_or_pd() { + const unsafe fn test_mm512_maskz_or_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_maskz_or_pd(0b01010101, a, b); @@ -7572,7 +7770,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_or_ps() { + const unsafe fn test_mm_mask_or_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let src = _mm_set_ps(1., 2., 3., 4.); @@ -7582,7 +7780,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_or_ps() { + const unsafe fn test_mm_maskz_or_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let r = _mm_maskz_or_ps(0b0101, a, b); @@ -7591,7 +7789,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_or_ps() { + const unsafe fn test_mm256_mask_or_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let src = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7601,7 +7799,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_or_ps() { + const unsafe fn test_mm256_maskz_or_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let r = _mm256_maskz_or_ps(0b01010101, a, b); @@ -7610,7 +7808,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_or_ps() { + const unsafe fn test_mm512_or_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_or_ps(a, b); @@ -7619,7 +7817,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_or_ps() { + const unsafe fn test_mm512_mask_or_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let src = _mm512_set_ps( @@ -7634,7 +7832,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_or_ps() { + const unsafe fn test_mm512_maskz_or_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_maskz_or_ps(0b0101010101010101, a, b); @@ -7645,7 +7843,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_xor_pd() { + const unsafe fn test_mm_mask_xor_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let src = _mm_set_pd(1., 2.); @@ -7655,7 +7853,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_xor_pd() { + const unsafe fn test_mm_maskz_xor_pd() { let a = _mm_set1_pd(OPRND1_64); let b = _mm_set1_pd(OPRND2_64); let r = _mm_maskz_xor_pd(0b01, a, b); @@ -7664,7 +7862,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_xor_pd() { + const unsafe fn test_mm256_mask_xor_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let src = _mm256_set_pd(1., 2., 3., 4.); @@ -7674,7 +7872,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_xor_pd() { + const unsafe fn test_mm256_maskz_xor_pd() { let a = _mm256_set1_pd(OPRND1_64); let b = _mm256_set1_pd(OPRND2_64); let r = _mm256_maskz_xor_pd(0b0101, a, b); @@ -7683,7 +7881,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_xor_pd() { + const unsafe fn test_mm512_xor_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_xor_pd(a, b); @@ -7692,7 +7890,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_xor_pd() { + const unsafe fn test_mm512_mask_xor_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let src = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7702,7 +7900,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_xor_pd() { + const unsafe fn test_mm512_maskz_xor_pd() { let a = _mm512_set1_pd(OPRND1_64); let b = _mm512_set1_pd(OPRND2_64); let r = _mm512_maskz_xor_pd(0b01010101, a, b); @@ -7711,7 +7909,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_xor_ps() { + const unsafe fn test_mm_mask_xor_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let src = _mm_set_ps(1., 2., 3., 4.); @@ -7721,7 +7919,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_xor_ps() { + const unsafe fn test_mm_maskz_xor_ps() { let a = _mm_set1_ps(OPRND1_32); let b = _mm_set1_ps(OPRND2_32); let r = _mm_maskz_xor_ps(0b0101, a, b); @@ -7730,7 +7928,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_xor_ps() { + const unsafe fn test_mm256_mask_xor_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let src = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); @@ -7740,7 +7938,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_xor_ps() { + const unsafe fn test_mm256_maskz_xor_ps() { let a = _mm256_set1_ps(OPRND1_32); let b = _mm256_set1_ps(OPRND2_32); let r = _mm256_maskz_xor_ps(0b01010101, a, b); @@ -7749,7 +7947,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_xor_ps() { + const unsafe fn test_mm512_xor_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_xor_ps(a, b); @@ -7758,7 +7956,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_xor_ps() { + const unsafe fn test_mm512_mask_xor_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let src = _mm512_set_ps( @@ -7773,7 +7971,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_xor_ps() { + const unsafe fn test_mm512_maskz_xor_ps() { let a = _mm512_set1_ps(OPRND1_32); let b = _mm512_set1_ps(OPRND2_32); let r = _mm512_maskz_xor_ps(0b0101010101010101, a, b); @@ -7785,7 +7983,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_broadcast_f32x2() { + const unsafe fn test_mm256_broadcast_f32x2() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm256_broadcast_f32x2(a); let e = _mm256_set_ps(3., 4., 3., 4., 3., 4., 3., 4.); @@ -7793,7 +7991,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_broadcast_f32x2() { + const unsafe fn test_mm256_mask_broadcast_f32x2() { let a = _mm_set_ps(1., 2., 3., 4.); let b = _mm256_set_ps(5., 6., 7., 8., 9., 10., 11., 12.); let r = _mm256_mask_broadcast_f32x2(b, 0b01101001, a); @@ -7802,7 +8000,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_broadcast_f32x2() { + const unsafe fn test_mm256_maskz_broadcast_f32x2() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm256_maskz_broadcast_f32x2(0b01101001, a); let e = _mm256_set_ps(0., 4., 3., 0., 3., 0., 0., 4.); @@ -7810,7 +8008,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_broadcast_f32x2() { + const unsafe fn test_mm512_broadcast_f32x2() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm512_broadcast_f32x2(a); let e = _mm512_set_ps( @@ -7820,7 +8018,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_broadcast_f32x2() { + const unsafe fn test_mm512_mask_broadcast_f32x2() { let a = _mm_set_ps(1., 2., 3., 4.); let b = _mm512_set_ps( 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., @@ -7833,7 +8031,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_broadcast_f32x2() { + const unsafe fn test_mm512_maskz_broadcast_f32x2() { let a = _mm_set_ps(1., 2., 3., 4.); let r = _mm512_maskz_broadcast_f32x2(0b0110100100111100, a); let e = _mm512_set_ps( @@ -7843,7 +8041,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_broadcast_f32x8() { + const unsafe fn test_mm512_broadcast_f32x8() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_broadcast_f32x8(a); let e = _mm512_set_ps( @@ -7853,7 +8051,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_broadcast_f32x8() { + const unsafe fn test_mm512_mask_broadcast_f32x8() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm512_set_ps( 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., @@ -7866,7 +8064,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_broadcast_f32x8() { + const unsafe fn test_mm512_maskz_broadcast_f32x8() { let a = _mm256_set_ps(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_maskz_broadcast_f32x8(0b0110100100111100, a); let e = _mm512_set_ps( @@ -7876,7 +8074,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_broadcast_f64x2() { + const unsafe fn test_mm256_broadcast_f64x2() { let a = _mm_set_pd(1., 2.); let r = _mm256_broadcast_f64x2(a); let e = _mm256_set_pd(1., 2., 1., 2.); @@ -7884,7 +8082,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_broadcast_f64x2() { + const unsafe fn test_mm256_mask_broadcast_f64x2() { let a = _mm_set_pd(1., 2.); let b = _mm256_set_pd(3., 4., 5., 6.); let r = _mm256_mask_broadcast_f64x2(b, 0b0110, a); @@ -7893,7 +8091,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_broadcast_f64x2() { + const unsafe fn test_mm256_maskz_broadcast_f64x2() { let a = _mm_set_pd(1., 2.); let r = _mm256_maskz_broadcast_f64x2(0b0110, a); let e = _mm256_set_pd(0., 2., 1., 0.); @@ -7901,7 +8099,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_broadcast_f64x2() { + const unsafe fn test_mm512_broadcast_f64x2() { let a = _mm_set_pd(1., 2.); let r = _mm512_broadcast_f64x2(a); let e = _mm512_set_pd(1., 2., 1., 2., 1., 2., 1., 2.); @@ -7909,7 +8107,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_broadcast_f64x2() { + const unsafe fn test_mm512_mask_broadcast_f64x2() { let a = _mm_set_pd(1., 2.); let b = _mm512_set_pd(3., 4., 5., 6., 7., 8., 9., 10.); let r = _mm512_mask_broadcast_f64x2(b, 0b01101001, a); @@ -7918,7 +8116,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_broadcast_f64x2() { + const unsafe fn test_mm512_maskz_broadcast_f64x2() { let a = _mm_set_pd(1., 2.); let r = _mm512_maskz_broadcast_f64x2(0b01101001, a); let e = _mm512_set_pd(0., 2., 1., 0., 1., 0., 0., 2.); @@ -7926,7 +8124,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_broadcast_i32x2() { + const unsafe fn test_mm_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm_broadcast_i32x2(a); let e = _mm_set_epi32(3, 4, 3, 4); @@ -7934,7 +8132,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_broadcast_i32x2() { + const unsafe fn test_mm_mask_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm_set_epi32(5, 6, 7, 8); let r = _mm_mask_broadcast_i32x2(b, 0b0110, a); @@ -7943,7 +8141,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_broadcast_i32x2() { + const unsafe fn test_mm_maskz_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm_maskz_broadcast_i32x2(0b0110, a); let e = _mm_set_epi32(0, 4, 3, 0); @@ -7951,7 +8149,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_broadcast_i32x2() { + const unsafe fn test_mm256_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm256_broadcast_i32x2(a); let e = _mm256_set_epi32(3, 4, 3, 4, 3, 4, 3, 4); @@ -7959,7 +8157,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_broadcast_i32x2() { + const unsafe fn test_mm256_mask_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm256_set_epi32(5, 6, 7, 8, 9, 10, 11, 12); let r = _mm256_mask_broadcast_i32x2(b, 0b01101001, a); @@ -7968,7 +8166,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_broadcast_i32x2() { + const unsafe fn test_mm256_maskz_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm256_maskz_broadcast_i32x2(0b01101001, a); let e = _mm256_set_epi32(0, 4, 3, 0, 3, 0, 0, 4); @@ -7976,7 +8174,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_broadcast_i32x2() { + const unsafe fn test_mm512_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm512_broadcast_i32x2(a); let e = _mm512_set_epi32(3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4); @@ -7984,7 +8182,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_broadcast_i32x2() { + const unsafe fn test_mm512_mask_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let b = _mm512_set_epi32(5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); let r = _mm512_mask_broadcast_i32x2(b, 0b0110100100111100, a); @@ -7993,7 +8191,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_broadcast_i32x2() { + const unsafe fn test_mm512_maskz_broadcast_i32x2() { let a = _mm_set_epi32(1, 2, 3, 4); let r = _mm512_maskz_broadcast_i32x2(0b0110100100111100, a); let e = _mm512_set_epi32(0, 4, 3, 0, 3, 0, 0, 4, 0, 0, 3, 4, 3, 4, 0, 0); @@ -8001,7 +8199,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_broadcast_i32x8() { + const unsafe fn test_mm512_broadcast_i32x8() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm512_broadcast_i32x8(a); let e = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8); @@ -8009,7 +8207,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_broadcast_i32x8() { + const unsafe fn test_mm512_mask_broadcast_i32x8() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi32( 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, @@ -8020,7 +8218,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_broadcast_i32x8() { + const unsafe fn test_mm512_maskz_broadcast_i32x8() { let a = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm512_maskz_broadcast_i32x8(0b0110100100111100, a); let e = _mm512_set_epi32(0, 2, 3, 0, 5, 0, 0, 8, 0, 0, 3, 4, 5, 6, 0, 0); @@ -8028,7 +8226,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_broadcast_i64x2() { + const unsafe fn test_mm256_broadcast_i64x2() { let a = _mm_set_epi64x(1, 2); let r = _mm256_broadcast_i64x2(a); let e = _mm256_set_epi64x(1, 2, 1, 2); @@ -8036,7 +8234,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_broadcast_i64x2() { + const unsafe fn test_mm256_mask_broadcast_i64x2() { let a = _mm_set_epi64x(1, 2); let b = _mm256_set_epi64x(3, 4, 5, 6); let r = _mm256_mask_broadcast_i64x2(b, 0b0110, a); @@ -8045,7 +8243,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_broadcast_i64x2() { + const unsafe fn test_mm256_maskz_broadcast_i64x2() { let a = _mm_set_epi64x(1, 2); let r = _mm256_maskz_broadcast_i64x2(0b0110, a); let e = _mm256_set_epi64x(0, 2, 1, 0); @@ -8053,7 +8251,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_broadcast_i64x2() { + const unsafe fn test_mm512_broadcast_i64x2() { let a = _mm_set_epi64x(1, 2); let r = _mm512_broadcast_i64x2(a); let e = _mm512_set_epi64(1, 2, 1, 2, 1, 2, 1, 2); @@ -8061,7 +8259,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_broadcast_i64x2() { + const unsafe fn test_mm512_mask_broadcast_i64x2() { let a = _mm_set_epi64x(1, 2); let b = _mm512_set_epi64(3, 4, 5, 6, 7, 8, 9, 10); let r = _mm512_mask_broadcast_i64x2(b, 0b01101001, a); @@ -8070,7 +8268,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_broadcast_i64x2() { + const unsafe fn test_mm512_maskz_broadcast_i64x2() { let a = _mm_set_epi64x(1, 2); let r = _mm512_maskz_broadcast_i64x2(0b01101001, a); let e = _mm512_set_epi64(0, 2, 1, 0, 1, 0, 0, 2); @@ -8078,7 +8276,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_extractf32x8_ps() { + const unsafe fn test_mm512_extractf32x8_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -8088,7 +8286,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_extractf32x8_ps() { + const unsafe fn test_mm512_mask_extractf32x8_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -8099,7 +8297,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_extractf32x8_ps() { + const unsafe fn test_mm512_maskz_extractf32x8_ps() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -8109,7 +8307,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_extractf64x2_pd() { + const unsafe fn test_mm256_extractf64x2_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let r = _mm256_extractf64x2_pd::<1>(a); let e = _mm_set_pd(1., 2.); @@ -8117,7 +8315,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_extractf64x2_pd() { + const unsafe fn test_mm256_mask_extractf64x2_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm_set_pd(5., 6.); let r = _mm256_mask_extractf64x2_pd::<1>(b, 0b01, a); @@ -8126,7 +8324,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_extractf64x2_pd() { + const unsafe fn test_mm256_maskz_extractf64x2_pd() { let a = _mm256_set_pd(1., 2., 3., 4.); let r = _mm256_maskz_extractf64x2_pd::<1>(0b01, a); let e = _mm_set_pd(0., 2.); @@ -8134,7 +8332,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_extractf64x2_pd() { + const unsafe fn test_mm512_extractf64x2_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_extractf64x2_pd::<2>(a); let e = _mm_set_pd(3., 4.); @@ -8142,7 +8340,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_extractf64x2_pd() { + const unsafe fn test_mm512_mask_extractf64x2_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_pd(9., 10.); let r = _mm512_mask_extractf64x2_pd::<2>(b, 0b01, a); @@ -8151,7 +8349,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_extractf64x2_pd() { + const unsafe fn test_mm512_maskz_extractf64x2_pd() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_maskz_extractf64x2_pd::<2>(0b01, a); let e = _mm_set_pd(0., 4.); @@ -8159,7 +8357,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_extracti32x8_epi32() { + const unsafe fn test_mm512_extracti32x8_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_extracti32x8_epi32::<1>(a); let e = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8); @@ -8167,7 +8365,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_extracti32x8_epi32() { + const unsafe fn test_mm512_mask_extracti32x8_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_mask_extracti32x8_epi32::<1>(b, 0b01101001, a); @@ -8176,7 +8374,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_extracti32x8_epi32() { + const unsafe fn test_mm512_maskz_extracti32x8_epi32() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_extracti32x8_epi32::<1>(0b01101001, a); let e = _mm256_set_epi32(0, 2, 3, 0, 5, 0, 0, 8); @@ -8184,7 +8382,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_extracti64x2_epi64() { + const unsafe fn test_mm256_extracti64x2_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let r = _mm256_extracti64x2_epi64::<1>(a); let e = _mm_set_epi64x(1, 2); @@ -8192,7 +8390,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_extracti64x2_epi64() { + const unsafe fn test_mm256_mask_extracti64x2_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm_set_epi64x(5, 6); let r = _mm256_mask_extracti64x2_epi64::<1>(b, 0b01, a); @@ -8201,7 +8399,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_extracti64x2_epi64() { + const unsafe fn test_mm256_maskz_extracti64x2_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let r = _mm256_maskz_extracti64x2_epi64::<1>(0b01, a); let e = _mm_set_epi64x(0, 2); @@ -8209,7 +8407,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_extracti64x2_epi64() { + const unsafe fn test_mm512_extracti64x2_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm512_extracti64x2_epi64::<2>(a); let e = _mm_set_epi64x(3, 4); @@ -8217,7 +8415,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_extracti64x2_epi64() { + const unsafe fn test_mm512_mask_extracti64x2_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi64x(9, 10); let r = _mm512_mask_extracti64x2_epi64::<2>(b, 0b01, a); @@ -8226,7 +8424,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_extracti64x2_epi64() { + const unsafe fn test_mm512_maskz_extracti64x2_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm512_maskz_extracti64x2_epi64::<2>(0b01, a); let e = _mm_set_epi64x(0, 4); @@ -8234,7 +8432,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_insertf32x8() { + const unsafe fn test_mm512_insertf32x8() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -8247,7 +8445,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_insertf32x8() { + const unsafe fn test_mm512_mask_insertf32x8() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -8263,7 +8461,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_insertf32x8() { + const unsafe fn test_mm512_maskz_insertf32x8() { let a = _mm512_set_ps( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -8276,7 +8474,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_insertf64x2() { + const unsafe fn test_mm256_insertf64x2() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm_set_pd(5., 6.); let r = _mm256_insertf64x2::<1>(a, b); @@ -8285,7 +8483,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_insertf64x2() { + const unsafe fn test_mm256_mask_insertf64x2() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm_set_pd(5., 6.); let src = _mm256_set_pd(7., 8., 9., 10.); @@ -8295,7 +8493,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_insertf64x2() { + const unsafe fn test_mm256_maskz_insertf64x2() { let a = _mm256_set_pd(1., 2., 3., 4.); let b = _mm_set_pd(5., 6.); let r = _mm256_maskz_insertf64x2::<1>(0b0110, a, b); @@ -8304,7 +8502,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_insertf64x2() { + const unsafe fn test_mm512_insertf64x2() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_pd(9., 10.); let r = _mm512_insertf64x2::<2>(a, b); @@ -8313,7 +8511,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_insertf64x2() { + const unsafe fn test_mm512_mask_insertf64x2() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_pd(9., 10.); let src = _mm512_set_pd(11., 12., 13., 14., 15., 16., 17., 18.); @@ -8323,7 +8521,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_insertf64x2() { + const unsafe fn test_mm512_maskz_insertf64x2() { let a = _mm512_set_pd(1., 2., 3., 4., 5., 6., 7., 8.); let b = _mm_set_pd(9., 10.); let r = _mm512_maskz_insertf64x2::<2>(0b01101001, a, b); @@ -8332,7 +8530,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_inserti32x8() { + const unsafe fn test_mm512_inserti32x8() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_inserti32x8::<1>(a, b); @@ -8343,7 +8541,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_inserti32x8() { + const unsafe fn test_mm512_mask_inserti32x8() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let src = _mm512_set_epi32( @@ -8357,7 +8555,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_inserti32x8() { + const unsafe fn test_mm512_maskz_inserti32x8() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let b = _mm256_set_epi32(17, 18, 19, 20, 21, 22, 23, 24); let r = _mm512_maskz_inserti32x8::<1>(0b0110100100111100, a, b); @@ -8366,7 +8564,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_inserti64x2() { + const unsafe fn test_mm256_inserti64x2() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm_set_epi64x(5, 6); let r = _mm256_inserti64x2::<1>(a, b); @@ -8375,7 +8573,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_inserti64x2() { + const unsafe fn test_mm256_mask_inserti64x2() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm_set_epi64x(5, 6); let src = _mm256_set_epi64x(7, 8, 9, 10); @@ -8385,7 +8583,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_inserti64x2() { + const unsafe fn test_mm256_maskz_inserti64x2() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm_set_epi64x(5, 6); let r = _mm256_maskz_inserti64x2::<1>(0b0110, a, b); @@ -8394,7 +8592,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_inserti64x2() { + const unsafe fn test_mm512_inserti64x2() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi64x(9, 10); let r = _mm512_inserti64x2::<2>(a, b); @@ -8403,7 +8601,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_inserti64x2() { + const unsafe fn test_mm512_mask_inserti64x2() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi64x(9, 10); let src = _mm512_set_epi64(11, 12, 13, 14, 15, 16, 17, 18); @@ -8413,7 +8611,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_inserti64x2() { + const unsafe fn test_mm512_maskz_inserti64x2() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm_set_epi64x(9, 10); let r = _mm512_maskz_inserti64x2::<2>(0b01101001, a, b); @@ -9654,7 +9852,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mullo_epi64() { + const unsafe fn test_mm_mullo_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(3, 4); let r = _mm_mullo_epi64(a, b); @@ -9663,7 +9861,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_mask_mullo_epi64() { + const unsafe fn test_mm_mask_mullo_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(3, 4); let c = _mm_set_epi64x(5, 6); @@ -9673,7 +9871,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_maskz_mullo_epi64() { + const unsafe fn test_mm_maskz_mullo_epi64() { let a = _mm_set_epi64x(1, 2); let b = _mm_set_epi64x(3, 4); let r = _mm_maskz_mullo_epi64(0b01, a, b); @@ -9682,7 +9880,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mullo_epi64() { + const unsafe fn test_mm256_mullo_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(5, 6, 7, 8); let r = _mm256_mullo_epi64(a, b); @@ -9691,7 +9889,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_mask_mullo_epi64() { + const unsafe fn test_mm256_mask_mullo_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(5, 6, 7, 8); let c = _mm256_set_epi64x(9, 10, 11, 12); @@ -9701,7 +9899,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_maskz_mullo_epi64() { + const unsafe fn test_mm256_maskz_mullo_epi64() { let a = _mm256_set_epi64x(1, 2, 3, 4); let b = _mm256_set_epi64x(5, 6, 7, 8); let r = _mm256_maskz_mullo_epi64(0b0110, a, b); @@ -9710,7 +9908,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mullo_epi64() { + const unsafe fn test_mm512_mullo_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_mullo_epi64(a, b); @@ -9719,7 +9917,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_mask_mullo_epi64() { + const unsafe fn test_mm512_mask_mullo_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(9, 10, 11, 12, 13, 14, 15, 16); let c = _mm512_set_epi64(17, 18, 19, 20, 21, 22, 23, 24); @@ -9729,7 +9927,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_maskz_mullo_epi64() { + const unsafe fn test_mm512_maskz_mullo_epi64() { let a = _mm512_set_epi64(1, 2, 3, 4, 5, 6, 7, 8); let b = _mm512_set_epi64(9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_mullo_epi64(0b01101001, a, b); @@ -9738,7 +9936,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_cvtmask8_u32() { + const unsafe fn test_cvtmask8_u32() { let a: __mmask8 = 0b01101001; let r = _cvtmask8_u32(a); let e: u32 = 0b01101001; @@ -9746,7 +9944,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_cvtu32_mask8() { + const unsafe fn test_cvtu32_mask8() { let a: u32 = 0b01101001; let r = _cvtu32_mask8(a); let e: __mmask8 = 0b01101001; @@ -9754,7 +9952,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kadd_mask16() { + const unsafe fn test_kadd_mask16() { let a: __mmask16 = 27549; let b: __mmask16 = 23434; let r = _kadd_mask16(a, b); @@ -9763,7 +9961,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kadd_mask8() { + const unsafe fn test_kadd_mask8() { let a: __mmask8 = 98; let b: __mmask8 = 117; let r = _kadd_mask8(a, b); @@ -9772,7 +9970,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kand_mask8() { + const unsafe fn test_kand_mask8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110011; let r = _kand_mask8(a, b); @@ -9781,7 +9979,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kandn_mask8() { + const unsafe fn test_kandn_mask8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110011; let r = _kandn_mask8(a, b); @@ -9790,7 +9988,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_knot_mask8() { + const unsafe fn test_knot_mask8() { let a: __mmask8 = 0b01101001; let r = _knot_mask8(a); let e: __mmask8 = 0b10010110; @@ -9798,7 +9996,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kor_mask8() { + const unsafe fn test_kor_mask8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110011; let r = _kor_mask8(a, b); @@ -9807,7 +10005,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kxnor_mask8() { + const unsafe fn test_kxnor_mask8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110011; let r = _kxnor_mask8(a, b); @@ -9816,7 +10014,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kxor_mask8() { + const unsafe fn test_kxor_mask8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110011; let r = _kxor_mask8(a, b); @@ -9825,7 +10023,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kortest_mask8_u8() { + const unsafe fn test_kortest_mask8_u8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110110; let mut all_ones: u8 = 0; @@ -9835,7 +10033,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kortestc_mask8_u8() { + const unsafe fn test_kortestc_mask8_u8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110110; let r = _kortestc_mask8_u8(a, b); @@ -9843,7 +10041,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kortestz_mask8_u8() { + const unsafe fn test_kortestz_mask8_u8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10110110; let r = _kortestz_mask8_u8(a, b); @@ -9851,7 +10049,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kshiftli_mask8() { + const unsafe fn test_kshiftli_mask8() { let a: __mmask8 = 0b01101001; let r = _kshiftli_mask8::<3>(a); let e: __mmask8 = 0b01001000; @@ -9871,7 +10069,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_kshiftri_mask8() { + const unsafe fn test_kshiftri_mask8() { let a: __mmask8 = 0b10101001; let r = _kshiftri_mask8::<3>(a); let e: __mmask8 = 0b00010101; @@ -9891,7 +10089,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_ktest_mask8_u8() { + const unsafe fn test_ktest_mask8_u8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10010110; let mut and_not: u8 = 0; @@ -9901,7 +10099,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_ktestc_mask8_u8() { + const unsafe fn test_ktestc_mask8_u8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10010110; let r = _ktestc_mask8_u8(a, b); @@ -9909,7 +10107,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_ktestz_mask8_u8() { + const unsafe fn test_ktestz_mask8_u8() { let a: __mmask8 = 0b01101001; let b: __mmask8 = 0b10010110; let r = _ktestz_mask8_u8(a, b); @@ -9917,7 +10115,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_ktest_mask16_u8() { + const unsafe fn test_ktest_mask16_u8() { let a: __mmask16 = 0b0110100100111100; let b: __mmask16 = 0b1001011011000011; let mut and_not: u8 = 0; @@ -9927,7 +10125,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_ktestc_mask16_u8() { + const unsafe fn test_ktestc_mask16_u8() { let a: __mmask16 = 0b0110100100111100; let b: __mmask16 = 0b1001011011000011; let r = _ktestc_mask16_u8(a, b); @@ -9935,7 +10133,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_ktestz_mask16_u8() { + const unsafe fn test_ktestz_mask16_u8() { let a: __mmask16 = 0b0110100100111100; let b: __mmask16 = 0b1001011011000011; let r = _ktestz_mask16_u8(a, b); @@ -9943,7 +10141,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_load_mask8() { + const unsafe fn test_load_mask8() { let a: __mmask8 = 0b01101001; let r = _load_mask8(&a); let e: __mmask8 = 0b01101001; @@ -9951,7 +10149,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_store_mask8() { + const unsafe fn test_store_mask8() { let a: __mmask8 = 0b01101001; let mut r = 0; _store_mask8(&mut r, a); @@ -9960,7 +10158,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_movepi32_mask() { + const unsafe fn test_mm_movepi32_mask() { let a = _mm_set_epi32(0, -2, -3, 4); let r = _mm_movepi32_mask(a); let e = 0b0110; @@ -9968,7 +10166,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_movepi32_mask() { + const unsafe fn test_mm256_movepi32_mask() { let a = _mm256_set_epi32(0, -2, -3, 4, -5, 6, 7, -8); let r = _mm256_movepi32_mask(a); let e = 0b01101001; @@ -9976,7 +10174,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_movepi32_mask() { + const unsafe fn test_mm512_movepi32_mask() { let a = _mm512_set_epi32( 0, -2, -3, 4, -5, 6, 7, -8, 9, 10, -11, -12, -13, -14, 15, 16, ); @@ -9986,7 +10184,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_movepi64_mask() { + const unsafe fn test_mm_movepi64_mask() { let a = _mm_set_epi64x(0, -2); let r = _mm_movepi64_mask(a); let e = 0b01; @@ -9994,7 +10192,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_movepi64_mask() { + const unsafe fn test_mm256_movepi64_mask() { let a = _mm256_set_epi64x(0, -2, -3, 4); let r = _mm256_movepi64_mask(a); let e = 0b0110; @@ -10002,7 +10200,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_movepi64_mask() { + const unsafe fn test_mm512_movepi64_mask() { let a = _mm512_set_epi64(0, -2, -3, 4, -5, 6, 7, -8); let r = _mm512_movepi64_mask(a); let e = 0b01101001; @@ -10010,7 +10208,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_movm_epi32() { + const unsafe fn test_mm_movm_epi32() { let a = 0b0110; let r = _mm_movm_epi32(a); let e = _mm_set_epi32(0, -1, -1, 0); @@ -10018,7 +10216,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_movm_epi32() { + const unsafe fn test_mm256_movm_epi32() { let a = 0b01101001; let r = _mm256_movm_epi32(a); let e = _mm256_set_epi32(0, -1, -1, 0, -1, 0, 0, -1); @@ -10026,7 +10224,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_movm_epi32() { + const unsafe fn test_mm512_movm_epi32() { let a = 0b0110100100111100; let r = _mm512_movm_epi32(a); let e = _mm512_set_epi32(0, -1, -1, 0, -1, 0, 0, -1, 0, 0, -1, -1, -1, -1, 0, 0); @@ -10034,7 +10232,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm_movm_epi64() { + const unsafe fn test_mm_movm_epi64() { let a = 0b01; let r = _mm_movm_epi64(a); let e = _mm_set_epi64x(0, -1); @@ -10042,7 +10240,7 @@ mod tests { } #[simd_test(enable = "avx512dq,avx512vl")] - unsafe fn test_mm256_movm_epi64() { + const unsafe fn test_mm256_movm_epi64() { let a = 0b0110; let r = _mm256_movm_epi64(a); let e = _mm256_set_epi64x(0, -1, -1, 0); @@ -10050,7 +10248,7 @@ mod tests { } #[simd_test(enable = "avx512dq")] - unsafe fn test_mm512_movm_epi64() { + const unsafe fn test_mm512_movm_epi64() { let a = 0b01101001; let r = _mm512_movm_epi64(a); let e = _mm512_set_epi64(0, -1, -1, 0, -1, 0, 0, -1); From 6695809811f597cb654fb817fbcbc54c03a00669 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:26:40 +0530 Subject: [PATCH 072/489] Make `avx512vbmi2` functions const --- .../crates/core_arch/src/x86/avx512vbmi2.rs | 613 ++++++++++++------ 1 file changed, 397 insertions(+), 216 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512vbmi2.rs b/library/stdarch/crates/core_arch/src/x86/avx512vbmi2.rs index e25fd4528dc2..da268f969c37 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512vbmi2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512vbmi2.rs @@ -499,7 +499,8 @@ pub fn _mm_maskz_expand_epi8(k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm512_shldv_epi64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shldv_epi64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shl( a.as_i64x8(), @@ -516,7 +517,8 @@ pub fn _mm512_shldv_epi64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm512_mask_shldv_epi64(a: __m512i, k: __mmask8, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shldv_epi64(a: __m512i, k: __mmask8, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shldv_epi64(a, b, c).as_i64x8(); transmute(simd_select_bitmask(k, shf, a.as_i64x8())) @@ -530,7 +532,8 @@ pub fn _mm512_mask_shldv_epi64(a: __m512i, k: __mmask8, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm512_maskz_shldv_epi64(k: __mmask8, a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shldv_epi64(k: __mmask8, a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shldv_epi64(a, b, c).as_i64x8(); transmute(simd_select_bitmask(k, shf, i64x8::ZERO)) @@ -544,7 +547,8 @@ pub fn _mm512_maskz_shldv_epi64(k: __mmask8, a: __m512i, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm256_shldv_epi64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shldv_epi64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shl( a.as_i64x4(), @@ -561,7 +565,8 @@ pub fn _mm256_shldv_epi64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm256_mask_shldv_epi64(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shldv_epi64(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shldv_epi64(a, b, c).as_i64x4(); transmute(simd_select_bitmask(k, shf, a.as_i64x4())) @@ -575,7 +580,8 @@ pub fn _mm256_mask_shldv_epi64(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm256_maskz_shldv_epi64(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shldv_epi64(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shldv_epi64(a, b, c).as_i64x4(); transmute(simd_select_bitmask(k, shf, i64x4::ZERO)) @@ -589,7 +595,8 @@ pub fn _mm256_maskz_shldv_epi64(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm_shldv_epi64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shldv_epi64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shl( a.as_i64x2(), @@ -606,7 +613,8 @@ pub fn _mm_shldv_epi64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm_mask_shldv_epi64(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shldv_epi64(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shldv_epi64(a, b, c).as_i64x2(); transmute(simd_select_bitmask(k, shf, a.as_i64x2())) @@ -620,7 +628,8 @@ pub fn _mm_mask_shldv_epi64(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvq))] -pub fn _mm_maskz_shldv_epi64(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shldv_epi64(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shldv_epi64(a, b, c).as_i64x2(); transmute(simd_select_bitmask(k, shf, i64x2::ZERO)) @@ -634,7 +643,8 @@ pub fn _mm_maskz_shldv_epi64(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm512_shldv_epi32(a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shldv_epi32(a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shl( a.as_i32x16(), @@ -651,7 +661,8 @@ pub fn _mm512_shldv_epi32(a: __m512i, b: __m512i, c: __m512i) -> __m512i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm512_mask_shldv_epi32(a: __m512i, k: __mmask16, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shldv_epi32(a: __m512i, k: __mmask16, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shldv_epi32(a, b, c).as_i32x16(); transmute(simd_select_bitmask(k, shf, a.as_i32x16())) @@ -665,7 +676,8 @@ pub fn _mm512_mask_shldv_epi32(a: __m512i, k: __mmask16, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm512_maskz_shldv_epi32(k: __mmask16, a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shldv_epi32(k: __mmask16, a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shldv_epi32(a, b, c).as_i32x16(); transmute(simd_select_bitmask(k, shf, i32x16::ZERO)) @@ -679,7 +691,8 @@ pub fn _mm512_maskz_shldv_epi32(k: __mmask16, a: __m512i, b: __m512i, c: __m512i #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm256_shldv_epi32(a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shldv_epi32(a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shl( a.as_i32x8(), @@ -696,7 +709,8 @@ pub fn _mm256_shldv_epi32(a: __m256i, b: __m256i, c: __m256i) -> __m256i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm256_mask_shldv_epi32(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shldv_epi32(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shldv_epi32(a, b, c).as_i32x8(); transmute(simd_select_bitmask(k, shf, a.as_i32x8())) @@ -710,7 +724,8 @@ pub fn _mm256_mask_shldv_epi32(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm256_maskz_shldv_epi32(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shldv_epi32(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shldv_epi32(a, b, c).as_i32x8(); transmute(simd_select_bitmask(k, shf, i32x8::ZERO)) @@ -724,7 +739,8 @@ pub fn _mm256_maskz_shldv_epi32(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm_shldv_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shldv_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shl( a.as_i32x4(), @@ -741,7 +757,8 @@ pub fn _mm_shldv_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm_mask_shldv_epi32(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shldv_epi32(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shldv_epi32(a, b, c).as_i32x4(); transmute(simd_select_bitmask(k, shf, a.as_i32x4())) @@ -755,7 +772,8 @@ pub fn _mm_mask_shldv_epi32(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvd))] -pub fn _mm_maskz_shldv_epi32(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shldv_epi32(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shldv_epi32(a, b, c).as_i32x4(); transmute(simd_select_bitmask(k, shf, i32x4::ZERO)) @@ -769,7 +787,8 @@ pub fn _mm_maskz_shldv_epi32(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm512_shldv_epi16(a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shldv_epi16(a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shl( a.as_i16x32(), @@ -786,7 +805,8 @@ pub fn _mm512_shldv_epi16(a: __m512i, b: __m512i, c: __m512i) -> __m512i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm512_mask_shldv_epi16(a: __m512i, k: __mmask32, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shldv_epi16(a: __m512i, k: __mmask32, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shldv_epi16(a, b, c).as_i16x32(); transmute(simd_select_bitmask(k, shf, a.as_i16x32())) @@ -800,7 +820,8 @@ pub fn _mm512_mask_shldv_epi16(a: __m512i, k: __mmask32, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm512_maskz_shldv_epi16(k: __mmask32, a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shldv_epi16(k: __mmask32, a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shldv_epi16(a, b, c).as_i16x32(); transmute(simd_select_bitmask(k, shf, i16x32::ZERO)) @@ -814,7 +835,8 @@ pub fn _mm512_maskz_shldv_epi16(k: __mmask32, a: __m512i, b: __m512i, c: __m512i #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm256_shldv_epi16(a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shldv_epi16(a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shl( a.as_i16x16(), @@ -831,7 +853,8 @@ pub fn _mm256_shldv_epi16(a: __m256i, b: __m256i, c: __m256i) -> __m256i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm256_mask_shldv_epi16(a: __m256i, k: __mmask16, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shldv_epi16(a: __m256i, k: __mmask16, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shldv_epi16(a, b, c).as_i16x16(); transmute(simd_select_bitmask(k, shf, a.as_i16x16())) @@ -845,7 +868,8 @@ pub fn _mm256_mask_shldv_epi16(a: __m256i, k: __mmask16, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm256_maskz_shldv_epi16(k: __mmask16, a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shldv_epi16(k: __mmask16, a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shldv_epi16(a, b, c).as_i16x16(); transmute(simd_select_bitmask(k, shf, i16x16::ZERO)) @@ -859,7 +883,8 @@ pub fn _mm256_maskz_shldv_epi16(k: __mmask16, a: __m256i, b: __m256i, c: __m256i #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm_shldv_epi16(a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shldv_epi16(a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shl( a.as_i16x8(), @@ -876,7 +901,8 @@ pub fn _mm_shldv_epi16(a: __m128i, b: __m128i, c: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm_mask_shldv_epi16(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shldv_epi16(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shldv_epi16(a, b, c).as_i16x8(); transmute(simd_select_bitmask(k, shf, a.as_i16x8())) @@ -890,7 +916,8 @@ pub fn _mm_mask_shldv_epi16(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldvw))] -pub fn _mm_maskz_shldv_epi16(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shldv_epi16(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shldv_epi16(a, b, c).as_i16x8(); transmute(simd_select_bitmask(k, shf, i16x8::ZERO)) @@ -904,7 +931,8 @@ pub fn _mm_maskz_shldv_epi16(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm512_shrdv_epi64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shrdv_epi64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shr( b.as_i64x8(), @@ -921,7 +949,8 @@ pub fn _mm512_shrdv_epi64(a: __m512i, b: __m512i, c: __m512i) -> __m512i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm512_mask_shrdv_epi64(a: __m512i, k: __mmask8, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shrdv_epi64(a: __m512i, k: __mmask8, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shrdv_epi64(a, b, c).as_i64x8(); transmute(simd_select_bitmask(k, shf, a.as_i64x8())) @@ -935,7 +964,8 @@ pub fn _mm512_mask_shrdv_epi64(a: __m512i, k: __mmask8, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm512_maskz_shrdv_epi64(k: __mmask8, a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shrdv_epi64(k: __mmask8, a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shrdv_epi64(a, b, c).as_i64x8(); transmute(simd_select_bitmask(k, shf, i64x8::ZERO)) @@ -949,7 +979,8 @@ pub fn _mm512_maskz_shrdv_epi64(k: __mmask8, a: __m512i, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm256_shrdv_epi64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shrdv_epi64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shr( b.as_i64x4(), @@ -966,7 +997,8 @@ pub fn _mm256_shrdv_epi64(a: __m256i, b: __m256i, c: __m256i) -> __m256i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm256_mask_shrdv_epi64(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shrdv_epi64(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shrdv_epi64(a, b, c).as_i64x4(); transmute(simd_select_bitmask(k, shf, a.as_i64x4())) @@ -980,7 +1012,8 @@ pub fn _mm256_mask_shrdv_epi64(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm256_maskz_shrdv_epi64(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shrdv_epi64(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shrdv_epi64(a, b, c).as_i64x4(); transmute(simd_select_bitmask(k, shf, i64x4::ZERO)) @@ -994,7 +1027,8 @@ pub fn _mm256_maskz_shrdv_epi64(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm_shrdv_epi64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shrdv_epi64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shr( b.as_i64x2(), @@ -1011,7 +1045,8 @@ pub fn _mm_shrdv_epi64(a: __m128i, b: __m128i, c: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm_mask_shrdv_epi64(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shrdv_epi64(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shrdv_epi64(a, b, c).as_i64x2(); transmute(simd_select_bitmask(k, shf, a.as_i64x2())) @@ -1025,7 +1060,8 @@ pub fn _mm_mask_shrdv_epi64(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvq))] -pub fn _mm_maskz_shrdv_epi64(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shrdv_epi64(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shrdv_epi64(a, b, c).as_i64x2(); transmute(simd_select_bitmask(k, shf, i64x2::ZERO)) @@ -1039,7 +1075,8 @@ pub fn _mm_maskz_shrdv_epi64(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm512_shrdv_epi32(a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shrdv_epi32(a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shr( b.as_i32x16(), @@ -1056,7 +1093,8 @@ pub fn _mm512_shrdv_epi32(a: __m512i, b: __m512i, c: __m512i) -> __m512i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm512_mask_shrdv_epi32(a: __m512i, k: __mmask16, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shrdv_epi32(a: __m512i, k: __mmask16, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shrdv_epi32(a, b, c).as_i32x16(); transmute(simd_select_bitmask(k, shf, a.as_i32x16())) @@ -1070,7 +1108,8 @@ pub fn _mm512_mask_shrdv_epi32(a: __m512i, k: __mmask16, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm512_maskz_shrdv_epi32(k: __mmask16, a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shrdv_epi32(k: __mmask16, a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shrdv_epi32(a, b, c).as_i32x16(); transmute(simd_select_bitmask(k, shf, i32x16::ZERO)) @@ -1084,7 +1123,8 @@ pub fn _mm512_maskz_shrdv_epi32(k: __mmask16, a: __m512i, b: __m512i, c: __m512i #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm256_shrdv_epi32(a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shrdv_epi32(a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shr( b.as_i32x8(), @@ -1101,7 +1141,8 @@ pub fn _mm256_shrdv_epi32(a: __m256i, b: __m256i, c: __m256i) -> __m256i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm256_mask_shrdv_epi32(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shrdv_epi32(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shrdv_epi32(a, b, c).as_i32x8(); transmute(simd_select_bitmask(k, shf, a.as_i32x8())) @@ -1115,7 +1156,8 @@ pub fn _mm256_mask_shrdv_epi32(a: __m256i, k: __mmask8, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm256_maskz_shrdv_epi32(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shrdv_epi32(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shrdv_epi32(a, b, c).as_i32x8(); transmute(simd_select_bitmask(k, shf, i32x8::ZERO)) @@ -1129,7 +1171,8 @@ pub fn _mm256_maskz_shrdv_epi32(k: __mmask8, a: __m256i, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm_shrdv_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shrdv_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shr( b.as_i32x4(), @@ -1146,7 +1189,8 @@ pub fn _mm_shrdv_epi32(a: __m128i, b: __m128i, c: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm_mask_shrdv_epi32(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shrdv_epi32(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shrdv_epi32(a, b, c).as_i32x4(); transmute(simd_select_bitmask(k, shf, a.as_i32x4())) @@ -1160,7 +1204,8 @@ pub fn _mm_mask_shrdv_epi32(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvd))] -pub fn _mm_maskz_shrdv_epi32(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shrdv_epi32(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shrdv_epi32(a, b, c).as_i32x4(); transmute(simd_select_bitmask(k, shf, i32x4::ZERO)) @@ -1174,7 +1219,8 @@ pub fn _mm_maskz_shrdv_epi32(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm512_shrdv_epi16(a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shrdv_epi16(a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { transmute(simd_funnel_shr( b.as_i16x32(), @@ -1191,7 +1237,8 @@ pub fn _mm512_shrdv_epi16(a: __m512i, b: __m512i, c: __m512i) -> __m512i { #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm512_mask_shrdv_epi16(a: __m512i, k: __mmask32, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shrdv_epi16(a: __m512i, k: __mmask32, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shrdv_epi16(a, b, c).as_i16x32(); transmute(simd_select_bitmask(k, shf, a.as_i16x32())) @@ -1205,7 +1252,8 @@ pub fn _mm512_mask_shrdv_epi16(a: __m512i, k: __mmask32, b: __m512i, c: __m512i) #[target_feature(enable = "avx512vbmi2")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm512_maskz_shrdv_epi16(k: __mmask32, a: __m512i, b: __m512i, c: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shrdv_epi16(k: __mmask32, a: __m512i, b: __m512i, c: __m512i) -> __m512i { unsafe { let shf = _mm512_shrdv_epi16(a, b, c).as_i16x32(); transmute(simd_select_bitmask(k, shf, i16x32::ZERO)) @@ -1219,7 +1267,8 @@ pub fn _mm512_maskz_shrdv_epi16(k: __mmask32, a: __m512i, b: __m512i, c: __m512i #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm256_shrdv_epi16(a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shrdv_epi16(a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { transmute(simd_funnel_shr( b.as_i16x16(), @@ -1236,7 +1285,8 @@ pub fn _mm256_shrdv_epi16(a: __m256i, b: __m256i, c: __m256i) -> __m256i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm256_mask_shrdv_epi16(a: __m256i, k: __mmask16, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shrdv_epi16(a: __m256i, k: __mmask16, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shrdv_epi16(a, b, c).as_i16x16(); transmute(simd_select_bitmask(k, shf, a.as_i16x16())) @@ -1250,7 +1300,8 @@ pub fn _mm256_mask_shrdv_epi16(a: __m256i, k: __mmask16, b: __m256i, c: __m256i) #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm256_maskz_shrdv_epi16(k: __mmask16, a: __m256i, b: __m256i, c: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shrdv_epi16(k: __mmask16, a: __m256i, b: __m256i, c: __m256i) -> __m256i { unsafe { let shf = _mm256_shrdv_epi16(a, b, c).as_i16x16(); transmute(simd_select_bitmask(k, shf, i16x16::ZERO)) @@ -1264,7 +1315,8 @@ pub fn _mm256_maskz_shrdv_epi16(k: __mmask16, a: __m256i, b: __m256i, c: __m256i #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm_shrdv_epi16(a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shrdv_epi16(a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { transmute(simd_funnel_shr( b.as_i16x8(), @@ -1281,7 +1333,8 @@ pub fn _mm_shrdv_epi16(a: __m128i, b: __m128i, c: __m128i) -> __m128i { #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm_mask_shrdv_epi16(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shrdv_epi16(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shrdv_epi16(a, b, c).as_i16x8(); transmute(simd_select_bitmask(k, shf, a.as_i16x8())) @@ -1295,7 +1348,8 @@ pub fn _mm_mask_shrdv_epi16(a: __m128i, k: __mmask8, b: __m128i, c: __m128i) -> #[target_feature(enable = "avx512vbmi2,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshrdvw))] -pub fn _mm_maskz_shrdv_epi16(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shrdv_epi16(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> __m128i { unsafe { let shf = _mm_shrdv_epi16(a, b, c).as_i16x8(); transmute(simd_select_bitmask(k, shf, i16x8::ZERO)) @@ -1310,7 +1364,8 @@ pub fn _mm_maskz_shrdv_epi16(k: __mmask8, a: __m128i, b: __m128i, c: __m128i) -> #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shldi_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shldi_epi64(a: __m512i, b: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_shldv_epi64(a, b, _mm512_set1_epi64(IMM8 as i64)) } @@ -1323,7 +1378,8 @@ pub fn _mm512_shldi_epi64(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shldi_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shldi_epi64( src: __m512i, k: __mmask8, a: __m512i, @@ -1344,7 +1400,12 @@ pub fn _mm512_mask_shldi_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shldi_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shldi_epi64( + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm512_shldi_epi64::(a, b).as_i64x8(); @@ -1360,7 +1421,8 @@ pub fn _mm512_maskz_shldi_epi64(k: __mmask8, a: __m512i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_shldi_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shldi_epi64(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_shldv_epi64(a, b, _mm256_set1_epi64x(IMM8 as i64)) } @@ -1373,7 +1435,8 @@ pub fn _mm256_shldi_epi64(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shldi_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shldi_epi64( src: __m256i, k: __mmask8, a: __m256i, @@ -1394,7 +1457,12 @@ pub fn _mm256_mask_shldi_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shldi_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shldi_epi64( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_shldi_epi64::(a, b).as_i64x4(); @@ -1410,7 +1478,8 @@ pub fn _mm256_maskz_shldi_epi64(k: __mmask8, a: __m256i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_shldi_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shldi_epi64(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_shldv_epi64(a, b, _mm_set1_epi64x(IMM8 as i64)) } @@ -1423,7 +1492,8 @@ pub fn _mm_shldi_epi64(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shldi_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shldi_epi64( src: __m128i, k: __mmask8, a: __m128i, @@ -1444,7 +1514,12 @@ pub fn _mm_mask_shldi_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shldi_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shldi_epi64( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_shldi_epi64::(a, b).as_i64x2(); @@ -1460,7 +1535,8 @@ pub fn _mm_maskz_shldi_epi64(k: __mmask8, a: __m128i, b: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shldi_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shldi_epi32(a: __m512i, b: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_shldv_epi32(a, b, _mm512_set1_epi32(IMM8)) } @@ -1473,7 +1549,8 @@ pub fn _mm512_shldi_epi32(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shldi_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shldi_epi32( src: __m512i, k: __mmask16, a: __m512i, @@ -1494,7 +1571,12 @@ pub fn _mm512_mask_shldi_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shldi_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shldi_epi32( + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm512_shldi_epi32::(a, b).as_i32x16(); @@ -1510,7 +1592,8 @@ pub fn _mm512_maskz_shldi_epi32(k: __mmask16, a: __m512i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_shldi_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shldi_epi32(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_shldv_epi32(a, b, _mm256_set1_epi32(IMM8)) } @@ -1523,7 +1606,8 @@ pub fn _mm256_shldi_epi32(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shldi_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shldi_epi32( src: __m256i, k: __mmask8, a: __m256i, @@ -1544,7 +1628,12 @@ pub fn _mm256_mask_shldi_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shldi_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shldi_epi32( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_shldi_epi32::(a, b).as_i32x8(); @@ -1560,7 +1649,8 @@ pub fn _mm256_maskz_shldi_epi32(k: __mmask8, a: __m256i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_shldi_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shldi_epi32(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_shldv_epi32(a, b, _mm_set1_epi32(IMM8)) } @@ -1573,7 +1663,8 @@ pub fn _mm_shldi_epi32(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shldi_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shldi_epi32( src: __m128i, k: __mmask8, a: __m128i, @@ -1594,7 +1685,12 @@ pub fn _mm_mask_shldi_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shldi_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shldi_epi32( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_shldi_epi32::(a, b).as_i32x4(); @@ -1610,7 +1706,8 @@ pub fn _mm_maskz_shldi_epi32(k: __mmask8, a: __m128i, b: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm512_shldi_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shldi_epi16(a: __m512i, b: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_shldv_epi16(a, b, _mm512_set1_epi16(IMM8 as i16)) } @@ -1623,7 +1720,8 @@ pub fn _mm512_shldi_epi16(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shldi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shldi_epi16( src: __m512i, k: __mmask32, a: __m512i, @@ -1644,7 +1742,12 @@ pub fn _mm512_mask_shldi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shldi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shldi_epi16( + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm512_shldi_epi16::(a, b).as_i16x32(); @@ -1660,7 +1763,8 @@ pub fn _mm512_maskz_shldi_epi16(k: __mmask32, a: __m512i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm256_shldi_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shldi_epi16(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_shldv_epi16(a, b, _mm256_set1_epi16(IMM8 as i16)) } @@ -1673,7 +1777,8 @@ pub fn _mm256_shldi_epi16(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shldi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shldi_epi16( src: __m256i, k: __mmask16, a: __m256i, @@ -1694,7 +1799,12 @@ pub fn _mm256_mask_shldi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shldi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shldi_epi16( + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_shldi_epi16::(a, b).as_i16x16(); @@ -1710,7 +1820,8 @@ pub fn _mm256_maskz_shldi_epi16(k: __mmask16, a: __m256i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(2)] -pub fn _mm_shldi_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shldi_epi16(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_shldv_epi16(a, b, _mm_set1_epi16(IMM8 as i16)) } @@ -1723,7 +1834,8 @@ pub fn _mm_shldi_epi16(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shldi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shldi_epi16( src: __m128i, k: __mmask8, a: __m128i, @@ -1744,7 +1856,12 @@ pub fn _mm_mask_shldi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shldi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shldi_epi16( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_shldi_epi16::(a, b).as_i16x8(); @@ -1760,7 +1877,8 @@ pub fn _mm_maskz_shldi_epi16(k: __mmask8, a: __m128i, b: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(2)] -pub fn _mm512_shrdi_epi64(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shrdi_epi64(a: __m512i, b: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_shrdv_epi64(a, b, _mm512_set1_epi64(IMM8 as i64)) } @@ -1773,7 +1891,8 @@ pub fn _mm512_shrdi_epi64(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shrdi_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shrdi_epi64( src: __m512i, k: __mmask8, a: __m512i, @@ -1794,7 +1913,12 @@ pub fn _mm512_mask_shrdi_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 255))] //should be vpshrdq #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shrdi_epi64(k: __mmask8, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shrdi_epi64( + k: __mmask8, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm512_shrdi_epi64::(a, b).as_i64x8(); @@ -1810,7 +1934,8 @@ pub fn _mm512_maskz_shrdi_epi64(k: __mmask8, a: __m512i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(2)] -pub fn _mm256_shrdi_epi64(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shrdi_epi64(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_shrdv_epi64(a, b, _mm256_set1_epi64x(IMM8 as i64)) } @@ -1823,7 +1948,8 @@ pub fn _mm256_shrdi_epi64(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shrdi_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shrdi_epi64( src: __m256i, k: __mmask8, a: __m256i, @@ -1844,7 +1970,12 @@ pub fn _mm256_mask_shrdi_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shrdi_epi64(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shrdi_epi64( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_shrdi_epi64::(a, b).as_i64x4(); @@ -1860,7 +1991,8 @@ pub fn _mm256_maskz_shrdi_epi64(k: __mmask8, a: __m256i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(2)] -pub fn _mm_shrdi_epi64(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shrdi_epi64(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_shrdv_epi64(a, b, _mm_set1_epi64x(IMM8 as i64)) } @@ -1873,7 +2005,8 @@ pub fn _mm_shrdi_epi64(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shrdi_epi64( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shrdi_epi64( src: __m128i, k: __mmask8, a: __m128i, @@ -1894,7 +2027,12 @@ pub fn _mm_mask_shrdi_epi64( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldq, IMM8 = 5))] //should be vpshrdq #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shrdi_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shrdi_epi64( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_shrdi_epi64::(a, b).as_i64x2(); @@ -1910,7 +2048,8 @@ pub fn _mm_maskz_shrdi_epi64(k: __mmask8, a: __m128i, b: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(2)] -pub fn _mm512_shrdi_epi32(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shrdi_epi32(a: __m512i, b: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_shrdv_epi32(a, b, _mm512_set1_epi32(IMM8)) } @@ -1923,7 +2062,8 @@ pub fn _mm512_shrdi_epi32(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shrdi_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shrdi_epi32( src: __m512i, k: __mmask16, a: __m512i, @@ -1944,7 +2084,12 @@ pub fn _mm512_mask_shrdi_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shrdi_epi32(k: __mmask16, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shrdi_epi32( + k: __mmask16, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm512_shrdi_epi32::(a, b).as_i32x16(); @@ -1960,7 +2105,8 @@ pub fn _mm512_maskz_shrdi_epi32(k: __mmask16, a: __m512i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(2)] -pub fn _mm256_shrdi_epi32(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shrdi_epi32(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_shrdv_epi32(a, b, _mm256_set1_epi32(IMM8)) } @@ -1973,7 +2119,8 @@ pub fn _mm256_shrdi_epi32(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shrdi_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shrdi_epi32( src: __m256i, k: __mmask8, a: __m256i, @@ -1994,7 +2141,12 @@ pub fn _mm256_mask_shrdi_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shrdi_epi32(k: __mmask8, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shrdi_epi32( + k: __mmask8, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_shrdi_epi32::(a, b).as_i32x8(); @@ -2010,7 +2162,8 @@ pub fn _mm256_maskz_shrdi_epi32(k: __mmask8, a: __m256i, b: __m #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(2)] -pub fn _mm_shrdi_epi32(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shrdi_epi32(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_shrdv_epi32(a, b, _mm_set1_epi32(IMM8)) } @@ -2023,7 +2176,8 @@ pub fn _mm_shrdi_epi32(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shrdi_epi32( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shrdi_epi32( src: __m128i, k: __mmask8, a: __m128i, @@ -2044,7 +2198,12 @@ pub fn _mm_mask_shrdi_epi32( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldd, IMM8 = 5))] //should be vpshldd #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shrdi_epi32(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shrdi_epi32( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_shrdi_epi32::(a, b).as_i32x4(); @@ -2060,7 +2219,8 @@ pub fn _mm_maskz_shrdi_epi32(k: __mmask8, a: __m128i, b: __m128 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(2)] -pub fn _mm512_shrdi_epi16(a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_shrdi_epi16(a: __m512i, b: __m512i) -> __m512i { static_assert_uimm_bits!(IMM8, 8); _mm512_shrdv_epi16(a, b, _mm512_set1_epi16(IMM8 as i16)) } @@ -2073,7 +2233,8 @@ pub fn _mm512_shrdi_epi16(a: __m512i, b: __m512i) -> __m512i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(4)] -pub fn _mm512_mask_shrdi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_shrdi_epi16( src: __m512i, k: __mmask32, a: __m512i, @@ -2094,7 +2255,12 @@ pub fn _mm512_mask_shrdi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(3)] -pub fn _mm512_maskz_shrdi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_shrdi_epi16( + k: __mmask32, + a: __m512i, + b: __m512i, +) -> __m512i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm512_shrdi_epi16::(a, b).as_i16x32(); @@ -2110,7 +2276,8 @@ pub fn _mm512_maskz_shrdi_epi16(k: __mmask32, a: __m512i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(2)] -pub fn _mm256_shrdi_epi16(a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_shrdi_epi16(a: __m256i, b: __m256i) -> __m256i { static_assert_uimm_bits!(IMM8, 8); _mm256_shrdv_epi16(a, b, _mm256_set1_epi16(IMM8 as i16)) } @@ -2123,7 +2290,8 @@ pub fn _mm256_shrdi_epi16(a: __m256i, b: __m256i) -> __m256i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(4)] -pub fn _mm256_mask_shrdi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_shrdi_epi16( src: __m256i, k: __mmask16, a: __m256i, @@ -2144,7 +2312,12 @@ pub fn _mm256_mask_shrdi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(3)] -pub fn _mm256_maskz_shrdi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_shrdi_epi16( + k: __mmask16, + a: __m256i, + b: __m256i, +) -> __m256i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm256_shrdi_epi16::(a, b).as_i16x16(); @@ -2160,7 +2333,8 @@ pub fn _mm256_maskz_shrdi_epi16(k: __mmask16, a: __m256i, b: __ #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(2)] -pub fn _mm_shrdi_epi16(a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_shrdi_epi16(a: __m128i, b: __m128i) -> __m128i { static_assert_uimm_bits!(IMM8, 8); _mm_shrdv_epi16(a, b, _mm_set1_epi16(IMM8 as i16)) } @@ -2173,7 +2347,8 @@ pub fn _mm_shrdi_epi16(a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(4)] -pub fn _mm_mask_shrdi_epi16( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_shrdi_epi16( src: __m128i, k: __mmask8, a: __m128i, @@ -2194,7 +2369,12 @@ pub fn _mm_mask_shrdi_epi16( #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpshldw, IMM8 = 5))] //should be vpshrdw #[rustc_legacy_const_generics(3)] -pub fn _mm_maskz_shrdi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_shrdi_epi16( + k: __mmask8, + a: __m128i, + b: __m128i, +) -> __m128i { unsafe { static_assert_uimm_bits!(IMM8, 8); let shf = _mm_shrdi_epi16::(a, b).as_i16x8(); @@ -2262,6 +2442,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; @@ -2581,7 +2762,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shldv_epi64() { + const unsafe fn test_mm512_shldv_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(1 << 63); let c = _mm512_set1_epi64(2); @@ -2591,7 +2772,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shldv_epi64() { + const unsafe fn test_mm512_mask_shldv_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(1 << 63); let c = _mm512_set1_epi64(2); @@ -2603,7 +2784,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shldv_epi64() { + const unsafe fn test_mm512_maskz_shldv_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(1 << 63); let c = _mm512_set1_epi64(2); @@ -2615,7 +2796,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shldv_epi64() { + const unsafe fn test_mm256_shldv_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(1 << 63); let c = _mm256_set1_epi64x(2); @@ -2625,7 +2806,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shldv_epi64() { + const unsafe fn test_mm256_mask_shldv_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(1 << 63); let c = _mm256_set1_epi64x(2); @@ -2637,7 +2818,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shldv_epi64() { + const unsafe fn test_mm256_maskz_shldv_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(1 << 63); let c = _mm256_set1_epi64x(2); @@ -2649,7 +2830,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shldv_epi64() { + const unsafe fn test_mm_shldv_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(1 << 63); let c = _mm_set1_epi64x(2); @@ -2659,7 +2840,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shldv_epi64() { + const unsafe fn test_mm_mask_shldv_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(1 << 63); let c = _mm_set1_epi64x(2); @@ -2671,7 +2852,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shldv_epi64() { + const unsafe fn test_mm_maskz_shldv_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(1 << 63); let c = _mm_set1_epi64x(2); @@ -2683,7 +2864,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shldv_epi32() { + const unsafe fn test_mm512_shldv_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(1 << 31); let c = _mm512_set1_epi32(2); @@ -2693,7 +2874,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shldv_epi32() { + const unsafe fn test_mm512_mask_shldv_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(1 << 31); let c = _mm512_set1_epi32(2); @@ -2705,7 +2886,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shldv_epi32() { + const unsafe fn test_mm512_maskz_shldv_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(1 << 31); let c = _mm512_set1_epi32(2); @@ -2717,7 +2898,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shldv_epi32() { + const unsafe fn test_mm256_shldv_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(1 << 31); let c = _mm256_set1_epi32(2); @@ -2727,7 +2908,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shldv_epi32() { + const unsafe fn test_mm256_mask_shldv_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(1 << 31); let c = _mm256_set1_epi32(2); @@ -2739,7 +2920,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shldv_epi32() { + const unsafe fn test_mm256_maskz_shldv_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(1 << 31); let c = _mm256_set1_epi32(2); @@ -2751,7 +2932,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shldv_epi32() { + const unsafe fn test_mm_shldv_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(1 << 31); let c = _mm_set1_epi32(2); @@ -2761,7 +2942,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shldv_epi32() { + const unsafe fn test_mm_mask_shldv_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(1 << 31); let c = _mm_set1_epi32(2); @@ -2773,7 +2954,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shldv_epi32() { + const unsafe fn test_mm_maskz_shldv_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(1 << 31); let c = _mm_set1_epi32(2); @@ -2785,7 +2966,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shldv_epi16() { + const unsafe fn test_mm512_shldv_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1 << 15); let c = _mm512_set1_epi16(2); @@ -2795,7 +2976,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shldv_epi16() { + const unsafe fn test_mm512_mask_shldv_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1 << 15); let c = _mm512_set1_epi16(2); @@ -2807,7 +2988,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shldv_epi16() { + const unsafe fn test_mm512_maskz_shldv_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1 << 15); let c = _mm512_set1_epi16(2); @@ -2819,7 +3000,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shldv_epi16() { + const unsafe fn test_mm256_shldv_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1 << 15); let c = _mm256_set1_epi16(2); @@ -2829,7 +3010,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shldv_epi16() { + const unsafe fn test_mm256_mask_shldv_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1 << 15); let c = _mm256_set1_epi16(2); @@ -2841,7 +3022,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shldv_epi16() { + const unsafe fn test_mm256_maskz_shldv_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1 << 15); let c = _mm256_set1_epi16(2); @@ -2853,7 +3034,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shldv_epi16() { + const unsafe fn test_mm_shldv_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1 << 15); let c = _mm_set1_epi16(2); @@ -2863,7 +3044,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shldv_epi16() { + const unsafe fn test_mm_mask_shldv_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1 << 15); let c = _mm_set1_epi16(2); @@ -2875,7 +3056,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shldv_epi16() { + const unsafe fn test_mm_maskz_shldv_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1 << 15); let c = _mm_set1_epi16(2); @@ -2887,7 +3068,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shrdv_epi64() { + const unsafe fn test_mm512_shrdv_epi64() { let a = _mm512_set1_epi64(2); let b = _mm512_set1_epi64(8); let c = _mm512_set1_epi64(1); @@ -2897,7 +3078,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shrdv_epi64() { + const unsafe fn test_mm512_mask_shrdv_epi64() { let a = _mm512_set1_epi64(2); let b = _mm512_set1_epi64(8); let c = _mm512_set1_epi64(1); @@ -2909,7 +3090,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shrdv_epi64() { + const unsafe fn test_mm512_maskz_shrdv_epi64() { let a = _mm512_set1_epi64(2); let b = _mm512_set1_epi64(8); let c = _mm512_set1_epi64(1); @@ -2921,7 +3102,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shrdv_epi64() { + const unsafe fn test_mm256_shrdv_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(8); let c = _mm256_set1_epi64x(1); @@ -2931,7 +3112,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shrdv_epi64() { + const unsafe fn test_mm256_mask_shrdv_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(8); let c = _mm256_set1_epi64x(1); @@ -2943,7 +3124,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shrdv_epi64() { + const unsafe fn test_mm256_maskz_shrdv_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(8); let c = _mm256_set1_epi64x(1); @@ -2955,7 +3136,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shrdv_epi64() { + const unsafe fn test_mm_shrdv_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(8); let c = _mm_set1_epi64x(1); @@ -2965,7 +3146,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shrdv_epi64() { + const unsafe fn test_mm_mask_shrdv_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(8); let c = _mm_set1_epi64x(1); @@ -2977,7 +3158,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shrdv_epi64() { + const unsafe fn test_mm_maskz_shrdv_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(8); let c = _mm_set1_epi64x(1); @@ -2989,7 +3170,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shrdv_epi32() { + const unsafe fn test_mm512_shrdv_epi32() { let a = _mm512_set1_epi32(2); let b = _mm512_set1_epi32(8); let c = _mm512_set1_epi32(1); @@ -2999,7 +3180,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shrdv_epi32() { + const unsafe fn test_mm512_mask_shrdv_epi32() { let a = _mm512_set1_epi32(2); let b = _mm512_set1_epi32(8); let c = _mm512_set1_epi32(1); @@ -3011,7 +3192,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shrdv_epi32() { + const unsafe fn test_mm512_maskz_shrdv_epi32() { let a = _mm512_set1_epi32(2); let b = _mm512_set1_epi32(8); let c = _mm512_set1_epi32(1); @@ -3023,7 +3204,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shrdv_epi32() { + const unsafe fn test_mm256_shrdv_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(8); let c = _mm256_set1_epi32(1); @@ -3033,7 +3214,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shrdv_epi32() { + const unsafe fn test_mm256_mask_shrdv_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(8); let c = _mm256_set1_epi32(1); @@ -3045,7 +3226,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shrdv_epi32() { + const unsafe fn test_mm256_maskz_shrdv_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(8); let c = _mm256_set1_epi32(1); @@ -3057,7 +3238,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shrdv_epi32() { + const unsafe fn test_mm_shrdv_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(8); let c = _mm_set1_epi32(1); @@ -3067,7 +3248,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shrdv_epi32() { + const unsafe fn test_mm_mask_shrdv_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(8); let c = _mm_set1_epi32(1); @@ -3079,7 +3260,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shrdv_epi32() { + const unsafe fn test_mm_maskz_shrdv_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(8); let c = _mm_set1_epi32(1); @@ -3091,7 +3272,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shrdv_epi16() { + const unsafe fn test_mm512_shrdv_epi16() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(8); let c = _mm512_set1_epi16(1); @@ -3101,7 +3282,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shrdv_epi16() { + const unsafe fn test_mm512_mask_shrdv_epi16() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(8); let c = _mm512_set1_epi16(1); @@ -3113,7 +3294,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shrdv_epi16() { + const unsafe fn test_mm512_maskz_shrdv_epi16() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(8); let c = _mm512_set1_epi16(1); @@ -3125,7 +3306,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shrdv_epi16() { + const unsafe fn test_mm256_shrdv_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(8); let c = _mm256_set1_epi16(1); @@ -3135,7 +3316,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shrdv_epi16() { + const unsafe fn test_mm256_mask_shrdv_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(8); let c = _mm256_set1_epi16(1); @@ -3147,7 +3328,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shrdv_epi16() { + const unsafe fn test_mm256_maskz_shrdv_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(8); let c = _mm256_set1_epi16(1); @@ -3159,7 +3340,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shrdv_epi16() { + const unsafe fn test_mm_shrdv_epi16() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(8); let c = _mm_set1_epi16(1); @@ -3169,7 +3350,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shrdv_epi16() { + const unsafe fn test_mm_mask_shrdv_epi16() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(8); let c = _mm_set1_epi16(1); @@ -3181,7 +3362,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shrdv_epi16() { + const unsafe fn test_mm_maskz_shrdv_epi16() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(8); let c = _mm_set1_epi16(1); @@ -3193,7 +3374,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shldi_epi64() { + const unsafe fn test_mm512_shldi_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(1 << 63); let r = _mm512_shldi_epi64::<2>(a, b); @@ -3202,7 +3383,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shldi_epi64() { + const unsafe fn test_mm512_mask_shldi_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(1 << 63); let r = _mm512_mask_shldi_epi64::<2>(a, 0, a, b); @@ -3213,7 +3394,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shldi_epi64() { + const unsafe fn test_mm512_maskz_shldi_epi64() { let a = _mm512_set1_epi64(1); let b = _mm512_set1_epi64(1 << 63); let r = _mm512_maskz_shldi_epi64::<2>(0, a, b); @@ -3224,7 +3405,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shldi_epi64() { + const unsafe fn test_mm256_shldi_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(1 << 63); let r = _mm256_shldi_epi64::<2>(a, b); @@ -3233,7 +3414,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shldi_epi64() { + const unsafe fn test_mm256_mask_shldi_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(1 << 63); let r = _mm256_mask_shldi_epi64::<2>(a, 0, a, b); @@ -3244,7 +3425,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shldi_epi64() { + const unsafe fn test_mm256_maskz_shldi_epi64() { let a = _mm256_set1_epi64x(1); let b = _mm256_set1_epi64x(1 << 63); let r = _mm256_maskz_shldi_epi64::<2>(0, a, b); @@ -3255,7 +3436,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shldi_epi64() { + const unsafe fn test_mm_shldi_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(1 << 63); let r = _mm_shldi_epi64::<2>(a, b); @@ -3264,7 +3445,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shldi_epi64() { + const unsafe fn test_mm_mask_shldi_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(1 << 63); let r = _mm_mask_shldi_epi64::<2>(a, 0, a, b); @@ -3275,7 +3456,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shldi_epi64() { + const unsafe fn test_mm_maskz_shldi_epi64() { let a = _mm_set1_epi64x(1); let b = _mm_set1_epi64x(1 << 63); let r = _mm_maskz_shldi_epi64::<2>(0, a, b); @@ -3286,7 +3467,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shldi_epi32() { + const unsafe fn test_mm512_shldi_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(1 << 31); let r = _mm512_shldi_epi32::<2>(a, b); @@ -3295,7 +3476,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shldi_epi32() { + const unsafe fn test_mm512_mask_shldi_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(1 << 31); let r = _mm512_mask_shldi_epi32::<2>(a, 0, a, b); @@ -3306,7 +3487,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shldi_epi32() { + const unsafe fn test_mm512_maskz_shldi_epi32() { let a = _mm512_set1_epi32(1); let b = _mm512_set1_epi32(1 << 31); let r = _mm512_maskz_shldi_epi32::<2>(0, a, b); @@ -3317,7 +3498,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shldi_epi32() { + const unsafe fn test_mm256_shldi_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(1 << 31); let r = _mm256_shldi_epi32::<2>(a, b); @@ -3326,7 +3507,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shldi_epi32() { + const unsafe fn test_mm256_mask_shldi_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(1 << 31); let r = _mm256_mask_shldi_epi32::<2>(a, 0, a, b); @@ -3337,7 +3518,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shldi_epi32() { + const unsafe fn test_mm256_maskz_shldi_epi32() { let a = _mm256_set1_epi32(1); let b = _mm256_set1_epi32(1 << 31); let r = _mm256_maskz_shldi_epi32::<2>(0, a, b); @@ -3348,7 +3529,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shldi_epi32() { + const unsafe fn test_mm_shldi_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(1 << 31); let r = _mm_shldi_epi32::<2>(a, b); @@ -3357,7 +3538,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shldi_epi32() { + const unsafe fn test_mm_mask_shldi_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(1 << 31); let r = _mm_mask_shldi_epi32::<2>(a, 0, a, b); @@ -3368,7 +3549,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shldi_epi32() { + const unsafe fn test_mm_maskz_shldi_epi32() { let a = _mm_set1_epi32(1); let b = _mm_set1_epi32(1 << 31); let r = _mm_maskz_shldi_epi32::<2>(0, a, b); @@ -3379,7 +3560,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shldi_epi16() { + const unsafe fn test_mm512_shldi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1 << 15); let r = _mm512_shldi_epi16::<2>(a, b); @@ -3388,7 +3569,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shldi_epi16() { + const unsafe fn test_mm512_mask_shldi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1 << 15); let r = _mm512_mask_shldi_epi16::<2>(a, 0, a, b); @@ -3399,7 +3580,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shldi_epi16() { + const unsafe fn test_mm512_maskz_shldi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1 << 15); let r = _mm512_maskz_shldi_epi16::<2>(0, a, b); @@ -3410,7 +3591,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shldi_epi16() { + const unsafe fn test_mm256_shldi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1 << 15); let r = _mm256_shldi_epi16::<2>(a, b); @@ -3419,7 +3600,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shldi_epi16() { + const unsafe fn test_mm256_mask_shldi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1 << 15); let r = _mm256_mask_shldi_epi16::<2>(a, 0, a, b); @@ -3430,7 +3611,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shldi_epi16() { + const unsafe fn test_mm256_maskz_shldi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1 << 15); let r = _mm256_maskz_shldi_epi16::<2>(0, a, b); @@ -3441,7 +3622,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shldi_epi16() { + const unsafe fn test_mm_shldi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1 << 15); let r = _mm_shldi_epi16::<2>(a, b); @@ -3450,7 +3631,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shldi_epi16() { + const unsafe fn test_mm_mask_shldi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1 << 15); let r = _mm_mask_shldi_epi16::<2>(a, 0, a, b); @@ -3461,7 +3642,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shldi_epi16() { + const unsafe fn test_mm_maskz_shldi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1 << 15); let r = _mm_maskz_shldi_epi16::<2>(0, a, b); @@ -3472,7 +3653,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shrdi_epi64() { + const unsafe fn test_mm512_shrdi_epi64() { let a = _mm512_set1_epi64(2); let b = _mm512_set1_epi64(8); let r = _mm512_shrdi_epi64::<1>(a, b); @@ -3481,7 +3662,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shrdi_epi64() { + const unsafe fn test_mm512_mask_shrdi_epi64() { let a = _mm512_set1_epi64(2); let b = _mm512_set1_epi64(8); let r = _mm512_mask_shrdi_epi64::<1>(a, 0, a, b); @@ -3492,7 +3673,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shrdi_epi64() { + const unsafe fn test_mm512_maskz_shrdi_epi64() { let a = _mm512_set1_epi64(2); let b = _mm512_set1_epi64(8); let r = _mm512_maskz_shrdi_epi64::<1>(0, a, b); @@ -3503,7 +3684,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shrdi_epi64() { + const unsafe fn test_mm256_shrdi_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(8); let r = _mm256_shrdi_epi64::<1>(a, b); @@ -3512,7 +3693,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shrdi_epi64() { + const unsafe fn test_mm256_mask_shrdi_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(8); let r = _mm256_mask_shrdi_epi64::<1>(a, 0, a, b); @@ -3523,7 +3704,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shrdi_epi64() { + const unsafe fn test_mm256_maskz_shrdi_epi64() { let a = _mm256_set1_epi64x(2); let b = _mm256_set1_epi64x(8); let r = _mm256_maskz_shrdi_epi64::<1>(0, a, b); @@ -3534,7 +3715,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shrdi_epi64() { + const unsafe fn test_mm_shrdi_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(8); let r = _mm_shrdi_epi64::<1>(a, b); @@ -3543,7 +3724,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shrdi_epi64() { + const unsafe fn test_mm_mask_shrdi_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(8); let r = _mm_mask_shrdi_epi64::<1>(a, 0, a, b); @@ -3554,7 +3735,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shrdi_epi64() { + const unsafe fn test_mm_maskz_shrdi_epi64() { let a = _mm_set1_epi64x(2); let b = _mm_set1_epi64x(8); let r = _mm_maskz_shrdi_epi64::<1>(0, a, b); @@ -3565,7 +3746,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shrdi_epi32() { + const unsafe fn test_mm512_shrdi_epi32() { let a = _mm512_set1_epi32(2); let b = _mm512_set1_epi32(8); let r = _mm512_shrdi_epi32::<1>(a, b); @@ -3574,7 +3755,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shrdi_epi32() { + const unsafe fn test_mm512_mask_shrdi_epi32() { let a = _mm512_set1_epi32(2); let b = _mm512_set1_epi32(8); let r = _mm512_mask_shrdi_epi32::<1>(a, 0, a, b); @@ -3585,7 +3766,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shrdi_epi32() { + const unsafe fn test_mm512_maskz_shrdi_epi32() { let a = _mm512_set1_epi32(2); let b = _mm512_set1_epi32(8); let r = _mm512_maskz_shrdi_epi32::<1>(0, a, b); @@ -3596,7 +3777,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shrdi_epi32() { + const unsafe fn test_mm256_shrdi_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(8); let r = _mm256_shrdi_epi32::<1>(a, b); @@ -3605,7 +3786,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shrdi_epi32() { + const unsafe fn test_mm256_mask_shrdi_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(8); let r = _mm256_mask_shrdi_epi32::<1>(a, 0, a, b); @@ -3616,7 +3797,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shrdi_epi32() { + const unsafe fn test_mm256_maskz_shrdi_epi32() { let a = _mm256_set1_epi32(2); let b = _mm256_set1_epi32(8); let r = _mm256_maskz_shrdi_epi32::<1>(0, a, b); @@ -3627,7 +3808,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shrdi_epi32() { + const unsafe fn test_mm_shrdi_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(8); let r = _mm_shrdi_epi32::<1>(a, b); @@ -3636,7 +3817,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shrdi_epi32() { + const unsafe fn test_mm_mask_shrdi_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(8); let r = _mm_mask_shrdi_epi32::<1>(a, 0, a, b); @@ -3647,7 +3828,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shrdi_epi32() { + const unsafe fn test_mm_maskz_shrdi_epi32() { let a = _mm_set1_epi32(2); let b = _mm_set1_epi32(8); let r = _mm_maskz_shrdi_epi32::<1>(0, a, b); @@ -3658,7 +3839,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_shrdi_epi16() { + const unsafe fn test_mm512_shrdi_epi16() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(8); let r = _mm512_shrdi_epi16::<1>(a, b); @@ -3667,7 +3848,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_mask_shrdi_epi16() { + const unsafe fn test_mm512_mask_shrdi_epi16() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(8); let r = _mm512_mask_shrdi_epi16::<1>(a, 0, a, b); @@ -3678,7 +3859,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2")] - unsafe fn test_mm512_maskz_shrdi_epi16() { + const unsafe fn test_mm512_maskz_shrdi_epi16() { let a = _mm512_set1_epi16(2); let b = _mm512_set1_epi16(8); let r = _mm512_maskz_shrdi_epi16::<1>(0, a, b); @@ -3689,7 +3870,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_shrdi_epi16() { + const unsafe fn test_mm256_shrdi_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(8); let r = _mm256_shrdi_epi16::<1>(a, b); @@ -3698,7 +3879,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_mask_shrdi_epi16() { + const unsafe fn test_mm256_mask_shrdi_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(8); let r = _mm256_mask_shrdi_epi16::<1>(a, 0, a, b); @@ -3709,7 +3890,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm256_maskz_shrdi_epi16() { + const unsafe fn test_mm256_maskz_shrdi_epi16() { let a = _mm256_set1_epi16(2); let b = _mm256_set1_epi16(8); let r = _mm256_maskz_shrdi_epi16::<1>(0, a, b); @@ -3720,7 +3901,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_shrdi_epi16() { + const unsafe fn test_mm_shrdi_epi16() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(8); let r = _mm_shrdi_epi16::<1>(a, b); @@ -3729,7 +3910,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_mask_shrdi_epi16() { + const unsafe fn test_mm_mask_shrdi_epi16() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(8); let r = _mm_mask_shrdi_epi16::<1>(a, 0, a, b); @@ -3740,7 +3921,7 @@ mod tests { } #[simd_test(enable = "avx512vbmi2,avx512vl")] - unsafe fn test_mm_maskz_shrdi_epi16() { + const unsafe fn test_mm_maskz_shrdi_epi16() { let a = _mm_set1_epi16(2); let b = _mm_set1_epi16(8); let r = _mm_maskz_shrdi_epi16::<1>(0, a, b); From 2e6bdf2b733dfa66f12ad9ababbb0404121014fc Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 18:28:32 +0530 Subject: [PATCH 073/489] Make `avx512bitalg` functions const --- .../crates/core_arch/src/x86/avx512bitalg.rs | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs b/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs index 1cbf0faea09f..832a58432208 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs @@ -43,7 +43,8 @@ unsafe extern "C" { #[target_feature(enable = "avx512bitalg")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm512_popcnt_epi16(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_popcnt_epi16(a: __m512i) -> __m512i { unsafe { transmute(simd_ctpop(a.as_i16x32())) } } @@ -57,7 +58,8 @@ pub fn _mm512_popcnt_epi16(a: __m512i) -> __m512i { #[target_feature(enable = "avx512bitalg")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm512_maskz_popcnt_epi16(k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_popcnt_epi16(k: __mmask32, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -77,7 +79,8 @@ pub fn _mm512_maskz_popcnt_epi16(k: __mmask32, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bitalg")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm512_mask_popcnt_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_popcnt_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -94,7 +97,8 @@ pub fn _mm512_mask_popcnt_epi16(src: __m512i, k: __mmask32, a: __m512i) -> __m51 #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm256_popcnt_epi16(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_popcnt_epi16(a: __m256i) -> __m256i { unsafe { transmute(simd_ctpop(a.as_i16x16())) } } @@ -108,7 +112,8 @@ pub fn _mm256_popcnt_epi16(a: __m256i) -> __m256i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm256_maskz_popcnt_epi16(k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_popcnt_epi16(k: __mmask16, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -128,7 +133,8 @@ pub fn _mm256_maskz_popcnt_epi16(k: __mmask16, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm256_mask_popcnt_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_popcnt_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -145,7 +151,8 @@ pub fn _mm256_mask_popcnt_epi16(src: __m256i, k: __mmask16, a: __m256i) -> __m25 #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm_popcnt_epi16(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_popcnt_epi16(a: __m128i) -> __m128i { unsafe { transmute(simd_ctpop(a.as_i16x8())) } } @@ -159,7 +166,8 @@ pub fn _mm_popcnt_epi16(a: __m128i) -> __m128i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm_maskz_popcnt_epi16(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_popcnt_epi16(k: __mmask8, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -179,7 +187,8 @@ pub fn _mm_maskz_popcnt_epi16(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntw))] -pub fn _mm_mask_popcnt_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_popcnt_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -196,7 +205,8 @@ pub fn _mm_mask_popcnt_epi16(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bitalg")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm512_popcnt_epi8(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_popcnt_epi8(a: __m512i) -> __m512i { unsafe { transmute(simd_ctpop(a.as_i8x64())) } } @@ -210,7 +220,8 @@ pub fn _mm512_popcnt_epi8(a: __m512i) -> __m512i { #[target_feature(enable = "avx512bitalg")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm512_maskz_popcnt_epi8(k: __mmask64, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_popcnt_epi8(k: __mmask64, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -230,7 +241,8 @@ pub fn _mm512_maskz_popcnt_epi8(k: __mmask64, a: __m512i) -> __m512i { #[target_feature(enable = "avx512bitalg")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm512_mask_popcnt_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_popcnt_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -247,7 +259,8 @@ pub fn _mm512_mask_popcnt_epi8(src: __m512i, k: __mmask64, a: __m512i) -> __m512 #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm256_popcnt_epi8(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_popcnt_epi8(a: __m256i) -> __m256i { unsafe { transmute(simd_ctpop(a.as_i8x32())) } } @@ -261,7 +274,8 @@ pub fn _mm256_popcnt_epi8(a: __m256i) -> __m256i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm256_maskz_popcnt_epi8(k: __mmask32, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_popcnt_epi8(k: __mmask32, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -281,7 +295,8 @@ pub fn _mm256_maskz_popcnt_epi8(k: __mmask32, a: __m256i) -> __m256i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm256_mask_popcnt_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_popcnt_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -298,7 +313,8 @@ pub fn _mm256_mask_popcnt_epi8(src: __m256i, k: __mmask32, a: __m256i) -> __m256 #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm_popcnt_epi8(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_popcnt_epi8(a: __m128i) -> __m128i { unsafe { transmute(simd_ctpop(a.as_i8x16())) } } @@ -312,7 +328,8 @@ pub fn _mm_popcnt_epi8(a: __m128i) -> __m128i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm_maskz_popcnt_epi8(k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_popcnt_epi8(k: __mmask16, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -332,7 +349,8 @@ pub fn _mm_maskz_popcnt_epi8(k: __mmask16, a: __m128i) -> __m128i { #[target_feature(enable = "avx512bitalg,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntb))] -pub fn _mm_mask_popcnt_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_popcnt_epi8(src: __m128i, k: __mmask16, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -436,12 +454,13 @@ mod tests { // __mXXXi happens to be defined in terms of signed integers. #![allow(overflowing_literals)] + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "avx512bitalg,avx512f")] - unsafe fn test_mm512_popcnt_epi16() { + const unsafe fn test_mm512_popcnt_epi16() { let test_data = _mm512_set_epi16( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1_FF, 0x3_FF, 0x7_FF, 0xF_FF, 0x1F_FF, 0x3F_FF, 0x7F_FF, 0xFF_FF, -1, -100, 255, 256, 2, 4, 8, 16, 32, 64, 128, 256, 512, @@ -456,7 +475,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f")] - unsafe fn test_mm512_maskz_popcnt_epi16() { + const unsafe fn test_mm512_maskz_popcnt_epi16() { let test_data = _mm512_set_epi16( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1_FF, 0x3_FF, 0x7_FF, 0xF_FF, 0x1F_FF, 0x3F_FF, 0x7F_FF, 0xFF_FF, -1, -100, 255, 256, 2, 4, 8, 16, 32, 64, 128, 256, 512, @@ -472,7 +491,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f")] - unsafe fn test_mm512_mask_popcnt_epi16() { + const unsafe fn test_mm512_mask_popcnt_epi16() { let test_data = _mm512_set_epi16( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1_FF, 0x3_FF, 0x7_FF, 0xF_FF, 0x1F_FF, 0x3F_FF, 0x7F_FF, 0xFF_FF, -1, -100, 255, 256, 2, 4, 8, 16, 32, 64, 128, 256, 512, @@ -488,7 +507,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm256_popcnt_epi16() { + const unsafe fn test_mm256_popcnt_epi16() { let test_data = _mm256_set_epi16( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1_FF, 0x3_FF, 0x7_FF, 0xF_FF, 0x1F_FF, 0x3F_FF, 0x7F_FF, @@ -500,7 +519,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm256_maskz_popcnt_epi16() { + const unsafe fn test_mm256_maskz_popcnt_epi16() { let test_data = _mm256_set_epi16( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1_FF, 0x3_FF, 0x7_FF, 0xF_FF, 0x1F_FF, 0x3F_FF, 0x7F_FF, @@ -512,7 +531,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm256_mask_popcnt_epi16() { + const unsafe fn test_mm256_mask_popcnt_epi16() { let test_data = _mm256_set_epi16( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1_FF, 0x3_FF, 0x7_FF, 0xF_FF, 0x1F_FF, 0x3F_FF, 0x7F_FF, @@ -526,7 +545,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm_popcnt_epi16() { + const unsafe fn test_mm_popcnt_epi16() { let test_data = _mm_set_epi16(0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F); let actual_result = _mm_popcnt_epi16(test_data); let reference_result = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); @@ -534,7 +553,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm_maskz_popcnt_epi16() { + const unsafe fn test_mm_maskz_popcnt_epi16() { let test_data = _mm_set_epi16(0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F); let mask = 0xF0; let actual_result = _mm_maskz_popcnt_epi16(mask, test_data); @@ -543,7 +562,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm_mask_popcnt_epi16() { + const unsafe fn test_mm_mask_popcnt_epi16() { let test_data = _mm_set_epi16(0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F); let mask = 0xF0; let actual_result = _mm_mask_popcnt_epi16(test_data, mask, test_data); @@ -552,7 +571,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f")] - unsafe fn test_mm512_popcnt_epi8() { + const unsafe fn test_mm512_popcnt_epi8() { let test_data = _mm512_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, 128, 171, 206, 100, 217, 109, 253, 190, 177, 254, 179, 215, 230, 68, 201, 172, 183, 154, 84, 56, 227, 189, @@ -569,7 +588,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f")] - unsafe fn test_mm512_maskz_popcnt_epi8() { + const unsafe fn test_mm512_maskz_popcnt_epi8() { let test_data = _mm512_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, 128, 171, 206, 100, 217, 109, 253, 190, 177, 254, 179, 215, 230, 68, 201, 172, 183, 154, 84, 56, 227, 189, @@ -587,7 +606,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f")] - unsafe fn test_mm512_mask_popcnt_epi8() { + const unsafe fn test_mm512_mask_popcnt_epi8() { let test_data = _mm512_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, 128, 171, 206, 100, 217, 109, 253, 190, 177, 254, 179, 215, 230, 68, 201, 172, 183, 154, 84, 56, 227, 189, @@ -605,7 +624,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm256_popcnt_epi8() { + const unsafe fn test_mm256_popcnt_epi8() { let test_data = _mm256_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, 128, 171, 206, 100, 217, 109, 253, 190, 177, 254, 179, 215, 230, 68, 201, 172, @@ -619,7 +638,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm256_maskz_popcnt_epi8() { + const unsafe fn test_mm256_maskz_popcnt_epi8() { let test_data = _mm256_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, 251, 73, 121, 143, 145, 85, 91, 137, 90, 225, 21, 249, 211, 155, 228, 70, @@ -634,7 +653,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm256_mask_popcnt_epi8() { + const unsafe fn test_mm256_mask_popcnt_epi8() { let test_data = _mm256_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, 251, 73, 121, 143, 145, 85, 91, 137, 90, 225, 21, 249, 211, 155, 228, 70, @@ -649,7 +668,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm_popcnt_epi8() { + const unsafe fn test_mm_popcnt_epi8() { let test_data = _mm_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, -1, 2, 4, 8, 16, 32, 64, ); @@ -659,7 +678,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm_maskz_popcnt_epi8() { + const unsafe fn test_mm_maskz_popcnt_epi8() { let test_data = _mm_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 90, 225, 21, 249, 211, 155, 228, 70, ); @@ -670,7 +689,7 @@ mod tests { } #[simd_test(enable = "avx512bitalg,avx512f,avx512vl")] - unsafe fn test_mm_mask_popcnt_epi8() { + const unsafe fn test_mm_mask_popcnt_epi8() { let test_data = _mm_set_epi8( 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, 90, 225, 21, 249, 211, 155, 228, 70, ); From 4506af45ddf0311558369451623cfd697b45f3b4 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:06:52 +0530 Subject: [PATCH 074/489] Make `avx512vpopcntdq` functions const --- .../core_arch/src/x86/avx512vpopcntdq.rs | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs b/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs index e47a14b24dfc..42bff33a286d 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs @@ -26,7 +26,8 @@ use stdarch_test::assert_instr; #[target_feature(enable = "avx512vpopcntdq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm512_popcnt_epi32(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_popcnt_epi32(a: __m512i) -> __m512i { unsafe { transmute(simd_ctpop(a.as_i32x16())) } } @@ -40,7 +41,8 @@ pub fn _mm512_popcnt_epi32(a: __m512i) -> __m512i { #[target_feature(enable = "avx512vpopcntdq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm512_maskz_popcnt_epi32(k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_popcnt_epi32(k: __mmask16, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -60,7 +62,8 @@ pub fn _mm512_maskz_popcnt_epi32(k: __mmask16, a: __m512i) -> __m512i { #[target_feature(enable = "avx512vpopcntdq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm512_mask_popcnt_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_popcnt_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -77,7 +80,8 @@ pub fn _mm512_mask_popcnt_epi32(src: __m512i, k: __mmask16, a: __m512i) -> __m51 #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm256_popcnt_epi32(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_popcnt_epi32(a: __m256i) -> __m256i { unsafe { transmute(simd_ctpop(a.as_i32x8())) } } @@ -91,7 +95,8 @@ pub fn _mm256_popcnt_epi32(a: __m256i) -> __m256i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm256_maskz_popcnt_epi32(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_popcnt_epi32(k: __mmask8, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -111,7 +116,8 @@ pub fn _mm256_maskz_popcnt_epi32(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm256_mask_popcnt_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_popcnt_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -128,7 +134,8 @@ pub fn _mm256_mask_popcnt_epi32(src: __m256i, k: __mmask8, a: __m256i) -> __m256 #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm_popcnt_epi32(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_popcnt_epi32(a: __m128i) -> __m128i { unsafe { transmute(simd_ctpop(a.as_i32x4())) } } @@ -142,7 +149,8 @@ pub fn _mm_popcnt_epi32(a: __m128i) -> __m128i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm_maskz_popcnt_epi32(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_popcnt_epi32(k: __mmask8, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -162,7 +170,8 @@ pub fn _mm_maskz_popcnt_epi32(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntd))] -pub fn _mm_mask_popcnt_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_popcnt_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -179,7 +188,8 @@ pub fn _mm_mask_popcnt_epi32(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512vpopcntdq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm512_popcnt_epi64(a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_popcnt_epi64(a: __m512i) -> __m512i { unsafe { transmute(simd_ctpop(a.as_i64x8())) } } @@ -193,7 +203,8 @@ pub fn _mm512_popcnt_epi64(a: __m512i) -> __m512i { #[target_feature(enable = "avx512vpopcntdq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm512_maskz_popcnt_epi64(k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_popcnt_epi64(k: __mmask8, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -213,7 +224,8 @@ pub fn _mm512_maskz_popcnt_epi64(k: __mmask8, a: __m512i) -> __m512i { #[target_feature(enable = "avx512vpopcntdq")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm512_mask_popcnt_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_popcnt_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512i { unsafe { transmute(simd_select_bitmask( k, @@ -230,7 +242,8 @@ pub fn _mm512_mask_popcnt_epi64(src: __m512i, k: __mmask8, a: __m512i) -> __m512 #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm256_popcnt_epi64(a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_popcnt_epi64(a: __m256i) -> __m256i { unsafe { transmute(simd_ctpop(a.as_i64x4())) } } @@ -244,7 +257,8 @@ pub fn _mm256_popcnt_epi64(a: __m256i) -> __m256i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm256_maskz_popcnt_epi64(k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_popcnt_epi64(k: __mmask8, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -264,7 +278,8 @@ pub fn _mm256_maskz_popcnt_epi64(k: __mmask8, a: __m256i) -> __m256i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm256_mask_popcnt_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_popcnt_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256i { unsafe { transmute(simd_select_bitmask( k, @@ -281,7 +296,8 @@ pub fn _mm256_mask_popcnt_epi64(src: __m256i, k: __mmask8, a: __m256i) -> __m256 #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm_popcnt_epi64(a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_popcnt_epi64(a: __m128i) -> __m128i { unsafe { transmute(simd_ctpop(a.as_i64x2())) } } @@ -295,7 +311,8 @@ pub fn _mm_popcnt_epi64(a: __m128i) -> __m128i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm_maskz_popcnt_epi64(k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_popcnt_epi64(k: __mmask8, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -315,7 +332,8 @@ pub fn _mm_maskz_popcnt_epi64(k: __mmask8, a: __m128i) -> __m128i { #[target_feature(enable = "avx512vpopcntdq,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpopcntq))] -pub fn _mm_mask_popcnt_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_popcnt_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { unsafe { transmute(simd_select_bitmask( k, @@ -327,12 +345,13 @@ pub fn _mm_mask_popcnt_epi64(src: __m128i, k: __mmask8, a: __m128i) -> __m128i { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use stdarch_test::simd_test; use crate::core_arch::x86::*; #[simd_test(enable = "avx512vpopcntdq,avx512f")] - unsafe fn test_mm512_popcnt_epi32() { + const unsafe fn test_mm512_popcnt_epi32() { let test_data = _mm512_set_epi32( 0, 1, @@ -358,7 +377,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f")] - unsafe fn test_mm512_mask_popcnt_epi32() { + const unsafe fn test_mm512_mask_popcnt_epi32() { let test_data = _mm512_set_epi32( 0, 1, @@ -401,7 +420,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f")] - unsafe fn test_mm512_maskz_popcnt_epi32() { + const unsafe fn test_mm512_maskz_popcnt_epi32() { let test_data = _mm512_set_epi32( 0, 1, @@ -427,7 +446,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f,avx512vl")] - unsafe fn test_mm256_popcnt_epi32() { + const unsafe fn test_mm256_popcnt_epi32() { let test_data = _mm256_set_epi32(0, 1, -1, 2, 7, 0xFF_FE, 0x7F_FF_FF_FF, -100); let actual_result = _mm256_popcnt_epi32(test_data); let reference_result = _mm256_set_epi32(0, 1, 32, 1, 3, 15, 31, 28); @@ -435,7 +454,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f,avx512vl")] - unsafe fn test_mm256_mask_popcnt_epi32() { + const unsafe fn test_mm256_mask_popcnt_epi32() { let test_data = _mm256_set_epi32(0, 1, -1, 2, 7, 0xFF_FE, 0x7F_FF_FF_FF, -100); let mask = 0xF0; let actual_result = _mm256_mask_popcnt_epi32(test_data, mask, test_data); @@ -444,7 +463,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f,avx512vl")] - unsafe fn test_mm256_maskz_popcnt_epi32() { + const unsafe fn test_mm256_maskz_popcnt_epi32() { let test_data = _mm256_set_epi32(0, 1, -1, 2, 7, 0xFF_FE, 0x7F_FF_FF_FF, -100); let mask = 0xF0; let actual_result = _mm256_maskz_popcnt_epi32(mask, test_data); @@ -453,7 +472,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f,avx512vl")] - unsafe fn test_mm_popcnt_epi32() { + const unsafe fn test_mm_popcnt_epi32() { let test_data = _mm_set_epi32(0, 1, -1, -100); let actual_result = _mm_popcnt_epi32(test_data); let reference_result = _mm_set_epi32(0, 1, 32, 28); @@ -461,7 +480,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f,avx512vl")] - unsafe fn test_mm_mask_popcnt_epi32() { + const unsafe fn test_mm_mask_popcnt_epi32() { let test_data = _mm_set_epi32(0, 1, -1, -100); let mask = 0xE; let actual_result = _mm_mask_popcnt_epi32(test_data, mask, test_data); @@ -470,7 +489,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f,avx512vl")] - unsafe fn test_mm_maskz_popcnt_epi32() { + const unsafe fn test_mm_maskz_popcnt_epi32() { let test_data = _mm_set_epi32(0, 1, -1, -100); let mask = 0xE; let actual_result = _mm_maskz_popcnt_epi32(mask, test_data); @@ -479,7 +498,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f")] - unsafe fn test_mm512_popcnt_epi64() { + const unsafe fn test_mm512_popcnt_epi64() { let test_data = _mm512_set_epi64(0, 1, -1, 2, 7, 0xFF_FE, 0x7F_FF_FF_FF_FF_FF_FF_FF, -100); let actual_result = _mm512_popcnt_epi64(test_data); let reference_result = _mm512_set_epi64(0, 1, 64, 1, 3, 15, 63, 60); @@ -487,7 +506,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f")] - unsafe fn test_mm512_mask_popcnt_epi64() { + const unsafe fn test_mm512_mask_popcnt_epi64() { let test_data = _mm512_set_epi64(0, 1, -1, 2, 7, 0xFF_FE, 0x7F_FF_FF_FF_FF_FF_FF_FF, -100); let mask = 0xF0; let actual_result = _mm512_mask_popcnt_epi64(test_data, mask, test_data); @@ -497,7 +516,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512f")] - unsafe fn test_mm512_maskz_popcnt_epi64() { + const unsafe fn test_mm512_maskz_popcnt_epi64() { let test_data = _mm512_set_epi64(0, 1, -1, 2, 7, 0xFF_FE, 0x7F_FF_FF_FF_FF_FF_FF_FF, -100); let mask = 0xF0; let actual_result = _mm512_maskz_popcnt_epi64(mask, test_data); @@ -506,7 +525,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512vl")] - unsafe fn test_mm256_popcnt_epi64() { + const unsafe fn test_mm256_popcnt_epi64() { let test_data = _mm256_set_epi64x(0, 1, -1, -100); let actual_result = _mm256_popcnt_epi64(test_data); let reference_result = _mm256_set_epi64x(0, 1, 64, 60); @@ -514,7 +533,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512vl")] - unsafe fn test_mm256_mask_popcnt_epi64() { + const unsafe fn test_mm256_mask_popcnt_epi64() { let test_data = _mm256_set_epi64x(0, 1, -1, -100); let mask = 0xE; let actual_result = _mm256_mask_popcnt_epi64(test_data, mask, test_data); @@ -523,7 +542,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512vl")] - unsafe fn test_mm256_maskz_popcnt_epi64() { + const unsafe fn test_mm256_maskz_popcnt_epi64() { let test_data = _mm256_set_epi64x(0, 1, -1, -100); let mask = 0xE; let actual_result = _mm256_maskz_popcnt_epi64(mask, test_data); @@ -532,7 +551,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512vl")] - unsafe fn test_mm_popcnt_epi64() { + const unsafe fn test_mm_popcnt_epi64() { let test_data = _mm_set_epi64x(0, 1); let actual_result = _mm_popcnt_epi64(test_data); let reference_result = _mm_set_epi64x(0, 1); @@ -544,7 +563,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512vl")] - unsafe fn test_mm_mask_popcnt_epi64() { + const unsafe fn test_mm_mask_popcnt_epi64() { let test_data = _mm_set_epi64x(0, -100); let mask = 0x2; let actual_result = _mm_mask_popcnt_epi64(test_data, mask, test_data); @@ -558,7 +577,7 @@ mod tests { } #[simd_test(enable = "avx512vpopcntdq,avx512vl")] - unsafe fn test_mm_maskz_popcnt_epi64() { + const unsafe fn test_mm_maskz_popcnt_epi64() { let test_data = _mm_set_epi64x(0, 1); let mask = 0x2; let actual_result = _mm_maskz_popcnt_epi64(mask, test_data); From 92098dd82d4f03350a1e2ffbcb14ecf9bcf676a8 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 23 Sep 2025 19:11:35 +0530 Subject: [PATCH 075/489] Make `avx512fp16` functions const --- .../crates/core_arch/src/x86/avx512fp16.rs | 1105 ++++++++++------- .../stdarch/crates/core_arch/src/x86/f16c.rs | 11 +- 2 files changed, 671 insertions(+), 445 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs index 7185531606d2..de058c307308 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs @@ -9,7 +9,8 @@ use crate::ptr; #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_set_ph( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_ph( e7: f16, e6: f16, e5: f16, @@ -28,7 +29,8 @@ pub fn _mm_set_ph( #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_set_ph( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set_ph( e15: f16, e14: f16, e13: f16, @@ -57,7 +59,8 @@ pub fn _mm256_set_ph( #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_set_ph( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set_ph( e31: f16, e30: f16, e29: f16, @@ -104,7 +107,8 @@ pub fn _mm512_set_ph( #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_set_sh(a: f16) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set_sh(a: f16) -> __m128h { __m128h([a, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) } @@ -114,7 +118,8 @@ pub fn _mm_set_sh(a: f16) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_set1_ph(a: f16) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_set1_ph(a: f16) -> __m128h { unsafe { transmute(f16x8::splat(a)) } } @@ -124,7 +129,8 @@ pub fn _mm_set1_ph(a: f16) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_set1_ph(a: f16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_set1_ph(a: f16) -> __m256h { unsafe { transmute(f16x16::splat(a)) } } @@ -134,7 +140,8 @@ pub fn _mm256_set1_ph(a: f16) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_set1_ph(a: f16) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_set1_ph(a: f16) -> __m512h { unsafe { transmute(f16x32::splat(a)) } } @@ -144,7 +151,8 @@ pub fn _mm512_set1_ph(a: f16) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_setr_ph( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setr_ph( e0: f16, e1: f16, e2: f16, @@ -163,7 +171,8 @@ pub fn _mm_setr_ph( #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_setr_ph( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setr_ph( e0: f16, e1: f16, e2: f16, @@ -192,7 +201,8 @@ pub fn _mm256_setr_ph( #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_setr_ph( +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setr_ph( e0: f16, e1: f16, e2: f16, @@ -238,7 +248,8 @@ pub fn _mm512_setr_ph( #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_setzero_ph() -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_setzero_ph() -> __m128h { unsafe { transmute(f16x8::ZERO) } } @@ -248,7 +259,8 @@ pub fn _mm_setzero_ph() -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_setzero_ph() -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_setzero_ph() -> __m256h { f16x16::ZERO.as_m256h() } @@ -258,7 +270,8 @@ pub fn _mm256_setzero_ph() -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_setzero_ph() -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_setzero_ph() -> __m512h { f16x32::ZERO.as_m512h() } @@ -271,7 +284,8 @@ pub fn _mm512_setzero_ph() -> __m512h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_undefined_ph() -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_undefined_ph() -> __m128h { f16x8::ZERO.as_m128h() } @@ -284,7 +298,8 @@ pub fn _mm_undefined_ph() -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_undefined_ph() -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_undefined_ph() -> __m256h { f16x16::ZERO.as_m256h() } @@ -297,7 +312,8 @@ pub fn _mm256_undefined_ph() -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_undefined_ph() -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_undefined_ph() -> __m512h { f16x32::ZERO.as_m512h() } @@ -308,7 +324,8 @@ pub fn _mm512_undefined_ph() -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_castpd_ph(a: __m128d) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castpd_ph(a: __m128d) -> __m128h { unsafe { transmute(a) } } @@ -319,7 +336,8 @@ pub fn _mm_castpd_ph(a: __m128d) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castpd_ph(a: __m256d) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castpd_ph(a: __m256d) -> __m256h { unsafe { transmute(a) } } @@ -330,7 +348,8 @@ pub fn _mm256_castpd_ph(a: __m256d) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castpd_ph(a: __m512d) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castpd_ph(a: __m512d) -> __m512h { unsafe { transmute(a) } } @@ -341,7 +360,8 @@ pub fn _mm512_castpd_ph(a: __m512d) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_castph_pd(a: __m128h) -> __m128d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castph_pd(a: __m128h) -> __m128d { unsafe { transmute(a) } } @@ -352,7 +372,8 @@ pub fn _mm_castph_pd(a: __m128h) -> __m128d { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castph_pd(a: __m256h) -> __m256d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castph_pd(a: __m256h) -> __m256d { unsafe { transmute(a) } } @@ -363,7 +384,8 @@ pub fn _mm256_castph_pd(a: __m256h) -> __m256d { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph_pd(a: __m512h) -> __m512d { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph_pd(a: __m512h) -> __m512d { unsafe { transmute(a) } } @@ -374,7 +396,8 @@ pub fn _mm512_castph_pd(a: __m512h) -> __m512d { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_castps_ph(a: __m128) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castps_ph(a: __m128) -> __m128h { unsafe { transmute(a) } } @@ -385,7 +408,8 @@ pub fn _mm_castps_ph(a: __m128) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castps_ph(a: __m256) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castps_ph(a: __m256) -> __m256h { unsafe { transmute(a) } } @@ -396,7 +420,8 @@ pub fn _mm256_castps_ph(a: __m256) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castps_ph(a: __m512) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castps_ph(a: __m512) -> __m512h { unsafe { transmute(a) } } @@ -407,7 +432,8 @@ pub fn _mm512_castps_ph(a: __m512) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_castph_ps(a: __m128h) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castph_ps(a: __m128h) -> __m128 { unsafe { transmute(a) } } @@ -418,7 +444,8 @@ pub fn _mm_castph_ps(a: __m128h) -> __m128 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castph_ps(a: __m256h) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castph_ps(a: __m256h) -> __m256 { unsafe { transmute(a) } } @@ -429,7 +456,8 @@ pub fn _mm256_castph_ps(a: __m256h) -> __m256 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph_ps(a: __m512h) -> __m512 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph_ps(a: __m512h) -> __m512 { unsafe { transmute(a) } } @@ -440,7 +468,8 @@ pub fn _mm512_castph_ps(a: __m512h) -> __m512 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_castsi128_ph(a: __m128i) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castsi128_ph(a: __m128i) -> __m128h { unsafe { transmute(a) } } @@ -451,7 +480,8 @@ pub fn _mm_castsi128_ph(a: __m128i) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castsi256_ph(a: __m256i) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castsi256_ph(a: __m256i) -> __m256h { unsafe { transmute(a) } } @@ -462,7 +492,8 @@ pub fn _mm256_castsi256_ph(a: __m256i) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castsi512_ph(a: __m512i) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castsi512_ph(a: __m512i) -> __m512h { unsafe { transmute(a) } } @@ -473,7 +504,8 @@ pub fn _mm512_castsi512_ph(a: __m512i) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_castph_si128(a: __m128h) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_castph_si128(a: __m128h) -> __m128i { unsafe { transmute(a) } } @@ -484,7 +516,8 @@ pub fn _mm_castph_si128(a: __m128h) -> __m128i { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castph_si256(a: __m256h) -> __m256i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castph_si256(a: __m256h) -> __m256i { unsafe { transmute(a) } } @@ -495,7 +528,8 @@ pub fn _mm256_castph_si256(a: __m256h) -> __m256i { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph_si512(a: __m512h) -> __m512i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph_si512(a: __m512h) -> __m512i { unsafe { transmute(a) } } @@ -506,7 +540,8 @@ pub fn _mm512_castph_si512(a: __m512h) -> __m512i { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castph256_ph128(a: __m256h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castph256_ph128(a: __m256h) -> __m128h { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]) } } @@ -517,7 +552,8 @@ pub fn _mm256_castph256_ph128(a: __m256h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph512_ph128(a: __m512h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph512_ph128(a: __m512h) -> __m128h { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]) } } @@ -528,7 +564,8 @@ pub fn _mm512_castph512_ph128(a: __m512h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph512_ph256(a: __m512h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph512_ph256(a: __m512h) -> __m256h { unsafe { simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) } } @@ -540,7 +577,8 @@ pub fn _mm512_castph512_ph256(a: __m512h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_castph128_ph256(a: __m128h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_castph128_ph256(a: __m128h) -> __m256h { unsafe { simd_shuffle!( a, @@ -558,7 +596,8 @@ pub fn _mm256_castph128_ph256(a: __m128h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph128_ph512(a: __m128h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph128_ph512(a: __m128h) -> __m512h { unsafe { simd_shuffle!( a, @@ -579,7 +618,8 @@ pub fn _mm512_castph128_ph512(a: __m128h) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_castph256_ph512(a: __m256h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_castph256_ph512(a: __m256h) -> __m512h { unsafe { simd_shuffle!( a, @@ -600,7 +640,8 @@ pub fn _mm512_castph256_ph512(a: __m256h) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_zextph128_ph256(a: __m128h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_zextph128_ph256(a: __m128h) -> __m256h { unsafe { simd_shuffle!( a, @@ -618,7 +659,8 @@ pub fn _mm256_zextph128_ph256(a: __m128h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_zextph256_ph512(a: __m256h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextph256_ph512(a: __m256h) -> __m512h { unsafe { simd_shuffle!( a, @@ -639,7 +681,8 @@ pub fn _mm512_zextph256_ph512(a: __m256h) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_zextph128_ph512(a: __m128h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_zextph128_ph512(a: __m128h) -> __m512h { unsafe { simd_shuffle!( a, @@ -1083,7 +1126,8 @@ pub fn _mm_ucomineq_sh(a: __m128h, b: __m128h) -> i32 { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm_load_ph(mem_addr: *const f16) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_ph(mem_addr: *const f16) -> __m128h { *mem_addr.cast() } @@ -1094,7 +1138,8 @@ pub unsafe fn _mm_load_ph(mem_addr: *const f16) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm256_load_ph(mem_addr: *const f16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_load_ph(mem_addr: *const f16) -> __m256h { *mem_addr.cast() } @@ -1105,7 +1150,8 @@ pub unsafe fn _mm256_load_ph(mem_addr: *const f16) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm512_load_ph(mem_addr: *const f16) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_load_ph(mem_addr: *const f16) -> __m512h { *mem_addr.cast() } @@ -1116,7 +1162,8 @@ pub unsafe fn _mm512_load_ph(mem_addr: *const f16) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm_load_sh(mem_addr: *const f16) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_load_sh(mem_addr: *const f16) -> __m128h { _mm_set_sh(*mem_addr) } @@ -1165,7 +1212,8 @@ pub unsafe fn _mm_maskz_load_sh(k: __mmask8, mem_addr: *const f16) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm_loadu_ph(mem_addr: *const f16) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_loadu_ph(mem_addr: *const f16) -> __m128h { ptr::read_unaligned(mem_addr.cast()) } @@ -1176,7 +1224,8 @@ pub unsafe fn _mm_loadu_ph(mem_addr: *const f16) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm256_loadu_ph(mem_addr: *const f16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_loadu_ph(mem_addr: *const f16) -> __m256h { ptr::read_unaligned(mem_addr.cast()) } @@ -1187,7 +1236,8 @@ pub unsafe fn _mm256_loadu_ph(mem_addr: *const f16) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm512_loadu_ph(mem_addr: *const f16) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_loadu_ph(mem_addr: *const f16) -> __m512h { ptr::read_unaligned(mem_addr.cast()) } @@ -1199,7 +1249,8 @@ pub unsafe fn _mm512_loadu_ph(mem_addr: *const f16) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_move_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_move_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let mut mov: f16 = simd_extract!(src, 0); if (k & 1) != 0 { @@ -1217,7 +1268,8 @@ pub fn _mm_mask_move_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __ #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_move_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_move_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let mut mov: f16 = 0.; if (k & 1) != 0 { @@ -1234,7 +1286,8 @@ pub fn _mm_maskz_move_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_move_sh(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_move_sh(a: __m128h, b: __m128h) -> __m128h { unsafe { let mov: f16 = simd_extract!(b, 0); simd_insert!(a, 0, mov) @@ -1248,7 +1301,8 @@ pub fn _mm_move_sh(a: __m128h, b: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm_store_ph(mem_addr: *mut f16, a: __m128h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_ph(mem_addr: *mut f16, a: __m128h) { *mem_addr.cast() = a; } @@ -1259,7 +1313,8 @@ pub unsafe fn _mm_store_ph(mem_addr: *mut f16, a: __m128h) { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm256_store_ph(mem_addr: *mut f16, a: __m256h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_store_ph(mem_addr: *mut f16, a: __m256h) { *mem_addr.cast() = a; } @@ -1270,7 +1325,8 @@ pub unsafe fn _mm256_store_ph(mem_addr: *mut f16, a: __m256h) { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm512_store_ph(mem_addr: *mut f16, a: __m512h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_store_ph(mem_addr: *mut f16, a: __m512h) { *mem_addr.cast() = a; } @@ -1280,7 +1336,8 @@ pub unsafe fn _mm512_store_ph(mem_addr: *mut f16, a: __m512h) { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm_store_sh(mem_addr: *mut f16, a: __m128h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_store_sh(mem_addr: *mut f16, a: __m128h) { *mem_addr = simd_extract!(a, 0); } @@ -1307,7 +1364,8 @@ pub unsafe fn _mm_mask_store_sh(mem_addr: *mut f16, k: __mmask8, a: __m128h) { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm_storeu_ph(mem_addr: *mut f16, a: __m128h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm_storeu_ph(mem_addr: *mut f16, a: __m128h) { ptr::write_unaligned(mem_addr.cast(), a); } @@ -1318,7 +1376,8 @@ pub unsafe fn _mm_storeu_ph(mem_addr: *mut f16, a: __m128h) { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm256_storeu_ph(mem_addr: *mut f16, a: __m256h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm256_storeu_ph(mem_addr: *mut f16, a: __m256h) { ptr::write_unaligned(mem_addr.cast(), a); } @@ -1329,7 +1388,8 @@ pub unsafe fn _mm256_storeu_ph(mem_addr: *mut f16, a: __m256h) { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub unsafe fn _mm512_storeu_ph(mem_addr: *mut f16, a: __m512h) { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const unsafe fn _mm512_storeu_ph(mem_addr: *mut f16, a: __m512h) { ptr::write_unaligned(mem_addr.cast(), a); } @@ -1340,7 +1400,8 @@ pub unsafe fn _mm512_storeu_ph(mem_addr: *mut f16, a: __m512h) { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_add_ph(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_ph(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_add(a, b) } } @@ -1352,7 +1413,8 @@ pub fn _mm_add_ph(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_add_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_add_ph(a, b); simd_select_bitmask(k, r, src) @@ -1367,7 +1429,8 @@ pub fn _mm_mask_add_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_add_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_add_ph(a, b); simd_select_bitmask(k, r, _mm_setzero_ph()) @@ -1381,7 +1444,8 @@ pub fn _mm_maskz_add_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_add_ph(a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_add_ph(a: __m256h, b: __m256h) -> __m256h { unsafe { simd_add(a, b) } } @@ -1393,7 +1457,8 @@ pub fn _mm256_add_ph(a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_add_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_add_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_add_ph(a, b); simd_select_bitmask(k, r, src) @@ -1408,7 +1473,8 @@ pub fn _mm256_mask_add_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_add_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_add_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_add_ph(a, b); simd_select_bitmask(k, r, _mm256_setzero_ph()) @@ -1422,7 +1488,8 @@ pub fn _mm256_maskz_add_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_add_ph(a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_add_ph(a: __m512h, b: __m512h) -> __m512h { unsafe { simd_add(a, b) } } @@ -1434,7 +1501,8 @@ pub fn _mm512_add_ph(a: __m512h, b: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_add_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_add_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_add_ph(a, b); simd_select_bitmask(k, r, src) @@ -1449,7 +1517,8 @@ pub fn _mm512_mask_add_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vaddph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_add_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_add_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_add_ph(a, b); simd_select_bitmask(k, r, _mm512_setzero_ph()) @@ -1614,7 +1683,8 @@ pub fn _mm_maskz_add_round_sh(k: __mmask8, a: __m128h, b: _ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vaddsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_add_sh(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_add_sh(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_insert!(a, 0, _mm_cvtsh_h(a) + _mm_cvtsh_h(b)) } } @@ -1627,7 +1697,8 @@ pub fn _mm_add_sh(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vaddsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_add_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_add_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let extractsrc: f16 = simd_extract!(src, 0); let mut add: f16 = extractsrc; @@ -1649,7 +1720,8 @@ pub fn _mm_mask_add_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vaddsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_add_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_add_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let mut add: f16 = 0.; if (k & 0b00000001) != 0 { @@ -1668,7 +1740,8 @@ pub fn _mm_maskz_add_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_sub_ph(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_ph(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_sub(a, b) } } @@ -1680,7 +1753,8 @@ pub fn _mm_sub_ph(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_sub_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_sub_ph(a, b); simd_select_bitmask(k, r, src) @@ -1695,7 +1769,8 @@ pub fn _mm_mask_sub_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_sub_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_sub_ph(a, b); simd_select_bitmask(k, r, _mm_setzero_ph()) @@ -1709,7 +1784,8 @@ pub fn _mm_maskz_sub_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_sub_ph(a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_sub_ph(a: __m256h, b: __m256h) -> __m256h { unsafe { simd_sub(a, b) } } @@ -1721,7 +1797,8 @@ pub fn _mm256_sub_ph(a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_sub_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_sub_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_sub_ph(a, b); simd_select_bitmask(k, r, src) @@ -1736,7 +1813,8 @@ pub fn _mm256_mask_sub_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_sub_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_sub_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_sub_ph(a, b); simd_select_bitmask(k, r, _mm256_setzero_ph()) @@ -1750,7 +1828,8 @@ pub fn _mm256_maskz_sub_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_sub_ph(a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_sub_ph(a: __m512h, b: __m512h) -> __m512h { unsafe { simd_sub(a, b) } } @@ -1762,7 +1841,8 @@ pub fn _mm512_sub_ph(a: __m512h, b: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_sub_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_sub_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_sub_ph(a, b); simd_select_bitmask(k, r, src) @@ -1777,7 +1857,8 @@ pub fn _mm512_mask_sub_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vsubph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_sub_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_sub_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_sub_ph(a, b); simd_select_bitmask(k, r, _mm512_setzero_ph()) @@ -1943,7 +2024,8 @@ pub fn _mm_maskz_sub_round_sh(k: __mmask8, a: __m128h, b: _ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vsubsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_sub_sh(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_sub_sh(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_insert!(a, 0, _mm_cvtsh_h(a) - _mm_cvtsh_h(b)) } } @@ -1956,7 +2038,8 @@ pub fn _mm_sub_sh(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vsubsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_sub_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_sub_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let extractsrc: f16 = simd_extract!(src, 0); let mut add: f16 = extractsrc; @@ -1978,7 +2061,8 @@ pub fn _mm_mask_sub_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vsubsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_sub_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_sub_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let mut add: f16 = 0.; if (k & 0b00000001) != 0 { @@ -1997,7 +2081,8 @@ pub fn _mm_maskz_sub_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mul_ph(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_ph(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_mul(a, b) } } @@ -2009,7 +2094,8 @@ pub fn _mm_mul_ph(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_mul_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_mul_ph(a, b); simd_select_bitmask(k, r, src) @@ -2024,7 +2110,8 @@ pub fn _mm_mask_mul_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_mul_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_mul_ph(a, b); simd_select_bitmask(k, r, _mm_setzero_ph()) @@ -2038,7 +2125,8 @@ pub fn _mm_maskz_mul_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mul_ph(a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mul_ph(a: __m256h, b: __m256h) -> __m256h { unsafe { simd_mul(a, b) } } @@ -2050,7 +2138,8 @@ pub fn _mm256_mul_ph(a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_mul_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_mul_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_mul_ph(a, b); simd_select_bitmask(k, r, src) @@ -2065,7 +2154,8 @@ pub fn _mm256_mask_mul_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_mul_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_mul_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_mul_ph(a, b); simd_select_bitmask(k, r, _mm256_setzero_ph()) @@ -2079,7 +2169,8 @@ pub fn _mm256_maskz_mul_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mul_ph(a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mul_ph(a: __m512h, b: __m512h) -> __m512h { unsafe { simd_mul(a, b) } } @@ -2091,7 +2182,8 @@ pub fn _mm512_mul_ph(a: __m512h, b: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_mul_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_mul_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_mul_ph(a, b); simd_select_bitmask(k, r, src) @@ -2106,7 +2198,8 @@ pub fn _mm512_mask_mul_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vmulph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_mul_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_mul_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_mul_ph(a, b); simd_select_bitmask(k, r, _mm512_setzero_ph()) @@ -2272,7 +2365,8 @@ pub fn _mm_maskz_mul_round_sh(k: __mmask8, a: __m128h, b: _ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vmulsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mul_sh(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mul_sh(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_insert!(a, 0, _mm_cvtsh_h(a) * _mm_cvtsh_h(b)) } } @@ -2285,7 +2379,8 @@ pub fn _mm_mul_sh(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vmulsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_mul_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_mul_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let extractsrc: f16 = simd_extract!(src, 0); let mut add: f16 = extractsrc; @@ -2307,7 +2402,8 @@ pub fn _mm_mask_mul_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vmulsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_mul_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_mul_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let mut add: f16 = 0.; if (k & 0b00000001) != 0 { @@ -2326,7 +2422,8 @@ pub fn _mm_maskz_mul_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_div_ph(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_div_ph(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_div(a, b) } } @@ -2338,7 +2435,8 @@ pub fn _mm_div_ph(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_div_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_div_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_div_ph(a, b); simd_select_bitmask(k, r, src) @@ -2353,7 +2451,8 @@ pub fn _mm_mask_div_ph(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_div_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_div_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let r = _mm_div_ph(a, b); simd_select_bitmask(k, r, _mm_setzero_ph()) @@ -2367,7 +2466,8 @@ pub fn _mm_maskz_div_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_div_ph(a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_div_ph(a: __m256h, b: __m256h) -> __m256h { unsafe { simd_div(a, b) } } @@ -2379,7 +2479,8 @@ pub fn _mm256_div_ph(a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_div_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_div_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_div_ph(a, b); simd_select_bitmask(k, r, src) @@ -2394,7 +2495,8 @@ pub fn _mm256_mask_div_ph(src: __m256h, k: __mmask16, a: __m256h, b: __m256h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_div_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_div_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { let r = _mm256_div_ph(a, b); simd_select_bitmask(k, r, _mm256_setzero_ph()) @@ -2408,7 +2510,8 @@ pub fn _mm256_maskz_div_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_div_ph(a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_div_ph(a: __m512h, b: __m512h) -> __m512h { unsafe { simd_div(a, b) } } @@ -2420,7 +2523,8 @@ pub fn _mm512_div_ph(a: __m512h, b: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_div_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_div_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_div_ph(a, b); simd_select_bitmask(k, r, src) @@ -2435,7 +2539,8 @@ pub fn _mm512_mask_div_ph(src: __m512h, k: __mmask32, a: __m512h, b: __m512h) -> #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vdivph))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_div_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_div_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { let r = _mm512_div_ph(a, b); simd_select_bitmask(k, r, _mm512_setzero_ph()) @@ -2601,7 +2706,8 @@ pub fn _mm_maskz_div_round_sh(k: __mmask8, a: __m128h, b: _ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vdivsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_div_sh(a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_div_sh(a: __m128h, b: __m128h) -> __m128h { unsafe { simd_insert!(a, 0, _mm_cvtsh_h(a) / _mm_cvtsh_h(b)) } } @@ -2614,7 +2720,8 @@ pub fn _mm_div_sh(a: __m128h, b: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vdivsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_div_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_div_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let extractsrc: f16 = simd_extract!(src, 0); let mut add: f16 = extractsrc; @@ -2636,7 +2743,8 @@ pub fn _mm_mask_div_sh(src: __m128h, k: __mmask8, a: __m128h, b: __m128h) -> __m #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vdivsh))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_div_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_div_sh(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { let mut add: f16 = 0.; if (k & 0b00000001) != 0 { @@ -3967,7 +4075,8 @@ pub fn _mm_maskz_fcmul_round_sch( #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_abs_ph(v2: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_abs_ph(v2: __m128h) -> __m128h { unsafe { transmute(_mm_and_si128(transmute(v2), _mm_set1_epi16(i16::MAX))) } } @@ -3978,7 +4087,8 @@ pub fn _mm_abs_ph(v2: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_abs_ph(v2: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_abs_ph(v2: __m256h) -> __m256h { unsafe { transmute(_mm256_and_si256(transmute(v2), _mm256_set1_epi16(i16::MAX))) } } @@ -3989,7 +4099,8 @@ pub fn _mm256_abs_ph(v2: __m256h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_abs_ph(v2: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_abs_ph(v2: __m512h) -> __m512h { unsafe { transmute(_mm512_and_si512(transmute(v2), _mm512_set1_epi16(i16::MAX))) } } @@ -4002,7 +4113,8 @@ pub fn _mm512_abs_ph(v2: __m512h) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_conj_pch(a: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_conj_pch(a: __m128h) -> __m128h { unsafe { transmute(_mm_xor_si128(transmute(a), _mm_set1_epi32(i32::MIN))) } } @@ -4015,7 +4127,8 @@ pub fn _mm_conj_pch(a: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_conj_pch(src: __m128h, k: __mmask8, a: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_conj_pch(src: __m128h, k: __mmask8, a: __m128h) -> __m128h { unsafe { let r: __m128 = transmute(_mm_conj_pch(a)); transmute(simd_select_bitmask(k, r, transmute(src))) @@ -4031,7 +4144,8 @@ pub fn _mm_mask_conj_pch(src: __m128h, k: __mmask8, a: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_conj_pch(k: __mmask8, a: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_conj_pch(k: __mmask8, a: __m128h) -> __m128h { _mm_mask_conj_pch(_mm_setzero_ph(), k, a) } @@ -4043,7 +4157,8 @@ pub fn _mm_maskz_conj_pch(k: __mmask8, a: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_conj_pch(a: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_conj_pch(a: __m256h) -> __m256h { unsafe { transmute(_mm256_xor_si256(transmute(a), _mm256_set1_epi32(i32::MIN))) } } @@ -4056,7 +4171,8 @@ pub fn _mm256_conj_pch(a: __m256h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_conj_pch(src: __m256h, k: __mmask8, a: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_conj_pch(src: __m256h, k: __mmask8, a: __m256h) -> __m256h { unsafe { let r: __m256 = transmute(_mm256_conj_pch(a)); transmute(simd_select_bitmask(k, r, transmute(src))) @@ -4072,7 +4188,8 @@ pub fn _mm256_mask_conj_pch(src: __m256h, k: __mmask8, a: __m256h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_conj_pch(k: __mmask8, a: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_conj_pch(k: __mmask8, a: __m256h) -> __m256h { _mm256_mask_conj_pch(_mm256_setzero_ph(), k, a) } @@ -4084,7 +4201,8 @@ pub fn _mm256_maskz_conj_pch(k: __mmask8, a: __m256h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_conj_pch(a: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_conj_pch(a: __m512h) -> __m512h { unsafe { transmute(_mm512_xor_si512(transmute(a), _mm512_set1_epi32(i32::MIN))) } } @@ -4097,7 +4215,8 @@ pub fn _mm512_conj_pch(a: __m512h) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_conj_pch(src: __m512h, k: __mmask16, a: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_conj_pch(src: __m512h, k: __mmask16, a: __m512h) -> __m512h { unsafe { let r: __m512 = transmute(_mm512_conj_pch(a)); transmute(simd_select_bitmask(k, r, transmute(src))) @@ -4113,7 +4232,8 @@ pub fn _mm512_mask_conj_pch(src: __m512h, k: __mmask16, a: __m512h) -> __m512h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_conj_pch(k: __mmask16, a: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_conj_pch(k: __mmask16, a: __m512h) -> __m512h { _mm512_mask_conj_pch(_mm512_setzero_ph(), k, a) } @@ -5198,7 +5318,8 @@ pub fn _mm_maskz_fcmadd_round_sch( #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fmadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_fma(a, b, c) } } @@ -5211,7 +5332,8 @@ pub fn _mm_fmadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fmadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmadd_ph(a, b, c), a) } } @@ -5224,7 +5346,8 @@ pub fn _mm_mask_fmadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fmadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmadd_ph(a, b, c), c) } } @@ -5237,7 +5360,8 @@ pub fn _mm_mask3_fmadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fmadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmadd_ph(a, b, c), _mm_setzero_ph()) } } @@ -5249,7 +5373,8 @@ pub fn _mm_maskz_fmadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_fmadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_fma(a, b, c) } } @@ -5262,7 +5387,8 @@ pub fn _mm256_fmadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_fmadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmadd_ph(a, b, c), a) } } @@ -5275,7 +5401,8 @@ pub fn _mm256_mask_fmadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask3_fmadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmadd_ph(a, b, c), c) } } @@ -5288,7 +5415,8 @@ pub fn _mm256_mask3_fmadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) - #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_fmadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmadd_ph(a, b, c), _mm256_setzero_ph()) } } @@ -5300,7 +5428,8 @@ pub fn _mm256_maskz_fmadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) - #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_fmadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_fma(a, b, c) } } @@ -5313,7 +5442,8 @@ pub fn _mm512_fmadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_fmadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmadd_ph(a, b, c), a) } } @@ -5326,7 +5456,8 @@ pub fn _mm512_mask_fmadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask3_fmadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmadd_ph(a, b, c), c) } } @@ -5339,7 +5470,8 @@ pub fn _mm512_mask3_fmadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) - #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_fmadd_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmadd_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmadd_ph(a, b, c), _mm512_setzero_ph()) } } @@ -5470,7 +5602,8 @@ pub fn _mm512_maskz_fmadd_round_ph( #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fmadd_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmadd_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let extracta: f16 = simd_extract!(a, 0); let extractb: f16 = simd_extract!(b, 0); @@ -5490,7 +5623,8 @@ pub fn _mm_fmadd_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fmadd_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmadd_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fmadd: f16 = simd_extract!(a, 0); if k & 1 != 0 { @@ -5512,7 +5646,8 @@ pub fn _mm_mask_fmadd_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fmadd_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmadd_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { let mut fmadd: f16 = simd_extract!(c, 0); if k & 1 != 0 { @@ -5534,7 +5669,8 @@ pub fn _mm_mask3_fmadd_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fmadd_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmadd_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fmadd: f16 = 0.0; if k & 1 != 0 { @@ -5697,7 +5833,8 @@ pub fn _mm_maskz_fmadd_round_sh( #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fmsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -5710,7 +5847,8 @@ pub fn _mm_fmsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fmsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmsub_ph(a, b, c), a) } } @@ -5723,7 +5861,8 @@ pub fn _mm_mask_fmsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fmsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmsub_ph(a, b, c), c) } } @@ -5736,7 +5875,8 @@ pub fn _mm_mask3_fmsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fmsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmsub_ph(a, b, c), _mm_setzero_ph()) } } @@ -5748,7 +5888,8 @@ pub fn _mm_maskz_fmsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_fmsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -5761,7 +5902,8 @@ pub fn _mm256_fmsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_fmsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmsub_ph(a, b, c), a) } } @@ -5774,7 +5916,8 @@ pub fn _mm256_mask_fmsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask3_fmsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmsub_ph(a, b, c), c) } } @@ -5787,7 +5930,8 @@ pub fn _mm256_mask3_fmsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) - #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_fmsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmsub_ph(a, b, c), _mm256_setzero_ph()) } } @@ -5799,7 +5943,8 @@ pub fn _mm256_maskz_fmsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) - #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_fmsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_fma(a, b, simd_neg(c)) } } @@ -5812,7 +5957,8 @@ pub fn _mm512_fmsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_fmsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmsub_ph(a, b, c), a) } } @@ -5825,7 +5971,8 @@ pub fn _mm512_mask_fmsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask3_fmsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmsub_ph(a, b, c), c) } } @@ -5838,7 +5985,8 @@ pub fn _mm512_mask3_fmsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) - #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_fmsub_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmsub_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmsub_ph(a, b, c), _mm512_setzero_ph()) } } @@ -5969,7 +6117,8 @@ pub fn _mm512_maskz_fmsub_round_ph( #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fmsub_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsub_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let extracta: f16 = simd_extract!(a, 0); let extractb: f16 = simd_extract!(b, 0); @@ -5989,7 +6138,8 @@ pub fn _mm_fmsub_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fmsub_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsub_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fmsub: f16 = simd_extract!(a, 0); if k & 1 != 0 { @@ -6011,7 +6161,8 @@ pub fn _mm_mask_fmsub_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fmsub_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsub_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { let mut fmsub: f16 = simd_extract!(c, 0); if k & 1 != 0 { @@ -6033,7 +6184,8 @@ pub fn _mm_mask3_fmsub_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fmsub_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsub_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fmsub: f16 = 0.0; if k & 1 != 0 { @@ -6187,7 +6339,8 @@ pub fn _mm_maskz_fmsub_round_sh( #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fnmadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -6200,7 +6353,8 @@ pub fn _mm_fnmadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fnmadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fnmadd_ph(a, b, c), a) } } @@ -6213,7 +6367,8 @@ pub fn _mm_mask_fnmadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fnmadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fnmadd_ph(a, b, c), c) } } @@ -6226,7 +6381,8 @@ pub fn _mm_mask3_fnmadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> _ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fnmadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fnmadd_ph(a, b, c), _mm_setzero_ph()) } } @@ -6238,7 +6394,8 @@ pub fn _mm_maskz_fnmadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> _ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_fnmadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fnmadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -6251,7 +6408,8 @@ pub fn _mm256_fnmadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_fnmadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fnmadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fnmadd_ph(a, b, c), a) } } @@ -6264,7 +6422,8 @@ pub fn _mm256_mask_fnmadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) - #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask3_fnmadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fnmadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fnmadd_ph(a, b, c), c) } } @@ -6277,7 +6436,8 @@ pub fn _mm256_mask3_fnmadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_fnmadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fnmadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fnmadd_ph(a, b, c), _mm256_setzero_ph()) } } @@ -6289,7 +6449,8 @@ pub fn _mm256_maskz_fnmadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_fnmadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fnmadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_fma(simd_neg(a), b, c) } } @@ -6302,7 +6463,8 @@ pub fn _mm512_fnmadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_fnmadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fnmadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fnmadd_ph(a, b, c), a) } } @@ -6315,7 +6477,8 @@ pub fn _mm512_mask_fnmadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) - #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask3_fnmadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fnmadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fnmadd_ph(a, b, c), c) } } @@ -6328,7 +6491,8 @@ pub fn _mm512_mask3_fnmadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_fnmadd_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fnmadd_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fnmadd_ph(a, b, c), _mm512_setzero_ph()) } } @@ -6459,7 +6623,8 @@ pub fn _mm512_maskz_fnmadd_round_ph( #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fnmadd_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmadd_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let extracta: f16 = simd_extract!(a, 0); let extractb: f16 = simd_extract!(b, 0); @@ -6479,7 +6644,8 @@ pub fn _mm_fnmadd_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fnmadd_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmadd_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fnmadd: f16 = simd_extract!(a, 0); if k & 1 != 0 { @@ -6501,7 +6667,8 @@ pub fn _mm_mask_fnmadd_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fnmadd_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmadd_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { let mut fnmadd: f16 = simd_extract!(c, 0); if k & 1 != 0 { @@ -6523,7 +6690,8 @@ pub fn _mm_mask3_fnmadd_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> _ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fnmadd_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmadd_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fnmadd: f16 = 0.0; if k & 1 != 0 { @@ -6685,7 +6853,8 @@ pub fn _mm_maskz_fnmadd_round_sh( #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fnmsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -6698,7 +6867,8 @@ pub fn _mm_fnmsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fnmsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fnmsub_ph(a, b, c), a) } } @@ -6711,7 +6881,8 @@ pub fn _mm_mask_fnmsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fnmsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fnmsub_ph(a, b, c), c) } } @@ -6724,7 +6895,8 @@ pub fn _mm_mask3_fnmsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> _ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fnmsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fnmsub_ph(a, b, c), _mm_setzero_ph()) } } @@ -6736,7 +6908,8 @@ pub fn _mm_maskz_fnmsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> _ #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_fnmsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fnmsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -6749,7 +6922,8 @@ pub fn _mm256_fnmsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_fnmsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fnmsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fnmsub_ph(a, b, c), a) } } @@ -6762,7 +6936,8 @@ pub fn _mm256_mask_fnmsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) - #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask3_fnmsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fnmsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fnmsub_ph(a, b, c), c) } } @@ -6775,7 +6950,8 @@ pub fn _mm256_mask3_fnmsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_fnmsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fnmsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fnmsub_ph(a, b, c), _mm256_setzero_ph()) } } @@ -6787,7 +6963,8 @@ pub fn _mm256_maskz_fnmsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_fnmsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fnmsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_fma(simd_neg(a), b, simd_neg(c)) } } @@ -6800,7 +6977,8 @@ pub fn _mm512_fnmsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_fnmsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fnmsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fnmsub_ph(a, b, c), a) } } @@ -6813,7 +6991,8 @@ pub fn _mm512_mask_fnmsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) - #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask3_fnmsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fnmsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fnmsub_ph(a, b, c), c) } } @@ -6826,7 +7005,8 @@ pub fn _mm512_mask3_fnmsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_fnmsub_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fnmsub_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fnmsub_ph(a, b, c), _mm512_setzero_ph()) } } @@ -6957,7 +7137,8 @@ pub fn _mm512_maskz_fnmsub_round_ph( #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fnmsub_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fnmsub_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let extracta: f16 = simd_extract!(a, 0); let extractb: f16 = simd_extract!(b, 0); @@ -6977,7 +7158,8 @@ pub fn _mm_fnmsub_sh(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fnmsub_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fnmsub_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fnmsub: f16 = simd_extract!(a, 0); if k & 1 != 0 { @@ -6999,7 +7181,8 @@ pub fn _mm_mask_fnmsub_sh(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fnmsub_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fnmsub_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { let mut fnmsub: f16 = simd_extract!(c, 0); if k & 1 != 0 { @@ -7021,7 +7204,8 @@ pub fn _mm_mask3_fnmsub_sh(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> _ #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfnmsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fnmsub_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fnmsub_sh(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let mut fnmsub: f16 = 0.0; if k & 1 != 0 { @@ -7183,7 +7367,8 @@ pub fn _mm_maskz_fnmsub_round_sh( #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fmaddsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmaddsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -7200,7 +7385,8 @@ pub fn _mm_fmaddsub_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fmaddsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmaddsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmaddsub_ph(a, b, c), a) } } @@ -7213,7 +7399,8 @@ pub fn _mm_mask_fmaddsub_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fmaddsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmaddsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmaddsub_ph(a, b, c), c) } } @@ -7226,7 +7413,8 @@ pub fn _mm_mask3_fmaddsub_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fmaddsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmaddsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmaddsub_ph(a, b, c), _mm_setzero_ph()) } } @@ -7238,7 +7426,8 @@ pub fn _mm_maskz_fmaddsub_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_fmaddsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmaddsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -7259,7 +7448,8 @@ pub fn _mm256_fmaddsub_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_fmaddsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmaddsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_ph(a, b, c), a) } } @@ -7272,7 +7462,8 @@ pub fn _mm256_mask_fmaddsub_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask3_fmaddsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmaddsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_ph(a, b, c), c) } } @@ -7285,7 +7476,8 @@ pub fn _mm256_mask3_fmaddsub_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16 #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_fmaddsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmaddsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmaddsub_ph(a, b, c), _mm256_setzero_ph()) } } @@ -7297,7 +7489,8 @@ pub fn _mm256_maskz_fmaddsub_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_fmaddsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmaddsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { let add = simd_fma(a, b, c); let sub = simd_fma(a, b, simd_neg(c)); @@ -7321,7 +7514,8 @@ pub fn _mm512_fmaddsub_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_fmaddsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmaddsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_ph(a, b, c), a) } } @@ -7334,7 +7528,8 @@ pub fn _mm512_mask_fmaddsub_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask3_fmaddsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmaddsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_ph(a, b, c), c) } } @@ -7347,7 +7542,8 @@ pub fn _mm512_mask3_fmaddsub_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32 #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmaddsub))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_fmaddsub_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmaddsub_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmaddsub_ph(a, b, c), _mm512_setzero_ph()) } } @@ -7481,7 +7677,8 @@ pub fn _mm512_maskz_fmaddsub_round_ph( #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_fmsubadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_fmsubadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { _mm_fmaddsub_ph(a, b, unsafe { simd_neg(c) }) } @@ -7494,7 +7691,8 @@ pub fn _mm_fmsubadd_ph(a: __m128h, b: __m128h, c: __m128h) -> __m128h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_fmsubadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_fmsubadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmsubadd_ph(a, b, c), a) } } @@ -7507,7 +7705,8 @@ pub fn _mm_mask_fmsubadd_ph(a: __m128h, k: __mmask8, b: __m128h, c: __m128h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask3_fmsubadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask3_fmsubadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmsubadd_ph(a, b, c), c) } } @@ -7520,7 +7719,8 @@ pub fn _mm_mask3_fmsubadd_ph(a: __m128h, b: __m128h, c: __m128h, k: __mmask8) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_maskz_fmsubadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_maskz_fmsubadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, _mm_fmsubadd_ph(a, b, c), _mm_setzero_ph()) } } @@ -7532,7 +7732,8 @@ pub fn _mm_maskz_fmsubadd_ph(k: __mmask8, a: __m128h, b: __m128h, c: __m128h) -> #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_fmsubadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_fmsubadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { _mm256_fmaddsub_ph(a, b, unsafe { simd_neg(c) }) } @@ -7545,7 +7746,8 @@ pub fn _mm256_fmsubadd_ph(a: __m256h, b: __m256h, c: __m256h) -> __m256h { #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_fmsubadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_fmsubadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_ph(a, b, c), a) } } @@ -7558,7 +7760,8 @@ pub fn _mm256_mask_fmsubadd_ph(a: __m256h, k: __mmask16, b: __m256h, c: __m256h) #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask3_fmsubadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask3_fmsubadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_ph(a, b, c), c) } } @@ -7571,7 +7774,8 @@ pub fn _mm256_mask3_fmsubadd_ph(a: __m256h, b: __m256h, c: __m256h, k: __mmask16 #[target_feature(enable = "avx512fp16,avx512vl")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_maskz_fmsubadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_maskz_fmsubadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, _mm256_fmsubadd_ph(a, b, c), _mm256_setzero_ph()) } } @@ -7583,7 +7787,8 @@ pub fn _mm256_maskz_fmsubadd_ph(k: __mmask16, a: __m256h, b: __m256h, c: __m256h #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_fmsubadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_fmsubadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { _mm512_fmaddsub_ph(a, b, unsafe { simd_neg(c) }) } @@ -7596,7 +7801,8 @@ pub fn _mm512_fmsubadd_ph(a: __m512h, b: __m512h, c: __m512h) -> __m512h { #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_fmsubadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_fmsubadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_ph(a, b, c), a) } } @@ -7609,7 +7815,8 @@ pub fn _mm512_mask_fmsubadd_ph(a: __m512h, k: __mmask32, b: __m512h, c: __m512h) #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask3_fmsubadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask3_fmsubadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_ph(a, b, c), c) } } @@ -7622,7 +7829,8 @@ pub fn _mm512_mask3_fmsubadd_ph(a: __m512h, b: __m512h, c: __m512h, k: __mmask32 #[target_feature(enable = "avx512fp16")] #[cfg_attr(test, assert_instr(vfmsubadd))] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_maskz_fmsubadd_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_maskz_fmsubadd_ph(k: __mmask32, a: __m512h, b: __m512h, c: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, _mm512_fmsubadd_ph(a, b, c), _mm512_setzero_ph()) } } @@ -11117,7 +11325,8 @@ pub fn _mm_maskz_reduce_round_sh( #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_reduce_add_ph(a: __m128h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_add_ph(a: __m128h) -> f16 { unsafe { let b = simd_shuffle!(a, a, [4, 5, 6, 7, 0, 1, 2, 3]); let a = _mm_add_ph(a, b); @@ -11134,7 +11343,8 @@ pub fn _mm_reduce_add_ph(a: __m128h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_reduce_add_ph(a: __m256h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_add_ph(a: __m256h) -> f16 { unsafe { let p = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); let q = simd_shuffle!(a, a, [8, 9, 10, 11, 12, 13, 14, 15]); @@ -11149,7 +11359,8 @@ pub fn _mm256_reduce_add_ph(a: __m256h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_reduce_add_ph(a: __m512h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_add_ph(a: __m512h) -> f16 { unsafe { let p = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); let q = simd_shuffle!( @@ -11170,7 +11381,8 @@ pub fn _mm512_reduce_add_ph(a: __m512h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_reduce_mul_ph(a: __m128h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_reduce_mul_ph(a: __m128h) -> f16 { unsafe { let b = simd_shuffle!(a, a, [4, 5, 6, 7, 0, 1, 2, 3]); let a = _mm_mul_ph(a, b); @@ -11187,7 +11399,8 @@ pub fn _mm_reduce_mul_ph(a: __m128h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_reduce_mul_ph(a: __m256h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_reduce_mul_ph(a: __m256h) -> f16 { unsafe { let p = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7]); let q = simd_shuffle!(a, a, [8, 9, 10, 11, 12, 13, 14, 15]); @@ -11202,7 +11415,8 @@ pub fn _mm256_reduce_mul_ph(a: __m256h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_reduce_mul_ph(a: __m512h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_reduce_mul_ph(a: __m512h) -> f16 { unsafe { let p = simd_shuffle!(a, a, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); let q = simd_shuffle!( @@ -11566,7 +11780,8 @@ pub fn _mm_mask_fpclass_sh_mask(k1: __mmask8, a: __m128h) -> __ #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_mask_blend_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_mask_blend_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { unsafe { simd_select_bitmask(k, b, a) } } @@ -11577,7 +11792,8 @@ pub fn _mm_mask_blend_ph(k: __mmask8, a: __m128h, b: __m128h) -> __m128h { #[inline] #[target_feature(enable = "avx512fp16,avx512vl")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_mask_blend_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_mask_blend_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { unsafe { simd_select_bitmask(k, b, a) } } @@ -11588,7 +11804,8 @@ pub fn _mm256_mask_blend_ph(k: __mmask16, a: __m256h, b: __m256h) -> __m256h { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_mask_blend_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_mask_blend_ph(k: __mmask32, a: __m512h, b: __m512h) -> __m512h { unsafe { simd_select_bitmask(k, b, a) } } @@ -16304,7 +16521,8 @@ pub fn _mm_maskz_cvt_roundsh_sd(k: __mmask8, a: __m128d, b: __m1 #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_cvtsh_h(a: __m128h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsh_h(a: __m128h) -> f16 { unsafe { simd_extract!(a, 0) } } @@ -16314,7 +16532,8 @@ pub fn _mm_cvtsh_h(a: __m128h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm256_cvtsh_h(a: __m256h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtsh_h(a: __m256h) -> f16 { unsafe { simd_extract!(a, 0) } } @@ -16324,7 +16543,8 @@ pub fn _mm256_cvtsh_h(a: __m256h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm512_cvtsh_h(a: __m512h) -> f16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm512_cvtsh_h(a: __m512h) -> f16 { unsafe { simd_extract!(a, 0) } } @@ -16334,7 +16554,8 @@ pub fn _mm512_cvtsh_h(a: __m512h) -> f16 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_cvtsi128_si16(a: __m128i) -> i16 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi128_si16(a: __m128i) -> i16 { unsafe { simd_extract!(a.as_i16x8(), 0) } } @@ -16344,7 +16565,8 @@ pub fn _mm_cvtsi128_si16(a: __m128i) -> i16 { #[inline] #[target_feature(enable = "avx512fp16")] #[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")] -pub fn _mm_cvtsi16_si128(a: i16) -> __m128i { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtsi16_si128(a: i16) -> __m128i { unsafe { transmute(simd_insert!(i16x8::ZERO, 0, a)) } } @@ -16708,6 +16930,7 @@ unsafe extern "C" { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::core_arch::x86::*; use crate::mem::transmute; use crate::ptr::{addr_of, addr_of_mut}; @@ -16737,14 +16960,14 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_set_ph() { + const unsafe fn test_mm_set_ph() { let r = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let e = _mm_setr_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); assert_eq_m128h(r, e); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_set_ph() { + const unsafe fn test_mm256_set_ph() { let r = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -16755,7 +16978,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_set_ph() { + const unsafe fn test_mm512_set_ph() { let r = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -16770,21 +16993,21 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_set_sh() { + const unsafe fn test_mm_set_sh() { let r = _mm_set_sh(1.0); let e = _mm_set_ph(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); assert_eq_m128h(r, e); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_set1_ph() { + const unsafe fn test_mm_set1_ph() { let r = _mm_set1_ph(1.0); let e = _mm_set_ph(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0); assert_eq_m128h(r, e); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_set1_ph() { + const unsafe fn test_mm256_set1_ph() { let r = _mm256_set1_ph(1.0); let e = _mm256_set_ph( 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, @@ -16793,7 +17016,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_set1_ph() { + const unsafe fn test_mm512_set1_ph() { let r = _mm512_set1_ph(1.0); let e = _mm512_set_ph( 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, @@ -16803,14 +17026,14 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_setr_ph() { + const unsafe fn test_mm_setr_ph() { let r = _mm_setr_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let e = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); assert_eq_m128h(r, e); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_setr_ph() { + const unsafe fn test_mm256_setr_ph() { let r = _mm256_setr_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -16821,7 +17044,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_setr_ph() { + const unsafe fn test_mm512_setr_ph() { let r = _mm512_setr_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -16836,28 +17059,28 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_setzero_ph() { + const unsafe fn test_mm_setzero_ph() { let r = _mm_setzero_ph(); let e = _mm_set1_ph(0.0); assert_eq_m128h(r, e); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_setzero_ph() { + const unsafe fn test_mm256_setzero_ph() { let r = _mm256_setzero_ph(); let e = _mm256_set1_ph(0.0); assert_eq_m256h(r, e); } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_setzero_ph() { + const unsafe fn test_mm512_setzero_ph() { let r = _mm512_setzero_ph(); let e = _mm512_set1_ph(0.0); assert_eq_m512h(r, e); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_castsi128_ph() { + const unsafe fn test_mm_castsi128_ph() { let a = _mm_set1_epi16(0x3c00); let r = _mm_castsi128_ph(a); let e = _mm_set1_ph(1.0); @@ -16865,7 +17088,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_castsi256_ph() { + const unsafe fn test_mm256_castsi256_ph() { let a = _mm256_set1_epi16(0x3c00); let r = _mm256_castsi256_ph(a); let e = _mm256_set1_ph(1.0); @@ -16873,7 +17096,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_castsi512_ph() { + const unsafe fn test_mm512_castsi512_ph() { let a = _mm512_set1_epi16(0x3c00); let r = _mm512_castsi512_ph(a); let e = _mm512_set1_ph(1.0); @@ -16881,7 +17104,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm_castph_si128() { + const unsafe fn test_mm_castph_si128() { let a = _mm_set1_ph(1.0); let r = _mm_castph_si128(a); let e = _mm_set1_epi16(0x3c00); @@ -16889,7 +17112,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm256_castph_si256() { + const unsafe fn test_mm256_castph_si256() { let a = _mm256_set1_ph(1.0); let r = _mm256_castph_si256(a); let e = _mm256_set1_epi16(0x3c00); @@ -16897,7 +17120,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_castph_si512() { + const unsafe fn test_mm512_castph_si512() { let a = _mm512_set1_ph(1.0); let r = _mm512_castph_si512(a); let e = _mm512_set1_epi16(0x3c00); @@ -16905,7 +17128,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_castps_ph() { + const unsafe fn test_mm_castps_ph() { let a = _mm_castsi128_ps(_mm_set1_epi16(0x3c00)); let r = _mm_castps_ph(a); let e = _mm_set1_ph(1.0); @@ -16913,7 +17136,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_castps_ph() { + const unsafe fn test_mm256_castps_ph() { let a = _mm256_castsi256_ps(_mm256_set1_epi16(0x3c00)); let r = _mm256_castps_ph(a); let e = _mm256_set1_ph(1.0); @@ -16921,7 +17144,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_castps_ph() { + const unsafe fn test_mm512_castps_ph() { let a = _mm512_castsi512_ps(_mm512_set1_epi16(0x3c00)); let r = _mm512_castps_ph(a); let e = _mm512_set1_ph(1.0); @@ -16929,7 +17152,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm_castph_ps() { + const unsafe fn test_mm_castph_ps() { let a = _mm_castsi128_ph(_mm_set1_epi32(0x3f800000)); let r = _mm_castph_ps(a); let e = _mm_set1_ps(1.0); @@ -16937,7 +17160,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm256_castph_ps() { + const unsafe fn test_mm256_castph_ps() { let a = _mm256_castsi256_ph(_mm256_set1_epi32(0x3f800000)); let r = _mm256_castph_ps(a); let e = _mm256_set1_ps(1.0); @@ -16945,7 +17168,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_castph_ps() { + const unsafe fn test_mm512_castph_ps() { let a = _mm512_castsi512_ph(_mm512_set1_epi32(0x3f800000)); let r = _mm512_castph_ps(a); let e = _mm512_set1_ps(1.0); @@ -16953,7 +17176,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_castpd_ph() { + const unsafe fn test_mm_castpd_ph() { let a = _mm_castsi128_pd(_mm_set1_epi16(0x3c00)); let r = _mm_castpd_ph(a); let e = _mm_set1_ph(1.0); @@ -16961,7 +17184,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_castpd_ph() { + const unsafe fn test_mm256_castpd_ph() { let a = _mm256_castsi256_pd(_mm256_set1_epi16(0x3c00)); let r = _mm256_castpd_ph(a); let e = _mm256_set1_ph(1.0); @@ -16969,7 +17192,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_castpd_ph() { + const unsafe fn test_mm512_castpd_ph() { let a = _mm512_castsi512_pd(_mm512_set1_epi16(0x3c00)); let r = _mm512_castpd_ph(a); let e = _mm512_set1_ph(1.0); @@ -16977,7 +17200,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm_castph_pd() { + const unsafe fn test_mm_castph_pd() { let a = _mm_castsi128_ph(_mm_set1_epi64x(0x3ff0000000000000)); let r = _mm_castph_pd(a); let e = _mm_set1_pd(1.0); @@ -16985,7 +17208,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm256_castph_pd() { + const unsafe fn test_mm256_castph_pd() { let a = _mm256_castsi256_ph(_mm256_set1_epi64x(0x3ff0000000000000)); let r = _mm256_castph_pd(a); let e = _mm256_set1_pd(1.0); @@ -16993,7 +17216,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_castph_pd() { + const unsafe fn test_mm512_castph_pd() { let a = _mm512_castsi512_ph(_mm512_set1_epi64(0x3ff0000000000000)); let r = _mm512_castph_pd(a); let e = _mm512_set1_pd(1.0); @@ -17001,7 +17224,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_castph256_ph128() { + const unsafe fn test_mm256_castph256_ph128() { let a = _mm256_setr_ph( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -17011,7 +17234,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm512_castph512_ph128() { + const unsafe fn test_mm512_castph512_ph128() { let a = _mm512_setr_ph( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., @@ -17022,7 +17245,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm512_castph512_ph256() { + const unsafe fn test_mm512_castph512_ph256() { let a = _mm512_setr_ph( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., @@ -17035,21 +17258,21 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_castph128_ph256() { + const unsafe fn test_mm256_castph128_ph256() { let a = _mm_setr_ph(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_castph128_ph256(a); assert_eq_m128h(_mm256_castph256_ph128(r), a); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm512_castph128_ph512() { + const unsafe fn test_mm512_castph128_ph512() { let a = _mm_setr_ph(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_castph128_ph512(a); assert_eq_m128h(_mm512_castph512_ph128(r), a); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm512_castph256_ph512() { + const unsafe fn test_mm512_castph256_ph512() { let a = _mm256_setr_ph( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -17058,7 +17281,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_zextph128_ph256() { + const unsafe fn test_mm256_zextph128_ph256() { let a = _mm_setr_ph(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm256_zextph128_ph256(a); let e = _mm256_setr_ph( @@ -17068,7 +17291,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_zextph128_ph512() { + const unsafe fn test_mm512_zextph128_ph512() { let a = _mm_setr_ph(1., 2., 3., 4., 5., 6., 7., 8.); let r = _mm512_zextph128_ph512(a); let e = _mm512_setr_ph( @@ -17079,7 +17302,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_zextph256_ph512() { + const unsafe fn test_mm512_zextph256_ph512() { let a = _mm256_setr_ph( 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., ); @@ -17346,14 +17569,14 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_load_ph() { + const unsafe fn test_mm_load_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_load_ph(addr_of!(a).cast()); assert_eq_m128h(a, b); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_load_ph() { + const unsafe fn test_mm256_load_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17362,7 +17585,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_load_ph() { + const unsafe fn test_mm512_load_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17373,7 +17596,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_load_sh() { + const unsafe fn test_mm_load_sh() { let a = _mm_set_sh(1.0); let b = _mm_load_sh(addr_of!(a).cast()); assert_eq_m128h(a, b); @@ -17399,7 +17622,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_loadu_ph() { + const unsafe fn test_mm_loadu_ph() { let array = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let r = _mm_loadu_ph(array.as_ptr()); let e = _mm_setr_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); @@ -17407,7 +17630,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_loadu_ph() { + const unsafe fn test_mm256_loadu_ph() { let array = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ]; @@ -17419,7 +17642,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_loadu_ph() { + const unsafe fn test_mm512_loadu_ph() { let array = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17435,7 +17658,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_move_sh() { + const unsafe fn test_mm_move_sh() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_sh(9.0); let r = _mm_move_sh(a, b); @@ -17444,7 +17667,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_move_sh() { + const unsafe fn test_mm_mask_move_sh() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_sh(9.0); let src = _mm_set_sh(10.0); @@ -17454,7 +17677,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_move_sh() { + const unsafe fn test_mm_maskz_move_sh() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_sh(9.0); let r = _mm_maskz_move_sh(0, a, b); @@ -17463,7 +17686,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_store_ph() { + const unsafe fn test_mm_store_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let mut b = _mm_setzero_ph(); _mm_store_ph(addr_of_mut!(b).cast(), a); @@ -17471,7 +17694,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_store_ph() { + const unsafe fn test_mm256_store_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17481,7 +17704,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_store_ph() { + const unsafe fn test_mm512_store_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17493,7 +17716,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_store_sh() { + const unsafe fn test_mm_store_sh() { let a = _mm_set_sh(1.0); let mut b = _mm_setzero_ph(); _mm_store_sh(addr_of_mut!(b).cast(), a); @@ -17511,7 +17734,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_storeu_ph() { + const unsafe fn test_mm_storeu_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let mut array = [0.0; 8]; _mm_storeu_ph(array.as_mut_ptr(), a); @@ -17519,7 +17742,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_storeu_ph() { + const unsafe fn test_mm256_storeu_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17529,7 +17752,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_storeu_ph() { + const unsafe fn test_mm512_storeu_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17541,7 +17764,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_add_ph() { + const unsafe fn test_mm_add_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let r = _mm_add_ph(a, b); @@ -17550,7 +17773,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_add_ph() { + const unsafe fn test_mm_mask_add_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let src = _mm_set_ph(10., 11., 12., 13., 14., 15., 16., 17.); @@ -17560,7 +17783,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_add_ph() { + const unsafe fn test_mm_maskz_add_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let r = _mm_maskz_add_ph(0b01010101, a, b); @@ -17569,7 +17792,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_add_ph() { + const unsafe fn test_mm256_add_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17582,7 +17805,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_add_ph() { + const unsafe fn test_mm256_mask_add_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17600,7 +17823,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_add_ph() { + const unsafe fn test_mm256_maskz_add_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17615,7 +17838,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_add_ph() { + const unsafe fn test_mm512_add_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17632,7 +17855,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_add_ph() { + const unsafe fn test_mm512_mask_add_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17656,7 +17879,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_add_ph() { + const unsafe fn test_mm512_maskz_add_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17786,7 +18009,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_add_sh() { + const unsafe fn test_mm_add_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_add_sh(a, b); @@ -17795,7 +18018,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_add_sh() { + const unsafe fn test_mm_mask_add_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let src = _mm_set_sh(4.0); @@ -17808,7 +18031,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_add_sh() { + const unsafe fn test_mm_maskz_add_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_maskz_add_sh(0, a, b); @@ -17820,7 +18043,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_sub_ph() { + const unsafe fn test_mm_sub_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let r = _mm_sub_ph(a, b); @@ -17829,7 +18052,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_sub_ph() { + const unsafe fn test_mm_mask_sub_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let src = _mm_set_ph(10., 11., 12., 13., 14., 15., 16., 17.); @@ -17839,7 +18062,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_sub_ph() { + const unsafe fn test_mm_maskz_sub_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let r = _mm_maskz_sub_ph(0b01010101, a, b); @@ -17848,7 +18071,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_sub_ph() { + const unsafe fn test_mm256_sub_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17864,7 +18087,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_sub_ph() { + const unsafe fn test_mm256_mask_sub_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17882,7 +18105,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_sub_ph() { + const unsafe fn test_mm256_maskz_sub_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -17897,7 +18120,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_sub_ph() { + const unsafe fn test_mm512_sub_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17918,7 +18141,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_sub_ph() { + const unsafe fn test_mm512_mask_sub_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -17942,7 +18165,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_sub_ph() { + const unsafe fn test_mm512_maskz_sub_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -18076,7 +18299,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_sub_sh() { + const unsafe fn test_mm_sub_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_sub_sh(a, b); @@ -18085,7 +18308,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_sub_sh() { + const unsafe fn test_mm_mask_sub_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let src = _mm_set_sh(4.0); @@ -18098,7 +18321,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_sub_sh() { + const unsafe fn test_mm_maskz_sub_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_maskz_sub_sh(0, a, b); @@ -18110,7 +18333,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mul_ph() { + const unsafe fn test_mm_mul_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let r = _mm_mul_ph(a, b); @@ -18119,7 +18342,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_mul_ph() { + const unsafe fn test_mm_mask_mul_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let src = _mm_set_ph(10., 11., 12., 13., 14., 15., 16., 17.); @@ -18129,7 +18352,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_mul_ph() { + const unsafe fn test_mm_maskz_mul_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0); let r = _mm_maskz_mul_ph(0b01010101, a, b); @@ -18138,7 +18361,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mul_ph() { + const unsafe fn test_mm256_mul_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -18154,7 +18377,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_mul_ph() { + const unsafe fn test_mm256_mask_mul_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -18172,7 +18395,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_mul_ph() { + const unsafe fn test_mm256_maskz_mul_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -18187,7 +18410,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mul_ph() { + const unsafe fn test_mm512_mul_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -18208,7 +18431,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_mul_ph() { + const unsafe fn test_mm512_mask_mul_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -18232,7 +18455,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_mul_ph() { + const unsafe fn test_mm512_maskz_mul_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -18366,7 +18589,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mul_sh() { + const unsafe fn test_mm_mul_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_mul_sh(a, b); @@ -18375,7 +18598,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_mul_sh() { + const unsafe fn test_mm_mask_mul_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let src = _mm_set_sh(4.0); @@ -18388,7 +18611,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_mul_sh() { + const unsafe fn test_mm_maskz_mul_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_maskz_mul_sh(0, a, b); @@ -18400,7 +18623,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_div_ph() { + const unsafe fn test_mm_div_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let r = _mm_div_ph(a, b); @@ -18409,7 +18632,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_div_ph() { + const unsafe fn test_mm_mask_div_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let src = _mm_set_ph(4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0); @@ -18419,7 +18642,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_div_ph() { + const unsafe fn test_mm_maskz_div_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let r = _mm_maskz_div_ph(0b01010101, a, b); @@ -18428,7 +18651,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_div_ph() { + const unsafe fn test_mm256_div_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let r = _mm256_div_ph(a, b); @@ -18437,7 +18660,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_div_ph() { + const unsafe fn test_mm256_mask_div_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let src = _mm256_set_ph( @@ -18452,7 +18675,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_div_ph() { + const unsafe fn test_mm256_maskz_div_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let r = _mm256_maskz_div_ph(0b0101010101010101, a, b); @@ -18463,7 +18686,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_div_ph() { + const unsafe fn test_mm512_div_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let r = _mm512_div_ph(a, b); @@ -18472,7 +18695,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_div_ph() { + const unsafe fn test_mm512_mask_div_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let src = _mm512_set_ph( @@ -18489,7 +18712,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_div_ph() { + const unsafe fn test_mm512_maskz_div_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let r = _mm512_maskz_div_ph(0b01010101010101010101010101010101, a, b); @@ -18588,7 +18811,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_div_sh() { + const unsafe fn test_mm_div_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_div_sh(a, b); @@ -18597,7 +18820,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_div_sh() { + const unsafe fn test_mm_mask_div_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let src = _mm_set_sh(4.0); @@ -18610,7 +18833,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_div_sh() { + const unsafe fn test_mm_maskz_div_sh() { let a = _mm_set_sh(1.0); let b = _mm_set_sh(2.0); let r = _mm_maskz_div_sh(0, a, b); @@ -19454,7 +19677,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_abs_ph() { + const unsafe fn test_mm_abs_ph() { let a = _mm_set_ph(-1.0, 0.0, 1.0, -2.0, 3.0, -4.0, 5.0, -6.0); let r = _mm_abs_ph(a); let e = _mm_set_ph(1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0); @@ -19462,7 +19685,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_abs_ph() { + const unsafe fn test_mm256_abs_ph() { let a = _mm256_set_ph( -1.0, 0.0, 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0, 9.0, -10.0, 11.0, -12.0, 13.0, -14.0, @@ -19475,7 +19698,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_abs_ph() { + const unsafe fn test_mm512_abs_ph() { let a = _mm512_set_ph( -1.0, 0.0, 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0, 9.0, -10.0, 11.0, -12.0, 13.0, -14.0, 15.0, -16.0, 17.0, -18.0, 19.0, -20.0, 21.0, -22.0, 23.0, -24.0, 25.0, -26.0, @@ -19491,7 +19714,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_conj_pch() { + const unsafe fn test_mm_conj_pch() { let a = _mm_set1_pch(0.0, 1.0); let r = _mm_conj_pch(a); let e = _mm_set1_pch(0.0, -1.0); @@ -19499,7 +19722,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_conj_pch() { + const unsafe fn test_mm_mask_conj_pch() { let a = _mm_set1_pch(0.0, 1.0); let src = _mm_setr_ph(2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); let r = _mm_mask_conj_pch(src, 0b0101, a); @@ -19508,7 +19731,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_conj_pch() { + const unsafe fn test_mm_maskz_conj_pch() { let a = _mm_set1_pch(0.0, 1.0); let r = _mm_maskz_conj_pch(0b0101, a); let e = _mm_setr_ph(0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0); @@ -19516,7 +19739,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_conj_pch() { + const unsafe fn test_mm256_conj_pch() { let a = _mm256_set1_pch(0.0, 1.0); let r = _mm256_conj_pch(a); let e = _mm256_set1_pch(0.0, -1.0); @@ -19524,7 +19747,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_conj_pch() { + const unsafe fn test_mm256_mask_conj_pch() { let a = _mm256_set1_pch(0.0, 1.0); let src = _mm256_setr_ph( 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, @@ -19537,7 +19760,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_conj_pch() { + const unsafe fn test_mm256_maskz_conj_pch() { let a = _mm256_set1_pch(0.0, 1.0); let r = _mm256_maskz_conj_pch(0b01010101, a); let e = _mm256_setr_ph( @@ -19547,7 +19770,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_conj_pch() { + const unsafe fn test_mm512_conj_pch() { let a = _mm512_set1_pch(0.0, 1.0); let r = _mm512_conj_pch(a); let e = _mm512_set1_pch(0.0, -1.0); @@ -19555,7 +19778,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_conj_pch() { + const unsafe fn test_mm512_mask_conj_pch() { let a = _mm512_set1_pch(0.0, 1.0); let src = _mm512_setr_ph( 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, @@ -19572,7 +19795,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_conj_pch() { + const unsafe fn test_mm512_maskz_conj_pch() { let a = _mm512_set1_pch(0.0, 1.0); let r = _mm512_maskz_conj_pch(0b0101010101010101, a); let e = _mm512_setr_ph( @@ -20203,7 +20426,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fmadd_ph() { + const unsafe fn test_mm_fmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20213,7 +20436,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fmadd_ph() { + const unsafe fn test_mm_mask_fmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20223,7 +20446,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fmadd_ph() { + const unsafe fn test_mm_mask3_fmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20233,7 +20456,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fmadd_ph() { + const unsafe fn test_mm_maskz_fmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20243,7 +20466,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_fmadd_ph() { + const unsafe fn test_mm256_fmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20253,7 +20476,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_fmadd_ph() { + const unsafe fn test_mm256_mask_fmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20265,7 +20488,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask3_fmadd_ph() { + const unsafe fn test_mm256_mask3_fmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20277,7 +20500,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_fmadd_ph() { + const unsafe fn test_mm256_maskz_fmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20289,7 +20512,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_fmadd_ph() { + const unsafe fn test_mm512_fmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20299,7 +20522,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_fmadd_ph() { + const unsafe fn test_mm512_mask_fmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20312,7 +20535,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask3_fmadd_ph() { + const unsafe fn test_mm512_mask3_fmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20325,7 +20548,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_fmadd_ph() { + const unsafe fn test_mm512_maskz_fmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20402,7 +20625,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fmadd_sh() { + const unsafe fn test_mm_fmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20412,7 +20635,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fmadd_sh() { + const unsafe fn test_mm_mask_fmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20425,7 +20648,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fmadd_sh() { + const unsafe fn test_mm_mask3_fmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20438,7 +20661,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fmadd_sh() { + const unsafe fn test_mm_maskz_fmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20512,7 +20735,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fmsub_ph() { + const unsafe fn test_mm_fmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20522,7 +20745,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fmsub_ph() { + const unsafe fn test_mm_mask_fmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20532,7 +20755,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fmsub_ph() { + const unsafe fn test_mm_mask3_fmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20542,7 +20765,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fmsub_ph() { + const unsafe fn test_mm_maskz_fmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20552,7 +20775,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_fmsub_ph() { + const unsafe fn test_mm256_fmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20562,7 +20785,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_fmsub_ph() { + const unsafe fn test_mm256_mask_fmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20574,7 +20797,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask3_fmsub_ph() { + const unsafe fn test_mm256_mask3_fmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20586,7 +20809,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_fmsub_ph() { + const unsafe fn test_mm256_maskz_fmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20598,7 +20821,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_fmsub_ph() { + const unsafe fn test_mm512_fmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20608,7 +20831,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_fmsub_ph() { + const unsafe fn test_mm512_mask_fmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20621,7 +20844,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask3_fmsub_ph() { + const unsafe fn test_mm512_mask3_fmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20634,7 +20857,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_fmsub_ph() { + const unsafe fn test_mm512_maskz_fmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20711,7 +20934,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fmsub_sh() { + const unsafe fn test_mm_fmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20721,7 +20944,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fmsub_sh() { + const unsafe fn test_mm_mask_fmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20734,7 +20957,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fmsub_sh() { + const unsafe fn test_mm_mask3_fmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20747,7 +20970,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fmsub_sh() { + const unsafe fn test_mm_maskz_fmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -20821,7 +21044,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fnmadd_ph() { + const unsafe fn test_mm_fnmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20831,7 +21054,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fnmadd_ph() { + const unsafe fn test_mm_mask_fnmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20841,7 +21064,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fnmadd_ph() { + const unsafe fn test_mm_mask3_fnmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20851,7 +21074,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fnmadd_ph() { + const unsafe fn test_mm_maskz_fnmadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -20861,7 +21084,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_fnmadd_ph() { + const unsafe fn test_mm256_fnmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20871,7 +21094,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_fnmadd_ph() { + const unsafe fn test_mm256_mask_fnmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20883,7 +21106,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask3_fnmadd_ph() { + const unsafe fn test_mm256_mask3_fnmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20895,7 +21118,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_fnmadd_ph() { + const unsafe fn test_mm256_maskz_fnmadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -20907,7 +21130,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_fnmadd_ph() { + const unsafe fn test_mm512_fnmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20917,7 +21140,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_fnmadd_ph() { + const unsafe fn test_mm512_mask_fnmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20930,7 +21153,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask3_fnmadd_ph() { + const unsafe fn test_mm512_mask3_fnmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -20943,7 +21166,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_fnmadd_ph() { + const unsafe fn test_mm512_maskz_fnmadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21021,7 +21244,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fnmadd_sh() { + const unsafe fn test_mm_fnmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21031,7 +21254,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fnmadd_sh() { + const unsafe fn test_mm_mask_fnmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21044,7 +21267,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fnmadd_sh() { + const unsafe fn test_mm_mask3_fnmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21057,7 +21280,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fnmadd_sh() { + const unsafe fn test_mm_maskz_fnmadd_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21131,7 +21354,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fnmsub_ph() { + const unsafe fn test_mm_fnmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21141,7 +21364,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fnmsub_ph() { + const unsafe fn test_mm_mask_fnmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21151,7 +21374,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fnmsub_ph() { + const unsafe fn test_mm_mask3_fnmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21161,7 +21384,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fnmsub_ph() { + const unsafe fn test_mm_maskz_fnmsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21171,7 +21394,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_fnmsub_ph() { + const unsafe fn test_mm256_fnmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21181,7 +21404,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_fnmsub_ph() { + const unsafe fn test_mm256_mask_fnmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21193,7 +21416,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask3_fnmsub_ph() { + const unsafe fn test_mm256_mask3_fnmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21205,7 +21428,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_fnmsub_ph() { + const unsafe fn test_mm256_maskz_fnmsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21217,7 +21440,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_fnmsub_ph() { + const unsafe fn test_mm512_fnmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21227,7 +21450,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_fnmsub_ph() { + const unsafe fn test_mm512_mask_fnmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21240,7 +21463,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask3_fnmsub_ph() { + const unsafe fn test_mm512_mask3_fnmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21253,7 +21476,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_fnmsub_ph() { + const unsafe fn test_mm512_maskz_fnmsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21331,7 +21554,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fnmsub_sh() { + const unsafe fn test_mm_fnmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21341,7 +21564,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fnmsub_sh() { + const unsafe fn test_mm_mask_fnmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21354,7 +21577,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fnmsub_sh() { + const unsafe fn test_mm_mask3_fnmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21367,7 +21590,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fnmsub_sh() { + const unsafe fn test_mm_maskz_fnmsub_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); let c = _mm_setr_ph(3.0, 30., 31., 32., 33., 34., 35., 36.); @@ -21441,7 +21664,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fmaddsub_ph() { + const unsafe fn test_mm_fmaddsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21451,7 +21674,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fmaddsub_ph() { + const unsafe fn test_mm_mask_fmaddsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21461,7 +21684,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fmaddsub_ph() { + const unsafe fn test_mm_mask3_fmaddsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21471,7 +21694,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fmaddsub_ph() { + const unsafe fn test_mm_maskz_fmaddsub_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21481,7 +21704,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_fmaddsub_ph() { + const unsafe fn test_mm256_fmaddsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21493,7 +21716,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_fmaddsub_ph() { + const unsafe fn test_mm256_mask_fmaddsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21505,7 +21728,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask3_fmaddsub_ph() { + const unsafe fn test_mm256_mask3_fmaddsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21517,7 +21740,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_fmaddsub_ph() { + const unsafe fn test_mm256_maskz_fmaddsub_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21529,7 +21752,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_fmaddsub_ph() { + const unsafe fn test_mm512_fmaddsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21542,7 +21765,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_fmaddsub_ph() { + const unsafe fn test_mm512_mask_fmaddsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21555,7 +21778,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask3_fmaddsub_ph() { + const unsafe fn test_mm512_mask3_fmaddsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21568,7 +21791,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_fmaddsub_ph() { + const unsafe fn test_mm512_maskz_fmaddsub_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21649,7 +21872,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_fmsubadd_ph() { + const unsafe fn test_mm_fmsubadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21659,7 +21882,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_fmsubadd_ph() { + const unsafe fn test_mm_mask_fmsubadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21669,7 +21892,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask3_fmsubadd_ph() { + const unsafe fn test_mm_mask3_fmsubadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21679,7 +21902,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_maskz_fmsubadd_ph() { + const unsafe fn test_mm_maskz_fmsubadd_ph() { let a = _mm_set1_ph(1.0); let b = _mm_set1_ph(2.0); let c = _mm_set1_ph(3.0); @@ -21689,7 +21912,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_fmsubadd_ph() { + const unsafe fn test_mm256_fmsubadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21701,7 +21924,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_fmsubadd_ph() { + const unsafe fn test_mm256_mask_fmsubadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21713,7 +21936,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask3_fmsubadd_ph() { + const unsafe fn test_mm256_mask3_fmsubadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21725,7 +21948,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_maskz_fmsubadd_ph() { + const unsafe fn test_mm256_maskz_fmsubadd_ph() { let a = _mm256_set1_ph(1.0); let b = _mm256_set1_ph(2.0); let c = _mm256_set1_ph(3.0); @@ -21737,7 +21960,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_fmsubadd_ph() { + const unsafe fn test_mm512_fmsubadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21750,7 +21973,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_fmsubadd_ph() { + const unsafe fn test_mm512_mask_fmsubadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21763,7 +21986,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask3_fmsubadd_ph() { + const unsafe fn test_mm512_mask3_fmsubadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -21776,7 +21999,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_maskz_fmsubadd_ph() { + const unsafe fn test_mm512_maskz_fmsubadd_ph() { let a = _mm512_set1_ph(1.0); let b = _mm512_set1_ph(2.0); let c = _mm512_set1_ph(3.0); @@ -23741,42 +23964,42 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_reduce_add_ph() { + const unsafe fn test_mm_reduce_add_ph() { let a = _mm_set1_ph(2.0); let r = _mm_reduce_add_ph(a); assert_eq!(r, 16.0); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_reduce_add_ph() { + const unsafe fn test_mm256_reduce_add_ph() { let a = _mm256_set1_ph(2.0); let r = _mm256_reduce_add_ph(a); assert_eq!(r, 32.0); } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_reduce_add_ph() { + const unsafe fn test_mm512_reduce_add_ph() { let a = _mm512_set1_ph(2.0); let r = _mm512_reduce_add_ph(a); assert_eq!(r, 64.0); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_reduce_mul_ph() { + const unsafe fn test_mm_reduce_mul_ph() { let a = _mm_set1_ph(2.0); let r = _mm_reduce_mul_ph(a); assert_eq!(r, 256.0); } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_reduce_mul_ph() { + const unsafe fn test_mm256_reduce_mul_ph() { let a = _mm256_set1_ph(2.0); let r = _mm256_reduce_mul_ph(a); assert_eq!(r, 65536.0); } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_reduce_mul_ph() { + const unsafe fn test_mm512_reduce_mul_ph() { let a = _mm512_set1_ph(2.0); let r = _mm512_reduce_mul_ph(a); assert_eq!(r, 16777216.0); @@ -24013,7 +24236,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm_mask_blend_ph() { + const unsafe fn test_mm_mask_blend_ph() { let a = _mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); let b = _mm_set_ph(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0); let r = _mm_mask_blend_ph(0b01010101, a, b); @@ -24022,7 +24245,7 @@ mod tests { } #[simd_test(enable = "avx512fp16,avx512vl")] - unsafe fn test_mm256_mask_blend_ph() { + const unsafe fn test_mm256_mask_blend_ph() { let a = _mm256_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -24039,7 +24262,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_mask_blend_ph() { + const unsafe fn test_mm512_mask_blend_ph() { let a = _mm512_set_ph( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -27310,14 +27533,14 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm_cvtsh_h() { + const unsafe fn test_mm_cvtsh_h() { let a = _mm_setr_ph(1.0, 2.0, 3.0, 42.0, 5.0, 6.0, 7.0, 8.0); let r = _mm_cvtsh_h(a); assert_eq!(r, 1.0); } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm256_cvtsh_h() { + const unsafe fn test_mm256_cvtsh_h() { let a = _mm256_setr_ph( 1.0, 2.0, 3.0, 42.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, ); @@ -27326,7 +27549,7 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm512_cvtsh_h() { + const unsafe fn test_mm512_cvtsh_h() { let a = _mm512_setr_ph( 1.0, 2.0, 3.0, 42.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, @@ -27337,14 +27560,14 @@ mod tests { } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm_cvtsi128_si16() { + const unsafe fn test_mm_cvtsi128_si16() { let a = _mm_setr_epi16(1, 2, 3, 4, 5, 6, 7, 8); let r = _mm_cvtsi128_si16(a); assert_eq!(r, 1); } #[simd_test(enable = "avx512fp16")] - unsafe fn test_mm_cvtsi16_si128() { + const unsafe fn test_mm_cvtsi16_si128() { let a = 1; let r = _mm_cvtsi16_si128(a); let e = _mm_setr_epi16(1, 0, 0, 0, 0, 0, 0, 0); diff --git a/library/stdarch/crates/core_arch/src/x86/f16c.rs b/library/stdarch/crates/core_arch/src/x86/f16c.rs index 519cc38294a3..09971939ba44 100644 --- a/library/stdarch/crates/core_arch/src/x86/f16c.rs +++ b/library/stdarch/crates/core_arch/src/x86/f16c.rs @@ -25,7 +25,8 @@ unsafe extern "unadjusted" { #[target_feature(enable = "f16c")] #[cfg_attr(test, assert_instr("vcvtph2ps"))] #[stable(feature = "x86_f16c_intrinsics", since = "1.68.0")] -pub fn _mm_cvtph_ps(a: __m128i) -> __m128 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm_cvtph_ps(a: __m128i) -> __m128 { unsafe { let a: f16x8 = transmute(a); let a: f16x4 = simd_shuffle!(a, a, [0, 1, 2, 3]); @@ -41,7 +42,8 @@ pub fn _mm_cvtph_ps(a: __m128i) -> __m128 { #[target_feature(enable = "f16c")] #[cfg_attr(test, assert_instr("vcvtph2ps"))] #[stable(feature = "x86_f16c_intrinsics", since = "1.68.0")] -pub fn _mm256_cvtph_ps(a: __m128i) -> __m256 { +#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] +pub const fn _mm256_cvtph_ps(a: __m128i) -> __m256 { unsafe { let a: f16x8 = transmute(a); simd_cast(a) @@ -103,6 +105,7 @@ pub fn _mm256_cvtps_ph(a: __m256) -> __m128i { #[cfg(test)] mod tests { + use crate::core_arch::assert_eq_const as assert_eq; use crate::{core_arch::x86::*, mem::transmute}; use stdarch_test::simd_test; @@ -116,7 +119,7 @@ mod tests { const F16_EIGHT: i16 = 0x4800; #[simd_test(enable = "f16c")] - unsafe fn test_mm_cvtph_ps() { + const unsafe fn test_mm_cvtph_ps() { let a = _mm_set_epi16(0, 0, 0, 0, F16_ONE, F16_TWO, F16_THREE, F16_FOUR); let r = _mm_cvtph_ps(a); let e = _mm_set_ps(1.0, 2.0, 3.0, 4.0); @@ -124,7 +127,7 @@ mod tests { } #[simd_test(enable = "f16c")] - unsafe fn test_mm256_cvtph_ps() { + const unsafe fn test_mm256_cvtph_ps() { let a = _mm_set_epi16( F16_ONE, F16_TWO, F16_THREE, F16_FOUR, F16_FIVE, F16_SIX, F16_SEVEN, F16_EIGHT, ); From 741f23f80e3d50ad016cb7b844d065d32731a348 Mon Sep 17 00:00:00 2001 From: reucru01 Date: Fri, 24 Oct 2025 10:15:30 +0100 Subject: [PATCH 076/489] Modifies CI to pass profile to test tool --- library/stdarch/.github/workflows/main.yml | 4 +-- library/stdarch/ci/intrinsic-test-docker.sh | 1 + library/stdarch/ci/intrinsic-test.sh | 21 +++++++------ library/stdarch/ci/run-docker.sh | 1 + library/stdarch/ci/run.sh | 30 +++++++++---------- .../crates/intrinsic-test/src/common/cli.rs | 7 +++++ .../intrinsic-test/src/common/compare.rs | 16 ++++++++-- .../intrinsic-test/src/common/gen_rust.rs | 9 ++++-- .../crates/intrinsic-test/src/common/mod.rs | 4 ++- 9 files changed, 62 insertions(+), 31 deletions(-) diff --git a/library/stdarch/.github/workflows/main.yml b/library/stdarch/.github/workflows/main.yml index 28c15cf4734a..92083443e425 100644 --- a/library/stdarch/.github/workflows/main.yml +++ b/library/stdarch/.github/workflows/main.yml @@ -220,7 +220,7 @@ jobs: if: matrix.build_std != '' # Configure some env vars based on matrix configuration - - run: echo "PROFILE=--profile=${{matrix.profile}}" >> $GITHUB_ENV + - run: echo "PROFILE=${{matrix.profile}}" >> $GITHUB_ENV shell: bash - run: echo "NORUN=1" >> $GITHUB_ENV shell: bash @@ -280,7 +280,7 @@ jobs: if: ${{ matrix.build_std }} # Configure some env vars based on matrix configuration - - run: echo "PROFILE=--profile=${{ matrix.profile }}" >> $GITHUB_ENV + - run: echo "PROFILE=${{ matrix.profile }}" >> $GITHUB_ENV - run: ./ci/intrinsic-test-docker.sh ${{ matrix.target }} if: ${{ !startsWith(matrix.target, 'thumb') }} env: diff --git a/library/stdarch/ci/intrinsic-test-docker.sh b/library/stdarch/ci/intrinsic-test-docker.sh index f62d7e484f5b..beeff42c7621 100755 --- a/library/stdarch/ci/intrinsic-test-docker.sh +++ b/library/stdarch/ci/intrinsic-test-docker.sh @@ -30,6 +30,7 @@ run() { --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --env TARGET="${1}" \ + --env PROFILE \ --env "${HOST_LINKER}"="cc" \ --env STDARCH_DISABLE_ASSERT_INSTR \ --env NOSTD \ diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index ff76a0c76996..89104e2672ad 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -6,7 +6,7 @@ set -ex export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir" export HOST_RUSTFLAGS="${RUSTFLAGS}" -export PROFILE="${PROFILE:="--profile=release"}" +export PROFILE="${PROFILE:="release"}" case ${TARGET} in # On 32-bit use a static relocation model which avoids some extra @@ -85,27 +85,29 @@ esac # Arm specific case "${TARGET}" in aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*) - CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \ - cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ + cargo run "${INTRINSIC_TEST}" --release \ --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ --runner "${TEST_RUNNER}" \ --cppcompiler "${TEST_CXX_COMPILER}" \ --skip "${TEST_SKIP_INTRINSICS}" \ --target "${TARGET}" \ + --profile "${PROFILE}" \ --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" ;; aarch64_be-unknown-linux-gnu*) - CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \ - cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ + cargo run "${INTRINSIC_TEST}" --release \ --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ --runner "${TEST_RUNNER}" \ --cppcompiler "${TEST_CXX_COMPILER}" \ --skip "${TEST_SKIP_INTRINSICS}" \ --target "${TARGET}" \ - --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" \ + --profile "${PROFILE}" \ --linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \ - --cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}" + --cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}" \ + --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" ;; x86_64-unknown-linux-gnu*) @@ -114,13 +116,14 @@ case "${TARGET}" in # Hence the use of `env -u`. env -u CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER \ CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" \ - RUST_LOG=info RUST_BACKTRACE=1 \ - cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ + RUST_LOG=warn RUST_BACKTRACE=1 \ + cargo run "${INTRINSIC_TEST}" --release \ --bin intrinsic-test -- intrinsics_data/x86-intel.xml \ --runner "${TEST_RUNNER}" \ --skip "${TEST_SKIP_INTRINSICS}" \ --cppcompiler "${TEST_CXX_COMPILER}" \ --target "${TARGET}" \ + --profile "${PROFILE}" \ --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" ;; *) diff --git a/library/stdarch/ci/run-docker.sh b/library/stdarch/ci/run-docker.sh index d7aa50a8c96f..28dfd5a24a9f 100755 --- a/library/stdarch/ci/run-docker.sh +++ b/library/stdarch/ci/run-docker.sh @@ -37,6 +37,7 @@ run() { --env NORUN \ --env RUSTFLAGS \ --env CARGO_UNSTABLE_BUILD_STD \ + --env PROFILE \ --volume "${HOME}/.cargo":/cargo \ --volume "$(rustc --print sysroot)":/rust:ro \ --volume "$(pwd)":/checkout:ro \ diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index 2bb77bae256f..a8925c470a10 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -12,7 +12,7 @@ set -ex export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir" export HOST_RUSTFLAGS="${RUSTFLAGS}" -export PROFILE="${PROFILE:="--profile=release"}" +export PROFILE="${PROFILE:="release"}" case ${TARGET} in # On Windows the linker performs identical COMDAT folding (ICF) by default @@ -63,7 +63,7 @@ cargo_test() { if [ "$NORUN" = "1" ]; then export subcmd="build" fi - cmd="$cmd ${subcmd} --target=$TARGET $1" + cmd="$cmd ${subcmd} --target=$TARGET --profile=$PROFILE $1" cmd="$cmd -- $2" case ${TARGET} in @@ -80,10 +80,10 @@ cargo_test() { CORE_ARCH="--manifest-path=crates/core_arch/Cargo.toml" STDARCH_EXAMPLES="--manifest-path=examples/Cargo.toml" -cargo_test "${CORE_ARCH} ${PROFILE}" +cargo_test "${CORE_ARCH}" if [ "$NOSTD" != "1" ]; then - cargo_test "${STDARCH_EXAMPLES} ${PROFILE}" + cargo_test "${STDARCH_EXAMPLES}" fi @@ -93,41 +93,41 @@ case ${TARGET} in export STDARCH_DISABLE_ASSERT_INSTR=1 export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx" - cargo_test "${PROFILE}" + cargo_test export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx512f" - cargo_test "${PROFILE}" + cargo_test ;; x86_64* | i686*) export STDARCH_DISABLE_ASSERT_INSTR=1 export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx" - cargo_test "${PROFILE}" + cargo_test ;; # FIXME: don't build anymore #mips-*gnu* | mipsel-*gnu*) # export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa,+fp64,+mips32r5" - # cargo_test "${PROFILE}" + # cargo_test # ;; mips64*) export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa" - cargo_test "${PROFILE}" + cargo_test ;; s390x*) export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+vector-enhancements-1" - cargo_test "${PROFILE}" + cargo_test ;; powerpc64*) export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+altivec" - cargo_test "${PROFILE}" + cargo_test export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+vsx" - cargo_test "${PROFILE}" + cargo_test ;; powerpc*) # qemu has a bug in PPC32 which leads to a crash when compiled with `vsx` export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+altivec" - cargo_test "${PROFILE}" + cargo_test ;; *) ;; @@ -138,7 +138,7 @@ if [ "$NORUN" != "1" ] && [ "$NOSTD" != 1 ]; then # Test examples ( cd examples - cargo test --target "$TARGET" "${PROFILE}" - echo test | cargo run --target "$TARGET" "${PROFILE}" hex + cargo test --target "${TARGET}" --profile "${PROFILE}" + echo test | cargo run --target "${TARGET}" --profile "${PROFILE}" hex ) fi diff --git a/library/stdarch/crates/intrinsic-test/src/common/cli.rs b/library/stdarch/crates/intrinsic-test/src/common/cli.rs index ff34ef3d2d3d..bed8259de8b6 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/cli.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/cli.rs @@ -41,6 +41,10 @@ pub struct Cli { #[arg(long, default_value_t = String::from("armv7-unknown-linux-gnueabihf"))] pub target: String, + /// Pass a profile (release, dev) + #[arg(long, default_value_t = String::from("release"))] + pub profile: String, + /// Set the linker #[arg(long)] pub linker: Option, @@ -59,6 +63,7 @@ pub struct ProcessedCli { pub cpp_compiler: Option, pub runner: String, pub target: String, + pub profile: String, pub linker: Option, pub cxx_toolchain_dir: Option, pub skip: Vec, @@ -70,6 +75,7 @@ impl ProcessedCli { let filename = cli_options.input; let runner = cli_options.runner.unwrap_or_default(); let target = cli_options.target; + let profile = cli_options.profile; let linker = cli_options.linker; let cxx_toolchain_dir = cli_options.cxx_toolchain_dir; let sample_percentage = cli_options.sample_percentage; @@ -103,6 +109,7 @@ impl ProcessedCli { cpp_compiler, runner, target, + profile, linker, cxx_toolchain_dir, skip, diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index c4c2a1e3e482..521434917159 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -11,7 +11,17 @@ fn runner_command(runner: &str) -> Command { cmd } -pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: &str) -> bool { +pub fn compare_outputs( + intrinsic_name_list: &Vec, + runner: &str, + target: &str, + profile: &str, +) -> bool { + let profile_dir = match profile { + "dev" => "debug", + _ => "release", + }; + let (c, rust) = rayon::join( || { runner_command(runner) @@ -21,7 +31,9 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: }, || { runner_command(runner) - .arg(format!("./target/{target}/release/intrinsic-test-programs")) + .arg(format!( + "./target/{target}/{profile_dir}/intrinsic-test-programs" + )) .current_dir("rust_programs") .output() }, diff --git a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs index fb047e2612de..82b97701bb14 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/gen_rust.rs @@ -140,7 +140,12 @@ pub fn write_lib_rs( Ok(()) } -pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Option<&str>) -> bool { +pub fn compile_rust_programs( + toolchain: Option<&str>, + target: &str, + profile: &str, + linker: Option<&str>, +) -> bool { /* If there has been a linker explicitly set from the command line then * we want to set it via setting it in the RUSTFLAGS*/ @@ -161,7 +166,7 @@ pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Opti if toolchain.is_some_and(|val| !val.is_empty()) { cargo_command.arg(toolchain.unwrap()); } - cargo_command.args(["build", "--target", target, "--release"]); + cargo_command.args(["build", "--target", target, "--profile", profile]); let mut rust_flags = "-Cdebuginfo=0".to_string(); if let Some(linker) = linker { diff --git a/library/stdarch/crates/intrinsic-test/src/common/mod.rs b/library/stdarch/crates/intrinsic-test/src/common/mod.rs index 8b6bd943a742..a1062b3a87db 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/mod.rs @@ -146,6 +146,7 @@ pub trait SupportedArchitectureTest { .unwrap(); let target = &self.cli_options().target; + let profile = &self.cli_options().profile; let toolchain = self.cli_options().toolchain.as_deref(); let linker = self.cli_options().linker.as_deref(); @@ -178,7 +179,7 @@ pub trait SupportedArchitectureTest { .collect::>() .unwrap(); - compile_rust_programs(toolchain, target, linker) + compile_rust_programs(toolchain, target, profile, linker) } fn compare_outputs(&self) -> bool { @@ -193,6 +194,7 @@ pub trait SupportedArchitectureTest { &intrinsics_name_list, &self.cli_options().runner, &self.cli_options().target, + &self.cli_options().profile, ) } else { true From 2f85d700e670559c3588cae31667e3e8004c9599 Mon Sep 17 00:00:00 2001 From: reucru01 Date: Tue, 28 Oct 2025 12:19:12 +0000 Subject: [PATCH 077/489] Fixes hardcoded path for WASM runner --- library/stdarch/ci/docker/wasm32-wasip1/Dockerfile | 2 -- library/stdarch/ci/run.sh | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library/stdarch/ci/docker/wasm32-wasip1/Dockerfile b/library/stdarch/ci/docker/wasm32-wasip1/Dockerfile index 0527c0df1777..cb4a9b2948cc 100644 --- a/library/stdarch/ci/docker/wasm32-wasip1/Dockerfile +++ b/library/stdarch/ci/docker/wasm32-wasip1/Dockerfile @@ -11,5 +11,3 @@ ENV VERSION=v38.0.3 RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/${VERSION}/wasmtime-${VERSION}-x86_64-linux.tar.xz | tar xJf - ENV PATH=$PATH:/wasmtime-${VERSION}-x86_64-linux - -ENV CARGO_TARGET_WASM32_WASIP1_RUNNER="wasmtime -Wexceptions --dir /checkout/target/wasm32-wasip1/release/deps::." diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index a8925c470a10..f40a305117b8 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -71,6 +71,12 @@ cargo_test() { # harness isn't trying to capture output, otherwise we won't get any useful # output. wasm32*) + if [ "$PROFILE" = "release" ]; then + dir="release" + else + dir="debug" + fi + export CARGO_TARGET_WASM32_WASIP1_RUNNER="wasmtime -Wexceptions --dir /checkout/target/wasm32-wasip1/$dir/deps::." cmd="$cmd --nocapture" ;; esac From 7d0300b8a578d4c7498365576279dc7ef1cf211b Mon Sep 17 00:00:00 2001 From: Adam Gemmell Date: Wed, 3 Dec 2025 12:03:13 +0000 Subject: [PATCH 078/489] Fix +vfp3,-d32 target configuration --- .../rustc_target/src/spec/targets/armv7_linux_androideabi.rs | 2 +- compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs | 2 +- .../src/spec/targets/armv7_unknown_linux_gnueabihf.rs | 2 +- .../src/spec/targets/armv7_unknown_linux_musleabihf.rs | 2 +- .../src/spec/targets/armv7_unknown_linux_uclibceabihf.rs | 2 +- .../src/spec/targets/armv7_unknown_netbsd_eabihf.rs | 2 +- .../rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs | 2 +- .../src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs | 2 +- compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs index ad8a14fdad53..3ccb99c9ab0f 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_linux_androideabi.rs @@ -28,7 +28,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::Eabi, llvm_floatabi: Some(FloatAbi::Soft), - features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".into(), + features: "+v7,+thumb-mode,+thumb2,+vfp3d16,-neon".into(), supported_sanitizers: SanitizerSet::ADDRESS, max_atomic_width: Some(64), ..base diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs index 0a8432ea8fe9..c358b530f742 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), ..base::freebsd::opts() diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs index cbf6d5d08dd0..639a9d225729 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_gnueabihf.rs @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs index 9b5fcd87b120..fb7bd1226a37 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_musleabihf.rs @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "\u{1}mcount".into(), // FIXME(compiler-team#422): musl targets should be dynamically linked by default. diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs index 927c910da596..8fb38d315bf6 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_linux_uclibceabihf.rs @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), cpu: "generic".into(), max_atomic_width: Some(64), mcount: "_mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs index 788944e64c84..8869210ce002 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "__mcount".into(), ..base::netbsd::opts() diff --git a/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs index e43e4fe85cad..27e81c5834f2 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_wrs_vxworks_eabihf.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), // Info about features at https://wiki.debian.org/ArmHardFloatPort - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), max_atomic_width: Some(64), ..base::vxworks::opts() }, diff --git a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs index 9433cbd46627..cb652e6a1e1b 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), linker: Some("arm-kmc-eabi-gcc".into()), - features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), + features: "+v7,+vfp3d16,+thumb2,-neon".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(64), diff --git a/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs index e03fe3e78b9d..28efdbe2291f 100644 --- a/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { llvm_floatabi: Some(FloatAbi::Hard), linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), - features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(), + features: "+v7,+vfp3d16,+thumb2,-neon,+strict-align".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(64), From 4ed68f01dc23b2877140c515ee16c6b59801a7a2 Mon Sep 17 00:00:00 2001 From: Adam Gemmell Date: Wed, 3 Dec 2025 12:04:41 +0000 Subject: [PATCH 079/489] Remove redundant -d32 in target specs --- .../src/spec/targets/arm_unknown_linux_gnueabihf.rs | 2 +- .../src/spec/targets/arm_unknown_linux_musleabihf.rs | 2 +- compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs | 2 +- .../src/spec/targets/armv6_unknown_netbsd_eabihf.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs index e003a65be393..1cae42c14559 100644 --- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_gnueabihf.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), - features: "+strict-align,+v6,+vfp2,-d32".into(), + features: "+strict-align,+v6,+vfp2".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), diff --git a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs index 76051403a559..99995e27af0d 100644 --- a/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/targets/arm_unknown_linux_musleabihf.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { llvm_floatabi: Some(FloatAbi::Hard), // Most of these settings are copied from the arm_unknown_linux_gnueabihf // target. - features: "+strict-align,+v6,+vfp2,-d32".into(), + features: "+strict-align,+v6,+vfp2".into(), max_atomic_width: Some(64), mcount: "\u{1}mcount".into(), // FIXME(compiler-team#422): musl targets should be dynamically linked by default. diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs index 20d91d6968a6..6d6dfeed96b0 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), - features: "+v6,+vfp2,-d32".into(), + features: "+v6,+vfp2".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), llvm_mcount_intrinsic: Some("llvm.arm.gnu.eabi.mcount".into()), diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs index 0316bd92999b..cb931e6c0e33 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { abi: Abi::EabiHf, llvm_floatabi: Some(FloatAbi::Hard), - features: "+v6,+vfp2,-d32".into(), + features: "+v6,+vfp2".into(), max_atomic_width: Some(64), mcount: "__mcount".into(), ..base::netbsd::opts() From 5c467cb4d17359960c4a8c4843977012e828b48f Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Wed, 3 Dec 2025 11:15:20 -0600 Subject: [PATCH 080/489] Allow PowerPC spe_acc as clobber-only register This register is only supported on the *powerpc*spe targets. It is only recognized by LLVM. gcc does not accept this as a clobber, nor does it support these targets. This is a volatile register, thus it is included with clobber_abi. --- src/asm.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index f237861b1595..ceb3dd3ffedf 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -209,10 +209,16 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { } ("r", dummy_output_type(self.cx, reg.reg_class())) } else { - // `clobber_abi` can add lots of clobbers that are not supported by the target, - // such as AVX-512 registers, so we just ignore unsupported registers - let is_target_supported = - reg.reg_class().supported_types(asm_arch, true).iter().any( + let is_target_supported = match reg.reg_class() { + // `clobber_abi` clobbers spe_acc on all PowerPC targets. This + // register is unique to the powerpc*spe target, and the target + // is not supported by gcc. Ignore it. + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::spe_acc, + ) => false, + // `clobber_abi` can add lots of clobbers that are not supported by the target, + // such as AVX-512 registers, so we just ignore unsupported registers + x => x.supported_types(asm_arch, true).iter().any( |&(_, feature)| { if let Some(feature) = feature { self.tcx @@ -222,7 +228,8 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { true // Register class is unconditionally supported } }, - ); + ), + }; if is_target_supported && !clobbers.contains(®_name) { clobbers.push(reg_name); @@ -710,7 +717,8 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str { PowerPCInlineAsmRegClass::cr | PowerPCInlineAsmRegClass::ctr | PowerPCInlineAsmRegClass::lr - | PowerPCInlineAsmRegClass::xer, + | PowerPCInlineAsmRegClass::xer + | PowerPCInlineAsmRegClass::spe_acc, ) => { unreachable!("clobber-only") } @@ -793,7 +801,8 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl PowerPCInlineAsmRegClass::cr | PowerPCInlineAsmRegClass::ctr | PowerPCInlineAsmRegClass::lr - | PowerPCInlineAsmRegClass::xer, + | PowerPCInlineAsmRegClass::xer + | PowerPCInlineAsmRegClass::spe_acc, ) => { unreachable!("clobber-only") } From 4122a226c8550f5e60eb3194e7afa1cf059c24e1 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Wed, 3 Dec 2025 22:58:55 +0100 Subject: [PATCH 081/489] Do not look for disallowed methods inside desugared code --- clippy_lints/src/disallowed_methods.rs | 3 +++ .../ui-toml/toml_disallowed_methods/clippy.toml | 2 ++ .../conf_disallowed_methods.rs | 16 ++++++++++++++++ .../conf_disallowed_methods.stderr | 8 +++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/disallowed_methods.rs b/clippy_lints/src/disallowed_methods.rs index 8c067432cb4e..58403ad19235 100644 --- a/clippy_lints/src/disallowed_methods.rs +++ b/clippy_lints/src/disallowed_methods.rs @@ -88,6 +88,9 @@ impl_lint_pass!(DisallowedMethods => [DISALLOWED_METHODS]); impl<'tcx> LateLintPass<'tcx> for DisallowedMethods { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { + if expr.span.desugaring_kind().is_some() { + return; + } let (id, span) = match &expr.kind { ExprKind::Path(path) if let Res::Def(_, id) = cx.qpath_res(path, expr.hir_id) => (id, expr.span), ExprKind::MethodCall(name, ..) if let Some(id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) => { diff --git a/tests/ui-toml/toml_disallowed_methods/clippy.toml b/tests/ui-toml/toml_disallowed_methods/clippy.toml index c7a326f28295..2c54b73d72d7 100644 --- a/tests/ui-toml/toml_disallowed_methods/clippy.toml +++ b/tests/ui-toml/toml_disallowed_methods/clippy.toml @@ -17,4 +17,6 @@ disallowed-methods = [ # re-exports "conf_disallowed_methods::identity", "conf_disallowed_methods::renamed", + # also used in desugaring + "std::future::Future::poll", ] diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs index 2dac01649a0f..621317246d6d 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs @@ -80,3 +80,19 @@ fn main() { renamed(1); //~^ disallowed_methods } + +mod issue16185 { + use std::pin::Pin; + use std::task::Context; + + async fn test(f: impl Future) { + // Should not lint even though desugaring uses + // disallowed method `std::future::Future::poll()`. + f.await + } + + fn explicit>(f: Pin<&mut F>, cx: &mut Context<'_>) { + f.poll(cx); + //~^ disallowed_methods + } +} diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr index 20474ad6e927..8e7e112a93f3 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr @@ -99,5 +99,11 @@ error: use of a disallowed method `conf_disallowed_methods::renamed` LL | renamed(1); | ^^^^^^^ -error: aborting due to 16 previous errors +error: use of a disallowed method `std::future::Future::poll` + --> tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs:95:11 + | +LL | f.poll(cx); + | ^^^^ + +error: aborting due to 17 previous errors From 69553f73871b1e4b358337bd109174163ecd05be Mon Sep 17 00:00:00 2001 From: reucru01 Date: Thu, 4 Dec 2025 12:18:28 +0000 Subject: [PATCH 082/489] Removes excess x86_64 test runs --- library/stdarch/ci/run.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index f40a305117b8..58d9a60e34f2 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -95,15 +95,6 @@ fi # Test targets compiled with extra features. case ${TARGET} in - x86_64-unknown-linux-gnu) - export STDARCH_DISABLE_ASSERT_INSTR=1 - - export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx" - cargo_test - - export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx512f" - cargo_test - ;; x86_64* | i686*) export STDARCH_DISABLE_ASSERT_INSTR=1 From 701b9ba0fbaa79bb359a6e4e0377e671b2ffba92 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Dec 2025 14:53:08 +0100 Subject: [PATCH 083/489] Merge commit 'dab6863ce82346cf56c88b6f90a146200358207f' into subtree-update_cg_gcc_2025-12-04 --- CONTRIBUTING.md | 37 ++++ Cargo.lock | 4 +- build_system/src/build.rs | 12 +- build_system/src/config.rs | 7 +- build_system/src/test.rs | 6 - src/int.rs | 48 +---- src/intrinsic/mod.rs | 382 ++++++++++++++++-------------------- src/lib.rs | 20 +- tests/lang_tests_common.rs | 14 +- tests/run/int_intrinsics.rs | 72 +++++++ 10 files changed, 324 insertions(+), 278 deletions(-) create mode 100644 tests/run/int_intrinsics.rs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 54cba0e6de37..8f81ecca445a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,6 +25,43 @@ We encourage new contributors to join our communication channels and introduce t ## Understanding Core Concepts +### Sysroot & compilation flags + +#### What *is* the sysroot? +The **sysroot** is the directory that stores the compiled standard +library (`core`, `alloc`, `std`, `test`, …) and compiler built-ins. +Rustup ships these libraries **pre-compiled with LLVM**. + +**rustc_codegen_gcc** replaces LLVM with the GCC backend. + +The freshly compiled sysroot ends up in +`build/build_sysroot/...`. + +A rebuild of sysroot is needed when + +* the backend changes in a way that affects code generation, or +* the user switches toolchains / updates submodules. + +Both backend and sysroot can be built using different [profiles](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles). +That is exactly what the `--sysroot`, `--release-sysroot` and `--release` flag supported by the build system script `y.sh` take care of. + + +#### Typical flag combinations + +| Command | Backend Profile | Sysroot Profile | Usage Scenario | +|--------------------------------------------|-------------------------------|----------------------------------|------------------------------------------------------------| +| `./y.sh build` |  dev* |  n/a |  Build backend in dev mode with optimized dependencies without rebuilding sysroot | +| `./y.sh build --release` |  release (optimized) |  n/a |  Build backend in release mode with optimized dependencies without rebuilding sysroot | +| `./y.sh build --release --sysroot` |  release (optimized) |  dev |  Build backend in release mode with optimized dependencies and sysroot in dev mode (unoptimized) | +| `./y.sh build --sysroot` |  dev* |  dev |  Build backend in dev mode with optimized dependencies and sysroot in dev mode (unoptimized) | +| `./y.sh build --release-sysroot --sysroot`|  dev* |  release (optimized) |  Build backend in dev mode and sysroot in release mode, both with optimized dependencies | + +\* In `dev` mode, dependencies are compiled with optimizations, while the code of the backend itself is not. + + +Note: `--release-sysroot` must be used together with `--sysroot`. + + ### Common Development Tasks #### Running Specific Tests diff --git a/Cargo.lock b/Cargo.lock index 00bdacaca676..dea1207b05da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "gccjit_sys" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "263da4f60b7bb5d6a5b21efda961741051ebdbf0e380a09118b03cce66a8c77e" +checksum = "4f81d901767ddba371a619fa9bba657066a4d3c5607ee69bbb557c1c5ba9bf85" dependencies = [ "libc", ] diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 56503b239a3b..27476465d740 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -46,8 +46,16 @@ impl BuildArg { println!( r#" `build` command help: - - --sysroot : Build with sysroot"# + --sysroot : When used on its own, build backend in dev mode with optimized dependencies + and sysroot in dev mode (unoptimized) + When used together with --release, build backend in release mode with optimized dependencies + When used together with --release-sysroot, + build the sysroot in release mode with optimized dependencies instead of in dev mode + --release-sysroot : When combined with --sysroot, additionally + build the sysroot in release mode with optimized dependencies. + It has no effect if `--sysroot` is not specified. + It should not be used on its own. + --sysroot-panic-abort : Build the sysroot without unwinding support"# ); ConfigInfo::show_usage(); println!(" --help : Show this help"); diff --git a/build_system/src/config.rs b/build_system/src/config.rs index 19255e1ba2b2..8eb6d8f019e1 100644 --- a/build_system/src/config.rs +++ b/build_system/src/config.rs @@ -459,14 +459,11 @@ impl ConfigInfo { pub fn show_usage() { println!( - "\ - --features [arg] : Add a new feature [arg] + " --features [arg] : Add a new feature [arg] --target-triple [arg] : Set the target triple to [arg] --target [arg] : Set the target to [arg] + --release : Build backend in release mode with optimized dependencies --out-dir : Location where the files will be generated - --release : Build in release mode - --release-sysroot : Build sysroot in release mode - --sysroot-panic-abort : Build the sysroot without unwinding support --config-file : Location of the config file to be used --gcc-path : Location of the GCC root folder --cg_gcc-path : Location of the rustc_codegen_gcc root folder (used diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 8aabfa894ce0..ca2a2a7dc2de 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -64,8 +64,6 @@ fn show_usage() { r#" `test` command help: - --release : Build codegen in release mode - --sysroot-panic-abort : Build the sysroot without unwinding support. --features [arg] : Add a new feature [arg] --use-system-gcc : Use system installed libgccjit --build-only : Only build rustc_codegen_gcc then exits @@ -92,7 +90,6 @@ struct TestArg { test_args: Vec, nb_parts: Option, current_part: Option, - sysroot_panic_abort: bool, config_info: ConfigInfo, sysroot_features: Vec, keep_lto_tests: bool, @@ -128,9 +125,6 @@ impl TestArg { test_arg.current_part = Some(get_number_after_arg(&mut args, "--current-part")?); } - "--sysroot-panic-abort" => { - test_arg.sysroot_panic_abort = true; - } "--keep-lto-tests" => { test_arg.keep_lto_tests = true; } diff --git a/src/int.rs b/src/int.rs index aa1d3b6b091c..49de0b490e88 100644 --- a/src/int.rs +++ b/src/int.rs @@ -287,51 +287,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { // TODO(antoyo): remove duplication with intrinsic? let name = if self.is_native_int_type(lhs.get_type()) { match oop { - OverflowOp::Add => match new_kind { - Int(I8) => "__builtin_add_overflow", - Int(I16) => "__builtin_add_overflow", - Int(I32) => "__builtin_sadd_overflow", - Int(I64) => "__builtin_saddll_overflow", - Int(I128) => "__builtin_add_overflow", - - Uint(U8) => "__builtin_add_overflow", - Uint(U16) => "__builtin_add_overflow", - Uint(U32) => "__builtin_uadd_overflow", - Uint(U64) => "__builtin_uaddll_overflow", - Uint(U128) => "__builtin_add_overflow", - - _ => unreachable!(), - }, - OverflowOp::Sub => match new_kind { - Int(I8) => "__builtin_sub_overflow", - Int(I16) => "__builtin_sub_overflow", - Int(I32) => "__builtin_ssub_overflow", - Int(I64) => "__builtin_ssubll_overflow", - Int(I128) => "__builtin_sub_overflow", - - Uint(U8) => "__builtin_sub_overflow", - Uint(U16) => "__builtin_sub_overflow", - Uint(U32) => "__builtin_usub_overflow", - Uint(U64) => "__builtin_usubll_overflow", - Uint(U128) => "__builtin_sub_overflow", - - _ => unreachable!(), - }, - OverflowOp::Mul => match new_kind { - Int(I8) => "__builtin_mul_overflow", - Int(I16) => "__builtin_mul_overflow", - Int(I32) => "__builtin_smul_overflow", - Int(I64) => "__builtin_smulll_overflow", - Int(I128) => "__builtin_mul_overflow", - - Uint(U8) => "__builtin_mul_overflow", - Uint(U16) => "__builtin_mul_overflow", - Uint(U32) => "__builtin_umul_overflow", - Uint(U64) => "__builtin_umulll_overflow", - Uint(U128) => "__builtin_mul_overflow", - - _ => unreachable!(), - }, + OverflowOp::Add => "__builtin_add_overflow", + OverflowOp::Sub => "__builtin_sub_overflow", + OverflowOp::Mul => "__builtin_mul_overflow", } } else { let (func_name, width) = match oop { diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index 8225df568641..23d16eda030c 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -441,43 +441,15 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc | sym::saturating_sub => { match int_type_width_signed(args[0].layout.ty, self) { Some((width, signed)) => match name { - sym::ctlz | sym::cttz => { - let func = self.current_func(); - let then_block = func.new_block("then"); - let else_block = func.new_block("else"); - let after_block = func.new_block("after"); + sym::ctlz => self.count_leading_zeroes(width, args[0].immediate()), - let arg = args[0].immediate(); - let result = func.new_local(None, self.u32_type, "zeros"); - let zero = self.cx.gcc_zero(arg.get_type()); - let cond = self.gcc_icmp(IntPredicate::IntEQ, arg, zero); - self.llbb().end_with_conditional(None, cond, then_block, else_block); - - let zero_result = self.cx.gcc_uint(self.u32_type, width); - then_block.add_assignment(None, result, zero_result); - then_block.end_with_jump(None, after_block); - - // NOTE: since jumps were added in a place - // count_leading_zeroes() does not expect, the current block - // in the state need to be updated. - self.switch_to_block(else_block); - - let zeros = match name { - sym::ctlz => self.count_leading_zeroes(width, arg), - sym::cttz => self.count_trailing_zeroes(width, arg), - _ => unreachable!(), - }; - self.llbb().add_assignment(None, result, zeros); - self.llbb().end_with_jump(None, after_block); - - // NOTE: since jumps were added in a place rustc does not - // expect, the current block in the state need to be updated. - self.switch_to_block(after_block); - - result.to_rvalue() + sym::ctlz_nonzero => { + self.count_leading_zeroes_nonzero(width, args[0].immediate()) + } + sym::cttz => self.count_trailing_zeroes(width, args[0].immediate()), + sym::cttz_nonzero => { + self.count_trailing_zeroes_nonzero(width, args[0].immediate()) } - sym::ctlz_nonzero => self.count_leading_zeroes(width, args[0].immediate()), - sym::cttz_nonzero => self.count_trailing_zeroes(width, args[0].immediate()), sym::ctpop => self.pop_count(args[0].immediate()), sym::bswap => { if width == 8 { @@ -912,179 +884,175 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { self.gcc_int_cast(result, result_type) } - fn count_leading_zeroes(&mut self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { - // TODO(antoyo): use width? - let arg_type = arg.get_type(); - let result_type = self.u32_type; - let arg = if arg_type.is_signed(self.cx) { - let new_type = arg_type.to_unsigned(self.cx); - self.gcc_int_cast(arg, new_type) + fn count_zeroes(&mut self, width: u64, arg: RValue<'gcc>, count_leading: bool) -> RValue<'gcc> { + // if arg is 0, early return 0, else call count_leading_zeroes_nonzero or count_trailing_zeroes_nonzero + let func = self.current_func(); + let then_block = func.new_block("then"); + let else_block = func.new_block("else"); + let after_block = func.new_block("after"); + + let result = func.new_local(None, self.u32_type, "zeros"); + let zero = self.cx.gcc_zero(arg.get_type()); + let cond = self.gcc_icmp(IntPredicate::IntEQ, arg, zero); + self.llbb().end_with_conditional(None, cond, then_block, else_block); + + let zero_result = self.cx.gcc_uint(self.u32_type, width); + then_block.add_assignment(None, result, zero_result); + then_block.end_with_jump(None, after_block); + + // NOTE: since jumps were added in a place count_xxxxing_zeroes_nonzero() does not expect, + // the current block in the state need to be updated. + self.switch_to_block(else_block); + + let zeros = if count_leading { + self.count_leading_zeroes_nonzero(width, arg) } else { - arg + self.count_trailing_zeroes_nonzero(width, arg) }; - let arg_type = arg.get_type(); - let count_leading_zeroes = - // TODO(antoyo): write a new function Type::is_compatible_with(&Type) and use it here - // instead of using is_uint(). - if arg_type.is_uchar(self.cx) || arg_type.is_ushort(self.cx) || arg_type.is_uint(self.cx) { - "__builtin_clz" - } - else if arg_type.is_ulong(self.cx) { - "__builtin_clzl" - } - else if arg_type.is_ulonglong(self.cx) { - "__builtin_clzll" - } - else if width == 128 { - // Algorithm from: https://stackoverflow.com/a/28433850/389119 - let array_type = self.context.new_array_type(None, arg_type, 3); - let result = self.current_func() - .new_local(None, array_type, "count_loading_zeroes_results"); + self.llbb().add_assignment(None, result, zeros); + self.llbb().end_with_jump(None, after_block); - let sixty_four = self.const_uint(arg_type, 64); - let shift = self.lshr(arg, sixty_four); - let high = self.gcc_int_cast(shift, self.u64_type); - let low = self.gcc_int_cast(arg, self.u64_type); + // NOTE: since jumps were added in a place rustc does not + // expect, the current block in the state need to be updated. + self.switch_to_block(after_block); - let zero = self.context.new_rvalue_zero(self.usize_type); - let one = self.context.new_rvalue_one(self.usize_type); - let two = self.context.new_rvalue_from_long(self.usize_type, 2); - - let clzll = self.context.get_builtin_function("__builtin_clzll"); - - let first_elem = self.context.new_array_access(None, result, zero); - let first_value = self.gcc_int_cast(self.context.new_call(None, clzll, &[high]), arg_type); - self.llbb() - .add_assignment(self.location, first_elem, first_value); - - let second_elem = self.context.new_array_access(self.location, result, one); - let cast = self.gcc_int_cast(self.context.new_call(self.location, clzll, &[low]), arg_type); - let second_value = self.add(cast, sixty_four); - self.llbb() - .add_assignment(self.location, second_elem, second_value); - - let third_elem = self.context.new_array_access(self.location, result, two); - let third_value = self.const_uint(arg_type, 128); - self.llbb() - .add_assignment(self.location, third_elem, third_value); - - let not_high = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, high); - let not_low = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, low); - let not_low_and_not_high = not_low & not_high; - let index = not_high + not_low_and_not_high; - // NOTE: the following cast is necessary to avoid a GIMPLE verification failure in - // gcc. - // TODO(antoyo): do the correct verification in libgccjit to avoid an error at the - // compilation stage. - let index = self.context.new_cast(self.location, index, self.i32_type); - - let res = self.context.new_array_access(self.location, result, index); - - return self.gcc_int_cast(res.to_rvalue(), result_type); - } - else { - let count_leading_zeroes = self.context.get_builtin_function("__builtin_clzll"); - let arg = self.context.new_cast(self.location, arg, self.ulonglong_type); - let diff = self.ulonglong_type.get_size() as i64 - arg_type.get_size() as i64; - let diff = self.context.new_rvalue_from_long(self.int_type, diff * 8); - let res = self.context.new_call(self.location, count_leading_zeroes, &[arg]) - diff; - return self.context.new_cast(self.location, res, result_type); - }; - let count_leading_zeroes = self.context.get_builtin_function(count_leading_zeroes); - let res = self.context.new_call(self.location, count_leading_zeroes, &[arg]); - self.context.new_cast(self.location, res, result_type) + result.to_rvalue() } - fn count_trailing_zeroes(&mut self, _width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { - let arg_type = arg.get_type(); - let result_type = self.u32_type; - let arg = if arg_type.is_signed(self.cx) { - let new_type = arg_type.to_unsigned(self.cx); - self.gcc_int_cast(arg, new_type) - } else { - arg - }; - let arg_type = arg.get_type(); - let (count_trailing_zeroes, expected_type) = - // TODO(antoyo): write a new function Type::is_compatible_with(&Type) and use it here - // instead of using is_uint(). - if arg_type.is_uchar(self.cx) || arg_type.is_ushort(self.cx) || arg_type.is_uint(self.cx) { - // NOTE: we don't need to & 0xFF for uchar because the result is undefined on zero. - ("__builtin_ctz", self.cx.uint_type) - } - else if arg_type.is_ulong(self.cx) { - ("__builtin_ctzl", self.cx.ulong_type) - } - else if arg_type.is_ulonglong(self.cx) { - ("__builtin_ctzll", self.cx.ulonglong_type) - } - else if arg_type.is_u128(self.cx) { - // Adapted from the algorithm to count leading zeroes from: https://stackoverflow.com/a/28433850/389119 - let array_type = self.context.new_array_type(None, arg_type, 3); - let result = self.current_func() - .new_local(None, array_type, "count_loading_zeroes_results"); - - let sixty_four = self.gcc_int(arg_type, 64); - let shift = self.gcc_lshr(arg, sixty_four); - let high = self.gcc_int_cast(shift, self.u64_type); - let low = self.gcc_int_cast(arg, self.u64_type); - - let zero = self.context.new_rvalue_zero(self.usize_type); - let one = self.context.new_rvalue_one(self.usize_type); - let two = self.context.new_rvalue_from_long(self.usize_type, 2); - - let ctzll = self.context.get_builtin_function("__builtin_ctzll"); - - let first_elem = self.context.new_array_access(self.location, result, zero); - let first_value = self.gcc_int_cast(self.context.new_call(self.location, ctzll, &[low]), arg_type); - self.llbb() - .add_assignment(self.location, first_elem, first_value); - - let second_elem = self.context.new_array_access(self.location, result, one); - let second_value = self.gcc_add(self.gcc_int_cast(self.context.new_call(self.location, ctzll, &[high]), arg_type), sixty_four); - self.llbb() - .add_assignment(self.location, second_elem, second_value); - - let third_elem = self.context.new_array_access(self.location, result, two); - let third_value = self.gcc_int(arg_type, 128); - self.llbb() - .add_assignment(self.location, third_elem, third_value); - - let not_low = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, low); - let not_high = self.context.new_unary_op(self.location, UnaryOp::LogicalNegate, self.u64_type, high); - let not_low_and_not_high = not_low & not_high; - let index = not_low + not_low_and_not_high; - // NOTE: the following cast is necessary to avoid a GIMPLE verification failure in - // gcc. - // TODO(antoyo): do the correct verification in libgccjit to avoid an error at the - // compilation stage. - let index = self.context.new_cast(self.location, index, self.i32_type); - - let res = self.context.new_array_access(self.location, result, index); - - return self.gcc_int_cast(res.to_rvalue(), result_type); - } - else { - let count_trailing_zeroes = self.context.get_builtin_function("__builtin_ctzll"); - let arg_size = arg_type.get_size(); - let casted_arg = self.context.new_cast(self.location, arg, self.ulonglong_type); - let byte_diff = self.ulonglong_type.get_size() as i64 - arg_size as i64; - let diff = self.context.new_rvalue_from_long(self.int_type, byte_diff * 8); - let mask = self.context.new_rvalue_from_long(arg_type, -1); // To get the value with all bits set. - let masked = mask & self.context.new_unary_op(self.location, UnaryOp::BitwiseNegate, arg_type, arg); - let cond = self.context.new_comparison(self.location, ComparisonOp::Equals, masked, mask); - let diff = diff * self.context.new_cast(self.location, cond, self.int_type); - let res = self.context.new_call(self.location, count_trailing_zeroes, &[casted_arg]) - diff; - return self.context.new_cast(self.location, res, result_type); + fn count_zeroes_nonzero( + &mut self, + width: u64, + arg: RValue<'gcc>, + count_leading: bool, + ) -> RValue<'gcc> { + // Pre-condition: arg is guaranteed to not be 0 by caller + fn use_builtin_function<'a, 'gcc, 'tcx>( + builder: &mut Builder<'a, 'gcc, 'tcx>, + builtin: &str, + arg: RValue<'gcc>, + arg_type: gccjit::Type<'gcc>, + expected_type: gccjit::Type<'gcc>, + ) -> RValue<'gcc> { + let arg = if arg_type != expected_type { + builder.context.new_cast(builder.location, arg, expected_type) + } else { + arg }; - let count_trailing_zeroes = self.context.get_builtin_function(count_trailing_zeroes); - let arg = if arg_type != expected_type { - self.context.new_cast(self.location, arg, expected_type) + let builtin = builder.context.get_builtin_function(builtin); + let res = builder.context.new_call(builder.location, builtin, &[arg]); + builder.context.new_cast(builder.location, res, builder.u32_type) + } + + // TODO(antoyo): use width? + let result_type = self.u32_type; + let mut arg_type = arg.get_type(); + let arg = if arg_type.is_signed(self.cx) { + arg_type = arg_type.to_unsigned(self.cx); + self.gcc_int_cast(arg, arg_type) } else { arg }; - let res = self.context.new_call(self.location, count_trailing_zeroes, &[arg]); - self.context.new_cast(self.location, res, result_type) + // TODO(antoyo): write a new function Type::is_compatible_with(&Type) and use it here + // instead of using is_uint(). + if arg_type.is_uchar(self.cx) || arg_type.is_ushort(self.cx) || arg_type.is_uint(self.cx) { + let builtin = if count_leading { "__builtin_clz" } else { "__builtin_ctz" }; + use_builtin_function(self, builtin, arg, arg_type, self.cx.uint_type) + } else if arg_type.is_ulong(self.cx) { + let builtin = if count_leading { "__builtin_clzl" } else { "__builtin_ctzl" }; + use_builtin_function(self, builtin, arg, arg_type, self.cx.uint_type) + } else if arg_type.is_ulonglong(self.cx) { + let builtin = if count_leading { "__builtin_clzll" } else { "__builtin_ctzll" }; + use_builtin_function(self, builtin, arg, arg_type, self.cx.uint_type) + } else if width == 128 { + // arg is guaranteed to not be 0, so either its 64 high or 64 low bits are not 0 + // __buildin_clzll is UB when called with 0, so call it on the 64 high bits if they are not 0, + // else call it on the 64 low bits and add 64. In the else case, 64 low bits can't be 0 + // because arg is not 0. + // __buildin_ctzll is UB when called with 0, so call it on the 64 low bits if they are not 0, + // else call it on the 64 high bits and add 64. In the else case, 64 high bits can't be 0 + // because arg is not 0. + + let result = self.current_func().new_local(None, result_type, "count_zeroes_results"); + + let cz_then_block = self.current_func().new_block("cz_then"); + let cz_else_block = self.current_func().new_block("cz_else"); + let cz_after_block = self.current_func().new_block("cz_after"); + + let low = self.gcc_int_cast(arg, self.u64_type); + let sixty_four = self.const_uint(arg_type, 64); + let shift = self.lshr(arg, sixty_four); + let high = self.gcc_int_cast(shift, self.u64_type); + + let (first, second, builtin) = if count_leading { + (low, high, self.context.get_builtin_function("__builtin_clzll")) + } else { + (high, low, self.context.get_builtin_function("__builtin_ctzll")) + }; + + let zero_64 = self.const_uint(self.u64_type, 0); + let cond = self.gcc_icmp(IntPredicate::IntNE, second, zero_64); + self.llbb().end_with_conditional(self.location, cond, cz_then_block, cz_else_block); + self.switch_to_block(cz_then_block); + + let result_128 = + self.gcc_int_cast(self.context.new_call(None, builtin, &[second]), result_type); + + cz_then_block.add_assignment(self.location, result, result_128); + cz_then_block.end_with_jump(self.location, cz_after_block); + + self.switch_to_block(cz_else_block); + let count_more_zeroes = + self.gcc_int_cast(self.context.new_call(None, builtin, &[first]), result_type); + let sixty_four_result_type = self.const_uint(result_type, 64); + let count_result_type = self.add(count_more_zeroes, sixty_four_result_type); + cz_else_block.add_assignment(self.location, result, count_result_type); + cz_else_block.end_with_jump(self.location, cz_after_block); + self.switch_to_block(cz_after_block); + result.to_rvalue() + } else { + let byte_diff = self.ulonglong_type.get_size() as i64 - arg_type.get_size() as i64; + let diff = self.context.new_rvalue_from_long(self.int_type, byte_diff * 8); + let ull_arg = self.context.new_cast(self.location, arg, self.ulonglong_type); + + let res = if count_leading { + let count_leading_zeroes = self.context.get_builtin_function("__builtin_clzll"); + self.context.new_call(self.location, count_leading_zeroes, &[ull_arg]) - diff + } else { + let count_trailing_zeroes = self.context.get_builtin_function("__builtin_ctzll"); + let mask = self.context.new_rvalue_from_long(arg_type, -1); // To get the value with all bits set. + let masked = mask + & self.context.new_unary_op( + self.location, + UnaryOp::BitwiseNegate, + arg_type, + arg, + ); + let cond = + self.context.new_comparison(self.location, ComparisonOp::Equals, masked, mask); + let diff = diff * self.context.new_cast(self.location, cond, self.int_type); + + self.context.new_call(self.location, count_trailing_zeroes, &[ull_arg]) - diff + }; + self.context.new_cast(self.location, res, result_type) + } + } + + fn count_leading_zeroes(&mut self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { + self.count_zeroes(width, arg, true) + } + + fn count_leading_zeroes_nonzero(&mut self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { + // Pre-condition: arg is guaranteed to not be 0 by caller, else count_leading_zeros should be used + self.count_zeroes_nonzero(width, arg, true) + } + + fn count_trailing_zeroes(&mut self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { + self.count_zeroes(width, arg, false) + } + + fn count_trailing_zeroes_nonzero(&mut self, width: u64, arg: RValue<'gcc>) -> RValue<'gcc> { + // Pre-condition: arg is guaranteed to not be 0 by caller, else count_trailing_zeros should be used + self.count_zeroes_nonzero(width, arg, false) } fn pop_count(&mut self, value: RValue<'gcc>) -> RValue<'gcc> { @@ -1196,14 +1164,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let res = func.new_local(self.location, result_type, "saturating_sum"); let supports_native_type = self.is_native_int_type(result_type); let overflow = if supports_native_type { - let func_name = match width { - 8 => "__builtin_add_overflow", - 16 => "__builtin_add_overflow", - 32 => "__builtin_sadd_overflow", - 64 => "__builtin_saddll_overflow", - 128 => "__builtin_add_overflow", - _ => unreachable!(), - }; + let func_name = "__builtin_add_overflow"; let overflow_func = self.context.get_builtin_function(func_name); self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(self.location)], None) } else { @@ -1267,14 +1228,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let res = func.new_local(self.location, result_type, "saturating_diff"); let supports_native_type = self.is_native_int_type(result_type); let overflow = if supports_native_type { - let func_name = match width { - 8 => "__builtin_sub_overflow", - 16 => "__builtin_sub_overflow", - 32 => "__builtin_ssub_overflow", - 64 => "__builtin_ssubll_overflow", - 128 => "__builtin_sub_overflow", - _ => unreachable!(), - }; + let func_name = "__builtin_sub_overflow"; let overflow_func = self.context.get_builtin_function(func_name); self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(self.location)], None) } else { diff --git a/src/lib.rs b/src/lib.rs index 662e303f94f2..c1506ee6176f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,6 +71,7 @@ mod type_of; use std::any::Any; use std::ffi::CString; use std::fmt::Debug; +use std::fs; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; @@ -180,14 +181,18 @@ pub struct GccCodegenBackend { static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); +fn libgccjit_path(sysroot_path: &Path) -> PathBuf { + let sysroot_lib_dir = sysroot_path.join("lib"); + sysroot_lib_dir.join("libgccjit.so") +} + fn load_libgccjit_if_needed(sysroot_path: &Path) { if gccjit::is_loaded() { // Do not load a libgccjit second time. return; } - let sysroot_lib_dir = sysroot_path.join("lib"); - let libgccjit_target_lib_file = sysroot_lib_dir.join("libgccjit.so"); + let libgccjit_target_lib_file = libgccjit_path(sysroot_path); let path = libgccjit_target_lib_file.to_str().expect("libgccjit path"); let string = CString::new(path).expect("string to libgccjit path"); @@ -207,7 +212,16 @@ impl CodegenBackend for GccCodegenBackend { } fn init(&self, sess: &Session) { - load_libgccjit_if_needed(sess.opts.sysroot.path()); + // We use all_paths() instead of only path() in case the path specified by --sysroot is + // invalid. + // This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null. + for path in sess.opts.sysroot.all_paths() { + let libgccjit_target_lib_file = libgccjit_path(path); + if let Ok(true) = fs::exists(libgccjit_target_lib_file) { + load_libgccjit_if_needed(path); + break; + } + } #[cfg(feature = "master")] { diff --git a/tests/lang_tests_common.rs b/tests/lang_tests_common.rs index 311f256b7600..0f2cb9231062 100644 --- a/tests/lang_tests_common.rs +++ b/tests/lang_tests_common.rs @@ -91,7 +91,19 @@ pub fn main_inner(profile: Profile) { } } match profile { - Profile::Debug => {} + Profile::Debug => { + if test_target.is_ok() { + // m68k doesn't have lubsan for now + compiler.args(["-C", "llvm-args=sanitize-undefined"]); + } else { + compiler.args([ + "-C", + "llvm-args=sanitize-undefined", + "-C", + "link-args=-lubsan", + ]); + } + } Profile::Release => { compiler.args(["-C", "opt-level=3", "-C", "lto=no"]); } diff --git a/tests/run/int_intrinsics.rs b/tests/run/int_intrinsics.rs new file mode 100644 index 000000000000..c3d363c8428b --- /dev/null +++ b/tests/run/int_intrinsics.rs @@ -0,0 +1,72 @@ +// Compiler: +// +// Run-time: +#![feature(core_intrinsics, intrinsics)] +#![no_main] + +use std::intrinsics::black_box; + +#[rustc_intrinsic] +pub const fn ctlz(_x: T) -> u32; + +#[rustc_intrinsic] +pub const fn cttz(_x: T) -> u32; + +#[no_mangle] +extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 { + macro_rules! check { + ($func_name:ident, $input:expr, $expected:expr, $res_ident:ident) => {{ + $res_ident += 1; + if $func_name(black_box($input)) != $expected { + return $res_ident; + } + }}; + } + let mut res = 0; + check!(ctlz, 0_u128, 128_u32, res); + check!(ctlz, 1_u128, 127_u32, res); + check!(ctlz, 0x4000_0000_0000_0000_0000_0000_0000_0000_u128, 1_u32, res); + check!(ctlz, 0x8000_0000_0000_0000_0000_0000_0000_0000_u128, 0_u32, res); + check!(cttz, 0_u128, 128_u32, res); + check!(cttz, 1_u128, 0_u32, res); + check!(cttz, 2_u128, 1_u32, res); + check!(cttz, 0x8000_0000_0000_0000_0000_0000_0000_0000_u128, 127_u32, res); + + check!(ctlz, 0_u64, 64_u32, res); + check!(ctlz, 1_u64, 63_u32, res); + check!(ctlz, 0x4000_0000_0000_0000_u64, 1_u32, res); + check!(ctlz, 0x8000_0000_0000_0000_u64, 0_u32, res); + check!(cttz, 0_u64, 64_u32, res); + check!(cttz, 1_u64, 0_u32, res); + check!(cttz, 2_u64, 1_u32, res); + check!(cttz, 0x8000_0000_0000_0000_u64, 63_u32, res); + + check!(ctlz, 0_u32, 32_u32, res); + check!(ctlz, 1_u32, 31_u32, res); + check!(ctlz, 0x4000_0000_u32, 1_u32, res); + check!(ctlz, 0x8000_0000_u32, 0_u32, res); + check!(cttz, 0_u32, 32_u32, res); + check!(cttz, 1_u32, 0_u32, res); + check!(cttz, 2_u32, 1_u32, res); + check!(cttz, 0x8000_0000_u32, 31_u32, res); + + check!(ctlz, 0_u16, 16_u32, res); + check!(ctlz, 1_u16, 15_u32, res); + check!(ctlz, 0x4000_u16, 1_u32, res); + check!(ctlz, 0x8000_u16, 0_u32, res); + check!(cttz, 0_u16, 16_u32, res); + check!(cttz, 1_u16, 0_u32, res); + check!(cttz, 2_u16, 1_u32, res); + check!(cttz, 0x8000_u16, 15_u32, res); + + check!(ctlz, 0_u8, 8_u32, res); + check!(ctlz, 1_u8, 7_u32, res); + check!(ctlz, 0x40_u8, 1_u32, res); + check!(ctlz, 0x80_u8, 0_u32, res); + check!(cttz, 0_u8, 8_u32, res); + check!(cttz, 1_u8, 0_u32, res); + check!(cttz, 2_u8, 1_u32, res); + check!(cttz, 0x80_u8, 7_u32, res); + + 0 +} From 897099e693c52c90baa7f3c5897668b0577f69de Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Dec 2025 17:53:01 +0100 Subject: [PATCH 084/489] Regenerate intrinsics --- src/intrinsic/archs.rs | 123 +++++++++++++++++++++++++++++++++-------- 1 file changed, 99 insertions(+), 24 deletions(-) diff --git a/src/intrinsic/archs.rs b/src/intrinsic/archs.rs index bb8bcbf66f38..43e7c352c34a 100644 --- a/src/intrinsic/archs.rs +++ b/src/intrinsic/archs.rs @@ -70,10 +70,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "sve.sm4e" => "__builtin_sve_svsm4e_u32", "sve.sm4ekey" => "__builtin_sve_svsm4ekey_u32", "sve.wrffr" => "__builtin_sve_svwrffr", - "tcancel" => "__builtin_arm_tcancel", - "tcommit" => "__builtin_arm_tcommit", - "tstart" => "__builtin_arm_tstart", - "ttest" => "__builtin_arm_ttest", _ => unimplemented!("***** unsupported LLVM intrinsic {full_name}"), } } @@ -1632,6 +1628,14 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vabs.f8.128B" => "__builtin_HEXAGON_V6_vabs_f8_128B", "V6.vabs.hf" => "__builtin_HEXAGON_V6_vabs_hf", "V6.vabs.hf.128B" => "__builtin_HEXAGON_V6_vabs_hf_128B", + "V6.vabs.qf16.hf" => "__builtin_HEXAGON_V6_vabs_qf16_hf", + "V6.vabs.qf16.hf.128B" => "__builtin_HEXAGON_V6_vabs_qf16_hf_128B", + "V6.vabs.qf16.qf16" => "__builtin_HEXAGON_V6_vabs_qf16_qf16", + "V6.vabs.qf16.qf16.128B" => "__builtin_HEXAGON_V6_vabs_qf16_qf16_128B", + "V6.vabs.qf32.qf32" => "__builtin_HEXAGON_V6_vabs_qf32_qf32", + "V6.vabs.qf32.qf32.128B" => "__builtin_HEXAGON_V6_vabs_qf32_qf32_128B", + "V6.vabs.qf32.sf" => "__builtin_HEXAGON_V6_vabs_qf32_sf", + "V6.vabs.qf32.sf.128B" => "__builtin_HEXAGON_V6_vabs_qf32_sf_128B", "V6.vabs.sf" => "__builtin_HEXAGON_V6_vabs_sf", "V6.vabs.sf.128B" => "__builtin_HEXAGON_V6_vabs_sf_128B", "V6.vabsb" => "__builtin_HEXAGON_V6_vabsb", @@ -1744,6 +1748,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vaddwsat.128B" => "__builtin_HEXAGON_V6_vaddwsat_128B", "V6.vaddwsat.dv" => "__builtin_HEXAGON_V6_vaddwsat_dv", "V6.vaddwsat.dv.128B" => "__builtin_HEXAGON_V6_vaddwsat_dv_128B", + "V6.valign4" => "__builtin_HEXAGON_V6_valign4", + "V6.valign4.128B" => "__builtin_HEXAGON_V6_valign4_128B", "V6.valignb" => "__builtin_HEXAGON_V6_valignb", "V6.valignb.128B" => "__builtin_HEXAGON_V6_valignb_128B", "V6.valignbi" => "__builtin_HEXAGON_V6_valignbi", @@ -1862,14 +1868,30 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vcl0w.128B" => "__builtin_HEXAGON_V6_vcl0w_128B", "V6.vcombine" => "__builtin_HEXAGON_V6_vcombine", "V6.vcombine.128B" => "__builtin_HEXAGON_V6_vcombine_128B", + "V6.vconv.bf.qf32" => "__builtin_HEXAGON_V6_vconv_bf_qf32", + "V6.vconv.bf.qf32.128B" => "__builtin_HEXAGON_V6_vconv_bf_qf32_128B", + "V6.vconv.f8.qf16" => "__builtin_HEXAGON_V6_vconv_f8_qf16", + "V6.vconv.f8.qf16.128B" => "__builtin_HEXAGON_V6_vconv_f8_qf16_128B", "V6.vconv.h.hf" => "__builtin_HEXAGON_V6_vconv_h_hf", "V6.vconv.h.hf.128B" => "__builtin_HEXAGON_V6_vconv_h_hf_128B", + "V6.vconv.h.hf.rnd" => "__builtin_HEXAGON_V6_vconv_h_hf_rnd", + "V6.vconv.h.hf.rnd.128B" => "__builtin_HEXAGON_V6_vconv_h_hf_rnd_128B", "V6.vconv.hf.h" => "__builtin_HEXAGON_V6_vconv_hf_h", "V6.vconv.hf.h.128B" => "__builtin_HEXAGON_V6_vconv_hf_h_128B", "V6.vconv.hf.qf16" => "__builtin_HEXAGON_V6_vconv_hf_qf16", "V6.vconv.hf.qf16.128B" => "__builtin_HEXAGON_V6_vconv_hf_qf16_128B", "V6.vconv.hf.qf32" => "__builtin_HEXAGON_V6_vconv_hf_qf32", "V6.vconv.hf.qf32.128B" => "__builtin_HEXAGON_V6_vconv_hf_qf32_128B", + "V6.vconv.qf16.f8" => "__builtin_HEXAGON_V6_vconv_qf16_f8", + "V6.vconv.qf16.f8.128B" => "__builtin_HEXAGON_V6_vconv_qf16_f8_128B", + "V6.vconv.qf16.hf" => "__builtin_HEXAGON_V6_vconv_qf16_hf", + "V6.vconv.qf16.hf.128B" => "__builtin_HEXAGON_V6_vconv_qf16_hf_128B", + "V6.vconv.qf16.qf16" => "__builtin_HEXAGON_V6_vconv_qf16_qf16", + "V6.vconv.qf16.qf16.128B" => "__builtin_HEXAGON_V6_vconv_qf16_qf16_128B", + "V6.vconv.qf32.qf32" => "__builtin_HEXAGON_V6_vconv_qf32_qf32", + "V6.vconv.qf32.qf32.128B" => "__builtin_HEXAGON_V6_vconv_qf32_qf32_128B", + "V6.vconv.qf32.sf" => "__builtin_HEXAGON_V6_vconv_qf32_sf", + "V6.vconv.qf32.sf.128B" => "__builtin_HEXAGON_V6_vconv_qf32_sf_128B", "V6.vconv.sf.qf32" => "__builtin_HEXAGON_V6_vconv_sf_qf32", "V6.vconv.sf.qf32.128B" => "__builtin_HEXAGON_V6_vconv_sf_qf32_128B", "V6.vconv.sf.w" => "__builtin_HEXAGON_V6_vconv_sf_w", @@ -1984,6 +2006,22 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.veqh.or.128B" => "__builtin_HEXAGON_V6_veqh_or_128B", "V6.veqh.xor" => "__builtin_HEXAGON_V6_veqh_xor", "V6.veqh.xor.128B" => "__builtin_HEXAGON_V6_veqh_xor_128B", + "V6.veqhf" => "__builtin_HEXAGON_V6_veqhf", + "V6.veqhf.128B" => "__builtin_HEXAGON_V6_veqhf_128B", + "V6.veqhf.and" => "__builtin_HEXAGON_V6_veqhf_and", + "V6.veqhf.and.128B" => "__builtin_HEXAGON_V6_veqhf_and_128B", + "V6.veqhf.or" => "__builtin_HEXAGON_V6_veqhf_or", + "V6.veqhf.or.128B" => "__builtin_HEXAGON_V6_veqhf_or_128B", + "V6.veqhf.xor" => "__builtin_HEXAGON_V6_veqhf_xor", + "V6.veqhf.xor.128B" => "__builtin_HEXAGON_V6_veqhf_xor_128B", + "V6.veqsf" => "__builtin_HEXAGON_V6_veqsf", + "V6.veqsf.128B" => "__builtin_HEXAGON_V6_veqsf_128B", + "V6.veqsf.and" => "__builtin_HEXAGON_V6_veqsf_and", + "V6.veqsf.and.128B" => "__builtin_HEXAGON_V6_veqsf_and_128B", + "V6.veqsf.or" => "__builtin_HEXAGON_V6_veqsf_or", + "V6.veqsf.or.128B" => "__builtin_HEXAGON_V6_veqsf_or_128B", + "V6.veqsf.xor" => "__builtin_HEXAGON_V6_veqsf_xor", + "V6.veqsf.xor.128B" => "__builtin_HEXAGON_V6_veqsf_xor_128B", "V6.veqw" => "__builtin_HEXAGON_V6_veqw", "V6.veqw.128B" => "__builtin_HEXAGON_V6_veqw_128B", "V6.veqw.and" => "__builtin_HEXAGON_V6_veqw_and", @@ -2096,6 +2134,14 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vgtw.or.128B" => "__builtin_HEXAGON_V6_vgtw_or_128B", "V6.vgtw.xor" => "__builtin_HEXAGON_V6_vgtw_xor", "V6.vgtw.xor.128B" => "__builtin_HEXAGON_V6_vgtw_xor_128B", + "V6.vilog2.hf" => "__builtin_HEXAGON_V6_vilog2_hf", + "V6.vilog2.hf.128B" => "__builtin_HEXAGON_V6_vilog2_hf_128B", + "V6.vilog2.qf16" => "__builtin_HEXAGON_V6_vilog2_qf16", + "V6.vilog2.qf16.128B" => "__builtin_HEXAGON_V6_vilog2_qf16_128B", + "V6.vilog2.qf32" => "__builtin_HEXAGON_V6_vilog2_qf32", + "V6.vilog2.qf32.128B" => "__builtin_HEXAGON_V6_vilog2_qf32_128B", + "V6.vilog2.sf" => "__builtin_HEXAGON_V6_vilog2_sf", + "V6.vilog2.sf.128B" => "__builtin_HEXAGON_V6_vilog2_sf_128B", "V6.vinsertwr" => "__builtin_HEXAGON_V6_vinsertwr", "V6.vinsertwr.128B" => "__builtin_HEXAGON_V6_vinsertwr_128B", "V6.vlalignb" => "__builtin_HEXAGON_V6_vlalignb", @@ -2350,6 +2396,14 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vnavgub.128B" => "__builtin_HEXAGON_V6_vnavgub_128B", "V6.vnavgw" => "__builtin_HEXAGON_V6_vnavgw", "V6.vnavgw.128B" => "__builtin_HEXAGON_V6_vnavgw_128B", + "V6.vneg.qf16.hf" => "__builtin_HEXAGON_V6_vneg_qf16_hf", + "V6.vneg.qf16.hf.128B" => "__builtin_HEXAGON_V6_vneg_qf16_hf_128B", + "V6.vneg.qf16.qf16" => "__builtin_HEXAGON_V6_vneg_qf16_qf16", + "V6.vneg.qf16.qf16.128B" => "__builtin_HEXAGON_V6_vneg_qf16_qf16_128B", + "V6.vneg.qf32.qf32" => "__builtin_HEXAGON_V6_vneg_qf32_qf32", + "V6.vneg.qf32.qf32.128B" => "__builtin_HEXAGON_V6_vneg_qf32_qf32_128B", + "V6.vneg.qf32.sf" => "__builtin_HEXAGON_V6_vneg_qf32_sf", + "V6.vneg.qf32.sf.128B" => "__builtin_HEXAGON_V6_vneg_qf32_sf_128B", "V6.vnormamth" => "__builtin_HEXAGON_V6_vnormamth", "V6.vnormamth.128B" => "__builtin_HEXAGON_V6_vnormamth_128B", "V6.vnormamtw" => "__builtin_HEXAGON_V6_vnormamtw", @@ -2684,6 +2738,24 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "iocsrwr.d" => "__builtin_loongarch_iocsrwr_d", "iocsrwr.h" => "__builtin_loongarch_iocsrwr_h", "iocsrwr.w" => "__builtin_loongarch_iocsrwr_w", + "lasx.cast.128" => "__builtin_lasx_cast_128", + "lasx.cast.128.d" => "__builtin_lasx_cast_128_d", + "lasx.cast.128.s" => "__builtin_lasx_cast_128_s", + "lasx.concat.128" => "__builtin_lasx_concat_128", + "lasx.concat.128.d" => "__builtin_lasx_concat_128_d", + "lasx.concat.128.s" => "__builtin_lasx_concat_128_s", + "lasx.extract.128.hi" => "__builtin_lasx_extract_128_hi", + "lasx.extract.128.hi.d" => "__builtin_lasx_extract_128_hi_d", + "lasx.extract.128.hi.s" => "__builtin_lasx_extract_128_hi_s", + "lasx.extract.128.lo" => "__builtin_lasx_extract_128_lo", + "lasx.extract.128.lo.d" => "__builtin_lasx_extract_128_lo_d", + "lasx.extract.128.lo.s" => "__builtin_lasx_extract_128_lo_s", + "lasx.insert.128.hi" => "__builtin_lasx_insert_128_hi", + "lasx.insert.128.hi.d" => "__builtin_lasx_insert_128_hi_d", + "lasx.insert.128.hi.s" => "__builtin_lasx_insert_128_hi_s", + "lasx.insert.128.lo" => "__builtin_lasx_insert_128_lo", + "lasx.insert.128.lo.d" => "__builtin_lasx_insert_128_lo_d", + "lasx.insert.128.lo.s" => "__builtin_lasx_insert_128_lo_s", "lasx.vext2xv.d.b" => "__builtin_lasx_vext2xv_d_b", "lasx.vext2xv.d.h" => "__builtin_lasx_vext2xv_d_h", "lasx.vext2xv.d.w" => "__builtin_lasx_vext2xv_d_w", @@ -4950,8 +5022,20 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "f16x2.to.e5m2x2.rn.relu" => "__nvvm_f16x2_to_e5m2x2_rn_relu", "f2bf16.rn" => "__nvvm_f2bf16_rn", "f2bf16.rn.relu" => "__nvvm_f2bf16_rn_relu", + "f2bf16.rn.relu.satfinite" => "__nvvm_f2bf16_rn_relu_satfinite", + "f2bf16.rn.satfinite" => "__nvvm_f2bf16_rn_satfinite", "f2bf16.rz" => "__nvvm_f2bf16_rz", "f2bf16.rz.relu" => "__nvvm_f2bf16_rz_relu", + "f2bf16.rz.relu.satfinite" => "__nvvm_f2bf16_rz_relu_satfinite", + "f2bf16.rz.satfinite" => "__nvvm_f2bf16_rz_satfinite", + "f2f16.rn" => "__nvvm_f2f16_rn", + "f2f16.rn.relu" => "__nvvm_f2f16_rn_relu", + "f2f16.rn.relu.satfinite" => "__nvvm_f2f16_rn_relu_satfinite", + "f2f16.rn.satfinite" => "__nvvm_f2f16_rn_satfinite", + "f2f16.rz" => "__nvvm_f2f16_rz", + "f2f16.rz.relu" => "__nvvm_f2f16_rz_relu", + "f2f16.rz.relu.satfinite" => "__nvvm_f2f16_rz_relu_satfinite", + "f2f16.rz.satfinite" => "__nvvm_f2f16_rz_satfinite", "f2h.rn" => "__nvvm_f2h_rn", "f2h.rn.ftz" => "__nvvm_f2h_rn_ftz", "f2i.rm" => "__nvvm_f2i_rm", @@ -5035,20 +5119,28 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "ff.to.ue8m0x2.rz.satfinite" => "__nvvm_ff_to_ue8m0x2_rz_satfinite", "ff2bf16x2.rn" => "__nvvm_ff2bf16x2_rn", "ff2bf16x2.rn.relu" => "__nvvm_ff2bf16x2_rn_relu", + "ff2bf16x2.rn.relu.satfinite" => "__nvvm_ff2bf16x2_rn_relu_satfinite", + "ff2bf16x2.rn.satfinite" => "__nvvm_ff2bf16x2_rn_satfinite", "ff2bf16x2.rs" => "__nvvm_ff2bf16x2_rs", "ff2bf16x2.rs.relu" => "__nvvm_ff2bf16x2_rs_relu", "ff2bf16x2.rs.relu.satfinite" => "__nvvm_ff2bf16x2_rs_relu_satfinite", "ff2bf16x2.rs.satfinite" => "__nvvm_ff2bf16x2_rs_satfinite", "ff2bf16x2.rz" => "__nvvm_ff2bf16x2_rz", "ff2bf16x2.rz.relu" => "__nvvm_ff2bf16x2_rz_relu", + "ff2bf16x2.rz.relu.satfinite" => "__nvvm_ff2bf16x2_rz_relu_satfinite", + "ff2bf16x2.rz.satfinite" => "__nvvm_ff2bf16x2_rz_satfinite", "ff2f16x2.rn" => "__nvvm_ff2f16x2_rn", "ff2f16x2.rn.relu" => "__nvvm_ff2f16x2_rn_relu", + "ff2f16x2.rn.relu.satfinite" => "__nvvm_ff2f16x2_rn_relu_satfinite", + "ff2f16x2.rn.satfinite" => "__nvvm_ff2f16x2_rn_satfinite", "ff2f16x2.rs" => "__nvvm_ff2f16x2_rs", "ff2f16x2.rs.relu" => "__nvvm_ff2f16x2_rs_relu", "ff2f16x2.rs.relu.satfinite" => "__nvvm_ff2f16x2_rs_relu_satfinite", "ff2f16x2.rs.satfinite" => "__nvvm_ff2f16x2_rs_satfinite", "ff2f16x2.rz" => "__nvvm_ff2f16x2_rz", "ff2f16x2.rz.relu" => "__nvvm_ff2f16x2_rz_relu", + "ff2f16x2.rz.relu.satfinite" => "__nvvm_ff2f16x2_rz_relu_satfinite", + "ff2f16x2.rz.satfinite" => "__nvvm_ff2f16x2_rz_satfinite", "floor.d" => "__nvvm_floor_d", "floor.f" => "__nvvm_floor_f", "floor.ftz.f" => "__nvvm_floor_ftz_f", @@ -5942,6 +6034,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "altivec.vupklsb" => "__builtin_altivec_vupklsb", "altivec.vupklsh" => "__builtin_altivec_vupklsh", "altivec.vupklsw" => "__builtin_altivec_vupklsw", + "amo.ldat" => "__builtin_amo_ldat", + "amo.lwat" => "__builtin_amo_lwat", "bcdadd" => "__builtin_ppc_bcdadd", "bcdadd.p" => "__builtin_ppc_bcdadd_p", "bcdcopysign" => "__builtin_ppc_bcdcopysign", @@ -6202,6 +6296,7 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "vsx.xvminsp" => "__builtin_vsx_xvminsp", "vsx.xvredp" => "__builtin_vsx_xvredp", "vsx.xvresp" => "__builtin_vsx_xvresp", + "vsx.xvrlw" => "__builtin_vsx_xvrlw", "vsx.xvrsqrtedp" => "__builtin_vsx_xvrsqrtedp", "vsx.xvrsqrtesp" => "__builtin_vsx_xvrsqrtesp", "vsx.xvtdivdp" => "__builtin_vsx_xvtdivdp", @@ -10158,24 +10253,16 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "stui" => "__builtin_ia32_stui", "subborrow.u32" => "__builtin_ia32_subborrow_u32", "subborrow.u64" => "__builtin_ia32_subborrow_u64", - "t2rpntlvwz0" => "__builtin_ia32_t2rpntlvwz0", "t2rpntlvwz0rs" => "__builtin_ia32_t2rpntlvwz0rs", "t2rpntlvwz0rst1" => "__builtin_ia32_t2rpntlvwz0rst1", - "t2rpntlvwz0t1" => "__builtin_ia32_t2rpntlvwz0t1", - "t2rpntlvwz1" => "__builtin_ia32_t2rpntlvwz1", "t2rpntlvwz1rs" => "__builtin_ia32_t2rpntlvwz1rs", "t2rpntlvwz1rst1" => "__builtin_ia32_t2rpntlvwz1rst1", - "t2rpntlvwz1t1" => "__builtin_ia32_t2rpntlvwz1t1", "tbm.bextri.u32" => "__builtin_ia32_bextri_u32", "tbm.bextri.u64" => "__builtin_ia32_bextri_u64", "tcmmimfp16ps" => "__builtin_ia32_tcmmimfp16ps", "tcmmimfp16ps.internal" => "__builtin_ia32_tcmmimfp16ps_internal", "tcmmrlfp16ps" => "__builtin_ia32_tcmmrlfp16ps", "tcmmrlfp16ps.internal" => "__builtin_ia32_tcmmrlfp16ps_internal", - "tconjtcmmimfp16ps" => "__builtin_ia32_tconjtcmmimfp16ps", - "tconjtcmmimfp16ps.internal" => "__builtin_ia32_tconjtcmmimfp16ps_internal", - "tconjtfp16" => "__builtin_ia32_tconjtfp16", - "tconjtfp16.internal" => "__builtin_ia32_tconjtfp16_internal", "tcvtrowd2ps" => "__builtin_ia32_tcvtrowd2ps", "tcvtrowd2ps.internal" => "__builtin_ia32_tcvtrowd2ps_internal", "tcvtrowps2bf16h" => "__builtin_ia32_tcvtrowps2bf16h", @@ -10225,18 +10312,6 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "tmmultf32ps" => "__builtin_ia32_tmmultf32ps", "tmmultf32ps.internal" => "__builtin_ia32_tmmultf32ps_internal", "tpause" => "__builtin_ia32_tpause", - "ttcmmimfp16ps" => "__builtin_ia32_ttcmmimfp16ps", - "ttcmmimfp16ps.internal" => "__builtin_ia32_ttcmmimfp16ps_internal", - "ttcmmrlfp16ps" => "__builtin_ia32_ttcmmrlfp16ps", - "ttcmmrlfp16ps.internal" => "__builtin_ia32_ttcmmrlfp16ps_internal", - "ttdpbf16ps" => "__builtin_ia32_ttdpbf16ps", - "ttdpbf16ps.internal" => "__builtin_ia32_ttdpbf16ps_internal", - "ttdpfp16ps" => "__builtin_ia32_ttdpfp16ps", - "ttdpfp16ps.internal" => "__builtin_ia32_ttdpfp16ps_internal", - "ttmmultf32ps" => "__builtin_ia32_ttmmultf32ps", - "ttmmultf32ps.internal" => "__builtin_ia32_ttmmultf32ps_internal", - "ttransposed" => "__builtin_ia32_ttransposed", - "ttransposed.internal" => "__builtin_ia32_ttransposed_internal", "umonitor" => "__builtin_ia32_umonitor", "umwait" => "__builtin_ia32_umwait", "urdmsr" => "__builtin_ia32_urdmsr", From c0d4f5fab1104ef8b96750352917e018d0d99e04 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 28 Nov 2025 14:16:56 -0500 Subject: [PATCH 085/489] Move the libgccjit.so file in a target directory Since GCC is not multi-target, we need multiple libgccjit.so. Our solution to have a directory per target so that we can have multiple libgccjit.so. --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c1506ee6176f..1bdc62f7f29c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,18 +181,18 @@ pub struct GccCodegenBackend { static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); -fn libgccjit_path(sysroot_path: &Path) -> PathBuf { +fn libgccjit_path(sysroot_path: &Path, target_triple: &str) -> PathBuf { let sysroot_lib_dir = sysroot_path.join("lib"); - sysroot_lib_dir.join("libgccjit.so") + sysroot_lib_dir.join(target_triple).join("libgccjit.so") } -fn load_libgccjit_if_needed(sysroot_path: &Path) { +fn load_libgccjit_if_needed(sysroot_path: &Path, target_triple: &str) { if gccjit::is_loaded() { // Do not load a libgccjit second time. return; } - let libgccjit_target_lib_file = libgccjit_path(sysroot_path); + let libgccjit_target_lib_file = libgccjit_path(sysroot_path, target_triple); let path = libgccjit_target_lib_file.to_str().expect("libgccjit path"); let string = CString::new(path).expect("string to libgccjit path"); @@ -216,9 +216,9 @@ impl CodegenBackend for GccCodegenBackend { // invalid. // This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null. for path in sess.opts.sysroot.all_paths() { - let libgccjit_target_lib_file = libgccjit_path(path); + let libgccjit_target_lib_file = libgccjit_path(path, &sess.target.llvm_target); if let Ok(true) = fs::exists(libgccjit_target_lib_file) { - load_libgccjit_if_needed(path); + load_libgccjit_if_needed(path, &sess.target.llvm_target); break; } } From 8e77eeb0178af56928d4b8b1d18e71ac82e1e76b Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 29 Nov 2025 11:09:23 -0500 Subject: [PATCH 086/489] Move to rustlib directory --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1bdc62f7f29c..c40ee39ba6e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,8 +182,9 @@ pub struct GccCodegenBackend { static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); fn libgccjit_path(sysroot_path: &Path, target_triple: &str) -> PathBuf { - let sysroot_lib_dir = sysroot_path.join("lib"); - sysroot_lib_dir.join(target_triple).join("libgccjit.so") + let sysroot_lib_dir = sysroot_path.join("lib").join("rustlib"); + let libgccjit_target_lib_file = + sysroot_lib_dir.join(target_triple).join("lib").join("libgccjit.so"); } fn load_libgccjit_if_needed(sysroot_path: &Path, target_triple: &str) { From b00418c0f5752f11aa2455abe927dd593957e3c7 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 29 Nov 2025 12:19:14 -0500 Subject: [PATCH 087/489] Fix lib path --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c40ee39ba6e4..6c072e7daca2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,7 @@ use rustc_middle::ty::TyCtxt; use rustc_middle::util::Providers; use rustc_session::Session; use rustc_session::config::{OptLevel, OutputFilenames}; +use rustc_session::filesearch::make_target_lib_path; use rustc_span::Symbol; use rustc_target::spec::{Arch, RelocModel}; use tempfile::TempDir; @@ -182,9 +183,7 @@ pub struct GccCodegenBackend { static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); fn libgccjit_path(sysroot_path: &Path, target_triple: &str) -> PathBuf { - let sysroot_lib_dir = sysroot_path.join("lib").join("rustlib"); - let libgccjit_target_lib_file = - sysroot_lib_dir.join(target_triple).join("lib").join("libgccjit.so"); + make_target_lib_path(sysroot_path, target_triple).join("libgccjit.so") } fn load_libgccjit_if_needed(sysroot_path: &Path, target_triple: &str) { From ff29461e1a03d52687f81da8d9ce44f5358d5f21 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 5 Dec 2025 09:58:37 -0500 Subject: [PATCH 088/489] Remove libgccjit_path function --- src/lib.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6c072e7daca2..a77239e23b4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,17 +182,12 @@ pub struct GccCodegenBackend { static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); -fn libgccjit_path(sysroot_path: &Path, target_triple: &str) -> PathBuf { - make_target_lib_path(sysroot_path, target_triple).join("libgccjit.so") -} - -fn load_libgccjit_if_needed(sysroot_path: &Path, target_triple: &str) { +fn load_libgccjit_if_needed(libgccjit_target_lib_file: &Path) { if gccjit::is_loaded() { // Do not load a libgccjit second time. return; } - let libgccjit_target_lib_file = libgccjit_path(sysroot_path, target_triple); let path = libgccjit_target_lib_file.to_str().expect("libgccjit path"); let string = CString::new(path).expect("string to libgccjit path"); @@ -216,9 +211,10 @@ impl CodegenBackend for GccCodegenBackend { // invalid. // This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null. for path in sess.opts.sysroot.all_paths() { - let libgccjit_target_lib_file = libgccjit_path(path, &sess.target.llvm_target); - if let Ok(true) = fs::exists(libgccjit_target_lib_file) { - load_libgccjit_if_needed(path, &sess.target.llvm_target); + let libgccjit_target_lib_file = + make_target_lib_path(path, &sess.target.llvm_target).join("libgccjit.so"); + if let Ok(true) = fs::exists(&libgccjit_target_lib_file) { + load_libgccjit_if_needed(&libgccjit_target_lib_file); break; } } From fb92c70c89f8b009748629b3da73bcfaede11e5a Mon Sep 17 00:00:00 2001 From: yanglsh Date: Wed, 1 Oct 2025 01:16:37 +0800 Subject: [PATCH 089/489] fix: `map_entry` suggests wrongly for insert with cfg-ed out code --- clippy_lints/src/entry.rs | 8 ++++++-- tests/ui/entry.fixed | 10 ++++++++++ tests/ui/entry.rs | 10 ++++++++++ tests/ui/entry.stderr | 23 ++++++++++++++++++++++- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index bdfe2e49e66e..75ab890a8a7f 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::is_copy; use clippy_utils::visitors::for_each_expr; use clippy_utils::{ SpanlessEq, can_move_expr_to_closure_no_visit, desugar_await, higher, is_expr_final_block_expr, - is_expr_used_or_unified, paths, peel_hir_expr_while, + is_expr_used_or_unified, paths, peel_hir_expr_while, span_contains_non_whitespace, }; use core::fmt::{self, Write}; use rustc_errors::Applicability; @@ -167,7 +167,11 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass { "if let {}::{entry_kind} = {map_str}.entry({key_str}) {body_str}", map_ty.entry_path(), )) - } else if let Some(insertion) = then_search.as_single_insertion() { + } else if let Some(insertion) = then_search.as_single_insertion() + && let span_in_between = then_expr.span.shrink_to_lo().between(insertion.call.span) + && let span_in_between = span_in_between.split_at(1).1 + && !span_contains_non_whitespace(cx, span_in_between, true) + { let value_str = snippet_with_context(cx, insertion.value.span, then_expr.span.ctxt(), "..", &mut app).0; if contains_expr.negated { if insertion.value.can_have_side_effects() { diff --git a/tests/ui/entry.fixed b/tests/ui/entry.fixed index 1e36ca4f1f09..75e173b9a84d 100644 --- a/tests/ui/entry.fixed +++ b/tests/ui/entry.fixed @@ -273,3 +273,13 @@ mod issue_16173 { } fn main() {} + +fn issue15781(m: &mut std::collections::HashMap, k: i32, v: i32) { + fn very_important_fn() {} + m.entry(k).or_insert_with(|| { + //~^ map_entry + #[cfg(test)] + very_important_fn(); + v + }); +} diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index b3da0ef3ffd6..7e3308c87356 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -279,3 +279,13 @@ mod issue_16173 { } fn main() {} + +fn issue15781(m: &mut std::collections::HashMap, k: i32, v: i32) { + fn very_important_fn() {} + if !m.contains_key(&k) { + //~^ map_entry + #[cfg(test)] + very_important_fn(); + m.insert(k, v); + } +} diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 009b78d29073..4a29b3860e89 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -246,5 +246,26 @@ LL + e.insert(42); LL + } | -error: aborting due to 11 previous errors +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> tests/ui/entry.rs:285:5 + | +LL | / if !m.contains_key(&k) { +LL | | +LL | | #[cfg(test)] +LL | | very_important_fn(); +LL | | m.insert(k, v); +LL | | } + | |_____^ + | +help: try + | +LL ~ m.entry(k).or_insert_with(|| { +LL + +LL + #[cfg(test)] +LL + very_important_fn(); +LL + v +LL + }); + | + +error: aborting due to 12 previous errors From b1993dce20001b5a9a062ce9035bcee0eb711fd0 Mon Sep 17 00:00:00 2001 From: km247 Date: Sat, 30 Aug 2025 12:12:08 -0500 Subject: [PATCH 090/489] Implement lint to check for usages of `from_raw_parts` where the same expression is used for the length and the capacity --- CHANGELOG.md | 1 + README.md | 2 +- book/src/README.md | 2 +- clippy_lints/src/declared_lints.rs | 1 + clippy_lints/src/lib.rs | 2 + clippy_lints/src/same_length_and_capacity.rs | 105 +++++++++++++++++++ clippy_utils/src/sym.rs | 1 + tests/ui/same_length_and_capacity.rs | 27 +++++ tests/ui/same_length_and_capacity.stderr | 20 ++++ 9 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 clippy_lints/src/same_length_and_capacity.rs create mode 100644 tests/ui/same_length_and_capacity.rs create mode 100644 tests/ui/same_length_and_capacity.stderr diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c81fa47eca9..84accb363988 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6839,6 +6839,7 @@ Released 2018-09-13 [`reversed_empty_ranges`]: https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges [`same_functions_in_if_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_functions_in_if_condition [`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push +[`same_length_and_capacity`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_length_and_capacity [`same_name_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_name_method [`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some [`seek_from_current`]: https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current diff --git a/README.md b/README.md index 20a5e997e629..78498c73ae78 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. -[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) +[There are over 800 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category. diff --git a/book/src/README.md b/book/src/README.md index 5d2c3972b060..c5b264c9f703 100644 --- a/book/src/README.md +++ b/book/src/README.md @@ -5,7 +5,7 @@ A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. -[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) +[There are over 800 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 1a02c2166454..c982463a3227 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -666,6 +666,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[ crate::returns::LET_AND_RETURN_INFO, crate::returns::NEEDLESS_RETURN_INFO, crate::returns::NEEDLESS_RETURN_WITH_QUESTION_MARK_INFO, + crate::same_length_and_capacity::SAME_LENGTH_AND_CAPACITY_INFO, crate::same_name_method::SAME_NAME_METHOD_INFO, crate::self_named_constructors::SELF_NAMED_CONSTRUCTORS_INFO, crate::semicolon_block::SEMICOLON_INSIDE_BLOCK_INFO, diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 5b39d8844797..e92d1a2ac789 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -318,6 +318,7 @@ mod replace_box; mod reserve_after_initialization; mod return_self_not_must_use; mod returns; +mod same_length_and_capacity; mod same_name_method; mod self_named_constructors; mod semicolon_block; @@ -852,6 +853,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co Box::new(|_| Box::new(volatile_composites::VolatileComposites)), Box::new(|_| Box::::default()), Box::new(move |_| Box::new(manual_ilog2::ManualIlog2::new(conf))), + Box::new(|_| Box::new(same_length_and_capacity::SameLengthAndCapacity)), // add late passes here, used by `cargo dev new_lint` ]; store.late_passes.extend(late_lints); diff --git a/clippy_lints/src/same_length_and_capacity.rs b/clippy_lints/src/same_length_and_capacity.rs new file mode 100644 index 000000000000..042dec35f7c9 --- /dev/null +++ b/clippy_lints/src/same_length_and_capacity.rs @@ -0,0 +1,105 @@ +use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::res::MaybeDef; +use clippy_utils::{eq_expr_value, sym}; +use rustc_hir::{Expr, ExprKind, LangItem, QPath}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_session::declare_lint_pass; +use rustc_span::symbol::sym as rustc_sym; + +declare_clippy_lint! { + /// ### What it does + /// + /// Checks for usages of `Vec::from_raw_parts` and `String::from_raw_parts` + /// where the same expression is used for the length and the capacity. + /// + /// ### Why is this bad? + /// + /// If the same expression is being passed for the length and + /// capacity, it is most likely a semantic error. In the case of a + /// Vec, for example, the only way to end up with one that has + /// the same length and capacity is by going through a boxed slice, + /// e.g. `Box::from(some_vec)`, which shrinks the capacity to match + /// the length. + /// + /// ### Example + /// + /// ```no_run + /// #![feature(vec_into_raw_parts)] + /// let mut original: Vec:: = Vec::with_capacity(20); + /// original.extend([1, 2, 3, 4, 5]); + /// + /// let (ptr, mut len, cap) = original.into_raw_parts(); + /// + /// // I will add three more integers: + /// unsafe { + /// let ptr = ptr as *mut i32; + /// + /// for i in 6..9 { + /// *ptr.add(i - 1) = i as i32; + /// len += 1; + /// } + /// } + /// + /// // But I forgot the capacity was separate from the length: + /// let reconstructed = unsafe { Vec::from_raw_parts(ptr, len, len) }; + /// ``` + /// + /// Use instead: + /// ```no_run + /// #![feature(vec_into_raw_parts)] + /// let mut original: Vec:: = Vec::with_capacity(20); + /// original.extend([1, 2, 3, 4, 5]); + /// + /// let (ptr, mut len, cap) = original.into_raw_parts(); + /// + /// // I will add three more integers: + /// unsafe { + /// let ptr = ptr as *mut i32; + /// + /// for i in 6..9 { + /// *ptr.add(i - 1) = i as i32; + /// len += 1; + /// } + /// } + /// + /// // This time, leverage the previously saved capacity: + /// let reconstructed = unsafe { Vec::from_raw_parts(ptr, len, cap) }; + /// ``` + #[clippy::version = "1.93.0"] + pub SAME_LENGTH_AND_CAPACITY, + pedantic, + "`from_raw_parts` with same length and capacity" +} +declare_lint_pass!(SameLengthAndCapacity => [SAME_LENGTH_AND_CAPACITY]); + +impl<'tcx> LateLintPass<'tcx> for SameLengthAndCapacity { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { + if let ExprKind::Call(path_expr, args) = expr.kind + && let ExprKind::Path(QPath::TypeRelative(ty, fn_path)) = path_expr.kind + && fn_path.ident.name == sym::from_raw_parts + && args.len() >= 3 + && eq_expr_value(cx, &args[1], &args[2]) + { + let middle_ty = cx.typeck_results().node_type(ty.hir_id); + if middle_ty.is_diag_item(cx, rustc_sym::Vec) { + span_lint_and_help( + cx, + SAME_LENGTH_AND_CAPACITY, + expr.span, + "usage of `Vec::from_raw_parts` with the same expression for length and capacity", + None, + "try `Box::from(slice::from_raw_parts(...)).into::>()`", + ); + } else if middle_ty.is_lang_item(cx, LangItem::String) { + span_lint_and_help( + cx, + SAME_LENGTH_AND_CAPACITY, + expr.span, + "usage of `String::from_raw_parts` with the same expression for length and capacity", + None, + "try `String::from(str::from_utf8_unchecked(slice::from_raw_parts(...)))`", + ); + } + } + } +} diff --git a/clippy_utils/src/sym.rs b/clippy_utils/src/sym.rs index 00f4a9c7e586..9a7987e60812 100644 --- a/clippy_utils/src/sym.rs +++ b/clippy_utils/src/sym.rs @@ -167,6 +167,7 @@ generate! { from_ne_bytes, from_ptr, from_raw, + from_raw_parts, from_str_radix, fs, fuse, diff --git a/tests/ui/same_length_and_capacity.rs b/tests/ui/same_length_and_capacity.rs new file mode 100644 index 000000000000..999fcf89881d --- /dev/null +++ b/tests/ui/same_length_and_capacity.rs @@ -0,0 +1,27 @@ +#![warn(clippy::same_length_and_capacity)] + +fn main() { + let mut my_vec: Vec = Vec::with_capacity(20); + my_vec.extend([1, 2, 3, 4, 5]); + let (ptr, mut len, cap) = my_vec.into_raw_parts(); + len = 8; + + let _reconstructed_vec = unsafe { Vec::from_raw_parts(ptr, len, len) }; + //~^ same_length_and_capacity + + // Don't want to lint different expressions for len and cap + let _properly_reconstructed_vec = unsafe { Vec::from_raw_parts(ptr, len, cap) }; + + // Don't want to lint if len and cap are distinct variables but happen to be equal + let len_from_cap = cap; + let _another_properly_reconstructed_vec = unsafe { Vec::from_raw_parts(ptr, len_from_cap, cap) }; + + let my_string = String::from("hello"); + let (string_ptr, string_len, string_cap) = my_string.into_raw_parts(); + + let _reconstructed_string = unsafe { String::from_raw_parts(string_ptr, string_len, string_len) }; + //~^ same_length_and_capacity + + // Don't want to lint different expressions for len and cap + let _properly_reconstructed_string = unsafe { String::from_raw_parts(string_ptr, string_len, string_cap) }; +} diff --git a/tests/ui/same_length_and_capacity.stderr b/tests/ui/same_length_and_capacity.stderr new file mode 100644 index 000000000000..6fc852831269 --- /dev/null +++ b/tests/ui/same_length_and_capacity.stderr @@ -0,0 +1,20 @@ +error: usage of `Vec::from_raw_parts` with the same expression for length and capacity + --> tests/ui/same_length_and_capacity.rs:9:39 + | +LL | let _reconstructed_vec = unsafe { Vec::from_raw_parts(ptr, len, len) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try `Box::from(slice::from_raw_parts(...)).into::>()` + = note: `-D clippy::same-length-and-capacity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::same_length_and_capacity)]` + +error: usage of `String::from_raw_parts` with the same expression for length and capacity + --> tests/ui/same_length_and_capacity.rs:22:42 + | +LL | let _reconstructed_string = unsafe { String::from_raw_parts(string_ptr, string_len, string_len) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try `String::from(str::from_utf8_unchecked(slice::from_raw_parts(...)))` + +error: aborting due to 2 previous errors + From 6693a568aff4d4f41007898d070c157f08a6d2db Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 8 Dec 2025 16:20:48 +0000 Subject: [PATCH 091/489] Merge commit 'e24f0fa3c54951d1a5843b54ebe052faaa3a3cd2' into sync_cg_clif-2025-12-08 --- .cirrus.yml | 2 +- Cargo.lock | 159 ++++++++++-------- Cargo.toml | 26 +-- build_system/abi_cafe.rs | 2 +- build_system/bench.rs | 39 +++-- build_system/build_backend.rs | 7 +- build_system/build_sysroot.rs | 43 ++--- build_system/main.rs | 7 +- build_system/tests.rs | 8 +- build_system/utils.rs | 4 +- ...-simd-Disable-broken-reduce_sum-test.patch | 26 --- rust-toolchain | 2 +- scripts/rustup.sh | 4 +- src/common.rs | 20 ++- src/debuginfo/line_info.rs | 9 +- src/debuginfo/mod.rs | 59 ++++--- src/debuginfo/types.rs | 3 +- src/lib.rs | 12 +- 18 files changed, 224 insertions(+), 208 deletions(-) delete mode 100644 patches/0001-portable-simd-Disable-broken-reduce_sum-test.patch diff --git a/.cirrus.yml b/.cirrus.yml index 3ed89beceb7f..9be095dbf2d8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,7 +1,7 @@ task: name: freebsd freebsd_instance: - image_family: freebsd-14-2 + image_family: freebsd-15-0-amd64-ufs setup_rust_script: - pkg install -y git-tiny binutils - curl https://sh.rustup.rs -sSf --output rustup.sh diff --git a/Cargo.lock b/Cargo.lock index 09b6c6b87c30..617c7f0e34cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,15 +10,15 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anyhow" -version = "1.0.98" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "arbitrary" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" [[package]] name = "bitflags" @@ -37,48 +37,48 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cranelift-assembler-x64" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f502c60b6af2025c312b37788c089943ef03156a2910da1aa046bb39eb8f61c7" +checksum = "bf7631e609c97f063f9777aae405e8492abf9bf92336d7aa3f875403dd4ffd7d" dependencies = [ "cranelift-assembler-x64-meta", ] [[package]] name = "cranelift-assembler-x64-meta" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b7e21a74bcf08443a4ef800a4a257063e5c51ee4d7a3bd58da5262d10340830" +checksum = "9c030edccdc4a5bbf28fbfe7701b5cd1f9854b4445184dd34af2a7e8f8db6f45" dependencies = [ "cranelift-srcgen", ] [[package]] name = "cranelift-bforest" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f337d268865c292ad5df0669a9bbf6223ca41460292a20ad5b0a57b8e9f27f93" +checksum = "bb544c1242d0ca98baf01873ebba96c79d5df155d5108d9bb699aefc741f5e6d" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0e60319a8242c8d1c7b5a2444d140c416f903f75e0d84da3256fceb822bab85" +checksum = "f0325aecbafec053d3d3f082edfdca7937e2945e7f09c5ff9672e05198312282" [[package]] name = "cranelift-codegen" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78dee669e447a1c68760bf7acee33835e99d564f0137b067f74d4718dfc9970d" +checksum = "abb3236fd319ae897ba00c8a25105081de5c1348576def0e96c062ad259f87a7" dependencies = [ "bumpalo", "cranelift-assembler-x64", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601f629d172b7230f41dd0e78ee797efaf7ec1a5e113c8f395f4027dff6a92ca" +checksum = "7b8791c911a361c539130ace34fb726b16aca4216470ec75d75264b1495c8a3a" dependencies = [ "cranelift-assembler-x64-meta", "cranelift-codegen-shared", @@ -114,33 +114,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15755c2660902c7d59d96f6551a66ef629650dc3fd405f9dad841e8c58c1a4a2" +checksum = "12ead718c2a10990870c19b2497b5a04b8aae6024485e33da25b5d02e35819e0" [[package]] name = "cranelift-control" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727bfca18705101a294ab9077ad214a8b762ea2bc9844389d0db233d7c61ec3b" +checksum = "c0a57fc972b5651047efddccb99440d103d9d8c13393ccebde15ddd5b6a1181b" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15564c6f0c72750ca4374f40b044857cbc8087571e46d4c7ccdbdcc29b1dec8b" +checksum = "5aae980b4a1678b601eab2f52e372ed0b3c9565a31c17f380008cb97b3a699c5" dependencies = [ "cranelift-bitset", ] [[package]] name = "cranelift-frontend" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c681f2731f1cf68eed9f3b6811571823a5ac498f59c52b73736b68599defb3" +checksum = "a78877016b607982ca1708c0dd4ce23bde04581a39854c9b43a1dca43625b54c" dependencies = [ "cranelift-codegen", "log", @@ -150,15 +150,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40cedc02f08307da019a3e06d3f20f772f829ff813aec975accb012f8930b688" +checksum = "5dc46a68b46d4f53f9f2f02ab8d3a34b00f03a21c124a7a965b8cbf5fdb6773b" [[package]] name = "cranelift-jit" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2864461448c72d15ae3311ea63df9c7e35f22f04683785f6715a0cf17e6577d" +checksum = "7df920009af919ad9df52eb7b47b1895145822e0c29da9b715a876fc8ecc6d82" dependencies = [ "anyhow", "cranelift-codegen", @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b31d249bbbccc4c1ae54701087d4d49d05951897691eef44f4a60e70252743b" +checksum = "ddcf313629071ce74de8e59f02092f5453d1a01047607fc4ad36886b8bd1486c" dependencies = [ "anyhow", "cranelift-codegen", @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db03ab51c60710eb83d0217725b77db4062aca83b35359f5e6aa99ed1c275977" +checksum = "03faa07ec8cf373250a8252eb773d098ff88259fa1c19ee1ecde8012839f4097" dependencies = [ "cranelift-codegen", "libc", @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7131e0eb45ee10b0bd6082d0c0114c2e9a670b034d46774b39d0fc5c0ed7cedf" +checksum = "7cca62c14f3c2e4f438192562bbf82d1a98a59543cc66ba04fb658ba99f515a6" dependencies = [ "anyhow", "cranelift-codegen", @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "cranelift-srcgen" -version = "0.125.1" +version = "0.126.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7a06c330b7994a891ad5b622ebc9aefcd17beae832dd25f577cf60c13426bf" +checksum = "0484cb32c527a742e1bba09ef174acac0afb1dcf623ef1adda42849200edcd2e" [[package]] name = "crc32fast" @@ -246,9 +246,9 @@ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "gimli" -version = "0.32.0" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93563d740bc9ef04104f9ed6f86f1e3275c2cdafb95664e26584b9ca807a8ffe" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" dependencies = [ "fallible-iterator", "indexmap", @@ -282,18 +282,18 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.174" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "libloading" -version = "0.8.8" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" dependencies = [ "cfg-if", - "windows-targets 0.53.3", + "windows-link 0.2.1", ] [[package]] @@ -304,9 +304,9 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "log" -version = "0.4.27" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "mach2" @@ -319,9 +319,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "object" @@ -337,27 +337,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] [[package]] name = "regalloc2" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd8138ce7c3d7c13be4f61893154b5d711bd798d2d7be3ecb8dcc7e7a06ca98" +checksum = "4e249c660440317032a71ddac302f25f1d5dff387667bcc3978d1f77aa31ac34" dependencies = [ "allocator-api2", "bumpalo", @@ -405,18 +405,27 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -431,15 +440,15 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -448,21 +457,21 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" +checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "wasmtime-internal-jit-icache-coherence" -version = "38.0.1" +version = "39.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d0a76f1a6e887cc1b551b02dfd6e2ce5f6738e8cacd9ad7284f6ac1aac4698f" +checksum = "3f67986f5c499274ae5b2ba5b173bba0b95d1381f5ca70d8eec657f2392117d8" dependencies = [ "anyhow", "cfg-if", @@ -472,9 +481,9 @@ dependencies = [ [[package]] name = "wasmtime-internal-math" -version = "38.0.1" +version = "39.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b900df4252ad86547e7f2b2c00201b006db4e864893bedfb3aca32b23d81868a" +checksum = "a681733e9b5d5d8804ee6cacd59f92c0d87ba2274f42ee1d4e5a943828d0075d" dependencies = [ "libm", ] @@ -485,6 +494,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-sys" version = "0.52.0" @@ -525,7 +540,7 @@ version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ - "windows-link", + "windows-link 0.1.3", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", diff --git a/Cargo.toml b/Cargo.toml index f2001123e579..58e61cd0b9d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,28 +8,28 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.125.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] } -cranelift-frontend = { version = "0.125.0" } -cranelift-module = { version = "0.125.0" } -cranelift-native = { version = "0.125.0" } -cranelift-jit = { version = "0.125.0", optional = true } -cranelift-object = { version = "0.125.0" } +cranelift-codegen = { version = "0.126.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] } +cranelift-frontend = { version = "0.126.0" } +cranelift-module = { version = "0.126.0" } +cranelift-native = { version = "0.126.0" } +cranelift-jit = { version = "0.126.0", optional = true } +cranelift-object = { version = "0.126.0" } target-lexicon = "0.13" gimli = { version = "0.32", default-features = false, features = ["write"] } object = { version = "0.37.3", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } indexmap = "2.0.0" -libloading = { version = "0.8.0", optional = true } +libloading = { version = "0.9.0", optional = true } smallvec = "1.8.1" [patch.crates-io] # Uncomment to use an unreleased version of cranelift -#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-38.0.0" } -#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-38.0.0" } -#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-38.0.0" } -#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-38.0.0" } -#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-38.0.0" } -#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-38.0.0" } +#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } +#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } +#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } +#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } +#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } +#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } # Uncomment to use local checkout of cranelift #cranelift-codegen = { path = "../wasmtime/cranelift/codegen" } diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index 5a393a217c27..762b2be8f440 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -11,7 +11,7 @@ static ABI_CAFE_REPO: GitRepo = GitRepo::github( "abi-cafe", ); -static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target"); +static ABI_CAFE: CargoProject = CargoProject::new(ABI_CAFE_REPO.source_dir(), "abi_cafe_target"); pub(crate) fn run( sysroot_kind: SysrootKind, diff --git a/build_system/bench.rs b/build_system/bench.rs index 192cb499536f..91353ba8a874 100644 --- a/build_system/bench.rs +++ b/build_system/bench.rs @@ -39,7 +39,26 @@ pub(crate) fn benchmark(dirs: &Dirs, compiler: &Compiler) { let rustc_clif = &compiler.rustc; let rustflags = &compiler.rustflags.join("\x1f"); let manifest_path = SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).join("Cargo.toml"); - let target_dir = dirs.build_dir.join("simple_raytracer"); + let target_dir = dirs.build_dir.join("simple-raytracer_target"); + + let raytracer_cg_llvm = dirs + .build_dir + .join(get_file_name(&compiler.rustc, "raytracer_cg_llvm", "bin")) + .to_str() + .unwrap() + .to_owned(); + let raytracer_cg_clif = dirs + .build_dir + .join(get_file_name(&compiler.rustc, "raytracer_cg_clif", "bin")) + .to_str() + .unwrap() + .to_owned(); + let raytracer_cg_clif_opt = dirs + .build_dir + .join(get_file_name(&compiler.rustc, "raytracer_cg_clif_opt", "bin")) + .to_str() + .unwrap() + .to_owned(); let clean_cmd = format!( "RUSTC=rustc cargo clean --manifest-path {manifest_path} --target-dir {target_dir}", @@ -47,19 +66,19 @@ pub(crate) fn benchmark(dirs: &Dirs, compiler: &Compiler) { target_dir = target_dir.display(), ); let llvm_build_cmd = format!( - "RUSTC=rustc cargo build --manifest-path {manifest_path} --target-dir {target_dir} && (rm build/raytracer_cg_llvm || true) && ln build/simple_raytracer/debug/main build/raytracer_cg_llvm", + "RUSTC=rustc cargo build --manifest-path {manifest_path} --target-dir {target_dir} && (rm {raytracer_cg_llvm} || true) && ln {target_dir}/debug/main {raytracer_cg_llvm}", manifest_path = manifest_path.display(), target_dir = target_dir.display(), ); let clif_build_cmd = format!( - "RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} && (rm build/raytracer_cg_clif || true) && ln build/simple_raytracer/debug/main build/raytracer_cg_clif", + "RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} && (rm {raytracer_cg_clif} || true) && ln {target_dir}/debug/main {raytracer_cg_clif}", cargo_clif = cargo_clif.display(), rustc_clif = rustc_clif.display(), manifest_path = manifest_path.display(), target_dir = target_dir.display(), ); let clif_build_opt_cmd = format!( - "RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} --release && (rm build/raytracer_cg_clif_opt || true) && ln build/simple_raytracer/release/main build/raytracer_cg_clif_opt", + "RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" CARGO_BUILD_INCREMENTAL=true {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} --release && (rm {raytracer_cg_clif_opt} || true) && ln {target_dir}/release/main {raytracer_cg_clif_opt}", cargo_clif = cargo_clif.display(), rustc_clif = rustc_clif.display(), manifest_path = manifest_path.display(), @@ -92,20 +111,14 @@ pub(crate) fn benchmark(dirs: &Dirs, compiler: &Compiler) { let bench_run_markdown = dirs.build_dir.join("bench_run.md"); - let raytracer_cg_llvm = - Path::new(".").join(get_file_name(&compiler.rustc, "raytracer_cg_llvm", "bin")); - let raytracer_cg_clif = - Path::new(".").join(get_file_name(&compiler.rustc, "raytracer_cg_clif", "bin")); - let raytracer_cg_clif_opt = - Path::new(".").join(get_file_name(&compiler.rustc, "raytracer_cg_clif_opt", "bin")); let mut bench_run = hyperfine_command( 0, bench_runs, None, &[ - ("", raytracer_cg_llvm.to_str().unwrap()), - ("", raytracer_cg_clif.to_str().unwrap()), - ("", raytracer_cg_clif_opt.to_str().unwrap()), + ("build/raytracer_cg_llvm", &raytracer_cg_llvm), + ("build/raytracer_cg_clif", &raytracer_cg_clif), + ("build/raytracer_cg_clif_opt", &raytracer_cg_clif_opt), ], &bench_run_markdown, ); diff --git a/build_system/build_backend.rs b/build_system/build_backend.rs index b9fa0ff2d94c..c0a8cc95614f 100644 --- a/build_system/build_backend.rs +++ b/build_system/build_backend.rs @@ -6,7 +6,7 @@ use crate::rustc_info::get_file_name; use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env}; use crate::utils::{CargoProject, Compiler, LogGroup}; -static CG_CLIF: CargoProject = CargoProject::new(&RelPath::source("."), "cg_clif"); +static CG_CLIF: CargoProject = CargoProject::new(RelPath::source("."), "cg_clif"); pub(crate) fn build_backend( dirs: &Dirs, @@ -22,6 +22,11 @@ pub(crate) fn build_backend( rustflags.push("-Zallow-features=rustc_private,f16,f128".to_owned()); rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags); + // Use incr comp despite release mode unless incremental builds are explicitly disabled + if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() { + cmd.env("CARGO_BUILD_INCREMENTAL", "true"); + } + if env::var("CG_CLIF_EXPENSIVE_CHECKS").is_ok() { // Enabling debug assertions implicitly enables the clif ir verifier cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true"); diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 70504ee8007d..e7363e37a45d 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -140,7 +140,7 @@ impl SysrootTarget { static STDLIB_SRC: RelPath = RelPath::build("stdlib"); static STANDARD_LIBRARY: CargoProject = - CargoProject::new(&RelPath::build("stdlib/library/sysroot"), "stdlib_target"); + CargoProject::new(RelPath::build("stdlib/library/sysroot"), "stdlib_target"); fn build_sysroot_for_triple( dirs: &Dirs, @@ -161,35 +161,18 @@ fn build_sysroot_for_triple( fn build_llvm_sysroot_for_triple(compiler: Compiler) -> SysrootTarget { let default_sysroot = crate::rustc_info::get_default_sysroot(&compiler.rustc); - let mut target_libs = SysrootTarget { triple: compiler.triple, libs: vec![] }; + let std_manifest_path = default_sysroot + .join("lib") + .join("rustlib") + .join(format!("manifest-rust-std-{}", compiler.triple)); - for entry in fs::read_dir( - default_sysroot.join("lib").join("rustlib").join(&target_libs.triple).join("lib"), - ) - .unwrap() - { - let entry = entry.unwrap(); - if entry.file_type().unwrap().is_dir() { - continue; - } - let file = entry.path(); - let file_name_str = file.file_name().unwrap().to_str().unwrap(); - if (file_name_str.contains("rustc_") - && !file_name_str.contains("rustc_std_workspace_") - && !file_name_str.contains("rustc_demangle") - && !file_name_str.contains("rustc_literal_escaper")) - || file_name_str.contains("chalk") - || file_name_str.contains("tracing") - || file_name_str.contains("regex") - { - // These are large crates that are part of the rustc-dev component and are not - // necessary to run regular programs. - continue; - } - target_libs.libs.push(file); - } + let libs = fs::read_to_string(std_manifest_path) + .unwrap() + .lines() + .map(|entry| default_sysroot.join(entry.strip_prefix("file:").unwrap())) + .collect(); - target_libs + SysrootTarget { triple: compiler.triple, libs } } fn build_clif_sysroot_for_triple( @@ -251,6 +234,10 @@ fn build_clif_sysroot_for_triple( if compiler.triple.contains("apple") { build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed"); } + // Use incr comp despite release mode unless incremental builds are explicitly disabled + if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() { + build_cmd.env("CARGO_BUILD_INCREMENTAL", "true"); + } spawn_and_wait(build_cmd); for entry in fs::read_dir(build_dir.join("deps")).unwrap() { diff --git a/build_system/main.rs b/build_system/main.rs index fc0093128300..6251687babc6 100644 --- a/build_system/main.rs +++ b/build_system/main.rs @@ -59,11 +59,6 @@ fn main() { } env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1"); - // Force incr comp even in release mode unless in CI or incremental builds are explicitly disabled - if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() { - env::set_var("CARGO_BUILD_INCREMENTAL", "true"); - } - let mut args = env::args().skip(1); let command = match args.next().as_deref() { Some("prepare") => Command::Prepare, @@ -79,7 +74,7 @@ fn main() { } }; - let mut out_dir = PathBuf::from("."); + let mut out_dir = std::env::current_dir().unwrap(); let mut download_dir = None; let mut sysroot_kind = SysrootKind::Clif; let mut use_unstable_features = true; diff --git a/build_system/tests.rs b/build_system/tests.rs index dd8cf929bc2f..3b6a2e7a055c 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -129,7 +129,7 @@ pub(crate) static RAND_REPO: GitRepo = GitRepo::github( "rand", ); -static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target"); +static RAND: CargoProject = CargoProject::new(RAND_REPO.source_dir(), "rand_target"); pub(crate) static REGEX_REPO: GitRepo = GitRepo::github( "rust-lang", @@ -139,15 +139,15 @@ pub(crate) static REGEX_REPO: GitRepo = GitRepo::github( "regex", ); -static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex_target"); +static REGEX: CargoProject = CargoProject::new(REGEX_REPO.source_dir(), "regex_target"); static PORTABLE_SIMD_SRC: RelPath = RelPath::build("portable-simd"); -static PORTABLE_SIMD: CargoProject = CargoProject::new(&PORTABLE_SIMD_SRC, "portable-simd_target"); +static PORTABLE_SIMD: CargoProject = CargoProject::new(PORTABLE_SIMD_SRC, "portable-simd_target"); static SYSROOT_TESTS_SRC: RelPath = RelPath::build("sysroot_tests"); -static SYSROOT_TESTS: CargoProject = CargoProject::new(&SYSROOT_TESTS_SRC, "sysroot_tests_target"); +static SYSROOT_TESTS: CargoProject = CargoProject::new(SYSROOT_TESTS_SRC, "sysroot_tests_target"); const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ TestCase::custom("test.rust-random/rand", &|runner| { diff --git a/build_system/utils.rs b/build_system/utils.rs index 3266aa0ce8b6..5c7cefa120a7 100644 --- a/build_system/utils.rs +++ b/build_system/utils.rs @@ -75,12 +75,12 @@ impl Compiler { } pub(crate) struct CargoProject { - source: &'static RelPath, + source: RelPath, target: &'static str, } impl CargoProject { - pub(crate) const fn new(path: &'static RelPath, target: &'static str) -> CargoProject { + pub(crate) const fn new(path: RelPath, target: &'static str) -> CargoProject { CargoProject { source: path, target } } diff --git a/patches/0001-portable-simd-Disable-broken-reduce_sum-test.patch b/patches/0001-portable-simd-Disable-broken-reduce_sum-test.patch deleted file mode 100644 index b1fd6224632b..000000000000 --- a/patches/0001-portable-simd-Disable-broken-reduce_sum-test.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 5489384bc265e9e6fc2efaa63d93a4d51ebec2f5 Mon Sep 17 00:00:00 2001 -From: bjorn3 <17426603+bjorn3@users.noreply.github.com> -Date: Thu, 22 Aug 2024 19:22:58 +0000 -Subject: [PATCH] Disable broken reduce_sum test - -It was broken by an upstream change to the .sum() implementation on -float iterators. ---- - crates/core_simd/tests/ops_macros.rs | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/crates/core_simd/tests/ops_macros.rs b/crates/core_simd/tests/ops_macros.rs -index aa565a1..5e6ac41 100644 ---- a/crates/core_simd/tests/ops_macros.rs -+++ b/crates/core_simd/tests/ops_macros.rs -@@ -646,6 +646,7 @@ macro_rules! impl_float_tests { - } - - fn reduce_sum() { -+ return; - test_helpers::test_1(&|x| { - test_helpers::prop_assert_biteq! ( - Vector::::from_array(x).reduce_sum(), --- -2.34.1 - diff --git a/rust-toolchain b/rust-toolchain index 17c2cc5ac660..461dbcdb0fb5 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2025-11-08" +channel = "nightly-2025-12-08" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" diff --git a/scripts/rustup.sh b/scripts/rustup.sh index fdfd03029b16..1a82193303e2 100755 --- a/scripts/rustup.sh +++ b/scripts/rustup.sh @@ -43,7 +43,7 @@ case $1 in cg_clif=$(pwd) pushd ../rust - git pull origin master + git pull origin main branch=sync_cg_clif-$(date +%Y-%m-%d) git checkout -b "$branch" "$cg_clif/git-fixed-subtree.sh" pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/rust-lang/rustc_codegen_cranelift.git main @@ -63,7 +63,7 @@ case $1 in cg_clif=$(pwd) pushd ../rust - git fetch origin master + git fetch origin main git -c advice.detachedHead=false checkout "$RUST_VERS" "$cg_clif/git-fixed-subtree.sh" push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust popd diff --git a/src/common.rs b/src/common.rs index 38676eaac3d5..b11f42408f58 100644 --- a/src/common.rs +++ b/src/common.rs @@ -377,26 +377,28 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { size.is_multiple_of(align), "size must be a multiple of alignment (size={size}, align={align})" ); + debug_assert!(align.is_power_of_two(), "alignment must be a power of two (align={align})"); let abi_align = if self.tcx.sess.target.arch == Arch::S390x { 8 } else { 16 }; + // Cranelift can only guarantee alignment up to the ABI alignment provided by the target. + // If the requested alignment is less than the abi_align it can be used directly. if align <= abi_align { let stack_slot = self.bcx.create_sized_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, - // FIXME Don't force the size to a multiple of bytes once Cranelift gets - // a way to specify stack slot alignment. - size: size.div_ceil(abi_align) * abi_align, - align_shift: 4, + size, + // The maximum value of ilog2 is 31 which will always fit in a u8. + align_shift: align.ilog2().try_into().unwrap(), + key: None, }); Pointer::stack_slot(stack_slot) } else { - // Alignment is too big to handle using the above hack. Dynamically realign a stack slot + // Alignment is larger than the ABI alignment guaranteed. Dynamically realign a stack slot // instead. This wastes some space for the realignment. let stack_slot = self.bcx.create_sized_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, - // FIXME Don't force the size to a multiple of bytes once Cranelift gets - // a way to specify stack slot alignment. - size: (size + align) / abi_align * abi_align, - align_shift: 4, + size: size + align, + align_shift: abi_align.ilog2().try_into().unwrap(), + key: None, }); let base_ptr = self.bcx.ins().stack_addr(self.pointer_type, stack_slot, 0); let misalign_offset = self.bcx.ins().band_imm(base_ptr, i64::from(align - 1)); diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 6fe22f5c6dd9..db58ee890911 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -5,7 +5,7 @@ use std::path::{Component, Path}; use cranelift_codegen::MachSrcLoc; use cranelift_codegen::binemit::CodeOffset; -use gimli::write::{AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable}; +use gimli::write::{FileId, FileInfo, LineProgram, LineString, LineStringTable}; use rustc_span::{FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHashAlgorithm, hygiene}; use crate::debuginfo::FunctionDebugContext; @@ -117,8 +117,7 @@ impl DebugContext { } filename => { // For anonymous sources, create an empty directory instead of using the default - let empty_dir = LineString::new(b"", line_program.encoding(), line_strings); - let dir_id = line_program.add_directory(empty_dir); + let dir_id = line_program.default_directory(); let dummy_file_name = LineString::new( filename.prefer_remapped_unconditionally().to_string().into_bytes(), @@ -176,10 +175,6 @@ impl FunctionDebugContext { assert_ne!(func_end, 0); - let entry = debug_context.dwarf.unit.get_mut(self.entry_id); - entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(address_for_func(func_id))); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(func_end))); - func_end } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 494002f525c8..8c43db92fe05 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -42,14 +42,14 @@ pub(crate) struct DebugContext { created_files: FxHashMap<(StableSourceFileId, SourceFileHash), FileId>, stack_pointer_register: Register, namespace_map: DefIdMap, - array_size_type: UnitEntryId, + array_size_type: Option, filename_display_preference: FileNameDisplayPreference, embed_source: bool, } pub(crate) struct FunctionDebugContext { - entry_id: UnitEntryId, + entry_id: Option, function_source_loc: (FileId, u64, u64), source_loc_set: IndexSet<(FileId, u64, u64)>, } @@ -154,18 +154,23 @@ impl DebugContext { root.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Constant(0))); } - let array_size_type = dwarf.unit.add(dwarf.unit.root(), gimli::DW_TAG_base_type); - let array_size_type_entry = dwarf.unit.get_mut(array_size_type); - array_size_type_entry.set( - gimli::DW_AT_name, - AttributeValue::StringRef(dwarf.strings.add("__ARRAY_SIZE_TYPE__")), - ); - array_size_type_entry - .set(gimli::DW_AT_encoding, AttributeValue::Encoding(gimli::DW_ATE_unsigned)); - array_size_type_entry.set( - gimli::DW_AT_byte_size, - AttributeValue::Udata(isa.frontend_config().pointer_bytes().into()), - ); + let array_size_type = if tcx.sess.opts.debuginfo == DebugInfo::LineTablesOnly { + None + } else { + let array_size_type = dwarf.unit.add(dwarf.unit.root(), gimli::DW_TAG_base_type); + let array_size_type_entry = dwarf.unit.get_mut(array_size_type); + array_size_type_entry.set( + gimli::DW_AT_name, + AttributeValue::StringRef(dwarf.strings.add("__ARRAY_SIZE_TYPE__")), + ); + array_size_type_entry + .set(gimli::DW_AT_encoding, AttributeValue::Encoding(gimli::DW_ATE_unsigned)); + array_size_type_entry.set( + gimli::DW_AT_byte_size, + AttributeValue::Udata(isa.frontend_config().pointer_bytes().into()), + ); + Some(array_size_type) + }; Some(DebugContext { endian, @@ -217,6 +222,14 @@ impl DebugContext { ) -> FunctionDebugContext { let (file_id, line, column) = self.get_span_loc(tcx, function_span, function_span); + if tcx.sess.opts.debuginfo == DebugInfo::LineTablesOnly { + return FunctionDebugContext { + entry_id: None, + function_source_loc: (file_id, line, column), + source_loc_set: IndexSet::new(), + }; + } + let scope = self.item_namespace(tcx, tcx.parent(instance.def_id())); let mut name = String::new(); @@ -274,7 +287,7 @@ impl DebugContext { } FunctionDebugContext { - entry_id, + entry_id: Some(entry_id), function_source_loc: (file_id, line, column), source_loc_set: IndexSet::new(), } @@ -288,6 +301,10 @@ impl DebugContext { def_id: DefId, data_id: DataId, ) { + if tcx.sess.opts.debuginfo == DebugInfo::LineTablesOnly { + return; + } + let DefKind::Static { nested, .. } = tcx.def_kind(def_id) else { bug!() }; if nested { return; @@ -353,10 +370,12 @@ impl FunctionDebugContext { .0 .push(Range::StartLength { begin: address_for_func(func_id), length: u64::from(end) }); - let func_entry = debug_context.dwarf.unit.get_mut(self.entry_id); - // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped. - func_entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(address_for_func(func_id))); - // Using Udata for DW_AT_high_pc requires at least DWARF4 - func_entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(end))); + if let Some(entry_id) = self.entry_id { + let entry = debug_context.dwarf.unit.get_mut(entry_id); + // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped. + entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(address_for_func(func_id))); + // Using Udata for DW_AT_high_pc requires at least DWARF4 + entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(end))); + } } } diff --git a/src/debuginfo/types.rs b/src/debuginfo/types.rs index a292429cdfad..18a0632a0939 100644 --- a/src/debuginfo/types.rs +++ b/src/debuginfo/types.rs @@ -109,7 +109,8 @@ impl DebugContext { let subrange_id = self.dwarf.unit.add(array_type_id, gimli::DW_TAG_subrange_type); let subrange_entry = self.dwarf.unit.get_mut(subrange_id); - subrange_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(self.array_size_type)); + subrange_entry + .set(gimli::DW_AT_type, AttributeValue::UnitRef(self.array_size_type.unwrap())); subrange_entry.set(gimli::DW_AT_lower_bound, AttributeValue::Udata(0)); subrange_entry.set(gimli::DW_AT_count, AttributeValue::Udata(len)); diff --git a/src/lib.rs b/src/lib.rs index 5fdecd014ac0..b47b9afa4f07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ use rustc_codegen_ssa::{CodegenResults, TargetConfig}; use rustc_log::tracing::info; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_session::Session; -use rustc_session::config::OutputFilenames; +use rustc_session::config::{OutputFilenames, PrintKind, PrintRequest}; use rustc_span::{Symbol, sym}; use rustc_target::spec::{Abi, Arch, Env, Os}; @@ -160,6 +160,16 @@ impl CodegenBackend for CraneliftCodegenBackend { } } + fn print(&self, req: &PrintRequest, out: &mut String, _sess: &Session) { + match req.kind { + // FIXME have a default impl that returns false + PrintKind::BackendHasZstd => { + out.push_str("false\n"); + } + _ => {} + } + } + fn target_config(&self, sess: &Session) -> TargetConfig { // FIXME return the actually used target features. this is necessary for #[cfg(target_feature)] let target_features = match sess.target.arch { From 51f9b90b2b8a7167410d770db4f890f4a008ceb5 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 8 Dec 2025 18:58:56 +0100 Subject: [PATCH 092/489] Remove `[no-mentions]` handler in our triagebot config https://github.blog/changelog/2025-11-07-removing-notifications-for-mentions-in-commit-messages/ --- library/stdarch/triagebot.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/library/stdarch/triagebot.toml b/library/stdarch/triagebot.toml index 2c281c8f7d42..621f39b2cbbf 100644 --- a/library/stdarch/triagebot.toml +++ b/library/stdarch/triagebot.toml @@ -56,7 +56,3 @@ Thanks! # Documentation at: https://forge.rust-lang.org/triagebot/issue-links.html [issue-links] check-commits = false - -# Prevents mentions in commits to avoid users being spammed -# Documentation at: https://forge.rust-lang.org/triagebot/no-mentions.html -[no-mentions] From 1314419ccdec8f54da53a812322c8053774f88c9 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 8 Dec 2025 19:23:10 +0100 Subject: [PATCH 093/489] Remove `[no-mentions]` handler in our triagebot config https://github.blog/changelog/2025-11-07-removing-notifications-for-mentions-in-commit-messages/ --- triagebot.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index 13da0a87def3..eb0c7b011f60 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -2,6 +2,3 @@ # Prevents un-canonicalized issue links (to avoid wrong issues being linked in r-l/rust) [issue-links] - -# Prevents mentions in commits to avoid users being spammed -[no-mentions] From 66381e3d790c8a5ea8f3e736e561dacb88780fdc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:11:04 +0000 Subject: [PATCH 094/489] Revert build_llvm_sysroot_for_triple back from reading the manifest to filtering Reading the manifest doesn't work when running in the context of the rust build system. --- build_system/build_sysroot.rs | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index e7363e37a45d..7b4c604580c1 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -161,18 +161,35 @@ fn build_sysroot_for_triple( fn build_llvm_sysroot_for_triple(compiler: Compiler) -> SysrootTarget { let default_sysroot = crate::rustc_info::get_default_sysroot(&compiler.rustc); - let std_manifest_path = default_sysroot - .join("lib") - .join("rustlib") - .join(format!("manifest-rust-std-{}", compiler.triple)); + let mut target_libs = SysrootTarget { triple: compiler.triple, libs: vec![] }; - let libs = fs::read_to_string(std_manifest_path) - .unwrap() - .lines() - .map(|entry| default_sysroot.join(entry.strip_prefix("file:").unwrap())) - .collect(); + for entry in fs::read_dir( + default_sysroot.join("lib").join("rustlib").join(&target_libs.triple).join("lib"), + ) + .unwrap() + { + let entry = entry.unwrap(); + if entry.file_type().unwrap().is_dir() { + continue; + } + let file = entry.path(); + let file_name_str = file.file_name().unwrap().to_str().unwrap(); + if (file_name_str.contains("rustc_") + && !file_name_str.contains("rustc_std_workspace_") + && !file_name_str.contains("rustc_demangle") + && !file_name_str.contains("rustc_literal_escaper")) + || file_name_str.contains("chalk") + || file_name_str.contains("tracing") + || file_name_str.contains("regex") + { + // These are large crates that are part of the rustc-dev component and are not + // necessary to run regular programs. + continue; + } + target_libs.libs.push(file); + } - SysrootTarget { triple: compiler.triple, libs } + target_libs } fn build_clif_sysroot_for_triple( From d38a5a6d1d3a988d43ceb247d378317d2e157c9e Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 8 Dec 2025 22:41:13 +1100 Subject: [PATCH 095/489] Make `--print=backend-has-zstd` work by default on any backend Using a defaulted `CodegenBackend` method that querying for zstd support should automatically print a safe value of `false` on any backend that doesn't specifically indicate the presence or absence of zstd. --- src/lib.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b47b9afa4f07..5fdecd014ac0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ use rustc_codegen_ssa::{CodegenResults, TargetConfig}; use rustc_log::tracing::info; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_session::Session; -use rustc_session::config::{OutputFilenames, PrintKind, PrintRequest}; +use rustc_session::config::OutputFilenames; use rustc_span::{Symbol, sym}; use rustc_target::spec::{Abi, Arch, Env, Os}; @@ -160,16 +160,6 @@ impl CodegenBackend for CraneliftCodegenBackend { } } - fn print(&self, req: &PrintRequest, out: &mut String, _sess: &Session) { - match req.kind { - // FIXME have a default impl that returns false - PrintKind::BackendHasZstd => { - out.push_str("false\n"); - } - _ => {} - } - } - fn target_config(&self, sess: &Session) -> TargetConfig { // FIXME return the actually used target features. this is necessary for #[cfg(target_feature)] let target_features = match sess.target.arch { From df38e1521d62e9f04ec339badf9de6317c8602a0 Mon Sep 17 00:00:00 2001 From: tison Date: Tue, 9 Dec 2025 20:38:47 +0800 Subject: [PATCH 096/489] Add const default for OnceCell and OnceLock Signed-off-by: tison --- library/core/src/cell/once.rs | 3 ++- library/std/src/lib.rs | 1 + library/std/src/sync/once_lock.rs | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/library/core/src/cell/once.rs b/library/core/src/cell/once.rs index 6c71e2216a71..af4469fad2cc 100644 --- a/library/core/src/cell/once.rs +++ b/library/core/src/cell/once.rs @@ -353,7 +353,8 @@ impl OnceCell { } #[stable(feature = "once_cell", since = "1.70.0")] -impl Default for OnceCell { +#[rustc_const_unstable(feature = "const_default", issue = "143894")] +impl const Default for OnceCell { #[inline] fn default() -> Self { Self::new() diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 0401e9b39ff4..65ea85f36d93 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -274,6 +274,7 @@ #![feature(cfg_sanitizer_cfi)] #![feature(cfg_target_thread_local)] #![feature(cfi_encoding)] +#![feature(const_default)] #![feature(const_trait_impl)] #![feature(core_float_math)] #![feature(decl_macro)] diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index d1bbe0ff843c..b9a7077e420e 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs @@ -582,7 +582,8 @@ impl RefUnwindSafe for OnceLock {} impl UnwindSafe for OnceLock {} #[stable(feature = "once_cell", since = "1.70.0")] -impl Default for OnceLock { +#[rustc_const_unstable(feature = "const_default", issue = "143894")] +impl const Default for OnceLock { /// Creates a new uninitialized cell. /// /// # Example From 6159c1971fba705963377f1a90824f0269fa8682 Mon Sep 17 00:00:00 2001 From: irelaxcn Date: Tue, 9 Dec 2025 21:37:53 +0800 Subject: [PATCH 097/489] Fix `if_then_some_else_none` FP when the `then` block contains `.await` --- clippy_lints/src/if_then_some_else_none.rs | 16 ++++++++++++---- tests/ui/if_then_some_else_none.fixed | 10 ++++++++++ tests/ui/if_then_some_else_none.rs | 10 ++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 7f3ef58c93d1..314c8e1dd54c 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -4,10 +4,12 @@ use clippy_utils::eager_or_lazy::switch_to_eager_eval; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::source::{snippet_with_applicability, snippet_with_context, walk_span_to_context}; use clippy_utils::sugg::Sugg; +use clippy_utils::visitors::for_each_expr_without_closures; use clippy_utils::{ - as_some_expr, contains_return, expr_adjustment_requires_coercion, higher, is_else_clause, is_in_const_context, - is_none_expr, peel_blocks, sym, + as_some_expr, expr_adjustment_requires_coercion, higher, is_else_clause, is_in_const_context, is_none_expr, + peel_blocks, sym, }; +use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -76,8 +78,14 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone { && !is_else_clause(cx.tcx, expr) && !is_in_const_context(cx) && self.msrv.meets(cx, msrvs::BOOL_THEN) - && !contains_return(then_block.stmts) - && then_block.expr.is_none_or(|expr| !contains_return(expr)) + && for_each_expr_without_closures(then_block, |e| { + if matches!(e.kind, ExprKind::Ret(..) | ExprKind::Yield(..)) { + ControlFlow::Break(()) + } else { + ControlFlow::Continue(()) + } + }) + .is_none() { let method_name = if switch_to_eager_eval(cx, expr) && self.msrv.meets(cx, msrvs::BOOL_THEN_SOME) { sym::then_some diff --git a/tests/ui/if_then_some_else_none.fixed b/tests/ui/if_then_some_else_none.fixed index 7da9401a308f..9d4cbe6baf07 100644 --- a/tests/ui/if_then_some_else_none.fixed +++ b/tests/ui/if_then_some_else_none.fixed @@ -218,3 +218,13 @@ mod issue15770 { Ok(()) } } + +mod issue16176 { + pub async fn foo() -> u32 { + todo!() + } + + pub async fn bar(cond: bool) -> Option { + if cond { Some(foo().await) } else { None } // OK + } +} diff --git a/tests/ui/if_then_some_else_none.rs b/tests/ui/if_then_some_else_none.rs index 02962f83ce8a..6b1ece61e775 100644 --- a/tests/ui/if_then_some_else_none.rs +++ b/tests/ui/if_then_some_else_none.rs @@ -274,3 +274,13 @@ mod issue15770 { Ok(()) } } + +mod issue16176 { + pub async fn foo() -> u32 { + todo!() + } + + pub async fn bar(cond: bool) -> Option { + if cond { Some(foo().await) } else { None } // OK + } +} From 2bda6713c7a225e73b266ea50748e04188efed38 Mon Sep 17 00:00:00 2001 From: is57primenumber <58158444+is57primenumber@users.noreply.github.com> Date: Tue, 9 Dec 2025 22:34:04 +0900 Subject: [PATCH 098/489] Add regression test for closure loop vectorization --- tests/assembly-llvm/slp-vectorize-closure.rs | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/assembly-llvm/slp-vectorize-closure.rs diff --git a/tests/assembly-llvm/slp-vectorize-closure.rs b/tests/assembly-llvm/slp-vectorize-closure.rs new file mode 100644 index 000000000000..fcdb469a2413 --- /dev/null +++ b/tests/assembly-llvm/slp-vectorize-closure.rs @@ -0,0 +1,28 @@ +//! Loop inside closure correctly compiled to assembly using SSE instructions. +//! Regression test for . +//! also see +//@ assembly-output: emit-asm +//@ compile-flags: -Copt-level=3 +//@ only-x86_64 +// to test SSE instructions + +#![crate_type = "lib"] + +// CHECK-LABEL: for_in_closure +// CHECK: {{paddb|psubb}} +#[inline(never)] +#[no_mangle] +pub fn for_in_closure() { + let mut v = [[0u8; 4]; 60]; + + let mut closure = || { + for item in &mut v { + item[0] += 1; + item[1] += 1; + item[2] += 1; + item[3] += 1; + } + }; + + closure(); +} From e6143962f9802e88018a7084ef836203c90cef45 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 Dec 2025 15:42:22 +0100 Subject: [PATCH 099/489] Fix clippy lint in `cg_gcc` --- src/builder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 1787415b72e6..df1e64c75b96 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -500,11 +500,11 @@ impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> { } fn set_rvalue_location<'a, 'gcc, 'tcx>( - bx: &mut Builder<'a, 'gcc, 'tcx>, + _bx: &mut Builder<'a, 'gcc, 'tcx>, rvalue: RValue<'gcc>, ) -> RValue<'gcc> { - if let Some(location) = bx.location { - #[cfg(feature = "master")] + #[cfg(feature = "master")] + if let Some(location) = _bx.location { rvalue.set_location(location); } rvalue From e013f772dadcaa6ea90927d95da12c177968c630 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Dec 2025 17:43:19 +0100 Subject: [PATCH 100/489] Update clippy code to new doc attribute API --- clippy_lints/src/doc/doc_suspicious_footnotes.rs | 14 +++++++++----- clippy_lints/src/doc/mod.rs | 2 +- clippy_lints/src/doc/suspicious_doc_comments.rs | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/doc/doc_suspicious_footnotes.rs b/clippy_lints/src/doc/doc_suspicious_footnotes.rs index 3330cc5defd3..1944cd7c91d3 100644 --- a/clippy_lints/src/doc/doc_suspicious_footnotes.rs +++ b/clippy_lints/src/doc/doc_suspicious_footnotes.rs @@ -1,10 +1,9 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::attr::AttributeExt as _; -use rustc_ast::token::CommentKind; +use rustc_ast::token::{CommentKind, DocFragmentKind}; use rustc_errors::Applicability; use rustc_hir::{AttrStyle, Attribute}; use rustc_lint::{LateContext, LintContext}; -use rustc_resolve::rustdoc::DocFragmentKind; use std::ops::Range; @@ -43,13 +42,18 @@ pub fn check(cx: &LateContext<'_>, doc: &str, range: Range, fragments: &F span, "looks like a footnote ref, but has no matching footnote", |diag| { - if this_fragment.kind == DocFragmentKind::SugaredDoc { - let (doc_attr, (_, doc_attr_comment_kind), attr_style) = attrs + if let DocFragmentKind::Sugared(_) = this_fragment.kind { + let (doc_attr, doc_attr_comment_kind, attr_style) = attrs .iter() .filter(|attr| attr.span().overlaps(this_fragment.span)) .rev() .find_map(|attr| { - Some((attr, attr.doc_str_and_comment_kind()?, attr.doc_resolution_scope()?)) + let (_, fragment) = attr.doc_str_and_fragment_kind()?; + let fragment = match fragment { + DocFragmentKind::Sugared(kind) => kind, + DocFragmentKind::Raw(_) => CommentKind::Line, + }; + Some((attr, fragment, attr.doc_resolution_scope()?)) }) .unwrap(); let (to_add, terminator) = match (doc_attr_comment_kind, attr_style) { diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 120da92da944..b11b2f8392c1 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -861,7 +861,7 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ let (fragments, _) = attrs_to_doc_fragments( attrs.iter().filter_map(|attr| { - if attr.doc_str_and_comment_kind().is_none() || attr.span().in_external_macro(cx.sess().source_map()) { + if attr.doc_str_and_fragment_kind().is_none() || attr.span().in_external_macro(cx.sess().source_map()) { None } else { Some((attr, None)) diff --git a/clippy_lints/src/doc/suspicious_doc_comments.rs b/clippy_lints/src/doc/suspicious_doc_comments.rs index 47d91b80e7ee..e751600f00a6 100644 --- a/clippy_lints/src/doc/suspicious_doc_comments.rs +++ b/clippy_lints/src/doc/suspicious_doc_comments.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::AttrStyle; -use rustc_ast::token::CommentKind; +use rustc_ast::token::{CommentKind, DocFragmentKind}; use rustc_errors::Applicability; use rustc_hir::Attribute; use rustc_hir::attrs::AttributeKind; @@ -46,8 +46,8 @@ fn collect_doc_replacements(attrs: &[Attribute]) -> Vec<(Span, String)> { && let Some(com) = comment.as_str().strip_prefix('!') { let sugg = match kind { - CommentKind::Line => format!("//!{com}"), - CommentKind::Block => format!("/*!{com}*/"), + DocFragmentKind::Sugared(CommentKind::Block) => format!("/*!{com}*/"), + DocFragmentKind::Sugared(CommentKind::Line) | DocFragmentKind::Raw(_) => format!("//!{com}"), }; Some((attr.span(), sugg)) } else { From 503b34ab0d22cf8bf658809ed71c1d27e8652717 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 8 Dec 2025 22:44:41 +0100 Subject: [PATCH 101/489] Update clippy code --- clippy_lints/src/doc/doc_suspicious_footnotes.rs | 9 ++++++++- clippy_lints/src/doc/suspicious_doc_comments.rs | 8 ++++---- clippy_utils/src/attrs.rs | 7 +------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clippy_lints/src/doc/doc_suspicious_footnotes.rs b/clippy_lints/src/doc/doc_suspicious_footnotes.rs index 1944cd7c91d3..deca29a1885f 100644 --- a/clippy_lints/src/doc/doc_suspicious_footnotes.rs +++ b/clippy_lints/src/doc/doc_suspicious_footnotes.rs @@ -2,6 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::attr::AttributeExt as _; use rustc_ast::token::{CommentKind, DocFragmentKind}; use rustc_errors::Applicability; +use rustc_hir::attrs::AttributeKind; use rustc_hir::{AttrStyle, Attribute}; use rustc_lint::{LateContext, LintContext}; @@ -45,7 +46,13 @@ pub fn check(cx: &LateContext<'_>, doc: &str, range: Range, fragments: &F if let DocFragmentKind::Sugared(_) = this_fragment.kind { let (doc_attr, doc_attr_comment_kind, attr_style) = attrs .iter() - .filter(|attr| attr.span().overlaps(this_fragment.span)) + .filter(|attr| { + matches!( + attr, + Attribute::Parsed(AttributeKind::DocComment { span, .. }) + if span.overlaps(this_fragment.span), + ) + }) .rev() .find_map(|attr| { let (_, fragment) = attr.doc_str_and_fragment_kind()?; diff --git a/clippy_lints/src/doc/suspicious_doc_comments.rs b/clippy_lints/src/doc/suspicious_doc_comments.rs index e751600f00a6..178d688264b7 100644 --- a/clippy_lints/src/doc/suspicious_doc_comments.rs +++ b/clippy_lints/src/doc/suspicious_doc_comments.rs @@ -39,15 +39,15 @@ fn collect_doc_replacements(attrs: &[Attribute]) -> Vec<(Span, String)> { .filter_map(|attr| { if let Attribute::Parsed(AttributeKind::DocComment { style: AttrStyle::Outer, - kind, + kind: DocFragmentKind::Sugared(comment_kind), comment, .. }) = attr && let Some(com) = comment.as_str().strip_prefix('!') { - let sugg = match kind { - DocFragmentKind::Sugared(CommentKind::Block) => format!("/*!{com}*/"), - DocFragmentKind::Sugared(CommentKind::Line) | DocFragmentKind::Raw(_) => format!("//!{com}"), + let sugg = match comment_kind { + CommentKind::Block => format!("/*!{com}*/"), + CommentKind::Line => format!("//!{com}"), }; Some((attr.span(), sugg)) } else { diff --git a/clippy_utils/src/attrs.rs b/clippy_utils/src/attrs.rs index 671b266ba008..2fd773b06781 100644 --- a/clippy_utils/src/attrs.rs +++ b/clippy_utils/src/attrs.rs @@ -2,7 +2,6 @@ use crate::source::SpanRangeExt; use crate::{sym, tokenize_with_text}; -use rustc_ast::attr; use rustc_ast::attr::AttributeExt; use rustc_errors::Applicability; use rustc_hir::attrs::AttributeKind; @@ -87,11 +86,7 @@ pub fn is_proc_macro(attrs: &[impl AttributeExt]) -> bool { /// Checks whether `attrs` contain `#[doc(hidden)]` pub fn is_doc_hidden(attrs: &[impl AttributeExt]) -> bool { - attrs - .iter() - .filter(|attr| attr.has_name(sym::doc)) - .filter_map(AttributeExt::meta_item_list) - .any(|l| attr::list_contains_name(&l, sym::hidden)) + attrs.iter().any(|attr| attr.is_doc_hidden()) } /// Checks whether the given ADT, or any of its fields/variants, are marked as `#[non_exhaustive]` From b67a2d5379f8fa6f7b4f4d4c4d88aba485e19066 Mon Sep 17 00:00:00 2001 From: benodiwal Date: Wed, 10 Dec 2025 17:37:26 +0530 Subject: [PATCH 102/489] feat: show parameter hint for missing arguments --- .../crates/ide/src/inlay_hints.rs | 2 + .../crates/ide/src/inlay_hints/param_name.rs | 195 ++++++++++++++++++ .../crates/ide/src/static_index.rs | 1 + .../rust-analyzer/src/cli/analysis_stats.rs | 1 + .../crates/rust-analyzer/src/config.rs | 6 + .../docs/book/src/configuration_generated.md | 7 + .../rust-analyzer/editors/code/package.json | 10 + 7 files changed, 222 insertions(+) diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs index 03674978d53d..d05c7811b087 100644 --- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs +++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs @@ -307,6 +307,7 @@ pub struct InlayHintsConfig<'a> { pub sized_bound: bool, pub discriminant_hints: DiscriminantHints, pub parameter_hints: bool, + pub parameter_hints_for_missing_arguments: bool, pub generic_parameter_hints: GenericParameterHints, pub chaining_hints: bool, pub adjustment_hints: AdjustmentHints, @@ -886,6 +887,7 @@ mod tests { render_colons: false, type_hints: false, parameter_hints: false, + parameter_hints_for_missing_arguments: false, sized_bound: false, generic_parameter_hints: GenericParameterHints { type_hints: false, diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs index 8d0348767316..f1e62a5ab8ac 100644 --- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs +++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs @@ -11,6 +11,7 @@ use hir::{EditionedFileId, Semantics}; use ide_db::{RootDatabase, famous_defs::FamousDefs}; use stdx::to_lower_snake_case; +use syntax::T; use syntax::ast::{self, AstNode, HasArgList, HasName, UnaryOp}; use crate::{InlayHint, InlayHintLabel, InlayHintPosition, InlayHintsConfig, InlayKind}; @@ -88,9 +89,75 @@ pub(super) fn hints( }); acc.extend(hints); + + // Show hint for the next expected (missing) argument if enabled + if config.parameter_hints_for_missing_arguments { + let provided_args_count = arg_list.args().count(); + let params = callable.params(); + let total_params = params.len(); + + if provided_args_count < total_params + && let Some(next_param) = params.get(provided_args_count) + && let Some(param_name) = next_param.name(sema.db) + { + // Apply heuristics to hide obvious parameter hints + if should_hide_missing_param_hint(unary_function, function_name, param_name.as_str()) { + return Some(()); + } + + // Determine the position for the hint + if let Some(hint_range) = missing_arg_hint_position(&arg_list) { + let colon = if config.render_colons { ":" } else { "" }; + let label = InlayHintLabel::simple( + format!("{}{}", param_name.display(sema.db, krate.edition(sema.db)), colon), + None, + config.lazy_location_opt(|| { + let source = sema.source(next_param.clone())?; + let name_syntax = match source.value.as_ref() { + Either::Left(pat) => pat.name(), + Either::Right(param) => match param.pat()? { + ast::Pat::IdentPat(it) => it.name(), + _ => None, + }, + }?; + sema.original_range_opt(name_syntax.syntax()).map(|frange| { + ide_db::FileRange { + file_id: frange.file_id.file_id(sema.db), + range: frange.range, + } + }) + }), + ); + acc.push(InlayHint { + range: hint_range, + kind: InlayKind::Parameter, + label, + text_edit: None, + position: InlayHintPosition::Before, + pad_left: true, + pad_right: false, + resolve_parent: Some(expr.syntax().text_range()), + }); + } + } + } + Some(()) } +/// Determines the position where the hint for a missing argument should be placed. +/// Returns the range of the token where the hint should appear. +fn missing_arg_hint_position(arg_list: &ast::ArgList) -> Option { + // Always place the hint on the closing paren, so it appears before `)`. + // This way `foo()` becomes `foo(a)` visually with the hint. + arg_list + .syntax() + .children_with_tokens() + .filter_map(|it| it.into_token()) + .find(|t| t.kind() == T![')']) + .map(|t| t.text_range()) +} + fn get_callable<'db>( sema: &Semantics<'db, RootDatabase>, expr: &ast::Expr, @@ -153,6 +220,37 @@ fn should_hide_param_name_hint( is_argument_expr_similar_to_param_name(sema, argument, param_name) } +/// Determines whether to hide the parameter hint for a missing argument. +/// This is a simplified version of `should_hide_param_name_hint` that doesn't +/// require an actual argument expression. +fn should_hide_missing_param_hint( + unary_function: bool, + function_name: Option<&str>, + param_name: &str, +) -> bool { + let param_name = param_name.trim_matches('_'); + if param_name.is_empty() { + return true; + } + + if param_name.starts_with("ra_fixture") { + return true; + } + + if unary_function { + if let Some(function_name) = function_name + && is_param_name_suffix_of_fn_name(param_name, function_name) + { + return true; + } + if is_obvious_param(param_name) { + return true; + } + } + + false +} + /// Hide the parameter name of a unary function if it is a `_` - prefixed suffix of the function's name, or equal. /// /// `fn strip_suffix(suffix)` will be hidden. @@ -606,6 +704,103 @@ fn main() { // ^^^^^^ a_d_e baz(a.d.ec); // ^^^^^^ a_d_e +}"#, + ); + } + + #[track_caller] + fn check_missing_params(#[rust_analyzer::rust_fixture] ra_fixture: &str) { + check_with_config( + InlayHintsConfig { + parameter_hints: true, + parameter_hints_for_missing_arguments: true, + ..DISABLED_CONFIG + }, + ra_fixture, + ); + } + + #[test] + fn missing_param_hint_empty_call() { + // When calling foo() with no args, show hint for first param on the closing paren + check_missing_params( + r#" +fn foo(a: i32, b: i32) -> i32 { a + b } +fn main() { + foo(); + //^ a +}"#, + ); + } + + #[test] + fn missing_param_hint_after_first_arg() { + // foo(1,) - show hint for 'a' on '1', and 'b' on the trailing comma + check_missing_params( + r#" +fn foo(a: i32, b: i32) -> i32 { a + b } +fn main() { + foo(1,); + //^ a + //^ b +}"#, + ); + } + + #[test] + fn missing_param_hint_partial_args() { + // foo(1, 2,) - show hints for a, b on args, and c on trailing comma + check_missing_params( + r#" +fn foo(a: i32, b: i32, c: i32) -> i32 { a + b + c } +fn main() { + foo(1, 2,); + //^ a + //^ b + //^ c +}"#, + ); + } + + #[test] + fn missing_param_hint_method_call() { + // S.foo(1,) - show hint for 'a' on '1', and 'b' on trailing comma + check_missing_params( + r#" +struct S; +impl S { + fn foo(&self, a: i32, b: i32) -> i32 { a + b } +} +fn main() { + S.foo(1,); + //^ a + //^ b +}"#, + ); + } + + #[test] + fn missing_param_hint_no_hint_when_complete() { + // When all args provided, no missing hint - just regular param hints + check_missing_params( + r#" +fn foo(a: i32, b: i32) -> i32 { a + b } +fn main() { + foo(1, 2); + //^ a + //^ b +}"#, + ); + } + + #[test] + fn missing_param_hint_respects_heuristics() { + // The hint should be hidden if it matches heuristics (e.g., single param unary fn with same name) + check_missing_params( + r#" +fn foo(foo: i32) -> i32 { foo } +fn main() { + foo(); }"#, ); } diff --git a/src/tools/rust-analyzer/crates/ide/src/static_index.rs b/src/tools/rust-analyzer/crates/ide/src/static_index.rs index 30e8d62ea210..e87766376acb 100644 --- a/src/tools/rust-analyzer/crates/ide/src/static_index.rs +++ b/src/tools/rust-analyzer/crates/ide/src/static_index.rs @@ -169,6 +169,7 @@ impl StaticIndex<'_> { type_hints: true, sized_bound: false, parameter_hints: true, + parameter_hints_for_missing_arguments: false, generic_parameter_hints: crate::GenericParameterHints { type_hints: false, lifetime_hints: false, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs index f39ab1301f8f..1a6cd784cf2f 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -1205,6 +1205,7 @@ impl flags::AnalysisStats { sized_bound: false, discriminant_hints: ide::DiscriminantHints::Always, parameter_hints: true, + parameter_hints_for_missing_arguments: false, generic_parameter_hints: ide::GenericParameterHints { type_hints: true, lifetime_hints: true, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 1a2ea97204aa..007725be7406 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -280,6 +280,9 @@ config_data! { /// Show function parameter name inlay hints at the call site. inlayHints_parameterHints_enable: bool = true, + /// Show parameter name inlay hints for missing arguments at the call site. + inlayHints_parameterHints_missingArguments_enable: bool = false, + /// Show exclusive range inlay hints. inlayHints_rangeExclusiveHints_enable: bool = false, @@ -1916,6 +1919,9 @@ impl Config { type_hints: self.inlayHints_typeHints_enable().to_owned(), sized_bound: self.inlayHints_implicitSizedBoundHints_enable().to_owned(), parameter_hints: self.inlayHints_parameterHints_enable().to_owned(), + parameter_hints_for_missing_arguments: self + .inlayHints_parameterHints_missingArguments_enable() + .to_owned(), generic_parameter_hints: GenericParameterHints { type_hints: self.inlayHints_genericParameterHints_type_enable().to_owned(), lifetime_hints: self.inlayHints_genericParameterHints_lifetime_enable().to_owned(), diff --git a/src/tools/rust-analyzer/docs/book/src/configuration_generated.md b/src/tools/rust-analyzer/docs/book/src/configuration_generated.md index b36576b4bb20..1f5c672233ae 100644 --- a/src/tools/rust-analyzer/docs/book/src/configuration_generated.md +++ b/src/tools/rust-analyzer/docs/book/src/configuration_generated.md @@ -1070,6 +1070,13 @@ Default: `true` Show function parameter name inlay hints at the call site. +## rust-analyzer.inlayHints.parameterHints.missingArguments.enable {#inlayHints.parameterHints.missingArguments.enable} + +Default: `false` + +Show parameter name inlay hints for missing arguments at the call site. + + ## rust-analyzer.inlayHints.rangeExclusiveHints.enable {#inlayHints.rangeExclusiveHints.enable} Default: `false` diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index abe85d6c9d72..98fe6a558b80 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -2396,6 +2396,16 @@ } } }, + { + "title": "Inlay Hints", + "properties": { + "rust-analyzer.inlayHints.parameterHints.missingArguments.enable": { + "markdownDescription": "Show parameter name inlay hints for missing arguments at the call site.", + "default": false, + "type": "boolean" + } + } + }, { "title": "Inlay Hints", "properties": { From 69db81658ef2f4c54e85c3b5510bbcdb92961b5a Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Wed, 10 Dec 2025 15:08:41 +0000 Subject: [PATCH 103/489] Move `collapsible_else_if` to `pedantic` --- clippy_lints/src/collapsible_if.rs | 2 +- .../collapsible_if/collapsible_else_if.fixed | 2 +- .../collapsible_if/collapsible_else_if.rs | 2 +- tests/ui/collapsible_else_if.fixed | 22 ++----------------- tests/ui/collapsible_else_if.rs | 22 ++----------------- tests/ui/collapsible_else_if.stderr | 2 +- 6 files changed, 8 insertions(+), 44 deletions(-) diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index b13e307a3f9c..0efcb3c77ff6 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -76,7 +76,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.51.0"] pub COLLAPSIBLE_ELSE_IF, - style, + pedantic, "nested `else`-`if` expressions that can be collapsed (e.g., `else { if x { ... } }`)" } diff --git a/tests/ui-toml/collapsible_if/collapsible_else_if.fixed b/tests/ui-toml/collapsible_if/collapsible_else_if.fixed index ec45dfd2033a..213b56b786b1 100644 --- a/tests/ui-toml/collapsible_if/collapsible_else_if.fixed +++ b/tests/ui-toml/collapsible_if/collapsible_else_if.fixed @@ -1,5 +1,5 @@ #![allow(clippy::eq_op, clippy::nonminimal_bool)] -#![warn(clippy::collapsible_if)] +#![warn(clippy::collapsible_else_if)] #[rustfmt::skip] fn main() { diff --git a/tests/ui-toml/collapsible_if/collapsible_else_if.rs b/tests/ui-toml/collapsible_if/collapsible_else_if.rs index 54315a3c32bf..2d4c2c54031e 100644 --- a/tests/ui-toml/collapsible_if/collapsible_else_if.rs +++ b/tests/ui-toml/collapsible_if/collapsible_else_if.rs @@ -1,5 +1,5 @@ #![allow(clippy::eq_op, clippy::nonminimal_bool)] -#![warn(clippy::collapsible_if)] +#![warn(clippy::collapsible_else_if)] #[rustfmt::skip] fn main() { diff --git a/tests/ui/collapsible_else_if.fixed b/tests/ui/collapsible_else_if.fixed index e7439beef186..d85bbf189075 100644 --- a/tests/ui/collapsible_else_if.fixed +++ b/tests/ui/collapsible_else_if.fixed @@ -1,5 +1,5 @@ #![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_ifs)] -#![warn(clippy::collapsible_if, clippy::collapsible_else_if)] +#![warn(clippy::collapsible_else_if)] #[rustfmt::skip] fn main() { @@ -88,30 +88,12 @@ fn issue_7318() { } fn issue_13365() { - // all the `expect`s that we should fulfill + // ensure we fulfill `#[expect]` if true { } else { #[expect(clippy::collapsible_else_if)] if false {} } - - if true { - } else { - #[expect(clippy::style)] - if false {} - } - - if true { - } else { - #[expect(clippy::all)] - if false {} - } - - if true { - } else { - #[expect(warnings)] - if false {} - } } fn issue14799() { diff --git a/tests/ui/collapsible_else_if.rs b/tests/ui/collapsible_else_if.rs index 434ba3654f98..10aef2792adb 100644 --- a/tests/ui/collapsible_else_if.rs +++ b/tests/ui/collapsible_else_if.rs @@ -1,5 +1,5 @@ #![allow(clippy::assertions_on_constants, clippy::equatable_if_let, clippy::needless_ifs)] -#![warn(clippy::collapsible_if, clippy::collapsible_else_if)] +#![warn(clippy::collapsible_else_if)] #[rustfmt::skip] fn main() { @@ -104,30 +104,12 @@ fn issue_7318() { } fn issue_13365() { - // all the `expect`s that we should fulfill + // ensure we fulfill `#[expect]` if true { } else { #[expect(clippy::collapsible_else_if)] if false {} } - - if true { - } else { - #[expect(clippy::style)] - if false {} - } - - if true { - } else { - #[expect(clippy::all)] - if false {} - } - - if true { - } else { - #[expect(warnings)] - if false {} - } } fn issue14799() { diff --git a/tests/ui/collapsible_else_if.stderr b/tests/ui/collapsible_else_if.stderr index ce1da593a8e9..98109099bae6 100644 --- a/tests/ui/collapsible_else_if.stderr +++ b/tests/ui/collapsible_else_if.stderr @@ -151,7 +151,7 @@ LL | | } | |_____^ help: collapse nested if block: `if false {}` error: this `else { if .. }` block can be collapsed - --> tests/ui/collapsible_else_if.rs:157:12 + --> tests/ui/collapsible_else_if.rs:139:12 | LL | } else { | ____________^ From 29ad85c116b40f8c72305074d52087831af02485 Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Fri, 31 Oct 2025 15:36:41 +0100 Subject: [PATCH 104/489] Do not propogate unnecessary closure constraints + tests. --- .../rustc_borrowck/src/region_infer/mod.rs | 20 ++++++++++++++ .../closure-prop-issue-104477-case1.rs | 14 ++++++++++ tests/ui/regions/closure-prop-issue-148289.rs | 26 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/ui/regions/closure-prop-issue-104477-case1.rs create mode 100644 tests/ui/regions/closure-prop-issue-148289.rs diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index e98c60e63380..61a6d6d5b79d 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1292,6 +1292,26 @@ impl<'tcx> RegionInferenceContext<'tcx> { // so slightly larger than `shorter_fr`. let shorter_fr_plus = self.universal_region_relations.non_local_upper_bounds(shorter_fr); + + // If any of the `shorter_fr+` regions are already outlived by `fr-`, we propagate only those. + // Otherwise, we might incorrectly reject valid code. + // + // Consider this example (`'b: 'a` == `a -> b`), where we try to propagate `'d: 'a`: + // a --> b --> d + // \ + // \-> c + // Here, `shorter_fr+` of `'a` == `['b, 'c]`. + // Propagating `'d: 'b` is correct and should occur; `'d: 'c` is redundant because of `'d: 'b` + // and could reject valid code. + // + // So we filter `shorter_fr+` to regions already outlived by `fr-`, but if the filter yields an empty set, + // we fall back to the original one. + let subset: Vec<_> = shorter_fr_plus + .iter() + .filter(|&&fr_plus| self.eval_outlives(fr_minus, fr_plus)) + .copied() + .collect(); + let shorter_fr_plus = if subset.is_empty() { shorter_fr_plus } else { subset }; debug!("try_propagate_universal_region_error: shorter_fr_plus={:?}", shorter_fr_plus); for fr in shorter_fr_plus { // Push the constraint `fr-: shorter_fr+` diff --git a/tests/ui/regions/closure-prop-issue-104477-case1.rs b/tests/ui/regions/closure-prop-issue-104477-case1.rs new file mode 100644 index 000000000000..307ca930baea --- /dev/null +++ b/tests/ui/regions/closure-prop-issue-104477-case1.rs @@ -0,0 +1,14 @@ +//@ check-pass +// This checks that the compiler does not require that 'a: 'b. '_ has 'a and 'b as non-local +// upper bounds, but the compiler should not propagate 'a: 'b OR 'b: 'a when checking +// the closures. If it did, this would fail to compile, eventhough it's a valid program. +// PR #148329 explains this in detail. + +struct MyTy<'x, 'a, 'b>(std::cell::Cell<(&'x &'a u8, &'x &'b u8)>); +fn wf(_: T) {} +fn test<'a, 'b>() { + |_: &'a u8, x: MyTy<'_, 'a, 'b>| wf(x); + |x: MyTy<'_, 'a, 'b>, _: &'a u8| wf(x); +} + +fn main(){} diff --git a/tests/ui/regions/closure-prop-issue-148289.rs b/tests/ui/regions/closure-prop-issue-148289.rs new file mode 100644 index 000000000000..7f89927a76e0 --- /dev/null +++ b/tests/ui/regions/closure-prop-issue-148289.rs @@ -0,0 +1,26 @@ +//@ check-pass +// This test checks that the compiler does not propagate 'd: 'c when propagating region errors +// for the closure argument. If it did, this would fail to compile, eventhough it's a valid program. +// It should only propagate 'd: 'b. +// PR #148329 explains this in detail. + +#[derive(Clone, Copy)] +struct Inv<'a>(*mut &'a ()); +impl<'a> Inv<'a> { + fn outlived_by<'b: 'a>(self, _: Inv<'b>) {} +} +struct OutlivedBy<'a, 'b: 'a>(Inv<'a>, Inv<'b>); + +fn closure_arg<'b, 'c, 'd>( + _: impl for<'a> FnOnce(Inv<'a>, OutlivedBy<'a, 'b>, OutlivedBy<'a, 'c>, Inv<'d>), +) { +} +fn foo<'b, 'c, 'd: 'b>() { + closure_arg::<'b, 'c, 'd>(|a, b, c, d| { + a.outlived_by(b.1); + a.outlived_by(c.1); + b.1.outlived_by(d); + }); +} + +fn main() {} From 0627df9151ec49426de114873309521c89f95da7 Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Tue, 11 Nov 2025 22:16:13 +0100 Subject: [PATCH 105/489] Propagate region error for every non-local lower bound --- .../rustc_borrowck/src/region_infer/mod.rs | 76 ++++++++++++------ .../src/type_check/free_region_relations.rs | 24 +----- ...opagate-approximated-both-lower-bounds.rs} | 14 ++-- ...gate-approximated-both-lower-bounds.stderr | 79 +++++++++++++++++++ ...pagate-approximated-fail-no-postdom.stderr | 42 ---------- .../closure-prop-issue-104477-case2.rs | 12 +++ 6 files changed, 155 insertions(+), 92 deletions(-) rename tests/ui/nll/closure-requirements/{propagate-approximated-fail-no-postdom.rs => propagate-approximated-both-lower-bounds.rs} (66%) create mode 100644 tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr delete mode 100644 tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr create mode 100644 tests/ui/regions/closure-prop-issue-104477-case2.rs diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 61a6d6d5b79d..2fec58ef3bc4 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1275,49 +1275,81 @@ impl<'tcx> RegionInferenceContext<'tcx> { shorter_fr: RegionVid, propagated_outlives_requirements: &mut Option<&mut Vec>>, ) -> RegionRelationCheckResult { - if let Some(propagated_outlives_requirements) = propagated_outlives_requirements - // Shrink `longer_fr` until we find a non-local region (if we do). - // We'll call it `fr-` -- it's ever so slightly smaller than + if let Some(propagated_outlives_requirements) = propagated_outlives_requirements { + // Shrink `longer_fr` until we find some non-local regions. + // We'll call them `longer_fr-` -- they are ever so slightly smaller than // `longer_fr`. - && let Some(fr_minus) = self.universal_region_relations.non_local_lower_bound(longer_fr) - { - debug!("try_propagate_universal_region_error: fr_minus={:?}", fr_minus); + let longer_fr_minus = self.universal_region_relations.non_local_lower_bounds(longer_fr); + + debug!("try_propagate_universal_region_error: fr_minus={:?}", longer_fr_minus); + + // If we don't find a any non-local regions, we should error out as there is nothing + // to propagate. + if longer_fr_minus.is_empty() { + return RegionRelationCheckResult::Error; + } let blame_constraint = self .best_blame_constraint(longer_fr, NllRegionVariableOrigin::FreeRegion, shorter_fr) .0; - // Grow `shorter_fr` until we find some non-local regions. (We - // always will.) We'll call them `shorter_fr+` -- they're ever - // so slightly larger than `shorter_fr`. + // Grow `shorter_fr` until we find some non-local regions. + // We will always find at least one: `'static`. We'll call + // them `shorter_fr+` -- they're ever so slightly larger + // than `shorter_fr`. let shorter_fr_plus = self.universal_region_relations.non_local_upper_bounds(shorter_fr); + debug!("try_propagate_universal_region_error: shorter_fr_plus={:?}", shorter_fr_plus); - // If any of the `shorter_fr+` regions are already outlived by `fr-`, we propagate only those. - // Otherwise, we might incorrectly reject valid code. + // We then create constraints `longer_fr-: shorter_fr+` that may or may not + // be propagated (see below). + let mut constraints = vec![]; + for fr_minus in longer_fr_minus { + for shorter_fr_plus in &shorter_fr_plus { + constraints.push((fr_minus, *shorter_fr_plus)); + } + } + + // We only need to propagate at least one of the constraints for + // soundness. However, we want to avoid arbitrary choices here + // and currently don't support returning OR constraints. + // + // If any of the `shorter_fr+` regions are already outlived by `longer_fr-`, + // we propagate only those. // // Consider this example (`'b: 'a` == `a -> b`), where we try to propagate `'d: 'a`: // a --> b --> d // \ // \-> c // Here, `shorter_fr+` of `'a` == `['b, 'c]`. - // Propagating `'d: 'b` is correct and should occur; `'d: 'c` is redundant because of `'d: 'b` - // and could reject valid code. + // Propagating `'d: 'b` is correct and should occur; `'d: 'c` is redundant because of + // `'d: 'b` and could reject valid code. // - // So we filter `shorter_fr+` to regions already outlived by `fr-`, but if the filter yields an empty set, - // we fall back to the original one. - let subset: Vec<_> = shorter_fr_plus + // So we filter the constraints to regions already outlived by `longer_fr-`, but if + // the filter yields an empty set, we fall back to the original one. + let subset: Vec<_> = constraints .iter() - .filter(|&&fr_plus| self.eval_outlives(fr_minus, fr_plus)) + .filter(|&&(fr_minus, shorter_fr_plus)| { + self.eval_outlives(fr_minus, shorter_fr_plus) + }) .copied() .collect(); - let shorter_fr_plus = if subset.is_empty() { shorter_fr_plus } else { subset }; - debug!("try_propagate_universal_region_error: shorter_fr_plus={:?}", shorter_fr_plus); - for fr in shorter_fr_plus { - // Push the constraint `fr-: shorter_fr+` + let propagated_constraints = if subset.is_empty() { constraints } else { subset }; + debug!( + "try_propagate_universal_region_error: constraints={:?}", + propagated_constraints + ); + + assert!( + !propagated_constraints.is_empty(), + "Expected at least one constraint to propagate here" + ); + + for (fr_minus, fr_plus) in propagated_constraints { + // Push the constraint `long_fr-: shorter_fr+` propagated_outlives_requirements.push(ClosureOutlivesRequirement { subject: ClosureOutlivesSubject::Region(fr_minus), - outlived_free_region: fr, + outlived_free_region: fr_plus, blame_span: blame_constraint.cause.span, category: blame_constraint.category, }); diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index d27a73535bab..279625cb87c9 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -94,28 +94,10 @@ impl UniversalRegionRelations<'_> { /// words, returns the largest (*) known region `fr1` that (a) is /// outlived by `fr` and (b) is not local. /// - /// (*) If there are multiple competing choices, we pick the "postdominating" - /// one. See `TransitiveRelation::postdom_upper_bound` for details. - pub(crate) fn non_local_lower_bound(&self, fr: RegionVid) -> Option { + /// (*) If there are multiple competing choices, we return all of them. + pub(crate) fn non_local_lower_bounds(&self, fr: RegionVid) -> Vec { debug!("non_local_lower_bound(fr={:?})", fr); - let lower_bounds = self.non_local_bounds(&self.outlives, fr); - - // In case we find more than one, reduce to one for - // convenience. This is to prevent us from generating more - // complex constraints, but it will cause spurious errors. - let post_dom = self.outlives.mutual_immediate_postdominator(lower_bounds); - - debug!("non_local_bound: post_dom={:?}", post_dom); - - post_dom.and_then(|post_dom| { - // If the mutual immediate postdom is not local, then - // there is no non-local result we can return. - if !self.universal_regions.is_local_free_region(post_dom) { - Some(post_dom) - } else { - None - } - }) + self.non_local_bounds(&self.outlives, fr) } /// Helper for `non_local_upper_bounds` and `non_local_lower_bounds`. diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs b/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.rs similarity index 66% rename from tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs rename to tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.rs index 5d21fa100a43..addfc7b91391 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.rs @@ -1,6 +1,5 @@ -// Test where we fail to approximate due to demanding a postdom -// relationship between our upper bounds. - +// Test that we can propagate multiple region errors for closure constraints +// where the longer region has multiple non-local lower bounds without any postdominating one. //@ compile-flags:-Zverbose-internals #![feature(rustc_attrs)] @@ -13,9 +12,8 @@ use std::cell::Cell; // 'x: 'b // 'c: 'y // -// we have to prove that `'x: 'y`. We currently can only approximate -// via a postdominator -- hence we fail to choose between `'a` and -// `'b` here and report the error in the closure. +// we have to prove that `'x: 'y`. We find non-local lower bounds of 'x to be 'a and 'b and +// non-local upper bound of 'y to be 'c. So we propagate `'b: 'c` and `'a: 'c`. fn establish_relationships<'a, 'b, 'c, F>( _cell_a: Cell<&'a u32>, _cell_b: Cell<&'b u32>, @@ -36,6 +34,8 @@ fn demand_y<'x, 'y>(_cell_x: Cell<&'x u32>, _cell_y: Cell<&'y u32>, _y: &'y u32) #[rustc_regions] fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { + //~vv ERROR lifetime may not live long enough + //~v ERROR lifetime may not live long enough establish_relationships( cell_a, cell_b, @@ -43,7 +43,7 @@ fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell |_outlives1, _outlives2, _outlives3, x, y| { // Only works if 'x: 'y: let p = x.get(); - demand_y(x, y, p) //~ ERROR + demand_y(x, y, p) }, ); } diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr new file mode 100644 index 000000000000..af7ea253cc52 --- /dev/null +++ b/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr @@ -0,0 +1,79 @@ +note: external requirements + --> $DIR/propagate-approximated-both-lower-bounds.rs:43:9 + | +LL | |_outlives1, _outlives2, _outlives3, x, y| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: defining type: supply::{closure#0} with closure args [ + i16, + for extern "rust-call" fn((std::cell::Cell<&'?1 &'^0 u32>, std::cell::Cell<&'?2 &'^0 u32>, std::cell::Cell<&'^1 &'?3 u32>, std::cell::Cell<&'^0 u32>, std::cell::Cell<&'^1 u32>)), + (), + ] + = note: late-bound region is '?7 + = note: late-bound region is '?8 + = note: late-bound region is '?4 + = note: late-bound region is '?5 + = note: late-bound region is '?6 + = note: number of external vids: 7 + = note: where '?2: '?3 + = note: where '?1: '?3 + +note: no external requirements + --> $DIR/propagate-approximated-both-lower-bounds.rs:36:1 + | +LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: defining type: supply + +error: lifetime may not live long enough + --> $DIR/propagate-approximated-both-lower-bounds.rs:39:5 + | +LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { + | -- -- lifetime `'c` defined here + | | + | lifetime `'a` defined here +... +LL | / establish_relationships( +LL | | cell_a, +LL | | cell_b, +LL | | cell_c, +... | +LL | | }, +LL | | ); + | |_____^ argument requires that `'a` must outlive `'c` + | + = help: consider adding the following bound: `'a: 'c` + = note: requirement occurs because of the type `Cell<&'?10 u32>`, which makes the generic argument `&'?10 u32` invariant + = note: the struct `Cell` is invariant over the parameter `T` + = help: see for more information about variance + +error: lifetime may not live long enough + --> $DIR/propagate-approximated-both-lower-bounds.rs:39:5 + | +LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { + | -- -- lifetime `'c` defined here + | | + | lifetime `'b` defined here +... +LL | / establish_relationships( +LL | | cell_a, +LL | | cell_b, +LL | | cell_c, +... | +LL | | }, +LL | | ); + | |_____^ argument requires that `'b` must outlive `'c` + | + = help: consider adding the following bound: `'b: 'c` + = note: requirement occurs because of the type `Cell<&'?10 u32>`, which makes the generic argument `&'?10 u32` invariant + = note: the struct `Cell` is invariant over the parameter `T` + = help: see for more information about variance + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'c` + = help: add bound `'b: 'c` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr deleted file mode 100644 index 134ce99014d8..000000000000 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ /dev/null @@ -1,42 +0,0 @@ -note: no external requirements - --> $DIR/propagate-approximated-fail-no-postdom.rs:43:9 - | -LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: defining type: supply::{closure#0} with closure args [ - i16, - for extern "rust-call" fn((std::cell::Cell<&'?1 &'^0 u32>, std::cell::Cell<&'?2 &'^0 u32>, std::cell::Cell<&'^1 &'?3 u32>, std::cell::Cell<&'^0 u32>, std::cell::Cell<&'^1 u32>)), - (), - ] - = note: late-bound region is '?7 - = note: late-bound region is '?8 - = note: late-bound region is '?4 - = note: late-bound region is '?5 - = note: late-bound region is '?6 - -error: lifetime may not live long enough - --> $DIR/propagate-approximated-fail-no-postdom.rs:46:13 - | -LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ---------- ---------- has type `Cell<&'2 &'?3 u32>` - | | - | has type `Cell<&'?1 &'1 u32>` -... -LL | demand_y(x, y, p) - | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - | - = note: requirement occurs because of the type `Cell<&'?34 u32>`, which makes the generic argument `&'?34 u32` invariant - = note: the struct `Cell` is invariant over the parameter `T` - = help: see for more information about variance - -note: no external requirements - --> $DIR/propagate-approximated-fail-no-postdom.rs:38:1 - | -LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: defining type: supply - -error: aborting due to 1 previous error - diff --git a/tests/ui/regions/closure-prop-issue-104477-case2.rs b/tests/ui/regions/closure-prop-issue-104477-case2.rs new file mode 100644 index 000000000000..a77a11d0eceb --- /dev/null +++ b/tests/ui/regions/closure-prop-issue-104477-case2.rs @@ -0,0 +1,12 @@ +//@ check-pass +// This test checks that the compiler propagates outlives requirements for both +// non-local lower bounds ['a, 'b] of '_, instead of conservatively finding a post-dominiting one +// from those 2. + +struct MyTy<'a, 'b, 'x>(std::cell::Cell<(&'a &'x str, &'b &'x str)>); +fn wf(_: T) {} +fn test<'a, 'b, 'x>() { + |x: MyTy<'a, 'b, '_>| wf(x); +} + +fn main() {} From dc0bf26dd4aa7641644204a3cd9b42d20017582c Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sun, 2 Nov 2025 23:28:02 +0000 Subject: [PATCH 106/489] fix: `match_like_matches_macro` wrongly unmangled macros --- .../src/matches/match_like_matches.rs | 18 +++--- tests/ui/match_like_matches_macro.fixed | 22 +++++++ tests/ui/match_like_matches_macro.rs | 25 ++++++++ tests/ui/match_like_matches_macro.stderr | 62 ++++++++++++++----- 4 files changed, 100 insertions(+), 27 deletions(-) diff --git a/clippy_lints/src/matches/match_like_matches.rs b/clippy_lints/src/matches/match_like_matches.rs index 89411115f730..c26b2dbde7fc 100644 --- a/clippy_lints/src/matches/match_like_matches.rs +++ b/clippy_lints/src/matches/match_like_matches.rs @@ -3,7 +3,7 @@ use super::REDUNDANT_PATTERN_MATCHING; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::higher::has_let_expr; -use clippy_utils::source::snippet_with_applicability; +use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::{is_lint_allowed, is_wild, span_contains_comment}; use rustc_ast::LitKind; use rustc_errors::Applicability; @@ -44,6 +44,8 @@ pub(crate) fn check_if_let<'tcx>( { ex_new = ex_inner; } + + let (snippet, _) = snippet_with_context(cx, ex_new.span, expr.span.ctxt(), "..", &mut applicability); span_lint_and_then( cx, MATCH_LIKE_MATCHES_MACRO, @@ -53,11 +55,7 @@ pub(crate) fn check_if_let<'tcx>( diag.span_suggestion_verbose( expr.span, "use `matches!` directly", - format!( - "{}matches!({}, {pat})", - if b0 { "" } else { "!" }, - snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), - ), + format!("{}matches!({snippet}, {pat})", if b0 { "" } else { "!" }), applicability, ); }, @@ -178,6 +176,8 @@ pub(super) fn check_match<'tcx>( { ex_new = ex_inner; } + + let (snippet, _) = snippet_with_context(cx, ex_new.span, e.span.ctxt(), "..", &mut applicability); span_lint_and_then( cx, MATCH_LIKE_MATCHES_MACRO, @@ -187,11 +187,7 @@ pub(super) fn check_match<'tcx>( diag.span_suggestion_verbose( e.span, "use `matches!` directly", - format!( - "{}matches!({}, {pat_and_guard})", - if b0 { "" } else { "!" }, - snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), - ), + format!("{}matches!({snippet}, {pat_and_guard})", if b0 { "" } else { "!" },), applicability, ); }, diff --git a/tests/ui/match_like_matches_macro.fixed b/tests/ui/match_like_matches_macro.fixed index dad59c1ce6e4..045ee32bd8bb 100644 --- a/tests/ui/match_like_matches_macro.fixed +++ b/tests/ui/match_like_matches_macro.fixed @@ -1,6 +1,7 @@ #![warn(clippy::match_like_matches_macro)] #![allow( unreachable_patterns, + irrefutable_let_patterns, clippy::equatable_if_let, clippy::needless_borrowed_reference, clippy::redundant_guards @@ -230,3 +231,24 @@ fn issue15841(opt: Option>>, value: i32) { let _ = matches!(opt, Some(first) if (if let Some(second) = first { true } else { todo!() })); //~^^^^ match_like_matches_macro } + +fn issue16015() -> bool { + use std::any::{TypeId, type_name}; + pub struct GetTypeId(T); + + impl GetTypeId { + pub const VALUE: TypeId = TypeId::of::(); + } + + macro_rules! typeid { + ($t:ty) => { + GetTypeId::<$t>::VALUE + }; + } + + matches!(typeid!(T), _); + //~^^^^ match_like_matches_macro + + matches!(typeid!(U), _) + //~^ match_like_matches_macro +} diff --git a/tests/ui/match_like_matches_macro.rs b/tests/ui/match_like_matches_macro.rs index 94bc6433e5cb..231e1ae98f86 100644 --- a/tests/ui/match_like_matches_macro.rs +++ b/tests/ui/match_like_matches_macro.rs @@ -1,6 +1,7 @@ #![warn(clippy::match_like_matches_macro)] #![allow( unreachable_patterns, + irrefutable_let_patterns, clippy::equatable_if_let, clippy::needless_borrowed_reference, clippy::redundant_guards @@ -277,3 +278,27 @@ fn issue15841(opt: Option>>, value: i32) { }; //~^^^^ match_like_matches_macro } + +fn issue16015() -> bool { + use std::any::{TypeId, type_name}; + pub struct GetTypeId(T); + + impl GetTypeId { + pub const VALUE: TypeId = TypeId::of::(); + } + + macro_rules! typeid { + ($t:ty) => { + GetTypeId::<$t>::VALUE + }; + } + + match typeid!(T) { + _ => true, + _ => false, + }; + //~^^^^ match_like_matches_macro + + if let _ = typeid!(U) { true } else { false } + //~^ match_like_matches_macro +} diff --git a/tests/ui/match_like_matches_macro.stderr b/tests/ui/match_like_matches_macro.stderr index a8e352461dbb..bc3e3584938e 100644 --- a/tests/ui/match_like_matches_macro.stderr +++ b/tests/ui/match_like_matches_macro.stderr @@ -1,5 +1,5 @@ error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:13:14 + --> tests/ui/match_like_matches_macro.rs:14:14 | LL | let _y = match x { | ______________^ @@ -20,7 +20,7 @@ LL + let _y = matches!(x, Some(0)); | error: redundant pattern matching, consider using `is_some()` - --> tests/ui/match_like_matches_macro.rs:20:14 + --> tests/ui/match_like_matches_macro.rs:21:14 | LL | let _w = match x { | ______________^ @@ -33,7 +33,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/match_like_matches_macro.rs:27:14 + --> tests/ui/match_like_matches_macro.rs:28:14 | LL | let _z = match x { | ______________^ @@ -43,7 +43,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:34:15 + --> tests/ui/match_like_matches_macro.rs:35:15 | LL | let _zz = match x { | _______________^ @@ -62,7 +62,7 @@ LL + let _zz = !matches!(x, Some(r) if r == 0); | error: `if let .. else` expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:41:16 + --> tests/ui/match_like_matches_macro.rs:42:16 | LL | let _zzz = if let Some(5) = x { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL + let _zzz = matches!(x, Some(5)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:66:20 + --> tests/ui/match_like_matches_macro.rs:67:20 | LL | let _ans = match x { | ____________________^ @@ -95,7 +95,7 @@ LL + let _ans = matches!(x, E::A(_) | E::B(_)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:77:20 + --> tests/ui/match_like_matches_macro.rs:78:20 | LL | let _ans = match x { | ____________________^ @@ -119,7 +119,7 @@ LL + let _ans = matches!(x, E::A(_) | E::B(_)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:88:20 + --> tests/ui/match_like_matches_macro.rs:89:20 | LL | let _ans = match x { | ____________________^ @@ -140,7 +140,7 @@ LL + let _ans = !matches!(x, E::B(_) | E::C); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:149:18 + --> tests/ui/match_like_matches_macro.rs:150:18 | LL | let _z = match &z { | __________________^ @@ -159,7 +159,7 @@ LL + let _z = matches!(z, Some(3)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:159:18 + --> tests/ui/match_like_matches_macro.rs:160:18 | LL | let _z = match &z { | __________________^ @@ -178,7 +178,7 @@ LL + let _z = matches!(&z, Some(3)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:177:21 + --> tests/ui/match_like_matches_macro.rs:178:21 | LL | let _ = match &z { | _____________________^ @@ -197,7 +197,7 @@ LL + let _ = matches!(&z, AnEnum::X); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:192:20 + --> tests/ui/match_like_matches_macro.rs:193:20 | LL | let _res = match &val { | ____________________^ @@ -216,7 +216,7 @@ LL + let _res = matches!(&val, &Some(ref _a)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:205:20 + --> tests/ui/match_like_matches_macro.rs:206:20 | LL | let _res = match &val { | ____________________^ @@ -235,7 +235,7 @@ LL + let _res = matches!(&val, &Some(ref _a)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:264:14 + --> tests/ui/match_like_matches_macro.rs:265:14 | LL | let _y = match Some(5) { | ______________^ @@ -254,7 +254,7 @@ LL + let _y = matches!(Some(5), Some(0)); | error: match expression looks like `matches!` macro - --> tests/ui/match_like_matches_macro.rs:274:13 + --> tests/ui/match_like_matches_macro.rs:275:13 | LL | let _ = match opt { | _____________^ @@ -272,5 +272,35 @@ LL - }; LL + let _ = matches!(opt, Some(first) if (if let Some(second) = first { true } else { todo!() })); | -error: aborting due to 15 previous errors +error: match expression looks like `matches!` macro + --> tests/ui/match_like_matches_macro.rs:296:5 + | +LL | / match typeid!(T) { +LL | | _ => true, +LL | | _ => false, +LL | | }; + | |_____^ + | +help: use `matches!` directly + | +LL - match typeid!(T) { +LL - _ => true, +LL - _ => false, +LL - }; +LL + matches!(typeid!(T), _); + | + +error: `if let .. else` expression looks like `matches!` macro + --> tests/ui/match_like_matches_macro.rs:302:5 + | +LL | if let _ = typeid!(U) { true } else { false } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `matches!` directly + | +LL - if let _ = typeid!(U) { true } else { false } +LL + matches!(typeid!(U), _) + | + +error: aborting due to 17 previous errors From 4ce7628869af3def2902a55b0c682d56d498c7f3 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Thu, 27 Nov 2025 21:19:53 +0100 Subject: [PATCH 107/489] clean-up --- clippy_utils/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index ed164fcf371b..10220a3da180 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -2490,7 +2490,7 @@ pub enum DefinedTy<'tcx> { /// in the context of its definition site. We also track the `def_id` of its /// definition site. /// - /// WARNING: As the `ty` in in the scope of the definition, not of the function + /// WARNING: As the `ty` is in the scope of the definition, not of the function /// using it, you must be very careful with how you use it. Using it in the wrong /// scope easily results in ICEs. Mir { @@ -2719,7 +2719,6 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &Expr<'tcx>) -> ExprUseCtx moved_before_use, same_ctxt, }, - Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow"), None => ExprUseCtxt { node: Node::Crate(cx.tcx.hir_root_module()), child_id: HirId::INVALID, From 932c939c9fa2c72c313172be4ea18b1fb1afcc7a Mon Sep 17 00:00:00 2001 From: Jamie Hill-Daniel Date: Wed, 10 Dec 2025 23:41:19 +0000 Subject: [PATCH 108/489] Remove uses of `cfg(any()/all())` --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index a0bee4e18214..ac5b3c240785 100644 --- a/src/base.rs +++ b/src/base.rs @@ -167,7 +167,7 @@ pub(crate) fn compile_fn( context.clear(); context.func = codegened_func.func; - #[cfg(any())] // This is never true + #[cfg(false)] let _clif_guard = { use std::fmt::Write; From 254e0cb3bcb48d07914ddb5f94449278f0ef0382 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Thu, 20 Nov 2025 19:06:00 +0100 Subject: [PATCH 109/489] feat(unnecessary_fold): lint on `fold`s with `Add::add`/`Mul::mul` --- clippy_lints/src/methods/unnecessary_fold.rs | 179 +++++++++++-------- tests/ui/unnecessary_fold.fixed | 85 +++++++++ tests/ui/unnecessary_fold.rs | 85 +++++++++ tests/ui/unnecessary_fold.stderr | 130 ++++++++++++-- 4 files changed, 384 insertions(+), 95 deletions(-) diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index bd471e0b18e3..9dae6fbb48dd 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -1,44 +1,52 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::res::{MaybeDef, MaybeResPath, MaybeTypeckRes}; +use clippy_utils::res::{MaybeDef, MaybeQPath, MaybeResPath, MaybeTypeckRes}; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::{peel_blocks, strip_pat_refs}; +use clippy_utils::{DefinedTy, ExprUseNode, expr_use_ctxt, peel_blocks, strip_pat_refs}; use rustc_ast::ast; use rustc_data_structures::packed::Pu128; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::PatKind; +use rustc_hir::def::{DefKind, Res}; use rustc_lint::LateContext; -use rustc_middle::ty; -use rustc_span::{Span, sym}; +use rustc_middle::ty::{self, Ty}; +use rustc_span::{Span, Symbol, sym}; use super::UNNECESSARY_FOLD; /// Do we need to suggest turbofish when suggesting a replacement method? /// Changing `fold` to `sum` needs it sometimes when the return type can't be /// inferred. This checks for some common cases where it can be safely omitted -fn needs_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { - let parent = cx.tcx.parent_hir_node(expr.hir_id); - - // some common cases where turbofish isn't needed: - // - assigned to a local variable with a type annotation - if let hir::Node::LetStmt(local) = parent - && local.ty.is_some() +fn needs_turbofish<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'tcx>) -> bool { + let use_cx = expr_use_ctxt(cx, expr); + if use_cx.same_ctxt + && let use_node = use_cx.use_node(cx) + && let Some(ty) = use_node.defined_ty(cx) { - return false; - } + // some common cases where turbofish isn't needed: + match (use_node, ty) { + // - assigned to a local variable with a type annotation + (ExprUseNode::LetStmt(_), _) => return false, - // - part of a function call argument, can be inferred from the function signature (provided that - // the parameter is not a generic type parameter) - if let hir::Node::Expr(parent_expr) = parent - && let hir::ExprKind::Call(recv, args) = parent_expr.kind - && let hir::ExprKind::Path(ref qpath) = recv.kind - && let Some(fn_def_id) = cx.qpath_res(qpath, recv.hir_id).opt_def_id() - && let fn_sig = cx.tcx.fn_sig(fn_def_id).skip_binder().skip_binder() - && let Some(arg_pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id) - && let Some(ty) = fn_sig.inputs().get(arg_pos) - && !matches!(ty.kind(), ty::Param(_)) - { - return false; + // - part of a function call argument, can be inferred from the function signature (provided that the + // parameter is not a generic type parameter) + (ExprUseNode::FnArg(..), DefinedTy::Mir { ty: arg_ty, .. }) + if !matches!(arg_ty.skip_binder().kind(), ty::Param(_)) => + { + return false; + }, + + // - the final expression in the body of a function with a simple return type + (ExprUseNode::Return(_), DefinedTy::Mir { ty: fn_return_ty, .. }) + if !fn_return_ty + .skip_binder() + .walk() + .any(|generic| generic.as_type().is_some_and(Ty::is_impl_trait)) => + { + return false; + }, + _ => {}, + } } // if it's neither of those, stay on the safe side and suggest turbofish, @@ -60,7 +68,7 @@ fn check_fold_with_op( fold_span: Span, op: hir::BinOpKind, replacement: Replacement, -) { +) -> bool { if let hir::ExprKind::Closure(&hir::Closure { body, .. }) = acc.kind // Extract the body of the closure passed to fold && let closure_body = cx.tcx.hir_body(body) @@ -93,7 +101,7 @@ fn check_fold_with_op( r = snippet_with_applicability(cx, right_expr.span, "EXPR", &mut applicability), ) } else { - format!("{method}{turbofish}()", method = replacement.method_name,) + format!("{method}{turbofish}()", method = replacement.method_name) }; span_lint_and_sugg( @@ -105,12 +113,47 @@ fn check_fold_with_op( sugg, applicability, ); + return true; + } + false +} + +fn check_fold_with_method( + cx: &LateContext<'_>, + expr: &hir::Expr<'_>, + acc: &hir::Expr<'_>, + fold_span: Span, + method: Symbol, + replacement: Replacement, +) { + // Extract the name of the function passed to `fold` + if let Res::Def(DefKind::AssocFn, fn_did) = acc.res_if_named(cx, method) + // Check if the function belongs to the operator + && cx.tcx.is_diagnostic_item(method, fn_did) + { + let applicability = Applicability::MachineApplicable; + + let turbofish = if replacement.has_generic_return { + format!("::<{}>", cx.typeck_results().expr_ty(expr)) + } else { + String::new() + }; + + span_lint_and_sugg( + cx, + UNNECESSARY_FOLD, + fold_span.with_hi(expr.span.hi()), + "this `.fold` can be written more succinctly using another method", + "try", + format!("{method}{turbofish}()", method = replacement.method_name), + applicability, + ); } } -pub(super) fn check( - cx: &LateContext<'_>, - expr: &hir::Expr<'_>, +pub(super) fn check<'tcx>( + cx: &LateContext<'tcx>, + expr: &hir::Expr<'tcx>, init: &hir::Expr<'_>, acc: &hir::Expr<'_>, fold_span: Span, @@ -124,60 +167,40 @@ pub(super) fn check( if let hir::ExprKind::Lit(lit) = init.kind { match lit.node { ast::LitKind::Bool(false) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::Or, - Replacement { - method_name: "any", - has_args: true, - has_generic_return: false, - }, - ); + let replacement = Replacement { + method_name: "any", + has_args: true, + has_generic_return: false, + }; + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Or, replacement); }, ast::LitKind::Bool(true) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::And, - Replacement { - method_name: "all", - has_args: true, - has_generic_return: false, - }, - ); + let replacement = Replacement { + method_name: "all", + has_args: true, + has_generic_return: false, + }; + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::And, replacement); }, ast::LitKind::Int(Pu128(0), _) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::Add, - Replacement { - method_name: "sum", - has_args: false, - has_generic_return: needs_turbofish(cx, expr), - }, - ); + let replacement = Replacement { + method_name: "sum", + has_args: false, + has_generic_return: needs_turbofish(cx, expr), + }; + if !check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Add, replacement) { + check_fold_with_method(cx, expr, acc, fold_span, sym::add, replacement); + } }, ast::LitKind::Int(Pu128(1), _) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::Mul, - Replacement { - method_name: "product", - has_args: false, - has_generic_return: needs_turbofish(cx, expr), - }, - ); + let replacement = Replacement { + method_name: "product", + has_args: false, + has_generic_return: needs_turbofish(cx, expr), + }; + if !check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Mul, replacement) { + check_fold_with_method(cx, expr, acc, fold_span, sym::mul, replacement); + } }, _ => (), } diff --git a/tests/ui/unnecessary_fold.fixed b/tests/ui/unnecessary_fold.fixed index 1c331be75094..c3eeafbc39cd 100644 --- a/tests/ui/unnecessary_fold.fixed +++ b/tests/ui/unnecessary_fold.fixed @@ -6,21 +6,35 @@ fn is_any(acc: bool, x: usize) -> bool { /// Calls which should trigger the `UNNECESSARY_FOLD` lint fn unnecessary_fold() { + use std::ops::{Add, Mul}; + // Can be replaced by .any let _ = (0..3).any(|x| x > 2); //~^ unnecessary_fold + // Can be replaced by .any (checking suggestion) let _ = (0..3).fold(false, is_any); //~^ redundant_closure + // Can be replaced by .all let _ = (0..3).all(|x| x > 2); //~^ unnecessary_fold + // Can be replaced by .sum let _: i32 = (0..3).sum(); //~^ unnecessary_fold + let _: i32 = (0..3).sum(); + //~^ unnecessary_fold + let _: i32 = (0..3).sum(); + //~^ unnecessary_fold + // Can be replaced by .product let _: i32 = (0..3).product(); //~^ unnecessary_fold + let _: i32 = (0..3).product(); + //~^ unnecessary_fold + let _: i32 = (0..3).product(); + //~^ unnecessary_fold } /// Should trigger the `UNNECESSARY_FOLD` lint, with an error span including exactly `.fold(...)` @@ -37,6 +51,43 @@ fn unnecessary_fold_should_ignore() { let _ = (0..3).fold(0, |acc, x| acc * x); let _ = (0..3).fold(0, |acc, x| 1 + acc + x); + struct Adder; + impl Adder { + fn add(lhs: i32, rhs: i32) -> i32 { + unimplemented!() + } + fn mul(lhs: i32, rhs: i32) -> i32 { + unimplemented!() + } + } + // `add`/`mul` are inherent methods + let _: i32 = (0..3).fold(0, Adder::add); + let _: i32 = (0..3).fold(1, Adder::mul); + + trait FakeAdd { + type Output; + fn add(self, other: Rhs) -> Self::Output; + } + impl FakeAdd for i32 { + type Output = Self; + fn add(self, other: i32) -> Self::Output { + self + other + } + } + trait FakeMul { + type Output; + fn mul(self, other: Rhs) -> Self::Output; + } + impl FakeMul for i32 { + type Output = Self; + fn mul(self, other: i32) -> Self::Output { + self * other + } + } + // `add`/`mul` come from an unrelated trait + let _: i32 = (0..3).fold(0, FakeAdd::add); + let _: i32 = (0..3).fold(1, FakeMul::mul); + // We only match against an accumulator on the left // hand side. We could lint for .sum and .product when // it's on the right, but don't for now (and this wouldn't @@ -63,6 +114,7 @@ fn unnecessary_fold_over_multiple_lines() { fn issue10000() { use std::collections::HashMap; use std::hash::BuildHasher; + use std::ops::{Add, Mul}; fn anything(_: T) {} fn num(_: i32) {} @@ -74,23 +126,56 @@ fn issue10000() { // more cases: let _ = map.values().sum::(); //~^ unnecessary_fold + let _ = map.values().sum::(); + //~^ unnecessary_fold let _ = map.values().product::(); //~^ unnecessary_fold + let _ = map.values().product::(); + //~^ unnecessary_fold + let _: i32 = map.values().sum(); + //~^ unnecessary_fold let _: i32 = map.values().sum(); //~^ unnecessary_fold let _: i32 = map.values().product(); //~^ unnecessary_fold + let _: i32 = map.values().product(); + //~^ unnecessary_fold + anything(map.values().sum::()); + //~^ unnecessary_fold anything(map.values().sum::()); //~^ unnecessary_fold anything(map.values().product::()); //~^ unnecessary_fold + anything(map.values().product::()); + //~^ unnecessary_fold num(map.values().sum()); //~^ unnecessary_fold + num(map.values().sum()); + //~^ unnecessary_fold + num(map.values().product()); + //~^ unnecessary_fold num(map.values().product()); //~^ unnecessary_fold } smoketest_map(HashMap::new()); + + fn add_turbofish_not_necessary() -> i32 { + (0..3).sum() + //~^ unnecessary_fold + } + fn mul_turbofish_not_necessary() -> i32 { + (0..3).product() + //~^ unnecessary_fold + } + fn add_turbofish_necessary() -> impl Add { + (0..3).sum::() + //~^ unnecessary_fold + } + fn mul_turbofish_necessary() -> impl Mul { + (0..3).product::() + //~^ unnecessary_fold + } } fn main() {} diff --git a/tests/ui/unnecessary_fold.rs b/tests/ui/unnecessary_fold.rs index e2050e37e3b1..6ab41a942625 100644 --- a/tests/ui/unnecessary_fold.rs +++ b/tests/ui/unnecessary_fold.rs @@ -6,21 +6,35 @@ fn is_any(acc: bool, x: usize) -> bool { /// Calls which should trigger the `UNNECESSARY_FOLD` lint fn unnecessary_fold() { + use std::ops::{Add, Mul}; + // Can be replaced by .any let _ = (0..3).fold(false, |acc, x| acc || x > 2); //~^ unnecessary_fold + // Can be replaced by .any (checking suggestion) let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); //~^ redundant_closure + // Can be replaced by .all let _ = (0..3).fold(true, |acc, x| acc && x > 2); //~^ unnecessary_fold + // Can be replaced by .sum let _: i32 = (0..3).fold(0, |acc, x| acc + x); //~^ unnecessary_fold + let _: i32 = (0..3).fold(0, Add::add); + //~^ unnecessary_fold + let _: i32 = (0..3).fold(0, i32::add); + //~^ unnecessary_fold + // Can be replaced by .product let _: i32 = (0..3).fold(1, |acc, x| acc * x); //~^ unnecessary_fold + let _: i32 = (0..3).fold(1, Mul::mul); + //~^ unnecessary_fold + let _: i32 = (0..3).fold(1, i32::mul); + //~^ unnecessary_fold } /// Should trigger the `UNNECESSARY_FOLD` lint, with an error span including exactly `.fold(...)` @@ -37,6 +51,43 @@ fn unnecessary_fold_should_ignore() { let _ = (0..3).fold(0, |acc, x| acc * x); let _ = (0..3).fold(0, |acc, x| 1 + acc + x); + struct Adder; + impl Adder { + fn add(lhs: i32, rhs: i32) -> i32 { + unimplemented!() + } + fn mul(lhs: i32, rhs: i32) -> i32 { + unimplemented!() + } + } + // `add`/`mul` are inherent methods + let _: i32 = (0..3).fold(0, Adder::add); + let _: i32 = (0..3).fold(1, Adder::mul); + + trait FakeAdd { + type Output; + fn add(self, other: Rhs) -> Self::Output; + } + impl FakeAdd for i32 { + type Output = Self; + fn add(self, other: i32) -> Self::Output { + self + other + } + } + trait FakeMul { + type Output; + fn mul(self, other: Rhs) -> Self::Output; + } + impl FakeMul for i32 { + type Output = Self; + fn mul(self, other: i32) -> Self::Output { + self * other + } + } + // `add`/`mul` come from an unrelated trait + let _: i32 = (0..3).fold(0, FakeAdd::add); + let _: i32 = (0..3).fold(1, FakeMul::mul); + // We only match against an accumulator on the left // hand side. We could lint for .sum and .product when // it's on the right, but don't for now (and this wouldn't @@ -63,6 +114,7 @@ fn unnecessary_fold_over_multiple_lines() { fn issue10000() { use std::collections::HashMap; use std::hash::BuildHasher; + use std::ops::{Add, Mul}; fn anything(_: T) {} fn num(_: i32) {} @@ -74,23 +126,56 @@ fn issue10000() { // more cases: let _ = map.values().fold(0, |x, y| x + y); //~^ unnecessary_fold + let _ = map.values().fold(0, Add::add); + //~^ unnecessary_fold let _ = map.values().fold(1, |x, y| x * y); //~^ unnecessary_fold + let _ = map.values().fold(1, Mul::mul); + //~^ unnecessary_fold let _: i32 = map.values().fold(0, |x, y| x + y); //~^ unnecessary_fold + let _: i32 = map.values().fold(0, Add::add); + //~^ unnecessary_fold let _: i32 = map.values().fold(1, |x, y| x * y); //~^ unnecessary_fold + let _: i32 = map.values().fold(1, Mul::mul); + //~^ unnecessary_fold anything(map.values().fold(0, |x, y| x + y)); //~^ unnecessary_fold + anything(map.values().fold(0, Add::add)); + //~^ unnecessary_fold anything(map.values().fold(1, |x, y| x * y)); //~^ unnecessary_fold + anything(map.values().fold(1, Mul::mul)); + //~^ unnecessary_fold num(map.values().fold(0, |x, y| x + y)); //~^ unnecessary_fold + num(map.values().fold(0, Add::add)); + //~^ unnecessary_fold num(map.values().fold(1, |x, y| x * y)); //~^ unnecessary_fold + num(map.values().fold(1, Mul::mul)); + //~^ unnecessary_fold } smoketest_map(HashMap::new()); + + fn add_turbofish_not_necessary() -> i32 { + (0..3).fold(0, |acc, x| acc + x) + //~^ unnecessary_fold + } + fn mul_turbofish_not_necessary() -> i32 { + (0..3).fold(1, |acc, x| acc * x) + //~^ unnecessary_fold + } + fn add_turbofish_necessary() -> impl Add { + (0..3).fold(0, |acc, x| acc + x) + //~^ unnecessary_fold + } + fn mul_turbofish_necessary() -> impl Mul { + (0..3).fold(1, |acc, x| acc * x) + //~^ unnecessary_fold + } } fn main() {} diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index d82b1f39b48b..bb8aa7e18d34 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,5 +1,5 @@ error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:10:20 + --> tests/ui/unnecessary_fold.rs:12:20 | LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` @@ -8,7 +8,7 @@ LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fold)]` error: redundant closure - --> tests/ui/unnecessary_fold.rs:13:32 + --> tests/ui/unnecessary_fold.rs:16:32 | LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `is_any` @@ -17,88 +17,184 @@ LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:16:20 + --> tests/ui/unnecessary_fold.rs:20:20 | LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:19:25 + --> tests/ui/unnecessary_fold.rs:24:25 | LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:22:25 + --> tests/ui/unnecessary_fold.rs:26:25 + | +LL | let _: i32 = (0..3).fold(0, Add::add); + | ^^^^^^^^^^^^^^^^^ help: try: `sum()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:28:25 + | +LL | let _: i32 = (0..3).fold(0, i32::add); + | ^^^^^^^^^^^^^^^^^ help: try: `sum()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:32:25 | LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:28:41 + --> tests/ui/unnecessary_fold.rs:34:25 + | +LL | let _: i32 = (0..3).fold(1, Mul::mul); + | ^^^^^^^^^^^^^^^^^ help: try: `product()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:36:25 + | +LL | let _: i32 = (0..3).fold(1, i32::mul); + | ^^^^^^^^^^^^^^^^^ help: try: `product()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:42:41 | LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:59:10 + --> tests/ui/unnecessary_fold.rs:110:10 | LL | .fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:71:33 + --> tests/ui/unnecessary_fold.rs:123:33 | LL | assert_eq!(map.values().fold(0, |x, y| x + y), 0); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:75:30 + --> tests/ui/unnecessary_fold.rs:127:30 | LL | let _ = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:77:30 + --> tests/ui/unnecessary_fold.rs:129:30 + | +LL | let _ = map.values().fold(0, Add::add); + | ^^^^^^^^^^^^^^^^^ help: try: `sum::()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:131:30 | LL | let _ = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:79:35 + --> tests/ui/unnecessary_fold.rs:133:30 + | +LL | let _ = map.values().fold(1, Mul::mul); + | ^^^^^^^^^^^^^^^^^ help: try: `product::()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:135:35 | LL | let _: i32 = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:81:35 + --> tests/ui/unnecessary_fold.rs:137:35 + | +LL | let _: i32 = map.values().fold(0, Add::add); + | ^^^^^^^^^^^^^^^^^ help: try: `sum()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:139:35 | LL | let _: i32 = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:83:31 + --> tests/ui/unnecessary_fold.rs:141:35 + | +LL | let _: i32 = map.values().fold(1, Mul::mul); + | ^^^^^^^^^^^^^^^^^ help: try: `product()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:143:31 | LL | anything(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:85:31 + --> tests/ui/unnecessary_fold.rs:145:31 + | +LL | anything(map.values().fold(0, Add::add)); + | ^^^^^^^^^^^^^^^^^ help: try: `sum::()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:147:31 | LL | anything(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:87:26 + --> tests/ui/unnecessary_fold.rs:149:31 + | +LL | anything(map.values().fold(1, Mul::mul)); + | ^^^^^^^^^^^^^^^^^ help: try: `product::()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:151:26 | LL | num(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> tests/ui/unnecessary_fold.rs:89:26 + --> tests/ui/unnecessary_fold.rs:153:26 + | +LL | num(map.values().fold(0, Add::add)); + | ^^^^^^^^^^^^^^^^^ help: try: `sum()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:155:26 | LL | num(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` -error: aborting due to 16 previous errors +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:157:26 + | +LL | num(map.values().fold(1, Mul::mul)); + | ^^^^^^^^^^^^^^^^^ help: try: `product()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:164:16 + | +LL | (0..3).fold(0, |acc, x| acc + x) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:168:16 + | +LL | (0..3).fold(1, |acc, x| acc * x) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:172:16 + | +LL | (0..3).fold(0, |acc, x| acc + x) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` + +error: this `.fold` can be written more succinctly using another method + --> tests/ui/unnecessary_fold.rs:176:16 + | +LL | (0..3).fold(1, |acc, x| acc * x) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` + +error: aborting due to 32 previous errors From 2a224f3e793da8da1c470dc58959fd81a34796e8 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Sat, 4 Oct 2025 12:33:55 +0200 Subject: [PATCH 110/489] clean-up --- clippy_lints/src/format_push_string.rs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/format_push_string.rs b/clippy_lints/src/format_push_string.rs index a23ba9ab837a..069f8f7d75ab 100644 --- a/clippy_lints/src/format_push_string.rs +++ b/clippy_lints/src/format_push_string.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::higher; use clippy_utils::res::MaybeDef; use rustc_hir::{AssignOpKind, Expr, ExprKind, LangItem, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; @@ -49,22 +48,15 @@ fn is_string(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { fn is_format(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { let e = e.peel_blocks().peel_borrows(); - if e.span.from_expansion() - && let Some(macro_def_id) = e.span.ctxt().outer_expn_data().macro_def_id - { - cx.tcx.get_diagnostic_name(macro_def_id) == Some(sym::format_macro) - } else if let Some(higher::If { then, r#else, .. }) = higher::If::hir(e) { - is_format(cx, then) || r#else.is_some_and(|e| is_format(cx, e)) - } else { - match higher::IfLetOrMatch::parse(cx, e) { - Some(higher::IfLetOrMatch::Match(_, arms, MatchSource::Normal)) => { - arms.iter().any(|arm| is_format(cx, arm.body)) - }, - Some(higher::IfLetOrMatch::IfLet(_, _, then, r#else, _)) => { - is_format(cx, then) || r#else.is_some_and(|e| is_format(cx, e)) - }, - _ => false, - } + match e.kind { + _ if e.span.from_expansion() + && let Some(macro_def_id) = e.span.ctxt().outer_expn_data().macro_def_id => + { + cx.tcx.is_diagnostic_item(sym::format_macro, macro_def_id) + }, + ExprKind::Match(_, arms, MatchSource::Normal) => arms.iter().any(|arm| is_format(cx, arm.body)), + ExprKind::If(_, then, els) => is_format(cx, then) || els.is_some_and(|e| is_format(cx, e)), + _ => false, } } From 34551be259d4b14af3103d0b61d2ef9d310b9f36 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Sat, 4 Oct 2025 12:05:56 +0200 Subject: [PATCH 111/489] feat(format_push_string): add a suggestion --- clippy_lints/src/format_push_string.rs | 201 +++++++++++---- clippy_lints/src/lib.rs | 5 +- tests/ui/format_push_string.fixed | 132 ++++++++++ tests/ui/format_push_string.rs | 140 +++++++++-- tests/ui/format_push_string.stderr | 205 ++++++++++++--- tests/ui/format_push_string_no_core.rs | 15 ++ tests/ui/format_push_string_no_std.fixed | 15 ++ tests/ui/format_push_string_no_std.rs | 15 ++ tests/ui/format_push_string_no_std.stderr | 17 ++ .../ui/format_push_string_no_std_unfixable.rs | 13 + ...format_push_string_no_std_unfixable.stderr | 17 ++ tests/ui/format_push_string_unfixable.rs | 144 +++++++++++ tests/ui/format_push_string_unfixable.stderr | 233 ++++++++++++++++++ 13 files changed, 1044 insertions(+), 108 deletions(-) create mode 100644 tests/ui/format_push_string.fixed create mode 100644 tests/ui/format_push_string_no_core.rs create mode 100644 tests/ui/format_push_string_no_std.fixed create mode 100644 tests/ui/format_push_string_no_std.rs create mode 100644 tests/ui/format_push_string_no_std.stderr create mode 100644 tests/ui/format_push_string_no_std_unfixable.rs create mode 100644 tests/ui/format_push_string_no_std_unfixable.stderr create mode 100644 tests/ui/format_push_string_unfixable.rs create mode 100644 tests/ui/format_push_string_unfixable.stderr diff --git a/clippy_lints/src/format_push_string.rs b/clippy_lints/src/format_push_string.rs index 069f8f7d75ab..fea55f91bce7 100644 --- a/clippy_lints/src/format_push_string.rs +++ b/clippy_lints/src/format_push_string.rs @@ -1,9 +1,13 @@ use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::macros::{FormatArgsStorage, format_args_inputs_span, root_macro_call_first_node}; use clippy_utils::res::MaybeDef; +use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; +use clippy_utils::std_or_core; +use rustc_errors::Applicability; use rustc_hir::{AssignOpKind, Expr, ExprKind, LangItem, MatchSource}; -use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::declare_lint_pass; -use rustc_span::sym; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_session::impl_lint_pass; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does @@ -37,7 +41,152 @@ declare_clippy_lint! { pedantic, "`format!(..)` appended to existing `String`" } -declare_lint_pass!(FormatPushString => [FORMAT_PUSH_STRING]); +impl_lint_pass!(FormatPushString => [FORMAT_PUSH_STRING]); + +pub(crate) struct FormatPushString { + format_args: FormatArgsStorage, +} + +enum FormatSearchResults { + /// The expression is itself a `format!()` invocation -- we can make a suggestion to replace it + Direct(Span), + /// The expression contains zero or more `format!()`s, e.g.: + /// ```ignore + /// if true { + /// format!("hello") + /// } else { + /// format!("world") + /// } + /// ``` + /// or + /// ```ignore + /// match true { + /// true => format!("hello"), + /// false => format!("world"), + /// } + Nested(Vec), +} + +impl FormatPushString { + pub(crate) fn new(format_args: FormatArgsStorage) -> Self { + Self { format_args } + } + + fn find_formats<'tcx>(&self, cx: &LateContext<'_>, e: &'tcx Expr<'tcx>) -> FormatSearchResults { + let expr_as_format = |e| { + if let Some(macro_call) = root_macro_call_first_node(cx, e) + && cx.tcx.is_diagnostic_item(sym::format_macro, macro_call.def_id) + && let Some(format_args) = self.format_args.get(cx, e, macro_call.expn) + { + Some(format_args_inputs_span(format_args)) + } else { + None + } + }; + + let e = e.peel_blocks().peel_borrows(); + if let Some(fmt) = expr_as_format(e) { + FormatSearchResults::Direct(fmt) + } else { + fn inner<'tcx>( + e: &'tcx Expr<'tcx>, + expr_as_format: &impl Fn(&'tcx Expr<'tcx>) -> Option, + out: &mut Vec, + ) { + let e = e.peel_blocks().peel_borrows(); + + match e.kind { + _ if expr_as_format(e).is_some() => out.push(e.span), + ExprKind::Match(_, arms, MatchSource::Normal) => { + for arm in arms { + inner(arm.body, expr_as_format, out); + } + }, + ExprKind::If(_, then, els) => { + inner(then, expr_as_format, out); + if let Some(els) = els { + inner(els, expr_as_format, out); + } + }, + _ => {}, + } + } + let mut spans = vec![]; + inner(e, &expr_as_format, &mut spans); + FormatSearchResults::Nested(spans) + } + } +} + +impl<'tcx> LateLintPass<'tcx> for FormatPushString { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { + let (recv, arg) = match expr.kind { + ExprKind::MethodCall(_, recv, [arg], _) => { + if let Some(fn_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) + && cx.tcx.is_diagnostic_item(sym::string_push_str, fn_def_id) + { + (recv, arg) + } else { + return; + } + }, + ExprKind::AssignOp(op, recv, arg) if op.node == AssignOpKind::AddAssign && is_string(cx, recv) => { + (recv, arg) + }, + _ => return, + }; + let Some(std_or_core) = std_or_core(cx) else { + // not even `core` is available, so can't suggest `write!` + return; + }; + match self.find_formats(cx, arg) { + FormatSearchResults::Direct(format_args) => { + span_lint_and_then( + cx, + FORMAT_PUSH_STRING, + expr.span, + "`format!(..)` appended to existing `String`", + |diag| { + let mut app = Applicability::MaybeIncorrect; + let msg = "consider using `write!` to avoid the extra allocation"; + + let sugg = format!( + "let _ = write!({recv}, {format_args})", + recv = snippet_with_context(cx.sess(), recv.span, expr.span.ctxt(), "_", &mut app).0, + format_args = snippet_with_applicability(cx.sess(), format_args, "..", &mut app), + ); + diag.span_suggestion_verbose(expr.span, msg, sugg, app); + + // TODO: omit the note if the `Write` trait is imported at point + // Tip: `TyCtxt::in_scope_traits` isn't it -- it returns a non-empty list only when called on + // the `HirId` of a `ExprKind::MethodCall` that is a call of a _trait_ method. + diag.note(format!("you may need to import the `{std_or_core}::fmt::Write` trait")); + }, + ); + }, + FormatSearchResults::Nested(spans) => { + if !spans.is_empty() { + span_lint_and_then( + cx, + FORMAT_PUSH_STRING, + expr.span, + "`format!(..)` appended to existing `String`", + |diag| { + diag.help("consider using `write!` to avoid the extra allocation"); + diag.span_labels(spans, "`format!` used here"); + + // TODO: omit the note if the `Write` trait is imported at point + // Tip: `TyCtxt::in_scope_traits` isn't it -- it returns a non-empty list only when called + // on the `HirId` of a `ExprKind::MethodCall` that is a call of + // a _trait_ method. + diag.note(format!("you may need to import the `{std_or_core}::fmt::Write` trait")); + }, + ); + } + }, + } + } +} fn is_string(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { cx.typeck_results() @@ -45,47 +194,3 @@ fn is_string(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { .peel_refs() .is_lang_item(cx, LangItem::String) } -fn is_format(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { - let e = e.peel_blocks().peel_borrows(); - - match e.kind { - _ if e.span.from_expansion() - && let Some(macro_def_id) = e.span.ctxt().outer_expn_data().macro_def_id => - { - cx.tcx.is_diagnostic_item(sym::format_macro, macro_def_id) - }, - ExprKind::Match(_, arms, MatchSource::Normal) => arms.iter().any(|arm| is_format(cx, arm.body)), - ExprKind::If(_, then, els) => is_format(cx, then) || els.is_some_and(|e| is_format(cx, e)), - _ => false, - } -} - -impl<'tcx> LateLintPass<'tcx> for FormatPushString { - fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - let arg = match expr.kind { - ExprKind::MethodCall(_, _, [arg], _) => { - if let Some(fn_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) - && cx.tcx.is_diagnostic_item(sym::string_push_str, fn_def_id) - { - arg - } else { - return; - } - }, - ExprKind::AssignOp(op, left, arg) if op.node == AssignOpKind::AddAssign && is_string(cx, left) => arg, - _ => return, - }; - if is_format(cx, arg) { - #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")] - span_lint_and_then( - cx, - FORMAT_PUSH_STRING, - expr.span, - "`format!(..)` appended to existing `String`", - |diag| { - diag.help("consider using `write!` to avoid the extra allocation"); - }, - ); - } - } -} diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 5b39d8844797..3b18f51c3323 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -739,7 +739,10 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co Box::new(move |_| Box::new(cargo::Cargo::new(conf))), Box::new(|_| Box::new(empty_with_brackets::EmptyWithBrackets::default())), Box::new(|_| Box::new(unnecessary_owned_empty_strings::UnnecessaryOwnedEmptyStrings)), - Box::new(|_| Box::new(format_push_string::FormatPushString)), + { + let format_args = format_args_storage.clone(); + Box::new(move |_| Box::new(format_push_string::FormatPushString::new(format_args.clone()))) + }, Box::new(move |_| Box::new(large_include_file::LargeIncludeFile::new(conf))), Box::new(|_| Box::new(strings::TrimSplitWhitespace)), Box::new(|_| Box::new(rc_clone_in_vec_init::RcCloneInVecInit)), diff --git a/tests/ui/format_push_string.fixed b/tests/ui/format_push_string.fixed new file mode 100644 index 000000000000..f6396d9982a3 --- /dev/null +++ b/tests/ui/format_push_string.fixed @@ -0,0 +1,132 @@ +#![warn(clippy::format_push_string)] + +fn main() { + use std::fmt::Write; + + let mut string = String::new(); + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + + let _ = write!(string, "{:?}", 5678); + //~^ format_push_string + + macro_rules! string { + () => { + String::new() + }; + } + let _ = write!(string!(), "{:?}", 5678); + //~^ format_push_string +} + +// TODO: recognize the already imported `fmt::Write`, and don't add a note suggesting to import it +// again +mod import_write { + mod push_str { + mod imported_anonymously { + fn main(string: &mut String) { + use std::fmt::Write as _; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported { + fn main(string: &mut String) { + use std::fmt::Write; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported_anonymously_in_module { + use std::fmt::Write as _; + + fn main(string: &mut String) { + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported_in_module { + use std::fmt::Write; + + fn main(string: &mut String) { + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported_and_imported { + fn foo(string: &mut String) { + use std::fmt::Write; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + + fn bar(string: &mut String) { + use std::fmt::Write; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + } + + mod add_assign { + mod imported_anonymously { + fn main(string: &mut String) { + use std::fmt::Write as _; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported { + fn main(string: &mut String) { + use std::fmt::Write; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported_anonymously_in_module { + use std::fmt::Write as _; + + fn main(string: &mut String) { + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported_in_module { + use std::fmt::Write; + + fn main(string: &mut String) { + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + + mod imported_and_imported { + fn foo(string: &mut String) { + use std::fmt::Write; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + + fn bar(string: &mut String) { + use std::fmt::Write; + + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string + } + } + } +} diff --git a/tests/ui/format_push_string.rs b/tests/ui/format_push_string.rs index 056ef59ff0e2..1ed0f5b3ac59 100644 --- a/tests/ui/format_push_string.rs +++ b/tests/ui/format_push_string.rs @@ -1,44 +1,132 @@ #![warn(clippy::format_push_string)] fn main() { + use std::fmt::Write; + let mut string = String::new(); string += &format!("{:?}", 1234); //~^ format_push_string string.push_str(&format!("{:?}", 5678)); //~^ format_push_string + + macro_rules! string { + () => { + String::new() + }; + } + string!().push_str(&format!("{:?}", 5678)); + //~^ format_push_string } -mod issue9493 { - pub fn u8vec_to_hex(vector: &Vec, upper: bool) -> String { - let mut hex = String::with_capacity(vector.len() * 2); - for byte in vector { - hex += &(if upper { +// TODO: recognize the already imported `fmt::Write`, and don't add a note suggesting to import it +// again +mod import_write { + mod push_str { + mod imported_anonymously { + fn main(string: &mut String) { + use std::fmt::Write as _; + + string.push_str(&format!("{:?}", 1234)); //~^ format_push_string - - format!("{byte:02X}") - } else { - format!("{byte:02x}") - }); + } + } + + mod imported { + fn main(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported_anonymously_in_module { + use std::fmt::Write as _; + + fn main(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported_in_module { + use std::fmt::Write; + + fn main(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported_and_imported { + fn foo(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } } - hex } - pub fn other_cases() { - let mut s = String::new(); - // if let - s += &(if let Some(_a) = Some(1234) { - //~^ format_push_string + mod add_assign { + mod imported_anonymously { + fn main(string: &mut String) { + use std::fmt::Write as _; - format!("{}", 1234) - } else { - format!("{}", 1234) - }); - // match - s += &(match Some(1234) { - //~^ format_push_string - Some(_) => format!("{}", 1234), - None => format!("{}", 1234), - }); + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported { + fn main(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported_anonymously_in_module { + use std::fmt::Write as _; + + fn main(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported_in_module { + use std::fmt::Write; + + fn main(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + mod imported_and_imported { + fn foo(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } } } diff --git a/tests/ui/format_push_string.stderr b/tests/ui/format_push_string.stderr index bba2a8947c43..05e26fcbfc2b 100644 --- a/tests/ui/format_push_string.stderr +++ b/tests/ui/format_push_string.stderr @@ -1,60 +1,199 @@ error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:5:5 + --> tests/ui/format_push_string.rs:7:5 | LL | string += &format!("{:?}", 1234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: consider using `write!` to avoid the extra allocation + = note: you may need to import the `std::fmt::Write` trait = note: `-D clippy::format-push-string` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` +help: consider using `write!` to avoid the extra allocation + | +LL - string += &format!("{:?}", 1234); +LL + let _ = write!(string, "{:?}", 1234); + | error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:8:5 + --> tests/ui/format_push_string.rs:10:5 | LL | string.push_str(&format!("{:?}", 5678)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: consider using `write!` to avoid the extra allocation + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 5678)); +LL + let _ = write!(string, "{:?}", 5678); + | error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:16:13 + --> tests/ui/format_push_string.rs:18:5 | -LL | / hex += &(if upper { -LL | | -LL | | -LL | | format!("{byte:02X}") -LL | | } else { -LL | | format!("{byte:02x}") -LL | | }); - | |______________^ +LL | string!().push_str(&format!("{:?}", 5678)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string!().push_str(&format!("{:?}", 5678)); +LL + let _ = write!(string!(), "{:?}", 5678); | - = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:30:9 + --> tests/ui/format_push_string.rs:30:17 | -LL | / s += &(if let Some(_a) = Some(1234) { -LL | | -LL | | -LL | | format!("{}", 1234) -LL | | } else { -LL | | format!("{}", 1234) -LL | | }); - | |__________^ +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); | - = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:38:9 + --> tests/ui/format_push_string.rs:39:17 | -LL | / s += &(match Some(1234) { -LL | | -LL | | Some(_) => format!("{}", 1234), -LL | | None => format!("{}", 1234), -LL | | }); - | |__________^ +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); | - = help: consider using `write!` to avoid the extra allocation -error: aborting due to 5 previous errors +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:48:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:57:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:66:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:73:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:84:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:93:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:102:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:111:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:120:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string.rs:127:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: aborting due to 15 previous errors diff --git a/tests/ui/format_push_string_no_core.rs b/tests/ui/format_push_string_no_core.rs new file mode 100644 index 000000000000..4bc45906fa78 --- /dev/null +++ b/tests/ui/format_push_string_no_core.rs @@ -0,0 +1,15 @@ +//@check-pass +#![warn(clippy::format_push_string)] +#![no_std] +#![feature(no_core)] +#![no_core] + +extern crate alloc; + +use alloc::format; +use alloc::string::String; + +fn foo(string: &mut String) { + // can't suggest even `core::fmt::Write` because of `#![no_core]` + string.push_str(&format!("{:?}", 1234)); +} diff --git a/tests/ui/format_push_string_no_std.fixed b/tests/ui/format_push_string_no_std.fixed new file mode 100644 index 000000000000..32d8659dcbd5 --- /dev/null +++ b/tests/ui/format_push_string_no_std.fixed @@ -0,0 +1,15 @@ +#![warn(clippy::format_push_string)] +#![no_std] + +extern crate alloc; + +use alloc::format; +use alloc::string::String; + +fn foo(string: &mut String) { + use core::fmt::Write; + + // TODO: recognize the already imported `fmt::Write`, and don't suggest importing it again + let _ = write!(string, "{:?}", 1234); + //~^ format_push_string +} diff --git a/tests/ui/format_push_string_no_std.rs b/tests/ui/format_push_string_no_std.rs new file mode 100644 index 000000000000..a74189abe528 --- /dev/null +++ b/tests/ui/format_push_string_no_std.rs @@ -0,0 +1,15 @@ +#![warn(clippy::format_push_string)] +#![no_std] + +extern crate alloc; + +use alloc::format; +use alloc::string::String; + +fn foo(string: &mut String) { + use core::fmt::Write; + + // TODO: recognize the already imported `fmt::Write`, and don't suggest importing it again + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string +} diff --git a/tests/ui/format_push_string_no_std.stderr b/tests/ui/format_push_string_no_std.stderr new file mode 100644 index 000000000000..30fd42ac71b2 --- /dev/null +++ b/tests/ui/format_push_string_no_std.stderr @@ -0,0 +1,17 @@ +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_no_std.rs:13:5 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `core::fmt::Write` trait + = note: `-D clippy::format-push-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/format_push_string_no_std_unfixable.rs b/tests/ui/format_push_string_no_std_unfixable.rs new file mode 100644 index 000000000000..f5ed5e435b5a --- /dev/null +++ b/tests/ui/format_push_string_no_std_unfixable.rs @@ -0,0 +1,13 @@ +//@no-rustfix +#![warn(clippy::format_push_string)] +#![no_std] + +extern crate alloc; + +use alloc::format; +use alloc::string::String; + +fn foo(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string +} diff --git a/tests/ui/format_push_string_no_std_unfixable.stderr b/tests/ui/format_push_string_no_std_unfixable.stderr new file mode 100644 index 000000000000..cc716c84efe2 --- /dev/null +++ b/tests/ui/format_push_string_no_std_unfixable.stderr @@ -0,0 +1,17 @@ +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_no_std_unfixable.rs:11:5 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `core::fmt::Write` trait + = note: `-D clippy::format-push-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/format_push_string_unfixable.rs b/tests/ui/format_push_string_unfixable.rs new file mode 100644 index 000000000000..ff6c13fe4a49 --- /dev/null +++ b/tests/ui/format_push_string_unfixable.rs @@ -0,0 +1,144 @@ +//@no-rustfix +#![warn(clippy::format_push_string)] + +mod issue9493 { + pub fn u8vec_to_hex(vector: &Vec, upper: bool) -> String { + let mut hex = String::with_capacity(vector.len() * 2); + for byte in vector { + hex += &(if upper { + format!("{byte:02X}") + //~^ format_push_string + } else { + format!("{byte:02x}") + }); + } + hex + } + + pub fn other_cases() { + let mut s = String::new(); + // if let + s += &(if let Some(_a) = Some(1234) { + format!("{}", 1234) + //~^ format_push_string + } else { + format!("{}", 1234) + }); + // match + s += &(match Some(1234) { + Some(_) => format!("{}", 1234), + //~^ format_push_string + None => format!("{}", 1234), + }); + } +} + +mod import_write { + mod push_str { + // TODO: suggest importing `std::fmt::Write`; + mod not_imported { + fn main(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + // TODO: suggest importing the first time, but not again + mod not_imported_and_not_imported { + fn foo(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + // TODO: suggest importing the first time, but not again + mod not_imported_and_imported { + fn foo(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + // TODO: suggest importing, but only for `bar` + mod imported_and_not_imported { + fn foo(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + } + + mod add_assign { + // TODO: suggest importing `std::fmt::Write`; + mod not_imported { + fn main(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + // TODO: suggest importing the first time, but not again + mod not_imported_and_not_imported { + fn foo(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + // TODO: suggest importing the first time, but not again + mod not_imported_and_imported { + fn foo(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + + // TODO: suggest importing, but only for `bar` + mod imported_and_not_imported { + fn foo(string: &mut String) { + use std::fmt::Write; + + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + + fn bar(string: &mut String) { + string.push_str(&format!("{:?}", 1234)); + //~^ format_push_string + } + } + } +} + +fn main() {} diff --git a/tests/ui/format_push_string_unfixable.stderr b/tests/ui/format_push_string_unfixable.stderr new file mode 100644 index 000000000000..145e7fcc440d --- /dev/null +++ b/tests/ui/format_push_string_unfixable.stderr @@ -0,0 +1,233 @@ +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:8:13 + | +LL | / hex += &(if upper { +LL | | format!("{byte:02X}") + | | --------------------- `format!` used here +LL | | +LL | | } else { +LL | | format!("{byte:02x}") + | | --------------------- `format!` used here +LL | | }); + | |______________^ + | + = help: consider using `write!` to avoid the extra allocation + = note: you may need to import the `std::fmt::Write` trait + = note: `-D clippy::format-push-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:21:9 + | +LL | / s += &(if let Some(_a) = Some(1234) { +LL | | format!("{}", 1234) + | | ------------------- `format!` used here +LL | | +LL | | } else { +LL | | format!("{}", 1234) + | | ------------------- `format!` used here +LL | | }); + | |__________^ + | + = help: consider using `write!` to avoid the extra allocation + = note: you may need to import the `std::fmt::Write` trait + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:28:9 + | +LL | / s += &(match Some(1234) { +LL | | Some(_) => format!("{}", 1234), + | | ------------------- `format!` used here +LL | | +LL | | None => format!("{}", 1234), + | | ------------------- `format!` used here +LL | | }); + | |__________^ + | + = help: consider using `write!` to avoid the extra allocation + = note: you may need to import the `std::fmt::Write` trait + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:41:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:49:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:54:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:62:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:69:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:79:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:84:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:94:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:102:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:107:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:115:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:122:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:132:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: `format!(..)` appended to existing `String` + --> tests/ui/format_push_string_unfixable.rs:137:17 + | +LL | string.push_str(&format!("{:?}", 1234)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: you may need to import the `std::fmt::Write` trait +help: consider using `write!` to avoid the extra allocation + | +LL - string.push_str(&format!("{:?}", 1234)); +LL + let _ = write!(string, "{:?}", 1234); + | + +error: aborting due to 17 previous errors + From 0428dd5586f3c90d7e7229ffbeb505d3b33dce34 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 11 Dec 2025 18:51:58 +0100 Subject: [PATCH 112/489] miri: add -Zbinary-dep-depinfo to dependency builds --- src/tools/clippy/tests/compile-test.rs | 4 ++++ src/tools/miri/tests/ui.rs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tools/clippy/tests/compile-test.rs b/src/tools/clippy/tests/compile-test.rs index 1ac688935278..fa2b6cf26806 100644 --- a/src/tools/clippy/tests/compile-test.rs +++ b/src/tools/clippy/tests/compile-test.rs @@ -173,6 +173,10 @@ impl TestContext { p.envs.push(("RUSTC_SNAPSHOT".into(), Some(rustc.into()))); p.envs.push(("RUSTC_SNAPSHOT_LIBDIR".into(), Some(libdir.into()))); p.envs.push(("RUSTC_SYSROOT".into(), Some(sysroot.into()))); + // Ensure we rebuild the dependencies when the sysroot changes. + // (Bootstrap usually sets this automatically, but since we invoke cargo + // ourselves we have to do it.) + p.args.push("-Zbinary-dep-depinfo".into()); } p }, diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index c2cbdd548078..338d55b9d773 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -133,7 +133,11 @@ fn miri_config( program: miri_path() .with_file_name(format!("cargo-miri{}", env::consts::EXE_SUFFIX)), // There is no `cargo miri build` so we just use `cargo miri run`. - args: ["miri", "run"].into_iter().map(Into::into).collect(), + // Add `-Zbinary-dep-depinfo` since it is needed for bootstrap builds (and doesn't harm otherwise). + args: ["miri", "run", "--quiet", "-Zbinary-dep-depinfo"] + .into_iter() + .map(Into::into) + .collect(), // Reset `RUSTFLAGS` to work around . envs: vec![("RUSTFLAGS".into(), None)], ..CommandBuilder::cargo() From 13d9d6559fb6458c36bef03f146c930982cc69af Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 11 Dec 2025 18:51:58 +0100 Subject: [PATCH 113/489] miri: add -Zbinary-dep-depinfo to dependency builds --- tests/compile-test.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 1ac688935278..fa2b6cf26806 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -173,6 +173,10 @@ impl TestContext { p.envs.push(("RUSTC_SNAPSHOT".into(), Some(rustc.into()))); p.envs.push(("RUSTC_SNAPSHOT_LIBDIR".into(), Some(libdir.into()))); p.envs.push(("RUSTC_SYSROOT".into(), Some(sysroot.into()))); + // Ensure we rebuild the dependencies when the sysroot changes. + // (Bootstrap usually sets this automatically, but since we invoke cargo + // ourselves we have to do it.) + p.args.push("-Zbinary-dep-depinfo".into()); } p }, From 19f0c81b3f674c5cfd76e3491ad146b033ddfa96 Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Thu, 11 Dec 2025 19:13:34 +0100 Subject: [PATCH 114/489] Merge commit '9e3e9649cbae7ed33ba62ca436f43081eaaedeb5' into clippy-subtree-update --- CHANGELOG.md | 83 ++++- Cargo.toml | 2 +- README.md | 2 +- book/src/README.md | 2 +- book/src/lint_configuration.md | 10 + clippy_config/Cargo.toml | 2 +- clippy_config/src/conf.rs | 3 + clippy_lints/Cargo.toml | 2 +- clippy_lints/src/casts/mod.rs | 32 ++ clippy_lints/src/casts/needless_type_cast.rs | 289 ++++++++++++++ clippy_lints/src/declared_lints.rs | 6 +- clippy_lints/src/deprecated_lints.rs | 2 +- clippy_lints/src/entry.rs | 48 ++- clippy_lints/src/large_stack_frames.rs | 152 +++++--- clippy_lints/src/len_without_is_empty.rs | 342 +++++++++++++++++ clippy_lints/src/len_zero.rs | 345 +---------------- clippy_lints/src/lib.rs | 4 + .../src/loops/while_let_on_iterator.rs | 31 +- clippy_lints/src/manual_ilog2.rs | 115 ++++++ .../src/matches/match_like_matches.rs | 52 ++- .../methods/manual_saturating_arithmetic.rs | 107 +++++- clippy_lints/src/methods/mod.rs | 53 ++- .../src/methods/ptr_offset_by_literal.rs | 138 +++++++ .../src/missing_asserts_for_indexing.rs | 94 ++--- clippy_lints/src/nonstandard_macro_braces.rs | 38 +- .../src/operators/decimal_bitwise_operands.rs | 76 ++++ clippy_lints/src/operators/mod.rs | 28 ++ clippy_lints/src/transmute/mod.rs | 36 +- .../src/transmute/transmute_ptr_to_ptr.rs | 10 +- .../src/transmute/transmute_ptr_to_ref.rs | 3 +- clippy_lints/src/tuple_array_conversions.rs | 41 +- clippy_lints/src/unwrap.rs | 9 +- clippy_lints/src/useless_conversion.rs | 5 +- clippy_lints/src/zero_repeat_side_effects.rs | 72 +++- clippy_utils/Cargo.toml | 6 +- clippy_utils/README.md | 2 +- clippy_utils/src/msrvs.rs | 1 + clippy_utils/src/sym.rs | 2 + declare_clippy_lint/Cargo.toml | 2 +- rust-toolchain.toml | 2 +- .../large_stack_frames_for_macros/clippy.toml | 1 + .../large_stack_frames.rs | 42 +++ .../large_stack_frames.stderr | 89 +++++ .../clippy.toml | 2 + .../large_stack_frames.rs | 13 + .../conf_nonstandard_macro_braces.fixed | 14 + .../conf_nonstandard_macro_braces.rs | 14 + .../conf_nonstandard_macro_braces.stderr | 44 ++- .../toml_unknown_key/conf_unknown_key.stderr | 3 + tests/ui/borrow_as_ptr.fixed | 2 +- tests/ui/borrow_as_ptr.rs | 2 +- .../ui/checked_unwrap/simple_conditionals.rs | 19 + tests/ui/crashes/ice-4579.rs | 2 +- tests/ui/decimal_bitwise_operands.rs | 133 +++++++ tests/ui/decimal_bitwise_operands.stderr | 204 ++++++++++ tests/ui/deprecated.stderr | 2 +- tests/ui/entry.fixed | 24 ++ tests/ui/entry.rs | 24 ++ tests/ui/len_without_is_empty.rs | 12 + tests/ui/manual_ilog2.fixed | 32 ++ tests/ui/manual_ilog2.rs | 32 ++ tests/ui/manual_ilog2.stderr | 23 ++ tests/ui/manual_saturating_arithmetic.fixed | 10 + tests/ui/manual_saturating_arithmetic.rs | 10 + tests/ui/manual_saturating_arithmetic.stderr | 8 +- tests/ui/match_like_matches_macro.fixed | 7 + tests/ui/match_like_matches_macro.rs | 10 + tests/ui/match_like_matches_macro.stderr | 156 +++++++- .../match_like_matches_macro_if_let_guard.rs | 51 +++ tests/ui/missing_asserts_for_indexing.stderr | 352 ++++-------------- ...sing_asserts_for_indexing_unfixable.stderr | 162 +------- tests/ui/needless_type_cast.fixed | 182 +++++++++ tests/ui/needless_type_cast.rs | 182 +++++++++ tests/ui/needless_type_cast.stderr | 71 ++++ tests/ui/ptr_offset_by_literal.fixed | 50 +++ tests/ui/ptr_offset_by_literal.rs | 50 +++ tests/ui/ptr_offset_by_literal.stderr | 141 +++++++ tests/ui/transmute_ptr_to_ptr.fixed | 23 ++ tests/ui/transmute_ptr_to_ptr.rs | 23 ++ tests/ui/transmute_ptr_to_ptr.stderr | 82 +++- tests/ui/transmute_ptr_to_ref.fixed | 56 ++- tests/ui/transmute_ptr_to_ref.rs | 56 ++- tests/ui/transmute_ptr_to_ref.stderr | 110 ++++-- tests/ui/tuple_array_conversions.rs | 23 ++ tests/ui/tuple_array_conversions.stderr | 10 +- tests/ui/useless_conversion.fixed | 11 + tests/ui/useless_conversion.rs | 11 + tests/ui/useless_conversion.stderr | 8 +- tests/ui/while_let_on_iterator.fixed | 104 ++++++ tests/ui/while_let_on_iterator.rs | 104 ++++++ tests/ui/while_let_on_iterator.stderr | 34 +- tests/ui/zero_offset.rs | 2 +- tests/ui/zero_repeat_side_effects.fixed | 32 +- tests/ui/zero_repeat_side_effects.rs | 26 +- tests/ui/zero_repeat_side_effects.stderr | 52 ++- triagebot.toml | 5 +- util/gh-pages/style.css | 4 +- 97 files changed, 4089 insertions(+), 1111 deletions(-) create mode 100644 clippy_lints/src/casts/needless_type_cast.rs create mode 100644 clippy_lints/src/len_without_is_empty.rs create mode 100644 clippy_lints/src/manual_ilog2.rs create mode 100644 clippy_lints/src/methods/ptr_offset_by_literal.rs create mode 100644 clippy_lints/src/operators/decimal_bitwise_operands.rs create mode 100644 tests/ui-toml/large_stack_frames_for_macros/clippy.toml create mode 100644 tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs create mode 100644 tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.stderr create mode 100644 tests/ui-toml/large_stack_frames_for_special_targets/clippy.toml create mode 100644 tests/ui-toml/large_stack_frames_for_special_targets/large_stack_frames.rs create mode 100644 tests/ui/decimal_bitwise_operands.rs create mode 100644 tests/ui/decimal_bitwise_operands.stderr create mode 100644 tests/ui/manual_ilog2.fixed create mode 100644 tests/ui/manual_ilog2.rs create mode 100644 tests/ui/manual_ilog2.stderr create mode 100644 tests/ui/match_like_matches_macro_if_let_guard.rs create mode 100644 tests/ui/needless_type_cast.fixed create mode 100644 tests/ui/needless_type_cast.rs create mode 100644 tests/ui/needless_type_cast.stderr create mode 100644 tests/ui/ptr_offset_by_literal.fixed create mode 100644 tests/ui/ptr_offset_by_literal.rs create mode 100644 tests/ui/ptr_offset_by_literal.stderr diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b81b5b74d6..6f666caf306f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,83 @@ document. ## Unreleased / Beta / In Rust Nightly -[e9b7045...master](https://github.com/rust-lang/rust-clippy/compare/e9b7045...master) +[d9fb15c...master](https://github.com/rust-lang/rust-clippy/compare/d9fb15c...master) + +## Rust 1.92 + +Current stable, released 2025-12-11 + +[View all 124 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2025-09-05T18%3A24%3A03Z..2025-10-16T14%3A13%3A43Z+base%3Amaster) + +### New Lints + +* Added [`unnecessary_option_map_or_else`] to `suspicious` + [#14662](https://github.com/rust-lang/rust-clippy/pull/14662) +* Added [`replace_box`] to `perf` + [#14953](https://github.com/rust-lang/rust-clippy/pull/14953) +* Added [`volatile_composites`] to `nursery` + [#15686](https://github.com/rust-lang/rust-clippy/pull/15686) +* Added [`self_only_used_in_recursion`] to `pedantic` + [#14787](https://github.com/rust-lang/rust-clippy/pull/14787) +* Added [`redundant_iter_cloned`] to `perf` + [#15277](https://github.com/rust-lang/rust-clippy/pull/15277) + +### Moves and Deprecations + +* Renamed [`unchecked_duration_subtraction`] to [`unchecked_time_subtraction`] + [#13800](https://github.com/rust-lang/rust-clippy/pull/13800) + +### Enhancements + +* [`mutex_atomic`] and [`mutex_integer`] overhauled to only lint definitions, not uses; added suggestions + and better help messages + [#15632](https://github.com/rust-lang/rust-clippy/pull/15632) +* [`manual_rotate`] now recognizes non-const rotation amounts + [#15402](https://github.com/rust-lang/rust-clippy/pull/15402) +* [`multiple_inherent_impl`] added `inherent-impl-lint-scope` config option (`module`, `file`, + or `crate`) + [#15843](https://github.com/rust-lang/rust-clippy/pull/15843) +* [`use_self`] now checks structs and enums + [#15566](https://github.com/rust-lang/rust-clippy/pull/15566) +* [`while_let_loop`] extended to lint on `loop { let else }` + [#15701](https://github.com/rust-lang/rust-clippy/pull/15701) +* [`mut_mut`] overhauled with structured suggestions and improved documentation + [#15417](https://github.com/rust-lang/rust-clippy/pull/15417) +* [`nonstandard_macro_braces`] now suggests trailing semicolon when needed + [#15593](https://github.com/rust-lang/rust-clippy/pull/15593) +* [`ptr_offset_with_cast`] now respects MSRV when suggesting fix, and lints more cases + [#15613](https://github.com/rust-lang/rust-clippy/pull/15613) +* [`cast_sign_loss`] and [`cast_possible_wrap`] added suggestions using `cast_{un,}signed()` methods + (MSRV 1.87+) + [#15384](https://github.com/rust-lang/rust-clippy/pull/15384) +* [`unchecked_time_subtraction`] extended to include `Duration - Duration` operations + [#13800](https://github.com/rust-lang/rust-clippy/pull/13800) +* [`filter_next`] now suggests replacing `filter().next_back()` with `rfind()` for + `DoubleEndedIterator` + [#15748](https://github.com/rust-lang/rust-clippy/pull/15748) + +### False Positive Fixes + +* [`unnecessary_safety_comment`] fixed FPs with comments above attributes + [#15678](https://github.com/rust-lang/rust-clippy/pull/15678) +* [`manual_unwrap_or`] fixed FP edge case + [#15812](https://github.com/rust-lang/rust-clippy/pull/15812) +* [`needless_continue`] fixed FP when match type is not unit or never + [#15547](https://github.com/rust-lang/rust-clippy/pull/15547) +* [`if_then_some_else_none`] fixed FP when return exists in block expr + [#15783](https://github.com/rust-lang/rust-clippy/pull/15783) +* [`new_without_default`] fixed to copy `#[cfg]` onto `impl Default` and fixed FP on private type + with trait impl + [#15720](https://github.com/rust-lang/rust-clippy/pull/15720) + [#15782](https://github.com/rust-lang/rust-clippy/pull/15782) +* [`question_mark`] fixed FP on variables used after + [#15644](https://github.com/rust-lang/rust-clippy/pull/15644) +* [`needless_return`] fixed FP with `cfg`d code after `return` + [#15669](https://github.com/rust-lang/rust-clippy/pull/15669) +* [`useless_attribute`] fixed FP on `deprecated_in_future` + [#15645](https://github.com/rust-lang/rust-clippy/pull/15645) +* [`double_parens`] fixed FP when macros are involved + [#15420](https://github.com/rust-lang/rust-clippy/pull/15420) ## Rust 1.91 @@ -6280,6 +6356,7 @@ Released 2018-09-13 [`cyclomatic_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cyclomatic_complexity [`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro [`debug_assert_with_mut_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#debug_assert_with_mut_call +[`decimal_bitwise_operands`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_bitwise_operands [`decimal_literal_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation [`declare_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const [`default_constructed_unit_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_constructed_unit_structs @@ -6541,6 +6618,7 @@ Released 2018-09-13 [`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten [`manual_hash_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one [`manual_ignore_case_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ignore_case_cmp +[`manual_ilog2`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ilog2 [`manual_inspect`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect [`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed [`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check @@ -6686,6 +6764,7 @@ Released 2018-09-13 [`needless_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [`needless_return_with_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return_with_question_mark [`needless_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_splitn +[`needless_type_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_type_cast [`needless_update`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_update [`neg_cmp_op_on_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_cmp_op_on_partial_ord [`neg_multiply`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply @@ -6765,6 +6844,7 @@ Released 2018-09-13 [`ptr_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr [`ptr_cast_constness`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness [`ptr_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq +[`ptr_offset_by_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_by_literal [`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast [`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names [`pub_underscore_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_underscore_fields @@ -7081,6 +7161,7 @@ Released 2018-09-13 [`allow-expect-in-consts`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-consts [`allow-expect-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-tests [`allow-indexing-slicing-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-indexing-slicing-in-tests +[`allow-large-stack-frames-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-large-stack-frames-in-tests [`allow-mixed-uninlined-format-args`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-mixed-uninlined-format-args [`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings [`allow-panic-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-panic-in-tests diff --git a/Cargo.toml b/Cargo.toml index fee885d8fa7e..67078adea2b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.1.93" +version = "0.1.94" description = "A bunch of helpful lints to avoid common pitfalls in Rust" repository = "https://github.com/rust-lang/rust-clippy" readme = "README.md" diff --git a/README.md b/README.md index 20a5e997e629..78498c73ae78 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. -[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) +[There are over 800 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category. diff --git a/book/src/README.md b/book/src/README.md index 5d2c3972b060..c5b264c9f703 100644 --- a/book/src/README.md +++ b/book/src/README.md @@ -5,7 +5,7 @@ A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. -[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) +[There are over 800 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index 2e185fb3a086..a1c079898594 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -111,6 +111,16 @@ Whether `indexing_slicing` should be allowed in test functions or `#[cfg(test)]` * [`indexing_slicing`](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing) +## `allow-large-stack-frames-in-tests` +Whether functions inside `#[cfg(test)]` modules or test functions should be checked. + +**Default Value:** `true` + +--- +**Affected lints:** +* [`large_stack_frames`](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames) + + ## `allow-mixed-uninlined-format-args` Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)` diff --git a/clippy_config/Cargo.toml b/clippy_config/Cargo.toml index 3f6b26d3334e..a65fe7bcbda5 100644 --- a/clippy_config/Cargo.toml +++ b/clippy_config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy_config" -version = "0.1.93" +version = "0.1.94" edition = "2024" publish = false diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs index 2e9cf8e91f7d..e1d7c1d88eb9 100644 --- a/clippy_config/src/conf.rs +++ b/clippy_config/src/conf.rs @@ -373,6 +373,9 @@ define_Conf! { /// Whether `indexing_slicing` should be allowed in test functions or `#[cfg(test)]` #[lints(indexing_slicing)] allow_indexing_slicing_in_tests: bool = false, + /// Whether functions inside `#[cfg(test)]` modules or test functions should be checked. + #[lints(large_stack_frames)] + allow_large_stack_frames_in_tests: bool = true, /// Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)` #[lints(uninlined_format_args)] allow_mixed_uninlined_format_args: bool = true, diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index bc97746a1cba..7a78ef32bf3c 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy_lints" -version = "0.1.93" +version = "0.1.94" description = "A bunch of helpful lints to avoid common pitfalls in Rust" repository = "https://github.com/rust-lang/rust-clippy" readme = "README.md" diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 47cc1da0a6e9..494d6180d3cb 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -19,6 +19,7 @@ mod fn_to_numeric_cast; mod fn_to_numeric_cast_any; mod fn_to_numeric_cast_with_truncation; mod manual_dangling_ptr; +mod needless_type_cast; mod ptr_as_ptr; mod ptr_cast_constness; mod ref_as_ptr; @@ -813,6 +814,32 @@ declare_clippy_lint! { "casting a primitive method pointer to any integer type" } +declare_clippy_lint! { + /// ### What it does + /// Checks for bindings (constants, statics, or let bindings) that are defined + /// with one numeric type but are consistently cast to a different type in all usages. + /// + /// ### Why is this bad? + /// If a binding is always cast to a different type when used, it would be clearer + /// and more efficient to define it with the target type from the start. + /// + /// ### Example + /// ```no_run + /// const SIZE: u16 = 15; + /// let arr: [u8; SIZE as usize] = [0; SIZE as usize]; + /// ``` + /// + /// Use instead: + /// ```no_run + /// const SIZE: usize = 15; + /// let arr: [u8; SIZE] = [0; SIZE]; + /// ``` + #[clippy::version = "1.93.0"] + pub NEEDLESS_TYPE_CAST, + pedantic, + "binding defined with one type but always cast to another" +} + pub struct Casts { msrv: Msrv, } @@ -851,6 +878,7 @@ impl_lint_pass!(Casts => [ AS_POINTER_UNDERSCORE, MANUAL_DANGLING_PTR, CONFUSING_METHOD_TO_NUMERIC_CAST, + NEEDLESS_TYPE_CAST, ]); impl<'tcx> LateLintPass<'tcx> for Casts { @@ -920,4 +948,8 @@ impl<'tcx> LateLintPass<'tcx> for Casts { cast_slice_different_sizes::check(cx, expr, self.msrv); ptr_cast_constness::check_null_ptr_cast_method(cx, expr); } + + fn check_body(&mut self, cx: &LateContext<'tcx>, body: &rustc_hir::Body<'tcx>) { + needless_type_cast::check(cx, body); + } } diff --git a/clippy_lints/src/casts/needless_type_cast.rs b/clippy_lints/src/casts/needless_type_cast.rs new file mode 100644 index 000000000000..ca6aa0f87bbf --- /dev/null +++ b/clippy_lints/src/casts/needless_type_cast.rs @@ -0,0 +1,289 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::visitors::{Descend, for_each_expr, for_each_expr_without_closures}; +use core::ops::ControlFlow; +use rustc_data_structures::fx::FxHashMap; +use rustc_errors::Applicability; +use rustc_hir::def::{DefKind, Res}; +use rustc_hir::{BlockCheckMode, Body, Expr, ExprKind, HirId, LetStmt, PatKind, StmtKind, UnsafeSource}; +use rustc_lint::LateContext; +use rustc_middle::ty::{Ty, TypeVisitableExt}; +use rustc_span::Span; + +use super::NEEDLESS_TYPE_CAST; + +struct BindingInfo<'a> { + source_ty: Ty<'a>, + ty_span: Span, +} + +struct UsageInfo<'a> { + cast_to: Option>, + in_generic_context: bool, +} + +pub(super) fn check<'a>(cx: &LateContext<'a>, body: &Body<'a>) { + let mut bindings: FxHashMap> = FxHashMap::default(); + + for_each_expr_without_closures(body.value, |expr| { + match expr.kind { + ExprKind::Block(block, _) => { + for stmt in block.stmts { + if let StmtKind::Let(let_stmt) = stmt.kind { + collect_binding_from_local(cx, let_stmt, &mut bindings); + } + } + }, + ExprKind::Let(let_expr) => { + collect_binding_from_let(cx, let_expr, &mut bindings); + }, + _ => {}, + } + ControlFlow::<()>::Continue(()) + }); + + #[allow(rustc::potential_query_instability)] + let mut binding_vec: Vec<_> = bindings.into_iter().collect(); + binding_vec.sort_by_key(|(_, info)| info.ty_span.lo()); + + for (hir_id, binding_info) in binding_vec { + check_binding_usages(cx, body, hir_id, &binding_info); + } +} + +fn collect_binding_from_let<'a>( + cx: &LateContext<'a>, + let_expr: &rustc_hir::LetExpr<'a>, + bindings: &mut FxHashMap>, +) { + if let_expr.ty.is_none() + || let_expr.span.from_expansion() + || has_generic_return_type(cx, let_expr.init) + || contains_unsafe(let_expr.init) + { + return; + } + + if let PatKind::Binding(_, hir_id, _, _) = let_expr.pat.kind + && let Some(ty_hir) = let_expr.ty + { + let ty = cx.typeck_results().pat_ty(let_expr.pat); + if ty.is_numeric() { + bindings.insert( + hir_id, + BindingInfo { + source_ty: ty, + ty_span: ty_hir.span, + }, + ); + } + } +} + +fn collect_binding_from_local<'a>( + cx: &LateContext<'a>, + let_stmt: &LetStmt<'a>, + bindings: &mut FxHashMap>, +) { + if let_stmt.ty.is_none() + || let_stmt.span.from_expansion() + || let_stmt + .init + .is_some_and(|init| has_generic_return_type(cx, init) || contains_unsafe(init)) + { + return; + } + + if let PatKind::Binding(_, hir_id, _, _) = let_stmt.pat.kind + && let Some(ty_hir) = let_stmt.ty + { + let ty = cx.typeck_results().pat_ty(let_stmt.pat); + if ty.is_numeric() { + bindings.insert( + hir_id, + BindingInfo { + source_ty: ty, + ty_span: ty_hir.span, + }, + ); + } + } +} + +fn contains_unsafe(expr: &Expr<'_>) -> bool { + for_each_expr_without_closures(expr, |e| { + if let ExprKind::Block(block, _) = e.kind + && let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules + { + return ControlFlow::Break(()); + } + ControlFlow::Continue(()) + }) + .is_some() +} + +fn has_generic_return_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { + match &expr.kind { + ExprKind::Block(block, _) => { + if let Some(tail_expr) = block.expr { + return has_generic_return_type(cx, tail_expr); + } + false + }, + ExprKind::If(_, then_block, else_expr) => { + has_generic_return_type(cx, then_block) || else_expr.is_some_and(|e| has_generic_return_type(cx, e)) + }, + ExprKind::Match(_, arms, _) => arms.iter().any(|arm| has_generic_return_type(cx, arm.body)), + ExprKind::Loop(block, label, ..) => for_each_expr_without_closures(*block, |e| { + match e.kind { + ExprKind::Loop(..) => { + // Unlabeled breaks inside nested loops target the inner loop, not ours + return ControlFlow::Continue(Descend::No); + }, + ExprKind::Break(dest, Some(break_expr)) => { + let targets_this_loop = + dest.label.is_none() || dest.label.map(|l| l.ident) == label.map(|l| l.ident); + if targets_this_loop && has_generic_return_type(cx, break_expr) { + return ControlFlow::Break(()); + } + }, + _ => {}, + } + ControlFlow::Continue(Descend::Yes) + }) + .is_some(), + ExprKind::MethodCall(..) => { + if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { + let sig = cx.tcx.fn_sig(def_id).instantiate_identity(); + let ret_ty = sig.output().skip_binder(); + return ret_ty.has_param(); + } + false + }, + ExprKind::Call(callee, _) => { + if let ExprKind::Path(qpath) = &callee.kind { + let res = cx.qpath_res(qpath, callee.hir_id); + if let Res::Def(DefKind::Fn | DefKind::AssocFn, def_id) = res { + let sig = cx.tcx.fn_sig(def_id).instantiate_identity(); + let ret_ty = sig.output().skip_binder(); + return ret_ty.has_param(); + } + } + false + }, + _ => false, + } +} + +fn is_generic_res(cx: &LateContext<'_>, res: Res) -> bool { + let has_type_params = |def_id| { + cx.tcx + .generics_of(def_id) + .own_params + .iter() + .any(|p| p.kind.is_ty_or_const()) + }; + match res { + Res::Def(DefKind::Fn | DefKind::AssocFn, def_id) => has_type_params(def_id), + // Ctor → Variant → ADT: constructor's parent is variant, variant's parent is the ADT + Res::Def(DefKind::Ctor(..), def_id) => has_type_params(cx.tcx.parent(cx.tcx.parent(def_id))), + _ => false, + } +} + +fn is_cast_in_generic_context<'a>(cx: &LateContext<'a>, cast_expr: &Expr<'a>) -> bool { + let mut current_id = cast_expr.hir_id; + + loop { + let parent_id = cx.tcx.parent_hir_id(current_id); + if parent_id == current_id { + return false; + } + + let parent = cx.tcx.hir_node(parent_id); + + match parent { + rustc_hir::Node::Expr(parent_expr) => { + match &parent_expr.kind { + ExprKind::Closure(_) => return false, + ExprKind::Call(callee, _) => { + if let ExprKind::Path(qpath) = &callee.kind { + let res = cx.qpath_res(qpath, callee.hir_id); + if is_generic_res(cx, res) { + return true; + } + } + }, + ExprKind::MethodCall(..) => { + if let Some(def_id) = cx.typeck_results().type_dependent_def_id(parent_expr.hir_id) + && cx + .tcx + .generics_of(def_id) + .own_params + .iter() + .any(|p| p.kind.is_ty_or_const()) + { + return true; + } + }, + _ => {}, + } + current_id = parent_id; + }, + _ => return false, + } + } +} + +fn check_binding_usages<'a>(cx: &LateContext<'a>, body: &Body<'a>, hir_id: HirId, binding_info: &BindingInfo<'a>) { + let mut usages = Vec::new(); + + for_each_expr(cx, body.value, |expr| { + if let ExprKind::Path(ref qpath) = expr.kind + && !expr.span.from_expansion() + && let Res::Local(id) = cx.qpath_res(qpath, expr.hir_id) + && id == hir_id + { + let parent_id = cx.tcx.parent_hir_id(expr.hir_id); + let parent = cx.tcx.hir_node(parent_id); + + let usage = if let rustc_hir::Node::Expr(parent_expr) = parent + && let ExprKind::Cast(..) = parent_expr.kind + && !parent_expr.span.from_expansion() + { + UsageInfo { + cast_to: Some(cx.typeck_results().expr_ty(parent_expr)), + in_generic_context: is_cast_in_generic_context(cx, parent_expr), + } + } else { + UsageInfo { + cast_to: None, + in_generic_context: false, + } + }; + usages.push(usage); + } + ControlFlow::<()>::Continue(()) + }); + + let Some(first_target) = usages + .first() + .and_then(|u| u.cast_to) + .filter(|&t| t != binding_info.source_ty) + .filter(|&t| usages.iter().all(|u| u.cast_to == Some(t) && !u.in_generic_context)) + else { + return; + }; + + span_lint_and_sugg( + cx, + NEEDLESS_TYPE_CAST, + binding_info.ty_span, + format!( + "this binding is defined as `{}` but is always cast to `{}`", + binding_info.source_ty, first_target + ), + "consider defining it as", + first_target.to_string(), + Applicability::MaybeIncorrect, + ); +} diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 4a350dca2993..87d75234ebc0 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -70,6 +70,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[ crate::casts::FN_TO_NUMERIC_CAST_ANY_INFO, crate::casts::FN_TO_NUMERIC_CAST_WITH_TRUNCATION_INFO, crate::casts::MANUAL_DANGLING_PTR_INFO, + crate::casts::NEEDLESS_TYPE_CAST_INFO, crate::casts::PTR_AS_PTR_INFO, crate::casts::PTR_CAST_CONSTNESS_INFO, crate::casts::REF_AS_PTR_INFO, @@ -245,8 +246,8 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[ crate::large_stack_arrays::LARGE_STACK_ARRAYS_INFO, crate::large_stack_frames::LARGE_STACK_FRAMES_INFO, crate::legacy_numeric_constants::LEGACY_NUMERIC_CONSTANTS_INFO, + crate::len_without_is_empty::LEN_WITHOUT_IS_EMPTY_INFO, crate::len_zero::COMPARISON_TO_EMPTY_INFO, - crate::len_zero::LEN_WITHOUT_IS_EMPTY_INFO, crate::len_zero::LEN_ZERO_INFO, crate::let_if_seq::USELESS_LET_IF_SEQ_INFO, crate::let_underscore::LET_UNDERSCORE_FUTURE_INFO, @@ -300,6 +301,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[ crate::manual_float_methods::MANUAL_IS_INFINITE_INFO, crate::manual_hash_one::MANUAL_HASH_ONE_INFO, crate::manual_ignore_case_cmp::MANUAL_IGNORE_CASE_CMP_INFO, + crate::manual_ilog2::MANUAL_ILOG2_INFO, crate::manual_is_ascii_check::MANUAL_IS_ASCII_CHECK_INFO, crate::manual_is_power_of_two::MANUAL_IS_POWER_OF_TWO_INFO, crate::manual_let_else::MANUAL_LET_ELSE_INFO, @@ -444,6 +446,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[ crate::methods::OR_THEN_UNWRAP_INFO, crate::methods::PATH_BUF_PUSH_OVERWRITE_INFO, crate::methods::PATH_ENDS_WITH_EXT_INFO, + crate::methods::PTR_OFFSET_BY_LITERAL_INFO, crate::methods::PTR_OFFSET_WITH_CAST_INFO, crate::methods::RANGE_ZIP_WITH_LEN_INFO, crate::methods::READONLY_WRITE_LOCK_INFO, @@ -578,6 +581,7 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[ crate::operators::ASSIGN_OP_PATTERN_INFO, crate::operators::BAD_BIT_MASK_INFO, crate::operators::CMP_OWNED_INFO, + crate::operators::DECIMAL_BITWISE_OPERANDS_INFO, crate::operators::DOUBLE_COMPARISONS_INFO, crate::operators::DURATION_SUBSEC_INFO, crate::operators::EQ_OP_INFO, diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index f010d17917f9..6e62e983d2f3 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -34,7 +34,7 @@ declare_with_version! { DEPRECATED(DEPRECATED_VERSION) = [ #[clippy::version = "pre 1.29.0"] ("clippy::should_assert_eq", "`assert!(a == b)` can now print the values the same way `assert_eq!(a, b) can"), #[clippy::version = "1.91.0"] - ("clippy::string_to_string", "`clippy:implicit_clone` covers those cases"), + ("clippy::string_to_string", "`clippy::implicit_clone` covers those cases"), #[clippy::version = "pre 1.29.0"] ("clippy::unsafe_vector_initialization", "the suggested alternative could be substantially slower"), #[clippy::version = "pre 1.29.0"] diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index a5ec6777b434..bdfe2e49e66e 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -3,11 +3,12 @@ use clippy_utils::source::{reindent_multiline, snippet_indent, snippet_with_appl use clippy_utils::ty::is_copy; use clippy_utils::visitors::for_each_expr; use clippy_utils::{ - SpanlessEq, can_move_expr_to_closure_no_visit, higher, is_expr_final_block_expr, is_expr_used_or_unified, - peel_hir_expr_while, + SpanlessEq, can_move_expr_to_closure_no_visit, desugar_await, higher, is_expr_final_block_expr, + is_expr_used_or_unified, paths, peel_hir_expr_while, }; use core::fmt::{self, Write}; use rustc_errors::Applicability; +use rustc_hir::def_id::DefId; use rustc_hir::hir_id::HirIdSet; use rustc_hir::intravisit::{Visitor, walk_body, walk_expr}; use rustc_hir::{Block, Expr, ExprKind, HirId, Pat, Stmt, StmtKind, UnOp}; @@ -382,6 +383,8 @@ struct InsertSearcher<'cx, 'tcx> { loops: Vec, /// Local variables created in the expression. These don't need to be captured. locals: HirIdSet, + /// Whether the map is a non-async-aware `MutexGuard`. + map_is_mutex_guard: bool, } impl<'tcx> InsertSearcher<'_, 'tcx> { /// Visit the expression as a branch in control flow. Multiple insert calls can be used, but @@ -524,15 +527,22 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> { ExprKind::If(cond_expr, then_expr, Some(else_expr)) => { self.is_single_insert = false; self.visit_non_tail_expr(cond_expr); - // Each branch may contain it's own insert expression. + // Each branch may contain its own insert expression. let mut is_map_used = self.visit_cond_arm(then_expr); is_map_used |= self.visit_cond_arm(else_expr); self.is_map_used = is_map_used; }, ExprKind::Match(scrutinee_expr, arms, _) => { + // If the map is a non-async-aware `MutexGuard` and + // `.await` expression appears alongside map insertion in the same `then` or `else` block, + // we cannot suggest using `entry()` because it would hold the lock across the await point, + // triggering `await_holding_lock` and risking deadlock. + if self.map_is_mutex_guard && desugar_await(expr).is_some() { + self.can_use_entry = false; + } self.is_single_insert = false; self.visit_non_tail_expr(scrutinee_expr); - // Each branch may contain it's own insert expression. + // Each branch may contain its own insert expression. let mut is_map_used = self.is_map_used; for arm in arms { self.visit_pat(arm.pat); @@ -725,16 +735,32 @@ fn find_insert_calls<'tcx>( edits: Vec::new(), loops: Vec::new(), locals: HirIdSet::default(), + map_is_mutex_guard: false, }; + // Check if the map is a non-async-aware `MutexGuard` + if let rustc_middle::ty::Adt(adt, _) = cx.typeck_results().expr_ty(contains_expr.map).kind() + && is_mutex_guard(cx, adt.did()) + { + s.map_is_mutex_guard = true; + } + s.visit_expr(expr); - let allow_insert_closure = s.allow_insert_closure; - let is_single_insert = s.is_single_insert; + if !s.can_use_entry { + return None; + } + let is_key_used_and_no_copy = s.is_key_used && !is_copy(cx, cx.typeck_results().expr_ty(contains_expr.key)); - let edits = s.edits; - s.can_use_entry.then_some(InsertSearchResults { - edits, - allow_insert_closure, - is_single_insert, + Some(InsertSearchResults { + edits: s.edits, + allow_insert_closure: s.allow_insert_closure, + is_single_insert: s.is_single_insert, is_key_used_and_no_copy, }) } + +fn is_mutex_guard(cx: &LateContext<'_>, def_id: DefId) -> bool { + match cx.tcx.get_diagnostic_name(def_id) { + Some(name) => matches!(name, sym::MutexGuard | sym::RwLockReadGuard | sym::RwLockWriteGuard), + None => paths::PARKING_LOT_GUARDS.iter().any(|guard| guard.matches(cx, def_id)), + } +} diff --git a/clippy_lints/src/large_stack_frames.rs b/clippy_lints/src/large_stack_frames.rs index 5ed948c02bbc..6b0080d04c44 100644 --- a/clippy_lints/src/large_stack_frames.rs +++ b/clippy_lints/src/large_stack_frames.rs @@ -2,15 +2,16 @@ use std::{fmt, ops}; use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::fn_has_unsatisfiable_preds; -use clippy_utils::source::SpanRangeExt; +use clippy_utils::source::{HasSession, SpanRangeExt}; +use clippy_utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, is_in_test}; +use rustc_errors::Diag; use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl}; use rustc_lexer::is_ident; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::Span; +use rustc_span::{Span, SyntaxContext}; declare_clippy_lint! { /// ### What it does @@ -83,12 +84,14 @@ declare_clippy_lint! { pub struct LargeStackFrames { maximum_allowed_size: u64, + allow_large_stack_frames_in_tests: bool, } impl LargeStackFrames { pub fn new(conf: &'static Conf) -> Self { Self { maximum_allowed_size: conf.stack_size_threshold, + allow_large_stack_frames_in_tests: conf.allow_large_stack_frames_in_tests, } } } @@ -152,67 +155,122 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames { let mir = cx.tcx.optimized_mir(def_id); let typing_env = mir.typing_env(cx.tcx); - let sizes_of_locals = || { - mir.local_decls.iter().filter_map(|local| { + let sizes_of_locals = mir + .local_decls + .iter() + .filter_map(|local| { let layout = cx.tcx.layout_of(typing_env.as_query_input(local.ty)).ok()?; Some((local, layout.size.bytes())) }) - }; + .collect::>(); - let frame_size = sizes_of_locals().fold(Space::Used(0), |sum, (_, size)| sum + size); + let frame_size = sizes_of_locals + .iter() + .fold(Space::Used(0), |sum, (_, size)| sum + *size); let limit = self.maximum_allowed_size; if frame_size.exceeds_limit(limit) { // Point at just the function name if possible, because lints that span // the entire body and don't have to are less legible. - let fn_span = match fn_kind { - FnKind::ItemFn(ident, _, _) | FnKind::Method(ident, _) => ident.span, - FnKind::Closure => entire_fn_span, + let (fn_span, fn_name) = match fn_kind { + FnKind::ItemFn(ident, _, _) => (ident.span, format!("function `{}`", ident.name)), + FnKind::Method(ident, _) => (ident.span, format!("method `{}`", ident.name)), + FnKind::Closure => (entire_fn_span, "closure".to_string()), }; + // Don't lint inside tests if configured to not do so. + if self.allow_large_stack_frames_in_tests && is_in_test(cx.tcx, cx.tcx.local_def_id_to_hir_id(local_def_id)) + { + return; + } + + let explain_lint = |diag: &mut Diag<'_, ()>, ctxt: SyntaxContext| { + // Point out the largest individual contribution to this size, because + // it is the most likely to be unintentionally large. + if let Some((local, size)) = sizes_of_locals.iter().max_by_key(|&(_, size)| size) + && let local_span = local.source_info.span + && local_span.ctxt() == ctxt + { + let size = Space::Used(*size); // pluralizes for us + let ty = local.ty; + + // TODO: Is there a cleaner, robust way to ask this question? + // The obvious `LocalDecl::is_user_variable()` panics on "unwrapping cross-crate data", + // and that doesn't get us the true name in scope rather than the span text either. + if let Some(name) = local_span.get_source_text(cx) + && is_ident(&name) + { + // If the local is an ordinary named variable, + // print its name rather than relying solely on the span. + diag.span_label( + local_span, + format!("`{name}` is the largest part, at {size} for type `{ty}`"), + ); + } else { + diag.span_label( + local_span, + format!("this is the largest part, at {size} for type `{ty}`"), + ); + } + } + + // Explain why we are linting this and not other functions. + diag.note(format!( + "{frame_size} is larger than Clippy's configured `stack-size-threshold` of {limit}" + )); + + // Explain why the user should care, briefly. + diag.note_once( + "allocating large amounts of stack space can overflow the stack \ + and cause the program to abort", + ); + }; + + if fn_span.from_expansion() { + // Don't lint on the main function generated by `--test` target + if cx.sess().is_test_crate() && is_entrypoint_fn(cx, local_def_id.to_def_id()) { + return; + } + + let is_from_external_macro = fn_span.in_external_macro(cx.sess().source_map()); + span_lint_and_then( + cx, + LARGE_STACK_FRAMES, + fn_span.source_callsite(), + format!( + "{} generated by this macro may allocate a lot of stack space", + if is_from_external_macro { + cx.tcx.def_descr(local_def_id.into()) + } else { + fn_name.as_str() + } + ), + |diag| { + if is_from_external_macro { + return; + } + + diag.span_label( + fn_span, + format!( + "this {} has a stack frame size of {frame_size}", + cx.tcx.def_descr(local_def_id.into()) + ), + ); + + explain_lint(diag, fn_span.ctxt()); + }, + ); + return; + } + span_lint_and_then( cx, LARGE_STACK_FRAMES, fn_span, format!("this function may allocate {frame_size} on the stack"), |diag| { - // Point out the largest individual contribution to this size, because - // it is the most likely to be unintentionally large. - if let Some((local, size)) = sizes_of_locals().max_by_key(|&(_, size)| size) { - let local_span: Span = local.source_info.span; - let size = Space::Used(size); // pluralizes for us - let ty = local.ty; - - // TODO: Is there a cleaner, robust way to ask this question? - // The obvious `LocalDecl::is_user_variable()` panics on "unwrapping cross-crate data", - // and that doesn't get us the true name in scope rather than the span text either. - if let Some(name) = local_span.get_source_text(cx) - && is_ident(&name) - { - // If the local is an ordinary named variable, - // print its name rather than relying solely on the span. - diag.span_label( - local_span, - format!("`{name}` is the largest part, at {size} for type `{ty}`"), - ); - } else { - diag.span_label( - local_span, - format!("this is the largest part, at {size} for type `{ty}`"), - ); - } - } - - // Explain why we are linting this and not other functions. - diag.note(format!( - "{frame_size} is larger than Clippy's configured `stack-size-threshold` of {limit}" - )); - - // Explain why the user should care, briefly. - diag.note_once( - "allocating large amounts of stack space can overflow the stack \ - and cause the program to abort", - ); + explain_lint(diag, SyntaxContext::root()); }, ); } diff --git a/clippy_lints/src/len_without_is_empty.rs b/clippy_lints/src/len_without_is_empty.rs new file mode 100644 index 000000000000..1d219d7c3b74 --- /dev/null +++ b/clippy_lints/src/len_without_is_empty.rs @@ -0,0 +1,342 @@ +use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; +use clippy_utils::res::MaybeDef; +use clippy_utils::{fulfill_or_allowed, get_parent_as_impl, sym}; +use rustc_hir::def::Res; +use rustc_hir::def_id::{DefId, DefIdSet}; +use rustc_hir::{ + FnRetTy, GenericArg, GenericBound, HirId, ImplItem, ImplItemKind, ImplicitSelfKind, Item, ItemKind, Mutability, + Node, OpaqueTyOrigin, PathSegment, PrimTy, QPath, TraitItemId, TyKind, +}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::{self, FnSig, Ty}; +use rustc_session::declare_lint_pass; +use rustc_span::symbol::kw; +use rustc_span::{Ident, Span, Symbol}; +use rustc_trait_selection::traits::supertrait_def_ids; + +declare_clippy_lint! { + /// ### What it does + /// Checks for items that implement `.len()` but not + /// `.is_empty()`. + /// + /// ### Why is this bad? + /// It is good custom to have both methods, because for + /// some data structures, asking about the length will be a costly operation, + /// whereas `.is_empty()` can usually answer in constant time. Also it used to + /// lead to false positives on the [`len_zero`](#len_zero) lint – currently that + /// lint will ignore such entities. + /// + /// ### Example + /// ```ignore + /// impl X { + /// pub fn len(&self) -> usize { + /// .. + /// } + /// } + /// ``` + #[clippy::version = "pre 1.29.0"] + pub LEN_WITHOUT_IS_EMPTY, + style, + "traits or impls with a public `len` method but no corresponding `is_empty` method" +} + +declare_lint_pass!(LenWithoutIsEmpty => [LEN_WITHOUT_IS_EMPTY]); + +impl<'tcx> LateLintPass<'tcx> for LenWithoutIsEmpty { + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { + if let ItemKind::Trait(_, _, _, ident, _, _, trait_items) = item.kind + && !item.span.from_expansion() + { + check_trait_items(cx, item, ident, trait_items); + } + } + + fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) { + if item.ident.name == sym::len + && let ImplItemKind::Fn(sig, _) = &item.kind + && sig.decl.implicit_self.has_implicit_self() + && sig.decl.inputs.len() == 1 + && cx.effective_visibilities.is_exported(item.owner_id.def_id) + && matches!(sig.decl.output, FnRetTy::Return(_)) + && let Some(imp) = get_parent_as_impl(cx.tcx, item.hir_id()) + && imp.of_trait.is_none() + && let TyKind::Path(ty_path) = &imp.self_ty.kind + && let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id() + && let Some(local_id) = ty_id.as_local() + && let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_id) + && let Some(output) = LenOutput::new(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder()) + { + let (name, kind) = match cx.tcx.hir_node(ty_hir_id) { + Node::ForeignItem(x) => (x.ident.name, "extern type"), + Node::Item(x) => match x.kind { + ItemKind::Struct(ident, ..) => (ident.name, "struct"), + ItemKind::Enum(ident, ..) => (ident.name, "enum"), + ItemKind::Union(ident, ..) => (ident.name, "union"), + _ => (x.kind.ident().unwrap().name, "type"), + }, + _ => return, + }; + check_for_is_empty( + cx, + sig.span, + sig.decl.implicit_self, + output, + ty_id, + name, + kind, + item.hir_id(), + ty_hir_id, + ); + } + } +} + +fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, ident: Ident, trait_items: &[TraitItemId]) { + fn is_named_self(cx: &LateContext<'_>, item: TraitItemId, name: Symbol) -> bool { + cx.tcx.item_name(item.owner_id) == name + && matches!( + cx.tcx.fn_arg_idents(item.owner_id), + [Some(Ident { + name: kw::SelfLower, + .. + })], + ) + } + + // fill the set with current and super traits + fn fill_trait_set(traitt: DefId, set: &mut DefIdSet, cx: &LateContext<'_>) { + if set.insert(traitt) { + for supertrait in supertrait_def_ids(cx.tcx, traitt) { + fill_trait_set(supertrait, set, cx); + } + } + } + + if cx.effective_visibilities.is_exported(visited_trait.owner_id.def_id) + && trait_items.iter().any(|&i| is_named_self(cx, i, sym::len)) + { + let mut current_and_super_traits = DefIdSet::default(); + fill_trait_set(visited_trait.owner_id.to_def_id(), &mut current_and_super_traits, cx); + let is_empty_method_found = current_and_super_traits + .items() + .flat_map(|&i| cx.tcx.associated_items(i).filter_by_name_unhygienic(sym::is_empty)) + .any(|i| i.is_method() && cx.tcx.fn_sig(i.def_id).skip_binder().inputs().skip_binder().len() == 1); + + if !is_empty_method_found { + span_lint( + cx, + LEN_WITHOUT_IS_EMPTY, + visited_trait.span, + format!( + "trait `{}` has a `len` method but no (possibly inherited) `is_empty` method", + ident.name + ), + ); + } + } +} + +fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&'tcx PathSegment<'tcx>> { + if let ty::Alias(_, alias_ty) = ty.kind() + && let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir_get_if_local(alias_ty.def_id) + && let OpaqueTyOrigin::AsyncFn { .. } = opaque.origin + && let [GenericBound::Trait(trait_ref)] = &opaque.bounds + && let Some(segment) = trait_ref.trait_ref.path.segments.last() + && let Some(generic_args) = segment.args + && let [constraint] = generic_args.constraints + && let Some(ty) = constraint.ty() + && let TyKind::Path(QPath::Resolved(_, path)) = ty.kind + && let [segment] = path.segments + { + return Some(segment); + } + + None +} + +fn is_first_generic_integral<'tcx>(segment: &'tcx PathSegment<'tcx>) -> bool { + if let Some(generic_args) = segment.args + && let [GenericArg::Type(ty), ..] = &generic_args.args + && let TyKind::Path(QPath::Resolved(_, path)) = ty.kind + && let [segment, ..] = &path.segments + && matches!(segment.res, Res::PrimTy(PrimTy::Uint(_) | PrimTy::Int(_))) + { + true + } else { + false + } +} + +#[derive(Debug, Clone, Copy)] +enum LenOutput { + Integral, + Option(DefId), + Result(DefId), +} + +impl LenOutput { + fn new<'tcx>(cx: &LateContext<'tcx>, sig: FnSig<'tcx>) -> Option { + if let Some(segment) = extract_future_output(cx, sig.output()) { + let res = segment.res; + + if matches!(res, Res::PrimTy(PrimTy::Uint(_) | PrimTy::Int(_))) { + return Some(Self::Integral); + } + + if let Res::Def(_, def_id) = res + && let Some(res) = match cx.tcx.get_diagnostic_name(def_id) { + Some(sym::Option) => Some(Self::Option(def_id)), + Some(sym::Result) => Some(Self::Result(def_id)), + _ => None, + } + && is_first_generic_integral(segment) + { + return Some(res); + } + + return None; + } + + match *sig.output().kind() { + ty::Int(_) | ty::Uint(_) => Some(Self::Integral), + ty::Adt(adt, subs) => match cx.tcx.get_diagnostic_name(adt.did()) { + Some(sym::Option) => subs.type_at(0).is_integral().then(|| Self::Option(adt.did())), + Some(sym::Result) => subs.type_at(0).is_integral().then(|| Self::Result(adt.did())), + _ => None, + }, + _ => None, + } + } + + fn matches_is_empty_output<'tcx>(self, cx: &LateContext<'tcx>, is_empty_output: Ty<'tcx>) -> bool { + if let Some(segment) = extract_future_output(cx, is_empty_output) { + return match (self, segment.res) { + (_, Res::PrimTy(PrimTy::Bool)) => true, + (Self::Option(_), Res::Def(_, def_id)) if cx.tcx.is_diagnostic_item(sym::Option, def_id) => true, + (Self::Result(_), Res::Def(_, def_id)) if cx.tcx.is_diagnostic_item(sym::Result, def_id) => true, + _ => false, + }; + } + + match (self, is_empty_output.kind()) { + (_, &ty::Bool) => true, + (Self::Option(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), + (Self::Result(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), + _ => false, + } + } +} + +/// The expected signature of `is_empty`, based on that of `len` +fn expected_is_empty_sig(len_output: LenOutput, len_self_kind: ImplicitSelfKind) -> String { + let self_ref = match len_self_kind { + ImplicitSelfKind::RefImm => "&", + ImplicitSelfKind::RefMut => "&(mut) ", + _ => "", + }; + match len_output { + LenOutput::Integral => format!("expected signature: `({self_ref}self) -> bool`"), + LenOutput::Option(_) => { + format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Option") + }, + LenOutput::Result(..) => { + format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Result") + }, + } +} + +/// Checks if the given signature matches the expectations for `is_empty` +fn check_is_empty_sig<'tcx>( + cx: &LateContext<'tcx>, + is_empty_sig: FnSig<'tcx>, + len_self_kind: ImplicitSelfKind, + len_output: LenOutput, +) -> bool { + if let [is_empty_self_arg, is_empty_output] = &**is_empty_sig.inputs_and_output + && len_output.matches_is_empty_output(cx, *is_empty_output) + { + match (is_empty_self_arg.kind(), len_self_kind) { + // if `len` takes `&self`, `is_empty` should do so as well + (ty::Ref(_, _, Mutability::Not), ImplicitSelfKind::RefImm) + // if `len` takes `&mut self`, `is_empty` may take that _or_ `&self` (#16190) + | (ty::Ref(_, _, Mutability::Mut | Mutability::Not), ImplicitSelfKind::RefMut) => true, + // if len takes `self`, `is_empty` should do so as well + // XXX: we might want to relax this to allow `&self` and `&mut self` + (_, ImplicitSelfKind::Imm | ImplicitSelfKind::Mut) if !is_empty_self_arg.is_ref() => true, + _ => false, + } + } else { + false + } +} + +/// Checks if the given type has an `is_empty` method with the appropriate signature. +#[expect(clippy::too_many_arguments)] +fn check_for_is_empty( + cx: &LateContext<'_>, + len_span: Span, + len_self_kind: ImplicitSelfKind, + len_output: LenOutput, + impl_ty: DefId, + item_name: Symbol, + item_kind: &str, + len_method_hir_id: HirId, + ty_decl_hir_id: HirId, +) { + // Implementor may be a type alias, in which case we need to get the `DefId` of the aliased type to + // find the correct inherent impls. + let impl_ty = if let Some(adt) = cx.tcx.type_of(impl_ty).skip_binder().ty_adt_def() { + adt.did() + } else { + return; + }; + + let is_empty = cx + .tcx + .inherent_impls(impl_ty) + .iter() + .flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(sym::is_empty)) + .find(|item| item.is_fn()); + + let (msg, is_empty_span, is_empty_expected_sig) = match is_empty { + None => ( + format!("{item_kind} `{item_name}` has a public `len` method, but no `is_empty` method"), + None, + None, + ), + Some(is_empty) if !cx.effective_visibilities.is_exported(is_empty.def_id.expect_local()) => ( + format!("{item_kind} `{item_name}` has a public `len` method, but a private `is_empty` method"), + Some(cx.tcx.def_span(is_empty.def_id)), + None, + ), + Some(is_empty) + if !(is_empty.is_method() + && check_is_empty_sig( + cx, + cx.tcx.fn_sig(is_empty.def_id).instantiate_identity().skip_binder(), + len_self_kind, + len_output, + )) => + { + ( + format!( + "{item_kind} `{item_name}` has a public `len` method, but the `is_empty` method has an unexpected signature", + ), + Some(cx.tcx.def_span(is_empty.def_id)), + Some(expected_is_empty_sig(len_output, len_self_kind)), + ) + }, + Some(_) => return, + }; + + if !fulfill_or_allowed(cx, LEN_WITHOUT_IS_EMPTY, [len_method_hir_id, ty_decl_hir_id]) { + span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, len_span, msg, |db| { + if let Some(span) = is_empty_span { + db.span_note(span, "`is_empty` defined here"); + } + if let Some(expected_sig) = is_empty_expected_sig { + db.note(expected_sig); + } + }); + } +} diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 877bd34a732b..2e576da38b89 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,27 +1,20 @@ use clippy_config::Conf; -use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::msrvs::Msrv; use clippy_utils::res::{MaybeDef, MaybeTypeckRes}; use clippy_utils::source::{SpanRangeExt, snippet_with_context}; use clippy_utils::sugg::{Sugg, has_enclosing_paren}; use clippy_utils::ty::implements_trait; -use clippy_utils::{fulfill_or_allowed, get_parent_as_impl, parent_item_name, peel_ref_operators, sym}; +use clippy_utils::{parent_item_name, peel_ref_operators, sym}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::def::Res; -use rustc_hir::def_id::{DefId, DefIdSet}; -use rustc_hir::{ - BinOpKind, Expr, ExprKind, FnRetTy, GenericArg, GenericBound, HirId, ImplItem, ImplItemKind, ImplicitSelfKind, - Item, ItemKind, Mutability, Node, OpaqueTyOrigin, PatExprKind, PatKind, PathSegment, PrimTy, QPath, RustcVersion, - StabilityLevel, StableSince, TraitItemId, TyKind, -}; +use rustc_hir::def_id::DefId; +use rustc_hir::{BinOpKind, Expr, ExprKind, PatExprKind, PatKind, RustcVersion, StabilityLevel, StableSince}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::{self, FnSig, Ty}; +use rustc_middle::ty::{self, Ty}; use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; -use rustc_span::symbol::kw; -use rustc_span::{Ident, Span, Symbol}; -use rustc_trait_selection::traits::supertrait_def_ids; +use rustc_span::{Span, Symbol}; declare_clippy_lint! { /// ### What it does @@ -58,32 +51,6 @@ declare_clippy_lint! { "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead" } -declare_clippy_lint! { - /// ### What it does - /// Checks for items that implement `.len()` but not - /// `.is_empty()`. - /// - /// ### Why is this bad? - /// It is good custom to have both methods, because for - /// some data structures, asking about the length will be a costly operation, - /// whereas `.is_empty()` can usually answer in constant time. Also it used to - /// lead to false positives on the [`len_zero`](#len_zero) lint – currently that - /// lint will ignore such entities. - /// - /// ### Example - /// ```ignore - /// impl X { - /// pub fn len(&self) -> usize { - /// .. - /// } - /// } - /// ``` - #[clippy::version = "pre 1.29.0"] - pub LEN_WITHOUT_IS_EMPTY, - style, - "traits or impls with a public `len` method but no corresponding `is_empty` method" -} - declare_clippy_lint! { /// ### What it does /// Checks for comparing to an empty slice such as `""` or `[]`, @@ -126,7 +93,7 @@ pub struct LenZero { msrv: Msrv, } -impl_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY, COMPARISON_TO_EMPTY]); +impl_lint_pass!(LenZero => [LEN_ZERO, COMPARISON_TO_EMPTY]); impl LenZero { pub fn new(conf: &'static Conf) -> Self { @@ -135,54 +102,6 @@ impl LenZero { } impl<'tcx> LateLintPass<'tcx> for LenZero { - fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { - if let ItemKind::Trait(_, _, _, ident, _, _, trait_items) = item.kind - && !item.span.from_expansion() - { - check_trait_items(cx, item, ident, trait_items); - } - } - - fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) { - if item.ident.name == sym::len - && let ImplItemKind::Fn(sig, _) = &item.kind - && sig.decl.implicit_self.has_implicit_self() - && sig.decl.inputs.len() == 1 - && cx.effective_visibilities.is_exported(item.owner_id.def_id) - && matches!(sig.decl.output, FnRetTy::Return(_)) - && let Some(imp) = get_parent_as_impl(cx.tcx, item.hir_id()) - && imp.of_trait.is_none() - && let TyKind::Path(ty_path) = &imp.self_ty.kind - && let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id() - && let Some(local_id) = ty_id.as_local() - && let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_id) - && let Some(output) = - parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder()) - { - let (name, kind) = match cx.tcx.hir_node(ty_hir_id) { - Node::ForeignItem(x) => (x.ident.name, "extern type"), - Node::Item(x) => match x.kind { - ItemKind::Struct(ident, ..) => (ident.name, "struct"), - ItemKind::Enum(ident, ..) => (ident.name, "enum"), - ItemKind::Union(ident, ..) => (ident.name, "union"), - _ => (x.kind.ident().unwrap().name, "type"), - }, - _ => return, - }; - check_for_is_empty( - cx, - sig.span, - sig.decl.implicit_self, - output, - ty_id, - name, - kind, - item.hir_id(), - ty_hir_id, - ); - } - } - fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::Let(lt) = expr.kind && match lt.pat.kind { @@ -356,256 +275,6 @@ fn span_without_enclosing_paren(cx: &LateContext<'_>, span: Span) -> Span { } } -fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, ident: Ident, trait_items: &[TraitItemId]) { - fn is_named_self(cx: &LateContext<'_>, item: TraitItemId, name: Symbol) -> bool { - cx.tcx.item_name(item.owner_id) == name - && matches!( - cx.tcx.fn_arg_idents(item.owner_id), - [Some(Ident { - name: kw::SelfLower, - .. - })], - ) - } - - // fill the set with current and super traits - fn fill_trait_set(traitt: DefId, set: &mut DefIdSet, cx: &LateContext<'_>) { - if set.insert(traitt) { - for supertrait in supertrait_def_ids(cx.tcx, traitt) { - fill_trait_set(supertrait, set, cx); - } - } - } - - if cx.effective_visibilities.is_exported(visited_trait.owner_id.def_id) - && trait_items.iter().any(|&i| is_named_self(cx, i, sym::len)) - { - let mut current_and_super_traits = DefIdSet::default(); - fill_trait_set(visited_trait.owner_id.to_def_id(), &mut current_and_super_traits, cx); - let is_empty_method_found = current_and_super_traits - .items() - .flat_map(|&i| cx.tcx.associated_items(i).filter_by_name_unhygienic(sym::is_empty)) - .any(|i| i.is_method() && cx.tcx.fn_sig(i.def_id).skip_binder().inputs().skip_binder().len() == 1); - - if !is_empty_method_found { - span_lint( - cx, - LEN_WITHOUT_IS_EMPTY, - visited_trait.span, - format!( - "trait `{}` has a `len` method but no (possibly inherited) `is_empty` method", - ident.name - ), - ); - } - } -} - -#[derive(Debug, Clone, Copy)] -enum LenOutput { - Integral, - Option(DefId), - Result(DefId), -} - -fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&'tcx PathSegment<'tcx>> { - if let ty::Alias(_, alias_ty) = ty.kind() - && let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir_get_if_local(alias_ty.def_id) - && let OpaqueTyOrigin::AsyncFn { .. } = opaque.origin - && let [GenericBound::Trait(trait_ref)] = &opaque.bounds - && let Some(segment) = trait_ref.trait_ref.path.segments.last() - && let Some(generic_args) = segment.args - && let [constraint] = generic_args.constraints - && let Some(ty) = constraint.ty() - && let TyKind::Path(QPath::Resolved(_, path)) = ty.kind - && let [segment] = path.segments - { - return Some(segment); - } - - None -} - -fn is_first_generic_integral<'tcx>(segment: &'tcx PathSegment<'tcx>) -> bool { - if let Some(generic_args) = segment.args - && let [GenericArg::Type(ty), ..] = &generic_args.args - && let TyKind::Path(QPath::Resolved(_, path)) = ty.kind - && let [segment, ..] = &path.segments - && matches!(segment.res, Res::PrimTy(PrimTy::Uint(_) | PrimTy::Int(_))) - { - true - } else { - false - } -} - -fn parse_len_output<'tcx>(cx: &LateContext<'tcx>, sig: FnSig<'tcx>) -> Option { - if let Some(segment) = extract_future_output(cx, sig.output()) { - let res = segment.res; - - if matches!(res, Res::PrimTy(PrimTy::Uint(_) | PrimTy::Int(_))) { - return Some(LenOutput::Integral); - } - - if let Res::Def(_, def_id) = res - && let Some(res) = match cx.tcx.get_diagnostic_name(def_id) { - Some(sym::Option) => Some(LenOutput::Option(def_id)), - Some(sym::Result) => Some(LenOutput::Result(def_id)), - _ => None, - } - && is_first_generic_integral(segment) - { - return Some(res); - } - - return None; - } - - match *sig.output().kind() { - ty::Int(_) | ty::Uint(_) => Some(LenOutput::Integral), - ty::Adt(adt, subs) => match cx.tcx.get_diagnostic_name(adt.did()) { - Some(sym::Option) => subs.type_at(0).is_integral().then(|| LenOutput::Option(adt.did())), - Some(sym::Result) => subs.type_at(0).is_integral().then(|| LenOutput::Result(adt.did())), - _ => None, - }, - _ => None, - } -} - -impl LenOutput { - fn matches_is_empty_output<'tcx>(self, cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - if let Some(segment) = extract_future_output(cx, ty) { - return match (self, segment.res) { - (_, Res::PrimTy(PrimTy::Bool)) => true, - (Self::Option(_), Res::Def(_, def_id)) if cx.tcx.is_diagnostic_item(sym::Option, def_id) => true, - (Self::Result(_), Res::Def(_, def_id)) if cx.tcx.is_diagnostic_item(sym::Result, def_id) => true, - _ => false, - }; - } - - match (self, ty.kind()) { - (_, &ty::Bool) => true, - (Self::Option(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), - (Self::Result(id), &ty::Adt(adt, subs)) if id == adt.did() => subs.type_at(0).is_bool(), - _ => false, - } - } - - fn expected_sig(self, self_kind: ImplicitSelfKind) -> String { - let self_ref = match self_kind { - ImplicitSelfKind::RefImm => "&", - ImplicitSelfKind::RefMut => "&mut ", - _ => "", - }; - match self { - Self::Integral => format!("expected signature: `({self_ref}self) -> bool`"), - Self::Option(_) => { - format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Option") - }, - Self::Result(..) => { - format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Result") - }, - } - } -} - -/// Checks if the given signature matches the expectations for `is_empty` -fn check_is_empty_sig<'tcx>( - cx: &LateContext<'tcx>, - sig: FnSig<'tcx>, - self_kind: ImplicitSelfKind, - len_output: LenOutput, -) -> bool { - match &**sig.inputs_and_output { - [arg, res] if len_output.matches_is_empty_output(cx, *res) => { - matches!( - (arg.kind(), self_kind), - (ty::Ref(_, _, Mutability::Not), ImplicitSelfKind::RefImm) - | (ty::Ref(_, _, Mutability::Mut), ImplicitSelfKind::RefMut) - ) || (!arg.is_ref() && matches!(self_kind, ImplicitSelfKind::Imm | ImplicitSelfKind::Mut)) - }, - _ => false, - } -} - -/// Checks if the given type has an `is_empty` method with the appropriate signature. -#[expect(clippy::too_many_arguments)] -fn check_for_is_empty( - cx: &LateContext<'_>, - span: Span, - self_kind: ImplicitSelfKind, - output: LenOutput, - impl_ty: DefId, - item_name: Symbol, - item_kind: &str, - len_method_hir_id: HirId, - ty_decl_hir_id: HirId, -) { - // Implementor may be a type alias, in which case we need to get the `DefId` of the aliased type to - // find the correct inherent impls. - let impl_ty = if let Some(adt) = cx.tcx.type_of(impl_ty).skip_binder().ty_adt_def() { - adt.did() - } else { - return; - }; - - let is_empty = cx - .tcx - .inherent_impls(impl_ty) - .iter() - .flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(sym::is_empty)) - .find(|item| item.is_fn()); - - let (msg, is_empty_span, self_kind) = match is_empty { - None => ( - format!( - "{item_kind} `{}` has a public `len` method, but no `is_empty` method", - item_name.as_str(), - ), - None, - None, - ), - Some(is_empty) if !cx.effective_visibilities.is_exported(is_empty.def_id.expect_local()) => ( - format!( - "{item_kind} `{}` has a public `len` method, but a private `is_empty` method", - item_name.as_str(), - ), - Some(cx.tcx.def_span(is_empty.def_id)), - None, - ), - Some(is_empty) - if !(is_empty.is_method() - && check_is_empty_sig( - cx, - cx.tcx.fn_sig(is_empty.def_id).instantiate_identity().skip_binder(), - self_kind, - output, - )) => - { - ( - format!( - "{item_kind} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature", - item_name.as_str(), - ), - Some(cx.tcx.def_span(is_empty.def_id)), - Some(self_kind), - ) - }, - Some(_) => return, - }; - - if !fulfill_or_allowed(cx, LEN_WITHOUT_IS_EMPTY, [len_method_hir_id, ty_decl_hir_id]) { - span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, msg, |db| { - if let Some(span) = is_empty_span { - db.span_note(span, "`is_empty` defined here"); - } - if let Some(self_kind) = self_kind { - db.note(output.expected_sig(self_kind)); - } - }); - } -} - fn is_empty_string(expr: &Expr<'_>) -> bool { if let ExprKind::Lit(lit) = expr.kind && let LitKind::Str(lit, _) = lit.node diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index bc62d9b8450c..40487fe48f22 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -182,6 +182,7 @@ mod large_include_file; mod large_stack_arrays; mod large_stack_frames; mod legacy_numeric_constants; +mod len_without_is_empty; mod len_zero; mod let_if_seq; mod let_underscore; @@ -201,6 +202,7 @@ mod manual_clamp; mod manual_float_methods; mod manual_hash_one; mod manual_ignore_case_cmp; +mod manual_ilog2; mod manual_is_ascii_check; mod manual_is_power_of_two; mod manual_let_else; @@ -538,6 +540,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co Box::new(|_| Box::new(unnecessary_mut_passed::UnnecessaryMutPassed)), Box::new(|_| Box::>::default()), Box::new(move |_| Box::new(len_zero::LenZero::new(conf))), + Box::new(|_| Box::new(len_without_is_empty::LenWithoutIsEmpty)), Box::new(move |_| Box::new(attrs::Attributes::new(conf))), Box::new(|_| Box::new(blocks_in_conditions::BlocksInConditions)), Box::new(|_| Box::new(unicode::Unicode)), @@ -848,6 +851,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co Box::new(|_| Box::new(toplevel_ref_arg::ToplevelRefArg)), Box::new(|_| Box::new(volatile_composites::VolatileComposites)), Box::new(|_| Box::::default()), + Box::new(move |_| Box::new(manual_ilog2::ManualIlog2::new(conf))), // add late passes here, used by `cargo dev new_lint` ]; store.late_passes.extend(late_lints); diff --git a/clippy_lints/src/loops/while_let_on_iterator.rs b/clippy_lints/src/loops/while_let_on_iterator.rs index 2545f81f1afa..6c95c7b54c50 100644 --- a/clippy_lints/src/loops/while_let_on_iterator.rs +++ b/clippy_lints/src/loops/while_let_on_iterator.rs @@ -43,26 +43,26 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { }; // If the iterator is a field or the iterator is accessed after the loop is complete it needs to be - // borrowed mutably. TODO: If the struct can be partially moved from and the struct isn't used + // passed by reference. TODO: If the struct can be partially moved from and the struct isn't used // afterwards a mutable borrow of a field isn't necessary. - let by_ref = if cx.typeck_results().expr_ty(iter_expr).ref_mutability() == Some(Mutability::Mut) + let iterator = snippet_with_applicability(cx, iter_expr.span, "_", &mut applicability); + let iterator_by_ref = if cx.typeck_results().expr_ty(iter_expr).ref_mutability() == Some(Mutability::Mut) || !iter_expr_struct.can_move || !iter_expr_struct.fields.is_empty() || needs_mutable_borrow(cx, &iter_expr_struct, expr) { - ".by_ref()" + make_iterator_snippet(cx, iter_expr, &iterator) } else { - "" + iterator.into_owned() }; - let iterator = snippet_with_applicability(cx, iter_expr.span, "_", &mut applicability); span_lint_and_sugg( cx, WHILE_LET_ON_ITERATOR, expr.span.with_hi(let_expr.span.hi()), "this loop could be written as a `for` loop", "try", - format!("{loop_label}for {loop_var} in {iterator}{by_ref}"), + format!("{loop_label}for {loop_var} in {iterator_by_ref}"), applicability, ); } @@ -355,3 +355,22 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: & .is_break() } } + +/// Constructs the transformed iterator expression for the suggestion. +/// Returns `iterator.by_ref()` unless the last deref adjustment targets an unsized type, +/// in which case it applies all derefs (e.g., `&mut **iterator` or `&mut ***iterator`). +fn make_iterator_snippet<'tcx>(cx: &LateContext<'tcx>, iter_expr: &Expr<'tcx>, iterator: &str) -> String { + if let Some((n, adjust)) = cx + .typeck_results() + .expr_adjustments(iter_expr) + .iter() + .take_while(|x| matches!(x.kind, Adjust::Deref(_))) + .enumerate() + .last() + && !adjust.target.is_sized(cx.tcx, cx.typing_env()) + { + format!("&mut {:* Self { + Self { msrv: conf.msrv } + } +} + +impl_lint_pass!(ManualIlog2 => [MANUAL_ILOG2]); + +impl LateLintPass<'_> for ManualIlog2 { + fn check_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'tcx>) { + if expr.span.in_external_macro(cx.sess().source_map()) { + return; + } + + match expr.kind { + // `BIT_WIDTH - 1 - n.leading_zeros()` + ExprKind::Binary(op, left, right) + if left.span.eq_ctxt(right.span) + && op.node == BinOpKind::Sub + && let ExprKind::Lit(lit) = left.kind + && let LitKind::Int(Pu128(val), _) = lit.node + && let ExprKind::MethodCall(leading_zeros, recv, [], _) = right.kind + && leading_zeros.ident.name == sym::leading_zeros + && let ty = cx.typeck_results().expr_ty(recv) + && let Some(bit_width) = match ty.kind() { + ty::Uint(uint_ty) => uint_ty.bit_width(), + ty::Int(_) => { + // On non-positive integers, `ilog2` would panic, which might be a sign that the author does + // in fact want to calculate something different, so stay on the safer side and don't + // suggest anything. + return; + }, + _ => return, + } + && val == u128::from(bit_width) - 1 + && self.msrv.meets(cx, msrvs::ILOG2) + && !is_from_proc_macro(cx, expr) => + { + emit(cx, recv, expr); + }, + + // `n.ilog(2)` + ExprKind::MethodCall(ilog, recv, [two], _) + if expr.span.eq_ctxt(two.span) + && ilog.ident.name == sym::ilog + && let ExprKind::Lit(lit) = two.kind + && let LitKind::Int(Pu128(2), _) = lit.node + && cx.typeck_results().expr_ty_adjusted(recv).is_integral() + /* no need to check MSRV here, as `ilog` and `ilog2` were introduced simultaneously */ + && !is_from_proc_macro(cx, expr) => + { + emit(cx, recv, expr); + }, + + _ => {}, + } + } +} + +fn emit(cx: &LateContext<'_>, recv: &Expr<'_>, full_expr: &Expr<'_>) { + let mut app = Applicability::MachineApplicable; + let recv = snippet_with_applicability(cx, recv.span, "_", &mut app); + span_lint_and_sugg( + cx, + MANUAL_ILOG2, + full_expr.span, + "manually reimplementing `ilog2`", + "try", + format!("{recv}.ilog2()"), + app, + ); +} diff --git a/clippy_lints/src/matches/match_like_matches.rs b/clippy_lints/src/matches/match_like_matches.rs index b5f631e8fea3..89411115f730 100644 --- a/clippy_lints/src/matches/match_like_matches.rs +++ b/clippy_lints/src/matches/match_like_matches.rs @@ -1,7 +1,8 @@ //! Lint a `match` or `if let .. { .. } else { .. }` expr that could be replaced by `matches!` use super::REDUNDANT_PATTERN_MATCHING; -use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::higher::has_let_expr; use clippy_utils::source::snippet_with_applicability; use clippy_utils::{is_lint_allowed, is_wild, span_contains_comment}; use rustc_ast::LitKind; @@ -43,18 +44,23 @@ pub(crate) fn check_if_let<'tcx>( { ex_new = ex_inner; } - span_lint_and_sugg( + span_lint_and_then( cx, MATCH_LIKE_MATCHES_MACRO, expr.span, - "if let .. else expression looks like `matches!` macro", - "try", - format!( - "{}matches!({}, {pat})", - if b0 { "" } else { "!" }, - snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), - ), - applicability, + "`if let .. else` expression looks like `matches!` macro", + |diag| { + diag.span_suggestion_verbose( + expr.span, + "use `matches!` directly", + format!( + "{}matches!({}, {pat})", + if b0 { "" } else { "!" }, + snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), + ), + applicability, + ); + }, ); } } @@ -87,7 +93,10 @@ pub(super) fn check_match<'tcx>( // ```rs // matches!(e, Either::Left $(if $guard)|+) // ``` - middle_arms.is_empty() + // + // But if the guard _is_ present, it may not be an `if-let` guard, as `matches!` doesn't + // support these (currently?) + (middle_arms.is_empty() && first_arm.guard.is_none_or(|g| !has_let_expr(g))) // - (added in #6216) There are middle arms // @@ -169,18 +178,23 @@ pub(super) fn check_match<'tcx>( { ex_new = ex_inner; } - span_lint_and_sugg( + span_lint_and_then( cx, MATCH_LIKE_MATCHES_MACRO, e.span, "match expression looks like `matches!` macro", - "try", - format!( - "{}matches!({}, {pat_and_guard})", - if b0 { "" } else { "!" }, - snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), - ), - applicability, + |diag| { + diag.span_suggestion_verbose( + e.span, + "use `matches!` directly", + format!( + "{}matches!({}, {pat_and_guard})", + if b0 { "" } else { "!" }, + snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), + ), + applicability, + ); + }, ); true } else { diff --git a/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs index 2196ce92b0ab..a3dd967bd77a 100644 --- a/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -4,18 +4,20 @@ use clippy_utils::source::snippet_with_applicability; use clippy_utils::sym; use rustc_ast::ast; use rustc_errors::Applicability; -use rustc_hir as hir; use rustc_hir::def::Res; +use rustc_hir::{self as hir, Expr}; use rustc_lint::LateContext; +use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf; +use rustc_span::Symbol; -pub fn check( +pub fn check_unwrap_or( cx: &LateContext<'_>, - expr: &hir::Expr<'_>, - arith_lhs: &hir::Expr<'_>, - arith_rhs: &hir::Expr<'_>, - unwrap_arg: &hir::Expr<'_>, - arith: &str, + expr: &Expr<'_>, + arith_lhs: &Expr<'_>, + arith_rhs: &Expr<'_>, + unwrap_arg: &Expr<'_>, + arith: Symbol, ) { let ty = cx.typeck_results().expr_ty(arith_lhs); if !ty.is_integral() { @@ -26,35 +28,75 @@ pub fn check( return; }; - if ty.is_signed() { - use self::MinMax::{Max, Min}; - use self::Sign::{Neg, Pos}; + let Some(checked_arith) = CheckedArith::new(arith) else { + return; + }; + check(cx, expr, arith_lhs, arith_rhs, ty, mm, checked_arith); +} + +pub(super) fn check_sub_unwrap_or_default( + cx: &LateContext<'_>, + expr: &Expr<'_>, + arith_lhs: &Expr<'_>, + arith_rhs: &Expr<'_>, +) { + let ty = cx.typeck_results().expr_ty(arith_lhs); + if !ty.is_integral() { + return; + } + + let mm = if ty.is_signed() { + return; // iN::default() is 0, which is neither MIN nor MAX + } else { + MinMax::Min // uN::default() is 0, which is also the MIN + }; + + let checked_arith = CheckedArith::Sub; + + check(cx, expr, arith_lhs, arith_rhs, ty, mm, checked_arith); +} + +fn check( + cx: &LateContext<'_>, + expr: &Expr<'_>, + arith_lhs: &Expr<'_>, + arith_rhs: &Expr<'_>, + ty: Ty<'_>, + mm: MinMax, + checked_arith: CheckedArith, +) { + use self::MinMax::{Max, Min}; + use self::Sign::{Neg, Pos}; + use CheckedArith::{Add, Mul, Sub}; + + if ty.is_signed() { let Some(sign) = lit_sign(arith_rhs) else { return; }; - match (arith, sign, mm) { - ("add", Pos, Max) | ("add", Neg, Min) | ("sub", Neg, Max) | ("sub", Pos, Min) => (), + match (checked_arith, sign, mm) { + (Add, Pos, Max) | (Add, Neg, Min) | (Sub, Neg, Max) | (Sub, Pos, Min) => (), // "mul" is omitted because lhs can be negative. _ => return, } } else { - match (mm, arith) { - (MinMax::Max, "add" | "mul") | (MinMax::Min, "sub") => (), + match (mm, checked_arith) { + (Max, Add | Mul) | (Min, Sub) => (), _ => return, } } let mut applicability = Applicability::MachineApplicable; + let saturating_arith = checked_arith.as_saturating(); span_lint_and_sugg( cx, super::MANUAL_SATURATING_ARITHMETIC, expr.span, "manual saturating arithmetic", - format!("consider using `saturating_{arith}`"), + format!("consider using `{saturating_arith}`"), format!( - "{}.saturating_{arith}({})", + "{}.{saturating_arith}({})", snippet_with_applicability(cx, arith_lhs.span, "..", &mut applicability), snippet_with_applicability(cx, arith_rhs.span, "..", &mut applicability), ), @@ -62,13 +104,40 @@ pub fn check( ); } +#[derive(Clone, Copy)] +enum CheckedArith { + Add, + Sub, + Mul, +} + +impl CheckedArith { + fn new(sym: Symbol) -> Option { + let res = match sym { + sym::checked_add => Self::Add, + sym::checked_sub => Self::Sub, + sym::checked_mul => Self::Mul, + _ => return None, + }; + Some(res) + } + + fn as_saturating(self) -> &'static str { + match self { + Self::Add => "saturating_add", + Self::Sub => "saturating_sub", + Self::Mul => "saturating_mul", + } + } +} + #[derive(PartialEq, Eq)] enum MinMax { Min, Max, } -fn is_min_or_max(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option { +fn is_min_or_max(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { // `T::max_value()` `T::min_value()` inherent methods if let hir::ExprKind::Call(func, []) = &expr.kind && let hir::ExprKind::Path(hir::QPath::TypeRelative(_, segment)) = &func.kind @@ -106,7 +175,7 @@ fn is_min_or_max(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option { (0, if bits == 128 { !0 } else { (1 << bits) - 1 }) }; - let check_lit = |expr: &hir::Expr<'_>, check_min: bool| { + let check_lit = |expr: &Expr<'_>, check_min: bool| { if let hir::ExprKind::Lit(lit) = &expr.kind && let ast::LitKind::Int(value, _) = lit.node { @@ -141,7 +210,7 @@ enum Sign { Neg, } -fn lit_sign(expr: &hir::Expr<'_>) -> Option { +fn lit_sign(expr: &Expr<'_>) -> Option { if let hir::ExprKind::Unary(hir::UnOp::Neg, inner) = &expr.kind { if let hir::ExprKind::Lit(..) = &inner.kind { return Some(Sign::Neg); diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index c22b0a548e3d..48842c8739c0 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -94,6 +94,7 @@ mod or_fun_call; mod or_then_unwrap; mod path_buf_push_overwrite; mod path_ends_with_ext; +mod ptr_offset_by_literal; mod ptr_offset_with_cast; mod range_zip_with_len; mod read_line_without_trim; @@ -1728,6 +1729,40 @@ declare_clippy_lint! { "Check for offset calculations on raw pointers to zero-sized types" } +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of the `offset` pointer method with an integer + /// literal. + /// + /// ### Why is this bad? + /// The `add` and `sub` methods more accurately express the intent. + /// + /// ### Example + /// ```no_run + /// let vec = vec![b'a', b'b', b'c']; + /// let ptr = vec.as_ptr(); + /// + /// unsafe { + /// ptr.offset(-8); + /// } + /// ``` + /// + /// Could be written: + /// + /// ```no_run + /// let vec = vec![b'a', b'b', b'c']; + /// let ptr = vec.as_ptr(); + /// + /// unsafe { + /// ptr.sub(8); + /// } + /// ``` + #[clippy::version = "1.92.0"] + pub PTR_OFFSET_BY_LITERAL, + pedantic, + "unneeded pointer offset" +} + declare_clippy_lint! { /// ### What it does /// Checks for usage of the `offset` pointer method with a `usize` casted to an @@ -4635,7 +4670,7 @@ declare_clippy_lint! { /// let x = vec![String::new()]; /// let _ = x.iter().map(|x| x.len()); /// ``` - #[clippy::version = "1.90.0"] + #[clippy::version = "1.92.0"] pub REDUNDANT_ITER_CLONED, perf, "detects redundant calls to `Iterator::cloned`" @@ -4659,7 +4694,7 @@ declare_clippy_lint! { /// let x: Option = Some(4); /// let y = x.unwrap_or_else(|| 2 * k); /// ``` - #[clippy::version = "1.88.0"] + #[clippy::version = "1.92.0"] pub UNNECESSARY_OPTION_MAP_OR_ELSE, suspicious, "making no use of the \"map closure\" when calling `.map_or_else(|| 2 * k, |n| n)`" @@ -4803,6 +4838,7 @@ impl_lint_pass!(Methods => [ UNINIT_ASSUMED_INIT, MANUAL_SATURATING_ARITHMETIC, ZST_OFFSET, + PTR_OFFSET_BY_LITERAL, PTR_OFFSET_WITH_CAST, FILETYPE_IS_FILE, OPTION_AS_REF_DEREF, @@ -5426,6 +5462,7 @@ impl Methods { zst_offset::check(cx, expr, recv); ptr_offset_with_cast::check(cx, name, expr, recv, arg, self.msrv); + ptr_offset_by_literal::check(cx, expr, self.msrv); }, (sym::ok_or_else, [arg]) => { unnecessary_lazy_eval::check(cx, expr, recv, arg, "ok_or"); @@ -5567,14 +5604,7 @@ impl Methods { (sym::unwrap_or, [u_arg]) => { match method_call(recv) { Some((arith @ (sym::checked_add | sym::checked_sub | sym::checked_mul), lhs, [rhs], _, _)) => { - manual_saturating_arithmetic::check( - cx, - expr, - lhs, - rhs, - u_arg, - &arith.as_str()[const { "checked_".len() }..], - ); + manual_saturating_arithmetic::check_unwrap_or(cx, expr, lhs, rhs, u_arg, arith); }, Some((sym::map, m_recv, [m_arg], span, _)) => { option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span, self.msrv); @@ -5595,6 +5625,9 @@ impl Methods { }, (sym::unwrap_or_default, []) => { match method_call(recv) { + Some((sym::checked_sub, lhs, [rhs], _, _)) => { + manual_saturating_arithmetic::check_sub_unwrap_or_default(cx, expr, lhs, rhs); + }, Some((sym::map, m_recv, [arg], span, _)) => { manual_is_variant_and::check(cx, expr, m_recv, arg, span, self.msrv); }, diff --git a/clippy_lints/src/methods/ptr_offset_by_literal.rs b/clippy_lints/src/methods/ptr_offset_by_literal.rs new file mode 100644 index 000000000000..b5d2add65cf1 --- /dev/null +++ b/clippy_lints/src/methods/ptr_offset_by_literal.rs @@ -0,0 +1,138 @@ +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::msrvs::{self, Msrv}; +use clippy_utils::source::SpanRangeExt; +use clippy_utils::sym; +use rustc_ast::LitKind; +use rustc_errors::Applicability; +use rustc_hir::{Expr, ExprKind, Lit, UnOp}; +use rustc_lint::LateContext; +use std::cmp::Ordering; +use std::fmt; + +use super::PTR_OFFSET_BY_LITERAL; + +pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Msrv) { + // `pointer::add` and `pointer::wrapping_add` are only stable since 1.26.0. These functions + // became const-stable in 1.61.0, the same version that `pointer::offset` became const-stable. + if !msrv.meets(cx, msrvs::POINTER_ADD_SUB_METHODS) { + return; + } + + let ExprKind::MethodCall(method_name, recv, [arg_expr], _) = expr.kind else { + return; + }; + + let method = match method_name.ident.name { + sym::offset => Method::Offset, + sym::wrapping_offset => Method::WrappingOffset, + _ => return, + }; + + if !cx.typeck_results().expr_ty_adjusted(recv).is_raw_ptr() { + return; + } + + // Check if the argument to the method call is a (negated) literal. + let Some((literal, literal_text)) = expr_as_literal(cx, arg_expr) else { + return; + }; + + match method.suggestion(literal) { + None => { + let msg = format!("use of `{method}` with zero"); + span_lint_and_then(cx, PTR_OFFSET_BY_LITERAL, expr.span, msg, |diag| { + diag.span_suggestion( + expr.span.with_lo(recv.span.hi()), + format!("remove the call to `{method}`"), + String::new(), + Applicability::MachineApplicable, + ); + }); + }, + Some(method_suggestion) => { + let msg = format!("use of `{method}` with a literal"); + span_lint_and_then(cx, PTR_OFFSET_BY_LITERAL, expr.span, msg, |diag| { + diag.multipart_suggestion( + format!("use `{method_suggestion}` instead"), + vec![ + (method_name.ident.span, method_suggestion.to_string()), + (arg_expr.span, literal_text), + ], + Applicability::MachineApplicable, + ); + }); + }, + } +} + +fn get_literal_bits<'tcx>(expr: &'tcx Expr<'tcx>) -> Option { + match expr.kind { + ExprKind::Lit(Lit { + node: LitKind::Int(packed_u128, _), + .. + }) => Some(packed_u128.get()), + _ => None, + } +} + +// If the given expression is a (negated) literal, return its value. +fn expr_as_literal<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<(i128, String)> { + if let Some(literal_bits) = get_literal_bits(expr) { + // The value must fit in a isize, so we can't have overflow here. + return Some((literal_bits.cast_signed(), format_isize_literal(cx, expr)?)); + } + + if let ExprKind::Unary(UnOp::Neg, inner) = expr.kind + && let Some(literal_bits) = get_literal_bits(inner) + { + return Some((-(literal_bits.cast_signed()), format_isize_literal(cx, inner)?)); + } + + None +} + +fn format_isize_literal<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option { + let text = expr.span.get_source_text(cx)?; + let text = peel_parens_str(&text); + Some(text.trim_end_matches("isize").trim_end_matches('_').to_string()) +} + +fn peel_parens_str(snippet: &str) -> &str { + let mut s = snippet.trim(); + while let Some(next) = s.strip_prefix("(").and_then(|suf| suf.strip_suffix(")")) { + s = next.trim(); + } + s +} + +#[derive(Copy, Clone)] +enum Method { + Offset, + WrappingOffset, +} + +impl Method { + fn suggestion(self, literal: i128) -> Option<&'static str> { + match Ord::cmp(&literal, &0) { + Ordering::Greater => match self { + Method::Offset => Some("add"), + Method::WrappingOffset => Some("wrapping_add"), + }, + // `ptr.offset(0)` is equivalent to `ptr`, so no adjustment is needed + Ordering::Equal => None, + Ordering::Less => match self { + Method::Offset => Some("sub"), + Method::WrappingOffset => Some("wrapping_sub"), + }, + } + } +} + +impl fmt::Display for Method { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Offset => write!(f, "offset"), + Self::WrappingOffset => write!(f, "wrapping_offset"), + } + } +} diff --git a/clippy_lints/src/missing_asserts_for_indexing.rs b/clippy_lints/src/missing_asserts_for_indexing.rs index 808adb7e71ce..87ee164a1760 100644 --- a/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/clippy_lints/src/missing_asserts_for_indexing.rs @@ -5,7 +5,7 @@ use clippy_utils::comparisons::{Rel, normalize_comparison}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::higher::{If, Range}; use clippy_utils::macros::{find_assert_eq_args, first_node_macro_backtrace, root_macro_call}; -use clippy_utils::source::snippet; +use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::visitors::for_each_expr_without_closures; use clippy_utils::{eq_expr_value, hash_expr}; use rustc_ast::{BinOpKind, LitKind, RangeLimits}; @@ -67,16 +67,13 @@ declare_clippy_lint! { } declare_lint_pass!(MissingAssertsForIndexing => [MISSING_ASSERTS_FOR_INDEXING]); -fn report_lint(cx: &LateContext<'_>, full_span: Span, msg: &'static str, indexes: &[Span], f: F) +fn report_lint(cx: &LateContext<'_>, index_spans: Vec, msg: &'static str, f: F) where F: FnOnce(&mut Diag<'_, ()>), { - span_lint_and_then(cx, MISSING_ASSERTS_FOR_INDEXING, full_span, msg, |diag| { + span_lint_and_then(cx, MISSING_ASSERTS_FOR_INDEXING, index_spans, msg, |diag| { f(diag); - for span in indexes { - diag.span_note(*span, "slice indexed here"); - } - diag.note("asserting the length before indexing will elide bounds checks"); + diag.note_once("asserting the length before indexing will elide bounds checks"); }); } @@ -213,15 +210,6 @@ impl<'hir> IndexEntry<'hir> { | IndexEntry::IndexWithoutAssert { slice, .. } => slice, } } - - pub fn index_spans(&self) -> Option<&[Span]> { - match self { - IndexEntry::StrayAssert { .. } => None, - IndexEntry::AssertWithIndex { indexes, .. } | IndexEntry::IndexWithoutAssert { indexes, .. } => { - Some(indexes) - }, - } - } } /// Extracts the upper index of a slice indexing expression. @@ -354,63 +342,47 @@ fn check_assert<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut Un /// Inspects indexes and reports lints. /// /// Called at the end of this lint after all indexing and `assert!` expressions have been collected. -fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap>>) { - for bucket in map.values() { +fn report_indexes(cx: &LateContext<'_>, map: UnindexMap>>) { + for bucket in map.into_values() { for entry in bucket { - let Some(full_span) = entry - .index_spans() - .and_then(|spans| spans.first().zip(spans.last())) - .map(|(low, &high)| low.to(high)) - else { - continue; - }; - - match *entry { + match entry { IndexEntry::AssertWithIndex { highest_index, is_first_highest, asserted_len, - ref indexes, + indexes, comparison, assert_span, slice, macro_call, } if indexes.len() > 1 && !is_first_highest => { + let mut app = Applicability::MachineApplicable; + let slice_str = snippet_with_applicability(cx, slice.span, "_", &mut app); // if we have found an `assert!`, let's also check that it's actually right // and if it covers the highest index and if not, suggest the correct length let sugg = match comparison { // `v.len() < 5` and `v.len() <= 5` does nothing in terms of bounds checks. // The user probably meant `v.len() > 5` - LengthComparison::LengthLessThanInt | LengthComparison::LengthLessThanOrEqualInt => Some( - format!("assert!({}.len() > {highest_index})", snippet(cx, slice.span, "..")), - ), + LengthComparison::LengthLessThanInt | LengthComparison::LengthLessThanOrEqualInt => { + Some(format!("assert!({slice_str}.len() > {highest_index})",)) + }, // `5 < v.len()` == `v.len() > 5` - LengthComparison::IntLessThanLength if asserted_len < highest_index => Some(format!( - "assert!({}.len() > {highest_index})", - snippet(cx, slice.span, "..") - )), + LengthComparison::IntLessThanLength if asserted_len < highest_index => { + Some(format!("assert!({slice_str}.len() > {highest_index})",)) + }, // `5 <= v.len() == `v.len() >= 5` - LengthComparison::IntLessThanOrEqualLength if asserted_len <= highest_index => Some(format!( - "assert!({}.len() > {highest_index})", - snippet(cx, slice.span, "..") - )), + LengthComparison::IntLessThanOrEqualLength if asserted_len <= highest_index => { + Some(format!("assert!({slice_str}.len() > {highest_index})",)) + }, // `highest_index` here is rather a length, so we need to add 1 to it LengthComparison::LengthEqualInt if asserted_len < highest_index + 1 => match macro_call { - sym::assert_eq_macro => Some(format!( - "assert_eq!({}.len(), {})", - snippet(cx, slice.span, ".."), - highest_index + 1 - )), - sym::debug_assert_eq_macro => Some(format!( - "debug_assert_eq!({}.len(), {})", - snippet(cx, slice.span, ".."), - highest_index + 1 - )), - _ => Some(format!( - "assert!({}.len() == {})", - snippet(cx, slice.span, ".."), - highest_index + 1 - )), + sym::assert_eq_macro => { + Some(format!("assert_eq!({slice_str}.len(), {})", highest_index + 1)) + }, + sym::debug_assert_eq_macro => { + Some(format!("debug_assert_eq!({slice_str}.len(), {})", highest_index + 1)) + }, + _ => Some(format!("assert!({slice_str}.len() == {})", highest_index + 1)), }, _ => None, }; @@ -418,22 +390,21 @@ fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap if let Some(sugg) = sugg { report_lint( cx, - full_span, - "indexing into a slice multiple times with an `assert` that does not cover the highest index", indexes, + "indexing into a slice multiple times with an `assert` that does not cover the highest index", |diag| { - diag.span_suggestion( + diag.span_suggestion_verbose( assert_span, "provide the highest index that is indexed with", sugg, - Applicability::MachineApplicable, + app, ); }, ); } }, IndexEntry::IndexWithoutAssert { - ref indexes, + indexes, highest_index, is_first_highest, slice, @@ -442,9 +413,8 @@ fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap // adding an `assert!` that covers the highest index report_lint( cx, - full_span, - "indexing into a slice multiple times without an `assert`", indexes, + "indexing into a slice multiple times without an `assert`", |diag| { diag.help(format!( "consider asserting the length before indexing: `assert!({}.len() > {highest_index});`", @@ -469,6 +439,6 @@ impl LateLintPass<'_> for MissingAssertsForIndexing { ControlFlow::::Continue(()) }); - report_indexes(cx, &map); + report_indexes(cx, map); } } diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 3a8a4dd0c713..8970970f4b47 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -115,35 +115,41 @@ impl EarlyLintPass for MacroBraces { } fn is_offending_macro(cx: &EarlyContext<'_>, span: Span, mac_braces: &MacroBraces) -> Option { - let unnested_or_local = || { - !span.ctxt().outer_expn_data().call_site.from_expansion() + let unnested_or_local = |span: Span| { + !span.from_expansion() || span .macro_backtrace() .last() .is_some_and(|e| e.macro_def_id.is_some_and(DefId::is_local)) }; - let callsite_span = span.ctxt().outer_expn_data().call_site; - if let ExpnKind::Macro(MacroKind::Bang, mac_name) = span.ctxt().outer_expn_data().kind + + let mut ctxt = span.ctxt(); + while !ctxt.is_root() { + let expn_data = ctxt.outer_expn_data(); + if let ExpnKind::Macro(MacroKind::Bang, mac_name) = expn_data.kind && let name = mac_name.as_str() && let Some(&braces) = mac_braces.macro_braces.get(name) - && let Some(snip) = callsite_span.get_source_text(cx) + && let Some(snip) = expn_data.call_site.get_source_text(cx) // we must check only invocation sites // https://github.com/rust-lang/rust-clippy/issues/7422 && let Some(macro_args_str) = snip.strip_prefix(name).and_then(|snip| snip.strip_prefix('!')) && let Some(old_open_brace @ ('{' | '(' | '[')) = macro_args_str.trim_start().chars().next() && old_open_brace != braces.0 - && unnested_or_local() - && !mac_braces.done.contains(&callsite_span) - { - Some(MacroInfo { - callsite_span, - callsite_snippet: snip, - old_open_brace, - braces, - }) - } else { - None + && unnested_or_local(expn_data.call_site) + && !mac_braces.done.contains(&expn_data.call_site) + { + return Some(MacroInfo { + callsite_span: expn_data.call_site, + callsite_snippet: snip, + old_open_brace, + braces, + }); + } + + ctxt = expn_data.call_site.ctxt(); } + + None } fn emit_help(cx: &EarlyContext<'_>, snip: &str, (open, close): (char, char), span: Span, add_semi: bool) { diff --git a/clippy_lints/src/operators/decimal_bitwise_operands.rs b/clippy_lints/src/operators/decimal_bitwise_operands.rs new file mode 100644 index 000000000000..8511f2151342 --- /dev/null +++ b/clippy_lints/src/operators/decimal_bitwise_operands.rs @@ -0,0 +1,76 @@ +use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::numeric_literal; +use clippy_utils::numeric_literal::NumericLiteral; +use clippy_utils::source::SpanRangeExt; +use rustc_ast::LitKind; +use rustc_data_structures::packed::Pu128; +use rustc_hir::{BinOpKind, Expr, ExprKind}; +use rustc_lint::LateContext; +use rustc_span::Span; + +use super::DECIMAL_BITWISE_OPERANDS; + +pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, op: BinOpKind, left: &'tcx Expr<'_>, right: &'tcx Expr<'_>) { + if !matches!(op, BinOpKind::BitAnd | BinOpKind::BitOr | BinOpKind::BitXor) { + return; + } + + for expr in [left, right] { + check_expr(cx, expr); + } +} + +fn check_expr(cx: &LateContext<'_>, expr: &Expr<'_>) { + match &expr.kind { + ExprKind::Block(block, _) => { + if let Some(block_expr) = block.expr { + check_expr(cx, block_expr); + } + }, + ExprKind::Cast(cast_expr, _) => { + check_expr(cx, cast_expr); + }, + ExprKind::Unary(_, unary_expr) => { + check_expr(cx, unary_expr); + }, + ExprKind::AddrOf(_, _, addr_of_expr) => { + check_expr(cx, addr_of_expr); + }, + ExprKind::Lit(lit) => { + if let LitKind::Int(Pu128(val), _) = lit.node + && !is_single_digit(val) + && !is_power_of_twoish(val) + && let Some(src) = lit.span.get_source_text(cx) + && let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) + && num_lit.is_decimal() + { + emit_lint(cx, lit.span, num_lit.suffix, val); + } + }, + _ => (), + } +} + +fn is_power_of_twoish(val: u128) -> bool { + val.is_power_of_two() || val.wrapping_add(1).is_power_of_two() +} + +fn is_single_digit(val: u128) -> bool { + val <= 9 +} + +fn emit_lint(cx: &LateContext<'_>, span: Span, suffix: Option<&str>, val: u128) { + span_lint_and_help( + cx, + DECIMAL_BITWISE_OPERANDS, + span, + "using decimal literal for bitwise operation", + None, + format!( + "use binary ({}), hex ({}), or octal ({}) notation for better readability", + numeric_literal::format(&format!("{val:#b}"), suffix, false), + numeric_literal::format(&format!("{val:#x}"), suffix, false), + numeric_literal::format(&format!("{val:#o}"), suffix, false), + ), + ); +} diff --git a/clippy_lints/src/operators/mod.rs b/clippy_lints/src/operators/mod.rs index 8db2cc1d3f57..53b8e9e5d5ae 100644 --- a/clippy_lints/src/operators/mod.rs +++ b/clippy_lints/src/operators/mod.rs @@ -3,6 +3,7 @@ mod assign_op_pattern; mod bit_mask; mod cmp_owned; mod const_comparisons; +mod decimal_bitwise_operands; mod double_comparison; mod duration_subsec; mod eq_op; @@ -935,6 +936,28 @@ declare_clippy_lint! { "use of disallowed default division and remainder operations" } +declare_clippy_lint! { + /// ### What it does + /// Checks for decimal literals used as bit masks in bitwise operations. + /// + /// ### Why is this bad? + /// Using decimal literals for bit masks can make the code less readable and obscure the intended bit pattern. + /// Binary, hexadecimal, or octal literals make the bit pattern more explicit and easier to understand at a glance. + /// + /// ### Example + /// ```rust,no_run + /// let a = 14 & 6; // Bit pattern is not immediately clear + /// ``` + /// Use instead: + /// ```rust,no_run + /// let a = 0b1110 & 0b0110; + /// ``` + #[clippy::version = "1.93.0"] + pub DECIMAL_BITWISE_OPERANDS, + pedantic, + "use binary, hex, or octal literals for bitwise operations" +} + pub struct Operators { arithmetic_context: numeric_arithmetic::Context, verbose_bit_mask_threshold: u64, @@ -984,6 +1007,7 @@ impl_lint_pass!(Operators => [ MANUAL_IS_MULTIPLE_OF, MANUAL_DIV_CEIL, INVALID_UPCAST_COMPARISONS, + DECIMAL_BITWISE_OPERANDS ]); impl<'tcx> LateLintPass<'tcx> for Operators { @@ -1003,6 +1027,7 @@ impl<'tcx> LateLintPass<'tcx> for Operators { needless_bitwise_bool::check(cx, e, op.node, lhs, rhs); manual_midpoint::check(cx, e, op.node, lhs, rhs, self.msrv); manual_is_multiple_of::check(cx, e, op.node, lhs, rhs, self.msrv); + decimal_bitwise_operands::check(cx, op.node, lhs, rhs); } self.arithmetic_context.check_binary(cx, e, op.node, lhs, rhs); bit_mask::check(cx, e, op.node, lhs, rhs); @@ -1028,6 +1053,9 @@ impl<'tcx> LateLintPass<'tcx> for Operators { }, ExprKind::AssignOp(op, lhs, rhs) => { let bin_op = op.node.into(); + if !e.span.from_expansion() { + decimal_bitwise_operands::check(cx, bin_op, lhs, rhs); + } self.arithmetic_context.check_binary(cx, e, bin_op, lhs, rhs); misrefactored_assign_op::check(cx, e, bin_op, lhs, rhs); modulo_arithmetic::check(cx, e, bin_op, lhs, rhs, false); diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index d643f7aea497..435cd7bcba4e 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -18,8 +18,11 @@ mod wrong_transmute; use clippy_config::Conf; use clippy_utils::is_in_const_context; use clippy_utils::msrvs::Msrv; +use clippy_utils::sugg::Sugg; +use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::{self, Ty}; use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; @@ -490,6 +493,32 @@ impl Transmute { pub fn new(conf: &'static Conf) -> Self { Self { msrv: conf.msrv } } + + /// When transmuting, a struct containing a single field works like the field. + /// This function extracts the field type and the expression to get the field. + fn extract_struct_field<'tcx>( + cx: &LateContext<'tcx>, + e: &'tcx Expr<'_>, + outer_type: Ty<'tcx>, + outer: &'tcx Expr<'tcx>, + ) -> (Ty<'tcx>, Sugg<'tcx>) { + let mut applicability = Applicability::MachineApplicable; + let outer_sugg = Sugg::hir_with_context(cx, outer, e.span.ctxt(), "..", &mut applicability); + if let ty::Adt(struct_def, struct_args) = *outer_type.kind() + && struct_def.is_struct() + && let mut fields = struct_def.all_fields() + && let Some(first) = fields.next() + && fields.next().is_none() + && first.vis.is_accessible_from(cx.tcx.parent_module(outer.hir_id), cx.tcx) + { + ( + first.ty(cx.tcx, struct_args), + Sugg::NonParen(format!("{}.{}", outer_sugg.maybe_paren(), first.name).into()), + ) + } else { + (outer_type, outer_sugg) + } + } } impl<'tcx> LateLintPass<'tcx> for Transmute { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { @@ -516,14 +545,17 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { return; } + // A struct having a single pointer can be treated like a pointer. + let (from_field_ty, from_field_expr) = Self::extract_struct_field(cx, e, from_ty, arg); + let linted = wrong_transmute::check(cx, e, from_ty, to_ty) | crosspointer_transmute::check(cx, e, from_ty, to_ty) | transmuting_null::check(cx, e, arg, to_ty) | transmute_null_to_fn::check(cx, e, arg, to_ty) - | transmute_ptr_to_ref::check(cx, e, from_ty, to_ty, arg, path, self.msrv) + | transmute_ptr_to_ref::check(cx, e, from_field_ty, to_ty, from_field_expr.clone(), path, self.msrv) | missing_transmute_annotations::check(cx, path, arg, from_ty, to_ty, e.hir_id) | transmute_ref_to_ref::check(cx, e, from_ty, to_ty, arg, const_context) - | transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, arg, self.msrv) + | transmute_ptr_to_ptr::check(cx, e, from_field_ty, to_ty, from_field_expr, self.msrv) | transmute_int_to_bool::check(cx, e, from_ty, to_ty, arg) | transmute_int_to_non_zero::check(cx, e, from_ty, to_ty, arg) | (unsound_collection_transmute::check(cx, e, from_ty, to_ty) diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs index 91fce5d5bd68..036b16e3dc3d 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs @@ -14,11 +14,9 @@ pub(super) fn check<'tcx>( e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, - arg: &'tcx Expr<'_>, + arg: sugg::Sugg<'_>, msrv: Msrv, ) -> bool { - let mut applicability = Applicability::MachineApplicable; - let arg_sugg = sugg::Sugg::hir_with_context(cx, arg, e.span.ctxt(), "..", &mut applicability); match (from_ty.kind(), to_ty.kind()) { (ty::RawPtr(from_pointee_ty, from_mutbl), ty::RawPtr(to_pointee_ty, to_mutbl)) => { span_lint_and_then( @@ -34,7 +32,7 @@ pub(super) fn check<'tcx>( diag.span_suggestion_verbose( e.span, "use `pointer::cast` instead", - format!("{}.cast::<{to_pointee_ty}>()", arg_sugg.maybe_paren()), + format!("{}.cast::<{to_pointee_ty}>()", arg.maybe_paren()), Applicability::MaybeIncorrect, ); } else if from_pointee_ty == to_pointee_ty @@ -49,14 +47,14 @@ pub(super) fn check<'tcx>( diag.span_suggestion_verbose( e.span, format!("use `pointer::{method}` instead"), - format!("{}.{method}()", arg_sugg.maybe_paren()), + format!("{}.{method}()", arg.maybe_paren()), Applicability::MaybeIncorrect, ); } else { diag.span_suggestion_verbose( e.span, "use an `as` cast instead", - arg_sugg.as_ty(to_ty), + arg.as_ty(to_ty), Applicability::MaybeIncorrect, ); } diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs index e67ab6a73d26..ba107eed6b14 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs @@ -15,7 +15,7 @@ pub(super) fn check<'tcx>( e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, - arg: &'tcx Expr<'_>, + arg: sugg::Sugg<'_>, path: &'tcx Path<'_>, msrv: Msrv, ) -> bool { @@ -27,7 +27,6 @@ pub(super) fn check<'tcx>( e.span, format!("transmute from a pointer type (`{from_ty}`) to a reference type (`{to_ty}`)"), |diag| { - let arg = sugg::Sugg::hir(cx, arg, ".."); let (deref, cast) = match mutbl { Mutability::Mut => ("&mut *", "*mut"), Mutability::Not => ("&*", "*const"), diff --git a/clippy_lints/src/tuple_array_conversions.rs b/clippy_lints/src/tuple_array_conversions.rs index 5d0945bece55..98bf9f9fea58 100644 --- a/clippy_lints/src/tuple_array_conversions.rs +++ b/clippy_lints/src/tuple_array_conversions.rs @@ -1,9 +1,9 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_help; -use clippy_utils::is_from_proc_macro; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::res::MaybeResPath; -use clippy_utils::visitors::for_each_local_use_after_expr; +use clippy_utils::visitors::local_used_once; +use clippy_utils::{get_enclosing_block, is_from_proc_macro}; use itertools::Itertools; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind, Node, PatKind}; @@ -11,7 +11,6 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::{self, Ty}; use rustc_session::impl_lint_pass; use std::iter::once; -use std::ops::ControlFlow; declare_clippy_lint! { /// ### What it does @@ -86,7 +85,7 @@ fn check_array<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: & ExprKind::Path(_) => Some(elements.iter().collect()), _ => None, }) - && all_bindings_are_for_conv(cx, &[ty], expr, elements, &locals, ToType::Array) + && all_bindings_are_for_conv(cx, &[ty], elements, &locals, ToType::Array) && !is_from_proc_macro(cx, expr) { span_lint_and_help( @@ -123,7 +122,7 @@ fn check_tuple<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: & ExprKind::Path(_) => Some(elements.iter().collect()), _ => None, }) - && all_bindings_are_for_conv(cx, tys, expr, elements, &locals, ToType::Tuple) + && all_bindings_are_for_conv(cx, tys, elements, &locals, ToType::Tuple) && !is_from_proc_macro(cx, expr) { span_lint_and_help( @@ -148,7 +147,6 @@ fn check_tuple<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: & fn all_bindings_are_for_conv<'tcx>( cx: &LateContext<'tcx>, final_tys: &[Ty<'tcx>], - expr: &Expr<'_>, elements: &[Expr<'_>], locals: &[&Expr<'_>], kind: ToType, @@ -166,13 +164,30 @@ fn all_bindings_are_for_conv<'tcx>( _ => None, }) .all_equal() - // Fix #11124, very convenient utils function! ❤️ - && locals - .iter() - .all(|&l| for_each_local_use_after_expr(cx, l, expr.hir_id, |_| ControlFlow::Break::<()>(())).is_continue()) + && locals.iter().zip(local_parents.iter()).all(|(&l, &parent)| { + if let Node::LetStmt(_) = parent { + return true; + } + + let Some(b) = get_enclosing_block(cx, l) else { + return true; + }; + local_used_once(cx, b, l).is_some() + }) && local_parents.first().is_some_and(|node| { let Some(ty) = match node { - Node::Pat(pat) => Some(pat.hir_id), + Node::Pat(pat) + if let PatKind::Tuple(pats, _) | PatKind::Slice(pats, None, []) = &pat.kind + && pats.iter().zip(locals.iter()).all(|(p, l)| { + if let PatKind::Binding(_, id, _, _) = p.kind { + id == *l + } else { + true + } + }) => + { + Some(pat.hir_id) + }, Node::LetStmt(l) => Some(l.hir_id), _ => None, } @@ -186,7 +201,9 @@ fn all_bindings_are_for_conv<'tcx>( tys.len() == elements.len() && tys.iter().chain(final_tys.iter().copied()).all_equal() }, (ToType::Tuple, ty::Array(ty, len)) => { - let Some(len) = len.try_to_target_usize(cx.tcx) else { return false }; + let Some(len) = len.try_to_target_usize(cx.tcx) else { + return false; + }; len as usize == elements.len() && final_tys.iter().chain(once(ty)).all_equal() }, _ => false, diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 8ed3df8731b3..a95f2b681add 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -180,14 +180,19 @@ impl Local { field_indices, .. } => { + let field_projections = place + .projections + .iter() + .filter(|proj| matches!(proj.kind, ProjectionKind::Field(_, _))) + .collect::>(); is_potentially_local_place(*local_id, place) // If there were projections other than field projections, err on the side of caution and say that they // _might_ be mutating something. // // The reason we use `<=` and not `==` is that a mutation of `struct` or `struct.field1` should count as // mutation of the child fields such as `struct.field1.field2` - && place.projections.len() <= field_indices.len() - && iter::zip(&place.projections, field_indices.iter().copied().rev()).all(|(proj, field_idx)| { + && field_projections.len() <= field_indices.len() + && iter::zip(&field_projections, field_indices.iter().copied().rev()).all(|(proj, field_idx)| { match proj.kind { ProjectionKind::Field(f_idx, _) => f_idx == field_idx, // If this is a projection we don't expect, it _might_ be mutating something diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 0cf5b9431a34..c06313d1a4c4 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -354,7 +354,10 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { return; } - let sugg = snippet(cx, recv.span, "").into_owned(); + let mut applicability = Applicability::MachineApplicable; + let sugg = snippet_with_context(cx, recv.span, e.span.ctxt(), "", &mut applicability) + .0 + .into_owned(); span_lint_and_sugg( cx, USELESS_CONVERSION, diff --git a/clippy_lints/src/zero_repeat_side_effects.rs b/clippy_lints/src/zero_repeat_side_effects.rs index a8351690068d..95085161c09c 100644 --- a/clippy_lints/src/zero_repeat_side_effects.rs +++ b/clippy_lints/src/zero_repeat_side_effects.rs @@ -4,10 +4,11 @@ use clippy_utils::source::{snippet, snippet_indent}; use rustc_ast::LitKind; use rustc_data_structures::packed::Pu128; use rustc_errors::Applicability; -use rustc_hir::{ConstArgKind, ExprKind, Node}; +use rustc_hir::{ConstArgKind, Expr, ExprKind, LetStmt, LocalSource, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::IsSuggestable; +use rustc_middle::ty::{IsSuggestable, Ty}; use rustc_session::declare_lint_pass; +use rustc_span::Span; declare_clippy_lint! { /// ### What it does @@ -44,7 +45,7 @@ declare_clippy_lint! { declare_lint_pass!(ZeroRepeatSideEffects => [ZERO_REPEAT_SIDE_EFFECTS]); impl LateLintPass<'_> for ZeroRepeatSideEffects { - fn check_expr(&mut self, cx: &LateContext<'_>, expr: &rustc_hir::Expr<'_>) { + fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { if let Some(args) = VecArgs::hir(cx, expr) && let VecArgs::Repeat(inner_expr, len) = args && let ExprKind::Lit(l) = len.kind @@ -69,7 +70,7 @@ impl LateLintPass<'_> for ZeroRepeatSideEffects { } } -fn inner_check(cx: &LateContext<'_>, expr: &'_ rustc_hir::Expr<'_>, inner_expr: &'_ rustc_hir::Expr<'_>, is_vec: bool) { +fn inner_check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, inner_expr: &'_ Expr<'_>, is_vec: bool) { // check if expr is a call or has a call inside it if inner_expr.can_have_side_effects() { let parent_hir_node = cx.tcx.parent_hir_node(expr.hir_id); @@ -81,19 +82,22 @@ fn inner_check(cx: &LateContext<'_>, expr: &'_ rustc_hir::Expr<'_>, inner_expr: let vec = if is_vec { "vec!" } else { "" }; let (span, sugg) = match parent_hir_node { - Node::LetStmt(l) => ( - l.span, - format!( - "{inner_expr};\n{indent}let {var_name}: {return_type} = {vec}[];", - var_name = snippet(cx, l.pat.span.source_callsite(), "..") - ), - ), + Node::LetStmt(l) + if matches!(l.source, LocalSource::AssignDesugar) + && let mut parent_iter = cx.tcx.hir_parent_iter(l.hir_id) + && let Some((_, Node::Stmt(_))) = parent_iter.next() + && let Some((_, Node::Block(_))) = parent_iter.next() + && let Some((_, Node::Expr(x))) = parent_iter.next() => + { + ( + x.span, + assign_expr_suggestion(cx, x, l.pat.span, &inner_expr, return_type, vec), + ) + }, + Node::LetStmt(l) => (l.span, let_stmt_suggestion(cx, l, &inner_expr, return_type, vec)), Node::Expr(x) if let ExprKind::Assign(l, _, _) = x.kind => ( x.span, - format!( - "{inner_expr};\n{indent}{var_name} = {vec}[] as {return_type}", - var_name = snippet(cx, l.span.source_callsite(), "..") - ), + assign_expr_suggestion(cx, x, l.span, &inner_expr, return_type, vec), ), // NOTE: don't use the stmt span to avoid touching the trailing semicolon Node::Stmt(_) => (expr.span, format!("{inner_expr};\n{indent}{vec}[] as {return_type}")), @@ -131,3 +135,41 @@ fn inner_check(cx: &LateContext<'_>, expr: &'_ rustc_hir::Expr<'_>, inner_expr: ); } } + +fn let_stmt_suggestion( + cx: &LateContext<'_>, + let_stmt: &LetStmt<'_>, + inner_expr: &str, + return_type: Ty<'_>, + vec_str: &str, +) -> String { + let indent = snippet_indent(cx, let_stmt.span).unwrap_or_default(); + format!( + "{inner_expr};\n{}let {var_name}: {return_type} = {vec_str}[];", + indent, + var_name = snippet(cx, let_stmt.pat.span.source_callsite(), "..") + ) +} + +fn assign_expr_suggestion( + cx: &LateContext<'_>, + outer_expr: &Expr<'_>, + assign_expr_span: Span, + inner_expr: &str, + return_type: Ty<'_>, + vec_str: &str, +) -> String { + let mut parent_hir_node = cx.tcx.parent_hir_node(outer_expr.hir_id); + if let Node::Stmt(stmt) = parent_hir_node { + parent_hir_node = cx.tcx.parent_hir_node(stmt.hir_id); + } + let needs_curly = !matches!(parent_hir_node, Node::Block(_)); + + let indent = snippet_indent(cx, outer_expr.span).unwrap_or_default(); + let var_name = snippet(cx, assign_expr_span.source_callsite(), ".."); + if needs_curly { + format!("{{\n {indent}{inner_expr};\n {indent}{var_name} = {vec_str}[] as {return_type}\n{indent}}}",) + } else { + format!("{inner_expr};\n{indent}{var_name} = {vec_str}[] as {return_type}") + } +} diff --git a/clippy_utils/Cargo.toml b/clippy_utils/Cargo.toml index a1e1b763dccb..503d581d6c7f 100644 --- a/clippy_utils/Cargo.toml +++ b/clippy_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy_utils" -version = "0.1.93" +version = "0.1.94" edition = "2024" description = "Helpful tools for writing lints, provided as they are used in Clippy" repository = "https://github.com/rust-lang/rust-clippy" @@ -16,6 +16,10 @@ itertools = "0.12" rustc_apfloat = "0.2.0" serde = { version = "1.0", features = ["derive"] } +[lints.rust.unexpected_cfgs] +level = "warn" +check-cfg = ['cfg(bootstrap)'] + [package.metadata.rust-analyzer] # This crate uses #[feature(rustc_private)] rustc_private = true diff --git a/clippy_utils/README.md b/clippy_utils/README.md index 4b1a10a3d9cf..dc8695fef9f5 100644 --- a/clippy_utils/README.md +++ b/clippy_utils/README.md @@ -8,7 +8,7 @@ This crate is only guaranteed to build with this `nightly` toolchain: ``` -nightly-2025-11-28 +nightly-2025-12-11 ``` diff --git a/clippy_utils/src/msrvs.rs b/clippy_utils/src/msrvs.rs index 86d17a8231d5..4a7fa3472cae 100644 --- a/clippy_utils/src/msrvs.rs +++ b/clippy_utils/src/msrvs.rs @@ -40,6 +40,7 @@ msrv_aliases! { 1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE } 1,70,0 { OPTION_RESULT_IS_VARIANT_AND, BINARY_HEAP_RETAIN } 1,68,0 { PATH_MAIN_SEPARATOR_STR } + 1,67,0 { ILOG2 } 1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS } 1,63,0 { CLONE_INTO, CONST_SLICE_FROM_REF } 1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE, CONST_EXTERN_C_FN } diff --git a/clippy_utils/src/sym.rs b/clippy_utils/src/sym.rs index 1d1537dd0e91..00f4a9c7e586 100644 --- a/clippy_utils/src/sym.rs +++ b/clippy_utils/src/sym.rs @@ -180,6 +180,7 @@ generate! { has_significant_drop, hidden_glob_reexports, hygiene, + ilog, insert, insert_str, inspect, @@ -207,6 +208,7 @@ generate! { join, kw, lazy_static, + leading_zeros, lint_vec, ln, lock, diff --git a/declare_clippy_lint/Cargo.toml b/declare_clippy_lint/Cargo.toml index b73a7c7bb4d9..ee6d6cdbc34e 100644 --- a/declare_clippy_lint/Cargo.toml +++ b/declare_clippy_lint/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "declare_clippy_lint" -version = "0.1.93" +version = "0.1.94" edition = "2024" repository = "https://github.com/rust-lang/rust-clippy" license = "MIT OR Apache-2.0" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5157b79832a3..1384f4078ebe 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] # begin autogenerated nightly -channel = "nightly-2025-11-28" +channel = "nightly-2025-12-11" # end autogenerated nightly components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] profile = "minimal" diff --git a/tests/ui-toml/large_stack_frames_for_macros/clippy.toml b/tests/ui-toml/large_stack_frames_for_macros/clippy.toml new file mode 100644 index 000000000000..b6fd0e8a0483 --- /dev/null +++ b/tests/ui-toml/large_stack_frames_for_macros/clippy.toml @@ -0,0 +1 @@ +stack-size-threshold = 0 diff --git a/tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs b/tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs new file mode 100644 index 000000000000..1f6265590f93 --- /dev/null +++ b/tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs @@ -0,0 +1,42 @@ +//@ignore-target: i686 +//@normalize-stderr-test: "\b10000(08|16|32)\b" -> "100$$PTR" +//@normalize-stderr-test: "\b2500(060|120)\b" -> "250$$PTR" + +#![warn(clippy::large_stack_frames)] + +extern crate serde; +use serde::{Deserialize, Serialize}; + +struct ArrayDefault([u8; N]); + +macro_rules! mac { + ($name:ident) => { + fn foo() { + let $name = 1; + println!("macro_name called"); + } + + fn bar() { + let $name = ArrayDefault([0; 1000]); + } + }; +} + +mac!(something); +//~^ large_stack_frames +//~| large_stack_frames + +#[derive(Deserialize, Serialize)] +//~^ large_stack_frames +//~| large_stack_frames +//~| large_stack_frames +//~| large_stack_frames +//~| large_stack_frames +//~| large_stack_frames +//~| large_stack_frames +//~| large_stack_frames +struct S { + a: [u128; 31], +} + +fn main() {} diff --git a/tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.stderr b/tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.stderr new file mode 100644 index 000000000000..bc222f6b1039 --- /dev/null +++ b/tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.stderr @@ -0,0 +1,89 @@ +error: function `foo` generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:25:1 + | +LL | fn foo() { + | --- this function has a stack frame size of 20 bytes +... +LL | mac!(something); + | ^^^^^^^^^^^^^^^ + | + = note: 20 bytes is larger than Clippy's configured `stack-size-threshold` of 0 + = note: allocating large amounts of stack space can overflow the stack and cause the program to abort + = note: `-D clippy::large-stack-frames` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]` + +error: function `bar` generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:25:1 + | +LL | fn bar() { + | --- this function has a stack frame size of 2000 bytes +LL | let $name = ArrayDefault([0; 1000]); + | --------- this is the largest part, at 1000 bytes for type `[u8; 1000]` +... +LL | mac!(something); + | ^^^^^^^^^^^^^^^ + | + = note: 2000 bytes is larger than Clippy's configured `stack-size-threshold` of 0 + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:10 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: method generated by this macro may allocate a lot of stack space + --> tests/ui-toml/large_stack_frames_for_macros/large_stack_frames.rs:29:23 + | +LL | #[derive(Deserialize, Serialize)] + | ^^^^^^^^^ + +error: aborting due to 10 previous errors + diff --git a/tests/ui-toml/large_stack_frames_for_special_targets/clippy.toml b/tests/ui-toml/large_stack_frames_for_special_targets/clippy.toml new file mode 100644 index 000000000000..02f3bc02dc4b --- /dev/null +++ b/tests/ui-toml/large_stack_frames_for_special_targets/clippy.toml @@ -0,0 +1,2 @@ +stack-size-threshold = 0 +allow-large-stack-frames-in-tests = false diff --git a/tests/ui-toml/large_stack_frames_for_special_targets/large_stack_frames.rs b/tests/ui-toml/large_stack_frames_for_special_targets/large_stack_frames.rs new file mode 100644 index 000000000000..cc01232ca408 --- /dev/null +++ b/tests/ui-toml/large_stack_frames_for_special_targets/large_stack_frames.rs @@ -0,0 +1,13 @@ +// This test checks if `clippy::large_stack_frames` is working correctly when encountering functions +// generated by special compiling targets like `--test`. +//@compile-flags: --test +//@check-pass + +#![warn(clippy::large_stack_frames)] + +#[cfg(test)] +#[expect(clippy::large_stack_frames)] +mod test { + #[test] + fn main_test() {} +} diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed index 419e62f92f46..3683e826aa92 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed @@ -1,6 +1,7 @@ //@aux-build:proc_macro_derive.rs #![warn(clippy::nonstandard_macro_braces)] +#![allow(clippy::println_empty_string)] extern crate proc_macro_derive; extern crate quote; @@ -75,3 +76,16 @@ fn issue9913() { [0]; // separate statement, not indexing into the result of println. //~^^ nonstandard_macro_braces } + +fn issue15594() { + println!(); + println!(""); + println!(); + //~^ nonstandard_macro_braces + println!(""); + //~^ nonstandard_macro_braces + println!(); + //~^ nonstandard_macro_braces + println!(""); + //~^ nonstandard_macro_braces +} diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs index b0bbced4ea3c..c1779dceff17 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs @@ -1,6 +1,7 @@ //@aux-build:proc_macro_derive.rs #![warn(clippy::nonstandard_macro_braces)] +#![allow(clippy::println_empty_string)] extern crate proc_macro_derive; extern crate quote; @@ -75,3 +76,16 @@ fn issue9913() { [0]; // separate statement, not indexing into the result of println. //~^^ nonstandard_macro_braces } + +fn issue15594() { + println!(); + println!(""); + println![]; + //~^ nonstandard_macro_braces + println![""]; + //~^ nonstandard_macro_braces + println! {}; + //~^ nonstandard_macro_braces + println! {""}; + //~^ nonstandard_macro_braces +} diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr index 87325f05c9bc..2488f7fa01e5 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr @@ -1,5 +1,5 @@ error: use of irregular braces for `vec!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:44:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:45:13 | LL | let _ = vec! {1, 2, 3}; | ^^^^^^^^^^^^^^ help: consider writing: `vec![1, 2, 3]` @@ -8,31 +8,31 @@ LL | let _ = vec! {1, 2, 3}; = help: to override `-D warnings` add `#[allow(clippy::nonstandard_macro_braces)]` error: use of irregular braces for `format!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:46:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:47:13 | LL | let _ = format!["ugh {} stop being such a good compiler", "hello"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `format!("ugh {} stop being such a good compiler", "hello")` error: use of irregular braces for `matches!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:48:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:49:13 | LL | let _ = matches!{{}, ()}; | ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())` error: use of irregular braces for `quote!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:50:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:51:13 | LL | let _ = quote!(let x = 1;); | ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}` error: use of irregular braces for `quote::quote!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:52:13 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:53:13 | LL | let _ = quote::quote!(match match match); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}` error: use of irregular braces for `vec!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:18:9 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:19:9 | LL | vec!{0, 0, 0} | ^^^^^^^^^^^^^ help: consider writing: `vec![0, 0, 0]` @@ -43,22 +43,46 @@ LL | let _ = test!(); // trigger when macro def is inside our own crate = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) error: use of irregular braces for `type_pos!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:62:12 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:63:12 | LL | let _: type_pos!(usize) = vec![]; | ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]` error: use of irregular braces for `eprint!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:65:5 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:66:5 | LL | eprint!("test if user config overrides defaults"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `eprint!["test if user config overrides defaults"]` error: use of irregular braces for `println!` macro - --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:74:5 + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:75:5 | LL | println! {"hello world"} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `println!("hello world");` -error: aborting due to 9 previous errors +error: use of irregular braces for `println!` macro + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:83:5 + | +LL | println![]; + | ^^^^^^^^^^ help: consider writing: `println!()` + +error: use of irregular braces for `println!` macro + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:85:5 + | +LL | println![""]; + | ^^^^^^^^^^^^ help: consider writing: `println!("")` + +error: use of irregular braces for `println!` macro + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:87:5 + | +LL | println! {}; + | ^^^^^^^^^^^ help: consider writing: `println!()` + +error: use of irregular braces for `println!` macro + --> tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs:89:5 + | +LL | println! {""}; + | ^^^^^^^^^^^^^ help: consider writing: `println!("")` + +error: aborting due to 13 previous errors diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index d5040f4a39bf..e208bd510657 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -9,6 +9,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect allow-expect-in-consts allow-expect-in-tests allow-indexing-slicing-in-tests + allow-large-stack-frames-in-tests allow-mixed-uninlined-format-args allow-one-hash-in-raw-strings allow-panic-in-tests @@ -107,6 +108,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect allow-expect-in-consts allow-expect-in-tests allow-indexing-slicing-in-tests + allow-large-stack-frames-in-tests allow-mixed-uninlined-format-args allow-one-hash-in-raw-strings allow-panic-in-tests @@ -205,6 +207,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni allow-expect-in-consts allow-expect-in-tests allow-indexing-slicing-in-tests + allow-large-stack-frames-in-tests allow-mixed-uninlined-format-args allow-one-hash-in-raw-strings allow-panic-in-tests diff --git a/tests/ui/borrow_as_ptr.fixed b/tests/ui/borrow_as_ptr.fixed index bfe826508f36..a4689a7840ce 100644 --- a/tests/ui/borrow_as_ptr.fixed +++ b/tests/ui/borrow_as_ptr.fixed @@ -1,6 +1,6 @@ //@aux-build:proc_macros.rs #![warn(clippy::borrow_as_ptr)] -#![allow(clippy::useless_vec)] +#![allow(clippy::useless_vec, clippy::ptr_offset_by_literal)] extern crate proc_macros; diff --git a/tests/ui/borrow_as_ptr.rs b/tests/ui/borrow_as_ptr.rs index ce248f157c6e..d7468f37a3a4 100644 --- a/tests/ui/borrow_as_ptr.rs +++ b/tests/ui/borrow_as_ptr.rs @@ -1,6 +1,6 @@ //@aux-build:proc_macros.rs #![warn(clippy::borrow_as_ptr)] -#![allow(clippy::useless_vec)] +#![allow(clippy::useless_vec, clippy::ptr_offset_by_literal)] extern crate proc_macros; diff --git a/tests/ui/checked_unwrap/simple_conditionals.rs b/tests/ui/checked_unwrap/simple_conditionals.rs index c6476a7507a1..bab20b091d38 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.rs +++ b/tests/ui/checked_unwrap/simple_conditionals.rs @@ -472,3 +472,22 @@ fn issue15321() { //~^ unnecessary_unwrap } } + +mod issue16188 { + struct Foo { + value: Option, + } + + impl Foo { + pub fn bar(&mut self) { + let print_value = |v: i32| { + println!("{}", v); + }; + + if self.value.is_none() { + self.value = Some(10); + print_value(self.value.unwrap()); + } + } + } +} diff --git a/tests/ui/crashes/ice-4579.rs b/tests/ui/crashes/ice-4579.rs index 14c8113e315b..a2592e74c66d 100644 --- a/tests/ui/crashes/ice-4579.rs +++ b/tests/ui/crashes/ice-4579.rs @@ -1,6 +1,6 @@ //@ check-pass -#![allow(clippy::single_match)] +#![allow(clippy::single_match, clippy::ptr_offset_by_literal)] use std::ptr; diff --git a/tests/ui/decimal_bitwise_operands.rs b/tests/ui/decimal_bitwise_operands.rs new file mode 100644 index 000000000000..f1c053bb4358 --- /dev/null +++ b/tests/ui/decimal_bitwise_operands.rs @@ -0,0 +1,133 @@ +#![allow( + clippy::erasing_op, + clippy::no_effect, + clippy::unnecessary_operation, + clippy::unnecessary_cast, + clippy::op_ref +)] +#![warn(clippy::decimal_bitwise_operands)] + +macro_rules! bitwise_op { + ($x:expr, $y:expr) => { + $x & $y; + }; +} + +pub const SOME_CONST: i32 = 12345; + +fn main() { + let mut x = 0; + // BAD: Bitwise operation, decimal literal, one literal + x & 9_8765_4321; //~ decimal_bitwise_operands + x & 100_i32; //~ decimal_bitwise_operands + x | (/* comment */99); //~ decimal_bitwise_operands + x ^ (99); //~ decimal_bitwise_operands + x &= 99; //~ decimal_bitwise_operands + x |= { 99 }; //~ decimal_bitwise_operands + x |= { { 99 } }; //~ decimal_bitwise_operands + x |= { + 0b1000; + 99 //~ decimal_bitwise_operands + }; + x ^= (99); //~ decimal_bitwise_operands + + // BAD: Bitwise operation, decimal literal, two literals + 0b1010 & 99; //~ decimal_bitwise_operands + 0b1010 | (99); //~ decimal_bitwise_operands + 0b1010 ^ (/* comment */99); //~ decimal_bitwise_operands + 99 & 0b1010; //~ decimal_bitwise_operands + (99) | 0b1010; //~ decimal_bitwise_operands + (/* comment */99) ^ 0b1010; //~ decimal_bitwise_operands + 0xD | { 99 }; //~ decimal_bitwise_operands + 88 & 99; + //~^ decimal_bitwise_operands + //~| decimal_bitwise_operands + 37 & 38 & 39; + //~^ decimal_bitwise_operands + //~| decimal_bitwise_operands + //~| decimal_bitwise_operands + + // GOOD: Bitwise operation, binary/hex/octal literal, one literal + x & 0b1010; + x | 0b1010; + x ^ 0b1010; + x &= 0b1010; + x |= 0b1010; + x ^= 0b1010; + x & 0xD; + x & 0o77; + x | 0o123; + x ^ 0o377; + x &= 0o777; + x |= 0o7; + x ^= 0o70; + + // GOOD: Bitwise operation, binary/hex/octal literal, two literals + 0b1010 & 0b1101; + 0xD ^ 0xF; + 0o377 ^ 0o77; + 0b1101 ^ 0xFF; + + // GOOD: Numeric operation, any literal + x += 99; + x -= 0b1010; + x *= 0xD; + 99 + 99; + 0b1010 - 0b1101; + 0xD * 0xD; + + // BAD: Unary, cast and reference, decimal literal + x & !100; //~ decimal_bitwise_operands + x & -100; //~ decimal_bitwise_operands + x & (100 as i32); //~ decimal_bitwise_operands + x & &100; //~ decimal_bitwise_operands + + // GOOD: Unary, cast and reference, non-decimal literal + x & !0b1101; + x & -0xD; + x & (0o333 as i32); + x & &0b1010; + + // GOOD: Bitwise operation, variables only + let y = 0; + x & y; + x &= y; + x + y; + x += y; + + // GOOD: Macro expansion (should be ignored) + bitwise_op!(x, 123); + bitwise_op!(0b1010, 123); + + // GOOD: Using const (should be ignored) + x & SOME_CONST; + x |= SOME_CONST; + + // GOOD: Parenthesized binary/hex literal (should not trigger lint) + x & (0b1111); + x |= (0b1010); + x ^ (/* comment */0b1100); + (0xFF) & x; + + // GOOD: Power of two and power of two minus one + x & 16; // 2^4 + x | (31); // 2^5 - 1 + x ^ 0x40; // 2^6 (hex) + x ^= 7; // 2^3 - 1 + + // GOOD: Bitwise operation, single digit decimal literal + 5 & 9; + x ^ 6; + x ^= 7; + + // GOOD: More complex expressions + (x + 1) & 0xFF; + (x * 2) | (y & 0xF); + (x ^ y) & 0b11110000; + x | (1 << 9); + + // GOOD: Special cases + x & 0; // All bits off + x | !0; // All bits on + x ^ 1; // Toggle LSB +} diff --git a/tests/ui/decimal_bitwise_operands.stderr b/tests/ui/decimal_bitwise_operands.stderr new file mode 100644 index 000000000000..1b2b7bb71b69 --- /dev/null +++ b/tests/ui/decimal_bitwise_operands.stderr @@ -0,0 +1,204 @@ +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:21:9 + | +LL | x & 9_8765_4321; + | ^^^^^^^^^^^ + | + = help: use binary (0b11_1010_1101_1110_0110_1000_1011_0001), hex (0x3ade_68b1), or octal (0o7_267_464_261) notation for better readability + = note: `-D clippy::decimal-bitwise-operands` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::decimal_bitwise_operands)]` + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:22:9 + | +LL | x & 100_i32; + | ^^^^^^^ + | + = help: use binary (0b110_0100_i32), hex (0x0064_i32), or octal (0o144_i32) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:23:23 + | +LL | x | (/* comment */99); + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:24:10 + | +LL | x ^ (99); + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:25:10 + | +LL | x &= 99; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:26:12 + | +LL | x |= { 99 }; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:27:14 + | +LL | x |= { { 99 } }; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:30:9 + | +LL | 99 + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:32:11 + | +LL | x ^= (99); + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:35:14 + | +LL | 0b1010 & 99; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:36:15 + | +LL | 0b1010 | (99); + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:37:28 + | +LL | 0b1010 ^ (/* comment */99); + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:38:5 + | +LL | 99 & 0b1010; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:39:6 + | +LL | (99) | 0b1010; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:40:19 + | +LL | (/* comment */99) ^ 0b1010; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:41:13 + | +LL | 0xD | { 99 }; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:42:5 + | +LL | 88 & 99; + | ^^ + | + = help: use binary (0b101_1000), hex (0x0058), or octal (0o130) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:42:10 + | +LL | 88 & 99; + | ^^ + | + = help: use binary (0b110_0011), hex (0x0063), or octal (0o143) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:45:15 + | +LL | 37 & 38 & 39; + | ^^ + | + = help: use binary (0b10_0111), hex (0x0027), or octal (0o47) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:45:5 + | +LL | 37 & 38 & 39; + | ^^ + | + = help: use binary (0b10_0101), hex (0x0025), or octal (0o45) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:45:10 + | +LL | 37 & 38 & 39; + | ^^ + | + = help: use binary (0b10_0110), hex (0x0026), or octal (0o46) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:80:10 + | +LL | x & !100; + | ^^^ + | + = help: use binary (0b110_0100), hex (0x0064), or octal (0o144) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:81:10 + | +LL | x & -100; + | ^^^ + | + = help: use binary (0b110_0100), hex (0x0064), or octal (0o144) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:82:10 + | +LL | x & (100 as i32); + | ^^^ + | + = help: use binary (0b110_0100), hex (0x0064), or octal (0o144) notation for better readability + +error: using decimal literal for bitwise operation + --> tests/ui/decimal_bitwise_operands.rs:83:10 + | +LL | x & &100; + | ^^^ + | + = help: use binary (0b110_0100), hex (0x0064), or octal (0o144) notation for better readability + +error: aborting due to 25 previous errors + diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index cd225da611c4..fa70371b926f 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -61,7 +61,7 @@ error: lint `clippy::should_assert_eq` has been removed: `assert!(a == b)` can n LL | #![warn(clippy::should_assert_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::string_to_string` has been removed: `clippy:implicit_clone` covers those cases +error: lint `clippy::string_to_string` has been removed: `clippy::implicit_clone` covers those cases --> tests/ui/deprecated.rs:15:9 | LL | #![warn(clippy::string_to_string)] diff --git a/tests/ui/entry.fixed b/tests/ui/entry.fixed index f2df9f0204ea..1e36ca4f1f09 100644 --- a/tests/ui/entry.fixed +++ b/tests/ui/entry.fixed @@ -248,4 +248,28 @@ mod issue14449 { } } +// Don't suggest when it would cause `MutexGuard` to be held across an await point. +mod issue_16173 { + use std::collections::HashMap; + use std::sync::Mutex; + + async fn f() {} + + async fn foo() { + let mu_map = Mutex::new(HashMap::new()); + if !mu_map.lock().unwrap().contains_key(&0) { + f().await; + mu_map.lock().unwrap().insert(0, 0); + } + + if mu_map.lock().unwrap().contains_key(&1) { + todo!(); + } else { + mu_map.lock().unwrap().insert(1, 42); + todo!(); + f().await; + } + } +} + fn main() {} diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index 166eea417ac2..b3da0ef3ffd6 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -254,4 +254,28 @@ mod issue14449 { } } +// Don't suggest when it would cause `MutexGuard` to be held across an await point. +mod issue_16173 { + use std::collections::HashMap; + use std::sync::Mutex; + + async fn f() {} + + async fn foo() { + let mu_map = Mutex::new(HashMap::new()); + if !mu_map.lock().unwrap().contains_key(&0) { + f().await; + mu_map.lock().unwrap().insert(0, 0); + } + + if mu_map.lock().unwrap().contains_key(&1) { + todo!(); + } else { + mu_map.lock().unwrap().insert(1, 42); + todo!(); + f().await; + } + } +} + fn main() {} diff --git a/tests/ui/len_without_is_empty.rs b/tests/ui/len_without_is_empty.rs index 011833072d76..509348628dd6 100644 --- a/tests/ui/len_without_is_empty.rs +++ b/tests/ui/len_without_is_empty.rs @@ -473,4 +473,16 @@ impl Alias2 { } } +// Issue #16190 +pub struct RefMutLenButRefIsEmpty; +impl RefMutLenButRefIsEmpty { + pub fn len(&mut self) -> usize { + todo!() + } + + pub fn is_empty(&self) -> bool { + todo!() + } +} + fn main() {} diff --git a/tests/ui/manual_ilog2.fixed b/tests/ui/manual_ilog2.fixed new file mode 100644 index 000000000000..a0f6d9392c30 --- /dev/null +++ b/tests/ui/manual_ilog2.fixed @@ -0,0 +1,32 @@ +//@aux-build:proc_macros.rs +#![warn(clippy::manual_ilog2)] +#![allow(clippy::unnecessary_operation)] + +use proc_macros::{external, with_span}; + +fn foo(a: u32, b: u64) { + a.ilog2(); //~ manual_ilog2 + a.ilog2(); //~ manual_ilog2 + + b.ilog2(); //~ manual_ilog2 + 64 - b.leading_zeros(); // No lint because manual ilog2 is `BIT_WIDTH - 1 - x.leading_zeros()` + + // don't lint when macros are involved + macro_rules! two { + () => { + 2 + }; + }; + + macro_rules! thirty_one { + () => { + 31 + }; + }; + + a.ilog(two!()); + thirty_one!() - a.leading_zeros(); + + external!($a.ilog(2)); + with_span!(span; a.ilog(2)); +} diff --git a/tests/ui/manual_ilog2.rs b/tests/ui/manual_ilog2.rs new file mode 100644 index 000000000000..bd4b5d9d3c0d --- /dev/null +++ b/tests/ui/manual_ilog2.rs @@ -0,0 +1,32 @@ +//@aux-build:proc_macros.rs +#![warn(clippy::manual_ilog2)] +#![allow(clippy::unnecessary_operation)] + +use proc_macros::{external, with_span}; + +fn foo(a: u32, b: u64) { + 31 - a.leading_zeros(); //~ manual_ilog2 + a.ilog(2); //~ manual_ilog2 + + 63 - b.leading_zeros(); //~ manual_ilog2 + 64 - b.leading_zeros(); // No lint because manual ilog2 is `BIT_WIDTH - 1 - x.leading_zeros()` + + // don't lint when macros are involved + macro_rules! two { + () => { + 2 + }; + }; + + macro_rules! thirty_one { + () => { + 31 + }; + }; + + a.ilog(two!()); + thirty_one!() - a.leading_zeros(); + + external!($a.ilog(2)); + with_span!(span; a.ilog(2)); +} diff --git a/tests/ui/manual_ilog2.stderr b/tests/ui/manual_ilog2.stderr new file mode 100644 index 000000000000..7c9694f35330 --- /dev/null +++ b/tests/ui/manual_ilog2.stderr @@ -0,0 +1,23 @@ +error: manually reimplementing `ilog2` + --> tests/ui/manual_ilog2.rs:8:5 + | +LL | 31 - a.leading_zeros(); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.ilog2()` + | + = note: `-D clippy::manual-ilog2` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::manual_ilog2)]` + +error: manually reimplementing `ilog2` + --> tests/ui/manual_ilog2.rs:9:5 + | +LL | a.ilog(2); + | ^^^^^^^^^ help: try: `a.ilog2()` + +error: manually reimplementing `ilog2` + --> tests/ui/manual_ilog2.rs:11:5 + | +LL | 63 - b.leading_zeros(); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `b.ilog2()` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/manual_saturating_arithmetic.fixed b/tests/ui/manual_saturating_arithmetic.fixed index 304be05f6c4c..8dd142b2c79a 100644 --- a/tests/ui/manual_saturating_arithmetic.fixed +++ b/tests/ui/manual_saturating_arithmetic.fixed @@ -58,3 +58,13 @@ fn main() { let _ = 1i8.checked_sub(1).unwrap_or(127); // ok let _ = 1i8.checked_sub(-1).unwrap_or(-128); // ok } + +fn issue15655() { + let _ = 5u32.saturating_sub(1u32); //~ manual_saturating_arithmetic + let _ = 5u32.checked_add(1u32).unwrap_or_default(); // ok + let _ = 5u32.checked_mul(1u32).unwrap_or_default(); // ok + + let _ = 5i32.checked_sub(1i32).unwrap_or_default(); // ok + let _ = 5i32.checked_add(1i32).unwrap_or_default(); // ok + let _ = 5i32.checked_mul(1i32).unwrap_or_default(); // ok +} diff --git a/tests/ui/manual_saturating_arithmetic.rs b/tests/ui/manual_saturating_arithmetic.rs index c2b570e974ac..9cc8bc42410d 100644 --- a/tests/ui/manual_saturating_arithmetic.rs +++ b/tests/ui/manual_saturating_arithmetic.rs @@ -73,3 +73,13 @@ fn main() { let _ = 1i8.checked_sub(1).unwrap_or(127); // ok let _ = 1i8.checked_sub(-1).unwrap_or(-128); // ok } + +fn issue15655() { + let _ = 5u32.checked_sub(1u32).unwrap_or_default(); //~ manual_saturating_arithmetic + let _ = 5u32.checked_add(1u32).unwrap_or_default(); // ok + let _ = 5u32.checked_mul(1u32).unwrap_or_default(); // ok + + let _ = 5i32.checked_sub(1i32).unwrap_or_default(); // ok + let _ = 5i32.checked_add(1i32).unwrap_or_default(); // ok + let _ = 5i32.checked_mul(1i32).unwrap_or_default(); // ok +} diff --git a/tests/ui/manual_saturating_arithmetic.stderr b/tests/ui/manual_saturating_arithmetic.stderr index 2f006a3ae170..aec0f0a16419 100644 --- a/tests/ui/manual_saturating_arithmetic.stderr +++ b/tests/ui/manual_saturating_arithmetic.stderr @@ -165,5 +165,11 @@ LL | | .checked_sub(-1) LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); | |_______________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(-1)` -error: aborting due to 24 previous errors +error: manual saturating arithmetic + --> tests/ui/manual_saturating_arithmetic.rs:78:13 + | +LL | let _ = 5u32.checked_sub(1u32).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `5u32.saturating_sub(1u32)` + +error: aborting due to 25 previous errors diff --git a/tests/ui/match_like_matches_macro.fixed b/tests/ui/match_like_matches_macro.fixed index a1c95e8a94f1..dad59c1ce6e4 100644 --- a/tests/ui/match_like_matches_macro.fixed +++ b/tests/ui/match_like_matches_macro.fixed @@ -223,3 +223,10 @@ fn msrv_1_42() { let _y = matches!(Some(5), Some(0)); //~^^^^ match_like_matches_macro } + +#[expect(clippy::option_option)] +fn issue15841(opt: Option>>, value: i32) { + // Lint: no if-let _in the guard_ + let _ = matches!(opt, Some(first) if (if let Some(second) = first { true } else { todo!() })); + //~^^^^ match_like_matches_macro +} diff --git a/tests/ui/match_like_matches_macro.rs b/tests/ui/match_like_matches_macro.rs index eb419ba5bf8d..94bc6433e5cb 100644 --- a/tests/ui/match_like_matches_macro.rs +++ b/tests/ui/match_like_matches_macro.rs @@ -267,3 +267,13 @@ fn msrv_1_42() { }; //~^^^^ match_like_matches_macro } + +#[expect(clippy::option_option)] +fn issue15841(opt: Option>>, value: i32) { + // Lint: no if-let _in the guard_ + let _ = match opt { + Some(first) if (if let Some(second) = first { true } else { todo!() }) => true, + _ => false, + }; + //~^^^^ match_like_matches_macro +} diff --git a/tests/ui/match_like_matches_macro.stderr b/tests/ui/match_like_matches_macro.stderr index ae277ce4dca6..a8e352461dbb 100644 --- a/tests/ui/match_like_matches_macro.stderr +++ b/tests/ui/match_like_matches_macro.stderr @@ -6,10 +6,18 @@ LL | let _y = match x { LL | | Some(0) => true, LL | | _ => false, LL | | }; - | |_____^ help: try: `matches!(x, Some(0))` + | |_____^ | = note: `-D clippy::match-like-matches-macro` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` +help: use `matches!` directly + | +LL - let _y = match x { +LL - Some(0) => true, +LL - _ => false, +LL - }; +LL + let _y = matches!(x, Some(0)); + | error: redundant pattern matching, consider using `is_some()` --> tests/ui/match_like_matches_macro.rs:20:14 @@ -42,13 +50,28 @@ LL | let _zz = match x { LL | | Some(r) if r == 0 => false, LL | | _ => true, LL | | }; - | |_____^ help: try: `!matches!(x, Some(r) if r == 0)` + | |_____^ + | +help: use `matches!` directly + | +LL - let _zz = match x { +LL - Some(r) if r == 0 => false, +LL - _ => true, +LL - }; +LL + let _zz = !matches!(x, Some(r) if r == 0); + | -error: if let .. else expression looks like `matches!` macro +error: `if let .. else` expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:41:16 | LL | let _zzz = if let Some(5) = x { true } else { false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(x, Some(5))` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `matches!` directly + | +LL - let _zzz = if let Some(5) = x { true } else { false }; +LL + let _zzz = matches!(x, Some(5)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:66:20 @@ -59,7 +82,17 @@ LL | | E::A(_) => true, LL | | E::B(_) => true, LL | | _ => false, LL | | }; - | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` + | |_________^ + | +help: use `matches!` directly + | +LL - let _ans = match x { +LL - E::A(_) => true, +LL - E::B(_) => true, +LL - _ => false, +LL - }; +LL + let _ans = matches!(x, E::A(_) | E::B(_)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:77:20 @@ -71,7 +104,19 @@ LL | | true ... | LL | | _ => false, LL | | }; - | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` + | |_________^ + | +help: use `matches!` directly + | +LL - let _ans = match x { +LL - E::A(_) => { +LL - true +LL - } +LL - E::B(_) => true, +LL - _ => false, +LL - }; +LL + let _ans = matches!(x, E::A(_) | E::B(_)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:88:20 @@ -82,7 +127,17 @@ LL | | E::B(_) => false, LL | | E::C => false, LL | | _ => true, LL | | }; - | |_________^ help: try: `!matches!(x, E::B(_) | E::C)` + | |_________^ + | +help: use `matches!` directly + | +LL - let _ans = match x { +LL - E::B(_) => false, +LL - E::C => false, +LL - _ => true, +LL - }; +LL + let _ans = !matches!(x, E::B(_) | E::C); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:149:18 @@ -92,7 +147,16 @@ LL | let _z = match &z { LL | | Some(3) => true, LL | | _ => false, LL | | }; - | |_________^ help: try: `matches!(z, Some(3))` + | |_________^ + | +help: use `matches!` directly + | +LL - let _z = match &z { +LL - Some(3) => true, +LL - _ => false, +LL - }; +LL + let _z = matches!(z, Some(3)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:159:18 @@ -102,7 +166,16 @@ LL | let _z = match &z { LL | | Some(3) => true, LL | | _ => false, LL | | }; - | |_________^ help: try: `matches!(&z, Some(3))` + | |_________^ + | +help: use `matches!` directly + | +LL - let _z = match &z { +LL - Some(3) => true, +LL - _ => false, +LL - }; +LL + let _z = matches!(&z, Some(3)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:177:21 @@ -112,7 +185,16 @@ LL | let _ = match &z { LL | | AnEnum::X => true, LL | | _ => false, LL | | }; - | |_____________^ help: try: `matches!(&z, AnEnum::X)` + | |_____________^ + | +help: use `matches!` directly + | +LL - let _ = match &z { +LL - AnEnum::X => true, +LL - _ => false, +LL - }; +LL + let _ = matches!(&z, AnEnum::X); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:192:20 @@ -122,7 +204,16 @@ LL | let _res = match &val { LL | | &Some(ref _a) => true, LL | | _ => false, LL | | }; - | |_________^ help: try: `matches!(&val, &Some(ref _a))` + | |_________^ + | +help: use `matches!` directly + | +LL - let _res = match &val { +LL - &Some(ref _a) => true, +LL - _ => false, +LL - }; +LL + let _res = matches!(&val, &Some(ref _a)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:205:20 @@ -132,7 +223,16 @@ LL | let _res = match &val { LL | | &Some(ref _a) => true, LL | | _ => false, LL | | }; - | |_________^ help: try: `matches!(&val, &Some(ref _a))` + | |_________^ + | +help: use `matches!` directly + | +LL - let _res = match &val { +LL - &Some(ref _a) => true, +LL - _ => false, +LL - }; +LL + let _res = matches!(&val, &Some(ref _a)); + | error: match expression looks like `matches!` macro --> tests/ui/match_like_matches_macro.rs:264:14 @@ -142,7 +242,35 @@ LL | let _y = match Some(5) { LL | | Some(0) => true, LL | | _ => false, LL | | }; - | |_____^ help: try: `matches!(Some(5), Some(0))` + | |_____^ + | +help: use `matches!` directly + | +LL - let _y = match Some(5) { +LL - Some(0) => true, +LL - _ => false, +LL - }; +LL + let _y = matches!(Some(5), Some(0)); + | -error: aborting due to 14 previous errors +error: match expression looks like `matches!` macro + --> tests/ui/match_like_matches_macro.rs:274:13 + | +LL | let _ = match opt { + | _____________^ +LL | | Some(first) if (if let Some(second) = first { true } else { todo!() }) => true, +LL | | _ => false, +LL | | }; + | |_____^ + | +help: use `matches!` directly + | +LL - let _ = match opt { +LL - Some(first) if (if let Some(second) = first { true } else { todo!() }) => true, +LL - _ => false, +LL - }; +LL + let _ = matches!(opt, Some(first) if (if let Some(second) = first { true } else { todo!() })); + | + +error: aborting due to 15 previous errors diff --git a/tests/ui/match_like_matches_macro_if_let_guard.rs b/tests/ui/match_like_matches_macro_if_let_guard.rs new file mode 100644 index 000000000000..b596d36072e5 --- /dev/null +++ b/tests/ui/match_like_matches_macro_if_let_guard.rs @@ -0,0 +1,51 @@ +//@check-pass +#![warn(clippy::match_like_matches_macro)] +#![feature(if_let_guard)] + +#[expect(clippy::option_option)] +fn issue15841(opt: Option>>, value: i32) { + let _ = match opt { + Some(first) + if let Some(second) = first + && let Some(third) = second + && third == value => + { + true + }, + _ => false, + }; + + // if-let is the second if + let _ = match opt { + Some(first) + if first.is_some() + && let Some(second) = first => + { + true + }, + _ => false, + }; + + // if-let is the third if + let _ = match opt { + Some(first) + if first.is_some() + && first.is_none() + && let Some(second) = first => + { + true + }, + _ => false, + }; + + // don't get confused by `or`s + let _ = match opt { + Some(first) + if (first.is_some() || first.is_none()) + && let Some(second) = first => + { + true + }, + _ => false, + }; +} diff --git a/tests/ui/missing_asserts_for_indexing.stderr b/tests/ui/missing_asserts_for_indexing.stderr index b686eda7530a..d5b5455343e4 100644 --- a/tests/ui/missing_asserts_for_indexing.stderr +++ b/tests/ui/missing_asserts_for_indexing.stderr @@ -1,407 +1,191 @@ error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:30:5 | -LL | assert!(v.len() < 5); - | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:30:5 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:30:12 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:30:19 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:30:26 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:30:33 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ = note: asserting the length before indexing will elide bounds checks = note: `-D clippy::missing-asserts-for-indexing` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` +help: provide the highest index that is indexed with + | +LL - assert!(v.len() < 5); +LL + assert!(v.len() > 4); + | error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:36:5 | -LL | assert!(v.len() <= 5); - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:36:5 +help: provide the highest index that is indexed with | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:36:12 +LL - assert!(v.len() <= 5); +LL + assert!(v.len() > 4); | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:36:19 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:36:26 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:36:33 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:42:5 | -LL | assert!(v.len() > 3); - | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:42:5 +help: provide the highest index that is indexed with | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:42:12 +LL - assert!(v.len() > 3); +LL + assert!(v.len() > 4); | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:42:19 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:42:26 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:42:33 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:48:5 | -LL | assert!(v.len() >= 4); - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:48:5 +help: provide the highest index that is indexed with | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:48:12 +LL - assert!(v.len() >= 4); +LL + assert!(v.len() > 4); | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:48:19 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:48:26 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:48:33 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:66:13 | -LL | assert!(v.len() >= 3); - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 3)` -LL | let _ = v[0]; - | _____________^ -... | -LL | | let _ = v[1..4]; - | |___________________^ - | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:66:13 - | LL | let _ = v[0]; | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:69:13 - | +... LL | let _ = v[1..4]; | ^^^^^^^ - = note: asserting the length before indexing will elide bounds checks + | +help: provide the highest index that is indexed with + | +LL - assert!(v.len() >= 3); +LL + assert!(v.len() > 3); + | error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:81:13 | -LL | assert!(v.len() >= 4); - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` -LL | let _ = v[0]; - | _____________^ -... | -LL | | let _ = v[1..=4]; - | |____________________^ - | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:81:13 - | LL | let _ = v[0]; | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:84:13 - | +... LL | let _ = v[1..=4]; | ^^^^^^^^ - = note: asserting the length before indexing will elide bounds checks + | +help: provide the highest index that is indexed with + | +LL - assert!(v.len() >= 4); +LL + assert!(v.len() > 4); + | error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:97:13 | -LL | assert!(v1.len() >= 12); - | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` -LL | assert!(v2.len() >= 15); LL | let _ = v1[0] + v1[12]; - | ^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:97:13 +help: provide the highest index that is indexed with | -LL | let _ = v1[0] + v1[12]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:97:21 +LL - assert!(v1.len() >= 12); +LL + assert!(v1.len() > 12); | -LL | let _ = v1[0] + v1[12]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:100:13 | -LL | assert!(v2.len() >= 15); - | ----------------------- help: provide the highest index that is indexed with: `assert!(v2.len() > 15)` -... LL | let _ = v2[5] + v2[15]; - | ^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:100:13 +help: provide the highest index that is indexed with | -LL | let _ = v2[5] + v2[15]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:100:21 +LL - assert!(v2.len() >= 15); +LL + assert!(v2.len() > 15); | -LL | let _ = v2[5] + v2[15]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:106:13 | -LL | assert!(v1.len() >= 12); - | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` -LL | assert!(v2.len() > 15); LL | let _ = v1[0] + v1[12]; - | ^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:106:13 +help: provide the highest index that is indexed with | -LL | let _ = v1[0] + v1[12]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:106:21 +LL - assert!(v1.len() >= 12); +LL + assert!(v1.len() > 12); | -LL | let _ = v1[0] + v1[12]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:131:13 | -LL | assert!(v1.len() == 2); - | ---------------------- help: provide the highest index that is indexed with: `assert!(v1.len() == 3)` -... LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^ ^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:131:13 +help: provide the highest index that is indexed with | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:131:21 +LL - assert!(v1.len() == 2); +LL + assert!(v1.len() == 3); | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:131:29 - | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:136:13 | -LL | assert!(2 == v3.len()); - | ---------------------- help: provide the highest index that is indexed with: `assert!(v3.len() == 3)` -... LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^ ^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:136:13 +help: provide the highest index that is indexed with | -LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:136:21 +LL - assert!(2 == v3.len()); +LL + assert!(v3.len() == 3); | -LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:136:29 - | -LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:158:13 | -LL | assert_eq!(v1.len(), 2); - | ----------------------- help: provide the highest index that is indexed with: `assert_eq!(v1.len(), 3)` -... LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^ ^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:158:13 +help: provide the highest index that is indexed with | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:158:21 +LL - assert_eq!(v1.len(), 2); +LL + assert_eq!(v1.len(), 3); | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:158:29 - | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:163:13 | -LL | assert_eq!(2, v3.len()); - | ----------------------- help: provide the highest index that is indexed with: `assert_eq!(v3.len(), 3)` -... LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^ ^^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:163:13 +help: provide the highest index that is indexed with | -LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:163:21 +LL - assert_eq!(2, v3.len()); +LL + assert_eq!(v3.len(), 3); | -LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:163:29 - | -LL | let _ = v3[0] + v3[1] + v3[2]; - | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:172:17 | -LL | assert_eq!(v.len(), 2); - | ---------------------- help: provide the highest index that is indexed with: `assert_eq!(v.len(), 3)` LL | let _ = v[0] + v[1] + v[2]; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:172:17 +help: provide the highest index that is indexed with | -LL | let _ = v[0] + v[1] + v[2]; - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:172:24 +LL - assert_eq!(v.len(), 2); +LL + assert_eq!(v.len(), 3); | -LL | let _ = v[0] + v[1] + v[2]; - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:172:31 - | -LL | let _ = v[0] + v[1] + v[2]; - | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:178:17 | -LL | debug_assert_eq!(v.len(), 2); - | ---------------------------- help: provide the highest index that is indexed with: `debug_assert_eq!(v.len(), 3)` LL | let _ = v[0] + v[1] + v[2]; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ | -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:178:17 +help: provide the highest index that is indexed with | -LL | let _ = v[0] + v[1] + v[2]; - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:178:24 +LL - debug_assert_eq!(v.len(), 2); +LL + debug_assert_eq!(v.len(), 3); | -LL | let _ = v[0] + v[1] + v[2]; - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:178:31 - | -LL | let _ = v[0] + v[1] + v[2]; - | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: aborting due to 15 previous errors diff --git a/tests/ui/missing_asserts_for_indexing_unfixable.stderr b/tests/ui/missing_asserts_for_indexing_unfixable.stderr index a17ad0232138..2929646494a4 100644 --- a/tests/ui/missing_asserts_for_indexing_unfixable.stderr +++ b/tests/ui/missing_asserts_for_indexing_unfixable.stderr @@ -2,34 +2,9 @@ error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ | = help: consider asserting the length before indexing: `assert!(v.len() > 4);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:12 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:19 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:26 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:33 - | -LL | v[0] + v[1] + v[2] + v[3] + v[4] - | ^^^^ = note: asserting the length before indexing will elide bounds checks = note: `-D clippy::missing-asserts-for-indexing` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` @@ -37,191 +12,82 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | -LL | let _ = v[0]; - | _____________^ -... | -LL | | let _ = v[1..4]; - | |___________________^ - | - = help: consider asserting the length before indexing: `assert!(v.len() > 3);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 - | LL | let _ = v[0]; | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:13:13 - | +... LL | let _ = v[1..4]; | ^^^^^^^ - = note: asserting the length before indexing will elide bounds checks + | + = help: consider asserting the length before indexing: `assert!(v.len() > 3);` error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:17:13 | -LL | let a = v[0]; - | _____________^ -LL | | -LL | | -LL | | let b = v[1]; -LL | | let c = v[2]; - | |________________^ - | - = help: consider asserting the length before indexing: `assert!(v.len() > 2);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:17:13 - | LL | let a = v[0]; | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:20:13 - | +... LL | let b = v[1]; | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:21:13 - | LL | let c = v[2]; | ^^^^ - = note: asserting the length before indexing will elide bounds checks + | + = help: consider asserting the length before indexing: `assert!(v.len() > 2);` error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:13 | LL | let _ = v1[0] + v1[12]; - | ^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^^ | = help: consider asserting the length before indexing: `assert!(v1.len() > 12);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:13 - | -LL | let _ = v1[0] + v1[12]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:21 - | -LL | let _ = v1[0] + v1[12]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:13 | LL | let _ = v2[5] + v2[15]; - | ^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:13 - | -LL | let _ = v2[5] + v2[15]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:21 - | -LL | let _ = v2[5] + v2[15]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:13 | LL | let _ = v2[5] + v2[15]; - | ^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:13 - | -LL | let _ = v2[5] + v2[15]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:21 - | -LL | let _ = v2[5] + v2[15]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:13 | LL | let _ = f.v[0] + f.v[1]; - | ^^^^^^^^^^^^^^^ + | ^^^^^^ ^^^^^^ | = help: consider asserting the length before indexing: `assert!(f.v.len() > 1);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:13 - | -LL | let _ = f.v[0] + f.v[1]; - | ^^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:22 - | -LL | let _ = f.v[0] + f.v[1]; - | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:13 | LL | let _ = x[0] + x[1]; - | ^^^^^^^^^^^ + | ^^^^ ^^^^ | = help: consider asserting the length before indexing: `assert!(x.len() > 1);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:13 - | -LL | let _ = x[0] + x[1]; - | ^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:20 - | -LL | let _ = x[0] + x[1]; - | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:77:13 | LL | let _ = v1[1] + v1[2]; - | ^^^^^^^^^^^^^ + | ^^^^^ ^^^^^ | = help: consider asserting the length before indexing: `assert!(v1.len() > 2);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:77:13 - | -LL | let _ = v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:77:21 - | -LL | let _ = v1[1] + v1[2]; - | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:85:13 | LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ ^^^^^ ^^^^^ | = help: consider asserting the length before indexing: `assert!(v1.len() > 2);` -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:85:13 - | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:85:21 - | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ -note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:85:29 - | -LL | let _ = v1[0] + v1[1] + v1[2]; - | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: aborting due to 10 previous errors diff --git a/tests/ui/needless_type_cast.fixed b/tests/ui/needless_type_cast.fixed new file mode 100644 index 000000000000..32c348d3ca3a --- /dev/null +++ b/tests/ui/needless_type_cast.fixed @@ -0,0 +1,182 @@ +#![warn(clippy::needless_type_cast)] +#![allow(clippy::no_effect, clippy::unnecessary_cast, unused)] + +fn takes_i32(x: i32) -> i32 { + x +} + +fn generic(x: T) -> T { + x +} + +fn main() { + let a: i32 = 10; + //~^ needless_type_cast + let _ = a as i32 + 5; + let _ = a as i32 * 2; + + let b: u16 = 20; + let _ = b; + let _ = b as u32; + + let c: u8 = 5; + let _ = c as u16; + let _ = c as u32; + + let d: i32 = 100; + let _ = d + 1; + + let e = 42u8; + let _ = e as i64; + let _ = e as i64 + 10; + + let f: usize = 1; + //~^ needless_type_cast + let _ = f as usize; +} + +fn test_function_call() { + let a: i32 = 10; + //~^ needless_type_cast + let _ = takes_i32(a as i32); + let _ = takes_i32(a as i32); +} + +fn test_generic_call() { + let a: u8 = 10; + let _ = generic(a as i32); + let _ = generic(a as i32); +} + +fn test_method_on_cast() { + let a: i32 = 10; + //~^ needless_type_cast + let _ = (a as i32).checked_add(5); + let _ = (a as i32).saturating_mul(2); +} + +fn test_iterator_sum() { + let a: i32 = 10; + //~^ needless_type_cast + let arr = [a as i32, a as i32]; + let _: i32 = arr.iter().copied().sum(); +} + +fn test_closure() { + let a: i32 = 10; + //~^ needless_type_cast + let _: i32 = [1i32, 2].iter().map(|x| x + a as i32).sum(); +} + +fn test_struct_field() { + struct S { + x: i32, + y: i32, + } + + let a: i32 = 10; + //~^ needless_type_cast + let _ = S { + x: a as i32, + y: a as i32, + }; +} + +fn test_option() { + let a: u8 = 10; + let _: Option = Some(a as i32); + let _: Option = Some(a as i32); +} + +fn test_mixed_context() { + let a: u8 = 10; + let _ = takes_i32(a as i32); + let _ = generic(a as i32); +} + +fn test_nested_block() { + if true { + let a: i32 = 10; + //~^ needless_type_cast + let _ = a as i32 + 1; + let _ = a as i32 * 2; + } +} + +fn test_match_expr() { + let a: i32 = 10; + //~^ needless_type_cast + let _ = match 1 { + 1 => a as i32, + _ => a as i32, + }; +} + +fn test_return_expr() -> i32 { + let a: i32 = 10; + //~^ needless_type_cast + a as i32 +} + +fn test_closure_always_cast() { + let a: i32 = 10; + //~^ needless_type_cast + let _ = [1, 2].iter().map(|_| a as i32).sum::(); + let _ = a as i32; +} + +fn test_closure_mixed_usage() { + let a: u8 = 10; + let _ = [1, 2].iter().map(|_| a as i32).sum::(); + let _ = a + 1; +} + +fn test_nested_generic_call() { + let a: u8 = 10; + let _ = generic(takes_i32(a as i32)); + let _ = generic(takes_i32(a as i32)); +} + +fn test_generic_initializer() { + // Should not lint: changing type would affect what generic() returns + let a: u8 = generic(10u8); + let _ = a as i32; + let _ = a as i32; +} + +fn test_unsafe_transmute() { + // Should not lint: initializer contains unsafe block + #[allow(clippy::useless_transmute)] + let x: u32 = unsafe { std::mem::transmute(0u32) }; + let _ = x as u64; +} + +fn test_if_with_generic() { + // Should not lint: one branch has generic return type + let x: u8 = if true { generic(1) } else { 2 }; + let _ = x as i32; +} + +fn test_match_with_generic() { + // Should not lint: one branch has generic return type + let x: u8 = match 1 { + 1 => generic(1), + _ => 2, + }; + let _ = x as i32; +} + +fn test_default() { + // Should not lint: Default::default() has generic return type + let x: u8 = Default::default(); + let _ = x as i32; +} + +fn test_loop_with_generic() { + // Should not lint: loop break has generic return type + #[allow(clippy::never_loop)] + let x: u8 = loop { + break generic(1); + }; + let _ = x as i32; +} diff --git a/tests/ui/needless_type_cast.rs b/tests/ui/needless_type_cast.rs new file mode 100644 index 000000000000..e28f620e035f --- /dev/null +++ b/tests/ui/needless_type_cast.rs @@ -0,0 +1,182 @@ +#![warn(clippy::needless_type_cast)] +#![allow(clippy::no_effect, clippy::unnecessary_cast, unused)] + +fn takes_i32(x: i32) -> i32 { + x +} + +fn generic(x: T) -> T { + x +} + +fn main() { + let a: u8 = 10; + //~^ needless_type_cast + let _ = a as i32 + 5; + let _ = a as i32 * 2; + + let b: u16 = 20; + let _ = b; + let _ = b as u32; + + let c: u8 = 5; + let _ = c as u16; + let _ = c as u32; + + let d: i32 = 100; + let _ = d + 1; + + let e = 42u8; + let _ = e as i64; + let _ = e as i64 + 10; + + let f: u8 = 1; + //~^ needless_type_cast + let _ = f as usize; +} + +fn test_function_call() { + let a: u8 = 10; + //~^ needless_type_cast + let _ = takes_i32(a as i32); + let _ = takes_i32(a as i32); +} + +fn test_generic_call() { + let a: u8 = 10; + let _ = generic(a as i32); + let _ = generic(a as i32); +} + +fn test_method_on_cast() { + let a: u8 = 10; + //~^ needless_type_cast + let _ = (a as i32).checked_add(5); + let _ = (a as i32).saturating_mul(2); +} + +fn test_iterator_sum() { + let a: u8 = 10; + //~^ needless_type_cast + let arr = [a as i32, a as i32]; + let _: i32 = arr.iter().copied().sum(); +} + +fn test_closure() { + let a: u8 = 10; + //~^ needless_type_cast + let _: i32 = [1i32, 2].iter().map(|x| x + a as i32).sum(); +} + +fn test_struct_field() { + struct S { + x: i32, + y: i32, + } + + let a: u8 = 10; + //~^ needless_type_cast + let _ = S { + x: a as i32, + y: a as i32, + }; +} + +fn test_option() { + let a: u8 = 10; + let _: Option = Some(a as i32); + let _: Option = Some(a as i32); +} + +fn test_mixed_context() { + let a: u8 = 10; + let _ = takes_i32(a as i32); + let _ = generic(a as i32); +} + +fn test_nested_block() { + if true { + let a: u8 = 10; + //~^ needless_type_cast + let _ = a as i32 + 1; + let _ = a as i32 * 2; + } +} + +fn test_match_expr() { + let a: u8 = 10; + //~^ needless_type_cast + let _ = match 1 { + 1 => a as i32, + _ => a as i32, + }; +} + +fn test_return_expr() -> i32 { + let a: u8 = 10; + //~^ needless_type_cast + a as i32 +} + +fn test_closure_always_cast() { + let a: u8 = 10; + //~^ needless_type_cast + let _ = [1, 2].iter().map(|_| a as i32).sum::(); + let _ = a as i32; +} + +fn test_closure_mixed_usage() { + let a: u8 = 10; + let _ = [1, 2].iter().map(|_| a as i32).sum::(); + let _ = a + 1; +} + +fn test_nested_generic_call() { + let a: u8 = 10; + let _ = generic(takes_i32(a as i32)); + let _ = generic(takes_i32(a as i32)); +} + +fn test_generic_initializer() { + // Should not lint: changing type would affect what generic() returns + let a: u8 = generic(10u8); + let _ = a as i32; + let _ = a as i32; +} + +fn test_unsafe_transmute() { + // Should not lint: initializer contains unsafe block + #[allow(clippy::useless_transmute)] + let x: u32 = unsafe { std::mem::transmute(0u32) }; + let _ = x as u64; +} + +fn test_if_with_generic() { + // Should not lint: one branch has generic return type + let x: u8 = if true { generic(1) } else { 2 }; + let _ = x as i32; +} + +fn test_match_with_generic() { + // Should not lint: one branch has generic return type + let x: u8 = match 1 { + 1 => generic(1), + _ => 2, + }; + let _ = x as i32; +} + +fn test_default() { + // Should not lint: Default::default() has generic return type + let x: u8 = Default::default(); + let _ = x as i32; +} + +fn test_loop_with_generic() { + // Should not lint: loop break has generic return type + #[allow(clippy::never_loop)] + let x: u8 = loop { + break generic(1); + }; + let _ = x as i32; +} diff --git a/tests/ui/needless_type_cast.stderr b/tests/ui/needless_type_cast.stderr new file mode 100644 index 000000000000..3ee9df1043e7 --- /dev/null +++ b/tests/ui/needless_type_cast.stderr @@ -0,0 +1,71 @@ +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:13:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + | + = note: `-D clippy::needless-type-cast` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_type_cast)]` + +error: this binding is defined as `u8` but is always cast to `usize` + --> tests/ui/needless_type_cast.rs:33:12 + | +LL | let f: u8 = 1; + | ^^ help: consider defining it as: `usize` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:39:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:52:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:59:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:66:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:77:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:99:16 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:107:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:116:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:122:12 + | +LL | let a: u8 = 10; + | ^^ help: consider defining it as: `i32` + +error: aborting due to 11 previous errors + diff --git a/tests/ui/ptr_offset_by_literal.fixed b/tests/ui/ptr_offset_by_literal.fixed new file mode 100644 index 000000000000..bd9e41def938 --- /dev/null +++ b/tests/ui/ptr_offset_by_literal.fixed @@ -0,0 +1,50 @@ +#![warn(clippy::ptr_offset_by_literal)] +#![allow(clippy::inconsistent_digit_grouping)] + +fn main() { + let arr = [b'a', b'b', b'c']; + let ptr = arr.as_ptr(); + + let var = 32; + const CONST: isize = 42; + + unsafe { + let _ = ptr; + //~^ ptr_offset_by_literal + let _ = ptr; + //~^ ptr_offset_by_literal + + let _ = ptr.add(5); + //~^ ptr_offset_by_literal + let _ = ptr.sub(5); + //~^ ptr_offset_by_literal + + let _ = ptr.offset(var); + let _ = ptr.offset(CONST); + + let _ = ptr.wrapping_add(5); + //~^ ptr_offset_by_literal + let _ = ptr.wrapping_sub(5); + //~^ ptr_offset_by_literal + + let _ = ptr.sub(5); + //~^ ptr_offset_by_literal + let _ = ptr.wrapping_sub(5); + //~^ ptr_offset_by_literal + + // isize::MAX and isize::MIN on 32-bit systems. + let _ = ptr.add(2_147_483_647); + //~^ ptr_offset_by_literal + let _ = ptr.sub(2_147_483_648); + //~^ ptr_offset_by_literal + + let _ = ptr.add(5_0); + //~^ ptr_offset_by_literal + let _ = ptr.sub(5_0); + //~^ ptr_offset_by_literal + + macro_rules! offs { { $e:expr, $offs:expr } => { $e.offset($offs) }; } + offs!(ptr, 6); + offs!(ptr, var); + } +} diff --git a/tests/ui/ptr_offset_by_literal.rs b/tests/ui/ptr_offset_by_literal.rs new file mode 100644 index 000000000000..b8e3f9b26c68 --- /dev/null +++ b/tests/ui/ptr_offset_by_literal.rs @@ -0,0 +1,50 @@ +#![warn(clippy::ptr_offset_by_literal)] +#![allow(clippy::inconsistent_digit_grouping)] + +fn main() { + let arr = [b'a', b'b', b'c']; + let ptr = arr.as_ptr(); + + let var = 32; + const CONST: isize = 42; + + unsafe { + let _ = ptr.offset(0); + //~^ ptr_offset_by_literal + let _ = ptr.offset(-0); + //~^ ptr_offset_by_literal + + let _ = ptr.offset(5); + //~^ ptr_offset_by_literal + let _ = ptr.offset(-5); + //~^ ptr_offset_by_literal + + let _ = ptr.offset(var); + let _ = ptr.offset(CONST); + + let _ = ptr.wrapping_offset(5isize); + //~^ ptr_offset_by_literal + let _ = ptr.wrapping_offset(-5isize); + //~^ ptr_offset_by_literal + + let _ = ptr.offset(-(5)); + //~^ ptr_offset_by_literal + let _ = ptr.wrapping_offset(-(5)); + //~^ ptr_offset_by_literal + + // isize::MAX and isize::MIN on 32-bit systems. + let _ = ptr.offset(2_147_483_647isize); + //~^ ptr_offset_by_literal + let _ = ptr.offset(-2_147_483_648isize); + //~^ ptr_offset_by_literal + + let _ = ptr.offset(5_0__isize); + //~^ ptr_offset_by_literal + let _ = ptr.offset(-5_0__isize); + //~^ ptr_offset_by_literal + + macro_rules! offs { { $e:expr, $offs:expr } => { $e.offset($offs) }; } + offs!(ptr, 6); + offs!(ptr, var); + } +} diff --git a/tests/ui/ptr_offset_by_literal.stderr b/tests/ui/ptr_offset_by_literal.stderr new file mode 100644 index 000000000000..f85fef87d55f --- /dev/null +++ b/tests/ui/ptr_offset_by_literal.stderr @@ -0,0 +1,141 @@ +error: use of `offset` with zero + --> tests/ui/ptr_offset_by_literal.rs:12:17 + | +LL | let _ = ptr.offset(0); + | ^^^---------- + | | + | help: remove the call to `offset` + | + = note: `-D clippy::ptr-offset-by-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_offset_by_literal)]` + +error: use of `offset` with zero + --> tests/ui/ptr_offset_by_literal.rs:14:17 + | +LL | let _ = ptr.offset(-0); + | ^^^----------- + | | + | help: remove the call to `offset` + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:17:17 + | +LL | let _ = ptr.offset(5); + | ^^^^^^^^^^^^^ + | +help: use `add` instead + | +LL - let _ = ptr.offset(5); +LL + let _ = ptr.add(5); + | + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:19:17 + | +LL | let _ = ptr.offset(-5); + | ^^^^^^^^^^^^^^ + | +help: use `sub` instead + | +LL - let _ = ptr.offset(-5); +LL + let _ = ptr.sub(5); + | + +error: use of `wrapping_offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:25:17 + | +LL | let _ = ptr.wrapping_offset(5isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `wrapping_add` instead + | +LL - let _ = ptr.wrapping_offset(5isize); +LL + let _ = ptr.wrapping_add(5); + | + +error: use of `wrapping_offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:27:17 + | +LL | let _ = ptr.wrapping_offset(-5isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `wrapping_sub` instead + | +LL - let _ = ptr.wrapping_offset(-5isize); +LL + let _ = ptr.wrapping_sub(5); + | + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:30:17 + | +LL | let _ = ptr.offset(-(5)); + | ^^^^^^^^^^^^^^^^ + | +help: use `sub` instead + | +LL - let _ = ptr.offset(-(5)); +LL + let _ = ptr.sub(5); + | + +error: use of `wrapping_offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:32:17 + | +LL | let _ = ptr.wrapping_offset(-(5)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `wrapping_sub` instead + | +LL - let _ = ptr.wrapping_offset(-(5)); +LL + let _ = ptr.wrapping_sub(5); + | + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:36:17 + | +LL | let _ = ptr.offset(2_147_483_647isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `add` instead + | +LL - let _ = ptr.offset(2_147_483_647isize); +LL + let _ = ptr.add(2_147_483_647); + | + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:38:17 + | +LL | let _ = ptr.offset(-2_147_483_648isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `sub` instead + | +LL - let _ = ptr.offset(-2_147_483_648isize); +LL + let _ = ptr.sub(2_147_483_648); + | + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:41:17 + | +LL | let _ = ptr.offset(5_0__isize); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `add` instead + | +LL - let _ = ptr.offset(5_0__isize); +LL + let _ = ptr.add(5_0); + | + +error: use of `offset` with a literal + --> tests/ui/ptr_offset_by_literal.rs:43:17 + | +LL | let _ = ptr.offset(-5_0__isize); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `sub` instead + | +LL - let _ = ptr.offset(-5_0__isize); +LL + let _ = ptr.sub(5_0); + | + +error: aborting due to 12 previous errors + diff --git a/tests/ui/transmute_ptr_to_ptr.fixed b/tests/ui/transmute_ptr_to_ptr.fixed index 476e7e35a1f6..caba277db754 100644 --- a/tests/ui/transmute_ptr_to_ptr.fixed +++ b/tests/ui/transmute_ptr_to_ptr.fixed @@ -24,6 +24,13 @@ struct GenericParam { t: T, } +#[derive(Clone, Copy)] +struct PtrNamed { + ptr: *const u32, +} +#[derive(Clone, Copy)] +struct Ptr(*const u32); + fn transmute_ptr_to_ptr() { let ptr = &1u32 as *const u32; let mut_ptr = &mut 1u32 as *mut u32; @@ -68,6 +75,18 @@ fn transmute_ptr_to_ptr() { let _: &GenericParam<&LifetimeParam<'static>> = unsafe { transmute(&GenericParam { t: &lp }) }; } +fn issue1966() { + let ptr = &1u32 as *const u32; + unsafe { + let _: *const f32 = Ptr(ptr).0.cast::(); + //~^ transmute_ptr_to_ptr + let _: *const f32 = PtrNamed { ptr }.ptr.cast::(); + //~^ transmute_ptr_to_ptr + let _: *mut u32 = Ptr(ptr).0.cast_mut(); + //~^ transmute_ptr_to_ptr + } +} + fn lifetime_to_static(v: *mut &()) -> *const &'static () { unsafe { v as *const &() } //~^ transmute_ptr_to_ptr @@ -81,11 +100,15 @@ const _: &() = { unsafe { transmute::<&'static Zst, &'static ()>(zst) } }; +#[derive(Clone, Copy)] +struct Ptr8(*const u8); #[clippy::msrv = "1.37"] fn msrv_1_37(ptr: *const u8) { unsafe { let _: *const i8 = ptr as *const i8; //~^ transmute_ptr_to_ptr + let _: *const i8 = Ptr8(ptr).0 as *const i8; + //~^ transmute_ptr_to_ptr } } diff --git a/tests/ui/transmute_ptr_to_ptr.rs b/tests/ui/transmute_ptr_to_ptr.rs index 7356668bcab5..b3c2baf29c36 100644 --- a/tests/ui/transmute_ptr_to_ptr.rs +++ b/tests/ui/transmute_ptr_to_ptr.rs @@ -24,6 +24,13 @@ struct GenericParam { t: T, } +#[derive(Clone, Copy)] +struct PtrNamed { + ptr: *const u32, +} +#[derive(Clone, Copy)] +struct Ptr(*const u32); + fn transmute_ptr_to_ptr() { let ptr = &1u32 as *const u32; let mut_ptr = &mut 1u32 as *mut u32; @@ -68,6 +75,18 @@ fn transmute_ptr_to_ptr() { let _: &GenericParam<&LifetimeParam<'static>> = unsafe { transmute(&GenericParam { t: &lp }) }; } +fn issue1966() { + let ptr = &1u32 as *const u32; + unsafe { + let _: *const f32 = transmute(Ptr(ptr)); + //~^ transmute_ptr_to_ptr + let _: *const f32 = transmute(PtrNamed { ptr }); + //~^ transmute_ptr_to_ptr + let _: *mut u32 = transmute(Ptr(ptr)); + //~^ transmute_ptr_to_ptr + } +} + fn lifetime_to_static(v: *mut &()) -> *const &'static () { unsafe { transmute(v) } //~^ transmute_ptr_to_ptr @@ -81,11 +100,15 @@ const _: &() = { unsafe { transmute::<&'static Zst, &'static ()>(zst) } }; +#[derive(Clone, Copy)] +struct Ptr8(*const u8); #[clippy::msrv = "1.37"] fn msrv_1_37(ptr: *const u8) { unsafe { let _: *const i8 = transmute(ptr); //~^ transmute_ptr_to_ptr + let _: *const i8 = transmute(Ptr8(ptr)); + //~^ transmute_ptr_to_ptr } } diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr index c8db4fe214fd..ba9e6df6c2d7 100644 --- a/tests/ui/transmute_ptr_to_ptr.stderr +++ b/tests/ui/transmute_ptr_to_ptr.stderr @@ -1,5 +1,5 @@ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:32:29 + --> tests/ui/transmute_ptr_to_ptr.rs:39:29 | LL | let _: *const f32 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + let _: *const f32 = ptr.cast::(); | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:35:27 + --> tests/ui/transmute_ptr_to_ptr.rs:42:27 | LL | let _: *mut f32 = transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^ @@ -25,37 +25,37 @@ LL + let _: *mut f32 = mut_ptr.cast::(); | error: transmute from a reference to a reference - --> tests/ui/transmute_ptr_to_ptr.rs:39:23 + --> tests/ui/transmute_ptr_to_ptr.rs:46:23 | LL | let _: &f32 = transmute(&1u32); | ^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` error: transmute from a reference to a reference - --> tests/ui/transmute_ptr_to_ptr.rs:42:23 + --> tests/ui/transmute_ptr_to_ptr.rs:49:23 | LL | let _: &f32 = transmute(&1f64); | ^^^^^^^^^^^^^^^^ help: try: `&*(&1f64 as *const f64 as *const f32)` error: transmute from a reference to a reference - --> tests/ui/transmute_ptr_to_ptr.rs:47:27 + --> tests/ui/transmute_ptr_to_ptr.rs:54:27 | LL | let _: &mut f32 = transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` error: transmute from a reference to a reference - --> tests/ui/transmute_ptr_to_ptr.rs:50:37 + --> tests/ui/transmute_ptr_to_ptr.rs:57:37 | LL | let _: &GenericParam = transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` error: transmute from a reference to a reference - --> tests/ui/transmute_ptr_to_ptr.rs:54:27 + --> tests/ui/transmute_ptr_to_ptr.rs:61:27 | LL | let u8_ref: &u8 = transmute(u64_ref); | ^^^^^^^^^^^^^^^^^^ help: try: `&*(u64_ref as *const u64 as *const u8)` error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:57:29 + --> tests/ui/transmute_ptr_to_ptr.rs:64:29 | LL | let _: *const u32 = transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL + let _: *const u32 = mut_ptr.cast_const(); | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:60:27 + --> tests/ui/transmute_ptr_to_ptr.rs:67:27 | LL | let _: *mut u32 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -79,7 +79,43 @@ LL + let _: *mut u32 = ptr.cast_mut(); | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:72:14 + --> tests/ui/transmute_ptr_to_ptr.rs:81:29 + | +LL | let _: *const f32 = transmute(Ptr(ptr)); + | ^^^^^^^^^^^^^^^^^^^ + | +help: use `pointer::cast` instead + | +LL - let _: *const f32 = transmute(Ptr(ptr)); +LL + let _: *const f32 = Ptr(ptr).0.cast::(); + | + +error: transmute from a pointer to a pointer + --> tests/ui/transmute_ptr_to_ptr.rs:83:29 + | +LL | let _: *const f32 = transmute(PtrNamed { ptr }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `pointer::cast` instead + | +LL - let _: *const f32 = transmute(PtrNamed { ptr }); +LL + let _: *const f32 = PtrNamed { ptr }.ptr.cast::(); + | + +error: transmute from a pointer to a pointer + --> tests/ui/transmute_ptr_to_ptr.rs:85:27 + | +LL | let _: *mut u32 = transmute(Ptr(ptr)); + | ^^^^^^^^^^^^^^^^^^^ + | +help: use `pointer::cast_mut` instead + | +LL - let _: *mut u32 = transmute(Ptr(ptr)); +LL + let _: *mut u32 = Ptr(ptr).0.cast_mut(); + | + +error: transmute from a pointer to a pointer + --> tests/ui/transmute_ptr_to_ptr.rs:91:14 | LL | unsafe { transmute(v) } | ^^^^^^^^^^^^ @@ -91,7 +127,7 @@ LL + unsafe { v as *const &() } | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:87:28 + --> tests/ui/transmute_ptr_to_ptr.rs:108:28 | LL | let _: *const i8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -103,7 +139,19 @@ LL + let _: *const i8 = ptr as *const i8; | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:95:28 + --> tests/ui/transmute_ptr_to_ptr.rs:110:28 + | +LL | let _: *const i8 = transmute(Ptr8(ptr)); + | ^^^^^^^^^^^^^^^^^^^^ + | +help: use an `as` cast instead + | +LL - let _: *const i8 = transmute(Ptr8(ptr)); +LL + let _: *const i8 = Ptr8(ptr).0 as *const i8; + | + +error: transmute from a pointer to a pointer + --> tests/ui/transmute_ptr_to_ptr.rs:118:28 | LL | let _: *const i8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -115,7 +163,7 @@ LL + let _: *const i8 = ptr.cast::(); | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:103:26 + --> tests/ui/transmute_ptr_to_ptr.rs:126:26 | LL | let _: *mut u8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -127,7 +175,7 @@ LL + let _: *mut u8 = ptr as *mut u8; | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:105:28 + --> tests/ui/transmute_ptr_to_ptr.rs:128:28 | LL | let _: *const u8 = transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^ @@ -139,7 +187,7 @@ LL + let _: *const u8 = mut_ptr as *const u8; | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:113:26 + --> tests/ui/transmute_ptr_to_ptr.rs:136:26 | LL | let _: *mut u8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -151,7 +199,7 @@ LL + let _: *mut u8 = ptr.cast_mut(); | error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:115:28 + --> tests/ui/transmute_ptr_to_ptr.rs:138:28 | LL | let _: *const u8 = transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^ @@ -162,5 +210,5 @@ LL - let _: *const u8 = transmute(mut_ptr); LL + let _: *const u8 = mut_ptr.cast_const(); | -error: aborting due to 16 previous errors +error: aborting due to 20 previous errors diff --git a/tests/ui/transmute_ptr_to_ref.fixed b/tests/ui/transmute_ptr_to_ref.fixed index c130575df960..8de47031a400 100644 --- a/tests/ui/transmute_ptr_to_ref.fixed +++ b/tests/ui/transmute_ptr_to_ref.fixed @@ -55,6 +55,52 @@ fn issue1231() { //~^ transmute_ptr_to_ref } +#[derive(Clone, Copy)] +struct PtrRefNamed<'a> { + ptr: *const &'a u32, +} +#[derive(Clone, Copy)] +struct PtrRef<'a>(*const &'a u32); +#[derive(Clone, Copy)] +struct PtrSliceRef<'a>(*const [&'a str]); +#[derive(Clone, Copy)] +struct PtrSlice(*const [i32]); +#[derive(Clone, Copy)] +struct Ptr(*const u32); +impl std::ops::Add for Ptr { + type Output = Self; + fn add(self, _: Self) -> Self { + self + } +} +mod ptr_mod { + #[derive(Clone, Copy)] + pub struct Ptr(*const u32); +} +fn issue1966(u: PtrSlice, v: PtrSliceRef, w: Ptr, x: PtrRefNamed, y: PtrRef, z: ptr_mod::Ptr) { + unsafe { + let _: &i32 = &*(w.0 as *const i32); + //~^ transmute_ptr_to_ref + let _: &u32 = &*w.0; + //~^ transmute_ptr_to_ref + let _: &&u32 = &*x.ptr.cast::<&u32>(); + //~^ transmute_ptr_to_ref + // The field is not accessible. The program should not generate code + // that accesses the field. + let _: &u32 = std::mem::transmute(z); + let _ = &*w.0.cast::(); + //~^ transmute_ptr_to_ref + let _: &[&str] = &*(v.0 as *const [&str]); + //~^ transmute_ptr_to_ref + let _ = &*(u.0 as *const [i32]); + //~^ transmute_ptr_to_ref + let _: &&u32 = &*y.0.cast::<&u32>(); + //~^ transmute_ptr_to_ref + let _: &u32 = &*(w + w).0; + //~^ transmute_ptr_to_ref + } +} + fn issue8924<'a, 'b, 'c>(x: *const &'a u32, y: *const &'b u32) -> &'c &'b u32 { unsafe { match 0 { @@ -89,7 +135,7 @@ fn meets_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 { } #[clippy::msrv = "1.37"] -fn under_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 { +fn under_msrv<'a, 'b, 'c>(x: *const &'a u32, y: PtrRef) -> &'c &'b u32 { unsafe { let a = 0u32; let a = &a as *const u32; @@ -97,10 +143,16 @@ fn under_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 { //~^ transmute_ptr_to_ref let _: &u32 = &*(a as *const u32); //~^ transmute_ptr_to_ref + let _ = &*(Ptr(a).0 as *const u32); + //~^ transmute_ptr_to_ref match 0 { 0 => &*(x as *const () as *const &u32), //~^ transmute_ptr_to_ref - _ => &*(x as *const () as *const &'b u32), + 1 => &*(x as *const () as *const &'b u32), + //~^ transmute_ptr_to_ref + 2 => &*(y.0 as *const () as *const &u32), + //~^ transmute_ptr_to_ref + _ => &*(y.0 as *const () as *const &'b u32), //~^ transmute_ptr_to_ref } } diff --git a/tests/ui/transmute_ptr_to_ref.rs b/tests/ui/transmute_ptr_to_ref.rs index f79d54234a2c..52fe669de935 100644 --- a/tests/ui/transmute_ptr_to_ref.rs +++ b/tests/ui/transmute_ptr_to_ref.rs @@ -55,6 +55,52 @@ fn issue1231() { //~^ transmute_ptr_to_ref } +#[derive(Clone, Copy)] +struct PtrRefNamed<'a> { + ptr: *const &'a u32, +} +#[derive(Clone, Copy)] +struct PtrRef<'a>(*const &'a u32); +#[derive(Clone, Copy)] +struct PtrSliceRef<'a>(*const [&'a str]); +#[derive(Clone, Copy)] +struct PtrSlice(*const [i32]); +#[derive(Clone, Copy)] +struct Ptr(*const u32); +impl std::ops::Add for Ptr { + type Output = Self; + fn add(self, _: Self) -> Self { + self + } +} +mod ptr_mod { + #[derive(Clone, Copy)] + pub struct Ptr(*const u32); +} +fn issue1966(u: PtrSlice, v: PtrSliceRef, w: Ptr, x: PtrRefNamed, y: PtrRef, z: ptr_mod::Ptr) { + unsafe { + let _: &i32 = std::mem::transmute(w); + //~^ transmute_ptr_to_ref + let _: &u32 = std::mem::transmute(w); + //~^ transmute_ptr_to_ref + let _: &&u32 = core::mem::transmute(x); + //~^ transmute_ptr_to_ref + // The field is not accessible. The program should not generate code + // that accesses the field. + let _: &u32 = std::mem::transmute(z); + let _ = std::mem::transmute::<_, &u32>(w); + //~^ transmute_ptr_to_ref + let _: &[&str] = core::mem::transmute(v); + //~^ transmute_ptr_to_ref + let _ = std::mem::transmute::<_, &[i32]>(u); + //~^ transmute_ptr_to_ref + let _: &&u32 = std::mem::transmute(y); + //~^ transmute_ptr_to_ref + let _: &u32 = std::mem::transmute(w + w); + //~^ transmute_ptr_to_ref + } +} + fn issue8924<'a, 'b, 'c>(x: *const &'a u32, y: *const &'b u32) -> &'c &'b u32 { unsafe { match 0 { @@ -89,7 +135,7 @@ fn meets_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 { } #[clippy::msrv = "1.37"] -fn under_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 { +fn under_msrv<'a, 'b, 'c>(x: *const &'a u32, y: PtrRef) -> &'c &'b u32 { unsafe { let a = 0u32; let a = &a as *const u32; @@ -97,10 +143,16 @@ fn under_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 { //~^ transmute_ptr_to_ref let _: &u32 = std::mem::transmute::<_, &u32>(a); //~^ transmute_ptr_to_ref + let _ = std::mem::transmute::<_, &u32>(Ptr(a)); + //~^ transmute_ptr_to_ref match 0 { 0 => std::mem::transmute(x), //~^ transmute_ptr_to_ref - _ => std::mem::transmute::<_, &&'b u32>(x), + 1 => std::mem::transmute::<_, &&'b u32>(x), + //~^ transmute_ptr_to_ref + 2 => std::mem::transmute(y), + //~^ transmute_ptr_to_ref + _ => std::mem::transmute::<_, &&'b u32>(y), //~^ transmute_ptr_to_ref } } diff --git a/tests/ui/transmute_ptr_to_ref.stderr b/tests/ui/transmute_ptr_to_ref.stderr index 3f404d295fef..c0f0ca916761 100644 --- a/tests/ui/transmute_ptr_to_ref.stderr +++ b/tests/ui/transmute_ptr_to_ref.stderr @@ -61,125 +61,191 @@ error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) LL | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` +error: transmute from a pointer type (`*const u32`) to a reference type (`&i32`) + --> tests/ui/transmute_ptr_to_ref.rs:82:23 + | +LL | let _: &i32 = std::mem::transmute(w); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(w.0 as *const i32)` + +error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:84:23 + | +LL | let _: &u32 = std::mem::transmute(w); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*w.0` + error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:61:18 + --> tests/ui/transmute_ptr_to_ref.rs:86:24 + | +LL | let _: &&u32 = core::mem::transmute(x); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.ptr.cast::<&u32>()` + +error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:91:17 + | +LL | let _ = std::mem::transmute::<_, &u32>(w); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*w.0.cast::()` + +error: transmute from a pointer type (`*const [&str]`) to a reference type (`&[&str]`) + --> tests/ui/transmute_ptr_to_ref.rs:93:26 + | +LL | let _: &[&str] = core::mem::transmute(v); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(v.0 as *const [&str])` + +error: transmute from a pointer type (`*const [i32]`) to a reference type (`&[i32]`) + --> tests/ui/transmute_ptr_to_ref.rs:95:17 + | +LL | let _ = std::mem::transmute::<_, &[i32]>(u); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u.0 as *const [i32])` + +error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:97:24 + | +LL | let _: &&u32 = std::mem::transmute(y); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.0.cast::<&u32>()` + +error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:99:23 + | +LL | let _: &u32 = std::mem::transmute(w + w); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(w + w).0` + +error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:107:18 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:63:18 + --> tests/ui/transmute_ptr_to_ref.rs:109:18 | LL | 1 => std::mem::transmute(y), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:65:18 + --> tests/ui/transmute_ptr_to_ref.rs:111:18 | LL | 2 => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:67:18 + --> tests/ui/transmute_ptr_to_ref.rs:113:18 | LL | _ => std::mem::transmute::<_, &&'b u32>(y), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&'b u32>()` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:78:23 + --> tests/ui/transmute_ptr_to_ref.rs:124:23 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:80:23 + --> tests/ui/transmute_ptr_to_ref.rs:126:23 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a.cast::()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:83:18 + --> tests/ui/transmute_ptr_to_ref.rs:129:18 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:85:18 + --> tests/ui/transmute_ptr_to_ref.rs:131:18 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:96:23 + --> tests/ui/transmute_ptr_to_ref.rs:142:23 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:98:23 + --> tests/ui/transmute_ptr_to_ref.rs:144:23 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const u32)` +error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:146:17 + | +LL | let _ = std::mem::transmute::<_, &u32>(Ptr(a)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(Ptr(a).0 as *const u32)` + error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:101:18 + --> tests/ui/transmute_ptr_to_ref.rs:149:18 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &u32)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> tests/ui/transmute_ptr_to_ref.rs:103:18 + --> tests/ui/transmute_ptr_to_ref.rs:151:18 | -LL | _ => std::mem::transmute::<_, &&'b u32>(x), +LL | 1 => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &'b u32)` +error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:153:18 + | +LL | 2 => std::mem::transmute(y), + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(y.0 as *const () as *const &u32)` + +error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) + --> tests/ui/transmute_ptr_to_ref.rs:155:18 + | +LL | _ => std::mem::transmute::<_, &&'b u32>(y), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(y.0 as *const () as *const &'b u32)` + error: transmute from a pointer type (`*const [i32]`) to a reference type (`&[u32]`) - --> tests/ui/transmute_ptr_to_ref.rs:113:17 + --> tests/ui/transmute_ptr_to_ref.rs:165:17 | LL | let _ = core::mem::transmute::<_, &[u32]>(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(ptr as *const [u32])` error: transmute from a pointer type (`*const [i32]`) to a reference type (`&[u32]`) - --> tests/ui/transmute_ptr_to_ref.rs:115:25 + --> tests/ui/transmute_ptr_to_ref.rs:167:25 | LL | let _: &[u32] = core::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(ptr as *const [u32])` error: transmute from a pointer type (`*const [&str]`) to a reference type (`&[&[u8]]`) - --> tests/ui/transmute_ptr_to_ref.rs:119:17 + --> tests/ui/transmute_ptr_to_ref.rs:171:17 | LL | let _ = core::mem::transmute::<_, &[&[u8]]>(a_s_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a_s_ptr as *const [&[u8]])` error: transmute from a pointer type (`*const [&str]`) to a reference type (`&[&[u8]]`) - --> tests/ui/transmute_ptr_to_ref.rs:121:27 + --> tests/ui/transmute_ptr_to_ref.rs:173:27 | LL | let _: &[&[u8]] = core::mem::transmute(a_s_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a_s_ptr as *const [&[u8]])` error: transmute from a pointer type (`*const [i32]`) to a reference type (`&[i32]`) - --> tests/ui/transmute_ptr_to_ref.rs:125:17 + --> tests/ui/transmute_ptr_to_ref.rs:177:17 | LL | let _ = core::mem::transmute::<_, &[i32]>(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(ptr as *const [i32])` error: transmute from a pointer type (`*const [i32]`) to a reference type (`&[i32]`) - --> tests/ui/transmute_ptr_to_ref.rs:127:25 + --> tests/ui/transmute_ptr_to_ref.rs:179:25 | LL | let _: &[i32] = core::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*ptr` error: transmute from a pointer type (`*const [&str]`) to a reference type (`&[&str]`) - --> tests/ui/transmute_ptr_to_ref.rs:131:17 + --> tests/ui/transmute_ptr_to_ref.rs:183:17 | LL | let _ = core::mem::transmute::<_, &[&str]>(a_s_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a_s_ptr as *const [&str])` error: transmute from a pointer type (`*const [&str]`) to a reference type (`&[&str]`) - --> tests/ui/transmute_ptr_to_ref.rs:133:26 + --> tests/ui/transmute_ptr_to_ref.rs:185:26 | LL | let _: &[&str] = core::mem::transmute(a_s_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a_s_ptr as *const [&str])` -error: aborting due to 30 previous errors +error: aborting due to 41 previous errors diff --git a/tests/ui/tuple_array_conversions.rs b/tests/ui/tuple_array_conversions.rs index 772c41df090e..17e6a252b266 100644 --- a/tests/ui/tuple_array_conversions.rs +++ b/tests/ui/tuple_array_conversions.rs @@ -116,3 +116,26 @@ fn msrv_juust_right() { let x = &[1, 2]; let x = (x[0], x[1]); } + +fn issue16192() { + fn do_something(tuple: (u32, u32)) {} + fn produce_array() -> [u32; 2] { + [1, 2] + } + + let [a, b] = produce_array(); + for tuple in [(a, b), (b, a)] { + do_something(tuple); + } + + let [a, b] = produce_array(); + let x = b; + do_something((a, b)); + + let [a, b] = produce_array(); + do_something((b, a)); + + let [a, b] = produce_array(); + do_something((a, b)); + //~^ tuple_array_conversions +} diff --git a/tests/ui/tuple_array_conversions.stderr b/tests/ui/tuple_array_conversions.stderr index 6dafb8d285d4..4c15769b7487 100644 --- a/tests/ui/tuple_array_conversions.stderr +++ b/tests/ui/tuple_array_conversions.stderr @@ -80,5 +80,13 @@ LL | let x = [x.0, x.1]; | = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed -error: aborting due to 10 previous errors +error: it looks like you're trying to convert an array to a tuple + --> tests/ui/tuple_array_conversions.rs:139:18 + | +LL | do_something((a, b)); + | ^^^^^^ + | + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed + +error: aborting due to 11 previous errors diff --git a/tests/ui/useless_conversion.fixed b/tests/ui/useless_conversion.fixed index 9de7d2c67149..adf5e58d9a1a 100644 --- a/tests/ui/useless_conversion.fixed +++ b/tests/ui/useless_conversion.fixed @@ -442,3 +442,14 @@ fn issue14739() { let _ = R.map(|_x| 0); //~^ useless_conversion } + +fn issue16165() { + macro_rules! mac { + (iter $e:expr) => { + $e.iter() + }; + } + + for _ in mac!(iter [1, 2]) {} + //~^ useless_conversion +} diff --git a/tests/ui/useless_conversion.rs b/tests/ui/useless_conversion.rs index 38cd1175aa48..d95fe49e2e2b 100644 --- a/tests/ui/useless_conversion.rs +++ b/tests/ui/useless_conversion.rs @@ -442,3 +442,14 @@ fn issue14739() { let _ = R.into_iter().map(|_x| 0); //~^ useless_conversion } + +fn issue16165() { + macro_rules! mac { + (iter $e:expr) => { + $e.iter() + }; + } + + for _ in mac!(iter [1, 2]).into_iter() {} + //~^ useless_conversion +} diff --git a/tests/ui/useless_conversion.stderr b/tests/ui/useless_conversion.stderr index 3bfaf1411c2c..052c664f6f2e 100644 --- a/tests/ui/useless_conversion.stderr +++ b/tests/ui/useless_conversion.stderr @@ -389,5 +389,11 @@ error: useless conversion to the same type: `std::ops::Range` LL | let _ = R.into_iter().map(|_x| 0); | ^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `R` -error: aborting due to 43 previous errors +error: useless conversion to the same type: `std::slice::Iter<'_, i32>` + --> tests/ui/useless_conversion.rs:453:14 + | +LL | for _ in mac!(iter [1, 2]).into_iter() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `mac!(iter [1, 2])` + +error: aborting due to 44 previous errors diff --git a/tests/ui/while_let_on_iterator.fixed b/tests/ui/while_let_on_iterator.fixed index f9ccefab5898..0d3b446af43f 100644 --- a/tests/ui/while_let_on_iterator.fixed +++ b/tests/ui/while_let_on_iterator.fixed @@ -492,6 +492,110 @@ fn issue13123() { } } +fn issue16089() { + trait CertainTrait: Iterator { + fn iter_over_self(&mut self) { + let mut a = 0; + for r in &mut *self { + //~^ while_let_on_iterator + a = r; + } + self.use_after_iter() + } + + fn use_after_iter(&mut self) {} + } +} + +fn issue16089_sized_trait_not_reborrowed() { + trait CertainTrait: Iterator + Sized { + fn iter_over_self(&mut self) { + let mut a = 0; + // Check that the suggestion is just "self", since the trait is sized. + for r in self.by_ref() { + //~^ while_let_on_iterator + a = r; + } + self.use_after_iter() + } + + fn use_after_iter(&mut self) {} + } +} + +fn issue16089_nested_derefs() { + struct S(T); + impl core::ops::Deref for S { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl core::ops::DerefMut for S { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + + fn f(mut x: S>>) { + for _ in &mut ***x {} + //~^ while_let_on_iterator + } +} + +fn issue16089_nested_derefs_last_not_sized() { + struct WithSize(T); + impl core::ops::Deref for WithSize { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl core::ops::DerefMut for WithSize { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + // The suggestion must use `&mut **x`. Using `x.by_ref()` doesn't work in this + // case, since the last type adjustment for `x` in the expression `x.next()` is + // to dereference a `?Sized` trait. + fn f(mut x: WithSize<&mut dyn Iterator>) { + for _ in &mut **x {} + //~^ while_let_on_iterator + } +} + +fn issue16089_nested_derefs_last_sized() { + struct NoSize(T); + impl core::ops::Deref for NoSize { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl core::ops::DerefMut for NoSize { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + + struct SizedIter {} + + impl Iterator for SizedIter { + type Item = u32; + fn next(&mut self) -> Option { + Some(0) + } + } + + // We want the suggestion to be `x.by_ref()`. It works in this case since the last type + // adjustment for `x` in the expression `x.next()` is to dereference a Sized type. + fn f(mut x: NoSize>) { + for _ in x.by_ref() {} + //~^ while_let_on_iterator + } +} + fn main() { let mut it = 0..20; for _ in it { diff --git a/tests/ui/while_let_on_iterator.rs b/tests/ui/while_let_on_iterator.rs index f957f2e5a523..e1d9e9081e45 100644 --- a/tests/ui/while_let_on_iterator.rs +++ b/tests/ui/while_let_on_iterator.rs @@ -492,6 +492,110 @@ fn issue13123() { } } +fn issue16089() { + trait CertainTrait: Iterator { + fn iter_over_self(&mut self) { + let mut a = 0; + while let Some(r) = self.next() { + //~^ while_let_on_iterator + a = r; + } + self.use_after_iter() + } + + fn use_after_iter(&mut self) {} + } +} + +fn issue16089_sized_trait_not_reborrowed() { + trait CertainTrait: Iterator + Sized { + fn iter_over_self(&mut self) { + let mut a = 0; + // Check that the suggestion is just "self", since the trait is sized. + while let Some(r) = self.next() { + //~^ while_let_on_iterator + a = r; + } + self.use_after_iter() + } + + fn use_after_iter(&mut self) {} + } +} + +fn issue16089_nested_derefs() { + struct S(T); + impl core::ops::Deref for S { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl core::ops::DerefMut for S { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + + fn f(mut x: S>>) { + while let Some(_) = x.next() {} + //~^ while_let_on_iterator + } +} + +fn issue16089_nested_derefs_last_not_sized() { + struct WithSize(T); + impl core::ops::Deref for WithSize { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl core::ops::DerefMut for WithSize { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + // The suggestion must use `&mut **x`. Using `x.by_ref()` doesn't work in this + // case, since the last type adjustment for `x` in the expression `x.next()` is + // to dereference a `?Sized` trait. + fn f(mut x: WithSize<&mut dyn Iterator>) { + while let Some(_) = x.next() {} + //~^ while_let_on_iterator + } +} + +fn issue16089_nested_derefs_last_sized() { + struct NoSize(T); + impl core::ops::Deref for NoSize { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl core::ops::DerefMut for NoSize { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + + struct SizedIter {} + + impl Iterator for SizedIter { + type Item = u32; + fn next(&mut self) -> Option { + Some(0) + } + } + + // We want the suggestion to be `x.by_ref()`. It works in this case since the last type + // adjustment for `x` in the expression `x.next()` is to dereference a Sized type. + fn f(mut x: NoSize>) { + while let Some(_) = x.next() {} + //~^ while_let_on_iterator + } +} + fn main() { let mut it = 0..20; while let Some(..) = it.next() { diff --git a/tests/ui/while_let_on_iterator.stderr b/tests/ui/while_let_on_iterator.stderr index 50f20227b90f..cd43d3c17800 100644 --- a/tests/ui/while_let_on_iterator.stderr +++ b/tests/ui/while_let_on_iterator.stderr @@ -164,10 +164,40 @@ LL | 'label: while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'label: for n in it` error: this loop could be written as a `for` loop - --> tests/ui/while_let_on_iterator.rs:497:5 + --> tests/ui/while_let_on_iterator.rs:499:13 + | +LL | while let Some(r) = self.next() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for r in &mut *self` + +error: this loop could be written as a `for` loop + --> tests/ui/while_let_on_iterator.rs:515:13 + | +LL | while let Some(r) = self.next() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for r in self.by_ref()` + +error: this loop could be written as a `for` loop + --> tests/ui/while_let_on_iterator.rs:541:9 + | +LL | while let Some(_) = x.next() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in &mut ***x` + +error: this loop could be written as a `for` loop + --> tests/ui/while_let_on_iterator.rs:563:9 + | +LL | while let Some(_) = x.next() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in &mut **x` + +error: this loop could be written as a `for` loop + --> tests/ui/while_let_on_iterator.rs:594:9 + | +LL | while let Some(_) = x.next() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in x.by_ref()` + +error: this loop could be written as a `for` loop + --> tests/ui/while_let_on_iterator.rs:601:5 | LL | while let Some(..) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in it` -error: aborting due to 28 previous errors +error: aborting due to 33 previous errors diff --git a/tests/ui/zero_offset.rs b/tests/ui/zero_offset.rs index bedb09536c53..5a9c3ac9248f 100644 --- a/tests/ui/zero_offset.rs +++ b/tests/ui/zero_offset.rs @@ -1,4 +1,4 @@ -#[allow(clippy::borrow_as_ptr)] +#[allow(clippy::borrow_as_ptr, clippy::ptr_offset_by_literal)] fn main() { unsafe { let m = &mut () as *mut (); diff --git a/tests/ui/zero_repeat_side_effects.fixed b/tests/ui/zero_repeat_side_effects.fixed index b5fca36f3f08..4bdff6fd0f6c 100644 --- a/tests/ui/zero_repeat_side_effects.fixed +++ b/tests/ui/zero_repeat_side_effects.fixed @@ -1,6 +1,11 @@ #![warn(clippy::zero_repeat_side_effects)] -#![expect(clippy::unnecessary_operation, clippy::useless_vec, clippy::needless_late_init)] -#![allow(clippy::no_effect)] // only fires _after_ the fix +#![allow( + clippy::unnecessary_operation, + clippy::useless_vec, + clippy::needless_late_init, + clippy::single_match, + clippy::no_effect // only fires _after_ the fix +)] fn f() -> i32 { println!("side effect"); @@ -119,3 +124,26 @@ fn issue_14681() { }); //~^ zero_repeat_side_effects } + +fn issue_15824() { + fn f() {} + + match 0 { + 0 => { + f(); + _ = [] as [(); 0] + }, + //~^ zero_repeat_side_effects + _ => {}, + } + + let mut a = [(); 0]; + match 0 { + 0 => { + f(); + a = [] as [(); 0] + }, + //~^ zero_repeat_side_effects + _ => {}, + } +} diff --git a/tests/ui/zero_repeat_side_effects.rs b/tests/ui/zero_repeat_side_effects.rs index ea043d21638c..a1454d724c87 100644 --- a/tests/ui/zero_repeat_side_effects.rs +++ b/tests/ui/zero_repeat_side_effects.rs @@ -1,6 +1,11 @@ #![warn(clippy::zero_repeat_side_effects)] -#![expect(clippy::unnecessary_operation, clippy::useless_vec, clippy::needless_late_init)] -#![allow(clippy::no_effect)] // only fires _after_ the fix +#![allow( + clippy::unnecessary_operation, + clippy::useless_vec, + clippy::needless_late_init, + clippy::single_match, + clippy::no_effect // only fires _after_ the fix +)] fn f() -> i32 { println!("side effect"); @@ -102,3 +107,20 @@ fn issue_14681() { foo(&[Some(Some(S::new())); 0]); //~^ zero_repeat_side_effects } + +fn issue_15824() { + fn f() {} + + match 0 { + 0 => _ = [f(); 0], + //~^ zero_repeat_side_effects + _ => {}, + } + + let mut a = [(); 0]; + match 0 { + 0 => a = [f(); 0], + //~^ zero_repeat_side_effects + _ => {}, + } +} diff --git a/tests/ui/zero_repeat_side_effects.stderr b/tests/ui/zero_repeat_side_effects.stderr index 49e850d03534..f376a1501b00 100644 --- a/tests/ui/zero_repeat_side_effects.stderr +++ b/tests/ui/zero_repeat_side_effects.stderr @@ -1,5 +1,5 @@ error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:17:5 + --> tests/ui/zero_repeat_side_effects.rs:22:5 | LL | let a = [f(); 0]; | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + let a: [i32; 0] = []; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:20:5 + --> tests/ui/zero_repeat_side_effects.rs:25:5 | LL | b = [f(); 0]; | ^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL ~ b = [] as [i32; 0]; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:25:5 + --> tests/ui/zero_repeat_side_effects.rs:30:5 | LL | let c = vec![f(); 0]; | ^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + let c: std::vec::Vec = vec![]; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:28:5 + --> tests/ui/zero_repeat_side_effects.rs:33:5 | LL | d = vec![f(); 0]; | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL ~ d = vec![] as std::vec::Vec; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:32:5 + --> tests/ui/zero_repeat_side_effects.rs:37:5 | LL | let e = [println!("side effect"); 0]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + let e: [(); 0] = []; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:36:5 + --> tests/ui/zero_repeat_side_effects.rs:41:5 | LL | let g = [{ f() }; 0]; | ^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + let g: [i32; 0] = []; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:40:10 + --> tests/ui/zero_repeat_side_effects.rs:45:10 | LL | drop(vec![f(); 0]); | ^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL ~ }); | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:44:5 + --> tests/ui/zero_repeat_side_effects.rs:49:5 | LL | vec![f(); 0]; | ^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL ~ vec![] as std::vec::Vec; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:46:5 + --> tests/ui/zero_repeat_side_effects.rs:51:5 | LL | [f(); 0]; | ^^^^^^^^ @@ -111,7 +111,7 @@ LL ~ [] as [i32; 0]; | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:100:10 + --> tests/ui/zero_repeat_side_effects.rs:105:10 | LL | foo(&[Some(f()); 0]); | ^^^^^^^^^^^^^^ @@ -125,7 +125,7 @@ LL ~ }); | error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects.rs:102:10 + --> tests/ui/zero_repeat_side_effects.rs:107:10 | LL | foo(&[Some(Some(S::new())); 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,5 +138,33 @@ LL + [] as [std::option::Option>; 0] LL ~ }); | -error: aborting due to 11 previous errors +error: expression with side effects as the initial value in a zero-sized array initializer + --> tests/ui/zero_repeat_side_effects.rs:115:14 + | +LL | 0 => _ = [f(); 0], + | ^^^^^^^^^^^^ + | +help: consider performing the side effect separately + | +LL ~ 0 => { +LL + f(); +LL + _ = [] as [(); 0] +LL ~ }, + | + +error: expression with side effects as the initial value in a zero-sized array initializer + --> tests/ui/zero_repeat_side_effects.rs:122:14 + | +LL | 0 => a = [f(); 0], + | ^^^^^^^^^^^^ + | +help: consider performing the side effect separately + | +LL ~ 0 => { +LL + f(); +LL + a = [] as [(); 0] +LL ~ }, + | + +error: aborting due to 13 previous errors diff --git a/triagebot.toml b/triagebot.toml index 3bf62b6b3bba..09dec7675e7e 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -22,9 +22,6 @@ allow-unauthenticated = [ [mentions."clippy_lints/src/doc"] cc = ["@notriddle"] -# Prevents mentions in commits to avoid users being spammed -[no-mentions] - # Have rustbot inform users about the *No Merge Policy* [no-merges] exclude_titles = ["Rustup"] # exclude syncs from rust-lang/rust @@ -65,6 +62,7 @@ users_on_vacation = [ "Manishearth", "Alexendoo", "y21", + "blyxyas", ] [assign.owners] @@ -77,7 +75,6 @@ users_on_vacation = [ "@Alexendoo", "@dswij", "@Jarcho", - "@blyxyas", "@y21", "@samueltardieu", ] diff --git a/util/gh-pages/style.css b/util/gh-pages/style.css index 242e2227ed94..ce478a3e18d0 100644 --- a/util/gh-pages/style.css +++ b/util/gh-pages/style.css @@ -637,14 +637,14 @@ pre, hr { display: flex; } -ul.dropdown-menu li.checkbox > button { +#menu-filters ul.dropdown-menu li.checkbox > button { border: 0; width: 100%; background: var(--theme-popup-bg); color: var(--fg); } -ul.dropdown-menu li.checkbox > button:hover { +#menu-filters ul.dropdown-menu li.checkbox > button:hover { background: var(--theme-hover); box-shadow: none; } From 36201bdf3e72c286d7c209f780d3c5944e5491a1 Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Tue, 9 Dec 2025 21:47:17 +0700 Subject: [PATCH 115/489] Add iterator reduction coverage to never_loop --- clippy_lints/src/loops/mod.rs | 18 ++++++- clippy_lints/src/loops/never_loop.rs | 52 ++++++++++++++++++- clippy_utils/src/sym.rs | 3 ++ tests/ui/never_loop_iterator_reduction.rs | 17 ++++++ tests/ui/never_loop_iterator_reduction.stderr | 27 ++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 tests/ui/never_loop_iterator_reduction.rs create mode 100644 tests/ui/never_loop_iterator_reduction.stderr diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 21198c3c8bc2..15993b832218 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -26,7 +26,7 @@ mod while_let_on_iterator; use clippy_config::Conf; use clippy_utils::msrvs::Msrv; -use clippy_utils::{higher, sym}; +use clippy_utils::{higher, sym, ty}; use rustc_ast::Label; use rustc_hir::{Expr, ExprKind, LoopSource, Pat}; use rustc_lint::{LateContext, LateLintPass}; @@ -889,6 +889,22 @@ impl<'tcx> LateLintPass<'tcx> for Loops { { unused_enumerate_index::check_method(cx, expr, recv, arg); } + + if let ExprKind::MethodCall(path, recv, args, _) = expr.kind + && matches!( + path.ident.name, + sym::for_each + | sym::try_for_each + | sym::fold + | sym::try_fold + | sym::reduce + | sym::all + | sym::any + ) + && ty::get_iterator_item_ty(cx, cx.typeck_results().expr_ty(recv)).is_some() + { + never_loop::check_iterator_reduction(cx, expr, recv, args); + } } } diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index 0d37be17689a..b80e10b3d3c9 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -4,13 +4,14 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::higher::ForLoop; use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::source::snippet; +use clippy_utils::sym; use clippy_utils::visitors::{Descend, for_each_expr_without_closures}; use rustc_errors::Applicability; use rustc_hir::{ Block, Destination, Expr, ExprKind, HirId, InlineAsm, InlineAsmOperand, Node, Pat, Stmt, StmtKind, StructTailExpr, }; use rustc_lint::LateContext; -use rustc_span::{BytePos, Span, sym}; +use rustc_span::{BytePos, Span}; use std::iter::once; use std::ops::ControlFlow; @@ -72,6 +73,55 @@ pub(super) fn check<'tcx>( } } +pub(super) fn check_iterator_reduction<'tcx>( + cx: &LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, + recv: &'tcx Expr<'tcx>, + args: &'tcx [Expr<'tcx>], +) { + // identify which argument is the closure based on the method kind + let Some(method_name) = (match expr.kind { + ExprKind::MethodCall(path, ..) => Some(path.ident.name), + _ => None, + }) else { + return; + }; + + let closure_arg = match method_name { + sym::for_each | sym::try_for_each | sym::reduce | sym::all | sym::any => args.get(0), + sym::fold | sym::try_fold => args.get(1), + _ => None, + }; + + let Some(closure_arg) = closure_arg else { + return; + }; + + // extract the closure body + let closure_body = match closure_arg.kind { + ExprKind::Closure(closure) => cx.tcx.hir_body(closure.body).value, + _ => return, + }; + + let body_ty = cx.typeck_results().expr_ty(closure_body); + if body_ty.is_never() { + span_lint_and_then( + cx, + NEVER_LOOP, + expr.span, + "this iterator reduction never loops (closure always diverges)", + |diag| { + let mut app = Applicability::Unspecified; + let recv_snip = make_iterator_snippet(cx, recv, &mut app); + diag.note("if you only need one element, `if let Some(x) = iter.next()` is clearer"); + let sugg = format!("if let Some(x) = {recv_snip}.next() {{ ... }}"); + diag.span_suggestion_verbose(expr.span, "consider this pattern", sugg, app); + }, + ); + return; + } +} + fn contains_any_break_or_continue(block: &Block<'_>) -> bool { for_each_expr_without_closures(block, |e| match e.kind { ExprKind::Break(..) | ExprKind::Continue(..) => ControlFlow::Break(()), diff --git a/clippy_utils/src/sym.rs b/clippy_utils/src/sym.rs index 00f4a9c7e586..7372ff6cb9aa 100644 --- a/clippy_utils/src/sym.rs +++ b/clippy_utils/src/sym.rs @@ -66,6 +66,7 @@ generate! { Regex, RegexBuilder, RegexSet, + reduce, Start, Symbol, SyntaxContext, @@ -364,7 +365,9 @@ generate! { trim_start, trim_start_matches, truncate, + try_fold, try_for_each, + try_reduce, unreachable_pub, unsafe_removed_from_name, unused, diff --git a/tests/ui/never_loop_iterator_reduction.rs b/tests/ui/never_loop_iterator_reduction.rs new file mode 100644 index 000000000000..6b07b91db29a --- /dev/null +++ b/tests/ui/never_loop_iterator_reduction.rs @@ -0,0 +1,17 @@ +//@no-rustfix +#![warn(clippy::never_loop)] + +fn main() { + // diverging closure: should trigger + [0, 1].into_iter().for_each(|x| { + //~^ never_loop + + let _ = x; + panic!("boom"); + }); + + // benign closure: should NOT trigger + [0, 1].into_iter().for_each(|x| { + let _ = x + 1; + }); +} diff --git a/tests/ui/never_loop_iterator_reduction.stderr b/tests/ui/never_loop_iterator_reduction.stderr new file mode 100644 index 000000000000..b76ee283146c --- /dev/null +++ b/tests/ui/never_loop_iterator_reduction.stderr @@ -0,0 +1,27 @@ +error: this iterator reduction never loops (closure always diverges) + --> tests/ui/never_loop_iterator_reduction.rs:6:5 + | +LL | / [0, 1].into_iter().for_each(|x| { +LL | | +LL | | +LL | | let _ = x; +LL | | panic!("boom"); +LL | | }); + | |______^ + | + = note: if you only need one element, `if let Some(x) = iter.next()` is clearer + = note: `-D clippy::never-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::never_loop)]` +help: consider this pattern + | +LL - [0, 1].into_iter().for_each(|x| { +LL - +LL - +LL - let _ = x; +LL - panic!("boom"); +LL - }); +LL + if let Some(x) = [0, 1].into_iter().next() { ... }; + | + +error: aborting due to 1 previous error + From 89a848c4399db85036e0b22f06f6f137801a79fe Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Fri, 12 Dec 2025 10:24:49 +0700 Subject: [PATCH 116/489] Fix fmt and dogfood lints for never_loop iterator reduction --- clippy_lints/src/loops/mod.rs | 8 +------- clippy_lints/src/loops/never_loop.rs | 3 +-- clippy_utils/src/sym.rs | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 15993b832218..1070f568eddd 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -893,13 +893,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops { if let ExprKind::MethodCall(path, recv, args, _) = expr.kind && matches!( path.ident.name, - sym::for_each - | sym::try_for_each - | sym::fold - | sym::try_fold - | sym::reduce - | sym::all - | sym::any + sym::for_each | sym::try_for_each | sym::fold | sym::try_fold | sym::reduce | sym::all | sym::any ) && ty::get_iterator_item_ty(cx, cx.typeck_results().expr_ty(recv)).is_some() { diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index b80e10b3d3c9..b57d800ff37c 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -88,7 +88,7 @@ pub(super) fn check_iterator_reduction<'tcx>( }; let closure_arg = match method_name { - sym::for_each | sym::try_for_each | sym::reduce | sym::all | sym::any => args.get(0), + sym::for_each | sym::try_for_each | sym::reduce | sym::all | sym::any => args.first(), sym::fold | sym::try_fold => args.get(1), _ => None, }; @@ -118,7 +118,6 @@ pub(super) fn check_iterator_reduction<'tcx>( diag.span_suggestion_verbose(expr.span, "consider this pattern", sugg, app); }, ); - return; } } diff --git a/clippy_utils/src/sym.rs b/clippy_utils/src/sym.rs index 7372ff6cb9aa..b66ef36c483e 100644 --- a/clippy_utils/src/sym.rs +++ b/clippy_utils/src/sym.rs @@ -66,7 +66,6 @@ generate! { Regex, RegexBuilder, RegexSet, - reduce, Start, Symbol, SyntaxContext, @@ -276,6 +275,7 @@ generate! { read_to_string, read_unaligned, read_volatile, + reduce, redundant_imports, redundant_pub_crate, regex, From fefd58b32b1bdc0bfb02cfa6c0c87e0c6a53d554 Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Fri, 12 Dec 2025 10:37:34 +0700 Subject: [PATCH 117/489] Clean up unused try_reduce entry in sym --- clippy_utils/src/sym.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/clippy_utils/src/sym.rs b/clippy_utils/src/sym.rs index b66ef36c483e..9e7f6e4ee308 100644 --- a/clippy_utils/src/sym.rs +++ b/clippy_utils/src/sym.rs @@ -367,7 +367,6 @@ generate! { truncate, try_fold, try_for_each, - try_reduce, unreachable_pub, unsafe_removed_from_name, unused, From b30c7c2554e995f0803d11ccfc163a57f1b0c079 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 5 Dec 2025 21:46:29 +0100 Subject: [PATCH 118/489] Adapt Clippy to the overhaul filename handling --- clippy_lints/src/module_style.rs | 2 +- clippy_utils/src/source.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/module_style.rs b/clippy_lints/src/module_style.rs index 9096d6f1c7b3..befd50a5c85f 100644 --- a/clippy_lints/src/module_style.rs +++ b/clippy_lints/src/module_style.rs @@ -81,7 +81,7 @@ pub struct ModStyle { impl EarlyLintPass for ModStyle { fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) { - self.working_dir = cx.sess().opts.working_dir.local_path().map(Path::to_path_buf); + self.working_dir = cx.sess().source_map().working_dir().local_path().map(Path::to_path_buf); } fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { diff --git a/clippy_utils/src/source.rs b/clippy_utils/src/source.rs index e29d45551d1b..b48d17863aa3 100644 --- a/clippy_utils/src/source.rs +++ b/clippy_utils/src/source.rs @@ -13,7 +13,7 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::source_map::{SourceMap, original_sp}; use rustc_span::{ - BytePos, DUMMY_SP, DesugaringKind, FileNameDisplayPreference, Pos, RelativeBytePos, SourceFile, SourceFileAndLine, + BytePos, DUMMY_SP, DesugaringKind, Pos, RelativeBytePos, SourceFile, SourceFileAndLine, Span, SpanData, SyntaxContext, hygiene, }; use std::borrow::Cow; @@ -268,7 +268,7 @@ fn map_range( debug_assert!( range.start <= text.len() && range.end <= text.len(), "Range `{range:?}` is outside the source file (file `{}`, length `{}`)", - src.sf.name.display(FileNameDisplayPreference::Local), + src.sf.name.prefer_local_unconditionally(), text.len(), ); debug_assert!(range.start <= range.end, "Range `{range:?}` has overlapping bounds"); From a95aaca24965ff3661fd11a8b45883ea990a29a0 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 6 Dec 2025 11:54:06 +0100 Subject: [PATCH 119/489] Adapt and fix `cg_gcc` to the overhauled filename remapping --- src/debuginfo.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 3979f62987f2..53d3670c1524 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -297,29 +297,11 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> { let pos = span.lo(); let DebugLoc { file, line, col } = self.lookup_debug_loc(pos); match file.name { - rustc_span::FileName::Real(ref name) => match *name { - rustc_span::RealFileName::LocalPath(ref name) => { - if let Some(name) = name.to_str() { - self.context.new_location(name, line as i32, col as i32) - } else { - Location::null() - } - } - rustc_span::RealFileName::Remapped { - ref local_path, - virtual_name: ref _unused, - } => { - if let Some(name) = local_path.as_ref() { - if let Some(name) = name.to_str() { - self.context.new_location(name, line as i32, col as i32) - } else { - Location::null() - } - } else { - Location::null() - } - } - }, + rustc_span::FileName::Real(ref name) => self.context.new_location( + name.path(rustc_span::RemapPathScopeComponents::DEBUGINFO).to_string_lossy(), + line as i32, + col as i32, + ), _ => Location::null(), } } From d55b61a684a8dd525883091f7ddbeb433e6cc30b Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 6 Dec 2025 11:31:46 +0100 Subject: [PATCH 120/489] Adapt `cg_cranelift` to the overhauled filename handling --- src/debuginfo/line_info.rs | 7 +++++-- src/debuginfo/mod.rs | 22 ++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index db58ee890911..12b0d5ec4963 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -6,7 +6,10 @@ use std::path::{Component, Path}; use cranelift_codegen::MachSrcLoc; use cranelift_codegen::binemit::CodeOffset; use gimli::write::{FileId, FileInfo, LineProgram, LineString, LineStringTable}; -use rustc_span::{FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHashAlgorithm, hygiene}; +use rustc_span::{ + FileName, Pos, RemapPathScopeComponents, SourceFile, SourceFileAndLine, + SourceFileHashAlgorithm, hygiene, +}; use crate::debuginfo::FunctionDebugContext; use crate::debuginfo::emit::address_for_func; @@ -95,7 +98,7 @@ impl DebugContext { match &source_file.name { FileName::Real(path) => { let (dir_path, file_name) = - split_path_dir_and_file(path.to_path(self.filename_display_preference)); + split_path_dir_and_file(path.path(RemapPathScopeComponents::DEBUGINFO)); let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str()); let file_name = osstr_as_utf8_bytes(file_name); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 8c43db92fe05..0cd510037293 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -21,7 +21,7 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::DefIdMap; use rustc_session::Session; use rustc_session::config::DebugInfo; -use rustc_span::{FileNameDisplayPreference, SourceFileHash, StableSourceFileId}; +use rustc_span::{RemapPathScopeComponents, SourceFileHash, StableSourceFileId}; use rustc_target::callconv::FnAbi; pub(crate) use self::emit::{DebugReloc, DebugRelocName}; @@ -44,7 +44,6 @@ pub(crate) struct DebugContext { namespace_map: DefIdMap, array_size_type: Option, - filename_display_preference: FileNameDisplayPreference, embed_source: bool, } @@ -102,18 +101,18 @@ impl DebugContext { let mut dwarf = DwarfUnit::new(encoding); - use rustc_session::config::RemapPathScopeComponents; - - let filename_display_preference = - tcx.sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO); - let producer = producer(tcx.sess); - let comp_dir = - tcx.sess.opts.working_dir.to_string_lossy(filename_display_preference).to_string(); + let comp_dir = tcx + .sess + .source_map() + .working_dir() + .path(RemapPathScopeComponents::DEBUGINFO) + .to_string_lossy(); let (name, file_info) = match tcx.sess.local_crate_source_file() { Some(path) => { - let name = path.to_string_lossy(filename_display_preference).to_string(); + let name = + path.path(RemapPathScopeComponents::DEBUGINFO).to_string_lossy().into_owned(); (name, None) } None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), @@ -137,7 +136,7 @@ impl DebugContext { { let name = dwarf.strings.add(format!("{name}/@/{cgu_name}")); - let comp_dir = dwarf.strings.add(comp_dir); + let comp_dir = dwarf.strings.add(&*comp_dir); let root = dwarf.unit.root(); let root = dwarf.unit.get_mut(root); @@ -180,7 +179,6 @@ impl DebugContext { stack_pointer_register, namespace_map: DefIdMap::default(), array_size_type, - filename_display_preference, embed_source, }) } From 8b69673c41207f2d4eeba0d20762ad9f6ae711ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Mon, 28 Jul 2025 10:40:21 +0200 Subject: [PATCH 121/489] EII ast changes --- clippy_utils/src/ast_utils/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clippy_utils/src/ast_utils/mod.rs b/clippy_utils/src/ast_utils/mod.rs index 08663782a1d5..432d7a251a21 100644 --- a/clippy_utils/src/ast_utils/mod.rs +++ b/clippy_utils/src/ast_utils/mod.rs @@ -382,6 +382,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { contract: lc, body: lb, define_opaque: _, + eii_impls: _, }), Fn(box ast::Fn { defaultness: rd, @@ -391,6 +392,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { contract: rc, body: rb, define_opaque: _, + eii_impls: _, }), ) => { eq_defaultness(*ld, *rd) @@ -554,6 +556,7 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { contract: lc, body: lb, define_opaque: _, + eii_impls: _, }), Fn(box ast::Fn { defaultness: rd, @@ -563,6 +566,7 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { contract: rc, body: rb, define_opaque: _, + eii_impls: _, }), ) => { eq_defaultness(*ld, *rd) @@ -638,6 +642,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { contract: lc, body: lb, define_opaque: _, + eii_impls: _, }), Fn(box ast::Fn { defaultness: rd, @@ -647,6 +652,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { contract: rc, body: rb, define_opaque: _, + eii_impls: _, }), ) => { eq_defaultness(*ld, *rd) From ae85cebffdbeef3068d633d8d03ac3936273b94a Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Fri, 12 Dec 2025 18:55:49 +0800 Subject: [PATCH 122/489] Fix not applicable fn in closure for add_return_type Example --- ```rust const _: fn() = || { fn foo() $0{ 45 } } ``` **Before this PR** Assist not applicable **After this PR** ```rust const _: fn() = || { fn foo() -> i32 { 45 } } ``` --- .../src/handlers/add_return_type.rs | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_return_type.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_return_type.rs index c9022f66d1e2..7934a80bfabb 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_return_type.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_return_type.rs @@ -1,3 +1,4 @@ +use either::Either; use hir::HirDisplay; use syntax::{AstNode, SyntaxKind, SyntaxToken, TextRange, TextSize, ast, match_ast}; @@ -133,8 +134,9 @@ fn peel_blocks(mut expr: ast::Expr) -> ast::Expr { } fn extract_tail(ctx: &AssistContext<'_>) -> Option<(FnType, ast::Expr, InsertOrReplace)> { - let (fn_type, tail_expr, return_type_range, action) = - if let Some(closure) = ctx.find_node_at_offset::() { + let node = ctx.find_node_at_offset::>()?; + let (fn_type, tail_expr, return_type_range, action) = match node { + Either::Left(closure) => { let rpipe = closure.param_list()?.syntax().last_token()?; let rpipe_pos = rpipe.text_range().end(); @@ -149,9 +151,8 @@ fn extract_tail(ctx: &AssistContext<'_>) -> Option<(FnType, ast::Expr, InsertOrR let ret_range = TextRange::new(rpipe_pos, body_start); (FnType::Closure { wrap_expr }, tail_expr, ret_range, action) - } else { - let func = ctx.find_node_at_offset::()?; - + } + Either::Right(func) => { let rparen = func.param_list()?.r_paren_token()?; let rparen_pos = rparen.text_range().end(); let action = ret_ty_to_action(func.ret_type(), rparen)?; @@ -163,7 +164,8 @@ fn extract_tail(ctx: &AssistContext<'_>) -> Option<(FnType, ast::Expr, InsertOrR let ret_range_end = stmt_list.l_curly_token()?.text_range().start(); let ret_range = TextRange::new(rparen_pos, ret_range_end); (FnType::Function, tail_expr, ret_range, action) - }; + } + }; let range = ctx.selection_trimmed(); if return_type_range.contains_range(range) { cov_mark::hit!(cursor_in_ret_position); @@ -239,6 +241,24 @@ mod tests { ); } + #[test] + fn infer_return_type_cursor_at_return_type_pos_fn_inside_closure() { + cov_mark::check!(cursor_in_ret_position); + check_assist( + add_return_type, + r#"const _: fn() = || { + fn foo() $0{ + 45 + } +};"#, + r#"const _: fn() = || { + fn foo() -> i32 { + 45 + } +};"#, + ); + } + #[test] fn infer_return_type() { cov_mark::check!(cursor_on_tail); From 8f9a93d0fd9bcfc4a3e1f0837a7a3d8e6d4230f6 Mon Sep 17 00:00:00 2001 From: Coca Date: Fri, 12 Dec 2025 14:26:28 +0000 Subject: [PATCH 123/489] `transmuting_null`: Check const integer casts changelog: [`transmuting_null`]: now checks const integers being casted to pointers --- clippy_lints/src/transmute/transmuting_null.rs | 9 ++------- tests/ui/transmuting_null.rs | 8 ++++++++ tests/ui/transmuting_null.stderr | 8 +++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/transmute/transmuting_null.rs b/clippy_lints/src/transmute/transmuting_null.rs index 1a6262f2ff76..31e770f421e1 100644 --- a/clippy_lints/src/transmute/transmuting_null.rs +++ b/clippy_lints/src/transmute/transmuting_null.rs @@ -1,6 +1,6 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint; -use clippy_utils::is_integer_literal; +use clippy_utils::is_integer_const; use clippy_utils::res::{MaybeDef, MaybeResPath}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; @@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'t // Catching: // `std::mem::transmute(0 as *const i32)` if let ExprKind::Cast(inner_expr, _cast_ty) = arg.kind - && is_integer_literal(inner_expr, 0) + && is_integer_const(cx, inner_expr, 0) { span_lint(cx, TRANSMUTING_NULL, expr.span, LINT_MSG); return true; @@ -42,10 +42,5 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'t return true; } - // FIXME: - // Also catch transmutations of variables which are known nulls. - // To do this, MIR const propagation seems to be the better tool. - // Whenever MIR const prop routines are more developed, this will - // become available. As of this writing (25/03/19) it is not yet. false } diff --git a/tests/ui/transmuting_null.rs b/tests/ui/transmuting_null.rs index f3eb5060cd0d..0d3b26673452 100644 --- a/tests/ui/transmuting_null.rs +++ b/tests/ui/transmuting_null.rs @@ -30,7 +30,15 @@ fn transmute_const() { } } +fn transmute_const_int() { + unsafe { + let _: &u64 = std::mem::transmute(u64::MIN as *const u64); + //~^ transmuting_null + } +} + fn main() { one_liners(); transmute_const(); + transmute_const_int(); } diff --git a/tests/ui/transmuting_null.stderr b/tests/ui/transmuting_null.stderr index c68e4102e405..ed7c3396a243 100644 --- a/tests/ui/transmuting_null.stderr +++ b/tests/ui/transmuting_null.stderr @@ -19,5 +19,11 @@ error: transmuting a known null pointer into a reference LL | let _: &u64 = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: transmuting a known null pointer into a reference + --> tests/ui/transmuting_null.rs:35:23 + | +LL | let _: &u64 = std::mem::transmute(u64::MIN as *const u64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors From eb8da2f3bab8ca472b180ee060e9787da3fb1ec3 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sat, 13 Dec 2025 00:32:10 +0900 Subject: [PATCH 124/489] move tests --- .../anon-params-trait-method-multiple.rs} | 0 .../autoderef-arc-boxed-closure-call.rs} | 0 .../issue-27268.rs => consts/const-closure-fn-trait-object.rs} | 0 .../issue-24161.rs => extern/extern-fn-pointer-clone-copy.rs} | 0 tests/ui/{issues/issue-23036.rs => hashmap/hashmap-path-key.rs} | 0 .../issue-20454.rs => inference/inference-thread-loop-closure.rs} | 0 .../disjoint-ref-mut-method.rs} | 0 .../issue-29540.rs => limits/limit-huge-struct-derive-debug.rs} | 0 .../unused/unused-attr-repr-packed-c-order.rs} | 0 .../issue-37686.rs => match/match-usize-min-max-pattern.rs} | 0 .../i128-min-literal-parses.rs} | 0 .../const-pattern-str-match-lifetime.rs} | 0 .../static-array-shared-slice-references.rs} | 0 .../raw-string-literal-unescaped-unicode.rs} | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-34074.rs => anon-params/anon-params-trait-method-multiple.rs} (100%) rename tests/ui/{issues/issue-21306.rs => autoref-autoderef/autoderef-arc-boxed-closure-call.rs} (100%) rename tests/ui/{issues/issue-27268.rs => consts/const-closure-fn-trait-object.rs} (100%) rename tests/ui/{issues/issue-24161.rs => extern/extern-fn-pointer-clone-copy.rs} (100%) rename tests/ui/{issues/issue-23036.rs => hashmap/hashmap-path-key.rs} (100%) rename tests/ui/{issues/issue-20454.rs => inference/inference-thread-loop-closure.rs} (100%) rename tests/ui/{issues/issue-19097.rs => inherent-impls-overlap-check/disjoint-ref-mut-method.rs} (100%) rename tests/ui/{issues/issue-29540.rs => limits/limit-huge-struct-derive-debug.rs} (100%) rename tests/ui/{issues/issue-26646.rs => lint/unused/unused-attr-repr-packed-c-order.rs} (100%) rename tests/ui/{issues/issue-37686.rs => match/match-usize-min-max-pattern.rs} (100%) rename tests/ui/{issues/issue-38987.rs => numbers-arithmetic/i128-min-literal-parses.rs} (100%) rename tests/ui/{issues/issue-18352.rs => pattern/const-pattern-str-match-lifetime.rs} (100%) rename tests/ui/{issues/issue-21891.rs => static/static-array-shared-slice-references.rs} (100%) rename tests/ui/{issues/issue-50471.rs => str/raw-string-literal-unescaped-unicode.rs} (100%) diff --git a/tests/ui/issues/issue-34074.rs b/tests/ui/anon-params/anon-params-trait-method-multiple.rs similarity index 100% rename from tests/ui/issues/issue-34074.rs rename to tests/ui/anon-params/anon-params-trait-method-multiple.rs diff --git a/tests/ui/issues/issue-21306.rs b/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs similarity index 100% rename from tests/ui/issues/issue-21306.rs rename to tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs diff --git a/tests/ui/issues/issue-27268.rs b/tests/ui/consts/const-closure-fn-trait-object.rs similarity index 100% rename from tests/ui/issues/issue-27268.rs rename to tests/ui/consts/const-closure-fn-trait-object.rs diff --git a/tests/ui/issues/issue-24161.rs b/tests/ui/extern/extern-fn-pointer-clone-copy.rs similarity index 100% rename from tests/ui/issues/issue-24161.rs rename to tests/ui/extern/extern-fn-pointer-clone-copy.rs diff --git a/tests/ui/issues/issue-23036.rs b/tests/ui/hashmap/hashmap-path-key.rs similarity index 100% rename from tests/ui/issues/issue-23036.rs rename to tests/ui/hashmap/hashmap-path-key.rs diff --git a/tests/ui/issues/issue-20454.rs b/tests/ui/inference/inference-thread-loop-closure.rs similarity index 100% rename from tests/ui/issues/issue-20454.rs rename to tests/ui/inference/inference-thread-loop-closure.rs diff --git a/tests/ui/issues/issue-19097.rs b/tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs similarity index 100% rename from tests/ui/issues/issue-19097.rs rename to tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs diff --git a/tests/ui/issues/issue-29540.rs b/tests/ui/limits/limit-huge-struct-derive-debug.rs similarity index 100% rename from tests/ui/issues/issue-29540.rs rename to tests/ui/limits/limit-huge-struct-derive-debug.rs diff --git a/tests/ui/issues/issue-26646.rs b/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs similarity index 100% rename from tests/ui/issues/issue-26646.rs rename to tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs diff --git a/tests/ui/issues/issue-37686.rs b/tests/ui/match/match-usize-min-max-pattern.rs similarity index 100% rename from tests/ui/issues/issue-37686.rs rename to tests/ui/match/match-usize-min-max-pattern.rs diff --git a/tests/ui/issues/issue-38987.rs b/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs similarity index 100% rename from tests/ui/issues/issue-38987.rs rename to tests/ui/numbers-arithmetic/i128-min-literal-parses.rs diff --git a/tests/ui/issues/issue-18352.rs b/tests/ui/pattern/const-pattern-str-match-lifetime.rs similarity index 100% rename from tests/ui/issues/issue-18352.rs rename to tests/ui/pattern/const-pattern-str-match-lifetime.rs diff --git a/tests/ui/issues/issue-21891.rs b/tests/ui/static/static-array-shared-slice-references.rs similarity index 100% rename from tests/ui/issues/issue-21891.rs rename to tests/ui/static/static-array-shared-slice-references.rs diff --git a/tests/ui/issues/issue-50471.rs b/tests/ui/str/raw-string-literal-unescaped-unicode.rs similarity index 100% rename from tests/ui/issues/issue-50471.rs rename to tests/ui/str/raw-string-literal-unescaped-unicode.rs From 1f406db0767bffaad1def6ec5fdfb2f4ab874103 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sat, 13 Dec 2025 00:45:22 +0900 Subject: [PATCH 125/489] cleaned up some tests --- .../ui/anon-params/anon-params-trait-method-multiple.rs | 4 ++-- .../autoderef-arc-boxed-closure-call.rs | 3 ++- tests/ui/consts/const-closure-fn-trait-object.rs | 3 ++- tests/ui/extern/extern-fn-pointer-clone-copy.rs | 5 +++-- tests/ui/hashmap/hashmap-path-key.rs | 1 + tests/ui/inference/inference-thread-loop-closure.rs | 7 +++++-- .../disjoint-ref-mut-method.rs | 2 +- tests/ui/limits/limit-huge-struct-derive-debug.rs | 1 + tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs | 3 ++- tests/ui/match/match-usize-min-max-pattern.rs | 1 + tests/ui/numbers-arithmetic/i128-min-literal-parses.rs | 1 + tests/ui/pattern/const-pattern-str-match-lifetime.rs | 3 ++- tests/ui/static/static-array-shared-slice-references.rs | 9 ++++----- tests/ui/str/raw-string-literal-unescaped-unicode.rs | 3 ++- 14 files changed, 29 insertions(+), 17 deletions(-) diff --git a/tests/ui/anon-params/anon-params-trait-method-multiple.rs b/tests/ui/anon-params/anon-params-trait-method-multiple.rs index d642c74d412a..ba06aa5115ba 100644 --- a/tests/ui/anon-params/anon-params-trait-method-multiple.rs +++ b/tests/ui/anon-params/anon-params-trait-method-multiple.rs @@ -1,3 +1,4 @@ +//! regression test for //@ edition: 2015 //@ check-pass // Make sure several unnamed function parameters don't conflict with each other @@ -7,5 +8,4 @@ trait Tr { fn f(u8, u8) {} } -fn main() { -} +fn main() {} diff --git a/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs b/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs index bf42e70a5bc0..fb7a8ee103e1 100644 --- a/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs +++ b/tests/ui/autoref-autoderef/autoderef-arc-boxed-closure-call.rs @@ -1,9 +1,10 @@ +//! regression test for //@ run-pass use std::sync::Arc; fn main() { let x = 5; - let command = Arc::new(Box::new(|| { x*2 })); + let command = Arc::new(Box::new(|| x * 2)); assert_eq!(command(), 10); } diff --git a/tests/ui/consts/const-closure-fn-trait-object.rs b/tests/ui/consts/const-closure-fn-trait-object.rs index e8704d215e88..e47a118dd3f4 100644 --- a/tests/ui/consts/const-closure-fn-trait-object.rs +++ b/tests/ui/consts/const-closure-fn-trait-object.rs @@ -1,4 +1,5 @@ +//! regression test for //@ run-pass fn main() { - const _C: &'static dyn Fn() = &||{}; + const _C: &'static dyn Fn() = &|| {}; } diff --git a/tests/ui/extern/extern-fn-pointer-clone-copy.rs b/tests/ui/extern/extern-fn-pointer-clone-copy.rs index 974add438616..a67e0d1d703a 100644 --- a/tests/ui/extern/extern-fn-pointer-clone-copy.rs +++ b/tests/ui/extern/extern-fn-pointer-clone-copy.rs @@ -1,11 +1,12 @@ +//! regression test for //@ check-pass #![allow(dead_code)] -#[derive(Copy,Clone)] +#[derive(Copy, Clone)] struct Functions { a: fn(u32) -> u32, b: extern "C" fn(u32) -> u32, c: unsafe fn(u32) -> u32, - d: unsafe extern "C" fn(u32) -> u32 + d: unsafe extern "C" fn(u32) -> u32, } pub fn main() {} diff --git a/tests/ui/hashmap/hashmap-path-key.rs b/tests/ui/hashmap/hashmap-path-key.rs index 5186fccd042b..0551ba7ea8ee 100644 --- a/tests/ui/hashmap/hashmap-path-key.rs +++ b/tests/ui/hashmap/hashmap-path-key.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass use std::collections::HashMap; diff --git a/tests/ui/inference/inference-thread-loop-closure.rs b/tests/ui/inference/inference-thread-loop-closure.rs index e56f2ffa371a..78b1b145367e 100644 --- a/tests/ui/inference/inference-thread-loop-closure.rs +++ b/tests/ui/inference/inference-thread-loop-closure.rs @@ -1,13 +1,16 @@ +//! regression test for //@ check-pass #![allow(unused_must_use)] use std::thread; fn _foo() { - thread::spawn(move || { // no need for -> () + thread::spawn(move || { + // no need for -> () loop { println!("hello"); } - }).join(); + }) + .join(); } fn main() {} diff --git a/tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs b/tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs index a329ba6f073e..d4594b2e2c95 100644 --- a/tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs +++ b/tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs @@ -1,6 +1,6 @@ +//! regression test for //@ check-pass #![allow(dead_code)] -// regression test for #19097 struct Foo(T); diff --git a/tests/ui/limits/limit-huge-struct-derive-debug.rs b/tests/ui/limits/limit-huge-struct-derive-debug.rs index 6bfeae8559dc..eb793aadd8c6 100644 --- a/tests/ui/limits/limit-huge-struct-derive-debug.rs +++ b/tests/ui/limits/limit-huge-struct-derive-debug.rs @@ -1,3 +1,4 @@ +//! regression test for //@ build-pass #[derive(Debug)] pub struct Config { diff --git a/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs b/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs index b1789b1a91fc..a9da3e4175bd 100644 --- a/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs +++ b/tests/ui/lint/unused/unused-attr-repr-packed-c-order.rs @@ -1,3 +1,4 @@ +//! regression test for //@ check-pass #![deny(unused_attributes)] @@ -9,4 +10,4 @@ pub struct Foo; #[repr(C)] pub struct Bar; -fn main() { } +fn main() {} diff --git a/tests/ui/match/match-usize-min-max-pattern.rs b/tests/ui/match/match-usize-min-max-pattern.rs index 5a72f2fc74c2..6a801406895d 100644 --- a/tests/ui/match/match-usize-min-max-pattern.rs +++ b/tests/ui/match/match-usize-min-max-pattern.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass fn main() { match (0, 0) { diff --git a/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs b/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs index 713fd5027918..623a8a92ae62 100644 --- a/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs +++ b/tests/ui/numbers-arithmetic/i128-min-literal-parses.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass fn main() { let _ = -0x8000_0000_0000_0000_0000_0000_0000_0000i128; diff --git a/tests/ui/pattern/const-pattern-str-match-lifetime.rs b/tests/ui/pattern/const-pattern-str-match-lifetime.rs index 8b6aa82ea8c0..8814d55c63b6 100644 --- a/tests/ui/pattern/const-pattern-str-match-lifetime.rs +++ b/tests/ui/pattern/const-pattern-str-match-lifetime.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass const X: &'static str = "12345"; @@ -5,7 +6,7 @@ const X: &'static str = "12345"; fn test(s: String) -> bool { match &*s { X => true, - _ => false + _ => false, } } diff --git a/tests/ui/static/static-array-shared-slice-references.rs b/tests/ui/static/static-array-shared-slice-references.rs index 0da6071cdac4..a2ef169e2a29 100644 --- a/tests/ui/static/static-array-shared-slice-references.rs +++ b/tests/ui/static/static-array-shared-slice-references.rs @@ -1,11 +1,10 @@ +//! regression test for //@ build-pass #![allow(dead_code)] -#![allow(non_upper_case_globals)] +static FOO: [usize; 3] = [1, 2, 3]; -static foo: [usize; 3] = [1, 2, 3]; - -static slice_1: &'static [usize] = &foo; -static slice_2: &'static [usize] = &foo; +static SLICE_1: &'static [usize] = &FOO; +static SLICE_2: &'static [usize] = &FOO; fn main() {} diff --git a/tests/ui/str/raw-string-literal-unescaped-unicode.rs b/tests/ui/str/raw-string-literal-unescaped-unicode.rs index 1d8bad20377c..c0dc0743a28f 100644 --- a/tests/ui/str/raw-string-literal-unescaped-unicode.rs +++ b/tests/ui/str/raw-string-literal-unescaped-unicode.rs @@ -1,7 +1,8 @@ +//! regression test for //@ check-pass fn main() { - assert!({false}); + assert!({ false }); assert!(r"\u{41}" == "A"); From bf9221458acbc9358c5043208838f18d5f094d92 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sat, 13 Dec 2025 01:04:59 +0900 Subject: [PATCH 126/489] Move inherent-impls-overlap-check to duplicate's subdirectory --- tests/ui/README.md | 6 ------ .../inherent-impls-overlap-check/auxiliary/repeat.rs | 0 .../inherent-impls-overlap-check/disjoint-ref-mut-method.rs | 0 .../inherent-impls-overlap-check/no-overlap.rs | 0 .../{ => duplicate}/inherent-impls-overlap-check/overlap.rs | 0 .../inherent-impls-overlap-check/overlap.stderr | 0 6 files changed, 6 deletions(-) rename tests/ui/{ => duplicate}/inherent-impls-overlap-check/auxiliary/repeat.rs (100%) rename tests/ui/{ => duplicate}/inherent-impls-overlap-check/disjoint-ref-mut-method.rs (100%) rename tests/ui/{ => duplicate}/inherent-impls-overlap-check/no-overlap.rs (100%) rename tests/ui/{ => duplicate}/inherent-impls-overlap-check/overlap.rs (100%) rename tests/ui/{ => duplicate}/inherent-impls-overlap-check/overlap.stderr (100%) diff --git a/tests/ui/README.md b/tests/ui/README.md index 25e870fd8f18..fd77c340b6a9 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -697,12 +697,6 @@ Tests on type inference. Tests for diagnostics on infinitely recursive types without indirection. -## `tests/ui/inherent-impls-overlap-check/` - -Checks that repeating the same function names across separate `impl` blocks triggers an informative error, but not if the `impl` are for different types, such as `Bar` and `Bar`. - -NOTE: This should maybe be a subdirectory within another related to duplicate definitions, such as `tests/ui/duplicate/`. - ## `tests/ui/inline-const/` These tests revolve around the inline `const` block that forces the compiler to const-eval its content. diff --git a/tests/ui/inherent-impls-overlap-check/auxiliary/repeat.rs b/tests/ui/duplicate/inherent-impls-overlap-check/auxiliary/repeat.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/auxiliary/repeat.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/auxiliary/repeat.rs diff --git a/tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs b/tests/ui/duplicate/inherent-impls-overlap-check/disjoint-ref-mut-method.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/disjoint-ref-mut-method.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/disjoint-ref-mut-method.rs diff --git a/tests/ui/inherent-impls-overlap-check/no-overlap.rs b/tests/ui/duplicate/inherent-impls-overlap-check/no-overlap.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/no-overlap.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/no-overlap.rs diff --git a/tests/ui/inherent-impls-overlap-check/overlap.rs b/tests/ui/duplicate/inherent-impls-overlap-check/overlap.rs similarity index 100% rename from tests/ui/inherent-impls-overlap-check/overlap.rs rename to tests/ui/duplicate/inherent-impls-overlap-check/overlap.rs diff --git a/tests/ui/inherent-impls-overlap-check/overlap.stderr b/tests/ui/duplicate/inherent-impls-overlap-check/overlap.stderr similarity index 100% rename from tests/ui/inherent-impls-overlap-check/overlap.stderr rename to tests/ui/duplicate/inherent-impls-overlap-check/overlap.stderr From 4d011efb8e418babc9337a24791462608a39d97e Mon Sep 17 00:00:00 2001 From: Urgau <3616612+Urgau@users.noreply.github.com> Date: Fri, 12 Dec 2025 18:13:08 +0100 Subject: [PATCH 127/489] Remove `[no-mentions]` handler in the triagebot config https://github.blog/changelog/2025-11-07-removing-notifications-for-mentions-in-commit-messages/ --- triagebot.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index 13da0a87def3..eb0c7b011f60 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -2,6 +2,3 @@ # Prevents un-canonicalized issue links (to avoid wrong issues being linked in r-l/rust) [issue-links] - -# Prevents mentions in commits to avoid users being spammed -[no-mentions] From 824f41ea6f68d04bc3a01e02c1fb0150e3c5c6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 9 Dec 2025 00:43:46 +0000 Subject: [PATCH 128/489] Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return` --- src/intrinsic/simd.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/intrinsic/simd.rs b/src/intrinsic/simd.rs index c7ed887b30d0..39b4bb3ebefa 100644 --- a/src/intrinsic/simd.rs +++ b/src/intrinsic/simd.rs @@ -774,24 +774,23 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>( return Err(()); }}; } - let (elem_ty_str, elem_ty, cast_type) = if let ty::Float(ref f) = *in_elem.kind() { - let elem_ty = bx.cx.type_float_from_ty(*f); - match f.bit_width() { - 16 => ("", elem_ty, Some(bx.cx.double_type)), - 32 => ("f", elem_ty, None), - 64 => ("", elem_ty, None), - _ => { - return_error!(InvalidMonomorphization::FloatingPointVector { - span, - name, - f_ty: *f, - in_ty - }); - } - } - } else { + let ty::Float(ref f) = *in_elem.kind() else { return_error!(InvalidMonomorphization::FloatingPointType { span, name, in_ty }); }; + let elem_ty = bx.cx.type_float_from_ty(*f); + let (elem_ty_str, elem_ty, cast_type) = match f.bit_width() { + 16 => ("", elem_ty, Some(bx.cx.double_type)), + 32 => ("f", elem_ty, None), + 64 => ("", elem_ty, None), + _ => { + return_error!(InvalidMonomorphization::FloatingPointVector { + span, + name, + f_ty: *f, + in_ty + }); + } + }; let vec_ty = bx.cx.type_vector(elem_ty, in_len); From e3f9bcef746096612567eb200f0695eaee152fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 9 Dec 2025 00:43:46 +0000 Subject: [PATCH 129/489] Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return` --- src/debuginfo/unwind.rs | 6 ++---- src/optimize/peephole.rs | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index ecaf88a26259..33ffe4cc4e9c 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -130,11 +130,9 @@ impl UnwindContext { return; } - let unwind_info = if let Some(unwind_info) = + let Some(unwind_info) = context.compiled_code().unwrap().create_unwind_info(module.isa()).unwrap() - { - unwind_info - } else { + else { return; }; diff --git a/src/optimize/peephole.rs b/src/optimize/peephole.rs index c93fe9352103..f38c1f96e6ed 100644 --- a/src/optimize/peephole.rs +++ b/src/optimize/peephole.rs @@ -29,11 +29,7 @@ pub(crate) fn maybe_known_branch_taken( arg: Value, test_zero: bool, ) -> Option { - let arg_inst = if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { - arg_inst - } else { - return None; - }; + let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) else { return None }; match bcx.func.dfg.insts[arg_inst] { InstructionData::UnaryImm { opcode: Opcode::Iconst, imm } => { From e39e127bd0d2baa51b57671f1fa00d0c4e7afbbb Mon Sep 17 00:00:00 2001 From: Oleksii Lozovskyi Date: Sat, 13 Dec 2025 16:19:33 +0900 Subject: [PATCH 130/489] libtest: Stricter XML validation Expect the entire input to be a single XML document, instead of reading it line by line. This detects trailing junk better. --- tests/run-make/libtest-junit/validate_junit.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/run-make/libtest-junit/validate_junit.py b/tests/run-make/libtest-junit/validate_junit.py index f92473751b03..a9cb0a059563 100755 --- a/tests/run-make/libtest-junit/validate_junit.py +++ b/tests/run-make/libtest-junit/validate_junit.py @@ -13,10 +13,10 @@ import sys import xml.etree.ElementTree as ET -# Try to decode line in order to ensure it is a valid XML document -for line in sys.stdin: - try: - ET.fromstring(line) - except ET.ParseError: - print("Invalid xml: %r" % line) - raise +# Read the entire output and try to decode it as XML. +junit = sys.stdin.read() +try: + ET.fromstring(junit) +except ET.ParseError: + print("Invalid xml: %r" % junit) + raise From 2cc434863c56a925d56e979cbfb1d824040d1cd7 Mon Sep 17 00:00:00 2001 From: Oleksii Lozovskyi Date: Sat, 13 Dec 2025 14:29:44 +0900 Subject: [PATCH 131/489] rustdoc: Test --format=junit Copied validate_junit.py from libtest-junit. JUnit format works well in edition 2021, but is currently broken in edition 2024 by the mergeable doctest report. --- .../run-make/doctests-junit/doctest-2021.xml | 1 + tests/run-make/doctests-junit/doctest.rs | 14 ++++ tests/run-make/doctests-junit/rmake.rs | 72 +++++++++++++++++++ .../run-make/doctests-junit/validate_junit.py | 22 ++++++ 4 files changed, 109 insertions(+) create mode 100644 tests/run-make/doctests-junit/doctest-2021.xml create mode 100644 tests/run-make/doctests-junit/doctest.rs create mode 100644 tests/run-make/doctests-junit/rmake.rs create mode 100755 tests/run-make/doctests-junit/validate_junit.py diff --git a/tests/run-make/doctests-junit/doctest-2021.xml b/tests/run-make/doctests-junit/doctest-2021.xml new file mode 100644 index 000000000000..5facfb80ce62 --- /dev/null +++ b/tests/run-make/doctests-junit/doctest-2021.xml @@ -0,0 +1 @@ + diff --git a/tests/run-make/doctests-junit/doctest.rs b/tests/run-make/doctests-junit/doctest.rs new file mode 100644 index 000000000000..1873d63a49c6 --- /dev/null +++ b/tests/run-make/doctests-junit/doctest.rs @@ -0,0 +1,14 @@ +/// ``` +/// assert_eq!(doctest::add(2, 2), 4); +/// ``` +/// +/// ```should_panic +/// assert_eq!(doctest::add(2, 2), 5); +/// ``` +/// +/// ```compile_fail +/// assert_eq!(doctest::add(2, 2), "banana"); +/// ``` +pub fn add(a: i32, b: i32) -> i32 { + a + b +} diff --git a/tests/run-make/doctests-junit/rmake.rs b/tests/run-make/doctests-junit/rmake.rs new file mode 100644 index 000000000000..40dc541b5d2c --- /dev/null +++ b/tests/run-make/doctests-junit/rmake.rs @@ -0,0 +1,72 @@ +// Check rustdoc's test JUnit (XML) output against snapshots. + +//@ ignore-cross-compile (running doctests) +//@ needs-unwind (test file contains `should_panic` test) + +use std::path::Path; + +use run_make_support::{cwd, diff, python_command, rustc, rustdoc}; + +fn main() { + let rlib = cwd().join("libdoctest.rlib"); + rustc().input("doctest.rs").crate_type("rlib").output(&rlib).run(); + + run_doctests(&rlib, "2021", "doctest-2021.xml"); + run_doctests_fail(&rlib, "2024"); +} + +#[track_caller] +fn run_doctests(rlib: &Path, edition: &str, expected_xml: &str) { + let rustdoc_out = rustdoc() + .input("doctest.rs") + .args(&[ + "--test", + "--test-args=-Zunstable-options", + "--test-args=--test-threads=1", + "--test-args=--format=junit", + ]) + .edition(edition) + .env("RUST_BACKTRACE", "0") + .extern_("doctest", rlib.display().to_string()) + .run(); + let rustdoc_stdout = &rustdoc_out.stdout_utf8(); + + python_command().arg("validate_junit.py").stdin_buf(rustdoc_stdout).run(); + + diff() + .expected_file(expected_xml) + .actual_text("output", rustdoc_stdout) + .normalize(r#"\btime="[0-9.]+""#, r#"time="$$TIME""#) + .run(); +} + +// FIXME: gone in the next patch +#[track_caller] +fn run_doctests_fail(rlib: &Path, edition: &str) { + let rustdoc_out = rustdoc() + .input("doctest.rs") + .args(&[ + "--test", + "--test-args=-Zunstable-options", + "--test-args=--test-threads=1", + "--test-args=--format=junit", + ]) + .edition(edition) + .env("RUST_BACKTRACE", "0") + .extern_("doctest", rlib.display().to_string()) + .run_fail(); + let rustdoc_stderr = &rustdoc_out.stderr_utf8(); + + diff() + .expected_text( + "expected", + r#" +thread 'main' ($TID) panicked at library/test/src/formatters/junit.rs:22:9: +assertion failed: !s.contains('\n') +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +"#, + ) + .actual_text("actual", rustdoc_stderr) + .normalize(r#"thread 'main' \([0-9]+\)"#, r#"thread 'main' ($$TID)"#) + .run(); +} diff --git a/tests/run-make/doctests-junit/validate_junit.py b/tests/run-make/doctests-junit/validate_junit.py new file mode 100755 index 000000000000..a9cb0a059563 --- /dev/null +++ b/tests/run-make/doctests-junit/validate_junit.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +# Trivial Python script that reads lines from stdin, and checks that each line +# is a well-formed XML document. +# +# This takes advantage of the fact that Python has a built-in XML parser, +# whereas doing the same check in Rust would require us to pull in an XML +# crate just for this relatively-minor test. +# +# If you're trying to remove Python scripts from the test suite, think twice +# before removing this one. You could do so, but it's probably not worth it. + +import sys +import xml.etree.ElementTree as ET + +# Read the entire output and try to decode it as XML. +junit = sys.stdin.read() +try: + ET.fromstring(junit) +except ET.ParseError: + print("Invalid xml: %r" % junit) + raise From 069cf9dfc906452d90d4e2898eac568fb558d25d Mon Sep 17 00:00:00 2001 From: Oleksii Lozovskyi Date: Sat, 29 Nov 2025 09:46:48 +0900 Subject: [PATCH 132/489] rustdoc: Write newline differently Fix the panic in write_message() which expects messages to contain no embedded newlines. We still want a trailing newline at the end of the file though, so write it in different manner. Doctest runner no longer panics, but the output is kinda broken when `compile_fail` doctests are present. This is because they are not mergeable. --- library/test/src/formatters/junit.rs | 6 ++- .../run-make/doctests-junit/doctest-2024.xml | 3 ++ tests/run-make/doctests-junit/rmake.rs | 40 +++---------------- 3 files changed, 13 insertions(+), 36 deletions(-) create mode 100644 tests/run-make/doctests-junit/doctest-2024.xml diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index 1566f1cb1dac..74d99e0f1270 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -189,8 +189,10 @@ impl OutputFormatter for JunitFormatter { compilation_time: f64, ) -> io::Result<()> { self.write_message(&format!( - "\n", - )) + "", + ))?; + self.out.write_all(b"\n")?; + Ok(()) } } diff --git a/tests/run-make/doctests-junit/doctest-2024.xml b/tests/run-make/doctests-junit/doctest-2024.xml new file mode 100644 index 000000000000..4f94f01c3e32 --- /dev/null +++ b/tests/run-make/doctests-junit/doctest-2024.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/run-make/doctests-junit/rmake.rs b/tests/run-make/doctests-junit/rmake.rs index 40dc541b5d2c..4cc7ac7c31d7 100644 --- a/tests/run-make/doctests-junit/rmake.rs +++ b/tests/run-make/doctests-junit/rmake.rs @@ -12,7 +12,7 @@ fn main() { rustc().input("doctest.rs").crate_type("rlib").output(&rlib).run(); run_doctests(&rlib, "2021", "doctest-2021.xml"); - run_doctests_fail(&rlib, "2024"); + run_doctests(&rlib, "2024", "doctest-2024.xml"); } #[track_caller] @@ -31,42 +31,14 @@ fn run_doctests(rlib: &Path, edition: &str, expected_xml: &str) { .run(); let rustdoc_stdout = &rustdoc_out.stdout_utf8(); - python_command().arg("validate_junit.py").stdin_buf(rustdoc_stdout).run(); + // FIXME: merged output of compile_fail tests is broken + if edition != "2024" { + python_command().arg("validate_junit.py").stdin_buf(rustdoc_stdout).run(); + } diff() .expected_file(expected_xml) .actual_text("output", rustdoc_stdout) - .normalize(r#"\btime="[0-9.]+""#, r#"time="$$TIME""#) - .run(); -} - -// FIXME: gone in the next patch -#[track_caller] -fn run_doctests_fail(rlib: &Path, edition: &str) { - let rustdoc_out = rustdoc() - .input("doctest.rs") - .args(&[ - "--test", - "--test-args=-Zunstable-options", - "--test-args=--test-threads=1", - "--test-args=--format=junit", - ]) - .edition(edition) - .env("RUST_BACKTRACE", "0") - .extern_("doctest", rlib.display().to_string()) - .run_fail(); - let rustdoc_stderr = &rustdoc_out.stderr_utf8(); - - diff() - .expected_text( - "expected", - r#" -thread 'main' ($TID) panicked at library/test/src/formatters/junit.rs:22:9: -assertion failed: !s.contains('\n') -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -"#, - ) - .actual_text("actual", rustdoc_stderr) - .normalize(r#"thread 'main' \([0-9]+\)"#, r#"thread 'main' ($$TID)"#) + .normalize(r#"\b(time|total_time|compilation_time)="[0-9.]+""#, r#"$1="$$TIME""#) .run(); } From 51580d38354328a58ff74c1124a67438722fda25 Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Sat, 13 Dec 2025 21:34:20 +0700 Subject: [PATCH 133/489] Refine never_loop iterator reduction check --- clippy_lints/src/loops/mod.rs | 31 +++++++++++++++------------- clippy_lints/src/loops/never_loop.rs | 6 +++--- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 1070f568eddd..e273567c98eb 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -26,7 +26,8 @@ mod while_let_on_iterator; use clippy_config::Conf; use clippy_utils::msrvs::Msrv; -use clippy_utils::{higher, sym, ty}; +use clippy_utils::res::{MaybeDef, MaybeTypeckRes}; +use clippy_utils::{higher, sym}; use rustc_ast::Label; use rustc_hir::{Expr, ExprKind, LoopSource, Pat}; use rustc_lint::{LateContext, LateLintPass}; @@ -881,23 +882,25 @@ impl<'tcx> LateLintPass<'tcx> for Loops { manual_while_let_some::check(cx, condition, body, span); } - if let ExprKind::MethodCall(path, recv, [arg], _) = expr.kind - && matches!( + if let ExprKind::MethodCall(path, recv, args, _) = expr.kind { + if matches!( path.ident.name, sym::all | sym::any | sym::filter_map | sym::find_map | sym::flat_map | sym::for_each | sym::map - ) - { - unused_enumerate_index::check_method(cx, expr, recv, arg); - } + ) && let [arg] = args + { + unused_enumerate_index::check_method(cx, expr, recv, arg); + } - if let ExprKind::MethodCall(path, recv, args, _) = expr.kind - && matches!( + if matches!( path.ident.name, - sym::for_each | sym::try_for_each | sym::fold | sym::try_fold | sym::reduce | sym::all | sym::any - ) - && ty::get_iterator_item_ty(cx, cx.typeck_results().expr_ty(recv)).is_some() - { - never_loop::check_iterator_reduction(cx, expr, recv, args); + sym::all | sym::any | sym::for_each | sym::try_for_each | sym::fold | sym::try_fold | sym::reduce + ) && cx + .ty_based_def(expr) + .assoc_fn_parent(cx) + .is_diag_item(cx, sym::Iterator) + { + never_loop::check_iterator_reduction(cx, expr, recv, args); + } } } } diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index b57d800ff37c..dca104795ce3 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -3,7 +3,7 @@ use super::utils::make_iterator_snippet; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::higher::ForLoop; use clippy_utils::macros::root_macro_call_first_node; -use clippy_utils::source::snippet; +use clippy_utils::source::{snippet, snippet_with_context}; use clippy_utils::sym; use clippy_utils::visitors::{Descend, for_each_expr_without_closures}; use rustc_errors::Applicability; @@ -111,8 +111,8 @@ pub(super) fn check_iterator_reduction<'tcx>( expr.span, "this iterator reduction never loops (closure always diverges)", |diag| { - let mut app = Applicability::Unspecified; - let recv_snip = make_iterator_snippet(cx, recv, &mut app); + let mut app = Applicability::HasPlaceholders; + let recv_snip = snippet_with_context(cx, recv.span, expr.span.ctxt(), "", &mut app).0; diag.note("if you only need one element, `if let Some(x) = iter.next()` is clearer"); let sugg = format!("if let Some(x) = {recv_snip}.next() {{ ... }}"); diag.span_suggestion_verbose(expr.span, "consider this pattern", sugg, app); From 6a821c5518a81145048faccf619b211eb7c23c2f Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Sat, 13 Dec 2025 15:18:07 +0100 Subject: [PATCH 134/489] simplify how inline asm handles `MaybeUninit` --- src/inline_asm.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 08cabe9d695c..ac0da06cbb8e 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -857,19 +857,9 @@ fn call_inline_asm<'tcx>( fn asm_clif_type<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> Option { match ty.kind() { - // Adapted from https://github.com/rust-lang/rust/blob/f3c66088610c1b80110297c2d9a8b5f9265b013f/compiler/rustc_hir_analysis/src/check/intrinsicck.rs#L136-L151 + // Adapted from https://github.com/rust-lang/rust/blob/df44a57fd29fca899ce473f85ed64efd0708dd7c/compiler/rustc_hir_typeck/src/inline_asm.rs#L180-L183 ty::Adt(adt, args) if fx.tcx.is_lang_item(adt.did(), LangItem::MaybeUninit) => { - let fields = &adt.non_enum_variant().fields; - let ty = fields[FieldIdx::ONE].ty(fx.tcx, args); - let ty::Adt(ty, args) = ty.kind() else { - unreachable!("expected first field of `MaybeUninit` to be an ADT") - }; - assert!( - ty.is_manually_drop(), - "expected first field of `MaybeUninit` to be `ManuallyDrop`" - ); - let fields = &ty.non_enum_variant().fields; - let ty = fields[FieldIdx::ZERO].ty(fx.tcx, args); + let ty = args.type_at(0); fx.clif_type(ty) } _ => fx.clif_type(ty), From aefb01b8521bd54128eec360ee78de83643b1d75 Mon Sep 17 00:00:00 2001 From: abd002 Date: Wed, 10 Dec 2025 19:14:47 +0200 Subject: [PATCH 135/489] Fix clippy::ref_as_ptr for non-temporary references in let/const --- clippy_lints/src/casts/ref_as_ptr.rs | 16 ++++++-- tests/ui/ref_as_ptr.fixed | 10 +++++ tests/ui/ref_as_ptr.rs | 10 +++++ tests/ui/ref_as_ptr.stderr | 60 ++++++++++++++++++---------- 4 files changed, 71 insertions(+), 25 deletions(-) diff --git a/clippy_lints/src/casts/ref_as_ptr.rs b/clippy_lints/src/casts/ref_as_ptr.rs index 592c820a25e1..b3805c678174 100644 --- a/clippy_lints/src/casts/ref_as_ptr.rs +++ b/clippy_lints/src/casts/ref_as_ptr.rs @@ -1,9 +1,9 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sugg::Sugg; -use clippy_utils::{ExprUseNode, expr_use_ctxt, std_or_core}; +use clippy_utils::{ExprUseNode, expr_use_ctxt, is_expr_temporary_value, std_or_core}; use rustc_errors::Applicability; -use rustc_hir::{Expr, Mutability, Ty, TyKind}; +use rustc_hir::{Expr, ExprKind, Mutability, Ty, TyKind}; use rustc_lint::LateContext; use rustc_middle::ty; @@ -23,10 +23,18 @@ pub(super) fn check<'tcx>( if matches!(cast_from.kind(), ty::Ref(..)) && let ty::RawPtr(_, to_mutbl) = cast_to.kind() && let use_cx = expr_use_ctxt(cx, expr) - // TODO: only block the lint if `cast_expr` is a temporary - && !matches!(use_cx.use_node(cx), ExprUseNode::LetStmt(_) | ExprUseNode::ConstStatic(_)) && let Some(std_or_core) = std_or_core(cx) { + if let ExprKind::AddrOf(_, _, addr_inner) = cast_expr.kind + && is_expr_temporary_value(cx, addr_inner) + && matches!( + use_cx.use_node(cx), + ExprUseNode::LetStmt(_) | ExprUseNode::ConstStatic(_) + ) + { + return; + } + let fn_name = match to_mutbl { Mutability::Not => "from_ref", Mutability::Mut => "from_mut", diff --git a/tests/ui/ref_as_ptr.fixed b/tests/ui/ref_as_ptr.fixed index ce144508581e..eadbb7c36415 100644 --- a/tests/ui/ref_as_ptr.fixed +++ b/tests/ui/ref_as_ptr.fixed @@ -86,6 +86,16 @@ fn main() { f(std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))); //~^ ref_as_ptr + let x = (10, 20); + let _ = std::ptr::from_ref(&x); + //~^ ref_as_ptr + let _ = std::ptr::from_ref(&x.0); + //~^ ref_as_ptr + + let x = Box::new(10); + let _ = std::ptr::from_ref(&*x); + //~^ ref_as_ptr + let _ = &String::new() as *const _; let _ = &mut String::new() as *mut _; const FOO: *const String = &String::new() as *const _; diff --git a/tests/ui/ref_as_ptr.rs b/tests/ui/ref_as_ptr.rs index acdff2c2ba29..ef96a3ff5693 100644 --- a/tests/ui/ref_as_ptr.rs +++ b/tests/ui/ref_as_ptr.rs @@ -86,6 +86,16 @@ fn main() { f(&mut std::array::from_fn(|i| i * i) as *mut [usize; 9]); //~^ ref_as_ptr + let x = (10, 20); + let _ = &x as *const _; + //~^ ref_as_ptr + let _ = &x.0 as *const _; + //~^ ref_as_ptr + + let x = Box::new(10); + let _ = &*x as *const _; + //~^ ref_as_ptr + let _ = &String::new() as *const _; let _ = &mut String::new() as *mut _; const FOO: *const String = &String::new() as *const _; diff --git a/tests/ui/ref_as_ptr.stderr b/tests/ui/ref_as_ptr.stderr index 79db29e596bd..587e4fb809cd 100644 --- a/tests/ui/ref_as_ptr.stderr +++ b/tests/ui/ref_as_ptr.stderr @@ -200,61 +200,67 @@ LL | f(&mut std::array::from_fn(|i| i * i) as *mut [usize; 9]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:109:7 + --> tests/ui/ref_as_ptr.rs:90:13 + | +LL | let _ = &x as *const _; + | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&x)` + +error: reference as raw pointer + --> tests/ui/ref_as_ptr.rs:92:13 + | +LL | let _ = &x.0 as *const _; + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&x.0)` + +error: reference as raw pointer + --> tests/ui/ref_as_ptr.rs:96:13 + | +LL | let _ = &*x as *const _; + | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&*x)` + +error: reference as raw pointer + --> tests/ui/ref_as_ptr.rs:119:7 | LL | f(val as *const i32); | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(val)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:111:7 + --> tests/ui/ref_as_ptr.rs:121:7 | LL | f(mut_val as *mut i32); | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(mut_val)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:116:7 + --> tests/ui/ref_as_ptr.rs:126:7 | LL | f(val as *const _); | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(val)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:118:7 + --> tests/ui/ref_as_ptr.rs:128:7 | LL | f(val as *const [u8]); | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[u8]>(val)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:123:7 + --> tests/ui/ref_as_ptr.rs:133:7 | LL | f(val as *mut _); | ^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(val)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:125:7 + --> tests/ui/ref_as_ptr.rs:135:7 | LL | f(val as *mut str); | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(val)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:133:9 + --> tests/ui/ref_as_ptr.rs:143:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:138:9 - | -LL | self.0 as *const _ as *const _ - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` - -error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:147:9 - | -LL | self.0 as *const _ as *const _ - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` - -error: reference as raw pointer - --> tests/ui/ref_as_ptr.rs:152:9 + --> tests/ui/ref_as_ptr.rs:148:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` @@ -262,8 +268,20 @@ LL | self.0 as *const _ as *const _ error: reference as raw pointer --> tests/ui/ref_as_ptr.rs:157:9 | +LL | self.0 as *const _ as *const _ + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` + +error: reference as raw pointer + --> tests/ui/ref_as_ptr.rs:162:9 + | +LL | self.0 as *const _ as *const _ + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` + +error: reference as raw pointer + --> tests/ui/ref_as_ptr.rs:167:9 + | LL | self.0 as *mut _ as *mut _ | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(self.0)` -error: aborting due to 44 previous errors +error: aborting due to 47 previous errors From 075548e9e98013c1ac5e04ae36052b64eab6a5b5 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sat, 13 Dec 2025 18:51:30 +0000 Subject: [PATCH 136/489] fix: `unchecked_time_subtraction` FN on `Ops::sub` method call --- clippy_lints/src/time_subtraction.rs | 55 ++++++++++------------ tests/ui/unchecked_time_subtraction.fixed | 10 ++++ tests/ui/unchecked_time_subtraction.rs | 10 ++++ tests/ui/unchecked_time_subtraction.stderr | 14 +++++- 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/clippy_lints/src/time_subtraction.rs b/clippy_lints/src/time_subtraction.rs index e0fdca97dbee..b4a07db9aeda 100644 --- a/clippy_lints/src/time_subtraction.rs +++ b/clippy_lints/src/time_subtraction.rs @@ -8,7 +8,6 @@ use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_session::impl_lint_pass; -use rustc_span::source_map::Spanned; use rustc_span::sym; declare_clippy_lint! { @@ -84,43 +83,41 @@ impl_lint_pass!(UncheckedTimeSubtraction => [MANUAL_INSTANT_ELAPSED, UNCHECKED_T impl LateLintPass<'_> for UncheckedTimeSubtraction { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) { - if let ExprKind::Binary( - Spanned { - node: BinOpKind::Sub, .. + let (lhs, rhs) = match expr.kind { + ExprKind::Binary(op, lhs, rhs) if matches!(op.node, BinOpKind::Sub,) => (lhs, rhs), + ExprKind::MethodCall(fn_name, lhs, [rhs], _) if cx.ty_based_def(expr).is_diag_item(cx, sym::sub) => { + (lhs, rhs) }, - lhs, - rhs, - ) = expr.kind - { - let typeck = cx.typeck_results(); - let lhs_ty = typeck.expr_ty(lhs); - let rhs_ty = typeck.expr_ty(rhs); + _ => return, + }; + let typeck = cx.typeck_results(); + let lhs_ty = typeck.expr_ty(lhs); + let rhs_ty = typeck.expr_ty(rhs); - if lhs_ty.is_diag_item(cx, sym::Instant) { - // Instant::now() - instant - if is_instant_now_call(cx, lhs) - && rhs_ty.is_diag_item(cx, sym::Instant) - && let Some(sugg) = Sugg::hir_opt(cx, rhs) - { - print_manual_instant_elapsed_sugg(cx, expr, sugg); - } - // instant - duration - else if rhs_ty.is_diag_item(cx, sym::Duration) - && !expr.span.from_expansion() - && self.msrv.meets(cx, msrvs::TRY_FROM) - { - print_unchecked_duration_subtraction_sugg(cx, lhs, rhs, expr); - } + if lhs_ty.is_diag_item(cx, sym::Instant) { + // Instant::now() - instant + if is_instant_now_call(cx, lhs) + && rhs_ty.is_diag_item(cx, sym::Instant) + && let Some(sugg) = Sugg::hir_opt(cx, rhs) + { + print_manual_instant_elapsed_sugg(cx, expr, sugg); } - // duration - duration - else if lhs_ty.is_diag_item(cx, sym::Duration) - && rhs_ty.is_diag_item(cx, sym::Duration) + // instant - duration + else if rhs_ty.is_diag_item(cx, sym::Duration) && !expr.span.from_expansion() && self.msrv.meets(cx, msrvs::TRY_FROM) { print_unchecked_duration_subtraction_sugg(cx, lhs, rhs, expr); } } + // duration - duration + else if lhs_ty.is_diag_item(cx, sym::Duration) + && rhs_ty.is_diag_item(cx, sym::Duration) + && !expr.span.from_expansion() + && self.msrv.meets(cx, msrvs::TRY_FROM) + { + print_unchecked_duration_subtraction_sugg(cx, lhs, rhs, expr); + } } } diff --git a/tests/ui/unchecked_time_subtraction.fixed b/tests/ui/unchecked_time_subtraction.fixed index 2f923fef4c25..a75de6c9717c 100644 --- a/tests/ui/unchecked_time_subtraction.fixed +++ b/tests/ui/unchecked_time_subtraction.fixed @@ -35,3 +35,13 @@ fn main() { let _ = (2 * dur1).checked_sub(dur2).unwrap(); //~^ unchecked_time_subtraction } + +fn issue16230() { + use std::ops::Sub as _; + + Duration::ZERO.checked_sub(Duration::MAX).unwrap(); + //~^ unchecked_time_subtraction + + let _ = Duration::ZERO.checked_sub(Duration::MAX).unwrap(); + //~^ unchecked_time_subtraction +} diff --git a/tests/ui/unchecked_time_subtraction.rs b/tests/ui/unchecked_time_subtraction.rs index cf727f62aafa..dd40d8aa14c4 100644 --- a/tests/ui/unchecked_time_subtraction.rs +++ b/tests/ui/unchecked_time_subtraction.rs @@ -35,3 +35,13 @@ fn main() { let _ = 2 * dur1 - dur2; //~^ unchecked_time_subtraction } + +fn issue16230() { + use std::ops::Sub as _; + + Duration::ZERO.sub(Duration::MAX); + //~^ unchecked_time_subtraction + + let _ = Duration::ZERO - Duration::MAX; + //~^ unchecked_time_subtraction +} diff --git a/tests/ui/unchecked_time_subtraction.stderr b/tests/ui/unchecked_time_subtraction.stderr index c129497447fc..046024d11f75 100644 --- a/tests/ui/unchecked_time_subtraction.stderr +++ b/tests/ui/unchecked_time_subtraction.stderr @@ -49,5 +49,17 @@ error: unchecked subtraction of a `Duration` LL | let _ = 2 * dur1 - dur2; | ^^^^^^^^^^^^^^^ help: try: `(2 * dur1).checked_sub(dur2).unwrap()` -error: aborting due to 8 previous errors +error: unchecked subtraction of a `Duration` + --> tests/ui/unchecked_time_subtraction.rs:42:5 + | +LL | Duration::ZERO.sub(Duration::MAX); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Duration::ZERO.checked_sub(Duration::MAX).unwrap()` + +error: unchecked subtraction of a `Duration` + --> tests/ui/unchecked_time_subtraction.rs:45:13 + | +LL | let _ = Duration::ZERO - Duration::MAX; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Duration::ZERO.checked_sub(Duration::MAX).unwrap()` + +error: aborting due to 10 previous errors From e95ceddbc6aea8bda568bad7793939749558a992 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sat, 13 Dec 2025 19:06:44 +0000 Subject: [PATCH 137/489] fix: `unchecked_time_subtraction` wrongly unmangled macros --- clippy_lints/src/time_subtraction.rs | 5 +++-- tests/ui/unchecked_time_subtraction.fixed | 15 +++++++++++++++ tests/ui/unchecked_time_subtraction.rs | 15 +++++++++++++++ tests/ui/unchecked_time_subtraction.stderr | 14 +++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/time_subtraction.rs b/clippy_lints/src/time_subtraction.rs index b4a07db9aeda..b3ad13d8488d 100644 --- a/clippy_lints/src/time_subtraction.rs +++ b/clippy_lints/src/time_subtraction.rs @@ -178,8 +178,9 @@ fn print_unchecked_duration_subtraction_sugg( // avoid suggestions if !is_chained_time_subtraction(cx, left_expr) { let mut applicability = Applicability::MachineApplicable; - let left_sugg = Sugg::hir_with_applicability(cx, left_expr, "", &mut applicability); - let right_sugg = Sugg::hir_with_applicability(cx, right_expr, "", &mut applicability); + let left_sugg = Sugg::hir_with_context(cx, left_expr, expr.span.ctxt(), "", &mut applicability); + let right_sugg = + Sugg::hir_with_context(cx, right_expr, expr.span.ctxt(), "", &mut applicability); diag.span_suggestion( expr.span, diff --git a/tests/ui/unchecked_time_subtraction.fixed b/tests/ui/unchecked_time_subtraction.fixed index a75de6c9717c..830b737f18e7 100644 --- a/tests/ui/unchecked_time_subtraction.fixed +++ b/tests/ui/unchecked_time_subtraction.fixed @@ -45,3 +45,18 @@ fn issue16230() { let _ = Duration::ZERO.checked_sub(Duration::MAX).unwrap(); //~^ unchecked_time_subtraction } + +fn issue16234() { + use std::ops::Sub as _; + + macro_rules! duration { + ($secs:expr) => { + Duration::from_secs($secs) + }; + } + + duration!(0).checked_sub(duration!(1)).unwrap(); + //~^ unchecked_time_subtraction + let _ = duration!(0).checked_sub(duration!(1)).unwrap(); + //~^ unchecked_time_subtraction +} diff --git a/tests/ui/unchecked_time_subtraction.rs b/tests/ui/unchecked_time_subtraction.rs index dd40d8aa14c4..e41860157c41 100644 --- a/tests/ui/unchecked_time_subtraction.rs +++ b/tests/ui/unchecked_time_subtraction.rs @@ -45,3 +45,18 @@ fn issue16230() { let _ = Duration::ZERO - Duration::MAX; //~^ unchecked_time_subtraction } + +fn issue16234() { + use std::ops::Sub as _; + + macro_rules! duration { + ($secs:expr) => { + Duration::from_secs($secs) + }; + } + + duration!(0).sub(duration!(1)); + //~^ unchecked_time_subtraction + let _ = duration!(0) - duration!(1); + //~^ unchecked_time_subtraction +} diff --git a/tests/ui/unchecked_time_subtraction.stderr b/tests/ui/unchecked_time_subtraction.stderr index 046024d11f75..fa4bd1db81ae 100644 --- a/tests/ui/unchecked_time_subtraction.stderr +++ b/tests/ui/unchecked_time_subtraction.stderr @@ -61,5 +61,17 @@ error: unchecked subtraction of a `Duration` LL | let _ = Duration::ZERO - Duration::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Duration::ZERO.checked_sub(Duration::MAX).unwrap()` -error: aborting due to 10 previous errors +error: unchecked subtraction of a `Duration` + --> tests/ui/unchecked_time_subtraction.rs:58:5 + | +LL | duration!(0).sub(duration!(1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `duration!(0).checked_sub(duration!(1)).unwrap()` + +error: unchecked subtraction of a `Duration` + --> tests/ui/unchecked_time_subtraction.rs:60:13 + | +LL | let _ = duration!(0) - duration!(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `duration!(0).checked_sub(duration!(1)).unwrap()` + +error: aborting due to 12 previous errors From e0a74c33352706d6c43fe8a14694241f5833b1eb Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sat, 13 Dec 2025 20:57:44 +0000 Subject: [PATCH 138/489] fix: `manual_instant_elapsed` wrongly unmangled macros --- clippy_lints/src/time_subtraction.rs | 13 ++++++------- tests/ui/manual_instant_elapsed.fixed | 16 ++++++++++++++++ tests/ui/manual_instant_elapsed.rs | 16 ++++++++++++++++ tests/ui/manual_instant_elapsed.stderr | 14 +++++++++++++- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/time_subtraction.rs b/clippy_lints/src/time_subtraction.rs index b3ad13d8488d..92bce998c32f 100644 --- a/clippy_lints/src/time_subtraction.rs +++ b/clippy_lints/src/time_subtraction.rs @@ -96,11 +96,8 @@ impl LateLintPass<'_> for UncheckedTimeSubtraction { if lhs_ty.is_diag_item(cx, sym::Instant) { // Instant::now() - instant - if is_instant_now_call(cx, lhs) - && rhs_ty.is_diag_item(cx, sym::Instant) - && let Some(sugg) = Sugg::hir_opt(cx, rhs) - { - print_manual_instant_elapsed_sugg(cx, expr, sugg); + if is_instant_now_call(cx, lhs) && rhs_ty.is_diag_item(cx, sym::Instant) { + print_manual_instant_elapsed_sugg(cx, expr, rhs); } // instant - duration else if rhs_ty.is_diag_item(cx, sym::Duration) @@ -150,7 +147,9 @@ fn is_time_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { ty.is_diag_item(cx, sym::Duration) || ty.is_diag_item(cx, sym::Instant) } -fn print_manual_instant_elapsed_sugg(cx: &LateContext<'_>, expr: &Expr<'_>, sugg: Sugg<'_>) { +fn print_manual_instant_elapsed_sugg(cx: &LateContext<'_>, expr: &Expr<'_>, rhs: &Expr<'_>) { + let mut applicability = Applicability::MachineApplicable; + let sugg = Sugg::hir_with_context(cx, rhs, expr.span.ctxt(), "", &mut applicability); span_lint_and_sugg( cx, MANUAL_INSTANT_ELAPSED, @@ -158,7 +157,7 @@ fn print_manual_instant_elapsed_sugg(cx: &LateContext<'_>, expr: &Expr<'_>, sugg "manual implementation of `Instant::elapsed`", "try", format!("{}.elapsed()", sugg.maybe_paren()), - Applicability::MachineApplicable, + applicability, ); } diff --git a/tests/ui/manual_instant_elapsed.fixed b/tests/ui/manual_instant_elapsed.fixed index a04c601e08c1..2fa5702f8a04 100644 --- a/tests/ui/manual_instant_elapsed.fixed +++ b/tests/ui/manual_instant_elapsed.fixed @@ -28,3 +28,19 @@ fn main() { // //~^^ manual_instant_elapsed } + +fn issue16236() { + use std::ops::Sub as _; + macro_rules! deref { + ($e:expr) => { + *$e + }; + } + + let start = &Instant::now(); + let _ = deref!(start).elapsed(); + //~^ manual_instant_elapsed + + deref!(start).elapsed(); + //~^ manual_instant_elapsed +} diff --git a/tests/ui/manual_instant_elapsed.rs b/tests/ui/manual_instant_elapsed.rs index 7c67f6acf85d..e7a0e6499e74 100644 --- a/tests/ui/manual_instant_elapsed.rs +++ b/tests/ui/manual_instant_elapsed.rs @@ -28,3 +28,19 @@ fn main() { // //~^^ manual_instant_elapsed } + +fn issue16236() { + use std::ops::Sub as _; + macro_rules! deref { + ($e:expr) => { + *$e + }; + } + + let start = &Instant::now(); + let _ = Instant::now().sub(deref!(start)); + //~^ manual_instant_elapsed + + Instant::now() - deref!(start); + //~^ manual_instant_elapsed +} diff --git a/tests/ui/manual_instant_elapsed.stderr b/tests/ui/manual_instant_elapsed.stderr index e84f3126f707..e42ac5739a29 100644 --- a/tests/ui/manual_instant_elapsed.stderr +++ b/tests/ui/manual_instant_elapsed.stderr @@ -13,5 +13,17 @@ error: manual implementation of `Instant::elapsed` LL | Instant::now() - *ref_to_instant; // to ensure parens are added correctly | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*ref_to_instant).elapsed()` -error: aborting due to 2 previous errors +error: manual implementation of `Instant::elapsed` + --> tests/ui/manual_instant_elapsed.rs:41:13 + | +LL | let _ = Instant::now().sub(deref!(start)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `deref!(start).elapsed()` + +error: manual implementation of `Instant::elapsed` + --> tests/ui/manual_instant_elapsed.rs:44:5 + | +LL | Instant::now() - deref!(start); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `deref!(start).elapsed()` + +error: aborting due to 4 previous errors From 9dca2a8ad32aeb93d75429427baf3c38d9d58de2 Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Sun, 14 Dec 2025 09:56:35 +0700 Subject: [PATCH 139/489] Refactor loops MethodCall handling into single match --- clippy_lints/src/loops/mod.rs | 36 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index e273567c98eb..051765a22c31 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -883,23 +883,29 @@ impl<'tcx> LateLintPass<'tcx> for Loops { } if let ExprKind::MethodCall(path, recv, args, _) = expr.kind { - if matches!( - path.ident.name, - sym::all | sym::any | sym::filter_map | sym::find_map | sym::flat_map | sym::for_each | sym::map - ) && let [arg] = args - { - unused_enumerate_index::check_method(cx, expr, recv, arg); - } - - if matches!( - path.ident.name, - sym::all | sym::any | sym::for_each | sym::try_for_each | sym::fold | sym::try_fold | sym::reduce - ) && cx + let name = path.ident.name; + let is_iterator_method = cx .ty_based_def(expr) .assoc_fn_parent(cx) - .is_diag_item(cx, sym::Iterator) - { - never_loop::check_iterator_reduction(cx, expr, recv, args); + .is_diag_item(cx, sym::Iterator); + + match (name, args) { + (sym::for_each | sym::all | sym::any, [arg]) => { + unused_enumerate_index::check_method(cx, expr, recv, arg); + if is_iterator_method { + never_loop::check_iterator_reduction(cx, expr, recv, args); + } + }, + + (sym::filter_map | sym::find_map | sym::flat_map | sym::map, [arg]) => { + unused_enumerate_index::check_method(cx, expr, recv, arg); + }, + + (sym::try_for_each | sym::reduce | sym::fold | sym::try_fold, args) if is_iterator_method => { + never_loop::check_iterator_reduction(cx, expr, recv, args); + }, + + _ => {}, } } } From 594623cada4441419550389c99822a541c99eced Mon Sep 17 00:00:00 2001 From: dfireBird Date: Sun, 7 Dec 2025 18:09:55 +0530 Subject: [PATCH 140/489] feat: semantics implementation of locals used for extract function fix: consider let-else expr for return control type --- .../crates/hir-expand/src/name.rs | 4 + .../rust-analyzer/crates/hir/src/semantics.rs | 84 ++++++- .../crates/hir/src/source_analyzer.rs | 2 +- .../src/handlers/extract_function.rs | 205 ++++++++++-------- 4 files changed, 200 insertions(+), 95 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/name.rs b/src/tools/rust-analyzer/crates/hir-expand/src/name.rs index 217d991d110d..1e5efb6e146f 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/name.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/name.rs @@ -197,6 +197,10 @@ impl Name { pub fn symbol(&self) -> &Symbol { &self.symbol } + + pub fn is_generated(&self) -> bool { + self.as_str().starts_with("") + } } struct Display<'a> { diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs index ffb518b1e66f..a9af26aa3f66 100644 --- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs @@ -16,7 +16,7 @@ use hir_def::{ expr_store::{Body, ExprOrPatSource, HygieneId, path::Path}, hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat}, nameres::{ModuleOrigin, crate_def_map}, - resolver::{self, HasResolver, Resolver, TypeNs}, + resolver::{self, HasResolver, Resolver, TypeNs, ValueNs}, type_ref::Mutability, }; use hir_expand::{ @@ -2192,6 +2192,88 @@ impl<'db> SemanticsImpl<'db> { self.cache(adt_source.value.syntax().ancestors().last().unwrap(), adt_source.file_id); ToDef::to_def(self, adt_source.as_ref()) } + + pub fn locals_used( + &self, + element: Either<&ast::Expr, &ast::StmtList>, + text_range: TextRange, + ) -> Option> { + let sa = self.analyze(element.either(|e| e.syntax(), |s| s.syntax()))?; + let store = sa.store()?; + let mut resolver = sa.resolver.clone(); + let def = resolver.body_owner()?; + + let is_not_generated = |path: &Path| { + !path.mod_path().and_then(|path| path.as_ident()).is_some_and(Name::is_generated) + }; + + let exprs = element.either( + |e| vec![e.clone()], + |stmts| { + let mut exprs: Vec<_> = stmts + .statements() + .filter(|stmt| text_range.contains_range(stmt.syntax().text_range())) + .filter_map(|stmt| match stmt { + ast::Stmt::ExprStmt(expr_stmt) => expr_stmt.expr().map(|e| vec![e]), + ast::Stmt::Item(_) => None, + ast::Stmt::LetStmt(let_stmt) => { + let init = let_stmt.initializer(); + let let_else = let_stmt + .let_else() + .and_then(|le| le.block_expr()) + .map(ast::Expr::BlockExpr); + + match (init, let_else) { + (Some(i), Some(le)) => Some(vec![i, le]), + (Some(i), _) => Some(vec![i]), + (_, Some(le)) => Some(vec![le]), + _ => None, + } + } + }) + .flatten() + .collect(); + + if let Some(tail_expr) = stmts.tail_expr() + && text_range.contains_range(tail_expr.syntax().text_range()) + { + exprs.push(tail_expr); + } + exprs + }, + ); + let mut exprs: Vec<_> = + exprs.into_iter().filter_map(|e| sa.expr_id(e).and_then(|e| e.as_expr())).collect(); + + let mut locals: Vec = Vec::new(); + let mut add_to_locals_used = |expr_id| { + if let Expr::Path(path) = &store[expr_id] + && is_not_generated(path) + { + let _ = resolver.update_to_inner_scope(self.db, def, expr_id); + resolver + .resolve_path_in_value_ns_fully(self.db, path, store.expr_path_hygiene(expr_id)) + .inspect(|value| { + if let ValueNs::LocalBinding(id) = value { + locals.push((def, *id).into()); + } + }); + } + }; + + while let Some(expr_id) = exprs.pop() { + let mut has_child = false; + store.walk_child_exprs(expr_id, |id| { + has_child = true; + exprs.push(id); + }); + if !has_child { + add_to_locals_used(expr_id) + } + } + + Some(locals) + } } // FIXME This can't be the best way to do this diff --git a/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs b/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs index 901c9e1575b2..b90eb97d8791 100644 --- a/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs +++ b/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs @@ -240,7 +240,7 @@ impl<'db> SourceAnalyzer<'db> { ) } - fn expr_id(&self, expr: ast::Expr) -> Option { + pub(crate) fn expr_id(&self, expr: ast::Expr) -> Option { let src = InFile { file_id: self.file_id, value: expr }; self.store_sm()?.node_expr(src.as_ref()) } diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs index 4b7314be4609..19ded49b1850 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs @@ -9,14 +9,14 @@ use hir::{ use ide_db::{ FxIndexSet, RootDatabase, assists::GroupLabel, - defs::{Definition, NameRefClass}, + defs::Definition, famous_defs::FamousDefs, helpers::mod_path_to_ast, imports::insert_use::{ImportScope, insert_use}, search::{FileReference, ReferenceCategory, SearchScope}, source_change::SourceChangeBuilder, syntax_helpers::node_ext::{ - for_each_tail_expr, preorder_expr, walk_expr, walk_pat, walk_patterns_in_expr, + for_each_tail_expr, preorder_expr, walk_pat, walk_patterns_in_expr, }, }; use itertools::Itertools; @@ -687,29 +687,6 @@ impl FunctionBody { } } - fn walk_expr(&self, cb: &mut dyn FnMut(ast::Expr)) { - match self { - FunctionBody::Expr(expr) => walk_expr(expr, cb), - FunctionBody::Span { parent, text_range, .. } => { - parent - .statements() - .filter(|stmt| text_range.contains_range(stmt.syntax().text_range())) - .filter_map(|stmt| match stmt { - ast::Stmt::ExprStmt(expr_stmt) => expr_stmt.expr(), - ast::Stmt::Item(_) => None, - ast::Stmt::LetStmt(stmt) => stmt.initializer(), - }) - .for_each(|expr| walk_expr(&expr, cb)); - if let Some(expr) = parent - .tail_expr() - .filter(|it| text_range.contains_range(it.syntax().text_range())) - { - walk_expr(&expr, cb); - } - } - } - } - fn preorder_expr(&self, cb: &mut dyn FnMut(WalkEvent) -> bool) { match self { FunctionBody::Expr(expr) => preorder_expr(expr, cb), @@ -718,10 +695,24 @@ impl FunctionBody { .statements() .filter(|stmt| text_range.contains_range(stmt.syntax().text_range())) .filter_map(|stmt| match stmt { - ast::Stmt::ExprStmt(expr_stmt) => expr_stmt.expr(), + ast::Stmt::ExprStmt(expr_stmt) => expr_stmt.expr().map(|e| vec![e]), ast::Stmt::Item(_) => None, - ast::Stmt::LetStmt(stmt) => stmt.initializer(), + ast::Stmt::LetStmt(stmt) => { + let init = stmt.initializer(); + let let_else = stmt + .let_else() + .and_then(|le| le.block_expr()) + .map(ast::Expr::BlockExpr); + + match (init, let_else) { + (Some(i), Some(le)) => Some(vec![i, le]), + (Some(i), _) => Some(vec![i]), + (_, Some(le)) => Some(vec![le]), + _ => None, + } + } }) + .flatten() .for_each(|expr| preorder_expr(&expr, cb)); if let Some(expr) = parent .tail_expr() @@ -799,22 +790,14 @@ impl FunctionBody { let mut self_param = None; let mut res = FxIndexSet::default(); - fn local_from_name_ref( - sema: &Semantics<'_, RootDatabase>, - name_ref: ast::NameRef, - ) -> Option { - match NameRefClass::classify(sema, &name_ref) { - Some( - NameRefClass::Definition(Definition::Local(local_ref), _) - | NameRefClass::FieldShorthand { local_ref, field_ref: _, adt_subst: _ }, - ) => Some(local_ref), - _ => None, - } - } + let (text_range, element) = match self { + FunctionBody::Expr(expr) => (expr.syntax().text_range(), Either::Left(expr)), + FunctionBody::Span { parent, text_range, .. } => (*text_range, Either::Right(parent)), + }; let mut add_name_if_local = |local_ref: Local| { - let InFile { file_id, value } = local_ref.primary_source(sema.db).source; // locals defined inside macros are not relevant to us + let InFile { file_id, value } = local_ref.primary_source(sema.db).source; if !file_id.is_macro() { match value { Either::Right(it) => { @@ -826,59 +809,11 @@ impl FunctionBody { } } }; - self.walk_expr(&mut |expr| match expr { - ast::Expr::PathExpr(path_expr) => { - if let Some(local) = path_expr - .path() - .and_then(|it| it.as_single_name_ref()) - .and_then(|name_ref| local_from_name_ref(sema, name_ref)) - { - add_name_if_local(local); - } - } - ast::Expr::ClosureExpr(closure_expr) => { - if let Some(body) = closure_expr.body() { - body.syntax() - .descendants() - .filter_map(ast::NameRef::cast) - .filter_map(|name_ref| local_from_name_ref(sema, name_ref)) - .for_each(&mut add_name_if_local); - } - } - ast::Expr::MacroExpr(expr) => { - if let Some(tt) = expr.macro_call().and_then(|call| call.token_tree()) { - tt.syntax() - .descendants_with_tokens() - .filter_map(SyntaxElement::into_token) - .filter(|it| { - matches!(it.kind(), SyntaxKind::STRING | SyntaxKind::IDENT | T![self]) - }) - .for_each(|t| { - if ast::String::can_cast(t.kind()) { - if let Some(parts) = - ast::String::cast(t).and_then(|s| sema.as_format_args_parts(&s)) - { - parts - .into_iter() - .filter_map(|(_, value)| value.and_then(|it| it.left())) - .filter_map(|path| match path { - PathResolution::Local(local) => Some(local), - _ => None, - }) - .for_each(&mut add_name_if_local); - } - } else { - sema.descend_into_macros_exact(t) - .into_iter() - .filter_map(|t| t.parent().and_then(ast::NameRef::cast)) - .filter_map(|name_ref| local_from_name_ref(sema, name_ref)) - .for_each(&mut add_name_if_local); - } - }); - } - } - _ => (), - }); + + if let Some(locals) = sema.locals_used(element, text_range) { + locals.into_iter().for_each(&mut add_name_if_local); + } + (res, self_param) } @@ -6291,6 +6226,90 @@ fn foo() { fn $0fun_name(v: i32) { print!("{v:?}{}", v == 123); +}"#, + ); + } + + #[test] + fn no_parameter_for_variable_used_only_let_else() { + check_assist( + extract_function, + r#" +fn foo() -> u32 { + let x = 5; + + $0let Some(y) = Some(1) else { + return x * 2; + };$0 + + y +}"#, + r#" +fn foo() -> u32 { + let x = 5; + + let y = match fun_name(x) { + Ok(value) => value, + Err(value) => return value, + }; + + y +} + +fn $0fun_name(x: u32) -> Result<_, u32> { + let Some(y) = Some(1) else { + return Err(x * 2); + }; + Ok(y) +}"#, + ); + } + + #[test] + fn deeply_nested_macros() { + check_assist( + extract_function, + r#" +macro_rules! m { + ($val:ident) => { $val }; +} + +macro_rules! n { + ($v1:ident, $v2:ident) => { m!($v1) + $v2 }; +} + +macro_rules! o { + ($v1:ident, $v2:ident, $v3:ident) => { n!($v1, $v2) + $v3 }; +} + +fn foo() -> u32 { + let v1 = 1; + let v2 = 2; + $0let v3 = 3; + o!(v1, v2, v3)$0 +}"#, + r#" +macro_rules! m { + ($val:ident) => { $val }; +} + +macro_rules! n { + ($v1:ident, $v2:ident) => { m!($v1) + $v2 }; +} + +macro_rules! o { + ($v1:ident, $v2:ident, $v3:ident) => { n!($v1, $v2) + $v3 }; +} + +fn foo() -> u32 { + let v1 = 1; + let v2 = 2; + fun_name(v1, v2) +} + +fn $0fun_name(v1: u32, v2: u32) -> u32 { + let v3 = 3; + o!(v1, v2, v3) }"#, ); } From ba6b40e6dc37cf3138aedc38a2cdf3a57c8aeb8f Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Sun, 14 Dec 2025 04:58:26 +0000 Subject: [PATCH 141/489] Prepare for merging from rust-lang/rust This updates the rust-version file to 2cd4ee6bcf517345dd76d7b102d56b2e873cddbc. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index e79ad9362c08..a1b44d65c597 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -dc47a69ed94bc88b10b7d500cceacf29b87bcbbe +2cd4ee6bcf517345dd76d7b102d56b2e873cddbc From a945d42399e53889a35281f3afc50935cae7fbcc Mon Sep 17 00:00:00 2001 From: usamoi Date: Sun, 14 Dec 2025 16:01:13 +0800 Subject: [PATCH 142/489] use simd_reduce_add_ordered on aarch64 --- .../core_arch/src/aarch64/neon/generated.rs | 32 +++++++++---------- .../spec/neon/aarch64.spec.yml | 16 +++++----- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs index ce864cc7d907..b1d36343a00c 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs @@ -613,7 +613,7 @@ pub fn vaddvq_f64(a: float64x2_t) -> f64 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addp))] pub fn vaddv_s32(a: int32x2_t) -> i32 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddv_s8)"] @@ -622,7 +622,7 @@ pub fn vaddv_s32(a: int32x2_t) -> i32 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddv_s8(a: int8x8_t) -> i8 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_s8)"] @@ -631,7 +631,7 @@ pub fn vaddv_s8(a: int8x8_t) -> i8 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddvq_s8(a: int8x16_t) -> i8 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddv_s16)"] @@ -640,7 +640,7 @@ pub fn vaddvq_s8(a: int8x16_t) -> i8 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddv_s16(a: int16x4_t) -> i16 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_s16)"] @@ -649,7 +649,7 @@ pub fn vaddv_s16(a: int16x4_t) -> i16 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddvq_s16(a: int16x8_t) -> i16 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_s32)"] @@ -658,7 +658,7 @@ pub fn vaddvq_s16(a: int16x8_t) -> i16 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddvq_s32(a: int32x4_t) -> i32 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddv_u32)"] @@ -667,7 +667,7 @@ pub fn vaddvq_s32(a: int32x4_t) -> i32 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addp))] pub fn vaddv_u32(a: uint32x2_t) -> u32 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddv_u8)"] @@ -676,7 +676,7 @@ pub fn vaddv_u32(a: uint32x2_t) -> u32 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddv_u8(a: uint8x8_t) -> u8 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_u8)"] @@ -685,7 +685,7 @@ pub fn vaddv_u8(a: uint8x8_t) -> u8 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddvq_u8(a: uint8x16_t) -> u8 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddv_u16)"] @@ -694,7 +694,7 @@ pub fn vaddvq_u8(a: uint8x16_t) -> u8 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddv_u16(a: uint16x4_t) -> u16 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_u16)"] @@ -703,7 +703,7 @@ pub fn vaddv_u16(a: uint16x4_t) -> u16 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddvq_u16(a: uint16x8_t) -> u16 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_u32)"] @@ -712,7 +712,7 @@ pub fn vaddvq_u16(a: uint16x8_t) -> u16 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addv))] pub fn vaddvq_u32(a: uint32x4_t) -> u32 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_s64)"] @@ -721,7 +721,7 @@ pub fn vaddvq_u32(a: uint32x4_t) -> u32 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addp))] pub fn vaddvq_s64(a: int64x2_t) -> i64 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add across vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vaddvq_u64)"] @@ -730,7 +730,7 @@ pub fn vaddvq_s64(a: int64x2_t) -> i64 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addp))] pub fn vaddvq_u64(a: uint64x2_t) -> u64 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Multi-vector floating-point absolute maximum"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vamax_f32)"] @@ -15774,7 +15774,7 @@ pub fn vpadds_f32(a: float32x2_t) -> f32 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addp))] pub fn vpaddd_s64(a: int64x2_t) -> i64 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Add pairwise"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vpaddd_u64)"] @@ -15783,7 +15783,7 @@ pub fn vpaddd_s64(a: int64x2_t) -> i64 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] #[cfg_attr(test, assert_instr(addp))] pub fn vpaddd_u64(a: uint64x2_t) -> u64 { - unsafe { simd_reduce_add_unordered(a) } + unsafe { simd_reduce_add_ordered(a, 0) } } #[doc = "Floating-point add pairwise"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vpaddq_f16)"] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml index 48c12779a8c1..41ba11fb0665 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml @@ -13261,7 +13261,7 @@ intrinsics: types: - [int64x2_t, i64] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vpaddd_u64" doc: "Add pairwise" @@ -13274,7 +13274,7 @@ intrinsics: types: - [uint64x2_t, u64] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddv{neon_type[0].no}" doc: "Add across vector" @@ -13291,7 +13291,7 @@ intrinsics: - [int16x8_t, i16] - [int32x4_t, i32] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddv{neon_type[0].no}" doc: "Add across vector" @@ -13304,7 +13304,7 @@ intrinsics: types: - [int32x2_t, i32] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddv{neon_type[0].no}" doc: "Add across vector" @@ -13317,7 +13317,7 @@ intrinsics: types: - [int64x2_t, i64] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddv{neon_type[0].no}" doc: "Add across vector" @@ -13334,7 +13334,7 @@ intrinsics: - [uint16x8_t, u16] - [uint32x4_t, u32] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddv{neon_type[0].no}" doc: "Add across vector" @@ -13347,7 +13347,7 @@ intrinsics: types: - [uint32x2_t, u32, i32] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddv{neon_type[0].no}" doc: "Add across vector" @@ -13360,7 +13360,7 @@ intrinsics: types: - [uint64x2_t, u64, i64] compose: - - FnCall: [simd_reduce_add_unordered, [a]] + - FnCall: [simd_reduce_add_ordered, [a, 0]] - name: "vaddlv{neon_type[0].no}" doc: "Signed Add Long across Vector" From 25376c8498494da1ac1e6c707aed3a71fa799347 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sun, 14 Dec 2025 18:51:52 +0800 Subject: [PATCH 143/489] Fix invalid logic op for replace_let_with_if_let Example --- ```rust fn main() { $0let x = true && false; } ``` **Before this PR** ```rust fn main() { if let x = true { } } ``` **After this PR** ```rust fn main() { if let x = (true && false) { } } ``` --- .../src/handlers/replace_let_with_if_let.rs | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_let_with_if_let.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_let_with_if_let.rs index 90f4ff7ad251..b95e9b52b053 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_let_with_if_let.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_let_with_if_let.rs @@ -60,11 +60,13 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext<'_> } } }; + let init_expr = + if let_expr_needs_paren(&init) { make.expr_paren(init).into() } else { init }; let block = make.block_expr([], None); block.indent(IndentLevel::from_node(let_stmt.syntax())); let if_expr = make.expr_if( - make.expr_let(pat, init).into(), + make.expr_let(pat, init_expr).into(), block, let_stmt .let_else() @@ -79,6 +81,16 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext<'_> ) } +fn let_expr_needs_paren(expr: &ast::Expr) -> bool { + let fake_expr_let = + ast::make::expr_let(ast::make::tuple_pat(None).into(), ast::make::ext::expr_unit()); + let Some(fake_expr) = fake_expr_let.expr() else { + stdx::never!(); + return false; + }; + expr.needs_parens_in_place_of(fake_expr_let.syntax(), fake_expr.syntax()) +} + #[cfg(test)] mod tests { use crate::tests::check_assist; @@ -107,6 +119,42 @@ fn main() { ) } + #[test] + fn replace_let_logic_and() { + check_assist( + replace_let_with_if_let, + r" +fn main() { + $0let x = true && false; +} + ", + r" +fn main() { + if let x = (true && false) { + } +} + ", + ) + } + + #[test] + fn replace_let_logic_or() { + check_assist( + replace_let_with_if_let, + r" +fn main() { + $0let x = true || false; +} + ", + r" +fn main() { + if let x = (true || false) { + } +} + ", + ) + } + #[test] fn replace_let_else() { check_assist( From 4748c5372077eb7ce4fc080769f974a5ea222de9 Mon Sep 17 00:00:00 2001 From: Opstic <46141527+opstic@users.noreply.github.com> Date: Sun, 14 Dec 2025 05:53:13 -0500 Subject: [PATCH 144/489] Add `llvm.x86.vcvtps2ph.128` (#1613) * Add `llvm.x86.vcvtps2ph.128` * `cargo fmt` * Test `_mm_cvtps_ph` --- example/std_example.rs | 18 ++++++++++++++++++ src/intrinsics/llvm_x86.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index c569ef0ef829..33db75f0943a 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -259,6 +259,9 @@ unsafe fn test_simd() { test_mm_cvttps_epi32(); test_mm_cvtsi128_si64(); + #[cfg(not(jit))] + test_mm_cvtps_ph(); + test_mm_extract_epi8(); test_mm_insert_epi16(); test_mm_shuffle_epi8(); @@ -558,6 +561,21 @@ unsafe fn test_mm_cvttps_epi32() { } } +#[cfg(target_arch = "x86_64")] +#[target_feature(enable = "f16c")] +#[cfg(not(jit))] +unsafe fn test_mm_cvtps_ph() { + const F16_ONE: i16 = 0x3c00; + const F16_TWO: i16 = 0x4000; + const F16_THREE: i16 = 0x4200; + const F16_FOUR: i16 = 0x4400; + + let a = _mm_set_ps(1.0, 2.0, 3.0, 4.0); + let r = _mm_cvtps_ph::<_MM_FROUND_CUR_DIRECTION>(a); + let e = _mm_set_epi16(0, 0, 0, 0, F16_ONE, F16_TWO, F16_THREE, F16_FOUR); + assert_eq_m128i(r, e); +} + fn test_checked_mul() { let u: Option = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index 37fbe4be1b0f..61f48fa97743 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -1313,6 +1313,35 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( ret.write_cvalue_transmute(fx, res); } + "llvm.x86.vcvtps2ph.128" => { + // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_cvtps_ph + intrinsic_args!(fx, args => (a, _imm8); intrinsic); + let a = a.load_scalar(fx); + + let imm8 = + if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[1].node) { + imm8 + } else { + fx.tcx + .dcx() + .span_fatal(span, "Index argument for `_mm_cvtps_ph` is not a constant"); + }; + + let imm8 = imm8.to_u32(); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String(format!("vcvtps2ph xmm0, xmm0, {imm8}").into())], + &[CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), + _late: true, + in_value: a, + out_place: Some(ret), + }], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + _ => { fx.tcx .dcx() From 230e91d2f6a6cb495bff8db9bbfc1530c97294d5 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 14 Dec 2025 13:29:59 +0100 Subject: [PATCH 145/489] Prevent double encoding when the filename wasn't remapped at all This is done by making the `local` part of `RealFileName` none. This works because `maybe_remapped` is equal to `local` when no remapping happened. --- compiler/rustc_span/src/lib.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 49b2e0c1ff1a..63c51164761d 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -370,7 +370,11 @@ impl RealFileName { /// /// May not exists if the filename was imported from another crate. pub fn local_path(&self) -> Option<&Path> { - self.local.as_ref().map(|lp| lp.name.as_ref()) + if self.was_not_remapped() { + Some(&self.maybe_remapped.name) + } else { + self.local.as_ref().map(|lp| lp.name.as_ref()) + } } /// Returns the path suitable for reading from the file system on the local host, @@ -378,7 +382,11 @@ impl RealFileName { /// /// May not exists if the filename was imported from another crate. pub fn into_local_path(self) -> Option { - self.local.map(|lp| lp.name) + if self.was_not_remapped() { + Some(self.maybe_remapped.name) + } else { + self.local.map(|lp| lp.name) + } } /// Returns whenever the filename was remapped. @@ -386,6 +394,18 @@ impl RealFileName { !self.scopes.is_empty() } + /// Returns whenever the filename was fully remapped. + #[inline] + fn was_fully_remapped(&self) -> bool { + self.scopes.is_all() + } + + /// Returns whenever the filename was not remapped. + #[inline] + fn was_not_remapped(&self) -> bool { + self.scopes.is_empty() + } + /// Returns an empty `RealFileName` /// /// Useful as the working directory input to `SourceMap::to_real_filename`. @@ -420,9 +440,14 @@ impl RealFileName { /// Update the filename for encoding in the crate metadata. /// /// Currently it's about removing the local part when the filename - /// is fully remapped. + /// is either fully remapped or not remapped at all. + #[inline] pub fn update_for_crate_metadata(&mut self) { - if self.scopes.is_all() { + if self.was_fully_remapped() || self.was_not_remapped() { + // NOTE: This works because when the filename is fully + // remapped, we don't care about the `local` part, + // and when the filename is not remapped at all, + // `maybe_remapped` and `local` are equal. self.local = None; } } From 7227bfed0847703f65e0628f60a860f5cad09594 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 14 Dec 2025 13:30:25 +0100 Subject: [PATCH 146/489] Prefer using `was_fully_remapped` helper function --- compiler/rustc_span/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 63c51164761d..53363fae933e 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -313,7 +313,7 @@ impl Hash for RealFileName { // remapped path if that exists. This is because remapped paths to // sysroot crates (/rust/$hash or /rust/$version) remain stable even // if the corresponding local path changes. - if !self.scopes.is_all() { + if !self.was_fully_remapped() { self.local.hash(state); } self.maybe_remapped.hash(state); From c877536864fc011dfcbcbde60f5d21698c6eee71 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 14 Dec 2025 13:32:16 +0100 Subject: [PATCH 147/489] Add `#[inline]` to a bunch of filename related functions --- compiler/rustc_span/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 53363fae933e..630656f9ec5c 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -241,12 +241,14 @@ bitflags::bitflags! { } impl Encodable for RemapPathScopeComponents { + #[inline] fn encode(&self, s: &mut E) { s.emit_u8(self.bits()); } } impl Decodable for RemapPathScopeComponents { + #[inline] fn decode(s: &mut D) -> RemapPathScopeComponents { RemapPathScopeComponents::from_bits(s.read_u8()) .expect("invalid bits for RemapPathScopeComponents") @@ -308,6 +310,7 @@ struct InnerRealFileName { } impl Hash for RealFileName { + #[inline] fn hash(&self, state: &mut H) { // To prevent #70924 from happening again we should only hash the // remapped path if that exists. This is because remapped paths to @@ -327,6 +330,7 @@ impl RealFileName { /// ## Panic /// /// Only one scope components can be given to this function. + #[inline] pub fn path(&self, scope: RemapPathScopeComponents) -> &Path { assert!( scope.bits().count_ones() == 1, @@ -351,6 +355,7 @@ impl RealFileName { /// ## Panic /// /// Only one scope components can be given to this function. + #[inline] pub fn embeddable_name(&self, scope: RemapPathScopeComponents) -> (&Path, &Path) { assert!( scope.bits().count_ones() == 1, @@ -369,6 +374,7 @@ impl RealFileName { /// if this information exists. /// /// May not exists if the filename was imported from another crate. + #[inline] pub fn local_path(&self) -> Option<&Path> { if self.was_not_remapped() { Some(&self.maybe_remapped.name) @@ -381,6 +387,7 @@ impl RealFileName { /// if this information exists. /// /// May not exists if the filename was imported from another crate. + #[inline] pub fn into_local_path(self) -> Option { if self.was_not_remapped() { Some(self.maybe_remapped.name) @@ -390,6 +397,7 @@ impl RealFileName { } /// Returns whenever the filename was remapped. + #[inline] pub(crate) fn was_remapped(&self) -> bool { !self.scopes.is_empty() } @@ -409,6 +417,7 @@ impl RealFileName { /// Returns an empty `RealFileName` /// /// Useful as the working directory input to `SourceMap::to_real_filename`. + #[inline] pub fn empty() -> RealFileName { RealFileName { local: Some(InnerRealFileName { @@ -554,6 +563,7 @@ impl FileName { /// if this information exists. /// /// Avoid embedding this in build artifacts. Prefer using the `display` method. + #[inline] pub fn prefer_remapped_unconditionally(&self) -> FileNameDisplay<'_> { FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Remapped } } @@ -562,16 +572,19 @@ impl FileName { /// if this information exists. /// /// Avoid embedding this in build artifacts. Prefer using the `display` method. + #[inline] pub fn prefer_local_unconditionally(&self) -> FileNameDisplay<'_> { FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Local } } /// Returns a short (either the filename or an empty string). + #[inline] pub fn short(&self) -> FileNameDisplay<'_> { FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Short } } /// Returns a `Display`-able path for the given scope. + #[inline] pub fn display(&self, scope: RemapPathScopeComponents) -> FileNameDisplay<'_> { FileNameDisplay { inner: self, display_pref: FileNameDisplayPreference::Scope(scope) } } From 3d83b9597dec0b364a81c5566fd8bafece16b473 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 20 Jun 2025 13:14:31 +0000 Subject: [PATCH 148/489] Split Map::register. --- .../rustc_mir_dataflow/src/value_analysis.rs | 257 ++++++++++-------- tests/coverage/closure.cov-map | 28 +- 2 files changed, 156 insertions(+), 129 deletions(-) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index daf304c1bf9d..9342128de8e9 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -370,21 +370,20 @@ impl<'tcx> Map<'tcx> { inner_values: IndexVec::new(), inner_values_buffer: Vec::new(), }; - let exclude = excluded_locals(body); - map.register(tcx, body, exclude, value_limit); + map.register_locals(tcx, body); + map.collect_places(tcx, body); + map.propagate_assignments(tcx, body); + map.create_values(tcx, body, value_limit); + map.trim_useless_places(); debug!("registered {} places ({} nodes in total)", map.value_count, map.places.len()); map } /// Register all non-excluded places that have scalar layout. #[tracing::instrument(level = "trace", skip(self, tcx, body))] - fn register( - &mut self, - tcx: TyCtxt<'tcx>, - body: &Body<'tcx>, - exclude: DenseBitSet, - value_limit: Option, - ) { + fn register_locals(&mut self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { + let exclude = excluded_locals(body); + // Start by constructing the places for each bare local. for (local, decl) in body.local_decls.iter_enumerated() { if exclude.contains(local) { @@ -399,23 +398,79 @@ impl<'tcx> Map<'tcx> { let place = self.places.push(PlaceInfo::new(decl.ty, None)); self.locals[local] = Some(place); } + } - // Collect syntactic places and assignments between them. - let mut collector = - PlaceCollector { tcx, body, map: self, assignments: Default::default() }; + /// Collect syntactic places from body, and create `PlaceIndex` for them. + #[tracing::instrument(level = "trace", skip(self, tcx, body))] + fn collect_places(&mut self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { + let mut collector = PlaceCollector { tcx, body, map: self }; collector.visit_body(body); - let PlaceCollector { mut assignments, .. } = collector; + } - // Just collecting syntactic places is not enough. We may need to propagate this pattern: - // _1 = (const 5u32, const 13i64); - // _2 = _1; - // _3 = (_2.0 as u32); - // - // `_1.0` does not appear, but we still need to track it. This is achieved by propagating - // projections from assignments. We recorded an assignment between `_2` and `_1`, so we - // want `_1` and `_2` to have the same sub-places. - // - // This is what this fixpoint loop does. While we are still creating places, run through + /// Just collecting syntactic places is not enough. We may need to propagate this pattern: + /// _1 = (const 5u32, const 13i64); + /// _2 = _1; + /// _3 = (_2.0 as u32); + /// + /// `_1.0` does not appear, but we still need to track it. This is achieved by propagating + /// projections from assignments. We recorded an assignment between `_2` and `_1`, so we + /// want `_1` and `_2` to have the same sub-places. + #[tracing::instrument(level = "trace", skip(self, tcx, body))] + fn propagate_assignments(&mut self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { + // Collect syntactic places and assignments between them. + let mut assignments = FxIndexSet::default(); + + for bbdata in body.basic_blocks.iter() { + for stmt in bbdata.statements.iter() { + let Some((lhs, rhs)) = stmt.kind.as_assign() else { continue }; + match rhs { + Rvalue::Use(Operand::Move(rhs) | Operand::Copy(rhs)) + | Rvalue::CopyForDeref(rhs) => { + let Some(lhs) = self.register_place(tcx, body, *lhs) else { continue }; + let Some(rhs) = self.register_place(tcx, body, *rhs) else { continue }; + assignments.insert((lhs, rhs)); + } + Rvalue::Aggregate(kind, fields) => { + let Some(mut lhs) = self.register_place(tcx, body, *lhs) else { continue }; + match **kind { + // Do not propagate unions. + AggregateKind::Adt(_, _, _, _, Some(_)) => continue, + AggregateKind::Adt(_, variant, _, _, None) => { + let ty = self.places[lhs].ty; + if ty.is_enum() { + lhs = self.register_place_index( + ty, + lhs, + TrackElem::Variant(variant), + ); + } + } + AggregateKind::RawPtr(..) + | AggregateKind::Array(_) + | AggregateKind::Tuple + | AggregateKind::Closure(..) + | AggregateKind::Coroutine(..) + | AggregateKind::CoroutineClosure(..) => {} + } + for (index, field) in fields.iter_enumerated() { + if let Some(rhs) = field.place() + && let Some(rhs) = self.register_place(tcx, body, rhs) + { + let lhs = self.register_place_index( + self.places[rhs].ty, + lhs, + TrackElem::Field(index), + ); + assignments.insert((lhs, rhs)); + } + } + } + _ => {} + } + } + } + + // This is a fixpoint loop does. While we are still creating places, run through // all the assignments, and register places for children. let mut num_places = 0; while num_places < self.places.len() { @@ -428,8 +483,11 @@ impl<'tcx> Map<'tcx> { let mut child = self.places[lhs].first_child; while let Some(lhs_child) = child { let PlaceInfo { ty, proj_elem, next_sibling, .. } = self.places[lhs_child]; - let rhs_child = - self.register_place(ty, rhs, proj_elem.expect("child is not a projection")); + let rhs_child = self.register_place_index( + ty, + rhs, + proj_elem.expect("child is not a projection"), + ); assignments.insert((lhs_child, rhs_child)); child = next_sibling; } @@ -438,16 +496,21 @@ impl<'tcx> Map<'tcx> { let mut child = self.places[rhs].first_child; while let Some(rhs_child) = child { let PlaceInfo { ty, proj_elem, next_sibling, .. } = self.places[rhs_child]; - let lhs_child = - self.register_place(ty, lhs, proj_elem.expect("child is not a projection")); + let lhs_child = self.register_place_index( + ty, + lhs, + proj_elem.expect("child is not a projection"), + ); assignments.insert((lhs_child, rhs_child)); child = next_sibling; } } } - drop(assignments); + } - // Create values for places whose type have scalar layout. + /// Create values for places whose type have scalar layout. + #[tracing::instrument(level = "trace", skip(self, tcx, body))] + fn create_values(&mut self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, value_limit: Option) { let typing_env = body.typing_env(tcx); for place_info in self.places.iter_mut() { // The user requires a bound on the number of created values. @@ -481,8 +544,11 @@ impl<'tcx> Map<'tcx> { self.cache_preorder_invoke(place); } } + } - // Trim useless places. + /// Trim useless places. + #[tracing::instrument(level = "trace", skip(self))] + fn trim_useless_places(&mut self) { for opt_place in self.locals.iter_mut() { if let Some(place) = *opt_place && self.inner_values[place].is_empty() @@ -495,7 +561,12 @@ impl<'tcx> Map<'tcx> { } #[tracing::instrument(level = "trace", skip(self), ret)] - fn register_place(&mut self, ty: Ty<'tcx>, base: PlaceIndex, elem: TrackElem) -> PlaceIndex { + fn register_place_index( + &mut self, + ty: Ty<'tcx>, + base: PlaceIndex, + elem: TrackElem, + ) -> PlaceIndex { *self.projections.entry((base, elem)).or_insert_with(|| { let next = self.places.push(PlaceInfo::new(ty, Some(elem))); self.places[next].next_sibling = self.places[base].first_child; @@ -504,6 +575,46 @@ impl<'tcx> Map<'tcx> { }) } + #[tracing::instrument(level = "trace", skip(self, tcx, body))] + fn register_place( + &mut self, + tcx: TyCtxt<'tcx>, + body: &Body<'tcx>, + place: Place<'tcx>, + ) -> Option { + // Create a place for this projection. + let mut place_index = self.locals[place.local]?; + let mut ty = PlaceTy::from_ty(body.local_decls[place.local].ty); + tracing::trace!(?place_index, ?ty); + + if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.ty.kind() + && let ty::Slice(..) = ref_ty.kind() + { + self.register_place_index(tcx.types.usize, place_index, TrackElem::DerefLen); + } else if ty.ty.is_enum() { + let discriminant_ty = ty.ty.discriminant_ty(tcx); + self.register_place_index(discriminant_ty, place_index, TrackElem::Discriminant); + } + + for proj in place.projection { + let track_elem = proj.try_into().ok()?; + ty = ty.projection_ty(tcx, proj); + place_index = self.register_place_index(ty.ty, place_index, track_elem); + tracing::trace!(?proj, ?place_index, ?ty); + + if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.ty.kind() + && let ty::Slice(..) = ref_ty.kind() + { + self.register_place_index(tcx.types.usize, place_index, TrackElem::DerefLen); + } else if ty.ty.is_enum() { + let discriminant_ty = ty.ty.discriminant_ty(tcx); + self.register_place_index(discriminant_ty, place_index, TrackElem::Discriminant); + } + } + + Some(place_index) + } + /// Precompute the list of values inside `root` and store it inside /// as a slice within `inner_values_buffer`. fn cache_preorder_invoke(&mut self, root: PlaceIndex) { @@ -528,44 +639,6 @@ struct PlaceCollector<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, map: &'a mut Map<'tcx>, - assignments: FxIndexSet<(PlaceIndex, PlaceIndex)>, -} - -impl<'tcx> PlaceCollector<'_, 'tcx> { - #[tracing::instrument(level = "trace", skip(self))] - fn register_place(&mut self, place: Place<'tcx>) -> Option { - // Create a place for this projection. - let mut place_index = self.map.locals[place.local]?; - let mut ty = PlaceTy::from_ty(self.body.local_decls[place.local].ty); - tracing::trace!(?place_index, ?ty); - - if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.ty.kind() - && let ty::Slice(..) = ref_ty.kind() - { - self.map.register_place(self.tcx.types.usize, place_index, TrackElem::DerefLen); - } else if ty.ty.is_enum() { - let discriminant_ty = ty.ty.discriminant_ty(self.tcx); - self.map.register_place(discriminant_ty, place_index, TrackElem::Discriminant); - } - - for proj in place.projection { - let track_elem = proj.try_into().ok()?; - ty = ty.projection_ty(self.tcx, proj); - place_index = self.map.register_place(ty.ty, place_index, track_elem); - tracing::trace!(?proj, ?place_index, ?ty); - - if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.ty.kind() - && let ty::Slice(..) = ref_ty.kind() - { - self.map.register_place(self.tcx.types.usize, place_index, TrackElem::DerefLen); - } else if ty.ty.is_enum() { - let discriminant_ty = ty.ty.discriminant_ty(self.tcx); - self.map.register_place(discriminant_ty, place_index, TrackElem::Discriminant); - } - } - - Some(place_index) - } } impl<'tcx> Visitor<'tcx> for PlaceCollector<'_, 'tcx> { @@ -575,51 +648,7 @@ impl<'tcx> Visitor<'tcx> for PlaceCollector<'_, 'tcx> { return; } - self.register_place(*place); - } - - fn visit_assign(&mut self, lhs: &Place<'tcx>, rhs: &Rvalue<'tcx>, location: Location) { - self.super_assign(lhs, rhs, location); - - match rhs { - Rvalue::Use(Operand::Move(rhs) | Operand::Copy(rhs)) | Rvalue::CopyForDeref(rhs) => { - let Some(lhs) = self.register_place(*lhs) else { return }; - let Some(rhs) = self.register_place(*rhs) else { return }; - self.assignments.insert((lhs, rhs)); - } - Rvalue::Aggregate(kind, fields) => { - let Some(mut lhs) = self.register_place(*lhs) else { return }; - match **kind { - // Do not propagate unions. - AggregateKind::Adt(_, _, _, _, Some(_)) => return, - AggregateKind::Adt(_, variant, _, _, None) => { - let ty = self.map.places[lhs].ty; - if ty.is_enum() { - lhs = self.map.register_place(ty, lhs, TrackElem::Variant(variant)); - } - } - AggregateKind::RawPtr(..) - | AggregateKind::Array(_) - | AggregateKind::Tuple - | AggregateKind::Closure(..) - | AggregateKind::Coroutine(..) - | AggregateKind::CoroutineClosure(..) => {} - } - for (index, field) in fields.iter_enumerated() { - if let Some(rhs) = field.place() - && let Some(rhs) = self.register_place(rhs) - { - let lhs = self.map.register_place( - self.map.places[rhs].ty, - lhs, - TrackElem::Field(index), - ); - self.assignments.insert((lhs, rhs)); - } - } - } - _ => {} - } + self.map.register_place(self.tcx, self.body, *place); } } diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index d713145d8612..d1d8cb4c418c 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -186,24 +186,22 @@ Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) Highest counter ID seen: c1 -Function name: closure::main::{closure#18} -Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 19, 0d, 00, 0e, 01, 01, 15, 00, 22, 01, 00, 25, 00, 26, 01, 01, 14, 00, 1c, 05, 00, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 00, 1f, 01, 00, 20, 00, 28, 01, 01, 0d, 00, 0e] +Function name: closure::main::{closure#18} (unused) +Raw bytes (49): 0x[01, 01, 00, 09, 00, 19, 0d, 00, 0e, 00, 01, 15, 00, 22, 00, 00, 25, 00, 26, 00, 01, 14, 00, 1c, 00, 00, 1d, 02, 12, 00, 02, 11, 00, 12, 00, 01, 11, 00, 1f, 00, 00, 20, 00, 28, 00, 01, 0d, 00, 0e] Number of files: 1 - file 0 => $DIR/closure.rs -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of expressions: 0 Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 25, 13) to (start + 0, 14) -- Code(Counter(0)) at (prev + 1, 21) to (start + 0, 34) -- Code(Counter(0)) at (prev + 0, 37) to (start + 0, 38) -- Code(Counter(0)) at (prev + 1, 20) to (start + 0, 28) -- Code(Counter(1)) at (prev + 0, 29) to (start + 2, 18) -- Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 18) - = (c0 - c1) -- Code(Counter(0)) at (prev + 1, 17) to (start + 0, 31) -- Code(Counter(0)) at (prev + 0, 32) to (start + 0, 40) -- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) -Highest counter ID seen: c1 +- Code(Zero) at (prev + 25, 13) to (start + 0, 14) +- Code(Zero) at (prev + 1, 21) to (start + 0, 34) +- Code(Zero) at (prev + 0, 37) to (start + 0, 38) +- Code(Zero) at (prev + 1, 20) to (start + 0, 28) +- Code(Zero) at (prev + 0, 29) to (start + 2, 18) +- Code(Zero) at (prev + 2, 17) to (start + 0, 18) +- Code(Zero) at (prev + 1, 17) to (start + 0, 31) +- Code(Zero) at (prev + 0, 32) to (start + 0, 40) +- Code(Zero) at (prev + 1, 13) to (start + 0, 14) +Highest counter ID seen: (none) Function name: closure::main::{closure#19} Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 43, 0d, 00, 0e, 01, 01, 15, 00, 22, 01, 00, 25, 00, 26, 01, 01, 14, 00, 1c, 05, 00, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 00, 1f, 01, 00, 20, 00, 28, 01, 01, 0d, 00, 0e] From 051dd12f9ec2b118302b4e06d6401279bef2a9e9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 20 Jun 2025 17:41:52 +0000 Subject: [PATCH 149/489] Pre-allocate places vectors. --- compiler/rustc_mir_dataflow/src/value_analysis.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 9342128de8e9..515fe41d8177 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -362,12 +362,13 @@ impl<'tcx> Map<'tcx> { /// chosen is an implementation detail and may not be relied upon (other than that their type /// are scalars). pub fn new(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, value_limit: Option) -> Self { + let capacity = 4 * body.local_decls.len() + value_limit.unwrap_or(body.local_decls.len()); let mut map = Self { locals: IndexVec::from_elem(None, &body.local_decls), projections: FxHashMap::default(), - places: IndexVec::new(), + places: IndexVec::with_capacity(capacity), value_count: 0, - inner_values: IndexVec::new(), + inner_values: IndexVec::with_capacity(capacity), inner_values_buffer: Vec::new(), }; map.register_locals(tcx, body); From 9415102fb42a94eca725e0b9a11e825bf7a4c3d2 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 22 Jun 2025 13:51:39 +0000 Subject: [PATCH 150/489] Create place and value indices on-demand. --- .../rustc_mir_dataflow/src/value_analysis.rs | 186 +++++++++++--- .../src/dataflow_const_prop.rs | 6 +- .../rustc_mir_transform/src/jump_threading.rs | 88 ++++--- tests/coverage/closure.cov-map | 28 +-- tests/coverage/try_error_result.cov-map | 231 +++++++----------- 5 files changed, 315 insertions(+), 224 deletions(-) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 515fe41d8177..ac94ee5c8104 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -1,3 +1,4 @@ +use std::assert_matches::debug_assert_matches; use std::fmt::{Debug, Formatter}; use std::ops::Range; @@ -350,32 +351,47 @@ pub struct Map<'tcx> { projections: FxHashMap<(PlaceIndex, TrackElem), PlaceIndex>, places: IndexVec>, value_count: usize, + mode: PlaceCollectionMode, // The Range corresponds to a slice into `inner_values_buffer`. inner_values: IndexVec>, inner_values_buffer: Vec, } +#[derive(Copy, Clone, Debug)] +pub enum PlaceCollectionMode { + Full { value_limit: Option }, + OnDemand, +} + impl<'tcx> Map<'tcx> { /// Returns a map that only tracks places whose type has scalar layout. /// /// This is currently the only way to create a [`Map`]. The way in which the tracked places are /// chosen is an implementation detail and may not be relied upon (other than that their type /// are scalars). - pub fn new(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, value_limit: Option) -> Self { - let capacity = 4 * body.local_decls.len() + value_limit.unwrap_or(body.local_decls.len()); + #[tracing::instrument(level = "trace", skip(tcx, body))] + pub fn new(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, mode: PlaceCollectionMode) -> Self { + tracing::trace!(def_id=?body.source.def_id()); + let capacity = 4 * body.local_decls.len(); let mut map = Self { locals: IndexVec::from_elem(None, &body.local_decls), projections: FxHashMap::default(), places: IndexVec::with_capacity(capacity), value_count: 0, - inner_values: IndexVec::with_capacity(capacity), + mode, + inner_values: IndexVec::new(), inner_values_buffer: Vec::new(), }; map.register_locals(tcx, body); - map.collect_places(tcx, body); - map.propagate_assignments(tcx, body); - map.create_values(tcx, body, value_limit); - map.trim_useless_places(); + match mode { + PlaceCollectionMode::Full { value_limit } => { + map.collect_places(tcx, body); + map.propagate_assignments(tcx, body); + map.create_values(tcx, body, value_limit); + map.trim_useless_places(); + } + PlaceCollectionMode::OnDemand => {} + } debug!("registered {} places ({} nodes in total)", map.value_count, map.places.len()); map } @@ -427,12 +443,18 @@ impl<'tcx> Map<'tcx> { match rhs { Rvalue::Use(Operand::Move(rhs) | Operand::Copy(rhs)) | Rvalue::CopyForDeref(rhs) => { - let Some(lhs) = self.register_place(tcx, body, *lhs) else { continue }; - let Some(rhs) = self.register_place(tcx, body, *rhs) else { continue }; + let Some(lhs) = self.register_place_and_discr(tcx, body, *lhs) else { + continue; + }; + let Some(rhs) = self.register_place_and_discr(tcx, body, *rhs) else { + continue; + }; assignments.insert((lhs, rhs)); } Rvalue::Aggregate(kind, fields) => { - let Some(mut lhs) = self.register_place(tcx, body, *lhs) else { continue }; + let Some(mut lhs) = self.register_place_and_discr(tcx, body, *lhs) else { + continue; + }; match **kind { // Do not propagate unions. AggregateKind::Adt(_, _, _, _, Some(_)) => continue, @@ -455,7 +477,7 @@ impl<'tcx> Map<'tcx> { } for (index, field) in fields.iter_enumerated() { if let Some(rhs) = field.place() - && let Some(rhs) = self.register_place(tcx, body, rhs) + && let Some(rhs) = self.register_place_and_discr(tcx, body, rhs) { let lhs = self.register_place_index( self.places[rhs].ty, @@ -512,6 +534,7 @@ impl<'tcx> Map<'tcx> { /// Create values for places whose type have scalar layout. #[tracing::instrument(level = "trace", skip(self, tcx, body))] fn create_values(&mut self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, value_limit: Option) { + debug_assert_matches!(self.mode, PlaceCollectionMode::Full { .. }); let typing_env = body.typing_env(tcx); for place_info in self.places.iter_mut() { // The user requires a bound on the number of created values. @@ -550,6 +573,7 @@ impl<'tcx> Map<'tcx> { /// Trim useless places. #[tracing::instrument(level = "trace", skip(self))] fn trim_useless_places(&mut self) { + debug_assert_matches!(self.mode, PlaceCollectionMode::Full { .. }); for opt_place in self.locals.iter_mut() { if let Some(place) = *opt_place && self.inner_values[place].is_empty() @@ -562,7 +586,7 @@ impl<'tcx> Map<'tcx> { } #[tracing::instrument(level = "trace", skip(self), ret)] - fn register_place_index( + pub fn register_place_index( &mut self, ty: Ty<'tcx>, base: PlaceIndex, @@ -576,49 +600,124 @@ impl<'tcx> Map<'tcx> { }) } - #[tracing::instrument(level = "trace", skip(self, tcx, body))] - fn register_place( + #[tracing::instrument(level = "trace", skip(self, tcx, body), ret)] + pub fn register_place( &mut self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>, place: Place<'tcx>, + tail: Option, ) -> Option { // Create a place for this projection. let mut place_index = self.locals[place.local]?; let mut ty = PlaceTy::from_ty(body.local_decls[place.local].ty); tracing::trace!(?place_index, ?ty); - if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.ty.kind() - && let ty::Slice(..) = ref_ty.kind() - { - self.register_place_index(tcx.types.usize, place_index, TrackElem::DerefLen); - } else if ty.ty.is_enum() { - let discriminant_ty = ty.ty.discriminant_ty(tcx); - self.register_place_index(discriminant_ty, place_index, TrackElem::Discriminant); - } - for proj in place.projection { let track_elem = proj.try_into().ok()?; ty = ty.projection_ty(tcx, proj); place_index = self.register_place_index(ty.ty, place_index, track_elem); tracing::trace!(?proj, ?place_index, ?ty); + } - if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.ty.kind() - && let ty::Slice(..) = ref_ty.kind() - { - self.register_place_index(tcx.types.usize, place_index, TrackElem::DerefLen); - } else if ty.ty.is_enum() { - let discriminant_ty = ty.ty.discriminant_ty(tcx); - self.register_place_index(discriminant_ty, place_index, TrackElem::Discriminant); - } + if let Some(tail) = tail { + let ty = match tail { + TrackElem::Discriminant => ty.ty.discriminant_ty(tcx), + TrackElem::Variant(..) | TrackElem::Field(..) => todo!(), + TrackElem::DerefLen => tcx.types.usize, + }; + place_index = self.register_place_index(ty, place_index, tail); } Some(place_index) } + #[tracing::instrument(level = "trace", skip(self, tcx, body), ret)] + fn register_place_and_discr( + &mut self, + tcx: TyCtxt<'tcx>, + body: &Body<'tcx>, + place: Place<'tcx>, + ) -> Option { + let place = self.register_place(tcx, body, place, None)?; + let ty = self.places[place].ty; + + if let ty::Ref(_, ref_ty, _) | ty::RawPtr(ref_ty, _) = ty.kind() + && let ty::Slice(..) = ref_ty.kind() + { + self.register_place_index(tcx.types.usize, place, TrackElem::DerefLen); + } else if ty.is_enum() { + let discriminant_ty = ty.discriminant_ty(tcx); + self.register_place_index(discriminant_ty, place, TrackElem::Discriminant); + } + + Some(place) + } + + #[tracing::instrument(level = "trace", skip(self, tcx, typing_env), ret)] + pub fn register_value( + &mut self, + tcx: TyCtxt<'tcx>, + typing_env: ty::TypingEnv<'tcx>, + place: PlaceIndex, + ) -> Option { + let place_info = &mut self.places[place]; + if let Some(value) = place_info.value_index { + return Some(value); + } + + if let Ok(ty) = tcx.try_normalize_erasing_regions(typing_env, place_info.ty) { + place_info.ty = ty; + } + + // Allocate a value slot if it doesn't have one, and the user requested one. + if let Ok(layout) = tcx.layout_of(typing_env.as_query_input(place_info.ty)) + && layout.backend_repr.is_scalar() + { + place_info.value_index = Some(self.value_count.into()); + self.value_count += 1; + } + + place_info.value_index + } + + #[tracing::instrument(level = "trace", skip(self, f))] + pub fn register_copy_tree( + &mut self, + // Tree to copy. + source: PlaceIndex, + // Tree to build. + target: PlaceIndex, + f: &mut impl FnMut(ValueIndex, ValueIndex), + ) { + if let Some(source_value) = self.places[source].value_index { + let target_value = *self.places[target].value_index.get_or_insert_with(|| { + let value_index = self.value_count.into(); + self.value_count += 1; + value_index + }); + f(source_value, target_value) + } + + // Iterate over `source` children and recurse. + let mut source_child_iter = self.places[source].first_child; + while let Some(source_child) = source_child_iter { + source_child_iter = self.places[source_child].next_sibling; + + // Try to find corresponding child and recurse. Reasoning is similar as above. + let source_info = &self.places[source_child]; + let source_ty = source_info.ty; + let source_elem = source_info.proj_elem.unwrap(); + let target_child = self.register_place_index(source_ty, target, source_elem); + self.register_copy_tree(source_child, target_child, f); + } + } + /// Precompute the list of values inside `root` and store it inside /// as a slice within `inner_values_buffer`. + #[tracing::instrument(level = "trace", skip(self))] fn cache_preorder_invoke(&mut self, root: PlaceIndex) { + debug_assert_matches!(self.mode, PlaceCollectionMode::Full { .. }); let start = self.inner_values_buffer.len(); if let Some(vi) = self.places[root].value_index { self.inner_values_buffer.push(vi); @@ -649,7 +748,7 @@ impl<'tcx> Visitor<'tcx> for PlaceCollector<'_, 'tcx> { return; } - self.map.register_place(self.tcx, self.body, *place); + self.map.register_place_and_discr(self.tcx, self.body, *place); } } @@ -724,6 +823,7 @@ impl<'tcx> Map<'tcx> { /// /// `tail_elem` allows to support discriminants that are not a place in MIR, but that we track /// as such. + #[tracing::instrument(level = "trace", skip(self, f))] pub fn for_each_aliasing_place( &self, place: PlaceRef<'_>, @@ -758,6 +858,7 @@ impl<'tcx> Map<'tcx> { } /// Invoke the given function on all the descendants of the given place, except one branch. + #[tracing::instrument(level = "trace", skip(self, f))] fn for_each_variant_sibling( &self, parent: PlaceIndex, @@ -784,9 +885,22 @@ impl<'tcx> Map<'tcx> { } /// Invoke a function on each value in the given place and all descendants. + #[tracing::instrument(level = "trace", skip(self, f))] fn for_each_value_inside(&self, root: PlaceIndex, f: &mut impl FnMut(ValueIndex)) { - for &v in self.values_inside(root) { - f(v) + if let Some(range) = self.inner_values.get(root) { + // Optimized path: we have cached the inner values. + let values = &self.inner_values_buffer[range.clone()]; + for &v in values { + f(v) + } + } else { + if let Some(root) = self.places[root].value_index { + f(root) + } + + for child in self.children(root) { + self.for_each_value_inside(child, f); + } } } @@ -799,7 +913,9 @@ impl<'tcx> Map<'tcx> { f: &mut impl FnMut(PlaceIndex, &O), ) { // Fast path is there is nothing to do. - if self.inner_values[root].is_empty() { + if let Some(value_range) = self.inner_values.get(root) + && value_range.is_empty() + { return; } diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index bccdd526ab7f..a76a6eaf9660 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_mir_dataflow::fmt::DebugWithContext; use rustc_mir_dataflow::lattice::{FlatSet, HasBottom}; use rustc_mir_dataflow::value_analysis::{ - Map, PlaceIndex, State, TrackElem, ValueOrPlace, debug_with_context, + Map, PlaceCollectionMode, PlaceIndex, State, TrackElem, ValueOrPlace, debug_with_context, }; use rustc_mir_dataflow::{Analysis, ResultsVisitor, visit_reachable_results}; use rustc_span::DUMMY_SP; @@ -55,10 +55,10 @@ impl<'tcx> crate::MirPass<'tcx> for DataflowConstProp { // `O(num_nodes * tracked_places * n)` in terms of time complexity. Since the number of // map nodes is strongly correlated to the number of tracked places, this becomes more or // less `O(n)` if we place a constant limit on the number of tracked places. - let place_limit = if tcx.sess.mir_opt_level() < 4 { Some(PLACE_LIMIT) } else { None }; + let value_limit = if tcx.sess.mir_opt_level() < 4 { Some(PLACE_LIMIT) } else { None }; // Decide which places to track during the analysis. - let map = Map::new(tcx, body, place_limit); + let map = Map::new(tcx, body, PlaceCollectionMode::Full { value_limit }); // Perform the actual dataflow analysis. let const_ = debug_span!("analyze") diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index c021e7d4c3ae..fd777a4c4224 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -62,7 +62,9 @@ use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::*; use rustc_middle::ty::{self, ScalarInt, TyCtxt}; -use rustc_mir_dataflow::value_analysis::{Map, PlaceIndex, TrackElem, ValueIndex}; +use rustc_mir_dataflow::value_analysis::{ + Map, PlaceCollectionMode, PlaceIndex, TrackElem, ValueIndex, +}; use rustc_span::DUMMY_SP; use tracing::{debug, instrument, trace}; @@ -71,7 +73,6 @@ use crate::cost_checker::CostChecker; pub(super) struct JumpThreading; const MAX_COST: u8 = 100; -const MAX_PLACES: usize = 100; impl<'tcx> crate::MirPass<'tcx> for JumpThreading { fn is_enabled(&self, sess: &rustc_session::Session) -> bool { @@ -95,7 +96,7 @@ impl<'tcx> crate::MirPass<'tcx> for JumpThreading { typing_env, ecx: InterpCx::new(tcx, DUMMY_SP, typing_env, DummyMachine), body, - map: Map::new(tcx, body, Some(MAX_PLACES)), + map: Map::new(tcx, body, PlaceCollectionMode::OnDemand), maybe_loop_headers: loops::maybe_loop_headers(body), entry_states: IndexVec::from_elem(ConditionSet::default(), &body.basic_blocks), }; @@ -273,6 +274,19 @@ impl ConditionSet { } impl<'a, 'tcx> TOFinder<'a, 'tcx> { + fn place(&mut self, place: Place<'tcx>, tail: Option) -> Option { + self.map.register_place(self.tcx, self.body, place, tail) + } + + fn value(&mut self, place: PlaceIndex) -> Option { + self.map.register_value(self.tcx, self.typing_env, place) + } + + fn place_value(&mut self, place: Place<'tcx>, tail: Option) -> Option { + let place = self.place(place, tail)?; + self.value(place) + } + /// Construct the condition set for `bb` from the terminator, without executing its effect. #[instrument(level = "trace", skip(self))] fn populate_from_outgoing_edges(&mut self, bb: BasicBlock) -> ConditionSet { @@ -397,7 +411,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { #[instrument(level = "trace", skip(self, state))] fn process_immediate(&mut self, lhs: PlaceIndex, rhs: ImmTy<'tcx>, state: &mut ConditionSet) { - if let Some(lhs) = self.map.value(lhs) + if let Some(lhs) = self.value(lhs) && let Immediate::Scalar(Scalar::Int(int)) = *rhs { state.fulfill_matches(lhs, int) @@ -412,10 +426,6 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { constant: OpTy<'tcx>, state: &mut ConditionSet, ) { - let values_inside = self.map.values_inside(lhs); - if !state.active.iter().any(|&(_, cond)| values_inside.contains(&cond.place)) { - return; - } self.map.for_each_projection_value( lhs, constant, @@ -450,9 +460,13 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { #[instrument(level = "trace", skip(self, state))] fn process_copy(&mut self, lhs: PlaceIndex, rhs: PlaceIndex, state: &mut ConditionSet) { let mut renames = FxHashMap::default(); - self.map.for_each_value_pair(rhs, lhs, &mut |rhs, lhs| { - renames.insert(lhs, rhs); - }); + self.map.register_copy_tree( + lhs, // tree to copy + rhs, // tree to build + &mut |lhs, rhs| { + renames.insert(lhs, rhs); + }, + ); state.for_each_mut(|c| { if let Some(rhs) = renames.get(&c.place) { c.place = *rhs @@ -474,7 +488,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { } // Transfer the conditions on the copied rhs. Operand::Move(rhs) | Operand::Copy(rhs) => { - let Some(rhs) = self.map.find(rhs.as_ref()) else { return }; + let Some(rhs) = self.place(*rhs, None) else { return }; self.process_copy(lhs, rhs, state) } } @@ -487,12 +501,12 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { rvalue: &Rvalue<'tcx>, state: &mut ConditionSet, ) { - let Some(lhs) = self.map.find(lhs_place.as_ref()) else { return }; + let Some(lhs) = self.place(*lhs_place, None) else { return }; match rvalue { Rvalue::Use(operand) => self.process_operand(lhs, operand, state), // Transfer the conditions on the copy rhs. Rvalue::Discriminant(rhs) => { - let Some(rhs) = self.map.find_discr(rhs.as_ref()) else { return }; + let Some(rhs) = self.place(*rhs, Some(TrackElem::Discriminant)) else { return }; self.process_copy(lhs, rhs, state) } // If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`. @@ -502,33 +516,37 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { // Do not support unions. AggregateKind::Adt(.., Some(_)) => return, AggregateKind::Adt(_, variant_index, ..) if agg_ty.is_enum() => { - if let Some(discr_target) = self.map.apply(lhs, TrackElem::Discriminant) - && let Some(discr_value) = self - .ecx - .discriminant_for_variant(agg_ty, *variant_index) - .discard_err() + let discr_ty = agg_ty.discriminant_ty(self.tcx); + let discr_target = + self.map.register_place_index(discr_ty, lhs, TrackElem::Discriminant); + if let Some(discr_value) = + self.ecx.discriminant_for_variant(agg_ty, *variant_index).discard_err() { self.process_immediate(discr_target, discr_value, state); } - if let Some(idx) = self.map.apply(lhs, TrackElem::Variant(*variant_index)) { - idx - } else { - return; - } + self.map.register_place_index( + agg_ty, + lhs, + TrackElem::Variant(*variant_index), + ) } _ => lhs, }; for (field_index, operand) in operands.iter_enumerated() { - if let Some(field) = self.map.apply(lhs, TrackElem::Field(field_index)) { - self.process_operand(field, operand, state); - } + let operand_ty = operand.ty(self.body, self.tcx); + let field = self.map.register_place_index( + operand_ty, + lhs, + TrackElem::Field(field_index), + ); + self.process_operand(field, operand, state); } } // Transfer the conditions on the copy rhs, after inverting the value of the condition. Rvalue::UnaryOp(UnOp::Not, Operand::Move(operand) | Operand::Copy(operand)) => { let layout = self.ecx.layout_of(operand.ty(self.body, self.tcx).ty).unwrap(); - let Some(lhs) = self.map.value(lhs) else { return }; - let Some(operand) = self.map.find_value(operand.as_ref()) else { return }; + let Some(lhs) = self.value(lhs) else { return }; + let Some(operand) = self.place_value(*operand, None) else { return }; state.retain_mut(|mut c| { if c.place == lhs { let value = self @@ -562,8 +580,8 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { // Avoid handling them, though this could be extended in the future. return; } - let Some(lhs) = self.map.value(lhs) else { return }; - let Some(operand) = self.map.find_value(operand.as_ref()) else { return }; + let Some(lhs) = self.value(lhs) else { return }; + let Some(operand) = self.place_value(*operand, None) else { return }; let Some(value) = value.const_.try_eval_scalar_int(self.tcx, self.typing_env) else { return; @@ -592,7 +610,9 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { // If we expect `discriminant(place) ?= A`, // we have an opportunity if `variant_index ?= A`. StatementKind::SetDiscriminant { box place, variant_index } => { - let Some(discr_target) = self.map.find_discr(place.as_ref()) else { return }; + let Some(discr_target) = self.place(*place, Some(TrackElem::Discriminant)) else { + return; + }; let enum_ty = place.ty(self.body, self.tcx).ty; // `SetDiscriminant` guarantees that the discriminant is now `variant_index`. // Even if the discriminant write does nothing due to niches, it is UB to set the @@ -608,7 +628,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume( Operand::Copy(place) | Operand::Move(place), )) => { - let Some(place) = self.map.find_value(place.as_ref()) else { return }; + let Some(place) = self.place_value(*place, None) else { return }; state.fulfill_matches(place, ScalarInt::TRUE); } StatementKind::Assign(box (lhs_place, rhs)) => { @@ -665,7 +685,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { state: &mut ConditionSet, ) { let Some(discr) = discr.place() else { return }; - let Some(discr_idx) = self.map.find_value(discr.as_ref()) else { return }; + let Some(discr_idx) = self.place_value(discr, None) else { return }; let discr_ty = discr.ty(self.body, self.tcx).ty; let Ok(discr_layout) = self.ecx.layout_of(discr_ty) else { return }; diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index d1d8cb4c418c..d21be004594d 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -69,24 +69,22 @@ Number of file 0 mappings: 61 - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 -Function name: closure::main::{closure#0} -Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 28, 05, 00, 06, 01, 01, 0d, 00, 1a, 01, 00, 1d, 00, 1e, 01, 01, 0c, 00, 14, 05, 00, 15, 02, 0a, 02, 02, 09, 00, 0a, 01, 01, 09, 00, 17, 01, 00, 18, 00, 20, 01, 01, 05, 00, 06] +Function name: closure::main::{closure#0} (unused) +Raw bytes (49): 0x[01, 01, 00, 09, 00, 28, 05, 00, 06, 00, 01, 0d, 00, 1a, 00, 00, 1d, 00, 1e, 00, 01, 0c, 00, 14, 00, 00, 15, 02, 0a, 00, 02, 09, 00, 0a, 00, 01, 09, 00, 17, 00, 00, 18, 00, 20, 00, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/closure.rs -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of expressions: 0 Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 40, 5) to (start + 0, 6) -- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 26) -- Code(Counter(0)) at (prev + 0, 29) to (start + 0, 30) -- Code(Counter(0)) at (prev + 1, 12) to (start + 0, 20) -- Code(Counter(1)) at (prev + 0, 21) to (start + 2, 10) -- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) - = (c0 - c1) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 23) -- Code(Counter(0)) at (prev + 0, 24) to (start + 0, 32) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) -Highest counter ID seen: c1 +- Code(Zero) at (prev + 40, 5) to (start + 0, 6) +- Code(Zero) at (prev + 1, 13) to (start + 0, 26) +- Code(Zero) at (prev + 0, 29) to (start + 0, 30) +- Code(Zero) at (prev + 1, 12) to (start + 0, 20) +- Code(Zero) at (prev + 0, 21) to (start + 2, 10) +- Code(Zero) at (prev + 2, 9) to (start + 0, 10) +- Code(Zero) at (prev + 1, 9) to (start + 0, 23) +- Code(Zero) at (prev + 0, 24) to (start + 0, 32) +- Code(Zero) at (prev + 1, 5) to (start + 0, 6) +Highest counter ID seen: (none) Function name: closure::main::{closure#10} (unused) Raw bytes (20): 0x[01, 01, 00, 03, 00, 9b, 01, 07, 00, 08, 00, 00, 09, 00, 11, 00, 00, 20, 00, 21] diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map index 53757ef8a9bd..fa937cfb7755 100644 --- a/tests/coverage/try_error_result.cov-map +++ b/tests/coverage/try_error_result.cov-map @@ -92,71 +92,28 @@ Number of file 0 mappings: 14 Highest counter ID seen: c1 Function name: try_error_result::test2 -Raw bytes (443): 0x[01, 01, 3d, 09, 0d, 09, 57, 0d, 15, 09, 57, 0d, 15, 09, 57, 0d, 15, 09, 4f, 53, 1d, 57, 19, 0d, 15, 09, 57, 0d, 15, 09, 57, 0d, 15, 09, 53, 57, 19, 0d, 15, 09, 4f, 53, 1d, 57, 19, 0d, 15, 41, 6b, 21, 25, 41, 21, 41, 6b, 21, 25, 05, 8f, 01, 93, 01, 2d, 09, 29, 05, 09, 05, 09, 05, 93, 01, 09, 29, 05, 8f, 01, 93, 01, 2d, 09, 29, 45, a7, 01, 31, 35, 45, 31, 45, a7, 01, 31, 35, 49, bb, 01, 39, 3d, 49, 39, 49, bb, 01, 39, 3d, 11, 05, c7, 01, 05, cb, 01, 3d, cf, 01, 39, d3, 01, 35, d7, 01, 31, db, 01, 2d, df, 01, 29, e3, 01, 25, e7, 01, 21, eb, 01, 1d, ef, 01, 19, f3, 01, 15, 11, 0d, 39, 01, 3d, 01, 00, 1d, 01, 01, 09, 00, 0f, 01, 00, 12, 00, 1a, 01, 01, 09, 01, 12, 01, 01, 15, 00, 17, 01, 05, 09, 00, 0e, 05, 02, 09, 01, 11, 05, 04, 0d, 00, 1a, 09, 02, 0d, 00, 13, 09, 00, 14, 00, 1f, 0d, 00, 2f, 00, 30, 02, 00, 31, 00, 35, 02, 00, 45, 00, 4f, 02, 00, 50, 00, 62, 02, 01, 0d, 00, 13, 02, 02, 11, 00, 1c, 15, 01, 11, 00, 12, 36, 02, 11, 00, 15, 36, 02, 11, 00, 1b, 36, 01, 15, 00, 27, 4a, 02, 11, 00, 14, 36, 00, 17, 00, 1d, 36, 00, 1e, 00, 29, 19, 00, 41, 00, 42, 3e, 00, 43, 00, 47, 1d, 00, 5f, 00, 60, 4a, 01, 0d, 00, 17, 66, 01, 11, 00, 14, 41, 00, 17, 00, 1d, 41, 00, 1e, 00, 29, 21, 00, 41, 00, 42, 62, 00, 43, 00, 47, 25, 00, 60, 00, 61, 66, 01, 0d, 00, 17, 8a, 01, 04, 11, 00, 14, 7e, 00, 17, 00, 1d, 7e, 00, 1e, 00, 29, 29, 00, 42, 00, 43, 82, 01, 00, 44, 00, 48, 2d, 00, 61, 00, 62, 8a, 01, 01, 0d, 00, 17, a2, 01, 01, 11, 00, 14, 45, 00, 17, 00, 1d, 45, 01, 12, 00, 1d, 31, 00, 36, 00, 37, 9e, 01, 01, 12, 00, 16, 35, 00, 2f, 00, 30, a2, 01, 01, 0d, 00, 17, b6, 01, 01, 11, 00, 14, 49, 00, 17, 00, 1d, 49, 01, 12, 00, 1d, 39, 01, 11, 00, 12, b2, 01, 01, 12, 00, 16, 3d, 01, 11, 00, 12, b6, 01, 02, 0d, 00, 17, be, 01, 03, 05, 00, 0b, c2, 01, 01, 01, 00, 02] +Raw bytes (325): 0x[01, 01, 12, 07, 09, 01, 05, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 01, 09, 05, 39, 01, 3d, 01, 00, 1d, 01, 01, 09, 00, 0f, 01, 00, 12, 00, 1a, 01, 01, 09, 01, 12, 01, 01, 15, 00, 17, 01, 05, 09, 00, 0e, 05, 02, 09, 01, 11, 05, 04, 0d, 00, 1a, 02, 02, 0d, 00, 13, 02, 00, 14, 00, 1f, 00, 00, 2f, 00, 30, 02, 00, 31, 00, 35, 02, 00, 45, 00, 4f, 02, 00, 50, 00, 62, 02, 01, 0d, 00, 13, 02, 02, 11, 00, 1c, 00, 01, 11, 00, 12, 02, 02, 11, 00, 15, 02, 02, 11, 00, 1b, 02, 01, 15, 00, 27, 00, 02, 11, 00, 14, 02, 00, 17, 00, 1d, 02, 00, 1e, 00, 29, 02, 00, 41, 00, 42, 00, 00, 43, 00, 47, 00, 00, 5f, 00, 60, 00, 01, 0d, 00, 17, 00, 01, 11, 00, 14, 00, 00, 17, 00, 1d, 00, 00, 1e, 00, 29, 00, 00, 41, 00, 42, 00, 00, 43, 00, 47, 00, 00, 60, 00, 61, 00, 01, 0d, 00, 17, 42, 04, 11, 00, 14, 42, 00, 17, 00, 1d, 42, 00, 1e, 00, 29, 00, 00, 42, 00, 43, 42, 00, 44, 00, 48, 00, 00, 61, 00, 62, 42, 01, 0d, 00, 17, 42, 01, 11, 00, 14, 42, 00, 17, 00, 1d, 42, 01, 12, 00, 1d, 00, 00, 36, 00, 37, 42, 01, 12, 00, 16, 00, 00, 2f, 00, 30, 42, 01, 0d, 00, 17, 42, 01, 11, 00, 14, 42, 00, 17, 00, 1d, 42, 01, 12, 00, 1d, 00, 01, 11, 00, 12, 42, 01, 12, 00, 16, 00, 01, 11, 00, 12, 42, 02, 0d, 00, 17, 46, 03, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/try_error_result.rs -Number of expressions: 61 -- expression 0 operands: lhs = Counter(2), rhs = Counter(3) -- expression 1 operands: lhs = Counter(2), rhs = Expression(21, Add) -- expression 2 operands: lhs = Counter(3), rhs = Counter(5) -- expression 3 operands: lhs = Counter(2), rhs = Expression(21, Add) -- expression 4 operands: lhs = Counter(3), rhs = Counter(5) -- expression 5 operands: lhs = Counter(2), rhs = Expression(21, Add) -- expression 6 operands: lhs = Counter(3), rhs = Counter(5) -- expression 7 operands: lhs = Counter(2), rhs = Expression(19, Add) -- expression 8 operands: lhs = Expression(20, Add), rhs = Counter(7) -- expression 9 operands: lhs = Expression(21, Add), rhs = Counter(6) -- expression 10 operands: lhs = Counter(3), rhs = Counter(5) -- expression 11 operands: lhs = Counter(2), rhs = Expression(21, Add) -- expression 12 operands: lhs = Counter(3), rhs = Counter(5) -- expression 13 operands: lhs = Counter(2), rhs = Expression(21, Add) -- expression 14 operands: lhs = Counter(3), rhs = Counter(5) -- expression 15 operands: lhs = Counter(2), rhs = Expression(20, Add) -- expression 16 operands: lhs = Expression(21, Add), rhs = Counter(6) -- expression 17 operands: lhs = Counter(3), rhs = Counter(5) -- expression 18 operands: lhs = Counter(2), rhs = Expression(19, Add) -- expression 19 operands: lhs = Expression(20, Add), rhs = Counter(7) -- expression 20 operands: lhs = Expression(21, Add), rhs = Counter(6) -- expression 21 operands: lhs = Counter(3), rhs = Counter(5) -- expression 22 operands: lhs = Counter(16), rhs = Expression(26, Add) -- expression 23 operands: lhs = Counter(8), rhs = Counter(9) -- expression 24 operands: lhs = Counter(16), rhs = Counter(8) -- expression 25 operands: lhs = Counter(16), rhs = Expression(26, Add) -- expression 26 operands: lhs = Counter(8), rhs = Counter(9) -- expression 27 operands: lhs = Counter(1), rhs = Expression(35, Add) -- expression 28 operands: lhs = Expression(36, Add), rhs = Counter(11) -- expression 29 operands: lhs = Counter(2), rhs = Counter(10) -- expression 30 operands: lhs = Counter(1), rhs = Counter(2) -- expression 31 operands: lhs = Counter(1), rhs = Counter(2) -- expression 32 operands: lhs = Counter(1), rhs = Expression(36, Add) -- expression 33 operands: lhs = Counter(2), rhs = Counter(10) -- expression 34 operands: lhs = Counter(1), rhs = Expression(35, Add) -- expression 35 operands: lhs = Expression(36, Add), rhs = Counter(11) -- expression 36 operands: lhs = Counter(2), rhs = Counter(10) -- expression 37 operands: lhs = Counter(17), rhs = Expression(41, Add) -- expression 38 operands: lhs = Counter(12), rhs = Counter(13) -- expression 39 operands: lhs = Counter(17), rhs = Counter(12) -- expression 40 operands: lhs = Counter(17), rhs = Expression(41, Add) -- expression 41 operands: lhs = Counter(12), rhs = Counter(13) -- expression 42 operands: lhs = Counter(18), rhs = Expression(46, Add) -- expression 43 operands: lhs = Counter(14), rhs = Counter(15) -- expression 44 operands: lhs = Counter(18), rhs = Counter(14) -- expression 45 operands: lhs = Counter(18), rhs = Expression(46, Add) -- expression 46 operands: lhs = Counter(14), rhs = Counter(15) -- expression 47 operands: lhs = Counter(4), rhs = Counter(1) -- expression 48 operands: lhs = Expression(49, Add), rhs = Counter(1) -- expression 49 operands: lhs = Expression(50, Add), rhs = Counter(15) -- expression 50 operands: lhs = Expression(51, Add), rhs = Counter(14) -- expression 51 operands: lhs = Expression(52, Add), rhs = Counter(13) -- expression 52 operands: lhs = Expression(53, Add), rhs = Counter(12) -- expression 53 operands: lhs = Expression(54, Add), rhs = Counter(11) -- expression 54 operands: lhs = Expression(55, Add), rhs = Counter(10) -- expression 55 operands: lhs = Expression(56, Add), rhs = Counter(9) -- expression 56 operands: lhs = Expression(57, Add), rhs = Counter(8) -- expression 57 operands: lhs = Expression(58, Add), rhs = Counter(7) -- expression 58 operands: lhs = Expression(59, Add), rhs = Counter(6) -- expression 59 operands: lhs = Expression(60, Add), rhs = Counter(5) -- expression 60 operands: lhs = Counter(4), rhs = Counter(3) +Number of expressions: 18 +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 2 operands: lhs = Counter(2), rhs = Counter(0) +- expression 3 operands: lhs = Counter(2), rhs = Counter(0) +- expression 4 operands: lhs = Counter(2), rhs = Counter(0) +- expression 5 operands: lhs = Counter(2), rhs = Counter(0) +- expression 6 operands: lhs = Counter(2), rhs = Counter(0) +- expression 7 operands: lhs = Counter(2), rhs = Counter(0) +- expression 8 operands: lhs = Counter(2), rhs = Counter(0) +- expression 9 operands: lhs = Counter(2), rhs = Counter(0) +- expression 10 operands: lhs = Counter(2), rhs = Counter(0) +- expression 11 operands: lhs = Counter(2), rhs = Counter(0) +- expression 12 operands: lhs = Counter(2), rhs = Counter(0) +- expression 13 operands: lhs = Counter(2), rhs = Counter(0) +- expression 14 operands: lhs = Counter(2), rhs = Counter(0) +- expression 15 operands: lhs = Counter(2), rhs = Counter(0) +- expression 16 operands: lhs = Counter(2), rhs = Counter(0) +- expression 17 operands: lhs = Counter(2), rhs = Counter(1) Number of file 0 mappings: 57 - Code(Counter(0)) at (prev + 61, 1) to (start + 0, 29) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 15) @@ -166,83 +123,83 @@ Number of file 0 mappings: 57 - Code(Counter(0)) at (prev + 5, 9) to (start + 0, 14) - Code(Counter(1)) at (prev + 2, 9) to (start + 1, 17) - Code(Counter(1)) at (prev + 4, 13) to (start + 0, 26) -- Code(Counter(2)) at (prev + 2, 13) to (start + 0, 19) -- Code(Counter(2)) at (prev + 0, 20) to (start + 0, 31) -- Code(Counter(3)) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19) + = ((c0 + c1) - c2) +- Code(Expression(0, Sub)) at (prev + 0, 20) to (start + 0, 31) + = ((c0 + c1) - c2) +- Code(Zero) at (prev + 0, 47) to (start + 0, 48) - Code(Expression(0, Sub)) at (prev + 0, 49) to (start + 0, 53) - = (c2 - c3) + = ((c0 + c1) - c2) - Code(Expression(0, Sub)) at (prev + 0, 69) to (start + 0, 79) - = (c2 - c3) + = ((c0 + c1) - c2) - Code(Expression(0, Sub)) at (prev + 0, 80) to (start + 0, 98) - = (c2 - c3) + = ((c0 + c1) - c2) - Code(Expression(0, Sub)) at (prev + 1, 13) to (start + 0, 19) - = (c2 - c3) + = ((c0 + c1) - c2) - Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 28) - = (c2 - c3) -- Code(Counter(5)) at (prev + 1, 17) to (start + 0, 18) -- Code(Expression(13, Sub)) at (prev + 2, 17) to (start + 0, 21) - = (c2 - (c3 + c5)) -- Code(Expression(13, Sub)) at (prev + 2, 17) to (start + 0, 27) - = (c2 - (c3 + c5)) -- Code(Expression(13, Sub)) at (prev + 1, 21) to (start + 0, 39) - = (c2 - (c3 + c5)) -- Code(Expression(18, Sub)) at (prev + 2, 17) to (start + 0, 20) - = (c2 - (((c3 + c5) + c6) + c7)) -- Code(Expression(13, Sub)) at (prev + 0, 23) to (start + 0, 29) - = (c2 - (c3 + c5)) -- Code(Expression(13, Sub)) at (prev + 0, 30) to (start + 0, 41) - = (c2 - (c3 + c5)) -- Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(15, Sub)) at (prev + 0, 67) to (start + 0, 71) - = (c2 - ((c3 + c5) + c6)) -- Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96) -- Code(Expression(18, Sub)) at (prev + 1, 13) to (start + 0, 23) - = (c2 - (((c3 + c5) + c6) + c7)) -- Code(Expression(25, Sub)) at (prev + 1, 17) to (start + 0, 20) - = (c16 - (c8 + c9)) -- Code(Counter(16)) at (prev + 0, 23) to (start + 0, 29) -- Code(Counter(16)) at (prev + 0, 30) to (start + 0, 41) -- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(24, Sub)) at (prev + 0, 67) to (start + 0, 71) - = (c16 - c8) -- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97) -- Code(Expression(25, Sub)) at (prev + 1, 13) to (start + 0, 23) - = (c16 - (c8 + c9)) -- Code(Expression(34, Sub)) at (prev + 4, 17) to (start + 0, 20) - = (c1 - ((c2 + c10) + c11)) -- Code(Expression(31, Sub)) at (prev + 0, 23) to (start + 0, 29) - = (c1 - c2) -- Code(Expression(31, Sub)) at (prev + 0, 30) to (start + 0, 41) - = (c1 - c2) -- Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67) -- Code(Expression(32, Sub)) at (prev + 0, 68) to (start + 0, 72) - = (c1 - (c2 + c10)) -- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98) -- Code(Expression(34, Sub)) at (prev + 1, 13) to (start + 0, 23) - = (c1 - ((c2 + c10) + c11)) -- Code(Expression(40, Sub)) at (prev + 1, 17) to (start + 0, 20) - = (c17 - (c12 + c13)) -- Code(Counter(17)) at (prev + 0, 23) to (start + 0, 29) -- Code(Counter(17)) at (prev + 1, 18) to (start + 0, 29) -- Code(Counter(12)) at (prev + 0, 54) to (start + 0, 55) -- Code(Expression(39, Sub)) at (prev + 1, 18) to (start + 0, 22) - = (c17 - c12) -- Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48) -- Code(Expression(40, Sub)) at (prev + 1, 13) to (start + 0, 23) - = (c17 - (c12 + c13)) -- Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20) - = (c18 - (c14 + c15)) -- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 29) -- Code(Counter(18)) at (prev + 1, 18) to (start + 0, 29) -- Code(Counter(14)) at (prev + 1, 17) to (start + 0, 18) -- Code(Expression(44, Sub)) at (prev + 1, 18) to (start + 0, 22) - = (c18 - c14) -- Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18) -- Code(Expression(45, Sub)) at (prev + 2, 13) to (start + 0, 23) - = (c18 - (c14 + c15)) -- Code(Expression(47, Sub)) at (prev + 3, 5) to (start + 0, 11) - = (c4 - c1) -- Code(Expression(48, Sub)) at (prev + 1, 1) to (start + 0, 2) - = (((((((((((((c4 + c3) + c5) + c6) + c7) + c8) + c9) + c10) + c11) + c12) + c13) + c14) + c15) - c1) -Highest counter ID seen: c18 + = ((c0 + c1) - c2) +- Code(Zero) at (prev + 1, 17) to (start + 0, 18) +- Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 21) + = ((c0 + c1) - c2) +- Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 27) + = ((c0 + c1) - c2) +- Code(Expression(0, Sub)) at (prev + 1, 21) to (start + 0, 39) + = ((c0 + c1) - c2) +- Code(Zero) at (prev + 2, 17) to (start + 0, 20) +- Code(Expression(0, Sub)) at (prev + 0, 23) to (start + 0, 29) + = ((c0 + c1) - c2) +- Code(Expression(0, Sub)) at (prev + 0, 30) to (start + 0, 41) + = ((c0 + c1) - c2) +- Code(Expression(0, Sub)) at (prev + 0, 65) to (start + 0, 66) + = ((c0 + c1) - c2) +- Code(Zero) at (prev + 0, 67) to (start + 0, 71) +- Code(Zero) at (prev + 0, 95) to (start + 0, 96) +- Code(Zero) at (prev + 1, 13) to (start + 0, 23) +- Code(Zero) at (prev + 1, 17) to (start + 0, 20) +- Code(Zero) at (prev + 0, 23) to (start + 0, 29) +- Code(Zero) at (prev + 0, 30) to (start + 0, 41) +- Code(Zero) at (prev + 0, 65) to (start + 0, 66) +- Code(Zero) at (prev + 0, 67) to (start + 0, 71) +- Code(Zero) at (prev + 0, 96) to (start + 0, 97) +- Code(Zero) at (prev + 1, 13) to (start + 0, 23) +- Code(Expression(16, Sub)) at (prev + 4, 17) to (start + 0, 20) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 0, 23) to (start + 0, 29) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 0, 30) to (start + 0, 41) + = (c2 - c0) +- Code(Zero) at (prev + 0, 66) to (start + 0, 67) +- Code(Expression(16, Sub)) at (prev + 0, 68) to (start + 0, 72) + = (c2 - c0) +- Code(Zero) at (prev + 0, 97) to (start + 0, 98) +- Code(Expression(16, Sub)) at (prev + 1, 13) to (start + 0, 23) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 1, 17) to (start + 0, 20) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 0, 23) to (start + 0, 29) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 1, 18) to (start + 0, 29) + = (c2 - c0) +- Code(Zero) at (prev + 0, 54) to (start + 0, 55) +- Code(Expression(16, Sub)) at (prev + 1, 18) to (start + 0, 22) + = (c2 - c0) +- Code(Zero) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(16, Sub)) at (prev + 1, 13) to (start + 0, 23) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 1, 17) to (start + 0, 20) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 0, 23) to (start + 0, 29) + = (c2 - c0) +- Code(Expression(16, Sub)) at (prev + 1, 18) to (start + 0, 29) + = (c2 - c0) +- Code(Zero) at (prev + 1, 17) to (start + 0, 18) +- Code(Expression(16, Sub)) at (prev + 1, 18) to (start + 0, 22) + = (c2 - c0) +- Code(Zero) at (prev + 1, 17) to (start + 0, 18) +- Code(Expression(16, Sub)) at (prev + 2, 13) to (start + 0, 23) + = (c2 - c0) +- Code(Expression(17, Sub)) at (prev + 3, 5) to (start + 0, 11) + = (c2 - c1) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) +Highest counter ID seen: c1 From 075f4cd57f3c2b175510c25638fc23bc87d7633b Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 14 Dec 2025 13:44:14 +0100 Subject: [PATCH 151/489] Restore embedding warning and simply `{,into_}local_path` methods --- compiler/rustc_span/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 630656f9ec5c..3d641905d325 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -374,12 +374,16 @@ impl RealFileName { /// if this information exists. /// /// May not exists if the filename was imported from another crate. + /// + /// Avoid embedding this in build artifacts; prefer `path()` or `embeddable_name()`. #[inline] pub fn local_path(&self) -> Option<&Path> { if self.was_not_remapped() { Some(&self.maybe_remapped.name) + } else if let Some(local) = &self.local { + Some(&local.name) } else { - self.local.as_ref().map(|lp| lp.name.as_ref()) + None } } @@ -387,12 +391,16 @@ impl RealFileName { /// if this information exists. /// /// May not exists if the filename was imported from another crate. + /// + /// Avoid embedding this in build artifacts; prefer `path()` or `embeddable_name()`. #[inline] pub fn into_local_path(self) -> Option { if self.was_not_remapped() { Some(self.maybe_remapped.name) + } else if let Some(local) = self.local { + Some(local.name) } else { - self.local.map(|lp| lp.name) + None } } From 1a227bd47ff200975f4afb287ec725861ab8b87a Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 9 Nov 2025 02:57:31 +0000 Subject: [PATCH 152/489] Replace Rvalue::NullaryOp by a variant in mir::ConstValue. --- compiler/rustc_borrowck/src/lib.rs | 4 -- .../src/polonius/legacy/loan_invalidations.rs | 2 - compiler/rustc_borrowck/src/type_check/mod.rs | 3 - compiler/rustc_codegen_cranelift/src/base.rs | 13 +---- .../rustc_codegen_cranelift/src/constant.rs | 5 ++ compiler/rustc_codegen_ssa/src/mir/operand.rs | 8 +++ compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 15 ----- .../src/check_consts/check.rs | 1 - .../src/check_consts/qualifs.rs | 4 +- .../src/check_consts/resolver.rs | 1 - .../rustc_const_eval/src/interpret/operand.rs | 4 ++ .../src/interpret/operator.rs | 8 --- .../rustc_const_eval/src/interpret/step.rs | 5 -- compiler/rustc_middle/src/mir/consts.rs | 39 ++++++++++++- compiler/rustc_middle/src/mir/mod.rs | 6 +- compiler/rustc_middle/src/mir/pretty.rs | 11 +--- compiler/rustc_middle/src/mir/statement.rs | 10 ---- compiler/rustc_middle/src/mir/syntax.rs | 32 ---------- compiler/rustc_middle/src/mir/traversal.rs | 4 +- compiler/rustc_middle/src/mir/visit.rs | 7 +-- .../rustc_middle/src/ty/structural_impls.rs | 2 +- .../src/impls/borrowed_locals.rs | 1 - .../src/move_paths/builder.rs | 5 +- .../rustc_mir_transform/src/cost_checker.rs | 29 +--------- .../src/dataflow_const_prop.rs | 3 - compiler/rustc_mir_transform/src/gvn.rs | 3 - .../rustc_mir_transform/src/instsimplify.rs | 43 ++++++++------ .../src/known_panics_lint.rs | 3 - compiler/rustc_mir_transform/src/lint.rs | 1 - .../src/lower_intrinsics.rs | 9 ++- .../rustc_mir_transform/src/promote_consts.rs | 4 -- compiler/rustc_mir_transform/src/validate.rs | 1 - compiler/rustc_public/src/alloc.rs | 1 + compiler/rustc_public/src/mir/body.rs | 20 ------- compiler/rustc_public/src/mir/pretty.rs | 3 - compiler/rustc_public/src/mir/visit.rs | 1 - compiler/rustc_public/src/ty.rs | 11 ++++ .../src/unstable/convert/stable/mir.rs | 21 ++++--- compiler/rustc_public/src/visitor.rs | 4 +- library/core/src/ub_checks.rs | 21 ++++--- .../clippy_utils/src/qualify_min_const_fn.rs | 4 +- tests/codegen-llvm/slice-iter-len-eq-zero.rs | 8 ++- ...ifyConstCondition-after-inst-simplify.diff | 5 +- ...ng_operand.test.GVN.32bit.panic-abort.diff | 58 +++++++++---------- ...ng_operand.test.GVN.64bit.panic-abort.diff | 58 +++++++++---------- ...l_unsigned_smaller.Inline.panic-abort.diff | 6 +- ..._unsigned_smaller.Inline.panic-unwind.diff | 6 +- ..._shr_signed_bigger.Inline.panic-abort.diff | 6 +- ...shr_signed_bigger.Inline.panic-unwind.diff | 6 +- ...d.unwrap_unchecked.Inline.panic-abort.diff | 5 +- ....unwrap_unchecked.Inline.panic-unwind.diff | 5 +- tests/mir-opt/instsimplify/ub_check.rs | 3 +- ...hecked.InstSimplify-after-simplifycfg.diff | 7 +-- 53 files changed, 210 insertions(+), 335 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index d82357fca2d4..d15983075af2 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1560,10 +1560,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { self.consume_operand(location, (operand2, span), state); } - Rvalue::NullaryOp(_op) => { - // nullary ops take no dynamic input; no borrowck effect. - } - Rvalue::Aggregate(aggregate_kind, operands) => { // We need to report back the list of mutable upvars that were // moved into the closure and subsequently used by the closure, diff --git a/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs index de479a7d74c8..85a08b7399e5 100644 --- a/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs +++ b/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs @@ -314,8 +314,6 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> { self.consume_operand(location, operand2); } - Rvalue::NullaryOp(_op) => {} - Rvalue::Aggregate(_, operands) => { for operand in operands { self.consume_operand(location, operand); diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 220de046293a..3507a1f8503c 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1046,8 +1046,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } } - &Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {} - Rvalue::ShallowInitBox(_operand, ty) => { let trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, span), [*ty]); @@ -2276,7 +2274,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | Rvalue::Cast(..) | Rvalue::ShallowInitBox(..) | Rvalue::BinaryOp(..) - | Rvalue::NullaryOp(..) | Rvalue::CopyForDeref(..) | Rvalue::UnaryOp(..) | Rvalue::Discriminant(..) diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index ac5b3c240785..4dbee7665eb8 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -10,7 +10,7 @@ use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; -use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv}; +use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -853,17 +853,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: fx.bcx.ins().nop(); } } - Rvalue::NullaryOp(ref null_op) => { - assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env())); - let val = match null_op { - NullOp::RuntimeChecks(kind) => kind.value(fx.tcx.sess), - }; - let val = CValue::by_val( - fx.bcx.ins().iconst(types::I8, i64::from(val)), - fx.layout_of(fx.tcx.types.bool), - ); - lval.write_cvalue(fx, val); - } Rvalue::Aggregate(ref kind, ref operands) if matches!(**kind, AggregateKind::RawPtr(..)) => { diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 2b65b8290681..29c8e8ab1e52 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -215,6 +215,11 @@ pub(crate) fn codegen_const_value<'tcx>( CValue::by_val(val, layout) } }, + ConstValue::RuntimeChecks(checks) => { + let int = checks.value(fx.tcx.sess); + let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + return CValue::const_val(fx, layout, int); + } ConstValue::Indirect { alloc_id, offset } => CValue::by_ref( Pointer::new(pointer_for_allocation(fx, alloc_id)) .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index 5a139702f81d..29108043feff 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -165,6 +165,14 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout)); OperandValue::Immediate(llval) } + mir::ConstValue::RuntimeChecks(checks) => { + let BackendRepr::Scalar(scalar) = layout.backend_repr else { + bug!("from_const: invalid ByVal layout: {:#?}", layout); + }; + let x = Scalar::from_bool(checks.value(bx.tcx().sess)); + let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout)); + OperandValue::Immediate(llval) + } ConstValue::ZeroSized => return OperandRef::zero_sized(layout), ConstValue::Slice { alloc_id, meta } => { let BackendRepr::ScalarPair(a_scalar, _) = layout.backend_repr else { diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index de626d04e785..ca8c8dd06ba6 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -619,21 +619,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } - mir::Rvalue::NullaryOp(ref null_op) => { - let val = match null_op { - mir::NullOp::RuntimeChecks(kind) => { - let val = kind.value(bx.tcx().sess); - bx.cx().const_bool(val) - } - }; - let tcx = self.cx.tcx(); - OperandRef { - val: OperandValue::Immediate(val), - layout: self.cx.layout_of(null_op.ty(tcx)), - move_annotation: None, - } - } - mir::Rvalue::ThreadLocalRef(def_id) => { assert!(bx.cx().tcx().is_static(def_id)); let layout = bx.layout_of(bx.cx().tcx().static_ptr_ty(def_id, bx.typing_env())); diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 78e4066ca910..ed2c0bd6f98e 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -645,7 +645,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::Cast(_, _, _) => {} - Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {} Rvalue::ShallowInitBox(_, _) => {} Rvalue::UnaryOp(op, operand) => { diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index f50c6af53bf1..49a477d8fdba 100644 --- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs @@ -230,9 +230,7 @@ where F: FnMut(Local) -> bool, { match rvalue { - Rvalue::ThreadLocalRef(_) | Rvalue::NullaryOp(..) => { - Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)) - } + Rvalue::ThreadLocalRef(_) => Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)), Rvalue::Discriminant(place) => in_place::(cx, in_local, place.as_ref()), diff --git a/compiler/rustc_const_eval/src/check_consts/resolver.rs b/compiler/rustc_const_eval/src/check_consts/resolver.rs index e6e3948305af..d4cc21996aea 100644 --- a/compiler/rustc_const_eval/src/check_consts/resolver.rs +++ b/compiler/rustc_const_eval/src/check_consts/resolver.rs @@ -198,7 +198,6 @@ where | mir::Rvalue::ThreadLocalRef(..) | mir::Rvalue::Repeat(..) | mir::Rvalue::BinaryOp(..) - | mir::Rvalue::NullaryOp(..) | mir::Rvalue::UnaryOp(..) | mir::Rvalue::Discriminant(..) | mir::Rvalue::Aggregate(..) diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index d3d119c8fc9c..32d08d064923 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -892,6 +892,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let ptr = Pointer::new(CtfeProvenance::from(alloc_id).as_immutable(), Size::ZERO); Immediate::new_slice(self.global_root_pointer(ptr)?.into(), meta, self) } + mir::ConstValue::RuntimeChecks(checks) => { + let val = M::runtime_checks(self, checks)?; + Scalar::from_bool(val).into() + } }; interp_ok(OpTy { op: Operand::Immediate(imm), layout }) } diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index 8548b774ddb4..ca8c096d3ab4 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -1,7 +1,6 @@ use either::Either; use rustc_abi::Size; use rustc_apfloat::{Float, FloatConvert}; -use rustc_middle::mir::NullOp; use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar}; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, FloatTy, ScalarInt}; @@ -505,11 +504,4 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } } } - - pub fn nullary_op(&self, null_op: NullOp) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> { - use rustc_middle::mir::NullOp::*; - interp_ok(match null_op { - RuntimeChecks(r) => ImmTy::from_bool(M::runtime_checks(self, r)?, *self.tcx), - }) - } } diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 88a116094758..47e8e2a9ec51 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -203,11 +203,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.write_immediate(*result, &dest)?; } - NullaryOp(null_op) => { - let val = self.nullary_op(null_op)?; - self.write_immediate(*val, &dest)?; - } - Aggregate(box ref kind, ref operands) => { self.write_aggregate(kind, operands, &dest)?; } diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index fe352df3b9f0..1b7d3ec9345f 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -68,6 +68,10 @@ pub enum ConstValue { /// Offset into `alloc` offset: Size, }, + + /// Special constants whose value depends on the evaluation context. Their value depends on a + /// flag on the crate being codegenned. + RuntimeChecks(RuntimeChecks), } #[cfg(target_pointer_width = "64")] @@ -77,7 +81,10 @@ impl ConstValue { #[inline] pub fn try_to_scalar(&self) -> Option { match *self { - ConstValue::Indirect { .. } | ConstValue::Slice { .. } | ConstValue::ZeroSized => None, + ConstValue::Indirect { .. } + | ConstValue::Slice { .. } + | ConstValue::ZeroSized + | ConstValue::RuntimeChecks(_) => None, ConstValue::Scalar(val) => Some(val), } } @@ -133,7 +140,7 @@ impl ConstValue { tcx: TyCtxt<'tcx>, ) -> Option<&'tcx [u8]> { let (alloc_id, start, len) = match self { - ConstValue::Scalar(_) | ConstValue::ZeroSized => { + ConstValue::Scalar(_) | ConstValue::ZeroSized | ConstValue::RuntimeChecks(_) => { bug!("`try_get_slice_bytes` on non-slice constant") } &ConstValue::Slice { alloc_id, meta } => (alloc_id, 0, meta), @@ -185,7 +192,9 @@ impl ConstValue { /// Can return `true` even if there is no provenance. pub fn may_have_provenance(&self, tcx: TyCtxt<'_>, size: Size) -> bool { match *self { - ConstValue::ZeroSized | ConstValue::Scalar(Scalar::Int(_)) => return false, + ConstValue::ZeroSized + | ConstValue::Scalar(Scalar::Int(_)) + | ConstValue::RuntimeChecks(_) => return false, ConstValue::Scalar(Scalar::Ptr(..)) => return true, // It's hard to find out the part of the allocation we point to; // just conservatively check everything. @@ -224,6 +233,29 @@ impl ConstValue { } } +#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] +pub enum RuntimeChecks { + /// Returns whether we should perform some UB-checking at runtime. + /// See the `ub_checks` intrinsic docs for details. + UbChecks, + /// Returns whether we should perform contract-checking at runtime. + /// See the `contract_checks` intrinsic docs for details. + ContractChecks, + /// Returns whether we should perform some overflow-checking at runtime. + /// See the `overflow_checks` intrinsic docs for details. + OverflowChecks, +} + +impl RuntimeChecks { + pub fn value(self, sess: &rustc_session::Session) -> bool { + match self { + Self::UbChecks => sess.ub_checks(), + Self::ContractChecks => sess.contract_checks(), + Self::OverflowChecks => sess.overflow_checks(), + } + } +} + /////////////////////////////////////////////////////////////////////////// /// Constants @@ -517,6 +549,7 @@ impl<'tcx> Const<'tcx> { ConstValue::Slice { .. } | ConstValue::ZeroSized | ConstValue::Scalar(_) + | ConstValue::RuntimeChecks(_) | ConstValue::Indirect { .. }, _, ) => true, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 4ae4152cfb93..bffff1b400d5 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -607,6 +607,9 @@ impl<'tcx> Body<'tcx> { typing_env, crate::ty::EarlyBinder::bind(constant.const_), ); + if let Const::Val(ConstValue::RuntimeChecks(check), _) = mono_literal { + return Some(check.value(tcx.sess) as u128); + } mono_literal.try_eval_bits(tcx, typing_env) }; @@ -649,9 +652,6 @@ impl<'tcx> Body<'tcx> { } match rvalue { - Rvalue::NullaryOp(NullOp::RuntimeChecks(kind)) => { - Some((kind.value(tcx.sess) as u128, targets)) - } Rvalue::Use(Operand::Constant(constant)) => { let bits = eval_mono_const(constant)?; Some((bits, targets)) diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index b225dd4ef60a..e4f85a115096 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1097,15 +1097,6 @@ impl<'tcx> Debug for Rvalue<'tcx> { BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{op:?}({a:?}, {b:?})"), UnaryOp(ref op, ref a) => write!(fmt, "{op:?}({a:?})"), Discriminant(ref place) => write!(fmt, "discriminant({place:?})"), - NullaryOp(ref op) => match op { - NullOp::RuntimeChecks(RuntimeChecks::UbChecks) => write!(fmt, "UbChecks()"), - NullOp::RuntimeChecks(RuntimeChecks::ContractChecks) => { - write!(fmt, "ContractChecks()") - } - NullOp::RuntimeChecks(RuntimeChecks::OverflowChecks) => { - write!(fmt, "OverflowChecks()") - } - }, ThreadLocalRef(did) => ty::tls::with(|tcx| { let muta = tcx.static_mutability(did).unwrap().prefix_str(); write!(fmt, "&/*tls*/ {}{}", muta, tcx.def_path_str(did)) @@ -1527,6 +1518,7 @@ pub fn write_allocations<'tcx>( match val { ConstValue::Scalar(interpret::Scalar::Ptr(ptr, _)) => Some(ptr.provenance.alloc_id()), ConstValue::Scalar(interpret::Scalar::Int { .. }) => None, + ConstValue::RuntimeChecks(_) => None, ConstValue::ZeroSized => None, ConstValue::Slice { alloc_id, .. } | ConstValue::Indirect { alloc_id, .. } => { // FIXME: we don't actually want to print all of these, since some are printed nicely directly as values inline in MIR. @@ -1977,6 +1969,7 @@ fn pretty_print_const_value_tcx<'tcx>( fmt.write_str(&p.into_buffer())?; return Ok(()); } + (ConstValue::RuntimeChecks(checks), _) => return write!(fmt, "{checks:?}"), (ConstValue::ZeroSized, ty::FnDef(d, s)) => { let mut p = FmtPrinter::new(tcx, Namespace::ValueNS); p.print_alloc_ids = true; diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index bd4188dd0ff4..942eb727de67 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -756,7 +756,6 @@ impl<'tcx> Rvalue<'tcx> { _, ) | Rvalue::BinaryOp(_, _) - | Rvalue::NullaryOp(_) | Rvalue::UnaryOp(_, _) | Rvalue::Discriminant(_) | Rvalue::Aggregate(_, _) @@ -794,7 +793,6 @@ impl<'tcx> Rvalue<'tcx> { op.ty(tcx, arg_ty) } Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx), - Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => tcx.types.bool, Rvalue::Aggregate(ref ak, ref ops) => match **ak { AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64), AggregateKind::Tuple => { @@ -858,14 +856,6 @@ impl BorrowKind { } } -impl NullOp { - pub fn ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { - match self { - NullOp::RuntimeChecks(_) => tcx.types.bool, - } - } -} - impl<'tcx> UnOp { pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> { match self { diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 204ad4815147..e96d6824c600 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1418,9 +1418,6 @@ pub enum Rvalue<'tcx> { /// matching types and return a value of that type. BinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>), - /// Computes a value as described by the operation. - NullaryOp(NullOp), - /// Exactly like `BinaryOp`, but less operands. /// /// Also does two's-complement arithmetic. Negation requires a signed integer or a float; @@ -1561,35 +1558,6 @@ pub enum AggregateKind<'tcx> { RawPtr(Ty<'tcx>, Mutability), } -#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] -pub enum NullOp { - /// Returns whether we should perform some checking at runtime. - RuntimeChecks(RuntimeChecks), -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] -pub enum RuntimeChecks { - /// Returns whether we should perform some UB-checking at runtime. - /// See the `ub_checks` intrinsic docs for details. - UbChecks, - /// Returns whether we should perform contract-checking at runtime. - /// See the `contract_checks` intrinsic docs for details. - ContractChecks, - /// Returns whether we should perform some overflow-checking at runtime. - /// See the `overflow_checks` intrinsic docs for details. - OverflowChecks, -} - -impl RuntimeChecks { - pub fn value(self, sess: &rustc_session::Session) -> bool { - match self { - Self::UbChecks => sess.ub_checks(), - Self::ContractChecks => sess.contract_checks(), - Self::OverflowChecks => sess.overflow_checks(), - } - } -} - #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)] pub enum UnOp { diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 7f6c7376501f..4f599aea0254 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -293,9 +293,9 @@ pub fn reverse_postorder<'a, 'tcx>( /// reachable. /// /// Such a traversal is mostly useful because it lets us skip lowering the `false` side -/// of `if ::CONST`, as well as [`NullOp::RuntimeChecks`]. +/// of `if ::CONST`, as well as [`ConstValue::RuntimeChecks`]. /// -/// [`NullOp::RuntimeChecks`]: rustc_middle::mir::NullOp::RuntimeChecks +/// [`ConstValue::RuntimeChecks`]: rustc_middle::mir::ConstValue::RuntimeChecks pub fn mono_reachable<'a, 'tcx>( body: &'a Body<'tcx>, tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 6d251988cbbd..da9b2b97235e 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -775,8 +775,6 @@ macro_rules! make_mir_visitor { ); } - Rvalue::NullaryOp(_op) => {} - Rvalue::Aggregate(kind, operands) => { let kind = &$($mutability)? **kind; match kind { @@ -972,10 +970,7 @@ macro_rules! make_mir_visitor { self.visit_span($(& $mutability)? *span); match const_ { Const::Ty(_, ct) => self.visit_ty_const($(&$mutability)? *ct, location), - Const::Val(_, ty) => { - self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)); - } - Const::Unevaluated(_, ty) => { + Const::Val(_, ty) | Const::Unevaluated(_, ty) => { self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)); } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 4f70830002ce..5126d902a6d5 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -243,7 +243,6 @@ TrivialTypeTraversalImpls! { crate::mir::FakeReadCause, crate::mir::Local, crate::mir::MirPhase, - crate::mir::NullOp, crate::mir::Promoted, crate::mir::RawPtrKind, crate::mir::RetagKind, @@ -284,6 +283,7 @@ TrivialTypeTraversalImpls! { // interners). TrivialTypeTraversalAndLiftImpls! { // tidy-alphabetical-start + crate::mir::RuntimeChecks, crate::ty::BoundTy, crate::ty::ParamTy, crate::ty::instance::ReifyReason, diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs index 331e41bd126b..4b2c52ad7999 100644 --- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs +++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs @@ -91,7 +91,6 @@ where | Rvalue::ThreadLocalRef(..) | Rvalue::Repeat(..) | Rvalue::BinaryOp(..) - | Rvalue::NullaryOp(..) | Rvalue::UnaryOp(..) | Rvalue::Discriminant(..) | Rvalue::Aggregate(..) diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index 0cd3405d1e61..a90f3ef35444 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -448,10 +448,7 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> { } } Rvalue::CopyForDeref(..) => unreachable!(), - Rvalue::Ref(..) - | Rvalue::RawPtr(..) - | Rvalue::Discriminant(..) - | Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {} + Rvalue::Ref(..) | Rvalue::RawPtr(..) | Rvalue::Discriminant(..) => {} } } diff --git a/compiler/rustc_mir_transform/src/cost_checker.rs b/compiler/rustc_mir_transform/src/cost_checker.rs index 1a9af0e22bbe..8f975866d135 100644 --- a/compiler/rustc_mir_transform/src/cost_checker.rs +++ b/compiler/rustc_mir_transform/src/cost_checker.rs @@ -60,7 +60,7 @@ impl<'b, 'tcx> CostChecker<'b, 'tcx> { } impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { - fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { + fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) { // Most costs are in rvalues and terminators, not in statements. match statement.kind { StatementKind::Intrinsic(ref ndi) => { @@ -69,31 +69,8 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { NonDivergingIntrinsic::CopyNonOverlapping(..) => CALL_PENALTY, }; } - _ => self.super_statement(statement, location), - } - } - - fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, _location: Location) { - match rvalue { - // FIXME: Should we do the same for `OverflowChecks`? - Rvalue::NullaryOp(NullOp::RuntimeChecks(RuntimeChecks::UbChecks), ..) - if !self - .tcx - .sess - .opts - .unstable_opts - .inline_mir_preserve_debug - .unwrap_or(self.tcx.sess.ub_checks()) => - { - // If this is in optimized MIR it's because it's used later, - // so if we don't need UB checks this session, give a bonus - // here to offset the cost of the call later. - self.bonus += CALL_PENALTY; - } - // These are essentially constants that didn't end up in an Operand, - // so treat them as also being free. - Rvalue::NullaryOp(..) => {} - _ => self.penalty += INSTR_COST, + StatementKind::Assign(..) => self.penalty += INSTR_COST, + _ => {} } } diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index bccdd526ab7f..232f07d31adb 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -463,9 +463,6 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { FlatSet::Top => FlatSet::Top, } } - Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => { - return ValueOrPlace::TOP; - } Rvalue::Discriminant(place) => state.get_discr(place.as_ref(), &self.map), Rvalue::Use(operand) => return self.handle_operand(operand, state), Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in runtime MIR"), diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 92c74e7fc276..f6bf678af5ba 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -248,7 +248,6 @@ enum Value<'a, 'tcx> { Discriminant(VnIndex), // Operations. - NullaryOp(NullOp), UnaryOp(UnOp, VnIndex), BinaryOp(BinOp, VnIndex, VnIndex), Cast { @@ -681,7 +680,6 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { self.ecx.discriminant_for_variant(base.layout.ty, variant).discard_err()?; discr_value.into() } - NullaryOp(NullOp::RuntimeChecks(_)) => return None, UnaryOp(un_op, operand) => { let operand = self.eval_to_const(operand)?; let operand = self.ecx.read_immediate(operand).discard_err()?; @@ -1034,7 +1032,6 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { let op = self.simplify_operand(op, location)?; Value::Repeat(op, amount) } - Rvalue::NullaryOp(op) => Value::NullaryOp(op), Rvalue::Aggregate(..) => return self.simplify_aggregate(lhs, rvalue, location), Rvalue::Ref(_, borrow_kind, ref mut place) => { self.simplify_place_projection(place, location); diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 4922d74743c9..7cb341818fab 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -4,10 +4,11 @@ use rustc_abi::ExternAbi; use rustc_ast::attr; use rustc_hir::LangItem; use rustc_middle::bug; +use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::*; use rustc_middle::ty::layout::ValidityRequirement; use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, layout}; -use rustc_span::{DUMMY_SP, Symbol, sym}; +use rustc_span::{Symbol, sym}; use crate::simplify::simplify_duplicate_switch_targets; @@ -29,22 +30,22 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify { } fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + let preserve_ub_checks = + attr::contains_name(tcx.hir_krate_attrs(), sym::rustc_preserve_ub_checks); + if !preserve_ub_checks { + SimplifyUbCheck { tcx }.visit_body(body); + } let ctx = InstSimplifyContext { tcx, local_decls: &body.local_decls, typing_env: body.typing_env(tcx), }; - let preserve_ub_checks = - attr::contains_name(tcx.hir_krate_attrs(), sym::rustc_preserve_ub_checks); for block in body.basic_blocks.as_mut() { for statement in block.statements.iter_mut() { let StatementKind::Assign(box (.., rvalue)) = &mut statement.kind else { continue; }; - if !preserve_ub_checks { - ctx.simplify_ub_check(rvalue); - } ctx.simplify_bool_cmp(rvalue); ctx.simplify_ref_deref(rvalue); ctx.simplify_ptr_aggregate(rvalue); @@ -168,17 +169,6 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> { } } - fn simplify_ub_check(&self, rvalue: &mut Rvalue<'tcx>) { - // FIXME: Should we do the same for overflow checks? - let Rvalue::NullaryOp(NullOp::RuntimeChecks(RuntimeChecks::UbChecks)) = *rvalue else { - return; - }; - - let const_ = Const::from_bool(self.tcx, self.tcx.sess.ub_checks()); - let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None }; - *rvalue = Rvalue::Use(Operand::Constant(Box::new(constant))); - } - fn simplify_cast(&self, rvalue: &mut Rvalue<'tcx>) { let Rvalue::Cast(kind, operand, cast_ty) = rvalue else { return }; @@ -362,3 +352,22 @@ fn resolve_rust_intrinsic<'tcx>( let intrinsic = tcx.intrinsic(def_id)?; Some((intrinsic.name, args)) } + +struct SimplifyUbCheck<'tcx> { + tcx: TyCtxt<'tcx>, +} + +impl<'tcx> MutVisitor<'tcx> for SimplifyUbCheck<'tcx> { + fn tcx(&self) -> TyCtxt<'tcx> { + self.tcx + } + + fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) { + if let Operand::Constant(c) = operand + && let Const::Val(c, _) = &mut c.const_ + && let ConstValue::RuntimeChecks(RuntimeChecks::UbChecks) = c + { + *c = ConstValue::from_bool(self.tcx.sess.ub_checks()); + } + } +} diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 1f5d31932f1a..53cb02d9c5b2 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -444,7 +444,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { | Rvalue::Cast(..) | Rvalue::ShallowInitBox(..) | Rvalue::Discriminant(..) - | Rvalue::NullaryOp(..) | Rvalue::WrapUnsafeBinder(..) => {} } @@ -605,8 +604,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { Ref(..) | RawPtr(..) => return None, - NullaryOp(NullOp::RuntimeChecks(_)) => return None, - ShallowInitBox(..) => return None, Cast(ref kind, ref value, to) => match kind { diff --git a/compiler/rustc_mir_transform/src/lint.rs b/compiler/rustc_mir_transform/src/lint.rs index 2ab49645dc44..88297a4efef7 100644 --- a/compiler/rustc_mir_transform/src/lint.rs +++ b/compiler/rustc_mir_transform/src/lint.rs @@ -88,7 +88,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Lint<'a, 'tcx> { | Rvalue::ShallowInitBox(..) | Rvalue::WrapUnsafeBinder(..) => true, Rvalue::ThreadLocalRef(..) - | Rvalue::NullaryOp(..) | Rvalue::UnaryOp(..) | Rvalue::BinaryOp(..) | Rvalue::Ref(..) diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index f25874fbbcb8..6740aa97fc8b 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -35,7 +35,14 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics { terminator.source_info, StatementKind::Assign(Box::new(( *destination, - Rvalue::NullaryOp(NullOp::RuntimeChecks(op)), + Rvalue::Use(Operand::Constant(Box::new(ConstOperand { + span: terminator.source_info.span, + user_ty: None, + const_: Const::Val( + ConstValue::RuntimeChecks(op), + tcx.types.bool, + ), + }))), ))), )); terminator.kind = TerminatorKind::Goto { target }; diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 7d631e96c32a..506cfb7abf92 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -443,10 +443,6 @@ impl<'tcx> Validator<'_, 'tcx> { self.validate_operand(operand)?; } - Rvalue::NullaryOp(op) => match op { - NullOp::RuntimeChecks(_) => {} - }, - Rvalue::ShallowInitBox(_, _) => return Err(Unpromotable), Rvalue::UnaryOp(op, operand) => { diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index cf8247c12abd..1afdb4639a0c 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -1439,7 +1439,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { Rvalue::Repeat(_, _) | Rvalue::ThreadLocalRef(_) | Rvalue::RawPtr(_, _) - | Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) | Rvalue::Discriminant(_) => {} Rvalue::WrapUnsafeBinder(op, ty) => { diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index 0c35b3b25dfc..5ede5b2b2712 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -53,6 +53,7 @@ pub(crate) fn try_new_allocation<'tcx>( ConstValue::Scalar(scalar) => { alloc::try_new_scalar(layout, scalar, cx).map(|alloc| alloc.stable(tables, cx)) } + ConstValue::RuntimeChecks(_) => todo!(), ConstValue::ZeroSized => Ok(new_empty_allocation(layout.align.abi)), ConstValue::Slice { alloc_id, meta } => { alloc::try_new_slice(layout, alloc_id, meta, cx).map(|alloc| alloc.stable(tables, cx)) diff --git a/compiler/rustc_public/src/mir/body.rs b/compiler/rustc_public/src/mir/body.rs index 03f289f30f42..92882a001c47 100644 --- a/compiler/rustc_public/src/mir/body.rs +++ b/compiler/rustc_public/src/mir/body.rs @@ -587,9 +587,6 @@ pub enum Rvalue { /// nature of this operation? ThreadLocalRef(crate::CrateItem), - /// Computes a value as described by the operation. - NullaryOp(NullOp), - /// Exactly like `BinaryOp`, but less operands. /// /// Also does two's-complement arithmetic. Negation requires a signed integer or a float; @@ -641,7 +638,6 @@ impl Rvalue { .discriminant_ty() .ok_or_else(|| error!("Expected a `RigidTy` but found: {place_ty:?}")) } - Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => Ok(Ty::bool_ty()), Rvalue::Aggregate(ak, ops) => match *ak { AggregateKind::Array(ty) => Ty::try_new_array(ty, ops.len() as u64), AggregateKind::Tuple => Ok(Ty::new_tuple( @@ -1018,22 +1014,6 @@ pub enum CastKind { Subtype, } -#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)] -pub enum NullOp { - /// Codegen conditions for runtime checks. - RuntimeChecks(RuntimeChecks), -} - -#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)] -pub enum RuntimeChecks { - /// cfg!(ub_checks), but at codegen time - UbChecks, - /// cfg!(contract_checks), but at codegen time - ContractChecks, - /// cfg!(overflow_checks), but at codegen time - OverflowChecks, -} - impl Operand { /// Get the type of an operand relative to the local declaration. /// diff --git a/compiler/rustc_public/src/mir/pretty.rs b/compiler/rustc_public/src/mir/pretty.rs index 08e4e0c7e0f9..d814947dc397 100644 --- a/compiler/rustc_public/src/mir/pretty.rs +++ b/compiler/rustc_public/src/mir/pretty.rs @@ -386,9 +386,6 @@ fn pretty_rvalue(writer: &mut W, rval: &Rvalue) -> io::Result<()> { Rvalue::ThreadLocalRef(item) => { write!(writer, "thread_local_ref{item:?}") } - Rvalue::NullaryOp(nul) => { - write!(writer, "{nul:?}() \" \"") - } Rvalue::UnaryOp(un, op) => { write!(writer, "{:?}({})", un, pretty_operand(op)) } diff --git a/compiler/rustc_public/src/mir/visit.rs b/compiler/rustc_public/src/mir/visit.rs index 35af39c43a27..f0fdbe059383 100644 --- a/compiler/rustc_public/src/mir/visit.rs +++ b/compiler/rustc_public/src/mir/visit.rs @@ -282,7 +282,6 @@ macro_rules! make_mir_visitor { self.visit_operand(op, location) } Rvalue::ThreadLocalRef(_) => {} - Rvalue::NullaryOp(_) => {} Rvalue::UnaryOp(_, op) | Rvalue::Use(op) => { self.visit_operand(op, location); } diff --git a/compiler/rustc_public/src/ty.rs b/compiler/rustc_public/src/ty.rs index 14656a2e594a..a87ac795da5c 100644 --- a/compiler/rustc_public/src/ty.rs +++ b/compiler/rustc_public/src/ty.rs @@ -1357,6 +1357,7 @@ pub enum ConstantKind { Ty(TyConst), Allocated(Allocation), Unevaluated(UnevaluatedConst), + RuntimeChecks(RuntimeChecks), Param(ParamConst), /// Store ZST constants. /// We have to special handle these constants since its type might be generic. @@ -1376,6 +1377,16 @@ pub struct UnevaluatedConst { pub promoted: Option, } +#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)] +pub enum RuntimeChecks { + /// cfg!(ub_checks), but at codegen time + UbChecks, + /// cfg!(contract_checks), but at codegen time + ContractChecks, + /// cfg!(overflow_checks), but at codegen time + OverflowChecks, +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)] pub enum TraitSpecializationKind { None, diff --git a/compiler/rustc_public/src/unstable/convert/stable/mir.rs b/compiler/rustc_public/src/unstable/convert/stable/mir.rs index e7a1c8218ce4..31f41653d4a2 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mir.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mir.rs @@ -232,7 +232,6 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { ) } } - NullaryOp(null_op) => crate::mir::Rvalue::NullaryOp(null_op.stable(tables, cx)), UnaryOp(un_op, op) => { crate::mir::Rvalue::UnaryOp(un_op.stable(tables, cx), op.stable(tables, cx)) } @@ -312,21 +311,18 @@ impl<'tcx> Stable<'tcx> for mir::FakeBorrowKind { } } -impl<'tcx> Stable<'tcx> for mir::NullOp { - type T = crate::mir::NullOp; +impl<'tcx> Stable<'tcx> for mir::RuntimeChecks { + type T = crate::ty::RuntimeChecks; fn stable<'cx>( &self, _: &mut Tables<'cx, BridgeTys>, _: &CompilerCtxt<'cx, BridgeTys>, ) -> Self::T { - use rustc_middle::mir::NullOp::*; use rustc_middle::mir::RuntimeChecks::*; match self { - RuntimeChecks(op) => crate::mir::NullOp::RuntimeChecks(match op { - UbChecks => crate::mir::RuntimeChecks::UbChecks, - ContractChecks => crate::mir::RuntimeChecks::ContractChecks, - OverflowChecks => crate::mir::RuntimeChecks::OverflowChecks, - }), + UbChecks => crate::ty::RuntimeChecks::UbChecks, + ContractChecks => crate::ty::RuntimeChecks::ContractChecks, + OverflowChecks => crate::ty::RuntimeChecks::OverflowChecks, } } } @@ -890,6 +886,13 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> { let ty = ty.stable(tables, cx); MirConst::new(ConstantKind::ZeroSized, ty, id) } + mir::Const::Val(mir::ConstValue::RuntimeChecks(checks), ty) => { + let ty = cx.lift(ty).unwrap(); + let checks = cx.lift(checks).unwrap(); + let ty = ty.stable(tables, cx); + let kind = ConstantKind::RuntimeChecks(checks.stable(tables, cx)); + MirConst::new(kind, ty, id) + } mir::Const::Val(val, ty) => { let ty = cx.lift(ty).unwrap(); let val = cx.lift(val).unwrap(); diff --git a/compiler/rustc_public/src/visitor.rs b/compiler/rustc_public/src/visitor.rs index acc333476961..2ebd73a43e90 100644 --- a/compiler/rustc_public/src/visitor.rs +++ b/compiler/rustc_public/src/visitor.rs @@ -68,7 +68,9 @@ impl Visitable for MirConst { super::ty::ConstantKind::Ty(ct) => ct.visit(visitor)?, super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor)?, super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor)?, - super::ty::ConstantKind::Param(_) | super::ty::ConstantKind::ZeroSized => {} + super::ty::ConstantKind::RuntimeChecks(_) + | super::ty::ConstantKind::Param(_) + | super::ty::ConstantKind::ZeroSized => {} } self.ty().visit(visitor) } diff --git a/library/core/src/ub_checks.rs b/library/core/src/ub_checks.rs index 50e02320748b..f25781ea8ce5 100644 --- a/library/core/src/ub_checks.rs +++ b/library/core/src/ub_checks.rs @@ -95,17 +95,16 @@ pub use intrinsics::ub_checks as check_library_ub; #[rustc_allow_const_fn_unstable(const_eval_select)] pub(crate) const fn check_language_ub() -> bool { // Only used for UB checks so we may const_eval_select. - intrinsics::ub_checks() - && const_eval_select!( - @capture { } -> bool: - if const { - // Always disable UB checks. - false - } else { - // Disable UB checks in Miri. - !cfg!(miri) - } - ) + const_eval_select!( + @capture { } -> bool: + if const { + // Always disable UB checks. + false + } else { + // Disable UB checks in Miri. + !cfg!(miri) + } + ) && intrinsics::ub_checks() } /// Checks whether `ptr` is properly aligned with respect to the given alignment, and diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 462cc644d4be..c1d00fc8d371 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -13,7 +13,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::Obligation; use rustc_lint::LateContext; use rustc_middle::mir::{ - Body, CastKind, NonDivergingIntrinsic, NullOp, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, + Body, CastKind, NonDivergingIntrinsic, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, }; use rustc_middle::traits::{BuiltinImplSource, ImplSource, ObligationCause}; @@ -194,7 +194,7 @@ fn check_rvalue<'tcx>( )) } }, - Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) | Rvalue::ShallowInitBox(_, _) => Ok(()), + Rvalue::ShallowInitBox(_, _) => Ok(()), Rvalue::UnaryOp(_, operand) => { let ty = operand.ty(body, cx.tcx); if ty.is_integral() || ty.is_bool() { diff --git a/tests/codegen-llvm/slice-iter-len-eq-zero.rs b/tests/codegen-llvm/slice-iter-len-eq-zero.rs index 6998d98e498c..ae1bdb1d58b9 100644 --- a/tests/codegen-llvm/slice-iter-len-eq-zero.rs +++ b/tests/codegen-llvm/slice-iter-len-eq-zero.rs @@ -8,8 +8,10 @@ type Demo = [u8; 3]; #[no_mangle] pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { // CHECK-NOT: sub - // CHECK: %[[RET:.+]] = icmp eq ptr {{%y.0, %y.1|%y.1, %y.0}} - // CHECK: ret i1 %[[RET]] + // CHECK: %2 = icmp ne ptr %1, null + // CHECK-NEXT: tail call void @llvm.assume(i1 %2) + // CHECK-NEXT: %[[RET:.+]] = icmp eq ptr {{%0, %1|%1, %0}} + // CHECK-NEXT: ret i1 %[[RET]] y.len() == 0 } @@ -31,7 +33,7 @@ struct MyZST; // CHECK-LABEL: @slice_zst_iter_len_eq_zero #[no_mangle] pub fn slice_zst_iter_len_eq_zero(y: std::slice::Iter<'_, MyZST>) -> bool { - // CHECK: %[[RET:.+]] = icmp eq ptr %y.1, null + // CHECK: %[[RET:.+]] = icmp eq ptr %1, null // CHECK: ret i1 %[[RET]] y.len() == 0 } diff --git a/tests/mir-opt/const_prop/trivial_const.unwrap_unchecked.SimplifyConstCondition-after-inst-simplify.diff b/tests/mir-opt/const_prop/trivial_const.unwrap_unchecked.SimplifyConstCondition-after-inst-simplify.diff index d14c42a330eb..4714e159396e 100644 --- a/tests/mir-opt/const_prop/trivial_const.unwrap_unchecked.SimplifyConstCondition-after-inst-simplify.diff +++ b/tests/mir-opt/const_prop/trivial_const.unwrap_unchecked.SimplifyConstCondition-after-inst-simplify.diff @@ -16,7 +16,6 @@ scope 4 (inlined #[track_caller] unreachable_unchecked) { let _5: (); scope 5 (inlined core::ub_checks::check_language_ub) { - let mut _6: bool; scope 6 (inlined core::ub_checks::check_language_ub::runtime) { } } @@ -38,9 +37,7 @@ } bb2: { -- StorageLive(_6); -- _6 = const false; -- assume(copy _6); +- assume(const false); - _5 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + unreachable; } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index 38beb81e1ead..ae2b8e574303 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -13,7 +13,7 @@ let mut _11: *const (); let mut _16: usize; let mut _17: usize; - let mut _27: usize; + let mut _26: usize; scope 1 { debug vp_ctx => _1; let _5: *const (); @@ -27,7 +27,7 @@ debug _x => _8; } scope 18 (inlined foo) { - let mut _28: *const [()]; + let mut _27: *const [()]; } } scope 16 (inlined slice_from_raw_parts::<()>) { @@ -52,7 +52,7 @@ scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { scope 13 (inlined NonNull::<[u8]>::cast::) { - let mut _26: *mut [u8]; + let mut _25: *mut [u8]; scope 14 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -65,9 +65,8 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let mut _23: bool; - let _24: (); - let mut _25: std::ptr::Alignment; + let _23: (); + let mut _24: std::ptr::Alignment; } } } @@ -94,10 +93,8 @@ StorageLive(_20); StorageLive(_21); StorageLive(_22); - StorageLive(_24); StorageLive(_23); - _23 = UbChecks(); - switchInt(move _23) -> [0: bb6, otherwise: bb5]; + switchInt(const UbChecks) -> [0: bb6, otherwise: bb5]; } bb1: { @@ -117,14 +114,14 @@ bb4: { _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_26); +- StorageLive(_25); + nop; - _26 = copy _21 as *mut [u8] (Transmute); - _12 = copy _26 as *mut u8 (PtrToPtr); -- StorageDead(_26); + _25 = copy _21 as *mut [u8] (Transmute); + _12 = copy _25 as *mut u8 (PtrToPtr); +- StorageDead(_25); + nop; StorageDead(_19); - StorageDead(_24); + StorageDead(_23); StorageDead(_22); StorageDead(_21); StorageDead(_20); @@ -132,7 +129,7 @@ StorageDead(_17); StorageDead(_16); - _13 = copy _12 as *const () (PtrToPtr); -+ _13 = copy _26 as *const () (PtrToPtr); ++ _13 = copy _25 as *const () (PtrToPtr); _14 = NonNull::<()> { pointer: copy _13 }; _15 = Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; _3 = Box::<()>(move _15, const std::alloc::Global); @@ -157,21 +154,21 @@ + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_27); - _27 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _27); + StorageLive(_26); + _26 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _26); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_27); + StorageDead(_26); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_28); -- _28 = copy _9; + StorageLive(_27); +- _27 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _28 = copy _6; ++ _27 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_28); + StorageDead(_27); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -183,18 +180,17 @@ } bb5: { -- _24 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; -+ _24 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _23 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; ++ _23 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_23); - StorageLive(_25); -- _25 = copy _17 as std::ptr::Alignment (Transmute); -- _18 = Layout { size: copy _16, align: move _25 }; -+ _25 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + StorageLive(_24); +- _24 = copy _17 as std::ptr::Alignment (Transmute); +- _18 = Layout { size: copy _16, align: move _24 }; ++ _24 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; - StorageDead(_25); + StorageDead(_24); StorageLive(_19); - _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _18, const false) -> [return: bb7, unwind unreachable]; + _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index 047579cdb509..164aeb2d9037 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -13,7 +13,7 @@ let mut _11: *const (); let mut _16: usize; let mut _17: usize; - let mut _27: usize; + let mut _26: usize; scope 1 { debug vp_ctx => _1; let _5: *const (); @@ -27,7 +27,7 @@ debug _x => _8; } scope 18 (inlined foo) { - let mut _28: *const [()]; + let mut _27: *const [()]; } } scope 16 (inlined slice_from_raw_parts::<()>) { @@ -52,7 +52,7 @@ scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { scope 13 (inlined NonNull::<[u8]>::cast::) { - let mut _26: *mut [u8]; + let mut _25: *mut [u8]; scope 14 (inlined NonNull::<[u8]>::as_ptr) { } } @@ -65,9 +65,8 @@ } } scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { - let mut _23: bool; - let _24: (); - let mut _25: std::ptr::Alignment; + let _23: (); + let mut _24: std::ptr::Alignment; } } } @@ -94,10 +93,8 @@ StorageLive(_20); StorageLive(_21); StorageLive(_22); - StorageLive(_24); StorageLive(_23); - _23 = UbChecks(); - switchInt(move _23) -> [0: bb6, otherwise: bb5]; + switchInt(const UbChecks) -> [0: bb6, otherwise: bb5]; } bb1: { @@ -117,14 +114,14 @@ bb4: { _21 = copy ((_19 as Ok).0: std::ptr::NonNull<[u8]>); -- StorageLive(_26); +- StorageLive(_25); + nop; - _26 = copy _21 as *mut [u8] (Transmute); - _12 = copy _26 as *mut u8 (PtrToPtr); -- StorageDead(_26); + _25 = copy _21 as *mut [u8] (Transmute); + _12 = copy _25 as *mut u8 (PtrToPtr); +- StorageDead(_25); + nop; StorageDead(_19); - StorageDead(_24); + StorageDead(_23); StorageDead(_22); StorageDead(_21); StorageDead(_20); @@ -132,7 +129,7 @@ StorageDead(_17); StorageDead(_16); - _13 = copy _12 as *const () (PtrToPtr); -+ _13 = copy _26 as *const () (PtrToPtr); ++ _13 = copy _25 as *const () (PtrToPtr); _14 = NonNull::<()> { pointer: copy _13 }; _15 = Unique::<()> { pointer: copy _14, _marker: const PhantomData::<()> }; _3 = Box::<()>(move _15, const std::alloc::Global); @@ -157,21 +154,21 @@ + nop; StorageLive(_7); _7 = copy _5; - StorageLive(_27); - _27 = const 1_usize; -- _6 = *const [()] from (copy _7, copy _27); + StorageLive(_26); + _26 = const 1_usize; +- _6 = *const [()] from (copy _7, copy _26); + _6 = *const [()] from (copy _5, const 1_usize); - StorageDead(_27); + StorageDead(_26); StorageDead(_7); StorageLive(_8); StorageLive(_9); _9 = copy _6; - StorageLive(_28); -- _28 = copy _9; + StorageLive(_27); +- _27 = copy _9; - _8 = copy _9 as *mut () (PtrToPtr); -+ _28 = copy _6; ++ _27 = copy _6; + _8 = copy _5 as *mut () (PtrToPtr); - StorageDead(_28); + StorageDead(_27); StorageDead(_9); _0 = const (); StorageDead(_8); @@ -183,18 +180,17 @@ } bb5: { -- _24 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; -+ _24 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; +- _23 = Layout::from_size_align_unchecked::precondition_check(copy _16, copy _17) -> [return: bb6, unwind unreachable]; ++ _23 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_23); - StorageLive(_25); -- _25 = copy _17 as std::ptr::Alignment (Transmute); -- _18 = Layout { size: copy _16, align: move _25 }; -+ _25 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + StorageLive(_24); +- _24 = copy _17 as std::ptr::Alignment (Transmute); +- _18 = Layout { size: copy _16, align: move _24 }; ++ _24 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); + _18 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; - StorageDead(_25); + StorageDead(_24); StorageLive(_19); - _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _18, const false) -> [return: bb7, unwind unreachable]; + _19 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index 813796657b24..153e314fb6f4 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -10,7 +10,6 @@ + scope 1 (inlined #[track_caller] core::num::::unchecked_shl) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { -+ let mut _6: bool; + scope 3 (inlined core::ub_checks::check_language_ub::runtime) { + } + } @@ -23,9 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shl(move _3, move _4) -> [return: bb1, unwind unreachable]; + StorageLive(_5); -+ StorageLive(_6); -+ _6 = UbChecks(); -+ switchInt(copy _6) -> [0: bb2, otherwise: bb1]; ++ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { @@ -34,7 +31,6 @@ + + bb2: { + _0 = ShlUnchecked(copy _3, copy _4); -+ StorageDead(_6); + StorageDead(_5); StorageDead(_4); StorageDead(_3); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index 61fdb69f74b7..fd9f5838efc3 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -10,7 +10,6 @@ + scope 1 (inlined #[track_caller] core::num::::unchecked_shl) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { -+ let mut _6: bool; + scope 3 (inlined core::ub_checks::check_language_ub::runtime) { + } + } @@ -23,9 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shl(move _3, move _4) -> [return: bb1, unwind continue]; + StorageLive(_5); -+ StorageLive(_6); -+ _6 = UbChecks(); -+ switchInt(copy _6) -> [0: bb2, otherwise: bb1]; ++ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { @@ -34,7 +31,6 @@ + + bb2: { + _0 = ShlUnchecked(copy _3, copy _4); -+ StorageDead(_6); + StorageDead(_5); StorageDead(_4); StorageDead(_3); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff index 5ea99e8301b8..5b12c1853359 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff @@ -10,7 +10,6 @@ + scope 1 (inlined #[track_caller] core::num::::unchecked_shr) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { -+ let mut _6: bool; + scope 3 (inlined core::ub_checks::check_language_ub::runtime) { + } + } @@ -23,9 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shr(move _3, move _4) -> [return: bb1, unwind unreachable]; + StorageLive(_5); -+ StorageLive(_6); -+ _6 = UbChecks(); -+ switchInt(copy _6) -> [0: bb2, otherwise: bb1]; ++ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { @@ -34,7 +31,6 @@ + + bb2: { + _0 = ShrUnchecked(copy _3, copy _4); -+ StorageDead(_6); + StorageDead(_5); StorageDead(_4); StorageDead(_3); diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff index b13531ab148f..e8474898b995 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -10,7 +10,6 @@ + scope 1 (inlined #[track_caller] core::num::::unchecked_shr) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { -+ let mut _6: bool; + scope 3 (inlined core::ub_checks::check_language_ub::runtime) { + } + } @@ -23,9 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shr(move _3, move _4) -> [return: bb1, unwind continue]; + StorageLive(_5); -+ StorageLive(_6); -+ _6 = UbChecks(); -+ switchInt(copy _6) -> [0: bb2, otherwise: bb1]; ++ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { @@ -34,7 +31,6 @@ + + bb2: { + _0 = ShrUnchecked(copy _3, copy _4); -+ StorageDead(_6); + StorageDead(_5); StorageDead(_4); StorageDead(_3); diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index 0119dd799704..7bd93b804e7f 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -12,7 +12,6 @@ + scope 3 (inlined #[track_caller] unreachable_unchecked) { + let _4: (); + scope 4 (inlined core::ub_checks::check_language_ub) { -+ let mut _5: bool; + scope 5 (inlined core::ub_checks::check_language_ub::runtime) { + } + } @@ -34,9 +33,7 @@ + } + + bb2: { -+ StorageLive(_5); -+ _5 = UbChecks(); -+ assume(copy _5); ++ assume(const UbChecks); + _4 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index d6a5eab1d6e9..ae194db56cc9 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -12,7 +12,6 @@ + scope 3 (inlined #[track_caller] unreachable_unchecked) { + let _4: (); + scope 4 (inlined core::ub_checks::check_language_ub) { -+ let mut _5: bool; + scope 5 (inlined core::ub_checks::check_language_ub::runtime) { + } + } @@ -38,9 +37,7 @@ - bb2 (cleanup): { - resume; + bb2: { -+ StorageLive(_5); -+ _5 = UbChecks(); -+ assume(copy _5); ++ assume(const UbChecks); + _4 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + diff --git a/tests/mir-opt/instsimplify/ub_check.rs b/tests/mir-opt/instsimplify/ub_check.rs index b513f60dc7b9..db890c184079 100644 --- a/tests/mir-opt/instsimplify/ub_check.rs +++ b/tests/mir-opt/instsimplify/ub_check.rs @@ -5,8 +5,7 @@ pub fn unwrap_unchecked(x: Option) -> i32 { // CHECK-LABEL: fn unwrap_unchecked( // CHECK-NOT: UbChecks() - // CHECK: [[assume:_.*]] = const false; - // CHECK-NEXT: assume(copy [[assume]]); + // CHECK: assume(const false); // CHECK-NEXT: unreachable_unchecked::precondition_check unsafe { x.unwrap_unchecked() } } diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff index 2c9071e6e207..890c87880441 100644 --- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff @@ -12,7 +12,6 @@ scope 3 (inlined #[track_caller] unreachable_unchecked) { let _4: (); scope 4 (inlined core::ub_checks::check_language_ub) { - let mut _5: bool; scope 5 (inlined core::ub_checks::check_language_ub::runtime) { } } @@ -33,10 +32,8 @@ } bb2: { - StorageLive(_5); -- _5 = UbChecks(); -+ _5 = const false; - assume(copy _5); +- assume(const UbChecks); ++ assume(const false); _4 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; } From a0de5ae5a1933acfc0a161d945b1ce1d05c7e82e Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 9 Nov 2025 02:57:31 +0000 Subject: [PATCH 153/489] Replace Rvalue::NullaryOp by a variant in mir::ConstValue. --- src/base.rs | 13 +------------ src/constant.rs | 5 +++++ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/base.rs b/src/base.rs index ac5b3c240785..4dbee7665eb8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -10,7 +10,7 @@ use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; -use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv}; +use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -853,17 +853,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: fx.bcx.ins().nop(); } } - Rvalue::NullaryOp(ref null_op) => { - assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env())); - let val = match null_op { - NullOp::RuntimeChecks(kind) => kind.value(fx.tcx.sess), - }; - let val = CValue::by_val( - fx.bcx.ins().iconst(types::I8, i64::from(val)), - fx.layout_of(fx.tcx.types.bool), - ); - lval.write_cvalue(fx, val); - } Rvalue::Aggregate(ref kind, ref operands) if matches!(**kind, AggregateKind::RawPtr(..)) => { diff --git a/src/constant.rs b/src/constant.rs index 2b65b8290681..29c8e8ab1e52 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -215,6 +215,11 @@ pub(crate) fn codegen_const_value<'tcx>( CValue::by_val(val, layout) } }, + ConstValue::RuntimeChecks(checks) => { + let int = checks.value(fx.tcx.sess); + let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + return CValue::const_val(fx, layout, int); + } ConstValue::Indirect { alloc_id, offset } => CValue::by_ref( Pointer::new(pointer_for_allocation(fx, alloc_id)) .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), From 8e967a5a7b6c6250d2dc61287bb8e737500216b9 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 9 Nov 2025 02:57:31 +0000 Subject: [PATCH 154/489] Replace Rvalue::NullaryOp by a variant in mir::ConstValue. --- clippy_utils/src/qualify_min_const_fn.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 462cc644d4be..c1d00fc8d371 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -13,7 +13,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::Obligation; use rustc_lint::LateContext; use rustc_middle::mir::{ - Body, CastKind, NonDivergingIntrinsic, NullOp, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, + Body, CastKind, NonDivergingIntrinsic, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, }; use rustc_middle::traits::{BuiltinImplSource, ImplSource, ObligationCause}; @@ -194,7 +194,7 @@ fn check_rvalue<'tcx>( )) } }, - Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) | Rvalue::ShallowInitBox(_, _) => Ok(()), + Rvalue::ShallowInitBox(_, _) => Ok(()), Rvalue::UnaryOp(_, operand) => { let ty = operand.ty(body, cx.tcx); if ty.is_integral() || ty.is_bool() { From 6319bee585561a078de4a0f8d07d567ce69cf12c Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 16 Nov 2025 19:21:17 +0000 Subject: [PATCH 155/489] Introduce Operand::RuntimeChecks. --- .../src/diagnostics/explain_borrow.rs | 2 + compiler/rustc_borrowck/src/lib.rs | 4 +- .../src/polonius/legacy/loan_invalidations.rs | 2 +- compiler/rustc_borrowck/src/type_check/mod.rs | 2 +- compiler/rustc_codegen_cranelift/src/base.rs | 8 +++- .../rustc_codegen_cranelift/src/constant.rs | 9 ++--- compiler/rustc_codegen_ssa/src/mir/operand.rs | 19 +++++---- .../src/check_consts/qualifs.rs | 1 + .../src/const_eval/dummy_machine.rs | 7 ++++ .../src/const_eval/machine.rs | 10 +++++ .../rustc_const_eval/src/interpret/machine.rs | 12 +----- .../rustc_const_eval/src/interpret/operand.rs | 9 +++-- .../rustc_const_eval/src/interpret/step.rs | 2 +- compiler/rustc_middle/src/mir/consts.rs | 39 ++----------------- compiler/rustc_middle/src/mir/mod.rs | 7 ++-- compiler/rustc_middle/src/mir/pretty.rs | 3 +- compiler/rustc_middle/src/mir/statement.rs | 8 ++-- compiler/rustc_middle/src/mir/syntax.rs | 27 +++++++++++++ compiler/rustc_middle/src/mir/visit.rs | 1 + .../src/builder/custom/parse.rs | 1 + compiler/rustc_mir_build/src/builder/scope.rs | 4 +- .../src/move_paths/builder.rs | 5 ++- .../rustc_mir_transform/src/cost_checker.rs | 2 +- .../src/dataflow_const_prop.rs | 4 +- .../src/early_otherwise_branch.rs | 6 +-- .../src/function_item_references.rs | 7 +--- compiler/rustc_mir_transform/src/gvn.rs | 10 +++++ .../rustc_mir_transform/src/instsimplify.rs | 14 ++++--- .../rustc_mir_transform/src/jump_threading.rs | 1 + .../src/known_panics_lint.rs | 1 + compiler/rustc_mir_transform/src/lib.rs | 2 +- .../src/lower_intrinsics.rs | 9 +---- .../rustc_mir_transform/src/promote_consts.rs | 3 ++ .../src/simplify_branches.rs | 2 +- compiler/rustc_mir_transform/src/sroa.rs | 13 ++++--- compiler/rustc_public/src/alloc.rs | 1 - compiler/rustc_public/src/mir/body.rs | 12 ++++++ compiler/rustc_public/src/mir/pretty.rs | 1 + compiler/rustc_public/src/mir/visit.rs | 1 + compiler/rustc_public/src/ty.rs | 11 ------ .../src/unstable/convert/stable/mir.rs | 16 +++----- compiler/rustc_public/src/visitor.rs | 4 +- .../clippy_utils/src/mir/possible_borrower.rs | 4 +- .../clippy_utils/src/qualify_min_const_fn.rs | 1 + tests/codegen-llvm/slice-iter-len-eq-zero.rs | 8 ++-- 45 files changed, 167 insertions(+), 148 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 8e18bf557758..743a28822eb9 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -764,6 +764,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { { // Just point to the function, to reduce the chance of overlapping spans. let function_span = match func { + Operand::RuntimeChecks(_) => span, Operand::Constant(c) => c.span, Operand::Copy(place) | Operand::Move(place) => { if let Some(l) = place.as_local() { @@ -809,6 +810,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { { // Just point to the function, to reduce the chance of overlapping spans. let function_span = match func { + Operand::RuntimeChecks(_) => span, Operand::Constant(c) => c.span, Operand::Copy(place) | Operand::Move(place) => { if let Some(l) = place.as_local() { diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index d15983075af2..72956f245bf9 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1696,7 +1696,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { _ => propagate_closure_used_mut_place(self, place), } } - Operand::Constant(..) => {} + Operand::Constant(..) | Operand::RuntimeChecks(_) => {} } } @@ -1747,7 +1747,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { state, ); } - Operand::Constant(_) => {} + Operand::Constant(_) | Operand::RuntimeChecks(_) => {} } } diff --git a/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs index 85a08b7399e5..d2eae2c7e65a 100644 --- a/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs +++ b/compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs @@ -247,7 +247,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> { LocalMutationIsAllowed::Yes, ); } - Operand::Constant(_) => {} + Operand::Constant(_) | Operand::RuntimeChecks(_) => {} } } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 3507a1f8503c..097416b4f280 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1023,7 +1023,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { // element, so we require the `Copy` trait. if len.try_to_target_usize(tcx).is_none_or(|len| len > 1) { match operand { - Operand::Copy(..) | Operand::Constant(..) => { + Operand::Copy(..) | Operand::Constant(..) | Operand::RuntimeChecks(_) => { // These are always okay: direct use of a const, or a value that can // evidently be copied. } diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 4dbee7665eb8..79f65141e66f 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; -use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; +use rustc_middle::ty::{ScalarInt, TypeVisitableExt}; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -1039,6 +1039,12 @@ pub(crate) fn codegen_operand<'tcx>( cplace.to_cvalue(fx) } Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_), + Operand::RuntimeChecks(checks) => { + let int = checks.value(fx.tcx.sess); + let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + let layout = fx.layout_of(fx.tcx.types.bool); + return CValue::const_val(fx, layout, int); + } } } diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 29c8e8ab1e52..c25034d4be22 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -215,11 +215,6 @@ pub(crate) fn codegen_const_value<'tcx>( CValue::by_val(val, layout) } }, - ConstValue::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); - return CValue::const_val(fx, layout, int); - } ConstValue::Indirect { alloc_id, offset } => CValue::by_ref( Pointer::new(pointer_for_allocation(fx, alloc_id)) .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), @@ -545,6 +540,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option { match operand { + Operand::RuntimeChecks(checks) => { + let int = checks.value(fx.tcx.sess); + ScalarInt::try_from_uint(int, Size::from_bits(1)) + } Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(), // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored // inside a temporary before being passed to the intrinsic requiring the const argument. diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index 29108043feff..aa80812388af 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -165,14 +165,6 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout)); OperandValue::Immediate(llval) } - mir::ConstValue::RuntimeChecks(checks) => { - let BackendRepr::Scalar(scalar) = layout.backend_repr else { - bug!("from_const: invalid ByVal layout: {:#?}", layout); - }; - let x = Scalar::from_bool(checks.value(bx.tcx().sess)); - let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout)); - OperandValue::Immediate(llval) - } ConstValue::ZeroSized => return OperandRef::zero_sized(layout), ConstValue::Slice { alloc_id, meta } => { let BackendRepr::ScalarPair(a_scalar, _) = layout.backend_repr else { @@ -1060,6 +1052,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { OperandRef { move_annotation, ..self.codegen_consume(bx, place.as_ref()) } } + mir::Operand::RuntimeChecks(checks) => { + let layout = bx.layout_of(bx.tcx().types.bool); + let BackendRepr::Scalar(scalar) = layout.backend_repr else { + bug!("from_const: invalid ByVal layout: {:#?}", layout); + }; + let x = Scalar::from_bool(checks.value(bx.tcx().sess)); + let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout)); + let val = OperandValue::Immediate(llval); + OperandRef { val, layout, move_annotation: None } + } + mir::Operand::Constant(ref constant) => { let constant_ty = self.monomorphize(constant.ty()); // Most SIMD vector constants should be passed as immediates. diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index 49a477d8fdba..42943648ffdd 100644 --- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs @@ -338,6 +338,7 @@ where Operand::Copy(place) | Operand::Move(place) => { return in_place::(cx, in_local, place.as_ref()); } + Operand::RuntimeChecks(_) => return Q::in_any_value_of_ty(cx, cx.tcx.types.bool), Operand::Constant(c) => c, }; diff --git a/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs b/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs index 438aed41b8be..40acff416bb0 100644 --- a/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs @@ -122,6 +122,13 @@ impl<'tcx> interpret::Machine<'tcx> for DummyMachine { unimplemented!() } + #[inline(always)] + fn runtime_checks(_ecx: &InterpCx<'tcx, Self>, r: RuntimeChecks) -> InterpResult<'tcx, bool> { + // We can't look at `tcx.sess` here as that can differ across crates, which can lead to + // unsound differences in evaluating the same constant at different instantiation sites. + panic!("compiletime machine evaluated {r:?}") + } + fn binary_ptr_op( ecx: &InterpCx<'tcx, Self>, bin_op: BinOp, diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 0c677b34df7b..7538130e9d92 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -637,6 +637,16 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> { Err(ConstEvalErrKind::AssertFailure(err)).into() } + #[inline(always)] + fn runtime_checks( + _ecx: &InterpCx<'tcx, Self>, + _r: mir::RuntimeChecks, + ) -> InterpResult<'tcx, bool> { + // We can't look at `tcx.sess` here as that can differ across crates, which can lead to + // unsound differences in evaluating the same constant at different instantiation sites. + interp_ok(true) + } + fn binary_ptr_op( _ecx: &InterpCx<'tcx, Self>, _bin_op: mir::BinOp, diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 753b2dd3b8ea..62ca47d23b4c 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -298,7 +298,7 @@ pub trait Machine<'tcx>: Sized { interp_ok(()) } - /// Determines the result of a `NullaryOp::RuntimeChecks` invocation. + /// Determines the result of a `Operand::RuntimeChecks` invocation. fn runtime_checks( _ecx: &InterpCx<'tcx, Self>, r: mir::RuntimeChecks, @@ -680,16 +680,6 @@ pub macro compile_time_machine(<$tcx: lifetime>) { true } - #[inline(always)] - fn runtime_checks( - _ecx: &InterpCx<$tcx, Self>, - _r: mir::RuntimeChecks, - ) -> InterpResult<$tcx, bool> { - // We can't look at `tcx.sess` here as that can differ across crates, which can lead to - // unsound differences in evaluating the same constant at different instantiation sites. - interp_ok(true) - } - #[inline(always)] fn adjust_global_allocation<'b>( _ecx: &InterpCx<$tcx, Self>, diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 32d08d064923..9a956259ba57 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -845,6 +845,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // FIXME: do some more logic on `move` to invalidate the old location &Copy(place) | &Move(place) => self.eval_place_to_op(place, layout)?, + &RuntimeChecks(checks) => { + let val = M::runtime_checks(self, checks)?; + ImmTy::from_bool(val, self.tcx()).into() + } + Constant(constant) => { let c = self.instantiate_from_current_frame_and_normalize_erasing_regions( constant.const_, @@ -892,10 +897,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let ptr = Pointer::new(CtfeProvenance::from(alloc_id).as_immutable(), Size::ZERO); Immediate::new_slice(self.global_root_pointer(ptr)?.into(), meta, self) } - mir::ConstValue::RuntimeChecks(checks) => { - let val = M::runtime_checks(self, checks)?; - Scalar::from_bool(val).into() - } }; interp_ok(OpTy { op: Operand::Immediate(imm), layout }) } diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 47e8e2a9ec51..0ef4e4d4ae3c 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -387,7 +387,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { move_definitely_disjoint: bool, ) -> InterpResult<'tcx, FnArg<'tcx, M::Provenance>> { interp_ok(match op { - mir::Operand::Copy(_) | mir::Operand::Constant(_) => { + mir::Operand::Copy(_) | mir::Operand::Constant(_) | mir::Operand::RuntimeChecks(_) => { // Make a regular copy. let op = self.eval_operand(op, None)?; FnArg::Copy(op) diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 1b7d3ec9345f..fe352df3b9f0 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -68,10 +68,6 @@ pub enum ConstValue { /// Offset into `alloc` offset: Size, }, - - /// Special constants whose value depends on the evaluation context. Their value depends on a - /// flag on the crate being codegenned. - RuntimeChecks(RuntimeChecks), } #[cfg(target_pointer_width = "64")] @@ -81,10 +77,7 @@ impl ConstValue { #[inline] pub fn try_to_scalar(&self) -> Option { match *self { - ConstValue::Indirect { .. } - | ConstValue::Slice { .. } - | ConstValue::ZeroSized - | ConstValue::RuntimeChecks(_) => None, + ConstValue::Indirect { .. } | ConstValue::Slice { .. } | ConstValue::ZeroSized => None, ConstValue::Scalar(val) => Some(val), } } @@ -140,7 +133,7 @@ impl ConstValue { tcx: TyCtxt<'tcx>, ) -> Option<&'tcx [u8]> { let (alloc_id, start, len) = match self { - ConstValue::Scalar(_) | ConstValue::ZeroSized | ConstValue::RuntimeChecks(_) => { + ConstValue::Scalar(_) | ConstValue::ZeroSized => { bug!("`try_get_slice_bytes` on non-slice constant") } &ConstValue::Slice { alloc_id, meta } => (alloc_id, 0, meta), @@ -192,9 +185,7 @@ impl ConstValue { /// Can return `true` even if there is no provenance. pub fn may_have_provenance(&self, tcx: TyCtxt<'_>, size: Size) -> bool { match *self { - ConstValue::ZeroSized - | ConstValue::Scalar(Scalar::Int(_)) - | ConstValue::RuntimeChecks(_) => return false, + ConstValue::ZeroSized | ConstValue::Scalar(Scalar::Int(_)) => return false, ConstValue::Scalar(Scalar::Ptr(..)) => return true, // It's hard to find out the part of the allocation we point to; // just conservatively check everything. @@ -233,29 +224,6 @@ impl ConstValue { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] -pub enum RuntimeChecks { - /// Returns whether we should perform some UB-checking at runtime. - /// See the `ub_checks` intrinsic docs for details. - UbChecks, - /// Returns whether we should perform contract-checking at runtime. - /// See the `contract_checks` intrinsic docs for details. - ContractChecks, - /// Returns whether we should perform some overflow-checking at runtime. - /// See the `overflow_checks` intrinsic docs for details. - OverflowChecks, -} - -impl RuntimeChecks { - pub fn value(self, sess: &rustc_session::Session) -> bool { - match self { - Self::UbChecks => sess.ub_checks(), - Self::ContractChecks => sess.contract_checks(), - Self::OverflowChecks => sess.overflow_checks(), - } - } -} - /////////////////////////////////////////////////////////////////////////// /// Constants @@ -549,7 +517,6 @@ impl<'tcx> Const<'tcx> { ConstValue::Slice { .. } | ConstValue::ZeroSized | ConstValue::Scalar(_) - | ConstValue::RuntimeChecks(_) | ConstValue::Indirect { .. }, _, ) => true, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index bffff1b400d5..418cdea01660 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -607,9 +607,6 @@ impl<'tcx> Body<'tcx> { typing_env, crate::ty::EarlyBinder::bind(constant.const_), ); - if let Const::Val(ConstValue::RuntimeChecks(check), _) = mono_literal { - return Some(check.value(tcx.sess) as u128); - } mono_literal.try_eval_bits(tcx, typing_env) }; @@ -623,6 +620,10 @@ impl<'tcx> Body<'tcx> { let bits = eval_mono_const(constant)?; return Some((bits, targets)); } + Operand::RuntimeChecks(check) => { + let bits = check.value(tcx.sess) as u128; + return Some((bits, targets)); + } Operand::Move(place) | Operand::Copy(place) => place, }; diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index e4f85a115096..1ac46fff1b4e 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1255,6 +1255,7 @@ impl<'tcx> Debug for Operand<'tcx> { Constant(ref a) => write!(fmt, "{a:?}"), Copy(ref place) => write!(fmt, "copy {place:?}"), Move(ref place) => write!(fmt, "move {place:?}"), + RuntimeChecks(checks) => write!(fmt, "const {checks:?}"), } } } @@ -1518,7 +1519,6 @@ pub fn write_allocations<'tcx>( match val { ConstValue::Scalar(interpret::Scalar::Ptr(ptr, _)) => Some(ptr.provenance.alloc_id()), ConstValue::Scalar(interpret::Scalar::Int { .. }) => None, - ConstValue::RuntimeChecks(_) => None, ConstValue::ZeroSized => None, ConstValue::Slice { alloc_id, .. } | ConstValue::Indirect { alloc_id, .. } => { // FIXME: we don't actually want to print all of these, since some are printed nicely directly as values inline in MIR. @@ -1969,7 +1969,6 @@ fn pretty_print_const_value_tcx<'tcx>( fmt.write_str(&p.into_buffer())?; return Ok(()); } - (ConstValue::RuntimeChecks(checks), _) => return write!(fmt, "{checks:?}"), (ConstValue::ZeroSized, ty::FnDef(d, s)) => { let mut p = FmtPrinter::new(tcx, Namespace::ValueNS); p.print_alloc_ids = true; diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 942eb727de67..372b3313e13f 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -642,7 +642,7 @@ impl<'tcx> Operand<'tcx> { pub fn to_copy(&self) -> Self { match *self { - Operand::Copy(_) | Operand::Constant(_) => self.clone(), + Operand::Copy(_) | Operand::Constant(_) | Operand::RuntimeChecks(_) => self.clone(), Operand::Move(place) => Operand::Copy(place), } } @@ -652,7 +652,7 @@ impl<'tcx> Operand<'tcx> { pub fn place(&self) -> Option> { match self { Operand::Copy(place) | Operand::Move(place) => Some(*place), - Operand::Constant(_) => None, + Operand::Constant(_) | Operand::RuntimeChecks(_) => None, } } @@ -661,7 +661,7 @@ impl<'tcx> Operand<'tcx> { pub fn constant(&self) -> Option<&ConstOperand<'tcx>> { match self { Operand::Constant(x) => Some(&**x), - Operand::Copy(_) | Operand::Move(_) => None, + Operand::Copy(_) | Operand::Move(_) | Operand::RuntimeChecks(_) => None, } } @@ -681,6 +681,7 @@ impl<'tcx> Operand<'tcx> { match self { &Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty, Operand::Constant(c) => c.const_.ty(), + Operand::RuntimeChecks(_) => tcx.types.bool, } } @@ -693,6 +694,7 @@ impl<'tcx> Operand<'tcx> { local_decls.local_decls()[l.local].source_info.span } Operand::Constant(c) => c.span, + Operand::RuntimeChecks(_) => DUMMY_SP, } } } diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index e96d6824c600..037caa8bfae1 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1327,6 +1327,10 @@ pub enum Operand<'tcx> { /// Constants are already semantically values, and remain unchanged. Constant(Box>), + + /// Special constants whose value depends on the evaluation context. Their value depends on a + /// flag on the crate being codegenned. + RuntimeChecks(RuntimeChecks), } #[derive(Clone, Copy, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)] @@ -1558,6 +1562,29 @@ pub enum AggregateKind<'tcx> { RawPtr(Ty<'tcx>, Mutability), } +#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] +pub enum RuntimeChecks { + /// Returns whether we should perform some UB-checking at runtime. + /// See the `ub_checks` intrinsic docs for details. + UbChecks, + /// Returns whether we should perform contract-checking at runtime. + /// See the `contract_checks` intrinsic docs for details. + ContractChecks, + /// Returns whether we should perform some overflow-checking at runtime. + /// See the `overflow_checks` intrinsic docs for details. + OverflowChecks, +} + +impl RuntimeChecks { + pub fn value(self, sess: &rustc_session::Session) -> bool { + match self { + Self::UbChecks => sess.ub_checks(), + Self::ContractChecks => sess.contract_checks(), + Self::OverflowChecks => sess.overflow_checks(), + } + } +} + #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)] pub enum UnOp { diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index da9b2b97235e..07a36aef4320 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -845,6 +845,7 @@ macro_rules! make_mir_visitor { Operand::Constant(constant) => { self.visit_const_operand(constant, location); } + Operand::RuntimeChecks(_) => {} } } diff --git a/compiler/rustc_mir_build/src/builder/custom/parse.rs b/compiler/rustc_mir_build/src/builder/custom/parse.rs index 10154461c339..c6ef362c6ea5 100644 --- a/compiler/rustc_mir_build/src/builder/custom/parse.rs +++ b/compiler/rustc_mir_build/src/builder/custom/parse.rs @@ -261,6 +261,7 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> { let value = match operand { Operand::Constant(c) => VarDebugInfoContents::Const(*c), Operand::Copy(p) | Operand::Move(p) => VarDebugInfoContents::Place(p), + Operand::RuntimeChecks(_) => unreachable!(), }; let dbginfo = VarDebugInfo { name, diff --git a/compiler/rustc_mir_build/src/builder/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index 966598736220..a176f3e49a50 100644 --- a/compiler/rustc_mir_build/src/builder/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -1099,7 +1099,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Some(DropData { source_info, local, kind: DropKind::Value }) } - Operand::Constant(_) => None, + Operand::Constant(_) | Operand::RuntimeChecks(_) => None, }) .collect(); @@ -1563,7 +1563,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // look for moves of a local variable, like `MOVE(_X)` let locals_moved = operands.iter().flat_map(|operand| match operand.node { - Operand::Copy(_) | Operand::Constant(_) => None, + Operand::Copy(_) | Operand::Constant(_) | Operand::RuntimeChecks(_) => None, Operand::Move(place) => place.as_local(), }); diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index a90f3ef35444..ced9bd735ba2 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -546,9 +546,10 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> { fn gather_operand(&mut self, operand: &Operand<'tcx>) { match *operand { - Operand::Constant(..) | Operand::Copy(..) => {} // not-a-move + // not-a-move + Operand::Constant(..) | Operand::Copy(..) | Operand::RuntimeChecks(_) => {} + // a move Operand::Move(place) => { - // a move self.gather_move(place); } } diff --git a/compiler/rustc_mir_transform/src/cost_checker.rs b/compiler/rustc_mir_transform/src/cost_checker.rs index 8f975866d135..aaf735269b22 100644 --- a/compiler/rustc_mir_transform/src/cost_checker.rs +++ b/compiler/rustc_mir_transform/src/cost_checker.rs @@ -103,7 +103,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { self.penalty += CALL_PENALTY; } TerminatorKind::SwitchInt { discr, targets } => { - if discr.constant().is_some() { + if matches!(discr, Operand::Constant(_) | Operand::RuntimeChecks(_)) { // Not only will this become a `Goto`, but likely other // things will be removable as unreachable. self.bonus += CONST_SWITCH_BONUS; diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 232f07d31adb..011c10b8bd1d 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -211,6 +211,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { state: &mut State>, ) -> ValueOrPlace> { match operand { + Operand::RuntimeChecks(_) => ValueOrPlace::TOP, Operand::Constant(box constant) => { ValueOrPlace::Value(self.handle_constant(constant, state)) } @@ -530,6 +531,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { operand: &Operand<'tcx>, ) { match operand { + Operand::RuntimeChecks(_) => {} Operand::Copy(rhs) | Operand::Move(rhs) => { if let Some(rhs) = self.map.find(rhs.as_ref()) { state.insert_place_idx(place, rhs, &self.map); @@ -1036,7 +1038,7 @@ impl<'tcx> MutVisitor<'tcx> for Patch<'tcx> { self.super_operand(operand, location) } } - Operand::Constant(_) => {} + Operand::Constant(_) | Operand::RuntimeChecks(_) => {} } } diff --git a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs index da88e5c698bf..47d735eed9b1 100644 --- a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs +++ b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs @@ -117,11 +117,7 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch { unreachable!() }; // Always correct since we can only switch on `Copy` types - let parent_op = match parent_op { - Operand::Move(x) => Operand::Copy(*x), - Operand::Copy(x) => Operand::Copy(*x), - Operand::Constant(x) => Operand::Constant(x.clone()), - }; + let parent_op = parent_op.to_copy(); let parent_ty = parent_op.ty(body.local_decls(), tcx); let statements_before = bbs[parent].statements.len(); let parent_end = Location { block: parent, statement_index: statements_before }; diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index 38b5ccdb32e7..2ae8f43cf6c8 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -136,12 +136,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { } fn nth_arg_span(&self, args: &[Spanned>], n: usize) -> Span { - match &args[n].node { - Operand::Copy(place) | Operand::Move(place) => { - self.body.local_decls[place.local].source_info.span - } - Operand::Constant(constant) => constant.span, - } + args[n].node.span(&self.body.local_decls) } fn emit_lint( diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index f6bf678af5ba..5a4774154504 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -248,6 +248,7 @@ enum Value<'a, 'tcx> { Discriminant(VnIndex), // Operations. + RuntimeChecks(RuntimeChecks), UnaryOp(UnOp, VnIndex), BinaryOp(BinOp, VnIndex, VnIndex), Cast { @@ -569,6 +570,8 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { _ if ty.is_zst() => ImmTy::uninit(ty).into(), Opaque(_) => return None, + // Keep runtime check constants as symbolic. + RuntimeChecks(..) => return None, // In general, evaluating repeat expressions just consumes a lot of memory. // But in the special case that the element is just Immediate::Uninit, we can evaluate @@ -1005,11 +1008,16 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { location: Location, ) -> Option { match *operand { + Operand::RuntimeChecks(c) => { + Some(self.insert(self.tcx.types.bool, Value::RuntimeChecks(c))) + } Operand::Constant(ref constant) => Some(self.insert_constant(constant.const_)), Operand::Copy(ref mut place) | Operand::Move(ref mut place) => { let value = self.simplify_place_value(place, location)?; if let Some(const_) = self.try_as_constant(value) { *operand = Operand::Constant(Box::new(const_)); + } else if let Value::RuntimeChecks(c) = self.get(value) { + *operand = Operand::RuntimeChecks(c); } Some(value) } @@ -1777,6 +1785,8 @@ impl<'tcx> VnState<'_, '_, 'tcx> { fn try_as_operand(&mut self, index: VnIndex, location: Location) -> Option> { if let Some(const_) = self.try_as_constant(index) { Some(Operand::Constant(Box::new(const_))) + } else if let Value::RuntimeChecks(c) = self.get(index) { + Some(Operand::RuntimeChecks(c)) } else if let Some(place) = self.try_as_place(index, location, false) { self.reused_locals.insert(place.local); Some(Operand::Copy(place)) diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 7cb341818fab..fa9ceb018dd5 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -363,11 +363,15 @@ impl<'tcx> MutVisitor<'tcx> for SimplifyUbCheck<'tcx> { } fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) { - if let Operand::Constant(c) = operand - && let Const::Val(c, _) = &mut c.const_ - && let ConstValue::RuntimeChecks(RuntimeChecks::UbChecks) = c - { - *c = ConstValue::from_bool(self.tcx.sess.ub_checks()); + if let Operand::RuntimeChecks(RuntimeChecks::UbChecks) = operand { + *operand = Operand::Constant(Box::new(ConstOperand { + span: rustc_span::DUMMY_SP, + user_ty: None, + const_: Const::Val( + ConstValue::from_bool(self.tcx.sess.ub_checks()), + self.tcx.types.bool, + ), + })); } } } diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index c021e7d4c3ae..e2959ca64bda 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -477,6 +477,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { let Some(rhs) = self.map.find(rhs.as_ref()) else { return }; self.process_copy(lhs, rhs, state) } + Operand::RuntimeChecks(_) => {} } } diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 53cb02d9c5b2..caaf300a88d6 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -282,6 +282,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { /// or `eval_place`, depending on the variant of `Operand` used. fn eval_operand(&mut self, op: &Operand<'tcx>) -> Option> { match *op { + Operand::RuntimeChecks(_) => None, Operand::Constant(ref c) => self.eval_constant(c), Operand::Move(place) | Operand::Copy(place) => self.eval_place(place), } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 6415f3908499..701d7ff854a7 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -261,7 +261,7 @@ fn remap_mir_for_const_eval_select<'tcx>( if context == hir::Constness::Const { called_in_const } else { called_at_rt }; let (method, place): (fn(Place<'tcx>) -> Operand<'tcx>, Place<'tcx>) = match tupled_args.node { - Operand::Constant(_) => { + Operand::Constant(_) | Operand::RuntimeChecks(_) => { // There is no good way of extracting a tuple arg from a constant // (const generic stuff) so we just create a temporary and deconstruct // that. diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 6740aa97fc8b..dcee54c37108 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -35,14 +35,7 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics { terminator.source_info, StatementKind::Assign(Box::new(( *destination, - Rvalue::Use(Operand::Constant(Box::new(ConstOperand { - span: terminator.source_info.span, - user_ty: None, - const_: Const::Val( - ConstValue::RuntimeChecks(op), - tcx.types.bool, - ), - }))), + Rvalue::Use(Operand::RuntimeChecks(op)), ))), )); terminator.kind = TerminatorKind::Goto { target }; diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 506cfb7abf92..faff0f23143a 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -360,6 +360,9 @@ impl<'tcx> Validator<'_, 'tcx> { match operand { Operand::Copy(place) | Operand::Move(place) => self.validate_place(place.as_ref()), + // Promoting a runtime check would transform a runtime error into a compile-time error. + Operand::RuntimeChecks(_) => Err(Unpromotable), + // The qualifs for a constant (e.g. `HasMutInterior`) are checked in // `validate_rvalue` upon access. Operand::Constant(c) => { diff --git a/compiler/rustc_mir_transform/src/simplify_branches.rs b/compiler/rustc_mir_transform/src/simplify_branches.rs index ba2286fd40a7..70ae3433353b 100644 --- a/compiler/rustc_mir_transform/src/simplify_branches.rs +++ b/compiler/rustc_mir_transform/src/simplify_branches.rs @@ -41,7 +41,7 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyConstCondition { { Some(const_operand) } - Operand::Copy(_) | Operand::Move(_) => None, + Operand::Copy(_) | Operand::Move(_) | Operand::RuntimeChecks(_) => None, } } diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index 801383493837..a6ed66c8427b 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -392,11 +392,14 @@ impl<'tcx, 'll> MutVisitor<'tcx> for ReplacementVisitor<'tcx, 'll> { // a_1 = move? place.1 // ... // ``` - StatementKind::Assign(box (lhs, Rvalue::Use(ref op))) => { - let (rplace, copy) = match *op { - Operand::Copy(rplace) => (rplace, true), - Operand::Move(rplace) => (rplace, false), - Operand::Constant(_) => bug!(), + StatementKind::Assign(box ( + lhs, + Rvalue::Use(ref op @ (Operand::Copy(rplace) | Operand::Move(rplace))), + )) => { + let copy = match *op { + Operand::Copy(_) => true, + Operand::Move(_) => false, + Operand::Constant(_) | Operand::RuntimeChecks(_) => bug!(), }; if let Some(final_locals) = self.replacements.place_fragments(lhs) { for (field, ty, new_local) in final_locals { diff --git a/compiler/rustc_public/src/alloc.rs b/compiler/rustc_public/src/alloc.rs index 5ede5b2b2712..0c35b3b25dfc 100644 --- a/compiler/rustc_public/src/alloc.rs +++ b/compiler/rustc_public/src/alloc.rs @@ -53,7 +53,6 @@ pub(crate) fn try_new_allocation<'tcx>( ConstValue::Scalar(scalar) => { alloc::try_new_scalar(layout, scalar, cx).map(|alloc| alloc.stable(tables, cx)) } - ConstValue::RuntimeChecks(_) => todo!(), ConstValue::ZeroSized => Ok(new_empty_allocation(layout.align.abi)), ConstValue::Slice { alloc_id, meta } => { alloc::try_new_slice(layout, alloc_id, meta, cx).map(|alloc| alloc.stable(tables, cx)) diff --git a/compiler/rustc_public/src/mir/body.rs b/compiler/rustc_public/src/mir/body.rs index 92882a001c47..e81b32ec9acf 100644 --- a/compiler/rustc_public/src/mir/body.rs +++ b/compiler/rustc_public/src/mir/body.rs @@ -673,6 +673,7 @@ pub enum Operand { Copy(Place), Move(Place), Constant(ConstOperand), + RuntimeChecks(RuntimeChecks), } #[derive(Clone, Eq, PartialEq, Hash, Serialize)] @@ -695,6 +696,16 @@ pub struct ConstOperand { pub const_: MirConst, } +#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)] +pub enum RuntimeChecks { + /// cfg!(ub_checks), but at codegen time + UbChecks, + /// cfg!(contract_checks), but at codegen time + ContractChecks, + /// cfg!(overflow_checks), but at codegen time + OverflowChecks, +} + /// Debug information pertaining to a user variable. #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub struct VarDebugInfo { @@ -1025,6 +1036,7 @@ impl Operand { match self { Operand::Copy(place) | Operand::Move(place) => place.ty(locals), Operand::Constant(c) => Ok(c.ty()), + Operand::RuntimeChecks(_) => Ok(Ty::bool_ty()), } } } diff --git a/compiler/rustc_public/src/mir/pretty.rs b/compiler/rustc_public/src/mir/pretty.rs index d814947dc397..fec5bd57efdd 100644 --- a/compiler/rustc_public/src/mir/pretty.rs +++ b/compiler/rustc_public/src/mir/pretty.rs @@ -332,6 +332,7 @@ fn pretty_operand(operand: &Operand) -> String { format!("move {mv:?}") } Operand::Constant(cnst) => pretty_mir_const(&cnst.const_), + Operand::RuntimeChecks(checks) => format!("const {checks:?}"), } } diff --git a/compiler/rustc_public/src/mir/visit.rs b/compiler/rustc_public/src/mir/visit.rs index f0fdbe059383..678205171ecf 100644 --- a/compiler/rustc_public/src/mir/visit.rs +++ b/compiler/rustc_public/src/mir/visit.rs @@ -296,6 +296,7 @@ macro_rules! make_mir_visitor { Operand::Constant(constant) => { self.visit_const_operand(constant, location); } + Operand::RuntimeChecks(_) => {} } } diff --git a/compiler/rustc_public/src/ty.rs b/compiler/rustc_public/src/ty.rs index a87ac795da5c..14656a2e594a 100644 --- a/compiler/rustc_public/src/ty.rs +++ b/compiler/rustc_public/src/ty.rs @@ -1357,7 +1357,6 @@ pub enum ConstantKind { Ty(TyConst), Allocated(Allocation), Unevaluated(UnevaluatedConst), - RuntimeChecks(RuntimeChecks), Param(ParamConst), /// Store ZST constants. /// We have to special handle these constants since its type might be generic. @@ -1377,16 +1376,6 @@ pub struct UnevaluatedConst { pub promoted: Option, } -#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)] -pub enum RuntimeChecks { - /// cfg!(ub_checks), but at codegen time - UbChecks, - /// cfg!(contract_checks), but at codegen time - ContractChecks, - /// cfg!(overflow_checks), but at codegen time - OverflowChecks, -} - #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)] pub enum TraitSpecializationKind { None, diff --git a/compiler/rustc_public/src/unstable/convert/stable/mir.rs b/compiler/rustc_public/src/unstable/convert/stable/mir.rs index 31f41653d4a2..a77808cfb275 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/mir.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/mir.rs @@ -312,7 +312,7 @@ impl<'tcx> Stable<'tcx> for mir::FakeBorrowKind { } impl<'tcx> Stable<'tcx> for mir::RuntimeChecks { - type T = crate::ty::RuntimeChecks; + type T = crate::mir::RuntimeChecks; fn stable<'cx>( &self, _: &mut Tables<'cx, BridgeTys>, @@ -320,9 +320,9 @@ impl<'tcx> Stable<'tcx> for mir::RuntimeChecks { ) -> Self::T { use rustc_middle::mir::RuntimeChecks::*; match self { - UbChecks => crate::ty::RuntimeChecks::UbChecks, - ContractChecks => crate::ty::RuntimeChecks::ContractChecks, - OverflowChecks => crate::ty::RuntimeChecks::OverflowChecks, + UbChecks => crate::mir::RuntimeChecks::UbChecks, + ContractChecks => crate::mir::RuntimeChecks::ContractChecks, + OverflowChecks => crate::mir::RuntimeChecks::OverflowChecks, } } } @@ -379,6 +379,7 @@ impl<'tcx> Stable<'tcx> for mir::Operand<'tcx> { Copy(place) => crate::mir::Operand::Copy(place.stable(tables, cx)), Move(place) => crate::mir::Operand::Move(place.stable(tables, cx)), Constant(c) => crate::mir::Operand::Constant(c.stable(tables, cx)), + RuntimeChecks(c) => crate::mir::Operand::RuntimeChecks(c.stable(tables, cx)), } } } @@ -886,13 +887,6 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> { let ty = ty.stable(tables, cx); MirConst::new(ConstantKind::ZeroSized, ty, id) } - mir::Const::Val(mir::ConstValue::RuntimeChecks(checks), ty) => { - let ty = cx.lift(ty).unwrap(); - let checks = cx.lift(checks).unwrap(); - let ty = ty.stable(tables, cx); - let kind = ConstantKind::RuntimeChecks(checks.stable(tables, cx)); - MirConst::new(kind, ty, id) - } mir::Const::Val(val, ty) => { let ty = cx.lift(ty).unwrap(); let val = cx.lift(val).unwrap(); diff --git a/compiler/rustc_public/src/visitor.rs b/compiler/rustc_public/src/visitor.rs index 2ebd73a43e90..acc333476961 100644 --- a/compiler/rustc_public/src/visitor.rs +++ b/compiler/rustc_public/src/visitor.rs @@ -68,9 +68,7 @@ impl Visitable for MirConst { super::ty::ConstantKind::Ty(ct) => ct.visit(visitor)?, super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor)?, super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor)?, - super::ty::ConstantKind::RuntimeChecks(_) - | super::ty::ConstantKind::Param(_) - | super::ty::ConstantKind::ZeroSized => {} + super::ty::ConstantKind::Param(_) | super::ty::ConstantKind::ZeroSized => {} } self.ty().visit(visitor) } diff --git a/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs b/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs index f2bffc8156af..0ead5944b4b3 100644 --- a/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs +++ b/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs @@ -110,7 +110,7 @@ impl<'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'_, '_, 'tcx> { immutable_borrowers.push(p.local); } }, - mir::Operand::Constant(..) => (), + mir::Operand::Constant(..) | mir::Operand::RuntimeChecks(..) => (), } } @@ -151,7 +151,7 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) { let mut visit_op = |op: &mir::Operand<'_>| match op { mir::Operand::Copy(p) | mir::Operand::Move(p) => visit(p.local), - mir::Operand::Constant(..) => (), + mir::Operand::Constant(..) | mir::Operand::RuntimeChecks(..) => (), }; match rvalue { diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index c1d00fc8d371..06220f91c745 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -277,6 +277,7 @@ fn check_operand<'tcx>( Some(_) => Err((span, "cannot access `static` items in const fn".into())), None => Ok(()), }, + Operand::RuntimeChecks(..) => Ok(()), } } diff --git a/tests/codegen-llvm/slice-iter-len-eq-zero.rs b/tests/codegen-llvm/slice-iter-len-eq-zero.rs index ae1bdb1d58b9..6998d98e498c 100644 --- a/tests/codegen-llvm/slice-iter-len-eq-zero.rs +++ b/tests/codegen-llvm/slice-iter-len-eq-zero.rs @@ -8,10 +8,8 @@ type Demo = [u8; 3]; #[no_mangle] pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { // CHECK-NOT: sub - // CHECK: %2 = icmp ne ptr %1, null - // CHECK-NEXT: tail call void @llvm.assume(i1 %2) - // CHECK-NEXT: %[[RET:.+]] = icmp eq ptr {{%0, %1|%1, %0}} - // CHECK-NEXT: ret i1 %[[RET]] + // CHECK: %[[RET:.+]] = icmp eq ptr {{%y.0, %y.1|%y.1, %y.0}} + // CHECK: ret i1 %[[RET]] y.len() == 0 } @@ -33,7 +31,7 @@ struct MyZST; // CHECK-LABEL: @slice_zst_iter_len_eq_zero #[no_mangle] pub fn slice_zst_iter_len_eq_zero(y: std::slice::Iter<'_, MyZST>) -> bool { - // CHECK: %[[RET:.+]] = icmp eq ptr %1, null + // CHECK: %[[RET:.+]] = icmp eq ptr %y.1, null // CHECK: ret i1 %[[RET]] y.len() == 0 } From fab64de7270010cde21f7421d5cfd0105dca554b Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Wed, 19 Nov 2025 01:06:37 +0000 Subject: [PATCH 156/489] Improve comments. --- compiler/rustc_const_eval/src/const_eval/dummy_machine.rs | 4 ++-- compiler/rustc_middle/src/mir/statement.rs | 1 + compiler/rustc_middle/src/mir/syntax.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs b/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs index 40acff416bb0..f41b68bb1f7e 100644 --- a/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/dummy_machine.rs @@ -124,8 +124,8 @@ impl<'tcx> interpret::Machine<'tcx> for DummyMachine { #[inline(always)] fn runtime_checks(_ecx: &InterpCx<'tcx, Self>, r: RuntimeChecks) -> InterpResult<'tcx, bool> { - // We can't look at `tcx.sess` here as that can differ across crates, which can lead to - // unsound differences in evaluating the same constant at different instantiation sites. + // Runtime checks have different value depending on the crate they are codegenned in. + // Verify we aren't trying to evaluate them in mir-optimizations. panic!("compiletime machine evaluated {r:?}") } diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 372b3313e13f..1ba1ae3e1531 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -694,6 +694,7 @@ impl<'tcx> Operand<'tcx> { local_decls.local_decls()[l.local].source_info.span } Operand::Constant(c) => c.span, + // User code should not contain this operand, so we should not need this span. Operand::RuntimeChecks(_) => DUMMY_SP, } } diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 037caa8bfae1..83e9a1f1784b 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1328,8 +1328,8 @@ pub enum Operand<'tcx> { /// Constants are already semantically values, and remain unchanged. Constant(Box>), - /// Special constants whose value depends on the evaluation context. Their value depends on a - /// flag on the crate being codegenned. + /// Query the compilation session of the current crate for a particular flag. This is not quite + /// a const since its value can differ across crates within a single crate graph. RuntimeChecks(RuntimeChecks), } From d8b897e3170fd56952c576f8bdc43c0d1b10490d Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Wed, 19 Nov 2025 01:23:04 +0000 Subject: [PATCH 157/489] Change pretty-printing. --- compiler/rustc_middle/src/mir/pretty.rs | 2 +- ...ind_without_updating_operand.test.GVN.32bit.panic-abort.diff | 2 +- ...ind_without_updating_operand.test.GVN.64bit.panic-abort.diff | 2 +- ...hifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff | 2 +- ...ifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff | 2 +- ...d_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff | 2 +- ..._shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff | 2 +- .../unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff | 2 +- .../unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff | 2 +- ...b_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 1ac46fff1b4e..2d84e919359e 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1255,7 +1255,7 @@ impl<'tcx> Debug for Operand<'tcx> { Constant(ref a) => write!(fmt, "{a:?}"), Copy(ref place) => write!(fmt, "copy {place:?}"), Move(ref place) => write!(fmt, "move {place:?}"), - RuntimeChecks(checks) => write!(fmt, "const {checks:?}"), + RuntimeChecks(checks) => write!(fmt, "{checks:?}"), } } } diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index ae2b8e574303..2aa92fd34ebf 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -94,7 +94,7 @@ StorageLive(_21); StorageLive(_22); StorageLive(_23); - switchInt(const UbChecks) -> [0: bb6, otherwise: bb5]; + switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } bb1: { diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index 164aeb2d9037..408ff60712e1 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -94,7 +94,7 @@ StorageLive(_21); StorageLive(_22); StorageLive(_23); - switchInt(const UbChecks) -> [0: bb6, otherwise: bb5]; + switchInt(UbChecks) -> [0: bb6, otherwise: bb5]; } bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index 153e314fb6f4..d66223b91bc4 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -22,7 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shl(move _3, move _4) -> [return: bb1, unwind unreachable]; + StorageLive(_5); -+ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; ++ switchInt(UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index fd9f5838efc3..54907cf809b4 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -22,7 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shl(move _3, move _4) -> [return: bb1, unwind continue]; + StorageLive(_5); -+ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; ++ switchInt(UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff index 5b12c1853359..c118f5b0df3f 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff @@ -22,7 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shr(move _3, move _4) -> [return: bb1, unwind unreachable]; + StorageLive(_5); -+ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; ++ switchInt(UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff index e8474898b995..6a1e6a0a2d26 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -22,7 +22,7 @@ _4 = copy _2; - _0 = core::num::::unchecked_shr(move _3, move _4) -> [return: bb1, unwind continue]; + StorageLive(_5); -+ switchInt(const UbChecks) -> [0: bb2, otherwise: bb1]; ++ switchInt(UbChecks) -> [0: bb2, otherwise: bb1]; } bb1: { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index 7bd93b804e7f..041dd27cb564 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -33,7 +33,7 @@ + } + + bb2: { -+ assume(const UbChecks); ++ assume(UbChecks); + _4 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index ae194db56cc9..be89063a8ac9 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -37,7 +37,7 @@ - bb2 (cleanup): { - resume; + bb2: { -+ assume(const UbChecks); ++ assume(UbChecks); + _4 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff index 890c87880441..c4fa526a7af9 100644 --- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff @@ -32,7 +32,7 @@ } bb2: { -- assume(const UbChecks); +- assume(UbChecks); + assume(const false); _4 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; } From b6bb7f96459583ef66094b2dcbc5ea3e7955fbcc Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Wed, 19 Nov 2025 01:28:59 +0000 Subject: [PATCH 158/489] Bless codegen test. --- tests/codegen-llvm/slice-iter-len-eq-zero.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codegen-llvm/slice-iter-len-eq-zero.rs b/tests/codegen-llvm/slice-iter-len-eq-zero.rs index 6998d98e498c..3085fbaed36a 100644 --- a/tests/codegen-llvm/slice-iter-len-eq-zero.rs +++ b/tests/codegen-llvm/slice-iter-len-eq-zero.rs @@ -8,7 +8,7 @@ type Demo = [u8; 3]; #[no_mangle] pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { // CHECK-NOT: sub - // CHECK: %[[RET:.+]] = icmp eq ptr {{%y.0, %y.1|%y.1, %y.0}} + // CHECK: %[[RET:.+]] = icmp eq ptr {{%0, %1|%1, %0}} // CHECK: ret i1 %[[RET]] y.len() == 0 } @@ -31,7 +31,7 @@ struct MyZST; // CHECK-LABEL: @slice_zst_iter_len_eq_zero #[no_mangle] pub fn slice_zst_iter_len_eq_zero(y: std::slice::Iter<'_, MyZST>) -> bool { - // CHECK: %[[RET:.+]] = icmp eq ptr %y.1, null + // CHECK: %[[RET:.+]] = icmp eq ptr %1, null // CHECK: ret i1 %[[RET]] y.len() == 0 } From fc9d9b88e6829be5db5db76bde56c58253e2a068 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Wed, 19 Nov 2025 01:34:15 +0000 Subject: [PATCH 159/489] Update ui-fulldeps test. --- tests/ui-fulldeps/rustc_public/check_transform.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui-fulldeps/rustc_public/check_transform.rs b/tests/ui-fulldeps/rustc_public/check_transform.rs index 900bb4014d54..815dec57b8be 100644 --- a/tests/ui-fulldeps/rustc_public/check_transform.rs +++ b/tests/ui-fulldeps/rustc_public/check_transform.rs @@ -69,6 +69,7 @@ fn check_msg(body: &Body, expected: &str) { }) .unwrap() } + Operand::RuntimeChecks(_) => panic!("unexpected runtime checks"), }; let ConstantKind::Allocated(alloc) = msg_const.const_.kind() else { unreachable!() From 0f9b7893d77d97738388ac478aa1afd52d6b7013 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Thu, 20 Nov 2025 01:27:07 +0000 Subject: [PATCH 160/489] Update doc. --- compiler/rustc_middle/src/mir/traversal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 4f599aea0254..a3c0a5b83ffa 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -293,9 +293,9 @@ pub fn reverse_postorder<'a, 'tcx>( /// reachable. /// /// Such a traversal is mostly useful because it lets us skip lowering the `false` side -/// of `if ::CONST`, as well as [`ConstValue::RuntimeChecks`]. +/// of `if ::CONST`, as well as [`Operand::RuntimeChecks`]. /// -/// [`ConstValue::RuntimeChecks`]: rustc_middle::mir::ConstValue::RuntimeChecks +/// [`Operand::RuntimeChecks`]: rustc_middle::mir::Operand::RuntimeChecks pub fn mono_reachable<'a, 'tcx>( body: &'a Body<'tcx>, tcx: TyCtxt<'tcx>, From a3676bd0facf44a576af975ee7529abd61122d55 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 16 Nov 2025 19:21:17 +0000 Subject: [PATCH 161/489] Introduce Operand::RuntimeChecks. --- src/base.rs | 8 +++++++- src/constant.rs | 9 ++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index 4dbee7665eb8..79f65141e66f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; -use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; +use rustc_middle::ty::{ScalarInt, TypeVisitableExt}; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -1039,6 +1039,12 @@ pub(crate) fn codegen_operand<'tcx>( cplace.to_cvalue(fx) } Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_), + Operand::RuntimeChecks(checks) => { + let int = checks.value(fx.tcx.sess); + let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + let layout = fx.layout_of(fx.tcx.types.bool); + return CValue::const_val(fx, layout, int); + } } } diff --git a/src/constant.rs b/src/constant.rs index 29c8e8ab1e52..c25034d4be22 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -215,11 +215,6 @@ pub(crate) fn codegen_const_value<'tcx>( CValue::by_val(val, layout) } }, - ConstValue::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); - return CValue::const_val(fx, layout, int); - } ConstValue::Indirect { alloc_id, offset } => CValue::by_ref( Pointer::new(pointer_for_allocation(fx, alloc_id)) .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), @@ -545,6 +540,10 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option { match operand { + Operand::RuntimeChecks(checks) => { + let int = checks.value(fx.tcx.sess); + ScalarInt::try_from_uint(int, Size::from_bits(1)) + } Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(), // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored // inside a temporary before being passed to the intrinsic requiring the const argument. From f57b09d0f2c0aa400fc3e1daa82aa3a0fc9ae586 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 16 Nov 2025 19:21:17 +0000 Subject: [PATCH 162/489] Introduce Operand::RuntimeChecks. --- clippy_utils/src/mir/possible_borrower.rs | 4 ++-- clippy_utils/src/qualify_min_const_fn.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clippy_utils/src/mir/possible_borrower.rs b/clippy_utils/src/mir/possible_borrower.rs index f2bffc8156af..0ead5944b4b3 100644 --- a/clippy_utils/src/mir/possible_borrower.rs +++ b/clippy_utils/src/mir/possible_borrower.rs @@ -110,7 +110,7 @@ impl<'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'_, '_, 'tcx> { immutable_borrowers.push(p.local); } }, - mir::Operand::Constant(..) => (), + mir::Operand::Constant(..) | mir::Operand::RuntimeChecks(..) => (), } } @@ -151,7 +151,7 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) { let mut visit_op = |op: &mir::Operand<'_>| match op { mir::Operand::Copy(p) | mir::Operand::Move(p) => visit(p.local), - mir::Operand::Constant(..) => (), + mir::Operand::Constant(..) | mir::Operand::RuntimeChecks(..) => (), }; match rvalue { diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index c1d00fc8d371..06220f91c745 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -277,6 +277,7 @@ fn check_operand<'tcx>( Some(_) => Err((span, "cannot access `static` items in const fn".into())), None => Ok(()), }, + Operand::RuntimeChecks(..) => Ok(()), } } From a601e768572a0e9753f40ad45c6d734c276d1043 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 14 Dec 2025 17:29:59 +0000 Subject: [PATCH 163/489] Use ScalarInt from bool. --- compiler/rustc_codegen_cranelift/src/base.rs | 7 +++---- compiler/rustc_codegen_cranelift/src/constant.rs | 5 +---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 79f65141e66f..1a916c876824 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{ScalarInt, TypeVisitableExt}; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -1040,10 +1040,9 @@ pub(crate) fn codegen_operand<'tcx>( } Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_), Operand::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + let val = checks.value(fx.tcx.sess); let layout = fx.layout_of(fx.tcx.types.bool); - return CValue::const_val(fx, layout, int); + return CValue::const_val(fx, layout, val.into()); } } } diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index c25034d4be22..ff8e6744bd32 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -540,10 +540,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option { match operand { - Operand::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - ScalarInt::try_from_uint(int, Size::from_bits(1)) - } + Operand::RuntimeChecks(checks) => Some(checks.value(fx.tcx.sess).into()), Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(), // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored // inside a temporary before being passed to the intrinsic requiring the const argument. From 85921620d1ea3f7f725b6942b386ed1aa8c3d18f Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 14 Dec 2025 17:29:59 +0000 Subject: [PATCH 164/489] Use ScalarInt from bool. --- src/base.rs | 7 +++---- src/constant.rs | 5 +---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index 79f65141e66f..1a916c876824 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,10 +8,10 @@ use rustc_ast::InlineAsmOptions; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_index::IndexVec; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{ScalarInt, TypeVisitableExt}; use rustc_session::config::OutputFilenames; use rustc_span::Symbol; @@ -1040,10 +1040,9 @@ pub(crate) fn codegen_operand<'tcx>( } Operand::Constant(const_) => crate::constant::codegen_constant_operand(fx, const_), Operand::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap(); + let val = checks.value(fx.tcx.sess); let layout = fx.layout_of(fx.tcx.types.bool); - return CValue::const_val(fx, layout, int); + return CValue::const_val(fx, layout, val.into()); } } } diff --git a/src/constant.rs b/src/constant.rs index c25034d4be22..ff8e6744bd32 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -540,10 +540,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option { match operand { - Operand::RuntimeChecks(checks) => { - let int = checks.value(fx.tcx.sess); - ScalarInt::try_from_uint(int, Size::from_bits(1)) - } + Operand::RuntimeChecks(checks) => Some(checks.value(fx.tcx.sess).into()), Operand::Constant(const_) => eval_mir_constant(fx, const_).0.try_to_scalar_int(), // FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored // inside a temporary before being passed to the intrinsic requiring the const argument. From 8759e5a8c68dec8b3aa67ddbdd24e1270700cd7e Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 14 Dec 2025 17:30:07 +0000 Subject: [PATCH 165/489] Update doc. --- compiler/rustc_mir_transform/src/promote_consts.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index faff0f23143a..11266ccc2832 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -360,7 +360,8 @@ impl<'tcx> Validator<'_, 'tcx> { match operand { Operand::Copy(place) | Operand::Move(place) => self.validate_place(place.as_ref()), - // Promoting a runtime check would transform a runtime error into a compile-time error. + // `RuntimeChecks` behaves different in const-eval and runtime MIR, + // so we do not promote it. Operand::RuntimeChecks(_) => Err(Unpromotable), // The qualifs for a constant (e.g. `HasMutInterior`) are checked in From 60c387afbd335f0cd377dafd6f027694ab673972 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 14 Dec 2025 17:30:21 +0000 Subject: [PATCH 166/489] Do not pprint as const. --- compiler/rustc_public/src/mir/pretty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_public/src/mir/pretty.rs b/compiler/rustc_public/src/mir/pretty.rs index fec5bd57efdd..5ba72965cb29 100644 --- a/compiler/rustc_public/src/mir/pretty.rs +++ b/compiler/rustc_public/src/mir/pretty.rs @@ -332,7 +332,7 @@ fn pretty_operand(operand: &Operand) -> String { format!("move {mv:?}") } Operand::Constant(cnst) => pretty_mir_const(&cnst.const_), - Operand::RuntimeChecks(checks) => format!("const {checks:?}"), + Operand::RuntimeChecks(checks) => format!("{checks:?}"), } } From a02dc3487afa61780ea4a74d9a7ecda3f85b86ab Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Sun, 14 Dec 2025 18:36:06 +0000 Subject: [PATCH 167/489] Bless codegen. --- tests/codegen-llvm/lib-optimizations/ilog10-range.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/codegen-llvm/lib-optimizations/ilog10-range.rs b/tests/codegen-llvm/lib-optimizations/ilog10-range.rs index b466855389fb..a459e3536127 100644 --- a/tests/codegen-llvm/lib-optimizations/ilog10-range.rs +++ b/tests/codegen-llvm/lib-optimizations/ilog10-range.rs @@ -148,8 +148,7 @@ fn usize_ilog10_range(value: usize) { // CHECK-LABEL: @usize_ilog10_range( // CHECK-NOT: panic - // CHECK: ret void - // CHECK-NEXT: } + // CHECK: } assert!(value == 0 || value.ilog10() <= MAX_RESULT); assert!(value.checked_ilog10().is_none_or(|result| result <= MAX_RESULT)); } From cc68f2227dd73471242f1a9ff600a5443a0b7785 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Sun, 14 Dec 2025 00:49:48 -0600 Subject: [PATCH 168/489] Enable llvm-libunwind by default for Hexagon targets Fixes library linking issues where libgcc_s was incorrectly being linked instead of the appropriate LLVM runtime libraries for Hexagon targets. * Set llvm-libunwind as default for all hexagon targets in bootstrap * Exclude hexagon from automatic libgcc_s linking in unwind * Enable libunwind.a copying for hexagon targets * Remove manual library linking from hexagon target specification --- library/unwind/src/lib.rs | 19 ++++++++++++++++++- src/bootstrap/src/core/build_steps/compile.rs | 5 ++++- src/bootstrap/src/core/config/config.rs | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index e3a0a77f53f0..cff2aa7b08b9 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -73,11 +73,28 @@ cfg_select! { } _ => { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] + #[link(name = "gcc_s", cfg(all(not(target_feature = "crt-static"), not(target_arch = "hexagon"))))] unsafe extern "C" {} } } +// Hexagon with musl uses llvm-libunwind by default +#[cfg(all(target_env = "musl", target_arch = "hexagon"))] +cfg_select! { + feature = "llvm-libunwind" => { + #[link(name = "unwind", kind = "static", modifiers = "-bundle")] + unsafe extern "C" {} + } + feature = "system-llvm-libunwind" => { + #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] + #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] + unsafe extern "C" {} + } + _ => { + // Fallback: should not happen since hexagon defaults to llvm-libunwind + } +} + // This is the same as musl except that we default to using the system libunwind // instead of libgcc. #[cfg(target_env = "ohos")] diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 82cc25f123bc..725e69ecee9b 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -354,7 +354,10 @@ fn copy_third_party_objects( if target == "x86_64-fortanix-unknown-sgx" || builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree - && (target.contains("linux") || target.contains("fuchsia") || target.contains("aix")) + && (target.contains("linux") + || target.contains("fuchsia") + || target.contains("aix") + || target.contains("hexagon")) { let libunwind_path = copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target)); diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 2f493658ec0e..6e6f5a1ea773 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1851,7 +1851,7 @@ impl Config { .get(&target) .and_then(|t| t.llvm_libunwind) .or(self.llvm_libunwind_default) - .unwrap_or(if target.contains("fuchsia") { + .unwrap_or(if target.contains("fuchsia") || target.contains("hexagon") { LlvmLibunwind::InTree } else { LlvmLibunwind::No From 0c1612eb98b42e5faa9a366774c4f7fb21c41772 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Sun, 14 Dec 2025 00:50:00 -0600 Subject: [PATCH 169/489] Implement va_arg for Hexagon Linux musl targets Implements proper variadic argument handling for hexagon-unknown-linux-musl targets using a 3-pointer VaList structure compatible with LLVM's HexagonBuiltinVaList implementation. * Handles register save area vs overflow area transition * Provides proper 4-byte and 8-byte alignment for arguments * Only activates for hexagon+musl targets via Arch::Hexagon & Env::Musl --- compiler/rustc_codegen_llvm/src/va_arg.rs | 88 ++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index add25da025b2..aa5776b298d2 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -7,7 +7,7 @@ use rustc_codegen_ssa::traits::{ }; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; -use rustc_target::spec::{Abi, Arch}; +use rustc_target::spec::{Abi, Arch, Env}; use crate::builder::Builder; use crate::llvm::{Type, Value}; @@ -780,6 +780,91 @@ fn x86_64_sysv64_va_arg_from_memory<'ll, 'tcx>( mem_addr } +fn emit_hexagon_va_arg<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, + list: OperandRef<'tcx, &'ll Value>, + target_ty: Ty<'tcx>, +) -> &'ll Value { + // Implementation of va_arg for Hexagon musl target. + // Based on LLVM's HexagonBuiltinVaList implementation. + // + // struct __va_list_tag { + // void *__current_saved_reg_area_pointer; + // void *__saved_reg_area_end_pointer; + // void *__overflow_area_pointer; + // }; + // + // All variadic arguments are passed on the stack, but the musl implementation + // uses a register save area for compatibility. + let va_list_addr = list.immediate(); + let layout = bx.cx.layout_of(target_ty); + let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + let ptr_size = bx.tcx().data_layout.pointer_size().bytes(); + + // Check if argument fits in register save area + let maybe_reg = bx.append_sibling_block("va_arg.maybe_reg"); + let from_overflow = bx.append_sibling_block("va_arg.from_overflow"); + let end = bx.append_sibling_block("va_arg.end"); + + // Load the three pointers from va_list + let current_ptr_addr = va_list_addr; + let end_ptr_addr = bx.inbounds_ptradd(va_list_addr, bx.const_usize(ptr_size)); + let overflow_ptr_addr = bx.inbounds_ptradd(va_list_addr, bx.const_usize(2 * ptr_size)); + + let current_ptr = bx.load(bx.type_ptr(), current_ptr_addr, ptr_align_abi); + let end_ptr = bx.load(bx.type_ptr(), end_ptr_addr, ptr_align_abi); + let overflow_ptr = bx.load(bx.type_ptr(), overflow_ptr_addr, ptr_align_abi); + + // Align current pointer based on argument type size (following LLVM's implementation) + // Arguments <= 32 bits (4 bytes) use 4-byte alignment, > 32 bits use 8-byte alignment + let type_size_bits = bx.cx.size_of(target_ty).bits(); + let arg_align = if type_size_bits > 32 { + Align::from_bytes(8).unwrap() + } else { + Align::from_bytes(4).unwrap() + }; + let aligned_current = round_pointer_up_to_alignment(bx, current_ptr, arg_align, bx.type_ptr()); + + // Calculate next pointer position (following LLVM's logic) + // Arguments <= 32 bits take 4 bytes, > 32 bits take 8 bytes + let arg_size = if type_size_bits > 32 { 8 } else { 4 }; + let next_ptr = bx.inbounds_ptradd(aligned_current, bx.const_usize(arg_size)); + + // Check if argument fits in register save area + let fits_in_regs = bx.icmp(IntPredicate::IntULE, next_ptr, end_ptr); + bx.cond_br(fits_in_regs, maybe_reg, from_overflow); + + // Load from register save area + bx.switch_to_block(maybe_reg); + let reg_value_addr = aligned_current; + // Update current pointer + bx.store(next_ptr, current_ptr_addr, ptr_align_abi); + bx.br(end); + + // Load from overflow area (stack) + bx.switch_to_block(from_overflow); + + // Align overflow pointer using the same alignment rules + let aligned_overflow = + round_pointer_up_to_alignment(bx, overflow_ptr, arg_align, bx.type_ptr()); + + let overflow_value_addr = aligned_overflow; + // Update overflow pointer - use the same size calculation + let next_overflow = bx.inbounds_ptradd(aligned_overflow, bx.const_usize(arg_size)); + bx.store(next_overflow, overflow_ptr_addr, ptr_align_abi); + + // IMPORTANT: Also update the current saved register area pointer to match + // This synchronizes the pointers when switching to overflow area + bx.store(next_overflow, current_ptr_addr, ptr_align_abi); + bx.br(end); + + // Return the value + bx.switch_to_block(end); + let value_addr = + bx.phi(bx.type_ptr(), &[reg_value_addr, overflow_value_addr], &[maybe_reg, from_overflow]); + bx.load(layout.llvm_type(bx), value_addr, layout.align.abi) +} + fn emit_xtensa_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, @@ -964,6 +1049,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), + Arch::Hexagon if target.env == Env::Musl => emit_hexagon_va_arg(bx, addr, target_ty), // For all other architecture/OS combinations fall back to using // the LLVM va_arg instruction. // https://llvm.org/docs/LangRef.html#va-arg-instruction From f7a81885909e5552a686362bbd8fa56a1a8d5453 Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Mon, 15 Dec 2025 05:00:57 +0000 Subject: [PATCH 170/489] Prepare for merging from rust-lang/rust This updates the rust-version file to 0208ee09be465f69005a7a12c28d5eccac7d5f34. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index a1b44d65c597..dcf82c94aaee 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -2cd4ee6bcf517345dd76d7b102d56b2e873cddbc +0208ee09be465f69005a7a12c28d5eccac7d5f34 From a07bd236bdb47d165c9c7f62e35e2a9a3d773ad6 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Thu, 13 Nov 2025 23:51:01 +0800 Subject: [PATCH 171/489] rustc_target: Add `efiapi` ABI support for LoongArch This commit adds basic `efiapi` ABI support for LoongArch by recognizing `extern "efiapi"` in the ABI map and inline asm clobber handling, and mapping it to the C calling convention. This change is intentionally submitted ahead of the full LoongArch UEFI target support. While UEFI binaries are ultimately produced as PE images, LoongArch UEFI applications can already be developed by building ELF objects, applying relocation fixups, and converting them to PE in a later step. For such workflows, having `efiapi` properly recognized by the compiler is a prerequisite, even without a dedicated UEFI target. Landing this ABI support early helps unblock LoongArch UEFI application and driver development, and allows the remaining UEFI-specific pieces to be introduced incrementally in follow-up patches. MCP: https://github.com/rust-lang/compiler-team/issues/953 --- compiler/rustc_target/src/asm/mod.rs | 4 ++-- compiler/rustc_target/src/spec/abi_map.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index 05b24d710948..0078866ab950 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -997,8 +997,8 @@ impl InlineAsmClobberAbi { _ => Err(&["C", "system"]), }, InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => match name { - "C" | "system" => Ok(InlineAsmClobberAbi::LoongArch), - _ => Err(&["C", "system"]), + "C" | "system" | "efiapi" => Ok(InlineAsmClobberAbi::LoongArch), + _ => Err(&["C", "system", "efiapi"]), }, InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => match name { "C" | "system" => Ok(if target.abi == Abi::Spe { diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs index 8126227d80e4..d7fc18cd3761 100644 --- a/compiler/rustc_target/src/spec/abi_map.rs +++ b/compiler/rustc_target/src/spec/abi_map.rs @@ -56,6 +56,7 @@ impl AbiMap { ArmVer::Other }), Arch::Avr => ArchKind::Avr, + Arch::LoongArch32 | Arch::LoongArch64 => ArchKind::LoongArch, Arch::Msp430 => ArchKind::Msp430, Arch::Nvptx64 => ArchKind::Nvptx, Arch::RiscV32 | Arch::RiscV64 => ArchKind::Riscv, @@ -108,7 +109,10 @@ impl AbiMap { (ExternAbi::EfiApi, ArchKind::Arm(..)) => CanonAbi::Arm(ArmCall::Aapcs), (ExternAbi::EfiApi, ArchKind::X86_64) => CanonAbi::X86(X86Call::Win64), - (ExternAbi::EfiApi, ArchKind::Aarch64 | ArchKind::Riscv | ArchKind::X86) => CanonAbi::C, + ( + ExternAbi::EfiApi, + ArchKind::Aarch64 | ArchKind::LoongArch | ArchKind::Riscv | ArchKind::X86, + ) => CanonAbi::C, (ExternAbi::EfiApi, _) => return AbiMapping::Invalid, /* arm */ @@ -196,6 +200,7 @@ enum ArchKind { Amdgpu, Arm(ArmVer), Avr, + LoongArch, Msp430, Nvptx, Riscv, From c59da4f8096c32a262224aa24a8f0678a790981f Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Mon, 15 Dec 2025 15:11:48 +0700 Subject: [PATCH 172/489] loops: reuse iterator checks for unused_enumerate_index --- clippy_lints/src/loops/mod.rs | 33 +++++++++++++------ clippy_lints/src/loops/never_loop.rs | 30 +++-------------- .../src/loops/unused_enumerate_index.rs | 12 +++---- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 051765a22c31..ddc783069385 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -884,25 +884,38 @@ impl<'tcx> LateLintPass<'tcx> for Loops { if let ExprKind::MethodCall(path, recv, args, _) = expr.kind { let name = path.ident.name; - let is_iterator_method = cx - .ty_based_def(expr) - .assoc_fn_parent(cx) - .is_diag_item(cx, sym::Iterator); + let is_iterator_method = || { + cx.ty_based_def(expr) + .assoc_fn_parent(cx) + .is_diag_item(cx, sym::Iterator) + }; + + // is_iterator_method is a bit expensive, so we call it last in each match arm match (name, args) { (sym::for_each | sym::all | sym::any, [arg]) => { - unused_enumerate_index::check_method(cx, expr, recv, arg); - if is_iterator_method { - never_loop::check_iterator_reduction(cx, expr, recv, args); + if let ExprKind::Closure(closure) = arg.kind + && is_iterator_method() + { + unused_enumerate_index::check_method(cx, recv, arg, closure); + never_loop::check_iterator_reduction(cx, expr, recv, closure); } }, (sym::filter_map | sym::find_map | sym::flat_map | sym::map, [arg]) => { - unused_enumerate_index::check_method(cx, expr, recv, arg); + if let ExprKind::Closure(closure) = arg.kind + && is_iterator_method() + { + unused_enumerate_index::check_method(cx, recv, arg, closure); + } }, - (sym::try_for_each | sym::reduce | sym::fold | sym::try_fold, args) if is_iterator_method => { - never_loop::check_iterator_reduction(cx, expr, recv, args); + (sym::try_for_each | sym::reduce, [arg]) | (sym::fold | sym::try_fold, [_, arg]) => { + if let ExprKind::Closure(closure) = arg.kind + && is_iterator_method() + { + never_loop::check_iterator_reduction(cx, expr, recv, closure); + } }, _ => {}, diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index dca104795ce3..a037af3433c3 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -8,7 +8,8 @@ use clippy_utils::sym; use clippy_utils::visitors::{Descend, for_each_expr_without_closures}; use rustc_errors::Applicability; use rustc_hir::{ - Block, Destination, Expr, ExprKind, HirId, InlineAsm, InlineAsmOperand, Node, Pat, Stmt, StmtKind, StructTailExpr, + Block, Closure, Destination, Expr, ExprKind, HirId, InlineAsm, InlineAsmOperand, Node, Pat, Stmt, StmtKind, + StructTailExpr, }; use rustc_lint::LateContext; use rustc_span::{BytePos, Span}; @@ -77,32 +78,9 @@ pub(super) fn check_iterator_reduction<'tcx>( cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, recv: &'tcx Expr<'tcx>, - args: &'tcx [Expr<'tcx>], + closure: &'tcx Closure<'tcx>, ) { - // identify which argument is the closure based on the method kind - let Some(method_name) = (match expr.kind { - ExprKind::MethodCall(path, ..) => Some(path.ident.name), - _ => None, - }) else { - return; - }; - - let closure_arg = match method_name { - sym::for_each | sym::try_for_each | sym::reduce | sym::all | sym::any => args.first(), - sym::fold | sym::try_fold => args.get(1), - _ => None, - }; - - let Some(closure_arg) = closure_arg else { - return; - }; - - // extract the closure body - let closure_body = match closure_arg.kind { - ExprKind::Closure(closure) => cx.tcx.hir_body(closure.body).value, - _ => return, - }; - + let closure_body = cx.tcx.hir_body(closure.body).value; let body_ty = cx.typeck_results().expr_ty(closure_body); if body_ty.is_never() { span_lint_and_then( diff --git a/clippy_lints/src/loops/unused_enumerate_index.rs b/clippy_lints/src/loops/unused_enumerate_index.rs index 82ded453616d..816273c7ba8b 100644 --- a/clippy_lints/src/loops/unused_enumerate_index.rs +++ b/clippy_lints/src/loops/unused_enumerate_index.rs @@ -1,10 +1,10 @@ use super::UNUSED_ENUMERATE_INDEX; use clippy_utils::diagnostics::span_lint_hir_and_then; -use clippy_utils::res::{MaybeDef, MaybeTypeckRes}; +use clippy_utils::res::MaybeDef; use clippy_utils::source::{SpanRangeExt, walk_span_to_context}; use clippy_utils::{expr_or_init, pat_is_wild}; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, Pat, PatKind, TyKind}; +use rustc_hir::{Closure, Expr, ExprKind, Pat, PatKind, TyKind}; use rustc_lint::LateContext; use rustc_span::{Span, SyntaxContext, sym}; @@ -60,14 +60,12 @@ pub(super) fn check<'tcx>( pub(super) fn check_method<'tcx>( cx: &LateContext<'tcx>, - e: &'tcx Expr<'tcx>, recv: &'tcx Expr<'tcx>, arg: &'tcx Expr<'tcx>, + closure: &'tcx Closure<'tcx>, ) { - if let ExprKind::Closure(closure) = arg.kind - && let body = cx.tcx.hir_body(closure.body) - && let [param] = body.params - && cx.ty_based_def(e).opt_parent(cx).is_diag_item(cx, sym::Iterator) + let body = cx.tcx.hir_body(closure.body); + if let [param] = body.params && let [input] = closure.fn_decl.inputs && !arg.span.from_expansion() && !input.span.from_expansion() From 141342c34f3b3a623a132e08cbfcc883d3e97017 Mon Sep 17 00:00:00 2001 From: usamoi Date: Mon, 15 Dec 2025 18:57:33 +0800 Subject: [PATCH 173/489] stabilize lazy_get --- library/core/src/cell/lazy.rs | 11 +--- library/core/src/lib.rs | 1 - library/coretests/tests/lib.rs | 1 - library/std/src/lib.rs | 1 - library/std/src/sync/lazy_lock.rs | 11 +--- library/std/tests/sync/lib.rs | 1 - ...onst-item-interior-mutations-const-cell.rs | 1 - ...-item-interior-mutations-const-cell.stderr | 44 +++++++------- .../const-item-interior-mutations-const.fixed | 1 - .../const-item-interior-mutations-const.rs | 1 - ...const-item-interior-mutations-const.stderr | 60 +++++++++---------- 11 files changed, 58 insertions(+), 75 deletions(-) diff --git a/library/core/src/cell/lazy.rs b/library/core/src/cell/lazy.rs index 3dae6c64200c..8ffa9b3def51 100644 --- a/library/core/src/cell/lazy.rs +++ b/library/core/src/cell/lazy.rs @@ -165,7 +165,6 @@ impl T> LazyCell { /// # Examples /// /// ``` - /// #![feature(lazy_get)] /// use std::cell::LazyCell; /// /// let mut lazy = LazyCell::new(|| 92); @@ -176,7 +175,7 @@ impl T> LazyCell { /// assert_eq!(*lazy, 44); /// ``` #[inline] - #[unstable(feature = "lazy_get", issue = "129333")] + #[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")] pub fn force_mut(this: &mut LazyCell) -> &mut T { #[cold] /// # Safety @@ -264,8 +263,6 @@ impl LazyCell { /// # Examples /// /// ``` - /// #![feature(lazy_get)] - /// /// use std::cell::LazyCell; /// /// let mut lazy = LazyCell::new(|| 92); @@ -276,7 +273,7 @@ impl LazyCell { /// assert_eq!(*lazy, 44); /// ``` #[inline] - #[unstable(feature = "lazy_get", issue = "129333")] + #[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")] pub fn get_mut(this: &mut LazyCell) -> Option<&mut T> { let state = this.state.get_mut(); match state { @@ -291,8 +288,6 @@ impl LazyCell { /// # Examples /// /// ``` - /// #![feature(lazy_get)] - /// /// use std::cell::LazyCell; /// /// let lazy = LazyCell::new(|| 92); @@ -302,7 +297,7 @@ impl LazyCell { /// assert_eq!(LazyCell::get(&lazy), Some(&92)); /// ``` #[inline] - #[unstable(feature = "lazy_get", issue = "129333")] + #[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")] pub fn get(this: &LazyCell) -> Option<&T> { // SAFETY: // This is sound for the same reason as in `force`: once the state is diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 9ecc2365e69b..962b0cea4a4f 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -113,7 +113,6 @@ #![feature(internal_impls_macro)] #![feature(ip)] #![feature(is_ascii_octdigit)] -#![feature(lazy_get)] #![feature(link_cfg)] #![feature(offset_of_enum)] #![feature(panic_internals)] diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 0387b442562d..b28e7338859c 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -79,7 +79,6 @@ #![feature(iterator_try_collect)] #![feature(iterator_try_reduce)] #![feature(layout_for_ptr)] -#![feature(lazy_get)] #![feature(maybe_uninit_fill)] #![feature(maybe_uninit_uninit_array_transpose)] #![feature(min_specialization)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 8fb1b1b05d20..1a1746c91edd 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -343,7 +343,6 @@ #![feature(hint_must_use)] #![feature(int_from_ascii)] #![feature(ip)] -#![feature(lazy_get)] #![feature(maybe_uninit_array_assume_init)] #![feature(panic_can_unwind)] #![feature(panic_internals)] diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index ef58b64d4967..ef5c949e471f 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -172,7 +172,6 @@ impl T> LazyLock { /// # Examples /// /// ``` - /// #![feature(lazy_get)] /// use std::sync::LazyLock; /// /// let mut lazy = LazyLock::new(|| 92); @@ -183,7 +182,7 @@ impl T> LazyLock { /// assert_eq!(*lazy, 44); /// ``` #[inline] - #[unstable(feature = "lazy_get", issue = "129333")] + #[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")] pub fn force_mut(this: &mut LazyLock) -> &mut T { #[cold] /// # Safety @@ -279,8 +278,6 @@ impl LazyLock { /// # Examples /// /// ``` - /// #![feature(lazy_get)] - /// /// use std::sync::LazyLock; /// /// let mut lazy = LazyLock::new(|| 92); @@ -291,7 +288,7 @@ impl LazyLock { /// assert_eq!(*lazy, 44); /// ``` #[inline] - #[unstable(feature = "lazy_get", issue = "129333")] + #[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")] pub fn get_mut(this: &mut LazyLock) -> Option<&mut T> { // `state()` does not perform an atomic load, so prefer it over `is_complete()`. let state = this.once.state(); @@ -309,8 +306,6 @@ impl LazyLock { /// # Examples /// /// ``` - /// #![feature(lazy_get)] - /// /// use std::sync::LazyLock; /// /// let lazy = LazyLock::new(|| 92); @@ -320,7 +315,7 @@ impl LazyLock { /// assert_eq!(LazyLock::get(&lazy), Some(&92)); /// ``` #[inline] - #[unstable(feature = "lazy_get", issue = "129333")] + #[stable(feature = "lazy_get", since = "CURRENT_RUSTC_VERSION")] #[rustc_should_not_be_called_on_const_items] pub fn get(this: &LazyLock) -> Option<&T> { if this.once.is_completed() { diff --git a/library/std/tests/sync/lib.rs b/library/std/tests/sync/lib.rs index 20e34c9aa6bd..7ade9f623147 100644 --- a/library/std/tests/sync/lib.rs +++ b/library/std/tests/sync/lib.rs @@ -1,4 +1,3 @@ -#![feature(lazy_get)] #![feature(mapped_lock_guards)] #![feature(mpmc_channel)] #![feature(once_cell_try)] diff --git a/tests/ui/lint/const-item-interior-mutations-const-cell.rs b/tests/ui/lint/const-item-interior-mutations-const-cell.rs index b4a7f54c8e7a..22b465fa0a95 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-cell.rs +++ b/tests/ui/lint/const-item-interior-mutations-const-cell.rs @@ -4,7 +4,6 @@ #![feature(sync_unsafe_cell)] #![feature(once_cell_try_insert)] #![feature(once_cell_try)] -#![feature(lazy_get)] use std::cell::{Cell, RefCell, SyncUnsafeCell, UnsafeCell}; use std::cell::{LazyCell, OnceCell}; diff --git a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr index d9f19c61fa77..ec3a5f4e38ee 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr @@ -1,5 +1,5 @@ warning: mutation of an interior mutable `const` item with call to `force` - --> $DIR/const-item-interior-mutations-const-cell.rs:16:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:15:13 | LL | let _ = LazyCell::force(&A); | ^^^^^^^^^^^^^^^^^-^ @@ -17,7 +17,7 @@ LL + static A: LazyCell = LazyCell::new(|| 0); | warning: mutation of an interior mutable `const` item with call to `set` - --> $DIR/const-item-interior-mutations-const-cell.rs:23:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:22:13 | LL | let _ = A.set(10); | -^^^^^^^^ @@ -34,7 +34,7 @@ LL + static A: OnceCell = OnceCell::new(); | warning: mutation of an interior mutable `const` item with call to `try_insert` - --> $DIR/const-item-interior-mutations-const-cell.rs:26:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:25:13 | LL | let _ = A.try_insert(20); | -^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL + static A: OnceCell = OnceCell::new(); | warning: mutation of an interior mutable `const` item with call to `get_or_init` - --> $DIR/const-item-interior-mutations-const-cell.rs:29:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:28:13 | LL | let _ = A.get_or_init(|| 30); | -^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL + static A: OnceCell = OnceCell::new(); | warning: mutation of an interior mutable `const` item with call to `get_or_try_init` - --> $DIR/const-item-interior-mutations-const-cell.rs:32:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:31:13 | LL | let _ = A.get_or_try_init(|| Ok::<_, ()>(40)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + static A: OnceCell = OnceCell::new(); | warning: mutation of an interior mutable `const` item with call to `set` - --> $DIR/const-item-interior-mutations-const-cell.rs:39:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:38:13 | LL | let _ = A.set(1); | -^^^^^^^ @@ -102,7 +102,7 @@ LL + static A: Cell = Cell::new(0); | warning: mutation of an interior mutable `const` item with call to `swap` - --> $DIR/const-item-interior-mutations-const-cell.rs:42:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:41:13 | LL | let _ = A.swap(&A); | -^^^^^^^^^ @@ -119,7 +119,7 @@ LL + static A: Cell = Cell::new(0); | warning: mutation of an interior mutable `const` item with call to `replace` - --> $DIR/const-item-interior-mutations-const-cell.rs:45:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:44:13 | LL | let _ = A.replace(2); | -^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL + static A: Cell = Cell::new(0); | warning: mutation of an interior mutable `const` item with call to `get` - --> $DIR/const-item-interior-mutations-const-cell.rs:48:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:47:13 | LL | let _ = A.get(); | -^^^^^^ @@ -153,7 +153,7 @@ LL + static A: Cell = Cell::new(0); | warning: mutation of an interior mutable `const` item with call to `update` - --> $DIR/const-item-interior-mutations-const-cell.rs:51:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:50:13 | LL | let _ = A.update(|x| x + 1); | -^^^^^^^^^^^^^^^^^^ @@ -170,7 +170,7 @@ LL + static A: Cell = Cell::new(0); | warning: mutation of an interior mutable `const` item with call to `replace` - --> $DIR/const-item-interior-mutations-const-cell.rs:58:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:57:13 | LL | let _ = A.replace(1); | -^^^^^^^^^^^ @@ -187,7 +187,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `replace_with` - --> $DIR/const-item-interior-mutations-const-cell.rs:61:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:60:13 | LL | let _ = A.replace_with(|x| *x + 2); | -^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -204,7 +204,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `swap` - --> $DIR/const-item-interior-mutations-const-cell.rs:64:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:63:13 | LL | let _ = A.swap(&A); | -^^^^^^^^^ @@ -221,7 +221,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `borrow` - --> $DIR/const-item-interior-mutations-const-cell.rs:67:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:66:13 | LL | let _ = A.borrow(); | -^^^^^^^^^ @@ -238,7 +238,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `try_borrow` - --> $DIR/const-item-interior-mutations-const-cell.rs:70:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:69:13 | LL | let _ = A.try_borrow(); | -^^^^^^^^^^^^^ @@ -255,7 +255,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `borrow_mut` - --> $DIR/const-item-interior-mutations-const-cell.rs:73:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:72:13 | LL | let _ = A.borrow_mut(); | -^^^^^^^^^^^^^ @@ -272,7 +272,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `try_borrow_mut` - --> $DIR/const-item-interior-mutations-const-cell.rs:76:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:75:13 | LL | let _ = A.try_borrow_mut(); | -^^^^^^^^^^^^^^^^^ @@ -289,7 +289,7 @@ LL + static A: RefCell = RefCell::new(0); | warning: mutation of an interior mutable `const` item with call to `replace` - --> $DIR/const-item-interior-mutations-const-cell.rs:83:22 + --> $DIR/const-item-interior-mutations-const-cell.rs:82:22 | LL | let _ = unsafe { A.replace(1) }; | -^^^^^^^^^^^ @@ -306,7 +306,7 @@ LL + static A: UnsafeCell = UnsafeCell::new(0); | warning: mutation of an interior mutable `const` item with call to `get` - --> $DIR/const-item-interior-mutations-const-cell.rs:86:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:85:13 | LL | let _ = A.get(); | -^^^^^^ @@ -323,7 +323,7 @@ LL + static A: UnsafeCell = UnsafeCell::new(0); | warning: mutation of an interior mutable `const` item with call to `as_ref_unchecked` - --> $DIR/const-item-interior-mutations-const-cell.rs:90:17 + --> $DIR/const-item-interior-mutations-const-cell.rs:89:17 | LL | let _ = A.as_ref_unchecked(); | -^^^^^^^^^^^^^^^^^^^ @@ -340,7 +340,7 @@ LL + static A: UnsafeCell = UnsafeCell::new(0); | warning: mutation of an interior mutable `const` item with call to `as_mut_unchecked` - --> $DIR/const-item-interior-mutations-const-cell.rs:93:17 + --> $DIR/const-item-interior-mutations-const-cell.rs:92:17 | LL | let _ = A.as_mut_unchecked(); | -^^^^^^^^^^^^^^^^^^^ @@ -357,7 +357,7 @@ LL + static A: UnsafeCell = UnsafeCell::new(0); | warning: mutation of an interior mutable `const` item with call to `get` - --> $DIR/const-item-interior-mutations-const-cell.rs:101:13 + --> $DIR/const-item-interior-mutations-const-cell.rs:100:13 | LL | let _ = A.get(); | -^^^^^^ diff --git a/tests/ui/lint/const-item-interior-mutations-const.fixed b/tests/ui/lint/const-item-interior-mutations-const.fixed index 82f3fdac43a3..97091ab10af8 100644 --- a/tests/ui/lint/const-item-interior-mutations-const.fixed +++ b/tests/ui/lint/const-item-interior-mutations-const.fixed @@ -6,7 +6,6 @@ #![feature(lock_value_accessors)] #![feature(once_cell_try_insert)] #![feature(once_cell_try)] -#![feature(lazy_get)] use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock}; use std::time::Duration; diff --git a/tests/ui/lint/const-item-interior-mutations-const.rs b/tests/ui/lint/const-item-interior-mutations-const.rs index 5dbbfd8ca32f..40565118ca79 100644 --- a/tests/ui/lint/const-item-interior-mutations-const.rs +++ b/tests/ui/lint/const-item-interior-mutations-const.rs @@ -6,7 +6,6 @@ #![feature(lock_value_accessors)] #![feature(once_cell_try_insert)] #![feature(once_cell_try)] -#![feature(lazy_get)] use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock}; use std::time::Duration; diff --git a/tests/ui/lint/const-item-interior-mutations-const.stderr b/tests/ui/lint/const-item-interior-mutations-const.stderr index 7d3e7bee7fbb..2fe8f190dbed 100644 --- a/tests/ui/lint/const-item-interior-mutations-const.stderr +++ b/tests/ui/lint/const-item-interior-mutations-const.stderr @@ -1,5 +1,5 @@ warning: mutation of an interior mutable `const` item with call to `set` - --> $DIR/const-item-interior-mutations-const.rs:17:14 + --> $DIR/const-item-interior-mutations-const.rs:16:14 | LL | let _a = A.set(1); | -^^^^^^^ @@ -17,7 +17,7 @@ LL + static A: Mutex = Mutex::new(0); | warning: mutation of an interior mutable `const` item with call to `replace` - --> $DIR/const-item-interior-mutations-const.rs:20:14 + --> $DIR/const-item-interior-mutations-const.rs:19:14 | LL | let _a = A.replace(2); | -^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL + static A: Mutex = Mutex::new(0); | warning: mutation of an interior mutable `const` item with call to `lock` - --> $DIR/const-item-interior-mutations-const.rs:23:10 + --> $DIR/const-item-interior-mutations-const.rs:22:10 | LL | drop(A.lock()); | -^^^^^^^ @@ -51,7 +51,7 @@ LL + static A: Mutex = Mutex::new(0); | warning: mutation of an interior mutable `const` item with call to `try_lock` - --> $DIR/const-item-interior-mutations-const.rs:26:10 + --> $DIR/const-item-interior-mutations-const.rs:25:10 | LL | drop(A.try_lock()); | -^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL + static A: Mutex = Mutex::new(0); | warning: mutation of an interior mutable `const` item with call to `clear_poison` - --> $DIR/const-item-interior-mutations-const.rs:29:14 + --> $DIR/const-item-interior-mutations-const.rs:28:14 | LL | let _a = A.clear_poison(); | -^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + static A: Mutex = Mutex::new(0); | warning: mutation of an interior mutable `const` item with call to `call_once` - --> $DIR/const-item-interior-mutations-const.rs:36:14 + --> $DIR/const-item-interior-mutations-const.rs:35:14 | LL | let _a = A.call_once(|| {}); | -^^^^^^^^^^^^^^^^^ @@ -102,7 +102,7 @@ LL + static A: Once = Once::new(); | warning: mutation of an interior mutable `const` item with call to `call_once_force` - --> $DIR/const-item-interior-mutations-const.rs:39:14 + --> $DIR/const-item-interior-mutations-const.rs:38:14 | LL | let _a = A.call_once_force(|_| {}); | -^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL + static A: Once = Once::new(); | warning: mutation of an interior mutable `const` item with call to `wait` - --> $DIR/const-item-interior-mutations-const.rs:42:14 + --> $DIR/const-item-interior-mutations-const.rs:41:14 | LL | let _a = A.wait(); | -^^^^^^^ @@ -136,7 +136,7 @@ LL + static A: Once = Once::new(); | warning: mutation of an interior mutable `const` item with call to `wait_force` - --> $DIR/const-item-interior-mutations-const.rs:45:14 + --> $DIR/const-item-interior-mutations-const.rs:44:14 | LL | let _a = A.wait_force(); | -^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ LL + static A: Once = Once::new(); | warning: mutation of an interior mutable `const` item with call to `set` - --> $DIR/const-item-interior-mutations-const.rs:52:14 + --> $DIR/const-item-interior-mutations-const.rs:51:14 | LL | let _a = A.set(1); | -^^^^^^^ @@ -170,7 +170,7 @@ LL + static A: RwLock = RwLock::new(0); | warning: mutation of an interior mutable `const` item with call to `replace` - --> $DIR/const-item-interior-mutations-const.rs:55:14 + --> $DIR/const-item-interior-mutations-const.rs:54:14 | LL | let _a = A.replace(2); | -^^^^^^^^^^^ @@ -187,7 +187,7 @@ LL + static A: RwLock = RwLock::new(0); | warning: mutation of an interior mutable `const` item with call to `read` - --> $DIR/const-item-interior-mutations-const.rs:58:10 + --> $DIR/const-item-interior-mutations-const.rs:57:10 | LL | drop(A.read()); | -^^^^^^^ @@ -204,7 +204,7 @@ LL + static A: RwLock = RwLock::new(0); | warning: mutation of an interior mutable `const` item with call to `try_read` - --> $DIR/const-item-interior-mutations-const.rs:61:10 + --> $DIR/const-item-interior-mutations-const.rs:60:10 | LL | drop(A.try_read()); | -^^^^^^^^^^^ @@ -221,7 +221,7 @@ LL + static A: RwLock = RwLock::new(0); | warning: mutation of an interior mutable `const` item with call to `write` - --> $DIR/const-item-interior-mutations-const.rs:64:10 + --> $DIR/const-item-interior-mutations-const.rs:63:10 | LL | drop(A.write()); | -^^^^^^^^ @@ -238,7 +238,7 @@ LL + static A: RwLock = RwLock::new(0); | warning: mutation of an interior mutable `const` item with call to `try_write` - --> $DIR/const-item-interior-mutations-const.rs:67:10 + --> $DIR/const-item-interior-mutations-const.rs:66:10 | LL | drop(A.try_write()); | -^^^^^^^^^^^^ @@ -255,7 +255,7 @@ LL + static A: RwLock = RwLock::new(0); | warning: mutation of an interior mutable `const` item with call to `force` - --> $DIR/const-item-interior-mutations-const.rs:74:14 + --> $DIR/const-item-interior-mutations-const.rs:73:14 | LL | let _a = LazyLock::force(&A); | ^^^^^^^^^^^^^^^^^-^ @@ -272,7 +272,7 @@ LL + static A: LazyLock = LazyLock::new(|| 0); | warning: mutation of an interior mutable `const` item with call to `get` - --> $DIR/const-item-interior-mutations-const.rs:77:14 + --> $DIR/const-item-interior-mutations-const.rs:76:14 | LL | let _a = LazyLock::get(&A); | ^^^^^^^^^^^^^^^-^ @@ -289,7 +289,7 @@ LL + static A: LazyLock = LazyLock::new(|| 0); | warning: mutation of an interior mutable `const` item with call to `get` - --> $DIR/const-item-interior-mutations-const.rs:84:14 + --> $DIR/const-item-interior-mutations-const.rs:83:14 | LL | let _a = A.get(); | -^^^^^^ @@ -306,7 +306,7 @@ LL + static A: OnceLock = OnceLock::new(); | warning: mutation of an interior mutable `const` item with call to `wait` - --> $DIR/const-item-interior-mutations-const.rs:87:14 + --> $DIR/const-item-interior-mutations-const.rs:86:14 | LL | let _a = A.wait(); | -^^^^^^^ @@ -323,7 +323,7 @@ LL + static A: OnceLock = OnceLock::new(); | warning: mutation of an interior mutable `const` item with call to `set` - --> $DIR/const-item-interior-mutations-const.rs:90:14 + --> $DIR/const-item-interior-mutations-const.rs:89:14 | LL | let _a = A.set(10); | -^^^^^^^^ @@ -340,7 +340,7 @@ LL + static A: OnceLock = OnceLock::new(); | warning: mutation of an interior mutable `const` item with call to `try_insert` - --> $DIR/const-item-interior-mutations-const.rs:93:14 + --> $DIR/const-item-interior-mutations-const.rs:92:14 | LL | let _a = A.try_insert(20); | -^^^^^^^^^^^^^^^ @@ -357,7 +357,7 @@ LL + static A: OnceLock = OnceLock::new(); | warning: mutation of an interior mutable `const` item with call to `get_or_init` - --> $DIR/const-item-interior-mutations-const.rs:96:14 + --> $DIR/const-item-interior-mutations-const.rs:95:14 | LL | let _a = A.get_or_init(|| 30); | -^^^^^^^^^^^^^^^^^^^ @@ -374,7 +374,7 @@ LL + static A: OnceLock = OnceLock::new(); | warning: mutation of an interior mutable `const` item with call to `get_or_try_init` - --> $DIR/const-item-interior-mutations-const.rs:99:14 + --> $DIR/const-item-interior-mutations-const.rs:98:14 | LL | let _a = A.get_or_try_init(|| Ok::<_, ()>(40)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -391,7 +391,7 @@ LL + static A: OnceLock = OnceLock::new(); | warning: mutation of an interior mutable `const` item with call to `wait` - --> $DIR/const-item-interior-mutations-const.rs:109:14 + --> $DIR/const-item-interior-mutations-const.rs:108:14 | LL | let _a = A.wait(guard); | -^^^^^^^^^^^^ @@ -408,7 +408,7 @@ LL + static A: Condvar = Condvar::new(); | warning: mutation of an interior mutable `const` item with call to `wait_while` - --> $DIR/const-item-interior-mutations-const.rs:114:14 + --> $DIR/const-item-interior-mutations-const.rs:113:14 | LL | let _a = A.wait_while(guard, |x| *x == 0); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -425,7 +425,7 @@ LL + static A: Condvar = Condvar::new(); | warning: mutation of an interior mutable `const` item with call to `wait_timeout_ms` - --> $DIR/const-item-interior-mutations-const.rs:119:14 + --> $DIR/const-item-interior-mutations-const.rs:118:14 | LL | let _a = A.wait_timeout_ms(guard, 10); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -442,7 +442,7 @@ LL + static A: Condvar = Condvar::new(); | warning: mutation of an interior mutable `const` item with call to `wait_timeout` - --> $DIR/const-item-interior-mutations-const.rs:124:14 + --> $DIR/const-item-interior-mutations-const.rs:123:14 | LL | let _a = A.wait_timeout(guard, Duration::from_millis(10)); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL + static A: Condvar = Condvar::new(); | warning: mutation of an interior mutable `const` item with call to `wait_timeout_while` - --> $DIR/const-item-interior-mutations-const.rs:129:14 + --> $DIR/const-item-interior-mutations-const.rs:128:14 | LL | let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -476,7 +476,7 @@ LL + static A: Condvar = Condvar::new(); | warning: mutation of an interior mutable `const` item with call to `notify_one` - --> $DIR/const-item-interior-mutations-const.rs:132:14 + --> $DIR/const-item-interior-mutations-const.rs:131:14 | LL | let _a = A.notify_one(); | -^^^^^^^^^^^^^ @@ -493,7 +493,7 @@ LL + static A: Condvar = Condvar::new(); | warning: mutation of an interior mutable `const` item with call to `notify_all` - --> $DIR/const-item-interior-mutations-const.rs:135:14 + --> $DIR/const-item-interior-mutations-const.rs:134:14 | LL | let _a = A.notify_all(); | -^^^^^^^^^^^^^ From a44de58d4b3135b80ed5925a85a004da66fe8bb0 Mon Sep 17 00:00:00 2001 From: dfireBird Date: Mon, 15 Dec 2025 17:28:05 +0530 Subject: [PATCH 174/489] fix: consider path used in pattern destructing assignments fix: assign mutable for variables in pattern destructing assignments --- .../rust-analyzer/crates/hir/src/semantics.rs | 53 +++++++++++----- .../src/handlers/extract_function.rs | 62 +++++++++++++++++++ .../rust-analyzer/crates/ide-db/src/search.rs | 2 +- 3 files changed, 99 insertions(+), 18 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs index a9af26aa3f66..ccbfd45e3011 100644 --- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs @@ -10,6 +10,7 @@ use std::{ ops::{self, ControlFlow, Not}, }; +use base_db::FxIndexSet; use either::Either; use hir_def::{ DefWithBodyId, FunctionId, MacroId, StructId, TraitId, VariantId, @@ -2197,7 +2198,7 @@ impl<'db> SemanticsImpl<'db> { &self, element: Either<&ast::Expr, &ast::StmtList>, text_range: TextRange, - ) -> Option> { + ) -> Option> { let sa = self.analyze(element.either(|e| e.syntax(), |s| s.syntax()))?; let store = sa.store()?; let mut resolver = sa.resolver.clone(); @@ -2245,31 +2246,49 @@ impl<'db> SemanticsImpl<'db> { let mut exprs: Vec<_> = exprs.into_iter().filter_map(|e| sa.expr_id(e).and_then(|e| e.as_expr())).collect(); - let mut locals: Vec = Vec::new(); - let mut add_to_locals_used = |expr_id| { - if let Expr::Path(path) = &store[expr_id] + let mut locals: FxIndexSet = FxIndexSet::default(); + let mut add_to_locals_used = |id, parent_expr| { + let path = match id { + ExprOrPatId::ExprId(expr_id) => { + if let Expr::Path(path) = &store[expr_id] { + Some(path) + } else { + None + } + } + ExprOrPatId::PatId(pat_id) => { + if let Pat::Path(path) = &store[pat_id] { + Some(path) + } else { + None + } + } + }; + + if let Some(path) = path && is_not_generated(path) { - let _ = resolver.update_to_inner_scope(self.db, def, expr_id); - resolver - .resolve_path_in_value_ns_fully(self.db, path, store.expr_path_hygiene(expr_id)) - .inspect(|value| { - if let ValueNs::LocalBinding(id) = value { - locals.push((def, *id).into()); - } - }); + let _ = resolver.update_to_inner_scope(self.db, def, parent_expr); + let hygiene = store.expr_or_pat_path_hygiene(id); + resolver.resolve_path_in_value_ns_fully(self.db, path, hygiene).inspect(|value| { + if let ValueNs::LocalBinding(id) = value { + locals.insert((def, *id).into()); + } + }); } }; while let Some(expr_id) = exprs.pop() { - let mut has_child = false; + if let Expr::Assignment { target, .. } = store[expr_id] { + store.walk_pats(target, &mut |id| { + add_to_locals_used(ExprOrPatId::PatId(id), expr_id) + }); + }; store.walk_child_exprs(expr_id, |id| { - has_child = true; exprs.push(id); }); - if !has_child { - add_to_locals_used(expr_id) - } + + add_to_locals_used(ExprOrPatId::ExprId(expr_id), expr_id) } Some(locals) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs index 19ded49b1850..231df9b5b3e1 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs @@ -6313,4 +6313,66 @@ fn $0fun_name(v1: u32, v2: u32) -> u32 { }"#, ); } + + #[test] + fn pattern_assignment() { + check_assist( + extract_function, + r#" +struct Point {x: u32, y: u32}; + +fn point() -> Point { + Point { x: 45, y: 50 }; +} + +fn foo() { + let mut a = 1; + let mut b = 3; + $0Point { x: a, y: b } = point();$0 +} +"#, + r#" +struct Point {x: u32, y: u32}; + +fn point() -> Point { + Point { x: 45, y: 50 }; +} + +fn foo() { + let mut a = 1; + let mut b = 3; + fun_name(a, b); +} + +fn $0fun_name(mut a: u32, mut b: u32) { + Point { x: a, y: b } = point(); +} +"#, + ); + } + + #[test] + fn tuple_assignment() { + check_assist( + extract_function, + r#" +fn foo() { + let mut a = 3; + let mut b = 4; + $0(a, b) = (b, a);$0 +} +"#, + r#" +fn foo() { + let mut a = 3; + let mut b = 4; + fun_name(a, b); +} + +fn $0fun_name(mut a: i32, mut b: i32) { + (a, b) = (b, a); +} +"#, + ); + } } diff --git a/src/tools/rust-analyzer/crates/ide-db/src/search.rs b/src/tools/rust-analyzer/crates/ide-db/src/search.rs index a48438cfa86f..1d865892a22b 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/search.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/search.rs @@ -1345,7 +1345,7 @@ impl ReferenceCategory { // If the variable or field ends on the LHS's end then it's a Write // (covers fields and locals). FIXME: This is not terribly accurate. if let Some(lhs) = expr.lhs() - && lhs.syntax().text_range().end() == r.syntax().text_range().end() { + && lhs.syntax().text_range().contains_range(r.syntax().text_range()) { return Some(ReferenceCategory::WRITE) } } From f0418b3461ec949f04e803e2292c568f8816f655 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 11 Dec 2025 11:15:15 -0500 Subject: [PATCH 175/489] When we cannot load libgccjit.so, show the paths that were tried --- src/lib.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a77239e23b4e..96d3a0024f41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,7 +98,6 @@ use rustc_middle::ty::TyCtxt; use rustc_middle::util::Providers; use rustc_session::Session; use rustc_session::config::{OptLevel, OutputFilenames}; -use rustc_session::filesearch::make_target_lib_path; use rustc_span::Symbol; use rustc_target::spec::{Arch, RelocModel}; use tempfile::TempDir; @@ -207,18 +206,38 @@ impl CodegenBackend for GccCodegenBackend { } fn init(&self, sess: &Session) { + fn file_path(sysroot_path: &Path, sess: &Session) -> PathBuf { + let rustlib_path = + rustc_target::relative_target_rustlib_path(sysroot_path, &sess.host.llvm_target); + sysroot_path + .join(rustlib_path) + .join("codegen-backends") + .join("lib") + .join(sess.target.llvm_target.as_ref()) + .join("libgccjit.so") + } + // We use all_paths() instead of only path() in case the path specified by --sysroot is // invalid. // This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null. for path in sess.opts.sysroot.all_paths() { - let libgccjit_target_lib_file = - make_target_lib_path(path, &sess.target.llvm_target).join("libgccjit.so"); + let libgccjit_target_lib_file = file_path(path, sess); if let Ok(true) = fs::exists(&libgccjit_target_lib_file) { load_libgccjit_if_needed(&libgccjit_target_lib_file); break; } } + if !gccjit::is_loaded() { + let mut paths = vec![]; + for path in sess.opts.sysroot.all_paths() { + let libgccjit_target_lib_file = file_path(path, sess); + paths.push(libgccjit_target_lib_file); + } + + panic!("Could not load libgccjit.so. Attempted paths: {:#?}", paths); + } + #[cfg(feature = "master")] { let target_cpu = target_cpu(sess); From 854f619d6a023b15a8b5461a7923134f347b3bb6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 15 Dec 2025 14:36:18 +0100 Subject: [PATCH 176/489] Correctly encode doc attribute metadata --- .../rustc_hir/src/attrs/data_structures.rs | 58 ++++++++++++++++++- compiler/rustc_metadata/src/rmeta/encoder.rs | 10 +--- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 34d78afca9b2..5ebe121dd67c 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -530,7 +530,7 @@ pub struct CfgHideShow { pub values: ThinVec, } -#[derive(Clone, Debug, Default, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, Default, HashStable_Generic, Decodable, PrintAttribute)] pub struct DocAttribute { pub aliases: FxIndexMap, pub hidden: Option, @@ -566,6 +566,62 @@ pub struct DocAttribute { pub no_crate_inject: Option, } +impl rustc_serialize::Encodable for DocAttribute { + fn encode(&self, encoder: &mut E) { + let DocAttribute { + aliases, + hidden, + inline, + cfg, + auto_cfg, + auto_cfg_change, + fake_variadic, + keyword, + attribute, + masked, + notable_trait, + search_unbox, + html_favicon_url, + html_logo_url, + html_playground_url, + html_root_url, + html_no_source, + issue_tracker_base_url, + rust_logo, + test_attrs, + no_crate_inject, + } = self; + rustc_serialize::Encodable::::encode(aliases, encoder); + rustc_serialize::Encodable::::encode(hidden, encoder); + + // FIXME: The `doc(inline)` attribute is never encoded, but is it actually the right thing + // to do? I suspect the condition was broken, should maybe instead not encode anything if we + // have `doc(no_inline)`. + let inline: ThinVec<_> = + inline.iter().filter(|(i, _)| *i != DocInline::Inline).cloned().collect(); + rustc_serialize::Encodable::::encode(&inline, encoder); + + rustc_serialize::Encodable::::encode(cfg, encoder); + rustc_serialize::Encodable::::encode(auto_cfg, encoder); + rustc_serialize::Encodable::::encode(auto_cfg_change, encoder); + rustc_serialize::Encodable::::encode(fake_variadic, encoder); + rustc_serialize::Encodable::::encode(keyword, encoder); + rustc_serialize::Encodable::::encode(attribute, encoder); + rustc_serialize::Encodable::::encode(masked, encoder); + rustc_serialize::Encodable::::encode(notable_trait, encoder); + rustc_serialize::Encodable::::encode(search_unbox, encoder); + rustc_serialize::Encodable::::encode(html_favicon_url, encoder); + rustc_serialize::Encodable::::encode(html_logo_url, encoder); + rustc_serialize::Encodable::::encode(html_playground_url, encoder); + rustc_serialize::Encodable::::encode(html_root_url, encoder); + rustc_serialize::Encodable::::encode(html_no_source, encoder); + rustc_serialize::Encodable::::encode(issue_tracker_base_url, encoder); + rustc_serialize::Encodable::::encode(rust_logo, encoder); + rustc_serialize::Encodable::::encode(test_attrs, encoder); + rustc_serialize::Encodable::::encode(no_crate_inject, encoder); + } +} + /// Represents parsed *built-in* inert attributes. /// /// ## Overview diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index b15ed34fc356..6abde26e7e6d 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -879,13 +879,9 @@ fn analyze_attr(attr: &hir::Attribute, state: &mut AnalyzeAttrState<'_>) -> bool should_encode = true; } } else if let hir::Attribute::Parsed(AttributeKind::Doc(d)) = attr { - // If this is a `doc` attribute that doesn't have anything except maybe `inline` (as in - // `#[doc(inline)]`), then we can remove it. It won't be inlinable in downstream crates. - if d.inline.is_empty() { - should_encode = true; - if d.hidden.is_some() { - state.is_doc_hidden = true; - } + should_encode = true; + if d.hidden.is_some() { + state.is_doc_hidden = true; } } else if let &[sym::diagnostic, seg] = &*attr.path() { should_encode = rustc_feature::is_stable_diagnostic_attribute(seg, state.features); From e260484e3eddc5eb16203512257068af78e673d8 Mon Sep 17 00:00:00 2001 From: Catherine Gasnier Date: Mon, 15 Dec 2025 06:21:38 -0800 Subject: [PATCH 177/489] Fix "Invariant violation: file emitted multiple times" when doing `scip .` Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- src/tools/rust-analyzer/crates/ide/src/static_index.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide/src/static_index.rs b/src/tools/rust-analyzer/crates/ide/src/static_index.rs index 7749f8e2f2ea..9d3fd9e005d8 100644 --- a/src/tools/rust-analyzer/crates/ide/src/static_index.rs +++ b/src/tools/rust-analyzer/crates/ide/src/static_index.rs @@ -325,12 +325,12 @@ impl StaticIndex<'_> { }; let mut visited_files = FxHashSet::default(); for module in work { - let file_id = module.definition_source_file_id(db).original_file(db); + let file_id = + module.definition_source_file_id(db).original_file(db).file_id(&analysis.db); if visited_files.contains(&file_id) { continue; } - this.add_file(file_id.file_id(&analysis.db)); - // mark the file + this.add_file(file_id); visited_files.insert(file_id); } this From f71e6d10384de7f4458c4dfeb5eff5bec4dd4a9c Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Mon, 15 Dec 2025 23:16:08 +0900 Subject: [PATCH 178/489] fix: Prefix json target file with workspace root for sysroot metadata --- .../crates/project-model/src/workspace.rs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs index 10abb21ace83..747aa68f082d 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs @@ -391,6 +391,7 @@ impl ProjectWorkspace { sysroot.load_workspace( &RustSourceWorkspaceConfig::CargoMetadata(sysroot_metadata_config( config, + workspace_dir, &targets, toolchain.clone(), )), @@ -500,6 +501,7 @@ impl ProjectWorkspace { sysroot.load_workspace( &RustSourceWorkspaceConfig::CargoMetadata(sysroot_metadata_config( config, + project_json.project_root(), &targets, toolchain.clone(), )), @@ -555,6 +557,7 @@ impl ProjectWorkspace { let loaded_sysroot = sysroot.load_workspace( &RustSourceWorkspaceConfig::CargoMetadata(sysroot_metadata_config( config, + dir, &targets, toolchain.clone(), )), @@ -1907,12 +1910,28 @@ fn add_dep_inner(graph: &mut CrateGraphBuilder, from: CrateBuilderId, dep: Depen fn sysroot_metadata_config( config: &CargoConfig, + workspace_root: &AbsPath, targets: &[String], toolchain_version: Option, ) -> CargoMetadataConfig { + // If the target is a JSON path, prefix it with workspace root directory. + // Since `cargo metadata` command for sysroot is run inside sysroots dir, it may fail to + // locate the target file if it is given as a relative path. + let targets = targets + .iter() + .map(|target| { + if target.ends_with(".json") { + // If `target` is an absolute path, this will replace the whole path. + workspace_root.join(target).to_string() + } else { + target.to_owned() + } + }) + .collect(); + CargoMetadataConfig { features: Default::default(), - targets: targets.to_vec(), + targets, extra_args: Default::default(), extra_env: config.extra_env.clone(), toolchain_version, From c9448e49497d3f524f0e22ff9881542823f3b453 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Mon, 15 Dec 2025 17:51:53 +0200 Subject: [PATCH 179/489] Fix method resolution for incoherent impls when there are two sysroots in the crate graph Which can happen when two workspaces are opened, by only considering impls from dependencies of this crate. I have no idea how to construct a test for this, but I tested it manually and it works. --- .../rust-analyzer/crates/base-db/src/input.rs | 4 +- .../crates/hir-ty/src/method_resolution.rs | 40 ++++++++----------- .../hir-ty/src/method_resolution/probe.rs | 10 +++-- src/tools/rust-analyzer/crates/hir/src/lib.rs | 19 ++++++--- 4 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/tools/rust-analyzer/crates/base-db/src/input.rs b/src/tools/rust-analyzer/crates/base-db/src/input.rs index 1b41386adf77..14649dde648f 100644 --- a/src/tools/rust-analyzer/crates/base-db/src/input.rs +++ b/src/tools/rust-analyzer/crates/base-db/src/input.rs @@ -465,7 +465,7 @@ impl Crate { /// including the crate itself. /// /// **Warning**: do not use this query in `hir-*` crates! It kills incrementality across crate metadata modifications. - pub fn transitive_deps(self, db: &dyn salsa::Database) -> Box<[Crate]> { + pub fn transitive_deps(self, db: &dyn salsa::Database) -> Vec { // There is a bit of duplication here and in `CrateGraphBuilder` in the same method, but it's not terrible // and removing that is a bit difficult. let mut worklist = vec![self]; @@ -480,7 +480,7 @@ impl Crate { worklist.extend(krate.data(db).dependencies.iter().map(|dep| dep.crate_id)); } - deps.into_boxed_slice() + deps } /// Returns all transitive reverse dependencies of the given crate, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs index 868ae00329b3..d66a386bcdeb 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs @@ -505,13 +505,19 @@ pub(crate) fn find_matching_impl<'db>( } #[salsa::tracked(returns(ref))] -fn crates_containing_incoherent_inherent_impls(db: &dyn HirDatabase) -> Box<[Crate]> { +fn crates_containing_incoherent_inherent_impls(db: &dyn HirDatabase, krate: Crate) -> Box<[Crate]> { + let _p = tracing::info_span!("crates_containing_incoherent_inherent_impls").entered(); // We assume that only sysroot crates contain `#[rustc_has_incoherent_inherent_impls]` // impls, since this is an internal feature and only std uses it. - db.all_crates().iter().copied().filter(|krate| krate.data(db).origin.is_lang()).collect() + krate.transitive_deps(db).into_iter().filter(|krate| krate.data(db).origin.is_lang()).collect() } -pub fn incoherent_inherent_impls(db: &dyn HirDatabase, self_ty: SimplifiedType) -> &[ImplId] { +pub fn with_incoherent_inherent_impls( + db: &dyn HirDatabase, + krate: Crate, + self_ty: &SimplifiedType, + mut callback: impl FnMut(&[ImplId]), +) { let has_incoherent_impls = match self_ty.def() { Some(def_id) => match def_id.try_into() { Ok(def_id) => AttrFlags::query(db, def_id) @@ -520,26 +526,14 @@ pub fn incoherent_inherent_impls(db: &dyn HirDatabase, self_ty: SimplifiedType) }, _ => true, }; - return if !has_incoherent_impls { - &[] - } else { - incoherent_inherent_impls_query(db, (), self_ty) - }; - - #[salsa::tracked(returns(ref))] - fn incoherent_inherent_impls_query( - db: &dyn HirDatabase, - _force_query_input_to_be_interned: (), - self_ty: SimplifiedType, - ) -> Box<[ImplId]> { - let _p = tracing::info_span!("incoherent_inherent_impl_crates").entered(); - - let mut result = Vec::new(); - for &krate in crates_containing_incoherent_inherent_impls(db) { - let impls = InherentImpls::for_crate(db, krate); - result.extend_from_slice(impls.for_self_ty(&self_ty)); - } - result.into_boxed_slice() + if !has_incoherent_impls { + return; + } + let _p = tracing::info_span!("incoherent_inherent_impls").entered(); + let crates = crates_containing_incoherent_inherent_impls(db, krate); + for &krate in crates { + let impls = InherentImpls::for_crate(db, krate); + callback(impls.for_self_ty(self_ty)); } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs index 6af47ab68bfc..9ea0d500a5f4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs @@ -27,7 +27,7 @@ use crate::{ lower::GenericPredicates, method_resolution::{ CandidateId, CandidateSource, InherentImpls, MethodError, MethodResolutionContext, - incoherent_inherent_impls, simplified_type_module, + simplified_type_module, with_incoherent_inherent_impls, }, next_solver::{ Binder, Canonical, ClauseKind, DbInterner, FnSig, GenericArg, GenericArgs, Goal, ParamEnv, @@ -965,9 +965,11 @@ impl<'a, 'db, Choice: ProbeChoice<'db>> ProbeContext<'a, 'db, Choice> { else { panic!("unexpected incoherent type: {:?}", self_ty) }; - for &impl_def_id in incoherent_inherent_impls(self.db(), simp) { - self.assemble_inherent_impl_probe(impl_def_id, receiver_steps); - } + with_incoherent_inherent_impls(self.db(), self.ctx.resolver.krate(), &simp, |impls| { + for &impl_def_id in impls { + self.assemble_inherent_impl_probe(impl_def_id, receiver_steps); + } + }); } fn assemble_inherent_impl_candidates_for_type( diff --git a/src/tools/rust-analyzer/crates/hir/src/lib.rs b/src/tools/rust-analyzer/crates/hir/src/lib.rs index a50a736ccd0e..ae7e4aa6c8ac 100644 --- a/src/tools/rust-analyzer/crates/hir/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir/src/lib.rs @@ -4331,10 +4331,7 @@ impl Impl { /// blanket impls, and only does a shallow type constructor check. In fact, this should've probably been on `Adt` /// etc., and not on `Type`. If you would want to create a precise list of all impls applying to a type, /// you would need to include blanket impls, and try to prove to predicates for each candidate. - pub fn all_for_type<'db>( - db: &'db dyn HirDatabase, - Type { ty, env: _ }: Type<'db>, - ) -> Vec { + pub fn all_for_type<'db>(db: &'db dyn HirDatabase, Type { ty, env }: Type<'db>) -> Vec { let mut result = Vec::new(); let interner = DbInterner::new_no_crate(db); let Some(simplified_ty) = @@ -4344,7 +4341,12 @@ impl Impl { }; let mut extend_with_impls = |impls: &[ImplId]| result.extend(impls.iter().copied().map(Impl::from)); - extend_with_impls(method_resolution::incoherent_inherent_impls(db, simplified_ty)); + method_resolution::with_incoherent_inherent_impls( + db, + env.krate, + &simplified_ty, + &mut extend_with_impls, + ); if let Some(module) = method_resolution::simplified_type_module(db, &simplified_ty) { InherentImpls::for_each_crate_and_block( db, @@ -5322,7 +5324,12 @@ impl<'db> Type<'db> { return; }; - handle_impls(method_resolution::incoherent_inherent_impls(db, simplified_type)); + method_resolution::with_incoherent_inherent_impls( + db, + self.env.krate, + &simplified_type, + &mut handle_impls, + ); if let Some(module) = method_resolution::simplified_type_module(db, &simplified_type) { InherentImpls::for_each_crate_and_block( From a4214a410b10ad7133998f75b8ff66a80ba0b844 Mon Sep 17 00:00:00 2001 From: dfireBird Date: Mon, 15 Dec 2025 22:33:06 +0530 Subject: [PATCH 180/489] fix: use `cmark_with_options` to write shortcuts links to the output --- src/tools/rust-analyzer/crates/ide/src/doc_links.rs | 8 +++----- src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide/src/doc_links.rs b/src/tools/rust-analyzer/crates/ide/src/doc_links.rs index 0ed91cf7f588..d854c1c45044 100644 --- a/src/tools/rust-analyzer/crates/ide/src/doc_links.rs +++ b/src/tools/rust-analyzer/crates/ide/src/doc_links.rs @@ -8,7 +8,7 @@ mod intra_doc_links; use std::ops::Range; use pulldown_cmark::{BrokenLink, CowStr, Event, InlineStr, LinkType, Options, Parser, Tag}; -use pulldown_cmark_to_cmark::{Options as CMarkOptions, cmark_resume_with_options}; +use pulldown_cmark_to_cmark::{Options as CMarkOptions, cmark_with_options}; use stdx::format_to; use url::Url; @@ -89,10 +89,9 @@ pub(crate) fn rewrite_links( } }); let mut out = String::new(); - cmark_resume_with_options( + cmark_with_options( doc, &mut out, - None, CMarkOptions { code_block_token_count: 3, ..Default::default() }, ) .ok(); @@ -125,10 +124,9 @@ pub(crate) fn remove_links(markdown: &str) -> String { }); let mut out = String::new(); - cmark_resume_with_options( + cmark_with_options( doc, &mut out, - None, CMarkOptions { code_block_token_count: 3, ..Default::default() }, ) .ok(); diff --git a/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs b/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs index 34ffc11c4b5f..8594a0a22475 100644 --- a/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs +++ b/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs @@ -724,7 +724,10 @@ pub struct $0Foo; /// [`foo`]: Foo pub struct $0Foo; "#, - expect![["[`foo`]"]], + expect![[r#" + [`foo`] + + [`foo`]: https://docs.rs/foo/*/foo/struct.Foo.html"#]], ); } From ebfe9698f0cab44ca719a6e5850c9404d1ebcc4b Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 15 Dec 2025 18:42:56 +0100 Subject: [PATCH 181/489] Parent of struct constructor is the struct itself Also, the `Fn`/`AssocFn` cases were not tested anywhere, and according to the comments inside `TyCtxt::res_generic_def_id()` could have made the `TyCtxt::generics_of()` call also trigger an ICE. --- clippy_lints/src/casts/needless_type_cast.rs | 7 +------ tests/ui/needless_type_cast_unfixable.rs | 20 ++++++++++++++++++++ tests/ui/needless_type_cast_unfixable.stderr | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 tests/ui/needless_type_cast_unfixable.rs create mode 100644 tests/ui/needless_type_cast_unfixable.stderr diff --git a/clippy_lints/src/casts/needless_type_cast.rs b/clippy_lints/src/casts/needless_type_cast.rs index ca6aa0f87bbf..8ef9db1b510c 100644 --- a/clippy_lints/src/casts/needless_type_cast.rs +++ b/clippy_lints/src/casts/needless_type_cast.rs @@ -182,12 +182,7 @@ fn is_generic_res(cx: &LateContext<'_>, res: Res) -> bool { .iter() .any(|p| p.kind.is_ty_or_const()) }; - match res { - Res::Def(DefKind::Fn | DefKind::AssocFn, def_id) => has_type_params(def_id), - // Ctor → Variant → ADT: constructor's parent is variant, variant's parent is the ADT - Res::Def(DefKind::Ctor(..), def_id) => has_type_params(cx.tcx.parent(cx.tcx.parent(def_id))), - _ => false, - } + cx.tcx.res_generics_def_id(res).is_some_and(has_type_params) } fn is_cast_in_generic_context<'a>(cx: &LateContext<'a>, cast_expr: &Expr<'a>) -> bool { diff --git a/tests/ui/needless_type_cast_unfixable.rs b/tests/ui/needless_type_cast_unfixable.rs new file mode 100644 index 000000000000..bbea9bd24296 --- /dev/null +++ b/tests/ui/needless_type_cast_unfixable.rs @@ -0,0 +1,20 @@ +//@no-rustfix +#![warn(clippy::needless_type_cast)] + +struct Foo(*mut core::ffi::c_void); + +enum Bar { + Variant(*mut core::ffi::c_void), +} + +// Suggestions will not compile directly, as `123` is a literal which +// is not compatible with the suggested `*mut core::ffi::c_void` type +fn issue_16243() { + let underlying: isize = 123; + //~^ needless_type_cast + let handle: Foo = Foo(underlying as _); + + let underlying: isize = 123; + //~^ needless_type_cast + let handle: Bar = Bar::Variant(underlying as _); +} diff --git a/tests/ui/needless_type_cast_unfixable.stderr b/tests/ui/needless_type_cast_unfixable.stderr new file mode 100644 index 000000000000..b71f8a09c40f --- /dev/null +++ b/tests/ui/needless_type_cast_unfixable.stderr @@ -0,0 +1,17 @@ +error: this binding is defined as `isize` but is always cast to `*mut std::ffi::c_void` + --> tests/ui/needless_type_cast_unfixable.rs:13:21 + | +LL | let underlying: isize = 123; + | ^^^^^ help: consider defining it as: `*mut std::ffi::c_void` + | + = note: `-D clippy::needless-type-cast` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::needless_type_cast)]` + +error: this binding is defined as `isize` but is always cast to `*mut std::ffi::c_void` + --> tests/ui/needless_type_cast_unfixable.rs:17:21 + | +LL | let underlying: isize = 123; + | ^^^^^ help: consider defining it as: `*mut std::ffi::c_void` + +error: aborting due to 2 previous errors + From 344ddcf9f2bfba51c49b047280eee45293ec2b4f Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 15 Dec 2025 20:12:17 +0100 Subject: [PATCH 182/489] Move `needless_type_cast` lint to nursery The lint is new and already has several bugs filed against it, including an ICE. --- clippy_lints/src/casts/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 494d6180d3cb..7220a8a80066 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -836,7 +836,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.93.0"] pub NEEDLESS_TYPE_CAST, - pedantic, + nursery, "binding defined with one type but always cast to another" } From 3493f8c0b6393430b3437121a463a6c6d69f3f3d Mon Sep 17 00:00:00 2001 From: Almog Gavra Date: Mon, 15 Dec 2025 13:02:47 -0800 Subject: [PATCH 183/489] fix docustring on fetch_or --- library/core/src/sync/atomic.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 0601019abbd5..1eae06ebd33e 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -1151,8 +1151,8 @@ impl AtomicBool { /// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), true); /// assert_eq!(foo.load(Ordering::SeqCst), true); /// - /// let foo = AtomicBool::new(true); - /// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), true); + /// let foo = AtomicBool::new(false); + /// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), false); /// assert_eq!(foo.load(Ordering::SeqCst), true); /// /// let foo = AtomicBool::new(false); From d8a0f800f7cc6b977e2bde9b28ad97964ed4381b Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 15 Dec 2025 16:22:55 -0600 Subject: [PATCH 184/489] fixup! Implement va_arg for Hexagon Linux musl targets --- compiler/rustc_codegen_llvm/src/va_arg.rs | 55 ++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index aa5776b298d2..82cc45d161c4 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -780,7 +780,7 @@ fn x86_64_sysv64_va_arg_from_memory<'ll, 'tcx>( mem_addr } -fn emit_hexagon_va_arg<'ll, 'tcx>( +fn emit_hexagon_va_arg_musl<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, target_ty: Ty<'tcx>, @@ -865,6 +865,57 @@ fn emit_hexagon_va_arg<'ll, 'tcx>( bx.load(layout.llvm_type(bx), value_addr, layout.align.abi) } +fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, + list: OperandRef<'tcx, &'ll Value>, + target_ty: Ty<'tcx>, +) -> &'ll Value { + // Implementation of va_arg for Hexagon bare-metal (non-musl) targets. + // Based on LLVM's EmitVAArgForHexagon implementation. + // + // va_list is a simple pointer (char *) + let va_list_addr = list.immediate(); + let layout = bx.cx.layout_of(target_ty); + let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + + // Load current pointer from va_list + let current_ptr = bx.load(bx.type_ptr(), va_list_addr, ptr_align_abi); + + // Handle address alignment for types with alignment > 4 bytes + let ty_align = layout.align.abi; + let aligned_ptr = if ty_align.bytes() > 4 { + // Ensure alignment is a power of 2 + debug_assert!(ty_align.bytes().is_power_of_two(), "Alignment is not power of 2!"); + round_pointer_up_to_alignment(bx, current_ptr, ty_align, bx.type_ptr()) + } else { + current_ptr + }; + + // Calculate offset: round up type size to 4-byte boundary (minimum stack slot size) + let type_size = layout.size.bytes(); + let offset = ((type_size + 3) / 4) * 4; // align to 4 bytes + + // Update va_list to point to next argument + let next_ptr = bx.inbounds_ptradd(aligned_ptr, bx.const_usize(offset)); + bx.store(next_ptr, va_list_addr, ptr_align_abi); + + // Load and return the argument value + bx.load(layout.llvm_type(bx), aligned_ptr, layout.align.abi) +} + +fn emit_hexagon_va_arg<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, + list: OperandRef<'tcx, &'ll Value>, + target_ty: Ty<'tcx>, + is_musl: bool, +) -> &'ll Value { + if is_musl { + emit_hexagon_va_arg_musl(bx, list, target_ty) + } else { + emit_hexagon_va_arg_bare_metal(bx, list, target_ty) + } +} + fn emit_xtensa_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, @@ -1049,7 +1100,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), - Arch::Hexagon if target.env == Env::Musl => emit_hexagon_va_arg(bx, addr, target_ty), + Arch::Hexagon => emit_hexagon_va_arg(bx, addr, target_ty, target.env == Env::Musl), // For all other architecture/OS combinations fall back to using // the LLVM va_arg instruction. // https://llvm.org/docs/LangRef.html#va-arg-instruction From cf267e5b47648d3a1240d1fdc42fdaede9636c89 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Mon, 1 Dec 2025 22:49:41 +0000 Subject: [PATCH 185/489] fix: `use_self` FP on type in const generics --- clippy_lints/src/use_self.rs | 36 +++++++++++++++- tests/ui/use_self.fixed | 25 +++++++++++ tests/ui/use_self.rs | 25 +++++++++++ tests/ui/use_self.stderr | 84 ++++++++++++++++++------------------ 4 files changed, 127 insertions(+), 43 deletions(-) diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index eba60501ae21..38ce9dc3f916 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -10,13 +10,14 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty}; use rustc_hir::{ self as hir, AmbigArg, Expr, ExprKind, FnRetTy, FnSig, GenericArgsParentheses, GenericParamKind, HirId, Impl, - ImplItemImplKind, ImplItemKind, Item, ItemKind, Pat, PatExpr, PatExprKind, PatKind, Path, QPath, Ty, TyKind, + ImplItemImplKind, ImplItemKind, Item, ItemKind, Node, Pat, PatExpr, PatExprKind, PatKind, Path, QPath, Ty, TyKind, }; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty as MiddleTy; use rustc_session::impl_lint_pass; use rustc_span::Span; use std::iter; +use std::ops::ControlFlow; declare_clippy_lint! { /// ### What it does @@ -213,6 +214,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf { path.res, Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } | Res::Def(DefKind::TyParam, _) ) + && !ty_is_in_generic_args(cx, hir_ty) && !types_to_skip.contains(&hir_ty.hir_id) && let ty = ty_from_hir_ty(cx, hir_ty.as_unambig_ty()) && let impl_ty = cx.tcx.type_of(impl_id).instantiate_identity() @@ -312,6 +314,38 @@ fn lint_path_to_variant(cx: &LateContext<'_>, path: &Path<'_>) { } } +fn ty_is_in_generic_args<'tcx>(cx: &LateContext<'tcx>, hir_ty: &Ty<'tcx, AmbigArg>) -> bool { + cx.tcx.hir_parent_iter(hir_ty.hir_id).any(|(_, parent)| { + matches!(parent, Node::ImplItem(impl_item) if impl_item.generics.params.iter().any(|param| { + let GenericParamKind::Const { ty: const_ty, .. } = ¶m.kind else { + return false; + }; + ty_contains_ty(const_ty, hir_ty) + })) + }) +} + +fn ty_contains_ty<'tcx>(outer: &Ty<'tcx>, inner: &Ty<'tcx, AmbigArg>) -> bool { + struct ContainsVisitor<'tcx> { + inner: &'tcx Ty<'tcx, AmbigArg>, + } + + impl<'tcx> Visitor<'tcx> for ContainsVisitor<'tcx> { + type Result = ControlFlow<()>; + + fn visit_ty(&mut self, t: &'tcx Ty<'tcx, AmbigArg>) -> Self::Result { + if t.hir_id == self.inner.hir_id { + return ControlFlow::Break(()); + } + + walk_ty(self, t) + } + } + + let mut visitor = ContainsVisitor { inner }; + visitor.visit_ty_unambig(outer).is_break() +} + /// Checks whether types `a` and `b` have the same lifetime parameters. /// /// This function does not check that types `a` and `b` are the same types. diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed index 075e31d202b0..37559f9a2367 100644 --- a/tests/ui/use_self.fixed +++ b/tests/ui/use_self.fixed @@ -10,6 +10,9 @@ clippy::needless_lifetimes, clippy::missing_transmute_annotations )] +#![allow(incomplete_features)] +#![feature(adt_const_params)] +#![feature(unsized_const_params)] #[macro_use] extern crate proc_macro_derive; @@ -769,3 +772,25 @@ mod issue_13277 { type Item<'foo> = Option>; } } + +mod issue16164 { + trait Bits { + fn bit(self) -> bool; + } + + impl Bits for u8 { + fn bit(self) -> bool { + todo!() + } + } + + trait T { + fn f(self) -> bool; + } + + impl T for u8 { + fn f(self) -> bool { + todo!() + } + } +} diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 6fbba0bbc550..74abd2f61bf9 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -10,6 +10,9 @@ clippy::needless_lifetimes, clippy::missing_transmute_annotations )] +#![allow(incomplete_features)] +#![feature(adt_const_params)] +#![feature(unsized_const_params)] #[macro_use] extern crate proc_macro_derive; @@ -769,3 +772,25 @@ mod issue_13277 { type Item<'foo> = Option>; } } + +mod issue16164 { + trait Bits { + fn bit(self) -> bool; + } + + impl Bits for u8 { + fn bit(self) -> bool { + todo!() + } + } + + trait T { + fn f(self) -> bool; + } + + impl T for u8 { + fn f(self) -> bool { + todo!() + } + } +} diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 5f65c53ea25c..8ce341d22d4f 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> tests/ui/use_self.rs:23:21 + --> tests/ui/use_self.rs:26:21 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` @@ -8,247 +8,247 @@ LL | fn new() -> Foo { = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:25:13 + --> tests/ui/use_self.rs:28:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:28:22 + --> tests/ui/use_self.rs:31:22 | LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:30:13 + --> tests/ui/use_self.rs:33:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:36:25 + --> tests/ui/use_self.rs:39:25 | LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:38:13 + --> tests/ui/use_self.rs:41:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:80:28 + --> tests/ui/use_self.rs:83:28 | LL | fn clone(&self) -> Foo<'a> { | ^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:114:24 + --> tests/ui/use_self.rs:117:24 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:114:55 + --> tests/ui/use_self.rs:117:55 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:131:13 + --> tests/ui/use_self.rs:134:13 | LL | TS(0) | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:167:29 + --> tests/ui/use_self.rs:170:29 | LL | fn bar() -> Bar { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:169:21 + --> tests/ui/use_self.rs:172:21 | LL | Bar { foo: Foo {} } | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:181:21 + --> tests/ui/use_self.rs:184:21 | LL | fn baz() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:183:13 + --> tests/ui/use_self.rs:186:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:201:21 + --> tests/ui/use_self.rs:204:21 | LL | let _ = Enum::B(42); | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:203:21 + --> tests/ui/use_self.rs:206:21 | LL | let _ = Enum::C { field: true }; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:205:21 + --> tests/ui/use_self.rs:208:21 | LL | let _ = Enum::A; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:248:13 + --> tests/ui/use_self.rs:251:13 | LL | nested::A::fun_1(); | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:250:13 + --> tests/ui/use_self.rs:253:13 | LL | nested::A::A; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:253:13 + --> tests/ui/use_self.rs:256:13 | LL | nested::A {}; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:273:13 + --> tests/ui/use_self.rs:276:13 | LL | TestStruct::from_something() | ^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:288:25 + --> tests/ui/use_self.rs:291:25 | LL | async fn g() -> S { | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:290:13 + --> tests/ui/use_self.rs:293:13 | LL | S {} | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:295:16 + --> tests/ui/use_self.rs:298:16 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:295:22 + --> tests/ui/use_self.rs:298:22 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:320:29 + --> tests/ui/use_self.rs:323:29 | LL | fn foo(value: T) -> Foo { | ^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:322:13 + --> tests/ui/use_self.rs:325:13 | LL | Foo:: { value } | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:495:13 + --> tests/ui/use_self.rs:498:13 | LL | A::new::(submod::B {}) | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:571:17 + --> tests/ui/use_self.rs:574:17 | LL | Foo::Bar => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:573:17 + --> tests/ui/use_self.rs:576:17 | LL | Foo::Baz => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:580:20 + --> tests/ui/use_self.rs:583:20 | LL | if let Foo::Bar = self { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:605:17 + --> tests/ui/use_self.rs:608:17 | LL | Something::Num(n) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:607:17 + --> tests/ui/use_self.rs:610:17 | LL | Something::TupleNums(n, _m) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:609:17 + --> tests/ui/use_self.rs:612:17 | LL | Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:616:17 + --> tests/ui/use_self.rs:619:17 | LL | crate::issue8845::Something::Num(n) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:618:17 + --> tests/ui/use_self.rs:621:17 | LL | crate::issue8845::Something::TupleNums(n, _m) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:620:17 + --> tests/ui/use_self.rs:623:17 | LL | crate::issue8845::Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:637:17 + --> tests/ui/use_self.rs:640:17 | LL | let Foo(x) = self; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:643:17 + --> tests/ui/use_self.rs:646:17 | LL | let crate::issue8845::Foo(x) = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:651:17 + --> tests/ui/use_self.rs:654:17 | LL | let Bar { x, .. } = self; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:657:17 + --> tests/ui/use_self.rs:660:17 | LL | let crate::issue8845::Bar { x, .. } = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> tests/ui/use_self.rs:697:17 + --> tests/ui/use_self.rs:700:17 | LL | E::A => {}, | ^ help: use the applicable keyword: `Self` From 07f77185269c135b06baf47c17576ebe3b5be864 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Tue, 16 Dec 2025 10:17:43 +0800 Subject: [PATCH 186/489] Fix expected type no strip deref Example --- ```rust fn main() { let r = &2; let _: fn() -> i32 = || *$0; } ``` **Before this PR** `ty: &'_ u32, name: x` ```rust fn main() { let r = &2; let _: fn() -> i32 = || **r; } ``` **After this PR** `ty: &'_ &'_ u32, name: x` ```rust fn main() { let r = &2; let _: fn() -> i32 = || *r; } ``` --- .../ide-completion/src/context/analysis.rs | 18 +++++++++++++++++- .../crates/ide-completion/src/context/tests.rs | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs index add637a16fdf..b65c68a2401e 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs @@ -600,10 +600,26 @@ fn expected_type_and_name<'db>( Some(it) => it, None => return ty, }; - for _ in top_syn.ancestors().skip(1).map_while(ast::RefExpr::cast) { + let refs_level = top_syn + .ancestors() + .skip(1) + .map_while(Either::::cast) + .take_while(|it| match it { + Either::Left(_) => true, + Either::Right(prefix) => prefix.op_kind() == Some(ast::UnaryOp::Deref), + }) + .fold(0i32, |level, expr| match expr { + Either::Left(_) => level + 1, + Either::Right(_) => level - 1, + }); + for _ in 0..refs_level { cov_mark::hit!(expected_type_fn_param_ref); ty = ty.strip_reference(); } + for _ in refs_level..0 { + cov_mark::hit!(expected_type_fn_param_deref); + ty = ty.add_reference(hir::Mutability::Shared); + } ty } _ => ty, diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs index 41f0db3c5282..b929d36ce687 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs @@ -146,6 +146,18 @@ fn bar(x: &u32) {} ); } +#[test] +fn expected_type_fn_param_deref() { + cov_mark::check!(expected_type_fn_param_deref); + check_expected_type_and_name( + r#" +fn foo() { bar(*$0); } +fn bar(x: &u32) {} +"#, + expect!["ty: &'_ &'_ u32, name: x"], + ); +} + #[test] fn expected_type_struct_field_without_leading_char() { cov_mark::check!(expected_type_struct_field_without_leading_char); From ce4929b173957fc2d9dc9b67179d6ff5586c5cf7 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Tue, 16 Dec 2025 10:46:45 +0800 Subject: [PATCH 187/489] Fix add reference for `&mut ty` -> `&ty` Example --- ```rust fn foo(r: &mut i32) -> &i32 { $0 } ``` **Before this PR** `lc &r [type+local]` This is a compilation error ```rust fn foo(r: &mut i32) -> &i32 { &r } ``` **After this PR** `lc r &mut i32 [type+local]` ```rust fn foo(r: &mut i32) -> &i32 { r } ``` --- .../crates/ide-completion/src/render.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/render.rs b/src/tools/rust-analyzer/crates/ide-completion/src/render.rs index bc5589a64550..f2312c64945e 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/render.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/render.rs @@ -604,6 +604,14 @@ fn compute_type_match( return None; } + // &mut ty -> &ty + if completion_ty.is_mutable_reference() + && let Some(expected_type) = expected_type.remove_ref() + && let Some(completion_ty) = completion_ty.remove_ref() + { + return match_types(ctx, &expected_type, &completion_ty); + } + match_types(ctx, expected_type, completion_ty) } @@ -622,6 +630,7 @@ fn compute_ref_match( return None; } if let Some(expected_without_ref) = &expected_without_ref + && completion_without_ref.is_none() && completion_ty.autoderef(ctx.db).any(|ty| ty == *expected_without_ref) { cov_mark::hit!(suggest_ref); @@ -2049,6 +2058,17 @@ fn go(world: &WorldSnapshot) { go(w$0) } ); } + #[test] + fn prioritize_mutable_ref_as_immutable_ref_match() { + check_relevance( + r#"fn foo(r: &mut i32) -> &i32 { $0 }"#, + expect![[r#" + lc r &mut i32 [type+local] + fn foo(…) fn(&mut i32) -> &i32 [type] + "#]], + ); + } + #[test] fn too_many_arguments() { cov_mark::check!(too_many_arguments); From 38ef5c1cdbd7861dbe26c256f232a1722967a065 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Tue, 16 Dec 2025 06:04:11 +0200 Subject: [PATCH 188/489] improve cg_gcc.md a little --- .../rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md b/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md index 7a1c5b9a98c0..9ed91550b262 100644 --- a/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md +++ b/src/doc/rustc-dev-guide/src/tests/codegen-backend-tests/cg_gcc.md @@ -79,10 +79,10 @@ if there are no local changes to the GCC sources and the given host target is av ## Providing your own GCC -There are cases where you will want to provide yourself the `libgccjit.so` file. +There are cases where you will want to provide your own `libgccjit.so` file. One such case is when you want to cross-compile `rustc` to another target since GCC is not a multi-target compiler. To support this use case, there is the bootstrap option `gcc.libgccjit-libs-dir`. -This option override `gcc.download-ci-gcc`, meaning `libgccjit.so` won't be downloaded or built locally by bootstrap. +This option overrides `gcc.download-ci-gcc`, meaning `libgccjit.so` won't be downloaded or built locally by bootstrap. The directory structure of this directory is `//libgccjit.so`, for instance: ``` From 4a00c4ff3aec7bdfe96caa85c9c3eeceee0378b5 Mon Sep 17 00:00:00 2001 From: Jesung Yang Date: Tue, 16 Dec 2025 04:50:26 +0000 Subject: [PATCH 189/489] internal: add special `ErasedFileAstId` used for bypassing downmapping Introduce `NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER`, which prevents `Span`s from being mapped down into macro expansions. This is a preparatory step for adding a new field to the `rust-project.json` format that can inject crate-level attributes. `Span`s for those attributes will be marked with `NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER`, indicating that they should not be mapped down into macro expansions. --- .../hir-def/src/macro_expansion_tests/mod.rs | 116 +++++++++++++----- .../crates/hir-expand/src/lib.rs | 12 +- .../rust-analyzer/crates/span/src/ast_id.rs | 9 ++ .../rust-analyzer/crates/span/src/lib.rs | 2 +- 4 files changed, 103 insertions(+), 36 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mod.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mod.rs index 78af976e1b13..59bd9474a959 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mod.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mod.rs @@ -19,7 +19,7 @@ use std::{any::TypeId, iter, ops::Range, sync}; use base_db::RootQueryDb; use expect_test::Expect; use hir_expand::{ - AstId, InFile, MacroCallId, MacroCallKind, MacroKind, + AstId, ExpansionInfo, InFile, MacroCallId, MacroCallKind, MacroKind, builtin::quote::quote, db::ExpandDatabase, proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind}, @@ -27,7 +27,10 @@ use hir_expand::{ }; use intern::{Symbol, sym}; use itertools::Itertools; -use span::{Edition, ROOT_ERASED_FILE_AST_ID, Span, SpanAnchor, SyntaxContext}; +use span::{ + Edition, NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER, ROOT_ERASED_FILE_AST_ID, Span, SpanAnchor, + SyntaxContext, +}; use stdx::{format_to, format_to_acc}; use syntax::{ AstNode, AstPtr, @@ -97,37 +100,6 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream }, )]; - fn resolve( - db: &dyn DefDatabase, - def_map: &DefMap, - ast_id: AstId, - ast_ptr: InFile>, - ) -> Option { - def_map.modules().find_map(|module| { - for decl in - module.1.scope.declarations().chain(module.1.scope.unnamed_consts().map(Into::into)) - { - let body = match decl { - ModuleDefId::FunctionId(it) => it.into(), - ModuleDefId::ConstId(it) => it.into(), - ModuleDefId::StaticId(it) => it.into(), - _ => continue, - }; - - let (body, sm) = db.body_with_source_map(body); - if let Some(it) = - body.blocks(db).find_map(|block| resolve(db, block.1, ast_id, ast_ptr)) - { - return Some(it); - } - if let Some((_, res)) = sm.macro_calls().find(|it| it.0 == ast_ptr) { - return Some(res); - } - } - module.1.scope.macro_invoc(ast_id) - }) - } - let db = TestDB::with_files_extra_proc_macros(ra_fixture, extra_proc_macros); let krate = db.fetch_test_crate(); let def_map = crate_def_map(&db, krate); @@ -144,7 +116,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream let ast_id = db.ast_id_map(source.file_id).ast_id(¯o_call_node); let ast_id = InFile::new(source.file_id, ast_id); let ptr = InFile::new(source.file_id, AstPtr::new(¯o_call_node)); - let macro_call_id = resolve(&db, def_map, ast_id, ptr) + let macro_call_id = resolve_macro_call_id(&db, def_map, ast_id, ptr) .unwrap_or_else(|| panic!("unable to find semantic macro call {macro_call_node}")); let expansion_result = db.parse_macro_expansion(macro_call_id); expansions.push((macro_call_node.clone(), expansion_result)); @@ -278,6 +250,38 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream expect.assert_eq(&expanded_text); } +fn resolve_macro_call_id( + db: &dyn DefDatabase, + def_map: &DefMap, + ast_id: AstId, + ast_ptr: InFile>, +) -> Option { + def_map.modules().find_map(|module| { + for decl in + module.1.scope.declarations().chain(module.1.scope.unnamed_consts().map(Into::into)) + { + let body = match decl { + ModuleDefId::FunctionId(it) => it.into(), + ModuleDefId::ConstId(it) => it.into(), + ModuleDefId::StaticId(it) => it.into(), + _ => continue, + }; + + let (body, sm) = db.body_with_source_map(body); + if let Some(it) = body + .blocks(db) + .find_map(|block| resolve_macro_call_id(db, block.1, ast_id, ast_ptr)) + { + return Some(it); + } + if let Some((_, res)) = sm.macro_calls().find(|it| it.0 == ast_ptr) { + return Some(res); + } + } + module.1.scope.macro_invoc(ast_id) + }) +} + fn reindent(indent: IndentLevel, pp: String) -> String { if !pp.contains('\n') { return pp; @@ -430,3 +434,47 @@ fn regression_20171() { Edition::CURRENT }); } + +#[test] +fn no_downmap() { + let fixture = r#" +macro_rules! m { + ($func_name:ident) => { + fn $func_name() { todo!() } + }; +} +m!(f); +m!(g); + "#; + + let (db, file_id) = TestDB::with_single_file(fixture); + let krate = file_id.krate(&db); + let def_map = crate_def_map(&db, krate); + let source = def_map[def_map.root].definition_source(&db); + let source_file = match source.value { + ModuleSource::SourceFile(it) => it, + ModuleSource::Module(_) | ModuleSource::BlockExpr(_) => panic!(), + }; + let no_downmap_spans: Vec<_> = source_file + .syntax() + .descendants() + .map(|node| { + let mut span = db.real_span_map(file_id).span_for_range(node.text_range()); + span.anchor.ast_id = NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER; + span + }) + .collect(); + + for macro_call_node in source_file.syntax().descendants().filter_map(ast::MacroCall::cast) { + let ast_id = db.ast_id_map(source.file_id).ast_id(¯o_call_node); + let ast_id = InFile::new(source.file_id, ast_id); + let ptr = InFile::new(source.file_id, AstPtr::new(¯o_call_node)); + let macro_call_id = resolve_macro_call_id(&db, def_map, ast_id, ptr) + .unwrap_or_else(|| panic!("unable to find semantic macro call {macro_call_node}")); + let expansion_info = ExpansionInfo::new(&db, macro_call_id); + for &span in no_downmap_spans.iter() { + assert!(expansion_info.map_range_down(span).is_none()); + assert!(expansion_info.map_range_down_exact(span).is_none()); + } + } +} diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs b/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs index c92e41f5070c..047996c97853 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs @@ -37,7 +37,9 @@ use std::{hash::Hash, ops}; use base_db::Crate; use either::Either; -use span::{Edition, ErasedFileAstId, FileAstId, Span, SyntaxContext}; +use span::{ + Edition, ErasedFileAstId, FileAstId, NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER, Span, SyntaxContext, +}; use syntax::{ SyntaxNode, SyntaxToken, TextRange, TextSize, ast::{self, AstNode}, @@ -854,6 +856,10 @@ impl ExpansionInfo { &self, span: Span, ) -> Option + '_>> { + if span.anchor.ast_id == NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER { + return None; + } + let tokens = self.exp_map.ranges_with_span_exact(span).flat_map(move |(range, ctx)| { self.expanded.value.covering_element(range).into_token().zip(Some(ctx)) }); @@ -869,6 +875,10 @@ impl ExpansionInfo { &self, span: Span, ) -> Option + '_>> { + if span.anchor.ast_id == NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER { + return None; + } + let tokens = self.exp_map.ranges_with_span(span).flat_map(move |(range, ctx)| { self.expanded.value.covering_element(range).into_token().zip(Some(ctx)) }); diff --git a/src/tools/rust-analyzer/crates/span/src/ast_id.rs b/src/tools/rust-analyzer/crates/span/src/ast_id.rs index bd49e08b10fa..a25189261311 100644 --- a/src/tools/rust-analyzer/crates/span/src/ast_id.rs +++ b/src/tools/rust-analyzer/crates/span/src/ast_id.rs @@ -48,6 +48,11 @@ pub const ROOT_ERASED_FILE_AST_ID: ErasedFileAstId = pub const FIXUP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId = ErasedFileAstId(pack_hash_index_and_kind(0, 0, ErasedFileAstIdKind::Fixup as u32)); +/// [`ErasedFileAstId`] used as the span for syntax nodes that should not be mapped down to +/// macro expansion. Any `Span` containing this file id is to be considered fake. +pub const NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId = + ErasedFileAstId(pack_hash_index_and_kind(0, 0, ErasedFileAstIdKind::NoDownmap as u32)); + /// This is a type erased FileAstId. #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct ErasedFileAstId(u32); @@ -95,6 +100,7 @@ impl fmt::Debug for ErasedFileAstId { BlockExpr, AsmExpr, Fixup, + NoDownmap, ); if f.alternate() { write!(f, "{kind}[{:04X}, {}]", self.hash_value(), self.index()) @@ -150,6 +156,9 @@ enum ErasedFileAstIdKind { // because incrementality is not a problem, they will always be the only item in the macro file, // and memory usage also not because they're rare. AsmExpr, + /// Represents a fake [`ErasedFileAstId`] that should not be mapped down to macro expansion + /// result. + NoDownmap, /// Keep this last. Root, } diff --git a/src/tools/rust-analyzer/crates/span/src/lib.rs b/src/tools/rust-analyzer/crates/span/src/lib.rs index c44b0198b72c..1a8aaeb71517 100644 --- a/src/tools/rust-analyzer/crates/span/src/lib.rs +++ b/src/tools/rust-analyzer/crates/span/src/lib.rs @@ -14,7 +14,7 @@ mod map; pub use self::{ ast_id::{ AstIdMap, AstIdNode, ErasedFileAstId, FIXUP_ERASED_FILE_AST_ID_MARKER, FileAstId, - ROOT_ERASED_FILE_AST_ID, + NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER, ROOT_ERASED_FILE_AST_ID, }, hygiene::{SyntaxContext, Transparency}, map::{RealSpanMap, SpanMap}, From 8f105cb330791dfdd9982989a8bc7a1fca437a77 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Tue, 16 Dec 2025 07:50:42 +0200 Subject: [PATCH 190/489] Fix an assert that didn't check what it should --- src/tools/rust-analyzer/crates/span/src/ast_id.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/span/src/ast_id.rs b/src/tools/rust-analyzer/crates/span/src/ast_id.rs index bd49e08b10fa..2e93925bd566 100644 --- a/src/tools/rust-analyzer/crates/span/src/ast_id.rs +++ b/src/tools/rust-analyzer/crates/span/src/ast_id.rs @@ -158,7 +158,7 @@ enum ErasedFileAstIdKind { const HASH_BITS: u32 = 16; const INDEX_BITS: u32 = 11; const KIND_BITS: u32 = 5; -const _: () = assert!(ErasedFileAstIdKind::Fixup as u32 <= ((1 << KIND_BITS) - 1)); +const _: () = assert!(ErasedFileAstIdKind::Root as u32 <= ((1 << KIND_BITS) - 1)); const _: () = assert!(HASH_BITS + INDEX_BITS + KIND_BITS == u32::BITS); #[inline] From 8d37589f37cf435d66d4fa2b6aed3ac006063a9e Mon Sep 17 00:00:00 2001 From: Laine Taffin Altman Date: Mon, 15 Dec 2025 22:08:00 -0800 Subject: [PATCH 191/489] std_detect: AArch64 Darwin: expose SME F16F16 and B16B16 features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This synchronizes the list with the current state of `sysctl` on macOS “Tahoe” 26.2. r? @Amanieu --- library/std_detect/src/detect/os/darwin/aarch64.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/std_detect/src/detect/os/darwin/aarch64.rs b/library/std_detect/src/detect/os/darwin/aarch64.rs index 8c9fd9647b8a..a23d65a23d81 100644 --- a/library/std_detect/src/detect/os/darwin/aarch64.rs +++ b/library/std_detect/src/detect/os/darwin/aarch64.rs @@ -76,6 +76,8 @@ pub(crate) fn detect_features() -> cache::Initializer { let sme = _sysctlbyname(c"hw.optional.arm.FEAT_SME"); let sme2 = _sysctlbyname(c"hw.optional.arm.FEAT_SME2"); let sme2p1 = _sysctlbyname(c"hw.optional.arm.FEAT_SME2p1"); + let sme_b16b16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_B16B16"); + let sme_f16f16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F16F16"); let sme_f64f64 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F64F64"); let sme_i16i64 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_I16I64"); let ssbs = _sysctlbyname(c"hw.optional.arm.FEAT_SSBS"); @@ -153,6 +155,8 @@ pub(crate) fn detect_features() -> cache::Initializer { enable_feature(Feature::sme, sme); enable_feature(Feature::sme2, sme2); enable_feature(Feature::sme2p1, sme2p1); + enable_feature(Feature::sme_b16b16, sme_b16b16); + enable_feature(Feature::sme_f16f16, sme_f16f16); enable_feature(Feature::sme_f64f64, sme_f64f64); enable_feature(Feature::sme_i16i64, sme_i16i64); enable_feature(Feature::ssbs, ssbs); From fc16679419b9f17cbfde666aa26fa728781fb435 Mon Sep 17 00:00:00 2001 From: usamoi Date: Sun, 14 Dec 2025 17:59:55 +0800 Subject: [PATCH 192/489] add avx512 pshufb --- src/tools/miri/src/shims/x86/avx2.rs | 25 +---------- src/tools/miri/src/shims/x86/avx512.rs | 9 +++- src/tools/miri/src/shims/x86/mod.rs | 45 +++++++++++++++++++ src/tools/miri/src/shims/x86/ssse3.rs | 24 +--------- .../pass/shims/x86/intrinsics-x86-avx512.rs | 24 ++++++++++ 5 files changed, 81 insertions(+), 46 deletions(-) diff --git a/src/tools/miri/src/shims/x86/avx2.rs b/src/tools/miri/src/shims/x86/avx2.rs index 8fe225c494d5..b089a0249bd7 100644 --- a/src/tools/miri/src/shims/x86/avx2.rs +++ b/src/tools/miri/src/shims/x86/avx2.rs @@ -6,7 +6,7 @@ use rustc_target::callconv::FnAbi; use super::{ ShiftOp, horizontal_bin_op, mpsadbw, packssdw, packsswb, packusdw, packuswb, permute, pmaddbw, - pmulhrsw, psadbw, psign, shift_simd_by_scalar, + pmulhrsw, psadbw, pshufb, psign, shift_simd_by_scalar, }; use crate::*; @@ -189,28 +189,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let [left, right] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; - let (left, left_len) = this.project_to_simd(left)?; - let (right, right_len) = this.project_to_simd(right)?; - let (dest, dest_len) = this.project_to_simd(dest)?; - - assert_eq!(dest_len, left_len); - assert_eq!(dest_len, right_len); - - for i in 0..dest_len { - let right = this.read_scalar(&this.project_index(&right, i)?)?.to_u8()?; - let dest = this.project_index(&dest, i)?; - - let res = if right & 0x80 == 0 { - // Shuffle each 128-bit (16-byte) block independently. - let j = u64::from(right % 16).strict_add(i & !15); - this.read_scalar(&this.project_index(&left, j)?)? - } else { - // If the highest bit in `right` is 1, write zero. - Scalar::from_u8(0) - }; - - this.write_scalar(res, &dest)?; - } + pshufb(this, left, right, dest)?; } // Used to implement the _mm256_sign_epi{8,16,32} functions. // Negates elements from `left` when the corresponding element in diff --git a/src/tools/miri/src/shims/x86/avx512.rs b/src/tools/miri/src/shims/x86/avx512.rs index 9b43aad96e5c..a886f5622ced 100644 --- a/src/tools/miri/src/shims/x86/avx512.rs +++ b/src/tools/miri/src/shims/x86/avx512.rs @@ -3,7 +3,7 @@ use rustc_middle::ty::Ty; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; -use super::{permute, pmaddbw, psadbw}; +use super::{permute, pmaddbw, psadbw, pshufb}; use crate::*; impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} @@ -102,6 +102,13 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { permute(this, left, right, dest)?; } + // Used to implement the _mm512_shuffle_epi8 intrinsic. + "pshuf.b.512" => { + let [left, right] = + this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; + + pshufb(this, left, right, dest)?; + } _ => return interp_ok(EmulateItemResult::NotSupported), } interp_ok(EmulateItemResult::NeedsReturn) diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs index 40dcd7ac1c2d..a5164cc87ab4 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -1155,6 +1155,51 @@ fn pclmulqdq<'tcx>( interp_ok(()) } +/// Shuffles bytes from `left` using `right` as pattern. Each 16-byte block is shuffled independently. +/// +/// `left` and `right` are both vectors of type `len` x i8. +/// +/// If the highest bit of a byte in `right` is not set, the corresponding byte in `dest` is taken +/// from the current 16-byte block of `left` at the position indicated by the lowest 4 bits of this +/// byte in `right`. If the highest bit of a byte in `right` is set, the corresponding byte in +/// `dest` is set to `0`. +/// +/// +/// +/// +fn pshufb<'tcx>( + ecx: &mut crate::MiriInterpCx<'tcx>, + left: &OpTy<'tcx>, + right: &OpTy<'tcx>, + dest: &MPlaceTy<'tcx>, +) -> InterpResult<'tcx, ()> { + let (left, left_len) = ecx.project_to_simd(left)?; + let (right, right_len) = ecx.project_to_simd(right)?; + let (dest, dest_len) = ecx.project_to_simd(dest)?; + + assert_eq!(dest_len, left_len); + assert_eq!(dest_len, right_len); + + for i in 0..dest_len { + let right = ecx.read_scalar(&ecx.project_index(&right, i)?)?.to_u8()?; + let dest = ecx.project_index(&dest, i)?; + + let res = if right & 0x80 == 0 { + // Shuffle each 128-bit (16-byte) block independently. + let block_offset = i & !15; // round down to previous multiple of 16 + let j = block_offset.strict_add((right % 16).into()); + ecx.read_scalar(&ecx.project_index(&left, j)?)? + } else { + // If the highest bit in `right` is 1, write zero. + Scalar::from_u8(0) + }; + + ecx.write_scalar(res, &dest)?; + } + + interp_ok(()) +} + /// Packs two N-bit integer vectors to a single N/2-bit integers. /// /// The conversion from N-bit to N/2-bit should be provided by `f`. diff --git a/src/tools/miri/src/shims/x86/ssse3.rs b/src/tools/miri/src/shims/x86/ssse3.rs index 56fc63ce1473..b01a8795b4d1 100644 --- a/src/tools/miri/src/shims/x86/ssse3.rs +++ b/src/tools/miri/src/shims/x86/ssse3.rs @@ -4,7 +4,7 @@ use rustc_middle::ty::Ty; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; -use super::{horizontal_bin_op, pmaddbw, pmulhrsw, psign}; +use super::{horizontal_bin_op, pmaddbw, pmulhrsw, pshufb, psign}; use crate::*; impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} @@ -29,27 +29,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let [left, right] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; - let (left, left_len) = this.project_to_simd(left)?; - let (right, right_len) = this.project_to_simd(right)?; - let (dest, dest_len) = this.project_to_simd(dest)?; - - assert_eq!(dest_len, left_len); - assert_eq!(dest_len, right_len); - - for i in 0..dest_len { - let right = this.read_scalar(&this.project_index(&right, i)?)?.to_u8()?; - let dest = this.project_index(&dest, i)?; - - let res = if right & 0x80 == 0 { - let j = right % 16; // index wraps around - this.read_scalar(&this.project_index(&left, j.into())?)? - } else { - // If the highest bit in `right` is 1, write zero. - Scalar::from_u8(0) - }; - - this.write_scalar(res, &dest)?; - } + pshufb(this, left, right, dest)?; } // Used to implement the _mm_h{adds,subs}_epi16 functions. // Horizontally add / subtract with saturation adjacent 16-bit diff --git a/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-avx512.rs b/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-avx512.rs index e778567b483f..f95429d59ebe 100644 --- a/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-avx512.rs +++ b/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-avx512.rs @@ -143,6 +143,30 @@ unsafe fn test_avx512() { assert_eq_m512i(r, e); } test_mm512_permutexvar_epi32(); + + #[target_feature(enable = "avx512bw")] + unsafe fn test_mm512_shuffle_epi8() { + #[rustfmt::skip] + let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63); + #[rustfmt::skip] + let b = _mm512_set_epi8(-1, 127, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + -1, 127, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + -1, 127, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + -1, 127, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + let r = _mm512_shuffle_epi8(a, b); + // `_mm512_set_epi8` sets the bytes in inverse order (?!?), so the indices in `b` seem to + // index from the *back* of the corresponding 16-byte block in `a`. + #[rustfmt::skip] + let e = _mm512_set_epi8(0, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 0, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 0, 32, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 0, 48, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62); + assert_eq_m512i(r, e); + } + test_mm512_shuffle_epi8(); } // Some of the constants in the tests below are just bit patterns. They should not From 11bc2e0907f3bec4a1a955c76bceaa799d8489f4 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 10 Jul 2025 10:17:44 +0000 Subject: [PATCH 193/489] codegen: implement `repr(scalable)` Introduces `BackendRepr::ScalableVector` corresponding to scalable vector types annotated with `repr(scalable)` which lowers to a scalable vector type in LLVM. Co-authored-by: Jamie Cunliffe --- src/builder.rs | 4 ++++ src/intrinsic/mod.rs | 2 +- src/type_of.rs | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index df1e64c75b96..79228c20d292 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -943,6 +943,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { .get_address(self.location) } + fn scalable_alloca(&mut self, _elt: u64, _align: Align, _element_ty: Ty<'_>) -> RValue<'gcc> { + todo!() + } + fn load(&mut self, pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> { let block = self.llbb(); let function = block.get_function(); diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index a38dcf8e4c93..d2714ba7914f 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -504,7 +504,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc let layout = self.layout_of(tp_ty).layout; let _use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - SimdVector { .. } => false, + SimdVector { .. } | ScalableVector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/src/type_of.rs b/src/type_of.rs index 93202483eed8..68fca5a17ad3 100644 --- a/src/type_of.rs +++ b/src/type_of.rs @@ -85,6 +85,7 @@ fn uncached_gcc_type<'gcc, 'tcx>( ); } BackendRepr::Memory { .. } => {} + BackendRepr::ScalableVector { .. } => todo!(), } let name = match *layout.ty.kind() { @@ -179,6 +180,8 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { fn is_gcc_immediate(&self) -> bool { match self.backend_repr { BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true, + // FIXME(rustc_scalable_vector): Not yet implemented in rustc_codegen_gcc. + BackendRepr::ScalableVector { .. } => todo!(), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } @@ -188,6 +191,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { BackendRepr::ScalarPair(..) => true, BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } + | BackendRepr::ScalableVector { .. } | BackendRepr::Memory { .. } => false, } } From f33abb17db4045a629e0ef4e9755dc145e3fdaec Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 16 Dec 2025 12:32:00 +0100 Subject: [PATCH 194/489] Update to LLVM 21.1.8 --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 89bab96463d4..85a90d119deb 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 89bab96463d42e979145166e0f8e6b8157fedc12 +Subproject commit 85a90d119deb25b518867cd37d62c7b93b575a6f From 7f6f52276159ed9d175f98c950adfa2306d46b44 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 15 Dec 2025 18:26:44 +1100 Subject: [PATCH 195/489] Rename `TestCase` to `TestableCase` --- .../src/builder/matches/buckets.rs | 35 +++++++++---------- .../src/builder/matches/match_pair.rs | 26 ++++++++------ .../src/builder/matches/mod.rs | 25 +++++++------ .../src/builder/matches/test.rs | 26 ++++++++------ .../src/builder/matches/util.rs | 6 ++-- 5 files changed, 64 insertions(+), 54 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/buckets.rs b/compiler/rustc_mir_build/src/builder/matches/buckets.rs index f53e73d406c3..6c5f0ed28a82 100644 --- a/compiler/rustc_mir_build/src/builder/matches/buckets.rs +++ b/compiler/rustc_mir_build/src/builder/matches/buckets.rs @@ -7,7 +7,7 @@ use tracing::debug; use crate::builder::Builder; use crate::builder::matches::test::is_switch_ty; -use crate::builder::matches::{Candidate, Test, TestBranch, TestCase, TestKind}; +use crate::builder::matches::{Candidate, Test, TestBranch, TestKind, TestableCase}; /// Output of [`Builder::partition_candidates_into_buckets`]. pub(crate) struct PartitionedCandidates<'tcx, 'b, 'c> { @@ -140,12 +140,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // branch, so it can be removed. If false, the match pair is _compatible_ // with its test branch, but still needs a more specific test. let fully_matched; - let ret = match (&test.kind, &match_pair.test_case) { + let ret = match (&test.kind, &match_pair.testable_case) { // If we are performing a variant switch, then this // informs variant patterns, but nothing else. ( &TestKind::Switch { adt_def: tested_adt_def }, - &TestCase::Variant { adt_def, variant_index }, + &TestableCase::Variant { adt_def, variant_index }, ) => { assert_eq!(adt_def, tested_adt_def); fully_matched = true; @@ -159,7 +159,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // things out here, in some cases. // // FIXME(Zalathar): Is the `is_switch_ty` test unnecessary? - (TestKind::SwitchInt, &TestCase::Constant { value }) + (TestKind::SwitchInt, &TestableCase::Constant { value }) if is_switch_ty(match_pair.pattern_ty) => { // An important invariant of candidate bucketing is that a candidate @@ -167,16 +167,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // a new value might invalidate that property for range patterns that // have already been partitioned into the failure arm, so we must take care // not to add such values here. - let is_covering_range = |test_case: &TestCase<'tcx>| { - test_case.as_range().is_some_and(|range| { + let is_covering_range = |testable_case: &TestableCase<'tcx>| { + testable_case.as_range().is_some_and(|range| { matches!(range.contains(value, self.tcx), None | Some(true)) }) }; let is_conflicting_candidate = |candidate: &&mut Candidate<'tcx>| { - candidate - .match_pairs - .iter() - .any(|mp| mp.place == Some(test_place) && is_covering_range(&mp.test_case)) + candidate.match_pairs.iter().any(|mp| { + mp.place == Some(test_place) && is_covering_range(&mp.testable_case) + }) }; if prior_candidates .get(&TestBranch::Failure) @@ -189,7 +188,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Some(TestBranch::Constant(value)) } } - (TestKind::SwitchInt, TestCase::Range(range)) => { + (TestKind::SwitchInt, TestableCase::Range(range)) => { // When performing a `SwitchInt` test, a range pattern can be // sorted into the failure arm if it doesn't contain _any_ of // the values being tested. (This restricts what values can be @@ -207,7 +206,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }) } - (TestKind::If, TestCase::Constant { value }) => { + (TestKind::If, TestableCase::Constant { value }) => { fully_matched = true; let value = value.try_to_bool().unwrap_or_else(|| { span_bug!(test.span, "expected boolean value but got {value:?}") @@ -217,7 +216,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ( &TestKind::Len { len: test_len, op: BinOp::Eq }, - &TestCase::Slice { len, variable_length }, + &TestableCase::Slice { len, variable_length }, ) => { match (test_len.cmp(&(len as u64)), variable_length) { (Ordering::Equal, false) => { @@ -249,7 +248,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } ( &TestKind::Len { len: test_len, op: BinOp::Ge }, - &TestCase::Slice { len, variable_length }, + &TestableCase::Slice { len, variable_length }, ) => { // the test is `$actual_len >= test_len` match (test_len.cmp(&(len as u64)), variable_length) { @@ -281,7 +280,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - (TestKind::Range(test), TestCase::Range(pat)) => { + (TestKind::Range(test), TestableCase::Range(pat)) => { if test == pat { fully_matched = true; Some(TestBranch::Success) @@ -292,7 +291,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if !test.overlaps(pat, self.tcx)? { Some(TestBranch::Failure) } else { None } } } - (TestKind::Range(range), &TestCase::Constant { value }) => { + (TestKind::Range(range), &TestableCase::Constant { value }) => { fully_matched = false; if !range.contains(value, self.tcx)? { // `value` is not contained in the testing range, @@ -303,7 +302,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - (TestKind::Eq { value: test_val, .. }, TestCase::Constant { value: case_val }) => { + (TestKind::Eq { value: test_val, .. }, TestableCase::Constant { value: case_val }) => { if test_val == case_val { fully_matched = true; Some(TestBranch::Success) @@ -313,7 +312,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - (TestKind::Deref { temp: test_temp, .. }, TestCase::Deref { temp, .. }) + (TestKind::Deref { temp: test_temp, .. }, TestableCase::Deref { temp, .. }) if test_temp == temp => { fully_matched = true; diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index a0d54354a9c6..dc1545c9278a 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -8,7 +8,7 @@ use rustc_middle::ty::{self, Pinnedness, Ty, TypeVisitableExt}; use crate::builder::Builder; use crate::builder::expr::as_place::{PlaceBase, PlaceBuilder}; -use crate::builder::matches::{FlatPat, MatchPairTree, PatternExtraData, TestCase}; +use crate::builder::matches::{FlatPat, MatchPairTree, PatternExtraData, TestableCase}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds and pushes [`MatchPairTree`] subtrees, one for each pattern in @@ -132,7 +132,7 @@ impl<'tcx> MatchPairTree<'tcx> { let place = place_builder.try_to_place(cx); let mut subpairs = Vec::new(); - let test_case = match pattern.kind { + let testable_case = match pattern.kind { PatKind::Missing | PatKind::Wild | PatKind::Error(_) => None, PatKind::Or { ref pats } => { @@ -146,18 +146,18 @@ impl<'tcx> MatchPairTree<'tcx> { // FIXME(@dianne): this needs updating/removing if we always merge or-patterns extra_data.bindings.push(super::SubpatternBindings::FromOrPattern); } - Some(TestCase::Or { pats }) + Some(TestableCase::Or { pats }) } PatKind::Range(ref range) => { if range.is_full_range(cx.tcx) == Some(true) { None } else { - Some(TestCase::Range(Arc::clone(range))) + Some(TestableCase::Range(Arc::clone(range))) } } - PatKind::Constant { value } => Some(TestCase::Constant { value }), + PatKind::Constant { value } => Some(TestableCase::Constant { value }), PatKind::AscribeUserType { ascription: Ascription { ref annotation, variance }, @@ -256,7 +256,7 @@ impl<'tcx> MatchPairTree<'tcx> { if prefix.is_empty() && slice.is_some() && suffix.is_empty() { None } else { - Some(TestCase::Slice { + Some(TestableCase::Slice { len: prefix.len() + suffix.len(), variable_length: slice.is_some(), }) @@ -275,7 +275,11 @@ impl<'tcx> MatchPairTree<'tcx> { cx.def_id.into(), ) }) && !adt_def.variant_list_has_applicable_non_exhaustive(); - if irrefutable { None } else { Some(TestCase::Variant { adt_def, variant_index }) } + if irrefutable { + None + } else { + Some(TestableCase::Variant { adt_def, variant_index }) + } } PatKind::Leaf { ref subpatterns } => { @@ -331,17 +335,17 @@ impl<'tcx> MatchPairTree<'tcx> { &mut subpairs, extra_data, ); - Some(TestCase::Deref { temp, mutability }) + Some(TestableCase::Deref { temp, mutability }) } - PatKind::Never => Some(TestCase::Never), + PatKind::Never => Some(TestableCase::Never), }; - if let Some(test_case) = test_case { + if let Some(testable_case) = testable_case { // This pattern is refutable, so push a new match-pair node. match_pairs.push(MatchPairTree { place, - test_case, + testable_case, subpairs, pattern_ty: pattern.ty, pattern_span: pattern.span, diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 5074ce336798..ecdc3842a9b8 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1078,7 +1078,7 @@ struct Candidate<'tcx> { /// (see [`Builder::test_remaining_match_pairs_after_or`]). /// /// Invariants: - /// - All or-patterns ([`TestCase::Or`]) have been sorted to the end. + /// - All or-patterns ([`TestableCase::Or`]) have been sorted to the end. match_pairs: Vec>, /// ...and if this is non-empty, one of these subcandidates also has to match... @@ -1164,12 +1164,15 @@ impl<'tcx> Candidate<'tcx> { /// Restores the invariant that or-patterns must be sorted to the end. fn sort_match_pairs(&mut self) { - self.match_pairs.sort_by_key(|pair| matches!(pair.test_case, TestCase::Or { .. })); + self.match_pairs.sort_by_key(|pair| matches!(pair.testable_case, TestableCase::Or { .. })); } /// Returns whether the first match pair of this candidate is an or-pattern. fn starts_with_or_pattern(&self) -> bool { - matches!(&*self.match_pairs, [MatchPairTree { test_case: TestCase::Or { .. }, .. }, ..]) + matches!( + &*self.match_pairs, + [MatchPairTree { testable_case: TestableCase::Or { .. }, .. }, ..] + ) } /// Visit the leaf candidates (those with no subcandidates) contained in @@ -1261,7 +1264,7 @@ struct Ascription<'tcx> { /// Instead they participate in or-pattern expansion, where they are transformed into /// subcandidates. See [`Builder::expand_and_match_or_candidates`]. #[derive(Debug, Clone)] -enum TestCase<'tcx> { +enum TestableCase<'tcx> { Variant { adt_def: ty::AdtDef<'tcx>, variant_index: VariantIdx }, Constant { value: ty::Value<'tcx> }, Range(Arc>), @@ -1271,7 +1274,7 @@ enum TestCase<'tcx> { Or { pats: Box<[FlatPat<'tcx>]> }, } -impl<'tcx> TestCase<'tcx> { +impl<'tcx> TestableCase<'tcx> { fn as_range(&self) -> Option<&PatRange<'tcx>> { if let Self::Range(v) = self { Some(v.as_ref()) } else { None } } @@ -1289,12 +1292,12 @@ pub(crate) struct MatchPairTree<'tcx> { /// --- /// This can be `None` if it referred to a non-captured place in a closure. /// - /// Invariant: Can only be `None` when `test_case` is `Or`. + /// Invariant: Can only be `None` when `testable_case` is `Or`. /// Therefore this must be `Some(_)` after or-pattern expansion. place: Option>, /// ... must pass this test... - test_case: TestCase<'tcx>, + testable_case: TestableCase<'tcx>, /// ... and these subpairs must match. /// @@ -1317,7 +1320,7 @@ enum TestKind<'tcx> { /// Test what enum variant a value is. /// /// The subset of expected variants is not stored here; instead they are - /// extracted from the [`TestCase`]s of the candidates participating in the + /// extracted from the [`TestableCase`]s of the candidates participating in the /// test. Switch { /// The enum type being tested. @@ -1327,7 +1330,7 @@ enum TestKind<'tcx> { /// Test what value an integer or `char` has. /// /// The test's target values are not stored here; instead they are extracted - /// from the [`TestCase`]s of the candidates participating in the test. + /// from the [`TestableCase`]s of the candidates participating in the test. SwitchInt, /// Test whether a `bool` is `true` or `false`. @@ -1948,7 +1951,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { candidate: &mut Candidate<'tcx>, match_pair: MatchPairTree<'tcx>, ) { - let TestCase::Or { pats } = match_pair.test_case else { bug!() }; + let TestableCase::Or { pats } = match_pair.testable_case else { bug!() }; debug!("expanding or-pattern: candidate={:#?}\npats={:#?}", candidate, pats); candidate.or_span = Some(match_pair.pattern_span); candidate.subcandidates = pats @@ -2116,7 +2119,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug_assert!( remaining_match_pairs .iter() - .all(|match_pair| matches!(match_pair.test_case, TestCase::Or { .. })) + .all(|match_pair| matches!(match_pair.testable_case, TestableCase::Or { .. })) ); // Visit each leaf candidate within this subtree, add a copy of the remaining diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index 46a76a7b9a30..55e21ff18aae 100644 --- a/compiler/rustc_mir_build/src/builder/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -19,7 +19,7 @@ use rustc_span::{DUMMY_SP, Span, Symbol, sym}; use tracing::{debug, instrument}; use crate::builder::Builder; -use crate::builder::matches::{MatchPairTree, Test, TestBranch, TestCase, TestKind}; +use crate::builder::matches::{MatchPairTree, Test, TestBranch, TestKind, TestableCase}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Identifies what test is needed to decide if `match_pair` is applicable. @@ -29,30 +29,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, match_pair: &MatchPairTree<'tcx>, ) -> Test<'tcx> { - let kind = match match_pair.test_case { - TestCase::Variant { adt_def, variant_index: _ } => TestKind::Switch { adt_def }, + let kind = match match_pair.testable_case { + TestableCase::Variant { adt_def, variant_index: _ } => TestKind::Switch { adt_def }, - TestCase::Constant { .. } if match_pair.pattern_ty.is_bool() => TestKind::If, - TestCase::Constant { .. } if is_switch_ty(match_pair.pattern_ty) => TestKind::SwitchInt, - TestCase::Constant { value } => TestKind::Eq { value, cast_ty: match_pair.pattern_ty }, + TestableCase::Constant { .. } if match_pair.pattern_ty.is_bool() => TestKind::If, + TestableCase::Constant { .. } if is_switch_ty(match_pair.pattern_ty) => { + TestKind::SwitchInt + } + TestableCase::Constant { value } => { + TestKind::Eq { value, cast_ty: match_pair.pattern_ty } + } - TestCase::Range(ref range) => { + TestableCase::Range(ref range) => { assert_eq!(range.ty, match_pair.pattern_ty); TestKind::Range(Arc::clone(range)) } - TestCase::Slice { len, variable_length } => { + TestableCase::Slice { len, variable_length } => { let op = if variable_length { BinOp::Ge } else { BinOp::Eq }; TestKind::Len { len: len as u64, op } } - TestCase::Deref { temp, mutability } => TestKind::Deref { temp, mutability }, + TestableCase::Deref { temp, mutability } => TestKind::Deref { temp, mutability }, - TestCase::Never => TestKind::Never, + TestableCase::Never => TestKind::Never, // Or-patterns are not tested directly; instead they are expanded into subcandidates, // which are then distinguished by testing whatever non-or patterns they contain. - TestCase::Or { .. } => bug!("or-patterns should have already been handled"), + TestableCase::Or { .. } => bug!("or-patterns should have already been handled"), }; Test { span: match_pair.pattern_span, kind } diff --git a/compiler/rustc_mir_build/src/builder/matches/util.rs b/compiler/rustc_mir_build/src/builder/matches/util.rs index 2c8ad95b6afd..f1df90f93fd6 100644 --- a/compiler/rustc_mir_build/src/builder/matches/util.rs +++ b/compiler/rustc_mir_build/src/builder/matches/util.rs @@ -6,7 +6,7 @@ use tracing::debug; use crate::builder::Builder; use crate::builder::expr::as_place::PlaceBase; -use crate::builder::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase}; +use crate::builder::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestableCase}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Creates a false edge to `imaginary_target` and a real edge to @@ -159,11 +159,11 @@ impl<'a, 'b, 'tcx> FakeBorrowCollector<'a, 'b, 'tcx> { } fn visit_match_pair(&mut self, match_pair: &MatchPairTree<'tcx>) { - if let TestCase::Or { pats, .. } = &match_pair.test_case { + if let TestableCase::Or { pats, .. } = &match_pair.testable_case { for flat_pat in pats.iter() { self.visit_flat_pat(flat_pat) } - } else if matches!(match_pair.test_case, TestCase::Deref { .. }) { + } else if matches!(match_pair.testable_case, TestableCase::Deref { .. }) { // The subpairs of a deref pattern are all places relative to the deref temporary, so we // don't fake borrow them. Problem is, if we only shallowly fake-borrowed // `match_pair.place`, this would allow: From a8f4a6744c5927053e3415704d54daf463e5eec1 Mon Sep 17 00:00:00 2001 From: Oleksii Lozovskyi Date: Tue, 16 Dec 2025 21:10:29 +0900 Subject: [PATCH 196/489] rustdoc: Test only in stage2 stage1's rustdoc is using stage0's libtest which does not have a fix from 069cf9dfc90, making the test run fail. Ensure that this test is executed with everything recompiled in stage2. --- tests/run-make/doctests-junit/rmake.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/run-make/doctests-junit/rmake.rs b/tests/run-make/doctests-junit/rmake.rs index 4cc7ac7c31d7..e3198502bb17 100644 --- a/tests/run-make/doctests-junit/rmake.rs +++ b/tests/run-make/doctests-junit/rmake.rs @@ -1,6 +1,7 @@ // Check rustdoc's test JUnit (XML) output against snapshots. //@ ignore-cross-compile (running doctests) +//@ ignore-stage1 (rustdoc depends on a fix in libtest) //@ needs-unwind (test file contains `should_panic` test) use std::path::Path; From 9dec5bb31a6041960083bb78678e85b0cc387c96 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 16 Dec 2025 10:48:15 +0000 Subject: [PATCH 197/489] remove fixme & update stderr files --- tests/ui/unit_arg.stderr | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index 0dcfb02b9fa0..eb7c56c45b59 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -204,21 +204,18 @@ error: passing a unit value to a function | LL | fn_take_unit(mac!(def)); | ^^^^^^^^^^^^^^^^^^^^^^^ - | error: passing a unit value to a function --> tests/ui/unit_arg.rs:173:5 | LL | fn_take_unit(mac!(func Default::default)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | error: passing a unit value to a function --> tests/ui/unit_arg.rs:175:5 | LL | fn_take_unit(mac!(nonempty_block Default::default())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | error: aborting due to 13 previous errors From 6cd1740e17f93d04d53a42b7dc06f49757bfba8f Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Tue, 16 Dec 2025 17:00:12 +0200 Subject: [PATCH 198/489] Upgrade rustc crates Changes: - `const_of_item()` was added to `Interner`, analogous to `type_of()`. No strongly-typed ID (yet). - New solver trait lang item: `TrivialClone`. - `TypeRelation` changed a bit, the code was copied from rustc. --- src/tools/rust-analyzer/Cargo.lock | 45 +++++++++---------- src/tools/rust-analyzer/Cargo.toml | 16 +++---- .../crates/hir-def/src/lang_item.rs | 1 + .../next_solver/infer/relate/generalize.rs | 39 ++++++++-------- .../src/next_solver/infer/relate/lattice.rs | 23 ++++++++-- .../crates/hir-ty/src/next_solver/interner.rs | 19 +++++++- .../crates/intern/src/symbol/symbols.rs | 1 + 7 files changed, 86 insertions(+), 58 deletions(-) diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index efe56cb7f61c..9b7b7650199e 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -2040,9 +2040,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "ra-ap-rustc_abi" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce480c45c05462cf6b700468118201b00132613a968a1849da5f7a555c0f1db9" +checksum = "1d49dbe5d570793b3c3227972a6ac85fc3e830f09b32c3cb3b68cfceebad3b0a" dependencies = [ "bitflags 2.9.4", "ra-ap-rustc_hashes", @@ -2052,34 +2052,33 @@ dependencies = [ [[package]] name = "ra-ap-rustc_ast_ir" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453da2376de406d740ca28412a31ae3d5a6039cd45698c1c2fb01b577dff64ae" +checksum = "cd0956db62c264a899d15667993cbbd2e8f0b02108712217e2579c61ac30b94b" [[package]] name = "ra-ap-rustc_hashes" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf411a55deaa3ea348594c8273fb2d1200265bf87b881b40c62b32f75caf8323" +checksum = "7df512084c24f4c96c8cc9a59cbd264301efbc8913d3759b065398024af316c9" dependencies = [ "rustc-stable-hash", ] [[package]] name = "ra-ap-rustc_index" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0dd4cf1417ea8a809e9e7bf296c6ce6e05b75b043483872d1bd2951a08142c" +checksum = "bca3a49a928d38ba7927605e5909b6abe77d09ff359e4695c070c3f91d69cc8a" dependencies = [ "ra-ap-rustc_index_macros", - "smallvec", ] [[package]] name = "ra-ap-rustc_index_macros" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b0d218fb91f8969716a962142c722d88b3cd3fd1f7ef03093261bf37e85dfd" +checksum = "4463e908a62c64c2a65c1966c2f4995d0e1f8b7dfc85a8b8de2562edf3d89070" dependencies = [ "proc-macro2", "quote", @@ -2088,9 +2087,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_lexer" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ec7c26e92c44d5433b29cf661faf0027e263b70a411d0f28996bd67e3bdb57e" +checksum = "228e01e1b237adb4bd8793487e1c37019c1e526a8f93716d99602301be267056" dependencies = [ "memchr", "unicode-properties", @@ -2099,9 +2098,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_next_trait_solver" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029686fdbc8a058cf3d81ad157e1cdc81a37b9de0400289ccb86a62465484313" +checksum = "10d6f91143011d474bb844d268b0784c6a4c6db57743558b83f5ad34511627f1" dependencies = [ "derive-where", "ra-ap-rustc_index", @@ -2112,9 +2111,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_parse_format" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509d279f1e87acc33476da3fbd05a6054e9ffeb4427cb38ba01b9d2656aec268" +checksum = "37fa8effbc436c0ddd9d7b1421aa3cccf8b94566c841c4e4aa3e09063b8f423f" dependencies = [ "ra-ap-rustc_lexer", "rustc-literal-escaper 0.0.5", @@ -2122,9 +2121,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_pattern_analysis" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb2c9930854314b03bd7aab060a14bca6f194b76381a4c309e3905ec3a02bbc" +checksum = "883c843fc27847ad03b8e772dd4a2d2728af4333a6d6821a22dfcfe7136dff3e" dependencies = [ "ra-ap-rustc_index", "rustc-hash 2.1.1", @@ -2135,9 +2134,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_type_ir" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4a92a3e4dbdebb0d4c9caceb52eff45c4df784d21fb2da90dac50e218f95c0" +checksum = "a86e33c46b2b261a173b23f207461a514812a8b2d2d7935bbc685f733eacce10" dependencies = [ "arrayvec", "bitflags 2.9.4", @@ -2155,9 +2154,9 @@ dependencies = [ [[package]] name = "ra-ap-rustc_type_ir_macros" -version = "0.139.0" +version = "0.143.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca368eca2472367f2e6fdfb431c8342e99d848e4ce89cb20dd3b3bdcc43cbc28" +checksum = "15034c2fcaa5cf302aea6db20eda0f71fffeb0b372d6073cc50f940e974a2a47" dependencies = [ "proc-macro2", "quote", diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index 6991eeec738e..17051e57de34 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -86,14 +86,14 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" } vfs = { path = "./crates/vfs", version = "0.0.0" } edition = { path = "./crates/edition", version = "0.0.0" } -ra-ap-rustc_lexer = { version = "0.139", default-features = false } -ra-ap-rustc_parse_format = { version = "0.139", default-features = false } -ra-ap-rustc_index = { version = "0.139", default-features = false } -ra-ap-rustc_abi = { version = "0.139", default-features = false } -ra-ap-rustc_pattern_analysis = { version = "0.139", default-features = false } -ra-ap-rustc_ast_ir = { version = "0.139", default-features = false } -ra-ap-rustc_type_ir = { version = "0.139", default-features = false } -ra-ap-rustc_next_trait_solver = { version = "0.139", default-features = false } +ra-ap-rustc_lexer = { version = "0.143", default-features = false } +ra-ap-rustc_parse_format = { version = "0.143", default-features = false } +ra-ap-rustc_index = { version = "0.143", default-features = false } +ra-ap-rustc_abi = { version = "0.143", default-features = false } +ra-ap-rustc_pattern_analysis = { version = "0.143", default-features = false } +ra-ap-rustc_ast_ir = { version = "0.143", default-features = false } +ra-ap-rustc_type_ir = { version = "0.143", default-features = false } +ra-ap-rustc_next_trait_solver = { version = "0.143", default-features = false } # local crates that aren't published to crates.io. These should not have versions. diff --git a/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs b/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs index 9fdfb5f5b32e..6c8fb55d8f51 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs @@ -237,6 +237,7 @@ language_item_table! { LangItems => StructuralTeq, sym::structural_teq, structural_teq_trait, TraitId, GenericRequirement::None; Copy, sym::copy, copy_trait, TraitId, GenericRequirement::Exact(0); Clone, sym::clone, clone_trait, TraitId, GenericRequirement::None; + TrivialClone, sym::trivial_clone, clone_trait, TraitId, GenericRequirement::None; Sync, sym::sync, sync_trait, TraitId, GenericRequirement::Exact(0); DiscriminantKind, sym::discriminant_kind, discriminant_kind_trait, TraitId, GenericRequirement::None; /// The associated item of the `DiscriminantKind` trait. diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/generalize.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/generalize.rs index d06984cac11c..0f7ae99fa41d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/generalize.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/generalize.rs @@ -16,14 +16,14 @@ use tracing::{debug, instrument, warn}; use super::{ PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation, }; -use crate::next_solver::infer::type_variable::TypeVariableValue; use crate::next_solver::infer::unify_key::ConstVariableValue; use crate::next_solver::infer::{InferCtxt, relate}; use crate::next_solver::util::MaxUniverse; use crate::next_solver::{ - AliasTy, Binder, ClauseKind, Const, ConstKind, DbInterner, GenericArgs, PredicateKind, Region, - SolverDefId, Term, TermVid, Ty, TyKind, TypingMode, UnevaluatedConst, + AliasTy, Binder, ClauseKind, Const, ConstKind, DbInterner, PredicateKind, Region, SolverDefId, + Term, TermVid, Ty, TyKind, TypingMode, UnevaluatedConst, }; +use crate::next_solver::{GenericArgs, infer::type_variable::TypeVariableValue}; impl<'db> InferCtxt<'db> { /// The idea is that we should ensure that the type variable `target_vid` @@ -384,29 +384,26 @@ impl<'db> TypeRelation> for Generalizer<'_, 'db> { self.infcx.interner } - fn relate_item_args( + fn relate_ty_args( &mut self, - item_def_id: SolverDefId, - a_arg: GenericArgs<'db>, - b_arg: GenericArgs<'db>, - ) -> RelateResult<'db, GenericArgs<'db>> { - if self.ambient_variance == Variance::Invariant { + a_ty: Ty<'db>, + _: Ty<'db>, + def_id: SolverDefId, + a_args: GenericArgs<'db>, + b_args: GenericArgs<'db>, + mk: impl FnOnce(GenericArgs<'db>) -> Ty<'db>, + ) -> RelateResult<'db, Ty<'db>> { + let args = if self.ambient_variance == Variance::Invariant { // Avoid fetching the variance if we are in an invariant // context; no need, and it can induce dependency cycles // (e.g., #41849). - relate::relate_args_invariantly(self, a_arg, b_arg) + relate::relate_args_invariantly(self, a_args, b_args) } else { - let tcx = self.cx(); - let opt_variances = tcx.variances_of(item_def_id); - relate::relate_args_with_variances( - self, - item_def_id, - opt_variances, - a_arg, - b_arg, - false, - ) - } + let interner = self.cx(); + let variances = interner.variances_of(def_id); + relate::relate_args_with_variances(self, variances, a_args, b_args) + }?; + if args == a_args { Ok(a_ty) } else { Ok(mk(args)) } } #[instrument(level = "debug", skip(self, variance, b), ret)] diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/lattice.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/lattice.rs index 374895c337c7..1abe6a93f4dd 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/lattice.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/relate/lattice.rs @@ -18,17 +18,19 @@ //! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order) use rustc_type_ir::{ - AliasRelationDirection, TypeVisitableExt, Upcast, Variance, + AliasRelationDirection, Interner, TypeVisitableExt, Upcast, Variance, inherent::{IntoKind, Span as _}, relate::{ Relate, StructurallyRelateAliases, TypeRelation, VarianceDiagInfo, - combine::{PredicateEmittingRelation, super_combine_consts, super_combine_tys}, + combine::{ + PredicateEmittingRelation, combine_ty_args, super_combine_consts, super_combine_tys, + }, }, }; use crate::next_solver::{ - AliasTy, Binder, Const, DbInterner, Goal, ParamEnv, Predicate, PredicateKind, Region, Span, Ty, - TyKind, + AliasTy, Binder, Const, DbInterner, GenericArgs, Goal, ParamEnv, Predicate, PredicateKind, + Region, SolverDefId, Span, Ty, TyKind, infer::{ InferCtxt, TypeTrace, relate::RelateResult, @@ -82,6 +84,19 @@ impl<'db> TypeRelation> for LatticeOp<'_, 'db> { self.infcx.interner } + fn relate_ty_args( + &mut self, + a_ty: Ty<'db>, + b_ty: Ty<'db>, + def_id: SolverDefId, + a_args: GenericArgs<'db>, + b_args: GenericArgs<'db>, + mk: impl FnOnce(GenericArgs<'db>) -> Ty<'db>, + ) -> RelateResult<'db, Ty<'db>> { + let variances = self.cx().variances_of(def_id); + combine_ty_args(self.infcx, self, a_ty, b_ty, variances, a_args, b_args, mk) + } + fn relate_with_variance>>( &mut self, variance: Variance, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index 8b24a20a5bed..2a9f6c4053a4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -25,7 +25,7 @@ use rustc_type_ir::{ elaborate::elaborate, error::TypeError, fast_reject, - inherent::{self, GenericsOf, IntoKind, SliceLike as _, Span as _, Ty as _}, + inherent::{self, Const as _, GenericsOf, IntoKind, SliceLike as _, Span as _, Ty as _}, lang_items::{SolverAdtLangItem, SolverLangItem, SolverTraitLangItem}, solve::SizedTraitKind, }; @@ -39,7 +39,7 @@ use crate::{ AdtIdWrapper, BoundConst, CallableIdWrapper, CanonicalVarKind, ClosureIdWrapper, CoroutineIdWrapper, Ctor, FnSig, FxIndexMap, GeneralConstIdWrapper, ImplIdWrapper, OpaqueTypeKey, RegionAssumptions, SimplifiedType, SolverContext, SolverDefIds, - TraitIdWrapper, TypeAliasIdWrapper, util::explicit_item_bounds, + TraitIdWrapper, TypeAliasIdWrapper, UnevaluatedConst, util::explicit_item_bounds, }, }; @@ -1512,6 +1512,7 @@ impl<'db> Interner for DbInterner<'db> { SolverTraitLangItem::BikeshedGuaranteedNoDrop => { unimplemented!() } + SolverTraitLangItem::TrivialClone => lang_items.TrivialClone, }; lang_item.expect("Lang item required but not found.").into() } @@ -1565,6 +1566,7 @@ impl<'db> Interner for DbInterner<'db> { AsyncFn, AsyncFnMut, AsyncFnOnce, + TrivialClone, ) } @@ -1651,6 +1653,7 @@ impl<'db> Interner for DbInterner<'db> { AsyncFn, AsyncFnMut, AsyncFnOnce, + TrivialClone, ) } @@ -2167,6 +2170,18 @@ impl<'db> Interner for DbInterner<'db> { Some(SolverTraitLangItem::Sized | SolverTraitLangItem::MetaSized) ) } + + fn const_of_item(self, def_id: Self::DefId) -> rustc_type_ir::EarlyBinder { + let id = match def_id { + SolverDefId::StaticId(id) => id.into(), + SolverDefId::ConstId(id) => id.into(), + _ => unreachable!(), + }; + EarlyBinder::bind(Const::new_unevaluated( + self, + UnevaluatedConst { def: GeneralConstIdWrapper(id), args: GenericArgs::empty(self) }, + )) + } } impl<'db> DbInterner<'db> { diff --git a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs index 462f1c69fa69..6e9c6d26b5b1 100644 --- a/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs +++ b/src/tools/rust-analyzer/crates/intern/src/symbol/symbols.rs @@ -161,6 +161,7 @@ define_symbols! { cfg_select, char, clone, + trivial_clone, Clone, coerce_unsized, column, From b9839eb105204f665e8675689c49b26a3d8fdcdd Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:13:22 +0000 Subject: [PATCH 199/489] Rustup to rustc 1.94.0-nightly (21ff67df1 2025-12-15) --- rust-toolchain | 2 +- src/driver/jit.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 461dbcdb0fb5..61ef39d75ffc 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2025-12-08" +channel = "nightly-2025-12-16" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 9dba46363936..3a8ca25a5fc0 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -190,7 +190,7 @@ fn dep_symbol_lookup_fn( diag.emit(); } Linkage::Dynamic => { - dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); + dylib_paths.push(src.dylib.as_ref().unwrap().clone()); } } } From b73270f189cfe1f2c4bfbf9dda70f300ee8ed0bb Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:40:44 +0000 Subject: [PATCH 200/489] Fix rustc test suite --- scripts/test_rustc_tests.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index b5af585a732e..570ac434b97e 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -70,6 +70,7 @@ rm tests/ui/linking/no-gc-encapsulation-symbols.rs # same rm tests/ui/attributes/fn-align-dyn.rs # per-function alignment not supported rm -r tests/ui/explicit-tail-calls # tail calls rm -r tests/run-make/pointer-auth-link-with-c # pointer auth +rm -r tests/ui/eii # EII not yet implemented # requires LTO rm -r tests/run-make/cdylib @@ -143,6 +144,14 @@ rm tests/ui/errors/remap-path-prefix-sysroot.rs # different sysroot source path rm -r tests/run-make/export/extern-opt # something about rustc version mismatches rm -r tests/run-make/export # same rm -r tests/ui/compiletest-self-test/compile-flags-incremental.rs # needs compiletest compiled with panic=unwind +rm tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs # something going wrong with stdlib source remapping +rm tests/ui/consts/miri_unleashed/drop.rs # same +rm tests/ui/error-emitter/multiline-removal-suggestion.rs # same +rm tests/ui/lint/lint-const-item-mutation.rs # same +rm tests/ui/lint/use-redundant/use-redundant-issue-71450.rs # same +rm tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs # same +rm tests/ui/specialization/const_trait_impl.rs # same +rm tests/ui/thir-print/offset_of.rs # same # genuine bugs # ============ From 49f1fa5110846d1ffec4e5557961a4a9a1b4334e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:42:17 +0000 Subject: [PATCH 201/489] Unconditionally install rustfmt Rustfmt used to be optional for nightlies long ago, but it is now always present. Also rename rust-toolchain to rust-toolchain.toml. --- .github/workflows/main.yml | 8 ++++---- .github/workflows/rustc.yml | 4 ++-- rust-toolchain | 4 ---- rust-toolchain.toml | 4 ++++ scripts/rustup.sh | 5 ++--- 5 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 rust-toolchain create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0930b924d177..07d9af4a9b54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: - name: Avoid installing rustc-dev run: | - sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain + sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain.toml rustfmt -v - name: Rustfmt @@ -88,7 +88,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - name: Set MinGW as the default toolchain if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' @@ -158,7 +158,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - name: Install hyperfine run: | @@ -207,7 +207,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - name: Set MinGW as the default toolchain if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' diff --git a/.github/workflows/rustc.yml b/.github/workflows/rustc.yml index 9253ab96353c..b22725fdc9d4 100644 --- a/.github/workflows/rustc.yml +++ b/.github/workflows/rustc.yml @@ -20,7 +20,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain', 'Cargo.lock') }} + key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }} - name: Test run: ./scripts/test_bootstrap.sh @@ -40,7 +40,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain', 'Cargo.lock') }} + key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }} - name: Install ripgrep run: | diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 61ef39d75ffc..000000000000 --- a/rust-toolchain +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly-2025-12-16" -components = ["rust-src", "rustc-dev", "llvm-tools"] -profile = "minimal" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000000..4d3fe30e7d47 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2025-12-16" +components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"] +profile = "minimal" diff --git a/scripts/rustup.sh b/scripts/rustup.sh index 1a82193303e2..e26be307328f 100755 --- a/scripts/rustup.sh +++ b/scripts/rustup.sh @@ -22,8 +22,7 @@ case $1 in "prepare") echo "=> Installing new nightly" rustup toolchain install --profile minimal "nightly-${TOOLCHAIN}" # Sanity check to see if the nightly exists - sed -i "s/\"nightly-.*\"/\"nightly-${TOOLCHAIN}\"/" rust-toolchain - rustup component add rustfmt || true + sed -i "s/\"nightly-.*\"/\"nightly-${TOOLCHAIN}\"/" rust-toolchain.toml echo "=> Uninstalling all old nightlies" for nightly in $(rustup toolchain list | grep nightly | grep -v "$TOOLCHAIN" | grep -v nightly-x86_64); do @@ -35,7 +34,7 @@ case $1 in ./y.sh prepare ;; "commit") - git add rust-toolchain + git add rust-toolchain.toml git commit -m "Rustup to $(rustc -V)" ;; "push") From bb9dac5fe5889f6c4cfb373388ca0e54413429f9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:49:44 +0000 Subject: [PATCH 202/489] Disable linker plugin lto rustc test --- scripts/test_rustc_tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index 570ac434b97e..09de603efa11 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -79,6 +79,7 @@ rm -r tests/run-make/lto-* rm -r tests/run-make/reproducible-build-2 rm -r tests/run-make/no-builtins-lto rm -r tests/run-make/reachable-extern-fn-available-lto +rm -r tests/run-make/no-builtins-linker-plugin-lto # coverage instrumentation rm tests/ui/consts/precise-drop-with-coverage.rs From 3822cf126bf004c9c9a5db6609f32e7758ea3427 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 16 Dec 2025 17:00:09 +0000 Subject: [PATCH 203/489] Disable a bunch of rustc tests that fail with --panic-unwind-support --- scripts/test_rustc_tests.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index 09de603efa11..69c6099c3ab8 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -53,17 +53,21 @@ rm tests/ui/sanitizer/kcfi-c-variadic.rs # same rm tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs # variadics for calling conventions other than C unsupported rm tests/ui/delegation/fn-header.rs +# inline assembly features +rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly +rm tests/ui/asm/global-asm-mono-sym-fn.rs # same +rm tests/ui/asm/naked-asm-mono-sym-fn.rs # same +rm tests/ui/asm/x86_64/goto.rs # inline asm labels not supported +rm tests/ui/asm/label-operand.rs # same +rm tests/ui/asm/may_unwind.rs # asm unwinding not supported +rm tests/ui/asm/aarch64/may_unwind.rs # same + # misc unimplemented things rm tests/ui/target-feature/missing-plusminus.rs # error not implemented rm -r tests/run-make/repr128-dwarf # debuginfo test rm -r tests/run-make/split-debuginfo # same rm -r tests/run-make/target-specs # i686 not supported by Cranelift rm -r tests/run-make/mismatching-target-triples # same -rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly -rm tests/ui/asm/global-asm-mono-sym-fn.rs # same -rm tests/ui/asm/naked-asm-mono-sym-fn.rs # same -rm tests/ui/asm/x86_64/goto.rs # inline asm labels not supported -rm tests/ui/asm/label-operand.rs # same rm tests/ui/simd/simd-bitmask-notpow2.rs # non-pow-of-2 simd vector sizes rm -r tests/run-make/used-proc-macro # used(linker) isn't supported yet rm tests/ui/linking/no-gc-encapsulation-symbols.rs # same @@ -71,6 +75,7 @@ rm tests/ui/attributes/fn-align-dyn.rs # per-function alignment not supported rm -r tests/ui/explicit-tail-calls # tail calls rm -r tests/run-make/pointer-auth-link-with-c # pointer auth rm -r tests/ui/eii # EII not yet implemented +rm -r tests/run-make/forced-unwind-terminate-pof # forced unwinding doesn't take precedence # requires LTO rm -r tests/run-make/cdylib @@ -89,6 +94,7 @@ rm -r tests/ui/instrument-coverage/ # ================== rm tests/ui/codegen/issue-28950.rs # depends on stack size optimizations rm tests/ui/codegen/init-large-type.rs # same +rm tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs # same rm tests/ui/statics/const_generics.rs # tests an optimization rm tests/ui/linking/executable-no-mangle-strip.rs # requires --gc-sections to work for statics @@ -167,6 +173,7 @@ rm tests/ui/lint/non-snake-case/lint-non-snake-case-crate.rs # same rm tests/ui/async-await/async-drop/async-drop-initial.rs # same (rust-lang/rust#140493) rm -r tests/ui/codegen/equal-pointers-unequal # make incorrect assumptions about the location of stack variables rm -r tests/run-make-cargo/rustdoc-scrape-examples-paths # FIXME(rust-lang/rust#145580) incr comp bug +rm -r tests/incremental/extern_static/issue-49153.rs # assumes reference to undefined static gets optimized away rm tests/ui/intrinsics/panic-uninitialized-zeroed.rs # really slow with unoptimized libstd rm tests/ui/process/process-panic-after-fork.rs # same From 4bd0e65bde6fdfc9b1e456336c1b30cb35e4c51e Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Mon, 15 Dec 2025 10:47:58 +0100 Subject: [PATCH 204/489] Port `#[rustc_legacy_const_generics]` to use attribute parser --- compiler/rustc_ast_lowering/src/lib.rs | 36 ++--- .../src/attributes/rustc_internal.rs | 46 +++++++ compiler/rustc_attr_parsing/src/context.rs | 7 +- .../rustc_hir/src/attrs/data_structures.rs | 3 + .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + .../rustc_hir/src/attrs/pretty_printing.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 1 - compiler/rustc_passes/messages.ftl | 3 - compiler/rustc_passes/src/check_attr.rs | 64 +++------ compiler/rustc_passes/src/errors.rs | 7 - compiler/rustc_resolve/src/lib.rs | 67 +++++----- src/librustdoc/clean/mod.rs | 38 +++--- ...d-rustc_legacy_const_generics-arguments.rs | 20 +-- ...stc_legacy_const_generics-arguments.stderr | 125 +++++++++++------- 14 files changed, 229 insertions(+), 191 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 10093da97fe3..d0871b0b98f4 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -237,25 +237,27 @@ impl SpanLowerer { #[extension(trait ResolverAstLoweringExt)] impl ResolverAstLowering { fn legacy_const_generic_args(&self, expr: &Expr) -> Option> { - if let ExprKind::Path(None, path) = &expr.kind { - // Don't perform legacy const generics rewriting if the path already - // has generic arguments. - if path.segments.last().unwrap().args.is_some() { - return None; - } + let ExprKind::Path(None, path) = &expr.kind else { + return None; + }; - if let Res::Def(DefKind::Fn, def_id) = self.partial_res_map.get(&expr.id)?.full_res()? { - // We only support cross-crate argument rewriting. Uses - // within the same crate should be updated to use the new - // const generics style. - if def_id.is_local() { - return None; - } + // Don't perform legacy const generics rewriting if the path already + // has generic arguments. + if path.segments.last().unwrap().args.is_some() { + return None; + } - if let Some(v) = self.legacy_const_generic_args.get(&def_id) { - return v.clone(); - } - } + let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?; + + // We only support cross-crate argument rewriting. Uses + // within the same crate should be updated to use the new + // const generics style. + if def_id.is_local() { + return None; + } + + if let Some(v) = self.legacy_const_generic_args.get(&def_id) { + return v.clone(); } None diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 4be141651ae6..f04d4ceea35a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -1,3 +1,5 @@ +use rustc_ast::{LitIntType, LitKind, MetaItemLit}; + use super::prelude::*; use super::util::parse_single_integer; use crate::session_diagnostics::RustcScalableVectorCountOutOfRange; @@ -41,6 +43,50 @@ impl SingleAttributeParser for RustcLayoutScalarValidRangeEndParser } } +pub(crate) struct RustcLegacyConstGenericsParser; + +impl SingleAttributeParser for RustcLegacyConstGenericsParser { + const PATH: &[Symbol] = &[sym::rustc_legacy_const_generics]; + const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]); + const TEMPLATE: AttributeTemplate = template!(List: &["N"]); + + fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { + let ArgParser::List(meta_items) = args else { + cx.expected_list(cx.attr_span, args); + return None; + }; + + let mut parsed_indexes = ThinVec::new(); + let mut errored = false; + + for possible_index in meta_items.mixed() { + if let MetaItemOrLitParser::Lit(MetaItemLit { + kind: LitKind::Int(index, LitIntType::Unsuffixed), + .. + }) = possible_index + { + parsed_indexes.push((index.0 as usize, possible_index.span())); + } else { + cx.expected_integer_literal(possible_index.span()); + errored = true; + } + } + if errored { + return None; + } else if parsed_indexes.is_empty() { + cx.expected_at_least_one_argument(args.span()?); + return None; + } + + Some(AttributeKind::RustcLegacyConstGenerics { + fn_indexes: parsed_indexes, + attr_span: cx.attr_span, + }) + } +} + pub(crate) struct RustcObjectLifetimeDefaultParser; impl SingleAttributeParser for RustcObjectLifetimeDefaultParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9c7006f84024..242e0c013bc0 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -59,9 +59,9 @@ use crate::attributes::proc_macro_attrs::{ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ - RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, RustcMainParser, - RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, - RustcSimdMonomorphizeLaneLimitParser, + RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, + RustcLegacyConstGenericsParser, RustcMainParser, RustcObjectLifetimeDefaultParser, + RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; use crate::attributes::stability::{ @@ -209,6 +209,7 @@ attribute_parsers!( Single, Single, Single, + Single, Single, Single, Single, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 5f38eaf4d5f4..177a4247e6f0 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -869,6 +869,9 @@ pub enum AttributeKind { /// Represents `#[rustc_layout_scalar_valid_range_start]`. RustcLayoutScalarValidRangeStart(Box, Span), + /// Represents `#[rustc_legacy_const_generics]` + RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span }, + /// Represents `#[rustc_main]`. RustcMain, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 90fb0497a5b2..10b7af14aeae 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -92,6 +92,7 @@ impl AttributeKind { RustcCoherenceIsCore(..) => No, RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, + RustcLegacyConstGenerics { .. } => Yes, RustcMain => No, RustcObjectLifetimeDefault => No, RustcPassIndirectlyInNonRusticAbis(..) => No, diff --git a/compiler/rustc_hir/src/attrs/pretty_printing.rs b/compiler/rustc_hir/src/attrs/pretty_printing.rs index 8bd267a1c256..f8ac2a547ca8 100644 --- a/compiler/rustc_hir/src/attrs/pretty_printing.rs +++ b/compiler/rustc_hir/src/attrs/pretty_printing.rs @@ -169,7 +169,7 @@ macro_rules! print_tup { print_tup!(A B C D E F G H); print_skip!(Span, (), ErrorGuaranteed); -print_disp!(u16, u128, bool, NonZero, Limit); +print_disp!(u16, u128, usize, bool, NonZero, Limit); print_debug!( Symbol, Ident, diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 91e6e6326c09..2021f175cd84 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -197,7 +197,6 @@ pub struct ResolverGlobalCtxt { #[derive(Debug)] pub struct ResolverAstLowering { pub legacy_const_generic_args: FxHashMap>>, - /// Resolutions for nodes that have a single resolution. pub partial_res_map: NodeMap, /// Resolutions for import nodes, which have multiple resolutions in different namespaces. diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 21191085253b..0f206edcc775 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -478,9 +478,6 @@ passes_rustc_legacy_const_generics_index_exceed = *[other] arguments } -passes_rustc_legacy_const_generics_index_negative = - arguments should be non-negative integers - passes_rustc_legacy_const_generics_only = #[rustc_legacy_const_generics] functions must only have const generics .label = non-const generic parameter diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index e836277e9761..f4896a8ca878 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -10,9 +10,10 @@ use std::collections::hash_map::Entry; use std::slice; use rustc_abi::{Align, ExternAbi, Size}; -use rustc_ast::{AttrStyle, LitKind, MetaItemKind, ast}; +use rustc_ast::{AttrStyle, MetaItemKind, ast}; use rustc_attr_parsing::{AttributeParser, Late}; use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::thin_vec::ThinVec; use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey}; use rustc_feature::{ ACCEPTED_LANG_FEATURES, AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, @@ -211,6 +212,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> { Attribute::Parsed(AttributeKind::MacroExport { span, .. }) => { self.check_macro_export(hir_id, *span, target) }, + Attribute::Parsed(AttributeKind::RustcLegacyConstGenerics{attr_span, fn_indexes}) => { + self.check_rustc_legacy_const_generics(item, *attr_span, fn_indexes) + }, Attribute::Parsed(AttributeKind::Doc(attr)) => self.check_doc_attrs(attr, hir_id, target), Attribute::Parsed(AttributeKind::EiiImpls(impls)) => { self.check_eii_impl(impls, target) @@ -306,9 +310,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { [sym::rustc_never_returns_null_ptr, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } - [sym::rustc_legacy_const_generics, ..] => { - self.check_rustc_legacy_const_generics(hir_id, attr, span, target, item) - } [sym::rustc_lint_query_instability, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } @@ -1218,33 +1219,17 @@ impl<'tcx> CheckAttrVisitor<'tcx> { /// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument. fn check_rustc_legacy_const_generics( &self, - hir_id: HirId, - attr: &Attribute, - span: Span, - target: Target, item: Option>, + attr_span: Span, + index_list: &ThinVec<(usize, Span)>, ) { - let is_function = matches!(target, Target::Fn); - if !is_function { - self.dcx().emit_err(errors::AttrShouldBeAppliedToFn { - attr_span: attr.span(), - defn_span: span, - on_crate: hir_id == CRATE_HIR_ID, - }); - return; - } - - let Some(list) = attr.meta_item_list() else { - // The attribute form is validated on AST. - return; - }; - let Some(ItemLike::Item(Item { kind: ItemKind::Fn { sig: FnSig { decl, .. }, generics, .. }, .. })) = item else { - bug!("should be a function item"); + // No error here, since it's already given by the parser + return; }; for param in generics.params { @@ -1252,7 +1237,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { hir::GenericParamKind::Const { .. } => {} _ => { self.dcx().emit_err(errors::RustcLegacyConstGenericsOnly { - attr_span: attr.span(), + attr_span, param_span: param.span, }); return; @@ -1260,34 +1245,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - if list.len() != generics.params.len() { + if index_list.len() != generics.params.len() { self.dcx().emit_err(errors::RustcLegacyConstGenericsIndex { - attr_span: attr.span(), + attr_span, generics_span: generics.span, }); return; } - let arg_count = decl.inputs.len() as u128 + generics.params.len() as u128; - let mut invalid_args = vec![]; - for meta in list { - if let Some(LitKind::Int(val, _)) = meta.lit().map(|lit| &lit.kind) { - if *val >= arg_count { - let span = meta.span(); - self.dcx().emit_err(errors::RustcLegacyConstGenericsIndexExceed { - span, - arg_count: arg_count as usize, - }); - return; - } - } else { - invalid_args.push(meta.span()); + let arg_count = decl.inputs.len() + generics.params.len(); + for (index, span) in index_list { + if *index >= arg_count { + self.dcx().emit_err(errors::RustcLegacyConstGenericsIndexExceed { + span: *span, + arg_count, + }); } } - - if !invalid_args.is_empty() { - self.dcx().emit_err(errors::RustcLegacyConstGenericsIndexNegative { invalid_args }); - } } /// Helper function for checking that the provided attribute is only applied to a function or diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 7abd2c703aeb..8ead69da9916 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -290,13 +290,6 @@ pub(crate) struct RustcLegacyConstGenericsIndexExceed { pub arg_count: usize, } -#[derive(Diagnostic)] -#[diag(passes_rustc_legacy_const_generics_index_negative)] -pub(crate) struct RustcLegacyConstGenericsIndexNegative { - #[primary_span] - pub invalid_args: Vec, -} - #[derive(Diagnostic)] #[diag(passes_rustc_dirty_clean)] pub(crate) struct RustcDirtyClean { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index b3141406e467..d373d6136b52 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -44,7 +44,7 @@ use rustc_arena::{DroplessArena, TypedArena}; use rustc_ast::node_id::NodeMap; use rustc_ast::{ self as ast, AngleBracketedArg, CRATE_NODE_ID, Crate, Expr, ExprKind, GenericArg, GenericArgs, - LitKind, NodeId, Path, attr, + NodeId, Path, attr, }; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; @@ -54,7 +54,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::{Applicability, Diag, ErrCode, ErrorGuaranteed, LintBuffer}; use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind}; use rustc_feature::BUILTIN_ATTRIBUTES; -use rustc_hir::attrs::StrippedCfgItem; +use rustc_hir::attrs::{AttributeKind, StrippedCfgItem}; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{ self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, MacroKinds, NonMacroAttrKind, PartialRes, @@ -62,7 +62,7 @@ use rustc_hir::def::{ }; use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::DisambiguatorState; -use rustc_hir::{PrimTy, TraitCandidate}; +use rustc_hir::{PrimTy, TraitCandidate, find_attr}; use rustc_index::bit_set::DenseBitSet; use rustc_metadata::creader::CStore; use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport}; @@ -1676,8 +1676,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { node_id_to_def_id, disambiguator: DisambiguatorState::new(), placeholder_field_indices: Default::default(), - invocation_parents, legacy_const_generic_args: Default::default(), + invocation_parents, item_generics_num_lifetimes: Default::default(), trait_impls: Default::default(), confused_type_with_std_module: Default::default(), @@ -2396,40 +2396,33 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// `#[rustc_legacy_const_generics]` and returns the argument index list /// from the attribute. fn legacy_const_generic_args(&mut self, expr: &Expr) -> Option> { - if let ExprKind::Path(None, path) = &expr.kind { - // Don't perform legacy const generics rewriting if the path already - // has generic arguments. - if path.segments.last().unwrap().args.is_some() { - return None; - } - - let res = self.partial_res_map.get(&expr.id)?.full_res()?; - if let Res::Def(def::DefKind::Fn, def_id) = res { - // We only support cross-crate argument rewriting. Uses - // within the same crate should be updated to use the new - // const generics style. - if def_id.is_local() { - return None; - } - - if let Some(v) = self.legacy_const_generic_args.get(&def_id) { - return v.clone(); - } - - let attr = self.tcx.get_attr(def_id, sym::rustc_legacy_const_generics)?; - let mut ret = Vec::new(); - for meta in attr.meta_item_list()? { - match meta.lit()?.kind { - LitKind::Int(a, _) => ret.push(a.get() as usize), - _ => panic!("invalid arg index"), - } - } - // Cache the lookup to avoid parsing attributes for an item multiple times. - self.legacy_const_generic_args.insert(def_id, Some(ret.clone())); - return Some(ret); - } + let ExprKind::Path(None, path) = &expr.kind else { + return None; + }; + // Don't perform legacy const generics rewriting if the path already + // has generic arguments. + if path.segments.last().unwrap().args.is_some() { + return None; } - None + + let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?; + + // We only support cross-crate argument rewriting. Uses + // within the same crate should be updated to use the new + // const generics style. + if def_id.is_local() { + return None; + } + + let indexes = find_attr!( + // we can use parsed attrs here since for other crates they're already available + self.tcx.get_all_attrs(def_id), + AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes + ) + .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect()); + + self.legacy_const_generic_args.insert(def_id, indexes.clone()); + indexes } fn resolve_main(&mut self) { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index dd5c50d2ba37..764b3a0acdb6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1,7 +1,7 @@ //! This module defines the primary IR[^1] used in rustdoc together with the procedures that //! transform rustc data types into it. //! -//! This IR — commonly referred to as the *cleaned AST* — is modeled after the [AST][ast]. +//! This IR — commonly referred to as the *cleaned AST* — is modeled after the [AST][rustc_ast]. //! //! There are two kinds of transformation — *cleaning* — procedures: //! @@ -38,6 +38,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, In use rustc_data_structures::thin_vec::ThinVec; use rustc_errors::codes::*; use rustc_errors::{FatalError, struct_span_code_err}; +use rustc_hir as hir; use rustc_hir::attrs::{AttributeKind, DocAttribute, DocInline}; use rustc_hir::def::{CtorKind, DefKind, MacroKinds, Res}; use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE, LocalDefId}; @@ -54,7 +55,6 @@ use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_trait_selection::traits::wf::object_region_bounds; use tracing::{debug, instrument}; use utils::*; -use {rustc_ast as ast, rustc_hir as hir}; pub(crate) use self::cfg::{CfgInfo, extract_cfg_from_attrs}; pub(crate) use self::types::*; @@ -1026,26 +1026,20 @@ fn clean_fn_or_proc_macro<'tcx>( /// `rustc_legacy_const_generics`. More information in /// . fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[hir::Attribute]) { - for meta_item_list in attrs - .iter() - .filter(|a| a.has_name(sym::rustc_legacy_const_generics)) - .filter_map(|a| a.meta_item_list()) - { - for (pos, literal) in meta_item_list.iter().filter_map(|meta| meta.lit()).enumerate() { - match literal.kind { - ast::LitKind::Int(a, _) => { - let GenericParamDef { name, kind, .. } = func.generics.params.remove(0); - if let GenericParamDefKind::Const { ty, .. } = kind { - func.decl.inputs.insert( - a.get() as _, - Parameter { name: Some(name), type_: *ty, is_const: true }, - ); - } else { - panic!("unexpected non const in position {pos}"); - } - } - _ => panic!("invalid arg index"), - } + let Some(indexes) = + find_attr!(attrs, AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes) + else { + return; + }; + + for (pos, (index, _)) in indexes.iter().enumerate() { + let GenericParamDef { name, kind, .. } = func.generics.params.remove(0); + if let GenericParamDefKind::Const { ty, .. } = kind { + func.decl + .inputs + .insert(*index, Parameter { name: Some(name), type_: *ty, is_const: true }); + } else { + panic!("unexpected non const in position {pos}"); } } } diff --git a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs index 73a0363904ae..03a28fac95de 100644 --- a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs +++ b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs @@ -9,20 +9,24 @@ fn foo2() {} #[rustc_legacy_const_generics(2)] //~ ERROR index exceeds number of arguments fn foo3(_: u8) {} -#[rustc_legacy_const_generics(a)] //~ ERROR arguments should be non-negative integers +#[rustc_legacy_const_generics(a)] //~ ERROR malformed `rustc_legacy_const_generics` attribute input fn foo4() {} -#[rustc_legacy_const_generics(1, a, 2, b)] //~ ERROR arguments should be non-negative integers +#[rustc_legacy_const_generics(1, a, 2, b)] +//~^ ERROR malformed `rustc_legacy_const_generics` attribute input +//~^^ ERROR malformed `rustc_legacy_const_generics` attribute input fn foo5() {} -#[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function +#[rustc_legacy_const_generics(0)] //~ ERROR `#[rustc_legacy_const_generics]` attribute cannot be used on structs struct S; -#[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes +#[rustc_legacy_const_generics(0usize)] +//~^ ERROR suffixed literals are not allowed in attributes +//~^^ ERROR malformed `rustc_legacy_const_generics` attribute input fn foo6() {} extern "C" { - #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function + #[rustc_legacy_const_generics(1)] //~ ERROR `#[rustc_legacy_const_generics]` attribute cannot be used on foreign functions fn foo7(); //~ ERROR foreign items may not have const parameters } @@ -30,14 +34,14 @@ extern "C" { fn foo8() {} impl S { - #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function + #[rustc_legacy_const_generics(0)] //~ ERROR `#[rustc_legacy_const_generics]` attribute cannot be used on inherent methods fn foo9() {} } -#[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute +#[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute input fn bar1() {} -#[rustc_legacy_const_generics = 1] //~ ERROR malformed `rustc_legacy_const_generics` attribute +#[rustc_legacy_const_generics = 1] //~ ERROR malformed `rustc_legacy_const_generics` attribute input fn bar2() {} fn main() {} diff --git a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr index 1ced1433fe95..e4da6c86c83e 100644 --- a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr +++ b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr @@ -1,22 +1,88 @@ +error[E0539]: malformed `rustc_legacy_const_generics` attribute input + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:12:1 + | +LL | #[rustc_legacy_const_generics(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_legacy_const_generics(N)]` + +error[E0539]: malformed `rustc_legacy_const_generics` attribute input + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:15:1 + | +LL | #[rustc_legacy_const_generics(1, a, 2, b)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^^^^^^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_legacy_const_generics(N)]` + +error[E0539]: malformed `rustc_legacy_const_generics` attribute input + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:15:1 + | +LL | #[rustc_legacy_const_generics(1, a, 2, b)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_legacy_const_generics(N)]` + +error: `#[rustc_legacy_const_generics]` attribute cannot be used on structs + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:20:1 + | +LL | #[rustc_legacy_const_generics(0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_legacy_const_generics]` can only be applied to functions + error: suffixed literals are not allowed in attributes - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:21:31 + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:23:31 | LL | #[rustc_legacy_const_generics(0usize)] | ^^^^^^ | = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) -error: malformed `rustc_legacy_const_generics` attribute input - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:1 +error[E0539]: malformed `rustc_legacy_const_generics` attribute input + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:23:1 + | +LL | #[rustc_legacy_const_generics(0usize)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_legacy_const_generics(N)]` + +error: `#[rustc_legacy_const_generics]` attribute cannot be used on foreign functions + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:29:5 + | +LL | #[rustc_legacy_const_generics(1)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_legacy_const_generics]` can only be applied to functions + +error: `#[rustc_legacy_const_generics]` attribute cannot be used on inherent methods + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:5 + | +LL | #[rustc_legacy_const_generics(0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_legacy_const_generics]` can only be applied to functions + +error[E0539]: malformed `rustc_legacy_const_generics` attribute input + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:41:1 | LL | #[rustc_legacy_const_generics] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_legacy_const_generics(N)]` -error: malformed `rustc_legacy_const_generics` attribute input - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:40:1 +error[E0539]: malformed `rustc_legacy_const_generics` attribute input + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:44:1 | LL | #[rustc_legacy_const_generics = 1] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | expected this to be a list + | help: must be of the form: `#[rustc_legacy_const_generics(N)]` error: #[rustc_legacy_const_generics] must have one index for each generic parameter --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:3:1 @@ -38,58 +104,23 @@ error: index exceeds number of arguments LL | #[rustc_legacy_const_generics(2)] | ^ there are only 2 arguments -error: arguments should be non-negative integers - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:12:31 - | -LL | #[rustc_legacy_const_generics(a)] - | ^ - -error: arguments should be non-negative integers - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:15:34 - | -LL | #[rustc_legacy_const_generics(1, a, 2, b)] - | ^ ^ - -error: attribute should be applied to a function definition - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:18:1 - | -LL | #[rustc_legacy_const_generics(0)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | struct S; - | --------- not a function definition - error: #[rustc_legacy_const_generics] functions must only have const generics - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:29:1 + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:1 | LL | #[rustc_legacy_const_generics(0)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | fn foo8() {} | - non-const generic parameter -error: attribute should be applied to a function definition - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:5 - | -LL | #[rustc_legacy_const_generics(0)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | fn foo9() {} - | ---------------------------- not a function definition - -error: attribute should be applied to a function definition - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5 - | -LL | #[rustc_legacy_const_generics(1)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | fn foo7(); - | -------------------------- not a function definition - error[E0044]: foreign items may not have const parameters - --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:26:5 + --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:30:5 | LL | fn foo7(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters | = help: replace the const parameters with concrete consts -error: aborting due to 13 previous errors +error: aborting due to 15 previous errors -For more information about this error, try `rustc --explain E0044`. +Some errors have detailed explanations: E0044, E0539. +For more information about an error, try `rustc --explain E0044`. From 1308c0afc76e8407fe76d10b519dc8a1aef5a96b Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Tue, 16 Dec 2025 17:40:02 +0200 Subject: [PATCH 205/489] Remove Rust ungram file from the Ungrammar repo It can be confused with the real Rust ungram, now that they're in the same repo. --- .../rust-analyzer/lib/ungrammar/rust.ungram | 666 ------------------ .../rust-analyzer/lib/ungrammar/src/lib.rs | 11 - 2 files changed, 677 deletions(-) delete mode 100644 src/tools/rust-analyzer/lib/ungrammar/rust.ungram diff --git a/src/tools/rust-analyzer/lib/ungrammar/rust.ungram b/src/tools/rust-analyzer/lib/ungrammar/rust.ungram deleted file mode 100644 index 7781e719e2af..000000000000 --- a/src/tools/rust-analyzer/lib/ungrammar/rust.ungram +++ /dev/null @@ -1,666 +0,0 @@ -// Note this grammar file does not reflect the current language as this file is no longer maintained. - -// Rust Un-Grammar. -// -// This grammar specifies the structure of Rust's concrete syntax tree. -// It does not specify parsing rules (ambiguities, precedence, etc are out of scope). -// Tokens are processed -- contextual keywords are recognised, compound operators glued. -// -// Legend: -// -// // -- comment -// Name = -- non-terminal definition -// 'ident' -- token (terminal) -// A B -- sequence -// A | B -- alternation -// A* -- zero or more repetition -// A? -- zero or one repetition -// (A) -- same as A -// label:A -- suggested name for field of AST node - -//*************************// -// Names, Paths and Macros // -//*************************// - -Name = - 'ident' | 'self' - -NameRef = - 'ident' | 'int_number' | 'self' | 'super' | 'crate' | 'Self' - -Lifetime = - 'lifetime_ident' - -Path = - (qualifier:Path '::')? segment:PathSegment - -PathSegment = - '::'? NameRef -| NameRef GenericArgList? -| NameRef ParamList RetType? -| '<' PathType ('as' PathType)? '>' - -GenericArgList = - '::'? '<' (GenericArg (',' GenericArg)* ','?)? '>' - -GenericArg = - TypeArg -| AssocTypeArg -| LifetimeArg -| ConstArg - -TypeArg = - Type - -AssocTypeArg = - NameRef GenericParamList? (':' TypeBoundList | '=' Type) - -LifetimeArg = - Lifetime - -ConstArg = - Expr - -MacroCall = - Attr* Path '!' TokenTree ';'? - -TokenTree = - '(' ')' -| '{' '}' -| '[' ']' - -MacroItems = - Item* - -MacroStmts = - statements:Stmt* - Expr? - -//*************************// -// Items // -//*************************// - -SourceFile = - 'shebang'? - Attr* - Item* - -Item = - Const -| Enum -| ExternBlock -| ExternCrate -| Fn -| Impl -| MacroCall -| MacroRules -| MacroDef -| Module -| Static -| Struct -| Trait -| TypeAlias -| Union -| Use - -MacroRules = - Attr* Visibility? - 'macro_rules' '!' Name - TokenTree - -MacroDef = - Attr* Visibility? - 'macro' Name args:TokenTree? - body:TokenTree - -Module = - Attr* Visibility? - 'mod' Name - (ItemList | ';') - -ItemList = - '{' Attr* Item* '}' - -ExternCrate = - Attr* Visibility? - 'extern' 'crate' NameRef Rename? ';' - -Rename = - 'as' (Name | '_') - -Use = - Attr* Visibility? - 'use' UseTree ';' - -UseTree = - (Path? '::')? ('*' | UseTreeList) -| Path Rename? - -UseTreeList = - '{' (UseTree (',' UseTree)* ','?)? '}' - -Fn = - Attr* Visibility? - 'default'? 'const'? 'async'? 'unsafe'? Abi? - 'fn' Name GenericParamList? ParamList RetType? WhereClause? - (body:BlockExpr | ';') - -Abi = - 'extern' 'string'? - -ParamList = - '('( - SelfParam - | (SelfParam ',')? (Param (',' Param)* ','?)? - )')' -| '|' (Param (',' Param)* ','?)? '|' - -SelfParam = - Attr* ( - ('&' Lifetime?)? 'mut'? Name - | 'mut'? Name ':' Type - ) - -Param = - Attr* ( - Pat (':' Type)? - | Type - | '...' - ) - -RetType = - '->' Type - -TypeAlias = - Attr* Visibility? - 'default'? - 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause? - ('=' Type)? ';' - -Struct = - Attr* Visibility? - 'struct' Name GenericParamList? ( - WhereClause? (RecordFieldList | ';') - | TupleFieldList WhereClause? ';' - ) - -RecordFieldList = - '{' fields:(RecordField (',' RecordField)* ','?)? '}' - -RecordField = - Attr* Visibility? - Name ':' Type - -TupleFieldList = - '(' fields:(TupleField (',' TupleField)* ','?)? ')' - -TupleField = - Attr* Visibility? - Type - -FieldList = - RecordFieldList -| TupleFieldList - -Enum = - Attr* Visibility? - 'enum' Name GenericParamList? WhereClause? - VariantList - -VariantList = - '{' (Variant (',' Variant)* ','?)? '}' - -Variant = - Attr* Visibility? - Name FieldList? ('=' Expr)? - -Union = - Attr* Visibility? - 'union' Name GenericParamList? WhereClause? - RecordFieldList - -// A Data Type. -// -// Not used directly in the grammar, but handy to have anyway. -Adt = - Enum -| Struct -| Union - -Const = - Attr* Visibility? - 'default'? - 'const' (Name | '_') ':' Type - ('=' body:Expr)? ';' - -Static = - Attr* Visibility? - 'static' 'mut'? Name ':' Type - ('=' body:Expr)? ';' - -Trait = - Attr* Visibility? - 'unsafe'? 'auto'? - 'trait' Name GenericParamList? (':' TypeBoundList?)? WhereClause? - AssocItemList - -AssocItemList = - '{' Attr* AssocItem* '}' - -AssocItem = - Const -| Fn -| MacroCall -| TypeAlias - -Impl = - Attr* Visibility? - 'default'? 'unsafe'? - 'impl' GenericParamList? ('const'? '!'? trait:Type 'for')? self_ty:Type WhereClause? - AssocItemList - -ExternBlock = - Attr* 'unsafe'? Abi ExternItemList - -ExternItemList = - '{' Attr* ExternItem* '}' - -ExternItem = - Fn -| MacroCall -| Static -| TypeAlias - -GenericParamList = - '<' (GenericParam (',' GenericParam)* ','?)? '>' - -GenericParam = - ConstParam -| LifetimeParam -| TypeParam - -TypeParam = - Attr* Name (':' TypeBoundList?)? - ('=' default_type:Type)? - -ConstParam = - Attr* 'const' Name ':' Type - ('=' default_val:Expr)? - -LifetimeParam = - Attr* Lifetime (':' TypeBoundList?)? - -WhereClause = - 'where' predicates:(WherePred (',' WherePred)* ','?) - -WherePred = - ('for' GenericParamList)? (Lifetime | Type) ':' TypeBoundList? - -Visibility = - 'pub' ('(' 'in'? Path ')')? - -Attr = - '#' '!'? '[' Meta ']' - -Meta = - Path ('=' Expr | TokenTree)? - -//****************************// -// Statements and Expressions // -//****************************// - -Stmt = - ';' -| ExprStmt -| Item -| LetStmt - -LetStmt = - Attr* 'let' Pat (':' Type)? - '=' initializer:Expr - LetElse? - ';' - -LetElse = - 'else' BlockExpr - -ExprStmt = - Expr ';'? - -Expr = - ArrayExpr -| AwaitExpr -| BinExpr -| BlockExpr -| BoxExpr -| BreakExpr -| CallExpr -| CastExpr -| ClosureExpr -| ContinueExpr -| FieldExpr -| ForExpr -| IfExpr -| IndexExpr -| Literal -| LoopExpr -| MacroCall -| MacroStmts -| MatchExpr -| MethodCallExpr -| ParenExpr -| PathExpr -| PrefixExpr -| RangeExpr -| RecordExpr -| RefExpr -| ReturnExpr -| TryExpr -| TupleExpr -| WhileExpr -| YieldExpr -| LetExpr -| UnderscoreExpr - -Literal = - Attr* value:( - 'int_number' | 'float_number' - | 'string' | 'raw_string' - | 'byte_string' | 'raw_byte_string' - | 'true' | 'false' - | 'char' | 'byte' - ) - -PathExpr = - Attr* Path - -StmtList = - '{' - Attr* - statements:Stmt* - tail_expr:Expr? - '}' - -RefExpr = - Attr* '&' ('raw' | 'mut' | 'const') Expr - -TryExpr = - Attr* Expr '?' - -BlockExpr = - Attr* Label? ('try' | 'unsafe' | 'async' | 'const') StmtList - -PrefixExpr = - Attr* op:('-' | '!' | '*') Expr - -BinExpr = - Attr* - lhs:Expr - op:( - '||' | '&&' - | '==' | '!=' | '<=' | '>=' | '<' | '>' - | '+' | '*' | '-' | '/' | '%' | '<<' | '>>' | '^' | '|' | '&' - | '=' | '+=' | '/=' | '*=' | '%=' | '>>=' | '<<=' | '-=' | '|=' | '&=' | '^=' - ) - rhs:Expr - -CastExpr = - Attr* Expr 'as' Type - -ParenExpr = - Attr* '(' Attr* Expr ')' - -ArrayExpr = - Attr* '[' Attr* ( - (Expr (',' Expr)* ','?)? - | Expr ';' Expr - ) ']' - -IndexExpr = - Attr* base:Expr '[' index:Expr ']' - -TupleExpr = - Attr* '(' Attr* fields:(Expr (',' Expr)* ','?)? ')' - -RecordExpr = - Path RecordExprFieldList - -RecordExprFieldList = - '{' - Attr* - fields:(RecordExprField (',' RecordExprField)* ','?)? - ('..' spread:Expr?)? - '}' - -RecordExprField = - Attr* (NameRef ':')? Expr - -CallExpr = - Attr* Expr ArgList - -ArgList = - '(' args:(Expr (',' Expr)* ','?)? ')' - -MethodCallExpr = - Attr* receiver:Expr '.' NameRef GenericArgList? ArgList - -FieldExpr = - Attr* Expr '.' NameRef - -ClosureExpr = - Attr* 'static'? 'async'? 'move'? ParamList RetType? - body:Expr - -IfExpr = - Attr* 'if' condition:Expr then_branch:BlockExpr - ('else' else_branch:(IfExpr | BlockExpr))? - -LoopExpr = - Attr* Label? 'loop' - loop_body:BlockExpr - -ForExpr = - Attr* Label? 'for' Pat 'in' iterable:Expr - loop_body:BlockExpr - -WhileExpr = - Attr* Label? 'while' condition:Expr - loop_body:BlockExpr - -Label = - Lifetime ':' - -BreakExpr = - Attr* 'break' Lifetime? Expr? - -ContinueExpr = - Attr* 'continue' Lifetime? - -RangeExpr = - Attr* start:Expr? op:('..' | '..=') end:Expr? - -MatchExpr = - Attr* 'match' Expr MatchArmList - -MatchArmList = - '{' - Attr* - arms:MatchArm* - '}' - -MatchArm = - Attr* Pat guard:MatchGuard? '=>' Expr ','? - -MatchGuard = - 'if' condition:Expr - -ReturnExpr = - Attr* 'return' Expr? - -YieldExpr = - Attr* 'yield' Expr? - -LetExpr = - Attr* 'let' Pat '=' Expr - -UnderscoreExpr = - Attr* '_' - -AwaitExpr = - Attr* Expr '.' 'await' - -BoxExpr = - Attr* 'box' Expr - -//*************************// -// Types // -//*************************// - -Type = - ArrayType -| DynTraitType -| FnPtrType -| ForType -| ImplTraitType -| InferType -| MacroType -| NeverType -| ParenType -| PathType -| PtrType -| RefType -| SliceType -| TupleType - -ParenType = - '(' Type ')' - -NeverType = - '!' - -MacroType = - MacroCall - -PathType = - Path - -TupleType = - '(' fields:(Type (',' Type)* ','?)? ')' - -PtrType = - '*' ('const' | 'mut') Type - -RefType = - '&' Lifetime? 'mut'? Type - -ArrayType = - '[' Type ';' Expr ']' - -SliceType = - '[' Type ']' - -InferType = - '_' - -FnPtrType = - 'const'? 'async'? 'unsafe'? Abi? 'fn' ParamList RetType? - -ForType = - 'for' GenericParamList Type - -ImplTraitType = - 'impl' TypeBoundList - -DynTraitType = - 'dyn' TypeBoundList - -TypeBoundList = - bounds:(TypeBound ('+' TypeBound)* '+'?) - -TypeBound = - Lifetime -| ('?' | '~' 'const')? Type - -//************************// -// Patterns // -//************************// - -Pat = - IdentPat -| BoxPat -| RestPat -| LiteralPat -| MacroPat -| OrPat -| ParenPat -| PathPat -| WildcardPat -| RangePat -| RecordPat -| RefPat -| SlicePat -| TuplePat -| TupleStructPat -| ConstBlockPat - -LiteralPat = - Literal - -IdentPat = - Attr* 'ref'? 'mut'? Name ('@' Pat)? - -WildcardPat = - '_' - -RangePat = - // 1.. - start:Pat op:('..' | '..=') - // 1..2 - | start:Pat op:('..' | '..=') end:Pat - // ..2 - | op:('..' | '..=') end:Pat - -RefPat = - '&' 'mut'? Pat - -RecordPat = - Path RecordPatFieldList - -RecordPatFieldList = - '{' - fields:(RecordPatField (',' RecordPatField)* ','?)? - RestPat? - '}' - -RecordPatField = - Attr* (NameRef ':')? Pat - -TupleStructPat = - Path '(' fields:(Pat (',' Pat)* ','?)? ')' - -TuplePat = - '(' fields:(Pat (',' Pat)* ','?)? ')' - -ParenPat = - '(' Pat ')' - -SlicePat = - '[' (Pat (',' Pat)* ','?)? ']' - -PathPat = - Path - -OrPat = - (Pat ('|' Pat)* '|'?) - -BoxPat = - 'box' Pat - -RestPat = - Attr* '..' - -MacroPat = - MacroCall - -ConstBlockPat = - 'const' BlockExpr diff --git a/src/tools/rust-analyzer/lib/ungrammar/src/lib.rs b/src/tools/rust-analyzer/lib/ungrammar/src/lib.rs index 6adf8ef8ea6a..e31b0c2f470a 100644 --- a/src/tools/rust-analyzer/lib/ungrammar/src/lib.rs +++ b/src/tools/rust-analyzer/lib/ungrammar/src/lib.rs @@ -19,12 +19,6 @@ use std::{ops, str::FromStr}; pub use error::{Error, Result}; -/// Returns a Rust grammar. -pub fn rust_grammar() -> Grammar { - let src = include_str!("../rust.ungram"); - src.parse().unwrap() -} - /// A node, like `A = 'b' | 'c'`. /// /// Indexing into a [`Grammar`] with a [`Node`] returns a reference to a @@ -130,8 +124,3 @@ fn smoke() { let grammar = grammar.parse::().unwrap(); drop(grammar) } - -#[test] -fn test_rust_grammar() { - let _ = rust_grammar(); -} From ca398e04feecfa2e84dc276c2d602035e65724b8 Mon Sep 17 00:00:00 2001 From: sayantn Date: Wed, 17 Dec 2025 01:41:29 +0530 Subject: [PATCH 206/489] panic if cpuid is called with SGX --- library/stdarch/crates/core_arch/src/x86/cpuid.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/stdarch/crates/core_arch/src/x86/cpuid.rs b/library/stdarch/crates/core_arch/src/x86/cpuid.rs index 84dcf75492b3..b35699bd7ab2 100644 --- a/library/stdarch/crates/core_arch/src/x86/cpuid.rs +++ b/library/stdarch/crates/core_arch/src/x86/cpuid.rs @@ -59,6 +59,10 @@ pub struct CpuidResult { #[cfg_attr(test, assert_instr(cpuid))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult { + if cfg!(target_env = "sgx") { + panic!("`__cpuid` cannot be used in SGX"); + } + let eax; let ebx; let ecx; From 96423581b2c5d792f25d5c6aab72c9d40d50980e Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Mon, 1 Dec 2025 22:08:08 +0000 Subject: [PATCH 207/489] Make `empty_enum_variants_with_brackets` to support empty variant with braces --- clippy_lints/src/empty_with_brackets.rs | 174 +++++++++--------- .../empty_enum_variants_with_brackets.fixed | 46 +++++ tests/ui/empty_enum_variants_with_brackets.rs | 46 +++++ .../empty_enum_variants_with_brackets.stderr | 33 +++- 4 files changed, 214 insertions(+), 85 deletions(-) diff --git a/clippy_lints/src/empty_with_brackets.rs b/clippy_lints/src/empty_with_brackets.rs index 5dc1bb96266a..7e335d5c9809 100644 --- a/clippy_lints/src/empty_with_brackets.rs +++ b/clippy_lints/src/empty_with_brackets.rs @@ -1,6 +1,8 @@ use clippy_utils::attrs::span_contains_cfg; use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; -use rustc_data_structures::fx::FxIndexMap; +use clippy_utils::source::SpanRangeExt; +use clippy_utils::span_contains_non_whitespace; +use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; use rustc_errors::Applicability; use rustc_hir::def::DefKind::Ctor; use rustc_hir::def::Res::Def; @@ -10,7 +12,7 @@ use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node, Pat, PatKind, Path, QPath, use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::impl_lint_pass; -use rustc_span::Span; +use rustc_span::{BytePos, Span}; declare_clippy_lint! { /// ### What it does @@ -118,7 +120,6 @@ impl LateLintPass<'_> for EmptyWithBrackets { } fn check_variant(&mut self, cx: &LateContext<'_>, variant: &Variant<'_>) { - // FIXME: handle `$name {}` if !variant.span.from_expansion() && !variant.ident.span.from_expansion() && let span_after_ident = variant.span.with_lo(variant.ident.span.hi()) @@ -126,44 +127,14 @@ impl LateLintPass<'_> for EmptyWithBrackets { { match variant.data { VariantData::Struct { .. } => { - // Empty struct variants can be linted immediately - span_lint_and_then( - cx, - EMPTY_ENUM_VARIANTS_WITH_BRACKETS, - span_after_ident, - "enum variant has empty brackets", - |diagnostic| { - diagnostic.span_suggestion_hidden( - span_after_ident, - "remove the brackets", - "", - Applicability::MaybeIncorrect, - ); - }, - ); + self.add_enum_variant(variant.def_id); }, VariantData::Tuple(.., local_def_id) => { // Don't lint reachable tuple enums if cx.effective_visibilities.is_reachable(variant.def_id) { return; } - if let Some(entry) = self.empty_tuple_enum_variants.get_mut(&local_def_id) { - // empty_tuple_enum_variants contains Usage::NoDefinition if the variant was called before the - // definition was encountered. Now that there's a definition, convert it - // to Usage::Unused. - if let Usage::NoDefinition { redundant_use_sites } = entry { - *entry = Usage::Unused { - redundant_use_sites: redundant_use_sites.clone(), - }; - } - } else { - self.empty_tuple_enum_variants.insert( - local_def_id, - Usage::Unused { - redundant_use_sites: vec![], - }, - ); - } + self.add_enum_variant(local_def_id); }, VariantData::Unit(..) => {}, } @@ -171,45 +142,58 @@ impl LateLintPass<'_> for EmptyWithBrackets { } fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { - if let Some(def_id) = check_expr_for_enum_as_function(expr) { - if let Some(parentheses_span) = call_parentheses_span(cx.tcx, expr) { + if let Some((def_id, mut span)) = check_expr_for_enum_as_function(cx, expr) { + if span.is_empty() + && let Some(parentheses_span) = call_parentheses_span(cx.tcx, expr) + { + span = parentheses_span; + } + + if span.is_empty() { + // The parentheses are not redundant. + self.empty_tuple_enum_variants.insert(def_id, Usage::Used); + } else { // Do not count expressions from macro expansion as a redundant use site. if expr.span.from_expansion() { return; } - self.update_enum_variant_usage(def_id, parentheses_span); - } else { - // The parentheses are not redundant. - self.empty_tuple_enum_variants.insert(def_id, Usage::Used); + self.update_enum_variant_usage(def_id, span); } } } fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { - if let Some((def_id, parentheses_span)) = check_pat_for_enum_as_function(cx, pat) { - if pat.span.from_expansion() { - return; - } - - self.update_enum_variant_usage(def_id, parentheses_span); + if !pat.span.from_expansion() + && let Some((def_id, span)) = check_pat_for_enum_as_function(cx, pat) + { + self.update_enum_variant_usage(def_id, span); } } fn check_crate_post(&mut self, cx: &LateContext<'_>) { - for (local_def_id, usage) in &self.empty_tuple_enum_variants { + for (&local_def_id, usage) in &self.empty_tuple_enum_variants { // Ignore all variants with Usage::Used or Usage::NoDefinition let Usage::Unused { redundant_use_sites } = usage else { continue; }; + // Attempt to fetch the Variant from LocalDefId. - let Node::Variant(variant) = cx.tcx.hir_node( - cx.tcx - .local_def_id_to_hir_id(cx.tcx.parent(local_def_id.to_def_id()).expect_local()), - ) else { + let variant = if let Node::Variant(variant) = cx.tcx.hir_node_by_def_id(local_def_id) { + variant + } else if let Node::Variant(variant) = cx.tcx.hir_node_by_def_id(cx.tcx.local_parent(local_def_id)) { + variant + } else { continue; }; + // Span of the parentheses in variant definition let span = variant.span.with_lo(variant.ident.span.hi()); + let span_inner = span + .with_lo(SpanRangeExt::trim_start(span, cx).start + BytePos(1)) + .with_hi(span.hi() - BytePos(1)); + if span_contains_non_whitespace(cx, span_inner, false) { + continue; + } span_lint_hir_and_then( cx, EMPTY_ENUM_VARIANTS_WITH_BRACKETS, @@ -242,28 +226,38 @@ impl LateLintPass<'_> for EmptyWithBrackets { } impl EmptyWithBrackets { - fn update_enum_variant_usage(&mut self, def_id: LocalDefId, parentheses_span: Span) { - match self.empty_tuple_enum_variants.get_mut(&def_id) { - Some( - &mut (Usage::Unused { - ref mut redundant_use_sites, + fn add_enum_variant(&mut self, local_def_id: LocalDefId) { + self.empty_tuple_enum_variants + .entry(local_def_id) + .and_modify(|entry| { + // empty_tuple_enum_variants contains Usage::NoDefinition if the variant was called before + // the definition was encountered. Now that there's a + // definition, convert it to Usage::Unused. + if let Usage::NoDefinition { redundant_use_sites } = entry { + *entry = Usage::Unused { + redundant_use_sites: redundant_use_sites.clone(), + }; + } + }) + .or_insert_with(|| Usage::Unused { + redundant_use_sites: vec![], + }); + } + + fn update_enum_variant_usage(&mut self, def_id: LocalDefId, parentheses_span: Span) { + match self.empty_tuple_enum_variants.entry(def_id) { + IndexEntry::Occupied(mut e) => { + if let Usage::Unused { redundant_use_sites } | Usage::NoDefinition { redundant_use_sites } = e.get_mut() + { + redundant_use_sites.push(parentheses_span); } - | Usage::NoDefinition { - ref mut redundant_use_sites, - }), - ) => { - redundant_use_sites.push(parentheses_span); }, - None => { + IndexEntry::Vacant(e) => { // The variant isn't in the IndexMap which means its definition wasn't encountered yet. - self.empty_tuple_enum_variants.insert( - def_id, - Usage::NoDefinition { - redundant_use_sites: vec![parentheses_span], - }, - ); + e.insert(Usage::NoDefinition { + redundant_use_sites: vec![parentheses_span], + }); }, - _ => {}, } } } @@ -293,18 +287,27 @@ fn call_parentheses_span(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> Option { } // Returns the LocalDefId of the variant being called as a function if it exists. -fn check_expr_for_enum_as_function(expr: &Expr<'_>) -> Option { - if let ExprKind::Path(QPath::Resolved( - _, - Path { - res: Def(Ctor(CtorOf::Variant, _), def_id), - .. +fn check_expr_for_enum_as_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<(LocalDefId, Span)> { + match expr.kind { + ExprKind::Path(QPath::Resolved( + _, + Path { + res: Def(Ctor(CtorOf::Variant, _), def_id), + span, + .. + }, + )) => def_id.as_local().map(|id| (id, span.with_lo(expr.span.hi()))), + ExprKind::Struct(qpath, ..) + if let Def(DefKind::Variant, mut def_id) = cx.typeck_results().qpath_res(qpath, expr.hir_id) => + { + let ty = cx.tcx.type_of(def_id).instantiate_identity(); + if let ty::FnDef(ctor_def_id, _) = ty.kind() { + def_id = *ctor_def_id; + } + + def_id.as_local().map(|id| (id, qpath.span().with_lo(expr.span.hi()))) }, - )) = expr.kind - { - def_id.as_local() - } else { - None + _ => None, } } @@ -316,10 +319,13 @@ fn check_pat_for_enum_as_function(cx: &LateContext<'_>, pat: &Pat<'_>) -> Option def_id.as_local().map(|id| (id, qpath.span().with_lo(pat.span.hi()))) }, PatKind::Struct(qpath, ..) - if let Def(DefKind::Variant, def_id) = cx.typeck_results().qpath_res(&qpath, pat.hir_id) - && let ty = cx.tcx.type_of(def_id).instantiate_identity() - && let ty::FnDef(def_id, _) = ty.kind() => + if let Def(DefKind::Variant, mut def_id) = cx.typeck_results().qpath_res(&qpath, pat.hir_id) => { + let ty = cx.tcx.type_of(def_id).instantiate_identity(); + if let ty::FnDef(ctor_def_id, _) = ty.kind() { + def_id = *ctor_def_id; + } + def_id.as_local().map(|id| (id, qpath.span().with_lo(pat.span.hi()))) }, _ => None, diff --git a/tests/ui/empty_enum_variants_with_brackets.fixed b/tests/ui/empty_enum_variants_with_brackets.fixed index 515d5a975944..caf34eaefab9 100644 --- a/tests/ui/empty_enum_variants_with_brackets.fixed +++ b/tests/ui/empty_enum_variants_with_brackets.fixed @@ -115,4 +115,50 @@ fn issue16157() { ::V = E::V; } +fn variant_with_braces() { + enum E { + V, + //~^ empty_enum_variants_with_brackets + } + E::V = E::V; + E::V = E::V; + ::V = ::V; + + enum F { + U, + //~^ empty_enum_variants_with_brackets + } + F::U = F::U; + ::U = F::U; +} + +fn variant_with_comments_and_cfg() { + enum E { + V( + // This is a comment + ), + } + E::V() = E::V(); + + enum F { + U { + // This is a comment + }, + } + F::U {} = F::U {}; + + enum G { + V(#[cfg(target_os = "cuda")] String), + } + G::V() = G::V(); + + enum H { + U { + #[cfg(target_os = "cuda")] + value: String, + }, + } + H::U {} = H::U {}; +} + fn main() {} diff --git a/tests/ui/empty_enum_variants_with_brackets.rs b/tests/ui/empty_enum_variants_with_brackets.rs index 2c29fc505d3b..f7ab062edd1e 100644 --- a/tests/ui/empty_enum_variants_with_brackets.rs +++ b/tests/ui/empty_enum_variants_with_brackets.rs @@ -115,4 +115,50 @@ fn issue16157() { ::V {} = E::V(); } +fn variant_with_braces() { + enum E { + V(), + //~^ empty_enum_variants_with_brackets + } + E::V() = E::V(); + E::V() = E::V {}; + ::V {} = ::V {}; + + enum F { + U {}, + //~^ empty_enum_variants_with_brackets + } + F::U {} = F::U {}; + ::U {} = F::U {}; +} + +fn variant_with_comments_and_cfg() { + enum E { + V( + // This is a comment + ), + } + E::V() = E::V(); + + enum F { + U { + // This is a comment + }, + } + F::U {} = F::U {}; + + enum G { + V(#[cfg(target_os = "cuda")] String), + } + G::V() = G::V(); + + enum H { + U { + #[cfg(target_os = "cuda")] + value: String, + }, + } + H::U {} = H::U {}; +} + fn main() {} diff --git a/tests/ui/empty_enum_variants_with_brackets.stderr b/tests/ui/empty_enum_variants_with_brackets.stderr index c487cebd21ac..d50b07036a94 100644 --- a/tests/ui/empty_enum_variants_with_brackets.stderr +++ b/tests/ui/empty_enum_variants_with_brackets.stderr @@ -96,5 +96,36 @@ LL ~ ::V = E::V; LL ~ ::V = E::V; | -error: aborting due to 9 previous errors +error: enum variant has empty brackets + --> tests/ui/empty_enum_variants_with_brackets.rs:120:10 + | +LL | V(), + | ^^ + | +help: remove the brackets + | +LL ~ V, +LL | +LL | } +LL ~ E::V = E::V; +LL ~ E::V = E::V; +LL ~ ::V = ::V; + | + +error: enum variant has empty brackets + --> tests/ui/empty_enum_variants_with_brackets.rs:128:10 + | +LL | U {}, + | ^^^ + | +help: remove the brackets + | +LL ~ U, +LL | +LL | } +LL ~ F::U = F::U; +LL ~ ::U = F::U; + | + +error: aborting due to 11 previous errors From 793d990d11fa7bf38677d27c88eccea6e360a783 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 16 Dec 2025 21:33:28 +0100 Subject: [PATCH 208/489] Emit a proper error if we fail to find libEnzyme --- compiler/rustc_codegen_llvm/messages.ftl | 3 ++- compiler/rustc_codegen_llvm/src/errors.rs | 5 +++++ compiler/rustc_codegen_llvm/src/lib.rs | 5 ++++- .../rustc_codegen_llvm/src/llvm/enzyme_ffi.rs | 18 ++++++++---------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_llvm/messages.ftl b/compiler/rustc_codegen_llvm/messages.ftl index 0e7b00d0bcb7..b3ef9840f5dc 100644 --- a/compiler/rustc_codegen_llvm/messages.ftl +++ b/compiler/rustc_codegen_llvm/messages.ftl @@ -1,9 +1,10 @@ +codegen_llvm_autodiff_component_unavailable = failed to load our autodiff backend. Did you install it via rustup? + codegen_llvm_autodiff_without_enable = using the autodiff feature requires -Z autodiff=Enable codegen_llvm_autodiff_without_lto = using the autodiff feature requires setting `lto="fat"` in your Cargo.toml codegen_llvm_copy_bitcode = failed to copy bitcode to object file: {$err} - codegen_llvm_fixed_x18_invalid_arch = the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture codegen_llvm_from_llvm_diag = {$message} diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index dd9fde0b08c6..f2e147b1ee0a 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -32,6 +32,11 @@ impl Diagnostic<'_, G> for ParseTargetMachineConfig<'_> { } } +#[cfg(feature = "llvm_enzyme")] +#[derive(Diagnostic)] +#[diag(codegen_llvm_autodiff_component_unavailable)] +pub(crate) struct AutoDiffComponentUnavailable; + #[derive(Diagnostic)] #[diag(codegen_llvm_autodiff_without_lto)] pub(crate) struct AutoDiffWithoutLto; diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index c51b334d95e1..4d0f8dbb9302 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -13,6 +13,7 @@ #![feature(impl_trait_in_assoc_type)] #![feature(iter_intersperse)] #![feature(macro_derive)] +#![feature(once_cell_try)] #![feature(trim_prefix_suffix)] #![feature(try_blocks)] // tidy-alphabetical-end @@ -247,7 +248,9 @@ impl CodegenBackend for LlvmCodegenBackend { use crate::back::lto::enable_autodiff_settings; if sess.opts.unstable_opts.autodiff.contains(&AutoDiff::Enable) { - drop(llvm::EnzymeWrapper::get_or_init(&sess.opts.sysroot)); + if let Err(_) = llvm::EnzymeWrapper::get_or_init(&sess.opts.sysroot) { + sess.dcx().emit_fatal(crate::errors::AutoDiffComponentUnavailable); + } enable_autodiff_settings(&sess.opts.unstable_opts.autodiff); } } diff --git a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs index 28923bf2743e..956a4e43a7de 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs @@ -199,15 +199,13 @@ pub(crate) mod Enzyme_AD { /// Safe to call multiple times - subsequent calls are no-ops due to OnceLock. pub(crate) fn get_or_init( sysroot: &rustc_session::config::Sysroot, - ) -> MutexGuard<'static, Self> { - ENZYME_INSTANCE - .get_or_init(|| { - Self::call_dynamic(sysroot) - .unwrap_or_else(|e| bug!("failed to load Enzyme: {e}")) - .into() - }) - .lock() - .unwrap() + ) -> Result, Box> { + let mtx: &'static Mutex = ENZYME_INSTANCE.get_or_try_init(|| { + let w = Self::call_dynamic(sysroot)?; + Ok::<_, Box>(Mutex::new(w)) + })?; + + Ok(mtx.lock().unwrap()) } /// Get the EnzymeWrapper instance. Panics if not initialized. @@ -475,7 +473,7 @@ pub(crate) mod Fallback_AD { impl EnzymeWrapper { pub(crate) fn get_or_init( _sysroot: &rustc_session::config::Sysroot, - ) -> MutexGuard<'static, Self> { + ) -> Result, Box> { unimplemented!("Enzyme not available: build with llvm_enzyme feature") } From 6847bd0facd27b6a3a2d81eb457d1afb33352539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 16 Dec 2025 20:38:23 +0100 Subject: [PATCH 209/489] Revert 147888 --- src/bootstrap/src/core/config/toml/llvm.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/config/toml/llvm.rs b/src/bootstrap/src/core/config/toml/llvm.rs index 9523f8021484..9751837a8879 100644 --- a/src/bootstrap/src/core/config/toml/llvm.rs +++ b/src/bootstrap/src/core/config/toml/llvm.rs @@ -117,7 +117,7 @@ pub fn check_incompatible_options_for_ci_llvm( enable_warnings, download_ci_llvm: _, build_config, - enzyme: _, + enzyme, } = ci_llvm_config; err!(current_llvm_config.optimize, optimize); @@ -139,6 +139,7 @@ pub fn check_incompatible_options_for_ci_llvm( err!(current_llvm_config.clang, clang); err!(current_llvm_config.build_config, build_config); err!(current_llvm_config.plugins, plugins); + err!(current_llvm_config.enzyme, enzyme); warn!(current_llvm_config.enable_warnings, enable_warnings); From 7463b150441f8a43f59b284a42af4ce6cffe6a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 16 Dec 2025 20:40:29 +0100 Subject: [PATCH 210/489] Print warning if LLVM CMake directory does not exist --- src/bootstrap/src/core/build_steps/llvm.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index db2a76c4a2df..51a791daef28 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -925,7 +925,7 @@ impl Step for Enzyme { } let target = self.target; - let LlvmResult { host_llvm_config, .. } = builder.ensure(Llvm { target: self.target }); + let LlvmResult { host_llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target }); static STAMP_HASH_MEMO: OnceLock = OnceLock::new(); let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| { @@ -955,15 +955,20 @@ impl Step for Enzyme { return out_dir; } + if !builder.config.dry_run() && !llvm_cmake_dir.is_dir() { + builder.info(&format!( + "WARNING: {} does not exist, Enzyme build will likely fail", + llvm_cmake_dir.display() + )); + } + trace!(?target, "(re)building enzyme artifacts"); builder.info(&format!("Building Enzyme for {target}")); t!(stamp.remove()); let _time = helpers::timeit(builder); t!(fs::create_dir_all(&out_dir)); - builder - .config - .update_submodule(Path::new("src").join("tools").join("enzyme").to_str().unwrap()); + builder.config.update_submodule("src/tools/enzyme"); let mut cfg = cmake::Config::new(builder.src.join("src/tools/enzyme/enzyme/")); configure_cmake(builder, target, &mut cfg, true, LdFlags::default(), &[]); @@ -983,7 +988,7 @@ impl Step for Enzyme { .define("LLVM_ENABLE_ASSERTIONS", "ON") .define("ENZYME_EXTERNAL_SHARED_LIB", "ON") .define("ENZYME_BC_LOADER", "OFF") - .define("LLVM_DIR", builder.llvm_out(target)); + .define("LLVM_DIR", llvm_cmake_dir); cfg.build(); From fc0d01b3a950d6a946f8f6a91732bf86fcb28623 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 16 Dec 2025 11:40:33 +0000 Subject: [PATCH 211/489] make the check calls fewer times --- compiler/rustc_mir_build/src/builder/mod.rs | 38 +++++++++------------ 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 14a24265a8f4..40f1fe0d5d11 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -838,26 +838,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.parent_module, self.infcx.typing_env(self.param_env), ); - - // check if the function's return type is inhabited - // this was added here because of this regression - // https://github.com/rust-lang/rust/issues/149571 - let output_is_inhabited = - if matches!(self.tcx.def_kind(self.def_id), DefKind::Fn | DefKind::AssocFn) { - self.tcx - .fn_sig(self.def_id) - .instantiate_identity() - .skip_binder() - .output() - .is_inhabited_from( - self.tcx, - self.parent_module, - self.infcx.typing_env(self.param_env), - ) - } else { - true - }; - if !ty_is_inhabited { // Unreachable code warnings are already emitted during type checking. // However, during type checking, full type information is being @@ -868,7 +848,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // uninhabited types (e.g. empty enums). The check above is used so // that we do not emit the same warning twice if the uninhabited type // is indeed `!`. - if !ty.is_never() && output_is_inhabited { + if !ty.is_never() + && matches!(self.tcx.def_kind(self.def_id), DefKind::Fn | DefKind::AssocFn) + // check if the function's return type is inhabited + // this was added here because of this regression + // https://github.com/rust-lang/rust/issues/149571 + && self + .tcx + .fn_sig(self.def_id) + .instantiate_identity() + .skip_binder() + .output() + .is_inhabited_from( + self.tcx, + self.parent_module, + self.infcx.typing_env(self.param_env), + ) + { lints.push((target_bb, ty, term.source_info.span)); } From 52bcaabdb865063439395db3bdc08cf29693a071 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Tue, 16 Dec 2025 22:06:29 +0100 Subject: [PATCH 212/489] Port `#[no_link]` to use attribute parser --- .../rustc_attr_parsing/src/attributes/mod.rs | 1 + .../src/attributes/no_link.rs | 14 ++ compiler/rustc_attr_parsing/src/context.rs | 2 + .../rustc_hir/src/attrs/data_structures.rs | 3 + .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_passes/messages.ftl | 9 - compiler/rustc_passes/src/check_attr.rs | 28 +-- compiler/rustc_passes/src/errors.rs | 15 -- tests/ui/attributes/malformed-attrs.stderr | 17 +- ...sue-43106-gating-of-builtin-attrs-error.rs | 22 +-- ...43106-gating-of-builtin-attrs-error.stderr | 176 +++++++++--------- .../lint/unused/unused-attr-duplicate.stderr | 24 +-- 12 files changed, 141 insertions(+), 171 deletions(-) create mode 100644 compiler/rustc_attr_parsing/src/attributes/no_link.rs diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index 64f29a4729c3..f7290bd7e6f2 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -47,6 +47,7 @@ pub(crate) mod loop_match; pub(crate) mod macro_attrs; pub(crate) mod must_use; pub(crate) mod no_implicit_prelude; +pub(crate) mod no_link; pub(crate) mod non_exhaustive; pub(crate) mod path; pub(crate) mod pin_v2; diff --git a/compiler/rustc_attr_parsing/src/attributes/no_link.rs b/compiler/rustc_attr_parsing/src/attributes/no_link.rs new file mode 100644 index 000000000000..43cd1c5406e9 --- /dev/null +++ b/compiler/rustc_attr_parsing/src/attributes/no_link.rs @@ -0,0 +1,14 @@ +use super::prelude::*; + +pub(crate) struct NoLinkParser; +impl NoArgsAttributeParser for NoLinkParser { + const PATH: &[Symbol] = &[sym::no_link]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::ExternCrate), + Warn(Target::Field), + Warn(Target::Arm), + Warn(Target::MacroDef), + ]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoLink; +} diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9c7006f84024..7b60ff731bd3 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -50,6 +50,7 @@ use crate::attributes::macro_attrs::{ }; use crate::attributes::must_use::MustUseParser; use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser; +use crate::attributes::no_link::NoLinkParser; use crate::attributes::non_exhaustive::NonExhaustiveParser; use crate::attributes::path::PathParser as PathAttributeParser; use crate::attributes::pin_v2::PinV2Parser; @@ -240,6 +241,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 5f38eaf4d5f4..64192f6f457e 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -803,6 +803,9 @@ pub enum AttributeKind { /// Represents `#[no_implicit_prelude]` NoImplicitPrelude(Span), + /// Represents `#[no_link]` + NoLink, + /// Represents `#[no_mangle]` NoMangle(Span), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 90fb0497a5b2..d51aea80101a 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -70,6 +70,7 @@ impl AttributeKind { Naked(..) => No, NoCore(..) => No, NoImplicitPrelude(..) => No, + NoLink => No, NoMangle(..) => Yes, // Needed for rustdoc NoStd(..) => No, NonExhaustive(..) => Yes, // Needed for rustdoc diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 21191085253b..5f792883826c 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -240,11 +240,6 @@ passes_has_incoherent_inherent_impl = `rustc_has_incoherent_inherent_impls` attribute should be applied to types or traits .label = only adts, extern types and traits are supported -passes_ignored_attr_with_macro = - `#[{$sym}]` is ignored on struct fields, match arms and macro defs - .warn = {-passes_previously_accepted} - .note = {-passes_see_issue(issue: "80564")} - passes_ignored_derived_impls = `{$name}` has {$trait_list_len -> [one] a derived impl @@ -379,10 +374,6 @@ passes_must_not_suspend = `must_not_suspend` attribute should be applied to a struct, enum, union, or trait .label = is not a struct, enum, union, or trait -passes_no_link = - attribute should be applied to an `extern crate` item - .label = not an `extern crate` item - passes_no_main_function = `main` function not found in crate `{$crate_name}` .here_is_main = here is a function named `main` diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index e836277e9761..735cf0ee5c33 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -250,6 +250,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::LinkSection { .. } | AttributeKind::MacroUse { .. } | AttributeKind::MacroEscape( .. ) + | AttributeKind::NoLink | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) | AttributeKind::RustcScalableVector { .. } @@ -299,7 +300,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } [sym::thread_local, ..] => self.check_thread_local(attr, span, target), - [sym::no_link, ..] => self.check_no_link(hir_id, attr, span, target), [sym::rustc_no_implicit_autorefs, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } @@ -456,15 +456,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_mix_no_mangle_export(hir_id, attrs); } - fn inline_attr_str_error_with_macro_def(&self, hir_id: HirId, attr_span: Span, sym: &str) { - self.tcx.emit_node_span_lint( - UNUSED_ATTRIBUTES, - hir_id, - attr_span, - errors::IgnoredAttrWithMacro { sym }, - ); - } - fn check_eii_impl(&self, impls: &[EiiImpl], target: Target) { for EiiImpl { span, inner_span, eii_macro, impl_marked_unsafe, is_default: _ } in impls { match target { @@ -1198,23 +1189,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { ); } - /// Checks if `#[no_link]` is applied to an `extern crate`. - fn check_no_link(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) { - match target { - Target::ExternCrate => {} - // FIXME(#80564): We permit struct fields, match arms and macro defs to have an - // `#[no_link]` attribute with just a lint, because we previously - // erroneously allowed it and some crates used it accidentally, to be compatible - // with crates depending on them, we can't throw an error here. - Target::Field | Target::Arm | Target::MacroDef => { - self.inline_attr_str_error_with_macro_def(hir_id, attr.span(), "no_link"); - } - _ => { - self.dcx().emit_err(errors::NoLink { attr_span: attr.span(), span }); - } - } - } - /// Checks if `#[rustc_legacy_const_generics]` is applied to a function and has a valid argument. fn check_rustc_legacy_const_generics( &self, diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 7abd2c703aeb..ea3cef258c58 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -80,12 +80,6 @@ pub(crate) struct OuterCrateLevelAttrSuggestion { #[diag(passes_inner_crate_level_attr)] pub(crate) struct InnerCrateLevelAttr; -#[derive(LintDiagnostic)] -#[diag(passes_ignored_attr_with_macro)] -pub(crate) struct IgnoredAttrWithMacro<'a> { - pub sym: &'a str, -} - #[derive(Diagnostic)] #[diag(passes_should_be_applied_to_fn)] pub(crate) struct AttrShouldBeAppliedToFn { @@ -254,15 +248,6 @@ pub(crate) struct Link { pub span: Option, } -#[derive(Diagnostic)] -#[diag(passes_no_link)] -pub(crate) struct NoLink { - #[primary_span] - pub attr_span: Span, - #[label] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(passes_rustc_legacy_const_generics_only)] pub(crate) struct RustcLegacyConstGenericsOnly { diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 0cd88e254194..228ea12cba8b 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -147,14 +147,6 @@ error: malformed `thread_local` attribute input LL | #[thread_local()] | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` -error: malformed `no_link` attribute input - --> $DIR/malformed-attrs.rs:214:1 - | -LL | #[no_link()] - | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]` - | - = note: for more information, visit - error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type --> $DIR/malformed-attrs.rs:105:1 | @@ -626,6 +618,15 @@ LL | #[non_exhaustive = 1] | | didn't expect any arguments here | help: must be of the form: `#[non_exhaustive]` +error[E0565]: malformed `no_link` attribute input + --> $DIR/malformed-attrs.rs:214:1 + | +LL | #[no_link()] + | ^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[no_link]` + error[E0539]: malformed `macro_use` attribute input --> $DIR/malformed-attrs.rs:216:1 | diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs index 0b0dd80f0115..c819e8763ef4 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs @@ -1,4 +1,3 @@ -//~ NOTE: not an `extern crate` item // This is testing whether various builtin attributes signals an // error or warning when put in "weird" places. // @@ -29,7 +28,7 @@ //~| WARN cannot be used on crates //~| WARN previously accepted #![no_link] -//~^ ERROR: attribute should be applied to an `extern crate` item +//~^ ERROR: `#[no_link]` attribute cannot be used on crates #![export_name = "2200"] //~^ ERROR: attribute cannot be used on //~| NOTE takes precedence @@ -60,29 +59,22 @@ mod inline { } #[no_link] -//~^ ERROR attribute should be applied to an `extern crate` item +//~^ ERROR `#[no_link]` attribute cannot be used on modules mod no_link { - //~^ NOTE not an `extern crate` item - mod inner { #![no_link] } - //~^ ERROR attribute should be applied to an `extern crate` item - //~| NOTE not an `extern crate` item + //~^ ERROR `#[no_link]` attribute cannot be used on modules #[no_link] fn f() { } - //~^ ERROR attribute should be applied to an `extern crate` item - //~| NOTE not an `extern crate` item + //~^ ERROR `#[no_link]` attribute cannot be used on functions #[no_link] struct S; - //~^ ERROR attribute should be applied to an `extern crate` item - //~| NOTE not an `extern crate` item + //~^ ERROR `#[no_link]` attribute cannot be used on structs #[no_link]type T = S; - //~^ ERROR attribute should be applied to an `extern crate` item - //~| NOTE not an `extern crate` item + //~^ ERROR `#[no_link]` attribute cannot be used on type aliases #[no_link] impl S { } - //~^ ERROR attribute should be applied to an `extern crate` item - //~| NOTE not an `extern crate` item + //~^ ERROR `#[no_link]` attribute cannot be used on inherent impl blocks } #[export_name = "2200"] diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr index 013e52923811..b4086e3ed916 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr @@ -1,5 +1,5 @@ error[E0658]: use of an internal attribute - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:11:1 | LL | #![rustc_main] | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![rustc_main] = note: the `#[rustc_main]` attribute is used internally to specify test entry point function error: `#[macro_export]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:10:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:9:1 | LL | #![macro_export] | ^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | #![macro_export] = help: `#[macro_export]` can only be applied to macro defs error: `#[rustc_main]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:11:1 | LL | #![rustc_main] | ^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | #![rustc_main] = help: `#[rustc_main]` can only be applied to functions error: `#[path]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:20:1 | LL | #![path = "3800"] | ^^^^^^^^^^^^^^^^^ @@ -33,15 +33,23 @@ LL | #![path = "3800"] = help: `#[path]` can only be applied to modules error: `#[automatically_derived]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:22:1 | LL | #![automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: `#[automatically_derived]` can only be applied to trait impl blocks +error: `#[no_link]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1 + | +LL | #![no_link] + | ^^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + error: `#[export_name]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:33:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1 | LL | #![export_name = "2200"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +57,7 @@ LL | #![export_name = "2200"] = help: `#[export_name]` can be applied to functions and statics error: `#[inline]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:36:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:35:1 | LL | #![inline] | ^^^^^^^^^^ @@ -57,7 +65,7 @@ LL | #![inline] = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:38:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:37:1 | LL | #[inline] | ^^^^^^^^^ @@ -65,7 +73,7 @@ LL | #[inline] = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:43:17 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:42:17 | LL | mod inner { #![inline] } | ^^^^^^^^^^ @@ -73,7 +81,7 @@ LL | mod inner { #![inline] } = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:52:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:51:5 | LL | #[inline] struct S; | ^^^^^^^^^ @@ -81,7 +89,7 @@ LL | #[inline] struct S; = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:55:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:54:5 | LL | #[inline] type T = S; | ^^^^^^^^^ @@ -89,15 +97,63 @@ LL | #[inline] type T = S; = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:58:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:57:5 | LL | #[inline] impl S { } | ^^^^^^^^^ | = help: `#[inline]` can only be applied to functions +error: `#[no_link]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:61:1 + | +LL | #[no_link] + | ^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + +error: `#[no_link]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:64:17 + | +LL | mod inner { #![no_link] } + | ^^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + +error: `#[no_link]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:5 + | +LL | #[no_link] fn f() { } + | ^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + +error: `#[no_link]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:5 + | +LL | #[no_link] struct S; + | ^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + +error: `#[no_link]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5 + | +LL | #[no_link]type T = S; + | ^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + +error: `#[no_link]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:76:5 + | +LL | #[no_link] impl S { } + | ^^^^^^^^^^ + | + = help: `#[no_link]` can only be applied to extern crates + error: `#[export_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:88:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:1 | LL | #[export_name = "2200"] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +161,7 @@ LL | #[export_name = "2200"] = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:17 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:83:17 | LL | mod inner { #![export_name="2200"] } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +169,7 @@ LL | mod inner { #![export_name="2200"] } = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:88:5 | LL | #[export_name = "2200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +177,7 @@ LL | #[export_name = "2200"] struct S; = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:99:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:5 | LL | #[export_name = "2200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -129,7 +185,7 @@ LL | #[export_name = "2200"] type T = S; = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:102:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:94:5 | LL | #[export_name = "2200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,29 +193,15 @@ LL | #[export_name = "2200"] impl S { } = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on required trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:9 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:98:9 | LL | #[export_name = "2200"] fn foo(); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: `#[export_name]` can be applied to functions, inherent methods, provided trait methods, statics, and trait methods in impl blocks -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:62:1 - | -LL | #[no_link] - | ^^^^^^^^^^ -LL | -LL | / mod no_link { -LL | | -LL | | -LL | | mod inner { #![no_link] } -... | -LL | | } - | |_- not an `extern crate` item - error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:8 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:105:8 | LL | #[repr(C)] | ^ @@ -172,7 +214,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:8 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:129:8 | LL | #[repr(Rust)] | ^^^^ @@ -184,20 +226,14 @@ LL | | mod inner { #![repr(Rust)] } LL | | } | |_- not a struct, enum, or union -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:31:1 - | -LL | #![no_link] - | ^^^^^^^^^^^ not an `extern crate` item - warning: `#[no_mangle]` attribute may not be used in combination with `#[export_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:24:1 | LL | #![no_mangle] | ^^^^^^^^^^^^^ `#[no_mangle]` is ignored | note: `#[export_name]` takes precedence - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:33:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1 | LL | #![export_name = "2200"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -208,7 +244,7 @@ LL - #![no_mangle] | error: `repr` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:16:1 | LL | #![repr()] | ^^^^^^^^^^ @@ -222,86 +258,56 @@ LL - #![repr()] LL + #[repr()] | -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:17 - | -LL | mod inner { #![no_link] } - | ------------^^^^^^^^^^^-- not an `extern crate` item - -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:71:5 - | -LL | #[no_link] fn f() { } - | ^^^^^^^^^^ ---------- not an `extern crate` item - -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:75:5 - | -LL | #[no_link] struct S; - | ^^^^^^^^^^ --------- not an `extern crate` item - -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:79:5 - | -LL | #[no_link]type T = S; - | ^^^^^^^^^^----------- not an `extern crate` item - -error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:83:5 - | -LL | #[no_link] impl S { } - | ^^^^^^^^^^ ---------- not an `extern crate` item - error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:117:25 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:25 | LL | mod inner { #![repr(C)] } | --------------------^---- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:121:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:12 | LL | #[repr(C)] fn f() { } | ^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:127:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:12 | LL | #[repr(C)] type T = S; | ^ ----------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:12 | LL | #[repr(C)] impl S { } | ^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:25 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:25 | LL | mod inner { #![repr(Rust)] } | --------------------^^^^---- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:145:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:12 | LL | #[repr(Rust)] fn f() { } | ^^^^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:151:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:143:12 | LL | #[repr(Rust)] type T = S; | ^^^^ ----------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:155:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:12 | LL | #[repr(Rust)] impl S { } | ^^^^ ---------- not a struct, enum, or union error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:45:5 | LL | #[inline = "2100"] fn f() { } | ^^^^^^^^^^^^^^^^^^ @@ -311,7 +317,7 @@ LL | #[inline = "2100"] fn f() { } = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:16:1 | LL | #![repr()] | ^^^^^^^^^^ help: remove this attribute @@ -319,7 +325,7 @@ LL | #![repr()] = note: using `repr` with an empty list has no effect warning: `#[no_mangle]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:24:1 | LL | #![no_mangle] | ^^^^^^^^^^^^^ @@ -333,7 +339,7 @@ Some errors have detailed explanations: E0517, E0658. For more information about an error, try `rustc --explain E0517`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:45:5 | LL | #[inline = "2100"] fn f() { } | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/unused/unused-attr-duplicate.stderr b/tests/ui/lint/unused/unused-attr-duplicate.stderr index 86506dba5f08..54ed351d4348 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.stderr +++ b/tests/ui/lint/unused/unused-attr-duplicate.stderr @@ -16,18 +16,6 @@ note: the lint level is defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:37:1 - | -LL | #[no_link] - | ^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:36:1 - | -LL | #[no_link] - | ^^^^^^^^^^ - error: unused attribute --> $DIR/unused-attr-duplicate.rs:34:1 | @@ -40,6 +28,18 @@ note: attribute also specified here LL | #![no_builtins] | ^^^^^^^^^^^^^^^ +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:37:1 + | +LL | #[no_link] + | ^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:36:1 + | +LL | #[no_link] + | ^^^^^^^^^^ + error: unused attribute --> $DIR/unused-attr-duplicate.rs:41:1 | From b09a9d006243e40b34e2597b1a4734f5b4188e8e Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Tue, 16 Dec 2025 22:45:56 +0100 Subject: [PATCH 213/489] add tests making sure to FCW warn on `field`, `arm`, and `macro def` --- ...sue-43106-gating-of-builtin-attrs-error.rs | 24 ++++++- ...43106-gating-of-builtin-attrs-error.stderr | 71 +++++++++++++------ 2 files changed, 70 insertions(+), 25 deletions(-) diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs index c819e8763ef4..1560f2b5f4a7 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs @@ -64,17 +64,35 @@ mod no_link { mod inner { #![no_link] } //~^ ERROR `#[no_link]` attribute cannot be used on modules - #[no_link] fn f() { } - //~^ ERROR `#[no_link]` attribute cannot be used on functions + #[no_link] fn f() { + //~^ ERROR `#[no_link]` attribute cannot be used on functions + match () { + #[no_link] + //~^ WARN `#[no_link]` attribute cannot be used on match arms [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + _ => () + } + } - #[no_link] struct S; + #[no_link] //~^ ERROR `#[no_link]` attribute cannot be used on structs + struct S { + #[no_link] + //~^ WARN `#[no_link]` attribute cannot be used on struct fields [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + field: () + } #[no_link]type T = S; //~^ ERROR `#[no_link]` attribute cannot be used on type aliases #[no_link] impl S { } //~^ ERROR `#[no_link]` attribute cannot be used on inherent impl blocks + + #[no_link] + //~^ WARN `#[no_link]` attribute cannot be used on macro defs + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + macro_rules! m{() => {}} } #[export_name = "2200"] diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr index b4086e3ed916..662776e58026 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr @@ -123,21 +123,21 @@ LL | mod inner { #![no_link] } error: `#[no_link]` attribute cannot be used on functions --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:5 | -LL | #[no_link] fn f() { } +LL | #[no_link] fn f() { | ^^^^^^^^^^ | = help: `#[no_link]` can only be applied to extern crates error: `#[no_link]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:77:5 | -LL | #[no_link] struct S; +LL | #[no_link] | ^^^^^^^^^^ | = help: `#[no_link]` can only be applied to extern crates error: `#[no_link]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5 | LL | #[no_link]type T = S; | ^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | #[no_link]type T = S; = help: `#[no_link]` can only be applied to extern crates error: `#[no_link]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:76:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:89:5 | LL | #[no_link] impl S { } | ^^^^^^^^^^ @@ -153,7 +153,7 @@ LL | #[no_link] impl S { } = help: `#[no_link]` can only be applied to extern crates error: `#[export_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:98:1 | LL | #[export_name = "2200"] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -161,7 +161,7 @@ LL | #[export_name = "2200"] = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:83:17 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:101:17 | LL | mod inner { #![export_name="2200"] } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL | mod inner { #![export_name="2200"] } = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:88:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:5 | LL | #[export_name = "2200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | #[export_name = "2200"] struct S; = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:5 | LL | #[export_name = "2200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -185,7 +185,7 @@ LL | #[export_name = "2200"] type T = S; = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:94:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:112:5 | LL | #[export_name = "2200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | #[export_name = "2200"] impl S { } = help: `#[export_name]` can be applied to functions and statics error: `#[export_name]` attribute cannot be used on required trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:98:9 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:116:9 | LL | #[export_name = "2200"] fn foo(); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -201,7 +201,7 @@ LL | #[export_name = "2200"] fn foo(); = help: `#[export_name]` can be applied to functions, inherent methods, provided trait methods, statics, and trait methods in impl blocks error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:105:8 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:8 | LL | #[repr(C)] | ^ @@ -214,7 +214,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:129:8 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:8 | LL | #[repr(Rust)] | ^^^^ @@ -259,49 +259,49 @@ LL + #[repr()] | error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:25 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:127:25 | LL | mod inner { #![repr(C)] } | --------------------^---- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:12 | LL | #[repr(C)] fn f() { } | ^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:12 | LL | #[repr(C)] type T = S; | ^ ----------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:123:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:12 | LL | #[repr(C)] impl S { } | ^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:25 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:151:25 | LL | mod inner { #![repr(Rust)] } | --------------------^^^^---- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:155:12 | LL | #[repr(Rust)] fn f() { } | ^^^^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:143:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:161:12 | LL | #[repr(Rust)] type T = S; | ^^^^ ----------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:165:12 | LL | #[repr(Rust)] impl S { } | ^^^^ ---------- not a struct, enum, or union @@ -316,6 +316,33 @@ LL | #[inline = "2100"] fn f() { } = note: for more information, see issue #57571 = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default +warning: `#[no_link]` attribute cannot be used on match arms + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:13 + | +LL | #[no_link] + | ^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_link]` can only be applied to extern crates + +warning: `#[no_link]` attribute cannot be used on struct fields + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:9 + | +LL | #[no_link] + | ^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_link]` can only be applied to extern crates + +warning: `#[no_link]` attribute cannot be used on macro defs + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:92:5 + | +LL | #[no_link] + | ^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_link]` can only be applied to extern crates + warning: unused attribute --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:16:1 | @@ -333,7 +360,7 @@ LL | #![no_mangle] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = help: `#[no_mangle]` can be applied to functions and statics -error: aborting due to 37 previous errors; 3 warnings emitted +error: aborting due to 37 previous errors; 6 warnings emitted Some errors have detailed explanations: E0517, E0658. For more information about an error, try `rustc --explain E0517`. From 383053e01602a1a754a170d7c201cc43fff87739 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 5 Sep 2025 15:27:17 -0400 Subject: [PATCH 214/489] Enable `outline-atomics` by default on AArch64 FreeBSD Many aarch64 targets without LSE in the baseline enable the `outline-atomics` feature, which uses runtime detection of LSE for its faster atomic ops. This provides nontrivial performance improvements on most hardware from the past decade, at a small cost to anything pre-LSE. This matches what Clang does [1]. [1]: https://github.com/llvm/llvm-project/commit/e24f90190c772b6fdd915cd0a2e55cbd468c3024 --- .../rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs index 69a65e6b0f02..47775f968400 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_freebsd.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), arch: Arch::AArch64, options: TargetOptions { - features: "+v8a".into(), + features: "+v8a,+outline-atomics".into(), max_atomic_width: Some(128), stack_probes: StackProbeType::Inline, supported_sanitizers: SanitizerSet::ADDRESS From 4ff4b255d078225d9c0244f9c4f0ade2ae5bb0d5 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 16 Dec 2025 21:05:13 -0600 Subject: [PATCH 215/489] fixup! Implement va_arg for Hexagon Linux musl targets --- compiler/rustc_codegen_llvm/src/va_arg.rs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 82cc45d161c4..163b83ee08cd 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -893,7 +893,7 @@ fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( // Calculate offset: round up type size to 4-byte boundary (minimum stack slot size) let type_size = layout.size.bytes(); - let offset = ((type_size + 3) / 4) * 4; // align to 4 bytes + let offset = type_size.next_multiple_of(4); // align to 4 bytes // Update va_list to point to next argument let next_ptr = bx.inbounds_ptradd(aligned_ptr, bx.const_usize(offset)); @@ -903,19 +903,6 @@ fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( bx.load(layout.llvm_type(bx), aligned_ptr, layout.align.abi) } -fn emit_hexagon_va_arg<'ll, 'tcx>( - bx: &mut Builder<'_, 'll, 'tcx>, - list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, - is_musl: bool, -) -> &'ll Value { - if is_musl { - emit_hexagon_va_arg_musl(bx, list, target_ty) - } else { - emit_hexagon_va_arg_bare_metal(bx, list, target_ty) - } -} - fn emit_xtensa_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, @@ -1100,7 +1087,13 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), - Arch::Hexagon => emit_hexagon_va_arg(bx, addr, target_ty, target.env == Env::Musl), + Arch::Hexagon => { + if target.env == Env::Musl { + emit_hexagon_va_arg_musl(bx, addr, target_ty) + } else { + emit_hexagon_va_arg_bare_metal(bx, addr, target_ty) + } + } // For all other architecture/OS combinations fall back to using // the LLVM va_arg instruction. // https://llvm.org/docs/LangRef.html#va-arg-instruction From 25cc98f1168f7e7c40718bb00deefb9112b71282 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Mon, 15 Dec 2025 20:35:01 -0800 Subject: [PATCH 216/489] Avoid unhelpful suggestion when crate name is invalid Pointing out they can set the crate's name is non-actionable: their problem is they found out how and set it incorrectly. Remove extraneous information that can only confuse the matter. --- compiler/rustc_session/messages.ftl | 1 - compiler/rustc_session/src/errors.rs | 2 -- compiler/rustc_session/src/output.rs | 1 - .../compile-flags/invalid/need-crate-arg-ignore-tidy$x.stderr | 2 -- 4 files changed, 6 deletions(-) diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index a4166951e350..2fdce628f0c9 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -57,7 +57,6 @@ session_int_literal_too_large = integer literal is too large .note = value exceeds limit of `{$limit}` session_invalid_character_in_crate_name = invalid character {$character} in crate name: `{$crate_name}` - .help = you can either pass `--crate-name` on the command line or add `#![crate_name = "…"]` to set the crate name session_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float literal .label = invalid suffix `{$suffix}` diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 07b41a3de714..1f2d386a23cb 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -238,8 +238,6 @@ pub(crate) struct InvalidCharacterInCrateName { pub(crate) span: Option, pub(crate) character: char, pub(crate) crate_name: Symbol, - #[help] - pub(crate) help: Option<()>, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index 99c736c3b1a5..de8f1d6009ab 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -69,7 +69,6 @@ pub fn validate_crate_name(sess: &Session, crate_name: Symbol, span: Option Date: Wed, 17 Dec 2025 07:22:03 +0000 Subject: [PATCH 217/489] Prepare for merging from rust-lang/rust This updates the rust-version file to 2dc30247c5d8293aaa31e1d7dae2ed2fde908ada. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 71a84e2bda12..7345c25066a8 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -cec70080fd441d16e9fb08a0d1d1a04c72d1ed25 +2dc30247c5d8293aaa31e1d7dae2ed2fde908ada From 8944338010db65e35273a7f2cf137558ad0f4480 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Wed, 17 Dec 2025 17:34:43 +0800 Subject: [PATCH 218/489] Fix match arm nested body invalid expected type Example --- ```rust struct Foo; enum E { X } fn foo() -> Foo { match E::X { Foo::X => { $0 } } } ``` **Before this PR** ```text ty: E, name: ? ``` **After this PR** ```text ty: Foo, name: ? ``` --- .../ide-completion/src/context/analysis.rs | 17 +++++++++++++++++ .../crates/ide-completion/src/context/tests.rs | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs index b65c68a2401e..e48c433fa4e9 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs @@ -734,6 +734,23 @@ fn expected_type_and_name<'db>( }.map(TypeInfo::original); (ty, None) }, + ast::MatchArm(it) => { + let on_arrow = previous_non_trivia_token(token.clone()).is_some_and(|it| T![=>] == it.kind()); + let in_body = it.expr().is_some_and(|it| it.syntax().text_range().contains_range(token.text_range())); + let match_expr = it.syntax().ancestors().nth(2).and_then(ast::MatchExpr::cast); + + let ty = if on_arrow || in_body { + // match foo { ..., pat => $0 } + cov_mark::hit!(expected_type_match_arm_body_without_leading_char); + cov_mark::hit!(expected_type_match_arm_body_with_leading_char); + match_expr.and_then(|it| sema.type_of_expr(&it.into())) + } else { + // match foo { $0 } + cov_mark::hit!(expected_type_match_arm_without_leading_char); + match_expr.and_then(|it| it.expr()).and_then(|e| sema.type_of_expr(&e)) + }.map(TypeInfo::original); + (ty, None) + }, ast::IfExpr(it) => { let ty = if let Some(body) = it.then_branch() && token.text_range().end() > body.syntax().text_range().start() diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs index b929d36ce687..09a9b6f112f0 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs @@ -256,6 +256,22 @@ fn foo() -> Foo { ); } +#[test] +fn expected_type_match_arm_block_body_without_leading_char() { + cov_mark::check!(expected_type_match_arm_body_without_leading_char); + cov_mark::check!(expected_type_match_arm_body_with_leading_char); + check_expected_type_and_name( + r#" +struct Foo; +enum E { X } +fn foo() -> Foo { + match E::X { Foo::X => { $0 } } +} +"#, + expect![[r#"ty: Foo, name: ?"#]], + ); +} + #[test] fn expected_type_match_body_arm_with_leading_char() { cov_mark::check!(expected_type_match_arm_body_with_leading_char); From 677b4be526a214400879b2c50d7da6e838a71fc3 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Wed, 17 Dec 2025 17:53:52 +0800 Subject: [PATCH 219/489] Fix applicable on non naked if for move_guard assist Example --- ```rust fn main() { match 92 { _ => { let cond = true; $0if cond { foo() } }, _ => true } } ``` **Before this PR** ```rust fn main() { match 92 { _ if cond => foo(), _ => true } } ``` **After this PR** Assist not applicable --- .../ide-assists/src/handlers/move_guard.rs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/move_guard.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/move_guard.rs index 6b50718424c7..8daf86923d92 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/move_guard.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/move_guard.rs @@ -108,6 +108,10 @@ pub(crate) fn move_arm_cond_to_match_guard( let mut replace_node = None; let if_expr: IfExpr = IfExpr::cast(arm_body.syntax().clone()).or_else(|| { let block_expr = BlockExpr::cast(arm_body.syntax().clone())?; + if block_expr.statements().next().is_some() { + cov_mark::hit!(move_guard_non_naked_if); + return None; + } if let Expr::IfExpr(e) = block_expr.tail_expr()? { replace_node = Some(block_expr.syntax().clone()); Some(e) @@ -238,6 +242,46 @@ fn main() { "#, ); } + + #[test] + fn move_non_naked_arm_cond_to_guard() { + cov_mark::check!(move_guard_non_naked_if); + check_assist_not_applicable( + move_arm_cond_to_match_guard, + r#" +fn main() { + match 92 { + _ => { + let cond = true; + $0if cond { + foo() + } + }, + _ => true + } +} +"#, + ); + check_assist_not_applicable( + move_arm_cond_to_match_guard, + r#" +fn main() { + match 92 { + _ => { + let cond = true; + $0if cond { + foo() + } else { + bar() + } + }, + _ => true + } +} +"#, + ); + } + #[test] fn move_guard_to_arm_body_target() { check_assist_target( From 60b616d3382b15b07c16db48edf5993254b7fc4d Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 17 Dec 2025 11:20:44 +0100 Subject: [PATCH 220/489] tests/run-make-cargo/same-crate-name-and-macro-name: New regression test --- .../consumer/Cargo.toml | 10 ++++++++++ .../consumer/src/main.rs | 7 +++++++ .../mylib_v1/Cargo.toml | 6 ++++++ .../mylib_v1/src/lib.rs | 6 ++++++ .../mylib_v2/Cargo.toml | 6 ++++++ .../mylib_v2/src/lib.rs | 6 ++++++ .../same-crate-name-and-macro-name/rmake.rs | 13 +++++++++++++ 7 files changed, 54 insertions(+) create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/consumer/Cargo.toml create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/consumer/src/main.rs create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/Cargo.toml create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/src/lib.rs create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/Cargo.toml create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/src/lib.rs create mode 100644 tests/run-make-cargo/same-crate-name-and-macro-name/rmake.rs diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/consumer/Cargo.toml b/tests/run-make-cargo/same-crate-name-and-macro-name/consumer/Cargo.toml new file mode 100644 index 000000000000..870d333da3a4 --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/consumer/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "consumer" +version = "0.1.0" + +[dependencies] +mylib_v1 = { path = "../mylib_v1", package = "mylib" } +mylib_v2 = { path = "../mylib_v2", package = "mylib" } + +# Avoid interference with root workspace when casually testing +[workspace] diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/consumer/src/main.rs b/tests/run-make-cargo/same-crate-name-and-macro-name/consumer/src/main.rs new file mode 100644 index 000000000000..80e76ae28117 --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/consumer/src/main.rs @@ -0,0 +1,7 @@ +fn main() { + let v1 = mylib_v1::my_macro!(); + assert_eq!(v1, "version 1"); + + let v2 = mylib_v2::my_macro!(); + assert_eq!(v2, "version 2"); +} diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/Cargo.toml b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/Cargo.toml new file mode 100644 index 000000000000..69f80bfc89ed --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "mylib" +version = "1.0.0" + +# Avoid interference with root workspace when casually testing +[workspace] diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/src/lib.rs b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/src/lib.rs new file mode 100644 index 000000000000..0603b754ea82 --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v1/src/lib.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! my_macro { + () => { + "version 1" + }; +} diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/Cargo.toml b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/Cargo.toml new file mode 100644 index 000000000000..f164616393ba --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "mylib" +version = "2.0.0" + +# Avoid interference with root workspace when casually testing +[workspace] diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/src/lib.rs b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/src/lib.rs new file mode 100644 index 000000000000..352c7c514f83 --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/mylib_v2/src/lib.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! my_macro { + () => { + "version 2" + }; +} diff --git a/tests/run-make-cargo/same-crate-name-and-macro-name/rmake.rs b/tests/run-make-cargo/same-crate-name-and-macro-name/rmake.rs new file mode 100644 index 000000000000..cce98cebb804 --- /dev/null +++ b/tests/run-make-cargo/same-crate-name-and-macro-name/rmake.rs @@ -0,0 +1,13 @@ +//! Regression test for +//! +//! (that particular comment describes the issue well). +//! +//! We test that two library crates with the same name can export macros with +//! the same name without causing interference when both are used in another +//! crate. + +use run_make_support::cargo; + +fn main() { + cargo().current_dir("consumer").arg("run").run(); +} From 3ca0ac033af115c53390ea9eaa98cb04b0dc54a7 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Tue, 16 Dec 2025 16:15:31 +0200 Subject: [PATCH 221/489] Upgrade Salsa The new version gives an additional `salsa::Id` to cycle handlers, and renames `non_update_return_type` to `non_update_types`. --- src/tools/rust-analyzer/Cargo.lock | 12 ++++++------ src/tools/rust-analyzer/Cargo.toml | 4 ++-- .../rust-analyzer/crates/hir-ty/src/consteval.rs | 3 +++ src/tools/rust-analyzer/crates/hir-ty/src/db.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/infer.rs | 4 ++-- .../rust-analyzer/crates/hir-ty/src/layout.rs | 1 + .../rust-analyzer/crates/hir-ty/src/layout/adt.rs | 1 + .../rust-analyzer/crates/hir-ty/src/lower.rs | 15 ++++++++++----- .../rust-analyzer/crates/hir-ty/src/mir/lower.rs | 1 + .../crates/hir-ty/src/mir/monomorphization.rs | 1 + .../crates/hir-ty/src/next_solver/consts.rs | 4 ++-- .../crates/hir-ty/src/next_solver/interner.rs | 4 ++-- .../crates/hir-ty/src/next_solver/opaques.rs | 2 +- .../crates/hir-ty/src/next_solver/predicate.rs | 4 ++-- .../crates/hir-ty/src/next_solver/region.rs | 2 +- .../crates/hir-ty/src/next_solver/ty.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/opaques.rs | 4 ++-- .../crates/hir-ty/src/specialization.rs | 1 + .../rust-analyzer/crates/hir-ty/src/variance.rs | 1 + .../crates/query-group-macro/src/queries.rs | 2 +- 20 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index efe56cb7f61c..ed13ffd4c3b3 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -2445,9 +2445,9 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "salsa" -version = "0.24.0" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27956164373aeec733ac24ff1736de8541234e3a8e7e6f916b28175b5752af3b" +checksum = "e2e2aa2fca57727371eeafc975acc8e6f4c52f8166a78035543f6ee1c74c2dcc" dependencies = [ "boxcar", "crossbeam-queue", @@ -2470,15 +2470,15 @@ dependencies = [ [[package]] name = "salsa-macro-rules" -version = "0.24.0" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ca3b9d6e47c08b5de4b218e0c5f7ec910b51bce6314e651c8e7b9d154d174da" +checksum = "1bfc2a1e7bf06964105515451d728f2422dedc3a112383324a00b191a5c397a3" [[package]] name = "salsa-macros" -version = "0.24.0" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6337b62f2968be6b8afa30017d7564ecbde6832ada47ed2261fb14d0fd402ff4" +checksum = "3d844c1aa34946da46af683b5c27ec1088a3d9d84a2b837a108223fd830220e1" dependencies = [ "proc-macro2", "quote", diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml index 6991eeec738e..3abe586db3c5 100644 --- a/src/tools/rust-analyzer/Cargo.toml +++ b/src/tools/rust-analyzer/Cargo.toml @@ -135,13 +135,13 @@ rayon = "1.10.0" rowan = "=0.15.17" # Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work # on impls without it -salsa = { version = "0.24.0", default-features = false, features = [ +salsa = { version = "0.25.2", default-features = false, features = [ "rayon", "salsa_unstable", "macros", "inventory", ] } -salsa-macros = "0.24.0" +salsa-macros = "0.25.2" semver = "1.0.26" serde = { version = "1.0.219" } serde_derive = { version = "1.0.219" } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs b/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs index 012632aa55b5..32c207b189f0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs @@ -257,6 +257,7 @@ pub(crate) fn eval_to_const<'db>(expr: ExprId, ctx: &mut InferenceContext<'_, 'd pub(crate) fn const_eval_cycle_result<'db>( _: &'db dyn HirDatabase, + _: salsa::Id, _: ConstId, _: GenericArgs<'db>, _: Option>, @@ -266,6 +267,7 @@ pub(crate) fn const_eval_cycle_result<'db>( pub(crate) fn const_eval_static_cycle_result<'db>( _: &'db dyn HirDatabase, + _: salsa::Id, _: StaticId, ) -> Result, ConstEvalError<'db>> { Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) @@ -273,6 +275,7 @@ pub(crate) fn const_eval_static_cycle_result<'db>( pub(crate) fn const_eval_discriminant_cycle_result<'db>( _: &'db dyn HirDatabase, + _: salsa::Id, _: EnumVariantId, ) -> Result> { Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/db.rs b/src/tools/rust-analyzer/crates/hir-ty/src/db.rs index f9523e7168de..47bb6675ea48 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/db.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/db.rs @@ -245,7 +245,7 @@ pub struct InternedConstParamId { pub loc: ConstParamId, } -#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)] +#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX, unsafe(non_update_types))] #[derive(PartialOrd, Ord)] pub struct InternedOpaqueTyId { pub loc: ImplTraitId<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs index 70868e4b95aa..d6682c0cf2fe 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs @@ -162,7 +162,7 @@ fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'_> ctx.resolve_all() } -fn infer_cycle_result(db: &dyn HirDatabase, _: DefWithBodyId) -> InferenceResult<'_> { +fn infer_cycle_result(db: &dyn HirDatabase, _: salsa::Id, _: DefWithBodyId) -> InferenceResult<'_> { InferenceResult { has_errors: true, ..InferenceResult::new(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)) @@ -547,7 +547,7 @@ pub struct InferenceResult<'db> { #[salsa::tracked] impl<'db> InferenceResult<'db> { - #[salsa::tracked(returns(ref), cycle_result = infer_cycle_result)] + #[salsa::tracked(returns(ref), cycle_result = infer_cycle_result, unsafe(non_update_types))] pub fn for_body(db: &'db dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'db> { infer_query(db, def) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index 4b20d6eb3220..1ed604865b00 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -359,6 +359,7 @@ pub fn layout_of_ty_query<'db>( pub(crate) fn layout_of_ty_cycle_result<'db>( _: &dyn HirDatabase, + _: salsa::Id, _: Ty<'db>, _: ParamEnvAndCrate<'db>, ) -> Result, LayoutError> { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs index cf2d0989fd9f..1e2c3aa31b8d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs @@ -97,6 +97,7 @@ pub fn layout_of_adt_query<'db>( pub(crate) fn layout_of_adt_cycle_result<'db>( _: &'db dyn HirDatabase, + _: salsa::Id, _def: AdtId, _args: GenericArgs<'db>, _trait_env: ParamEnvAndCrate<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs index dd34bbe2fd02..3f901ad69285 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs @@ -1137,7 +1137,7 @@ impl InternedOpaqueTyId { #[salsa::tracked] impl<'db> ImplTraits<'db> { - #[salsa::tracked(returns(ref), unsafe(non_update_return_type))] + #[salsa::tracked(returns(ref), unsafe(non_update_types))] pub(crate) fn return_type_impl_traits( db: &'db dyn HirDatabase, def: hir_def::FunctionId, @@ -1166,7 +1166,7 @@ impl<'db> ImplTraits<'db> { } } - #[salsa::tracked(returns(ref), unsafe(non_update_return_type))] + #[salsa::tracked(returns(ref), unsafe(non_update_types))] pub(crate) fn type_alias_impl_traits( db: &'db dyn HirDatabase, def: hir_def::TypeAliasId, @@ -1373,6 +1373,7 @@ pub(crate) fn type_for_type_alias_with_diagnostics_query<'db>( pub(crate) fn type_for_type_alias_with_diagnostics_cycle_result<'db>( db: &'db dyn HirDatabase, + _: salsa::Id, _adt: TypeAliasId, ) -> (EarlyBinder<'db, Ty<'db>>, Diagnostics) { (EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None) @@ -1406,6 +1407,7 @@ pub(crate) fn impl_self_ty_with_diagnostics_query<'db>( pub(crate) fn impl_self_ty_with_diagnostics_cycle_result( db: &dyn HirDatabase, + _: salsa::Id, _impl_id: ImplId, ) -> (EarlyBinder<'_, Ty<'_>>, Diagnostics) { (EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None) @@ -1443,6 +1445,7 @@ pub(crate) fn const_param_ty_with_diagnostics_query<'db>( pub(crate) fn const_param_ty_with_diagnostics_cycle_result<'db>( db: &'db dyn HirDatabase, + _: salsa::Id, _: crate::db::HirDatabaseData, _def: ConstParamId, ) -> (Ty<'db>, Diagnostics) { @@ -1496,7 +1499,7 @@ pub(crate) fn field_types_with_diagnostics_query<'db>( /// following bounds are disallowed: `T: Foo, U: Foo`, but /// these are fine: `T: Foo, U: Foo<()>`. #[tracing::instrument(skip(db), ret)] -#[salsa::tracked(returns(ref), unsafe(non_update_return_type), cycle_result = generic_predicates_for_param_cycle_result)] +#[salsa::tracked(returns(ref), unsafe(non_update_types), cycle_result = generic_predicates_for_param_cycle_result)] pub(crate) fn generic_predicates_for_param<'db>( db: &'db dyn HirDatabase, def: GenericDefId, @@ -1609,6 +1612,7 @@ pub(crate) fn generic_predicates_for_param<'db>( pub(crate) fn generic_predicates_for_param_cycle_result<'db>( _db: &'db dyn HirDatabase, + _: salsa::Id, _def: GenericDefId, _param_id: TypeOrConstParamId, _assoc_name: Option, @@ -1624,7 +1628,7 @@ pub(crate) fn type_alias_bounds<'db>( type_alias_bounds_with_diagnostics(db, type_alias).0.as_ref().map_bound(|it| &**it) } -#[salsa::tracked(returns(ref), unsafe(non_update_return_type))] +#[salsa::tracked(returns(ref), unsafe(non_update_types))] pub fn type_alias_bounds_with_diagnostics<'db>( db: &'db dyn HirDatabase, type_alias: TypeAliasId, @@ -1682,7 +1686,7 @@ impl<'db> GenericPredicates<'db> { /// Resolve the where clause(s) of an item with generics. /// /// Diagnostics are computed only for this item's predicates, not for parents. - #[salsa::tracked(returns(ref), unsafe(non_update_return_type))] + #[salsa::tracked(returns(ref), unsafe(non_update_types))] pub fn query_with_diagnostics( db: &'db dyn HirDatabase, def: GenericDefId, @@ -2090,6 +2094,7 @@ pub(crate) fn generic_defaults_with_diagnostics_query( pub(crate) fn generic_defaults_with_diagnostics_cycle_result( _db: &dyn HirDatabase, + _: salsa::Id, _def: GenericDefId, ) -> (GenericDefaults<'_>, Diagnostics) { (GenericDefaults(None), None) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs index 5bce4222a4fa..d7a8c18614a4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs @@ -2261,6 +2261,7 @@ pub fn mir_body_query<'db>( pub(crate) fn mir_body_cycle_result<'db>( _db: &'db dyn HirDatabase, + _: salsa::Id, _def: DefWithBodyId, ) -> Result<'db, Arc>> { Err(MirLowerError::Loop) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs index b67365c344a6..beb0003c31ca 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs @@ -223,6 +223,7 @@ pub fn monomorphized_mir_body_query<'db>( pub(crate) fn monomorphized_mir_body_cycle_result<'db>( _db: &'db dyn HirDatabase, + _: salsa::Id, _: DefWithBodyId, _: GenericArgs<'db>, _: ParamEnvAndCrate<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs index 926dbdc03d03..3a32cf8b1fef 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs @@ -23,7 +23,7 @@ use super::{BoundVarKind, DbInterner, ErrorGuaranteed, GenericArgs, Placeholder, pub type ConstKind<'db> = rustc_type_ir::ConstKind>; pub type UnevaluatedConst<'db> = rustc_type_ir::UnevaluatedConst>; -#[salsa::interned(constructor = new_)] +#[salsa::interned(constructor = new_, unsafe(non_update_types))] pub struct Const<'db> { #[returns(ref)] kind_: InternedWrapperNoDebug>>, @@ -202,7 +202,7 @@ impl Hash for ConstBytes<'_> { } } -#[salsa::interned(constructor = new_, debug)] +#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))] pub struct Valtree<'db> { #[returns(ref)] bytes_: ConstBytes<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index 8b24a20a5bed..4c34183da99c 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -202,7 +202,7 @@ macro_rules! _interned_vec_db { } }; ($name:ident, $ty:ident, nofold) => { - #[salsa::interned(constructor = new_)] + #[salsa::interned(constructor = new_, unsafe(non_update_types))] pub struct $name<'db> { #[returns(ref)] inner_: smallvec::SmallVec<[$ty<'db>; 2]>, @@ -762,7 +762,7 @@ impl std::ops::Deref for UnsizingParams { pub type PatternKind<'db> = rustc_type_ir::PatternKind>; -#[salsa::interned(constructor = new_, debug)] +#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))] pub struct Pattern<'db> { #[returns(ref)] kind_: InternedWrapperNoDebug>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs index e8f5be2eb598..4fbeb76adaad 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs @@ -15,7 +15,7 @@ pub type ExternalConstraintsData<'db> = interned_vec_nolifetime_salsa!(SolverDefIds, SolverDefId); -#[salsa::interned(constructor = new_, debug)] +#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))] pub struct ExternalConstraints<'db> { #[returns(ref)] kind_: rustc_type_ir::solve::ExternalConstraintsData>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs index 783966ee1ee1..71d9b0b55a30 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs @@ -172,7 +172,7 @@ impl<'db> rustc_type_ir::relate::Relate> for BoundExistentialPre } } -#[salsa::interned(constructor = new_)] +#[salsa::interned(constructor = new_, unsafe(non_update_types))] pub struct Predicate<'db> { #[returns(ref)] kind_: InternedWrapperNoDebug>>>, @@ -278,7 +278,7 @@ impl<'db> std::hash::Hash for InternedClausesWrapper<'db> { } } -#[salsa::interned(constructor = new_)] +#[salsa::interned(constructor = new_, unsafe(non_update_types))] pub struct Clauses<'db> { #[returns(ref)] inner_: InternedClausesWrapper<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs index 19f3c38b673d..3be715ab07d3 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs @@ -18,7 +18,7 @@ use super::{ pub type RegionKind<'db> = rustc_type_ir::RegionKind>; -#[salsa::interned(constructor = new_)] +#[salsa::interned(constructor = new_, unsafe(non_update_types))] pub struct Region<'db> { #[returns(ref)] kind_: RegionKind<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs index ff89f8e059a5..7dcb8567c2e4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs @@ -44,7 +44,7 @@ pub type SimplifiedType = rustc_type_ir::fast_reject::SimplifiedType = rustc_type_ir::TyKind>; pub type FnHeader<'db> = rustc_type_ir::FnHeader>; -#[salsa::interned(constructor = new_)] +#[salsa::interned(constructor = new_, unsafe(non_update_types))] pub struct Ty<'db> { #[returns(ref)] kind_: InternedWrapperNoDebug>>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs index 4c6b585016fa..76a6207e2338 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs @@ -89,7 +89,7 @@ pub(crate) fn opaque_types_defined_by( // These are firewall queries to prevent drawing dependencies between infers: -#[salsa::tracked(returns(ref), unsafe(non_update_return_type))] +#[salsa::tracked(returns(ref), unsafe(non_update_types))] pub(crate) fn rpit_hidden_types<'db>( db: &'db dyn HirDatabase, function: FunctionId, @@ -103,7 +103,7 @@ pub(crate) fn rpit_hidden_types<'db>( result } -#[salsa::tracked(returns(ref), unsafe(non_update_return_type))] +#[salsa::tracked(returns(ref), unsafe(non_update_types))] pub(crate) fn tait_hidden_types<'db>( db: &'db dyn HirDatabase, type_alias: TypeAliasId, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs b/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs index 9ae9a8e2a993..4164e39e6592 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs @@ -22,6 +22,7 @@ use crate::{ // cannot create a cycle, but a cycle handler is required nevertheless. fn specializes_query_cycle( _db: &dyn HirDatabase, + _: salsa::Id, _specializing_impl_def_id: ImplId, _parent_impl_def_id: ImplId, ) -> bool { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs index 5c0af6dafb52..b32180d41247 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs @@ -105,6 +105,7 @@ fn glb(v1: Variance, v2: Variance) -> Variance { pub(crate) fn variances_of_cycle_initial( db: &dyn HirDatabase, + _: salsa::Id, def: GenericDefId, ) -> VariancesOf<'_> { let interner = DbInterner::new_no_crate(db); diff --git a/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs b/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs index 7698ce5fff13..fe932ac133a0 100644 --- a/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs +++ b/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs @@ -49,7 +49,7 @@ impl ToTokens for TrackedQuery { }) .into_iter() .chain(self.lru.map(|lru| quote!(lru = #lru))) - .chain(Some(quote!(unsafe(non_update_return_type)))); + .chain(Some(quote!(unsafe(non_update_types)))); let annotation = quote!(#[salsa_macros::tracked( #(#options),* )]); let pat_and_tys = &self.pat_and_tys; From 6166f9072afb9696a52e7e05370f6cea21caa1ea Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Wed, 17 Dec 2025 13:11:23 +0200 Subject: [PATCH 222/489] Remove redundant things from the lang items macro --- .../crates/hir-def/src/lang_item.rs | 304 +++++++++--------- 1 file changed, 149 insertions(+), 155 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs b/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs index 6c8fb55d8f51..fd693477a4b4 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs @@ -154,16 +154,10 @@ pub(crate) fn crate_notable_traits(db: &dyn DefDatabase, krate: Crate) -> Option if traits.is_empty() { None } else { Some(traits.into_iter().collect()) } } -pub enum GenericRequirement { - None, - Minimum(usize), - Exact(usize), -} - macro_rules! language_item_table { ( $LangItems:ident => - $( $(#[$attr:meta])* $lang_item:ident, $module:ident :: $name:ident, $method:ident, $target:ident, $generics:expr; )* + $( $(#[$attr:meta])* $lang_item:ident, $module:ident :: $name:ident, $target:ident; )* ) => { #[allow(non_snake_case)] // FIXME: Should we remove this? #[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] @@ -226,101 +220,101 @@ macro_rules! language_item_table { } language_item_table! { LangItems => -// Variant name, Name, Getter method name, Target Generic requirements; - Sized, sym::sized, sized_trait, TraitId, GenericRequirement::Exact(0); - MetaSized, sym::meta_sized, sized_trait, TraitId, GenericRequirement::Exact(0); - PointeeSized, sym::pointee_sized, sized_trait, TraitId, GenericRequirement::Exact(0); - Unsize, sym::unsize, unsize_trait, TraitId, GenericRequirement::Minimum(1); +// Variant name, Name, Target; + Sized, sym::sized, TraitId; + MetaSized, sym::meta_sized, TraitId; + PointeeSized, sym::pointee_sized, TraitId; + Unsize, sym::unsize, TraitId; /// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ"). - StructuralPeq, sym::structural_peq, structural_peq_trait, TraitId, GenericRequirement::None; + StructuralPeq, sym::structural_peq, TraitId; /// Trait injected by `#[derive(Eq)]`, (i.e. "Total EQ"; no, I will not apologize). - StructuralTeq, sym::structural_teq, structural_teq_trait, TraitId, GenericRequirement::None; - Copy, sym::copy, copy_trait, TraitId, GenericRequirement::Exact(0); - Clone, sym::clone, clone_trait, TraitId, GenericRequirement::None; - TrivialClone, sym::trivial_clone, clone_trait, TraitId, GenericRequirement::None; - Sync, sym::sync, sync_trait, TraitId, GenericRequirement::Exact(0); - DiscriminantKind, sym::discriminant_kind, discriminant_kind_trait, TraitId, GenericRequirement::None; + StructuralTeq, sym::structural_teq, TraitId; + Copy, sym::copy, TraitId; + Clone, sym::clone, TraitId; + TrivialClone, sym::trivial_clone, TraitId; + Sync, sym::sync, TraitId; + DiscriminantKind, sym::discriminant_kind, TraitId; /// The associated item of the `DiscriminantKind` trait. - Discriminant, sym::discriminant_type, discriminant_type, TypeAliasId, GenericRequirement::None; + Discriminant, sym::discriminant_type, TypeAliasId; - PointeeTrait, sym::pointee_trait, pointee_trait, TraitId, GenericRequirement::None; - Metadata, sym::metadata_type, metadata_type, TypeAliasId, GenericRequirement::None; - DynMetadata, sym::dyn_metadata, dyn_metadata, StructId, GenericRequirement::None; + PointeeTrait, sym::pointee_trait, TraitId; + Metadata, sym::metadata_type, TypeAliasId; + DynMetadata, sym::dyn_metadata, StructId; - Freeze, sym::freeze, freeze_trait, TraitId, GenericRequirement::Exact(0); + Freeze, sym::freeze, TraitId; - FnPtrTrait, sym::fn_ptr_trait, fn_ptr_trait, TraitId, GenericRequirement::Exact(0); - FnPtrAddr, sym::fn_ptr_addr, fn_ptr_addr, FunctionId, GenericRequirement::None; + FnPtrTrait, sym::fn_ptr_trait, TraitId; + FnPtrAddr, sym::fn_ptr_addr, FunctionId; - Drop, sym::drop, drop_trait, TraitId, GenericRequirement::None; - Destruct, sym::destruct, destruct_trait, TraitId, GenericRequirement::None; + Drop, sym::drop, TraitId; + Destruct, sym::destruct, TraitId; - CoerceUnsized, sym::coerce_unsized, coerce_unsized_trait, TraitId, GenericRequirement::Minimum(1); - DispatchFromDyn, sym::dispatch_from_dyn, dispatch_from_dyn_trait, TraitId, GenericRequirement::Minimum(1); + CoerceUnsized, sym::coerce_unsized, TraitId; + DispatchFromDyn, sym::dispatch_from_dyn, TraitId; // language items relating to transmutability - TransmuteOpts, sym::transmute_opts, transmute_opts, StructId, GenericRequirement::Exact(0); - TransmuteTrait, sym::transmute_trait, transmute_trait, TraitId, GenericRequirement::Exact(3); + TransmuteOpts, sym::transmute_opts, StructId; + TransmuteTrait, sym::transmute_trait, TraitId; - Add, sym::add, add_trait, TraitId, GenericRequirement::Exact(1); - Sub, sym::sub, sub_trait, TraitId, GenericRequirement::Exact(1); - Mul, sym::mul, mul_trait, TraitId, GenericRequirement::Exact(1); - Div, sym::div, div_trait, TraitId, GenericRequirement::Exact(1); - Rem, sym::rem, rem_trait, TraitId, GenericRequirement::Exact(1); - Neg, sym::neg, neg_trait, TraitId, GenericRequirement::Exact(0); - Not, sym::not, not_trait, TraitId, GenericRequirement::Exact(0); - BitXor, sym::bitxor, bitxor_trait, TraitId, GenericRequirement::Exact(1); - BitAnd, sym::bitand, bitand_trait, TraitId, GenericRequirement::Exact(1); - BitOr, sym::bitor, bitor_trait, TraitId, GenericRequirement::Exact(1); - Shl, sym::shl, shl_trait, TraitId, GenericRequirement::Exact(1); - Shr, sym::shr, shr_trait, TraitId, GenericRequirement::Exact(1); - AddAssign, sym::add_assign, add_assign_trait, TraitId, GenericRequirement::Exact(1); - SubAssign, sym::sub_assign, sub_assign_trait, TraitId, GenericRequirement::Exact(1); - MulAssign, sym::mul_assign, mul_assign_trait, TraitId, GenericRequirement::Exact(1); - DivAssign, sym::div_assign, div_assign_trait, TraitId, GenericRequirement::Exact(1); - RemAssign, sym::rem_assign, rem_assign_trait, TraitId, GenericRequirement::Exact(1); - BitXorAssign, sym::bitxor_assign, bitxor_assign_trait, TraitId, GenericRequirement::Exact(1); - BitAndAssign, sym::bitand_assign, bitand_assign_trait, TraitId, GenericRequirement::Exact(1); - BitOrAssign, sym::bitor_assign, bitor_assign_trait, TraitId, GenericRequirement::Exact(1); - ShlAssign, sym::shl_assign, shl_assign_trait, TraitId, GenericRequirement::Exact(1); - ShrAssign, sym::shr_assign, shr_assign_trait, TraitId, GenericRequirement::Exact(1); - Index, sym::index, index_trait, TraitId, GenericRequirement::Exact(1); - IndexMut, sym::index_mut, index_mut_trait, TraitId, GenericRequirement::Exact(1); + Add, sym::add, TraitId; + Sub, sym::sub, TraitId; + Mul, sym::mul, TraitId; + Div, sym::div, TraitId; + Rem, sym::rem, TraitId; + Neg, sym::neg, TraitId; + Not, sym::not, TraitId; + BitXor, sym::bitxor, TraitId; + BitAnd, sym::bitand, TraitId; + BitOr, sym::bitor, TraitId; + Shl, sym::shl, TraitId; + Shr, sym::shr, TraitId; + AddAssign, sym::add_assign, TraitId; + SubAssign, sym::sub_assign, TraitId; + MulAssign, sym::mul_assign, TraitId; + DivAssign, sym::div_assign, TraitId; + RemAssign, sym::rem_assign, TraitId; + BitXorAssign, sym::bitxor_assign, TraitId; + BitAndAssign, sym::bitand_assign, TraitId; + BitOrAssign, sym::bitor_assign, TraitId; + ShlAssign, sym::shl_assign, TraitId; + ShrAssign, sym::shr_assign, TraitId; + Index, sym::index, TraitId; + IndexMut, sym::index_mut, TraitId; - UnsafeCell, sym::unsafe_cell, unsafe_cell_type, StructId, GenericRequirement::None; - UnsafePinned, sym::unsafe_pinned, unsafe_pinned_type, StructId, GenericRequirement::None; - VaList, sym::va_list, va_list, StructId, GenericRequirement::None; + UnsafeCell, sym::unsafe_cell, StructId; + UnsafePinned, sym::unsafe_pinned, StructId; + VaList, sym::va_list, StructId; - Deref, sym::deref, deref_trait, TraitId, GenericRequirement::Exact(0); - DerefMut, sym::deref_mut, deref_mut_trait, TraitId, GenericRequirement::Exact(0); - DerefTarget, sym::deref_target, deref_target, TypeAliasId, GenericRequirement::None; - Receiver, sym::receiver, receiver_trait, TraitId, GenericRequirement::None; - ReceiverTarget, sym::receiver_target, receiver_target, TypeAliasId, GenericRequirement::None; + Deref, sym::deref, TraitId; + DerefMut, sym::deref_mut, TraitId; + DerefTarget, sym::deref_target, TypeAliasId; + Receiver, sym::receiver, TraitId; + ReceiverTarget, sym::receiver_target, TypeAliasId; - Fn, sym::fn_, fn_trait, TraitId, GenericRequirement::Exact(1); - FnMut, sym::fn_mut, fn_mut_trait, TraitId, GenericRequirement::Exact(1); - FnOnce, sym::fn_once, fn_once_trait, TraitId, GenericRequirement::Exact(1); - AsyncFn, sym::async_fn, async_fn_trait, TraitId, GenericRequirement::Exact(1); - AsyncFnMut, sym::async_fn_mut, async_fn_mut_trait, TraitId, GenericRequirement::Exact(1); - AsyncFnOnce, sym::async_fn_once, async_fn_once_trait, TraitId, GenericRequirement::Exact(1); + Fn, sym::fn_, TraitId; + FnMut, sym::fn_mut, TraitId; + FnOnce, sym::fn_once, TraitId; + AsyncFn, sym::async_fn, TraitId; + AsyncFnMut, sym::async_fn_mut, TraitId; + AsyncFnOnce, sym::async_fn_once, TraitId; - CallRefFuture, sym::call_ref_future, call_ref_future_ty, TypeAliasId, GenericRequirement::None; - CallOnceFuture, sym::call_once_future, call_once_future_ty, TypeAliasId, GenericRequirement::None; - AsyncFnOnceOutput, sym::async_fn_once_output, async_fn_once_output_ty, TypeAliasId, GenericRequirement::None; + CallRefFuture, sym::call_ref_future, TypeAliasId; + CallOnceFuture, sym::call_once_future, TypeAliasId; + AsyncFnOnceOutput, sym::async_fn_once_output, TypeAliasId; - FnOnceOutput, sym::fn_once_output, fn_once_output, TypeAliasId, GenericRequirement::None; + FnOnceOutput, sym::fn_once_output, TypeAliasId; - Future, sym::future_trait, future_trait, TraitId, GenericRequirement::Exact(0); - CoroutineState, sym::coroutine_state, coroutine_state, EnumId, GenericRequirement::None; - Coroutine, sym::coroutine, coroutine_trait, TraitId, GenericRequirement::Minimum(1); - CoroutineReturn, sym::coroutine_return, coroutine_return_ty, TypeAliasId, GenericRequirement::None; - CoroutineYield, sym::coroutine_yield, coroutine_yield_ty, TypeAliasId, GenericRequirement::None; - Unpin, sym::unpin, unpin_trait, TraitId, GenericRequirement::None; - Pin, sym::pin, pin_type, StructId, GenericRequirement::None; + Future, sym::future_trait, TraitId; + CoroutineState, sym::coroutine_state, EnumId; + Coroutine, sym::coroutine, TraitId; + CoroutineReturn, sym::coroutine_return, TypeAliasId; + CoroutineYield, sym::coroutine_yield, TypeAliasId; + Unpin, sym::unpin, TraitId; + Pin, sym::pin, StructId; - PartialEq, sym::eq, eq_trait, TraitId, GenericRequirement::Exact(1); - PartialOrd, sym::partial_ord, partial_ord_trait, TraitId, GenericRequirement::Exact(1); - CVoid, sym::c_void, c_void, EnumId, GenericRequirement::None; + PartialEq, sym::eq, TraitId; + PartialOrd, sym::partial_ord, TraitId; + CVoid, sym::c_void, EnumId; // A number of panic-related lang items. The `panic` item corresponds to divide-by-zero and // various panic cases with `match`. The `panic_bounds_check` item is for indexing arrays. @@ -329,107 +323,107 @@ language_item_table! { LangItems => // in the sense that a crate is not required to have it defined to use it, but a final product // is required to define it somewhere. Additionally, there are restrictions on crates that use // a weak lang item, but do not have it defined. - Panic, sym::panic, panic_fn, FunctionId, GenericRequirement::Exact(0); - PanicNounwind, sym::panic_nounwind, panic_nounwind, FunctionId, GenericRequirement::Exact(0); - PanicFmt, sym::panic_fmt, panic_fmt, FunctionId, GenericRequirement::None; - PanicDisplay, sym::panic_display, panic_display, FunctionId, GenericRequirement::None; - ConstPanicFmt, sym::const_panic_fmt, const_panic_fmt, FunctionId, GenericRequirement::None; - PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, FunctionId, GenericRequirement::Exact(0); - PanicMisalignedPointerDereference, sym::panic_misaligned_pointer_dereference, panic_misaligned_pointer_dereference_fn, FunctionId, GenericRequirement::Exact(0); - PanicInfo, sym::panic_info, panic_info, StructId, GenericRequirement::None; - PanicLocation, sym::panic_location, panic_location, StructId, GenericRequirement::None; - PanicImpl, sym::panic_impl, panic_impl, FunctionId, GenericRequirement::None; - PanicCannotUnwind, sym::panic_cannot_unwind, panic_cannot_unwind, FunctionId, GenericRequirement::Exact(0); - PanicNullPointerDereference, sym::panic_null_pointer_dereference, panic_null_pointer_dereference, FunctionId, GenericRequirement::None; + Panic, sym::panic, FunctionId; + PanicNounwind, sym::panic_nounwind, FunctionId; + PanicFmt, sym::panic_fmt, FunctionId; + PanicDisplay, sym::panic_display, FunctionId; + ConstPanicFmt, sym::const_panic_fmt, FunctionId; + PanicBoundsCheck, sym::panic_bounds_check, FunctionId; + PanicMisalignedPointerDereference, sym::panic_misaligned_pointer_dereference, FunctionId; + PanicInfo, sym::panic_info, StructId; + PanicLocation, sym::panic_location, StructId; + PanicImpl, sym::panic_impl, FunctionId; + PanicCannotUnwind, sym::panic_cannot_unwind, FunctionId; + PanicNullPointerDereference, sym::panic_null_pointer_dereference, FunctionId; /// libstd panic entry point. Necessary for const eval to be able to catch it - BeginPanic, sym::begin_panic, begin_panic_fn, FunctionId, GenericRequirement::None; + BeginPanic, sym::begin_panic, FunctionId; // Lang items needed for `format_args!()`. - FormatAlignment, sym::format_alignment, format_alignment, EnumId, GenericRequirement::None; - FormatArgument, sym::format_argument, format_argument, StructId, GenericRequirement::None; - FormatArguments, sym::format_arguments, format_arguments, StructId, GenericRequirement::None; - FormatCount, sym::format_count, format_count, EnumId, GenericRequirement::None; - FormatPlaceholder, sym::format_placeholder, format_placeholder, StructId, GenericRequirement::None; - FormatUnsafeArg, sym::format_unsafe_arg, format_unsafe_arg, StructId, GenericRequirement::None; + FormatAlignment, sym::format_alignment, EnumId; + FormatArgument, sym::format_argument, StructId; + FormatArguments, sym::format_arguments, StructId; + FormatCount, sym::format_count, EnumId; + FormatPlaceholder, sym::format_placeholder, StructId; + FormatUnsafeArg, sym::format_unsafe_arg, StructId; - ExchangeMalloc, sym::exchange_malloc, exchange_malloc_fn, FunctionId, GenericRequirement::None; - BoxFree, sym::box_free, box_free_fn, FunctionId, GenericRequirement::Minimum(1); - DropInPlace, sym::drop_in_place, drop_in_place_fn, FunctionId, GenericRequirement::Minimum(1); - AllocLayout, sym::alloc_layout, alloc_layout, StructId, GenericRequirement::None; + ExchangeMalloc, sym::exchange_malloc, FunctionId; + BoxFree, sym::box_free, FunctionId; + DropInPlace, sym::drop_in_place, FunctionId; + AllocLayout, sym::alloc_layout, StructId; - Start, sym::start, start_fn, FunctionId, GenericRequirement::Exact(1); + Start, sym::start, FunctionId; - EhPersonality, sym::eh_personality, eh_personality, FunctionId, GenericRequirement::None; - EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, StaticId, GenericRequirement::None; + EhPersonality, sym::eh_personality, FunctionId; + EhCatchTypeinfo, sym::eh_catch_typeinfo, StaticId; - OwnedBox, sym::owned_box, owned_box, StructId, GenericRequirement::Minimum(1); + OwnedBox, sym::owned_box, StructId; - PhantomData, sym::phantom_data, phantom_data, StructId, GenericRequirement::Exact(1); + PhantomData, sym::phantom_data, StructId; - ManuallyDrop, sym::manually_drop, manually_drop, StructId, GenericRequirement::None; + ManuallyDrop, sym::manually_drop, StructId; - MaybeUninit, sym::maybe_uninit, maybe_uninit, UnionId, GenericRequirement::None; + MaybeUninit, sym::maybe_uninit, UnionId; /// Align offset for stride != 1; must not panic. - AlignOffset, sym::align_offset, align_offset_fn, FunctionId, GenericRequirement::None; + AlignOffset, sym::align_offset, FunctionId; - Termination, sym::termination, termination, TraitId, GenericRequirement::None; + Termination, sym::termination, TraitId; - Try, sym::Try, try_trait, TraitId, GenericRequirement::None; + Try, sym::Try, TraitId; - Tuple, sym::tuple_trait, tuple_trait, TraitId, GenericRequirement::Exact(0); + Tuple, sym::tuple_trait, TraitId; - SliceLen, sym::slice_len_fn, slice_len_fn, FunctionId, GenericRequirement::None; + SliceLen, sym::slice_len_fn, FunctionId; // Language items from AST lowering - TryTraitFromResidual, sym::from_residual, from_residual_fn, FunctionId, GenericRequirement::None; - TryTraitFromOutput, sym::from_output, from_output_fn, FunctionId, GenericRequirement::None; - TryTraitBranch, sym::branch, branch_fn, FunctionId, GenericRequirement::None; - TryTraitFromYeet, sym::from_yeet, from_yeet_fn, FunctionId, GenericRequirement::None; + TryTraitFromResidual, sym::from_residual, FunctionId; + TryTraitFromOutput, sym::from_output, FunctionId; + TryTraitBranch, sym::branch, FunctionId; + TryTraitFromYeet, sym::from_yeet, FunctionId; - PointerLike, sym::pointer_like, pointer_like, TraitId, GenericRequirement::Exact(0); + PointerLike, sym::pointer_like, TraitId; - ConstParamTy, sym::const_param_ty, const_param_ty_trait, TraitId, GenericRequirement::Exact(0); + ConstParamTy, sym::const_param_ty, TraitId; - Poll, sym::Poll, poll, EnumId, GenericRequirement::None; - PollReady, sym::Ready, poll_ready_variant, EnumVariantId, GenericRequirement::None; - PollPending, sym::Pending, poll_pending_variant, EnumVariantId, GenericRequirement::None; + Poll, sym::Poll, EnumId; + PollReady, sym::Ready, EnumVariantId; + PollPending, sym::Pending, EnumVariantId; // FIXME(swatinem): the following lang items are used for async lowering and // should become obsolete eventually. - ResumeTy, sym::ResumeTy, resume_ty, StructId, GenericRequirement::None; - GetContext, sym::get_context, get_context_fn, FunctionId, GenericRequirement::None; + ResumeTy, sym::ResumeTy, StructId; + GetContext, sym::get_context, FunctionId; - Context, sym::Context, context, StructId, GenericRequirement::None; - FuturePoll, sym::poll, future_poll_fn, FunctionId, GenericRequirement::None; - FutureOutput, sym::future_output, future_output, TypeAliasId, GenericRequirement::None; + Context, sym::Context, StructId; + FuturePoll, sym::poll, FunctionId; + FutureOutput, sym::future_output, TypeAliasId; - Option, sym::Option, option_type, EnumId, GenericRequirement::None; - OptionSome, sym::Some, option_some_variant, EnumVariantId, GenericRequirement::None; - OptionNone, sym::None, option_none_variant, EnumVariantId, GenericRequirement::None; + Option, sym::Option, EnumId; + OptionSome, sym::Some, EnumVariantId; + OptionNone, sym::None, EnumVariantId; - ResultOk, sym::Ok, result_ok_variant, EnumVariantId, GenericRequirement::None; - ResultErr, sym::Err, result_err_variant, EnumVariantId, GenericRequirement::None; + ResultOk, sym::Ok, EnumVariantId; + ResultErr, sym::Err, EnumVariantId; - ControlFlowContinue, sym::Continue, cf_continue_variant, EnumVariantId, GenericRequirement::None; - ControlFlowBreak, sym::Break, cf_break_variant, EnumVariantId, GenericRequirement::None; + ControlFlowContinue, sym::Continue, EnumVariantId; + ControlFlowBreak, sym::Break, EnumVariantId; - IntoFutureIntoFuture, sym::into_future, into_future_fn, FunctionId, GenericRequirement::None; - IntoIterIntoIter, sym::into_iter, into_iter_fn, FunctionId, GenericRequirement::None; - IteratorNext, sym::next, next_fn, FunctionId, GenericRequirement::None; - Iterator, sym::iterator, iterator, TraitId, GenericRequirement::None; + IntoFutureIntoFuture, sym::into_future, FunctionId; + IntoIterIntoIter, sym::into_iter, FunctionId; + IteratorNext, sym::next, FunctionId; + Iterator, sym::iterator, TraitId; - PinNewUnchecked, sym::new_unchecked, new_unchecked_fn, FunctionId, GenericRequirement::None; + PinNewUnchecked, sym::new_unchecked, FunctionId; - RangeFrom, sym::RangeFrom, range_from_struct, StructId, GenericRequirement::None; - RangeFull, sym::RangeFull, range_full_struct, StructId, GenericRequirement::None; - RangeInclusiveStruct, sym::RangeInclusive, range_inclusive_struct, StructId, GenericRequirement::None; - RangeInclusiveNew, sym::range_inclusive_new, range_inclusive_new_method, FunctionId, GenericRequirement::None; - Range, sym::Range, range_struct, StructId, GenericRequirement::None; - RangeToInclusive, sym::RangeToInclusive, range_to_inclusive_struct, StructId, GenericRequirement::None; - RangeTo, sym::RangeTo, range_to_struct, StructId, GenericRequirement::None; + RangeFrom, sym::RangeFrom, StructId; + RangeFull, sym::RangeFull, StructId; + RangeInclusiveStruct, sym::RangeInclusive, StructId; + RangeInclusiveNew, sym::range_inclusive_new, FunctionId; + Range, sym::Range, StructId; + RangeToInclusive, sym::RangeToInclusive, StructId; + RangeTo, sym::RangeTo, StructId; - String, sym::String, string, StructId, GenericRequirement::None; - CStr, sym::CStr, c_str, StructId, GenericRequirement::None; - Ordering, sym::Ordering, ordering, EnumId, GenericRequirement::None; + String, sym::String, StructId; + CStr, sym::CStr, StructId; + Ordering, sym::Ordering, EnumId; } From 3e55ab1adfd50292a3710ad860fd01f511bc7b66 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Mon, 20 Oct 2025 17:41:40 +0200 Subject: [PATCH 223/489] dogfood the lint This commit is put before the one that actually introduces the lint, since, were they put in the opposite order, the first commit wouldn't pass dogfood --- clippy_lints/src/booleans.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/implicit_hasher.rs | 23 +++++------ clippy_lints/src/loops/for_kv_map.rs | 2 +- clippy_lints/src/manual_let_else.rs | 2 +- clippy_lints/src/matches/match_wild_enum.rs | 2 +- clippy_lints/src/methods/expect_fun_call.rs | 10 ++--- clippy_lints/src/methods/iter_count.rs | 31 ++++++--------- clippy_lints/src/methods/iter_kv_map.rs | 2 +- .../src/methods/join_absolute_paths.rs | 2 +- clippy_lints/src/methods/map_clone.rs | 2 +- clippy_lints/src/methods/or_then_unwrap.rs | 38 ++++++++++--------- .../src/methods/unnecessary_get_then_check.rs | 4 +- .../src/methods/unwrap_expect_used.rs | 24 ++++++------ clippy_lints/src/missing_fields_in_debug.rs | 12 ++++-- clippy_lints/src/time_subtraction.rs | 16 ++++---- clippy_lints/src/zero_sized_map_values.rs | 2 +- clippy_utils/src/consts.rs | 10 +++-- clippy_utils/src/sym.rs | 4 ++ 19 files changed, 94 insertions(+), 96 deletions(-) diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 902ba70577b9..a04a56d72bc0 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -433,7 +433,7 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: Msrv, expr: &Expr<'_>) -> Optio }, ExprKind::MethodCall(path, receiver, args, _) => { let type_of_receiver = cx.typeck_results().expr_ty(receiver); - if !type_of_receiver.is_diag_item(cx, sym::Option) && !type_of_receiver.is_diag_item(cx, sym::Result) { + if !matches!(type_of_receiver.opt_diag_name(cx), Some(sym::Option | sym::Result)) { return None; } METHODS_WITH_NEGATION diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index c42998ffc3f5..bd2bd6628464 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -82,7 +82,7 @@ fn lint_impl_body(cx: &LateContext<'_>, item_def_id: hir::OwnerId, impl_span: Sp // check for `unwrap` if let Some(arglists) = method_chain_args(expr, &[sym::unwrap]) { let receiver_ty = self.typeck_results.expr_ty(arglists[0].0).peel_refs(); - if receiver_ty.is_diag_item(self.lcx, sym::Option) || receiver_ty.is_diag_item(self.lcx, sym::Result) { + if matches!(receiver_ty.opt_diag_name(self.lcx), Some(sym::Option | sym::Result)) { self.result.push(expr.span); } } diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index 638a08b096db..9dc74a157cbf 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -223,25 +223,20 @@ impl<'tcx> ImplicitHasherType<'tcx> { _ => None, }) .collect(); - let params_len = params.len(); let ty = lower_ty(cx.tcx, hir_ty); - if ty.is_diag_item(cx, sym::HashMap) && params_len == 2 { - Some(ImplicitHasherType::HashMap( + match (ty.opt_diag_name(cx), ¶ms[..]) { + (Some(sym::HashMap), [k, v]) => Some(ImplicitHasherType::HashMap( hir_ty.span, ty, - snippet(cx, params[0].span, "K"), - snippet(cx, params[1].span, "V"), - )) - } else if ty.is_diag_item(cx, sym::HashSet) && params_len == 1 { - Some(ImplicitHasherType::HashSet( - hir_ty.span, - ty, - snippet(cx, params[0].span, "T"), - )) - } else { - None + snippet(cx, k.span, "K"), + snippet(cx, v.span, "V"), + )), + (Some(sym::HashSet), [t]) => { + Some(ImplicitHasherType::HashSet(hir_ty.span, ty, snippet(cx, t.span, "T"))) + }, + _ => None, } } else { None diff --git a/clippy_lints/src/loops/for_kv_map.rs b/clippy_lints/src/loops/for_kv_map.rs index c6b650a1a88b..39b2391c98ec 100644 --- a/clippy_lints/src/loops/for_kv_map.rs +++ b/clippy_lints/src/loops/for_kv_map.rs @@ -34,7 +34,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx _ => arg, }; - if ty.is_diag_item(cx, sym::HashMap) || ty.is_diag_item(cx, sym::BTreeMap) { + if matches!(ty.opt_diag_name(cx), Some(sym::HashMap | sym::BTreeMap)) { span_lint_and_then( cx, FOR_KV_MAP, diff --git a/clippy_lints/src/manual_let_else.rs b/clippy_lints/src/manual_let_else.rs index 0f3d8b336675..38ee4ce104a5 100644 --- a/clippy_lints/src/manual_let_else.rs +++ b/clippy_lints/src/manual_let_else.rs @@ -374,7 +374,7 @@ fn pat_allowed_for_else(cx: &LateContext<'_>, pat: &'_ Pat<'_>, check_types: boo } let ty = typeck_results.pat_ty(pat); // Option and Result are allowed, everything else isn't. - if !(ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result)) { + if !matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)) { has_disallowed = true; } }); diff --git a/clippy_lints/src/matches/match_wild_enum.rs b/clippy_lints/src/matches/match_wild_enum.rs index fa44a56af182..00bd1c2ca698 100644 --- a/clippy_lints/src/matches/match_wild_enum.rs +++ b/clippy_lints/src/matches/match_wild_enum.rs @@ -16,7 +16,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) { let ty = cx.typeck_results().expr_ty(ex).peel_refs(); let adt_def = match ty.kind() { ty::Adt(adt_def, _) - if adt_def.is_enum() && !(ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result)) => + if adt_def.is_enum() && !matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)) => { adt_def }, diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index 288f966991ac..e891b2ac6d64 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -26,12 +26,10 @@ pub(super) fn check<'tcx>( let arg_root = get_arg_root(cx, arg); if contains_call(cx, arg_root) && !contains_return(arg_root) { let receiver_type = cx.typeck_results().expr_ty_adjusted(receiver); - let closure_args = if receiver_type.is_diag_item(cx, sym::Option) { - "||" - } else if receiver_type.is_diag_item(cx, sym::Result) { - "|_|" - } else { - return; + let closure_args = match receiver_type.opt_diag_name(cx) { + Some(sym::Option) => "||", + Some(sym::Result) => "|_|", + _ => return, }; let span_replace_word = method_span.with_hi(expr.span.hi()); diff --git a/clippy_lints/src/methods/iter_count.rs b/clippy_lints/src/methods/iter_count.rs index ea2508cd7f38..8b303c0ca5b2 100644 --- a/clippy_lints/src/methods/iter_count.rs +++ b/clippy_lints/src/methods/iter_count.rs @@ -11,26 +11,17 @@ use super::ITER_COUNT; pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx Expr<'tcx>, iter_method: Symbol) { let ty = cx.typeck_results().expr_ty(recv); - let caller_type = if derefs_to_slice(cx, recv, ty).is_some() { - "slice" - } else if ty.is_diag_item(cx, sym::Vec) { - "Vec" - } else if ty.is_diag_item(cx, sym::VecDeque) { - "VecDeque" - } else if ty.is_diag_item(cx, sym::HashSet) { - "HashSet" - } else if ty.is_diag_item(cx, sym::HashMap) { - "HashMap" - } else if ty.is_diag_item(cx, sym::BTreeMap) { - "BTreeMap" - } else if ty.is_diag_item(cx, sym::BTreeSet) { - "BTreeSet" - } else if ty.is_diag_item(cx, sym::LinkedList) { - "LinkedList" - } else if ty.is_diag_item(cx, sym::BinaryHeap) { - "BinaryHeap" - } else { - return; + let caller_type = match ty.opt_diag_name(cx) { + _ if derefs_to_slice(cx, recv, ty).is_some() => "slice", + Some(sym::Vec) => "Vec", + Some(sym::VecDeque) => "VecDeque", + Some(sym::HashSet) => "HashSet", + Some(sym::HashMap) => "HashMap", + Some(sym::BTreeMap) => "BTreeMap", + Some(sym::BTreeSet) => "BTreeSet", + Some(sym::LinkedList) => "LinkedList", + Some(sym::BinaryHeap) => "BinaryHeap", + _ => return, }; let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( diff --git a/clippy_lints/src/methods/iter_kv_map.rs b/clippy_lints/src/methods/iter_kv_map.rs index 2d6bc36dc535..16db8663941e 100644 --- a/clippy_lints/src/methods/iter_kv_map.rs +++ b/clippy_lints/src/methods/iter_kv_map.rs @@ -38,7 +38,7 @@ pub(super) fn check<'tcx>( _ => return, } && let ty = cx.typeck_results().expr_ty_adjusted(recv).peel_refs() - && (ty.is_diag_item(cx, sym::HashMap) || ty.is_diag_item(cx, sym::BTreeMap)) + && matches!(ty.opt_diag_name(cx), Some(sym::HashMap | sym::BTreeMap)) { let mut applicability = rustc_errors::Applicability::MachineApplicable; let recv_snippet = snippet_with_applicability(cx, recv.span, "map", &mut applicability); diff --git a/clippy_lints/src/methods/join_absolute_paths.rs b/clippy_lints/src/methods/join_absolute_paths.rs index e84b7452c758..905a58afa795 100644 --- a/clippy_lints/src/methods/join_absolute_paths.rs +++ b/clippy_lints/src/methods/join_absolute_paths.rs @@ -13,7 +13,7 @@ use super::JOIN_ABSOLUTE_PATHS; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx Expr<'tcx>, join_arg: &'tcx Expr<'tcx>, expr_span: Span) { let ty = cx.typeck_results().expr_ty(recv).peel_refs(); - if (ty.is_diag_item(cx, sym::Path) || ty.is_diag_item(cx, sym::PathBuf)) + if matches!(ty.opt_diag_name(cx), Some(sym::Path | sym::PathBuf)) && let ExprKind::Lit(spanned) = expr_or_init(cx, join_arg).kind && let LitKind::Str(symbol, _) = spanned.node && let sym_str = symbol.as_str() diff --git a/clippy_lints/src/methods/map_clone.rs b/clippy_lints/src/methods/map_clone.rs index a1aac96ccf86..8a1cc664ac60 100644 --- a/clippy_lints/src/methods/map_clone.rs +++ b/clippy_lints/src/methods/map_clone.rs @@ -25,7 +25,7 @@ fn should_run_lint(cx: &LateContext<'_>, e: &hir::Expr<'_>, method_parent_id: De } // We check if it's an `Option` or a `Result`. if let Some(ty) = method_parent_id.opt_impl_ty(cx) { - if !ty.is_diag_item(cx, sym::Option) && !ty.is_diag_item(cx, sym::Result) { + if !matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)) { return false; } } else { diff --git a/clippy_lints/src/methods/or_then_unwrap.rs b/clippy_lints/src/methods/or_then_unwrap.rs index 07199b84f39e..448ab621a7ce 100644 --- a/clippy_lints/src/methods/or_then_unwrap.rs +++ b/clippy_lints/src/methods/or_then_unwrap.rs @@ -20,24 +20,28 @@ pub(super) fn check<'tcx>( let title; let or_arg_content: Span; - if ty.is_diag_item(cx, sym::Option) { - title = "found `.or(Some(…)).unwrap()`"; - if let Some(content) = get_content_if_ctor_matches(cx, or_arg, LangItem::OptionSome) { - or_arg_content = content; - } else { + match ty.opt_diag_name(cx) { + Some(sym::Option) => { + title = "found `.or(Some(…)).unwrap()`"; + if let Some(content) = get_content_if_ctor_matches(cx, or_arg, LangItem::OptionSome) { + or_arg_content = content; + } else { + return; + } + }, + Some(sym::Result) => { + title = "found `.or(Ok(…)).unwrap()`"; + if let Some(content) = get_content_if_ctor_matches(cx, or_arg, LangItem::ResultOk) { + or_arg_content = content; + } else { + return; + } + }, + _ => { + // Someone has implemented a struct with .or(...).unwrap() chaining, + // but it's not an Option or a Result, so bail return; - } - } else if ty.is_diag_item(cx, sym::Result) { - title = "found `.or(Ok(…)).unwrap()`"; - if let Some(content) = get_content_if_ctor_matches(cx, or_arg, LangItem::ResultOk) { - or_arg_content = content; - } else { - return; - } - } else { - // Someone has implemented a struct with .or(...).unwrap() chaining, - // but it's not an Option or a Result, so bail - return; + }, } let mut applicability = Applicability::MachineApplicable; diff --git a/clippy_lints/src/methods/unnecessary_get_then_check.rs b/clippy_lints/src/methods/unnecessary_get_then_check.rs index 10ea0c0c3e23..3207c4207fc0 100644 --- a/clippy_lints/src/methods/unnecessary_get_then_check.rs +++ b/clippy_lints/src/methods/unnecessary_get_then_check.rs @@ -11,11 +11,11 @@ use rustc_span::{Span, sym}; use super::UNNECESSARY_GET_THEN_CHECK; fn is_a_std_set_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { - ty.is_diag_item(cx, sym::HashSet) || ty.is_diag_item(cx, sym::BTreeSet) + matches!(ty.opt_diag_name(cx), Some(sym::HashSet | sym::BTreeSet)) } fn is_a_std_map_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { - ty.is_diag_item(cx, sym::HashMap) || ty.is_diag_item(cx, sym::BTreeMap) + matches!(ty.opt_diag_name(cx), Some(sym::HashMap | sym::BTreeMap)) } pub(super) fn check( diff --git a/clippy_lints/src/methods/unwrap_expect_used.rs b/clippy_lints/src/methods/unwrap_expect_used.rs index 73a407be4f21..30db2a75df57 100644 --- a/clippy_lints/src/methods/unwrap_expect_used.rs +++ b/clippy_lints/src/methods/unwrap_expect_used.rs @@ -46,19 +46,19 @@ pub(super) fn check( ) { let ty = cx.typeck_results().expr_ty(recv).peel_refs(); - let (kind, none_value, none_prefix) = if ty.is_diag_item(cx, sym::Option) && !is_err { - ("an `Option`", "None", "") - } else if ty.is_diag_item(cx, sym::Result) - && let ty::Adt(_, substs) = ty.kind() - && let Some(t_or_e_ty) = substs[usize::from(!is_err)].as_type() - { - if is_never_like(t_or_e_ty) { - return; - } + let (kind, none_value, none_prefix) = match ty.opt_diag_name(cx) { + Some(sym::Option) if !is_err => ("an `Option`", "None", ""), + Some(sym::Result) + if let ty::Adt(_, substs) = ty.kind() + && let Some(t_or_e_ty) = substs[usize::from(!is_err)].as_type() => + { + if is_never_like(t_or_e_ty) { + return; + } - ("a `Result`", if is_err { "Ok" } else { "Err" }, "an ") - } else { - return; + ("a `Result`", if is_err { "Ok" } else { "Err" }, "an ") + }, + _ => return, }; let method_suffix = if is_err { "_err" } else { "" }; diff --git a/clippy_lints/src/missing_fields_in_debug.rs b/clippy_lints/src/missing_fields_in_debug.rs index 15b773c2c64f..a26f24d15247 100644 --- a/clippy_lints/src/missing_fields_in_debug.rs +++ b/clippy_lints/src/missing_fields_in_debug.rs @@ -112,10 +112,14 @@ fn should_lint<'tcx>( if let ExprKind::MethodCall(path, recv, ..) = &expr.kind { let recv_ty = typeck_results.expr_ty(recv).peel_refs(); - if path.ident.name == sym::debug_struct && recv_ty.is_diag_item(cx, sym::Formatter) { - has_debug_struct = true; - } else if path.ident.name == sym::finish_non_exhaustive && recv_ty.is_diag_item(cx, sym::DebugStruct) { - has_finish_non_exhaustive = true; + match (path.ident.name, recv_ty.opt_diag_name(cx)) { + (sym::debug_struct, Some(sym::Formatter)) => { + has_debug_struct = true; + }, + (sym::finish_non_exhaustive, Some(sym::DebugStruct)) => { + has_finish_non_exhaustive = true; + }, + _ => {}, } } ControlFlow::::Continue(()) diff --git a/clippy_lints/src/time_subtraction.rs b/clippy_lints/src/time_subtraction.rs index 92bce998c32f..3ba59aefea06 100644 --- a/clippy_lints/src/time_subtraction.rs +++ b/clippy_lints/src/time_subtraction.rs @@ -91,16 +91,16 @@ impl LateLintPass<'_> for UncheckedTimeSubtraction { _ => return, }; let typeck = cx.typeck_results(); - let lhs_ty = typeck.expr_ty(lhs); - let rhs_ty = typeck.expr_ty(rhs); + let lhs_name = typeck.expr_ty(lhs).opt_diag_name(cx); + let rhs_name = typeck.expr_ty(rhs).opt_diag_name(cx); - if lhs_ty.is_diag_item(cx, sym::Instant) { + if lhs_name == Some(sym::Instant) { // Instant::now() - instant - if is_instant_now_call(cx, lhs) && rhs_ty.is_diag_item(cx, sym::Instant) { + if is_instant_now_call(cx, lhs) && rhs_name == Some(sym::Instant) { print_manual_instant_elapsed_sugg(cx, expr, rhs); } // instant - duration - else if rhs_ty.is_diag_item(cx, sym::Duration) + else if rhs_name == Some(sym::Duration) && !expr.span.from_expansion() && self.msrv.meets(cx, msrvs::TRY_FROM) { @@ -108,8 +108,8 @@ impl LateLintPass<'_> for UncheckedTimeSubtraction { } } // duration - duration - else if lhs_ty.is_diag_item(cx, sym::Duration) - && rhs_ty.is_diag_item(cx, sym::Duration) + else if lhs_name == Some(sym::Duration) + && rhs_name == Some(sym::Duration) && !expr.span.from_expansion() && self.msrv.meets(cx, msrvs::TRY_FROM) { @@ -144,7 +144,7 @@ fn is_chained_time_subtraction(cx: &LateContext<'_>, lhs: &Expr<'_>) -> bool { /// Returns true if the type is Duration or Instant fn is_time_type(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { - ty.is_diag_item(cx, sym::Duration) || ty.is_diag_item(cx, sym::Instant) + matches!(ty.opt_diag_name(cx), Some(sym::Duration | sym::Instant)) } fn print_manual_instant_elapsed_sugg(cx: &LateContext<'_>, expr: &Expr<'_>, rhs: &Expr<'_>) { diff --git a/clippy_lints/src/zero_sized_map_values.rs b/clippy_lints/src/zero_sized_map_values.rs index bf133d26ed9d..94c2fb20d5f5 100644 --- a/clippy_lints/src/zero_sized_map_values.rs +++ b/clippy_lints/src/zero_sized_map_values.rs @@ -49,7 +49,7 @@ impl LateLintPass<'_> for ZeroSizedMapValues { && !in_trait_impl(cx, hir_ty.hir_id) // We don't care about infer vars && let ty = ty_from_hir_ty(cx, hir_ty.as_unambig_ty()) - && (ty.is_diag_item(cx, sym::HashMap) || ty.is_diag_item(cx, sym::BTreeMap)) + && matches!(ty.opt_diag_name(cx), Some(sym::HashMap | sym::BTreeMap)) && let ty::Adt(_, args) = ty.kind() && let ty = args.type_at(1) // Ensure that no type information is missing, to avoid a delayed bug in the compiler if this is not the case. diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 7e3fa4f9909b..83b0aebb9e8e 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -809,10 +809,12 @@ impl<'tcx> ConstEvalCtxt<'tcx> { | sym::i128_legacy_const_max ) ) || self.tcx.opt_parent(did).is_some_and(|parent| { - parent.is_diag_item(&self.tcx, sym::f16_consts_mod) - || parent.is_diag_item(&self.tcx, sym::f32_consts_mod) - || parent.is_diag_item(&self.tcx, sym::f64_consts_mod) - || parent.is_diag_item(&self.tcx, sym::f128_consts_mod) + matches!( + parent.opt_diag_name(&self.tcx), + Some( + sym::f16_consts_mod | sym::f32_consts_mod | sym::f64_consts_mod | sym::f128_consts_mod + ) + ) })) => { did diff --git a/clippy_utils/src/sym.rs b/clippy_utils/src/sym.rs index 9e7f6e4ee308..db7e263b6269 100644 --- a/clippy_utils/src/sym.rs +++ b/clippy_utils/src/sym.rs @@ -58,6 +58,7 @@ generate! { LowerHex, MAX, MIN, + MaybeDef, MsrvStack, Octal, OpenOptions, @@ -192,6 +193,8 @@ generate! { io, is_ascii, is_char_boundary, + is_diag_item, + is_diagnostic_item, is_digit, is_empty, is_err, @@ -283,6 +286,7 @@ generate! { repeat, replace, replacen, + res, reserve, resize, restriction, From 29659288ffc98b7406c5c16110e8b9a10f541557 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Wed, 17 Dec 2025 12:16:10 +0100 Subject: [PATCH 224/489] feat(repeated_is_diagnostic_item): new internal lint --- clippy_lints_internal/src/internal_paths.rs | 1 + clippy_lints_internal/src/lib.rs | 2 + .../src/repeated_is_diagnostic_item.rs | 561 ++++++++++++++++++ .../repeated_is_diagnostic_item.fixed | 77 +++ .../repeated_is_diagnostic_item.rs | 77 +++ .../repeated_is_diagnostic_item.stderr | 82 +++ .../repeated_is_diagnostic_item_unfixable.rs | 213 +++++++ ...peated_is_diagnostic_item_unfixable.stderr | 374 ++++++++++++ 8 files changed, 1387 insertions(+) create mode 100644 clippy_lints_internal/src/repeated_is_diagnostic_item.rs create mode 100644 tests/ui-internal/repeated_is_diagnostic_item.fixed create mode 100644 tests/ui-internal/repeated_is_diagnostic_item.rs create mode 100644 tests/ui-internal/repeated_is_diagnostic_item.stderr create mode 100644 tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs create mode 100644 tests/ui-internal/repeated_is_diagnostic_item_unfixable.stderr diff --git a/clippy_lints_internal/src/internal_paths.rs b/clippy_lints_internal/src/internal_paths.rs index 95bdf27b019c..14d4139a0065 100644 --- a/clippy_lints_internal/src/internal_paths.rs +++ b/clippy_lints_internal/src/internal_paths.rs @@ -17,6 +17,7 @@ pub static TY_CTXT: PathLookup = type_path!(rustc_middle::ty::TyCtxt); // Paths in clippy itself pub static CLIPPY_SYM_MODULE: PathLookup = type_path!(clippy_utils::sym); +pub static MAYBE_DEF: PathLookup = type_path!(clippy_utils::res::MaybeDef); pub static MSRV_STACK: PathLookup = type_path!(clippy_utils::msrvs::MsrvStack); pub static PATH_LOOKUP_NEW: PathLookup = value_path!(clippy_utils::paths::PathLookup::new); pub static SPAN_LINT_AND_THEN: PathLookup = value_path!(clippy_utils::diagnostics::span_lint_and_then); diff --git a/clippy_lints_internal/src/lib.rs b/clippy_lints_internal/src/lib.rs index d686ba73387c..cca5608fa6be 100644 --- a/clippy_lints_internal/src/lib.rs +++ b/clippy_lints_internal/src/lib.rs @@ -38,6 +38,7 @@ mod lint_without_lint_pass; mod msrv_attr_impl; mod outer_expn_data_pass; mod produce_ice; +mod repeated_is_diagnostic_item; mod symbols; mod unnecessary_def_path; mod unsorted_clippy_utils_paths; @@ -77,4 +78,5 @@ pub fn register_lints(store: &mut LintStore) { store.register_late_pass(|_| Box::new(msrv_attr_impl::MsrvAttrImpl)); store.register_late_pass(|_| Box::new(almost_standard_lint_formulation::AlmostStandardFormulation::new())); store.register_late_pass(|_| Box::new(unusual_names::UnusualNames)); + store.register_late_pass(|_| Box::new(repeated_is_diagnostic_item::RepeatedIsDiagnosticItem)); } diff --git a/clippy_lints_internal/src/repeated_is_diagnostic_item.rs b/clippy_lints_internal/src/repeated_is_diagnostic_item.rs new file mode 100644 index 000000000000..55fb78b1e296 --- /dev/null +++ b/clippy_lints_internal/src/repeated_is_diagnostic_item.rs @@ -0,0 +1,561 @@ +use std::iter; +use std::ops::ControlFlow; + +use crate::internal_paths::MAYBE_DEF; +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::res::{MaybeDef, MaybeTypeckRes}; +use clippy_utils::source::{snippet_indent, snippet_with_applicability}; +use clippy_utils::visitors::for_each_expr; +use clippy_utils::{eq_expr_value, if_sequence, sym}; +use rustc_errors::Applicability; +use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Node, StmtKind, UnOp}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::print::with_forced_trimmed_paths; +use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::Span; + +declare_tool_lint! { + /// ### What it does + /// Checks for repeated use of `MaybeDef::is_diag_item`/`TyCtxt::is_diagnostic_item`; + /// suggests to first call `MaybDef::opt_diag_name`/`TyCtxt::get_diagnostic_name` and then + /// compare the output with all the `Symbol`s. + /// + /// ### Why is this bad? + /// Each of such calls ultimately invokes the `diagnostic_items` query. + /// While the query is cached, it's still better to avoid calling it multiple times if possible. + /// + /// ### Example + /// ```no_run + /// ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result) + /// cx.tcx.is_diagnostic_item(sym::Option, did) || cx.tcx.is_diagnostic_item(sym::Result, did) + /// + /// if ty.is_diag_item(cx, sym::Option) { + /// .. + /// } else if ty.is_diag_item(cx, sym::Result) { + /// .. + /// } else { + /// .. + /// } + /// + /// if cx.tcx.is_diagnostic_item(sym::Option, did) { + /// .. + /// } else if cx.tcx.is_diagnostic_item(sym::Result, did) { + /// .. + /// } else { + /// .. + /// } + /// + /// { + /// if ty.is_diag_item(cx, sym::Option) { + /// .. + /// } + /// if ty.is_diag_item(cx, sym::Result) { + /// .. + /// } + /// } + /// + /// { + /// if cx.tcx.is_diagnostic_item(sym::Option, did) { + /// .. + /// } + /// if cx.tcx.is_diagnostic_item(sym::Result, did) { + /// .. + /// } + /// } + /// ``` + /// Use instead: + /// ```no_run + /// matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)) + /// matches!(cx.tcx.get_diagnostic_name(did), Some(sym::Option | sym::Result)) + /// + /// match ty.opt_diag_name(cx) { + /// Some(sym::Option) => { + /// .. + /// } + /// Some(sym::Result) => { + /// .. + /// } + /// _ => { + /// .. + /// } + /// } + /// + /// match cx.tcx.get_diagnostic_name(did) { + /// Some(sym::Option) => { + /// .. + /// } + /// Some(sym::Result) => { + /// .. + /// } + /// _ => { + /// .. + /// } + /// } + /// + /// { + /// let name = ty.opt_diag_name(cx); + /// if name == Some(sym::Option) { + /// .. + /// } + /// if name == Some(sym::Result) { + /// .. + /// } + /// } + /// + /// { + /// let name = cx.tcx.get_diagnostic_name(did); + /// if name == Some(sym::Option) { + /// .. + /// } + /// if name == Some(sym::Result) { + /// .. + /// } + /// } + /// ``` + pub clippy::REPEATED_IS_DIAGNOSTIC_ITEM, + Warn, + "repeated use of `MaybeDef::is_diag_item`/`TyCtxt::is_diagnostic_item`" +} +declare_lint_pass!(RepeatedIsDiagnosticItem => [REPEATED_IS_DIAGNOSTIC_ITEM]); + +const NOTE: &str = "each call performs the same compiler query -- it's faster to query once, and reuse the results"; + +impl<'tcx> LateLintPass<'tcx> for RepeatedIsDiagnosticItem { + #[expect(clippy::too_many_lines)] + fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx Block<'_>) { + for [(cond1, stmt1_span), (cond2, stmt2_span)] in block + .stmts + .windows(2) + .filter_map(|pair| { + if let [if1, if2] = pair + && let StmtKind::Expr(e1) | StmtKind::Semi(e1) = if1.kind + && let ExprKind::If(cond1, ..) = e1.kind + && let StmtKind::Expr(e2) | StmtKind::Semi(e2) = if2.kind + && let ExprKind::If(cond2, ..) = e2.kind + { + Some([(cond1, if1.span), (cond2, if2.span)]) + } else { + None + } + }) + .chain( + if let Some(if1) = block.stmts.last() + && let StmtKind::Expr(e1) | StmtKind::Semi(e1) = if1.kind + && let ExprKind::If(cond1, ..) = e1.kind + && let Some(e2) = block.expr + && let ExprKind::If(cond2, ..) = e2.kind + { + Some([(cond1, if1.span), (cond2, e2.span)]) + } else { + None + }, + ) + { + let lint_span = stmt1_span.to(stmt2_span); + + // if recv1.is_diag_item(cx, sym1) && .. { + // .. + // } + // if recv2.is_diag_item(cx, sym2) && .. { + // .. + // } + if let Some(first @ (span1, (cx1, recv1, _))) = extract_nested_is_diag_item(cx, cond1) + && let Some(second @ (span2, (cx2, recv2, _))) = extract_nested_is_diag_item(cx, cond2) + && eq_expr_value(cx, cx1, cx2) + && eq_expr_value(cx, recv1, recv2) + { + let recv_ty = + with_forced_trimmed_paths!(format!("{}", cx.typeck_results().expr_ty_adjusted(recv1).peel_refs())); + let recv_ty = recv_ty.trim_end_matches("<'_>"); + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + lint_span, + format!("repeated calls to `{recv_ty}::is_diag_item`"), + |diag| { + diag.span_labels([span1, span2], "called here"); + diag.note(NOTE); + + let mut app = Applicability::HasPlaceholders; + let cx_str = snippet_with_applicability(cx, cx1.span, "_", &mut app); + let recv = snippet_with_applicability(cx, recv1.span, "_", &mut app); + let indent = snippet_indent(cx, stmt1_span).unwrap_or_default(); + let sugg: Vec<_> = iter::once(( + stmt1_span.shrink_to_lo(), + format!("let /* name */ = {recv}.opt_diag_name({cx_str});\n{indent}"), + )) // call `opt_diag_name` once + .chain([first, second].into_iter().map(|(expr_span, (_, _, sym))| { + let sym = snippet_with_applicability(cx, sym.span, "_", &mut app); + (expr_span, format!("/* name */ == Some({sym})")) + })) + .collect(); + + diag.multipart_suggestion_verbose( + format!("call `{recv_ty}::opt_diag_name`, and reuse the results"), + sugg, + app, + ); + }, + ); + return; + } + + // if cx.tcx.is_diagnostic_item(sym1, did) && .. { + // .. + // } + // if cx.tcx.is_diagnostic_item(sym2, did) && .. { + // .. + // } + if let Some(first @ (span1, (tcx1, did1, _))) = extract_nested_is_diagnostic_item(cx, cond1) + && let Some(second @ (span2, (tcx2, did2, _))) = extract_nested_is_diagnostic_item(cx, cond2) + && eq_expr_value(cx, tcx1, tcx2) + && eq_expr_value(cx, did1, did2) + { + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + lint_span, + "repeated calls to `TyCtxt::is_diagnostic_item`", + |diag| { + diag.span_labels([span1, span2], "called here"); + diag.note(NOTE); + + let mut app = Applicability::HasPlaceholders; + let tcx = snippet_with_applicability(cx, tcx1.span, "_", &mut app); + let did = snippet_with_applicability(cx, did1.span, "_", &mut app); + let indent = snippet_indent(cx, stmt1_span).unwrap_or_default(); + let sugg: Vec<_> = iter::once(( + stmt1_span.shrink_to_lo(), + format!("let /* name */ = {tcx}.get_diagnostic_name({did});\n{indent}"), + )) // call `get_diagnostic_name` once + .chain([first, second].into_iter().map(|(expr_span, (_, _, sym))| { + let sym = snippet_with_applicability(cx, sym.span, "_", &mut app); + (expr_span, format!("/* name */ == Some({sym})")) + })) + .collect(); + + diag.multipart_suggestion_verbose( + "call `TyCtxt::get_diagnostic_name`, and reuse the results", + sugg, + app, + ); + }, + ); + } + } + } + + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { + if let ExprKind::Binary(op, left, right) = expr.kind { + if op.node == BinOpKind::Or { + check_ors(cx, expr.span, left, right); + } else if op.node == BinOpKind::And + && let ExprKind::Unary(UnOp::Not, left) = left.kind + && let ExprKind::Unary(UnOp::Not, right) = right.kind + { + check_ands(cx, expr.span, left, right); + } + } else if let (conds, _) = if_sequence(expr) + && !conds.is_empty() + { + check_if_chains(cx, expr, conds); + } + } +} + +fn check_ors(cx: &LateContext<'_>, span: Span, left: &Expr<'_>, right: &Expr<'_>) { + // recv1.is_diag_item(cx, sym1) || recv2.is_diag_item(cx, sym2) + if let Some((cx1, recv1, sym1)) = extract_is_diag_item(cx, left) + && let Some((cx2, recv2, sym2)) = extract_is_diag_item(cx, right) + && eq_expr_value(cx, cx1, cx2) + && eq_expr_value(cx, recv1, recv2) + { + let recv_ty = + with_forced_trimmed_paths!(format!("{}", cx.typeck_results().expr_ty_adjusted(recv1).peel_refs())); + let recv_ty = recv_ty.trim_end_matches("<'_>"); + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + span, + format!("repeated calls to `{recv_ty}::is_diag_item`"), + |diag| { + diag.note(NOTE); + + let mut app = Applicability::MachineApplicable; + let cx_str = snippet_with_applicability(cx, cx1.span, "_", &mut app); + let recv = snippet_with_applicability(cx, recv1.span, "_", &mut app); + let sym1 = snippet_with_applicability(cx, sym1.span, "_", &mut app); + let sym2 = snippet_with_applicability(cx, sym2.span, "_", &mut app); + diag.span_suggestion_verbose( + span, + format!("call `{recv_ty}::opt_diag_name`, and reuse the results"), + format!("matches!({recv}.opt_diag_name({cx_str}), Some({sym1} | {sym2}))"), + app, + ); + }, + ); + return; + } + + // cx.tcx.is_diagnostic_item(sym1, did) || cx.tcx.is_diagnostic_item(sym2, did) + if let Some((tcx1, did1, sym1)) = extract_is_diagnostic_item(cx, left) + && let Some((tcx2, did2, sym2)) = extract_is_diagnostic_item(cx, right) + && eq_expr_value(cx, tcx1, tcx2) + && eq_expr_value(cx, did1, did2) + { + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + span, + "repeated calls to `TyCtxt::is_diagnostic_item`", + |diag| { + diag.note(NOTE); + + let mut app = Applicability::MachineApplicable; + let tcx = snippet_with_applicability(cx, tcx1.span, "_", &mut app); + let did = snippet_with_applicability(cx, did1.span, "_", &mut app); + let sym1 = snippet_with_applicability(cx, sym1.span, "_", &mut app); + let sym2 = snippet_with_applicability(cx, sym2.span, "_", &mut app); + diag.span_suggestion_verbose( + span, + "call `TyCtxt::get_diagnostic_name`, and reuse the results", + format!("matches!({tcx}.get_diagnostic_name({did}), Some({sym1} | {sym2}))"), + app, + ); + }, + ); + } +} + +fn check_ands(cx: &LateContext<'_>, span: Span, left: &Expr<'_>, right: &Expr<'_>) { + // !recv1.is_diag_item(cx, sym1) && !recv2.is_diag_item(cx, sym2) + if let Some((cx1, recv1, sym1)) = extract_is_diag_item(cx, left) + && let Some((cx2, recv2, sym2)) = extract_is_diag_item(cx, right) + && eq_expr_value(cx, cx1, cx2) + && eq_expr_value(cx, recv1, recv2) + { + let recv_ty = + with_forced_trimmed_paths!(format!("{}", cx.typeck_results().expr_ty_adjusted(recv1).peel_refs())); + let recv_ty = recv_ty.trim_end_matches("<'_>"); + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + span, + format!("repeated calls to `{recv_ty}::is_diag_item`"), + |diag| { + diag.note(NOTE); + + let mut app = Applicability::MachineApplicable; + let cx_str = snippet_with_applicability(cx, cx1.span, "_", &mut app); + let recv = snippet_with_applicability(cx, recv1.span, "_", &mut app); + let sym1 = snippet_with_applicability(cx, sym1.span, "_", &mut app); + let sym2 = snippet_with_applicability(cx, sym2.span, "_", &mut app); + diag.span_suggestion_verbose( + span, + format!("call `{recv_ty}::opt_diag_name`, and reuse the results"), + format!("!matches!({recv}.opt_diag_name({cx_str}), Some({sym1} | {sym2}))"), + app, + ); + }, + ); + return; + } + + // !cx.tcx.is_diagnostic_item(sym1, did) && !cx.tcx.is_diagnostic_item(sym2, did) + if let Some((tcx1, did1, sym1)) = extract_is_diagnostic_item(cx, left) + && let Some((tcx2, did2, sym2)) = extract_is_diagnostic_item(cx, right) + && eq_expr_value(cx, tcx1, tcx2) + && eq_expr_value(cx, did1, did2) + { + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + span, + "repeated calls to `TyCtxt::is_diagnostic_item`", + |diag| { + diag.note(NOTE); + + let mut app = Applicability::MachineApplicable; + let tcx = snippet_with_applicability(cx, tcx1.span, "_", &mut app); + let did = snippet_with_applicability(cx, did1.span, "_", &mut app); + let sym1 = snippet_with_applicability(cx, sym1.span, "_", &mut app); + let sym2 = snippet_with_applicability(cx, sym2.span, "_", &mut app); + diag.span_suggestion_verbose( + span, + "call `TyCtxt::get_diagnostic_name`, and reuse the results", + format!("!matches!({tcx}.get_diagnostic_name({did}), Some({sym1} | {sym2}))"), + app, + ); + }, + ); + } +} + +fn check_if_chains<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, conds: Vec<&'tcx Expr<'_>>) { + // if ty.is_diag_item(cx, sym1) { + // .. + // } else if ty.is_diag_item(cx, sym2) { + // .. + // } else { + // .. + // } + let mut found = conds.iter().filter_map(|cond| extract_nested_is_diag_item(cx, cond)); + if let Some(first @ (_, (cx_1, recv1, _))) = found.next() + && let other = + found.filter(|(_, (cx_, recv, _))| eq_expr_value(cx, cx_, cx_1) && eq_expr_value(cx, recv, recv1)) + && let results = iter::once(first).chain(other).collect::>() + && results.len() > 1 + { + let recv_ty = + with_forced_trimmed_paths!(format!("{}", cx.typeck_results().expr_ty_adjusted(recv1).peel_refs())); + let recv_ty = recv_ty.trim_end_matches("<'_>"); + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + expr.span, + format!("repeated calls to `{recv_ty}::is_diag_item`"), + |diag| { + diag.span_labels(results.iter().map(|(span, _)| *span), "called here"); + diag.note(NOTE); + + let mut app = Applicability::HasPlaceholders; + let cx_str = snippet_with_applicability(cx, cx_1.span, "_", &mut app); + let recv = snippet_with_applicability(cx, recv1.span, "_", &mut app); + let span_before = if let Node::LetStmt(let_stmt) = cx.tcx.parent_hir_node(expr.hir_id) { + let_stmt.span + } else { + expr.span + }; + let indent = snippet_indent(cx, span_before).unwrap_or_default(); + let sugg: Vec<_> = iter::once(( + span_before.shrink_to_lo(), + format!("let /* name */ = {recv}.opt_diag_name({cx_str});\n{indent}"), + )) // call `opt_diag_name` once + .chain(results.into_iter().map(|(expr_span, (_, _, sym))| { + let sym = snippet_with_applicability(cx, sym.span, "_", &mut app); + (expr_span, format!("/* name */ == Some({sym})")) + })) + .collect(); + + diag.multipart_suggestion_verbose( + format!("call `{recv_ty}::opt_diag_name`, and reuse the results"), + sugg, + app, + ); + }, + ); + } + + // if cx.tcx.is_diagnostic_item(sym1, did) { + // .. + // } else if cx.tcx.is_diagnostic_item(sym2, did) { + // .. + // } else { + // .. + // } + let mut found = conds + .into_iter() + .filter_map(|cond| extract_nested_is_diagnostic_item(cx, cond)); + if let Some(first @ (_, (tcx1, did1, _))) = found.next() + && let other = found.filter(|(_, (tcx, did, _))| eq_expr_value(cx, tcx, tcx1) && eq_expr_value(cx, did, did1)) + && let results = iter::once(first).chain(other).collect::>() + && results.len() > 1 + { + span_lint_and_then( + cx, + REPEATED_IS_DIAGNOSTIC_ITEM, + expr.span, + "repeated calls to `TyCtxt::is_diagnostic_item`", + |diag| { + diag.span_labels(results.iter().map(|(span, _)| *span), "called here"); + diag.note(NOTE); + + let mut app = Applicability::HasPlaceholders; + let tcx = snippet_with_applicability(cx, tcx1.span, "_", &mut app); + let recv = snippet_with_applicability(cx, did1.span, "_", &mut app); + let span_before = if let Node::LetStmt(let_stmt) = cx.tcx.parent_hir_node(expr.hir_id) { + let_stmt.span + } else { + expr.span + }; + let indent = snippet_indent(cx, span_before).unwrap_or_default(); + let sugg: Vec<_> = iter::once(( + span_before.shrink_to_lo(), + format!("let /* name */ = {tcx}.get_diagnostic_name({recv});\n{indent}"), + )) // call `get_diagnostic_name` once + .chain(results.into_iter().map(|(expr_span, (_, _, sym))| { + let sym = snippet_with_applicability(cx, sym.span, "_", &mut app); + (expr_span, format!("/* name */ == Some({sym})")) + })) + .collect(); + + diag.multipart_suggestion_verbose( + "call `TyCtxt::get_diagnostic_name`, and reuse the results", + sugg, + app, + ); + }, + ); + } +} + +fn extract_is_diag_item<'tcx>( + cx: &LateContext<'_>, + expr: &'tcx Expr<'tcx>, +) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, &'tcx Expr<'tcx>)> { + if let ExprKind::MethodCall(is_diag_item, recv, [cx_, sym], _) = expr.kind + && is_diag_item.ident.name == sym::is_diag_item + // Whether this a method from the `MaybeDef` trait + && let Some(did) = cx.ty_based_def(expr).opt_parent(cx).opt_def_id() + && MAYBE_DEF.matches(cx, did) + { + Some((cx_, recv, sym)) + } else { + None + } +} + +fn extract_is_diagnostic_item<'tcx>( + cx: &LateContext<'_>, + expr: &'tcx Expr<'tcx>, +) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, &'tcx Expr<'tcx>)> { + if let ExprKind::MethodCall(is_diag_item, tcx, [sym, did], _) = expr.kind + && is_diag_item.ident.name == sym::is_diagnostic_item + // Whether this is an inherent method on `TyCtxt` + && cx + .ty_based_def(expr) + .opt_parent(cx) + .opt_impl_ty(cx) + .is_diag_item(cx, sym::TyCtxt) + { + Some((tcx, did, sym)) + } else { + None + } +} + +fn extract_nested_is_diag_item<'tcx>( + cx: &LateContext<'tcx>, + cond: &'tcx Expr<'_>, +) -> Option<(Span, (&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, &'tcx Expr<'tcx>))> { + for_each_expr(cx, cond, |cond_part| { + if let Some(res) = extract_is_diag_item(cx, cond_part) { + ControlFlow::Break((cond_part.span, res)) + } else { + ControlFlow::Continue(()) + } + }) +} + +fn extract_nested_is_diagnostic_item<'tcx>( + cx: &LateContext<'tcx>, + cond: &'tcx Expr<'_>, +) -> Option<(Span, (&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, &'tcx Expr<'tcx>))> { + for_each_expr(cx, cond, |cond_part| { + if let Some(res) = extract_is_diagnostic_item(cx, cond_part) { + ControlFlow::Break((cond_part.span, res)) + } else { + ControlFlow::Continue(()) + } + }) +} diff --git a/tests/ui-internal/repeated_is_diagnostic_item.fixed b/tests/ui-internal/repeated_is_diagnostic_item.fixed new file mode 100644 index 000000000000..fcacf504804c --- /dev/null +++ b/tests/ui-internal/repeated_is_diagnostic_item.fixed @@ -0,0 +1,77 @@ +#![feature(rustc_private)] + +extern crate rustc_hir; +extern crate rustc_lint; +extern crate rustc_middle; +extern crate rustc_span; + +use clippy_utils::res::MaybeDef; +use clippy_utils::sym; +use rustc_hir::def_id::DefId; +use rustc_lint::LateContext; +use rustc_middle::ty::{AdtDef, Ty, TyCtxt}; +use rustc_span::Symbol; + +fn binops(cx: &LateContext<'_>, ty: Ty<'_>, adt_def: &AdtDef<'_>) { + let did = ty.opt_def_id().unwrap(); + + let _ = matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)); + //~^ repeated_is_diagnostic_item + let _ = !matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)); + //~^ repeated_is_diagnostic_item + let _ = matches!(adt_def.opt_diag_name(cx), Some(sym::Option | sym::Result)); + //~^ repeated_is_diagnostic_item + let _ = !matches!(adt_def.opt_diag_name(cx), Some(sym::Option | sym::Result)); + //~^ repeated_is_diagnostic_item + let _ = matches!(cx.tcx.get_diagnostic_name(did), Some(sym::Option | sym::Result)); + //~^ repeated_is_diagnostic_item + let _ = !matches!(cx.tcx.get_diagnostic_name(did), Some(sym::Option | sym::Result)); + //~^ repeated_is_diagnostic_item + + // Don't lint: `is_diagnostic_item` is called not on `TyCtxt` + struct FakeTyCtxt; + impl FakeTyCtxt { + fn is_diagnostic_item(&self, sym: Symbol, did: DefId) -> bool { + unimplemented!() + } + } + let f = FakeTyCtxt; + let _ = f.is_diagnostic_item(sym::Option, did) || f.is_diagnostic_item(sym::Result, did); + + // Don't lint: `is_diagnostic_item` on `TyCtxt` comes from a(n unrelated) trait + trait IsDiagnosticItem { + fn is_diagnostic_item(&self, sym: Symbol, did: DefId) -> bool; + } + impl IsDiagnosticItem for TyCtxt<'_> { + fn is_diagnostic_item(&self, sym: Symbol, did: DefId) -> bool { + unimplemented!() + } + } + let _ = IsDiagnosticItem::is_diagnostic_item(&cx.tcx, sym::Option, did) + || IsDiagnosticItem::is_diagnostic_item(&cx.tcx, sym::Result, did); + + // Don't lint: `is_diag_item` is an inherent method + struct DoesntImplMaybeDef; + impl DoesntImplMaybeDef { + fn is_diag_item(&self, cx: &LateContext, sym: Symbol) -> bool { + unimplemented!() + } + } + let d = DoesntImplMaybeDef; + let _ = d.is_diag_item(cx, sym::Option) || d.is_diag_item(cx, sym::Result); + + // Don't lint: `is_diag_item` comes from a trait other than `MaybeDef` + trait FakeMaybeDef { + fn is_diag_item(&self, cx: &LateContext, sym: Symbol) -> bool; + } + struct Bar; + impl FakeMaybeDef for Bar { + fn is_diag_item(&self, cx: &LateContext, sym: Symbol) -> bool { + unimplemented!() + } + } + let b = Bar; + let _ = b.is_diag_item(cx, sym::Option) || b.is_diag_item(cx, sym::Result); +} + +fn main() {} diff --git a/tests/ui-internal/repeated_is_diagnostic_item.rs b/tests/ui-internal/repeated_is_diagnostic_item.rs new file mode 100644 index 000000000000..7ccbbfd94029 --- /dev/null +++ b/tests/ui-internal/repeated_is_diagnostic_item.rs @@ -0,0 +1,77 @@ +#![feature(rustc_private)] + +extern crate rustc_hir; +extern crate rustc_lint; +extern crate rustc_middle; +extern crate rustc_span; + +use clippy_utils::res::MaybeDef; +use clippy_utils::sym; +use rustc_hir::def_id::DefId; +use rustc_lint::LateContext; +use rustc_middle::ty::{AdtDef, Ty, TyCtxt}; +use rustc_span::Symbol; + +fn binops(cx: &LateContext<'_>, ty: Ty<'_>, adt_def: &AdtDef<'_>) { + let did = ty.opt_def_id().unwrap(); + + let _ = ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result); + //~^ repeated_is_diagnostic_item + let _ = !ty.is_diag_item(cx, sym::Option) && !ty.is_diag_item(cx, sym::Result); + //~^ repeated_is_diagnostic_item + let _ = adt_def.is_diag_item(cx, sym::Option) || adt_def.is_diag_item(cx, sym::Result); + //~^ repeated_is_diagnostic_item + let _ = !adt_def.is_diag_item(cx, sym::Option) && !adt_def.is_diag_item(cx, sym::Result); + //~^ repeated_is_diagnostic_item + let _ = cx.tcx.is_diagnostic_item(sym::Option, did) || cx.tcx.is_diagnostic_item(sym::Result, did); + //~^ repeated_is_diagnostic_item + let _ = !cx.tcx.is_diagnostic_item(sym::Option, did) && !cx.tcx.is_diagnostic_item(sym::Result, did); + //~^ repeated_is_diagnostic_item + + // Don't lint: `is_diagnostic_item` is called not on `TyCtxt` + struct FakeTyCtxt; + impl FakeTyCtxt { + fn is_diagnostic_item(&self, sym: Symbol, did: DefId) -> bool { + unimplemented!() + } + } + let f = FakeTyCtxt; + let _ = f.is_diagnostic_item(sym::Option, did) || f.is_diagnostic_item(sym::Result, did); + + // Don't lint: `is_diagnostic_item` on `TyCtxt` comes from a(n unrelated) trait + trait IsDiagnosticItem { + fn is_diagnostic_item(&self, sym: Symbol, did: DefId) -> bool; + } + impl IsDiagnosticItem for TyCtxt<'_> { + fn is_diagnostic_item(&self, sym: Symbol, did: DefId) -> bool { + unimplemented!() + } + } + let _ = IsDiagnosticItem::is_diagnostic_item(&cx.tcx, sym::Option, did) + || IsDiagnosticItem::is_diagnostic_item(&cx.tcx, sym::Result, did); + + // Don't lint: `is_diag_item` is an inherent method + struct DoesntImplMaybeDef; + impl DoesntImplMaybeDef { + fn is_diag_item(&self, cx: &LateContext, sym: Symbol) -> bool { + unimplemented!() + } + } + let d = DoesntImplMaybeDef; + let _ = d.is_diag_item(cx, sym::Option) || d.is_diag_item(cx, sym::Result); + + // Don't lint: `is_diag_item` comes from a trait other than `MaybeDef` + trait FakeMaybeDef { + fn is_diag_item(&self, cx: &LateContext, sym: Symbol) -> bool; + } + struct Bar; + impl FakeMaybeDef for Bar { + fn is_diag_item(&self, cx: &LateContext, sym: Symbol) -> bool { + unimplemented!() + } + } + let b = Bar; + let _ = b.is_diag_item(cx, sym::Option) || b.is_diag_item(cx, sym::Result); +} + +fn main() {} diff --git a/tests/ui-internal/repeated_is_diagnostic_item.stderr b/tests/ui-internal/repeated_is_diagnostic_item.stderr new file mode 100644 index 000000000000..8c52ba561d79 --- /dev/null +++ b/tests/ui-internal/repeated_is_diagnostic_item.stderr @@ -0,0 +1,82 @@ +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item.rs:18:13 + | +LL | let _ = ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results + = note: `-D clippy::repeated-is-diagnostic-item` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::repeated_is_diagnostic_item)]` +help: call `Ty::opt_diag_name`, and reuse the results + | +LL - let _ = ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result); +LL + let _ = matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)); + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item.rs:20:13 + | +LL | let _ = !ty.is_diag_item(cx, sym::Option) && !ty.is_diag_item(cx, sym::Result); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL - let _ = !ty.is_diag_item(cx, sym::Option) && !ty.is_diag_item(cx, sym::Result); +LL + let _ = !matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result)); + | + +error: repeated calls to `AdtDef::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item.rs:22:13 + | +LL | let _ = adt_def.is_diag_item(cx, sym::Option) || adt_def.is_diag_item(cx, sym::Result); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `AdtDef::opt_diag_name`, and reuse the results + | +LL - let _ = adt_def.is_diag_item(cx, sym::Option) || adt_def.is_diag_item(cx, sym::Result); +LL + let _ = matches!(adt_def.opt_diag_name(cx), Some(sym::Option | sym::Result)); + | + +error: repeated calls to `AdtDef::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item.rs:24:13 + | +LL | let _ = !adt_def.is_diag_item(cx, sym::Option) && !adt_def.is_diag_item(cx, sym::Result); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `AdtDef::opt_diag_name`, and reuse the results + | +LL - let _ = !adt_def.is_diag_item(cx, sym::Option) && !adt_def.is_diag_item(cx, sym::Result); +LL + let _ = !matches!(adt_def.opt_diag_name(cx), Some(sym::Option | sym::Result)); + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item.rs:26:13 + | +LL | let _ = cx.tcx.is_diagnostic_item(sym::Option, did) || cx.tcx.is_diagnostic_item(sym::Result, did); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL - let _ = cx.tcx.is_diagnostic_item(sym::Option, did) || cx.tcx.is_diagnostic_item(sym::Result, did); +LL + let _ = matches!(cx.tcx.get_diagnostic_name(did), Some(sym::Option | sym::Result)); + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item.rs:28:13 + | +LL | let _ = !cx.tcx.is_diagnostic_item(sym::Option, did) && !cx.tcx.is_diagnostic_item(sym::Result, did); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL - let _ = !cx.tcx.is_diagnostic_item(sym::Option, did) && !cx.tcx.is_diagnostic_item(sym::Result, did); +LL + let _ = !matches!(cx.tcx.get_diagnostic_name(did), Some(sym::Option | sym::Result)); + | + +error: aborting due to 6 previous errors + diff --git a/tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs b/tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs new file mode 100644 index 000000000000..807da07ce8aa --- /dev/null +++ b/tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs @@ -0,0 +1,213 @@ +//@no-rustfix +#![feature(rustc_private)] + +extern crate rustc_hir; +extern crate rustc_lint; +extern crate rustc_middle; +extern crate rustc_span; + +use clippy_utils::res::MaybeDef; +use clippy_utils::sym; +use rustc_hir::def_id::DefId; +use rustc_lint::LateContext; +use rustc_middle::ty::{AdtDef, Ty, TyCtxt}; +use rustc_span::Symbol; + +fn main() {} + +// if-chains with repeated calls on the same `ty` +fn if_chains(cx: &LateContext<'_>, ty: Ty<'_>, adt_def: &AdtDef<'_>) { + let did = ty.opt_def_id().unwrap(); + + let _ = if ty.is_diag_item(cx, sym::Option) { + //~^ repeated_is_diagnostic_item + "Option" + } else if ty.is_diag_item(cx, sym::Result) { + "Result" + } else { + return; + }; + // should ideally suggest the following: + // let _ = match ty.opt_diag_name() { + // Some(sym::Option) => { + // "Option" + // } + // Some(sym::Result) => { + // "Result" + // } + // _ => { + // return; + // } + // }; + + // same but in a stmt + if ty.is_diag_item(cx, sym::Option) { + //~^ repeated_is_diagnostic_item + eprintln!("Option"); + } else if ty.is_diag_item(cx, sym::Result) { + eprintln!("Result"); + } + // should ideally suggest the following: + // match ty.opt_diag_name() { + // Some(sym::Option) => { + // "Option" + // } + // Some(sym::Result) => { + // "Result" + // } + // _ => {} + // }; + + // nested conditions + let _ = if ty.is_diag_item(cx, sym::Option) && 4 == 5 { + //~^ repeated_is_diagnostic_item + "Option" + } else if ty.is_diag_item(cx, sym::Result) && 4 == 5 { + "Result" + } else { + return; + }; + + let _ = if cx.tcx.is_diagnostic_item(sym::Option, did) { + //~^ repeated_is_diagnostic_item + "Option" + } else if cx.tcx.is_diagnostic_item(sym::Result, did) { + "Result" + } else { + return; + }; + // should ideally suggest the following: + // let _ = match cx.get_diagnostic_name(did) { + // Some(sym::Option) => { + // "Option" + // } + // Some(sym::Result) => { + // "Result" + // } + // _ => { + // return; + // } + // }; + + // same but in a stmt + if cx.tcx.is_diagnostic_item(sym::Option, did) { + //~^ repeated_is_diagnostic_item + eprintln!("Option"); + } else if cx.tcx.is_diagnostic_item(sym::Result, did) { + eprintln!("Result"); + } + // should ideally suggest the following: + // match cx.tcx.get_diagnostic_name(did) { + // Some(sym::Option) => { + // "Option" + // } + // Some(sym::Result) => { + // "Result" + // } + // _ => {} + // }; + + // nested conditions + let _ = if cx.tcx.is_diagnostic_item(sym::Option, did) && 4 == 5 { + //~^ repeated_is_diagnostic_item + "Option" + } else if cx.tcx.is_diagnostic_item(sym::Result, did) && 4 == 5 { + "Result" + } else { + return; + }; +} + +// if-chains with repeated calls on the same `ty` +fn consecutive_ifs(cx: &LateContext<'_>, ty: Ty<'_>, adt_def: &AdtDef<'_>) { + let did = ty.opt_def_id().unwrap(); + + { + if ty.is_diag_item(cx, sym::Option) { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if ty.is_diag_item(cx, sym::Result) { + println!("Result"); + } + println!("done!") + } + + // nested conditions + { + if ty.is_diag_item(cx, sym::Option) && 4 == 5 { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if ty.is_diag_item(cx, sym::Result) && 4 == 5 { + println!("Result"); + } + println!("done!") + } + + { + if cx.tcx.is_diagnostic_item(sym::Option, did) { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if cx.tcx.is_diagnostic_item(sym::Result, did) { + println!("Result"); + } + println!("done!") + } + + // nested conditions + { + if cx.tcx.is_diagnostic_item(sym::Option, did) && 4 == 5 { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if cx.tcx.is_diagnostic_item(sym::Result, did) && 4 == 5 { + println!("Result"); + } + println!("done!") + } + + // All the same, but the second if is the final expression + { + if ty.is_diag_item(cx, sym::Option) { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if ty.is_diag_item(cx, sym::Result) { + println!("Result"); + } + } + + // nested conditions + { + if ty.is_diag_item(cx, sym::Option) && 4 == 5 { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if ty.is_diag_item(cx, sym::Result) && 4 == 5 { + println!("Result"); + } + } + + { + if cx.tcx.is_diagnostic_item(sym::Option, did) { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if cx.tcx.is_diagnostic_item(sym::Result, did) { + println!("Result"); + } + } + + // nested conditions + { + if cx.tcx.is_diagnostic_item(sym::Option, did) && 4 == 5 { + //~^ repeated_is_diagnostic_item + println!("Option"); + } + if cx.tcx.is_diagnostic_item(sym::Result, did) && 4 == 5 { + println!("Result"); + } + } +} diff --git a/tests/ui-internal/repeated_is_diagnostic_item_unfixable.stderr b/tests/ui-internal/repeated_is_diagnostic_item_unfixable.stderr new file mode 100644 index 000000000000..890817da5235 --- /dev/null +++ b/tests/ui-internal/repeated_is_diagnostic_item_unfixable.stderr @@ -0,0 +1,374 @@ +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:22:13 + | +LL | let _ = if ty.is_diag_item(cx, sym::Option) { + | ^ -------------------------------- called here + | _____________| + | | +LL | | +LL | | "Option" +LL | | } else if ty.is_diag_item(cx, sym::Result) { + | | -------------------------------- called here +... | +LL | | return; +LL | | }; + | |_____^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results + = note: `-D clippy::repeated-is-diagnostic-item` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::repeated_is_diagnostic_item)]` +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ let _ = if /* name */ == Some(sym::Option) { +LL | +LL | "Option" +LL ~ } else if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:44:5 + | +LL | if ty.is_diag_item(cx, sym::Option) { + | ^ -------------------------------- called here + | _____| + | | +LL | | +LL | | eprintln!("Option"); +LL | | } else if ty.is_diag_item(cx, sym::Result) { + | | -------------------------------- called here +LL | | eprintln!("Result"); +LL | | } + | |_____^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ if /* name */ == Some(sym::Option) { +LL | +LL | eprintln!("Option"); +LL ~ } else if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:62:13 + | +LL | let _ = if ty.is_diag_item(cx, sym::Option) && 4 == 5 { + | ^ -------------------------------- called here + | _____________| + | | +LL | | +LL | | "Option" +LL | | } else if ty.is_diag_item(cx, sym::Result) && 4 == 5 { + | | -------------------------------- called here +... | +LL | | return; +LL | | }; + | |_____^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ let _ = if /* name */ == Some(sym::Option) && 4 == 5 { +LL | +LL | "Option" +LL ~ } else if /* name */ == Some(sym::Result) && 4 == 5 { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:71:13 + | +LL | let _ = if cx.tcx.is_diagnostic_item(sym::Option, did) { + | ^ ------------------------------------------- called here + | _____________| + | | +LL | | +LL | | "Option" +LL | | } else if cx.tcx.is_diagnostic_item(sym::Result, did) { + | | ------------------------------------------- called here +... | +LL | | return; +LL | | }; + | |_____^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ let _ = if /* name */ == Some(sym::Option) { +LL | +LL | "Option" +LL ~ } else if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:93:5 + | +LL | if cx.tcx.is_diagnostic_item(sym::Option, did) { + | ^ ------------------------------------------- called here + | _____| + | | +LL | | +LL | | eprintln!("Option"); +LL | | } else if cx.tcx.is_diagnostic_item(sym::Result, did) { + | | ------------------------------------------- called here +LL | | eprintln!("Result"); +LL | | } + | |_____^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ if /* name */ == Some(sym::Option) { +LL | +LL | eprintln!("Option"); +LL ~ } else if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:111:13 + | +LL | let _ = if cx.tcx.is_diagnostic_item(sym::Option, did) && 4 == 5 { + | ^ ------------------------------------------- called here + | _____________| + | | +LL | | +LL | | "Option" +LL | | } else if cx.tcx.is_diagnostic_item(sym::Result, did) && 4 == 5 { + | | ------------------------------------------- called here +... | +LL | | return; +LL | | }; + | |_____^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ let _ = if /* name */ == Some(sym::Option) && 4 == 5 { +LL | +LL | "Option" +LL ~ } else if /* name */ == Some(sym::Result) && 4 == 5 { + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:126:9 + | +LL | if ty.is_diag_item(cx, sym::Option) { + | ^ -------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if ty.is_diag_item(cx, sym::Result) { + | | -------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ if /* name */ == Some(sym::Option) { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:138:9 + | +LL | if ty.is_diag_item(cx, sym::Option) && 4 == 5 { + | ^ -------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if ty.is_diag_item(cx, sym::Result) && 4 == 5 { + | | -------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ if /* name */ == Some(sym::Option) && 4 == 5 { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) && 4 == 5 { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:149:9 + | +LL | if cx.tcx.is_diagnostic_item(sym::Option, did) { + | ^ ------------------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if cx.tcx.is_diagnostic_item(sym::Result, did) { + | | ------------------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ if /* name */ == Some(sym::Option) { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:161:9 + | +LL | if cx.tcx.is_diagnostic_item(sym::Option, did) && 4 == 5 { + | ^ ------------------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if cx.tcx.is_diagnostic_item(sym::Result, did) && 4 == 5 { + | | ------------------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ if /* name */ == Some(sym::Option) && 4 == 5 { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) && 4 == 5 { + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:173:9 + | +LL | if ty.is_diag_item(cx, sym::Option) { + | ^ -------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if ty.is_diag_item(cx, sym::Result) { + | | -------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ if /* name */ == Some(sym::Option) { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `Ty::is_diag_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:184:9 + | +LL | if ty.is_diag_item(cx, sym::Option) && 4 == 5 { + | ^ -------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if ty.is_diag_item(cx, sym::Result) && 4 == 5 { + | | -------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `Ty::opt_diag_name`, and reuse the results + | +LL ~ let /* name */ = ty.opt_diag_name(cx); +LL ~ if /* name */ == Some(sym::Option) && 4 == 5 { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) && 4 == 5 { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:194:9 + | +LL | if cx.tcx.is_diagnostic_item(sym::Option, did) { + | ^ ------------------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if cx.tcx.is_diagnostic_item(sym::Result, did) { + | | ------------------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ if /* name */ == Some(sym::Option) { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) { + | + +error: repeated calls to `TyCtxt::is_diagnostic_item` + --> tests/ui-internal/repeated_is_diagnostic_item_unfixable.rs:205:9 + | +LL | if cx.tcx.is_diagnostic_item(sym::Option, did) && 4 == 5 { + | ^ ------------------------------------------- called here + | _________| + | | +LL | | +LL | | println!("Option"); +LL | | } +LL | | if cx.tcx.is_diagnostic_item(sym::Result, did) && 4 == 5 { + | | ------------------------------------------- called here +LL | | println!("Result"); +LL | | } + | |_________^ + | + = note: each call performs the same compiler query -- it's faster to query once, and reuse the results +help: call `TyCtxt::get_diagnostic_name`, and reuse the results + | +LL ~ let /* name */ = cx.tcx.get_diagnostic_name(did); +LL ~ if /* name */ == Some(sym::Option) && 4 == 5 { +LL | +LL | println!("Option"); +LL | } +LL ~ if /* name */ == Some(sym::Result) && 4 == 5 { + | + +error: aborting due to 14 previous errors + From 569206452179abcfdb15fa2f7432cdd7c86af1ad Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Wed, 17 Dec 2025 11:54:35 +0100 Subject: [PATCH 225/489] Port `#[rustc_never_returns_null_ptr]` to attribute parser --- .../src/attributes/rustc_internal.rs | 15 +++++++++++++++ compiler/rustc_attr_parsing/src/context.rs | 6 ++++-- compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/ptr_nulls.rs | 7 ++++--- compiler/rustc_passes/src/check_attr.rs | 4 +--- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index f04d4ceea35a..620878fb87a7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -13,6 +13,21 @@ impl NoArgsAttributeParser for RustcMainParser { const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain; } +pub(crate) struct RustcNeverReturnsNullPointerParser; + +impl NoArgsAttributeParser for RustcNeverReturnsNullPointerParser { + const PATH: &[Symbol] = &[sym::rustc_never_returns_null_ptr]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNeverReturnsNullPointer; +} + pub(crate) struct RustcLayoutScalarValidRangeStartParser; impl SingleAttributeParser for RustcLayoutScalarValidRangeStartParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9e83ea411493..54c9785a42f6 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,8 +61,9 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcMainParser, RustcObjectLifetimeDefaultParser, - RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, + RustcLegacyConstGenericsParser, RustcMainParser, RustcNeverReturnsNullPointerParser, + RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, + RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; use crate::attributes::stability::{ @@ -255,6 +256,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index fb3d9a6368ab..4a81c4ebe1e7 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -878,6 +878,9 @@ pub enum AttributeKind { /// Represents `#[rustc_main]`. RustcMain, + /// Represents `#[rustc_never_returns_null_ptr]` + RustcNeverReturnsNullPointer, + /// Represents `#[rustc_object_lifetime_default]`. RustcObjectLifetimeDefault, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 56446e8959c1..e631d6a2ab87 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -95,6 +95,7 @@ impl AttributeKind { RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, RustcMain => No, + RustcNeverReturnsNullPointer => Yes, RustcObjectLifetimeDefault => No, RustcPassIndirectlyInNonRusticAbis(..) => No, RustcScalableVector { .. } => Yes, diff --git a/compiler/rustc_lint/src/ptr_nulls.rs b/compiler/rustc_lint/src/ptr_nulls.rs index b2fa0fba76d9..b89e00dcbaae 100644 --- a/compiler/rustc_lint/src/ptr_nulls.rs +++ b/compiler/rustc_lint/src/ptr_nulls.rs @@ -1,5 +1,6 @@ use rustc_ast::LitKind; -use rustc_hir::{BinOpKind, Expr, ExprKind, TyKind}; +use rustc_hir::attrs::AttributeKind; +use rustc_hir::{BinOpKind, Expr, ExprKind, TyKind, find_attr}; use rustc_middle::ty::RawPtr; use rustc_session::{declare_lint, declare_lint_pass}; use rustc_span::{Span, sym}; @@ -72,14 +73,14 @@ fn useless_check<'a, 'tcx: 'a>( e = e.peel_blocks(); if let ExprKind::MethodCall(_, _expr, [], _) = e.kind && let Some(def_id) = cx.typeck_results().type_dependent_def_id(e.hir_id) - && cx.tcx.has_attr(def_id, sym::rustc_never_returns_null_ptr) + && find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::RustcNeverReturnsNullPointer) && let Some(fn_name) = cx.tcx.opt_item_ident(def_id) { return Some(UselessPtrNullChecksDiag::FnRet { fn_name }); } else if let ExprKind::Call(path, _args) = e.kind && let ExprKind::Path(ref qpath) = path.kind && let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id() - && cx.tcx.has_attr(def_id, sym::rustc_never_returns_null_ptr) + && find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::RustcNeverReturnsNullPointer) && let Some(fn_name) = cx.tcx.opt_item_ident(def_id) { return Some(UselessPtrNullChecksDiag::FnRet { fn_name }); diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d8ecbbc49138..d1f96721fc65 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -257,6 +257,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::NoLink | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) + | AttributeKind::RustcNeverReturnsNullPointer | AttributeKind::RustcScalableVector { .. } | AttributeKind::RustcSimdMonomorphizeLaneLimit(..) | AttributeKind::RustcShouldNotBeCalledOnConstItems(..) @@ -307,9 +308,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { [sym::rustc_no_implicit_autorefs, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } - [sym::rustc_never_returns_null_ptr, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } [sym::rustc_lint_query_instability, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } From cb301751b3ade3cf65f1d3eeb0c94ffce1a45561 Mon Sep 17 00:00:00 2001 From: delta17920 Date: Sat, 13 Dec 2025 15:18:34 +0000 Subject: [PATCH 226/489] Suggest struct pattern when destructuring Range with .. syntax --- .../rustc_resolve/src/late/diagnostics.rs | 36 ++++++++++ .../suggest-range-struct-destructuring.rs | 15 +++++ .../suggest-range-struct-destructuring.stderr | 66 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 tests/ui/resolve/suggest-range-struct-destructuring.rs create mode 100644 tests/ui/resolve/suggest-range-struct-destructuring.stderr diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 233a4c48862a..0348764009b2 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -440,6 +440,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { self.detect_missing_binding_available_from_pattern(&mut err, path, following_seg); self.suggest_at_operator_in_slice_pat_with_range(&mut err, path); + self.suggest_range_struct_destructuring(&mut err, path, source); self.suggest_swapping_misplaced_self_ty_and_trait(&mut err, source, res, base_error.span); if let Some((span, label)) = base_error.span_label { @@ -1383,6 +1384,41 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } } + fn suggest_range_struct_destructuring( + &self, + err: &mut Diag<'_>, + path: &[Segment], + source: PathSource<'_, '_, '_>, + ) { + // We accept Expr here because range bounds (start..end) are parsed as expressions + if !matches!(source, PathSource::Pat | PathSource::TupleStruct(..) | PathSource::Expr(..)) { + return; + } + + if let Some(pat) = self.diag_metadata.current_pat + && let ast::PatKind::Range(Some(start_expr), Some(end_expr), _) = &pat.kind + && let (ast::ExprKind::Path(None, start_path), ast::ExprKind::Path(None, end_path)) = + (&start_expr.kind, &end_expr.kind) + && path.len() == 1 + { + let ident = path[0].ident; + + if (start_path.segments.len() == 1 && start_path.segments[0].ident == ident) + || (end_path.segments.len() == 1 && end_path.segments[0].ident == ident) + { + let start_name = start_path.segments[0].ident; + let end_name = end_path.segments[0].ident; + + err.span_suggestion_verbose( + pat.span, + "if you meant to destructure a `Range`, use the struct pattern", + format!("std::ops::Range {{ start: {}, end: {} }}", start_name, end_name), + Applicability::MaybeIncorrect, + ); + } + } + } + fn suggest_swapping_misplaced_self_ty_and_trait( &mut self, err: &mut Diag<'_>, diff --git a/tests/ui/resolve/suggest-range-struct-destructuring.rs b/tests/ui/resolve/suggest-range-struct-destructuring.rs new file mode 100644 index 000000000000..f690a7cad23f --- /dev/null +++ b/tests/ui/resolve/suggest-range-struct-destructuring.rs @@ -0,0 +1,15 @@ +use std::ops::Range; + +fn test_basic_range(r: Range) { + let start..end = r; + //~^ ERROR cannot find value `start` in this scope + //~| ERROR cannot find value `end` in this scope +} + +fn test_different_names(r: Range) { + let min..max = r; + //~^ ERROR cannot find value `min` in this scope + //~| ERROR cannot find value `max` in this scope +} + +fn main() {} diff --git a/tests/ui/resolve/suggest-range-struct-destructuring.stderr b/tests/ui/resolve/suggest-range-struct-destructuring.stderr new file mode 100644 index 000000000000..291abf0d01d3 --- /dev/null +++ b/tests/ui/resolve/suggest-range-struct-destructuring.stderr @@ -0,0 +1,66 @@ +error[E0425]: cannot find value `start` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:4:9 + | +LL | let start..end = r; + | ^^^^^ not found in this scope + | +help: if you meant to destructure a `Range`, use the struct pattern + | +LL - let start..end = r; +LL + let std::ops::Range { start: start, end: end } = r; + | + +error[E0425]: cannot find value `end` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:4:16 + | +LL | let start..end = r; + | ^^^ not found in this scope + | +help: if you meant to destructure a `Range`, use the struct pattern + | +LL - let start..end = r; +LL + let std::ops::Range { start: start, end: end } = r; + | + +error[E0425]: cannot find value `min` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:10:9 + | +LL | let min..max = r; + | ^^^ +... +LL | fn main() {} + | --------- similarly named function `main` defined here + | +help: if you meant to destructure a `Range`, use the struct pattern + | +LL - let min..max = r; +LL + let std::ops::Range { start: min, end: max } = r; + | +help: a function with a similar name exists + | +LL | let main..max = r; + | + +help: consider importing this function + | +LL + use std::cmp::min; + | + +error[E0425]: cannot find value `max` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:10:14 + | +LL | let min..max = r; + | ^^^ not found in this scope + | +help: if you meant to destructure a `Range`, use the struct pattern + | +LL - let min..max = r; +LL + let std::ops::Range { start: min, end: max } = r; + | +help: consider importing this function + | +LL + use std::cmp::max; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. From 3e78653ec32342708b70268e179dfcaad02f4d4e Mon Sep 17 00:00:00 2001 From: delta17920 Date: Sun, 14 Dec 2025 04:04:53 +0000 Subject: [PATCH 227/489] Fix grammar in suggestion message --- compiler/rustc_resolve/src/late/diagnostics.rs | 2 +- .../ui/resolve/suggest-range-struct-destructuring.stderr | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 0348764009b2..85e8917ae32e 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1411,7 +1411,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { err.span_suggestion_verbose( pat.span, - "if you meant to destructure a `Range`, use the struct pattern", + "if you meant to destructure a `Range`, use a struct pattern", format!("std::ops::Range {{ start: {}, end: {} }}", start_name, end_name), Applicability::MaybeIncorrect, ); diff --git a/tests/ui/resolve/suggest-range-struct-destructuring.stderr b/tests/ui/resolve/suggest-range-struct-destructuring.stderr index 291abf0d01d3..1a11e6ac8421 100644 --- a/tests/ui/resolve/suggest-range-struct-destructuring.stderr +++ b/tests/ui/resolve/suggest-range-struct-destructuring.stderr @@ -4,7 +4,7 @@ error[E0425]: cannot find value `start` in this scope LL | let start..end = r; | ^^^^^ not found in this scope | -help: if you meant to destructure a `Range`, use the struct pattern +help: if you meant to destructure a `Range`, use a struct pattern | LL - let start..end = r; LL + let std::ops::Range { start: start, end: end } = r; @@ -16,7 +16,7 @@ error[E0425]: cannot find value `end` in this scope LL | let start..end = r; | ^^^ not found in this scope | -help: if you meant to destructure a `Range`, use the struct pattern +help: if you meant to destructure a `Range`, use a struct pattern | LL - let start..end = r; LL + let std::ops::Range { start: start, end: end } = r; @@ -31,7 +31,7 @@ LL | let min..max = r; LL | fn main() {} | --------- similarly named function `main` defined here | -help: if you meant to destructure a `Range`, use the struct pattern +help: if you meant to destructure a `Range`, use a struct pattern | LL - let min..max = r; LL + let std::ops::Range { start: min, end: max } = r; @@ -51,7 +51,7 @@ error[E0425]: cannot find value `max` in this scope LL | let min..max = r; | ^^^ not found in this scope | -help: if you meant to destructure a `Range`, use the struct pattern +help: if you meant to destructure a `Range`, use a struct pattern | LL - let min..max = r; LL + let std::ops::Range { start: min, end: max } = r; From 4b07875505bdd5c4b635fbf821401fcd4573dffd Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 17 Dec 2025 14:33:52 +0000 Subject: [PATCH 228/489] Revert #148937 (Remove initialized-bytes tracking from `BorrowedBuf` and `BorrowedCursor`) This caused several performance regressions because of existing code which uses `Read::read` and therefore requires full buffer initialization. This is particularly a problem when the same buffer is re-used for multiple read calls since this means it needs to be fully re-initialized each time. There is still some benefit to landing the API changes, but we will have to add private APIs so that the existing infrastructure can track and avoid redundant initialization. --- library/core/src/io/borrowed_buf.rs | 162 +++++++++++++++--- library/coretests/tests/io/borrowed_buf.rs | 90 ++++++++-- library/std/src/fs/tests.rs | 2 + library/std/src/io/buffered/bufreader.rs | 9 + .../std/src/io/buffered/bufreader/buffer.rs | 27 ++- library/std/src/io/buffered/tests.rs | 24 +++ library/std/src/io/copy.rs | 13 ++ library/std/src/io/mod.rs | 53 +++++- library/std/src/io/tests.rs | 9 + library/std/src/io/util.rs | 2 +- library/std/src/io/util/tests.rs | 8 + library/std/src/net/tcp/tests.rs | 2 + library/std/src/process/tests.rs | 2 + library/std/src/sys/fd/hermit.rs | 2 +- library/std/src/sys/fd/unix.rs | 4 +- library/std/src/sys/fs/solid.rs | 2 +- .../src/sys/net/connection/socket/hermit.rs | 2 +- .../src/sys/net/connection/socket/solid.rs | 2 +- .../std/src/sys/net/connection/socket/unix.rs | 2 +- .../src/sys/net/connection/socket/windows.rs | 2 +- .../std/src/sys/pal/sgx/abi/usercalls/mod.rs | 2 +- library/std/src/sys/pal/windows/handle.rs | 4 +- .../std/src/sys/process/windows/child_pipe.rs | 2 +- library/std/src/sys/stdio/zkvm.rs | 2 +- 24 files changed, 366 insertions(+), 63 deletions(-) diff --git a/library/core/src/io/borrowed_buf.rs b/library/core/src/io/borrowed_buf.rs index b765b96fd00a..088dea781294 100644 --- a/library/core/src/io/borrowed_buf.rs +++ b/library/core/src/io/borrowed_buf.rs @@ -2,26 +2,27 @@ use crate::fmt::{self, Debug, Formatter}; use crate::mem::{self, MaybeUninit}; +use crate::{cmp, ptr}; -/// A borrowed buffer of initially uninitialized bytes, which is incrementally filled. +/// A borrowed byte buffer which is incrementally filled and initialized. /// -/// This type makes it safer to work with `MaybeUninit` buffers, such as to read into a buffer -/// without having to initialize it first. It tracks the region of bytes that have been filled and -/// the region that remains uninitialized. +/// This type is a sort of "double cursor". It tracks three regions in the buffer: a region at the beginning of the +/// buffer that has been logically filled with data, a region that has been initialized at some point but not yet +/// logically filled, and a region at the end that is fully uninitialized. The filled region is guaranteed to be a +/// subset of the initialized region. /// -/// The contents of the buffer can be visualized as: +/// In summary, the contents of the buffer can be visualized as: /// ```not_rust -/// [ capacity ] -/// [ len: filled and initialized | capacity - len: uninitialized ] +/// [ capacity ] +/// [ filled | unfilled ] +/// [ initialized | uninitialized ] /// ``` /// -/// Note that `BorrowedBuf` does not distinguish between uninitialized data and data that was -/// previously initialized but no longer contains valid data. -/// -/// A `BorrowedBuf` is created around some existing data (or capacity for data) via a unique -/// reference (`&mut`). The `BorrowedBuf` can be configured (e.g., using `clear` or `set_len`), but -/// cannot be directly written. To write into the buffer, use `unfilled` to create a -/// `BorrowedCursor`. The cursor has write-only access to the unfilled portion of the buffer. +/// A `BorrowedBuf` is created around some existing data (or capacity for data) via a unique reference +/// (`&mut`). The `BorrowedBuf` can be configured (e.g., using `clear` or `set_init`), but cannot be +/// directly written. To write into the buffer, use `unfilled` to create a `BorrowedCursor`. The cursor +/// has write-only access to the unfilled portion of the buffer (you can think of it as a +/// write-only iterator). /// /// The lifetime `'data` is a bound on the lifetime of the underlying data. pub struct BorrowedBuf<'data> { @@ -29,11 +30,14 @@ pub struct BorrowedBuf<'data> { buf: &'data mut [MaybeUninit], /// The length of `self.buf` which is known to be filled. filled: usize, + /// The length of `self.buf` which is known to be initialized. + init: usize, } impl Debug for BorrowedBuf<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_struct("BorrowedBuf") + .field("init", &self.init) .field("filled", &self.filled) .field("capacity", &self.capacity()) .finish() @@ -44,22 +48,24 @@ impl Debug for BorrowedBuf<'_> { impl<'data> From<&'data mut [u8]> for BorrowedBuf<'data> { #[inline] fn from(slice: &'data mut [u8]) -> BorrowedBuf<'data> { + let len = slice.len(); + BorrowedBuf { - // SAFETY: Always in bounds. We treat the buffer as uninitialized, even though it's - // already initialized. + // SAFETY: initialized data never becoming uninitialized is an invariant of BorrowedBuf buf: unsafe { (slice as *mut [u8]).as_uninit_slice_mut().unwrap() }, filled: 0, + init: len, } } } /// Creates a new `BorrowedBuf` from an uninitialized buffer. /// -/// Use `set_filled` if part of the buffer is known to be already filled. +/// Use `set_init` if part of the buffer is known to be already initialized. impl<'data> From<&'data mut [MaybeUninit]> for BorrowedBuf<'data> { #[inline] fn from(buf: &'data mut [MaybeUninit]) -> BorrowedBuf<'data> { - BorrowedBuf { buf, filled: 0 } + BorrowedBuf { buf, filled: 0, init: 0 } } } @@ -68,11 +74,14 @@ impl<'data> From<&'data mut [MaybeUninit]> for BorrowedBuf<'data> { /// Use `BorrowedCursor::with_unfilled_buf` instead for a safer alternative. impl<'data> From> for BorrowedBuf<'data> { #[inline] - fn from(buf: BorrowedCursor<'data>) -> BorrowedBuf<'data> { + fn from(mut buf: BorrowedCursor<'data>) -> BorrowedBuf<'data> { + let init = buf.init_mut().len(); BorrowedBuf { - // SAFETY: Always in bounds. We treat the buffer as uninitialized. + // SAFETY: no initialized byte is ever uninitialized as per + // `BorrowedBuf`'s invariant buf: unsafe { buf.buf.buf.get_unchecked_mut(buf.buf.filled..) }, filled: 0, + init, } } } @@ -90,6 +99,12 @@ impl<'data> BorrowedBuf<'data> { self.filled } + /// Returns the length of the initialized part of the buffer. + #[inline] + pub fn init_len(&self) -> usize { + self.init + } + /// Returns a shared reference to the filled portion of the buffer. #[inline] pub fn filled(&self) -> &[u8] { @@ -144,16 +159,33 @@ impl<'data> BorrowedBuf<'data> { /// Clears the buffer, resetting the filled region to empty. /// - /// The contents of the buffer are not modified. + /// The number of initialized bytes is not changed, and the contents of the buffer are not modified. #[inline] pub fn clear(&mut self) -> &mut Self { self.filled = 0; self } + + /// Asserts that the first `n` bytes of the buffer are initialized. + /// + /// `BorrowedBuf` assumes that bytes are never de-initialized, so this method does nothing when called with fewer + /// bytes than are already known to be initialized. + /// + /// # Safety + /// + /// The caller must ensure that the first `n` unfilled bytes of the buffer have already been initialized. + #[inline] + pub unsafe fn set_init(&mut self, n: usize) -> &mut Self { + self.init = cmp::max(self.init, n); + self + } } /// A writeable view of the unfilled portion of a [`BorrowedBuf`]. /// +/// The unfilled portion consists of an initialized and an uninitialized part; see [`BorrowedBuf`] +/// for details. +/// /// Data can be written directly to the cursor by using [`append`](BorrowedCursor::append) or /// indirectly by getting a slice of part or all of the cursor and writing into the slice. In the /// indirect case, the caller must call [`advance`](BorrowedCursor::advance) after writing to inform @@ -206,17 +238,48 @@ impl<'a> BorrowedCursor<'a> { self.buf.filled } + /// Returns a mutable reference to the initialized portion of the cursor. + #[inline] + pub fn init_mut(&mut self) -> &mut [u8] { + // SAFETY: We only slice the initialized part of the buffer, which is always valid + unsafe { + let buf = self.buf.buf.get_unchecked_mut(self.buf.filled..self.buf.init); + buf.assume_init_mut() + } + } + /// Returns a mutable reference to the whole cursor. /// /// # Safety /// - /// The caller must not uninitialize any previously initialized bytes. + /// The caller must not uninitialize any bytes in the initialized portion of the cursor. #[inline] pub unsafe fn as_mut(&mut self) -> &mut [MaybeUninit] { // SAFETY: always in bounds unsafe { self.buf.buf.get_unchecked_mut(self.buf.filled..) } } + /// Advances the cursor by asserting that `n` bytes have been filled. + /// + /// After advancing, the `n` bytes are no longer accessible via the cursor and can only be + /// accessed via the underlying buffer. I.e., the buffer's filled portion grows by `n` elements + /// and its unfilled portion (and the capacity of this cursor) shrinks by `n` elements. + /// + /// If less than `n` bytes initialized (by the cursor's point of view), `set_init` should be + /// called first. + /// + /// # Panics + /// + /// Panics if there are less than `n` bytes initialized. + #[inline] + pub fn advance(&mut self, n: usize) -> &mut Self { + // The subtraction cannot underflow by invariant of this type. + assert!(n <= self.buf.init - self.buf.filled); + + self.buf.filled += n; + self + } + /// Advances the cursor by asserting that `n` bytes have been filled. /// /// After advancing, the `n` bytes are no longer accessible via the cursor and can only be @@ -225,11 +288,42 @@ impl<'a> BorrowedCursor<'a> { /// /// # Safety /// - /// The caller must ensure that the first `n` bytes of the cursor have been initialized. `n` - /// must not exceed the remaining capacity of this cursor. + /// The caller must ensure that the first `n` bytes of the cursor have been properly + /// initialised. #[inline] - pub unsafe fn advance(&mut self, n: usize) -> &mut Self { + pub unsafe fn advance_unchecked(&mut self, n: usize) -> &mut Self { self.buf.filled += n; + self.buf.init = cmp::max(self.buf.init, self.buf.filled); + self + } + + /// Initializes all bytes in the cursor. + #[inline] + pub fn ensure_init(&mut self) -> &mut Self { + // SAFETY: always in bounds and we never uninitialize these bytes. + let uninit = unsafe { self.buf.buf.get_unchecked_mut(self.buf.init..) }; + + // SAFETY: 0 is a valid value for MaybeUninit and the length matches the allocation + // since it is comes from a slice reference. + unsafe { + ptr::write_bytes(uninit.as_mut_ptr(), 0, uninit.len()); + } + self.buf.init = self.buf.capacity(); + + self + } + + /// Asserts that the first `n` unfilled bytes of the cursor are initialized. + /// + /// `BorrowedBuf` assumes that bytes are never de-initialized, so this method does nothing when + /// called with fewer bytes than are already known to be initialized. + /// + /// # Safety + /// + /// The caller must ensure that the first `n` bytes of the buffer have already been initialized. + #[inline] + pub unsafe fn set_init(&mut self, n: usize) -> &mut Self { + self.buf.init = cmp::max(self.buf.init, self.buf.filled + n); self } @@ -247,6 +341,10 @@ impl<'a> BorrowedCursor<'a> { self.as_mut()[..buf.len()].write_copy_of_slice(buf); } + // SAFETY: We just added the entire contents of buf to the filled section. + unsafe { + self.set_init(buf.len()); + } self.buf.filled += buf.len(); } @@ -269,9 +367,17 @@ impl<'a> BorrowedCursor<'a> { // there, one could mark some bytes as initialized even though there aren't. assert!(core::ptr::addr_eq(prev_ptr, buf.buf)); - // SAFETY: These bytes were filled in the `BorrowedBuf`, so they're filled in the cursor - // too, because the buffer wasn't replaced. - self.buf.filled += buf.filled; + let filled = buf.filled; + let init = buf.init; + + // Update `init` and `filled` fields with what was written to the buffer. + // `self.buf.filled` was the starting length of the `BorrowedBuf`. + // + // SAFETY: These amounts of bytes were initialized/filled in the `BorrowedBuf`, + // and therefore they are initialized/filled in the cursor too, because the + // buffer wasn't replaced. + self.buf.init = self.buf.filled + init; + self.buf.filled += filled; res } diff --git a/library/coretests/tests/io/borrowed_buf.rs b/library/coretests/tests/io/borrowed_buf.rs index 730ba04465a1..aaa98d26ff8b 100644 --- a/library/coretests/tests/io/borrowed_buf.rs +++ b/library/coretests/tests/io/borrowed_buf.rs @@ -8,6 +8,7 @@ fn new() { let mut rbuf: BorrowedBuf<'_> = buf.into(); assert_eq!(rbuf.filled().len(), 0); + assert_eq!(rbuf.init_len(), 16); assert_eq!(rbuf.capacity(), 16); assert_eq!(rbuf.unfilled().capacity(), 16); } @@ -19,16 +20,27 @@ fn uninit() { let mut rbuf: BorrowedBuf<'_> = buf.into(); assert_eq!(rbuf.filled().len(), 0); + assert_eq!(rbuf.init_len(), 0); assert_eq!(rbuf.capacity(), 16); assert_eq!(rbuf.unfilled().capacity(), 16); } +#[test] +fn initialize_unfilled() { + let buf: &mut [_] = &mut [MaybeUninit::uninit(); 16]; + let mut rbuf: BorrowedBuf<'_> = buf.into(); + + rbuf.unfilled().ensure_init(); + + assert_eq!(rbuf.init_len(), 16); +} + #[test] fn advance_filled() { let buf: &mut [_] = &mut [0; 16]; let mut rbuf: BorrowedBuf<'_> = buf.into(); - unsafe { rbuf.unfilled().advance(1) }; + rbuf.unfilled().advance(1); assert_eq!(rbuf.filled().len(), 1); assert_eq!(rbuf.unfilled().capacity(), 15); @@ -39,7 +51,7 @@ fn clear() { let buf: &mut [_] = &mut [255; 16]; let mut rbuf: BorrowedBuf<'_> = buf.into(); - unsafe { rbuf.unfilled().advance(16) }; + rbuf.unfilled().advance(16); assert_eq!(rbuf.filled().len(), 16); assert_eq!(rbuf.unfilled().capacity(), 0); @@ -49,9 +61,33 @@ fn clear() { assert_eq!(rbuf.filled().len(), 0); assert_eq!(rbuf.unfilled().capacity(), 16); - unsafe { rbuf.unfilled().advance(16) }; + assert_eq!(rbuf.unfilled().init_mut(), [255; 16]); +} - assert_eq!(rbuf.filled(), [255; 16]); +#[test] +fn set_init() { + let buf: &mut [_] = &mut [MaybeUninit::zeroed(); 16]; + let mut rbuf: BorrowedBuf<'_> = buf.into(); + + unsafe { + rbuf.set_init(8); + } + + assert_eq!(rbuf.init_len(), 8); + + rbuf.unfilled().advance(4); + + unsafe { + rbuf.set_init(2); + } + + assert_eq!(rbuf.init_len(), 8); + + unsafe { + rbuf.set_init(8); + } + + assert_eq!(rbuf.init_len(), 8); } #[test] @@ -61,6 +97,7 @@ fn append() { rbuf.unfilled().append(&[0; 8]); + assert_eq!(rbuf.init_len(), 8); assert_eq!(rbuf.filled().len(), 8); assert_eq!(rbuf.filled(), [0; 8]); @@ -68,6 +105,7 @@ fn append() { rbuf.unfilled().append(&[1; 16]); + assert_eq!(rbuf.init_len(), 16); assert_eq!(rbuf.filled().len(), 16); assert_eq!(rbuf.filled(), [1; 16]); } @@ -87,12 +125,43 @@ fn reborrow_written() { assert_eq!(cursor.written(), 32); assert_eq!(buf.unfilled().written(), 32); + assert_eq!(buf.init_len(), 32); assert_eq!(buf.filled().len(), 32); let filled = buf.filled(); assert_eq!(&filled[..16], [1; 16]); assert_eq!(&filled[16..], [2; 16]); } +#[test] +fn cursor_set_init() { + let buf: &mut [_] = &mut [MaybeUninit::zeroed(); 16]; + let mut rbuf: BorrowedBuf<'_> = buf.into(); + + unsafe { + rbuf.unfilled().set_init(8); + } + + assert_eq!(rbuf.init_len(), 8); + assert_eq!(rbuf.unfilled().init_mut().len(), 8); + assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 16); + + rbuf.unfilled().advance(4); + + unsafe { + rbuf.unfilled().set_init(2); + } + + assert_eq!(rbuf.init_len(), 8); + + unsafe { + rbuf.unfilled().set_init(8); + } + + assert_eq!(rbuf.init_len(), 12); + assert_eq!(rbuf.unfilled().init_mut().len(), 8); + assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 12); +} + #[test] fn cursor_with_unfilled_buf() { let buf: &mut [_] = &mut [MaybeUninit::uninit(); 16]; @@ -100,30 +169,31 @@ fn cursor_with_unfilled_buf() { let mut cursor = rbuf.unfilled(); cursor.with_unfilled_buf(|buf| { - assert_eq!(buf.capacity(), 16); buf.unfilled().append(&[1, 2, 3]); assert_eq!(buf.filled(), &[1, 2, 3]); }); + assert_eq!(cursor.init_mut().len(), 0); assert_eq!(cursor.written(), 3); cursor.with_unfilled_buf(|buf| { assert_eq!(buf.capacity(), 13); + assert_eq!(buf.init_len(), 0); - unsafe { - buf.unfilled().as_mut().write_filled(0); - buf.unfilled().advance(4) - }; + buf.unfilled().ensure_init(); + buf.unfilled().advance(4); }); + assert_eq!(cursor.init_mut().len(), 9); assert_eq!(cursor.written(), 7); cursor.with_unfilled_buf(|buf| { assert_eq!(buf.capacity(), 9); + assert_eq!(buf.init_len(), 9); }); + assert_eq!(cursor.init_mut().len(), 9); assert_eq!(cursor.written(), 7); - assert_eq!(rbuf.len(), 7); assert_eq!(rbuf.filled(), &[1, 2, 3, 0, 0, 0, 0]); } diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index bcaafcfee787..0a5d1153d860 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -709,6 +709,8 @@ fn file_test_read_buf() { let mut file = check!(File::open(filename)); check!(file.read_buf(buf.unfilled())); assert_eq!(buf.filled(), &[1, 2, 3, 4]); + // File::read_buf should omit buffer initialization. + assert_eq!(buf.init_len(), 4); check!(fs::remove_file(filename)); } diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index 69c260b5410a..40441dc057d0 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -284,6 +284,15 @@ impl BufReader { } } +// This is only used by a test which asserts that the initialization-tracking is correct. +#[cfg(test)] +impl BufReader { + #[allow(missing_docs)] + pub fn initialized(&self) -> usize { + self.buf.initialized() + } +} + impl BufReader { /// Seeks relative to the current position. If the new position lies within the buffer, /// the buffer will not be flushed, allowing for more efficient seeks. diff --git a/library/std/src/io/buffered/bufreader/buffer.rs b/library/std/src/io/buffered/bufreader/buffer.rs index 2694726b3f44..9b600cd55758 100644 --- a/library/std/src/io/buffered/bufreader/buffer.rs +++ b/library/std/src/io/buffered/bufreader/buffer.rs @@ -21,19 +21,25 @@ pub struct Buffer { // Each call to `fill_buf` sets `filled` to indicate how many bytes at the start of `buf` are // initialized with bytes from a read. filled: usize, + // This is the max number of bytes returned across all `fill_buf` calls. We track this so that we + // can accurately tell `read_buf` how many bytes of buf are initialized, to bypass as much of its + // defensive initialization as possible. Note that while this often the same as `filled`, it + // doesn't need to be. Calls to `fill_buf` are not required to actually fill the buffer, and + // omitting this is a huge perf regression for `Read` impls that do not. + initialized: usize, } impl Buffer { #[inline] pub fn with_capacity(capacity: usize) -> Self { let buf = Box::new_uninit_slice(capacity); - Self { buf, pos: 0, filled: 0 } + Self { buf, pos: 0, filled: 0, initialized: 0 } } #[inline] pub fn try_with_capacity(capacity: usize) -> io::Result { match Box::try_new_uninit_slice(capacity) { - Ok(buf) => Ok(Self { buf, pos: 0, filled: 0 }), + Ok(buf) => Ok(Self { buf, pos: 0, filled: 0, initialized: 0 }), Err(_) => { Err(io::const_error!(ErrorKind::OutOfMemory, "failed to allocate read buffer")) } @@ -62,6 +68,12 @@ impl Buffer { self.pos } + // This is only used by a test which asserts that the initialization-tracking is correct. + #[cfg(test)] + pub fn initialized(&self) -> usize { + self.initialized + } + #[inline] pub fn discard_buffer(&mut self) { self.pos = 0; @@ -98,8 +110,13 @@ impl Buffer { /// Read more bytes into the buffer without discarding any of its contents pub fn read_more(&mut self, mut reader: impl Read) -> io::Result { let mut buf = BorrowedBuf::from(&mut self.buf[self.filled..]); + let old_init = self.initialized - self.filled; + unsafe { + buf.set_init(old_init); + } reader.read_buf(buf.unfilled())?; self.filled += buf.len(); + self.initialized += buf.init_len() - old_init; Ok(buf.len()) } @@ -120,10 +137,16 @@ impl Buffer { debug_assert!(self.pos == self.filled); let mut buf = BorrowedBuf::from(&mut *self.buf); + // SAFETY: `self.filled` bytes will always have been initialized. + unsafe { + buf.set_init(self.initialized); + } + let result = reader.read_buf(buf.unfilled()); self.pos = 0; self.filled = buf.len(); + self.initialized = buf.init_len(); result?; } diff --git a/library/std/src/io/buffered/tests.rs b/library/std/src/io/buffered/tests.rs index fc77b02a8e82..6ad4158b9290 100644 --- a/library/std/src/io/buffered/tests.rs +++ b/library/std/src/io/buffered/tests.rs @@ -1052,6 +1052,30 @@ fn single_formatted_write() { assert_eq!(writer.get_ref().events, [RecordedEvent::Write("hello, world!\n".to_string())]); } +#[test] +fn bufreader_full_initialize() { + struct OneByteReader; + impl Read for OneByteReader { + fn read(&mut self, buf: &mut [u8]) -> crate::io::Result { + if buf.len() > 0 { + buf[0] = 0; + Ok(1) + } else { + Ok(0) + } + } + } + let mut reader = BufReader::new(OneByteReader); + // Nothing is initialized yet. + assert_eq!(reader.initialized(), 0); + + let buf = reader.fill_buf().unwrap(); + // We read one byte... + assert_eq!(buf.len(), 1); + // But we initialized the whole buffer! + assert_eq!(reader.initialized(), reader.capacity()); +} + /// This is a regression test for https://github.com/rust-lang/rust/issues/127584. #[test] fn bufwriter_aliasing() { diff --git a/library/std/src/io/copy.rs b/library/std/src/io/copy.rs index 8b5e7c4df4e0..2b558efb8885 100644 --- a/library/std/src/io/copy.rs +++ b/library/std/src/io/copy.rs @@ -214,19 +214,28 @@ impl BufferedWriterSpec for BufWriter { } let mut len = 0; + let mut init = 0; loop { let buf = self.buffer_mut(); let mut read_buf: BorrowedBuf<'_> = buf.spare_capacity_mut().into(); + unsafe { + // SAFETY: init is either 0 or the init_len from the previous iteration. + read_buf.set_init(init); + } + if read_buf.capacity() >= DEFAULT_BUF_SIZE { let mut cursor = read_buf.unfilled(); match reader.read_buf(cursor.reborrow()) { Ok(()) => { let bytes_read = cursor.written(); + if bytes_read == 0 { return Ok(len); } + + init = read_buf.init_len() - bytes_read; len += bytes_read as u64; // SAFETY: BorrowedBuf guarantees all of its filled bytes are init @@ -239,6 +248,10 @@ impl BufferedWriterSpec for BufWriter { Err(e) => return Err(e), } } else { + // All the bytes that were already in the buffer are initialized, + // treat them as such when the buffer is flushed. + init += buf.len(); + self.flush_buf()?; } } diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 4c064c435e5b..b7756befa11e 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -419,6 +419,8 @@ pub(crate) fn default_read_to_end( .and_then(|s| s.checked_add(1024)?.checked_next_multiple_of(DEFAULT_BUF_SIZE)) .unwrap_or(DEFAULT_BUF_SIZE); + let mut initialized = 0; // Extra initialized bytes from previous loop iteration + const PROBE_SIZE: usize = 32; fn small_probe_read(r: &mut R, buf: &mut Vec) -> Result { @@ -447,6 +449,8 @@ pub(crate) fn default_read_to_end( } } + let mut consecutive_short_reads = 0; + loop { if buf.len() == buf.capacity() && buf.capacity() == start_cap { // The buffer might be an exact fit. Let's read into a probe buffer @@ -470,6 +474,11 @@ pub(crate) fn default_read_to_end( spare = &mut spare[..buf_len]; let mut read_buf: BorrowedBuf<'_> = spare.into(); + // SAFETY: These bytes were initialized but not filled in the previous loop + unsafe { + read_buf.set_init(initialized); + } + let mut cursor = read_buf.unfilled(); let result = loop { match r.read_buf(cursor.reborrow()) { @@ -480,7 +489,9 @@ pub(crate) fn default_read_to_end( } }; + let unfilled_but_initialized = cursor.init_mut().len(); let bytes_read = cursor.written(); + let was_fully_initialized = read_buf.init_len() == buf_len; // SAFETY: BorrowedBuf's invariants mean this much memory is initialized. unsafe { @@ -495,8 +506,27 @@ pub(crate) fn default_read_to_end( return Ok(buf.len() - start_len); } + if bytes_read < buf_len { + consecutive_short_reads += 1; + } else { + consecutive_short_reads = 0; + } + + // store how much was initialized but not filled + initialized = unfilled_but_initialized; + // Use heuristics to determine the max read size if no initial size hint was provided if size_hint.is_none() { + // The reader is returning short reads but it doesn't call ensure_init(). + // In that case we no longer need to restrict read sizes to avoid + // initialization costs. + // When reading from disk we usually don't get any short reads except at EOF. + // So we wait for at least 2 short reads before uncapping the read buffer; + // this helps with the Windows issue. + if !was_fully_initialized && consecutive_short_reads > 1 { + max_read_size = usize::MAX; + } + // we have passed a larger buffer than previously and the // reader still hasn't returned a short read if buf_len >= max_read_size && bytes_read == buf_len { @@ -557,13 +587,8 @@ pub(crate) fn default_read_buf(read: F, mut cursor: BorrowedCursor<'_>) -> Re where F: FnOnce(&mut [u8]) -> Result, { - // SAFETY: We do not uninitialize any part of the buffer. - let n = read(unsafe { cursor.as_mut().write_filled(0) })?; - assert!(n <= cursor.capacity()); - // SAFETY: We've initialized the entire buffer, and `read` can't make it uninitialized. - unsafe { - cursor.advance(n); - } + let n = read(cursor.ensure_init().init_mut())?; + cursor.advance(n); Ok(()) } @@ -3073,21 +3098,31 @@ impl Read for Take { // The condition above guarantees that `self.limit` fits in `usize`. let limit = self.limit as usize; + let extra_init = cmp::min(limit, buf.init_mut().len()); + // SAFETY: no uninit data is written to ibuf let ibuf = unsafe { &mut buf.as_mut()[..limit] }; let mut sliced_buf: BorrowedBuf<'_> = ibuf.into(); + // SAFETY: extra_init bytes of ibuf are known to be initialized + unsafe { + sliced_buf.set_init(extra_init); + } + let mut cursor = sliced_buf.unfilled(); let result = self.inner.read_buf(cursor.reborrow()); + let new_init = cursor.init_mut().len(); let filled = sliced_buf.len(); // cursor / sliced_buf / ibuf must drop here - // SAFETY: filled bytes have been filled and therefore initialized unsafe { - buf.advance(filled); + // SAFETY: filled bytes have been filled and therefore initialized + buf.advance_unchecked(filled); + // SAFETY: new_init bytes of buf's unfilled buffer have been initialized + buf.set_init(new_init); } self.limit -= filled as u64; diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index e14e6432eafa..b22988d4a8a9 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -209,6 +209,15 @@ fn read_buf_exact() { assert_eq!(c.read_buf_exact(buf.unfilled()).unwrap_err().kind(), io::ErrorKind::UnexpectedEof); } +#[test] +#[should_panic] +fn borrowed_cursor_advance_overflow() { + let mut buf = [0; 512]; + let mut buf = BorrowedBuf::from(&mut buf[..]); + buf.unfilled().advance(1); + buf.unfilled().advance(usize::MAX); +} + #[test] fn take_eof() { struct R; diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index a09c8bc06930..0410df3ef1a3 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -283,7 +283,7 @@ impl Read for Repeat { // SAFETY: No uninit bytes are being written. unsafe { buf.as_mut() }.write_filled(self.byte); // SAFETY: the entire unfilled portion of buf has been initialized. - unsafe { buf.advance(buf.capacity()) }; + unsafe { buf.advance_unchecked(buf.capacity()) }; Ok(()) } diff --git a/library/std/src/io/util/tests.rs b/library/std/src/io/util/tests.rs index 92dbc3919bea..d0f106d7af41 100644 --- a/library/std/src/io/util/tests.rs +++ b/library/std/src/io/util/tests.rs @@ -75,36 +75,43 @@ fn empty_reads() { let mut buf: BorrowedBuf<'_> = buf.into(); e.read_buf(buf.unfilled()).unwrap(); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [_] = &mut [MaybeUninit::uninit()]; let mut buf: BorrowedBuf<'_> = buf.into(); e.read_buf(buf.unfilled()).unwrap(); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [_] = &mut [MaybeUninit::uninit(); 1024]; let mut buf: BorrowedBuf<'_> = buf.into(); e.read_buf(buf.unfilled()).unwrap(); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [_] = &mut [MaybeUninit::uninit(); 1024]; let mut buf: BorrowedBuf<'_> = buf.into(); Read::by_ref(&mut e).read_buf(buf.unfilled()).unwrap(); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [MaybeUninit<_>] = &mut []; let mut buf: BorrowedBuf<'_> = buf.into(); e.read_buf_exact(buf.unfilled()).unwrap(); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [_] = &mut [MaybeUninit::uninit()]; let mut buf: BorrowedBuf<'_> = buf.into(); assert_eq!(e.read_buf_exact(buf.unfilled()).unwrap_err().kind(), ErrorKind::UnexpectedEof); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [_] = &mut [MaybeUninit::uninit(); 1024]; let mut buf: BorrowedBuf<'_> = buf.into(); assert_eq!(e.read_buf_exact(buf.unfilled()).unwrap_err().kind(), ErrorKind::UnexpectedEof); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let buf: &mut [_] = &mut [MaybeUninit::uninit(); 1024]; let mut buf: BorrowedBuf<'_> = buf.into(); @@ -113,6 +120,7 @@ fn empty_reads() { ErrorKind::UnexpectedEof, ); assert_eq!(buf.len(), 0); + assert_eq!(buf.init_len(), 0); let mut buf = Vec::new(); assert_eq!(e.read_to_end(&mut buf).unwrap(), 0); diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index 4787f8a1040b..7c7ef7b2f701 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -315,6 +315,8 @@ fn read_buf() { let mut buf = BorrowedBuf::from(buf.as_mut_slice()); t!(s.read_buf(buf.unfilled())); assert_eq!(buf.filled(), &[1, 2, 3, 4]); + // TcpStream::read_buf should omit buffer initialization. + assert_eq!(buf.init_len(), 4); t.join().ok().expect("thread panicked"); }) diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index c8a83edffe42..12c5130defe5 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -188,8 +188,10 @@ fn child_stdout_read_buf() { // ChildStdout::read_buf should omit buffer initialization. if cfg!(target_os = "windows") { assert_eq!(buf.filled(), b"abc\r\n"); + assert_eq!(buf.init_len(), 5); } else { assert_eq!(buf.filled(), b"abc\n"); + assert_eq!(buf.init_len(), 4); }; } diff --git a/library/std/src/sys/fd/hermit.rs b/library/std/src/sys/fd/hermit.rs index 28fafdaf57d8..2666da16420c 100644 --- a/library/std/src/sys/fd/hermit.rs +++ b/library/std/src/sys/fd/hermit.rs @@ -33,7 +33,7 @@ impl FileDesc { ) })?; // SAFETY: Exactly `result` bytes have been filled. - unsafe { buf.advance(result as usize) }; + unsafe { buf.advance_unchecked(result as usize) }; Ok(()) } diff --git a/library/std/src/sys/fd/unix.rs b/library/std/src/sys/fd/unix.rs index c5e8646dada1..bb6c0ac9e18e 100644 --- a/library/std/src/sys/fd/unix.rs +++ b/library/std/src/sys/fd/unix.rs @@ -185,7 +185,7 @@ impl FileDesc { // SAFETY: `ret` bytes were written to the initialized portion of the buffer unsafe { - cursor.advance(ret as usize); + cursor.advance_unchecked(ret as usize); } Ok(()) } @@ -203,7 +203,7 @@ impl FileDesc { // SAFETY: `ret` bytes were written to the initialized portion of the buffer unsafe { - cursor.advance(ret as usize); + cursor.advance_unchecked(ret as usize); } Ok(()) } diff --git a/library/std/src/sys/fs/solid.rs b/library/std/src/sys/fs/solid.rs index ec1db262855a..f6d5d3b784d3 100644 --- a/library/std/src/sys/fs/solid.rs +++ b/library/std/src/sys/fs/solid.rs @@ -401,7 +401,7 @@ impl File { // Safety: `num_bytes_read` bytes were written to the unfilled // portion of the buffer - cursor.advance(num_bytes_read); + cursor.advance_unchecked(num_bytes_read); Ok(()) } diff --git a/library/std/src/sys/net/connection/socket/hermit.rs b/library/std/src/sys/net/connection/socket/hermit.rs index 8350d2b5fe4a..c32f8dcc8de8 100644 --- a/library/std/src/sys/net/connection/socket/hermit.rs +++ b/library/std/src/sys/net/connection/socket/hermit.rs @@ -143,7 +143,7 @@ impl Socket { ) })?; unsafe { - buf.advance(ret as usize); + buf.advance_unchecked(ret as usize); } Ok(()) } diff --git a/library/std/src/sys/net/connection/socket/solid.rs b/library/std/src/sys/net/connection/socket/solid.rs index ac06cdc00c8f..673d75046d3f 100644 --- a/library/std/src/sys/net/connection/socket/solid.rs +++ b/library/std/src/sys/net/connection/socket/solid.rs @@ -190,7 +190,7 @@ impl Socket { netc::recv(self.as_raw_fd(), buf.as_mut().as_mut_ptr().cast(), buf.capacity(), flags) })?; unsafe { - buf.advance(ret as usize); + buf.advance_unchecked(ret as usize); } Ok(()) } diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs index 323d6214347e..6d06a8d86bf1 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -294,7 +294,7 @@ impl Socket { ) })?; unsafe { - buf.advance(ret as usize); + buf.advance_unchecked(ret as usize); } Ok(()) } diff --git a/library/std/src/sys/net/connection/socket/windows.rs b/library/std/src/sys/net/connection/socket/windows.rs index 4da51d78ea69..7355f0ce6bf5 100644 --- a/library/std/src/sys/net/connection/socket/windows.rs +++ b/library/std/src/sys/net/connection/socket/windows.rs @@ -243,7 +243,7 @@ impl Socket { } } _ => { - unsafe { buf.advance(result as usize) }; + unsafe { buf.advance_unchecked(result as usize) }; Ok(()) } } diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs b/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs index f1e4a5a42577..5041770faf66 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs @@ -46,7 +46,7 @@ pub fn read_buf(fd: Fd, mut buf: BorrowedCursor<'_>) -> IoResult<()> { let mut userbuf = alloc::User::<[u8]>::uninitialized(buf.capacity()); let len = raw::read(fd, userbuf.as_mut_ptr().cast(), userbuf.len()).from_sgx_result()?; userbuf[..len].copy_to_enclave(&mut buf.as_mut()[..len]); - buf.advance(len); + buf.advance_unchecked(len); Ok(()) } } diff --git a/library/std/src/sys/pal/windows/handle.rs b/library/std/src/sys/pal/windows/handle.rs index ffa8507831ac..90e243e1aa03 100644 --- a/library/std/src/sys/pal/windows/handle.rs +++ b/library/std/src/sys/pal/windows/handle.rs @@ -117,7 +117,7 @@ impl Handle { Ok(read) => { // Safety: `read` bytes were written to the initialized portion of the buffer unsafe { - cursor.advance(read); + cursor.advance_unchecked(read); } Ok(()) } @@ -140,7 +140,7 @@ impl Handle { // SAFETY: `read` bytes were written to the initialized portion of the buffer unsafe { - cursor.advance(read); + cursor.advance_unchecked(read); } Ok(()) } diff --git a/library/std/src/sys/process/windows/child_pipe.rs b/library/std/src/sys/process/windows/child_pipe.rs index b848435ac275..da7a86ca072e 100644 --- a/library/std/src/sys/process/windows/child_pipe.rs +++ b/library/std/src/sys/process/windows/child_pipe.rs @@ -260,7 +260,7 @@ impl ChildPipe { Err(e) => Err(e), Ok(n) => { unsafe { - buf.advance(n); + buf.advance_unchecked(n); } Ok(()) } diff --git a/library/std/src/sys/stdio/zkvm.rs b/library/std/src/sys/stdio/zkvm.rs index 84496ac93736..f31c6c26e87c 100644 --- a/library/std/src/sys/stdio/zkvm.rs +++ b/library/std/src/sys/stdio/zkvm.rs @@ -19,7 +19,7 @@ impl io::Read for Stdin { fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { unsafe { let n = abi::sys_read(fileno::STDIN, buf.as_mut().as_mut_ptr().cast(), buf.capacity()); - buf.advance(n); + buf.advance_unchecked(n); } Ok(()) } From 6fac0fac9962962f77f46fe148bbca2ed6b60f59 Mon Sep 17 00:00:00 2001 From: delta17920 Date: Sun, 14 Dec 2025 15:08:01 +0000 Subject: [PATCH 229/489] Apply review suggestions --- .../rustc_resolve/src/late/diagnostics.rs | 85 +++++++++--- tests/ui/match/issue-92100.stderr | 6 + ...tern-meant-to-be-slice-rest-pattern.stderr | 18 +++ .../suggest-range-struct-destructuring.rs | 41 ++++-- .../suggest-range-struct-destructuring.stderr | 127 +++++++++++++----- tests/ui/typeck/issue-105946.stderr | 6 + 6 files changed, 221 insertions(+), 62 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 85e8917ae32e..f75ac400dc0b 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1385,38 +1385,81 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } fn suggest_range_struct_destructuring( - &self, + &mut self, err: &mut Diag<'_>, path: &[Segment], source: PathSource<'_, '_, '_>, ) { - // We accept Expr here because range bounds (start..end) are parsed as expressions if !matches!(source, PathSource::Pat | PathSource::TupleStruct(..) | PathSource::Expr(..)) { return; } - if let Some(pat) = self.diag_metadata.current_pat - && let ast::PatKind::Range(Some(start_expr), Some(end_expr), _) = &pat.kind - && let (ast::ExprKind::Path(None, start_path), ast::ExprKind::Path(None, end_path)) = - (&start_expr.kind, &end_expr.kind) - && path.len() == 1 - { - let ident = path[0].ident; + let Some(pat) = self.diag_metadata.current_pat else { return }; + let ast::PatKind::Range(start, end, end_kind) = &pat.kind else { return }; - if (start_path.segments.len() == 1 && start_path.segments[0].ident == ident) - || (end_path.segments.len() == 1 && end_path.segments[0].ident == ident) - { - let start_name = start_path.segments[0].ident; - let end_name = end_path.segments[0].ident; + let [segment] = path else { return }; + let failing_span = segment.ident.span; - err.span_suggestion_verbose( - pat.span, - "if you meant to destructure a `Range`, use a struct pattern", - format!("std::ops::Range {{ start: {}, end: {} }}", start_name, end_name), - Applicability::MaybeIncorrect, - ); - } + let in_start = start.as_ref().is_some_and(|e| e.span.contains(failing_span)); + let in_end = end.as_ref().is_some_and(|e| e.span.contains(failing_span)); + + if !in_start && !in_end { + return; } + + let start_snippet = + start.as_ref().and_then(|e| self.r.tcx.sess.source_map().span_to_snippet(e.span).ok()); + let end_snippet = + end.as_ref().and_then(|e| self.r.tcx.sess.source_map().span_to_snippet(e.span).ok()); + + let field = |name: &str, val: String| { + if val == name { val } else { format!("{name}: {val}") } + }; + + let mut resolve_short_name = |short: Symbol, full: &str| -> String { + let ident = Ident::with_dummy_span(short); + let path = Segment::from_path(&Path::from_ident(ident)); + + match self.resolve_path(&path, Some(TypeNS), None, PathSource::Type) { + PathResult::NonModule(..) => short.to_string(), + _ => full.to_string(), + } + }; + // FIXME(new_range): Also account for new range types + let (struct_path, fields) = match (start_snippet, end_snippet, &end_kind.node) { + (Some(start), Some(end), ast::RangeEnd::Excluded) => ( + resolve_short_name(sym::Range, "std::ops::Range"), + vec![field("start", start), field("end", end)], + ), + (Some(start), Some(end), ast::RangeEnd::Included(_)) => ( + resolve_short_name(sym::RangeInclusive, "std::ops::RangeInclusive"), + vec![field("start", start), field("end", end)], + ), + (Some(start), None, _) => ( + resolve_short_name(sym::RangeFrom, "std::ops::RangeFrom"), + vec![field("start", start)], + ), + (None, Some(end), ast::RangeEnd::Excluded) => { + (resolve_short_name(sym::RangeTo, "std::ops::RangeTo"), vec![field("end", end)]) + } + (None, Some(end), ast::RangeEnd::Included(_)) => ( + resolve_short_name(sym::RangeToInclusive, "std::ops::RangeToInclusive"), + vec![field("end", end)], + ), + _ => return, + }; + + err.span_suggestion_verbose( + pat.span, + format!("if you meant to destructure a range use a struct pattern"), + format!("{} {{ {} }}", struct_path, fields.join(", ")), + Applicability::MaybeIncorrect, + ); + + err.note( + "range patterns match against the start and end of a range; \ + to bind the components, use a struct pattern", + ); } fn suggest_swapping_misplaced_self_ty_and_trait( diff --git a/tests/ui/match/issue-92100.stderr b/tests/ui/match/issue-92100.stderr index eb9f4ba1ad69..13aacc4782af 100644 --- a/tests/ui/match/issue-92100.stderr +++ b/tests/ui/match/issue-92100.stderr @@ -4,10 +4,16 @@ error[E0425]: cannot find value `a` in this scope LL | [a.., a] => {} | ^ not found in this scope | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern help: if you meant to collect the rest of the slice in `a`, use the at operator | LL | [a @ .., a] => {} | + +help: if you meant to destructure a range use a struct pattern + | +LL - [a.., a] => {} +LL + [std::ops::RangeFrom { start: a }, a] => {} + | error: aborting due to 1 previous error diff --git a/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr index 37b2d96bb019..378ff04d3a1a 100644 --- a/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr +++ b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.stderr @@ -16,10 +16,16 @@ error[E0425]: cannot find value `rest` in this scope LL | [1, rest..] => println!("{rest}"), | ^^^^ not found in this scope | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern help: if you meant to collect the rest of the slice in `rest`, use the at operator | LL | [1, rest @ ..] => println!("{rest}"), | + +help: if you meant to destructure a range use a struct pattern + | +LL - [1, rest..] => println!("{rest}"), +LL + [1, std::ops::RangeFrom { start: rest }] => println!("{rest}"), + | error[E0425]: cannot find value `rest` in this scope --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:35 @@ -33,11 +39,17 @@ error[E0425]: cannot find value `tail` in this scope LL | [_, ..tail] => println!("{tail}"), | ^^^^ not found in this scope | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern help: if you meant to collect the rest of the slice in `tail`, use the at operator | LL - [_, ..tail] => println!("{tail}"), LL + [_, tail @ ..] => println!("{tail}"), | +help: if you meant to destructure a range use a struct pattern + | +LL - [_, ..tail] => println!("{tail}"), +LL + [_, std::ops::RangeTo { end: tail }] => println!("{tail}"), + | error[E0425]: cannot find value `tail` in this scope --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:11:35 @@ -51,11 +63,17 @@ error[E0425]: cannot find value `tail` in this scope LL | [_, ...tail] => println!("{tail}"), | ^^^^ not found in this scope | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern help: if you meant to collect the rest of the slice in `tail`, use the at operator | LL - [_, ...tail] => println!("{tail}"), LL + [_, tail @ ..] => println!("{tail}"), | +help: if you meant to destructure a range use a struct pattern + | +LL - [_, ...tail] => println!("{tail}"), +LL + [_, std::ops::RangeToInclusive { end: tail }] => println!("{tail}"), + | error[E0425]: cannot find value `tail` in this scope --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:17:36 diff --git a/tests/ui/resolve/suggest-range-struct-destructuring.rs b/tests/ui/resolve/suggest-range-struct-destructuring.rs index f690a7cad23f..ee8a99ceaa1a 100644 --- a/tests/ui/resolve/suggest-range-struct-destructuring.rs +++ b/tests/ui/resolve/suggest-range-struct-destructuring.rs @@ -1,15 +1,40 @@ -use std::ops::Range; +use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive}; -fn test_basic_range(r: Range) { +fn test_range(r: Range) { let start..end = r; - //~^ ERROR cannot find value `start` in this scope - //~| ERROR cannot find value `end` in this scope + //~^ ERROR cannot find value `start` + //~| ERROR cannot find value `end` } -fn test_different_names(r: Range) { - let min..max = r; - //~^ ERROR cannot find value `min` in this scope - //~| ERROR cannot find value `max` in this scope +fn test_inclusive(r: RangeInclusive) { + let start..=end = r; + //~^ ERROR cannot find value `start` + //~| ERROR cannot find value `end` +} + +fn test_from(r: RangeFrom) { + let start.. = r; + //~^ ERROR cannot find value `start` +} + +fn test_to(r: RangeTo) { + let ..end = r; + //~^ ERROR cannot find value `end` +} + +fn test_to_inclusive(r: RangeToInclusive) { + let ..=end = r; + //~^ ERROR cannot find value `end` +} + +// Case 6: Complex Path (Keep this! It works!) +mod my { + // We don't define MISSING here to trigger the error +} +fn test_path(r: Range) { + let my::MISSING..end = r; + //~^ ERROR cannot find value `MISSING` + //~| ERROR cannot find value `end` } fn main() {} diff --git a/tests/ui/resolve/suggest-range-struct-destructuring.stderr b/tests/ui/resolve/suggest-range-struct-destructuring.stderr index 1a11e6ac8421..78a248ed777d 100644 --- a/tests/ui/resolve/suggest-range-struct-destructuring.stderr +++ b/tests/ui/resolve/suggest-range-struct-destructuring.stderr @@ -4,10 +4,11 @@ error[E0425]: cannot find value `start` in this scope LL | let start..end = r; | ^^^^^ not found in this scope | -help: if you meant to destructure a `Range`, use a struct pattern + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to destructure a range use a struct pattern | LL - let start..end = r; -LL + let std::ops::Range { start: start, end: end } = r; +LL + let Range { start, end } = r; | error[E0425]: cannot find value `end` in this scope @@ -16,51 +17,111 @@ error[E0425]: cannot find value `end` in this scope LL | let start..end = r; | ^^^ not found in this scope | -help: if you meant to destructure a `Range`, use a struct pattern + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to destructure a range use a struct pattern | LL - let start..end = r; -LL + let std::ops::Range { start: start, end: end } = r; +LL + let Range { start, end } = r; | -error[E0425]: cannot find value `min` in this scope +error[E0425]: cannot find value `start` in this scope --> $DIR/suggest-range-struct-destructuring.rs:10:9 | -LL | let min..max = r; - | ^^^ -... -LL | fn main() {} - | --------- similarly named function `main` defined here +LL | let start..=end = r; + | ^^^^^ not found in this scope | -help: if you meant to destructure a `Range`, use a struct pattern + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to destructure a range use a struct pattern | -LL - let min..max = r; -LL + let std::ops::Range { start: min, end: max } = r; - | -help: a function with a similar name exists - | -LL | let main..max = r; - | + -help: consider importing this function - | -LL + use std::cmp::min; +LL - let start..=end = r; +LL + let RangeInclusive { start, end } = r; | -error[E0425]: cannot find value `max` in this scope - --> $DIR/suggest-range-struct-destructuring.rs:10:14 +error[E0425]: cannot find value `end` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:10:17 | -LL | let min..max = r; - | ^^^ not found in this scope +LL | let start..=end = r; + | ^^^ not found in this scope | -help: if you meant to destructure a `Range`, use a struct pattern + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to destructure a range use a struct pattern | -LL - let min..max = r; -LL + let std::ops::Range { start: min, end: max } = r; - | -help: consider importing this function - | -LL + use std::cmp::max; +LL - let start..=end = r; +LL + let RangeInclusive { start, end } = r; | -error: aborting due to 4 previous errors +error[E0425]: cannot find value `start` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:16:9 + | +LL | let start.. = r; + | ^^^^^ not found in this scope + | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to collect the rest of the slice in `start`, use the at operator + | +LL | let start @ .. = r; + | + +help: if you meant to destructure a range use a struct pattern + | +LL - let start.. = r; +LL + let RangeFrom { start } = r; + | + +error[E0425]: cannot find value `end` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:21:11 + | +LL | let ..end = r; + | ^^^ not found in this scope + | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to collect the rest of the slice in `end`, use the at operator + | +LL - let ..end = r; +LL + let end @ .. = r; + | +help: if you meant to destructure a range use a struct pattern + | +LL - let ..end = r; +LL + let RangeTo { end } = r; + | + +error[E0425]: cannot find value `end` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:26:12 + | +LL | let ..=end = r; + | ^^^ not found in this scope + | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to collect the rest of the slice in `end`, use the at operator + | +LL - let ..=end = r; +LL + let end @ .. = r; + | +help: if you meant to destructure a range use a struct pattern + | +LL - let ..=end = r; +LL + let RangeToInclusive { end } = r; + | + +error[E0425]: cannot find value `MISSING` in module `my` + --> $DIR/suggest-range-struct-destructuring.rs:35:13 + | +LL | let my::MISSING..end = r; + | ^^^^^^^ not found in `my` + +error[E0425]: cannot find value `end` in this scope + --> $DIR/suggest-range-struct-destructuring.rs:35:22 + | +LL | let my::MISSING..end = r; + | ^^^ not found in this scope + | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern +help: if you meant to destructure a range use a struct pattern + | +LL - let my::MISSING..end = r; +LL + let Range { start: my::MISSING, end } = r; + | + +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/typeck/issue-105946.stderr b/tests/ui/typeck/issue-105946.stderr index 30fe2000a461..3f8733bda763 100644 --- a/tests/ui/typeck/issue-105946.stderr +++ b/tests/ui/typeck/issue-105946.stderr @@ -4,10 +4,16 @@ error[E0425]: cannot find value `_y` in this scope LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^ not found in this scope | + = note: range patterns match against the start and end of a range; to bind the components, use a struct pattern help: if you meant to collect the rest of the slice in `_y`, use the at operator | LL | let [_y @ ..] = [Box::new(1), Box::new(2)]; | + +help: if you meant to destructure a range use a struct pattern + | +LL - let [_y..] = [Box::new(1), Box::new(2)]; +LL + let [std::ops::RangeFrom { start: _y }] = [Box::new(1), Box::new(2)]; + | error[E0658]: `X..` patterns in slices are experimental --> $DIR/issue-105946.rs:7:10 From c7dd19b8d6fc3a06dfec78ad76452babcadef3b5 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 17 Dec 2025 12:25:45 +0100 Subject: [PATCH 230/489] add `miri_spin_loop` to make `hint::spin_loop` work consistently --- library/core/src/hint.rs | 9 +++++++++ src/tools/miri/src/shims/foreign_items.rs | 7 +++++++ src/tools/miri/tests/utils/miri_extern.rs | 3 +++ 3 files changed, 19 insertions(+) diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index e2ac746d3149..4c050b49bf7e 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -269,6 +269,15 @@ pub const unsafe fn assert_unchecked(cond: bool) { #[stable(feature = "renamed_spin_loop", since = "1.49.0")] pub fn spin_loop() { crate::cfg_select! { + miri => { + unsafe extern "Rust" { + safe fn miri_spin_loop(); + } + + // Miri does support some of the intrinsics that are called below, but to guarantee + // consistent behavior across targets, this custom function is used. + miri_spin_loop(); + } target_arch = "x86" => { // SAFETY: the `cfg` attr ensures that we only execute this on x86 targets. crate::arch::x86::_mm_pause() diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 8a959d06bf9c..48f4ca53cdca 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -435,6 +435,13 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Return value: 0 on success, otherwise the size it would have needed. this.write_int(if success { 0 } else { needed_size }, dest)?; } + // Hint that a loop is spinning indefinitely. + "miri_spin_loop" => { + let [] = this.check_shim_sig_lenient(abi, CanonAbi::Rust, link_name, args)?; + + // Try to run another thread to maximize the chance of finding actual bugs. + this.yield_active_thread(); + } // Obtains the size of a Miri backtrace. See the README for details. "miri_backtrace_size" => { this.handle_miri_backtrace_size(abi, link_name, args, dest)?; diff --git a/src/tools/miri/tests/utils/miri_extern.rs b/src/tools/miri/tests/utils/miri_extern.rs index 09f9ca032d43..bd01866dc34c 100644 --- a/src/tools/miri/tests/utils/miri_extern.rs +++ b/src/tools/miri/tests/utils/miri_extern.rs @@ -155,4 +155,7 @@ extern "Rust" { /// Blocks the current execution if the argument is false pub fn miri_genmc_assume(condition: bool); + + /// Indicate to Miri that this thread is busy-waiting in a spin loop. + pub fn miri_spin_loop(); } From 0f17de76b81f64f032d31a309d63f8a6c250a7c6 Mon Sep 17 00:00:00 2001 From: Samuel Onoja Date: Wed, 17 Dec 2025 16:23:28 +0100 Subject: [PATCH 231/489] skip `needless_type_cast` for single-use non-coercible casts --- clippy_lints/src/casts/needless_type_cast.rs | 59 +++++++++- tests/ui/needless_type_cast.fixed | 87 ++++++++++++++ tests/ui/needless_type_cast.rs | 87 ++++++++++++++ tests/ui/needless_type_cast.stderr | 114 +++++++++++++++++-- 4 files changed, 330 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/casts/needless_type_cast.rs b/clippy_lints/src/casts/needless_type_cast.rs index 8ef9db1b510c..1d899a21c229 100644 --- a/clippy_lints/src/casts/needless_type_cast.rs +++ b/clippy_lints/src/casts/needless_type_cast.rs @@ -1,6 +1,8 @@ -use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg::Sugg; use clippy_utils::visitors::{Descend, for_each_expr, for_each_expr_without_closures}; use core::ops::ControlFlow; +use rustc_ast::ast::{LitFloatType, LitIntType, LitKind}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; @@ -14,6 +16,7 @@ use super::NEEDLESS_TYPE_CAST; struct BindingInfo<'a> { source_ty: Ty<'a>, ty_span: Span, + init: Option<&'a Expr<'a>>, } struct UsageInfo<'a> { @@ -73,6 +76,7 @@ fn collect_binding_from_let<'a>( BindingInfo { source_ty: ty, ty_span: ty_hir.span, + init: Some(let_expr.init), }, ); } @@ -103,6 +107,7 @@ fn collect_binding_from_local<'a>( BindingInfo { source_ty: ty, ty_span: ty_hir.span, + init: let_stmt.init, }, ); } @@ -229,6 +234,18 @@ fn is_cast_in_generic_context<'a>(cx: &LateContext<'a>, cast_expr: &Expr<'a>) -> } } +fn can_coerce_to_target_type(expr: &Expr<'_>) -> bool { + match expr.kind { + ExprKind::Lit(lit) => matches!( + lit.node, + LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed) + ), + ExprKind::Unary(rustc_hir::UnOp::Neg, inner) => can_coerce_to_target_type(inner), + ExprKind::Binary(_, lhs, rhs) => can_coerce_to_target_type(lhs) && can_coerce_to_target_type(rhs), + _ => false, + } +} + fn check_binding_usages<'a>(cx: &LateContext<'a>, body: &Body<'a>, hir_id: HirId, binding_info: &BindingInfo<'a>) { let mut usages = Vec::new(); @@ -269,7 +286,19 @@ fn check_binding_usages<'a>(cx: &LateContext<'a>, body: &Body<'a>, hir_id: HirId return; }; - span_lint_and_sugg( + // Don't lint if there's exactly one use and the initializer cannot be coerced to the + // target type (i.e., would require an explicit cast). In such cases, the fix would add + // a cast to the initializer rather than eliminating one - the cast isn't truly "needless." + // See: https://github.com/rust-lang/rust-clippy/issues/16240 + if usages.len() == 1 + && binding_info + .init + .is_some_and(|init| !can_coerce_to_target_type(init) && !init.span.from_expansion()) + { + return; + } + + span_lint_and_then( cx, NEEDLESS_TYPE_CAST, binding_info.ty_span, @@ -277,8 +306,28 @@ fn check_binding_usages<'a>(cx: &LateContext<'a>, body: &Body<'a>, hir_id: HirId "this binding is defined as `{}` but is always cast to `{}`", binding_info.source_ty, first_target ), - "consider defining it as", - first_target.to_string(), - Applicability::MaybeIncorrect, + |diag| { + if let Some(init) = binding_info + .init + .filter(|i| !can_coerce_to_target_type(i) && !i.span.from_expansion()) + { + let sugg = Sugg::hir(cx, init, "..").as_ty(first_target); + diag.multipart_suggestion( + format!("consider defining it as `{first_target}` and casting the initializer"), + vec![ + (binding_info.ty_span, first_target.to_string()), + (init.span, sugg.to_string()), + ], + Applicability::MachineApplicable, + ); + } else { + diag.span_suggestion( + binding_info.ty_span, + "consider defining it as", + first_target.to_string(), + Applicability::MachineApplicable, + ); + } + }, ); } diff --git a/tests/ui/needless_type_cast.fixed b/tests/ui/needless_type_cast.fixed index 32c348d3ca3a..72eed32c4d73 100644 --- a/tests/ui/needless_type_cast.fixed +++ b/tests/ui/needless_type_cast.fixed @@ -9,6 +9,10 @@ fn generic(x: T) -> T { x } +fn returns_u8() -> u8 { + 10 +} + fn main() { let a: i32 = 10; //~^ needless_type_cast @@ -180,3 +184,86 @@ fn test_loop_with_generic() { }; let _ = x as i32; } + +fn test_size_of_cast() { + use std::mem::size_of; + // Should lint: suggest casting the initializer + let size: u64 = size_of::() as u64; + //~^ needless_type_cast + let _ = size as u64; + let _ = size as u64; +} + +fn test_suffixed_literal_cast() { + // Should lint: suggest casting the initializer + let a: i32 = 10u8 as i32; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_negative_literal() { + // Negative literal - should just change type, not add cast + let a: i32 = -10; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_suffixed_negative_literal() { + // Suffixed negative - needs cast + let a: i32 = -10i8 as i32; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_binary_op() { + // Binary op needs parens in cast + let a: i32 = 10 + 5; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_fn_return_as_init() { + let a: i32 = returns_u8() as i32; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_method_as_init() { + let a: i32 = 2u8.saturating_add(3) as i32; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_const_as_init() { + const X: u8 = 10; + let a: i32 = X as i32; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_single_use_fn_call() { + // Should not lint: only one use, and fixing would just move the cast + // to the initializer rather than eliminating it + let a: u8 = returns_u8(); + let _ = a as i32; +} + +fn test_single_use_suffixed_literal() { + // Should not lint: only one use with a suffixed literal + let a: u8 = 10u8; + let _ = a as i32; +} + +fn test_single_use_binary_op() { + // Should lint: binary op of unsuffixed literals can be coerced + let a: i32 = 10 + 5; + //~^ needless_type_cast + let _ = a as i32; +} diff --git a/tests/ui/needless_type_cast.rs b/tests/ui/needless_type_cast.rs index e28f620e035f..31337575fcc3 100644 --- a/tests/ui/needless_type_cast.rs +++ b/tests/ui/needless_type_cast.rs @@ -9,6 +9,10 @@ fn generic(x: T) -> T { x } +fn returns_u8() -> u8 { + 10 +} + fn main() { let a: u8 = 10; //~^ needless_type_cast @@ -180,3 +184,86 @@ fn test_loop_with_generic() { }; let _ = x as i32; } + +fn test_size_of_cast() { + use std::mem::size_of; + // Should lint: suggest casting the initializer + let size: usize = size_of::(); + //~^ needless_type_cast + let _ = size as u64; + let _ = size as u64; +} + +fn test_suffixed_literal_cast() { + // Should lint: suggest casting the initializer + let a: u8 = 10u8; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_negative_literal() { + // Negative literal - should just change type, not add cast + let a: i8 = -10; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_suffixed_negative_literal() { + // Suffixed negative - needs cast + let a: i8 = -10i8; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_binary_op() { + // Binary op needs parens in cast + let a: u8 = 10 + 5; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_fn_return_as_init() { + let a: u8 = returns_u8(); + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_method_as_init() { + let a: u8 = 2u8.saturating_add(3); + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_const_as_init() { + const X: u8 = 10; + let a: u8 = X; + //~^ needless_type_cast + let _ = a as i32; + let _ = a as i32; +} + +fn test_single_use_fn_call() { + // Should not lint: only one use, and fixing would just move the cast + // to the initializer rather than eliminating it + let a: u8 = returns_u8(); + let _ = a as i32; +} + +fn test_single_use_suffixed_literal() { + // Should not lint: only one use with a suffixed literal + let a: u8 = 10u8; + let _ = a as i32; +} + +fn test_single_use_binary_op() { + // Should lint: binary op of unsuffixed literals can be coerced + let a: u8 = 10 + 5; + //~^ needless_type_cast + let _ = a as i32; +} diff --git a/tests/ui/needless_type_cast.stderr b/tests/ui/needless_type_cast.stderr index 3ee9df1043e7..56d9e978d05c 100644 --- a/tests/ui/needless_type_cast.stderr +++ b/tests/ui/needless_type_cast.stderr @@ -1,5 +1,5 @@ error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:13:12 + --> tests/ui/needless_type_cast.rs:17:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` @@ -8,64 +8,154 @@ LL | let a: u8 = 10; = help: to override `-D warnings` add `#[allow(clippy::needless_type_cast)]` error: this binding is defined as `u8` but is always cast to `usize` - --> tests/ui/needless_type_cast.rs:33:12 + --> tests/ui/needless_type_cast.rs:37:12 | LL | let f: u8 = 1; | ^^ help: consider defining it as: `usize` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:39:12 + --> tests/ui/needless_type_cast.rs:43:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:52:12 + --> tests/ui/needless_type_cast.rs:56:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:59:12 + --> tests/ui/needless_type_cast.rs:63:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:66:12 + --> tests/ui/needless_type_cast.rs:70:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:77:12 + --> tests/ui/needless_type_cast.rs:81:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:99:16 + --> tests/ui/needless_type_cast.rs:103:16 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:107:12 + --> tests/ui/needless_type_cast.rs:111:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:116:12 + --> tests/ui/needless_type_cast.rs:120:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` error: this binding is defined as `u8` but is always cast to `i32` - --> tests/ui/needless_type_cast.rs:122:12 + --> tests/ui/needless_type_cast.rs:126:12 | LL | let a: u8 = 10; | ^^ help: consider defining it as: `i32` -error: aborting due to 11 previous errors +error: this binding is defined as `usize` but is always cast to `u64` + --> tests/ui/needless_type_cast.rs:191:15 + | +LL | let size: usize = size_of::(); + | ^^^^^ + | +help: consider defining it as `u64` and casting the initializer + | +LL - let size: usize = size_of::(); +LL + let size: u64 = size_of::() as u64; + | + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:199:12 + | +LL | let a: u8 = 10u8; + | ^^ + | +help: consider defining it as `i32` and casting the initializer + | +LL - let a: u8 = 10u8; +LL + let a: i32 = 10u8 as i32; + | + +error: this binding is defined as `i8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:207:12 + | +LL | let a: i8 = -10; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `i8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:215:12 + | +LL | let a: i8 = -10i8; + | ^^ + | +help: consider defining it as `i32` and casting the initializer + | +LL - let a: i8 = -10i8; +LL + let a: i32 = -10i8 as i32; + | + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:223:12 + | +LL | let a: u8 = 10 + 5; + | ^^ help: consider defining it as: `i32` + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:230:12 + | +LL | let a: u8 = returns_u8(); + | ^^ + | +help: consider defining it as `i32` and casting the initializer + | +LL - let a: u8 = returns_u8(); +LL + let a: i32 = returns_u8() as i32; + | + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:237:12 + | +LL | let a: u8 = 2u8.saturating_add(3); + | ^^ + | +help: consider defining it as `i32` and casting the initializer + | +LL - let a: u8 = 2u8.saturating_add(3); +LL + let a: i32 = 2u8.saturating_add(3) as i32; + | + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:245:12 + | +LL | let a: u8 = X; + | ^^ + | +help: consider defining it as `i32` and casting the initializer + | +LL - let a: u8 = X; +LL + let a: i32 = X as i32; + | + +error: this binding is defined as `u8` but is always cast to `i32` + --> tests/ui/needless_type_cast.rs:266:12 + | +LL | let a: u8 = 10 + 5; + | ^^ help: consider defining it as: `i32` + +error: aborting due to 20 previous errors From 8fcddc639303a83fcfbae47b1d7c88adc94e917c Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Wed, 17 Dec 2025 16:41:00 +0100 Subject: [PATCH 232/489] remove `legacy_const_generic_args` cache --- compiler/rustc_ast_lowering/src/expr.rs | 3 ++- compiler/rustc_ast_lowering/src/lib.rs | 16 +++++++++------- compiler/rustc_middle/src/ty/mod.rs | 3 +-- compiler/rustc_resolve/src/lib.rs | 10 ++-------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index c8a311443a58..0502fd2873e9 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -114,7 +114,8 @@ impl<'hir> LoweringContext<'_, 'hir> { } ExprKind::Tup(elts) => hir::ExprKind::Tup(self.lower_exprs(elts)), ExprKind::Call(f, args) => { - if let Some(legacy_args) = self.resolver.legacy_const_generic_args(f) { + if let Some(legacy_args) = self.resolver.legacy_const_generic_args(f, self.tcx) + { self.lower_legacy_const_generics((**f).clone(), args.clone(), &legacy_args) } else { let f = self.lower_expr(f); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index d0871b0b98f4..1bc8d7c25bb5 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -47,13 +47,14 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::spawn; use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle}; +use rustc_hir::attrs::AttributeKind; use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId}; use rustc_hir::definitions::{DefPathData, DisambiguatorState}; use rustc_hir::lints::DelayedLint; use rustc_hir::{ self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource, - LifetimeSyntax, ParamName, Target, TraitCandidate, + LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr, }; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_macros::extension; @@ -236,7 +237,7 @@ impl SpanLowerer { #[extension(trait ResolverAstLoweringExt)] impl ResolverAstLowering { - fn legacy_const_generic_args(&self, expr: &Expr) -> Option> { + fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'_>) -> Option> { let ExprKind::Path(None, path) = &expr.kind else { return None; }; @@ -256,11 +257,12 @@ impl ResolverAstLowering { return None; } - if let Some(v) = self.legacy_const_generic_args.get(&def_id) { - return v.clone(); - } - - None + find_attr!( + // we can use parsed attrs here since for other crates they're already available + tcx.get_all_attrs(def_id), + AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes + ) + .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect()) } fn get_partial_res(&self, id: NodeId) -> Option { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 2021f175cd84..5239fc242c86 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -31,7 +31,7 @@ use rustc_ast::AttrVec; use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree}; use rustc_ast::node_id::NodeMap; pub use rustc_ast_ir::{Movability, Mutability, try_visit}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::steal::Steal; @@ -196,7 +196,6 @@ pub struct ResolverGlobalCtxt { /// This struct is meant to be consumed by lowering. #[derive(Debug)] pub struct ResolverAstLowering { - pub legacy_const_generic_args: FxHashMap>>, /// Resolutions for nodes that have a single resolution. pub partial_res_map: NodeMap, /// Resolutions for import nodes, which have multiple resolutions in different namespaces. diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 5d4134fd91c3..01687e6f4889 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1271,7 +1271,6 @@ pub struct Resolver<'ra, 'tcx> { /// and how the `impl Trait` fragments were introduced. invocation_parents: FxHashMap, - legacy_const_generic_args: FxHashMap>>, /// Amount of lifetime parameters for each item in the crate. item_generics_num_lifetimes: FxHashMap, delegation_fn_sigs: LocalDefIdMap, @@ -1675,7 +1674,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { node_id_to_def_id, disambiguator: DisambiguatorState::new(), placeholder_field_indices: Default::default(), - legacy_const_generic_args: Default::default(), invocation_parents, item_generics_num_lifetimes: Default::default(), trait_impls: Default::default(), @@ -1805,7 +1803,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { stripped_cfg_items, }; let ast_lowering = ty::ResolverAstLowering { - legacy_const_generic_args: self.legacy_const_generic_args, partial_res_map: self.partial_res_map, import_res_map: self.import_res_map, label_res_map: self.label_res_map, @@ -2413,15 +2410,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { return None; } - let indexes = find_attr!( + find_attr!( // we can use parsed attrs here since for other crates they're already available self.tcx.get_all_attrs(def_id), AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes ) - .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect()); - - self.legacy_const_generic_args.insert(def_id, indexes.clone()); - indexes + .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect()) } fn resolve_main(&mut self) { From 851f1698ab9defd3728137f1e04a60dc10070f22 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 17 Dec 2025 16:57:22 +0100 Subject: [PATCH 233/489] Fix invalid handling of field followed by negated macro call --- src/librustdoc/html/highlight.rs | 76 +++++++++++-------- .../field-followed-by-exclamation.rs | 26 +++++++ 2 files changed, 71 insertions(+), 31 deletions(-) create mode 100644 tests/rustdoc/macro-expansion/field-followed-by-exclamation.rs diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 6f6345cd8666..bc268d9495f8 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -832,6 +832,20 @@ impl<'a> PeekIter<'a> { .copied() } + fn peek_next_if bool>( + &mut self, + f: F, + ) -> Option<(TokenKind, &'a str)> { + let next = self.peek_next()?; + if f(next) { + Some(next) + } else { + // We go one step back. + self.peek_pos -= 1; + None + } + } + fn stop_peeking(&mut self) { self.peek_pos = 0; } @@ -903,18 +917,19 @@ fn classify<'src>( } } - if let Some((TokenKind::Colon | TokenKind::Ident, _)) = classifier.tokens.peek() { - let tokens = classifier.get_full_ident_path(); - for &(token, start, end) in &tokens { - let text = &classifier.src[start..end]; - classifier.advance(token, text, sink, start as u32); - classifier.byte_pos += text.len() as u32; + if let Some((TokenKind::Colon | TokenKind::Ident, _)) = classifier.tokens.peek() + && let Some(nb_items) = classifier.get_full_ident_path() + { + let start = classifier.byte_pos as usize; + let mut len = 0; + for _ in 0..nb_items { + if let Some((_, text, _)) = classifier.next() { + len += text.len(); + } } - if !tokens.is_empty() { - continue; - } - } - if let Some((token, text, before)) = classifier.next() { + let text = &classifier.src[start..start + len]; + classifier.advance(TokenKind::Ident, text, sink, start as u32); + } else if let Some((token, text, before)) = classifier.next() { classifier.advance(token, text, sink, before); } else { break; @@ -957,47 +972,47 @@ impl<'src> Classifier<'src> { } /// Concatenate colons and idents as one when possible. - fn get_full_ident_path(&mut self) -> Vec<(TokenKind, usize, usize)> { - let start = self.byte_pos as usize; - let mut pos = start; + fn get_full_ident_path(&mut self) -> Option { let mut has_ident = false; + let mut nb_items = 0; - loop { + let ret = loop { let mut nb = 0; - while let Some((TokenKind::Colon, _)) = self.tokens.peek() { - self.tokens.next(); + while self.tokens.peek_next_if(|(token, _)| token == TokenKind::Colon).is_some() { nb += 1; + nb_items += 1; } // Ident path can start with "::" but if we already have content in the ident path, // the "::" is mandatory. if has_ident && nb == 0 { - return vec![(TokenKind::Ident, start, pos)]; + break Some(nb_items); } else if nb != 0 && nb != 2 { if has_ident { - return vec![(TokenKind::Ident, start, pos), (TokenKind::Colon, pos, pos + nb)]; + // Following `;` will be handled on its own. + break Some(nb_items - 1); } else { - return vec![(TokenKind::Colon, start, pos + nb)]; + break None; } } - if let Some((TokenKind::Ident, text)) = self.tokens.peek() + if let Some((TokenKind::Ident, text)) = + self.tokens.peek_next_if(|(token, _)| token == TokenKind::Ident) && let symbol = Symbol::intern(text) && (symbol.is_path_segment_keyword() || !is_keyword(symbol)) { - // We only "add" the colon if there is an ident behind. - pos += text.len() + nb; has_ident = true; - self.tokens.next(); + nb_items += 1; } else if nb > 0 && has_ident { - return vec![(TokenKind::Ident, start, pos), (TokenKind::Colon, pos, pos + nb)]; - } else if nb > 0 { - return vec![(TokenKind::Colon, start, start + nb)]; + // Following `;` will be handled on its own. + break Some(nb_items - 1); } else if has_ident { - return vec![(TokenKind::Ident, start, pos)]; + break Some(nb_items); } else { - return Vec::new(); + break None; } - } + }; + self.tokens.stop_peeking(); + ret } /// Wraps the tokens iteration to ensure that the `byte_pos` is always correct. @@ -1243,7 +1258,6 @@ impl<'src> Classifier<'src> { Class::MacroNonTerminal } TokenKind::Ident => { - let file_span = self.file_span; let span = || new_span(before, text, file_span); match text { diff --git a/tests/rustdoc/macro-expansion/field-followed-by-exclamation.rs b/tests/rustdoc/macro-expansion/field-followed-by-exclamation.rs new file mode 100644 index 000000000000..e80b4c4ec873 --- /dev/null +++ b/tests/rustdoc/macro-expansion/field-followed-by-exclamation.rs @@ -0,0 +1,26 @@ +// This test ensures that the macro expansion is correctly handled in cases like: +// `field: !f!`, because the `:` was simply not considered because of how paths +// are handled. + +//@ compile-flags: -Zunstable-options --generate-macro-expansion + +#![crate_name = "foo"] + +//@ has 'src/foo/field-followed-by-exclamation.rs.html' + +struct Bar { + bla: bool, +} + +macro_rules! f { + () => {{ false }} +} + +const X: Bar = Bar { + //@ has - '//*[@class="expansion"]/*[@class="original"]/*[@class="macro"]' 'f!' + //@ has - '//*[@class="expansion"]/*[@class="original"]' 'f!()' + //@ has - '//*[@class="expansion"]/*[@class="expanded"]' '{ false }' + // It includes both original and expanded code. + //@ has - '//*[@class="expansion"]' ' bla: !{ false }f!()' + bla: !f!(), +}; From bd137df64a4a9af48f7e107f4a488787fce3f51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Wed, 17 Dec 2025 14:23:13 +0100 Subject: [PATCH 234/489] test for duplicate default eii ICE 149985 Co-authored-by: SATVIKsynopsis --- tests/ui/eii/default/multiple-default-impls.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/ui/eii/default/multiple-default-impls.rs diff --git a/tests/ui/eii/default/multiple-default-impls.rs b/tests/ui/eii/default/multiple-default-impls.rs new file mode 100644 index 000000000000..8a91feec382d --- /dev/null +++ b/tests/ui/eii/default/multiple-default-impls.rs @@ -0,0 +1,8 @@ +#![crate_type = "lib"] +#![feature(extern_item_impls)] + +#[eii(eii1)] +fn a() {} + +#[eii(eii1)] +fn b() {} From 1cd7cb1e8d5cfcf64942222091dae67725bb1951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Wed, 17 Dec 2025 17:53:07 +0100 Subject: [PATCH 235/489] turn panic into span_delayed_bug --- compiler/rustc_passes/src/eii.rs | 3 ++- tests/ui/eii/default/multiple-default-impls.rs | 10 ++++++++++ tests/ui/eii/default/multiple-default-impls.stderr | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/ui/eii/default/multiple-default-impls.stderr diff --git a/compiler/rustc_passes/src/eii.rs b/compiler/rustc_passes/src/eii.rs index 691576e6a05f..ab3f9f0d2182 100644 --- a/compiler/rustc_passes/src/eii.rs +++ b/compiler/rustc_passes/src/eii.rs @@ -116,7 +116,8 @@ pub(crate) fn check_externally_implementable_items<'tcx>(tcx: TyCtxt<'tcx>, (): } if default_impls.len() > 1 { - panic!("multiple not supported right now"); + let decl_span = tcx.def_ident_span(decl_did).unwrap(); + tcx.dcx().span_delayed_bug(decl_span, "multiple not supported right now"); } let (local_impl, is_default) = diff --git a/tests/ui/eii/default/multiple-default-impls.rs b/tests/ui/eii/default/multiple-default-impls.rs index 8a91feec382d..8d2ad0c1e137 100644 --- a/tests/ui/eii/default/multiple-default-impls.rs +++ b/tests/ui/eii/default/multiple-default-impls.rs @@ -1,8 +1,18 @@ #![crate_type = "lib"] #![feature(extern_item_impls)] +// `eii` expands to, among other things, `macro eii() {}`. +// If we have two eiis named the same thing, we have a duplicate definition +// for that macro. The compiler happily continues compiling on duplicate +// definitions though, to emit as many diagnostics as possible. +// However, in the case of eiis, this can break the assumption that every +// eii has only one default implementation, since the default for both eiis will +// name resolve to the same eii definiton (since the other definition was duplicate) +// This test tests for the previously-ICE that occurred when this assumption +// (of 1 default) was broken which was reported in #149982. #[eii(eii1)] fn a() {} #[eii(eii1)] +//~^ ERROR the name `eii1` is defined multiple times fn b() {} diff --git a/tests/ui/eii/default/multiple-default-impls.stderr b/tests/ui/eii/default/multiple-default-impls.stderr new file mode 100644 index 000000000000..b270b2346cd5 --- /dev/null +++ b/tests/ui/eii/default/multiple-default-impls.stderr @@ -0,0 +1,14 @@ +error[E0428]: the name `eii1` is defined multiple times + --> $DIR/multiple-default-impls.rs:16:1 + | +LL | #[eii(eii1)] + | ------------ previous definition of the macro `eii1` here +... +LL | #[eii(eii1)] + | ^^^^^^^^^^^^ `eii1` redefined here + | + = note: `eii1` must be defined only once in the macro namespace of this module + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0428`. From 08b7d34e06832250d3b1c8a4bf5ec78fbbae12a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Wed, 17 Dec 2025 17:57:04 +0100 Subject: [PATCH 236/489] another related case that deserved a test --- .../multiple-default-impls-same-name.rs | 19 ++++++++++++++ .../multiple-default-impls-same-name.stderr | 25 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/ui/eii/default/multiple-default-impls-same-name.rs create mode 100644 tests/ui/eii/default/multiple-default-impls-same-name.stderr diff --git a/tests/ui/eii/default/multiple-default-impls-same-name.rs b/tests/ui/eii/default/multiple-default-impls-same-name.rs new file mode 100644 index 000000000000..080e0a46b755 --- /dev/null +++ b/tests/ui/eii/default/multiple-default-impls-same-name.rs @@ -0,0 +1,19 @@ +#![crate_type = "lib"] +#![feature(extern_item_impls)] +// `eii` expands to, among other things, `macro eii() {}`. +// If we have two eiis named the same thing, we have a duplicate definition +// for that macro. The compiler happily continues compiling on duplicate +// definitions though, to emit as many diagnostics as possible. +// However, in the case of eiis, this can break the assumption that every +// eii has only one default implementation, since the default for both eiis will +// name resolve to the same eii definiton (since the other definition was duplicate) +// This test tests for the previously-ICE that occurred when this assumption +// (of 1 default) was broken which was reported in #149982. + +#[eii(eii1)] +fn a() {} + +#[eii(eii1)] +//~^ ERROR the name `eii1` is defined multiple times +fn a() {} +//~^ ERROR the name `a` is defined multiple times diff --git a/tests/ui/eii/default/multiple-default-impls-same-name.stderr b/tests/ui/eii/default/multiple-default-impls-same-name.stderr new file mode 100644 index 000000000000..20544fcfeeba --- /dev/null +++ b/tests/ui/eii/default/multiple-default-impls-same-name.stderr @@ -0,0 +1,25 @@ +error[E0428]: the name `a` is defined multiple times + --> $DIR/multiple-default-impls-same-name.rs:18:1 + | +LL | fn a() {} + | ------ previous definition of the value `a` here +... +LL | fn a() {} + | ^^^^^^ `a` redefined here + | + = note: `a` must be defined only once in the value namespace of this module + +error[E0428]: the name `eii1` is defined multiple times + --> $DIR/multiple-default-impls-same-name.rs:16:1 + | +LL | #[eii(eii1)] + | ------------ previous definition of the macro `eii1` here +... +LL | #[eii(eii1)] + | ^^^^^^^^^^^^ `eii1` redefined here + | + = note: `eii1` must be defined only once in the macro namespace of this module + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0428`. From bbda675aacff15a8bf93c9b98a66d2faeb0c0d1b Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Wed, 17 Dec 2025 12:31:58 +0100 Subject: [PATCH 237/489] Port `#[rustc_no_implicit_autorefs]` to attribute parser --- .../src/attributes/rustc_internal.rs | 15 +++++++++++++++ compiler/rustc_attr_parsing/src/context.rs | 3 ++- compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/autorefs.rs | 6 +++--- compiler/rustc_passes/src/check_attr.rs | 4 +--- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 620878fb87a7..dc743117d69c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -27,6 +27,21 @@ impl NoArgsAttributeParser for RustcNeverReturnsNullPointerParser { ]); const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNeverReturnsNullPointer; } +pub(crate) struct RustcNoImplicitAutorefsParser; + +impl NoArgsAttributeParser for RustcNoImplicitAutorefsParser { + const PATH: &[Symbol] = &[sym::rustc_no_implicit_autorefs]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitAutorefs; +} pub(crate) struct RustcLayoutScalarValidRangeStartParser; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 54c9785a42f6..8f286d4a0882 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,7 +61,7 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcMainParser, RustcNeverReturnsNullPointerParser, + RustcLegacyConstGenericsParser, RustcMainParser, RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; @@ -257,6 +257,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 4a81c4ebe1e7..bc5473f91cf7 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -881,6 +881,9 @@ pub enum AttributeKind { /// Represents `#[rustc_never_returns_null_ptr]` RustcNeverReturnsNullPointer, + /// Represents `#[rustc_no_implicit_autorefs]` + RustcNoImplicitAutorefs, + /// Represents `#[rustc_object_lifetime_default]`. RustcObjectLifetimeDefault, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index e631d6a2ab87..7b930ca22b1f 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -96,6 +96,7 @@ impl AttributeKind { RustcLegacyConstGenerics { .. } => Yes, RustcMain => No, RustcNeverReturnsNullPointer => Yes, + RustcNoImplicitAutorefs => Yes, RustcObjectLifetimeDefault => No, RustcPassIndirectlyInNonRusticAbis(..) => No, RustcScalableVector { .. } => Yes, diff --git a/compiler/rustc_lint/src/autorefs.rs b/compiler/rustc_lint/src/autorefs.rs index 5490a3aac9b7..ed7ac0e33244 100644 --- a/compiler/rustc_lint/src/autorefs.rs +++ b/compiler/rustc_lint/src/autorefs.rs @@ -1,8 +1,8 @@ use rustc_ast::{BorrowKind, UnOp}; -use rustc_hir::{Expr, ExprKind, Mutability}; +use rustc_hir::attrs::AttributeKind; +use rustc_hir::{Expr, ExprKind, Mutability, find_attr}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, OverloadedDeref}; use rustc_session::{declare_lint, declare_lint_pass}; -use rustc_span::sym; use crate::lints::{ ImplicitUnsafeAutorefsDiag, ImplicitUnsafeAutorefsMethodNote, ImplicitUnsafeAutorefsOrigin, @@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs { ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id), _ => None, } - && method_did.map(|did| cx.tcx.has_attr(did, sym::rustc_no_implicit_autorefs)).unwrap_or(true) + && method_did.map(|did| find_attr!(cx.tcx.get_all_attrs(did), AttributeKind::RustcNoImplicitAutorefs)).unwrap_or(true) { cx.emit_span_lint( DANGEROUS_IMPLICIT_AUTOREFS, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d1f96721fc65..25628605a03c 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -255,6 +255,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::MacroUse { .. } | AttributeKind::MacroEscape( .. ) | AttributeKind::NoLink + | AttributeKind::RustcNoImplicitAutorefs | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) | AttributeKind::RustcNeverReturnsNullPointer @@ -305,9 +306,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } [sym::thread_local, ..] => self.check_thread_local(attr, span, target), - [sym::rustc_no_implicit_autorefs, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } [sym::rustc_lint_query_instability, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } From 81d20363b3f7e1c5d56b35c0de516061b04709a8 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Wed, 17 Dec 2025 13:38:19 +0100 Subject: [PATCH 238/489] Port `#[rustc_lint_opt_ty]` to parsed attribute --- .../src/attributes/rustc_internal.rs | 9 +++++++++ compiler/rustc_attr_parsing/src/context.rs | 4 +++- compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ compiler/rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/internal.rs | 5 +++-- compiler/rustc_passes/messages.ftl | 4 ---- compiler/rustc_passes/src/check_attr.rs | 12 +----------- compiler/rustc_passes/src/errors.rs | 9 --------- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index dc743117d69c..dc03e1c9312a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -117,6 +117,15 @@ impl SingleAttributeParser for RustcLegacyConstGenericsParser { } } +pub(crate) struct RustcLintOptTyParser; + +impl NoArgsAttributeParser for RustcLintOptTyParser { + const PATH: &[Symbol] = &[sym::rustc_lint_opt_ty]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintOptTy; +} + pub(crate) struct RustcObjectLifetimeDefaultParser; impl SingleAttributeParser for RustcObjectLifetimeDefaultParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 8f286d4a0882..8cd30ac9ca46 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,7 +61,8 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcMainParser, RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, + RustcLegacyConstGenericsParser, RustcLintOptTyParser, RustcMainParser, + RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; @@ -255,6 +256,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index bc5473f91cf7..761078bf79fa 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -875,6 +875,9 @@ pub enum AttributeKind { /// Represents `#[rustc_legacy_const_generics]` RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span }, + /// Represents `#[rustc_lint_opt_ty]` + RustcLintOptTy, + /// Represents `#[rustc_main]`. RustcMain, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 7b930ca22b1f..e84fca61ac48 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -94,6 +94,7 @@ impl AttributeKind { RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, + RustcLintOptTy => Yes, RustcMain => No, RustcNeverReturnsNullPointer => Yes, RustcNoImplicitAutorefs => Yes, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index c00ba4959c94..25f5710cca3a 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -1,9 +1,10 @@ //! Some lints that are only useful in the compiler or crates that use compiler internals, such as //! Clippy. +use rustc_hir::attrs::AttributeKind; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; -use rustc_hir::{Expr, ExprKind, HirId}; +use rustc_hir::{Expr, ExprKind, HirId, find_attr}; use rustc_middle::ty::{self, GenericArgsRef, PredicatePolarity, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::hygiene::{ExpnKind, MacroKind}; @@ -658,7 +659,7 @@ impl LateLintPass<'_> for BadOptAccess { let Some(adt_def) = cx.typeck_results().expr_ty(base).ty_adt_def() else { return }; // Skip types without `#[rustc_lint_opt_ty]` - only so that the rest of the lint can be // avoided. - if !cx.tcx.has_attr(adt_def.did(), sym::rustc_lint_opt_ty) { + if !find_attr!(cx.tcx.get_all_attrs(adt_def.did()), AttributeKind::RustcLintOptTy) { return; } diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index dfa7826ece7d..5a9b75957517 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -477,10 +477,6 @@ passes_rustc_lint_opt_deny_field_access = `#[rustc_lint_opt_deny_field_access]` should be applied to a field .label = not a field -passes_rustc_lint_opt_ty = - `#[rustc_lint_opt_ty]` should be applied to a struct - .label = not a struct - passes_rustc_pub_transparent = attribute should be applied to `#[repr(transparent)]` types .label = not a `#[repr(transparent)]` type diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 25628605a03c..00169cf6ae0c 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -258,6 +258,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcNoImplicitAutorefs | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) + | AttributeKind::RustcLintOptTy | AttributeKind::RustcNeverReturnsNullPointer | AttributeKind::RustcScalableVector { .. } | AttributeKind::RustcSimdMonomorphizeLaneLimit(..) @@ -315,7 +316,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { [sym::rustc_lint_diagnostics, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } - [sym::rustc_lint_opt_ty, ..] => self.check_rustc_lint_opt_ty(attr, span, target), [sym::rustc_lint_opt_deny_field_access, ..] => { self.check_rustc_lint_opt_deny_field_access(attr, span, target) } @@ -1253,16 +1253,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks that the `#[rustc_lint_opt_ty]` attribute is only applied to a struct. - fn check_rustc_lint_opt_ty(&self, attr: &Attribute, span: Span, target: Target) { - match target { - Target::Struct => {} - _ => { - self.dcx().emit_err(errors::RustcLintOptTy { attr_span: attr.span(), span }); - } - } - } - /// Checks that the `#[rustc_lint_opt_deny_field_access]` attribute is only applied to a field. fn check_rustc_lint_opt_deny_field_access(&self, attr: &Attribute, span: Span, target: Target) { match target { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 6b3c2bd1a7b2..f2b7d3740cb6 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -412,15 +412,6 @@ pub(crate) struct UnusedMultiple { pub name: Symbol, } -#[derive(Diagnostic)] -#[diag(passes_rustc_lint_opt_ty)] -pub(crate) struct RustcLintOptTy { - #[primary_span] - pub attr_span: Span, - #[label] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(passes_rustc_lint_opt_deny_field_access)] pub(crate) struct RustcLintOptDenyFieldAccess { From 96e453d713738204f68f75558d13f923097e33ae Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Wed, 17 Dec 2025 14:38:56 +0100 Subject: [PATCH 239/489] Port `#[rustc_lint_query_instability]` to parsed attribute --- .../src/attributes/rustc_internal.rs | 15 ++++++++++++ compiler/rustc_attr_parsing/src/context.rs | 5 ++-- .../rustc_hir/src/attrs/data_structures.rs | 3 +++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/internal.rs | 7 ++++-- compiler/rustc_passes/src/check_attr.rs | 4 +--- .../query_stability_incorrect.rs | 2 +- .../query_stability_incorrect.stderr | 23 +++++++++++-------- 8 files changed, 42 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index dc03e1c9312a..7910443787b4 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -126,6 +126,21 @@ impl NoArgsAttributeParser for RustcLintOptTyParser { const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintOptTy; } +pub(crate) struct RustcLintQueryInstabilityParser; + +impl NoArgsAttributeParser for RustcLintQueryInstabilityParser { + const PATH: &[Symbol] = &[sym::rustc_lint_query_instability]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintQueryInstability; +} + pub(crate) struct RustcObjectLifetimeDefaultParser; impl SingleAttributeParser for RustcObjectLifetimeDefaultParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 8cd30ac9ca46..b4854c430cae 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,8 +61,8 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcLintOptTyParser, RustcMainParser, - RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, + RustcLegacyConstGenericsParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser, + RustcMainParser, RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; @@ -257,6 +257,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 761078bf79fa..3c7edb3201b7 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -878,6 +878,9 @@ pub enum AttributeKind { /// Represents `#[rustc_lint_opt_ty]` RustcLintOptTy, + /// Represents `#[rustc_lint_query_instability]` + RustcLintQueryInstability, + /// Represents `#[rustc_main]`. RustcMain, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index e84fca61ac48..f99069e416bd 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -95,6 +95,7 @@ impl AttributeKind { RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, RustcLintOptTy => Yes, + RustcLintQueryInstability => Yes, RustcMain => No, RustcNeverReturnsNullPointer => Yes, RustcNoImplicitAutorefs => Yes, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 25f5710cca3a..c32fed3674fc 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for QueryStability { ty::Instance::try_resolve(cx.tcx, cx.typing_env(), callee_def_id, generic_args) { let def_id = instance.def_id(); - if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) { + if find_attr!(cx.tcx.get_all_attrs(def_id), AttributeKind::RustcLintQueryInstability) { cx.emit_span_lint( POTENTIAL_QUERY_INSTABILITY, span, @@ -151,7 +151,10 @@ fn has_unstable_into_iter_predicate<'tcx>( }; // Does the input type's `IntoIterator` implementation have the // `rustc_lint_query_instability` attribute on its `into_iter` method? - if cx.tcx.has_attr(instance.def_id(), sym::rustc_lint_query_instability) { + if find_attr!( + cx.tcx.get_all_attrs(instance.def_id()), + AttributeKind::RustcLintQueryInstability + ) { return true; } } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 00169cf6ae0c..d03da2e06cf1 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -259,6 +259,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) | AttributeKind::RustcLintOptTy + | AttributeKind::RustcLintQueryInstability | AttributeKind::RustcNeverReturnsNullPointer | AttributeKind::RustcScalableVector { .. } | AttributeKind::RustcSimdMonomorphizeLaneLimit(..) @@ -307,9 +308,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } [sym::thread_local, ..] => self.check_thread_local(attr, span, target), - [sym::rustc_lint_query_instability, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } [sym::rustc_lint_untracked_query_information, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } diff --git a/tests/ui/internal-lints/query_stability_incorrect.rs b/tests/ui/internal-lints/query_stability_incorrect.rs index a428611caaa4..cefd89867711 100644 --- a/tests/ui/internal-lints/query_stability_incorrect.rs +++ b/tests/ui/internal-lints/query_stability_incorrect.rs @@ -3,7 +3,7 @@ #![feature(rustc_attrs)] #[rustc_lint_query_instability] -//~^ ERROR attribute should be applied to a function +//~^ ERROR `#[rustc_lint_query_instability]` attribute cannot be used on structs struct Foo; impl Foo { diff --git a/tests/ui/internal-lints/query_stability_incorrect.stderr b/tests/ui/internal-lints/query_stability_incorrect.stderr index 3f78b39edd96..8149ac3b9518 100644 --- a/tests/ui/internal-lints/query_stability_incorrect.stderr +++ b/tests/ui/internal-lints/query_stability_incorrect.stderr @@ -1,17 +1,20 @@ -error: malformed `rustc_lint_query_instability` attribute input - --> $DIR/query_stability_incorrect.rs:10:5 - | -LL | #[rustc_lint_query_instability(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]` - -error: attribute should be applied to a function definition +error: `#[rustc_lint_query_instability]` attribute cannot be used on structs --> $DIR/query_stability_incorrect.rs:5:1 | LL | #[rustc_lint_query_instability] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Foo; - | ----------- not a function definition + | + = help: `#[rustc_lint_query_instability]` can only be applied to functions + +error[E0565]: malformed `rustc_lint_query_instability` attribute input + --> $DIR/query_stability_incorrect.rs:10:5 + | +LL | #[rustc_lint_query_instability(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_lint_query_instability]` error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0565`. From af3604e84e9a584adc5aefdfbea60f4a8802cec4 Mon Sep 17 00:00:00 2001 From: Adam Gemmell Date: Mon, 15 Dec 2025 17:06:56 +0000 Subject: [PATCH 240/489] Remove fp16 target feature from some aarch64 intrinsics This seems to affect codegen on a lot of Arm intrinsics so I've avoided making the change there. --- .../core_arch/src/aarch64/neon/generated.rs | 20 +- .../src/arm_shared/neon/generated.rs | 233 ++++++++++++------ .../spec/neon/aarch64.spec.yml | 3 - .../spec/neon/arm_shared.spec.yml | 82 +++--- 4 files changed, 207 insertions(+), 131 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs index ce864cc7d907..f1291c8fbddf 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs @@ -7217,8 +7217,8 @@ pub fn vcvtq_f64_u64(a: uint64x2_t) -> float64x2_t { #[doc = "Floating-point convert to lower precision"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_high_f16_f32)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(fcvtn2))] -#[target_feature(enable = "neon,fp16")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vcvt_high_f16_f32(a: float16x4_t, b: float32x4_t) -> float16x8_t { @@ -7227,8 +7227,8 @@ pub fn vcvt_high_f16_f32(a: float16x4_t, b: float32x4_t) -> float16x8_t { #[doc = "Floating-point convert to higher precision"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_high_f32_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(test, assert_instr(fcvtl2))] -#[target_feature(enable = "neon,fp16")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vcvt_high_f32_f16(a: float16x8_t) -> float32x4_t { @@ -21492,7 +21492,7 @@ pub fn vrecpxh_f16(a: f16) -> f16 { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f64_f16)"] #[inline] #[cfg(target_endian = "little")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21503,7 +21503,7 @@ pub fn vreinterpret_f64_f16(a: float16x4_t) -> float64x1_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f64_f16)"] #[inline] #[cfg(target_endian = "big")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21515,7 +21515,7 @@ pub fn vreinterpret_f64_f16(a: float16x4_t) -> float64x1_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f64_f16)"] #[inline] #[cfg(target_endian = "little")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21526,7 +21526,7 @@ pub fn vreinterpretq_f64_f16(a: float16x8_t) -> float64x2_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f64_f16)"] #[inline] #[cfg(target_endian = "big")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21541,7 +21541,7 @@ pub fn vreinterpretq_f64_f16(a: float16x8_t) -> float64x2_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_f64)"] #[inline] #[cfg(target_endian = "little")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21552,7 +21552,7 @@ pub fn vreinterpret_f16_f64(a: float64x1_t) -> float16x4_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpret_f16_f64)"] #[inline] #[cfg(target_endian = "big")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21566,7 +21566,7 @@ pub fn vreinterpret_f16_f64(a: float64x1_t) -> float16x4_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_f64)"] #[inline] #[cfg(target_endian = "little")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -21577,7 +21577,7 @@ pub fn vreinterpretq_f16_f64(a: float64x2_t) -> float16x8_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vreinterpretq_f16_f64)"] #[inline] #[cfg(target_endian = "big")] -#[target_feature(enable = "neon,fp16")] +#[target_feature(enable = "neon")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs index d45454c696c7..cfd9c201864c 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs @@ -7569,8 +7569,9 @@ pub fn vcntq_p8(a: poly8x16_t) -> poly8x16_t { #[doc = "Join two smaller vectors into a single larger vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcombine_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -7785,13 +7786,14 @@ pub fn vcombine_p64(a: poly64x1_t, b: poly64x1_t) -> poly64x2_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcreate_f16)"] #[inline] #[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vcreate_f16(a: u64) -> float16x4_t { @@ -7801,13 +7803,14 @@ pub fn vcreate_f16(a: u64) -> float16x4_t { #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcreate_f16)"] #[inline] #[cfg(target_endian = "big")] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vcreate_f16(a: u64) -> float16x4_t { @@ -8305,13 +8308,14 @@ pub fn vcreate_p64(a: u64) -> poly64x1_t { #[doc = "Floating-point convert to lower precision narrow"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_f16_f32)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] # [cfg_attr (all (test , target_arch = "arm") , assert_instr (vcvt . f16 . f32))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(fcvtn) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vcvt_f16_f32(a: float32x4_t) -> float16x4_t { @@ -8380,13 +8384,14 @@ pub fn vcvtq_f16_u16(a: uint16x8_t) -> float16x8_t { #[doc = "Floating-point convert to higher precision long"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vcvt_f32_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vcvt))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(fcvtl) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vcvt_f32_f16(a: float16x4_t) -> float32x4_t { @@ -9545,6 +9550,7 @@ pub fn vdotq_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x16_t) -> uint32x4_t { #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_lane_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16", N = 2))] #[cfg_attr( @@ -9552,7 +9558,7 @@ pub fn vdotq_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x16_t) -> uint32x4_t { assert_instr(dup, N = 2) )] #[rustc_legacy_const_generics(1)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vdup_lane_f16(a: float16x4_t) -> float16x4_t { @@ -9562,6 +9568,7 @@ pub fn vdup_lane_f16(a: float16x4_t) -> float16x4_t { #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_lane_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16", N = 2))] #[cfg_attr( @@ -9569,7 +9576,7 @@ pub fn vdup_lane_f16(a: float16x4_t) -> float16x4_t { assert_instr(dup, N = 2) )] #[rustc_legacy_const_generics(1)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vdupq_lane_f16(a: float16x4_t) -> float16x8_t { @@ -10108,6 +10115,7 @@ pub fn vdup_lane_u64(a: uint64x1_t) -> uint64x1_t { #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_laneq_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16", N = 4))] #[cfg_attr( @@ -10115,7 +10123,7 @@ pub fn vdup_lane_u64(a: uint64x1_t) -> uint64x1_t { assert_instr(dup, N = 4) )] #[rustc_legacy_const_generics(1)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vdup_laneq_f16(a: float16x8_t) -> float16x4_t { @@ -10125,6 +10133,7 @@ pub fn vdup_laneq_f16(a: float16x8_t) -> float16x4_t { #[doc = "Set all vector lanes to the same value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_laneq_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16", N = 4))] #[cfg_attr( @@ -10132,7 +10141,7 @@ pub fn vdup_laneq_f16(a: float16x8_t) -> float16x4_t { assert_instr(dup, N = 4) )] #[rustc_legacy_const_generics(1)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vdupq_laneq_f16(a: float16x8_t) -> float16x8_t { @@ -10671,13 +10680,14 @@ pub fn vdup_laneq_u64(a: uint64x2_t) -> uint64x1_t { #[doc = "Create a new vector with all lanes set to a value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdup_n_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(dup) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vdup_n_f16(a: f16) -> float16x4_t { @@ -10686,13 +10696,14 @@ pub fn vdup_n_f16(a: f16) -> float16x4_t { #[doc = "Create a new vector with all lanes set to a value"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vdupq_n_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(dup) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vdupq_n_f16(a: f16) -> float16x8_t { @@ -12829,8 +12840,9 @@ pub fn vfmsq_n_f32(a: float32x4_t, b: float32x4_t, c: f32) -> float32x4_t { #[doc = "Duplicate vector element to vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_high_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -12840,8 +12852,9 @@ pub fn vget_high_f16(a: float16x8_t) -> float16x4_t { #[doc = "Duplicate vector element to vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_low_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(nop))] @@ -13082,14 +13095,15 @@ pub fn vget_high_u64(a: uint64x2_t) -> uint64x1_t { #[doc = "Duplicate vector element to scalar"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vget_lane_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop, LANE = 0) )] #[rustc_legacy_const_generics(1)] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vget_lane_f16(a: float16x4_t) -> f16 { @@ -13099,14 +13113,15 @@ pub fn vget_lane_f16(a: float16x4_t) -> f16 { #[doc = "Duplicate vector element to scalar"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vgetq_lane_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(nop, LANE = 0) )] #[rustc_legacy_const_generics(1)] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vgetq_lane_f16(a: float16x8_t) -> f16 { @@ -14457,13 +14472,14 @@ pub fn vhsubq_u32(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1r) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1_dup_f16(ptr: *const f16) -> float16x4_t { @@ -14475,13 +14491,14 @@ pub unsafe fn vld1_dup_f16(ptr: *const f16) -> float16x4_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1r) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1q_dup_f16(ptr: *const f16) -> float16x8_t { @@ -15123,13 +15140,14 @@ pub unsafe fn vld1q_f16(ptr: *const f16) -> float16x8_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1_f16_x2(a: *const f16) -> float16x4x2_t { @@ -15148,13 +15166,14 @@ pub unsafe fn vld1_f16_x2(a: *const f16) -> float16x4x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1_f16_x3(a: *const f16) -> float16x4x3_t { @@ -15173,13 +15192,14 @@ pub unsafe fn vld1_f16_x3(a: *const f16) -> float16x4x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1_f16_x4(a: *const f16) -> float16x4x4_t { @@ -15198,13 +15218,14 @@ pub unsafe fn vld1_f16_x4(a: *const f16) -> float16x4x4_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1q_f16_x2(a: *const f16) -> float16x8x2_t { @@ -15223,13 +15244,14 @@ pub unsafe fn vld1q_f16_x2(a: *const f16) -> float16x8x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1q_f16_x3(a: *const f16) -> float16x8x3_t { @@ -15248,13 +15270,14 @@ pub unsafe fn vld1q_f16_x3(a: *const f16) -> float16x8x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld1) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1q_f16_x4(a: *const f16) -> float16x8x4_t { @@ -15654,6 +15677,7 @@ pub unsafe fn vld1q_f32_x4(a: *const f32) -> float32x4x4_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1, LANE = 0))] #[cfg_attr( @@ -15661,7 +15685,7 @@ pub unsafe fn vld1q_f32_x4(a: *const f32) -> float32x4x4_t { assert_instr(ld1, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1_lane_f16(ptr: *const f16, src: float16x4_t) -> float16x4_t { @@ -15673,6 +15697,7 @@ pub unsafe fn vld1_lane_f16(ptr: *const f16, src: float16x4_t) #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld1, LANE = 0))] #[cfg_attr( @@ -15680,7 +15705,7 @@ pub unsafe fn vld1_lane_f16(ptr: *const f16, src: float16x4_t) assert_instr(ld1, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld1q_lane_f16(ptr: *const f16, src: float16x8_t) -> float16x8_t { @@ -19458,9 +19483,10 @@ pub unsafe fn vld1q_dup_p64(ptr: *const p64) -> poly64x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld2))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] @@ -19476,9 +19502,10 @@ pub unsafe fn vld2_dup_f16(a: *const f16) -> float16x4x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld2))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] @@ -19494,12 +19521,13 @@ pub unsafe fn vld2q_dup_f16(a: *const f16) -> float16x8x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld2r) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2_dup_f16(a: *const f16) -> float16x4x2_t { @@ -19517,12 +19545,13 @@ pub unsafe fn vld2_dup_f16(a: *const f16) -> float16x4x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld2r) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2q_dup_f16(a: *const f16) -> float16x8x2_t { @@ -20435,10 +20464,11 @@ pub unsafe fn vld2q_dup_p16(a: *const p16) -> poly16x8x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld2))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2_f16(a: *const f16) -> float16x4x2_t { @@ -20453,10 +20483,11 @@ pub unsafe fn vld2_f16(a: *const f16) -> float16x4x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld2))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2q_f16(a: *const f16) -> float16x8x2_t { @@ -20471,12 +20502,13 @@ pub unsafe fn vld2q_f16(a: *const f16) -> float16x8x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld2) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2_f16(a: *const f16) -> float16x4x2_t { @@ -20494,12 +20526,13 @@ pub unsafe fn vld2_f16(a: *const f16) -> float16x4x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld2) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2q_f16(a: *const f16) -> float16x8x2_t { @@ -20801,7 +20834,7 @@ pub unsafe fn vld2q_s32(a: *const i32) -> int32x4x2_t { #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld2, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2_lane_f16(a: *const f16, b: float16x4x2_t) -> float16x4x2_t { @@ -20827,7 +20860,7 @@ pub unsafe fn vld2_lane_f16(a: *const f16, b: float16x4x2_t) -> #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld2, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2q_lane_f16(a: *const f16, b: float16x8x2_t) -> float16x8x2_t { @@ -20849,13 +20882,14 @@ pub unsafe fn vld2q_lane_f16(a: *const f16, b: float16x8x2_t) - #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld2, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2_lane_f16(a: *const f16, b: float16x4x2_t) -> float16x4x2_t { @@ -20875,13 +20909,14 @@ pub unsafe fn vld2_lane_f16(a: *const f16, b: float16x4x2_t) -> #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld2, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld2q_lane_f16(a: *const f16, b: float16x8x2_t) -> float16x8x2_t { @@ -22031,10 +22066,11 @@ pub unsafe fn vld2q_p16(a: *const p16) -> poly16x8x2_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld3))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3_dup_f16(a: *const f16) -> float16x4x3_t { @@ -22049,10 +22085,11 @@ pub unsafe fn vld3_dup_f16(a: *const f16) -> float16x4x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld3))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3q_dup_f16(a: *const f16) -> float16x8x3_t { @@ -22067,12 +22104,13 @@ pub unsafe fn vld3q_dup_f16(a: *const f16) -> float16x8x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld3r) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3_dup_f16(a: *const f16) -> float16x4x3_t { @@ -22090,12 +22128,13 @@ pub unsafe fn vld3_dup_f16(a: *const f16) -> float16x4x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld3r) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3q_dup_f16(a: *const f16) -> float16x8x3_t { @@ -23030,10 +23069,11 @@ pub unsafe fn vld3q_dup_p16(a: *const p16) -> poly16x8x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld3))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3_f16(a: *const f16) -> float16x4x3_t { @@ -23048,10 +23088,11 @@ pub unsafe fn vld3_f16(a: *const f16) -> float16x4x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld3))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3q_f16(a: *const f16) -> float16x8x3_t { @@ -23066,12 +23107,13 @@ pub unsafe fn vld3q_f16(a: *const f16) -> float16x8x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld3) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3_f16(a: *const f16) -> float16x4x3_t { @@ -23089,12 +23131,13 @@ pub unsafe fn vld3_f16(a: *const f16) -> float16x4x3_t { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld3) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3q_f16(a: *const f16) -> float16x8x3_t { @@ -23396,7 +23439,7 @@ pub unsafe fn vld3q_s32(a: *const i32) -> int32x4x3_t { #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld3, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3_lane_f16(a: *const f16, b: float16x4x3_t) -> float16x4x3_t { @@ -23423,7 +23466,7 @@ pub unsafe fn vld3_lane_f16(a: *const f16, b: float16x4x3_t) -> #[cfg(target_arch = "arm")] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(vld3, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3q_lane_f16(a: *const f16, b: float16x8x3_t) -> float16x8x3_t { @@ -23446,13 +23489,14 @@ pub unsafe fn vld3q_lane_f16(a: *const f16, b: float16x8x3_t) - #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld3, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3_lane_f16(a: *const f16, b: float16x4x3_t) -> float16x4x3_t { @@ -23477,13 +23521,14 @@ pub unsafe fn vld3_lane_f16(a: *const f16, b: float16x4x3_t) -> #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(ld3, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vld3q_lane_f16(a: *const f16, b: float16x8x3_t) -> float16x8x3_t { @@ -31524,13 +31569,14 @@ pub fn vmmlaq_u32(a: uint32x4_t, b: uint8x16_t, c: uint8x16_t) -> uint32x4_t { #[doc = "Duplicate element to vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vmov_n_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(dup) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vmov_n_f16(a: f16) -> float16x4_t { @@ -31539,13 +31585,14 @@ pub fn vmov_n_f16(a: f16) -> float16x4_t { #[doc = "Duplicate element to vector"] #[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vmovq_n_f16)"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr("vdup.16"))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(dup) )] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub fn vmovq_n_f16(a: f16) -> float16x8_t { @@ -63675,9 +63722,10 @@ pub unsafe fn vst1q_f16_x3(a: *mut f16, b: float16x8x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst1))] @@ -63699,9 +63747,10 @@ pub unsafe fn vst1_f16_x4(a: *mut f16, b: float16x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst1))] @@ -64313,6 +64362,7 @@ pub unsafe fn vst1q_f32_x4(a: *mut f32, b: float32x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] #[cfg_attr( @@ -64320,7 +64370,7 @@ pub unsafe fn vst1q_f32_x4(a: *mut f32, b: float32x4x4_t) { assert_instr(nop, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst1_lane_f16(a: *mut f16, b: float16x4_t) { @@ -64332,6 +64382,7 @@ pub unsafe fn vst1_lane_f16(a: *mut f16, b: float16x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(all(test, target_arch = "arm"), assert_instr(nop, LANE = 0))] #[cfg_attr( @@ -64339,7 +64390,7 @@ pub unsafe fn vst1_lane_f16(a: *mut f16, b: float16x4_t) { assert_instr(nop, LANE = 0) )] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst1q_lane_f16(a: *mut f16, b: float16x8_t) { @@ -66933,8 +66984,9 @@ pub unsafe fn vst1q_lane_p64(a: *mut p64, b: poly64x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(st2))] @@ -66953,8 +67005,9 @@ pub unsafe fn vst2_f16(a: *mut f16, b: float16x4x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(st2))] @@ -66973,9 +67026,10 @@ pub unsafe fn vst2q_f16(a: *mut f16, b: float16x8x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst2))] @@ -66991,9 +67045,10 @@ pub unsafe fn vst2_f16(a: *mut f16, b: float16x4x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst2))] @@ -67289,10 +67344,11 @@ pub unsafe fn vst2q_s32(a: *mut i32, b: int32x4x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(st2, LANE = 0))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst2_lane_f16(a: *mut f16, b: float16x4x2_t) { @@ -67311,10 +67367,11 @@ pub unsafe fn vst2_lane_f16(a: *mut f16, b: float16x4x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(st2, LANE = 0))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst2q_lane_f16(a: *mut f16, b: float16x8x2_t) { @@ -67333,11 +67390,12 @@ pub unsafe fn vst2q_lane_f16(a: *mut f16, b: float16x8x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(test, assert_instr(vst2, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst2_lane_f16(a: *mut f16, b: float16x4x2_t) { @@ -67353,11 +67411,12 @@ pub unsafe fn vst2_lane_f16(a: *mut f16, b: float16x4x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(test, assert_instr(vst2, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst2q_lane_f16(a: *mut f16, b: float16x8x2_t) { @@ -68157,9 +68216,10 @@ pub unsafe fn vst2q_p16(a: *mut p16, b: poly16x8x2_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst3))] @@ -68175,9 +68235,10 @@ pub unsafe fn vst3_f16(a: *mut f16, b: float16x4x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst3))] @@ -68193,8 +68254,9 @@ pub unsafe fn vst3q_f16(a: *mut f16, b: float16x8x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(st3))] @@ -68213,8 +68275,9 @@ pub unsafe fn vst3_f16(a: *mut f16, b: float16x4x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(st3))] @@ -68513,11 +68576,12 @@ pub unsafe fn vst3q_s32(a: *mut i32, b: int32x4x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(test, assert_instr(vst3, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst3_lane_f16(a: *mut f16, b: float16x4x3_t) { @@ -68540,11 +68604,12 @@ pub unsafe fn vst3_lane_f16(a: *mut f16, b: float16x4x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(test, assert_instr(vst3, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst3q_lane_f16(a: *mut f16, b: float16x8x3_t) { @@ -68567,10 +68632,11 @@ pub unsafe fn vst3q_lane_f16(a: *mut f16, b: float16x8x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(st3, LANE = 0))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst3_lane_f16(a: *mut f16, b: float16x4x3_t) { @@ -68589,10 +68655,11 @@ pub unsafe fn vst3_lane_f16(a: *mut f16, b: float16x4x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(st3, LANE = 0))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst3q_lane_f16(a: *mut f16, b: float16x8x3_t) { @@ -69437,9 +69504,10 @@ pub unsafe fn vst3q_p16(a: *mut p16, b: poly16x8x3_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst4))] @@ -69462,9 +69530,10 @@ pub unsafe fn vst4_f16(a: *mut f16, b: float16x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(vst4))] @@ -69487,8 +69556,9 @@ pub unsafe fn vst4q_f16(a: *mut f16, b: float16x8x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(st4))] @@ -69507,8 +69577,9 @@ pub unsafe fn vst4_f16(a: *mut f16, b: float16x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] #[cfg_attr(test, assert_instr(st4))] @@ -69856,11 +69927,12 @@ pub unsafe fn vst4q_s32(a: *mut i32, b: int32x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(test, assert_instr(vst4, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst4_lane_f16(a: *mut f16, b: float16x4x4_t) { @@ -69884,11 +69956,12 @@ pub unsafe fn vst4_lane_f16(a: *mut f16, b: float16x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(target_arch = "arm")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] #[cfg_attr(test, assert_instr(vst4, LANE = 0))] #[rustc_legacy_const_generics(2)] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst4q_lane_f16(a: *mut f16, b: float16x8x4_t) { @@ -69912,10 +69985,11 @@ pub unsafe fn vst4q_lane_f16(a: *mut f16, b: float16x8x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(st4, LANE = 0))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst4_lane_f16(a: *mut f16, b: float16x4x4_t) { @@ -69941,10 +70015,11 @@ pub unsafe fn vst4_lane_f16(a: *mut f16, b: float16x4x4_t) { #[doc = "## Safety"] #[doc = " * Neon instrinsic unsafe"] #[inline] +#[target_feature(enable = "neon")] #[cfg(not(target_arch = "arm"))] #[rustc_legacy_const_generics(2)] #[cfg_attr(test, assert_instr(st4, LANE = 0))] -#[target_feature(enable = "neon,fp16")] +#[cfg_attr(target_arch = "arm", target_feature(enable = "fp16"))] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] pub unsafe fn vst4q_lane_f16(a: *mut f16, b: float16x8x4_t) { diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml index 48c12779a8c1..f3faf1483827 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml @@ -1506,7 +1506,6 @@ intrinsics: return_type: "{neon_type[0]}" attr: - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [fcvtn2]]}]] - - *neon-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe @@ -1524,7 +1523,6 @@ intrinsics: return_type: "{neon_type[0]}" attr: - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [fcvtl2]]}]] - - *neon-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe @@ -8793,7 +8791,6 @@ intrinsics: arguments: ["a: {type[0]}"] return_type: "{type[1]}" attr: - - *neon-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [nop] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml index 9ebdc4334c25..9727f0a4bbe4 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml @@ -71,6 +71,10 @@ neon-i8mm: &neon-i8mm neon-fp16: &neon-fp16 FnCall: [target_feature, ['enable = "neon,fp16"']] +# #[cfg_attr[target_arch = "arm", target_feature(enable = "neon,fp16")] +arm-fp16: &arm-fp16 + FnCall: [cfg_attr, ['target_arch = "arm"', {FnCall: [target_feature, ['enable = "fp16"']]}]] + enable-fcma: &enable-fcma FnCall: [cfg_attr, [{ FnCall: [not, ['target_arch = "arm"']]}, { FnCall: [target_feature, ['enable = "fcma"']] }]] @@ -1502,7 +1506,7 @@ intrinsics: - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdup.16"', 'N = 4']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [dup, 'N = 4']]}]] - FnCall: [rustc_legacy_const_generics, ['1']] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const N: i32'] @@ -1522,7 +1526,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdup.16"']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [dup]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe @@ -1541,7 +1545,7 @@ intrinsics: - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdup.16"', 'N = 2']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [dup, 'N = 2']]}]] - FnCall: [rustc_legacy_const_generics, ['1']] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const N: i32'] @@ -2754,7 +2758,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld1]]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld1]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -2785,7 +2789,7 @@ intrinsics: - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld1, 'LANE = 0']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld1, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["2"]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -2806,7 +2810,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ["vld1"]]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld1r]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3399,7 +3403,7 @@ intrinsics: - *neon-v7 - *target-is-arm - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld2]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3428,7 +3432,7 @@ intrinsics: attr: - *target-not-arm - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld2]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3455,7 +3459,7 @@ intrinsics: attr: - *neon-v7 - *target-is-arm - - *neon-fp16 + - *arm-fp16 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld2]]}]] - *neon-unstable-f16 - *target-not-arm64ec @@ -3486,7 +3490,7 @@ intrinsics: attr: - *target-not-arm - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld2r]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3516,7 +3520,7 @@ intrinsics: - *target-is-arm - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['vld2', 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["2"]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: @@ -3559,7 +3563,7 @@ intrinsics: - *target-not-arm - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld2, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["2"]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: @@ -3600,7 +3604,7 @@ intrinsics: - *neon-v7 - *target-is-arm - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld3]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3629,7 +3633,7 @@ intrinsics: attr: - *target-not-arm - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld3]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3657,7 +3661,7 @@ intrinsics: - *neon-v7 - *target-is-arm - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vld3]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3687,7 +3691,7 @@ intrinsics: attr: - *target-not-arm - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld3r]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: @@ -3717,7 +3721,7 @@ intrinsics: - *target-is-arm - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['vld3', 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["2"]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: @@ -3762,7 +3766,7 @@ intrinsics: - *target-not-arm - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [ld3, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["2"]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: @@ -4744,7 +4748,7 @@ intrinsics: - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 0']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["2"]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec types: @@ -4982,7 +4986,7 @@ intrinsics: attr: - *target-is-arm - *neon-v7 - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [vst1] @@ -5126,7 +5130,7 @@ intrinsics: arguments: ["a: *mut {type[0]}", "b: {neon_type[1]}"] attr: - *target-not-arm - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [st2] @@ -5217,7 +5221,7 @@ intrinsics: - *target-not-arm - FnCall: [rustc_legacy_const_generics, ['2']] - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [st2, 'LANE = 0']]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -5309,7 +5313,7 @@ intrinsics: attr: - *target-is-arm - *neon-v7 - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [vst2] @@ -5376,7 +5380,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [vst2, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ['2']] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -5587,7 +5591,7 @@ intrinsics: attr: - *target-is-arm - *neon-v7 - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [vst3] @@ -5656,7 +5660,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [vst3, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ['2']] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -5717,7 +5721,7 @@ intrinsics: arguments: ["a: *mut {type[0]}", "b: {neon_type[1]}"] attr: - *target-not-arm - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [st3] @@ -5782,7 +5786,7 @@ intrinsics: - *target-not-arm - FnCall: [rustc_legacy_const_generics, ['2']] - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [st3, 'LANE = 0']]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -5996,7 +6000,7 @@ intrinsics: attr: - *target-is-arm - *neon-v7 - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [vst4] @@ -6066,7 +6070,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [vst4, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ['2']] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -6129,7 +6133,7 @@ intrinsics: arguments: ["a: *mut {type[0]}", "b: {neon_type[1]}"] attr: - *target-not-arm - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [st4] @@ -6196,7 +6200,7 @@ intrinsics: - *target-not-arm - FnCall: [rustc_legacy_const_generics, ['2']] - FnCall: [cfg_attr, [test, {FnCall: [assert_instr, [st4, 'LANE = 0']]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -9139,7 +9143,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop]]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe @@ -10730,7 +10734,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vcvt.f16.f32]]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [fcvtn]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe @@ -10747,7 +10751,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vcvt]]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [fcvtl]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe @@ -14055,7 +14059,7 @@ intrinsics: return_type: "{neon_type[1]}" attr: - *neon-v7 - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [nop] @@ -14071,7 +14075,7 @@ intrinsics: return_type: "{neon_type[0]}" attr: - *neon-v7 - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec assert_instr: [nop] @@ -14088,10 +14092,10 @@ intrinsics: return_type: "{type[1]}" attr: - *neon-v7 - - *neon-fp16 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [nop, 'LANE = 0']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [nop, 'LANE = 0']]}]] - FnCall: [rustc_legacy_const_generics, ["1"]] + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec static_defs: ['const LANE: i32'] @@ -14111,7 +14115,7 @@ intrinsics: - *neon-v7 - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, ['"vdup.16"']]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [dup]]}]] - - *neon-fp16 + - *arm-fp16 - *neon-unstable-f16 - *target-not-arm64ec safety: safe From 2c15ae530f03c0577435f87dffa249f2010e00af Mon Sep 17 00:00:00 2001 From: Adam Gemmell Date: Tue, 16 Dec 2025 11:24:11 +0000 Subject: [PATCH 241/489] Fix some Arm instruction assertion tests --- .../crates/core_arch/src/aarch64/neon/generated.rs | 10 +++++----- .../crates/core_arch/src/arm_shared/neon/generated.rs | 2 +- .../crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml | 8 ++++---- .../stdarch-gen-arm/spec/neon/arm_shared.spec.yml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs index f1291c8fbddf..0c703916c136 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs @@ -9487,7 +9487,7 @@ pub fn vdivq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t { #[target_feature(enable = "neon,fp16")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] -#[cfg_attr(test, assert_instr(nop))] +#[cfg_attr(test, assert_instr(fdiv))] pub fn vdivh_f16(a: f16, b: f16) -> f16 { a / b } @@ -14829,7 +14829,7 @@ pub fn vmuld_lane_f64(a: f64, b: float64x1_t) -> f64 { #[target_feature(enable = "neon,fp16")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] -#[cfg_attr(test, assert_instr(nop))] +#[cfg_attr(test, assert_instr(fmul))] pub fn vmulh_f16(a: f16, b: f16) -> f16 { a * b } @@ -26719,7 +26719,7 @@ pub fn vsubq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t { #[inline] #[target_feature(enable = "neon")] #[stable(feature = "neon_intrinsics", since = "1.59.0")] -#[cfg_attr(test, assert_instr(nop))] +#[cfg_attr(test, assert_instr(sub))] pub fn vsubd_s64(a: i64, b: i64) -> i64 { a.wrapping_sub(b) } @@ -26728,7 +26728,7 @@ pub fn vsubd_s64(a: i64, b: i64) -> i64 { #[inline] #[target_feature(enable = "neon")] #[stable(feature = "neon_intrinsics", since = "1.59.0")] -#[cfg_attr(test, assert_instr(nop))] +#[cfg_attr(test, assert_instr(sub))] pub fn vsubd_u64(a: u64, b: u64) -> u64 { a.wrapping_sub(b) } @@ -26738,7 +26738,7 @@ pub fn vsubd_u64(a: u64, b: u64) -> u64 { #[target_feature(enable = "neon,fp16")] #[unstable(feature = "stdarch_neon_f16", issue = "136306")] #[cfg(not(target_arch = "arm64ec"))] -#[cfg_attr(test, assert_instr(nop))] +#[cfg_attr(test, assert_instr(fsub))] pub fn vsubh_f16(a: f16, b: f16) -> f16 { a - b } diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs index cfd9c201864c..314965cc208f 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs @@ -8310,7 +8310,7 @@ pub fn vcreate_p64(a: u64) -> poly64x1_t { #[inline] #[target_feature(enable = "neon")] #[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))] -# [cfg_attr (all (test , target_arch = "arm") , assert_instr (vcvt . f16 . f32))] +#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vcvt))] #[cfg_attr( all(test, any(target_arch = "aarch64", target_arch = "arm64ec")), assert_instr(fcvtn) diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml index f3faf1483827..42f716874b37 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml @@ -5669,7 +5669,7 @@ intrinsics: - *neon-fp16 - *neon-unstable-f16 - *target-not-arm64ec - assert_instr: [nop] + assert_instr: [fdiv] safety: safe types: - [f16, 'h'] @@ -5694,7 +5694,7 @@ intrinsics: arguments: ["a: {type[1]}", "b: {type[1]}"] return_type: "{type[1]}" attr: [*neon-stable] - assert_instr: [nop] + assert_instr: [sub] safety: safe types: - ['d_s64', 'i64'] @@ -5710,7 +5710,7 @@ intrinsics: - *neon-fp16 - *neon-unstable-f16 - *target-not-arm64ec - assert_instr: [nop] + assert_instr: [fsub] safety: safe types: - ['h_f16', 'f16'] @@ -11271,7 +11271,7 @@ intrinsics: - *neon-fp16 - *neon-unstable-f16 - *target-not-arm64ec - assert_instr: [nop] + assert_instr: [fmul] safety: safe types: - [f16, 'h'] diff --git a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml index 9727f0a4bbe4..e8b31d73f939 100644 --- a/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml +++ b/library/stdarch/crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml @@ -10732,7 +10732,7 @@ intrinsics: return_type: "{neon_type[1]}" attr: - *neon-v7 - - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vcvt.f16.f32]]}]] + - FnCall: [cfg_attr, [*test-is-arm, {FnCall: [assert_instr, [vcvt]]}]] - FnCall: [cfg_attr, [*neon-target-aarch64-arm64ec, {FnCall: [assert_instr, [fcvtn]]}]] - *arm-fp16 - *neon-unstable-f16 From 15069c2a378e2e5c954cafdaca61cef3c7ce6e57 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Mon, 2 Jun 2025 11:51:40 -0700 Subject: [PATCH 242/489] Implement SetFileInformationByHandle, as well as direct shim test for it --- .../miri/src/shims/windows/foreign_items.rs | 6 ++ src/tools/miri/src/shims/windows/fs.rs | 85 +++++++++++++++++++ .../miri/tests/pass-dep/shims/windows-fs.rs | 35 +++++++- src/tools/miri/tests/pass/shims/fs.rs | 13 ++- 4 files changed, 133 insertions(+), 6 deletions(-) diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index c824147ad4be..7d30582c582c 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -307,6 +307,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let res = this.GetFileInformationByHandle(handle, info)?; this.write_scalar(res, dest)?; } + "SetFileInformationByHandle" => { + let [handle, class, info, size] = + this.check_shim_sig_lenient(abi, sys_conv, link_name, args)?; + let res = this.SetFileInformationByHandle(handle, class, info, size)?; + this.write_scalar(res, dest)?; + } "DeleteFileW" => { let [file_name] = this.check_shim_sig_lenient(abi, sys_conv, link_name, args)?; let res = this.DeleteFileW(file_name)?; diff --git a/src/tools/miri/src/shims/windows/fs.rs b/src/tools/miri/src/shims/windows/fs.rs index ad22df2425af..967164cb250d 100644 --- a/src/tools/miri/src/shims/windows/fs.rs +++ b/src/tools/miri/src/shims/windows/fs.rs @@ -5,6 +5,7 @@ use std::path::PathBuf; use std::time::SystemTime; use bitflags::bitflags; +use rustc_abi::Size; use rustc_target::spec::Os; use crate::shims::files::{FdId, FileDescription, FileHandle}; @@ -372,6 +373,90 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { interp_ok(this.eval_windows("c", "TRUE")) } + fn SetFileInformationByHandle( + &mut self, + file: &OpTy<'tcx>, // HANDLE + class: &OpTy<'tcx>, // FILE_INFO_BY_HANDLE_CLASS + file_information: &OpTy<'tcx>, // LPVOID + buffer_size: &OpTy<'tcx>, // DWORD + ) -> InterpResult<'tcx, Scalar> { + // ^ Returns BOOL (i32 on Windows) + let this = self.eval_context_mut(); + this.assert_target_os(Os::Windows, "SetFileInformationByHandle"); + this.check_no_isolation("`SetFileInformationByHandle`")?; + + let class = this.read_scalar(class)?.to_u32()?; + let buffer_size = this.read_scalar(buffer_size)?.to_u32()?; + let file_information = this.read_pointer(file_information)?; + this.check_ptr_access( + file_information, + Size::from_bytes(buffer_size), + CheckInAllocMsg::MemoryAccess, + )?; + + let file = this.read_handle(file, "SetFileInformationByHandle")?; + let Handle::File(fd_num) = file else { this.invalid_handle("SetFileInformationByHandle")? }; + let Some(desc) = this.machine.fds.get(fd_num) else { + this.invalid_handle("SetFileInformationByHandle")? + }; + let file = desc.downcast::().ok_or_else(|| { + err_unsup_format!( + "`SetFileInformationByHandle` is only supported on file-backed file descriptors" + ) + })?; + + if class == this.eval_windows_u32("c", "FileEndOfFileInfo") { + let place = this + .ptr_to_mplace(file_information, this.windows_ty_layout("FILE_END_OF_FILE_INFO")); + let new_len = + this.read_scalar(&this.project_field_named(&place, "EndOfFile")?)?.to_i64()?; + match file.file.set_len(new_len.try_into().unwrap()) { + Ok(_) => interp_ok(this.eval_windows("c", "TRUE")), + Err(e) => { + this.set_last_error(e)?; + interp_ok(this.eval_windows("c", "FALSE")) + } + } + } else if class == this.eval_windows_u32("c", "FileAllocationInfo") { + // On Windows, files are somewhat similar to a `Vec` in that they have a separate + // "length" (called "EOF position") and "capacity" (called "allocation size"). + // Growing the allocation size is largely a performance hint which we can + // ignore -- it can also be directly queried, but we currently do not support that. + // So we only need to do something if this operation shrinks the allocation size + // so far that it affects the EOF position. + let place = this + .ptr_to_mplace(file_information, this.windows_ty_layout("FILE_ALLOCATION_INFO")); + let new_alloc_size: u64 = this + .read_scalar(&this.project_field_named(&place, "AllocationSize")?)? + .to_i64()? + .try_into() + .unwrap(); + let old_len = match file.file.metadata() { + Ok(m) => m.len(), + Err(e) => { + this.set_last_error(e)?; + return interp_ok(this.eval_windows("c", "FALSE")); + } + }; + if new_alloc_size < old_len { + match file.file.set_len(new_alloc_size) { + Ok(_) => interp_ok(this.eval_windows("c", "TRUE")), + Err(e) => { + this.set_last_error(e)?; + interp_ok(this.eval_windows("c", "FALSE")) + } + } + } else { + interp_ok(this.eval_windows("c", "TRUE")) + } + } else { + throw_unsup_format!( + "SetFileInformationByHandle: Unsupported `FileInformationClass` value {}", + class + ) + } + } + fn DeleteFileW( &mut self, file_name: &OpTy<'tcx>, // LPCWSTR diff --git a/src/tools/miri/tests/pass-dep/shims/windows-fs.rs b/src/tools/miri/tests/pass-dep/shims/windows-fs.rs index 7b756603d929..0037f34d3c9a 100644 --- a/src/tools/miri/tests/pass-dep/shims/windows-fs.rs +++ b/src/tools/miri/tests/pass-dep/shims/windows-fs.rs @@ -19,9 +19,11 @@ use windows_sys::Win32::Foundation::{ }; use windows_sys::Win32::Storage::FileSystem::{ BY_HANDLE_FILE_INFORMATION, CREATE_ALWAYS, CREATE_NEW, CreateFileW, DeleteFileW, - FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_NORMAL, FILE_BEGIN, FILE_CURRENT, - FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, FILE_SHARE_DELETE, FILE_SHARE_READ, - FILE_SHARE_WRITE, GetFileInformationByHandle, OPEN_ALWAYS, OPEN_EXISTING, SetFilePointerEx, + FILE_ALLOCATION_INFO, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_NORMAL, FILE_BEGIN, + FILE_CURRENT, FILE_END_OF_FILE_INFO, FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, + FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, FileAllocationInfo, FileEndOfFileInfo, + GetFileInformationByHandle, OPEN_ALWAYS, OPEN_EXISTING, SetFileInformationByHandle, + SetFilePointerEx, }; use windows_sys::Win32::System::IO::IO_STATUS_BLOCK; use windows_sys::Win32::System::Threading::GetCurrentProcess; @@ -37,6 +39,7 @@ fn main() { test_ntstatus_to_dos(); test_file_read_write(); test_file_seek(); + test_set_file_info(); test_dup_handle(); } } @@ -275,6 +278,32 @@ unsafe fn test_file_read_write() { assert_eq!(GetLastError(), 1234); } +unsafe fn test_set_file_info() { + let temp = utils::tmp().join("test_set_file.txt"); + let mut file = fs::File::create(&temp).unwrap(); + let handle = file.as_raw_handle(); + + let info = FILE_END_OF_FILE_INFO { EndOfFile: 20 }; + let res = SetFileInformationByHandle( + handle, + FileEndOfFileInfo, + ptr::from_ref(&info).cast(), + size_of::().try_into().unwrap(), + ); + assert!(res != 0); + assert_eq!(file.seek(SeekFrom::End(0)).unwrap(), 20); + + let info = FILE_ALLOCATION_INFO { AllocationSize: 0 }; + let res = SetFileInformationByHandle( + handle, + FileAllocationInfo, + ptr::from_ref(&info).cast(), + size_of::().try_into().unwrap(), + ); + assert!(res != 0); + assert_eq!(file.metadata().unwrap().len(), 0); +} + unsafe fn test_dup_handle() { let temp = utils::tmp().join("test_dup.txt"); diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index 43fbf6b085f7..70bca703cc2f 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -28,9 +28,9 @@ fn main() { test_errors(); test_from_raw_os_error(); test_file_clone(); + test_file_set_len(); // Windows file handling is very incomplete. if cfg!(not(windows)) { - test_file_set_len(); test_file_sync(); test_rename(); test_directory(); @@ -77,6 +77,9 @@ fn test_file() { // However, writing 0 bytes can succeed or fail. let _ignore = file.write(&[]); + // Test calling File::create on an existing file, since that uses a different code path + File::create(&path).unwrap(); + // Removing file should succeed. remove_file(&path).unwrap(); } @@ -87,7 +90,6 @@ fn test_file_partial_reads_writes() { // Ensure we sometimes do incomplete writes. check_nondet(|| { - let _ = remove_file(&path1); // FIXME(win, issue #4483): errors if the file already exists let mut file = File::create(&path1).unwrap(); file.write(&[0; 4]).unwrap() == 4 }); @@ -210,7 +212,12 @@ fn test_file_set_len() { // Can't use set_len on a file not opened for writing let file = OpenOptions::new().read(true).open(&path).unwrap(); - assert_eq!(ErrorKind::InvalidInput, file.set_len(14).unwrap_err().kind()); + // Due to https://github.com/rust-lang/miri/issues/4457, we have to assume the failure could + // be either of the Windows or Unix kind, no matter which platform we're on. + assert!( + [ErrorKind::PermissionDenied, ErrorKind::InvalidInput] + .contains(&file.set_len(14).unwrap_err().kind()) + ); remove_file(&path).unwrap(); } From 977bf0a134609bd601343023bbb561137392f18f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 20:29:58 +0200 Subject: [PATCH 243/489] crash test readme: point to rustc-dev-guide There is information that is duplicated here and in rustc-dev-guide, and the latter is more comprehensive, so point there. --- tests/crashes/README.md | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/tests/crashes/README.md b/tests/crashes/README.md index 2dc81a115df3..8026b7c2463c 100644 --- a/tests/crashes/README.md +++ b/tests/crashes/README.md @@ -1,25 +1 @@ -This is serves as a collection of crashes so that accidental ICE fixes are tracked. -This was formally done at https://github.com/rust-lang/glacier but doing it inside -the rustc testsuite is more convenient. - -It is imperative that a test in the suite causes an internal compiler error/panic -or makes rustc crash in some other way. -A test will "pass" if rustc exits with something other than 1 or 0. - -When adding crashes from https://github.com/rust-lang/rust/issues, the -issue number should be noted in the file name (12345.rs should suffice) -and also inside the file via `//@ known-bug #4321` if possible. - -If you happen to fix one of the crashes, please move it to a fitting -subdirectory in `tests/ui` and give it a meaningful name. -Also please add a doc comment at the top of the file explaining why -this test exists. :) -Adding -Fixes #NNNNN -Fixes #MMMMM -to the description of your pull request will ensure the -corresponding tickets will be closed automatically upon merge. -The ticket ids can be found in the file name or the `known-bug` annotation -inside the testfile. - -Please do not re-report any crashes that you find here! +Documentation on crash tests is at https://rustc-dev-guide.rust-lang.org/tests/compiletest#crash-tests From 67bd5f5cfdd3d29cd302d1cc535f8d0ea2c6e351 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 17 Dec 2025 20:19:28 +0100 Subject: [PATCH 244/489] Prefer remapping the relative `library/` and `compiler/` directories This is done to avoid leaking the relative paths to the standard library after the overall of filenames. Noted that the paths were already leaking before, but to a lesser extent since the paths embedded in the distributed `rlib` were absolute. In general Cargo compiles workspace members with relative paths, so it's better anyway to remap the relative path. cf https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/remapping.20of.20the.20standard.20library/near/564093571 --- src/bootstrap/src/core/builder/cargo.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 5a6bade59a6a..4697de7ffe0d 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1032,10 +1032,7 @@ impl Builder<'_> { self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::Compiler) { // When building compiler sources, we want to apply the compiler remap scheme. - cargo.env( - "RUSTC_DEBUGINFO_MAP", - format!("{}={}", self.build.src.display(), map_to), - ); + cargo.env("RUSTC_DEBUGINFO_MAP", format!("compiler/={map_to}/compiler")); cargo.env("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR", map_to); } } @@ -1047,10 +1044,7 @@ impl Builder<'_> { if let Some(ref map_to) = self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler) { - cargo.env( - "RUSTC_DEBUGINFO_MAP", - format!("{}={}", self.build.src.display(), map_to), - ); + cargo.env("RUSTC_DEBUGINFO_MAP", format!("library/={map_to}/library")); } } } From e17c2f3eccc7436d7f94c6ed4bc8a367f4c6a7fb Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 21:25:19 +0200 Subject: [PATCH 245/489] show how to view docs locally --- tests/crashes/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/crashes/README.md b/tests/crashes/README.md index 8026b7c2463c..a809ae798c20 100644 --- a/tests/crashes/README.md +++ b/tests/crashes/README.md @@ -1 +1,9 @@ -Documentation on crash tests is at https://rustc-dev-guide.rust-lang.org/tests/compiletest#crash-tests +Documentation on crash tests is at https://rustc-dev-guide.rust-lang.org/tests/compiletest#crash-tests. + +Alternatively, you can build the documentation from this repository: + +```console +mdbook serve --open src/doc/rustc-dev-guide +``` + +The documentation will then be available at http://localhost:3000/tests/compiletest.html#crash-tests. From 74eecf977696ba5e9eda6b25985269dd118fb1c1 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 17 Dec 2025 20:31:38 +0100 Subject: [PATCH 246/489] Use the non-embeddable (absolute) path to test relative remap of std --- compiler/rustc_metadata/src/rmeta/decoder.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 0a6e5f153dde..9bf2439910ed 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1669,15 +1669,14 @@ impl<'a> CrateMetadataRef<'a> { for virtual_dir in virtual_source_base_dir.iter().flatten() { if let Some(real_dir) = &real_source_base_dir && let rustc_span::FileName::Real(old_name) = name - && let (_working_dir, embeddable_name) = - old_name.embeddable_name(RemapPathScopeComponents::MACRO) - && let Ok(rest) = embeddable_name.strip_prefix(virtual_dir) + && let virtual_path = old_name.path(RemapPathScopeComponents::MACRO) + && let Ok(rest) = virtual_path.strip_prefix(virtual_dir) { let new_path = real_dir.join(rest); debug!( "try_to_translate_virtual_to_real: `{}` -> `{}`", - embeddable_name.display(), + virtual_path.display(), new_path.display(), ); From fd513105d8c6292e75db21e613375c13585a27cd Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 21:38:54 +0200 Subject: [PATCH 247/489] output of "git diff" is better, and is what I use mostly --- src/doc/rustc-dev-guide/ci/sembr/Cargo.lock | 26 -------------------- src/doc/rustc-dev-guide/ci/sembr/Cargo.toml | 1 - src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 17 ------------- 3 files changed, 44 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock b/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock index 077fa42d2e5b..4defe49579f3 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock +++ b/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock @@ -148,12 +148,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "globset" version = "0.4.18" @@ -167,15 +161,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash", -] - [[package]] name = "heck" version = "0.5.0" @@ -198,16 +183,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "imara-diff" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f01d462f766df78ab820dd06f5eb700233c51f0f4c2e846520eaf4ba6aa5c5c" -dependencies = [ - "hashbrown", - "memchr", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -295,7 +270,6 @@ dependencies = [ "anyhow", "clap", "ignore", - "imara-diff", "regex", ] diff --git a/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml b/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml index 00818e2b3c2d..46228ea47922 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml +++ b/src/doc/rustc-dev-guide/ci/sembr/Cargo.toml @@ -5,7 +5,6 @@ edition = "2024" [dependencies] anyhow = "1" ignore = "0.4" -imara-diff = "0.2" [dependencies.regex] version = "1" diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 2539a9eadda3..c19f19541846 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -5,7 +5,6 @@ use std::{fs, process}; use anyhow::Result; use clap::Parser; use ignore::Walk; -use imara_diff::{Algorithm, BasicLineDiffPrinter, Diff, InternedInput, UnifiedDiffConfig}; use regex::Regex; #[derive(Parser)] @@ -18,8 +17,6 @@ struct Cli { /// Applies to lines that are to be split #[arg(long, default_value_t = 100)] line_length_limit: usize, - #[arg(long)] - show_diff: bool, } static REGEX_IGNORE_END: LazyLock = @@ -54,10 +51,6 @@ fn main() -> Result<()> { } else if cli.overwrite { fs::write(&path, new)?; made_compliant.push(path.clone()); - } else if cli.show_diff { - println!("{}:", path.display()); - show_diff(&old, &new); - println!("---"); } else { not_compliant.push(path.clone()); } @@ -76,16 +69,6 @@ fn main() -> Result<()> { Ok(()) } -fn show_diff(old: &str, new: &str) { - let input = InternedInput::new(old, new); - let mut diff = Diff::compute(Algorithm::Histogram, &input); - diff.postprocess_lines(&input); - let diff = diff - .unified_diff(&BasicLineDiffPrinter(&input.interner), UnifiedDiffConfig::default(), &input) - .to_string(); - print!("{diff}"); -} - fn display(header: &str, paths: &[PathBuf]) { println!("{header}:"); for element in paths { From 9cb47c6e8ece9cf36b698bf2e061290c1e0c634b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Wed, 26 Mar 2025 03:26:09 +0100 Subject: [PATCH 248/489] ExprUseVisitor: properly report discriminant reads This solves the "can't find the upvar" ICEs that resulted from `maybe_read_scrutinee` being unfit for purpose. --- .../rustc_hir_typeck/src/expr_use_visitor.rs | 102 +++++++++-- tests/crashes/137467-1.rs | 17 -- tests/crashes/137467-2.rs | 18 -- tests/crashes/137467-3.rs | 8 - .../2229_closure_analysis/capture-enums.rs | 2 + .../capture-enums.stderr | 26 ++- .../match/patterns-capture-analysis.rs | 5 + .../match/patterns-capture-analysis.stderr | 79 +++++--- .../only-inhabited-variant-stable.rs | 23 +++ .../only-inhabited-variant-stable.stderr | 20 +++ ...habited-variant.exhaustive_patterns.stderr | 20 +++ .../only-inhabited-variant.normal.stderr | 20 +++ ...tivariant.rs => only-inhabited-variant.rs} | 8 +- tests/ui/closures/or-patterns-issue-137467.rs | 170 ++++++++++++++++++ 14 files changed, 426 insertions(+), 92 deletions(-) delete mode 100644 tests/crashes/137467-1.rs delete mode 100644 tests/crashes/137467-2.rs delete mode 100644 tests/crashes/137467-3.rs create mode 100644 tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs create mode 100644 tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr create mode 100644 tests/ui/closures/2229_closure_analysis/only-inhabited-variant.exhaustive_patterns.stderr create mode 100644 tests/ui/closures/2229_closure_analysis/only-inhabited-variant.normal.stderr rename tests/ui/closures/2229_closure_analysis/{run_pass/multivariant.rs => only-inhabited-variant.rs} (55%) create mode 100644 tests/ui/closures/or-patterns-issue-137467.rs diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 27b66d07f98e..2e993cf7db95 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -943,6 +943,19 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx } /// The core driver for walking a pattern + /// + /// This should mirror how pattern-matching gets lowered to MIR, as + /// otherwise lowering will ICE when trying to resolve the upvars. + /// + /// However, it is okay to approximate it here by doing *more* accesses than + /// the actual MIR builder will, which is useful when some checks are too + /// cumbersome to perform here. For example, if after typeck it becomes + /// clear that only one variant of an enum is inhabited, and therefore a + /// read of the discriminant is not necessary, `walk_pat` will have + /// over-approximated the necessary upvar capture granularity. + /// + /// Do note that discrepancies like these do still create obscure corners + /// in the semantics of the language, and should be avoided if possible. #[instrument(skip(self), level = "debug")] fn walk_pat( &self, @@ -952,6 +965,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx ) -> Result<(), Cx::Error> { let tcx = self.cx.tcx(); self.cat_pattern(discr_place.clone(), pat, &mut |place, pat| { + debug!("walk_pat: pat.kind={:?}", pat.kind); + let read_discriminant = || { + self.delegate.borrow_mut().borrow(place, discr_place.hir_id, BorrowKind::Immutable); + }; + match pat.kind { PatKind::Binding(_, canonical_id, ..) => { debug!("walk_pat: binding place={:?} pat={:?}", place, pat); @@ -974,11 +992,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx // binding when lowering pattern guards to ensure that the guard does not // modify the scrutinee. if has_guard { - self.delegate.borrow_mut().borrow( - place, - discr_place.hir_id, - BorrowKind::Immutable, - ); + read_discriminant(); } // It is also a borrow or copy/move of the value being matched. @@ -1014,13 +1028,71 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx PatKind::Never => { // A `!` pattern always counts as an immutable read of the discriminant, // even in an irrefutable pattern. - self.delegate.borrow_mut().borrow( - place, - discr_place.hir_id, - BorrowKind::Immutable, - ); + read_discriminant(); + } + PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, span }) => { + // A `Path` pattern is just a name like `Foo`. This is either a + // named constant or else it refers to an ADT variant + + let res = self.cx.typeck_results().qpath_res(qpath, *hir_id); + match res { + Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => { + // Named constants have to be equated with the value + // being matched, so that's a read of the value being matched. + // + // FIXME: Does the MIR code skip this read when matching on a ZST? + // If so, we can also skip it here. + read_discriminant(); + } + _ => { + // Otherwise, this is a struct/enum variant, and so it's + // only a read if we need to read the discriminant. + if self.is_multivariant_adt(place.place.ty(), *span) { + read_discriminant(); + } + } + } + } + PatKind::Expr(_) | PatKind::Range(..) => { + // When matching against a literal or range, we need to + // borrow the place to compare it against the pattern. + // + // FIXME: What if the type being matched only has one + // possible value? + // FIXME: What if the range is the full range of the type + // and doesn't actually require a discriminant read? + read_discriminant(); + } + PatKind::Struct(..) | PatKind::TupleStruct(..) => { + if self.is_multivariant_adt(place.place.ty(), pat.span) { + read_discriminant(); + } + } + PatKind::Slice(lhs, wild, rhs) => { + // We don't need to test the length if the pattern is `[..]` + if matches!((lhs, wild, rhs), (&[], Some(_), &[])) + // Arrays have a statically known size, so + // there is no need to read their length + || place.place.ty().peel_refs().is_array() + { + // No read necessary + } else { + read_discriminant(); + } + } + PatKind::Or(_) + | PatKind::Box(_) + | PatKind::Ref(..) + | PatKind::Guard(..) + | PatKind::Tuple(..) + | PatKind::Wild + | PatKind::Missing + | PatKind::Err(_) => { + // If the PatKind is Or, Box, Ref, Guard, or Tuple, the relevant accesses + // are made later as these patterns contains subpatterns. + // If the PatKind is Missing, Wild or Err, any relevant accesses are made when processing + // the other patterns that are part of the match } - _ => {} } Ok(()) @@ -1904,6 +1976,14 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx } } + /// Checks whether a type has multiple variants, and therefore, whether a + /// read of the discriminant might be necessary. Note that the actual MIR + /// builder code does a more specific check, filtering out variants that + /// happen to be uninhabited. + /// + /// Here, we cannot perform such an accurate checks, because querying + /// whether a type is inhabited requires that it has been fully inferred, + /// which cannot be guaranteed at this point. fn is_multivariant_adt(&self, ty: Ty<'tcx>, span: Span) -> bool { if let ty::Adt(def, _) = self.cx.structurally_resolve_type(span, ty).kind() { // Note that if a non-exhaustive SingleVariant is defined in another crate, we need diff --git a/tests/crashes/137467-1.rs b/tests/crashes/137467-1.rs deleted file mode 100644 index b6bff2bdc4e8..000000000000 --- a/tests/crashes/137467-1.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ known-bug: #137467 -//@ edition: 2021 -enum Camera { - Normal { base_transform: i32 }, - Volume { transform: i32 }, -} - -fn draw_ui(camera: &mut Camera) { - || { - let (Camera::Normal { - base_transform: _transform, - } - | Camera::Volume { - transform: _transform, - }) = camera; - }; -} diff --git a/tests/crashes/137467-2.rs b/tests/crashes/137467-2.rs deleted file mode 100644 index a70ea92b22dc..000000000000 --- a/tests/crashes/137467-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #137467 -//@ edition: 2021 - -enum Camera { - Normal { base_transform: i32 }, - Volume { transform: i32 }, -} - -fn draw_ui(camera: &mut Camera) { - || { - let (Camera::Normal { - base_transform: _, - } - | Camera::Volume { - transform: _, - }) = camera; - }; -} diff --git a/tests/crashes/137467-3.rs b/tests/crashes/137467-3.rs deleted file mode 100644 index cb81a9a912e7..000000000000 --- a/tests/crashes/137467-3.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #137467 -//@ edition: 2021 - -fn meow(x: (u32, u32, u32)) { - let f = || { - let ((0, a, _) | (_, _, a)) = x; - }; -} diff --git a/tests/ui/closures/2229_closure_analysis/capture-enums.rs b/tests/ui/closures/2229_closure_analysis/capture-enums.rs index d9c06a68c95b..4c600ccdaa43 100644 --- a/tests/ui/closures/2229_closure_analysis/capture-enums.rs +++ b/tests/ui/closures/2229_closure_analysis/capture-enums.rs @@ -22,6 +22,7 @@ fn multi_variant_enum() { //~| ERROR Min Capture analysis includes: if let Info::Point(_, _, str) = point { //~^ NOTE: Capturing point[] -> Immutable + //~| NOTE: Capturing point[] -> Immutable //~| NOTE: Capturing point[(2, 0)] -> ByValue //~| NOTE: Min Capture point[] -> ByValue println!("{}", str); @@ -29,6 +30,7 @@ fn multi_variant_enum() { if let Info::Meta(_, v) = meta { //~^ NOTE: Capturing meta[] -> Immutable + //~| NOTE: Capturing meta[] -> Immutable //~| NOTE: Capturing meta[(1, 1)] -> ByValue //~| NOTE: Min Capture meta[] -> ByValue println!("{:?}", v); diff --git a/tests/ui/closures/2229_closure_analysis/capture-enums.stderr b/tests/ui/closures/2229_closure_analysis/capture-enums.stderr index 89a879cec468..b62384ffe12e 100644 --- a/tests/ui/closures/2229_closure_analysis/capture-enums.stderr +++ b/tests/ui/closures/2229_closure_analysis/capture-enums.stderr @@ -9,7 +9,7 @@ LL | let c = #[rustc_capture_analysis] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: attributes on expressions are experimental - --> $DIR/capture-enums.rs:48:13 + --> $DIR/capture-enums.rs:50:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,18 +34,28 @@ note: Capturing point[] -> Immutable | LL | if let Info::Point(_, _, str) = point { | ^^^^^ +note: Capturing point[] -> Immutable + --> $DIR/capture-enums.rs:23:41 + | +LL | if let Info::Point(_, _, str) = point { + | ^^^^^ note: Capturing point[(2, 0)] -> ByValue --> $DIR/capture-enums.rs:23:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ note: Capturing meta[] -> Immutable - --> $DIR/capture-enums.rs:30:35 + --> $DIR/capture-enums.rs:31:35 + | +LL | if let Info::Meta(_, v) = meta { + | ^^^^ +note: Capturing meta[] -> Immutable + --> $DIR/capture-enums.rs:31:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ note: Capturing meta[(1, 1)] -> ByValue - --> $DIR/capture-enums.rs:30:35 + --> $DIR/capture-enums.rs:31:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ @@ -67,13 +77,13 @@ note: Min Capture point[] -> ByValue LL | if let Info::Point(_, _, str) = point { | ^^^^^ note: Min Capture meta[] -> ByValue - --> $DIR/capture-enums.rs:30:35 + --> $DIR/capture-enums.rs:31:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ error: First Pass analysis includes: - --> $DIR/capture-enums.rs:52:5 + --> $DIR/capture-enums.rs:54:5 | LL | / || { LL | | @@ -85,13 +95,13 @@ LL | | }; | |_____^ | note: Capturing point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:55:47 + --> $DIR/capture-enums.rs:57:47 | LL | let SingleVariant::Point(_, _, str) = point; | ^^^^^ error: Min Capture analysis includes: - --> $DIR/capture-enums.rs:52:5 + --> $DIR/capture-enums.rs:54:5 | LL | / || { LL | | @@ -103,7 +113,7 @@ LL | | }; | |_____^ | note: Min Capture point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:55:47 + --> $DIR/capture-enums.rs:57:47 | LL | let SingleVariant::Point(_, _, str) = point; | ^^^^^ diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs index 40330af4088c..a9d2777d93f1 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs @@ -14,6 +14,7 @@ fn test_1_should_capture() { //~| ERROR Min Capture analysis includes: match variant { //~^ NOTE: Capturing variant[] -> Immutable + //~| NOTE: Capturing variant[] -> Immutable //~| NOTE: Min Capture variant[] -> Immutable Some(_) => {} _ => {} @@ -132,6 +133,7 @@ fn test_5_should_capture_multi_variant() { //~| ERROR Min Capture analysis includes: match variant { //~^ NOTE: Capturing variant[] -> Immutable + //~| NOTE: Capturing variant[] -> Immutable //~| NOTE: Min Capture variant[] -> Immutable MVariant::A => {} _ => {} @@ -150,6 +152,7 @@ fn test_7_should_capture_slice_len() { //~| ERROR Min Capture analysis includes: match slice { //~^ NOTE: Capturing slice[] -> Immutable + //~| NOTE: Capturing slice[Deref] -> Immutable //~| NOTE: Min Capture slice[] -> Immutable [_,_,_] => {}, _ => {} @@ -162,6 +165,7 @@ fn test_7_should_capture_slice_len() { //~| ERROR Min Capture analysis includes: match slice { //~^ NOTE: Capturing slice[] -> Immutable + //~| NOTE: Capturing slice[Deref] -> Immutable //~| NOTE: Min Capture slice[] -> Immutable [] => {}, _ => {} @@ -174,6 +178,7 @@ fn test_7_should_capture_slice_len() { //~| ERROR Min Capture analysis includes: match slice { //~^ NOTE: Capturing slice[] -> Immutable + //~| NOTE: Capturing slice[Deref] -> Immutable //~| NOTE: Min Capture slice[] -> Immutable [_, .. ,_] => {}, _ => {} diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr index e7e5e7f7fa1b..4b9d6fad0e50 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr @@ -14,6 +14,11 @@ note: Capturing variant[] -> Immutable | LL | match variant { | ^^^^^^^ +note: Capturing variant[] -> Immutable + --> $DIR/patterns-capture-analysis.rs:15:15 + | +LL | match variant { + | ^^^^^^^ error: Min Capture analysis includes: --> $DIR/patterns-capture-analysis.rs:12:5 @@ -33,7 +38,7 @@ LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:30:5 + --> $DIR/patterns-capture-analysis.rs:31:5 | LL | / || { LL | | @@ -44,7 +49,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:49:5 + --> $DIR/patterns-capture-analysis.rs:50:5 | LL | / || { LL | | @@ -55,7 +60,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:63:5 + --> $DIR/patterns-capture-analysis.rs:64:5 | LL | / || { LL | | @@ -66,18 +71,18 @@ LL | | }; | |_____^ | note: Capturing variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:66:15 + --> $DIR/patterns-capture-analysis.rs:67:15 | LL | match variant { | ^^^^^^^ note: Capturing variant[(0, 0)] -> Immutable - --> $DIR/patterns-capture-analysis.rs:66:15 + --> $DIR/patterns-capture-analysis.rs:67:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:63:5 + --> $DIR/patterns-capture-analysis.rs:64:5 | LL | / || { LL | | @@ -88,13 +93,13 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:66:15 + --> $DIR/patterns-capture-analysis.rs:67:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:83:5 + --> $DIR/patterns-capture-analysis.rs:84:5 | LL | / || { LL | | @@ -105,7 +110,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:95:5 + --> $DIR/patterns-capture-analysis.rs:96:5 | LL | / || { LL | | @@ -116,7 +121,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:108:5 + --> $DIR/patterns-capture-analysis.rs:109:5 | LL | / || { LL | | @@ -127,7 +132,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:130:5 + --> $DIR/patterns-capture-analysis.rs:131:5 | LL | / || { LL | | @@ -138,13 +143,18 @@ LL | | }; | |_____^ | note: Capturing variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:133:15 + --> $DIR/patterns-capture-analysis.rs:134:15 + | +LL | match variant { + | ^^^^^^^ +note: Capturing variant[] -> Immutable + --> $DIR/patterns-capture-analysis.rs:134:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:130:5 + --> $DIR/patterns-capture-analysis.rs:131:5 | LL | / || { LL | | @@ -155,13 +165,13 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:133:15 + --> $DIR/patterns-capture-analysis.rs:134:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:148:5 + --> $DIR/patterns-capture-analysis.rs:150:5 | LL | / || { LL | | @@ -172,13 +182,18 @@ LL | | }; | |_____^ | note: Capturing slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:151:15 + --> $DIR/patterns-capture-analysis.rs:153:15 + | +LL | match slice { + | ^^^^^ +note: Capturing slice[Deref] -> Immutable + --> $DIR/patterns-capture-analysis.rs:153:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:148:5 + --> $DIR/patterns-capture-analysis.rs:150:5 | LL | / || { LL | | @@ -189,13 +204,13 @@ LL | | }; | |_____^ | note: Min Capture slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:151:15 + --> $DIR/patterns-capture-analysis.rs:153:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:160:5 + --> $DIR/patterns-capture-analysis.rs:163:5 | LL | / || { LL | | @@ -206,13 +221,18 @@ LL | | }; | |_____^ | note: Capturing slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:163:15 + --> $DIR/patterns-capture-analysis.rs:166:15 + | +LL | match slice { + | ^^^^^ +note: Capturing slice[Deref] -> Immutable + --> $DIR/patterns-capture-analysis.rs:166:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:160:5 + --> $DIR/patterns-capture-analysis.rs:163:5 | LL | / || { LL | | @@ -223,13 +243,13 @@ LL | | }; | |_____^ | note: Min Capture slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:163:15 + --> $DIR/patterns-capture-analysis.rs:166:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:172:5 + --> $DIR/patterns-capture-analysis.rs:176:5 | LL | / || { LL | | @@ -240,13 +260,18 @@ LL | | }; | |_____^ | note: Capturing slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:175:15 + --> $DIR/patterns-capture-analysis.rs:179:15 + | +LL | match slice { + | ^^^^^ +note: Capturing slice[Deref] -> Immutable + --> $DIR/patterns-capture-analysis.rs:179:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:172:5 + --> $DIR/patterns-capture-analysis.rs:176:5 | LL | / || { LL | | @@ -257,13 +282,13 @@ LL | | }; | |_____^ | note: Min Capture slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:175:15 + --> $DIR/patterns-capture-analysis.rs:179:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:189:5 + --> $DIR/patterns-capture-analysis.rs:194:5 | LL | / || { LL | | diff --git a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs new file mode 100644 index 000000000000..a8e4b9cd1823 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs @@ -0,0 +1,23 @@ +// This example used to compile, but the fact that it should was never properly +// discussed. With further experience, we concluded that capture precision +// depending on whether some types are inhabited goes too far, introducing a +// bunch of headaches without much benefit. +//@ edition:2021 +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +enum Void {} + +pub fn main() { + let mut r = Result::::Err((0, 0)); + let mut f = || { + let Err((ref mut a, _)) = r; + *a = 1; + }; + let mut g = || { + //~^ ERROR: cannot borrow `r` as mutable more than once at a time + let Err((_, ref mut b)) = r; + *b = 2; + }; + f(); + g(); + assert_eq!(r, Err((1, 2))); +} diff --git a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr new file mode 100644 index 000000000000..dea85ff947ce --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr @@ -0,0 +1,20 @@ +error[E0499]: cannot borrow `r` as mutable more than once at a time + --> $DIR/only-inhabited-variant-stable.rs:15:17 + | +LL | let mut f = || { + | -- first mutable borrow occurs here +LL | let Err((ref mut a, _)) = r; + | - first borrow occurs due to use of `r` in closure +... +LL | let mut g = || { + | ^^ second mutable borrow occurs here +LL | +LL | let Err((_, ref mut b)) = r; + | - second borrow occurs due to use of `r` in closure +... +LL | f(); + | - first borrow later used here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.exhaustive_patterns.stderr b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.exhaustive_patterns.stderr new file mode 100644 index 000000000000..58a5348aa391 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.exhaustive_patterns.stderr @@ -0,0 +1,20 @@ +error[E0499]: cannot borrow `r` as mutable more than once at a time + --> $DIR/only-inhabited-variant.rs:16:17 + | +LL | let mut f = || { + | -- first mutable borrow occurs here +LL | let Err((ref mut a, _)) = r; + | - first borrow occurs due to use of `r` in closure +... +LL | let mut g = || { + | ^^ second mutable borrow occurs here +LL | +LL | let Err((_, ref mut b)) = r; + | - second borrow occurs due to use of `r` in closure +... +LL | f(); + | - first borrow later used here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.normal.stderr b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.normal.stderr new file mode 100644 index 000000000000..58a5348aa391 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.normal.stderr @@ -0,0 +1,20 @@ +error[E0499]: cannot borrow `r` as mutable more than once at a time + --> $DIR/only-inhabited-variant.rs:16:17 + | +LL | let mut f = || { + | -- first mutable borrow occurs here +LL | let Err((ref mut a, _)) = r; + | - first borrow occurs due to use of `r` in closure +... +LL | let mut g = || { + | ^^ second mutable borrow occurs here +LL | +LL | let Err((_, ref mut b)) = r; + | - second borrow occurs due to use of `r` in closure +... +LL | f(); + | - first borrow later used here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.rs similarity index 55% rename from tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs rename to tests/ui/closures/2229_closure_analysis/only-inhabited-variant.rs index 74f37b514e4a..463838734726 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant.rs @@ -1,8 +1,9 @@ -// Test precise capture of a multi-variant enum (when remaining variants are -// visibly uninhabited). +// This example used to compile, but the fact that it should was never properly +// discussed. With further experience, we concluded that capture precision +// depending on whether some types are inhabited goes too far, introducing a +// bunch of headaches without much benefit. //@ revisions: normal exhaustive_patterns //@ edition:2021 -//@ run-pass #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![feature(never_type)] @@ -13,6 +14,7 @@ pub fn main() { *a = 1; }; let mut g = || { + //~^ ERROR: cannot borrow `r` as mutable more than once at a time let Err((_, ref mut b)) = r; *b = 2; }; diff --git a/tests/ui/closures/or-patterns-issue-137467.rs b/tests/ui/closures/or-patterns-issue-137467.rs new file mode 100644 index 000000000000..38144aa1e816 --- /dev/null +++ b/tests/ui/closures/or-patterns-issue-137467.rs @@ -0,0 +1,170 @@ +//@ edition:2024 +//@ check-pass + +const X: u32 = 0; + +fn match_literal(x: (u32, u32, u32)) { + let _ = || { + let ((0, a, _) | (_, _, a)) = x; + a + }; +} + +fn match_range(x: (u32, u32, u32)) { + let _ = || { + let ((0..5, a, _) | (_, _, a)) = x; + a + }; +} + +fn match_const(x: (u32, u32, u32)) { + let _ = || { + let ((X, a, _) | (_, _, a)) = x; + a + }; +} + +enum Choice { A, B } + +fn match_unit_variant(x: (Choice, u32, u32)) { + let _ = || { + let ((Choice::A, a, _) | (Choice::B, _, a)) = x; + a + }; +} + +struct Unit; + +fn match_unit_struct(mut x: (Unit, u32)) { + let r = &mut x.0; + let _ = || { + let (Unit, a) = x; + a + }; + + let _ = *r; +} + +enum Also { Unit } + +fn match_unit_enum(mut x: (Also, u32)) { + let r = &mut x.0; + let _ = || { + let (Also::Unit, a) = x; + a + }; + + let _ = *r; +} + +enum TEnum { + A(u32), + B(u32), +} + +enum SEnum { + A { a: u32 }, + B { a: u32 }, +} + +fn match_tuple_enum(x: TEnum) { + let _ = || { + let (TEnum::A(a) | TEnum::B(a)) = x; + a + }; +} + +fn match_struct_enum(x: SEnum) { + let _ = || { + let (SEnum::A { a } | SEnum::B { a }) = x; + a + }; +} + +enum TSingle { + A(u32, u32), +} + +enum SSingle { + A { a: u32, b: u32 }, +} + +struct TStruct(u32, u32); +struct SStruct { a: u32, b: u32 } + +fn match_struct(mut x: SStruct) { + let r = &mut x.a; + let _ = || { + let SStruct { b, .. } = x; + b + }; + + let _ = *r; +} + +fn match_tuple_struct(mut x: TStruct) { + let r = &mut x.0; + let _ = || { + let TStruct(_, a) = x; + a + }; + + let _ = *r; +} + +fn match_singleton(mut x: SSingle) { + let SSingle::A { a: ref mut r, .. } = x; + let _ = || { + let SSingle::A { b, .. } = x; + b + }; + + let _ = *r; +} + +fn match_tuple_singleton(mut x: TSingle) { + let TSingle::A(ref mut r, _) = x; + let _ = || { + let TSingle::A(_, a) = x; + a + }; + + let _ = *r; +} + +fn match_slice(x: (&[u32], u32, u32)) { + let _ = || { + let (([], a, _) | ([_, ..], _, a)) = x; + a + }; +} + +// Original testcase, for completeness +enum Camera { + Normal { base_transform: i32 }, + Volume { transform: i32 }, +} + +fn draw_ui(camera: &mut Camera) { + || { + let (Camera::Normal { + base_transform: _transform, + } + | Camera::Volume { + transform: _transform, + }) = camera; + }; +} + +fn draw_ui2(camera: &mut Camera) { + || { + let (Camera::Normal { + base_transform: _, + } + | Camera::Volume { + transform: _, + }) = camera; + }; +} + +fn main() {} From e25803acea4ba86691cb0f9be74f3d10b4be8b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Wed, 26 Mar 2025 20:59:50 +0100 Subject: [PATCH 249/489] ExprUseVisitor: remove maybe_read_scrutinee The split between walk_pat and maybe_read_scrutinee has now become redundant. Due to this change, one testcase within the testsuite has become similar enough to a known ICE to also break. I am leaving this as future work, as it requires feature(type_alias_impl_trait) --- .../rustc_hir_typeck/src/expr_use_visitor.rs | 167 +++--------------- tests/crashes/{119786.rs => 119786-1.rs} | 0 tests/crashes/119786-2.rs | 15 ++ tests/crashes/119786-3.rs | 15 ++ ...oo-{closure#0}-{closure#0}.built.after.mir | 29 ++- ...-{closure#0}-{synthetic#0}.built.after.mir | 24 ++- .../match/match-edge-cases_2.stderr | 2 +- .../match/patterns-capture-analysis.rs | 22 +-- .../match/patterns-capture-analysis.stderr | 90 ++++------ .../at-pattern-weirdness-issue-137553.rs | 41 +++++ .../issue-96572-unconstrained.rs | 9 - 11 files changed, 152 insertions(+), 262 deletions(-) rename tests/crashes/{119786.rs => 119786-1.rs} (100%) create mode 100644 tests/crashes/119786-2.rs create mode 100644 tests/crashes/119786-3.rs create mode 100644 tests/ui/closures/at-pattern-weirdness-issue-137553.rs diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 2e993cf7db95..b35f62df82b7 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -7,9 +7,7 @@ use std::cell::{Ref, RefCell}; use std::ops::Deref; -use std::slice::from_ref; -use hir::Expr; use hir::def::DefKind; use hir::pat_util::EnumerateAndAdjustIterator as _; use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; @@ -313,7 +311,8 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx let param_place = self.cat_rvalue(param.hir_id, param_ty); - self.walk_irrefutable_pat(¶m_place, param.pat)?; + self.fake_read_scrutinee(¶m_place, false)?; + self.walk_pat(¶m_place, param.pat, false)?; } self.consume_expr(body.value)?; @@ -455,13 +454,9 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx hir::ExprKind::Match(discr, arms, _) => { let discr_place = self.cat_expr(discr)?; - self.maybe_read_scrutinee( - discr, - discr_place.clone(), - arms.iter().map(|arm| arm.pat), - )?; + self.fake_read_scrutinee(&discr_place, true)?; + self.walk_expr(discr)?; - // treatment of the discriminant is handled while walking the arms. for arm in arms { self.walk_arm(&discr_place, arm)?; } @@ -598,116 +593,25 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx Ok(()) } - fn maybe_read_scrutinee<'t>( + #[instrument(skip(self), level = "debug")] + fn fake_read_scrutinee( &self, - discr: &Expr<'_>, - discr_place: PlaceWithHirId<'tcx>, - pats: impl Iterator>, + discr_place: &PlaceWithHirId<'tcx>, + refutable: bool, ) -> Result<(), Cx::Error> { - // Matching should not always be considered a use of the place, hence - // discr does not necessarily need to be borrowed. - // We only want to borrow discr if the pattern contain something other - // than wildcards. - let mut needs_to_be_read = false; - for pat in pats { - self.cat_pattern(discr_place.clone(), pat, &mut |place, pat| { - match &pat.kind { - PatKind::Missing => unreachable!(), - PatKind::Binding(.., opt_sub_pat) => { - // If the opt_sub_pat is None, then the binding does not count as - // a wildcard for the purpose of borrowing discr. - if opt_sub_pat.is_none() { - needs_to_be_read = true; - } - } - PatKind::Never => { - // A never pattern reads the value. - // FIXME(never_patterns): does this do what I expect? - needs_to_be_read = true; - } - PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, span }) => { - // A `Path` pattern is just a name like `Foo`. This is either a - // named constant or else it refers to an ADT variant + let closure_def_id = match discr_place.place.base { + PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id), + _ => None, + }; - let res = self.cx.typeck_results().qpath_res(qpath, *hir_id); - match res { - Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => { - // Named constants have to be equated with the value - // being matched, so that's a read of the value being matched. - // - // FIXME: We don't actually reads for ZSTs. - needs_to_be_read = true; - } - _ => { - // Otherwise, this is a struct/enum variant, and so it's - // only a read if we need to read the discriminant. - needs_to_be_read |= - self.is_multivariant_adt(place.place.ty(), *span); - } - } - } - PatKind::TupleStruct(..) | PatKind::Struct(..) | PatKind::Tuple(..) => { - // For `Foo(..)`, `Foo { ... }` and `(...)` patterns, check if we are matching - // against a multivariant enum or struct. In that case, we have to read - // the discriminant. Otherwise this kind of pattern doesn't actually - // read anything (we'll get invoked for the `...`, which may indeed - // perform some reads). - - let place_ty = place.place.ty(); - needs_to_be_read |= self.is_multivariant_adt(place_ty, pat.span); - } - PatKind::Expr(_) | PatKind::Range(..) => { - // If the PatKind is a Lit or a Range then we want - // to borrow discr. - needs_to_be_read = true; - } - PatKind::Slice(lhs, wild, rhs) => { - // We don't need to test the length if the pattern is `[..]` - if matches!((lhs, wild, rhs), (&[], Some(_), &[])) - // Arrays have a statically known size, so - // there is no need to read their length - || place.place.ty().peel_refs().is_array() - { - } else { - needs_to_be_read = true; - } - } - PatKind::Or(_) - | PatKind::Box(_) - | PatKind::Deref(_) - | PatKind::Ref(..) - | PatKind::Guard(..) - | PatKind::Wild - | PatKind::Err(_) => { - // If the PatKind is Or, Box, or Ref, the decision is made later - // as these patterns contains subpatterns - // If the PatKind is Wild or Err, the decision is made based on the other patterns - // being examined - } - } - - Ok(()) - })? - } - - if needs_to_be_read { - self.borrow_expr(discr, BorrowKind::Immutable)?; + let cause = if refutable { + FakeReadCause::ForMatchedPlace(closure_def_id) } else { - let closure_def_id = match discr_place.place.base { - PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id), - _ => None, - }; + FakeReadCause::ForLet(closure_def_id) + }; - self.delegate.borrow_mut().fake_read( - &discr_place, - FakeReadCause::ForMatchedPlace(closure_def_id), - discr_place.hir_id, - ); + self.delegate.borrow_mut().fake_read(discr_place, cause, discr_place.hir_id); - // We always want to walk the discriminant. We want to make sure, for instance, - // that the discriminant has been initialized. - self.walk_expr(discr)?; - } Ok(()) } @@ -724,12 +628,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx self.walk_expr(expr)?; let expr_place = self.cat_expr(expr)?; f()?; + self.fake_read_scrutinee(&expr_place, els.is_some())?; + self.walk_pat(&expr_place, pat, false)?; if let Some(els) = els { - // borrowing because we need to test the discriminant - self.maybe_read_scrutinee(expr, expr_place.clone(), from_ref(pat).iter())?; self.walk_block(els)?; } - self.walk_irrefutable_pat(&expr_place, pat)?; Ok(()) } @@ -901,16 +804,6 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx discr_place: &PlaceWithHirId<'tcx>, arm: &hir::Arm<'_>, ) -> Result<(), Cx::Error> { - let closure_def_id = match discr_place.place.base { - PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id), - _ => None, - }; - - self.delegate.borrow_mut().fake_read( - discr_place, - FakeReadCause::ForMatchedPlace(closure_def_id), - discr_place.hir_id, - ); self.walk_pat(discr_place, arm.pat, arm.guard.is_some())?; if let Some(ref e) = arm.guard { @@ -921,27 +814,6 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx Ok(()) } - /// Walks a pat that occurs in isolation (i.e., top-level of fn argument or - /// let binding, and *not* a match arm or nested pat.) - fn walk_irrefutable_pat( - &self, - discr_place: &PlaceWithHirId<'tcx>, - pat: &hir::Pat<'_>, - ) -> Result<(), Cx::Error> { - let closure_def_id = match discr_place.place.base { - PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id), - _ => None, - }; - - self.delegate.borrow_mut().fake_read( - discr_place, - FakeReadCause::ForLet(closure_def_id), - discr_place.hir_id, - ); - self.walk_pat(discr_place, pat, false)?; - Ok(()) - } - /// The core driver for walking a pattern /// /// This should mirror how pattern-matching gets lowered to MIR, as @@ -1984,6 +1856,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx /// Here, we cannot perform such an accurate checks, because querying /// whether a type is inhabited requires that it has been fully inferred, /// which cannot be guaranteed at this point. + #[instrument(skip(self, span), level = "debug")] fn is_multivariant_adt(&self, ty: Ty<'tcx>, span: Span) -> bool { if let ty::Adt(def, _) = self.cx.structurally_resolve_type(span, ty).kind() { // Note that if a non-exhaustive SingleVariant is defined in another crate, we need diff --git a/tests/crashes/119786.rs b/tests/crashes/119786-1.rs similarity index 100% rename from tests/crashes/119786.rs rename to tests/crashes/119786-1.rs diff --git a/tests/crashes/119786-2.rs b/tests/crashes/119786-2.rs new file mode 100644 index 000000000000..76c5deb4605a --- /dev/null +++ b/tests/crashes/119786-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #119786 +//@ edition:2021 + +fn enum_upvar() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + let x = move || { + match foo { + None => (), + Some(_) => (), + } + }; +} + +pub fn main() {} diff --git a/tests/crashes/119786-3.rs b/tests/crashes/119786-3.rs new file mode 100644 index 000000000000..34bb90fd0fae --- /dev/null +++ b/tests/crashes/119786-3.rs @@ -0,0 +1,15 @@ +//@ known-bug: #119786 +//@ edition:2021 + +fn enum_upvar() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + let x = move || { + match foo { + None => (), + Some((a, b)) => (), + } + }; +} + +pub fn main() {} diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir index b43af549b232..9ff1a90ab820 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir @@ -4,18 +4,16 @@ fn foo::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_fake yields () { debug _task_context => _2; - debug f => (*(_1.0: &&Foo)); + debug f => (*(_1.0: &Foo)); let mut _0: (); let mut _3: &Foo; let mut _4: &&Foo; - let mut _5: &&&Foo; - let mut _6: isize; - let mut _7: bool; + let mut _5: isize; + let mut _6: bool; bb0: { - PlaceMention((*(_1.0: &&Foo))); - _6 = discriminant((*(*(_1.0: &&Foo)))); - switchInt(move _6) -> [0: bb2, otherwise: bb1]; + _5 = discriminant((*(_1.0: &Foo))); + switchInt(move _5) -> [0: bb2, otherwise: bb1]; } bb1: { @@ -32,17 +30,15 @@ yields () } bb4: { - FakeRead(ForMatchedPlace(None), (*(_1.0: &&Foo))); unreachable; } bb5: { - _3 = &fake shallow (*(*(_1.0: &&Foo))); - _4 = &fake shallow (*(_1.0: &&Foo)); - _5 = &fake shallow (_1.0: &&Foo); - StorageLive(_7); - _7 = const true; - switchInt(move _7) -> [0: bb8, otherwise: bb7]; + _3 = &fake shallow (*(_1.0: &Foo)); + _4 = &fake shallow (_1.0: &Foo); + StorageLive(_6); + _6 = const true; + switchInt(move _6) -> [0: bb8, otherwise: bb7]; } bb6: { @@ -50,10 +46,9 @@ yields () } bb7: { - StorageDead(_7); + StorageDead(_6); FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _4); - FakeRead(ForMatchGuard, _5); _0 = const (); goto -> bb10; } @@ -63,7 +58,7 @@ yields () } bb9: { - StorageDead(_7); + StorageDead(_6); goto -> bb6; } diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir index 5623b6d64e97..4b745caf48c5 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir @@ -4,18 +4,16 @@ fn foo::{closure#0}::{synthetic#0}(_1: {async closure body@$DIR/async_closure_fa yields () { debug _task_context => _2; - debug f => (_1.0: &Foo); + debug f => (*(_1.0: &Foo)); let mut _0: (); let mut _3: &Foo; let mut _4: &&Foo; - let mut _5: &&&Foo; - let mut _6: isize; - let mut _7: bool; + let mut _5: isize; + let mut _6: bool; bb0: { - PlaceMention((_1.0: &Foo)); - _6 = discriminant((*(_1.0: &Foo))); - switchInt(move _6) -> [0: bb2, otherwise: bb1]; + _5 = discriminant((*(_1.0: &Foo))); + switchInt(move _5) -> [0: bb2, otherwise: bb1]; } bb1: { @@ -29,24 +27,22 @@ yields () bb3: { _3 = &fake shallow (*(_1.0: &Foo)); - _4 = &fake shallow (_1.0: &Foo); nop; - StorageLive(_7); - _7 = const true; - switchInt(move _7) -> [0: bb5, otherwise: bb4]; + StorageLive(_6); + _6 = const true; + switchInt(move _6) -> [0: bb5, otherwise: bb4]; } bb4: { - StorageDead(_7); + StorageDead(_6); FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _4); - FakeRead(ForMatchGuard, _5); _0 = const (); goto -> bb6; } bb5: { - StorageDead(_7); + StorageDead(_6); falseEdge -> [real: bb1, imaginary: bb1]; } diff --git a/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr b/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr index d82db0481a06..3f5fe9eda423 100644 --- a/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr @@ -4,7 +4,7 @@ error[E0505]: cannot move out of `ts` because it is borrowed LL | let _b = || { match ts { | -- -- borrow occurs due to use in closure | | - | borrow of `ts` occurs here + | borrow of `ts.x` occurs here ... LL | let mut mut_ts = ts; | ^^ move out of `ts` occurs here diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs index a9d2777d93f1..16cb9d7355da 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs @@ -14,7 +14,6 @@ fn test_1_should_capture() { //~| ERROR Min Capture analysis includes: match variant { //~^ NOTE: Capturing variant[] -> Immutable - //~| NOTE: Capturing variant[] -> Immutable //~| NOTE: Min Capture variant[] -> Immutable Some(_) => {} _ => {} @@ -65,9 +64,8 @@ fn test_6_should_capture_single_variant() { //~^ ERROR First Pass analysis includes: //~| ERROR Min Capture analysis includes: match variant { - //~^ NOTE: Capturing variant[] -> Immutable - //~| NOTE: Capturing variant[(0, 0)] -> Immutable - //~| NOTE: Min Capture variant[] -> Immutable + //~^ NOTE: Capturing variant[(0, 0)] -> Immutable + //~| NOTE: Min Capture variant[(0, 0)] -> Immutable SingleVariant::Points(a) => { println!("{:?}", a); } @@ -133,7 +131,6 @@ fn test_5_should_capture_multi_variant() { //~| ERROR Min Capture analysis includes: match variant { //~^ NOTE: Capturing variant[] -> Immutable - //~| NOTE: Capturing variant[] -> Immutable //~| NOTE: Min Capture variant[] -> Immutable MVariant::A => {} _ => {} @@ -151,9 +148,8 @@ fn test_7_should_capture_slice_len() { //~^ ERROR First Pass analysis includes: //~| ERROR Min Capture analysis includes: match slice { - //~^ NOTE: Capturing slice[] -> Immutable - //~| NOTE: Capturing slice[Deref] -> Immutable - //~| NOTE: Min Capture slice[] -> Immutable + //~^ NOTE: Capturing slice[Deref] -> Immutable + //~| NOTE: Min Capture slice[Deref] -> Immutable [_,_,_] => {}, _ => {} } @@ -164,9 +160,8 @@ fn test_7_should_capture_slice_len() { //~^ ERROR First Pass analysis includes: //~| ERROR Min Capture analysis includes: match slice { - //~^ NOTE: Capturing slice[] -> Immutable - //~| NOTE: Capturing slice[Deref] -> Immutable - //~| NOTE: Min Capture slice[] -> Immutable + //~^ NOTE: Capturing slice[Deref] -> Immutable + //~| NOTE: Min Capture slice[Deref] -> Immutable [] => {}, _ => {} } @@ -177,9 +172,8 @@ fn test_7_should_capture_slice_len() { //~^ ERROR First Pass analysis includes: //~| ERROR Min Capture analysis includes: match slice { - //~^ NOTE: Capturing slice[] -> Immutable - //~| NOTE: Capturing slice[Deref] -> Immutable - //~| NOTE: Min Capture slice[] -> Immutable + //~^ NOTE: Capturing slice[Deref] -> Immutable + //~| NOTE: Min Capture slice[Deref] -> Immutable [_, .. ,_] => {}, _ => {} } diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr index 4b9d6fad0e50..73c685e15276 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr @@ -14,11 +14,6 @@ note: Capturing variant[] -> Immutable | LL | match variant { | ^^^^^^^ -note: Capturing variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:15:15 - | -LL | match variant { - | ^^^^^^^ error: Min Capture analysis includes: --> $DIR/patterns-capture-analysis.rs:12:5 @@ -38,7 +33,7 @@ LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:31:5 + --> $DIR/patterns-capture-analysis.rs:30:5 | LL | / || { LL | | @@ -49,7 +44,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:50:5 + --> $DIR/patterns-capture-analysis.rs:49:5 | LL | / || { LL | | @@ -60,7 +55,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:64:5 + --> $DIR/patterns-capture-analysis.rs:63:5 | LL | / || { LL | | @@ -70,19 +65,14 @@ LL | | match variant { LL | | }; | |_____^ | -note: Capturing variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:67:15 - | -LL | match variant { - | ^^^^^^^ note: Capturing variant[(0, 0)] -> Immutable - --> $DIR/patterns-capture-analysis.rs:67:15 + --> $DIR/patterns-capture-analysis.rs:66:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:64:5 + --> $DIR/patterns-capture-analysis.rs:63:5 | LL | / || { LL | | @@ -92,14 +82,14 @@ LL | | match variant { LL | | }; | |_____^ | -note: Min Capture variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:67:15 +note: Min Capture variant[(0, 0)] -> Immutable + --> $DIR/patterns-capture-analysis.rs:66:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:84:5 + --> $DIR/patterns-capture-analysis.rs:82:5 | LL | / || { LL | | @@ -110,7 +100,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:96:5 + --> $DIR/patterns-capture-analysis.rs:94:5 | LL | / || { LL | | @@ -121,7 +111,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:109:5 + --> $DIR/patterns-capture-analysis.rs:107:5 | LL | / || { LL | | @@ -132,7 +122,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:131:5 + --> $DIR/patterns-capture-analysis.rs:129:5 | LL | / || { LL | | @@ -143,18 +133,13 @@ LL | | }; | |_____^ | note: Capturing variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:134:15 - | -LL | match variant { - | ^^^^^^^ -note: Capturing variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:134:15 + --> $DIR/patterns-capture-analysis.rs:132:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:131:5 + --> $DIR/patterns-capture-analysis.rs:129:5 | LL | / || { LL | | @@ -165,13 +150,13 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:134:15 + --> $DIR/patterns-capture-analysis.rs:132:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:150:5 + --> $DIR/patterns-capture-analysis.rs:147:5 | LL | / || { LL | | @@ -181,19 +166,14 @@ LL | | match slice { LL | | }; | |_____^ | -note: Capturing slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:153:15 - | -LL | match slice { - | ^^^^^ note: Capturing slice[Deref] -> Immutable - --> $DIR/patterns-capture-analysis.rs:153:15 + --> $DIR/patterns-capture-analysis.rs:150:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:150:5 + --> $DIR/patterns-capture-analysis.rs:147:5 | LL | / || { LL | | @@ -203,14 +183,14 @@ LL | | match slice { LL | | }; | |_____^ | -note: Min Capture slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:153:15 +note: Min Capture slice[Deref] -> Immutable + --> $DIR/patterns-capture-analysis.rs:150:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:163:5 + --> $DIR/patterns-capture-analysis.rs:159:5 | LL | / || { LL | | @@ -220,19 +200,14 @@ LL | | match slice { LL | | }; | |_____^ | -note: Capturing slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:166:15 - | -LL | match slice { - | ^^^^^ note: Capturing slice[Deref] -> Immutable - --> $DIR/patterns-capture-analysis.rs:166:15 + --> $DIR/patterns-capture-analysis.rs:162:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:163:5 + --> $DIR/patterns-capture-analysis.rs:159:5 | LL | / || { LL | | @@ -242,14 +217,14 @@ LL | | match slice { LL | | }; | |_____^ | -note: Min Capture slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:166:15 +note: Min Capture slice[Deref] -> Immutable + --> $DIR/patterns-capture-analysis.rs:162:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:176:5 + --> $DIR/patterns-capture-analysis.rs:171:5 | LL | / || { LL | | @@ -259,19 +234,14 @@ LL | | match slice { LL | | }; | |_____^ | -note: Capturing slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:179:15 - | -LL | match slice { - | ^^^^^ note: Capturing slice[Deref] -> Immutable - --> $DIR/patterns-capture-analysis.rs:179:15 + --> $DIR/patterns-capture-analysis.rs:174:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:176:5 + --> $DIR/patterns-capture-analysis.rs:171:5 | LL | / || { LL | | @@ -281,14 +251,14 @@ LL | | match slice { LL | | }; | |_____^ | -note: Min Capture slice[] -> Immutable - --> $DIR/patterns-capture-analysis.rs:179:15 +note: Min Capture slice[Deref] -> Immutable + --> $DIR/patterns-capture-analysis.rs:174:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:194:5 + --> $DIR/patterns-capture-analysis.rs:188:5 | LL | / || { LL | | diff --git a/tests/ui/closures/at-pattern-weirdness-issue-137553.rs b/tests/ui/closures/at-pattern-weirdness-issue-137553.rs new file mode 100644 index 000000000000..7c934d4a1433 --- /dev/null +++ b/tests/ui/closures/at-pattern-weirdness-issue-137553.rs @@ -0,0 +1,41 @@ +//@ edition:2024 +//@ check-pass + +// Background: +fn f1() { + let mut a = (21, 37); + // only captures a.0, example compiles fine + let mut f = || { + let (ref mut x, _) = a; + *x = 42; + }; + a.1 = 69; + f(); +} + +// This used to error out: +fn f2() { + let mut a = (21, 37); + // used to capture all of a, now captures only a.0 + let mut f = || { + match a { + (ref mut x, _) => *x = 42, + } + }; + a.1 = 69; + f(); +} + +// This was inconsistent with the following: +fn main() { + let mut a = (21, 37); + // the useless @-pattern would cause it to capture only a.0. now the + // behavior is consistent with the case that doesn't use the @-pattern + let mut f = || { + match a { + (ref mut x @ _, _) => *x = 42, + } + }; + a.1 = 69; + f(); +} diff --git a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs index 7f0f6a214aae..383d9108eb90 100644 --- a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs +++ b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs @@ -23,15 +23,6 @@ fn upvar() { }; } -fn enum_upvar() { - type T = impl Copy; - let foo: T = Some((1u32, 2u32)); - let x = move || match foo { - None => (), - Some((a, b)) => (), - }; -} - fn r#struct() { #[derive(Copy, Clone)] struct Foo((u32, u32)); From 1cc7e7fe8b675dd3f55b5d75325b2e52466700bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Thu, 27 Mar 2025 16:50:11 +0100 Subject: [PATCH 250/489] Add test case for issue 138973 --- tests/ui/closures/or-patterns-issue-137467.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/ui/closures/or-patterns-issue-137467.rs b/tests/ui/closures/or-patterns-issue-137467.rs index 38144aa1e816..5a1e84e1c9a0 100644 --- a/tests/ui/closures/or-patterns-issue-137467.rs +++ b/tests/ui/closures/or-patterns-issue-137467.rs @@ -24,6 +24,13 @@ fn match_const(x: (u32, u32, u32)) { }; } +// related testcase reported in #138973 +fn without_bindings(x: u32) { + let _ = || { + let (0 | _) = x; + }; +} + enum Choice { A, B } fn match_unit_variant(x: (Choice, u32, u32)) { From 8800f956f4ac5a8a99f32a0820468bb96391654c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Tue, 1 Apr 2025 20:32:13 +0200 Subject: [PATCH 251/489] Avoid using #[derive] in test As per code review, it is preferred to not use derives in tests that aren't about them. --- .../2229_closure_analysis/only-inhabited-variant-stable.rs | 3 +-- .../2229_closure_analysis/only-inhabited-variant-stable.stderr | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs index a8e4b9cd1823..c7f367cc48ab 100644 --- a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.rs @@ -3,7 +3,6 @@ // depending on whether some types are inhabited goes too far, introducing a // bunch of headaches without much benefit. //@ edition:2021 -#[derive(Clone, Copy, PartialEq, Eq, Debug)] enum Void {} pub fn main() { @@ -19,5 +18,5 @@ pub fn main() { }; f(); g(); - assert_eq!(r, Err((1, 2))); + assert!(matches!(r, Err((1, 2)))); } diff --git a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr index dea85ff947ce..7f4c8942b0d9 100644 --- a/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr +++ b/tests/ui/closures/2229_closure_analysis/only-inhabited-variant-stable.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `r` as mutable more than once at a time - --> $DIR/only-inhabited-variant-stable.rs:15:17 + --> $DIR/only-inhabited-variant-stable.rs:14:17 | LL | let mut f = || { | -- first mutable borrow occurs here From 462b51a525b80200151c344c59f81f8af0788610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Tue, 22 Apr 2025 01:02:48 +0200 Subject: [PATCH 252/489] Add debug logging in hir_typeck::upvar This aims to make each major part responsible for modifying the precision be visible in the logs. --- compiler/rustc_hir_typeck/src/upvar.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 445386412058..1a2b76485f35 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -761,6 +761,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// ], /// } /// ``` + #[instrument(level = "debug", skip(self))] fn compute_min_captures( &self, closure_def_id: LocalDefId, @@ -2029,6 +2030,7 @@ struct InferBorrowKind<'tcx> { } impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> { + #[instrument(skip(self), level = "debug")] fn fake_read( &mut self, place_with_id: &PlaceWithHirId<'tcx>, @@ -2119,6 +2121,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> { } /// Rust doesn't permit moving fields out of a type that implements drop +#[instrument(skip(fcx), ret, level = "debug")] fn restrict_precision_for_drop_types<'a, 'tcx>( fcx: &'a FnCtxt<'a, 'tcx>, mut place: Place<'tcx>, @@ -2179,6 +2182,7 @@ fn restrict_precision_for_unsafe( /// - No unsafe block is required to capture `place`. /// /// Returns the truncated place and updated capture mode. +#[instrument(ret, level = "debug")] fn restrict_capture_precision( place: Place<'_>, curr_mode: ty::UpvarCapture, @@ -2208,6 +2212,7 @@ fn restrict_capture_precision( } /// Truncate deref of any reference. +#[instrument(ret, level = "debug")] fn adjust_for_move_closure( mut place: Place<'_>, mut kind: ty::UpvarCapture, @@ -2222,6 +2227,7 @@ fn adjust_for_move_closure( } /// Truncate deref of any reference. +#[instrument(ret, level = "debug")] fn adjust_for_use_closure( mut place: Place<'_>, mut kind: ty::UpvarCapture, @@ -2237,6 +2243,7 @@ fn adjust_for_use_closure( /// Adjust closure capture just that if taking ownership of data, only move data /// from enclosing stack frame. +#[instrument(ret, level = "debug")] fn adjust_for_non_move_closure( mut place: Place<'_>, mut kind: ty::UpvarCapture, @@ -2559,6 +2566,7 @@ fn determine_place_ancestry_relation<'tcx>( /// // it is constrained to `'a` /// } /// ``` +#[instrument(ret, level = "debug")] fn truncate_capture_for_optimization( mut place: Place<'_>, mut curr_mode: ty::UpvarCapture, From 19f6bc4ab7c8e8a740ab9dbe0c012e5e59431cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Tue, 22 Apr 2025 02:51:46 +0200 Subject: [PATCH 253/489] Add miri tests for new closure capture behavior --- .../tests/fail/closures/deref-in-pattern.rs | 20 ++++++++++++ .../fail/closures/deref-in-pattern.stderr | 20 ++++++++++++ .../tests/fail/closures/partial-pattern.rs | 28 +++++++++++++++++ .../fail/closures/partial-pattern.stderr | 20 ++++++++++++ .../fail/closures/uninhabited-variant.rs | 31 +++++++++++++++++++ .../fail/closures/uninhabited-variant.stderr | 20 ++++++++++++ 6 files changed, 139 insertions(+) create mode 100644 src/tools/miri/tests/fail/closures/deref-in-pattern.rs create mode 100644 src/tools/miri/tests/fail/closures/deref-in-pattern.stderr create mode 100644 src/tools/miri/tests/fail/closures/partial-pattern.rs create mode 100644 src/tools/miri/tests/fail/closures/partial-pattern.stderr create mode 100644 src/tools/miri/tests/fail/closures/uninhabited-variant.rs create mode 100644 src/tools/miri/tests/fail/closures/uninhabited-variant.stderr diff --git a/src/tools/miri/tests/fail/closures/deref-in-pattern.rs b/src/tools/miri/tests/fail/closures/deref-in-pattern.rs new file mode 100644 index 000000000000..c729469c78b0 --- /dev/null +++ b/src/tools/miri/tests/fail/closures/deref-in-pattern.rs @@ -0,0 +1,20 @@ +// This test serves to document the change in semantics introduced by +// rust-lang/rust#138961. +// +// A corollary of partial-pattern.rs: while the tuple access testcase makes +// it clear why these semantics are useful, it is actually the dereference +// being performed by the pattern that matters. + +fn main() { + // the inner reference is dangling + let x: &&u32 = unsafe { + let x: u32 = 42; + &&* &raw const x + }; + + let _ = || { //~ ERROR: encountered a dangling reference + match x { + &&_y => {}, + } + }; +} diff --git a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr new file mode 100644 index 000000000000..aa97fd4b7ac2 --- /dev/null +++ b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: constructing invalid value: encountered a dangling reference (use-after-free) + --> tests/fail/closures/deref-in-pattern.rs:LL:CC + | +LL | let _ = || { + | _____________^ +LL | | match x { +LL | | &&_y => {}, +LL | | } +LL | | }; + | |_____^ constructing invalid value: encountered a dangling reference (use-after-free) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at tests/fail/closures/deref-in-pattern.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/src/tools/miri/tests/fail/closures/partial-pattern.rs b/src/tools/miri/tests/fail/closures/partial-pattern.rs new file mode 100644 index 000000000000..cb6446208180 --- /dev/null +++ b/src/tools/miri/tests/fail/closures/partial-pattern.rs @@ -0,0 +1,28 @@ +// This test serves to document the change in semantics introduced by +// rust-lang/rust#138961. +// +// Previously, the closure would capture the entirety of x, and access *(*x).0 +// when called. Now, the closure only captures *(*x).0, which means that +// a &*(*x).0 reborrow happens when the closure is constructed. +// +// Hence, if one of the references is dangling, this constitutes newly introduced UB +// in the case where the closure doesn't get called. This isn't a big deal, +// because while opsem only now considers this to be UB, the unsafe code +// guidelines have long recommended against any handling of dangling references. + +fn main() { + // the inner references are dangling + let x: &(&u32, &u32) = unsafe { + let a = 21; + let b = 37; + let ra = &* &raw const a; + let rb = &* &raw const b; + &(ra, rb) + }; + + let _ = || { //~ ERROR: encountered a dangling reference + match x { + (&_y, _) => {}, + } + }; +} diff --git a/src/tools/miri/tests/fail/closures/partial-pattern.stderr b/src/tools/miri/tests/fail/closures/partial-pattern.stderr new file mode 100644 index 000000000000..67b26709eb0d --- /dev/null +++ b/src/tools/miri/tests/fail/closures/partial-pattern.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: constructing invalid value: encountered a dangling reference (use-after-free) + --> tests/fail/closures/partial-pattern.rs:LL:CC + | +LL | let _ = || { + | _____________^ +LL | | match x { +LL | | (&_y, _) => {}, +LL | | } +LL | | }; + | |_____^ constructing invalid value: encountered a dangling reference (use-after-free) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at tests/fail/closures/partial-pattern.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/src/tools/miri/tests/fail/closures/uninhabited-variant.rs b/src/tools/miri/tests/fail/closures/uninhabited-variant.rs new file mode 100644 index 000000000000..9c50fdc13a35 --- /dev/null +++ b/src/tools/miri/tests/fail/closures/uninhabited-variant.rs @@ -0,0 +1,31 @@ +// Motivated by rust-lang/rust#138961, this shows how invalid discriminants interact with +// closure captures. +#![feature(never_type)] + +#[repr(C)] +#[allow(dead_code)] +enum E { + V0, // discriminant: 0 + V1, // 1 + V2(!), // 2 +} + +fn main() { + assert_eq!(std::mem::size_of::(), 4); + + let val = 2u32; + let ptr = (&raw const val).cast::(); + let r = unsafe { &*ptr }; + let f = || { + // After rust-lang/rust#138961, constructing the closure performs a reborrow of r. + // Nevertheless, the discriminant is only actually inspected when the closure + // is called. + match r { //~ ERROR: read discriminant of an uninhabited enum variant + E::V0 => {} + E::V1 => {} + E::V2(_) => {} + } + }; + + f(); +} diff --git a/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr b/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr new file mode 100644 index 000000000000..0c374804b970 --- /dev/null +++ b/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: read discriminant of an uninhabited enum variant + --> tests/fail/closures/uninhabited-variant.rs:LL:CC + | +LL | match r { + | ^ read discriminant of an uninhabited enum variant + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at tests/fail/closures/uninhabited-variant.rs:LL:CC +note: inside `main` + --> tests/fail/closures/uninhabited-variant.rs:LL:CC + | +LL | f(); + | ^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + From e6c59990bd91b3b2b4c97192baf1d7e92baadd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Tue, 22 Apr 2025 03:32:20 +0200 Subject: [PATCH 254/489] add a comment: MatchPair and ExprUseVisitor must stay in sync --- compiler/rustc_mir_build/src/builder/matches/match_pair.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index a0d54354a9c6..67c12bfa7790 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -339,6 +339,12 @@ impl<'tcx> MatchPairTree<'tcx> { if let Some(test_case) = test_case { // This pattern is refutable, so push a new match-pair node. + // + // Note: unless test_case is TestCase::Or, place must not be None. + // This means that the closure capture analysis in + // rustc_hir_typeck::upvar, and in particular the pattern handling + // code of ExprUseVisitor, must capture all of the places we'll use. + // Make sure to keep these two parts in sync! match_pairs.push(MatchPairTree { place, test_case, From 3d5d1d72e0db38ff9832df8021fd62af873f1d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sat, 31 May 2025 00:07:16 +0200 Subject: [PATCH 255/489] Mark crash 140011 as fixed --- tests/crashes/140011.rs | 11 ------ .../malformed-pattern-issue-140011.rs | 13 +++++++ .../malformed-pattern-issue-140011.stderr | 36 +++++++++++++++++++ 3 files changed, 49 insertions(+), 11 deletions(-) delete mode 100644 tests/crashes/140011.rs create mode 100644 tests/ui/closures/malformed-pattern-issue-140011.rs create mode 100644 tests/ui/closures/malformed-pattern-issue-140011.stderr diff --git a/tests/crashes/140011.rs b/tests/crashes/140011.rs deleted file mode 100644 index b9d57a2822d2..000000000000 --- a/tests/crashes/140011.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #140011 -//@compile-flags: -Wrust-2021-incompatible-closure-captures -enum b { - c(d), - e(f), -} -struct f; -fn g() { - let h; - || b::e(a) = h; -} diff --git a/tests/ui/closures/malformed-pattern-issue-140011.rs b/tests/ui/closures/malformed-pattern-issue-140011.rs new file mode 100644 index 000000000000..18061613e988 --- /dev/null +++ b/tests/ui/closures/malformed-pattern-issue-140011.rs @@ -0,0 +1,13 @@ +//@compile-flags: -Wrust-2021-incompatible-closure-captures +enum B { + C(D), //~ ERROR: cannot find type `D` in this scope + E(F), +} +struct F; +fn f(h: B) { + || { + let B::E(a) = h; //~ ERROR: refutable pattern in local binding + }; +} + +fn main() {} diff --git a/tests/ui/closures/malformed-pattern-issue-140011.stderr b/tests/ui/closures/malformed-pattern-issue-140011.stderr new file mode 100644 index 000000000000..08122b8a7d2e --- /dev/null +++ b/tests/ui/closures/malformed-pattern-issue-140011.stderr @@ -0,0 +1,36 @@ +error[E0412]: cannot find type `D` in this scope + --> $DIR/malformed-pattern-issue-140011.rs:3:7 + | +LL | C(D), + | ^ not found in this scope + | +help: you might be missing a type parameter + | +LL | enum B { + | +++ + +error[E0005]: refutable pattern in local binding + --> $DIR/malformed-pattern-issue-140011.rs:9:13 + | +LL | let B::E(a) = h; + | ^^^^^^^ pattern `B::C(_)` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html +note: `B` defined here + --> $DIR/malformed-pattern-issue-140011.rs:2:6 + | +LL | enum B { + | ^ +LL | C(D), + | - not covered + = note: the matched value is of type `B` +help: you might want to use `let else` to handle the variant that isn't matched + | +LL | let B::E(a) = h else { todo!() }; + | ++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0005, E0412. +For more information about an error, try `rustc --explain E0005`. From a2e249cd2672843493b641518141b62c0bccf745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sat, 31 May 2025 00:13:46 +0200 Subject: [PATCH 256/489] =?UTF-8?q?ExprUseVisitor:=20resolve=20a=20FIXME?= =?UTF-8?q?=20=E2=80=93=20it's=20fine=20as=20is?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index b35f62df82b7..93304d794bc2 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -929,10 +929,12 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx // When matching against a literal or range, we need to // borrow the place to compare it against the pattern. // + // Note that we do this read even if the range matches all + // possible values, such as 0..=u8::MAX. This is because + // we don't want to depend on consteval here. + // // FIXME: What if the type being matched only has one // possible value? - // FIXME: What if the range is the full range of the type - // and doesn't actually require a discriminant read? read_discriminant(); } PatKind::Struct(..) | PatKind::TupleStruct(..) => { From 4f7915ba58a77cedc06d755bdeb714a9057ddc35 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 15 Oct 2025 07:27:39 +0000 Subject: [PATCH 257/489] Bless miri tests --- src/tools/miri/tests/fail/closures/deref-in-pattern.stderr | 2 +- src/tools/miri/tests/fail/closures/partial-pattern.stderr | 2 +- src/tools/miri/tests/fail/closures/uninhabited-variant.stderr | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr index aa97fd4b7ac2..ccdfad577315 100644 --- a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr +++ b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr @@ -7,7 +7,7 @@ LL | | match x { LL | | &&_y => {}, LL | | } LL | | }; - | |_____^ constructing invalid value: encountered a dangling reference (use-after-free) + | |_____^ Undefined Behavior occurred here | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/miri/tests/fail/closures/partial-pattern.stderr b/src/tools/miri/tests/fail/closures/partial-pattern.stderr index 67b26709eb0d..f26d6ffed54b 100644 --- a/src/tools/miri/tests/fail/closures/partial-pattern.stderr +++ b/src/tools/miri/tests/fail/closures/partial-pattern.stderr @@ -7,7 +7,7 @@ LL | | match x { LL | | (&_y, _) => {}, LL | | } LL | | }; - | |_____^ constructing invalid value: encountered a dangling reference (use-after-free) + | |_____^ Undefined Behavior occurred here | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr b/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr index 0c374804b970..995a5e3eac14 100644 --- a/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr +++ b/src/tools/miri/tests/fail/closures/uninhabited-variant.stderr @@ -2,7 +2,7 @@ error: Undefined Behavior: read discriminant of an uninhabited enum variant --> tests/fail/closures/uninhabited-variant.rs:LL:CC | LL | match r { - | ^ read discriminant of an uninhabited enum variant + | ^ Undefined Behavior occurred here | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information From d05b1d76f3ae7f1cebd17613f17058669b5971a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 19 Oct 2025 00:38:31 +0200 Subject: [PATCH 258/489] Add a test for deref projections in new pattern capture behavior --- .../deref-mut-in-pattern.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs diff --git a/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs b/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs new file mode 100644 index 000000000000..4839fc7d9192 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs @@ -0,0 +1,35 @@ +// Newly accepted examples as a result of the changes introduced in #138961. +// +//@ edition:2024 +//@ check-pass +#![allow(unused_assignments)] + +fn f() { + let mut x: &mut [u8] = &mut [1, 2, 3]; + let c = || { + match x { + [] => (), + _ => (), + } + }; + x = &mut []; + c(); +} + +fn g() { + let mut x: &mut bool = &mut false; + let mut t = true; + let c = || { + match x { + true => (), + false => (), + } + }; + x = &mut t; + c(); +} + +fn main() { + f(); + g(); +} From 2443fba3a2af1f4474ba76f5a10627157fe59f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 19 Oct 2025 00:49:56 +0200 Subject: [PATCH 259/489] Rewrite the comment on is_multivariant_adt As Nadrieril remarked, the previous comment was misleadingly framed. --- compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 93304d794bc2..12c4dd203203 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -1855,9 +1855,14 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx /// builder code does a more specific check, filtering out variants that /// happen to be uninhabited. /// - /// Here, we cannot perform such an accurate checks, because querying - /// whether a type is inhabited requires that it has been fully inferred, - /// which cannot be guaranteed at this point. + /// Here, it is not practical to perform such a check, because inhabitedness + /// queries require typeck results, and typeck requires closure capture analysis. + /// + /// Moreover, the language is moving towards uninhabited variants still semantically + /// causing a discriminant read, so we *shouldn't* perform any such check. + /// + /// FIXME(never_patterns): update this comment once the aforementioned MIR builder + /// code is changed to be insensitive to inhhabitedness. #[instrument(skip(self, span), level = "debug")] fn is_multivariant_adt(&self, ty: Ty<'tcx>, span: Span) -> bool { if let ty::Adt(def, _) = self.cx.structurally_resolve_type(span, ty).kind() { From ae19274fb290396849c12e2b059dfbe4170964ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 19 Oct 2025 16:13:50 +0200 Subject: [PATCH 260/489] Add more variations from the PR thread --- .../deref-mut-in-pattern.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs b/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs index 4839fc7d9192..b2c0eac9efa2 100644 --- a/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs +++ b/tests/ui/closures/2229_closure_analysis/deref-mut-in-pattern.rs @@ -4,6 +4,7 @@ //@ check-pass #![allow(unused_assignments)] +// Reading the length as part of a pattern captures the pointee. fn f() { let mut x: &mut [u8] = &mut [1, 2, 3]; let c = || { @@ -16,6 +17,7 @@ fn f() { c(); } +// Plain old deref as part of pattern behaves similarly fn g() { let mut x: &mut bool = &mut false; let mut t = true; @@ -29,6 +31,23 @@ fn g() { c(); } +// Like f, but the lifetime implications are expressed in terms of +// returning a closure. +fn f2<'l: 's, 's>(x: &'s mut &'l [u8]) -> impl Fn() + 'l { + || match *x { + &[] => (), + _ => (), + } +} + +// Related testcase that was already accepted before +fn f3<'l: 's, 's>(x: &'s mut &'l [u8]) -> impl Fn() + 'l { + || match **x { + [] => (), + _ => (), + } +} + fn main() { f(); g(); From 9e98885a97094766293fbd0d5a0737d6e95f3b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Fri, 14 Nov 2025 23:53:46 +0100 Subject: [PATCH 261/489] re-bless miri tests --- src/tools/miri/tests/fail/closures/deref-in-pattern.stderr | 2 -- src/tools/miri/tests/fail/closures/partial-pattern.stderr | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr index ccdfad577315..1264f4e3fb95 100644 --- a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr +++ b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr @@ -11,8 +11,6 @@ LL | | }; | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at tests/fail/closures/deref-in-pattern.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/closures/partial-pattern.stderr b/src/tools/miri/tests/fail/closures/partial-pattern.stderr index f26d6ffed54b..5b7ee35ecc73 100644 --- a/src/tools/miri/tests/fail/closures/partial-pattern.stderr +++ b/src/tools/miri/tests/fail/closures/partial-pattern.stderr @@ -11,8 +11,6 @@ LL | | }; | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at tests/fail/closures/partial-pattern.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace From de65837b5bda534a332041e9b1ae4bb0d779e968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Fri, 14 Nov 2025 23:53:58 +0100 Subject: [PATCH 262/489] `search_is_some`: move to nursery See clippy issue 16086 for context --- .../clippy/clippy_lints/src/methods/mod.rs | 2 +- src/tools/clippy/tests/ui/crashes/ice-9041.rs | 1 + .../clippy/tests/ui/crashes/ice-9041.stderr | 2 +- .../ui/search_is_some_fixable_some.fixed | 14 +++++---- .../tests/ui/search_is_some_fixable_some.rs | 7 +++-- .../ui/search_is_some_fixable_some.stderr | 29 +------------------ 6 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index 48842c8739c0..248a147cfd77 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -889,7 +889,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "pre 1.29.0"] pub SEARCH_IS_SOME, - complexity, + nursery, "using an iterator or string search followed by `is_some()` or `is_none()`, which is more succinctly expressed as a call to `any()` or `contains()` (with negation in case of `is_none()`)" } diff --git a/src/tools/clippy/tests/ui/crashes/ice-9041.rs b/src/tools/clippy/tests/ui/crashes/ice-9041.rs index 4b2a0f953114..fae3233ba2f5 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9041.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-9041.rs @@ -1,3 +1,4 @@ +#![warn(clippy::search_is_some)] pub struct Thing; //@no-rustfix pub fn has_thing(things: &[Thing]) -> bool { diff --git a/src/tools/clippy/tests/ui/crashes/ice-9041.stderr b/src/tools/clippy/tests/ui/crashes/ice-9041.stderr index dd9db71c5de8..256c8b833034 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9041.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9041.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> tests/ui/crashes/ice-9041.rs:5:19 + --> tests/ui/crashes/ice-9041.rs:6:19 | LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|p| is_thing_ready(&p))` diff --git a/src/tools/clippy/tests/ui/search_is_some_fixable_some.fixed b/src/tools/clippy/tests/ui/search_is_some_fixable_some.fixed index 1213fdcf6119..daae41c0c891 100644 --- a/src/tools/clippy/tests/ui/search_is_some_fixable_some.fixed +++ b/src/tools/clippy/tests/ui/search_is_some_fixable_some.fixed @@ -311,19 +311,23 @@ mod issue9120 { } } +// skip this test due to rust-lang/rust-clippy#16086 +/* #[allow(clippy::match_like_matches_macro)] fn issue15102() { let values = [None, Some(3)]; - let has_even = values.iter().any(|v| matches!(&v, Some(x) if x % 2 == 0)); - //~^ search_is_some + let has_even = values.iter().find(|v| matches!(v, Some(x) if x % 2 == 0)).is_some(); + ~^ search_is_some println!("{has_even}"); let has_even = values .iter() - .any(|v| match &v { - //~^ search_is_some + .find(|v| match v { + ~^ search_is_some Some(x) if x % 2 == 0 => true, _ => false, - }); + }) + .is_some(); println!("{has_even}"); } +*/ diff --git a/src/tools/clippy/tests/ui/search_is_some_fixable_some.rs b/src/tools/clippy/tests/ui/search_is_some_fixable_some.rs index 4294a39333f2..ead101a491a6 100644 --- a/src/tools/clippy/tests/ui/search_is_some_fixable_some.rs +++ b/src/tools/clippy/tests/ui/search_is_some_fixable_some.rs @@ -322,20 +322,23 @@ mod issue9120 { } } +// skip this test due to rust-lang/rust-clippy#16086 +/* #[allow(clippy::match_like_matches_macro)] fn issue15102() { let values = [None, Some(3)]; let has_even = values.iter().find(|v| matches!(v, Some(x) if x % 2 == 0)).is_some(); - //~^ search_is_some + ~^ search_is_some println!("{has_even}"); let has_even = values .iter() .find(|v| match v { - //~^ search_is_some + ~^ search_is_some Some(x) if x % 2 == 0 => true, _ => false, }) .is_some(); println!("{has_even}"); } +*/ diff --git a/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr b/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr index cee1eb08876b..c56fe859aac0 100644 --- a/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr +++ b/src/tools/clippy/tests/ui/search_is_some_fixable_some.stderr @@ -346,32 +346,5 @@ error: called `is_some()` after searching an `Iterator` with `find` LL | let _ = v.iter().find(|x: &&u32| (*arg_no_deref_dyn)(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| (*arg_no_deref_dyn)(&x))` -error: called `is_some()` after searching an `Iterator` with `find` - --> tests/ui/search_is_some_fixable_some.rs:328:34 - | -LL | let has_even = values.iter().find(|v| matches!(v, Some(x) if x % 2 == 0)).is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| matches!(&v, Some(x) if x % 2 == 0))` - -error: called `is_some()` after searching an `Iterator` with `find` - --> tests/ui/search_is_some_fixable_some.rs:334:10 - | -LL | .find(|v| match v { - | __________^ -LL | | -LL | | Some(x) if x % 2 == 0 => true, -LL | | _ => false, -LL | | }) -LL | | .is_some(); - | |__________________^ - | -help: consider using - | -LL ~ .any(|v| match &v { -LL + -LL + Some(x) if x % 2 == 0 => true, -LL + _ => false, -LL ~ }); - | - -error: aborting due to 51 previous errors +error: aborting due to 49 previous errors From 55bbe0531a2d2f58daec7feb525b3eaa13063b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Fri, 12 Dec 2025 20:23:34 +0100 Subject: [PATCH 263/489] Re-bless tests --- tests/ui/closures/malformed-pattern-issue-140011.stderr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/closures/malformed-pattern-issue-140011.stderr b/tests/ui/closures/malformed-pattern-issue-140011.stderr index 08122b8a7d2e..43beb7c58632 100644 --- a/tests/ui/closures/malformed-pattern-issue-140011.stderr +++ b/tests/ui/closures/malformed-pattern-issue-140011.stderr @@ -1,4 +1,4 @@ -error[E0412]: cannot find type `D` in this scope +error[E0425]: cannot find type `D` in this scope --> $DIR/malformed-pattern-issue-140011.rs:3:7 | LL | C(D), @@ -25,12 +25,12 @@ LL | enum B { LL | C(D), | - not covered = note: the matched value is of type `B` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let B::E(a) = h else { todo!() }; | ++++++++++++++++ error: aborting due to 2 previous errors -Some errors have detailed explanations: E0005, E0412. +Some errors have detailed explanations: E0005, E0425. For more information about an error, try `rustc --explain E0005`. From cc2c59efa8777f2b8576a4e1316845d19fddd1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Fri, 14 Nov 2025 23:53:58 +0100 Subject: [PATCH 264/489] `search_is_some`: move to nursery See clippy issue 16086 for context --- clippy_lints/src/methods/mod.rs | 2 +- tests/ui/crashes/ice-9041.rs | 1 + tests/ui/crashes/ice-9041.stderr | 2 +- tests/ui/search_is_some_fixable_some.fixed | 14 ++++++---- tests/ui/search_is_some_fixable_some.rs | 7 +++-- tests/ui/search_is_some_fixable_some.stderr | 29 +-------------------- 6 files changed, 18 insertions(+), 37 deletions(-) diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 48842c8739c0..248a147cfd77 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -889,7 +889,7 @@ declare_clippy_lint! { /// ``` #[clippy::version = "pre 1.29.0"] pub SEARCH_IS_SOME, - complexity, + nursery, "using an iterator or string search followed by `is_some()` or `is_none()`, which is more succinctly expressed as a call to `any()` or `contains()` (with negation in case of `is_none()`)" } diff --git a/tests/ui/crashes/ice-9041.rs b/tests/ui/crashes/ice-9041.rs index 4b2a0f953114..fae3233ba2f5 100644 --- a/tests/ui/crashes/ice-9041.rs +++ b/tests/ui/crashes/ice-9041.rs @@ -1,3 +1,4 @@ +#![warn(clippy::search_is_some)] pub struct Thing; //@no-rustfix pub fn has_thing(things: &[Thing]) -> bool { diff --git a/tests/ui/crashes/ice-9041.stderr b/tests/ui/crashes/ice-9041.stderr index dd9db71c5de8..256c8b833034 100644 --- a/tests/ui/crashes/ice-9041.stderr +++ b/tests/ui/crashes/ice-9041.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> tests/ui/crashes/ice-9041.rs:5:19 + --> tests/ui/crashes/ice-9041.rs:6:19 | LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|p| is_thing_ready(&p))` diff --git a/tests/ui/search_is_some_fixable_some.fixed b/tests/ui/search_is_some_fixable_some.fixed index 1213fdcf6119..daae41c0c891 100644 --- a/tests/ui/search_is_some_fixable_some.fixed +++ b/tests/ui/search_is_some_fixable_some.fixed @@ -311,19 +311,23 @@ mod issue9120 { } } +// skip this test due to rust-lang/rust-clippy#16086 +/* #[allow(clippy::match_like_matches_macro)] fn issue15102() { let values = [None, Some(3)]; - let has_even = values.iter().any(|v| matches!(&v, Some(x) if x % 2 == 0)); - //~^ search_is_some + let has_even = values.iter().find(|v| matches!(v, Some(x) if x % 2 == 0)).is_some(); + ~^ search_is_some println!("{has_even}"); let has_even = values .iter() - .any(|v| match &v { - //~^ search_is_some + .find(|v| match v { + ~^ search_is_some Some(x) if x % 2 == 0 => true, _ => false, - }); + }) + .is_some(); println!("{has_even}"); } +*/ diff --git a/tests/ui/search_is_some_fixable_some.rs b/tests/ui/search_is_some_fixable_some.rs index 4294a39333f2..ead101a491a6 100644 --- a/tests/ui/search_is_some_fixable_some.rs +++ b/tests/ui/search_is_some_fixable_some.rs @@ -322,20 +322,23 @@ mod issue9120 { } } +// skip this test due to rust-lang/rust-clippy#16086 +/* #[allow(clippy::match_like_matches_macro)] fn issue15102() { let values = [None, Some(3)]; let has_even = values.iter().find(|v| matches!(v, Some(x) if x % 2 == 0)).is_some(); - //~^ search_is_some + ~^ search_is_some println!("{has_even}"); let has_even = values .iter() .find(|v| match v { - //~^ search_is_some + ~^ search_is_some Some(x) if x % 2 == 0 => true, _ => false, }) .is_some(); println!("{has_even}"); } +*/ diff --git a/tests/ui/search_is_some_fixable_some.stderr b/tests/ui/search_is_some_fixable_some.stderr index cee1eb08876b..c56fe859aac0 100644 --- a/tests/ui/search_is_some_fixable_some.stderr +++ b/tests/ui/search_is_some_fixable_some.stderr @@ -346,32 +346,5 @@ error: called `is_some()` after searching an `Iterator` with `find` LL | let _ = v.iter().find(|x: &&u32| (*arg_no_deref_dyn)(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| (*arg_no_deref_dyn)(&x))` -error: called `is_some()` after searching an `Iterator` with `find` - --> tests/ui/search_is_some_fixable_some.rs:328:34 - | -LL | let has_even = values.iter().find(|v| matches!(v, Some(x) if x % 2 == 0)).is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| matches!(&v, Some(x) if x % 2 == 0))` - -error: called `is_some()` after searching an `Iterator` with `find` - --> tests/ui/search_is_some_fixable_some.rs:334:10 - | -LL | .find(|v| match v { - | __________^ -LL | | -LL | | Some(x) if x % 2 == 0 => true, -LL | | _ => false, -LL | | }) -LL | | .is_some(); - | |__________________^ - | -help: consider using - | -LL ~ .any(|v| match &v { -LL + -LL + Some(x) if x % 2 == 0 => true, -LL + _ => false, -LL ~ }); - | - -error: aborting due to 51 previous errors +error: aborting due to 49 previous errors From 78f52c1d127858c6d50751cd62876982b6708945 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 17 Dec 2025 20:16:02 +0000 Subject: [PATCH 265/489] Update tracking issue for PinCoerceUnsized --- library/alloc/src/boxed.rs | 2 +- library/alloc/src/rc.rs | 6 +++--- library/alloc/src/sync.rs | 6 +++--- library/core/src/cell.rs | 12 ++++++------ library/core/src/pin.rs | 2 +- library/core/src/ptr/unique.rs | 2 +- library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index f714a87c1868..60758551cc04 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2253,7 +2253,7 @@ impl + ?Sized, A: Allocator> AsyncFn for Box #[unstable(feature = "coerce_unsized", issue = "18598")] impl, U: ?Sized, A: Allocator> CoerceUnsized> for Box {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Box {} // It is quite crucial that we only allow the `Global` allocator here. diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index a3ebbbbaae05..8a72748668cc 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2417,14 +2417,14 @@ impl Deref for Rc { } } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Rc {} //#[unstable(feature = "unique_rc_arc", issue = "112566")] -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UniqueRc {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Weak {} #[unstable(feature = "deref_pure_trait", issue = "87121")] diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 6a49017a8276..4180fe91cb55 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2423,10 +2423,10 @@ impl Deref for Arc { } } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Arc {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Weak {} #[unstable(feature = "deref_pure_trait", issue = "87121")] @@ -4852,7 +4852,7 @@ impl Deref for UniqueArc { } // #[unstable(feature = "unique_rc_arc", issue = "112566")] -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UniqueArc {} #[unstable(feature = "unique_rc_arc", issue = "112566")] diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index c8340c328be1..9a3f7166f1fc 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -2696,20 +2696,20 @@ fn assert_coerce_unsized( let _: RefCell<&dyn Send> = d; } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UnsafeCell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for SyncUnsafeCell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Cell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for RefCell {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl<'b, T: ?Sized> PinCoerceUnsized for Ref<'b, T> {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl<'b, T: ?Sized> PinCoerceUnsized for RefMut<'b, T> {} diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 81c2dabf0d1d..74ecb5ee4946 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1825,7 +1825,7 @@ where { } -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] /// Trait that indicates that this is a pointer or a wrapper for one, where /// unsizing can be performed on the pointee when it is pinned. /// diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs index 1bbe3ea242f6..3160c9de4b7e 100644 --- a/library/core/src/ptr/unique.rs +++ b/library/core/src/ptr/unique.rs @@ -176,7 +176,7 @@ impl CoerceUnsized> for Unique wh #[unstable(feature = "ptr_internals", issue = "none")] impl DispatchFromDyn> for Unique where T: Unsize {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for Unique {} #[unstable(feature = "ptr_internals", issue = "none")] diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index fb410c285160..aaf380d1bef4 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -773,7 +773,7 @@ where #[unstable(feature = "sgx_platform", issue = "56975")] impl, U> CoerceUnsized> for UserRef {} -#[unstable(feature = "pin_coerce_unsized_trait", issue = "123430")] +#[unstable(feature = "pin_coerce_unsized_trait", issue = "150112")] unsafe impl PinCoerceUnsized for UserRef {} #[unstable(feature = "sgx_platform", issue = "56975")] From d28e41b981651e95d60ed95b66c78c4ebdce20eb Mon Sep 17 00:00:00 2001 From: Niko Kajula Date: Wed, 17 Dec 2025 22:41:21 +0200 Subject: [PATCH 266/489] Fix broken AMD Developer's Manual links --- library/stdarch/crates/core_arch/src/x86/abm.rs | 2 +- library/stdarch/crates/core_arch/src/x86/avx.rs | 2 +- library/stdarch/crates/core_arch/src/x86/avx2.rs | 2 +- library/stdarch/crates/core_arch/src/x86/cpuid.rs | 2 +- library/stdarch/crates/core_arch/src/x86/fma.rs | 2 +- library/stdarch/crates/core_arch/src/x86/tbm.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/abm.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/avx.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/tbm.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/abm.rs b/library/stdarch/crates/core_arch/src/x86/abm.rs index 59f3877b4ace..7f46e1a8d06e 100644 --- a/library/stdarch/crates/core_arch/src/x86/abm.rs +++ b/library/stdarch/crates/core_arch/src/x86/abm.rs @@ -13,7 +13,7 @@ //! available. //! //! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 diff --git a/library/stdarch/crates/core_arch/src/x86/avx.rs b/library/stdarch/crates/core_arch/src/x86/avx.rs index acba0a3db7c6..bda0b8ac5047 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx.rs @@ -10,7 +10,7 @@ //! [Wikipedia][wiki] provides a quick overview of the instructions available. //! //! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions use crate::{ diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index b3b2accd7338..e7fd19fa2e97 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -14,7 +14,7 @@ //! overview of the instructions available. //! //! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki_avx]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions //! [wiki_fma]: https://en.wikipedia.org/wiki/Fused_multiply-accumulate diff --git a/library/stdarch/crates/core_arch/src/x86/cpuid.rs b/library/stdarch/crates/core_arch/src/x86/cpuid.rs index b35699bd7ab2..3f13ea8369bb 100644 --- a/library/stdarch/crates/core_arch/src/x86/cpuid.rs +++ b/library/stdarch/crates/core_arch/src/x86/cpuid.rs @@ -54,7 +54,7 @@ pub struct CpuidResult { /// /// [wiki_cpuid]: https://en.wikipedia.org/wiki/CPUID /// [intel64_ref]: https://cdrdv2-public.intel.com/671110/325383-sdm-vol-2abcd.pdf -/// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +/// [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 #[inline] #[cfg_attr(test, assert_instr(cpuid))] #[stable(feature = "simd_x86", since = "1.27.0")] diff --git a/library/stdarch/crates/core_arch/src/x86/fma.rs b/library/stdarch/crates/core_arch/src/x86/fma.rs index abf79f4904fe..a8439935660f 100644 --- a/library/stdarch/crates/core_arch/src/x86/fma.rs +++ b/library/stdarch/crates/core_arch/src/x86/fma.rs @@ -15,7 +15,7 @@ //! instructions available. //! //! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki_fma]: https://en.wikipedia.org/wiki/Fused_multiply-accumulate use crate::core_arch::x86::*; diff --git a/library/stdarch/crates/core_arch/src/x86/tbm.rs b/library/stdarch/crates/core_arch/src/x86/tbm.rs index d7769b916d4f..1e863fe15c0b 100644 --- a/library/stdarch/crates/core_arch/src/x86/tbm.rs +++ b/library/stdarch/crates/core_arch/src/x86/tbm.rs @@ -6,7 +6,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the available //! instructions. //! -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 diff --git a/library/stdarch/crates/core_arch/src/x86_64/abm.rs b/library/stdarch/crates/core_arch/src/x86_64/abm.rs index 63e422864d3b..2b63cb5dc763 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/abm.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/abm.rs @@ -13,7 +13,7 @@ //! available. //! //! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 diff --git a/library/stdarch/crates/core_arch/src/x86_64/avx.rs b/library/stdarch/crates/core_arch/src/x86_64/avx.rs index bb8d25620714..80ef7fbd60a6 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/avx.rs @@ -10,7 +10,7 @@ //! [Wikipedia][wiki] provides a quick overview of the instructions available. //! //! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions use crate::{core_arch::x86::*, mem::transmute}; diff --git a/library/stdarch/crates/core_arch/src/x86_64/tbm.rs b/library/stdarch/crates/core_arch/src/x86_64/tbm.rs index e7d4b8d3e4c9..031bd320713e 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/tbm.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/tbm.rs @@ -6,7 +6,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the available //! instructions. //! -//! [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf +//! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 From 011c5ed7ba0d20dec130609abafa7537d5ea199e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Wed, 17 Dec 2025 22:11:55 +0100 Subject: [PATCH 267/489] Skip rust-analyzer closure layout tests for now --- .../crates/hir-ty/src/layout/tests/closure.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests/closure.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests/closure.rs index 6c76c6fed062..9e761aa98ff8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests/closure.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests/closure.rs @@ -166,6 +166,9 @@ fn capture_specific_fields() { *a + x + (*b as i64) } } + // FIXME: These tests currently fail, because rust-analyzer hasn't yet implemented the changes + // introduced in rust-lang/rust#138961. See rust-lang/rust-analyzer#21274 for more discussion. + /* size_and_align_expr! { struct X(i64, i32, (u8, i128)); let y: X = X(2, 5, (7, 3)); @@ -183,6 +186,7 @@ fn capture_specific_fields() { a + x + (b as i64) } } + */ } #[test] @@ -194,6 +198,9 @@ fn match_pattern() { x } } + // FIXME: These tests currently fail, because rust-analyzer hasn't yet implemented the changes + // introduced in rust-lang/rust#138961. See rust-lang/rust-analyzer#21274 for more discussion. + /* size_and_align_expr! { minicore: copy; stmts: [ @@ -206,6 +213,7 @@ fn match_pattern() { } } } + */ size_and_align_expr! { minicore: copy; stmts: [ From 4ea5cac7d492e6b95e251b8a1f63a068186d74d7 Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Wed, 29 Oct 2025 19:25:22 +0100 Subject: [PATCH 268/489] add `MaybeDangling` to `core` Co-authored-by: Ralf Jung --- library/core/src/mem/maybe_dangling.rs | 113 +++++++++++++++++++++++++ library/core/src/mem/mod.rs | 4 + 2 files changed, 117 insertions(+) create mode 100644 library/core/src/mem/maybe_dangling.rs diff --git a/library/core/src/mem/maybe_dangling.rs b/library/core/src/mem/maybe_dangling.rs new file mode 100644 index 000000000000..3a8af8cc7bd8 --- /dev/null +++ b/library/core/src/mem/maybe_dangling.rs @@ -0,0 +1,113 @@ +#![unstable(feature = "maybe_dangling", issue = "118166")] + +use crate::{mem, ptr}; + +/// Allows wrapped [references] and [boxes] to dangle. +/// +///
+/// This type is not properly implemented yet, and the documentation below is thus not accurate. +///
+/// +/// That is, if a reference (or a `Box`) is wrapped in `MaybeDangling` (including when in a +/// (nested) field of a compound type wrapped in `MaybeDangling`), it does not have to follow +/// pointer aliasing rules or be dereferenceable. +/// +/// This can be useful when the value can become dangling while the function holding it is still +/// executing (particularly in concurrent code). As a somewhat absurd example, consider this code: +/// +/// ```rust,no_run +/// #![feature(box_as_ptr)] +/// # use std::alloc::{dealloc, Layout}; +/// # use std::mem; +/// +/// let mut boxed = Box::new(0_u32); +/// let ptr = Box::as_mut_ptr(&mut boxed); +/// +/// // Safety: the pointer comes from a box and thus was allocated before; `box` is not used afterwards +/// unsafe { dealloc(ptr.cast(), Layout::new::()) }; +/// +/// mem::forget(boxed); // <-- this is UB! +/// ``` +/// +/// Even though the `Box`e's destructor is not run (and thus we don't have a double free bug), this +/// code is still UB. This is because when moving `boxed` into `forget`, its validity invariants +/// are asserted, causing UB since the `Box` is dangling. The safety comment is as such wrong, as +/// moving the `boxed` variable as part of the `forget` call *is* a use. +/// +/// To fix this we could use `MaybeDangling`: +/// +/// ```rust +/// #![feature(maybe_dangling, box_as_ptr)] +/// # use std::alloc::{dealloc, Layout}; +/// # use std::mem::{self, MaybeDangling}; +/// +/// let mut boxed = MaybeDangling::new(Box::new(0_u32)); +/// let ptr = Box::as_mut_ptr(boxed.as_mut()); +/// +/// // Safety: the pointer comes from a box and thus was allocated before; `box` is not used afterwards +/// unsafe { dealloc(ptr.cast(), Layout::new::()) }; +/// +/// mem::forget(boxed); // <-- this is OK! +/// ``` +/// +/// Note that the bit pattern must still be valid for the wrapped type. That is, [references] +/// (and [boxes]) still must be aligned and non-null. +/// +/// Additionally note that safe code can still assume that the inner value in a `MaybeDangling` is +/// **not** dangling -- functions like [`as_ref`] and [`into_inner`] are safe. It is not sound to +/// return a dangling reference in a `MaybeDangling` to safe code. However, it *is* sound +/// to hold such values internally inside your code -- and there's no way to do that without +/// this type. Note that other types can use this type and thus get the same effect; in particular, +/// [`ManuallyDrop`] will use `MaybeDangling`. +/// +/// Note that `MaybeDangling` doesn't prevent drops from being run, which can lead to UB if the +/// drop observes a dangling value. If you need to prevent drops from being run use [`ManuallyDrop`] +/// instead. +/// +/// [references]: prim@reference +/// [boxes]: ../../std/boxed/struct.Box.html +/// [`into_inner`]: MaybeDangling::into_inner +/// [`as_ref`]: MaybeDangling::as_ref +/// [`ManuallyDrop`]: crate::mem::ManuallyDrop +#[repr(transparent)] +#[rustc_pub_transparent] +#[derive(Debug, Copy, Clone, Default)] +pub struct MaybeDangling(P); + +impl MaybeDangling

{ + /// Wraps a value in a `MaybeDangling`, allowing it to dangle. + pub const fn new(x: P) -> Self + where + P: Sized, + { + MaybeDangling(x) + } + + /// Returns a reference to the inner value. + /// + /// Note that this is UB if the inner value is currently dangling. + pub const fn as_ref(&self) -> &P { + &self.0 + } + + /// Returns a mutable reference to the inner value. + /// + /// Note that this is UB if the inner value is currently dangling. + pub const fn as_mut(&mut self) -> &mut P { + &mut self.0 + } + + /// Extracts the value from the `MaybeDangling` container. + /// + /// Note that this is UB if the inner value is currently dangling. + pub const fn into_inner(self) -> P + where + P: Sized, + { + // FIXME: replace this with `self.0` when const checker can figure out that `self` isn't actually dropped + // SAFETY: this is equivalent to `self.0` + let x = unsafe { ptr::read(&self.0) }; + mem::forget(self); + x + } +} diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index ad5fda0cfe4d..4f7edce1e977 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -19,6 +19,10 @@ mod maybe_uninit; #[stable(feature = "maybe_uninit", since = "1.36.0")] pub use maybe_uninit::MaybeUninit; +mod maybe_dangling; +#[unstable(feature = "maybe_dangling", issue = "118166")] +pub use maybe_dangling::MaybeDangling; + mod transmutability; #[unstable(feature = "transmutability", issue = "99571")] pub use transmutability::{Assume, TransmuteFrom}; From 722e3102a22c529bade40c61f63bb3d88845360a Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Wed, 29 Oct 2025 19:26:26 +0100 Subject: [PATCH 269/489] use `MaybeDangling` in `ManuallyDrop` --- library/core/src/mem/manually_drop.rs | 55 ++++++++++++++++--- .../future-sizes/async-awaiting-fut.stdout | 8 +++ .../async-await/future-sizes/large-arg.stdout | 6 ++ tests/ui/print_type_sizes/async.stdout | 4 ++ .../coroutine_discr_placement.stdout | 2 + tests/ui/thir-print/offset_of.stdout | 18 +++--- 6 files changed, 75 insertions(+), 18 deletions(-) diff --git a/library/core/src/mem/manually_drop.rs b/library/core/src/mem/manually_drop.rs index 7d49da850957..74f917bcf1cc 100644 --- a/library/core/src/mem/manually_drop.rs +++ b/library/core/src/mem/manually_drop.rs @@ -1,4 +1,7 @@ -use crate::marker::Destruct; +use crate::cmp::Ordering; +use crate::hash::{Hash, Hasher}; +use crate::marker::{Destruct, StructuralPartialEq}; +use crate::mem::MaybeDangling; use crate::ops::{Deref, DerefMut, DerefPure}; use crate::ptr; @@ -152,11 +155,11 @@ use crate::ptr; /// [`MaybeUninit`]: crate::mem::MaybeUninit #[stable(feature = "manually_drop", since = "1.20.0")] #[lang = "manually_drop"] -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, Default)] #[repr(transparent)] #[rustc_pub_transparent] pub struct ManuallyDrop { - value: T, + value: MaybeDangling, } impl ManuallyDrop { @@ -179,7 +182,7 @@ impl ManuallyDrop { #[rustc_const_stable(feature = "const_manually_drop", since = "1.32.0")] #[inline(always)] pub const fn new(value: T) -> ManuallyDrop { - ManuallyDrop { value } + ManuallyDrop { value: MaybeDangling::new(value) } } /// Extracts the value from the `ManuallyDrop` container. @@ -197,7 +200,7 @@ impl ManuallyDrop { #[rustc_const_stable(feature = "const_manually_drop", since = "1.32.0")] #[inline(always)] pub const fn into_inner(slot: ManuallyDrop) -> T { - slot.value + slot.value.into_inner() } /// Takes the value from the `ManuallyDrop` container out. @@ -222,7 +225,7 @@ impl ManuallyDrop { pub const unsafe fn take(slot: &mut ManuallyDrop) -> T { // SAFETY: we are reading from a reference, which is guaranteed // to be valid for reads. - unsafe { ptr::read(&slot.value) } + unsafe { ptr::read(slot.value.as_ref()) } } } @@ -259,7 +262,7 @@ impl ManuallyDrop { // SAFETY: we are dropping the value pointed to by a mutable reference // which is guaranteed to be valid for writes. // It is up to the caller to make sure that `slot` isn't dropped again. - unsafe { ptr::drop_in_place(&mut slot.value) } + unsafe { ptr::drop_in_place(slot.value.as_mut()) } } } @@ -269,7 +272,7 @@ impl const Deref for ManuallyDrop { type Target = T; #[inline(always)] fn deref(&self) -> &T { - &self.value + self.value.as_ref() } } @@ -278,9 +281,43 @@ impl const Deref for ManuallyDrop { impl const DerefMut for ManuallyDrop { #[inline(always)] fn deref_mut(&mut self) -> &mut T { - &mut self.value + self.value.as_mut() } } #[unstable(feature = "deref_pure_trait", issue = "87121")] unsafe impl DerefPure for ManuallyDrop {} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl Eq for ManuallyDrop {} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl PartialEq for ManuallyDrop { + fn eq(&self, other: &Self) -> bool { + self.value.as_ref().eq(other.value.as_ref()) + } +} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl StructuralPartialEq for ManuallyDrop {} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl Ord for ManuallyDrop { + fn cmp(&self, other: &Self) -> Ordering { + self.value.as_ref().cmp(other.value.as_ref()) + } +} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl PartialOrd for ManuallyDrop { + fn partial_cmp(&self, other: &Self) -> Option { + self.value.as_ref().partial_cmp(other.value.as_ref()) + } +} + +#[stable(feature = "manually_drop", since = "1.20.0")] +impl Hash for ManuallyDrop { + fn hash(&self, state: &mut H) { + self.value.as_ref().hash(state); + } +} diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index b30c15bcbe6e..13f03ffa65b5 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -7,6 +7,8 @@ print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3077 bytes, alignment: 1 bytes print-type-size field `.value`: 3077 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3077 bytes, alignment: 1 bytes +print-type-size field `.0`: 3077 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 3077 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 3077 bytes print-type-size field `.uninit`: 0 bytes @@ -36,6 +38,8 @@ print-type-size variant `Panicked`: 1025 bytes print-type-size upvar `.fut`: 1025 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of big_fut()}>`: 1025 bytes, alignment: 1 bytes print-type-size field `.value`: 1025 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of big_fut()}>`: 1025 bytes, alignment: 1 bytes +print-type-size field `.0`: 1025 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of big_fut()}>`: 1025 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1025 bytes print-type-size field `.uninit`: 0 bytes @@ -85,6 +89,10 @@ print-type-size type: `std::mem::ManuallyDrop`: 1 bytes, alignment: 1 byte print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes +print-type-size type: `std::mem::MaybeDangling`: 1 bytes, alignment: 1 bytes +print-type-size field `.0`: 1 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes +print-type-size field `.0`: 1 bytes print-type-size type: `std::mem::MaybeUninit`: 1 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1 bytes print-type-size field `.uninit`: 0 bytes diff --git a/tests/ui/async-await/future-sizes/large-arg.stdout b/tests/ui/async-await/future-sizes/large-arg.stdout index e00420d1493f..d51afa33595c 100644 --- a/tests/ui/async-await/future-sizes/large-arg.stdout +++ b/tests/ui/async-await/future-sizes/large-arg.stdout @@ -7,6 +7,8 @@ print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of a<[u8; 1024]>()}>`: 3075 bytes, alignment: 1 bytes print-type-size field `.value`: 3075 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of a<[u8; 1024]>()}>`: 3075 bytes, alignment: 1 bytes +print-type-size field `.0`: 3075 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of a<[u8; 1024]>()}>`: 3075 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 3075 bytes print-type-size field `.uninit`: 0 bytes @@ -24,6 +26,8 @@ print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.t`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of b<[u8; 1024]>()}>`: 2050 bytes, alignment: 1 bytes print-type-size field `.value`: 2050 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of b<[u8; 1024]>()}>`: 2050 bytes, alignment: 1 bytes +print-type-size field `.0`: 2050 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of b<[u8; 1024]>()}>`: 2050 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 2050 bytes print-type-size field `.uninit`: 0 bytes @@ -41,6 +45,8 @@ print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.t`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of c<[u8; 1024]>()}>`: 1025 bytes, alignment: 1 bytes print-type-size field `.value`: 1025 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of c<[u8; 1024]>()}>`: 1025 bytes, alignment: 1 bytes +print-type-size field `.0`: 1025 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of c<[u8; 1024]>()}>`: 1025 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1025 bytes print-type-size field `.uninit`: 0 bytes diff --git a/tests/ui/print_type_sizes/async.stdout b/tests/ui/print_type_sizes/async.stdout index d3d6b6471c6e..d2adff80e3c9 100644 --- a/tests/ui/print_type_sizes/async.stdout +++ b/tests/ui/print_type_sizes/async.stdout @@ -12,6 +12,8 @@ print-type-size variant `Panicked`: 8192 bytes print-type-size upvar `.arg`: 8192 bytes print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes print-type-size field `.value`: 8192 bytes +print-type-size type: `std::mem::MaybeDangling<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes +print-type-size field `.0`: 8192 bytes print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 8192 bytes print-type-size field `.uninit`: 0 bytes @@ -47,6 +49,8 @@ print-type-size type: `std::ptr::NonNull`: 8 bytes, print-type-size field `.pointer`: 8 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes +print-type-size type: `std::mem::MaybeDangling<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes +print-type-size field `.0`: 1 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1 bytes print-type-size field `.uninit`: 0 bytes diff --git a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout index 4ce1ce46f6e8..b51beb514ba8 100644 --- a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout @@ -11,6 +11,8 @@ print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes print-type-size type: `std::mem::ManuallyDrop`: 4 bytes, alignment: 4 bytes print-type-size field `.value`: 4 bytes +print-type-size type: `std::mem::MaybeDangling`: 4 bytes, alignment: 4 bytes +print-type-size field `.0`: 4 bytes print-type-size type: `std::mem::MaybeUninit`: 4 bytes, alignment: 4 bytes print-type-size variant `MaybeUninit`: 4 bytes print-type-size field `.uninit`: 0 bytes diff --git a/tests/ui/thir-print/offset_of.stdout b/tests/ui/thir-print/offset_of.stdout index 846817f47528..ab924091ba7a 100644 --- a/tests/ui/thir-print/offset_of.stdout +++ b/tests/ui/thir-print/offset_of.stdout @@ -68,7 +68,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).10)) - span: $DIR/offset_of.rs:37:5: 1433:57 (#0) + span: $DIR/offset_of.rs:37:5: 1437:57 (#0) } } Stmt { @@ -117,7 +117,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).20)) - span: $DIR/offset_of.rs:38:5: 1433:57 (#0) + span: $DIR/offset_of.rs:38:5: 1437:57 (#0) } } Stmt { @@ -166,7 +166,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).30)) - span: $DIR/offset_of.rs:39:5: 1433:57 (#0) + span: $DIR/offset_of.rs:39:5: 1437:57 (#0) } } Stmt { @@ -215,7 +215,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).40)) - span: $DIR/offset_of.rs:40:5: 1433:57 (#0) + span: $DIR/offset_of.rs:40:5: 1437:57 (#0) } } Stmt { @@ -264,7 +264,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).50)) - span: $DIR/offset_of.rs:41:5: 1433:57 (#0) + span: $DIR/offset_of.rs:41:5: 1437:57 (#0) } } ] @@ -864,7 +864,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).12)) - span: $DIR/offset_of.rs:45:5: 1433:57 (#0) + span: $DIR/offset_of.rs:45:5: 1437:57 (#0) } } Stmt { @@ -913,7 +913,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).24)) - span: $DIR/offset_of.rs:46:5: 1433:57 (#0) + span: $DIR/offset_of.rs:46:5: 1437:57 (#0) } } Stmt { @@ -962,7 +962,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).36)) - span: $DIR/offset_of.rs:47:5: 1433:57 (#0) + span: $DIR/offset_of.rs:47:5: 1437:57 (#0) } } Stmt { @@ -1011,7 +1011,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).48)) - span: $DIR/offset_of.rs:48:5: 1433:57 (#0) + span: $DIR/offset_of.rs:48:5: 1437:57 (#0) } } ] From 64c1e97f32cacc482ccb35cfe20813169ef8f913 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:40:38 +0200 Subject: [PATCH 270/489] place it all in just 2 unit tests --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 49 ++++++-------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index c19f19541846..aa34fbbb53f2 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -196,6 +196,9 @@ some code. block sentence with *italics* should not be ignored. truly. git log main.. compiler foo. bar. baz +o? whatever +r? @reviewer + r? @reviewer "; let expected = " # some. heading @@ -221,6 +224,10 @@ git log main.. compiler foo. bar. baz +o? +whatever +r? @reviewer + r? @reviewer "; assert_eq!(expected, comply(original)); } @@ -247,6 +254,12 @@ do not mess with code block chars leave the text alone ``` + + handle the + indented well + +[a target]: https://example.com +[another target]: https://example.com "; let expected = "\ do not split short sentences @@ -267,43 +280,11 @@ do not mess with code block chars leave the text alone ``` -"; - assert_eq!(expected, lengthen_lines(original, 50)); -} -#[test] -fn test_prettify_prefix_spaces() { - let original = "\ - do not split - short sentences -"; - let expected = "\ - do not split short sentences -"; - assert_eq!(expected, lengthen_lines(original, 50)); -} + handle the indented well -#[test] -fn test_prettify_ignore_link_targets() { - let original = "\ [a target]: https://example.com [another target]: https://example.com "; - assert_eq!(original, lengthen_lines(original, 100)); -} - -#[test] -fn test_sembr_question_mark() { - let original = " -o? whatever -r? @reviewer - r? @reviewer -"; - let expected = " -o? -whatever -r? @reviewer - r? @reviewer -"; - assert_eq!(expected, comply(original)); + assert_eq!(expected, lengthen_lines(original, 50)); } From 82ee8b21cb66364792f4103616a2368847fb5421 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Fri, 12 Dec 2025 17:37:39 +0100 Subject: [PATCH 271/489] `cfg_select!`: emit parse errors in unused branches --- .../src/attributes/cfg_select.rs | 27 ++++++ .../rustc_builtin_macros/src/cfg_select.rs | 80 ++++++++++++++---- tests/ui/macros/cfg_select.rs | 83 +++++++++++++++++++ tests/ui/macros/cfg_select.stderr | 24 +++--- tests/ui/macros/cfg_select_parse_error.rs | 18 ++++ tests/ui/macros/cfg_select_parse_error.stderr | 26 ++++++ 6 files changed, 229 insertions(+), 29 deletions(-) create mode 100644 tests/ui/macros/cfg_select_parse_error.rs create mode 100644 tests/ui/macros/cfg_select_parse_error.stderr diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs index 0c0915558089..00a2d12106e7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs @@ -28,6 +28,33 @@ pub struct CfgSelectBranches { pub unreachable: Vec<(CfgSelectPredicate, TokenStream, Span)>, } +impl CfgSelectBranches { + /// Removes the top-most branch for which `predicate` returns `true`, + /// or the wildcard if none of the reachable branches satisfied the predicate. + pub fn pop_first_match(&mut self, predicate: F) -> Option<(TokenStream, Span)> + where + F: Fn(&CfgEntry) -> bool, + { + for (index, (cfg, _, _)) in self.reachable.iter().enumerate() { + if predicate(cfg) { + let matched = self.reachable.remove(index); + return Some((matched.1, matched.2)); + } + } + + self.wildcard.take().map(|(_, tts, span)| (tts, span)) + } + + /// Consume this value and iterate over all the `TokenStream`s that it stores. + pub fn into_iter_tts(self) -> impl Iterator { + let it1 = self.reachable.into_iter().map(|(_, tts, span)| (tts, span)); + let it2 = self.wildcard.into_iter().map(|(_, tts, span)| (tts, span)); + let it3 = self.unreachable.into_iter().map(|(_, tts, span)| (tts, span)); + + it1.chain(it2).chain(it3) + } +} + pub fn parse_cfg_select( p: &mut Parser<'_>, sess: &Session, diff --git a/compiler/rustc_builtin_macros/src/cfg_select.rs b/compiler/rustc_builtin_macros/src/cfg_select.rs index dc8077b2a1ff..f11190b28105 100644 --- a/compiler/rustc_builtin_macros/src/cfg_select.rs +++ b/compiler/rustc_builtin_macros/src/cfg_select.rs @@ -1,22 +1,65 @@ use rustc_ast::tokenstream::TokenStream; +use rustc_ast::{Expr, ast}; use rustc_attr_parsing as attr; use rustc_attr_parsing::{ CfgSelectBranches, CfgSelectPredicate, EvalConfigResult, parse_cfg_select, }; -use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; +use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult}; use rustc_span::{Ident, Span, sym}; +use smallvec::SmallVec; use crate::errors::{CfgSelectNoMatches, CfgSelectUnreachable}; -/// Selects the first arm whose predicate evaluates to true. -fn select_arm(ecx: &ExtCtxt<'_>, branches: CfgSelectBranches) -> Option<(TokenStream, Span)> { - for (cfg, tt, arm_span) in branches.reachable { - if let EvalConfigResult::True = attr::eval_config_entry(&ecx.sess, &cfg) { - return Some((tt, arm_span)); - } - } +/// This intermediate structure is used to emit parse errors for the branches that are not chosen. +/// The `MacResult` instance below parses all branches, emitting any errors it encounters, but only +/// keeps the parse result for the selected branch. +struct CfgSelectResult<'cx, 'sess> { + ecx: &'cx mut ExtCtxt<'sess>, + site_span: Span, + selected_tts: TokenStream, + selected_span: Span, + other_branches: CfgSelectBranches, +} - branches.wildcard.map(|(_, tt, span)| (tt, span)) +fn tts_to_mac_result<'cx, 'sess>( + ecx: &'cx mut ExtCtxt<'sess>, + site_span: Span, + tts: TokenStream, + span: Span, +) -> Box { + match ExpandResult::from_tts(ecx, tts, site_span, span, Ident::with_dummy_span(sym::cfg_select)) + { + ExpandResult::Ready(x) => x, + _ => unreachable!("from_tts always returns Ready"), + } +} + +macro_rules! forward_to_parser_any_macro { + ($method_name:ident, $ret_ty:ty) => { + fn $method_name(self: Box) -> Option<$ret_ty> { + let CfgSelectResult { ecx, site_span, selected_tts, selected_span, .. } = *self; + + for (tts, span) in self.other_branches.into_iter_tts() { + let _ = tts_to_mac_result(ecx, site_span, tts, span).$method_name(); + } + + tts_to_mac_result(ecx, site_span, selected_tts, selected_span).$method_name() + } + }; +} + +impl<'cx, 'sess> MacResult for CfgSelectResult<'cx, 'sess> { + forward_to_parser_any_macro!(make_expr, Box); + forward_to_parser_any_macro!(make_stmts, SmallVec<[ast::Stmt; 1]>); + forward_to_parser_any_macro!(make_items, SmallVec<[Box; 1]>); + + forward_to_parser_any_macro!(make_impl_items, SmallVec<[Box; 1]>); + forward_to_parser_any_macro!(make_trait_impl_items, SmallVec<[Box; 1]>); + forward_to_parser_any_macro!(make_trait_items, SmallVec<[Box; 1]>); + forward_to_parser_any_macro!(make_foreign_items, SmallVec<[Box; 1]>); + + forward_to_parser_any_macro!(make_ty, Box); + forward_to_parser_any_macro!(make_pat, Box); } pub(super) fn expand_cfg_select<'cx>( @@ -31,7 +74,7 @@ pub(super) fn expand_cfg_select<'cx>( Some(ecx.ecfg.features), ecx.current_expansion.lint_node_id, ) { - Ok(branches) => { + Ok(mut branches) => { if let Some((underscore, _, _)) = branches.wildcard { // Warn for every unreachable predicate. We store the fully parsed branch for rustfmt. for (predicate, _, _) in &branches.unreachable { @@ -44,14 +87,17 @@ pub(super) fn expand_cfg_select<'cx>( } } - if let Some((tts, arm_span)) = select_arm(ecx, branches) { - return ExpandResult::from_tts( + if let Some((selected_tts, selected_span)) = branches.pop_first_match(|cfg| { + matches!(attr::eval_config_entry(&ecx.sess, cfg), EvalConfigResult::True) + }) { + let mac = CfgSelectResult { ecx, - tts, - sp, - arm_span, - Ident::with_dummy_span(sym::cfg_select), - ); + selected_tts, + selected_span, + other_branches: branches, + site_span: sp, + }; + return ExpandResult::Ready(Box::new(mac)); } else { // Emit a compiler error when none of the predicates matched. let guar = ecx.dcx().emit_err(CfgSelectNoMatches { span: sp }); diff --git a/tests/ui/macros/cfg_select.rs b/tests/ui/macros/cfg_select.rs index 9fc680307025..2369158ba82a 100644 --- a/tests/ui/macros/cfg_select.rs +++ b/tests/ui/macros/cfg_select.rs @@ -47,6 +47,89 @@ fn arm_rhs_expr_3() -> i32 { } } +fn expand_to_statements() -> i32 { + cfg_select! { + true => { + let a = 1; + a + 1 + } + false => { + let b = 2; + b + 1 + } + } +} + +type ExpandToType = cfg_select! { + unix => u32, + _ => i32, +}; + +fn expand_to_pattern(x: Option) -> bool { + match x { + (cfg_select! { + unix => Some(n), + _ => None, + }) => true, + _ => false, + } +} + +cfg_select! { + true => { + fn foo() {} + } + _ => { + fn bar() {} + } +} + +struct S; + +impl S { + cfg_select! { + true => { + fn foo() {} + } + _ => { + fn bar() {} + } + } +} + +trait T { + cfg_select! { + true => { + fn a(); + } + _ => { + fn b(); + } + } +} + +impl T for S { + cfg_select! { + true => { + fn a() {} + } + _ => { + fn b() {} + } + } +} + +extern "C" { + cfg_select! { + true => { + fn puts(s: *const i8) -> i32; + } + _ => { + fn printf(fmt: *const i8, ...) -> i32; + } + } +} + cfg_select! { _ => {} true => {} diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr index 510fc33d6d11..ffd8540425ab 100644 --- a/tests/ui/macros/cfg_select.stderr +++ b/tests/ui/macros/cfg_select.stderr @@ -1,5 +1,5 @@ warning: unreachable predicate - --> $DIR/cfg_select.rs:52:5 + --> $DIR/cfg_select.rs:135:5 | LL | _ => {} | - always matches @@ -7,7 +7,7 @@ LL | true => {} | ^^^^ this predicate is never reached error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:56:1 + --> $DIR/cfg_select.rs:139:1 | LL | / cfg_select! { LL | | @@ -16,55 +16,55 @@ LL | | } | |_^ error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:61:1 + --> $DIR/cfg_select.rs:144:1 | LL | cfg_select! {} | ^^^^^^^^^^^^^^ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `=>` - --> $DIR/cfg_select.rs:65:5 + --> $DIR/cfg_select.rs:148:5 | LL | => {} | ^^ error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found expression - --> $DIR/cfg_select.rs:70:5 + --> $DIR/cfg_select.rs:153:5 | LL | () => {} | ^^ expressions are not allowed here error[E0539]: malformed `cfg_select` macro input - --> $DIR/cfg_select.rs:75:5 + --> $DIR/cfg_select.rs:158:5 | LL | "str" => {} | ^^^^^ expected a valid identifier here error[E0539]: malformed `cfg_select` macro input - --> $DIR/cfg_select.rs:80:5 + --> $DIR/cfg_select.rs:163:5 | LL | a::b => {} | ^^^^ expected a valid identifier here error[E0537]: invalid predicate `a` - --> $DIR/cfg_select.rs:85:5 + --> $DIR/cfg_select.rs:168:5 | LL | a() => {} | ^^^ error: expected one of `(`, `::`, `=>`, or `=`, found `+` - --> $DIR/cfg_select.rs:90:7 + --> $DIR/cfg_select.rs:173:7 | LL | a + 1 => {} | ^ expected one of `(`, `::`, `=>`, or `=` error: expected one of `(`, `::`, `=>`, or `=`, found `!` - --> $DIR/cfg_select.rs:96:8 + --> $DIR/cfg_select.rs:179:8 | LL | cfg!() => {} | ^ expected one of `(`, `::`, `=>`, or `=` warning: unexpected `cfg` condition name: `a` - --> $DIR/cfg_select.rs:90:5 + --> $DIR/cfg_select.rs:173:5 | LL | a + 1 => {} | ^ help: found config with similar value: `target_feature = "a"` @@ -75,7 +75,7 @@ LL | a + 1 => {} = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `cfg` - --> $DIR/cfg_select.rs:96:5 + --> $DIR/cfg_select.rs:179:5 | LL | cfg!() => {} | ^^^ diff --git a/tests/ui/macros/cfg_select_parse_error.rs b/tests/ui/macros/cfg_select_parse_error.rs new file mode 100644 index 000000000000..90fcb2309b34 --- /dev/null +++ b/tests/ui/macros/cfg_select_parse_error.rs @@ -0,0 +1,18 @@ +#![feature(cfg_select)] +#![crate_type = "lib"] + +// Check that parse errors in arms that are not selected are still reported. + +fn print() { + println!(cfg_select! { + false => { 1 ++ 2 } + //~^ ERROR Rust has no postfix increment operator + _ => { "not unix" } + }); +} + +cfg_select! { + false => { fn foo() { 1 +++ 2 } } + //~^ ERROR Rust has no postfix increment operator + _ => {} +} diff --git a/tests/ui/macros/cfg_select_parse_error.stderr b/tests/ui/macros/cfg_select_parse_error.stderr new file mode 100644 index 000000000000..d4c86c3ceade --- /dev/null +++ b/tests/ui/macros/cfg_select_parse_error.stderr @@ -0,0 +1,26 @@ +error: Rust has no postfix increment operator + --> $DIR/cfg_select_parse_error.rs:8:22 + | +LL | false => { 1 ++ 2 } + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL - false => { 1 ++ 2 } +LL + false => { { let tmp = 1 ; 1 += 1; tmp } 2 } + | + +error: Rust has no postfix increment operator + --> $DIR/cfg_select_parse_error.rs:15:29 + | +LL | false => { fn foo() { 1 +++ 2 } } + | ^^ not a valid postfix operator + | +help: use `+= 1` instead + | +LL - false => { fn foo() { 1 +++ 2 } } +LL + false => { fn foo() { { let tmp = 1 ; 1 += 1; tmp }+ 2 } } + | + +error: aborting due to 2 previous errors + From e254e7ef2d54ee546f75db6c1a75aa6bb1b83514 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:47:04 +0200 Subject: [PATCH 272/489] match fn name --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index aa34fbbb53f2..8e963627066a 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -233,7 +233,7 @@ r? @reviewer } #[test] -fn test_prettify() { +fn test_lengthen_lines() { let original = "\ do not split short sentences From 8b2c9d8189ab55595f3a636b9e1cfe41b0748217 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:49:54 +0200 Subject: [PATCH 273/489] sembr src/about-this-guide.md --- src/doc/rustc-dev-guide/src/about-this-guide.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/about-this-guide.md b/src/doc/rustc-dev-guide/src/about-this-guide.md index 841691d859f9..2082481a200e 100644 --- a/src/doc/rustc-dev-guide/src/about-this-guide.md +++ b/src/doc/rustc-dev-guide/src/about-this-guide.md @@ -77,8 +77,7 @@ You might also find the following sites useful: - [std-dev-guide] -- a similar guide for developing the standard library. - [rust-analyzer book] -- documentation for the rust-analyzer. - [The t-compiler Zulip][z] -- The [Rust Internals forum][rif], a place to ask questions and - discuss Rust's internals +- The [Rust Internals forum][rif], a place to ask questions and discuss Rust's internals - The [Rust reference][rr], even though it doesn't specifically talk about Rust's internals, is a great resource nonetheless - Although out of date, [Tom Lee's great blog article][tlgba] is very helpful @@ -89,11 +88,10 @@ You might also find the following sites useful: the compiler, the books, the references, and the guides) to quickly find information about the language and compiler. - You can also use Rustdoc's built-in search feature to find documentation on - types and functions within the crates you're looking at. You can also search - by type signature! For example, searching for `* -> vec` should find all - functions that return a `Vec`. - _Hint:_ Find more tips and keyboard shortcuts by typing `?` on any Rustdoc - page! + types and functions within the crates you're looking at. + You can also search by type signature! + For example, searching for `* -> vec` should find all functions that return a `Vec`. + _Hint:_ Find more tips and keyboard shortcuts by typing `?` on any Rustdoc page! [rustc dev guide]: about-this-guide.md From 6a911741048a5a585c92533677b62ee65aaa8dcb Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 17 Dec 2025 23:53:15 +0200 Subject: [PATCH 274/489] sembr src/appendix/bibliography.md --- .../src/appendix/bibliography.md | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/appendix/bibliography.md b/src/doc/rustc-dev-guide/src/appendix/bibliography.md index 13a9c3a0b40b..c161bba5b34f 100644 --- a/src/doc/rustc-dev-guide/src/appendix/bibliography.md +++ b/src/doc/rustc-dev-guide/src/appendix/bibliography.md @@ -1,7 +1,7 @@ # Rust Bibliography -This is a reading list of material relevant to Rust. It includes prior -research that has - at one time or another - influenced the design of +This is a reading list of material relevant to Rust. +It includes prior research that has - at one time or another - influenced the design of Rust, as well as publications about Rust. ## Type system @@ -44,8 +44,7 @@ Rust, as well as publications about Rust. ## Papers *about* Rust -* [GPU Programming in Rust: Implementing High Level Abstractions in a Systems - Level +* [GPU Programming in Rust: Implementing High Level Abstractions in a Systems Level Language](https://ieeexplore.ieee.org/document/6650903). Early GPU work by Eric Holk. * [Parallel closures: a new twist on an old @@ -55,38 +54,47 @@ Rust, as well as publications about Rust. Language](https://dada.cs.washington.edu/research/tr/2015/03/UW-CSE-15-03-02.pdf). Early formalization of a subset of the type system, by Eric Reed. * [Experience Report: Developing the Servo Web Browser Engine using - Rust](https://arxiv.org/abs/1505.07383). By Lars Bergstrom. + Rust](https://arxiv.org/abs/1505.07383). + By Lars Bergstrom. * [Implementing a Generic Radix Trie in - Rust](https://michaelsproul.github.io/rust_radix_paper/rust-radix-sproul.pdf). Undergrad - paper by Michael Sproul. + Rust](https://michaelsproul.github.io/rust_radix_paper/rust-radix-sproul.pdf). + Undergrad paper by Michael Sproul. * [Reenix: Implementing a Unix-Like Operating System in - Rust](https://scialex.github.io/reenix.pdf). Undergrad paper by Alex - Light. + Rust](https://scialex.github.io/reenix.pdf). + Undergrad paper by Alex Light. * [Evaluation of performance and productivity metrics of potential programming languages in the HPC environment](https://github.com/1wilkens/thesis-ba). - Bachelor's thesis by Florian Wilkens. Compares C, Go and Rust. + Bachelor's thesis by Florian Wilkens. + Compares C, Go and Rust. * [Nom, a byte oriented, streaming, zero copy, parser combinators library - in Rust](http://spw15.langsec.org/papers/couprie-nom.pdf). By - Geoffroy Couprie, research for VLC. + in Rust](http://spw15.langsec.org/papers/couprie-nom.pdf). + By Geoffroy Couprie, research for VLC. * [Graph-Based Higher-Order Intermediate - Representation](https://compilers.cs.uni-saarland.de/papers/lkh15_cgo.pdf). An - experimental IR implemented in Impala, a Rust-like language. -* [Code Refinement of Stencil - Codes](https://compilers.cs.uni-saarland.de/papers/ppl14_web.pdf). Another - paper using Impala. + Representation](https://compilers.cs.uni-saarland.de/papers/lkh15_cgo.pdf). + An experimental IR implemented in Impala, a Rust-like language. +* [Code Refinement of Stencil Codes](https://compilers.cs.uni-saarland.de/papers/ppl14_web.pdf). + Another paper using Impala. * [Parallelization in Rust with fork-join and - friends](http://publications.lib.chalmers.se/records/fulltext/219016/219016.pdf). Linus - Farnstrand's master's thesis. -* [Session Types for - Rust](https://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip - Munksgaard's master's thesis. Research for Servo. -* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](https://amitlevy.com/papers/tock-plos2015.pdf) -* [You can't spell trust without Rust](https://faultlore.com/blah/papers/thesis.pdf). Aria Beingessner's master's thesis. -* [Rust-Bio: a fast and safe bioinformatics library](https://rust-bio.github.io/). Johannes Köster -* [Safe, Correct, and Fast Low-Level Networking](https://csperkins.org/research/thesis-msci-clipsham.pdf). Robert Clipsham's master's thesis. -* [Formalizing Rust traits](https://open.library.ubc.ca/cIRcle/collections/ubctheses/24/items/1.0220521). Jonatan Milewski's master's thesis. + friends](http://publications.lib.chalmers.se/records/fulltext/219016/219016.pdf). + Linus Farnstrand's master's thesis. +* [Session Types for Rust](https://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). + Philip Munksgaard's master's thesis. + Research for Servo. +* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. + al.](https://amitlevy.com/papers/tock-plos2015.pdf) +* [You can't spell trust without Rust](https://faultlore.com/blah/papers/thesis.pdf). + Aria Beingessner's master's thesis. +* [Rust-Bio: a fast and safe bioinformatics library](https://rust-bio.github.io/). + Johannes Köster +* [Safe, Correct, and Fast Low-Level Networking](https://csperkins.org/research/thesis-msci-clipsham.pdf). + Robert Clipsham's master's thesis. +* [Formalizing Rust traits](https://open.library.ubc.ca/cIRcle/collections/ubctheses/24/items/1.0220521). + Jonatan Milewski's master's thesis. * [Rust as a Language for High Performance GC Implementation](https://dl.acm.org/doi/pdf/10.1145/3241624.2926707) -* [Simple Verification of Rust Programs via Functional Purification](https://github.com/Kha/electrolysis). Sebastian Ullrich's master's thesis. +* [Simple Verification of Rust Programs via Functional Purification](https://github.com/Kha/electrolysis). + Sebastian Ullrich's master's thesis. * [Writing parsers like it is 2017](http://spw17.langsec.org/papers/chifflier-parsing-in-2017.pdf) Pierre Chifflier and Geoffroy Couprie for the Langsec Workshop * [The Case for Writing a Kernel in Rust](https://www.tockos.org/assets/papers/rust-kernel-apsys2017.pdf) * [RustBelt: Securing the Foundations of the Rust Programming Language](https://plv.mpi-sws.org/rustbelt/popl18/) -* [Oxide: The Essence of Rust](https://arxiv.org/abs/1903.00982). By Aaron Weiss, Olek Gierczak, Daniel Patterson, Nicholas D. Matsakis, and Amal Ahmed. +* [Oxide: The Essence of Rust](https://arxiv.org/abs/1903.00982). + By Aaron Weiss, Olek Gierczak, Daniel Patterson, Nicholas D. + Matsakis, and Amal Ahmed. From f685b240d8169cd0be8b21312cec07241f7fae08 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:09:33 +0200 Subject: [PATCH 275/489] fix corner case --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 8e963627066a..2eb32491e3aa 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -80,6 +80,7 @@ fn ignore(line: &str, in_code_block: bool) -> bool { in_code_block || line.to_lowercase().contains("e.g.") || line.contains("i.e.") + || line.contains("et. al") || line.contains('|') || line.trim_start().starts_with('>') || line.starts_with('#') From e1fe9c64624a1040b88da91eef5044e3d810a537 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:11:34 +0200 Subject: [PATCH 276/489] sembr src/appendix/bibliography.md (after fix from parent commit) Please enter the commit message for your changes. Lines starting --- src/doc/rustc-dev-guide/src/appendix/bibliography.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/appendix/bibliography.md b/src/doc/rustc-dev-guide/src/appendix/bibliography.md index c161bba5b34f..4f87e4d2fa00 100644 --- a/src/doc/rustc-dev-guide/src/appendix/bibliography.md +++ b/src/doc/rustc-dev-guide/src/appendix/bibliography.md @@ -79,8 +79,7 @@ Rust, as well as publications about Rust. * [Session Types for Rust](https://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip Munksgaard's master's thesis. Research for Servo. -* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. - al.](https://amitlevy.com/papers/tock-plos2015.pdf) +* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](https://amitlevy.com/papers/tock-plos2015.pdf) * [You can't spell trust without Rust](https://faultlore.com/blah/papers/thesis.pdf). Aria Beingessner's master's thesis. * [Rust-Bio: a fast and safe bioinformatics library](https://rust-bio.github.io/). From 2dac444b7e2b7a87157b46b6a708c6fa6bce4c27 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:18:45 +0200 Subject: [PATCH 277/489] sembr src/diagnostics/error-codes.md --- .../src/diagnostics/error-codes.md | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md b/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md index c7bb6669dce4..9a302f9100f1 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/error-codes.md @@ -1,24 +1,24 @@ # Error codes -We generally try to assign each error message a unique code like `E0123`. These -codes are defined in the compiler in the `diagnostics.rs` files found in each -crate, which basically consist of macros. All error codes have an associated -explanation: new error codes must include them. Note that not all _historical_ -(no longer emitted) error codes have explanations. +We generally try to assign each error message a unique code like `E0123`. +These codes are defined in the compiler in the `diagnostics.rs` files found in each +crate, which basically consist of macros. +All error codes have an associated explanation: new error codes must include them. +Note that not all _historical_ (no longer emitted) error codes have explanations. ## Error explanations The explanations are written in Markdown (see the [CommonMark Spec] for -specifics around syntax), and all of them are linked in the [`rustc_error_codes`] -crate. Please read [RFC 1567] for details on how to format and write long error -codes. As of February 2023, there is an -effort[^new-explanations] to replace this largely outdated RFC with a new more -flexible standard. +specifics around syntax), and all of them are linked in the [`rustc_error_codes`] crate. +Please read [RFC 1567] for details on how to format and write long error codes. +As of February 2023, there is an +effort[^new-explanations] to replace this largely outdated RFC with a new more flexible standard. Error explanations should expand on the error message and provide details about -_why_ the error occurs. It is not helpful for users to copy-paste a quick fix; -explanations should help users understand why their code cannot be accepted by -the compiler. Rust prides itself on helpful error messages and long-form -explanations are no exception. However, before error explanations are +_why_ the error occurs. +It is not helpful for users to copy-paste a quick fix; +explanations should help users understand why their code cannot be accepted by the compiler. +Rust prides itself on helpful error messages and long-form explanations are no exception. +However, before error explanations are overhauled[^new-explanations] it is a bit open as to how exactly they should be written, as always: ask your reviewer or ask around on the Rust Zulip. @@ -33,12 +33,12 @@ written, as always: ask your reviewer or ask around on the Rust Zulip. Error codes are stored in `compiler/rustc_error_codes`. -To create a new error, you first need to find the next available code. +To create a new error, you first need to find the next available code. You can find it by opening `rustc_error_codes/src/lib.rs` and scrolling down to the end of the `error_codes!` macro declaration. -Here we might see the highest error code in use is `E0805`, so we _probably_ want -`E0806`. To be sure, run `rg E0806` and check, you should see no references. +Here we might see the highest error code in use is `E0805`, so we _probably_ want `E0806`. +To be sure, run `rg E0806` and check, you should see no references. You will have to write an extended description for your error, which will go in `rustc_error_codes/src/error_codes/E0806.md`. @@ -62,8 +62,7 @@ struct_span_code_err!(self.dcx(), // some path to the `DiagCtxt` here .emit() // actually issue the error ``` -If you want to add notes or other snippets, you can invoke methods before you -call `.emit()`: +If you want to add notes or other snippets, you can invoke methods before you call `.emit()`: ```rust struct_span_code_err!(...) From 5e1352b6318d1e10560546c831f682debf0e43f4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:25:13 +0200 Subject: [PATCH 278/489] sembr src/query.md --- src/doc/rustc-dev-guide/src/query.md | 104 ++++++++++++++------------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 5df9de762038..28e421acb207 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -2,11 +2,13 @@ As described in [Overview of the compiler], the Rust compiler is still (as of July 2021) transitioning from a -traditional "pass-based" setup to a "demand-driven" system. The compiler query -system is the key to rustc's demand-driven organization. -The idea is pretty simple. Instead of entirely independent passes +traditional "pass-based" setup to a "demand-driven" system. +The compiler query system is the key to rustc's demand-driven organization. +The idea is pretty simple. +Instead of entirely independent passes (parsing, type-checking, etc.), a set of function-like *queries* -compute information about the input source. For example, +compute information about the input source. +For example, there is a query called `type_of` that, given the [`DefId`] of some item, will compute the type of that item and return it to you. @@ -14,25 +16,21 @@ some item, will compute the type of that item and return it to you. [Overview of the compiler]: overview.md#queries Query execution is *memoized*. The first time you invoke a -query, it will go do the computation, but the next time, the result is -returned from a hashtable. Moreover, query execution fits nicely into +query, it will go do the computation, but the next time, the result is returned from a hashtable. +Moreover, query execution fits nicely into *incremental computation*; the idea is roughly that, when you invoke a -query, the result *may* be returned to you by loading stored data -from disk.[^incr-comp-detail] +query, the result *may* be returned to you by loading stored data from disk.[^incr-comp-detail] -Eventually, we want the entire compiler -control-flow to be query driven. There will effectively be one -top-level query (`compile`) that will run compilation on a crate; this -will in turn demand information about that crate, starting from the -*end*. For example: +Eventually, we want the entire compiler control-flow to be query driven. +There will effectively be one top-level query (`compile`) that will run compilation on a crate; this +will in turn demand information about that crate, starting from the *end*. For example: - The `compile` query might demand to get a list of codegen-units (i.e. modules that need to be compiled by LLVM). - But computing the list of codegen-units would invoke some subquery that returns the list of all modules defined in the Rust source. - That query in turn would invoke something asking for the HIR. -- This keeps going further and further back until we wind up doing the - actual parsing. +- This keeps going further and further back until we wind up doing the actual parsing. Although this vision is not fully realized, large sections of the compiler (for example, generating [MIR]) currently work exactly like this. @@ -46,9 +44,9 @@ If you intend to write a query of your own, this is a good read. ## Invoking queries -Invoking a query is simple. The [`TyCtxt`] ("type context") struct offers a method -for each defined query. For example, to invoke the `type_of` -query, you would just do this: +Invoking a query is simple. +The [`TyCtxt`] ("type context") struct offers a method for each defined query. +For example, to invoke the `type_of` query, you would just do this: ```rust,ignore let ty = tcx.type_of(some_def_id); @@ -58,8 +56,8 @@ let ty = tcx.type_of(some_def_id); ## How the compiler executes a query -So you may be wondering what happens when you invoke a query -method. The answer is that, for each query, the compiler maintains a +So you may be wondering what happens when you invoke a query method. +The answer is that, for each query, the compiler maintains a cache – if your query has already been executed, then, the answer is simple: we clone the return value out of the cache and return it (therefore, you should try to ensure that the return types of queries @@ -68,11 +66,12 @@ are cheaply cloneable; insert an `Rc` if necessary). ### Providers If, however, the query is *not* in the cache, then the compiler will -call the corresponding **provider** function. A provider is a function -implemented in a specific module and **manually registered** into either +call the corresponding **provider** function. +A provider is a function implemented in a specific module and **manually registered** into either the [`Providers`][providers_struct] struct (for local crate queries) or the [`ExternProviders`][extern_providers_struct] struct (for external crate queries) -during compiler initialization. The macro system generates both structs, +during compiler initialization. +The macro system generates both structs, which act as function tables for all query implementations, where each field is a function pointer to the actual provider. @@ -80,8 +79,8 @@ field is a function pointer to the actual provider. They are **not** Rust traits, but plain structs with function pointer fields. **Providers are defined per-crate.** The compiler maintains, -internally, a table of providers for every crate, at least -conceptually. There are two sets of providers: +internally, a table of providers for every crate, at least conceptually. +There are two sets of providers: - The `Providers` struct for queries about the **local crate** (that is, the one being compiled) - The `ExternProviders` struct for queries about **external crates** (that is, dependencies of the local crate) @@ -89,8 +88,7 @@ dependencies of the local crate) Note that what determines the crate that a query is targeting is not the *kind* of query, but the *key*. For example, when you invoke `tcx.type_of(def_id)`, that could be a local query or an external query, depending on what crate the `def_id` -is referring to (see the [`self::keys::Key`][Key] trait for more -information on how that works). +is referring to (see the [`self::keys::Key`][Key] trait for more information on how that works). Providers always have the same signature: @@ -106,10 +104,11 @@ fn provider<'tcx>( Providers take two arguments: the `tcx` and the query key. They return the result of the query. -N.B. Most of the `rustc_*` crates only provide **local +N.B. +Most of the `rustc_*` crates only provide **local providers**. Almost all **extern providers** wind up going through the -[`rustc_metadata` crate][rustc_metadata], which loads the information -from the crate metadata. But in some cases there are crates that +[`rustc_metadata` crate][rustc_metadata], which loads the information from the crate metadata. +But in some cases there are crates that provide queries for *both* local and external crates, in which case they define both a `provide` and a `provide_extern` function, through [`wasm_import_module_map`][wasm_import_module_map], that `rustc_driver` can invoke. @@ -120,7 +119,8 @@ they define both a `provide` and a `provide_extern` function, through ### How providers are set up When the tcx is created, it is given both the local and external providers by its creator using -the `Providers` struct from `rustc_middle::util`. This struct contains both the local and external providers: +the `Providers` struct from `rustc_middle::util`. +This struct contains both the local and external providers: ```rust,ignore pub struct Providers { @@ -134,7 +134,7 @@ Each of these provider structs is generated by the macros and contains function #### How are providers registered? -The `util::Providers` struct is filled in during compiler initialization, by the `rustc_interface` crate from the `DEFAULT_QUERY_PROVIDERS` static. +The `util::Providers` struct is filled in during compiler initialization, by the `rustc_interface` crate from the `DEFAULT_QUERY_PROVIDERS` static. The actual provider functions are defined across various `rustc_*` crates (like `rustc_middle`, `rustc_hir_analysis`, etc). To register providers, each crate exposes a [`provide`][provide_fn] function that looks like this: @@ -151,7 +151,9 @@ pub fn provide(providers: &mut query::Providers) { } ``` -Note that this function accepts `query::Providers` not `util::Providers`. It is exceedingly rare to need a `provide` function that doesn't just accept `query::Providers`. If more than the `queries` field of `util::Providers` is being updated then `util::Providers` can be accepted instead: +Note that this function accepts `query::Providers` not `util::Providers`. +It is exceedingly rare to need a `provide` function that doesn't just accept `query::Providers`. +If more than the `queries` field of `util::Providers` is being updated then `util::Providers` can be accepted instead: ```rust,ignore pub fn provide(providers: &mut rustc_middle::util::Providers) { providers.queries.type_of = type_of; @@ -173,7 +175,8 @@ Note that `util::Providers` implements `DerefMut` to `query::Providers` so calle #### Adding a new provider -Suppose you want to add a new query called `fubar`. This section focuses on wiring up the providers; for how to declare the query itself in the big `rustc_queries!` macro, see [Adding a new query](#adding-a-new-query) below. +Suppose you want to add a new query called `fubar`. +This section focuses on wiring up the providers; for how to declare the query itself in the big `rustc_queries!` macro, see [Adding a new query](#adding-a-new-query) below. In practice you usually: @@ -184,7 +187,8 @@ In practice you usually: // existing assignments } ``` - If it exists, you will extend it to set the field for your new query. If the crate does not yet have a `provide` function, add one and make sure it is included in `DEFAULT_QUERY_PROVIDERS` in the `rustc_interface` crate so that it actually gets called during initialization (see the discussion above). + If it exists, you will extend it to set the field for your new query. + If the crate does not yet have a `provide` function, add one and make sure it is included in `DEFAULT_QUERY_PROVIDERS` in the `rustc_interface` crate so that it actually gets called during initialization (see the discussion above). 3. Implement the provider function itself: ```rust,ignore fn fubar<'tcx>(tcx: TyCtxt<'tcx>, key: LocalDefId) -> Fubar<'tcx> { ... } @@ -210,7 +214,8 @@ The process works like this: This determines whether to use the local provider from [`Providers`][providers_struct] or the external provider from [`ExternProviders`][extern_providers_struct]. 2. For external crates, the query system will look for a provider in the [`ExternProviders`][extern_providers_struct] struct. - The `rustc_metadata` crate registers these external providers through the `provide_extern` function in `rustc_metadata/src/rmeta/decoder/cstore_impl.rs`. Just like: + The `rustc_metadata` crate registers these external providers through the `provide_extern` function in `rustc_metadata/src/rmeta/decoder/cstore_impl.rs`. + Just like: ```rust pub fn provide_extern(providers: &mut ExternProviders) { providers.foo = |tcx, def_id| { @@ -222,7 +227,8 @@ The process works like this: } ``` -3. The metadata is stored in a binary format in `.rmeta` files that contains pre-computed information about the external crate, such as types, function signatures, trait implementations, and other information needed by the compiler. When an external query is made, the `rustc_metadata` crate: +3. The metadata is stored in a binary format in `.rmeta` files that contains pre-computed information about the external crate, such as types, function signatures, trait implementations, and other information needed by the compiler. + When an external query is made, the `rustc_metadata` crate: - Loads the `.rmeta` file for the external crate - Decodes the metadata using the `Decodable` trait - Returns the decoded information to the query system @@ -234,10 +240,11 @@ Here is a simplified example, when you call `tcx.type_of(def_id)` for a type def 3. The provider will load and decode the type information from the external crate's metadata 4. Return the decoded type to the caller -This is why most `rustc_*` crates only need to provide local providers - the external providers are handled by the metadata system. +This is why most `rustc_*` crates only need to provide local providers - the external providers are handled by the metadata system. The only exception is when a crate needs to provide special handling for external queries, in which case it would implement both local and external providers. -When we define a new query that should work across crates, it does not automatically become cross-crate just because it is listed in `rustc_queries!`. You will typically need to: +When we define a new query that should work across crates, it does not automatically become cross-crate just because it is listed in `rustc_queries!`. +You will typically need to: - Add the query to `rustc_queries!` with appropriate modifiers (for example whether it is cached on disk). - Implement a local provider in the owning crate and register it via that crate's `provide` function. @@ -296,17 +303,16 @@ query keyword Let's go over these elements one by one: - **Query keyword:** indicates a start of a query definition. -- **Name of query:** the name of the query method - (`tcx.type_of(..)`). Also used as the name of a struct - (`ty::queries::type_of`) that will be generated to represent +- **Name of query:** the name of the query method (`tcx.type_of(..)`). + Also used as the name of a struct (`ty::queries::type_of`) that will be generated to represent this query. - **Query key type:** the type of the argument to this query. This type must implement the [`ty::query::keys::Key`][Key] trait, which defines (for example) how to map it to a crate, and so forth. -- **Result type of query:** the type produced by this query. This type - should (a) not use `RefCell` or other interior mutability and (b) be - cheaply cloneable. Interning or using `Rc` or `Arc` is recommended for - non-trivial data types.[^steal] +- **Result type of query:** the type produced by this query. + This type should (a) not use `RefCell` or other interior mutability and (b) be + cheaply cloneable. + Interning or using `Rc` or `Arc` is recommended for non-trivial data types.[^steal] - **Query modifiers:** various flags and options that customize how the query is processed (mostly with respect to [incremental compilation][incrcomp]). @@ -320,9 +326,9 @@ So, to add a query: or add a new one if needed and ensure that `rustc_driver` is invoking it. [^steal]: The one exception to those rules is the `ty::steal::Steal` type, -which is used to cheaply modify MIR in place. See the definition -of `Steal` for more details. New uses of `Steal` should **not** be -added without alerting `@rust-lang/compiler`. +which is used to cheaply modify MIR in place. +See the definition of `Steal` for more details. +New uses of `Steal` should **not** be added without alerting `@rust-lang/compiler`. ## External links From 2114b2107068617b0303f9d0e91ad12ad00a296c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 17 Dec 2025 23:27:38 +0100 Subject: [PATCH 279/489] Improve code by using `iterator::sum` instead of looping --- src/librustdoc/html/highlight.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index bc268d9495f8..f70b350de283 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -921,12 +921,10 @@ fn classify<'src>( && let Some(nb_items) = classifier.get_full_ident_path() { let start = classifier.byte_pos as usize; - let mut len = 0; - for _ in 0..nb_items { - if let Some((_, text, _)) = classifier.next() { - len += text.len(); - } - } + let len: usize = iter::from_fn(|| classifier.next()) + .take(nb_items) + .map(|(_, text, _)| text.len()) + .sum(); let text = &classifier.src[start..start + len]; classifier.advance(TokenKind::Ident, text, sink, start as u32); } else if let Some((token, text, before)) = classifier.next() { From 40d05f8108b551e435445a86977d7d8e8b2e2cfa Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:36:27 +0200 Subject: [PATCH 280/489] corner case --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 1 + src/doc/rustc-dev-guide/src/query.md | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 2eb32491e3aa..d41a57d6f747 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -79,6 +79,7 @@ fn display(header: &str, paths: &[PathBuf]) { fn ignore(line: &str, in_code_block: bool) -> bool { in_code_block || line.to_lowercase().contains("e.g.") + || line.to_lowercase().contains("n.b.") || line.contains("i.e.") || line.contains("et. al") || line.contains('|') diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 28e421acb207..90bb08d8abcd 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -104,8 +104,7 @@ fn provider<'tcx>( Providers take two arguments: the `tcx` and the query key. They return the result of the query. -N.B. -Most of the `rustc_*` crates only provide **local +N.B. Most of the `rustc_*` crates only provide **local providers**. Almost all **extern providers** wind up going through the [`rustc_metadata` crate][rustc_metadata], which loads the information from the crate metadata. But in some cases there are crates that @@ -158,10 +157,10 @@ If more than the `queries` field of `util::Providers` is being updated then `ut pub fn provide(providers: &mut rustc_middle::util::Providers) { providers.queries.type_of = type_of; // ... add more local providers here - + providers.extern_queries.type_of = extern_type_of; // ... add more external providers here - + providers.hooks.some_hook = some_hook; // ... add more hooks here } @@ -205,7 +204,7 @@ In practice you usually: ### How queries interact with external crate metadata -When a query is made for an external crate (i.e., a dependency), the query system needs to load the information from that crate's metadata. +When a query is made for an external crate (i.e., a dependency), the query system needs to load the information from that crate's metadata. This is handled by the [`rustc_metadata` crate][rustc_metadata], which is responsible for decoding and providing the information stored in the `.rmeta` files. The process works like this: From 2fe2052bbec7bab1951712ddde3f3c0863575c4d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:40:03 +0200 Subject: [PATCH 281/489] manual sembr --- src/doc/rustc-dev-guide/src/query.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 90bb08d8abcd..1961d68509f9 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -23,7 +23,9 @@ query, the result *may* be returned to you by loading stored data from disk.[^in Eventually, we want the entire compiler control-flow to be query driven. There will effectively be one top-level query (`compile`) that will run compilation on a crate; this -will in turn demand information about that crate, starting from the *end*. For example: +will in turn demand information about that crate, starting from the *end*. + +For example: - The `compile` query might demand to get a list of codegen-units (i.e. modules that need to be compiled by LLVM). From 4673d56b4178fbbccb428784f9a1c706bdcc8f3f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:41:31 +0200 Subject: [PATCH 282/489] sembr src/conventions.md --- src/doc/rustc-dev-guide/src/conventions.md | 64 ++++++++++------------ 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/conventions.md b/src/doc/rustc-dev-guide/src/conventions.md index 92ed0825c8c3..36ea0c584240 100644 --- a/src/doc/rustc-dev-guide/src/conventions.md +++ b/src/doc/rustc-dev-guide/src/conventions.md @@ -1,9 +1,8 @@ # Coding conventions -This file offers some tips on the coding conventions for rustc. This -chapter covers [formatting](#formatting), [coding for correctness](#cc), -[using crates from crates.io](#cio), and some tips on -[structuring your PR for easy review](#er). +This file offers some tips on the coding conventions for rustc. +This chapter covers [formatting](#formatting), [coding for correctness](#cc), +[using crates from crates.io](#cio), and some tips on [structuring your PR for easy review](#er). @@ -15,11 +14,11 @@ However, for now we don't use stable `rustfmt`; we use a pinned version with a special config, so this may result in different style from normal [`rustfmt`]. Therefore, formatting this repository using `cargo fmt` is not recommended. -Instead, formatting should be done using `./x fmt`. It's a good habit to run -`./x fmt` before every commit, as this reduces conflicts later. +Instead, formatting should be done using `./x fmt`. +It's a good habit to run `./x fmt` before every commit, as this reduces conflicts later. -Formatting is checked by the `tidy` script. It runs automatically when you do -`./x test` and can be run in isolation with `./x fmt --check`. +Formatting is checked by the `tidy` script. +It runs automatically when you do `./x test` and can be run in isolation with `./x fmt --check`. > **Note: Formatting and test suites** > @@ -47,13 +46,12 @@ When modifying that code, use this command to format it: ./x test tidy --extra-checks cpp:fmt --bless ``` -This uses a pinned version of `clang-format`, to avoid relying on the local -environment. +This uses a pinned version of `clang-format`, to avoid relying on the local environment. ### Formatting and linting Python code -The Rust repository contains quite a lot of Python code. We try to keep -it both linted and formatted by the [ruff] tool. +The Rust repository contains quite a lot of Python code. +We try to keep it both linted and formatted by the [ruff] tool. When modifying Python code, use this command to format it: @@ -78,8 +76,8 @@ These use a pinned version of `ruff`, to avoid relying on the local environment. ### Copyright notice -In the past, files began with a copyright and license notice. Please **omit** -this notice for new files licensed under the standard terms (dual +In the past, files began with a copyright and license notice. +Please **omit** this notice for new files licensed under the standard terms (dual MIT/Apache-2.0). All of the copyright notices should be gone by now, but if you come across one @@ -87,8 +85,8 @@ in the rust-lang/rust repo, feel free to open a PR to remove it. ### Line length -Lines should be at most 100 characters. It's even better if you can -keep things to 80. +Lines should be at most 100 characters. +It's even better if you can keep things to 80. Sometimes, and particularly for tests, it can be necessary to exempt yourself from this limit. In that case, you can add a comment towards the top of the file like so: @@ -105,17 +103,15 @@ Prefer 4-space indents. ## Coding for correctness -Beyond formatting, there are a few other tips that are worth -following. +Beyond formatting, there are a few other tips that are worth following. ### Prefer exhaustive matches Using `_` in a match is convenient, but it means that when new variants are added to the enum, they may not get handled correctly. Ask yourself: if a new variant were added to this enum, what's the -chance that it would want to use the `_` code, versus having some -other treatment? Unless the answer is "low", then prefer an -exhaustive match. +chance that it would want to use the `_` code, versus having some other treatment? +Unless the answer is "low", then prefer an exhaustive match. The same advice applies to `if let` and `while let`, which are effectively tests for a single variant. @@ -155,41 +151,39 @@ See the [crates.io dependencies][crates] section. ## How to structure your PR -How you prepare the commits in your PR can make a big difference for the -reviewer. Here are some tips. +How you prepare the commits in your PR can make a big difference for the reviewer. +Here are some tips. **Isolate "pure refactorings" into their own commit.** For example, if you rename a method, then put that rename into its own commit, along with the renames of all the uses. **More commits is usually better.** If you are doing a large change, -it's almost always better to break it up into smaller steps that can -be independently understood. The one thing to be aware of is that if +it's almost always better to break it up into smaller steps that can be independently understood. +The one thing to be aware of is that if you introduce some code following one strategy, then change it -dramatically (versus adding to it) in a later commit, that -'back-and-forth' can be confusing. +dramatically (versus adding to it) in a later commit, that 'back-and-forth' can be confusing. **Format liberally.** While only the final commit of a PR must be correctly formatted, it is both easier to review and less noisy to format each commit individually using `./x fmt`. -**No merges.** We do not allow merge commits into our history, other -than those by bors. If you get a merge conflict, rebase instead via a +**No merges.** We do not allow merge commits into our history, other than those by bors. +If you get a merge conflict, rebase instead via a command like `git rebase --interactive rust-lang/main` (presuming you use the name `rust-lang` for your remote). **Individual commits do not have to build (but it's nice).** We do not require that every intermediate commit successfully builds – we only -expect to be able to bisect at a PR level. However, if you *can* make -individual commits build, that is always helpful. +expect to be able to bisect at a PR level. +However, if you *can* make individual commits build, that is always helpful. ## Naming conventions -Apart from normal Rust style/naming conventions, there are also some specific -to the compiler. +Apart from normal Rust style/naming conventions, there are also some specific to the compiler. -- `cx` tends to be short for "context" and is often used as a suffix. For - example, `tcx` is a common name for the [Typing Context][tcx]. +- `cx` tends to be short for "context" and is often used as a suffix. + For example, `tcx` is a common name for the [Typing Context][tcx]. - [`'tcx`][tcx] is used as the lifetime name for the Typing Context. From 3aa4a794a7e76fd0977dcd9d020bfd59aa9a43be Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 18 Dec 2025 00:48:43 +0200 Subject: [PATCH 283/489] that basically repeats the title --- src/doc/rustc-dev-guide/src/conventions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/conventions.md b/src/doc/rustc-dev-guide/src/conventions.md index 36ea0c584240..5153f2c5711a 100644 --- a/src/doc/rustc-dev-guide/src/conventions.md +++ b/src/doc/rustc-dev-guide/src/conventions.md @@ -1,6 +1,5 @@ # Coding conventions -This file offers some tips on the coding conventions for rustc. This chapter covers [formatting](#formatting), [coding for correctness](#cc), [using crates from crates.io](#cio), and some tips on [structuring your PR for easy review](#er). From 2daccc92e18d60ea4ada94367d8f693702d0eb97 Mon Sep 17 00:00:00 2001 From: Niko Kajula Date: Thu, 18 Dec 2025 01:00:29 +0200 Subject: [PATCH 284/489] Fix intel manual links --- library/stdarch/crates/core_arch/src/x86/abm.rs | 2 +- library/stdarch/crates/core_arch/src/x86/aes.rs | 2 +- library/stdarch/crates/core_arch/src/x86/avx.rs | 2 +- library/stdarch/crates/core_arch/src/x86/avx2.rs | 2 +- library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs | 2 +- library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs | 2 +- library/stdarch/crates/core_arch/src/x86/bmi1.rs | 2 +- library/stdarch/crates/core_arch/src/x86/bmi2.rs | 2 +- library/stdarch/crates/core_arch/src/x86/fma.rs | 2 +- library/stdarch/crates/core_arch/src/x86/gfni.rs | 2 +- library/stdarch/crates/core_arch/src/x86/pclmulqdq.rs | 2 +- library/stdarch/crates/core_arch/src/x86/rtm.rs | 2 +- library/stdarch/crates/core_arch/src/x86/vaes.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/abm.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/avx.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/bmi.rs | 2 +- library/stdarch/crates/core_arch/src/x86_64/bmi2.rs | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/abm.rs b/library/stdarch/crates/core_arch/src/x86/abm.rs index 7f46e1a8d06e..b73076361d86 100644 --- a/library/stdarch/crates/core_arch/src/x86/abm.rs +++ b/library/stdarch/crates/core_arch/src/x86/abm.rs @@ -12,7 +12,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the instructions //! available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 diff --git a/library/stdarch/crates/core_arch/src/x86/aes.rs b/library/stdarch/crates/core_arch/src/x86/aes.rs index 7db743b2ccd3..be01d6ddd8d0 100644 --- a/library/stdarch/crates/core_arch/src/x86/aes.rs +++ b/library/stdarch/crates/core_arch/src/x86/aes.rs @@ -5,7 +5,7 @@ //! The reference is [Intel 64 and IA-32 Architectures Software Developer's //! Manual Volume 2: Instruction Set Reference, A-Z][intel64_ref]. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf use crate::core_arch::x86::__m128i; diff --git a/library/stdarch/crates/core_arch/src/x86/avx.rs b/library/stdarch/crates/core_arch/src/x86/avx.rs index bda0b8ac5047..6d4f79fc7cfe 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx.rs @@ -9,7 +9,7 @@ //! //! [Wikipedia][wiki] provides a quick overview of the instructions available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index e7fd19fa2e97..a297544e9e9b 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -13,7 +13,7 @@ //! Wikipedia's [AVX][wiki_avx] and [FMA][wiki_fma] pages provide a quick //! overview of the instructions available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki_avx]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions //! [wiki_fma]: https://en.wikipedia.org/wiki/Fused_multiply-accumulate diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs b/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs index 832a58432208..497fa21c4fe1 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bitalg.rs @@ -5,7 +5,7 @@ //! The reference is [Intel 64 and IA-32 Architectures Software Developer's //! Manual Volume 2: Instruction Set Reference, A-Z][intel64_ref]. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf use crate::core_arch::simd::i8x16; use crate::core_arch::simd::i8x32; diff --git a/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs b/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs index 42bff33a286d..38ef54b550fd 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512vpopcntdq.rs @@ -5,7 +5,7 @@ //! The reference is [Intel 64 and IA-32 Architectures Software Developer's //! Manual Volume 2: Instruction Set Reference, A-Z][intel64_ref]. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf use crate::core_arch::simd::*; use crate::core_arch::x86::__m128i; diff --git a/library/stdarch/crates/core_arch/src/x86/bmi1.rs b/library/stdarch/crates/core_arch/src/x86/bmi1.rs index 08444aaaeddd..11d66f699a12 100644 --- a/library/stdarch/crates/core_arch/src/x86/bmi1.rs +++ b/library/stdarch/crates/core_arch/src/x86/bmi1.rs @@ -6,7 +6,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the instructions //! available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [wikipedia_bmi]: https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 #[cfg(test)] diff --git a/library/stdarch/crates/core_arch/src/x86/bmi2.rs b/library/stdarch/crates/core_arch/src/x86/bmi2.rs index b5b7d0f34073..54d3b5387ec7 100644 --- a/library/stdarch/crates/core_arch/src/x86/bmi2.rs +++ b/library/stdarch/crates/core_arch/src/x86/bmi2.rs @@ -6,7 +6,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the instructions //! available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 diff --git a/library/stdarch/crates/core_arch/src/x86/fma.rs b/library/stdarch/crates/core_arch/src/x86/fma.rs index a8439935660f..c0900e61d92d 100644 --- a/library/stdarch/crates/core_arch/src/x86/fma.rs +++ b/library/stdarch/crates/core_arch/src/x86/fma.rs @@ -14,7 +14,7 @@ //! Wikipedia's [FMA][wiki_fma] page provides a quick overview of the //! instructions available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki_fma]: https://en.wikipedia.org/wiki/Fused_multiply-accumulate diff --git a/library/stdarch/crates/core_arch/src/x86/gfni.rs b/library/stdarch/crates/core_arch/src/x86/gfni.rs index 8c4d097fee9e..681b8ae330d4 100644 --- a/library/stdarch/crates/core_arch/src/x86/gfni.rs +++ b/library/stdarch/crates/core_arch/src/x86/gfni.rs @@ -5,7 +5,7 @@ //! The reference is [Intel 64 and IA-32 Architectures Software Developer's //! Manual Volume 2: Instruction Set Reference, A-Z][intel64_ref]. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf use crate::core_arch::simd::i8x16; use crate::core_arch::simd::i8x32; diff --git a/library/stdarch/crates/core_arch/src/x86/pclmulqdq.rs b/library/stdarch/crates/core_arch/src/x86/pclmulqdq.rs index cce6a51e2cd6..efc01190305e 100644 --- a/library/stdarch/crates/core_arch/src/x86/pclmulqdq.rs +++ b/library/stdarch/crates/core_arch/src/x86/pclmulqdq.rs @@ -3,7 +3,7 @@ //! The reference is [Intel 64 and IA-32 Architectures Software Developer's //! Manual Volume 2: Instruction Set Reference, A-Z][intel64_ref] (p. 4-241). //! -//! [intel64_ref]: http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf use crate::core_arch::x86::__m128i; diff --git a/library/stdarch/crates/core_arch/src/x86/rtm.rs b/library/stdarch/crates/core_arch/src/x86/rtm.rs index b807305d6aa8..b37e7571eb8f 100644 --- a/library/stdarch/crates/core_arch/src/x86/rtm.rs +++ b/library/stdarch/crates/core_arch/src/x86/rtm.rs @@ -9,7 +9,7 @@ //! Intel's [programming considerations][intel_consid] details what sorts of instructions within a //! transaction are likely to cause an abort. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [wikipedia_rtm]: https://en.wikipedia.org/wiki/Transactional_Synchronization_Extensions#Restricted_Transactional_Memory //! [intel_consid]: https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-intel-transactional-synchronization-extensions-intel-tsx-programming-considerations diff --git a/library/stdarch/crates/core_arch/src/x86/vaes.rs b/library/stdarch/crates/core_arch/src/x86/vaes.rs index b1fe193e3f5d..561b8b4b308c 100644 --- a/library/stdarch/crates/core_arch/src/x86/vaes.rs +++ b/library/stdarch/crates/core_arch/src/x86/vaes.rs @@ -5,7 +5,7 @@ //! The reference is [Intel 64 and IA-32 Architectures Software Developer's //! Manual Volume 2: Instruction Set Reference, A-Z][intel64_ref]. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf use crate::core_arch::x86::__m256i; use crate::core_arch::x86::__m512i; diff --git a/library/stdarch/crates/core_arch/src/x86_64/abm.rs b/library/stdarch/crates/core_arch/src/x86_64/abm.rs index 2b63cb5dc763..9fb76be4ba89 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/abm.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/abm.rs @@ -12,7 +12,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the instructions //! available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 diff --git a/library/stdarch/crates/core_arch/src/x86_64/avx.rs b/library/stdarch/crates/core_arch/src/x86_64/avx.rs index 80ef7fbd60a6..aae3c981d6fe 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/avx.rs @@ -9,7 +9,7 @@ //! //! [Wikipedia][wiki] provides a quick overview of the instructions available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [amd64_ref]: https://docs.amd.com/v/u/en-US/24594_3.37 //! [wiki]: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions diff --git a/library/stdarch/crates/core_arch/src/x86_64/bmi.rs b/library/stdarch/crates/core_arch/src/x86_64/bmi.rs index ee41d4137591..d5fd97583fb1 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/bmi.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/bmi.rs @@ -6,7 +6,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the instructions //! available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [wikipedia_bmi]: https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 #[cfg(test)] diff --git a/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs b/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs index 4eb53ed5ea4a..be12465c8147 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/bmi2.rs @@ -6,7 +6,7 @@ //! [Wikipedia][wikipedia_bmi] provides a quick overview of the instructions //! available. //! -//! [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf +//! [intel64_ref]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf //! [wikipedia_bmi]: //! https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29 From 97927aa4702e729ac4f36604d2e517a0f3166d90 Mon Sep 17 00:00:00 2001 From: Jesung Yang Date: Thu, 18 Dec 2025 00:03:05 +0000 Subject: [PATCH 285/489] feat: pretty print attributes up to `cfg(false)` Extend ItemTree pretty-printing to include attributes even when a cfg expression evaluates to false, emitting explicit `cfg(cfg_expr)` marker after the attributes. This improves testability of ItemTree attribute handling by exposing more information in pretty-printed output. --- .../rust-analyzer/crates/cfg/src/cfg_expr.rs | 30 +++++++++++++++++++ .../crates/hir-def/src/item_tree/pretty.rs | 9 ++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs b/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs index 76e0aba859e6..a0e0dc5ff090 100644 --- a/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs +++ b/src/tools/rust-analyzer/crates/cfg/src/cfg_expr.rs @@ -56,6 +56,36 @@ pub enum CfgExpr { Not(Box), } +impl fmt::Display for CfgExpr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + CfgExpr::Atom(atom) => atom.fmt(f), + CfgExpr::All(exprs) => { + write!(f, "all(")?; + for (i, expr) in exprs.iter().enumerate() { + if i > 0 { + write!(f, ", ")?; + } + expr.fmt(f)?; + } + write!(f, ")") + } + CfgExpr::Any(exprs) => { + write!(f, "any(")?; + for (i, expr) in exprs.iter().enumerate() { + if i > 0 { + write!(f, ", ")?; + } + expr.fmt(f)?; + } + write!(f, ")") + } + CfgExpr::Not(expr) => write!(f, "not({})", expr), + CfgExpr::Invalid => write!(f, "invalid"), + } + } +} + impl From for CfgExpr { fn from(atom: CfgAtom) -> Self { CfgExpr::Atom(atom) diff --git a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/pretty.rs b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/pretty.rs index 66a2d14a734f..c89299e6d863 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/pretty.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/pretty.rs @@ -86,9 +86,9 @@ impl Printer<'_> { } fn print_attrs(&mut self, attrs: &AttrsOrCfg, inner: bool, separated_by: &str) { - let AttrsOrCfg::Enabled { attrs } = attrs else { - w!(self, "#[cfg(false)]{separated_by}"); - return; + let (cfg_disabled_expr, attrs) = match attrs { + AttrsOrCfg::Enabled { attrs } => (None, attrs), + AttrsOrCfg::CfgDisabled(inner_box) => (Some(&inner_box.0), &inner_box.1), }; let inner = if inner { "!" } else { "" }; for attr in &*attrs.as_ref() { @@ -101,6 +101,9 @@ impl Printer<'_> { separated_by, ); } + if let Some(expr) = cfg_disabled_expr { + w!(self, "#{inner}[cfg({expr})]{separated_by}"); + } } fn print_attrs_of(&mut self, of: ModItemId, separated_by: &str) { From 23d056329518bc0e98b4a4a1838bd4536ab08fd3 Mon Sep 17 00:00:00 2001 From: Jesung Yang Date: Tue, 16 Dec 2025 05:49:37 +0000 Subject: [PATCH 286/489] feat: introduce `crate_attrs` field in `rust-project.json` Since the commit 50384460c68f ("Rewrite method resolution to follow rustc more closely"), the method resolution logic has changed: rust-analyzer only looks up inherent methods for primitive types in sysroot crates. Unfortunately, this change broke at least one project that relies on `rust-project.json`: Rust-for-Linux. Its auto-generated `rust-project.json` directly embeds `core`, `alloc`, and `std` in the `crates` list without defining `sysroot_src`. Consequently, rust-analyzer fails to identify them as sysroot crates, breaking IDE support for primitive methods (e.g., `0_i32.rotate_left(0)`). However, specifying `sysroot_src` creates a new issue: it implicitly adds `std` as a dependency to all kernel module crates, which are actually compiled with `-Zcrate-attr=no_std`. Since rust-analyzer cannot see compiler flags passed outside of the project definition, we need a method to explicitly specify `#![no_std]` or, more generally, crate-level attributes through the project configuration. To resolve this, extend the `rust-project.json` format with a new `crate_attrs` field. This allows users to specify crate-level attributes such as `#![no_std]` directly into the configuration, enabling rust-analyzer to respect them when analyzing crates. References: - The original Zulip discussion: https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Primitive.20type.20inherent.20method.20lookup.20fails/with/562983853 --- .../rust-analyzer/crates/base-db/src/input.rs | 19 ++++ .../rust-analyzer/crates/hir-def/src/attrs.rs | 92 +++++++++++++++---- .../crates/hir-def/src/item_tree.rs | 52 ++++++++++- .../crates/hir-def/src/item_tree/attrs.rs | 59 ++++++++++-- .../crates/hir-def/src/item_tree/tests.rs | 42 +++++++++ .../crates/hir-def/src/nameres/collector.rs | 13 +++ .../hir-def/src/nameres/tests/incremental.rs | 2 + .../rust-analyzer/crates/hir/src/semantics.rs | 16 +++- .../src/handlers/unused_variables.rs | 40 ++++++++ .../crates/ide-diagnostics/src/lib.rs | 23 +++-- .../crates/ide/src/doc_links/tests.rs | 15 +++ src/tools/rust-analyzer/crates/ide/src/lib.rs | 2 + .../rust-analyzer/crates/ide/src/status.rs | 2 + .../crates/project-model/src/project_json.rs | 5 + .../crates/project-model/src/tests.rs | 9 ++ .../crates/project-model/src/workspace.rs | 5 + .../project-model/test_data/crate-attrs.json | 13 +++ .../cargo_hello_world_project_model.txt | 5 + ...project_model_with_selective_overrides.txt | 5 + ..._project_model_with_wildcard_overrides.txt | 5 + .../output/rust_project_cfg_groups.txt | 2 + .../output/rust_project_crate_attrs.txt | 54 +++++++++++ ...rust_project_hello_world_project_model.txt | 1 + .../crates/test-fixture/src/lib.rs | 6 ++ .../crates/test-utils/src/fixture.rs | 18 +++- .../docs/book/src/non_cargo_based_projects.md | 9 ++ 26 files changed, 473 insertions(+), 41 deletions(-) create mode 100644 src/tools/rust-analyzer/crates/project-model/test_data/crate-attrs.json create mode 100644 src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_crate_attrs.txt diff --git a/src/tools/rust-analyzer/crates/base-db/src/input.rs b/src/tools/rust-analyzer/crates/base-db/src/input.rs index 14649dde648f..240f1264917a 100644 --- a/src/tools/rust-analyzer/crates/base-db/src/input.rs +++ b/src/tools/rust-analyzer/crates/base-db/src/input.rs @@ -351,6 +351,8 @@ pub struct CrateData { /// declared in source via `extern crate test`. pub dependencies: Vec>, pub origin: CrateOrigin, + /// Extra crate-level attributes, including the surrounding `#![]`. + pub crate_attrs: Box<[Box]>, pub is_proc_macro: bool, /// The working directory to run proc-macros in invoked in the context of this crate. /// This is the workspace root of the cargo workspace for workspace members, the crate manifest @@ -530,6 +532,7 @@ impl CrateGraphBuilder { mut potential_cfg_options: Option, mut env: Env, origin: CrateOrigin, + crate_attrs: Vec, is_proc_macro: bool, proc_macro_cwd: Arc, ws_data: Arc, @@ -539,12 +542,17 @@ impl CrateGraphBuilder { if let Some(potential_cfg_options) = &mut potential_cfg_options { potential_cfg_options.shrink_to_fit(); } + let crate_attrs: Vec<_> = crate_attrs + .into_iter() + .map(|raw_attr| format!("#![{raw_attr}]").into_boxed_str()) + .collect(); self.arena.alloc(CrateBuilder { basic: CrateData { root_file_id, edition, dependencies: Vec::new(), origin, + crate_attrs: crate_attrs.into_boxed_slice(), is_proc_macro, proc_macro_cwd, }, @@ -648,6 +656,7 @@ impl CrateGraphBuilder { edition: krate.basic.edition, is_proc_macro: krate.basic.is_proc_macro, origin: krate.basic.origin.clone(), + crate_attrs: krate.basic.crate_attrs.clone(), root_file_id: krate.basic.root_file_id, proc_macro_cwd: krate.basic.proc_macro_cwd.clone(), }; @@ -975,6 +984,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -988,6 +998,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1001,6 +1012,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1034,6 +1046,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1047,6 +1060,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1075,6 +1089,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1088,6 +1103,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1101,6 +1117,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1129,6 +1146,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), @@ -1142,6 +1160,7 @@ mod tests { Default::default(), Env::default(), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, Arc::new(AbsPathBuf::assert_utf8(std::env::current_dir().unwrap())), empty_ws_data(), diff --git a/src/tools/rust-analyzer/crates/hir-def/src/attrs.rs b/src/tools/rust-analyzer/crates/hir-def/src/attrs.rs index febc794b5a05..34a9230794d1 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/attrs.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/attrs.rs @@ -39,7 +39,7 @@ use rustc_abi::ReprOptions; use rustc_hash::FxHashSet; use smallvec::SmallVec; use syntax::{ - AstNode, AstToken, NodeOrToken, SmolStr, SyntaxNode, SyntaxToken, T, + AstNode, AstToken, NodeOrToken, SmolStr, SourceFile, SyntaxNode, SyntaxToken, T, ast::{self, AttrDocCommentIter, HasAttrs, IsString, TokenTreeChildren}, }; use tt::{TextRange, TextSize}; @@ -292,35 +292,69 @@ bitflags::bitflags! { } } +pub fn parse_extra_crate_attrs(db: &dyn DefDatabase, krate: Crate) -> Option { + let crate_data = krate.data(db); + let crate_attrs = &crate_data.crate_attrs; + if crate_attrs.is_empty() { + return None; + } + // All attributes are already enclosed in `#![]`. + let combined = crate_attrs.concat(); + let p = SourceFile::parse(&combined, crate_data.edition); + + let errs = p.errors(); + if !errs.is_empty() { + let base_msg = "Failed to parse extra crate-level attribute"; + let crate_name = + krate.extra_data(db).display_name.as_ref().map_or("{unknown}", |name| name.as_str()); + let mut errs = errs.iter().peekable(); + let mut offset = TextSize::from(0); + for raw_attr in crate_attrs { + let attr_end = offset + TextSize::of(&**raw_attr); + if errs.peeking_take_while(|e| e.range().start() < attr_end).count() > 0 { + tracing::error!("{base_msg} {raw_attr} for crate {crate_name}"); + } + offset = attr_end + } + return None; + } + + Some(p.tree()) +} + fn attrs_source( db: &dyn DefDatabase, owner: AttrDefId, -) -> (InFile, Option>, Crate) { +) -> (InFile, Option>, Option, Crate) { let (owner, krate) = match owner { AttrDefId::ModuleId(id) => { let def_map = id.def_map(db); - let (definition, declaration) = match def_map[id].origin { + let krate = def_map.krate(); + let (definition, declaration, extra_crate_attrs) = match def_map[id].origin { ModuleOrigin::CrateRoot { definition } => { - let file = db.parse(definition).tree(); - (InFile::new(definition.into(), ast::AnyHasAttrs::from(file)), None) + let definition_source = db.parse(definition).tree(); + let definition = InFile::new(definition.into(), definition_source.into()); + let extra_crate_attrs = parse_extra_crate_attrs(db, krate); + (definition, None, extra_crate_attrs) } ModuleOrigin::File { declaration, declaration_tree_id, definition, .. } => { + let definition_source = db.parse(definition).tree(); + let definition = InFile::new(definition.into(), definition_source.into()); let declaration = InFile::new(declaration_tree_id.file_id(), declaration); let declaration = declaration.with_value(declaration.to_node(db)); - let definition_source = db.parse(definition).tree(); - (InFile::new(definition.into(), definition_source.into()), Some(declaration)) + (definition, Some(declaration), None) } ModuleOrigin::Inline { definition_tree_id, definition } => { let definition = InFile::new(definition_tree_id.file_id(), definition); let definition = definition.with_value(definition.to_node(db).into()); - (definition, None) + (definition, None, None) } ModuleOrigin::BlockExpr { block, .. } => { let definition = block.to_node(db); - (block.with_value(definition.into()), None) + (block.with_value(definition.into()), None, None) } }; - return (definition, declaration, def_map.krate()); + return (definition, declaration, extra_crate_attrs, krate); } AttrDefId::AdtId(AdtId::StructId(it)) => attrs_from_ast_id_loc(db, it), AttrDefId::AdtId(AdtId::UnionId(it)) => attrs_from_ast_id_loc(db, it), @@ -339,7 +373,7 @@ fn attrs_source( AttrDefId::ExternCrateId(it) => attrs_from_ast_id_loc(db, it), AttrDefId::UseId(it) => attrs_from_ast_id_loc(db, it), }; - (owner, None, krate) + (owner, None, None, krate) } fn collect_attrs( @@ -347,14 +381,15 @@ fn collect_attrs( owner: AttrDefId, mut callback: impl FnMut(Meta) -> ControlFlow, ) -> Option { - let (source, outer_mod_decl, krate) = attrs_source(db, owner); + let (source, outer_mod_decl, extra_crate_attrs, krate) = attrs_source(db, owner); + let extra_attrs = extra_crate_attrs + .into_iter() + .flat_map(|src| src.attrs()) + .chain(outer_mod_decl.into_iter().flat_map(|it| it.value.attrs())); let mut cfg_options = None; expand_cfg_attr( - outer_mod_decl - .into_iter() - .flat_map(|it| it.value.attrs()) - .chain(ast::attrs_including_inner(&source.value)), + extra_attrs.chain(ast::attrs_including_inner(&source.value)), || cfg_options.get_or_insert_with(|| krate.cfg_options(db)), move |meta, _, _, _| callback(meta), ) @@ -1013,10 +1048,12 @@ impl AttrFlags { pub fn doc_html_root_url(db: &dyn DefDatabase, krate: Crate) -> Option { let root_file_id = krate.root_file_id(db); let syntax = db.parse(root_file_id).tree(); + let extra_crate_attrs = + parse_extra_crate_attrs(db, krate).into_iter().flat_map(|src| src.attrs()); let mut cfg_options = None; expand_cfg_attr( - syntax.attrs(), + extra_crate_attrs.chain(syntax.attrs()), || cfg_options.get_or_insert(krate.cfg_options(db)), |attr, _, _, _| { if let Meta::TokenTree { path, tt } = attr @@ -1231,8 +1268,11 @@ impl AttrFlags { // We LRU this query because it is only used by IDE. #[salsa::tracked(returns(ref), lru = 250)] pub fn docs(db: &dyn DefDatabase, owner: AttrDefId) -> Option> { - let (source, outer_mod_decl, krate) = attrs_source(db, owner); + let (source, outer_mod_decl, _extra_crate_attrs, krate) = attrs_source(db, owner); let inner_attrs_node = source.value.inner_attributes_node(); + // Note: we don't have to pass down `_extra_crate_attrs` here, since `extract_docs` + // does not handle crate-level attributes related to docs. + // See: https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#at-the-crate-level extract_docs(&|| krate.cfg_options(db), source, outer_mod_decl, inner_attrs_node) } @@ -1480,8 +1520,9 @@ mod tests { use test_fixture::WithFixture; use tt::{TextRange, TextSize}; - use crate::attrs::IsInnerDoc; - use crate::{attrs::Docs, test_db::TestDB}; + use crate::AttrDefId; + use crate::attrs::{AttrFlags, Docs, IsInnerDoc}; + use crate::test_db::TestDB; #[test] fn docs() { @@ -1617,4 +1658,15 @@ mod tests { Some((in_file(range(263, 265)), IsInnerDoc::Yes)) ); } + + #[test] + fn crate_attrs() { + let fixture = r#" +//- /lib.rs crate:foo crate-attr:no_std crate-attr:cfg(target_arch="x86") + "#; + let (db, file_id) = TestDB::with_single_file(fixture); + let module = db.module_for_file(file_id.file_id(&db)); + let attrs = AttrFlags::query(&db, AttrDefId::ModuleId(module)); + assert!(attrs.contains(AttrFlags::IS_NO_STD | AttrFlags::HAS_CFG)); + } } diff --git a/src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs b/src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs index 2a104fff2b92..6eab8888d92d 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs @@ -44,6 +44,7 @@ use std::{ }; use ast::{AstNode, StructKind}; +use cfg::CfgOptions; use hir_expand::{ ExpandTo, HirFileId, mod_path::{ModPath, PathKind}, @@ -52,13 +53,17 @@ use hir_expand::{ use intern::Interned; use la_arena::{Idx, RawIdx}; use rustc_hash::FxHashMap; -use span::{AstIdNode, Edition, FileAstId, SyntaxContext}; +use span::{ + AstIdNode, Edition, FileAstId, NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER, Span, SpanAnchor, + SyntaxContext, +}; use stdx::never; -use syntax::{SyntaxKind, ast, match_ast}; +use syntax::{SourceFile, SyntaxKind, ast, match_ast}; use thin_vec::ThinVec; use triomphe::Arc; +use tt::TextRange; -use crate::{BlockId, Lookup, db::DefDatabase}; +use crate::{BlockId, Lookup, attrs::parse_extra_crate_attrs, db::DefDatabase}; pub(crate) use crate::item_tree::{ attrs::*, @@ -88,6 +93,33 @@ impl fmt::Debug for RawVisibilityId { } } +fn lower_extra_crate_attrs<'a>( + db: &dyn DefDatabase, + crate_attrs_as_src: SourceFile, + file_id: span::EditionedFileId, + cfg_options: &dyn Fn() -> &'a CfgOptions, +) -> AttrsOrCfg { + #[derive(Copy, Clone)] + struct FakeSpanMap { + file_id: span::EditionedFileId, + } + impl syntax_bridge::SpanMapper for FakeSpanMap { + fn span_for(&self, range: TextRange) -> Span { + Span { + range, + anchor: SpanAnchor { + file_id: self.file_id, + ast_id: NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER, + }, + ctx: SyntaxContext::root(self.file_id.edition()), + } + } + } + + let span_map = FakeSpanMap { file_id }; + AttrsOrCfg::lower(db, &crate_attrs_as_src, cfg_options, span_map) +} + #[salsa_macros::tracked(returns(deref))] pub(crate) fn file_item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc { let _p = tracing::info_span!("file_item_tree_query", ?file_id).entered(); @@ -98,7 +130,19 @@ pub(crate) fn file_item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> let mut item_tree = match_ast! { match syntax { ast::SourceFile(file) => { - let top_attrs = ctx.lower_attrs(&file); + let krate = file_id.krate(db); + let root_file_id = krate.root_file_id(db); + let extra_top_attrs = (file_id == root_file_id).then(|| { + parse_extra_crate_attrs(db, krate).map(|crate_attrs| { + let file_id = root_file_id.editioned_file_id(db); + lower_extra_crate_attrs(db, crate_attrs, file_id, &|| ctx.cfg_options()) + }) + }).flatten(); + let top_attrs = match extra_top_attrs { + Some(attrs @ AttrsOrCfg::Enabled { .. }) => attrs.merge(ctx.lower_attrs(&file)), + Some(attrs @ AttrsOrCfg::CfgDisabled(_)) => attrs, + None => ctx.lower_attrs(&file) + }; let mut item_tree = ctx.lower_module_items(&file); item_tree.top_attrs = top_attrs; item_tree diff --git a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/attrs.rs b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/attrs.rs index 5c635a4b3831..81a9b28b628e 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/attrs.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/attrs.rs @@ -16,9 +16,9 @@ use hir_expand::{ attrs::{Attr, AttrId, AttrInput, Meta, collect_item_tree_attrs}, mod_path::ModPath, name::Name, - span_map::SpanMapRef, }; use intern::{Interned, Symbol, sym}; +use span::Span; use syntax::{AstNode, T, ast}; use syntax_bridge::DocCommentDesugarMode; use tt::token_to_literal; @@ -42,12 +42,15 @@ impl Default for AttrsOrCfg { } impl AttrsOrCfg { - pub(crate) fn lower<'a>( + pub(crate) fn lower<'a, S>( db: &dyn DefDatabase, owner: &dyn ast::HasAttrs, cfg_options: &dyn Fn() -> &'a CfgOptions, - span_map: SpanMapRef<'_>, - ) -> AttrsOrCfg { + span_map: S, + ) -> AttrsOrCfg + where + S: syntax_bridge::SpanMapper + Copy, + { let mut attrs = Vec::new(); let result = collect_item_tree_attrs::(owner, cfg_options, |meta, container, _, _| { @@ -55,17 +58,17 @@ impl AttrsOrCfg { // tracking. let (span, path_range, input) = match meta { Meta::NamedKeyValue { path_range, name: _, value } => { - let span = span_map.span_for_range(path_range); + let span = span_map.span_for(path_range); let input = value.map(|value| { Box::new(AttrInput::Literal(token_to_literal( value.text(), - span_map.span_for_range(value.text_range()), + span_map.span_for(value.text_range()), ))) }); (span, path_range, input) } Meta::TokenTree { path, tt } => { - let span = span_map.span_for_range(path.range); + let span = span_map.span_for(path.range); let tt = syntax_bridge::syntax_node_to_token_tree( tt.syntax(), span_map, @@ -76,7 +79,7 @@ impl AttrsOrCfg { (span, path.range, input) } Meta::Path { path } => { - let span = span_map.span_for_range(path.range); + let span = span_map.span_for(path.range); (span, path.range, None) } }; @@ -90,7 +93,7 @@ impl AttrsOrCfg { .filter(|it| it.kind().is_any_identifier()); ModPath::from_tokens( db, - &mut |range| span_map.span_for_range(range).ctx, + &mut |range| span_map.span_for(range).ctx, is_abs, segments, ) @@ -107,6 +110,44 @@ impl AttrsOrCfg { None => AttrsOrCfg::Enabled { attrs }, } } + + // Merges two `AttrsOrCfg`s, assuming `self` is placed before `other` in the source code. + // The operation follows these rules: + // + // - If `self` and `other` are both `AttrsOrCfg::Enabled`, the result is a new + // `AttrsOrCfg::Enabled`. It contains the concatenation of `self`'s attributes followed by + // `other`'s. + // - If `self` is `AttrsOrCfg::Enabled` but `other` is `AttrsOrCfg::CfgDisabled`, the result + // is a new `AttrsOrCfg::CfgDisabled`. It contains the concatenation of `self`'s attributes + // followed by `other`'s. + // - If `self` is `AttrsOrCfg::CfgDisabled`, return `self` as-is. + // + // The rationale is that attribute collection is sequential and order-sensitive. This operation + // preserves those semantics when combining attributes from two different sources. + // `AttrsOrCfg::CfgDisabled` marks a point where collection stops due to a false `#![cfg(...)]` + // condition. It acts as a "breakpoint": attributes beyond it are not collected. Therefore, + // when merging, an `AttrsOrCfg::CfgDisabled` on the left-hand side short-circuits the + // operation, while an `AttrsOrCfg::CfgDisabled` on the right-hand side preserves all + // attributes collected up to that point. + // + // Note that this operation is neither commutative nor associative. + pub(crate) fn merge(self, other: AttrsOrCfg) -> AttrsOrCfg { + match (self, other) { + (AttrsOrCfg::Enabled { attrs }, AttrsOrCfg::Enabled { attrs: other_attrs }) => { + let mut v = attrs.0.into_vec(); + v.extend(other_attrs.0); + AttrsOrCfg::Enabled { attrs: AttrsOwned(v.into_boxed_slice()) } + } + (AttrsOrCfg::Enabled { attrs }, AttrsOrCfg::CfgDisabled(mut other)) => { + let other_attrs = &mut other.1; + let mut v = attrs.0.into_vec(); + v.extend(std::mem::take(&mut other_attrs.0)); + other_attrs.0 = v.into_boxed_slice(); + AttrsOrCfg::CfgDisabled(other) + } + (this @ AttrsOrCfg::CfgDisabled(_), _) => this, + } + } } #[derive(Debug, PartialEq, Eq)] diff --git a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/tests.rs b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/tests.rs index a57432f33c3d..1926ed74e869 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/item_tree/tests.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/item_tree/tests.rs @@ -244,3 +244,45 @@ pub(self) struct S; "#]], ) } + +#[test] +fn crate_attrs_should_preserve_order() { + check( + r#" +//- /main.rs crate:foo crate-attr:no_std crate-attr:features(f16) crate-attr:crate_type="bin" + "#, + expect![[r##" + #![no_std] + #![features(f16)] + #![crate_type = "bin"] + "##]], + ); +} + +#[test] +fn crate_attrs_with_disabled_cfg_injected() { + check( + r#" +//- /main.rs crate:foo crate-attr:no_std crate-attr:cfg(false) crate-attr:features(f16,f128) crate-attr:crate_type="bin" + "#, + expect![[r#" + #![no_std] + #![cfg(false)] + "#]], + ); +} + +#[test] +fn crate_attrs_with_disabled_cfg_in_source() { + check( + r#" +//- /lib.rs crate:foo crate-attr:no_std +#![cfg(false)] +#![no_core] + "#, + expect![[r#" + #![no_std] + #![cfg(false)] + "#]], + ); +} diff --git a/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs b/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs index 08edf41c5694..10581378bef9 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs @@ -2608,4 +2608,17 @@ foo!(KABOOM); "#, ); } + + #[test] + fn crate_attrs() { + let fixture = r#" +//- /lib.rs crate:foo crate-attr:recursion_limit="4" crate-attr:no_core crate-attr:no_std crate-attr:feature(register_tool) + "#; + let (db, file_id) = TestDB::with_single_file(fixture); + let def_map = crate_def_map(&db, file_id.krate(&db)); + assert_eq!(def_map.recursion_limit(), 4); + assert!(def_map.is_no_core()); + assert!(def_map.is_no_std()); + assert!(def_map.is_unstable_feature_enabled(&sym::register_tool)); + } } diff --git a/src/tools/rust-analyzer/crates/hir-def/src/nameres/tests/incremental.rs b/src/tools/rust-analyzer/crates/hir-def/src/nameres/tests/incremental.rs index 57243346019f..225ba958634e 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/nameres/tests/incremental.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/nameres/tests/incremental.rs @@ -76,6 +76,7 @@ pub const BAZ: u32 = 0; None, Env::default(), CrateOrigin::Local { repo: None, name: Some(Symbol::intern(crate_name)) }, + Vec::new(), false, Arc::new( // FIXME: This is less than ideal @@ -117,6 +118,7 @@ pub const BAZ: u32 = 0; expect![[r#" [ "crate_local_def_map", + "file_item_tree_query", "crate_local_def_map", ] "#]], diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs index 80fac3512ece..b65a24d61c6e 100644 --- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs @@ -14,6 +14,7 @@ use base_db::FxIndexSet; use either::Either; use hir_def::{ DefWithBodyId, FunctionId, MacroId, StructId, TraitId, VariantId, + attrs::parse_extra_crate_attrs, expr_store::{Body, ExprOrPatSource, HygieneId, path::Path}, hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat}, nameres::{ModuleOrigin, crate_def_map}, @@ -266,14 +267,27 @@ impl Semantics<'_, DB> { pub fn lint_attrs( &self, + file_id: FileId, krate: Crate, item: ast::AnyHasAttrs, ) -> impl DoubleEndedIterator { let mut cfg_options = None; let cfg_options = || *cfg_options.get_or_insert_with(|| krate.id.cfg_options(self.db)); + + let is_crate_root = file_id == krate.root_file(self.imp.db); + let is_source_file = ast::SourceFile::can_cast(item.syntax().kind()); + let extra_crate_attrs = (is_crate_root && is_source_file) + .then(|| { + parse_extra_crate_attrs(self.imp.db, krate.id) + .into_iter() + .flat_map(|src| src.attrs()) + }) + .into_iter() + .flatten(); + let mut result = Vec::new(); hir_expand::attrs::expand_cfg_attr::( - ast::attrs_including_inner(&item), + extra_crate_attrs.chain(ast::attrs_including_inner(&item)), cfg_options, |attr, _, _, _| { let hir_expand::attrs::Meta::TokenTree { path, tt } = attr else { diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unused_variables.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unused_variables.rs index b7ec8fa53fa7..52a2f44fd0f8 100644 --- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unused_variables.rs +++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unused_variables.rs @@ -387,6 +387,46 @@ struct S { field : u32 } fn f(S { field }: error) { // ^^^^^ 💡 warn: unused variable } +"#, + ); + } + + #[test] + fn crate_attrs_lint_smoke_test() { + check_diagnostics( + r#" +//- /lib.rs crate:foo crate-attr:deny(unused_variables) +fn main() { + let x = 2; + //^ 💡 error: unused variable +} +"#, + ); + } + + #[test] + fn crate_attrs_should_not_override_lints_in_source() { + check_diagnostics( + r#" +//- /lib.rs crate:foo crate-attr:allow(unused_variables) +#![deny(unused_variables)] +fn main() { + let x = 2; + //^ 💡 error: unused variable +} +"#, + ); + } + + #[test] + fn crate_attrs_should_preserve_lint_order() { + check_diagnostics( + r#" +//- /lib.rs crate:foo crate-attr:allow(unused_variables) crate-attr:warn(unused_variables) +fn main() { + let x = 2; + //^ 💡 warn: unused variable +} "#, ); } diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs index 2b8474c3163b..0b321442497b 100644 --- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs +++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs @@ -485,7 +485,7 @@ pub fn semantic_diagnostics( // The edition isn't accurate (each diagnostics may have its own edition due to macros), // but it's okay as it's only being used for error recovery. - handle_lints(&ctx.sema, krate, &mut lints, editioned_file_id.edition(db)); + handle_lints(&ctx.sema, file_id, krate, &mut lints, editioned_file_id.edition(db)); res.retain(|d| d.severity != Severity::Allow); @@ -593,6 +593,7 @@ fn build_lints_map( fn handle_lints( sema: &Semantics<'_, RootDatabase>, + file_id: FileId, krate: hir::Crate, diagnostics: &mut [(InFile, &mut Diagnostic)], edition: Edition, @@ -609,10 +610,10 @@ fn handle_lints( } let mut diag_severity = - lint_severity_at(sema, krate, node, &lint_groups(&diag.code, edition)); + lint_severity_at(sema, file_id, krate, node, &lint_groups(&diag.code, edition)); if let outline_diag_severity @ Some(_) = - find_outline_mod_lint_severity(sema, krate, node, diag, edition) + find_outline_mod_lint_severity(sema, file_id, krate, node, diag, edition) { diag_severity = outline_diag_severity; } @@ -635,6 +636,7 @@ fn default_lint_severity(lint: &Lint, edition: Edition) -> Severity { fn find_outline_mod_lint_severity( sema: &Semantics<'_, RootDatabase>, + file_id: FileId, krate: hir::Crate, node: &InFile, diag: &Diagnostic, @@ -651,6 +653,7 @@ fn find_outline_mod_lint_severity( let lint_groups = lint_groups(&diag.code, edition); lint_attrs( sema, + file_id, krate, ast::AnyHasAttrs::cast(module_source_file.value).expect("SourceFile always has attrs"), ) @@ -659,6 +662,7 @@ fn find_outline_mod_lint_severity( fn lint_severity_at( sema: &Semantics<'_, RootDatabase>, + file_id: FileId, krate: hir::Crate, node: &InFile, lint_groups: &LintGroups, @@ -667,21 +671,28 @@ fn lint_severity_at( .ancestors() .filter_map(ast::AnyHasAttrs::cast) .find_map(|ancestor| { - lint_attrs(sema, krate, ancestor) + lint_attrs(sema, file_id, krate, ancestor) .find_map(|(lint, severity)| lint_groups.contains(&lint).then_some(severity)) }) .or_else(|| { - lint_severity_at(sema, krate, &sema.find_parent_file(node.file_id)?, lint_groups) + lint_severity_at( + sema, + file_id, + krate, + &sema.find_parent_file(node.file_id)?, + lint_groups, + ) }) } // FIXME: Switch this to analysis' `expand_cfg_attr`. fn lint_attrs( sema: &Semantics<'_, RootDatabase>, + file_id: FileId, krate: hir::Crate, ancestor: ast::AnyHasAttrs, ) -> impl Iterator { - sema.lint_attrs(krate, ancestor).rev().map(|(lint_attr, lint)| { + sema.lint_attrs(file_id, krate, ancestor).rev().map(|(lint_attr, lint)| { let severity = match lint_attr { hir::LintAttr::Allow | hir::LintAttr::Expect => Severity::Allow, hir::LintAttr::Warn => Severity::Warning, diff --git a/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs b/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs index 8594a0a22475..a61a6c677f65 100644 --- a/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs +++ b/src/tools/rust-analyzer/crates/ide/src/doc_links/tests.rs @@ -658,6 +658,21 @@ pub struct B$0ar ); } +#[test] +fn rewrite_html_root_url_using_crate_attr() { + check_rewrite( + r#" +//- /main.rs crate:foo crate-attr:doc(arbitrary_attribute="test",html_root_url="https:/example.com",arbitrary_attribute2) +pub mod foo { + pub struct Foo; +} +/// [Foo](foo::Foo) +pub struct B$0ar +"#, + expect![[r#"[Foo](https://example.com/foo/foo/struct.Foo.html)"#]], + ); +} + #[test] fn rewrite_on_field() { check_rewrite( diff --git a/src/tools/rust-analyzer/crates/ide/src/lib.rs b/src/tools/rust-analyzer/crates/ide/src/lib.rs index 94362649043d..0066ceed21ed 100644 --- a/src/tools/rust-analyzer/crates/ide/src/lib.rs +++ b/src/tools/rust-analyzer/crates/ide/src/lib.rs @@ -254,6 +254,7 @@ impl Analysis { TryFrom::try_from(&*std::env::current_dir().unwrap().as_path().to_string_lossy()) .unwrap(), ); + let crate_attrs = Vec::new(); cfg_options.insert_atom(sym::test); crate_graph.add_crate_root( file_id, @@ -264,6 +265,7 @@ impl Analysis { None, Env::default(), CrateOrigin::Local { repo: None, name: None }, + crate_attrs, false, proc_macro_cwd, Arc::new(CrateWorkspaceData { diff --git a/src/tools/rust-analyzer/crates/ide/src/status.rs b/src/tools/rust-analyzer/crates/ide/src/status.rs index cfcd76d2aa3b..7f377e416b32 100644 --- a/src/tools/rust-analyzer/crates/ide/src/status.rs +++ b/src/tools/rust-analyzer/crates/ide/src/status.rs @@ -40,6 +40,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { edition, dependencies, origin, + crate_attrs, is_proc_macro, proc_macro_cwd, } = crate_id.data(db); @@ -62,6 +63,7 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option) -> String { format_to!(buf, " Potential cfgs: {:?}\n", potential_cfg_options); format_to!(buf, " Env: {:?}\n", env); format_to!(buf, " Origin: {:?}\n", origin); + format_to!(buf, " Extra crate-level attrs: {:?}\n", crate_attrs); format_to!(buf, " Is a proc macro crate: {}\n", is_proc_macro); format_to!(buf, " Proc macro cwd: {:?}\n", proc_macro_cwd); let deps = dependencies diff --git a/src/tools/rust-analyzer/crates/project-model/src/project_json.rs b/src/tools/rust-analyzer/crates/project-model/src/project_json.rs index 041b9accf41d..b3478d2cfe03 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/project_json.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/project_json.rs @@ -163,6 +163,7 @@ impl ProjectJson { cfg, target: crate_data.target, env: crate_data.env, + crate_attrs: crate_data.crate_attrs, proc_macro_dylib_path: crate_data .proc_macro_dylib_path .map(absolutize_on_base), @@ -244,6 +245,8 @@ pub struct Crate { pub(crate) cfg: Vec, pub(crate) target: Option, pub(crate) env: FxHashMap, + // Extra crate-level attributes, without the surrounding `#![]`. + pub(crate) crate_attrs: Vec, pub(crate) proc_macro_dylib_path: Option, pub(crate) is_workspace_member: bool, pub(crate) include: Vec, @@ -365,6 +368,8 @@ struct CrateData { target: Option, #[serde(default)] env: FxHashMap, + #[serde(default)] + crate_attrs: Vec, proc_macro_dylib_path: Option, is_workspace_member: Option, source: Option, diff --git a/src/tools/rust-analyzer/crates/project-model/src/tests.rs b/src/tools/rust-analyzer/crates/project-model/src/tests.rs index 1908fc02904a..a03ed562e1be 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/tests.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/tests.rs @@ -198,6 +198,15 @@ fn rust_project_cfg_groups() { check_crate_graph(crate_graph, expect_file!["../test_data/output/rust_project_cfg_groups.txt"]); } +#[test] +fn rust_project_crate_attrs() { + let (crate_graph, _proc_macros) = load_rust_project("crate-attrs.json"); + check_crate_graph( + crate_graph, + expect_file!["../test_data/output/rust_project_crate_attrs.txt"], + ); +} + #[test] fn crate_graph_dedup_identical() { let (mut crate_graph, proc_macros) = load_cargo("regex-metadata.json"); diff --git a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs index 747aa68f082d..fa3a79e041e0 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs +++ b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs @@ -1093,6 +1093,7 @@ fn project_json_to_crate_graph( cfg, target, env, + crate_attrs, proc_macro_dylib_path, is_proc_macro, repository, @@ -1163,6 +1164,7 @@ fn project_json_to_crate_graph( } else { CrateOrigin::Local { repo: None, name: None } }, + crate_attrs.clone(), *is_proc_macro, match proc_macro_cwd { Some(path) => Arc::new(path.clone()), @@ -1467,6 +1469,7 @@ fn detached_file_to_crate_graph( repo: None, name: display_name.map(|n| n.canonical_name().to_owned()), }, + Vec::new(), false, Arc::new(detached_file.parent().to_path_buf()), crate_ws_data, @@ -1647,6 +1650,7 @@ fn add_target_crate_root( potential_cfg_options, env, origin, + Vec::new(), matches!(kind, TargetKind::Lib { is_proc_macro: true }), proc_macro_cwd, crate_ws_data, @@ -1830,6 +1834,7 @@ fn sysroot_to_crate_graph( None, Env::default(), CrateOrigin::Lang(LangCrateOrigin::from(&*stitched[krate].name)), + Vec::new(), false, Arc::new(stitched[krate].root.parent().to_path_buf()), crate_ws_data.clone(), diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/crate-attrs.json b/src/tools/rust-analyzer/crates/project-model/test_data/crate-attrs.json new file mode 100644 index 000000000000..b2a7e3715017 --- /dev/null +++ b/src/tools/rust-analyzer/crates/project-model/test_data/crate-attrs.json @@ -0,0 +1,13 @@ +{ + "sysroot_src": null, + "crates": [ + { + "display_name": "foo", + "root_module": "$ROOT$src/lib.rs", + "edition": "2024", + "deps": [], + "crate_attrs": ["no_std", "feature(f16,f128)", "crate_type = \"lib\""], + "is_workspace_member": true + } + ] +} diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt index 4f6ce4dc9537..a895ef53afa0 100644 --- a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt +++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt @@ -21,6 +21,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -106,6 +107,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -191,6 +193,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -276,6 +279,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -344,6 +348,7 @@ ), name: "libc", }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt index 4f6ce4dc9537..a895ef53afa0 100644 --- a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt +++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt @@ -21,6 +21,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -106,6 +107,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -191,6 +193,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -276,6 +279,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -344,6 +348,7 @@ ), name: "libc", }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt index 6862918e09ae..9eb47947b6fd 100644 --- a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt +++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt @@ -21,6 +21,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -105,6 +106,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -189,6 +191,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -273,6 +276,7 @@ "hello-world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$hello-world", @@ -340,6 +344,7 @@ ), name: "libc", }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_cfg_groups.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_cfg_groups.txt index 28ad3236ae81..32f9206a3e16 100644 --- a/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_cfg_groups.txt +++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_cfg_groups.txt @@ -12,6 +12,7 @@ "hello_world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$", @@ -62,6 +63,7 @@ "other_crate", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$", diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_crate_attrs.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_crate_attrs.txt new file mode 100644 index 000000000000..21b484bc0c42 --- /dev/null +++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_crate_attrs.txt @@ -0,0 +1,54 @@ +{ + 0: CrateBuilder { + basic: CrateData { + root_file_id: FileId( + 1, + ), + edition: Edition2024, + dependencies: [], + origin: Local { + repo: None, + name: Some( + "foo", + ), + }, + crate_attrs: [ + "#![no_std]", + "#![feature(f16,f128)]", + "#![crate_type = \"lib\"]", + ], + is_proc_macro: false, + proc_macro_cwd: AbsPathBuf( + "$ROOT$", + ), + }, + extra: ExtraCrateData { + version: None, + display_name: Some( + CrateDisplayName { + crate_name: CrateName( + "foo", + ), + canonical_name: "foo", + }, + ), + potential_cfg_options: None, + }, + cfg_options: CfgOptions( + [ + "rust_analyzer", + "test", + "true", + ], + ), + env: Env { + entries: {}, + }, + ws_data: CrateWorkspaceData { + target: Err( + "test has no target data", + ), + toolchain: None, + }, + }, +} \ No newline at end of file diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt index dabb3aa67441..de793115b9d5 100644 --- a/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt +++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt @@ -12,6 +12,7 @@ "hello_world", ), }, + crate_attrs: [], is_proc_macro: false, proc_macro_cwd: AbsPathBuf( "$ROOT$", diff --git a/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs b/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs index 5e8b250c24a0..01e4215cfb86 100644 --- a/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs +++ b/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs @@ -239,6 +239,7 @@ impl ChangeFixture { Some(meta.cfg), meta.env, origin, + meta.crate_attrs, false, proc_macro_cwd.clone(), crate_ws_data.clone(), @@ -292,6 +293,7 @@ impl ChangeFixture { String::from("__ra_is_test_fixture"), )]), CrateOrigin::Lang(LangCrateOrigin::Core), + Vec::new(), false, proc_macro_cwd.clone(), crate_ws_data.clone(), @@ -322,6 +324,7 @@ impl ChangeFixture { Some(default_cfg), default_env, CrateOrigin::Local { repo: None, name: None }, + Vec::new(), false, proc_macro_cwd.clone(), crate_ws_data.clone(), @@ -385,6 +388,7 @@ impl ChangeFixture { String::from("__ra_is_test_fixture"), )]), CrateOrigin::Local { repo: None, name: None }, + Vec::new(), true, proc_macro_cwd, crate_ws_data, @@ -635,6 +639,7 @@ struct FileMeta { cfg: CfgOptions, edition: Edition, env: Env, + crate_attrs: Vec, introduce_new_source_root: Option, } @@ -666,6 +671,7 @@ impl FileMeta { cfg, edition: f.edition.map_or(Edition::CURRENT, |v| Edition::from_str(&v).unwrap()), env: f.env.into_iter().collect(), + crate_attrs: f.crate_attrs, introduce_new_source_root, } } diff --git a/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs b/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs index 831d2b30c1b6..1f6262c897c7 100644 --- a/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs +++ b/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs @@ -107,6 +107,11 @@ pub struct Fixture { /// /// Syntax: `env:PATH=/bin,RUST_LOG=debug` pub env: FxHashMap, + /// Specifies extra crate-level attributes injected at the top of the crate root file. + /// This must be used with `crate` meta. + /// + /// Syntax: `crate-attr:no_std crate-attr:features(f16,f128) crate-attr:cfg(target_arch="x86")` + pub crate_attrs: Vec, /// Introduces a new source root. This file **and the following /// files** will belong the new source root. This must be used /// with `crate` meta. @@ -275,6 +280,7 @@ impl FixtureWithProjectMeta { let mut krate = None; let mut deps = Vec::new(); + let mut crate_attrs = Vec::new(); let mut extern_prelude = None; let mut edition = None; let mut cfgs = Vec::new(); @@ -292,6 +298,7 @@ impl FixtureWithProjectMeta { match key { "crate" => krate = Some(value.to_owned()), "deps" => deps = value.split(',').map(|it| it.to_owned()).collect(), + "crate-attr" => crate_attrs.push(value.to_owned()), "extern-prelude" => { if value.is_empty() { extern_prelude = Some(Vec::new()); @@ -334,6 +341,7 @@ impl FixtureWithProjectMeta { line, krate, deps, + crate_attrs, extern_prelude, cfgs, edition, @@ -548,7 +556,7 @@ fn parse_fixture_gets_full_meta() { //- toolchain: nightly //- proc_macros: identity //- minicore: coerce_unsized -//- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo +//- /lib.rs crate:foo deps:bar,baz crate-attr:no_std crate-attr:features(f16,f128) crate-attr:cfg(target_arch="x86") cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo mod m; "#, ); @@ -561,6 +569,14 @@ mod m; assert_eq!("mod m;\n", meta.text); assert_eq!("foo", meta.krate.as_ref().unwrap()); + assert_eq!( + vec![ + "no_std".to_owned(), + "features(f16,f128)".to_owned(), + "cfg(target_arch=\"x86\")".to_owned() + ], + meta.crate_attrs + ); assert_eq!("/lib.rs", meta.path); assert_eq!(2, meta.env.len()); } diff --git a/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md b/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md index 74489a9046ba..e7df4a5d7668 100644 --- a/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md +++ b/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md @@ -144,6 +144,15 @@ interface Crate { /// Environment variables, used for /// the `env!` macro env: { [key: string]: string; }; + /// Extra crate-level attributes applied to this crate. + /// + /// rust-analyzer will behave as if these attributes + /// were present before the first source line of the + /// crate root. + /// + /// Each string should contain the contents of a `#![...]` + /// crate-level attribute, without the surrounding `#![]`. + crate_attrs?: string[]; /// Whether the crate is a proc-macro crate. is_proc_macro: boolean; From 186fc3c0003c70f73e7cdeddd51d2531c033d82a Mon Sep 17 00:00:00 2001 From: Redddy Date: Thu, 18 Dec 2025 12:00:12 +0900 Subject: [PATCH 287/489] Clarify serialization macros documentation remove `MetadataDecodable` and add `BlobDecodable` and `LazyDecodable`. --- src/doc/rustc-dev-guide/src/serialization.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index a6c2ee17a667..fcea4f3e605b 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -126,20 +126,21 @@ and `Encodable`. all `Encoders` and `Decoders`. These should be used in crates that don't depend on [`rustc_middle`], or that have to be serialized by a type that does not implement `TyEncoder`. -- [`MetadataEncodable`] and [`MetadataDecodable`] generate implementations that - only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`] and - [`rustc_metadata::rmeta::decoder::DecodeContext`]. These are used for types - that contain [`rustc_metadata::rmeta::`]`Lazy*`. +- [`MetadataEncodable`] generate implementations that + only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`]. +- [`BlobDecodable`] and [`LazyDecodable`] generate implementations that decode + with the metadata blob decoders in [`rustc_metadata::rmeta`]; use `BlobDecodable` + when the type has no lazy metadata handles, and `LazyDecodable` when it does. - `TyEncodable` and `TyDecodable` generate implementation that apply to any `TyEncoder` or `TyDecoder`. These should be used for types that are only serialized in crate metadata and/or the incremental cache, which is most serializable types in `rustc_middle`. -[`MetadataDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.MetadataDecodable.html +[`BlobDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.BlobDecodable.html +[`LazyDecodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.LazyDecodable.html [`MetadataEncodable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_macros/derive.MetadataEncodable.html [`rustc_macros`]: https://github.com/rust-lang/rust/tree/HEAD/compiler/rustc_macros -[`rustc_metadata::rmeta::`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/index.html -[`rustc_metadata::rmeta::decoder::DecodeContext`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/struct.DecodeContext.html +[`rustc_metadata::rmeta`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/index.html [`rustc_metadata::rmeta::encoder::EncodeContext`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/encoder/struct.EncodeContext.html [`rustc_middle`]: https://github.com/rust-lang/rust/tree/HEAD/compiler/rustc_middle From c92d39e454c407bc78820fa610bf9576ee995a4d Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Thu, 18 Dec 2025 04:58:27 +0000 Subject: [PATCH 288/489] Prepare for merging from rust-lang/rust This updates the rust-version file to 686f9cefc37c5bdec069a75357f0277b390657ca. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index dcf82c94aaee..11c138c28c24 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -0208ee09be465f69005a7a12c28d5eccac7d5f34 +686f9cefc37c5bdec069a75357f0277b390657ca From b48defae19f25b821fbd4236e2abf44823160f27 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 12 Dec 2025 11:53:05 -0800 Subject: [PATCH 289/489] Implement FlushFileBuffers --- .../miri/src/shims/windows/foreign_items.rs | 5 +++ src/tools/miri/src/shims/windows/fs.rs | 33 +++++++++++++++++++ src/tools/miri/tests/pass/shims/fs.rs | 14 +++++--- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index 7d30582c582c..3bc52dddfe8b 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -313,6 +313,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let res = this.SetFileInformationByHandle(handle, class, info, size)?; this.write_scalar(res, dest)?; } + "FlushFileBuffers" => { + let [handle] = this.check_shim_sig_lenient(abi, sys_conv, link_name, args)?; + let res = this.FlushFileBuffers(handle)?; + this.write_scalar(res, dest)?; + } "DeleteFileW" => { let [file_name] = this.check_shim_sig_lenient(abi, sys_conv, link_name, args)?; let res = this.DeleteFileW(file_name)?; diff --git a/src/tools/miri/src/shims/windows/fs.rs b/src/tools/miri/src/shims/windows/fs.rs index 967164cb250d..e5a98e86d645 100644 --- a/src/tools/miri/src/shims/windows/fs.rs +++ b/src/tools/miri/src/shims/windows/fs.rs @@ -457,6 +457,39 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } + fn FlushFileBuffers( + &mut self, + file: &OpTy<'tcx>, // HANDLE + ) -> InterpResult<'tcx, Scalar> { + // ^ returns BOOL (i32 on Windows) + let this = self.eval_context_mut(); + this.assert_target_os(Os::Windows, "FlushFileBuffers"); + + let file = this.read_handle(file, "FlushFileBuffers")?; + let Handle::File(fd_num) = file else { this.invalid_handle("FlushFileBuffers")? }; + let Some(desc) = this.machine.fds.get(fd_num) else { + this.invalid_handle("FlushFileBuffers")? + }; + let file = desc.downcast::().ok_or_else(|| { + err_unsup_format!( + "`FlushFileBuffers` is only supported on file-backed file descriptors" + ) + })?; + + if !file.writable { + this.set_last_error(IoError::WindowsError("ERROR_ACCESS_DENIED"))?; + return interp_ok(this.eval_windows("c", "FALSE")); + } + + match file.file.sync_all() { + Ok(_) => interp_ok(this.eval_windows("c", "TRUE")), + Err(e) => { + this.set_last_error(e)?; + interp_ok(this.eval_windows("c", "FALSE")) + } + } + } + fn DeleteFileW( &mut self, file_name: &OpTy<'tcx>, // LPCWSTR diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index 70bca703cc2f..648c90b5dd97 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -29,9 +29,9 @@ fn main() { test_from_raw_os_error(); test_file_clone(); test_file_set_len(); + test_file_sync(); // Windows file handling is very incomplete. if cfg!(not(windows)) { - test_file_sync(); test_rename(); test_directory(); test_canonicalize(); @@ -231,10 +231,16 @@ fn test_file_sync() { file.sync_data().unwrap(); file.sync_all().unwrap(); - // Test that we can call sync_data and sync_all on a file opened for reading. + // Test that we can call sync_data and sync_all on a file opened for reading on unix, but not + // on Windows let file = File::open(&path).unwrap(); - file.sync_data().unwrap(); - file.sync_all().unwrap(); + if cfg!(unix) { + file.sync_data().unwrap(); + file.sync_all().unwrap(); + } else { + file.sync_data().unwrap_err(); + file.sync_all().unwrap_err(); + } remove_file(&path).unwrap(); } From b63e6fb7d238ec986cb89454a8fe93bfa3611604 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 12 Dec 2025 11:56:35 -0800 Subject: [PATCH 290/489] Implement direct shim test --- .../miri/tests/pass-dep/shims/windows-fs.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/tests/pass-dep/shims/windows-fs.rs b/src/tools/miri/tests/pass-dep/shims/windows-fs.rs index 0037f34d3c9a..91639c502325 100644 --- a/src/tools/miri/tests/pass-dep/shims/windows-fs.rs +++ b/src/tools/miri/tests/pass-dep/shims/windows-fs.rs @@ -22,8 +22,8 @@ use windows_sys::Win32::Storage::FileSystem::{ FILE_ALLOCATION_INFO, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_NORMAL, FILE_BEGIN, FILE_CURRENT, FILE_END_OF_FILE_INFO, FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, FileAllocationInfo, FileEndOfFileInfo, - GetFileInformationByHandle, OPEN_ALWAYS, OPEN_EXISTING, SetFileInformationByHandle, - SetFilePointerEx, + FlushFileBuffers, GetFileInformationByHandle, OPEN_ALWAYS, OPEN_EXISTING, + SetFileInformationByHandle, SetFilePointerEx, }; use windows_sys::Win32::System::IO::IO_STATUS_BLOCK; use windows_sys::Win32::System::Threading::GetCurrentProcess; @@ -41,6 +41,7 @@ fn main() { test_file_seek(); test_set_file_info(); test_dup_handle(); + test_flush_buffers(); } } @@ -362,6 +363,19 @@ unsafe fn test_file_seek() { assert_eq!(pos, 5); } +unsafe fn test_flush_buffers() { + let temp = utils::tmp().join("test_flush_buffers.txt"); + let file = fs::File::options().create(true).write(true).read(true).open(&temp).unwrap(); + if FlushFileBuffers(file.as_raw_handle()) == 0 { + panic!("Failed to flush buffers"); + } + + let file = fs::File::options().read(true).open(&temp).unwrap(); + if FlushFileBuffers(file.as_raw_handle()) != 0 { + panic!("Successfully flushed buffers on read-only file"); + } +} + fn to_wide_cstr(path: &Path) -> Vec { let mut raw_path = path.as_os_str().encode_wide().collect::>(); raw_path.extend([0, 0]); From 0383197fbe1d293c1b10e05f463b00075e7f1320 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 17 Dec 2025 21:10:03 +1100 Subject: [PATCH 291/489] Don't use `thir::PatKind::DerefPattern` for implicit pin-patterns --- .../src/builder/matches/match_pair.rs | 3 ++- compiler/rustc_mir_build/src/thir/pattern/mod.rs | 13 ++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index dc1545c9278a..e08ef0d26748 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -287,8 +287,9 @@ impl<'tcx> MatchPairTree<'tcx> { None } + // FIXME: Pin-patterns should probably have their own pattern kind, + // instead of overloading `PatKind::Deref` via the pattern type. PatKind::Deref { ref subpattern } - | PatKind::DerefPattern { ref subpattern, borrow: ByRef::Yes(Pinnedness::Pinned, _) } if let Some(ref_ty) = pattern.ty.pinned_ty() && ref_ty.is_ref() => { diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 02e6f8d6ce71..a13536559527 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -11,7 +11,7 @@ use rustc_abi::{FieldIdx, Integer}; use rustc_errors::codes::*; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::pat_util::EnumerateAndAdjustIterator; -use rustc_hir::{self as hir, ByRef, LangItem, Mutability, Pinnedness, RangeEnd}; +use rustc_hir::{self as hir, LangItem, RangeEnd}; use rustc_index::Idx; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::interpret::LitToConstInput; @@ -114,16 +114,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { let borrow = self.typeck_results.deref_pat_borrow_mode(adjust.source, pat); PatKind::DerefPattern { subpattern: thir_pat, borrow } } - PatAdjust::PinDeref => { - let mutable = self.typeck_results.pat_has_ref_mut_binding(pat); - PatKind::DerefPattern { - subpattern: thir_pat, - borrow: ByRef::Yes( - Pinnedness::Pinned, - if mutable { Mutability::Mut } else { Mutability::Not }, - ), - } - } + PatAdjust::PinDeref => PatKind::Deref { subpattern: thir_pat }, }; Box::new(Pat { span, ty: adjust.source, kind }) }); From 1ae96045d255ebda6ae9bb4a3b578f47ec24f6e7 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 17 Dec 2025 21:24:26 +1100 Subject: [PATCH 292/489] Don't use `ByRef` for the `thir::PatKind::DerefPattern` borrow mode This avoids having to awkwardly ignore the `Pinnedness` field. --- .../rustc_hir_typeck/src/expr_use_visitor.rs | 7 ++++--- compiler/rustc_middle/src/thir.rs | 12 +++++++++--- compiler/rustc_middle/src/ty/typeck_results.rs | 17 +++++++++++------ .../src/builder/matches/match_pair.rs | 11 +++-------- .../rustc_mir_build/src/builder/matches/mod.rs | 8 ++------ .../rustc_mir_build/src/thir/pattern/mod.rs | 4 ++-- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index 27b66d07f98e..be4fdb5240c7 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -23,6 +23,7 @@ use rustc_middle::hir::place::ProjectionKind; // Export these here so that Clippy can use them. pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection}; use rustc_middle::mir::FakeReadCause; +use rustc_middle::thir::DerefPatBorrowMode; use rustc_middle::ty::{ self, BorrowKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt as _, adjustment, }; @@ -1004,7 +1005,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx // Deref patterns on boxes don't borrow, so we ignore them here. // HACK: this could be a fake pattern corresponding to a deref inserted by match // ergonomics, in which case `pat.hir_id` will be the id of the subpattern. - if let hir::ByRef::Yes(_, mutability) = + if let DerefPatBorrowMode::Borrow(mutability) = self.cx.typeck_results().deref_pat_borrow_mode(place.place.ty(), subpattern) { let bk = ty::BorrowKind::from_mutbl(mutability); @@ -1891,9 +1892,9 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx ) -> Result, Cx::Error> { match self.cx.typeck_results().deref_pat_borrow_mode(base_place.place.ty(), inner) { // Deref patterns on boxes are lowered using a built-in deref. - hir::ByRef::No => self.cat_deref(hir_id, base_place), + DerefPatBorrowMode::Box => self.cat_deref(hir_id, base_place), // For other types, we create a temporary to match on. - hir::ByRef::Yes(_, mutability) => { + DerefPatBorrowMode::Borrow(mutability) => { let re_erased = self.cx.tcx().lifetimes.re_erased; let ty = Ty::new_ref(self.cx.tcx(), re_erased, target_ty, mutability); // A deref pattern stores the result of `Deref::deref` or `DerefMut::deref_mut` ... diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index edbb736128cf..3d893bf75e0b 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -14,7 +14,7 @@ use std::ops::Index; use std::sync::Arc; use rustc_abi::{FieldIdx, Integer, Size, VariantIdx}; -use rustc_ast::{AsmMacro, InlineAsmOptions, InlineAsmTemplatePiece}; +use rustc_ast::{AsmMacro, InlineAsmOptions, InlineAsmTemplatePiece, Mutability}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd}; @@ -811,11 +811,11 @@ pub enum PatKind<'tcx> { DerefPattern { subpattern: Box>, /// Whether the pattern scrutinee needs to be borrowed in order to call `Deref::deref` or - /// `DerefMut::deref_mut`, and if so, which. This is `ByRef::No` for deref patterns on + /// `DerefMut::deref_mut`, and if so, which. This is `DerefPatBorrowMode::Box` for deref patterns on /// boxes; they are lowered using a built-in deref rather than a method call, thus they /// don't borrow the scrutinee. #[type_visitable(ignore)] - borrow: ByRef, + borrow: DerefPatBorrowMode, }, /// One of the following: @@ -879,6 +879,12 @@ pub enum PatKind<'tcx> { Error(ErrorGuaranteed), } +#[derive(Copy, Clone, Debug, HashStable)] +pub enum DerefPatBorrowMode { + Borrow(Mutability), + Box, +} + /// A range pattern. /// The boundaries must be of the same type and that type must be numeric. #[derive(Clone, Debug, PartialEq, HashStable, TypeVisitable)] diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index a3353661d9dd..2c5e4957d0ae 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -11,7 +11,6 @@ use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap}; use rustc_hir::hir_id::OwnerId; use rustc_hir::{ self as hir, BindingMode, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability, - Pinnedness, }; use rustc_index::IndexVec; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; @@ -21,6 +20,7 @@ use rustc_span::Span; use crate::hir::place::Place as HirPlace; use crate::infer::canonical::Canonical; use crate::mir::FakeReadCause; +use crate::thir::DerefPatBorrowMode; use crate::traits::ObligationCause; use crate::ty::{ self, BoundVar, CanonicalPolyFnSig, ClosureSizeProfileData, GenericArgKind, GenericArgs, @@ -491,13 +491,18 @@ impl<'tcx> TypeckResults<'tcx> { /// In most cases, if the pattern recursively contains a `ref mut` binding, we find the inner /// pattern's scrutinee by calling `DerefMut::deref_mut`, and otherwise we call `Deref::deref`. /// However, for boxes we can use a built-in deref instead, which doesn't borrow the scrutinee; - /// in this case, we return `ByRef::No`. - pub fn deref_pat_borrow_mode(&self, pointer_ty: Ty<'_>, inner: &hir::Pat<'_>) -> ByRef { + /// in this case, we return `DerefPatBorrowMode::Box`. + pub fn deref_pat_borrow_mode( + &self, + pointer_ty: Ty<'_>, + inner: &hir::Pat<'_>, + ) -> DerefPatBorrowMode { if pointer_ty.is_box() { - ByRef::No + DerefPatBorrowMode::Box } else { - let mutable = self.pat_has_ref_mut_binding(inner); - ByRef::Yes(Pinnedness::Not, if mutable { Mutability::Mut } else { Mutability::Not }) + let mutability = + if self.pat_has_ref_mut_binding(inner) { Mutability::Mut } else { Mutability::Not }; + DerefPatBorrowMode::Borrow(mutability) } } diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index e08ef0d26748..8d612b8c5efe 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -1,10 +1,9 @@ use std::sync::Arc; use rustc_abi::FieldIdx; -use rustc_hir::ByRef; use rustc_middle::mir::*; use rustc_middle::thir::*; -use rustc_middle::ty::{self, Pinnedness, Ty, TypeVisitableExt}; +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use crate::builder::Builder; use crate::builder::expr::as_place::{PlaceBase, PlaceBuilder}; @@ -303,12 +302,8 @@ impl<'tcx> MatchPairTree<'tcx> { None } - PatKind::DerefPattern { borrow: ByRef::Yes(Pinnedness::Pinned, _), .. } => { - rustc_middle::bug!("RefPin pattern on non-`Pin` type {:?}", pattern.ty) - } - PatKind::Deref { ref subpattern } - | PatKind::DerefPattern { ref subpattern, borrow: ByRef::No } => { + | PatKind::DerefPattern { ref subpattern, borrow: DerefPatBorrowMode::Box } => { MatchPairTree::for_pattern( place_builder.deref(), subpattern, @@ -321,7 +316,7 @@ impl<'tcx> MatchPairTree<'tcx> { PatKind::DerefPattern { ref subpattern, - borrow: ByRef::Yes(Pinnedness::Not, mutability), + borrow: DerefPatBorrowMode::Borrow(mutability), } => { // Create a new temporary for each deref pattern. // FIXME(deref_patterns): dedup temporaries to avoid multiple `deref()` calls? diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index ecdc3842a9b8..66e36a99d3c4 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -11,10 +11,10 @@ use std::mem; use std::sync::Arc; use itertools::{Itertools, Position}; -use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx}; +use rustc_abi::{FIRST_VARIANT, VariantIdx}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stack::ensure_sufficient_stack; -use rustc_hir::{BindingMode, ByRef, LangItem, LetStmt, LocalSource, Node, Pinnedness}; +use rustc_hir::{BindingMode, ByRef, LangItem, LetStmt, LocalSource, Node}; use rustc_middle::middle::region::{self, TempLifetime}; use rustc_middle::mir::*; use rustc_middle::thir::{self, *}; @@ -920,10 +920,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { visit_subpat(self, subpattern, &user_tys.deref(), f); } - PatKind::DerefPattern { ref subpattern, borrow: ByRef::Yes(Pinnedness::Pinned, _) } => { - visit_subpat(self, subpattern, &user_tys.leaf(FieldIdx::ZERO).deref(), f); - } - PatKind::DerefPattern { ref subpattern, .. } => { visit_subpat(self, subpattern, &ProjectedUserTypesNode::None, f); } diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index a13536559527..891a7df7d235 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -16,7 +16,7 @@ use rustc_index::Idx; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::interpret::LitToConstInput; use rustc_middle::thir::{ - Ascription, FieldPat, LocalVarId, Pat, PatKind, PatRange, PatRangeBoundary, + Ascription, DerefPatBorrowMode, FieldPat, LocalVarId, Pat, PatKind, PatRange, PatRangeBoundary, }; use rustc_middle::ty::adjustment::{PatAdjust, PatAdjustment}; use rustc_middle::ty::layout::IntegerExt; @@ -325,7 +325,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { } hir::PatKind::Box(subpattern) => PatKind::DerefPattern { subpattern: self.lower_pattern(subpattern), - borrow: hir::ByRef::No, + borrow: DerefPatBorrowMode::Box, }, hir::PatKind::Slice(prefix, slice, suffix) => { From c820f461228ba5d8d6bc6879e5a311a45673fb84 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 15 Dec 2025 14:42:01 +0100 Subject: [PATCH 293/489] Generate macro expansion for rust compiler crates docs --- src/bootstrap/src/core/build_steps/doc.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index b86582807f72..fa36a6471cae 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -932,6 +932,7 @@ impl Step for Rustc { // see https://github.com/rust-lang/rust/pull/122066#issuecomment-1983049222 // If there is any bug, please comment out the next line. cargo.rustdocflag("--generate-link-to-definition"); + cargo.rustdocflag("--generate-macro-expansion"); compile::rustc_cargo(builder, &mut cargo, target, &build_compiler, &self.crates); cargo.arg("-Zskip-rustdoc-fingerprint"); From 3fd2d64dc4e47b9a4ae9e9ac7fa430ffe6a24d19 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 18 Dec 2025 08:09:56 +0100 Subject: [PATCH 294/489] remove spin_loop hint intrinsics we no longer need --- src/tools/miri/src/shims/aarch64.rs | 14 -------------- src/tools/miri/src/shims/foreign_items.rs | 16 ---------------- 2 files changed, 30 deletions(-) diff --git a/src/tools/miri/src/shims/aarch64.rs b/src/tools/miri/src/shims/aarch64.rs index 6e422b4ab716..595a6595b531 100644 --- a/src/tools/miri/src/shims/aarch64.rs +++ b/src/tools/miri/src/shims/aarch64.rs @@ -19,20 +19,6 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Prefix should have already been checked. let unprefixed_name = link_name.as_str().strip_prefix("llvm.aarch64.").unwrap(); match unprefixed_name { - "isb" => { - let [arg] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; - let arg = this.read_scalar(arg)?.to_i32()?; - match arg { - // SY ("full system scope") - 15 => { - this.yield_active_thread(); - } - _ => { - throw_unsup_format!("unsupported llvm.aarch64.isb argument {}", arg); - } - } - } - // Used to implement the vpmaxq_u8 function. // Computes the maximum of adjacent pairs; the first half of the output is produced from the // `left` input, the second half of the output from the `right` input. diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 48f4ca53cdca..74ae93348d58 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -813,22 +813,6 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { this, link_name, abi, args, dest, ); } - // FIXME: Move this to an `arm` submodule. - "llvm.arm.hint" if this.tcx.sess.target.arch == Arch::Arm => { - let [arg] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?; - let arg = this.read_scalar(arg)?.to_i32()?; - // Note that different arguments might have different target feature requirements. - match arg { - // YIELD - 1 => { - this.expect_target_feature_for_intrinsic(link_name, "v6")?; - this.yield_active_thread(); - } - _ => { - throw_unsup_format!("unsupported llvm.arm.hint argument {}", arg); - } - } - } // Fallback to shims in submodules. _ => { From ae5e0d5492b1106f8843ee2e00f6017bb0bf75b7 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Thu, 18 Dec 2025 10:42:47 +0300 Subject: [PATCH 295/489] Support recursive delegation --- compiler/rustc_ast_lowering/messages.ftl | 2 + compiler/rustc_ast_lowering/src/delegation.rs | 68 +++++++++---- compiler/rustc_ast_lowering/src/errors.rs | 14 +++ compiler/rustc_ast_lowering/src/item.rs | 6 +- compiler/rustc_hir_analysis/src/delegation.rs | 6 -- compiler/rustc_middle/src/ty/mod.rs | 3 + compiler/rustc_resolve/src/late.rs | 22 ++++- compiler/rustc_resolve/src/lib.rs | 3 + .../auxiliary/recursive-delegation-aux.rs | 7 ++ tests/ui/delegation/ice-issue-124347.rs | 4 +- tests/ui/delegation/ice-issue-124347.stderr | 19 ++-- .../delegation/recursive-delegation-errors.rs | 54 ++++++++++ .../recursive-delegation-errors.stderr | 98 +++++++++++++++++++ .../delegation/recursive-delegation-pass.rs | 68 +++++++++++++ .../ui/delegation/unsupported.current.stderr | 13 +-- tests/ui/delegation/unsupported.next.stderr | 13 +-- tests/ui/delegation/unsupported.rs | 1 - 17 files changed, 331 insertions(+), 70 deletions(-) create mode 100644 tests/ui/delegation/auxiliary/recursive-delegation-aux.rs create mode 100644 tests/ui/delegation/recursive-delegation-errors.rs create mode 100644 tests/ui/delegation/recursive-delegation-errors.stderr create mode 100644 tests/ui/delegation/recursive-delegation-pass.rs diff --git a/compiler/rustc_ast_lowering/messages.ftl b/compiler/rustc_ast_lowering/messages.ftl index 370b15d2871a..e1fccead4d21 100644 --- a/compiler/rustc_ast_lowering/messages.ftl +++ b/compiler/rustc_ast_lowering/messages.ftl @@ -56,6 +56,8 @@ ast_lowering_coroutine_too_many_parameters = ast_lowering_default_field_in_tuple = default fields are not supported in tuple structs .label = default fields are only supported on structs +ast_lowering_delegation_cycle_in_signature_resolution = encountered a cycle during delegation signature resolution +ast_lowering_delegation_unresolved_callee = failed to resolve delegation callee ast_lowering_does_not_support_modifiers = the `{$class_name}` register class does not support template modifiers diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 82bade8829a2..532a0ce520cd 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -44,6 +44,7 @@ use hir::{BodyId, HirId}; use rustc_abi::ExternAbi; use rustc_ast::*; use rustc_attr_parsing::{AttributeParser, ShouldEmit}; +use rustc_data_structures::fx::FxHashSet; use rustc_errors::ErrorGuaranteed; use rustc_hir::Target; use rustc_hir::attrs::{AttributeKind, InlineAttr}; @@ -55,6 +56,7 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol}; use {rustc_ast as ast, rustc_hir as hir}; use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode}; +use crate::errors::{CycleInDelegationSignatureResolution, UnresolvedDelegationCallee}; use crate::{AllowReturnTypeNotation, ImplTraitPosition, ResolverAstLoweringExt}; pub(crate) struct DelegationResults<'hir> { @@ -119,10 +121,14 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, delegation: &Delegation, item_id: NodeId, - is_in_trait_impl: bool, ) -> DelegationResults<'hir> { let span = self.lower_span(delegation.path.segments.last().unwrap().ident.span); - let sig_id = self.get_delegation_sig_id(item_id, delegation.id, span, is_in_trait_impl); + + let sig_id = self.get_delegation_sig_id( + self.resolver.delegation_sig_resolution_nodes[&self.local_def_id(item_id)], + span, + ); + match sig_id { Ok(sig_id) => { self.add_attributes_if_needed(span, sig_id); @@ -238,24 +244,48 @@ impl<'hir> LoweringContext<'_, 'hir> { fn get_delegation_sig_id( &self, - item_id: NodeId, - path_id: NodeId, + mut node_id: NodeId, span: Span, - is_in_trait_impl: bool, ) -> Result { - let sig_id = if is_in_trait_impl { item_id } else { path_id }; - self.get_resolution_id(sig_id, span) + let mut visited: FxHashSet = Default::default(); + + loop { + visited.insert(node_id); + + let Some(def_id) = self.get_resolution_id(node_id) else { + return Err(self.tcx.dcx().span_delayed_bug( + span, + format!( + "LoweringContext: couldn't resolve node {:?} in delegation item", + node_id + ), + )); + }; + + // If def_id is in local crate and it corresponds to another delegation + // it means that we refer to another delegation as a callee, so in order to obtain + // a signature DefId we obtain NodeId of the callee delegation and try to get signature from it. + if let Some(local_id) = def_id.as_local() + && let Some(next_node_id) = + self.resolver.delegation_sig_resolution_nodes.get(&local_id) + { + node_id = *next_node_id; + if visited.contains(&node_id) { + // We encountered a cycle in the resolution, or delegation callee refers to non-existent + // entity, in this case emit an error. + return Err(match visited.len() { + 1 => self.dcx().emit_err(UnresolvedDelegationCallee { span }), + _ => self.dcx().emit_err(CycleInDelegationSignatureResolution { span }), + }); + } + } else { + return Ok(def_id); + } + } } - fn get_resolution_id(&self, node_id: NodeId, span: Span) -> Result { - let def_id = - self.resolver.get_partial_res(node_id).and_then(|r| r.expect_full_res().opt_def_id()); - def_id.ok_or_else(|| { - self.tcx.dcx().span_delayed_bug( - span, - format!("LoweringContext: couldn't resolve node {:?} in delegation item", node_id), - ) - }) + fn get_resolution_id(&self, node_id: NodeId) -> Option { + self.resolver.get_partial_res(node_id).and_then(|r| r.expect_full_res().opt_def_id()) } fn lower_delegation_generics(&mut self, span: Span) -> &'hir hir::Generics<'hir> { @@ -271,8 +301,6 @@ impl<'hir> LoweringContext<'_, 'hir> { // Function parameter count, including C variadic `...` if present. fn param_count(&self, sig_id: DefId) -> (usize, bool /*c_variadic*/) { if let Some(local_sig_id) = sig_id.as_local() { - // Map may be filled incorrectly due to recursive delegation. - // Error will be emitted later during HIR ty lowering. match self.resolver.delegation_fn_sigs.get(&local_sig_id) { Some(sig) => (sig.param_count, sig.c_variadic), None => (0, false), @@ -489,8 +517,8 @@ impl<'hir> LoweringContext<'_, 'hir> { delegation.path.segments.iter().rev().skip(1).any(|segment| segment.args.is_some()); let call = if self - .get_resolution_id(delegation.id, span) - .and_then(|def_id| Ok(self.is_method(def_id, span))) + .get_resolution_id(delegation.id) + .map(|def_id| self.is_method(def_id, span)) .unwrap_or_default() && delegation.qself.is_none() && !has_generic_args diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index 83f3a976e83f..35c37fe91d49 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -475,3 +475,17 @@ pub(crate) struct UnionWithDefault { #[primary_span] pub span: Span, } + +#[derive(Diagnostic)] +#[diag(ast_lowering_delegation_unresolved_callee)] +pub(crate) struct UnresolvedDelegationCallee { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(ast_lowering_delegation_cycle_in_signature_resolution)] +pub(crate) struct CycleInDelegationSignatureResolution { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index a68d63bf1464..bfce7c25b75d 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -541,7 +541,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ItemKind::Macro(ident, macro_def, macro_kinds) } ItemKind::Delegation(box delegation) => { - let delegation_results = self.lower_delegation(delegation, id, false); + let delegation_results = self.lower_delegation(delegation, id); hir::ItemKind::Fn { sig: delegation_results.sig, ident: delegation_results.ident, @@ -1026,7 +1026,7 @@ impl<'hir> LoweringContext<'_, 'hir> { (*ident, generics, kind, ty.is_some()) } AssocItemKind::Delegation(box delegation) => { - let delegation_results = self.lower_delegation(delegation, i.id, false); + let delegation_results = self.lower_delegation(delegation, i.id); let item_kind = hir::TraitItemKind::Fn( delegation_results.sig, hir::TraitFn::Provided(delegation_results.body_id), @@ -1196,7 +1196,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ) } AssocItemKind::Delegation(box delegation) => { - let delegation_results = self.lower_delegation(delegation, i.id, is_in_trait_impl); + let delegation_results = self.lower_delegation(delegation, i.id); ( delegation.ident, ( diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index 125fc21a5cc1..4ab13140bf9c 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -401,12 +401,6 @@ fn check_constraints<'tcx>( })); }; - if let Some(local_sig_id) = sig_id.as_local() - && tcx.hir_opt_delegation_sig_id(local_sig_id).is_some() - { - emit("recursive delegation is not supported yet"); - } - if tcx.fn_sig(sig_id).skip_binder().skip_binder().c_variadic { // See issue #127443 for explanation. emit("delegation to C-variadic functions is not allowed"); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index b91176e3d486..e918f7ba362d 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -220,6 +220,9 @@ pub struct ResolverAstLowering { /// Information about functions signatures for delegation items expansion pub delegation_fn_sigs: LocalDefIdMap, + // NodeIds (either delegation.id or item_id in case of a trait impl) for signature resolution, + // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914 + pub delegation_sig_resolution_nodes: LocalDefIdMap, } bitflags::bitflags! { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 5a4fbad6aaf8..d3428a4af348 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2928,7 +2928,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { item.id, LifetimeBinderKind::Function, span, - |this| this.resolve_delegation(delegation), + |this| this.resolve_delegation(delegation, item.id, false), ); } @@ -3257,7 +3257,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { item.id, LifetimeBinderKind::Function, delegation.path.segments.last().unwrap().ident.span, - |this| this.resolve_delegation(delegation), + |this| this.resolve_delegation(delegation, item.id, false), ); } AssocItemKind::Type(box TyAlias { generics, .. }) => self @@ -3550,7 +3550,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |i, s, c| MethodNotMemberOfTrait(i, s, c), ); - this.resolve_delegation(delegation) + this.resolve_delegation(delegation, item.id, trait_id.is_some()); }, ); } @@ -3699,17 +3699,30 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { }) } - fn resolve_delegation(&mut self, delegation: &'ast Delegation) { + fn resolve_delegation( + &mut self, + delegation: &'ast Delegation, + item_id: NodeId, + is_in_trait_impl: bool, + ) { self.smart_resolve_path( delegation.id, &delegation.qself, &delegation.path, PathSource::Delegation, ); + if let Some(qself) = &delegation.qself { self.visit_ty(&qself.ty); } + self.visit_path(&delegation.path); + + self.r.delegation_sig_resolution_nodes.insert( + self.r.local_def_id(item_id), + if is_in_trait_impl { item_id } else { delegation.id }, + ); + let Some(body) = &delegation.body else { return }; self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| { let span = delegation.path.segments.last().unwrap().ident.span; @@ -4294,7 +4307,6 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { ); } - #[instrument(level = "debug", skip(self))] fn smart_resolve_path_fragment( &mut self, qself: &Option>, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index b3141406e467..646a1b891413 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1276,6 +1276,7 @@ pub struct Resolver<'ra, 'tcx> { /// Amount of lifetime parameters for each item in the crate. item_generics_num_lifetimes: FxHashMap, delegation_fn_sigs: LocalDefIdMap, + delegation_sig_resolution_nodes: LocalDefIdMap, main_def: Option = None, trait_impls: FxIndexMap>, @@ -1694,6 +1695,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { current_crate_outer_attr_insert_span, mods_with_parse_errors: Default::default(), impl_trait_names: Default::default(), + delegation_sig_resolution_nodes: Default::default(), .. }; @@ -1822,6 +1824,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { lifetime_elision_allowed: self.lifetime_elision_allowed, lint_buffer: Steal::new(self.lint_buffer), delegation_fn_sigs: self.delegation_fn_sigs, + delegation_sig_resolution_nodes: self.delegation_sig_resolution_nodes, }; ResolverOutputs { global_ctxt, ast_lowering } } diff --git a/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs b/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs new file mode 100644 index 000000000000..5df644974f3e --- /dev/null +++ b/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs @@ -0,0 +1,7 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +fn foo() {} + +reuse foo as bar; +pub reuse bar as goo; diff --git a/tests/ui/delegation/ice-issue-124347.rs b/tests/ui/delegation/ice-issue-124347.rs index 3e0a5b36ddcf..6bf3a08ba5b4 100644 --- a/tests/ui/delegation/ice-issue-124347.rs +++ b/tests/ui/delegation/ice-issue-124347.rs @@ -1,12 +1,12 @@ #![feature(fn_delegation)] #![allow(incomplete_features)] -// FIXME(fn_delegation): `recursive delegation` error should be emitted here trait Trait { reuse Trait::foo { &self.0 } + //~^ ERROR failed to resolve delegation callee } reuse foo; -//~^ ERROR cycle detected when computing generics of `foo` +//~^ ERROR failed to resolve delegation callee fn main() {} diff --git a/tests/ui/delegation/ice-issue-124347.stderr b/tests/ui/delegation/ice-issue-124347.stderr index 2955c0442034..40be6be4abfa 100644 --- a/tests/ui/delegation/ice-issue-124347.stderr +++ b/tests/ui/delegation/ice-issue-124347.stderr @@ -1,17 +1,14 @@ -error[E0391]: cycle detected when computing generics of `foo` +error: failed to resolve delegation callee + --> $DIR/ice-issue-124347.rs:5:18 + | +LL | reuse Trait::foo { &self.0 } + | ^^^ + +error: failed to resolve delegation callee --> $DIR/ice-issue-124347.rs:9:7 | LL | reuse foo; | ^^^ - | - = note: ...which immediately requires computing generics of `foo` again -note: cycle used when checking that `foo` is well-formed - --> $DIR/ice-issue-124347.rs:9:7 - | -LL | reuse foo; - | ^^^ - = 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 +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/delegation/recursive-delegation-errors.rs b/tests/ui/delegation/recursive-delegation-errors.rs new file mode 100644 index 000000000000..194182e20ed0 --- /dev/null +++ b/tests/ui/delegation/recursive-delegation-errors.rs @@ -0,0 +1,54 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + + +mod first_mod { + reuse foo; + //~^ ERROR failed to resolve delegation callee +} + +mod second_mod { + reuse foo as bar; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse bar as foo; + //~^ ERROR encountered a cycle during delegation signature resolution +} + +mod third_mod { + reuse foo as foo1; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse foo1 as foo2; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse foo2 as foo3; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse foo3 as foo4; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse foo4 as foo5; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse foo5 as foo; + //~^ ERROR encountered a cycle during delegation signature resolution +} + +mod fourth_mod { + trait Trait { + reuse Trait::foo as bar; + //~^ ERROR encountered a cycle during delegation signature resolution + reuse Trait::bar as foo; + //~^ ERROR encountered a cycle during delegation signature resolution + } +} + +mod fifth_mod { + reuse super::fifth_mod::{bar as foo, foo as bar}; + //~^ ERROR encountered a cycle during delegation signature resolution + //~| ERROR encountered a cycle during delegation signature resolution + + trait GlobReuse { + reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; + //~^ ERROR encountered a cycle during delegation signature resolution + //~| ERROR encountered a cycle during delegation signature resolution + //~| ERROR encountered a cycle during delegation signature resolution + } +} + +fn main() {} diff --git a/tests/ui/delegation/recursive-delegation-errors.stderr b/tests/ui/delegation/recursive-delegation-errors.stderr new file mode 100644 index 000000000000..9c4e316745ae --- /dev/null +++ b/tests/ui/delegation/recursive-delegation-errors.stderr @@ -0,0 +1,98 @@ +error: failed to resolve delegation callee + --> $DIR/recursive-delegation-errors.rs:6:11 + | +LL | reuse foo; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:11:11 + | +LL | reuse foo as bar; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:13:11 + | +LL | reuse bar as foo; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:18:11 + | +LL | reuse foo as foo1; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:20:11 + | +LL | reuse foo1 as foo2; + | ^^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:22:11 + | +LL | reuse foo2 as foo3; + | ^^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:24:11 + | +LL | reuse foo3 as foo4; + | ^^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:26:11 + | +LL | reuse foo4 as foo5; + | ^^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:28:11 + | +LL | reuse foo5 as foo; + | ^^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:34:22 + | +LL | reuse Trait::foo as bar; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:36:22 + | +LL | reuse Trait::bar as foo; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:42:30 + | +LL | reuse super::fifth_mod::{bar as foo, foo as bar}; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:42:42 + | +LL | reuse super::fifth_mod::{bar as foo, foo as bar}; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:47:27 + | +LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:47:39 + | +LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; + | ^^^ + +error: encountered a cycle during delegation signature resolution + --> $DIR/recursive-delegation-errors.rs:47:51 + | +LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; + | ^^^ + +error: aborting due to 16 previous errors + diff --git a/tests/ui/delegation/recursive-delegation-pass.rs b/tests/ui/delegation/recursive-delegation-pass.rs new file mode 100644 index 000000000000..93f8fa401b55 --- /dev/null +++ b/tests/ui/delegation/recursive-delegation-pass.rs @@ -0,0 +1,68 @@ +//@ check-pass +//@ edition:2018 +//@ aux-crate:recursive_delegation_aux=recursive-delegation-aux.rs + +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod first_mod { + pub mod to_reuse { + pub fn foo(x: usize) -> usize { + x + 1 + } + } + + mod single_reuse { + reuse crate::first_mod::to_reuse::foo; + reuse foo as bar; + reuse foo as bar1; + reuse bar as goo; + reuse goo as koo; + reuse koo as too; + } + + mod glob_reuse { + reuse super::to_reuse::{foo as bar, foo as bar1} { self } + reuse super::glob_reuse::{bar as goo, goo as koo, koo as too} { self } + } +} + +mod second_mod { + trait T { + fn foo(&self); + reuse T::foo as bar; + reuse T::bar as goo; + reuse T::goo as poo; + } + + trait TGlob { + fn xd(&self) -> &Self; + fn foo1(&self); + fn foo2(&self); + fn foo3(&self); + fn foo4(&self); + + reuse TGlob::{foo1 as bar1, foo3 as bar3, bar1 as bar11, bar11 as bar111} { self.xd() } + } +} + +mod third_mod { + reuse crate::first_mod::to_reuse::foo { + reuse foo as bar { + reuse bar as goo { + bar(123) + } + + goo(123) + } + + bar(123) + } +} + +mod fourth_mod { + reuse recursive_delegation_aux::goo as bar; + reuse bar as foo; +} + +fn main() {} diff --git a/tests/ui/delegation/unsupported.current.stderr b/tests/ui/delegation/unsupported.current.stderr index 5c4115630c00..2bb0633621f2 100644 --- a/tests/ui/delegation/unsupported.current.stderr +++ b/tests/ui/delegation/unsupported.current.stderr @@ -36,24 +36,15 @@ LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ = 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: recursive delegation is not supported yet - --> $DIR/unsupported.rs:46:22 - | -LL | pub reuse to_reuse2::foo; - | --- callee defined here -... -LL | reuse to_reuse1::foo; - | ^^^ - error[E0283]: type annotations needed - --> $DIR/unsupported.rs:55:18 + --> $DIR/unsupported.rs:54:18 | LL | reuse Trait::foo; | ^^^ cannot infer type | = note: cannot satisfy `_: effects::Trait` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0283, E0391. For more information about an error, try `rustc --explain E0283`. diff --git a/tests/ui/delegation/unsupported.next.stderr b/tests/ui/delegation/unsupported.next.stderr index a626da9a1442..1665d1f39d6d 100644 --- a/tests/ui/delegation/unsupported.next.stderr +++ b/tests/ui/delegation/unsupported.next.stderr @@ -28,24 +28,15 @@ LL | reuse ToReuse::opaque_ret; = note: cycle used when computing implied outlives bounds for `::opaque_ret::{anon_assoc#0}` (hack disabled = 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: recursive delegation is not supported yet - --> $DIR/unsupported.rs:46:22 - | -LL | pub reuse to_reuse2::foo; - | --- callee defined here -... -LL | reuse to_reuse1::foo; - | ^^^ - error[E0283]: type annotations needed - --> $DIR/unsupported.rs:55:18 + --> $DIR/unsupported.rs:54:18 | LL | reuse Trait::foo; | ^^^ cannot infer type | = note: cannot satisfy `_: effects::Trait` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0283, E0391. For more information about an error, try `rustc --explain E0283`. diff --git a/tests/ui/delegation/unsupported.rs b/tests/ui/delegation/unsupported.rs index 5e2bd832a4d8..1681888e34ea 100644 --- a/tests/ui/delegation/unsupported.rs +++ b/tests/ui/delegation/unsupported.rs @@ -44,7 +44,6 @@ mod recursive { } reuse to_reuse1::foo; - //~^ ERROR recursive delegation is not supported yet } mod effects { From 49f42ea517783031e766bc0e94b27a62c92930c4 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Wed, 10 Dec 2025 06:35:11 +0200 Subject: [PATCH 296/489] Lay the basics for non-`Copy` solver types with GC That means stop using Salsa for interning solver types. --- src/tools/rust-analyzer/Cargo.lock | 1 + .../hir-def/src/nameres/attr_resolution.rs | 4 +- .../crates/hir-def/src/nameres/collector.rs | 2 +- .../crates/hir-ty/src/consteval.rs | 149 ++-- .../crates/hir-ty/src/consteval/tests.rs | 10 +- .../rust-analyzer/crates/hir-ty/src/db.rs | 130 ++-- .../crates/hir-ty/src/diagnostics/expr.rs | 12 +- .../hir-ty/src/diagnostics/match_check.rs | 17 +- .../diagnostics/match_check/pat_analysis.rs | 4 +- .../hir-ty/src/diagnostics/unsafe_check.rs | 22 +- .../crates/hir-ty/src/display.rs | 50 +- .../rust-analyzer/crates/hir-ty/src/drop.rs | 6 +- .../crates/hir-ty/src/dyn_compatibility.rs | 3 +- .../rust-analyzer/crates/hir-ty/src/infer.rs | 335 ++++----- .../crates/hir-ty/src/infer/autoderef.rs | 7 +- .../crates/hir-ty/src/infer/cast.rs | 20 +- .../hir-ty/src/infer/closure/analysis.rs | 88 +-- .../crates/hir-ty/src/infer/coerce.rs | 64 +- .../crates/hir-ty/src/infer/diagnostics.rs | 16 +- .../crates/hir-ty/src/infer/expr.rs | 88 +-- .../crates/hir-ty/src/infer/mutability.rs | 4 +- .../crates/hir-ty/src/infer/op.rs | 4 +- .../crates/hir-ty/src/infer/opaques.rs | 4 +- .../crates/hir-ty/src/infer/pat.rs | 35 +- .../crates/hir-ty/src/infer/path.rs | 2 +- .../crates/hir-ty/src/infer/place_op.rs | 15 +- .../crates/hir-ty/src/infer/unify.rs | 3 +- .../crates/hir-ty/src/inhabitedness.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/layout.rs | 68 +- .../crates/hir-ty/src/layout/adt.rs | 24 +- .../crates/hir-ty/src/layout/tests.rs | 6 +- .../rust-analyzer/crates/hir-ty/src/lib.rs | 19 +- .../rust-analyzer/crates/hir-ty/src/lower.rs | 692 ++++++++++-------- .../crates/hir-ty/src/lower/path.rs | 14 +- .../crates/hir-ty/src/method_resolution.rs | 2 +- .../hir-ty/src/method_resolution/confirm.rs | 22 +- .../hir-ty/src/method_resolution/probe.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/mir.rs | 261 ++++--- .../crates/hir-ty/src/mir/borrowck.rs | 123 ++-- .../crates/hir-ty/src/mir/eval.rs | 301 ++++---- .../crates/hir-ty/src/mir/eval/shim.rs | 31 +- .../crates/hir-ty/src/mir/eval/shim/simd.rs | 3 +- .../crates/hir-ty/src/mir/eval/tests.rs | 9 +- .../crates/hir-ty/src/mir/lower.rs | 327 ++++----- .../crates/hir-ty/src/mir/lower/as_place.rs | 54 +- .../hir-ty/src/mir/lower/pattern_matching.rs | 115 +-- .../crates/hir-ty/src/mir/monomorphization.rs | 106 +-- .../crates/hir-ty/src/mir/pretty.rs | 48 +- .../crates/hir-ty/src/next_solver.rs | 2 + .../crates/hir-ty/src/next_solver/binder.rs | 83 +++ .../crates/hir-ty/src/next_solver/consts.rs | 115 ++- .../crates/hir-ty/src/next_solver/fulfill.rs | 2 +- .../hir-ty/src/next_solver/fulfill/errors.rs | 2 +- .../hir-ty/src/next_solver/generic_arg.rs | 357 +++++++-- .../crates/hir-ty/src/next_solver/infer/at.rs | 2 +- .../infer/canonical/canonicalizer.rs | 4 +- .../infer/canonical/instantiate.rs | 2 +- .../next_solver/infer/outlives/obligations.rs | 10 +- .../crates/hir-ty/src/next_solver/interner.rs | 510 +++++++------ .../crates/hir-ty/src/next_solver/ir_print.rs | 1 - .../crates/hir-ty/src/next_solver/opaques.rs | 59 +- .../hir-ty/src/next_solver/predicate.rs | 295 ++++---- .../crates/hir-ty/src/next_solver/region.rs | 66 +- .../crates/hir-ty/src/next_solver/solver.rs | 2 +- .../crates/hir-ty/src/next_solver/ty.rs | 88 ++- .../crates/hir-ty/src/opaques.rs | 44 +- .../crates/hir-ty/src/specialization.rs | 1 - .../rust-analyzer/crates/hir-ty/src/tests.rs | 26 +- .../hir-ty/src/tests/closure_captures.rs | 1 + .../crates/hir-ty/src/tests/incremental.rs | 100 +-- .../rust-analyzer/crates/hir-ty/src/traits.rs | 29 +- .../crates/hir-ty/src/variance.rs | 58 +- .../crates/hir/src/diagnostics.rs | 21 +- src/tools/rust-analyzer/crates/hir/src/lib.rs | 86 ++- .../rust-analyzer/crates/hir/src/semantics.rs | 7 +- .../crates/hir/src/source_analyzer.rs | 101 ++- .../ide/src/inlay_hints/implicit_drop.rs | 2 +- .../rust-analyzer/crates/ide/src/interpret.rs | 2 +- .../rust-analyzer/crates/intern/Cargo.toml | 1 + .../rust-analyzer/crates/intern/src/intern.rs | 331 +++++++++ .../crates/intern/src/intern_slice.rs | 351 +++++++++ .../rust-analyzer/crates/intern/src/lib.rs | 221 +----- .../rust-analyzer/crates/macros/src/lib.rs | 30 + .../crates/query-group-macro/src/queries.rs | 3 +- .../rust-analyzer/src/cli/analysis_stats.rs | 33 +- 85 files changed, 3818 insertions(+), 2554 deletions(-) create mode 100644 src/tools/rust-analyzer/crates/hir-ty/src/next_solver/binder.rs create mode 100644 src/tools/rust-analyzer/crates/intern/src/intern.rs create mode 100644 src/tools/rust-analyzer/crates/intern/src/intern_slice.rs diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index 70611dd1311b..081c7d66f1d8 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1215,6 +1215,7 @@ dependencies = [ "dashmap", "hashbrown 0.14.5", "rustc-hash 2.1.1", + "smallvec", "triomphe", ] diff --git a/src/tools/rust-analyzer/crates/hir-def/src/nameres/attr_resolution.rs b/src/tools/rust-analyzer/crates/hir-def/src/nameres/attr_resolution.rs index ec05c02bd635..1cbd2c10b5a1 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/nameres/attr_resolution.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/nameres/attr_resolution.rs @@ -63,7 +63,7 @@ impl DefMap { return Ok(ResolvedAttr::Other); } } - None => return Err(UnresolvedMacro { path: ast_id.path.as_ref().clone() }), + None => return Err(UnresolvedMacro { path: (*ast_id.path).clone() }), }; Ok(ResolvedAttr::Macro(attr_macro_as_call_id( @@ -145,7 +145,7 @@ pub(super) fn derive_macro_as_call_id( ) -> Result<(MacroId, MacroDefId, MacroCallId), UnresolvedMacro> { let (macro_id, def_id) = resolver(&item_attr.path) .filter(|(_, def_id)| def_id.is_derive()) - .ok_or_else(|| UnresolvedMacro { path: item_attr.path.as_ref().clone() })?; + .ok_or_else(|| UnresolvedMacro { path: (*item_attr.path).clone() })?; let call_id = def_id.make_call( db, krate, diff --git a/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs b/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs index 10581378bef9..7e1ec526a7bc 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs @@ -1675,7 +1675,7 @@ impl<'db> DefCollector<'db> { derive_index: *derive_pos as u32, derive_macro_id: *derive_macro_id, }, - ast_id.path.as_ref().clone(), + (*ast_id.path).clone(), )); } // These are diagnosed by `reseed_with_unresolved_attribute`, as that function consumes them diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs b/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs index 32c207b189f0..f11240e0f78c 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs @@ -23,8 +23,9 @@ use crate::{ mir::{MirEvalError, MirLowerError}, next_solver::{ Const, ConstBytes, ConstKind, DbInterner, ErrorGuaranteed, GenericArg, GenericArgs, - ParamEnv, Ty, ValueConst, + ParamEnv, StoredConst, StoredGenericArgs, Ty, ValueConst, }, + traits::StoredParamEnvAndCrate, }; use super::mir::{interpret_mir, lower_to_mir, pad16}; @@ -38,12 +39,12 @@ pub fn unknown_const_as_generic<'db>(ty: Ty<'db>) -> GenericArg<'db> { } #[derive(Debug, Clone, PartialEq, Eq)] -pub enum ConstEvalError<'db> { - MirLowerError(MirLowerError<'db>), - MirEvalError(MirEvalError<'db>), +pub enum ConstEvalError { + MirLowerError(MirLowerError), + MirEvalError(MirEvalError), } -impl ConstEvalError<'_> { +impl ConstEvalError { pub fn pretty_print( &self, f: &mut String, @@ -62,8 +63,8 @@ impl ConstEvalError<'_> { } } -impl<'db> From> for ConstEvalError<'db> { - fn from(value: MirLowerError<'db>) -> Self { +impl From for ConstEvalError { + fn from(value: MirLowerError) -> Self { match value { MirLowerError::ConstEvalError(_, e) => *e, _ => ConstEvalError::MirLowerError(value), @@ -71,8 +72,8 @@ impl<'db> From> for ConstEvalError<'db> { } } -impl<'db> From> for ConstEvalError<'db> { - fn from(value: MirEvalError<'db>) -> Self { +impl From for ConstEvalError { + fn from(value: MirEvalError) -> Self { ConstEvalError::MirEvalError(value) } } @@ -85,7 +86,8 @@ pub fn intern_const_ref<'a>( krate: Crate, ) -> Const<'a> { let interner = DbInterner::new_no_crate(db); - let layout = db.layout_of_ty(ty, ParamEnvAndCrate { param_env: ParamEnv::empty(), krate }); + let layout = db + .layout_of_ty(ty.store(), ParamEnvAndCrate { param_env: ParamEnv::empty(), krate }.store()); let kind = match value { LiteralConstRef::Int(i) => { // FIXME: We should handle failure of layout better. @@ -180,10 +182,10 @@ pub fn try_const_isize<'db>(db: &'db dyn HirDatabase, c: &Const<'db>) -> Option< } } -pub(crate) fn const_eval_discriminant_variant<'db>( - db: &'db dyn HirDatabase, +pub(crate) fn const_eval_discriminant_variant( + db: &dyn HirDatabase, variant_id: EnumVariantId, -) -> Result> { +) -> Result { let interner = DbInterner::new_no_crate(db); let def = variant_id.into(); let body = db.body(def); @@ -206,8 +208,9 @@ pub(crate) fn const_eval_discriminant_variant<'db>( let mir_body = db.monomorphized_mir_body( def, - GenericArgs::new_from_iter(interner, []), - ParamEnvAndCrate { param_env: db.trait_environment_for_body(def), krate: def.krate(db) }, + GenericArgs::empty(interner).store(), + ParamEnvAndCrate { param_env: db.trait_environment_for_body(def), krate: def.krate(db) } + .store(), )?; let c = interpret_mir(db, mir_body, false, None)?.0?; let c = if is_signed { @@ -233,7 +236,7 @@ pub(crate) fn eval_to_const<'db>(expr: ExprId, ctx: &mut InferenceContext<'_, 'd } if has_closure(ctx.body, expr) { // Type checking clousres need an isolated body (See the above FIXME). Bail out early to prevent panic. - return unknown_const(infer[expr]); + return Const::error(ctx.interner()); } if let Expr::Path(p) = &ctx.body[expr] { let mut ctx = TyLoweringContext::new( @@ -252,63 +255,89 @@ pub(crate) fn eval_to_const<'db>(expr: ExprId, ctx: &mut InferenceContext<'_, 'd { return result; } - unknown_const(infer[expr]) + Const::error(ctx.interner()) } -pub(crate) fn const_eval_cycle_result<'db>( - _: &'db dyn HirDatabase, - _: salsa::Id, - _: ConstId, - _: GenericArgs<'db>, - _: Option>, -) -> Result, ConstEvalError<'db>> { - Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) -} - -pub(crate) fn const_eval_static_cycle_result<'db>( - _: &'db dyn HirDatabase, - _: salsa::Id, - _: StaticId, -) -> Result, ConstEvalError<'db>> { - Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) -} - -pub(crate) fn const_eval_discriminant_cycle_result<'db>( - _: &'db dyn HirDatabase, +pub(crate) fn const_eval_discriminant_cycle_result( + _: &dyn HirDatabase, _: salsa::Id, _: EnumVariantId, -) -> Result> { +) -> Result { Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) } -pub(crate) fn const_eval_query<'db>( +pub(crate) fn const_eval<'db>( db: &'db dyn HirDatabase, def: ConstId, subst: GenericArgs<'db>, trait_env: Option>, -) -> Result, ConstEvalError<'db>> { - let body = db.monomorphized_mir_body( - def.into(), - subst, - ParamEnvAndCrate { param_env: db.trait_environment(def.into()), krate: def.krate(db) }, - )?; - let c = interpret_mir(db, body, false, trait_env)?.0?; - Ok(c) +) -> Result, ConstEvalError> { + return match const_eval_query(db, def, subst.store(), trait_env.map(|env| env.store())) { + Ok(konst) => Ok(konst.as_ref()), + Err(err) => Err(err.clone()), + }; + + #[salsa::tracked(returns(ref), cycle_result = const_eval_cycle_result)] + pub(crate) fn const_eval_query<'db>( + db: &'db dyn HirDatabase, + def: ConstId, + subst: StoredGenericArgs, + trait_env: Option, + ) -> Result { + let body = db.monomorphized_mir_body( + def.into(), + subst, + ParamEnvAndCrate { param_env: db.trait_environment(def.into()), krate: def.krate(db) } + .store(), + )?; + let c = interpret_mir(db, body, false, trait_env.as_ref().map(|env| env.as_ref()))?.0?; + Ok(c.store()) + } + + pub(crate) fn const_eval_cycle_result( + _: &dyn HirDatabase, + _: salsa::Id, + _: ConstId, + _: StoredGenericArgs, + _: Option, + ) -> Result { + Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) + } } -pub(crate) fn const_eval_static_query<'db>( +pub(crate) fn const_eval_static<'db>( db: &'db dyn HirDatabase, def: StaticId, -) -> Result, ConstEvalError<'db>> { - let interner = DbInterner::new_no_crate(db); - let body = db.monomorphized_mir_body( - def.into(), - GenericArgs::new_from_iter(interner, []), - ParamEnvAndCrate { - param_env: db.trait_environment_for_body(def.into()), - krate: def.krate(db), - }, - )?; - let c = interpret_mir(db, body, false, None)?.0?; - Ok(c) +) -> Result, ConstEvalError> { + return match const_eval_static_query(db, def) { + Ok(konst) => Ok(konst.as_ref()), + Err(err) => Err(err.clone()), + }; + + #[salsa::tracked(returns(ref), cycle_result = const_eval_static_cycle_result)] + pub(crate) fn const_eval_static_query<'db>( + db: &'db dyn HirDatabase, + def: StaticId, + ) -> Result { + let interner = DbInterner::new_no_crate(db); + let body = db.monomorphized_mir_body( + def.into(), + GenericArgs::empty(interner).store(), + ParamEnvAndCrate { + param_env: db.trait_environment_for_body(def.into()), + krate: def.krate(db), + } + .store(), + )?; + let c = interpret_mir(db, body, false, None)?.0?; + Ok(c.store()) + } + + pub(crate) fn const_eval_static_cycle_result( + _: &dyn HirDatabase, + _: salsa::Id, + _: StaticId, + ) -> Result { + Err(ConstEvalError::MirLowerError(MirLowerError::Loop)) + } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests.rs b/src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests.rs index 2dc937d76031..8816e13ba7b6 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests.rs @@ -27,7 +27,7 @@ use super::{ mod intrinsics; -fn simplify(e: ConstEvalError<'_>) -> ConstEvalError<'_> { +fn simplify(e: ConstEvalError) -> ConstEvalError { match e { ConstEvalError::MirEvalError(MirEvalError::InFunction(e, _)) => { simplify(ConstEvalError::MirEvalError(*e)) @@ -39,7 +39,7 @@ fn simplify(e: ConstEvalError<'_>) -> ConstEvalError<'_> { #[track_caller] fn check_fail( #[rust_analyzer::rust_fixture] ra_fixture: &str, - error: impl FnOnce(ConstEvalError<'_>) -> bool, + error: impl FnOnce(ConstEvalError) -> bool, ) { let (db, file_id) = TestDB::with_single_file(ra_fixture); crate::attach_db(&db, || match eval_goal(&db, file_id) { @@ -104,7 +104,7 @@ fn check_answer( }); } -fn pretty_print_err(e: ConstEvalError<'_>, db: &TestDB) -> String { +fn pretty_print_err(e: ConstEvalError, db: &TestDB) -> String { let mut err = String::new(); let span_formatter = |file, range| format!("{file:?} {range:?}"); let display_target = @@ -121,7 +121,7 @@ fn pretty_print_err(e: ConstEvalError<'_>, db: &TestDB) -> String { err } -fn eval_goal(db: &TestDB, file_id: EditionedFileId) -> Result, ConstEvalError<'_>> { +fn eval_goal(db: &TestDB, file_id: EditionedFileId) -> Result, ConstEvalError> { let _tracing = setup_tracing(); let interner = DbInterner::new_no_crate(db); let module_id = db.module_for_file(file_id.file_id(db)); @@ -142,7 +142,7 @@ fn eval_goal(db: &TestDB, file_id: EditionedFileId) -> Result, ConstEv _ => None, }) .expect("No const named GOAL found in the test"); - db.const_eval(const_id, GenericArgs::new_from_iter(interner, []), None) + db.const_eval(const_id, GenericArgs::empty(interner), None) } #[test] diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/db.rs b/src/tools/rust-analyzer/crates/hir-ty/src/db.rs index 47bb6675ea48..f0f65eedbce9 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/db.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/db.rs @@ -19,9 +19,10 @@ use crate::{ lower::{Diagnostics, GenericDefaults}, mir::{BorrowckResult, MirBody, MirLowerError}, next_solver::{ - Const, EarlyBinder, GenericArgs, ParamEnv, PolyFnSig, TraitRef, Ty, VariancesOf, + Const, EarlyBinder, GenericArgs, ParamEnv, PolyFnSig, StoredEarlyBinder, StoredGenericArgs, + StoredTy, TraitRef, Ty, VariancesOf, }, - traits::ParamEnvAndCrate, + traits::{ParamEnvAndCrate, StoredParamEnvAndCrate}, }; #[query_group::query_group] @@ -32,60 +33,48 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { // and `monomorphized_mir_body_for_closure` into `monomorphized_mir_body` #[salsa::invoke(crate::mir::mir_body_query)] #[salsa::cycle(cycle_result = crate::mir::mir_body_cycle_result)] - fn mir_body<'db>( - &'db self, - def: DefWithBodyId, - ) -> Result>, MirLowerError<'db>>; + fn mir_body(&self, def: DefWithBodyId) -> Result, MirLowerError>; #[salsa::invoke(crate::mir::mir_body_for_closure_query)] - fn mir_body_for_closure<'db>( - &'db self, - def: InternedClosureId, - ) -> Result>, MirLowerError<'db>>; + fn mir_body_for_closure(&self, def: InternedClosureId) -> Result, MirLowerError>; #[salsa::invoke(crate::mir::monomorphized_mir_body_query)] #[salsa::cycle(cycle_result = crate::mir::monomorphized_mir_body_cycle_result)] - fn monomorphized_mir_body<'db>( - &'db self, + fn monomorphized_mir_body( + &self, def: DefWithBodyId, - subst: GenericArgs<'db>, - env: ParamEnvAndCrate<'db>, - ) -> Result>, MirLowerError<'db>>; + subst: StoredGenericArgs, + env: StoredParamEnvAndCrate, + ) -> Result, MirLowerError>; #[salsa::invoke(crate::mir::monomorphized_mir_body_for_closure_query)] - fn monomorphized_mir_body_for_closure<'db>( - &'db self, + fn monomorphized_mir_body_for_closure( + &self, def: InternedClosureId, - subst: GenericArgs<'db>, - env: ParamEnvAndCrate<'db>, - ) -> Result>, MirLowerError<'db>>; + subst: StoredGenericArgs, + env: StoredParamEnvAndCrate, + ) -> Result, MirLowerError>; #[salsa::invoke(crate::mir::borrowck_query)] #[salsa::lru(2024)] - fn borrowck<'db>( - &'db self, - def: DefWithBodyId, - ) -> Result]>, MirLowerError<'db>>; + fn borrowck(&self, def: DefWithBodyId) -> Result, MirLowerError>; - #[salsa::invoke(crate::consteval::const_eval_query)] - #[salsa::cycle(cycle_result = crate::consteval::const_eval_cycle_result)] + #[salsa::invoke(crate::consteval::const_eval)] + #[salsa::transparent] fn const_eval<'db>( &'db self, def: ConstId, subst: GenericArgs<'db>, trait_env: Option>, - ) -> Result, ConstEvalError<'db>>; + ) -> Result, ConstEvalError>; - #[salsa::invoke(crate::consteval::const_eval_static_query)] - #[salsa::cycle(cycle_result = crate::consteval::const_eval_static_cycle_result)] - fn const_eval_static<'db>(&'db self, def: StaticId) -> Result, ConstEvalError<'db>>; + #[salsa::invoke(crate::consteval::const_eval_static)] + #[salsa::transparent] + fn const_eval_static<'db>(&'db self, def: StaticId) -> Result, ConstEvalError>; #[salsa::invoke(crate::consteval::const_eval_discriminant_variant)] #[salsa::cycle(cycle_result = crate::consteval::const_eval_discriminant_cycle_result)] - fn const_eval_discriminant<'db>( - &'db self, - def: EnumVariantId, - ) -> Result>; + fn const_eval_discriminant(&self, def: EnumVariantId) -> Result; #[salsa::invoke(crate::method_resolution::lookup_impl_method_query)] #[salsa::transparent] @@ -100,19 +89,19 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { #[salsa::invoke(crate::layout::layout_of_adt_query)] #[salsa::cycle(cycle_result = crate::layout::layout_of_adt_cycle_result)] - fn layout_of_adt<'db>( - &'db self, + fn layout_of_adt( + &self, def: AdtId, - args: GenericArgs<'db>, - trait_env: ParamEnvAndCrate<'db>, + args: StoredGenericArgs, + trait_env: StoredParamEnvAndCrate, ) -> Result, LayoutError>; #[salsa::invoke(crate::layout::layout_of_ty_query)] #[salsa::cycle(cycle_result = crate::layout::layout_of_ty_cycle_result)] - fn layout_of_ty<'db>( - &'db self, - ty: Ty<'db>, - env: ParamEnvAndCrate<'db>, + fn layout_of_ty( + &self, + ty: StoredTy, + env: StoredParamEnvAndCrate, ) -> Result, LayoutError>; #[salsa::invoke(crate::layout::target_data_layout_query)] @@ -125,8 +114,8 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { #[salsa::transparent] fn ty<'db>(&'db self, def: TyDefId) -> EarlyBinder<'db, Ty<'db>>; - #[salsa::invoke(crate::lower::type_for_type_alias_with_diagnostics_query)] - #[salsa::cycle(cycle_result = crate::lower::type_for_type_alias_with_diagnostics_cycle_result)] + #[salsa::invoke(crate::lower::type_for_type_alias_with_diagnostics)] + #[salsa::transparent] fn type_for_type_alias_with_diagnostics<'db>( &'db self, def: TypeAliasId, @@ -134,11 +123,12 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { /// Returns the type of the value of the given constant, or `None` if the `ValueTyDefId` is /// a `StructId` or `EnumVariantId` with a record constructor. - #[salsa::invoke(crate::lower::value_ty_query)] + #[salsa::invoke(crate::lower::value_ty)] + #[salsa::transparent] fn value_ty<'db>(&'db self, def: ValueTyDefId) -> Option>>; - #[salsa::invoke(crate::lower::impl_self_ty_with_diagnostics_query)] - #[salsa::cycle(cycle_result = crate::lower::impl_self_ty_with_diagnostics_cycle_result)] + #[salsa::invoke(crate::lower::impl_self_ty_with_diagnostics)] + #[salsa::transparent] fn impl_self_ty_with_diagnostics<'db>( &'db self, def: ImplId, @@ -148,9 +138,8 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { #[salsa::transparent] fn impl_self_ty<'db>(&'db self, def: ImplId) -> EarlyBinder<'db, Ty<'db>>; - // FIXME: Make this a non-interned query. - #[salsa::invoke_interned(crate::lower::const_param_ty_with_diagnostics_query)] - #[salsa::cycle(cycle_result = crate::lower::const_param_ty_with_diagnostics_cycle_result)] + #[salsa::invoke(crate::lower::const_param_ty_with_diagnostics)] + #[salsa::transparent] fn const_param_ty_with_diagnostics<'db>(&'db self, def: ConstParamId) -> (Ty<'db>, Diagnostics); @@ -158,7 +147,8 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { #[salsa::transparent] fn const_param_ty_ns<'db>(&'db self, def: ConstParamId) -> Ty<'db>; - #[salsa::invoke(crate::lower::impl_trait_with_diagnostics_query)] + #[salsa::invoke(crate::lower::impl_trait_with_diagnostics)] + #[salsa::transparent] fn impl_trait_with_diagnostics<'db>( &'db self, def: ImplId, @@ -169,19 +159,18 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { fn impl_trait<'db>(&'db self, def: ImplId) -> Option>>; #[salsa::invoke(crate::lower::field_types_with_diagnostics_query)] - fn field_types_with_diagnostics<'db>( - &'db self, + #[salsa::transparent] + fn field_types_with_diagnostics( + &self, var: VariantId, - ) -> (Arc>>>, Diagnostics); + ) -> &(ArenaMap>, Diagnostics); #[salsa::invoke(crate::lower::field_types_query)] #[salsa::transparent] - fn field_types<'db>( - &'db self, - var: VariantId, - ) -> Arc>>>; + fn field_types(&self, var: VariantId) -> &ArenaMap>; - #[salsa::invoke(crate::lower::callable_item_signature_query)] + #[salsa::invoke(crate::lower::callable_item_signature)] + #[salsa::transparent] fn callable_item_signature<'db>( &'db self, def: CallableDefId, @@ -191,26 +180,27 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { #[salsa::transparent] fn trait_environment_for_body<'db>(&'db self, def: DefWithBodyId) -> ParamEnv<'db>; - #[salsa::invoke(crate::lower::trait_environment_query)] + #[salsa::invoke(crate::lower::trait_environment)] + #[salsa::transparent] fn trait_environment<'db>(&'db self, def: GenericDefId) -> ParamEnv<'db>; #[salsa::invoke(crate::lower::generic_defaults_with_diagnostics_query)] #[salsa::cycle(cycle_result = crate::lower::generic_defaults_with_diagnostics_cycle_result)] - fn generic_defaults_with_diagnostics<'db>( - &'db self, + fn generic_defaults_with_diagnostics( + &self, def: GenericDefId, - ) -> (GenericDefaults<'db>, Diagnostics); + ) -> (GenericDefaults, Diagnostics); /// This returns an empty list if no parameter has default. /// /// The binders of the returned defaults are only up to (not including) this parameter. #[salsa::invoke(crate::lower::generic_defaults_query)] #[salsa::transparent] - fn generic_defaults<'db>(&'db self, def: GenericDefId) -> GenericDefaults<'db>; + fn generic_defaults(&self, def: GenericDefId) -> GenericDefaults; // Interned IDs for solver integration #[salsa::interned] - fn intern_impl_trait_id(&self, id: ImplTraitId<'_>) -> InternedOpaqueTyId; + fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId; #[salsa::interned] fn intern_closure(&self, id: InternedClosure) -> InternedClosureId; @@ -219,11 +209,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug { fn intern_coroutine(&self, id: InternedCoroutine) -> InternedCoroutineId; #[salsa::invoke(crate::variance::variances_of)] - #[salsa::cycle( - // cycle_fn = crate::variance::variances_of_cycle_fn, - // cycle_initial = crate::variance::variances_of_cycle_initial, - cycle_result = crate::variance::variances_of_cycle_initial, - )] + #[salsa::transparent] fn variances_of<'db>(&'db self, def: GenericDefId) -> VariancesOf<'db>; } @@ -245,10 +231,10 @@ pub struct InternedConstParamId { pub loc: ConstParamId, } -#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX, unsafe(non_update_types))] +#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)] #[derive(PartialOrd, Ord)] pub struct InternedOpaqueTyId { - pub loc: ImplTraitId<'db>, + pub loc: ImplTraitId, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/expr.rs index 0de7fab8d1b2..dd1fc3b36ef8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/expr.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/expr.rs @@ -99,7 +99,7 @@ impl BodyValidationDiagnostic { struct ExprValidator<'db> { owner: DefWithBodyId, body: Arc, - infer: &'db InferenceResult<'db>, + infer: &'db InferenceResult, env: ParamEnv<'db>, diagnostics: Vec, validate_lints: bool, @@ -313,7 +313,7 @@ impl<'db> ExprValidator<'db> { ); value_or_partial.is_none_or(|v| !matches!(v, ValueNs::StaticId(_))) } - Expr::Field { expr, .. } => match self.infer.type_of_expr[*expr].kind() { + Expr::Field { expr, .. } => match self.infer.expr_ty(*expr).kind() { TyKind::Adt(adt, ..) if matches!(adt.def_id().0, AdtId::UnionId(_)) => false, _ => self.is_known_valid_scrutinee(*expr), }, @@ -554,7 +554,7 @@ impl<'db> FilterMapNextChecker<'db> { pub fn record_literal_missing_fields( db: &dyn HirDatabase, - infer: &InferenceResult<'_>, + infer: &InferenceResult, id: ExprId, expr: &Expr, ) -> Option<(VariantId, Vec, /*exhaustive*/ bool)> { @@ -584,7 +584,7 @@ pub fn record_literal_missing_fields( pub fn record_pattern_missing_fields( db: &dyn HirDatabase, - infer: &InferenceResult<'_>, + infer: &InferenceResult, id: PatId, pat: &Pat, ) -> Option<(VariantId, Vec, /*exhaustive*/ bool)> { @@ -612,8 +612,8 @@ pub fn record_pattern_missing_fields( Some((variant_def, missed_fields, exhaustive)) } -fn types_of_subpatterns_do_match(pat: PatId, body: &Body, infer: &InferenceResult<'_>) -> bool { - fn walk(pat: PatId, body: &Body, infer: &InferenceResult<'_>, has_type_mismatches: &mut bool) { +fn types_of_subpatterns_do_match(pat: PatId, body: &Body, infer: &InferenceResult) -> bool { + fn walk(pat: PatId, body: &Body, infer: &InferenceResult, has_type_mismatches: &mut bool) { match infer.type_mismatch_for_pat(pat) { Some(_) => *has_type_mismatches = true, None if *has_type_mismatches => (), diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check.rs b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check.rs index 80b65ace77cd..8e6101e6a0e3 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check.rs @@ -16,7 +16,7 @@ use hir_def::{ item_tree::FieldsShape, }; use hir_expand::name::Name; -use rustc_type_ir::inherent::{IntoKind, SliceLike}; +use rustc_type_ir::inherent::IntoKind; use span::Edition; use stdx::{always, never, variance::PhantomCovariantLifetime}; @@ -96,7 +96,7 @@ pub(crate) enum PatKind<'db> { pub(crate) struct PatCtxt<'a, 'db> { db: &'db dyn HirDatabase, - infer: &'a InferenceResult<'db>, + infer: &'db InferenceResult, body: &'a Body, pub(crate) errors: Vec, } @@ -104,7 +104,7 @@ pub(crate) struct PatCtxt<'a, 'db> { impl<'a, 'db> PatCtxt<'a, 'db> { pub(crate) fn new( db: &'db dyn HirDatabase, - infer: &'a InferenceResult<'db>, + infer: &'db InferenceResult, body: &'a Body, ) -> Self { Self { db, infer, body, errors: Vec::new() } @@ -119,12 +119,15 @@ impl<'a, 'db> PatCtxt<'a, 'db> { let unadjusted_pat = self.lower_pattern_unadjusted(pat); self.infer.pat_adjustments.get(&pat).map(|it| &**it).unwrap_or_default().iter().rev().fold( unadjusted_pat, - |subpattern, ref_ty| Pat { ty: *ref_ty, kind: Box::new(PatKind::Deref { subpattern }) }, + |subpattern, ref_ty| Pat { + ty: ref_ty.as_ref(), + kind: Box::new(PatKind::Deref { subpattern }), + }, ) } fn lower_pattern_unadjusted(&mut self, pat: PatId) -> Pat<'db> { - let mut ty = self.infer[pat]; + let mut ty = self.infer.pat_ty(pat); let variant = self.infer.variant_resolution_for_pat(pat); let kind = match self.body[pat] { @@ -151,7 +154,7 @@ impl<'a, 'db> PatCtxt<'a, 'db> { hir_def::hir::Pat::Bind { id, subpat, .. } => { let bm = self.infer.binding_modes[pat]; - ty = self.infer[id]; + ty = self.infer.binding_ty(id); let name = &self.body[id].name; match (bm, ty.kind()) { (BindingMode::Ref(_), TyKind::Ref(_, rty, _)) => ty = rty, @@ -273,7 +276,7 @@ impl<'a, 'db> PatCtxt<'a, 'db> { } fn lower_path(&mut self, pat: PatId, _path: &Path) -> Pat<'db> { - let ty = self.infer[pat]; + let ty = self.infer.pat_ty(pat); let pat_from_kind = |kind| Pat { ty, kind: Box::new(kind) }; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs index 91448d5806f9..eda7e7e249b3 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs @@ -11,7 +11,7 @@ use rustc_pattern_analysis::{ constructor::{Constructor, ConstructorSet, VariantVisibility}, usefulness::{PlaceValidity, UsefulnessReport, compute_match_usefulness}, }; -use rustc_type_ir::inherent::{AdtDef, IntoKind, SliceLike}; +use rustc_type_ir::inherent::{AdtDef, IntoKind}; use smallvec::{SmallVec, smallvec}; use stdx::never; @@ -150,7 +150,7 @@ impl<'a, 'db> MatchCheckCtx<'a, 'db> { let fields_len = variant.fields(self.db).fields().len() as u32; (0..fields_len).map(|idx| LocalFieldId::from_raw(idx.into())).map(move |fid| { - let ty = field_tys[fid].instantiate(self.infcx.interner, substs); + let ty = field_tys[fid].get().instantiate(self.infcx.interner, substs); let ty = self .infcx .at(&ObligationCause::dummy(), self.env) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/unsafe_check.rs b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/unsafe_check.rs index bbc381ba5d51..50d4517d0125 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/unsafe_check.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/unsafe_check.rs @@ -97,9 +97,9 @@ enum UnsafeDiagnostic { DeprecatedSafe2024 { node: ExprId, inside_unsafe_block: InsideUnsafeBlock }, } -pub fn unsafe_operations_for_body<'db>( - db: &'db dyn HirDatabase, - infer: &InferenceResult<'db>, +pub fn unsafe_operations_for_body( + db: &dyn HirDatabase, + infer: &InferenceResult, def: DefWithBodyId, body: &Body, callback: &mut dyn FnMut(ExprOrPatId), @@ -116,9 +116,9 @@ pub fn unsafe_operations_for_body<'db>( } } -pub fn unsafe_operations<'db>( - db: &'db dyn HirDatabase, - infer: &InferenceResult<'db>, +pub fn unsafe_operations( + db: &dyn HirDatabase, + infer: &InferenceResult, def: DefWithBodyId, body: &Body, current: ExprId, @@ -136,7 +136,7 @@ pub fn unsafe_operations<'db>( struct UnsafeVisitor<'db> { db: &'db dyn HirDatabase, - infer: &'db InferenceResult<'db>, + infer: &'db InferenceResult, body: &'db Body, resolver: Resolver<'db>, def: DefWithBodyId, @@ -155,7 +155,7 @@ struct UnsafeVisitor<'db> { impl<'db> UnsafeVisitor<'db> { fn new( db: &'db dyn HirDatabase, - infer: &'db InferenceResult<'db>, + infer: &'db InferenceResult, body: &'db Body, def: DefWithBodyId, unsafe_expr_cb: &'db mut dyn FnMut(UnsafeDiagnostic), @@ -260,7 +260,7 @@ impl<'db> UnsafeVisitor<'db> { match pat { Pat::Record { .. } => { - if let Some((AdtId::UnionId(_), _)) = self.infer[current].as_adt() { + if let Some((AdtId::UnionId(_), _)) = self.infer.pat_ty(current).as_adt() { let old_inside_union_destructure = mem::replace(&mut self.inside_union_destructure, true); self.body.walk_pats_shallow(current, |pat| self.walk_pat(pat)); @@ -286,7 +286,7 @@ impl<'db> UnsafeVisitor<'db> { let inside_assignment = mem::replace(&mut self.inside_assignment, false); match expr { &Expr::Call { callee, .. } => { - let callee = self.infer[callee]; + let callee = self.infer.expr_ty(callee); if let TyKind::FnDef(CallableIdWrapper(CallableDefId::FunctionId(func)), _) = callee.kind() { @@ -341,7 +341,7 @@ impl<'db> UnsafeVisitor<'db> { } } Expr::UnaryOp { expr, op: UnaryOp::Deref } => { - if let TyKind::RawPtr(..) = self.infer[*expr].kind() { + if let TyKind::RawPtr(..) = self.infer.expr_ty(*expr).kind() { self.on_unsafe_op(current.into(), UnsafetyReason::RawPtrDeref); } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/display.rs b/src/tools/rust-analyzer/crates/hir-ty/src/display.rs index e1d62a9c7a3e..8e44c14abe23 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/display.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/display.rs @@ -38,7 +38,7 @@ use rustc_hash::FxHashSet; use rustc_type_ir::{ AliasTyKind, BoundVarIndexKind, CoroutineArgsParts, CoroutineClosureArgsParts, RegionKind, Upcast, - inherent::{AdtDef, GenericArgs as _, IntoKind, SliceLike, Term as _, Ty as _, Tys as _}, + inherent::{AdtDef, GenericArgs as _, IntoKind, Term as _, Ty as _, Tys as _}, }; use smallvec::SmallVec; use span::Edition; @@ -52,9 +52,9 @@ use crate::{ lower::GenericPredicates, mir::pad16, next_solver::{ - AliasTy, Clause, ClauseKind, Const, ConstKind, DbInterner, EarlyBinder, - ExistentialPredicate, FnSig, GenericArg, GenericArgs, ParamEnv, PolyFnSig, Region, - SolverDefId, Term, TraitRef, Ty, TyKind, TypingMode, + AliasTy, Clause, ClauseKind, Const, ConstKind, DbInterner, ExistentialPredicate, FnSig, + GenericArg, GenericArgKind, GenericArgs, ParamEnv, PolyFnSig, Region, SolverDefId, + StoredEarlyBinder, StoredTy, Term, TermKind, TraitRef, Ty, TyKind, TypingMode, abi::Safety, infer::{DbInternerInferExt, traits::ObligationCause}, }, @@ -602,7 +602,7 @@ impl<'db, T: HirDisplay<'db>> HirDisplay<'db> for &T { impl<'db, T: HirDisplay<'db> + Internable> HirDisplay<'db> for Interned { fn hir_fmt(&self, f: &mut HirFormatter<'_, 'db>) -> Result { - HirDisplay::hir_fmt(self.as_ref(), f) + HirDisplay::hir_fmt(&**self, f) } } @@ -664,10 +664,10 @@ fn write_projection<'db>(f: &mut HirFormatter<'_, 'db>, alias: &AliasTy<'db>) -> impl<'db> HirDisplay<'db> for GenericArg<'db> { fn hir_fmt(&self, f: &mut HirFormatter<'_, 'db>) -> Result { - match self { - GenericArg::Ty(ty) => ty.hir_fmt(f), - GenericArg::Lifetime(lt) => lt.hir_fmt(f), - GenericArg::Const(c) => c.hir_fmt(f), + match self.kind() { + GenericArgKind::Type(ty) => ty.hir_fmt(f), + GenericArgKind::Lifetime(lt) => lt.hir_fmt(f), + GenericArgKind::Const(c) => c.hir_fmt(f), } } } @@ -790,7 +790,7 @@ fn render_const_scalar_inner<'db>( TyKind::Slice(ty) => { let addr = usize::from_le_bytes(b[0..b.len() / 2].try_into().unwrap()); let count = usize::from_le_bytes(b[b.len() / 2..].try_into().unwrap()); - let Ok(layout) = f.db.layout_of_ty(ty, param_env) else { + let Ok(layout) = f.db.layout_of_ty(ty.store(), param_env.store()) else { return f.write_str(""); }; let size_one = layout.size.bytes_usize(); @@ -824,7 +824,7 @@ fn render_const_scalar_inner<'db>( let Ok(t) = memory_map.vtable_ty(ty_id) else { return f.write_str(""); }; - let Ok(layout) = f.db.layout_of_ty(t, param_env) else { + let Ok(layout) = f.db.layout_of_ty(t.store(), param_env.store()) else { return f.write_str(""); }; let size = layout.size.bytes_usize(); @@ -854,7 +854,7 @@ fn render_const_scalar_inner<'db>( return f.write_str(""); } }); - let Ok(layout) = f.db.layout_of_ty(t, param_env) else { + let Ok(layout) = f.db.layout_of_ty(t.store(), param_env.store()) else { return f.write_str(""); }; let size = layout.size.bytes_usize(); @@ -866,7 +866,7 @@ fn render_const_scalar_inner<'db>( } }, TyKind::Tuple(tys) => { - let Ok(layout) = f.db.layout_of_ty(ty, param_env) else { + let Ok(layout) = f.db.layout_of_ty(ty.store(), param_env.store()) else { return f.write_str(""); }; f.write_str("(")?; @@ -878,7 +878,7 @@ fn render_const_scalar_inner<'db>( f.write_str(", ")?; } let offset = layout.fields.offset(id).bytes_usize(); - let Ok(layout) = f.db.layout_of_ty(ty, param_env) else { + let Ok(layout) = f.db.layout_of_ty(ty.store(), param_env.store()) else { f.write_str("")?; continue; }; @@ -889,7 +889,7 @@ fn render_const_scalar_inner<'db>( } TyKind::Adt(def, args) => { let def = def.def_id().0; - let Ok(layout) = f.db.layout_of_adt(def, args, param_env) else { + let Ok(layout) = f.db.layout_of_adt(def, args.store(), param_env.store()) else { return f.write_str(""); }; match def { @@ -900,7 +900,7 @@ fn render_const_scalar_inner<'db>( render_variant_after_name( s.fields(f.db), f, - &field_types, + field_types, f.db.trait_environment(def.into()), &layout, args, @@ -932,7 +932,7 @@ fn render_const_scalar_inner<'db>( render_variant_after_name( var_id.fields(f.db), f, - &field_types, + field_types, f.db.trait_environment(def.into()), var_layout, args, @@ -952,7 +952,7 @@ fn render_const_scalar_inner<'db>( let Some(len) = consteval::try_const_usize(f.db, len) else { return f.write_str(""); }; - let Ok(layout) = f.db.layout_of_ty(ty, param_env) else { + let Ok(layout) = f.db.layout_of_ty(ty.store(), param_env.store()) else { return f.write_str(""); }; let size_one = layout.size.bytes_usize(); @@ -992,7 +992,7 @@ fn render_const_scalar_inner<'db>( fn render_variant_after_name<'db>( data: &VariantFields, f: &mut HirFormatter<'_, 'db>, - field_types: &ArenaMap>>, + field_types: &'db ArenaMap>, param_env: ParamEnv<'db>, layout: &Layout, args: GenericArgs<'db>, @@ -1004,8 +1004,8 @@ fn render_variant_after_name<'db>( FieldsShape::Record | FieldsShape::Tuple => { let render_field = |f: &mut HirFormatter<'_, 'db>, id: LocalFieldId| { let offset = layout.fields.offset(u32::from(id.into_raw()) as usize).bytes_usize(); - let ty = field_types[id].instantiate(f.interner, args); - let Ok(layout) = f.db.layout_of_ty(ty, param_env) else { + let ty = field_types[id].get().instantiate(f.interner, args); + let Ok(layout) = f.db.layout_of_ty(ty.store(), param_env.store()) else { return f.write_str(""); }; let size = layout.size.bytes_usize(); @@ -1223,7 +1223,7 @@ impl<'db> HirDisplay<'db> for Ty<'db> { }; f.end_location_link(); - if args.len() > 0 { + if !args.is_empty() { let generic_def_id = GenericDefId::from_callable(db, def); let generics = generics(db, generic_def_id); let (parent_len, self_param, type_, const_, impl_, lifetime) = @@ -1787,9 +1787,9 @@ impl<'db> HirDisplay<'db> for PolyFnSig<'db> { impl<'db> HirDisplay<'db> for Term<'db> { fn hir_fmt(&self, f: &mut HirFormatter<'_, 'db>) -> Result { - match self { - Term::Ty(it) => it.hir_fmt(f), - Term::Const(it) => it.hir_fmt(f), + match self.kind() { + TermKind::Ty(it) => it.hir_fmt(f), + TermKind::Const(it) => it.hir_fmt(f), } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/drop.rs b/src/tools/rust-analyzer/crates/hir-ty/src/drop.rs index 3ae6451d6952..66692143bc1a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/drop.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/drop.rs @@ -2,7 +2,7 @@ use hir_def::{AdtId, signatures::StructFlags}; use rustc_hash::FxHashSet; -use rustc_type_ir::inherent::{AdtDef, IntoKind, SliceLike}; +use rustc_type_ir::inherent::{AdtDef, IntoKind}; use stdx::never; use crate::{ @@ -85,7 +85,7 @@ fn has_drop_glue_impl<'db>( .map(|(_, field_ty)| { has_drop_glue_impl( infcx, - field_ty.instantiate(infcx.interner, subst), + field_ty.get().instantiate(infcx.interner, subst), env, visited, ) @@ -105,7 +105,7 @@ fn has_drop_glue_impl<'db>( .map(|(_, field_ty)| { has_drop_glue_impl( infcx, - field_ty.instantiate(infcx.interner, subst), + field_ty.get().instantiate(infcx.interner, subst), env, visited, ) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs b/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs index 64b15eb017a6..ffdc9ca0f85a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs @@ -10,8 +10,7 @@ use hir_def::{ use rustc_hash::FxHashSet; use rustc_type_ir::{ AliasTyKind, ClauseKind, PredicatePolarity, TypeSuperVisitable as _, TypeVisitable as _, - Upcast, elaborate, - inherent::{IntoKind, SliceLike}, + Upcast, elaborate, inherent::IntoKind, }; use smallvec::SmallVec; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs index d6682c0cf2fe..bd5fffc4cc65 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs @@ -28,7 +28,7 @@ mod path; mod place_op; pub(crate) mod unify; -use std::{cell::OnceCell, convert::identity, iter, ops::Index}; +use std::{cell::OnceCell, convert::identity, iter}; use base_db::Crate; use either::Either; @@ -47,14 +47,12 @@ use hir_expand::{mod_path::ModPath, name::Name}; use indexmap::IndexSet; use intern::sym; use la_arena::ArenaMap; -use macros::{TypeFoldable, TypeVisitable}; use rustc_ast_ir::Mutability; use rustc_hash::{FxHashMap, FxHashSet}; use rustc_type_ir::{ AliasTyKind, TypeFoldable, - inherent::{AdtDef, IntoKind, Region as _, SliceLike, Ty as _}, + inherent::{AdtDef, IntoKind, Region as _, Ty as _}, }; -use salsa::Update; use span::Edition; use stdx::never; use thin_vec::ThinVec; @@ -74,8 +72,8 @@ use crate::{ method_resolution::{CandidateId, MethodResolutionUnstableFeatures}, mir::MirSpan, next_solver::{ - AliasTy, Const, DbInterner, ErrorGuaranteed, GenericArg, GenericArgs, Region, Ty, TyKind, - Tys, + AliasTy, Const, DbInterner, ErrorGuaranteed, GenericArg, GenericArgs, Region, + StoredGenericArgs, StoredTy, StoredTys, Ty, TyKind, Tys, abi::Safety, infer::{InferCtxt, traits::ObligationCause}, }, @@ -95,7 +93,7 @@ use cast::{CastCheck, CastError}; pub(crate) use closure::analysis::{CaptureKind, CapturedItem, CapturedItemWithoutTy}; /// The entry point of type inference. -fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'_> { +fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult { let _p = tracing::info_span!("infer_query").entered(); let resolver = def.resolver(db); let body = db.body(def); @@ -162,7 +160,7 @@ fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'_> ctx.resolve_all() } -fn infer_cycle_result(db: &dyn HirDatabase, _: salsa::Id, _: DefWithBodyId) -> InferenceResult<'_> { +fn infer_cycle_result(db: &dyn HirDatabase, _: salsa::Id, _: DefWithBodyId) -> InferenceResult { InferenceResult { has_errors: true, ..InferenceResult::new(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)) @@ -196,8 +194,8 @@ pub enum InferenceTyDiagnosticSource { Signature, } -#[derive(Debug, PartialEq, Eq, Clone, Update)] -pub enum InferenceDiagnostic<'db> { +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum InferenceDiagnostic { NoSuchField { field: ExprOrPatId, private: Option, @@ -213,16 +211,16 @@ pub enum InferenceDiagnostic<'db> { }, UnresolvedField { expr: ExprId, - receiver: Ty<'db>, + receiver: StoredTy, name: Name, method_with_same_name_exists: bool, }, UnresolvedMethodCall { expr: ExprId, - receiver: Ty<'db>, + receiver: StoredTy, name: Name, /// Contains the type the field resolves to - field_with_same_name: Option>, + field_with_same_name: Option, assoc_func_with_same_name: Option, }, UnresolvedAssocItem { @@ -249,21 +247,21 @@ pub enum InferenceDiagnostic<'db> { }, ExpectedFunction { call_expr: ExprId, - found: Ty<'db>, + found: StoredTy, }, TypedHole { expr: ExprId, - expected: Ty<'db>, + expected: StoredTy, }, CastToUnsized { expr: ExprId, - cast_ty: Ty<'db>, + cast_ty: StoredTy, }, InvalidCast { expr: ExprId, error: CastError, - expr_ty: Ty<'db>, - cast_ty: Ty<'db>, + expr_ty: StoredTy, + cast_ty: StoredTy, }, TyDiagnostic { source: InferenceTyDiagnosticSource, @@ -290,10 +288,10 @@ pub enum InferenceDiagnostic<'db> { } /// A mismatch between an expected and an inferred type. -#[derive(Clone, PartialEq, Eq, Debug, Hash, Update)] -pub struct TypeMismatch<'db> { - pub expected: Ty<'db>, - pub actual: Ty<'db>, +#[derive(Clone, PartialEq, Eq, Debug, Hash)] +pub struct TypeMismatch { + pub expected: StoredTy, + pub actual: StoredTy, } /// Represents coercing a value to a different type of value. @@ -336,20 +334,23 @@ pub struct TypeMismatch<'db> { /// At some point, of course, `Box` should move out of the compiler, in which /// case this is analogous to transforming a struct. E.g., Box<[i32; 4]> -> /// Box<[i32]> is an `Adjust::Unsize` with the target `Box<[i32]>`. -#[derive(Clone, Debug, PartialEq, Eq, Hash, TypeVisitable, TypeFoldable, Update)] -pub struct Adjustment<'db> { - #[type_visitable(ignore)] - #[type_foldable(identity)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct Adjustment { pub kind: Adjust, - pub target: Ty<'db>, + pub target: StoredTy, } -impl<'db> Adjustment<'db> { - pub fn borrow(interner: DbInterner<'db>, m: Mutability, ty: Ty<'db>, lt: Region<'db>) -> Self { +impl Adjustment { + pub fn borrow<'db>( + interner: DbInterner<'db>, + m: Mutability, + ty: Ty<'db>, + lt: Region<'db>, + ) -> Self { let ty = Ty::new_ref(interner, lt, ty, m); Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::new(m, AllowTwoPhase::No))), - target: ty, + target: ty.store(), } } } @@ -473,56 +474,47 @@ pub enum PointerCast { /// When you add a field that stores types (including `Substitution` and the like), don't forget /// `resolve_completely()`'ing them in `InferenceContext::resolve_all()`. Inference variables must /// not appear in the final inference result. -#[derive(Clone, PartialEq, Eq, Debug, Update)] -pub struct InferenceResult<'db> { +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct InferenceResult { /// For each method call expr, records the function it resolves to. - #[update(unsafe(with(crate::utils::unsafe_update_eq /* expr id is technically update */)))] - method_resolutions: FxHashMap)>, + method_resolutions: FxHashMap, /// For each field access expr, records the field it resolves to. field_resolutions: FxHashMap>, /// For each struct literal or pattern, records the variant it resolves to. variant_resolutions: FxHashMap, /// For each associated item record what it resolves to - assoc_resolutions: FxHashMap)>, + assoc_resolutions: FxHashMap, /// Whenever a tuple field expression access a tuple field, we allocate a tuple id in /// [`InferenceContext`] and store the tuples substitution there. This map is the reverse of /// that which allows us to resolve a [`TupleFieldId`]s type. - #[update(unsafe(with(crate::utils::unsafe_update_eq /* thinvec is technically update */)))] - tuple_field_access_types: ThinVec>, + tuple_field_access_types: ThinVec, - #[update(unsafe(with(crate::utils::unsafe_update_eq /* expr id is technically update */)))] - pub(crate) type_of_expr: ArenaMap>, + pub(crate) type_of_expr: ArenaMap, /// For each pattern record the type it resolves to. /// /// **Note**: When a pattern type is resolved it may still contain /// unresolved or missing subpatterns or subpatterns of mismatched types. - #[update(unsafe(with(crate::utils::unsafe_update_eq /* pat id is technically update */)))] - pub(crate) type_of_pat: ArenaMap>, - #[update(unsafe(with(crate::utils::unsafe_update_eq /* binding id is technically update */)))] - pub(crate) type_of_binding: ArenaMap>, - #[update(unsafe(with(crate::utils::unsafe_update_eq /* type ref id is technically update */)))] - pub(crate) type_of_type_placeholder: FxHashMap>, - pub(crate) type_of_opaque: FxHashMap>, + pub(crate) type_of_pat: ArenaMap, + pub(crate) type_of_binding: ArenaMap, + pub(crate) type_of_type_placeholder: FxHashMap, + pub(crate) type_of_opaque: FxHashMap, - pub(crate) type_mismatches: Option>>>, + pub(crate) type_mismatches: Option>>, /// Whether there are any type-mismatching errors in the result. // FIXME: This isn't as useful as initially thought due to us falling back placeholders to // `TyKind::Error`. // Which will then mark this field. pub(crate) has_errors: bool, /// During inference this field is empty and [`InferenceContext::diagnostics`] is filled instead. - #[update(unsafe(with(crate::utils::unsafe_update_eq /* thinvec is technically update */)))] - diagnostics: ThinVec>, + diagnostics: ThinVec, /// Interned `Error` type to return references to. // FIXME: Remove this. - error_ty: Ty<'db>, + error_ty: StoredTy, - #[update(unsafe(with(crate::utils::unsafe_update_eq /* expr id is technically update */)))] - pub(crate) expr_adjustments: FxHashMap]>>, + pub(crate) expr_adjustments: FxHashMap>, /// Stores the types which were implicitly dereferenced in pattern binding modes. - #[update(unsafe(with(crate::utils::unsafe_update_eq /* pat id is technically update */)))] - pub(crate) pat_adjustments: FxHashMap>>, + pub(crate) pat_adjustments: FxHashMap>, /// Stores the binding mode (`ref` in `let ref x = 2`) of bindings. /// /// This one is tied to the `PatId` instead of `BindingId`, because in some rare cases, a binding in an @@ -538,7 +530,7 @@ pub struct InferenceResult<'db> { /// the first `rest` has implicit `ref` binding mode, but the second `rest` binding mode is `move`. pub(crate) binding_modes: ArenaMap, - pub(crate) closure_info: FxHashMap>, FnTrait)>, + pub(crate) closure_info: FxHashMap, FnTrait)>, // FIXME: remove this field pub mutated_bindings_in_closure: FxHashSet, @@ -546,15 +538,15 @@ pub struct InferenceResult<'db> { } #[salsa::tracked] -impl<'db> InferenceResult<'db> { - #[salsa::tracked(returns(ref), cycle_result = infer_cycle_result, unsafe(non_update_types))] - pub fn for_body(db: &'db dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'db> { +impl InferenceResult { + #[salsa::tracked(returns(ref), cycle_result = infer_cycle_result)] + pub fn for_body(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult { infer_query(db, def) } } -impl<'db> InferenceResult<'db> { - fn new(error_ty: Ty<'db>) -> Self { +impl InferenceResult { + fn new(error_ty: Ty<'_>) -> Self { Self { method_resolutions: Default::default(), field_resolutions: Default::default(), @@ -569,7 +561,7 @@ impl<'db> InferenceResult<'db> { type_of_opaque: Default::default(), type_mismatches: Default::default(), has_errors: Default::default(), - error_ty, + error_ty: error_ty.store(), pat_adjustments: Default::default(), binding_modes: Default::default(), expr_adjustments: Default::default(), @@ -579,8 +571,8 @@ impl<'db> InferenceResult<'db> { } } - pub fn method_resolution(&self, expr: ExprId) -> Option<(FunctionId, GenericArgs<'db>)> { - self.method_resolutions.get(&expr).copied() + pub fn method_resolution<'db>(&self, expr: ExprId) -> Option<(FunctionId, GenericArgs<'db>)> { + self.method_resolutions.get(&expr).map(|(func, args)| (*func, args.as_ref())) } pub fn field_resolution(&self, expr: ExprId) -> Option> { self.field_resolutions.get(&expr).copied() @@ -597,16 +589,19 @@ impl<'db> InferenceResult<'db> { ExprOrPatId::PatId(id) => self.variant_resolution_for_pat(id), } } - pub fn assoc_resolutions_for_expr( + pub fn assoc_resolutions_for_expr<'db>( &self, id: ExprId, ) -> Option<(CandidateId, GenericArgs<'db>)> { - self.assoc_resolutions.get(&id.into()).copied() + self.assoc_resolutions.get(&id.into()).map(|(assoc, args)| (*assoc, args.as_ref())) } - pub fn assoc_resolutions_for_pat(&self, id: PatId) -> Option<(CandidateId, GenericArgs<'db>)> { - self.assoc_resolutions.get(&id.into()).copied() + pub fn assoc_resolutions_for_pat<'db>( + &self, + id: PatId, + ) -> Option<(CandidateId, GenericArgs<'db>)> { + self.assoc_resolutions.get(&id.into()).map(|(assoc, args)| (*assoc, args.as_ref())) } - pub fn assoc_resolutions_for_expr_or_pat( + pub fn assoc_resolutions_for_expr_or_pat<'db>( &self, id: ExprOrPatId, ) -> Option<(CandidateId, GenericArgs<'db>)> { @@ -615,20 +610,20 @@ impl<'db> InferenceResult<'db> { ExprOrPatId::PatId(id) => self.assoc_resolutions_for_pat(id), } } - pub fn type_mismatch_for_expr(&self, expr: ExprId) -> Option<&TypeMismatch<'db>> { + pub fn type_mismatch_for_expr(&self, expr: ExprId) -> Option<&TypeMismatch> { self.type_mismatches.as_deref()?.get(&expr.into()) } - pub fn type_mismatch_for_pat(&self, pat: PatId) -> Option<&TypeMismatch<'db>> { + pub fn type_mismatch_for_pat(&self, pat: PatId) -> Option<&TypeMismatch> { self.type_mismatches.as_deref()?.get(&pat.into()) } - pub fn type_mismatches(&self) -> impl Iterator)> { + pub fn type_mismatches(&self) -> impl Iterator { self.type_mismatches .as_deref() .into_iter() .flatten() .map(|(expr_or_pat, mismatch)| (*expr_or_pat, mismatch)) } - pub fn expr_type_mismatches(&self) -> impl Iterator)> { + pub fn expr_type_mismatches(&self) -> impl Iterator { self.type_mismatches.as_deref().into_iter().flatten().filter_map( |(expr_or_pat, mismatch)| match *expr_or_pat { ExprOrPatId::ExprId(expr) => Some((expr, mismatch)), @@ -636,22 +631,22 @@ impl<'db> InferenceResult<'db> { }, ) } - pub fn placeholder_types(&self) -> impl Iterator)> { - self.type_of_type_placeholder.iter().map(|(&type_ref, ty)| (type_ref, ty)) + pub fn placeholder_types<'db>(&self) -> impl Iterator)> { + self.type_of_type_placeholder.iter().map(|(&type_ref, ty)| (type_ref, ty.as_ref())) } - pub fn type_of_type_placeholder(&self, type_ref: TypeRefId) -> Option> { - self.type_of_type_placeholder.get(&type_ref).copied() + pub fn type_of_type_placeholder<'db>(&self, type_ref: TypeRefId) -> Option> { + self.type_of_type_placeholder.get(&type_ref).map(|ty| ty.as_ref()) } - pub fn closure_info(&self, closure: InternedClosureId) -> &(Vec>, FnTrait) { + pub fn closure_info(&self, closure: InternedClosureId) -> &(Vec, FnTrait) { self.closure_info.get(&closure).unwrap() } - pub fn type_of_expr_or_pat(&self, id: ExprOrPatId) -> Option> { + pub fn type_of_expr_or_pat<'db>(&self, id: ExprOrPatId) -> Option> { match id { - ExprOrPatId::ExprId(id) => self.type_of_expr.get(id).copied(), - ExprOrPatId::PatId(id) => self.type_of_pat.get(id).copied(), + ExprOrPatId::ExprId(id) => self.type_of_expr.get(id).map(|it| it.as_ref()), + ExprOrPatId::PatId(id) => self.type_of_pat.get(id).map(|it| it.as_ref()), } } - pub fn type_of_expr_with_adjust(&self, id: ExprId) -> Option> { + pub fn type_of_expr_with_adjust<'db>(&self, id: ExprId) -> Option> { match self.expr_adjustments.get(&id).and_then(|adjustments| { adjustments.iter().rfind(|adj| { // https://github.com/rust-lang/rust/blob/67819923ac8ea353aaa775303f4c3aacbf41d010/compiler/rustc_mir_build/src/thir/cx/expr.rs#L140 @@ -660,37 +655,37 @@ impl<'db> InferenceResult<'db> { Adjustment { kind: Adjust::NeverToAny, target, - } if target.is_never() + } if target.as_ref().is_never() ) }) }) { - Some(adjustment) => Some(adjustment.target), - None => self.type_of_expr.get(id).copied(), + Some(adjustment) => Some(adjustment.target.as_ref()), + None => self.type_of_expr.get(id).map(|it| it.as_ref()), } } - pub fn type_of_pat_with_adjust(&self, id: PatId) -> Option> { + pub fn type_of_pat_with_adjust<'db>(&self, id: PatId) -> Option> { match self.pat_adjustments.get(&id).and_then(|adjustments| adjustments.last()) { - Some(adjusted) => Some(*adjusted), - None => self.type_of_pat.get(id).copied(), + Some(adjusted) => Some(adjusted.as_ref()), + None => self.type_of_pat.get(id).map(|it| it.as_ref()), } } pub fn is_erroneous(&self) -> bool { self.has_errors && self.type_of_expr.iter().count() == 0 } - pub fn diagnostics(&self) -> &[InferenceDiagnostic<'db>] { + pub fn diagnostics(&self) -> &[InferenceDiagnostic] { &self.diagnostics } - pub fn tuple_field_access_type(&self, id: TupleId) -> Tys<'db> { - self.tuple_field_access_types[id.0 as usize] + pub fn tuple_field_access_type<'db>(&self, id: TupleId) -> Tys<'db> { + self.tuple_field_access_types[id.0 as usize].as_ref() } - pub fn pat_adjustment(&self, id: PatId) -> Option<&[Ty<'db>]> { + pub fn pat_adjustment(&self, id: PatId) -> Option<&[StoredTy]> { self.pat_adjustments.get(&id).map(|it| &**it) } - pub fn expr_adjustment(&self, id: ExprId) -> Option<&[Adjustment<'db>]> { + pub fn expr_adjustment(&self, id: ExprId) -> Option<&[Adjustment]> { self.expr_adjustments.get(&id).map(|it| &**it) } @@ -699,66 +694,47 @@ impl<'db> InferenceResult<'db> { } // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. - pub fn expression_types(&self) -> impl Iterator)> { - self.type_of_expr.iter().map(|(k, v)| (k, *v)) + pub fn expression_types<'db>(&self) -> impl Iterator)> { + self.type_of_expr.iter().map(|(k, v)| (k, v.as_ref())) } // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. - pub fn pattern_types(&self) -> impl Iterator)> { - self.type_of_pat.iter().map(|(k, v)| (k, *v)) + pub fn pattern_types<'db>(&self) -> impl Iterator)> { + self.type_of_pat.iter().map(|(k, v)| (k, v.as_ref())) } // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. - pub fn binding_types(&self) -> impl Iterator)> { - self.type_of_binding.iter().map(|(k, v)| (k, *v)) + pub fn binding_types<'db>(&self) -> impl Iterator)> { + self.type_of_binding.iter().map(|(k, v)| (k, v.as_ref())) } // This method is consumed by external tools to run rust-analyzer as a library. Don't remove, please. - pub fn return_position_impl_trait_types( - &self, + pub fn return_position_impl_trait_types<'db>( + &'db self, db: &'db dyn HirDatabase, - ) -> impl Iterator, Ty<'db>)> { - self.type_of_opaque.iter().filter_map(move |(&id, &ty)| { + ) -> impl Iterator)> { + self.type_of_opaque.iter().filter_map(move |(&id, ty)| { let ImplTraitId::ReturnTypeImplTrait(_, rpit_idx) = id.loc(db) else { return None; }; - Some((rpit_idx, ty)) + Some((rpit_idx, ty.as_ref())) }) } -} -impl<'db> Index for InferenceResult<'db> { - type Output = Ty<'db>; - - fn index(&self, expr: ExprId) -> &Ty<'db> { - self.type_of_expr.get(expr).unwrap_or(&self.error_ty) + pub fn expr_ty<'db>(&self, id: ExprId) -> Ty<'db> { + self.type_of_expr.get(id).map_or(self.error_ty.as_ref(), |it| it.as_ref()) } -} -impl<'db> Index for InferenceResult<'db> { - type Output = Ty<'db>; - - fn index(&self, pat: PatId) -> &Ty<'db> { - self.type_of_pat.get(pat).unwrap_or(&self.error_ty) + pub fn pat_ty<'db>(&self, id: PatId) -> Ty<'db> { + self.type_of_pat.get(id).map_or(self.error_ty.as_ref(), |it| it.as_ref()) } -} -impl<'db> Index for InferenceResult<'db> { - type Output = Ty<'db>; - - fn index(&self, id: ExprOrPatId) -> &Ty<'db> { - match id { - ExprOrPatId::ExprId(id) => &self[id], - ExprOrPatId::PatId(id) => &self[id], - } + pub fn expr_or_pat_ty<'db>(&self, id: ExprOrPatId) -> Ty<'db> { + self.type_of_expr_or_pat(id).unwrap_or(self.error_ty.as_ref()) } -} -impl<'db> Index for InferenceResult<'db> { - type Output = Ty<'db>; - - fn index(&self, b: BindingId) -> &Ty<'db> { - self.type_of_binding.get(b).unwrap_or(&self.error_ty) + pub fn binding_ty<'db>(&self, id: BindingId) -> Ty<'db> { + self.type_of_binding.get(id).map_or(self.error_ty.as_ref(), |it| it.as_ref()) } } @@ -826,7 +802,7 @@ impl<'db> InternedStandardTypes<'db> { re_error: Region::error(interner), re_erased: Region::new_erased(interner), - empty_args: GenericArgs::new_from_iter(interner, []), + empty_args: GenericArgs::empty(interner), } } } @@ -848,7 +824,7 @@ pub(crate) struct InferenceContext<'body, 'db> { pub(crate) lang_items: &'db LangItems, /// The traits in scope, disregarding block modules. This is used for caching purposes. traits_in_scope: FxHashSet, - pub(crate) result: InferenceResult<'db>, + pub(crate) result: InferenceResult, tuple_field_accesses_rev: IndexSet, std::hash::BuildHasherDefault>, /// The return type of the function being inferred, the closure or async block if we're @@ -873,7 +849,7 @@ pub(crate) struct InferenceContext<'body, 'db> { deferred_cast_checks: Vec>, // fields related to closure capture - current_captures: Vec>, + current_captures: Vec, /// A stack that has an entry for each projection in the current capture. /// /// For example, in `a.b.c`, we capture the spans of `a`, `a.b`, and `a.b.c`. @@ -886,7 +862,7 @@ pub(crate) struct InferenceContext<'body, 'db> { closure_dependencies: FxHashMap>, deferred_closures: FxHashMap, Ty<'db>, Vec>, ExprId)>>, - diagnostics: Diagnostics<'db>, + diagnostics: Diagnostics, } #[derive(Clone, Debug)] @@ -1008,7 +984,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { /// Clones `self` and calls `resolve_all()` on it. // FIXME: Remove this. - pub(crate) fn fixme_resolve_all_clone(&self) -> InferenceResult<'db> { + pub(crate) fn fixme_resolve_all_clone(&self) -> InferenceResult { let mut ctx = self.clone(); ctx.type_inference_fallback(); @@ -1032,7 +1008,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { // `InferenceResult` in the middle of inference. See the fixme comment in `consteval::eval_to_const`. If you // used this function for another workaround, mention it here. If you really need this function and believe that // there is no problem in it being `pub(crate)`, remove this comment. - fn resolve_all(self) -> InferenceResult<'db> { + fn resolve_all(self) -> InferenceResult { let InferenceContext { mut table, mut result, tuple_field_accesses_rev, diagnostics, .. } = self; @@ -1066,23 +1042,23 @@ impl<'body, 'db> InferenceContext<'body, 'db> { } = &mut result; for ty in type_of_expr.values_mut() { - *ty = table.resolve_completely(*ty); - *has_errors = *has_errors || ty.references_non_lt_error(); + *ty = table.resolve_completely(ty.as_ref()).store(); + *has_errors = *has_errors || ty.as_ref().references_non_lt_error(); } type_of_expr.shrink_to_fit(); for ty in type_of_pat.values_mut() { - *ty = table.resolve_completely(*ty); - *has_errors = *has_errors || ty.references_non_lt_error(); + *ty = table.resolve_completely(ty.as_ref()).store(); + *has_errors = *has_errors || ty.as_ref().references_non_lt_error(); } type_of_pat.shrink_to_fit(); for ty in type_of_binding.values_mut() { - *ty = table.resolve_completely(*ty); - *has_errors = *has_errors || ty.references_non_lt_error(); + *ty = table.resolve_completely(ty.as_ref()).store(); + *has_errors = *has_errors || ty.as_ref().references_non_lt_error(); } type_of_binding.shrink_to_fit(); for ty in type_of_type_placeholder.values_mut() { - *ty = table.resolve_completely(*ty); - *has_errors = *has_errors || ty.references_non_lt_error(); + *ty = table.resolve_completely(ty.as_ref()).store(); + *has_errors = *has_errors || ty.as_ref().references_non_lt_error(); } type_of_type_placeholder.shrink_to_fit(); type_of_opaque.shrink_to_fit(); @@ -1090,8 +1066,8 @@ impl<'body, 'db> InferenceContext<'body, 'db> { if let Some(type_mismatches) = type_mismatches { *has_errors = true; for mismatch in type_mismatches.values_mut() { - mismatch.expected = table.resolve_completely(mismatch.expected); - mismatch.actual = table.resolve_completely(mismatch.actual); + mismatch.expected = table.resolve_completely(mismatch.expected.as_ref()).store(); + mismatch.actual = table.resolve_completely(mismatch.actual.as_ref()).store(); } type_mismatches.shrink_to_fit(); } @@ -1101,23 +1077,23 @@ impl<'body, 'db> InferenceContext<'body, 'db> { ExpectedFunction { found: ty, .. } | UnresolvedField { receiver: ty, .. } | UnresolvedMethodCall { receiver: ty, .. } => { - *ty = table.resolve_completely(*ty); + *ty = table.resolve_completely(ty.as_ref()).store(); // FIXME: Remove this when we are on par with rustc in terms of inference - if ty.references_non_lt_error() { + if ty.as_ref().references_non_lt_error() { return false; } if let UnresolvedMethodCall { field_with_same_name, .. } = diagnostic && let Some(ty) = field_with_same_name { - *ty = table.resolve_completely(*ty); - if ty.references_non_lt_error() { + *ty = table.resolve_completely(ty.as_ref()).store(); + if ty.as_ref().references_non_lt_error() { *field_with_same_name = None; } } } TypedHole { expected: ty, .. } => { - *ty = table.resolve_completely(*ty); + *ty = table.resolve_completely(ty.as_ref()).store(); } _ => (), } @@ -1125,30 +1101,33 @@ impl<'body, 'db> InferenceContext<'body, 'db> { }); diagnostics.shrink_to_fit(); for (_, subst) in method_resolutions.values_mut() { - *subst = table.resolve_completely(*subst); - *has_errors = *has_errors || subst.types().any(|ty| ty.references_non_lt_error()); + *subst = table.resolve_completely(subst.as_ref()).store(); + *has_errors = + *has_errors || subst.as_ref().types().any(|ty| ty.references_non_lt_error()); } method_resolutions.shrink_to_fit(); for (_, subst) in assoc_resolutions.values_mut() { - *subst = table.resolve_completely(*subst); - *has_errors = *has_errors || subst.types().any(|ty| ty.references_non_lt_error()); + *subst = table.resolve_completely(subst.as_ref()).store(); + *has_errors = + *has_errors || subst.as_ref().types().any(|ty| ty.references_non_lt_error()); } assoc_resolutions.shrink_to_fit(); for adjustment in expr_adjustments.values_mut().flatten() { - adjustment.target = table.resolve_completely(adjustment.target); - *has_errors = *has_errors || adjustment.target.references_non_lt_error(); + adjustment.target = table.resolve_completely(adjustment.target.as_ref()).store(); + *has_errors = *has_errors || adjustment.target.as_ref().references_non_lt_error(); } expr_adjustments.shrink_to_fit(); for adjustment in pat_adjustments.values_mut().flatten() { - *adjustment = table.resolve_completely(*adjustment); - *has_errors = *has_errors || adjustment.references_non_lt_error(); + *adjustment = table.resolve_completely(adjustment.as_ref()).store(); + *has_errors = *has_errors || adjustment.as_ref().references_non_lt_error(); } pat_adjustments.shrink_to_fit(); result.tuple_field_access_types = tuple_field_accesses_rev .into_iter() - .map(|subst| table.resolve_completely(subst)) + .map(|subst| table.resolve_completely(subst).store()) .inspect(|subst| { - *has_errors = *has_errors || subst.iter().any(|ty| ty.references_non_lt_error()); + *has_errors = + *has_errors || subst.as_ref().iter().any(|ty| ty.references_non_lt_error()); }) .collect(); result.tuple_field_access_types.shrink_to_fit(); @@ -1262,10 +1241,10 @@ impl<'body, 'db> InferenceContext<'body, 'db> { } fn write_expr_ty(&mut self, expr: ExprId, ty: Ty<'db>) { - self.result.type_of_expr.insert(expr, ty); + self.result.type_of_expr.insert(expr, ty.store()); } - pub(crate) fn write_expr_adj(&mut self, expr: ExprId, adjustments: Box<[Adjustment<'db>]>) { + pub(crate) fn write_expr_adj(&mut self, expr: ExprId, adjustments: Box<[Adjustment]>) { if adjustments.is_empty() { return; } @@ -1278,7 +1257,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { ) => { // NeverToAny coercion can target any type, so instead of adding a new // adjustment on top we can change the target. - *target = *new_target; + *target = new_target.clone(); } _ => { *entry.get_mut() = adjustments; @@ -1291,7 +1270,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { } } - fn write_pat_adj(&mut self, pat: PatId, adjustments: Box<[Ty<'db>]>) { + fn write_pat_adj(&mut self, pat: PatId, adjustments: Box<[StoredTy]>) { if adjustments.is_empty() { return; } @@ -1304,7 +1283,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { func: FunctionId, subst: GenericArgs<'db>, ) { - self.result.method_resolutions.insert(expr, (func, subst)); + self.result.method_resolutions.insert(expr, (func, subst.store())); } fn write_variant_resolution(&mut self, id: ExprOrPatId, variant: VariantId) { @@ -1317,22 +1296,22 @@ impl<'body, 'db> InferenceContext<'body, 'db> { item: CandidateId, subs: GenericArgs<'db>, ) { - self.result.assoc_resolutions.insert(id, (item, subs)); + self.result.assoc_resolutions.insert(id, (item, subs.store())); } fn write_pat_ty(&mut self, pat: PatId, ty: Ty<'db>) { - self.result.type_of_pat.insert(pat, ty); + self.result.type_of_pat.insert(pat, ty.store()); } fn write_type_placeholder_ty(&mut self, type_ref: TypeRefId, ty: Ty<'db>) { - self.result.type_of_type_placeholder.insert(type_ref, ty); + self.result.type_of_type_placeholder.insert(type_ref, ty.store()); } fn write_binding_ty(&mut self, id: BindingId, ty: Ty<'db>) { - self.result.type_of_binding.insert(id, ty); + self.result.type_of_binding.insert(id, ty.store()); } - pub(crate) fn push_diagnostic(&self, diagnostic: InferenceDiagnostic<'db>) { + pub(crate) fn push_diagnostic(&self, diagnostic: InferenceDiagnostic) { self.diagnostics.push(diagnostic); } @@ -1486,7 +1465,13 @@ impl<'body, 'db> InferenceContext<'body, 'db> { match ty.kind() { TyKind::Adt(adt_def, substs) => match adt_def.def_id().0 { AdtId::StructId(struct_id) => { - match self.db.field_types(struct_id.into()).values().next_back().copied() { + match self + .db + .field_types(struct_id.into()) + .values() + .next_back() + .map(|it| it.get()) + { Some(field) => { ty = field.instantiate(self.interner(), substs); } @@ -1547,7 +1532,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { self.result .type_mismatches .get_or_insert_default() - .insert(id, TypeMismatch { expected, actual }); + .insert(id, TypeMismatch { expected: expected.store(), actual: actual.store() }); } result } @@ -1592,7 +1577,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { } fn expr_ty(&self, expr: ExprId) -> Ty<'db> { - self.result[expr] + self.result.expr_ty(expr) } fn expr_ty_after_adjustments(&self, e: ExprId) -> Ty<'db> { @@ -1600,7 +1585,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { if let Some(it) = self.result.expr_adjustments.get(&e) && let Some(it) = it.last() { - ty = Some(it.target); + ty = Some(it.target.as_ref()); } ty.unwrap_or_else(|| self.expr_ty(e)) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/autoderef.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/autoderef.rs index b54a6cdee2d4..d748c89e6775 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/autoderef.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/autoderef.rs @@ -25,7 +25,7 @@ impl<'db> InferenceTable<'db> { } impl<'db, Ctx: AutoderefCtx<'db>> GeneralAutoderef<'db, Ctx> { - pub(crate) fn adjust_steps_as_infer_ok(&mut self) -> InferOk<'db, Vec>> { + pub(crate) fn adjust_steps_as_infer_ok(&mut self) -> InferOk<'db, Vec> { let steps = self.steps(); if steps.is_empty() { return InferOk { obligations: PredicateObligations::new(), value: vec![] }; @@ -42,7 +42,10 @@ impl<'db, Ctx: AutoderefCtx<'db>> GeneralAutoderef<'db, Ctx> { } }) .zip(targets) - .map(|(autoderef, target)| Adjustment { kind: Adjust::Deref(autoderef), target }) + .map(|(autoderef, target)| Adjustment { + kind: Adjust::Deref(autoderef), + target: target.store(), + }) .collect(); InferOk { obligations: self.take_obligations(), value: steps } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/cast.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/cast.rs index 00a1dfff6d95..d073b06ccc8a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/cast.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/cast.rs @@ -4,7 +4,7 @@ use hir_def::{AdtId, hir::ExprId, signatures::TraitFlags}; use rustc_ast_ir::Mutability; use rustc_type_ir::{ Flags, InferTy, TypeFlags, UintTy, - inherent::{AdtDef, BoundExistentialPredicates as _, IntoKind, SliceLike, Ty as _}, + inherent::{AdtDef, BoundExistentialPredicates as _, IntoKind, Ty as _}, }; use stdx::never; @@ -83,8 +83,13 @@ impl CastError { expr: ExprId, expr_ty: Ty<'db>, cast_ty: Ty<'db>, - ) -> InferenceDiagnostic<'db> { - InferenceDiagnostic::InvalidCast { expr, error: self, expr_ty, cast_ty } + ) -> InferenceDiagnostic { + InferenceDiagnostic::InvalidCast { + expr, + error: self, + expr_ty: expr_ty.store(), + cast_ty: cast_ty.store(), + } } } @@ -109,7 +114,7 @@ impl<'db> CastCheck<'db> { pub(super) fn check( &mut self, ctx: &mut InferenceContext<'_, 'db>, - ) -> Result<(), InferenceDiagnostic<'db>> { + ) -> Result<(), InferenceDiagnostic> { self.expr_ty = ctx.table.try_structurally_resolve_type(self.expr_ty); self.cast_ty = ctx.table.try_structurally_resolve_type(self.cast_ty); @@ -137,7 +142,7 @@ impl<'db> CastCheck<'db> { { return Err(InferenceDiagnostic::CastToUnsized { expr: self.expr, - cast_ty: self.cast_ty, + cast_ty: self.cast_ty.store(), }); } @@ -393,8 +398,9 @@ fn pointer_kind<'db>( let struct_data = id.fields(ctx.db); if let Some((last_field, _)) = struct_data.fields().iter().last() { - let last_field_ty = - ctx.db.field_types(id.into())[last_field].instantiate(ctx.interner(), subst); + let last_field_ty = ctx.db.field_types(id.into())[last_field] + .get() + .instantiate(ctx.interner(), subst); pointer_kind(last_field_ty, ctx) } else { Ok(Some(PointerKind::Thin)) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs index 308c01865ae3..a7369d606da4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs @@ -15,7 +15,7 @@ use hir_def::{ }; use rustc_ast_ir::Mutability; use rustc_hash::{FxHashMap, FxHashSet}; -use rustc_type_ir::inherent::{IntoKind, SliceLike, Ty as _}; +use rustc_type_ir::inherent::{IntoKind, Ty as _}; use smallvec::{SmallVec, smallvec}; use stdx::{format_to, never}; use syntax::utils::is_raw_identifier; @@ -25,21 +25,21 @@ use crate::{ db::{HirDatabase, InternedClosure, InternedClosureId}, infer::InferenceContext, mir::{BorrowKind, MirSpan, MutBorrowKind, ProjectionElem}, - next_solver::{DbInterner, EarlyBinder, GenericArgs, Ty, TyKind}, + next_solver::{DbInterner, GenericArgs, StoredEarlyBinder, StoredTy, Ty, TyKind}, traits::FnTrait, }; // The below functions handle capture and closure kind (Fn, FnMut, ..) #[derive(Debug, Clone, PartialEq, Eq, Hash, salsa::Update)] -pub(crate) struct HirPlace<'db> { +pub(crate) struct HirPlace { pub(crate) local: BindingId, - pub(crate) projections: Vec>, + pub(crate) projections: Vec>, } -impl<'db> HirPlace<'db> { - fn ty(&self, ctx: &mut InferenceContext<'_, 'db>) -> Ty<'db> { - let mut ty = ctx.table.resolve_completely(ctx.result[self.local]); +impl HirPlace { + fn ty<'db>(&self, ctx: &mut InferenceContext<'_, 'db>) -> Ty<'db> { + let mut ty = ctx.table.resolve_completely(ctx.result.binding_ty(self.local)); for p in &self.projections { ty = p.projected_ty( &ctx.table.infer_ctxt, @@ -78,8 +78,8 @@ pub enum CaptureKind { } #[derive(Debug, Clone, PartialEq, Eq, salsa::Update)] -pub struct CapturedItem<'db> { - pub(crate) place: HirPlace<'db>, +pub struct CapturedItem { + pub(crate) place: HirPlace, pub(crate) kind: CaptureKind, /// The inner vec is the stacks; the outer vec is for each capture reference. /// @@ -88,11 +88,10 @@ pub struct CapturedItem<'db> { /// copy all captures of the inner closure to the outer closure, and then we may /// truncate them, and we want the correct span to be reported. span_stacks: SmallVec<[SmallVec<[MirSpan; 3]>; 3]>, - #[update(unsafe(with(crate::utils::unsafe_update_eq)))] - pub(crate) ty: EarlyBinder<'db, Ty<'db>>, + pub(crate) ty: StoredEarlyBinder, } -impl<'db> CapturedItem<'db> { +impl CapturedItem { pub fn local(&self) -> BindingId { self.place.local } @@ -102,9 +101,9 @@ impl<'db> CapturedItem<'db> { self.place.projections.iter().any(|it| !matches!(it, ProjectionElem::Deref)) } - pub fn ty(&self, db: &'db dyn HirDatabase, subst: GenericArgs<'db>) -> Ty<'db> { + pub fn ty<'db>(&self, db: &'db dyn HirDatabase, subst: GenericArgs<'db>) -> Ty<'db> { let interner = DbInterner::new_no_crate(db); - self.ty.instantiate(interner, subst.split_closure_args_untupled().parent_args) + self.ty.get().instantiate(interner, subst.split_closure_args_untupled().parent_args) } pub fn kind(&self) -> CaptureKind { @@ -273,15 +272,15 @@ impl<'db> CapturedItem<'db> { } #[derive(Debug, Clone, PartialEq, Eq)] -pub(crate) struct CapturedItemWithoutTy<'db> { - pub(crate) place: HirPlace<'db>, +pub(crate) struct CapturedItemWithoutTy { + pub(crate) place: HirPlace, pub(crate) kind: CaptureKind, /// The inner vec is the stacks; the outer vec is for each capture reference. pub(crate) span_stacks: SmallVec<[SmallVec<[MirSpan; 3]>; 3]>, } -impl<'db> CapturedItemWithoutTy<'db> { - fn with_ty(self, ctx: &mut InferenceContext<'_, 'db>) -> CapturedItem<'db> { +impl CapturedItemWithoutTy { + fn with_ty(self, ctx: &mut InferenceContext<'_, '_>) -> CapturedItem { let ty = self.place.ty(ctx); let ty = match &self.kind { CaptureKind::ByValue => ty, @@ -297,13 +296,13 @@ impl<'db> CapturedItemWithoutTy<'db> { place: self.place, kind: self.kind, span_stacks: self.span_stacks, - ty: EarlyBinder::bind(ty), + ty: StoredEarlyBinder::bind(ty.store()), } } } impl<'db> InferenceContext<'_, 'db> { - fn place_of_expr(&mut self, tgt_expr: ExprId) -> Option> { + fn place_of_expr(&mut self, tgt_expr: ExprId) -> Option { let r = self.place_of_expr_without_adjust(tgt_expr)?; let adjustments = self.result.expr_adjustments.get(&tgt_expr).map(|it| &**it).unwrap_or_default(); @@ -311,7 +310,7 @@ impl<'db> InferenceContext<'_, 'db> { } /// Pushes the span into `current_capture_span_stack`, *without clearing it first*. - fn path_place(&mut self, path: &Path, id: ExprOrPatId) -> Option> { + fn path_place(&mut self, path: &Path, id: ExprOrPatId) -> Option { if path.type_anchor().is_some() { return None; } @@ -332,7 +331,7 @@ impl<'db> InferenceContext<'_, 'db> { } /// Changes `current_capture_span_stack` to contain the stack of spans for this expr. - fn place_of_expr_without_adjust(&mut self, tgt_expr: ExprId) -> Option> { + fn place_of_expr_without_adjust(&mut self, tgt_expr: ExprId) -> Option { self.current_capture_span_stack.clear(); match &self.body[tgt_expr] { Expr::Path(p) => { @@ -367,7 +366,7 @@ impl<'db> InferenceContext<'_, 'db> { None } - fn push_capture(&mut self, place: HirPlace<'db>, kind: CaptureKind) { + fn push_capture(&mut self, place: HirPlace, kind: CaptureKind) { self.current_captures.push(CapturedItemWithoutTy { place, kind, @@ -375,11 +374,7 @@ impl<'db> InferenceContext<'_, 'db> { }); } - fn truncate_capture_spans( - &self, - capture: &mut CapturedItemWithoutTy<'db>, - mut truncate_to: usize, - ) { + fn truncate_capture_spans(&self, capture: &mut CapturedItemWithoutTy, mut truncate_to: usize) { // The first span is the identifier, and it must always remain. truncate_to += 1; for span_stack in &mut capture.span_stacks { @@ -404,14 +399,14 @@ impl<'db> InferenceContext<'_, 'db> { } } - fn ref_expr(&mut self, expr: ExprId, place: Option>) { + fn ref_expr(&mut self, expr: ExprId, place: Option) { if let Some(place) = place { self.add_capture(place, CaptureKind::ByRef(BorrowKind::Shared)); } self.walk_expr(expr); } - fn add_capture(&mut self, place: HirPlace<'db>, kind: CaptureKind) { + fn add_capture(&mut self, place: HirPlace, kind: CaptureKind) { if self.is_upvar(&place) { self.push_capture(place, kind); } @@ -427,7 +422,7 @@ impl<'db> InferenceContext<'_, 'db> { } } - fn mutate_expr(&mut self, expr: ExprId, place: Option>) { + fn mutate_expr(&mut self, expr: ExprId, place: Option) { if let Some(place) = place { self.add_capture( place, @@ -444,7 +439,7 @@ impl<'db> InferenceContext<'_, 'db> { self.walk_expr(expr); } - fn consume_place(&mut self, place: HirPlace<'db>) { + fn consume_place(&mut self, place: HirPlace) { if self.is_upvar(&place) { let ty = place.ty(self); let kind = if self.is_ty_copy(ty) { @@ -456,7 +451,7 @@ impl<'db> InferenceContext<'_, 'db> { } } - fn walk_expr_with_adjust(&mut self, tgt_expr: ExprId, adjustment: &[Adjustment<'db>]) { + fn walk_expr_with_adjust(&mut self, tgt_expr: ExprId, adjustment: &[Adjustment]) { if let Some((last, rest)) = adjustment.split_last() { match &last.kind { Adjust::NeverToAny | Adjust::Deref(None) | Adjust::Pointer(_) => { @@ -477,12 +472,7 @@ impl<'db> InferenceContext<'_, 'db> { } } - fn ref_capture_with_adjusts( - &mut self, - m: Mutability, - tgt_expr: ExprId, - rest: &[Adjustment<'db>], - ) { + fn ref_capture_with_adjusts(&mut self, m: Mutability, tgt_expr: ExprId, rest: &[Adjustment]) { let capture_kind = match m { Mutability::Mut => CaptureKind::ByRef(BorrowKind::Mut { kind: MutBorrowKind::Default }), Mutability::Not => CaptureKind::ByRef(BorrowKind::Shared), @@ -780,7 +770,7 @@ impl<'db> InferenceContext<'_, 'db> { } Pat::Bind { id, .. } => match self.result.binding_modes[p] { crate::BindingMode::Move => { - if self.is_ty_copy(self.result.type_of_binding[*id]) { + if self.is_ty_copy(self.result.binding_ty(*id)) { update_result(CaptureKind::ByRef(BorrowKind::Shared)); } else { update_result(CaptureKind::ByValue); @@ -798,7 +788,7 @@ impl<'db> InferenceContext<'_, 'db> { self.body.walk_pats_shallow(p, |p| self.walk_pat_inner(p, update_result, for_mut)); } - fn is_upvar(&self, place: &HirPlace<'db>) -> bool { + fn is_upvar(&self, place: &HirPlace) -> bool { if let Some(c) = self.current_closure { let InternedClosure(_, root) = self.db.lookup_intern_closure(c); return self.body.is_binding_upvar(place.local, root); @@ -830,7 +820,7 @@ impl<'db> InferenceContext<'_, 'db> { // FIXME: Borrow checker problems without this. let mut current_captures = std::mem::take(&mut self.current_captures); for capture in &mut current_captures { - let mut ty = self.table.resolve_completely(self.result[capture.place.local]); + let mut ty = self.table.resolve_completely(self.result.binding_ty(capture.place.local)); if ty.is_raw_ptr() || ty.is_union() { capture.kind = CaptureKind::ByRef(BorrowKind::Shared); self.truncate_capture_spans(capture, 0); @@ -875,7 +865,7 @@ impl<'db> InferenceContext<'_, 'db> { fn minimize_captures(&mut self) { self.current_captures.sort_unstable_by_key(|it| it.place.projections.len()); - let mut hash_map = FxHashMap::, usize>::default(); + let mut hash_map = FxHashMap::::default(); let result = mem::take(&mut self.current_captures); for mut item in result { let mut lookup_place = HirPlace { local: item.place.local, projections: vec![] }; @@ -910,7 +900,7 @@ impl<'db> InferenceContext<'_, 'db> { } } - fn consume_with_pat(&mut self, mut place: HirPlace<'db>, tgt_pat: PatId) { + fn consume_with_pat(&mut self, mut place: HirPlace, tgt_pat: PatId) { let adjustments_count = self.result.pat_adjustments.get(&tgt_pat).map(|it| it.len()).unwrap_or_default(); place.projections.extend((0..adjustments_count).map(|_| ProjectionElem::Deref)); @@ -921,7 +911,7 @@ impl<'db> InferenceContext<'_, 'db> { Pat::Missing | Pat::Wild => (), Pat::Tuple { args, ellipsis } => { let (al, ar) = args.split_at(ellipsis.map_or(args.len(), |it| it as usize)); - let field_count = match self.result[tgt_pat].kind() { + let field_count = match self.result.pat_ty(tgt_pat).kind() { TyKind::Tuple(s) => s.len(), _ => break 'reset_span_stack, }; @@ -1221,11 +1211,11 @@ impl<'db> InferenceContext<'_, 'db> { } /// Call this only when the last span in the stack isn't a split. -fn apply_adjusts_to_place<'db>( +fn apply_adjusts_to_place( current_capture_span_stack: &mut Vec, - mut r: HirPlace<'db>, - adjustments: &[Adjustment<'db>], -) -> Option> { + mut r: HirPlace, + adjustments: &[Adjustment], +) -> Option { let span = *current_capture_span_stack.last().expect("empty capture span stack"); for adj in adjustments { match &adj.kind { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs index 77c7155550da..1233543c40f5 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs @@ -104,7 +104,7 @@ struct Coerce { cause: ObligationCause, } -type CoerceResult<'db> = InferResult<'db, (Vec>, Ty<'db>)>; +type CoerceResult<'db> = InferResult<'db, (Vec, Ty<'db>)>; /// Coercing a mutable reference to an immutable works, while /// coercing `&T` to `&mut T` should be forbidden. @@ -114,7 +114,7 @@ fn coerce_mutbls<'db>(from_mutbl: Mutability, to_mutbl: Mutability) -> RelateRes /// This always returns `Ok(...)`. fn success<'db>( - adj: Vec>, + adj: Vec, target: Ty<'db>, obligations: PredicateObligations<'db>, ) -> CoerceResult<'db> { @@ -206,14 +206,17 @@ where &mut self, a: Ty<'db>, b: Ty<'db>, - adjustments: impl IntoIterator>, + adjustments: impl IntoIterator, final_adjustment: Adjust, ) -> CoerceResult<'db> { self.unify_raw(a, b).and_then(|InferOk { value: ty, obligations }| { success( adjustments .into_iter() - .chain(std::iter::once(Adjustment { target: ty, kind: final_adjustment })) + .chain(std::iter::once(Adjustment { + target: ty.store(), + kind: final_adjustment, + })) .collect(), ty, obligations, @@ -237,7 +240,7 @@ where if self.coerce_never { return success( - vec![Adjustment { kind: Adjust::NeverToAny, target: b }], + vec![Adjustment { kind: Adjust::NeverToAny, target: b.store() }], b, PredicateObligations::new(), ); @@ -532,7 +535,8 @@ where // Now apply the autoref. let mutbl = AutoBorrowMutability::new(mutbl_b, self.allow_two_phase); - adjustments.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: ty }); + adjustments + .push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target: ty.store() }); debug!("coerce_borrowed_pointer: succeeded ty={:?} adjustments={:?}", ty, adjustments); @@ -635,10 +639,10 @@ where let mutbl = AutoBorrowMutability::new(mutbl_b, AllowTwoPhase::No); Some(( - Adjustment { kind: Adjust::Deref(None), target: ty_a }, + Adjustment { kind: Adjust::Deref(None), target: ty_a.store() }, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), - target: Ty::new_ref(self.interner(), r_borrow, ty_a, mutbl_b), + target: Ty::new_ref(self.interner(), r_borrow, ty_a, mutbl_b).store(), }, )) } @@ -646,16 +650,16 @@ where coerce_mutbls(mt_a, mt_b)?; Some(( - Adjustment { kind: Adjust::Deref(None), target: ty_a }, + Adjustment { kind: Adjust::Deref(None), target: ty_a.store() }, Adjustment { kind: Adjust::Borrow(AutoBorrow::RawPtr(mt_b)), - target: Ty::new_ptr(self.interner(), ty_a, mt_b), + target: Ty::new_ptr(self.interner(), ty_a, mt_b).store(), }, )) } _ => None, }; - let coerce_source = reborrow.as_ref().map_or(source, |(_, r)| r.target); + let coerce_source = reborrow.as_ref().map_or(source, |(_, r)| r.target.as_ref()); // Setup either a subtyping or a LUB relationship between // the `CoerceUnsized` target type and the expected type. @@ -726,7 +730,7 @@ where Ok(None) => { if trait_pred.def_id().0 == unsize_did { let self_ty = trait_pred.self_ty(); - let unsize_ty = trait_pred.trait_ref.args.inner()[1].expect_ty(); + let unsize_ty = trait_pred.trait_ref.args[1].expect_ty(); debug!("coerce_unsized: ambiguous unsize case for {:?}", trait_pred); match (self_ty.kind(), unsize_ty.kind()) { (TyKind::Infer(rustc_type_ir::TyVar(v)), TyKind::Dynamic(..)) @@ -815,7 +819,7 @@ where b, adjustment.map(|kind| Adjustment { kind, - target: Ty::new_fn_ptr(this.interner(), fn_ty_a), + target: Ty::new_fn_ptr(this.interner(), fn_ty_a).store(), }), Adjust::Pointer(PointerCast::UnsafeFnPointer), ) @@ -955,7 +959,7 @@ where self.unify_and( a_raw, b, - [Adjustment { kind: Adjust::Deref(None), target: mt_a.ty }], + [Adjustment { kind: Adjust::Deref(None), target: mt_a.ty.store() }], Adjust::Borrow(AutoBorrow::RawPtr(mutbl_b)), ) } else if mt_a.mutbl != mutbl_b { @@ -1170,12 +1174,15 @@ impl<'db> InferenceContext<'_, 'db> { for &expr in exprs { self.write_expr_adj( expr, - Box::new([Adjustment { kind: prev_adjustment.clone(), target: fn_ptr }]), + Box::new([Adjustment { + kind: prev_adjustment.clone(), + target: fn_ptr.store(), + }]), ); } self.write_expr_adj( new, - Box::new([Adjustment { kind: next_adjustment, target: fn_ptr }]), + Box::new([Adjustment { kind: next_adjustment, target: fn_ptr.store() }]), ); return Ok(fn_ptr); } @@ -1510,9 +1517,9 @@ impl<'db, 'exprs> CoerceMany<'db, 'exprs> { icx.result.type_mismatches.get_or_insert_default().insert( expression.into(), if label_expression_as_expected { - TypeMismatch { expected: found, actual: expected } + TypeMismatch { expected: found.store(), actual: expected.store() } } else { - TypeMismatch { expected, actual: found } + TypeMismatch { expected: expected.store(), actual: found.store() } }, ); } @@ -1570,7 +1577,7 @@ fn coerce<'db>( db: &'db dyn HirDatabase, env: ParamEnvAndCrate<'db>, tys: &Canonical<'db, (Ty<'db>, Ty<'db>)>, -) -> Result<(Vec>, Ty<'db>), TypeError>> { +) -> Result<(Vec, Ty<'db>), TypeError>> { let interner = DbInterner::new_with(db, env.krate); let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis); let ((ty1_with_vars, ty2_with_vars), vars) = infcx.instantiate_canonical(tys); @@ -1593,7 +1600,6 @@ fn coerce<'db>( let mut ocx = ObligationCtxt::new(&infcx); let (adjustments, ty) = ocx.register_infer_ok_obligations(infer_ok); _ = ocx.try_evaluate_obligations(); - let (adjustments, ty) = infcx.resolve_vars_if_possible((adjustments, ty)); // default any type vars that weren't unified back to their original bound vars // (kind of hacky) @@ -1701,10 +1707,18 @@ fn coerce<'db>( } // FIXME: We don't fallback correctly since this is done on `InferenceContext` and we only have `InferCtxt`. - let (adjustments, ty) = (adjustments, ty).fold_with(&mut Resolver { - interner, - debruijn: DebruijnIndex::ZERO, - var_values: vars.var_values, - }); + let mut resolver = + Resolver { interner, debruijn: DebruijnIndex::ZERO, var_values: vars.var_values }; + let ty = infcx.resolve_vars_if_possible(ty).fold_with(&mut resolver); + let adjustments = adjustments + .into_iter() + .map(|adjustment| Adjustment { + kind: adjustment.kind, + target: infcx + .resolve_vars_if_possible(adjustment.target.as_ref()) + .fold_with(&mut resolver) + .store(), + }) + .collect(); Ok((adjustments, ty)) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/diagnostics.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/diagnostics.rs index 0eb7a2f4740f..2bdc6f9491dc 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/diagnostics.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/diagnostics.rs @@ -25,10 +25,10 @@ use crate::{ // to our resolver and so we cannot have mutable reference, but we really want to have // ability to dispatch diagnostics during this work otherwise the code becomes a complete mess. #[derive(Debug, Default, Clone)] -pub(super) struct Diagnostics<'db>(RefCell>>); +pub(super) struct Diagnostics(RefCell>); -impl<'db> Diagnostics<'db> { - pub(super) fn push(&self, diagnostic: InferenceDiagnostic<'db>) { +impl Diagnostics { + pub(super) fn push(&self, diagnostic: InferenceDiagnostic) { self.0.borrow_mut().push(diagnostic); } @@ -42,19 +42,19 @@ impl<'db> Diagnostics<'db> { ); } - pub(super) fn finish(self) -> ThinVec> { + pub(super) fn finish(self) -> ThinVec { self.0.into_inner() } } -pub(crate) struct PathDiagnosticCallbackData<'a, 'db> { +pub(crate) struct PathDiagnosticCallbackData<'a> { node: ExprOrPatId, - diagnostics: &'a Diagnostics<'db>, + diagnostics: &'a Diagnostics, } pub(super) struct InferenceTyLoweringContext<'db, 'a> { ctx: TyLoweringContext<'db, 'a>, - diagnostics: &'a Diagnostics<'db>, + diagnostics: &'a Diagnostics, source: InferenceTyDiagnosticSource, } @@ -64,7 +64,7 @@ impl<'db, 'a> InferenceTyLoweringContext<'db, 'a> { db: &'db dyn HirDatabase, resolver: &'a Resolver<'db>, store: &'a ExpressionStore, - diagnostics: &'a Diagnostics<'db>, + diagnostics: &'a Diagnostics, source: InferenceTyDiagnosticSource, generic_def: GenericDefId, lifetime_elision: LifetimeElisionKind<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs index 4e1711e48ec4..5eeaeef9d9f6 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs @@ -17,7 +17,7 @@ use hir_expand::name::Name; use rustc_ast_ir::Mutability; use rustc_type_ir::{ CoroutineArgs, CoroutineArgsParts, InferTy, Interner, - inherent::{AdtDef, GenericArgs as _, IntoKind, SliceLike, Ty as _}, + inherent::{AdtDef, GenericArgs as _, IntoKind, Ty as _}, }; use syntax::ast::RangeOp; use tracing::debug; @@ -35,7 +35,7 @@ use crate::{ lower::{GenericPredicates, lower_mutability}, method_resolution::{self, CandidateId, MethodCallee, MethodError}, next_solver::{ - ErrorGuaranteed, FnSig, GenericArgs, TraitRef, Ty, TyKind, TypeError, + ErrorGuaranteed, FnSig, GenericArg, GenericArgs, TraitRef, Ty, TyKind, TypeError, infer::{ BoundRegionConversionTime, InferOk, traits::{Obligation, ObligationCause}, @@ -68,10 +68,10 @@ impl<'db> InferenceContext<'_, 'db> { if let Some(expected_ty) = expected.only_has_type(&mut self.table) { let could_unify = self.unify(ty, expected_ty); if !could_unify { - self.result - .type_mismatches - .get_or_insert_default() - .insert(tgt_expr.into(), TypeMismatch { expected: expected_ty, actual: ty }); + self.result.type_mismatches.get_or_insert_default().insert( + tgt_expr.into(), + TypeMismatch { expected: expected_ty.store(), actual: ty.store() }, + ); } } ty @@ -98,10 +98,10 @@ impl<'db> InferenceContext<'_, 'db> { match self.coerce(expr.into(), ty, target, AllowTwoPhase::No, is_read) { Ok(res) => res, Err(_) => { - self.result - .type_mismatches - .get_or_insert_default() - .insert(expr.into(), TypeMismatch { expected: target, actual: ty }); + self.result.type_mismatches.get_or_insert_default().insert( + expr.into(), + TypeMismatch { expected: target.store(), actual: ty.store() }, + ); target } } @@ -276,7 +276,7 @@ impl<'db> InferenceContext<'_, 'db> { if ty.is_never() { if let Some(adjustments) = self.result.expr_adjustments.get(&expr) { return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &**adjustments { - *target + target.as_ref() } else { self.err_ty() }; @@ -292,10 +292,10 @@ impl<'db> InferenceContext<'_, 'db> { if let Some(expected_ty) = expected.only_has_type(&mut self.table) { let could_unify = self.unify(ty, expected_ty); if !could_unify { - self.result - .type_mismatches - .get_or_insert_default() - .insert(expr.into(), TypeMismatch { expected: expected_ty, actual: ty }); + self.result.type_mismatches.get_or_insert_default().insert( + expr.into(), + TypeMismatch { expected: expected_ty.store(), actual: ty.store() }, + ); } } ty @@ -637,7 +637,7 @@ impl<'db> InferenceContext<'_, 'db> { } }; let field_ty = field_def.map_or(self.err_ty(), |it| { - field_types[it].instantiate(self.interner(), &substs) + field_types[it].get().instantiate(self.interner(), &substs) }); // Field type might have some unknown types @@ -780,7 +780,7 @@ impl<'db> InferenceContext<'_, 'db> { Ty::new_adt( self.interner(), adt, - GenericArgs::new_from_iter(self.interner(), [ty.into()]), + GenericArgs::new_from_iter(self.interner(), [GenericArg::from(ty)]), ) }; match (range_type, lhs_ty, rhs_ty) { @@ -947,7 +947,10 @@ impl<'db> InferenceContext<'_, 'db> { // Underscore expression is an error, we render a specialized diagnostic // to let the user know what type is expected though. let expected = expected.to_option(&mut self.table).unwrap_or_else(|| self.err_ty()); - self.push_diagnostic(InferenceDiagnostic::TypedHole { expr: tgt_expr, expected }); + self.push_diagnostic(InferenceDiagnostic::TypedHole { + expr: tgt_expr, + expected: expected.store(), + }); expected } Expr::OffsetOf(_) => self.types.usize, @@ -1183,10 +1186,10 @@ impl<'db> InferenceContext<'_, 'db> { match this.coerce(tgt_expr.into(), ty, target, AllowTwoPhase::No, ExprIsRead::Yes) { Ok(res) => res, Err(_) => { - this.result - .type_mismatches - .get_or_insert_default() - .insert(tgt_expr.into(), TypeMismatch { expected: target, actual: ty }); + this.result.type_mismatches.get_or_insert_default().insert( + tgt_expr.into(), + TypeMismatch { expected: target.store(), actual: ty.store() }, + ); target } } @@ -1234,7 +1237,7 @@ impl<'db> InferenceContext<'_, 'db> { &mut self, fn_x: FnTrait, derefed_callee: Ty<'db>, - adjustments: &mut Vec>, + adjustments: &mut Vec, callee_ty: Ty<'db>, params: &[Ty<'db>], tgt_expr: ExprId, @@ -1249,7 +1252,8 @@ impl<'db> InferenceContext<'_, 'db> { .unwrap_or(true) { // prefer reborrow to move - adjustments.push(Adjustment { kind: Adjust::Deref(None), target: inner }); + adjustments + .push(Adjustment { kind: Adjust::Deref(None), target: inner.store() }); adjustments.push(Adjustment::borrow( self.interner(), Mutability::Mut, @@ -1282,13 +1286,10 @@ impl<'db> InferenceContext<'_, 'db> { }; let trait_data = trait_.trait_items(self.db); if let Some(func) = trait_data.method_by_name(&fn_x.method_name()) { - let subst = GenericArgs::new_from_iter( - self.interner(), - [ - callee_ty.into(), - Ty::new_tup_from_iter(self.interner(), params.iter().copied()).into(), - ], - ); + let subst = GenericArgs::new_from_slice(&[ + callee_ty.into(), + Ty::new_tup(self.interner(), params).into(), + ]); self.write_method_resolution(tgt_expr, func, subst); } } @@ -1549,7 +1550,10 @@ impl<'db> InferenceContext<'_, 'db> { { this.result.type_mismatches.get_or_insert_default().insert( expr.into(), - TypeMismatch { expected: t, actual: this.types.unit }, + TypeMismatch { + expected: t.store(), + actual: this.types.unit.store(), + }, ); } t @@ -1567,7 +1571,7 @@ impl<'db> InferenceContext<'_, 'db> { &mut self, receiver_ty: Ty<'db>, name: &Name, - ) -> Option<(Ty<'db>, Either, Vec>, bool)> { + ) -> Option<(Ty<'db>, Either, Vec, bool)> { let interner = self.interner(); let mut autoderef = self.table.autoderef_with_tracking(receiver_ty); let mut private_field = None; @@ -1612,6 +1616,7 @@ impl<'db> InferenceContext<'_, 'db> { return None; } let ty = self.db.field_types(field_id.parent)[field_id.local_id] + .get() .instantiate(interner, parameters); Some((Either::Left(field_id), ty)) }); @@ -1629,6 +1634,7 @@ impl<'db> InferenceContext<'_, 'db> { let adjustments = self.table.register_infer_ok(autoderef.adjust_steps_as_infer_ok()); let ty = self.db.field_types(field_id.parent)[field_id.local_id] + .get() .instantiate(self.interner(), subst); let ty = self.process_remote_user_written_ty(ty); @@ -1679,7 +1685,7 @@ impl<'db> InferenceContext<'_, 'db> { ); self.push_diagnostic(InferenceDiagnostic::UnresolvedField { expr: tgt_expr, - receiver: receiver_ty, + receiver: receiver_ty.store(), name: name.clone(), method_with_same_name_exists: resolved.is_ok(), }); @@ -1755,7 +1761,7 @@ impl<'db> InferenceContext<'_, 'db> { None => { self.push_diagnostic(InferenceDiagnostic::ExpectedFunction { call_expr: tgt_expr, - found: callee_ty, + found: callee_ty.store(), }); (Vec::new(), Ty::new_error(interner, ErrorGuaranteed)) } @@ -1867,9 +1873,9 @@ impl<'db> InferenceContext<'_, 'db> { self.push_diagnostic(InferenceDiagnostic::UnresolvedMethodCall { expr: tgt_expr, - receiver: receiver_ty, + receiver: receiver_ty.store(), name: method_name.clone(), - field_with_same_name: field_with_same_name_exists, + field_with_same_name: field_with_same_name_exists.map(|it| it.store()), assoc_func_with_same_name: assoc_func_with_same_name.map(|it| it.def_id), }); @@ -2115,10 +2121,10 @@ impl<'db> InferenceContext<'_, 'db> { && args_count_matches { // Don't report type mismatches if there is a mismatch in args count. - self.result - .type_mismatches - .get_or_insert_default() - .insert((*arg).into(), TypeMismatch { expected, actual: found }); + self.result.type_mismatches.get_or_insert_default().insert( + (*arg).into(), + TypeMismatch { expected: expected.store(), actual: found.store() }, + ); } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/mutability.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/mutability.rs index 87dcaa8a4ea8..729ed214daea 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/mutability.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/mutability.rs @@ -26,8 +26,8 @@ impl<'db> InferenceContext<'_, 'db> { Adjust::Deref(Some(d)) => { if mutability == Mutability::Mut { let source_ty = match adjustments.peek() { - Some(prev_adj) => prev_adj.target, - None => self.result.type_of_expr[tgt_expr], + Some(prev_adj) => prev_adj.target.as_ref(), + None => self.result.type_of_expr[tgt_expr].as_ref(), }; if let Some(infer_ok) = Self::try_mutable_overloaded_place_op( &self.table, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs index 8236de167f73..c61b6c9ae53d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs @@ -213,7 +213,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::Yes); let autoref = Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), - target: method.sig.inputs_and_output.inputs()[0], + target: method.sig.inputs_and_output.inputs()[0].store(), }; self.write_expr_adj(lhs_expr, Box::new([autoref])); } @@ -227,7 +227,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { let autoref = Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), - target: method.sig.inputs_and_output.inputs()[1], + target: method.sig.inputs_and_output.inputs()[1].store(), }; // HACK(eddyb) Bypass checks due to reborrows being in // some cases applied on the RHS, on top of which we need diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs index ce4597f83d55..1c722897f47b 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs @@ -112,12 +112,12 @@ impl<'db> InferenceContext<'_, 'db> { _ = self.demand_eqtype_fixme_no_diag(expected, hidden_type.ty); } - self.result.type_of_opaque.insert(def_id, ty.ty); + self.result.type_of_opaque.insert(def_id, ty.ty.store()); continue; } - self.result.type_of_opaque.insert(def_id, self.types.error); + self.result.type_of_opaque.insert(def_id, self.types.error.store()); } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs index a02e280ac637..5eddd4102ba7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs @@ -9,7 +9,7 @@ use hir_def::{ }; use hir_expand::name::Name; use rustc_ast_ir::Mutability; -use rustc_type_ir::inherent::{GenericArg as _, GenericArgs as _, IntoKind, SliceLike, Ty as _}; +use rustc_type_ir::inherent::{GenericArg as _, GenericArgs as _, IntoKind, Ty as _}; use stdx::TupleExt; use crate::{ @@ -82,7 +82,7 @@ impl<'db> InferenceContext<'_, 'db> { { // FIXME(DIAGNOSE): private tuple field } - let f = field_types[local_id]; + let f = field_types[local_id].get(); let expected_ty = match substs { Some(substs) => f.instantiate(self.interner(), substs), None => f.instantiate(self.interner(), &[]), @@ -146,7 +146,7 @@ impl<'db> InferenceContext<'_, 'db> { variant: def, }); } - let f = field_types[local_id]; + let f = field_types[local_id].get(); let expected_ty = match substs { Some(substs) => f.instantiate(self.interner(), substs), None => f.instantiate(self.interner(), &[]), @@ -270,7 +270,7 @@ impl<'db> InferenceContext<'_, 'db> { } else if self.is_non_ref_pat(self.body, pat) { let mut pat_adjustments = Vec::new(); while let TyKind::Ref(_lifetime, inner, mutability) = expected.kind() { - pat_adjustments.push(expected); + pat_adjustments.push(expected.store()); expected = self.table.try_structurally_resolve_type(inner); default_bm = match default_bm { BindingMode::Move => BindingMode::Ref(mutability), @@ -333,7 +333,10 @@ impl<'db> InferenceContext<'_, 'db> { Err(_) => { self.result.type_mismatches.get_or_insert_default().insert( pat.into(), - TypeMismatch { expected, actual: ty_inserted_vars }, + TypeMismatch { + expected: expected.store(), + actual: ty_inserted_vars.store(), + }, ); self.write_pat_ty(pat, ty); // We return `expected` to prevent cascading errors. I guess an alternative is to @@ -413,10 +416,10 @@ impl<'db> InferenceContext<'_, 'db> { ) { Ok(ty) => ty, Err(_) => { - self.result - .type_mismatches - .get_or_insert_default() - .insert(pat.into(), TypeMismatch { expected, actual: lhs_ty }); + self.result.type_mismatches.get_or_insert_default().insert( + pat.into(), + TypeMismatch { expected: expected.store(), actual: lhs_ty.store() }, + ); // `rhs_ty` is returned so no further type mismatches are // reported because of this mismatch. expected @@ -432,22 +435,22 @@ impl<'db> InferenceContext<'_, 'db> { let ty = self.insert_type_vars_shallow(ty); // FIXME: This never check is odd, but required with out we do inference right now if !expected.is_never() && !self.unify(ty, expected) { - self.result - .type_mismatches - .get_or_insert_default() - .insert(pat.into(), TypeMismatch { expected, actual: ty }); + self.result.type_mismatches.get_or_insert_default().insert( + pat.into(), + TypeMismatch { expected: expected.store(), actual: ty.store() }, + ); } self.write_pat_ty(pat, ty); self.pat_ty_after_adjustment(pat) } fn pat_ty_after_adjustment(&self, pat: PatId) -> Ty<'db> { - *self - .result + self.result .pat_adjustments .get(&pat) .and_then(|it| it.last()) - .unwrap_or(&self.result.type_of_pat[pat]) + .unwrap_or_else(|| &self.result.type_of_pat[pat]) + .as_ref() } fn infer_ref_pat( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs index 301cbf462ce0..a323952494c0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs @@ -64,7 +64,7 @@ impl<'db> InferenceContext<'_, 'db> { } ValueNs::LocalBinding(pat) => { return match self.result.type_of_binding.get(pat) { - Some(ty) => Some(ValuePathResolution::NonGeneric(*ty)), + Some(ty) => Some(ValuePathResolution::NonGeneric(ty.as_ref())), None => { never!("uninferred pattern?"); None diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs index 3ef5e5870a58..5bcae21aa11b 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs @@ -65,7 +65,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { oprnd_expr, Box::new([Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Not)), - target: method.sig.inputs_and_output.inputs()[0], + target: method.sig.inputs_and_output.inputs()[0].store(), }]), ); } else { @@ -151,7 +151,8 @@ impl<'a, 'db> InferenceContext<'a, 'db> { { adjustments.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(AutoBorrowMutability::Not)), - target: Ty::new_imm_ref(autoderef.ctx().interner(), region, adjusted_ty), + target: Ty::new_imm_ref(autoderef.ctx().interner(), region, adjusted_ty) + .store(), }); } else { panic!("input to index is not a ref?"); @@ -159,7 +160,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { if unsize { adjustments.push(Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), - target: method.sig.inputs_and_output.inputs()[0], + target: method.sig.inputs_and_output.inputs()[0].store(), }); } autoderef.ctx().write_expr_adj(base_expr, adjustments.into_boxed_slice()); @@ -283,7 +284,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { None => return, }; debug!("convert_place_op_to_mutable: method={:?}", method); - self.result.method_resolutions.insert(expr, (method.def_id, method.args)); + self.result.method_resolutions.insert(expr, (method.def_id, method.args.store())); let TyKind::Ref(region, _, Mutability::Mut) = method.sig.inputs_and_output.inputs()[0].kind() @@ -308,9 +309,9 @@ impl<'a, 'db> InferenceContext<'a, 'db> { allow_two_phase_borrow: AllowTwoPhase::No, }; adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(mutbl)); - adjustment.target = Ty::new_ref(interner, region, source, mutbl.into()); + adjustment.target = Ty::new_ref(interner, region, source, mutbl.into()).store(); } - source = adjustment.target; + source = adjustment.target.as_ref(); } // If we have an autoref followed by unsizing at the end, fix the unsize target. @@ -320,7 +321,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), ref mut target }, ] = adjustments[..] { - *target = method.sig.inputs_and_output.inputs()[0]; + *target = method.sig.inputs_and_output.inputs()[0].store(); } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs index a5060416a16e..ac84797f37a9 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs @@ -9,7 +9,7 @@ use intern::sym; use rustc_hash::FxHashSet; use rustc_type_ir::{ TyVid, TypeFoldable, TypeVisitableExt, UpcastFrom, - inherent::{Const as _, GenericArg as _, IntoKind, SliceLike, Ty as _}, + inherent::{Const as _, GenericArg as _, IntoKind, Ty as _}, solve::Certainty, }; use smallvec::SmallVec; @@ -640,6 +640,7 @@ impl<'db> InferenceTable<'db> { let struct_data = id.fields(self.db); if let Some((last_field, _)) = struct_data.fields().iter().next_back() { let last_field_ty = self.db.field_types(id.into())[last_field] + .get() .instantiate(self.interner(), subst); if structs.contains(&ty) { // A struct recursively contains itself as a tail field somewhere. diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/inhabitedness.rs b/src/tools/rust-analyzer/crates/hir-ty/src/inhabitedness.rs index 075a7066db78..402e9ce96971 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/inhabitedness.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/inhabitedness.rs @@ -154,7 +154,7 @@ impl<'a, 'db> UninhabitedFrom<'a, 'db> { let field_vis = if is_enum { None } else { Some(self.db().field_visibilities(variant)) }; for (fid, _) in fields.iter() { - self.visit_field(field_vis.as_ref().map(|it| it[fid]), &field_tys[fid], subst)?; + self.visit_field(field_vis.as_ref().map(|it| it[fid]), &field_tys[fid].get(), subst)?; } CONTINUE_OPAQUELY_INHABITED } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index 1ed604865b00..b6ad3624ae28 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -14,10 +14,7 @@ use rustc_abi::{ TargetDataLayout, WrappingRange, }; use rustc_index::IndexVec; -use rustc_type_ir::{ - FloatTy, IntTy, UintTy, - inherent::{IntoKind, SliceLike}, -}; +use rustc_type_ir::{FloatTy, IntTy, UintTy, inherent::IntoKind}; use triomphe::Arc; use crate::{ @@ -25,9 +22,10 @@ use crate::{ consteval::try_const_usize, db::HirDatabase, next_solver::{ - DbInterner, GenericArgs, Ty, TyKind, TypingMode, + DbInterner, GenericArgs, StoredTy, Ty, TyKind, TypingMode, infer::{DbInternerInferExt, traits::ObligationCause}, }, + traits::StoredParamEnvAndCrate, }; pub(crate) use self::adt::layout_of_adt_cycle_result; @@ -144,22 +142,22 @@ fn layout_of_simd_ty<'db>( let Some(TyKind::Array(e_ty, e_len)) = fields .next() .filter(|_| fields.next().is_none()) - .map(|f| (*f.1).instantiate(DbInterner::new_no_crate(db), args).kind()) + .map(|f| (*f.1).get().instantiate(DbInterner::new_no_crate(db), args).kind()) else { return Err(LayoutError::InvalidSimdType); }; let e_len = try_const_usize(db, e_len).ok_or(LayoutError::HasErrorConst)? as u64; - let e_ly = db.layout_of_ty(e_ty, env)?; + let e_ly = db.layout_of_ty(e_ty.store(), env.store())?; let cx = LayoutCx::new(dl); Ok(Arc::new(cx.calc.simd_type(e_ly, e_len, repr_packed)?)) } -pub fn layout_of_ty_query<'db>( - db: &'db dyn HirDatabase, - ty: Ty<'db>, - trait_env: ParamEnvAndCrate<'db>, +pub fn layout_of_ty_query( + db: &dyn HirDatabase, + ty: StoredTy, + trait_env: StoredParamEnvAndCrate, ) -> Result, LayoutError> { let krate = trait_env.krate; let interner = DbInterner::new_with(db, krate); @@ -170,19 +168,29 @@ pub fn layout_of_ty_query<'db>( let cx = LayoutCx::new(dl); let infer_ctxt = interner.infer_ctxt().build(TypingMode::PostAnalysis); let cause = ObligationCause::dummy(); - let ty = infer_ctxt.at(&cause, trait_env.param_env).deeply_normalize(ty).unwrap_or(ty); + let ty = infer_ctxt + .at(&cause, trait_env.param_env()) + .deeply_normalize(ty.as_ref()) + .unwrap_or(ty.as_ref()); let result = match ty.kind() { TyKind::Adt(def, args) => { match def.inner().id { hir_def::AdtId::StructId(s) => { let repr = AttrFlags::repr(db, s.into()).unwrap_or_default(); if repr.simd() { - return layout_of_simd_ty(db, s, repr.packed(), &args, trait_env, &target); + return layout_of_simd_ty( + db, + s, + repr.packed(), + &args, + trait_env.as_ref(), + &target, + ); } } _ => {} } - return db.layout_of_adt(def.inner().id, args, trait_env); + return db.layout_of_adt(def.inner().id, args.store(), trait_env); } TyKind::Bool => Layout::scalar( dl, @@ -246,21 +254,23 @@ pub fn layout_of_ty_query<'db>( ), TyKind::Tuple(tys) => { let kind = - if tys.len() == 0 { StructKind::AlwaysSized } else { StructKind::MaybeUnsized }; + if tys.is_empty() { StructKind::AlwaysSized } else { StructKind::MaybeUnsized }; - let fields = - tys.iter().map(|k| db.layout_of_ty(k, trait_env)).collect::, _>>()?; + let fields = tys + .iter() + .map(|k| db.layout_of_ty(k.store(), trait_env.clone())) + .collect::, _>>()?; let fields = fields.iter().map(|it| &**it).collect::>(); let fields = fields.iter().collect::>(); cx.calc.univariant(&fields, &ReprOptions::default(), kind)? } TyKind::Array(element, count) => { let count = try_const_usize(db, count).ok_or(LayoutError::HasErrorConst)? as u64; - let element = db.layout_of_ty(element, trait_env)?; + let element = db.layout_of_ty(element.store(), trait_env)?; cx.calc.array_like::<_, _, ()>(&element, Some(count))? } TyKind::Slice(element) => { - let element = db.layout_of_ty(element, trait_env)?; + let element = db.layout_of_ty(element.store(), trait_env)?; cx.calc.array_like::<_, _, ()>(&element, None)? } TyKind::Str => { @@ -325,9 +335,11 @@ pub fn layout_of_ty_query<'db>( let fields = captures .iter() .map(|it| { - let ty = - it.ty.instantiate(interner, args.split_closure_args_untupled().parent_args); - db.layout_of_ty(ty, trait_env) + let ty = it + .ty + .get() + .instantiate(interner, args.split_closure_args_untupled().parent_args); + db.layout_of_ty(ty.store(), trait_env.clone()) }) .collect::, _>>()?; let fields = fields.iter().map(|it| &**it).collect::>(); @@ -357,11 +369,11 @@ pub fn layout_of_ty_query<'db>( Ok(Arc::new(result)) } -pub(crate) fn layout_of_ty_cycle_result<'db>( +pub(crate) fn layout_of_ty_cycle_result( _: &dyn HirDatabase, _: salsa::Id, - _: Ty<'db>, - _: ParamEnvAndCrate<'db>, + _: StoredTy, + _: StoredParamEnvAndCrate, ) -> Result, LayoutError> { Err(LayoutError::RecursiveTypeWithoutIndirection) } @@ -377,7 +389,7 @@ fn struct_tail_erasing_lifetimes<'a>(db: &'a dyn HirDatabase, pointee: Ty<'a>) - let mut it = data.fields().iter().rev(); match it.next() { Some((f, _)) => { - let last_field_ty = field_ty(db, struct_id.into(), f, &args); + let last_field_ty = field_ty(db, struct_id.into(), f, args); struct_tail_erasing_lifetimes(db, last_field_ty) } None => pointee, @@ -398,9 +410,9 @@ fn field_ty<'a>( db: &'a dyn HirDatabase, def: hir_def::VariantId, fd: LocalFieldId, - args: &GenericArgs<'a>, + args: GenericArgs<'a>, ) -> Ty<'a> { - db.field_types(def)[fd].instantiate(DbInterner::new_no_crate(db), args) + db.field_types(def)[fd].get().instantiate(DbInterner::new_no_crate(db), args) } fn scalar_unit(dl: &TargetDataLayout, value: Primitive) -> Scalar { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs index 1e2c3aa31b8d..d2495917187e 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs @@ -13,17 +13,17 @@ use smallvec::SmallVec; use triomphe::Arc; use crate::{ - ParamEnvAndCrate, db::HirDatabase, layout::{Layout, LayoutCx, LayoutError, field_ty}, - next_solver::GenericArgs, + next_solver::StoredGenericArgs, + traits::StoredParamEnvAndCrate, }; -pub fn layout_of_adt_query<'db>( - db: &'db dyn HirDatabase, +pub fn layout_of_adt_query( + db: &dyn HirDatabase, def: AdtId, - args: GenericArgs<'db>, - trait_env: ParamEnvAndCrate<'db>, + args: StoredGenericArgs, + trait_env: StoredParamEnvAndCrate, ) -> Result, LayoutError> { let krate = trait_env.krate; let Ok(target) = db.target_data_layout(krate) else { @@ -34,7 +34,9 @@ pub fn layout_of_adt_query<'db>( let handle_variant = |def: VariantId, var: &VariantFields| { var.fields() .iter() - .map(|(fd, _)| db.layout_of_ty(field_ty(db, def, fd, &args), trait_env)) + .map(|(fd, _)| { + db.layout_of_ty(field_ty(db, def, fd, args.as_ref()).store(), trait_env.clone()) + }) .collect::, _>>() }; let (variants, repr, is_special_no_niche) = match def { @@ -95,12 +97,12 @@ pub fn layout_of_adt_query<'db>( Ok(Arc::new(result)) } -pub(crate) fn layout_of_adt_cycle_result<'db>( - _: &'db dyn HirDatabase, +pub(crate) fn layout_of_adt_cycle_result( + _: &dyn HirDatabase, _: salsa::Id, _def: AdtId, - _args: GenericArgs<'db>, - _trait_env: ParamEnvAndCrate<'db>, + _args: StoredGenericArgs, + _trait_env: StoredParamEnvAndCrate, ) -> Result, LayoutError> { Err(LayoutError::RecursiveTypeWithoutIndirection) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests.rs index be6a76478a11..8c91be1d7811 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout/tests.rs @@ -98,7 +98,7 @@ fn eval_goal( Either::Left(it) => it.krate(&db), Either::Right(it) => it.krate(&db), }; - db.layout_of_ty(goal_ty, ParamEnvAndCrate { param_env, krate }) + db.layout_of_ty(goal_ty.store(), ParamEnvAndCrate { param_env, krate }.store()) }) } @@ -140,10 +140,10 @@ fn eval_expr( .unwrap() .0; let infer = InferenceResult::for_body(&db, function_id.into()); - let goal_ty = infer.type_of_binding[b]; + let goal_ty = infer.type_of_binding[b].clone(); let param_env = db.trait_environment(function_id.into()); let krate = function_id.krate(&db); - db.layout_of_ty(goal_ty, ParamEnvAndCrate { param_env, krate }) + db.layout_of_ty(goal_ty, ParamEnvAndCrate { param_env, krate }.store()) }) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs index 5ebe87c5d5d6..012fd8a10abd 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs @@ -61,11 +61,12 @@ use hir_def::{CallableDefId, TypeOrConstParamId, type_ref::Rawness}; use hir_expand::name::Name; use indexmap::{IndexMap, map::Entry}; use intern::{Symbol, sym}; +use macros::GenericTypeVisitable; use mir::{MirEvalError, VTableMap}; use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet}; use rustc_type_ir::{ BoundVarIndexKind, TypeSuperVisitable, TypeVisitableExt, UpcastFrom, - inherent::{IntoKind, SliceLike, Ty as _}, + inherent::{IntoKind, Ty as _}, }; use syntax::ast::{ConstArg, make}; use traits::FnTrait; @@ -104,7 +105,7 @@ pub use utils::{ /// A constant can have reference to other things. Memory map job is holding /// the necessary bits of memory of the const eval session to keep the constant /// meaningful. -#[derive(Debug, Default, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq, Eq, GenericTypeVisitable)] pub enum MemoryMap<'db> { #[default] Empty, @@ -112,7 +113,7 @@ pub enum MemoryMap<'db> { Complex(Box>), } -#[derive(Debug, Default, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq, Eq, GenericTypeVisitable)] pub struct ComplexMemoryMap<'db> { memory: IndexMap, FxBuildHasher>, vtable: VTableMap<'db>, @@ -134,7 +135,7 @@ impl ComplexMemoryMap<'_> { } impl<'db> MemoryMap<'db> { - pub fn vtable_ty(&self, id: usize) -> Result, MirEvalError<'db>> { + pub fn vtable_ty(&self, id: usize) -> Result, MirEvalError> { match self { MemoryMap::Empty | MemoryMap::Simple(_) => Err(MirEvalError::InvalidVTableId(id)), MemoryMap::Complex(cm) => cm.vtable.ty(id), @@ -150,8 +151,8 @@ impl<'db> MemoryMap<'db> { /// allocator function as `f` and it will return a mapping of old addresses to new addresses. fn transform_addresses( &self, - mut f: impl FnMut(&[u8], usize) -> Result>, - ) -> Result, MirEvalError<'db>> { + mut f: impl FnMut(&[u8], usize) -> Result, + ) -> Result, MirEvalError> { let mut transform = |(addr, val): (&usize, &[u8])| { let addr = *addr; let align = if addr == 0 { 64 } else { (addr - (addr & (addr - 1))).min(64) }; @@ -333,9 +334,9 @@ impl FnAbi { } #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] -pub enum ImplTraitId<'db> { - ReturnTypeImplTrait(hir_def::FunctionId, next_solver::ImplTraitIdx<'db>), - TypeAliasImplTrait(hir_def::TypeAliasId, next_solver::ImplTraitIdx<'db>), +pub enum ImplTraitId { + ReturnTypeImplTrait(hir_def::FunctionId, next_solver::ImplTraitIdx), + TypeAliasImplTrait(hir_def::TypeAliasId, next_solver::ImplTraitIdx), } /// 'Canonicalizes' the `t` by replacing any errors with new variables. Also diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs index 3f901ad69285..50f808affa99 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs @@ -15,8 +15,8 @@ use either::Either; use hir_def::{ AdtId, AssocItemId, CallableDefId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GeneralConstId, GenericDefId, GenericParamId, HasModule, ImplId, ItemContainerId, - LifetimeParamId, LocalFieldId, Lookup, StaticId, StructId, TypeAliasId, TypeOrConstParamId, - TypeParamId, UnionId, VariantId, + LifetimeParamId, LocalFieldId, Lookup, StaticId, StructId, TraitId, TypeAliasId, + TypeOrConstParamId, TypeParamId, UnionId, VariantId, builtin_type::BuiltinType, expr_store::{ExpressionStore, HygieneId, path::Path}, hir::generics::{ @@ -61,36 +61,38 @@ use crate::{ AliasTy, Binder, BoundExistentialPredicates, Clause, ClauseKind, Clauses, Const, DbInterner, EarlyBinder, EarlyParamRegion, ErrorGuaranteed, FxIndexMap, GenericArg, GenericArgs, ParamConst, ParamEnv, PolyFnSig, Predicate, Region, SolverDefId, - TraitPredicate, TraitRef, Ty, Tys, UnevaluatedConst, abi::Safety, util::BottomUpFolder, + StoredClauses, StoredEarlyBinder, StoredGenericArg, StoredGenericArgs, StoredPolyFnSig, + StoredTy, TraitPredicate, TraitRef, Ty, Tys, UnevaluatedConst, abi::Safety, + util::BottomUpFolder, }, }; pub(crate) struct PathDiagnosticCallbackData(pub(crate) TypeRefId); #[derive(PartialEq, Eq, Debug, Hash)] -pub struct ImplTraits<'db> { - pub(crate) impl_traits: Arena>, +pub struct ImplTraits { + pub(crate) impl_traits: Arena, } #[derive(PartialEq, Eq, Debug, Hash)] -pub struct ImplTrait<'db> { - pub(crate) predicates: Box<[Clause<'db>]>, +pub struct ImplTrait { + pub(crate) predicates: StoredClauses, } -pub type ImplTraitIdx<'db> = Idx>; +pub type ImplTraitIdx = Idx; #[derive(Debug, Default)] -struct ImplTraitLoweringState<'db> { +struct ImplTraitLoweringState { /// When turning `impl Trait` into opaque types, we have to collect the /// bounds at the same time to get the IDs correct (without becoming too /// complicated). mode: ImplTraitLoweringMode, // This is structured as a struct with fields and not as an enum because it helps with the borrow checker. - opaque_type_data: Arena>, + opaque_type_data: Arena, } -impl<'db> ImplTraitLoweringState<'db> { - fn new(mode: ImplTraitLoweringMode) -> ImplTraitLoweringState<'db> { +impl ImplTraitLoweringState { + fn new(mode: ImplTraitLoweringMode) -> ImplTraitLoweringState { Self { mode, opaque_type_data: Arena::new() } } } @@ -174,7 +176,7 @@ pub struct TyLoweringContext<'db, 'a> { def: GenericDefId, generics: OnceCell, in_binders: DebruijnIndex, - impl_trait_mode: ImplTraitLoweringState<'db>, + impl_trait_mode: ImplTraitLoweringState, /// Tracks types with explicit `?Sized` bounds. pub(crate) unsized_types: FxHashSet>, pub(crate) diagnostics: Vec, @@ -337,7 +339,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { } } Some(ValueNs::ConstId(c)) => { - let args = GenericArgs::new_from_iter(self.interner, []); + let args = GenericArgs::empty(self.interner); Some(Const::new( self.interner, rustc_type_ir::ConstKind::Unevaluated(UnevaluatedConst::new( @@ -476,7 +478,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { let idx = self .impl_trait_mode .opaque_type_data - .alloc(ImplTrait { predicates: Box::default() }); + .alloc(ImplTrait { predicates: Clauses::empty(interner).store() }); let impl_trait_id = origin.either( |f| ImplTraitId::ReturnTypeImplTrait(f, idx), @@ -989,7 +991,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { } } - fn lower_impl_trait(&mut self, def_id: SolverDefId, bounds: &[TypeBound]) -> ImplTrait<'db> { + fn lower_impl_trait(&mut self, def_id: SolverDefId, bounds: &[TypeBound]) -> ImplTrait { let interner = self.interner; cov_mark::hit!(lower_rpit); let args = GenericArgs::identity_for_item(interner, def_id); @@ -1010,7 +1012,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { let trait_ref = TraitRef::new_from_args( interner, trait_id.into(), - GenericArgs::new_from_iter(interner, [self_ty.into()]), + GenericArgs::new_from_slice(&[self_ty.into()]), ); Clause(Predicate::new( interner, @@ -1024,9 +1026,9 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { }); predicates.extend(sized_clause); } - predicates.into_boxed_slice() + predicates }); - ImplTrait { predicates } + ImplTrait { predicates: Clauses::new_from_slice(&predicates).store() } } pub(crate) fn lower_lifetime(&mut self, lifetime: LifetimeRefId) -> Region<'db> { @@ -1090,28 +1092,50 @@ pub(crate) fn impl_trait_query<'db>( db.impl_trait_with_diagnostics(impl_id).map(|it| it.0) } -pub(crate) fn impl_trait_with_diagnostics_query<'db>( +pub(crate) fn impl_trait_with_diagnostics<'db>( db: &'db dyn HirDatabase, impl_id: ImplId, ) -> Option<(EarlyBinder<'db, TraitRef<'db>>, Diagnostics)> { - let impl_data = db.impl_signature(impl_id); - let resolver = impl_id.resolver(db); - let mut ctx = TyLoweringContext::new( - db, - &resolver, - &impl_data.store, - impl_id.into(), - LifetimeElisionKind::AnonymousCreateParameter { report_in_path: true }, - ); - let self_ty = db.impl_self_ty(impl_id).skip_binder(); - let target_trait = impl_data.target_trait.as_ref()?; - let trait_ref = EarlyBinder::bind(ctx.lower_trait_ref(target_trait, self_ty)?); - Some((trait_ref, create_diagnostics(ctx.diagnostics))) + return impl_trait_with_diagnostics_query(db, impl_id).as_ref().map(|(binder, diags)| { + ( + binder.get_with(|(trait_id, args)| { + TraitRef::new_from_args( + DbInterner::new_no_crate(db), + (*trait_id).into(), + args.as_ref(), + ) + }), + diags.clone(), + ) + }); + + #[salsa::tracked(returns(ref))] + pub(crate) fn impl_trait_with_diagnostics_query<'db>( + db: &'db dyn HirDatabase, + impl_id: ImplId, + ) -> Option<(StoredEarlyBinder<(TraitId, StoredGenericArgs)>, Diagnostics)> { + let impl_data = db.impl_signature(impl_id); + let resolver = impl_id.resolver(db); + let mut ctx = TyLoweringContext::new( + db, + &resolver, + &impl_data.store, + impl_id.into(), + LifetimeElisionKind::AnonymousCreateParameter { report_in_path: true }, + ); + let self_ty = db.impl_self_ty(impl_id).skip_binder(); + let target_trait = impl_data.target_trait.as_ref()?; + let trait_ref = ctx.lower_trait_ref(target_trait, self_ty)?; + Some(( + StoredEarlyBinder::bind((trait_ref.def_id.0, trait_ref.args.store())), + create_diagnostics(ctx.diagnostics), + )) + } } -impl<'db> ImplTraitId<'db> { +impl ImplTraitId { #[inline] - pub fn predicates(self, db: &'db dyn HirDatabase) -> EarlyBinder<'db, &'db [Clause<'db>]> { + pub fn predicates<'db>(self, db: &'db dyn HirDatabase) -> EarlyBinder<'db, &'db [Clause<'db>]> { let (impl_traits, idx) = match self { ImplTraitId::ReturnTypeImplTrait(owner, idx) => { (ImplTraits::return_type_impl_traits(db, owner), idx) @@ -1123,8 +1147,7 @@ impl<'db> ImplTraitId<'db> { impl_traits .as_deref() .expect("owner should have opaque type") - .as_ref() - .map_bound(|it| &*it.impl_traits[idx].predicates) + .get_with(|it| it.impl_traits[idx].predicates.as_ref().as_slice()) } } @@ -1136,12 +1159,12 @@ impl InternedOpaqueTyId { } #[salsa::tracked] -impl<'db> ImplTraits<'db> { - #[salsa::tracked(returns(ref), unsafe(non_update_types))] +impl ImplTraits { + #[salsa::tracked(returns(ref))] pub(crate) fn return_type_impl_traits( - db: &'db dyn HirDatabase, + db: &dyn HirDatabase, def: hir_def::FunctionId, - ) -> Option>>> { + ) -> Option>> { // FIXME unify with fn_sig_for_fn instead of doing lowering twice, maybe let data = db.function_signature(def); let resolver = def.resolver(db); @@ -1162,15 +1185,15 @@ impl<'db> ImplTraits<'db> { None } else { return_type_impl_traits.impl_traits.shrink_to_fit(); - Some(Box::new(EarlyBinder::bind(return_type_impl_traits))) + Some(Box::new(StoredEarlyBinder::bind(return_type_impl_traits))) } } - #[salsa::tracked(returns(ref), unsafe(non_update_types))] + #[salsa::tracked(returns(ref))] pub(crate) fn type_alias_impl_traits( - db: &'db dyn HirDatabase, + db: &dyn HirDatabase, def: hir_def::TypeAliasId, - ) -> Option>>> { + ) -> Option>> { let data = db.type_alias_signature(def); let resolver = def.resolver(db); let mut ctx = TyLoweringContext::new( @@ -1190,7 +1213,7 @@ impl<'db> ImplTraits<'db> { None } else { type_alias_impl_traits.impl_traits.shrink_to_fit(); - Some(Box::new(EarlyBinder::bind(type_alias_impl_traits))) + Some(Box::new(StoredEarlyBinder::bind(type_alias_impl_traits))) } } } @@ -1246,17 +1269,20 @@ pub(crate) fn ty_query<'db>(db: &'db dyn HirDatabase, def: TyDefId) -> EarlyBind /// Build the declared type of a function. This should not need to look at the /// function body. -fn type_for_fn<'db>(db: &'db dyn HirDatabase, def: FunctionId) -> EarlyBinder<'db, Ty<'db>> { +fn type_for_fn(db: &dyn HirDatabase, def: FunctionId) -> StoredEarlyBinder { let interner = DbInterner::new_no_crate(db); - EarlyBinder::bind(Ty::new_fn_def( - interner, - CallableDefId::FunctionId(def).into(), - GenericArgs::identity_for_item(interner, def.into()), - )) + StoredEarlyBinder::bind( + Ty::new_fn_def( + interner, + CallableDefId::FunctionId(def).into(), + GenericArgs::identity_for_item(interner, def.into()), + ) + .store(), + ) } /// Build the declared type of a const. -fn type_for_const<'db>(db: &'db dyn HirDatabase, def: ConstId) -> EarlyBinder<'db, Ty<'db>> { +fn type_for_const(db: &dyn HirDatabase, def: ConstId) -> StoredEarlyBinder { let resolver = def.resolver(db); let data = db.const_signature(def); let parent = def.loc(db).container; @@ -1268,11 +1294,11 @@ fn type_for_const<'db>(db: &'db dyn HirDatabase, def: ConstId) -> EarlyBinder<'d LifetimeElisionKind::AnonymousReportError, ); ctx.set_lifetime_elision(LifetimeElisionKind::for_const(ctx.interner, parent)); - EarlyBinder::bind(ctx.lower_ty(data.type_ref)) + StoredEarlyBinder::bind(ctx.lower_ty(data.type_ref).store()) } /// Build the declared type of a static. -fn type_for_static<'db>(db: &'db dyn HirDatabase, def: StaticId) -> EarlyBinder<'db, Ty<'db>> { +fn type_for_static(db: &dyn HirDatabase, def: StaticId) -> StoredEarlyBinder { let resolver = def.resolver(db); let data = db.static_signature(def); let mut ctx = TyLoweringContext::new( @@ -1283,100 +1309,129 @@ fn type_for_static<'db>(db: &'db dyn HirDatabase, def: StaticId) -> EarlyBinder< LifetimeElisionKind::AnonymousReportError, ); ctx.set_lifetime_elision(LifetimeElisionKind::Elided(Region::new_static(ctx.interner))); - EarlyBinder::bind(ctx.lower_ty(data.type_ref)) + StoredEarlyBinder::bind(ctx.lower_ty(data.type_ref).store()) } /// Build the type of a tuple struct constructor. -fn type_for_struct_constructor<'db>( - db: &'db dyn HirDatabase, +fn type_for_struct_constructor( + db: &dyn HirDatabase, def: StructId, -) -> Option>> { +) -> Option> { let struct_data = def.fields(db); match struct_data.shape { FieldsShape::Record => None, FieldsShape::Unit => Some(type_for_adt(db, def.into())), FieldsShape::Tuple => { let interner = DbInterner::new_no_crate(db); - Some(EarlyBinder::bind(Ty::new_fn_def( - interner, - CallableDefId::StructId(def).into(), - GenericArgs::identity_for_item(interner, def.into()), - ))) + Some(StoredEarlyBinder::bind( + Ty::new_fn_def( + interner, + CallableDefId::StructId(def).into(), + GenericArgs::identity_for_item(interner, def.into()), + ) + .store(), + )) } } } /// Build the type of a tuple enum variant constructor. -fn type_for_enum_variant_constructor<'db>( - db: &'db dyn HirDatabase, +fn type_for_enum_variant_constructor( + db: &dyn HirDatabase, def: EnumVariantId, -) -> Option>> { +) -> Option> { let struct_data = def.fields(db); match struct_data.shape { FieldsShape::Record => None, FieldsShape::Unit => Some(type_for_adt(db, def.loc(db).parent.into())), FieldsShape::Tuple => { let interner = DbInterner::new_no_crate(db); - Some(EarlyBinder::bind(Ty::new_fn_def( - interner, - CallableDefId::EnumVariantId(def).into(), - GenericArgs::identity_for_item(interner, def.loc(db).parent.into()), - ))) + Some(StoredEarlyBinder::bind( + Ty::new_fn_def( + interner, + CallableDefId::EnumVariantId(def).into(), + GenericArgs::identity_for_item(interner, def.loc(db).parent.into()), + ) + .store(), + )) } } } -pub(crate) fn value_ty_query<'db>( +pub(crate) fn value_ty<'db>( db: &'db dyn HirDatabase, def: ValueTyDefId, ) -> Option>> { - match def { - ValueTyDefId::FunctionId(it) => Some(type_for_fn(db, it)), - ValueTyDefId::StructId(it) => type_for_struct_constructor(db, it), - ValueTyDefId::UnionId(it) => Some(type_for_adt(db, it.into())), - ValueTyDefId::EnumVariantId(it) => type_for_enum_variant_constructor(db, it), - ValueTyDefId::ConstId(it) => Some(type_for_const(db, it)), - ValueTyDefId::StaticId(it) => Some(type_for_static(db, it)), + return value_ty_query(db, def).as_ref().map(|it| it.get()); + + #[salsa::tracked(returns(ref))] + pub(crate) fn value_ty_query<'db>( + db: &'db dyn HirDatabase, + def: ValueTyDefId, + ) -> Option> { + match def { + ValueTyDefId::FunctionId(it) => Some(type_for_fn(db, it)), + ValueTyDefId::StructId(it) => type_for_struct_constructor(db, it), + ValueTyDefId::UnionId(it) => Some(type_for_adt(db, it.into())), + ValueTyDefId::EnumVariantId(it) => type_for_enum_variant_constructor(db, it), + ValueTyDefId::ConstId(it) => Some(type_for_const(db, it)), + ValueTyDefId::StaticId(it) => Some(type_for_static(db, it)), + } } } -pub(crate) fn type_for_type_alias_with_diagnostics_query<'db>( +pub(crate) fn type_for_type_alias_with_diagnostics<'db>( db: &'db dyn HirDatabase, t: TypeAliasId, ) -> (EarlyBinder<'db, Ty<'db>>, Diagnostics) { - let type_alias_data = db.type_alias_signature(t); - let mut diags = None; - let resolver = t.resolver(db); - let interner = DbInterner::new_no_crate(db); - let inner = if type_alias_data.flags.contains(TypeAliasFlags::IS_EXTERN) { - EarlyBinder::bind(Ty::new_foreign(interner, t.into())) - } else { - let mut ctx = TyLoweringContext::new( - db, - &resolver, - &type_alias_data.store, - t.into(), - LifetimeElisionKind::AnonymousReportError, - ) - .with_impl_trait_mode(ImplTraitLoweringMode::Opaque); - let res = EarlyBinder::bind( - type_alias_data - .ty - .map(|type_ref| ctx.lower_ty(type_ref)) - .unwrap_or_else(|| Ty::new_error(interner, ErrorGuaranteed)), - ); - diags = create_diagnostics(ctx.diagnostics); - res - }; - (inner, diags) -} + let (ty, diags) = type_for_type_alias_with_diagnostics_query(db, t); + return (ty.get(), diags.clone()); -pub(crate) fn type_for_type_alias_with_diagnostics_cycle_result<'db>( - db: &'db dyn HirDatabase, - _: salsa::Id, - _adt: TypeAliasId, -) -> (EarlyBinder<'db, Ty<'db>>, Diagnostics) { - (EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None) + #[salsa::tracked(returns(ref), cycle_result = type_for_type_alias_with_diagnostics_cycle_result)] + pub(crate) fn type_for_type_alias_with_diagnostics_query<'db>( + db: &'db dyn HirDatabase, + t: TypeAliasId, + ) -> (StoredEarlyBinder, Diagnostics) { + let type_alias_data = db.type_alias_signature(t); + let mut diags = None; + let resolver = t.resolver(db); + let interner = DbInterner::new_no_crate(db); + let inner = if type_alias_data.flags.contains(TypeAliasFlags::IS_EXTERN) { + StoredEarlyBinder::bind(Ty::new_foreign(interner, t.into()).store()) + } else { + let mut ctx = TyLoweringContext::new( + db, + &resolver, + &type_alias_data.store, + t.into(), + LifetimeElisionKind::AnonymousReportError, + ) + .with_impl_trait_mode(ImplTraitLoweringMode::Opaque); + let res = StoredEarlyBinder::bind( + type_alias_data + .ty + .map(|type_ref| ctx.lower_ty(type_ref)) + .unwrap_or_else(|| Ty::new_error(interner, ErrorGuaranteed)) + .store(), + ); + diags = create_diagnostics(ctx.diagnostics); + res + }; + (inner, diags) + } + + pub(crate) fn type_for_type_alias_with_diagnostics_cycle_result( + db: &dyn HirDatabase, + _: salsa::Id, + _adt: TypeAliasId, + ) -> (StoredEarlyBinder, Diagnostics) { + ( + StoredEarlyBinder::bind( + Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed).store(), + ), + None, + ) + } } pub(crate) fn impl_self_ty_query<'db>( @@ -1386,31 +1441,45 @@ pub(crate) fn impl_self_ty_query<'db>( db.impl_self_ty_with_diagnostics(impl_id).0 } -pub(crate) fn impl_self_ty_with_diagnostics_query<'db>( +pub(crate) fn impl_self_ty_with_diagnostics<'db>( db: &'db dyn HirDatabase, impl_id: ImplId, ) -> (EarlyBinder<'db, Ty<'db>>, Diagnostics) { - let resolver = impl_id.resolver(db); + let (ty, diags) = impl_self_ty_with_diagnostics_query(db, impl_id); + return (ty.get(), diags.clone()); - let impl_data = db.impl_signature(impl_id); - let mut ctx = TyLoweringContext::new( - db, - &resolver, - &impl_data.store, - impl_id.into(), - LifetimeElisionKind::AnonymousCreateParameter { report_in_path: true }, - ); - let ty = ctx.lower_ty(impl_data.self_ty); - assert!(!ty.has_escaping_bound_vars()); - (EarlyBinder::bind(ty), create_diagnostics(ctx.diagnostics)) -} + #[salsa::tracked(returns(ref), cycle_result = impl_self_ty_with_diagnostics_cycle_result)] + pub(crate) fn impl_self_ty_with_diagnostics_query<'db>( + db: &'db dyn HirDatabase, + impl_id: ImplId, + ) -> (StoredEarlyBinder, Diagnostics) { + let resolver = impl_id.resolver(db); -pub(crate) fn impl_self_ty_with_diagnostics_cycle_result( - db: &dyn HirDatabase, - _: salsa::Id, - _impl_id: ImplId, -) -> (EarlyBinder<'_, Ty<'_>>, Diagnostics) { - (EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None) + let impl_data = db.impl_signature(impl_id); + let mut ctx = TyLoweringContext::new( + db, + &resolver, + &impl_data.store, + impl_id.into(), + LifetimeElisionKind::AnonymousCreateParameter { report_in_path: true }, + ); + let ty = ctx.lower_ty(impl_data.self_ty); + assert!(!ty.has_escaping_bound_vars()); + (StoredEarlyBinder::bind(ty.store()), create_diagnostics(ctx.diagnostics)) + } + + pub(crate) fn impl_self_ty_with_diagnostics_cycle_result( + db: &dyn HirDatabase, + _: salsa::Id, + _impl_id: ImplId, + ) -> (StoredEarlyBinder, Diagnostics) { + ( + StoredEarlyBinder::bind( + Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed).store(), + ), + None, + ) + } } pub(crate) fn const_param_ty_query<'db>(db: &'db dyn HirDatabase, def: ConstParamId) -> Ty<'db> { @@ -1418,57 +1487,69 @@ pub(crate) fn const_param_ty_query<'db>(db: &'db dyn HirDatabase, def: ConstPara } // returns None if def is a type arg -pub(crate) fn const_param_ty_with_diagnostics_query<'db>( +pub(crate) fn const_param_ty_with_diagnostics<'db>( db: &'db dyn HirDatabase, def: ConstParamId, ) -> (Ty<'db>, Diagnostics) { - let (parent_data, store) = db.generic_params_and_store(def.parent()); - let data = &parent_data[def.local_id()]; - let resolver = def.parent().resolver(db); - let interner = DbInterner::new_no_crate(db); - let mut ctx = TyLoweringContext::new( - db, - &resolver, - &store, - def.parent(), - LifetimeElisionKind::AnonymousReportError, - ); - let ty = match data { - TypeOrConstParamData::TypeParamData(_) => { - never!(); - Ty::new_error(interner, ErrorGuaranteed) - } - TypeOrConstParamData::ConstParamData(d) => ctx.lower_ty(d.ty), - }; - (ty, create_diagnostics(ctx.diagnostics)) + let (ty, diags) = const_param_ty_with_diagnostics_query(db, (), def); + return (ty.as_ref(), diags.clone()); + + // FIXME: Make this query non-interned. + #[salsa::tracked(returns(ref), cycle_result = const_param_ty_with_diagnostics_cycle_result)] + pub(crate) fn const_param_ty_with_diagnostics_query<'db>( + db: &'db dyn HirDatabase, + _: (), + def: ConstParamId, + ) -> (StoredTy, Diagnostics) { + let (parent_data, store) = db.generic_params_and_store(def.parent()); + let data = &parent_data[def.local_id()]; + let resolver = def.parent().resolver(db); + let interner = DbInterner::new_no_crate(db); + let mut ctx = TyLoweringContext::new( + db, + &resolver, + &store, + def.parent(), + LifetimeElisionKind::AnonymousReportError, + ); + let ty = match data { + TypeOrConstParamData::TypeParamData(_) => { + never!(); + Ty::new_error(interner, ErrorGuaranteed) + } + TypeOrConstParamData::ConstParamData(d) => ctx.lower_ty(d.ty), + }; + (ty.store(), create_diagnostics(ctx.diagnostics)) + } + + pub(crate) fn const_param_ty_with_diagnostics_cycle_result( + db: &dyn HirDatabase, + _: salsa::Id, + _: (), + _def: ConstParamId, + ) -> (StoredTy, Diagnostics) { + let interner = DbInterner::new_no_crate(db); + (Ty::new_error(interner, ErrorGuaranteed).store(), None) + } } -pub(crate) fn const_param_ty_with_diagnostics_cycle_result<'db>( - db: &'db dyn HirDatabase, - _: salsa::Id, - _: crate::db::HirDatabaseData, - _def: ConstParamId, -) -> (Ty<'db>, Diagnostics) { - let interner = DbInterner::new_no_crate(db); - (Ty::new_error(interner, ErrorGuaranteed), None) -} - -pub(crate) fn field_types_query<'db>( - db: &'db dyn HirDatabase, +pub(crate) fn field_types_query( + db: &dyn HirDatabase, variant_id: VariantId, -) -> Arc>>> { - db.field_types_with_diagnostics(variant_id).0 +) -> &ArenaMap> { + &db.field_types_with_diagnostics(variant_id).0 } /// Build the type of all specific fields of a struct or enum variant. +#[salsa::tracked(returns(ref))] pub(crate) fn field_types_with_diagnostics_query<'db>( db: &'db dyn HirDatabase, variant_id: VariantId, -) -> (Arc>>>, Diagnostics) { +) -> (ArenaMap>, Diagnostics) { let var_data = variant_id.fields(db); let fields = var_data.fields(); if fields.is_empty() { - return (Arc::new(ArenaMap::default()), None); + return (ArenaMap::default(), None); } let (resolver, def): (_, GenericDefId) = match variant_id { @@ -1485,9 +1566,9 @@ pub(crate) fn field_types_with_diagnostics_query<'db>( LifetimeElisionKind::AnonymousReportError, ); for (field_id, field_data) in var_data.fields().iter() { - res.insert(field_id, EarlyBinder::bind(ctx.lower_ty(field_data.type_ref))); + res.insert(field_id, StoredEarlyBinder::bind(ctx.lower_ty(field_data.type_ref).store())); } - (Arc::new(res), create_diagnostics(ctx.diagnostics)) + (res, create_diagnostics(ctx.diagnostics)) } /// This query exists only to be used when resolving short-hand associated types @@ -1499,13 +1580,13 @@ pub(crate) fn field_types_with_diagnostics_query<'db>( /// following bounds are disallowed: `T: Foo, U: Foo`, but /// these are fine: `T: Foo, U: Foo<()>`. #[tracing::instrument(skip(db), ret)] -#[salsa::tracked(returns(ref), unsafe(non_update_types), cycle_result = generic_predicates_for_param_cycle_result)] +#[salsa::tracked(returns(ref), cycle_result = generic_predicates_for_param_cycle_result)] pub(crate) fn generic_predicates_for_param<'db>( db: &'db dyn HirDatabase, def: GenericDefId, param_id: TypeOrConstParamId, assoc_name: Option, -) -> EarlyBinder<'db, Box<[Clause<'db>]>> { +) -> StoredEarlyBinder { let generics = generics(db, def); let interner = DbInterner::new_no_crate(db); let resolver = def.resolver(db); @@ -1607,17 +1688,17 @@ pub(crate) fn generic_predicates_for_param<'db>( predicates.extend(implicitly_sized_predicates); }; } - EarlyBinder::bind(predicates.into_boxed_slice()) + StoredEarlyBinder::bind(Clauses::new_from_slice(&predicates).store()) } -pub(crate) fn generic_predicates_for_param_cycle_result<'db>( - _db: &'db dyn HirDatabase, +pub(crate) fn generic_predicates_for_param_cycle_result( + db: &dyn HirDatabase, _: salsa::Id, _def: GenericDefId, _param_id: TypeOrConstParamId, _assoc_name: Option, -) -> EarlyBinder<'db, Box<[Clause<'db>]>> { - EarlyBinder::bind(Box::new([])) +) -> StoredEarlyBinder { + StoredEarlyBinder::bind(Clauses::empty(DbInterner::new_no_crate(db)).store()) } #[inline] @@ -1625,84 +1706,95 @@ pub(crate) fn type_alias_bounds<'db>( db: &'db dyn HirDatabase, type_alias: TypeAliasId, ) -> EarlyBinder<'db, &'db [Clause<'db>]> { - type_alias_bounds_with_diagnostics(db, type_alias).0.as_ref().map_bound(|it| &**it) + type_alias_bounds_with_diagnostics(db, type_alias).0.map_bound(|it| it.as_slice()) } -#[salsa::tracked(returns(ref), unsafe(non_update_types))] -pub fn type_alias_bounds_with_diagnostics<'db>( +pub(crate) fn type_alias_bounds_with_diagnostics<'db>( db: &'db dyn HirDatabase, type_alias: TypeAliasId, -) -> (EarlyBinder<'db, Box<[Clause<'db>]>>, Diagnostics) { - let type_alias_data = db.type_alias_signature(type_alias); - let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db); - let mut ctx = TyLoweringContext::new( - db, - &resolver, - &type_alias_data.store, - type_alias.into(), - LifetimeElisionKind::AnonymousReportError, - ); - let interner = ctx.interner; - let def_id = type_alias.into(); +) -> (EarlyBinder<'db, Clauses<'db>>, Diagnostics) { + let (bounds, diags) = type_alias_bounds_with_diagnostics_query(db, type_alias); + return (bounds.get(), diags.clone()); - let item_args = GenericArgs::identity_for_item(interner, def_id); - let interner_ty = Ty::new_projection_from_args(interner, def_id, item_args); + #[salsa::tracked(returns(ref))] + pub fn type_alias_bounds_with_diagnostics_query<'db>( + db: &'db dyn HirDatabase, + type_alias: TypeAliasId, + ) -> (StoredEarlyBinder, Diagnostics) { + let type_alias_data = db.type_alias_signature(type_alias); + let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db); + let mut ctx = TyLoweringContext::new( + db, + &resolver, + &type_alias_data.store, + type_alias.into(), + LifetimeElisionKind::AnonymousReportError, + ); + let interner = ctx.interner; + let def_id = type_alias.into(); - let mut bounds = Vec::new(); - for bound in &type_alias_data.bounds { - ctx.lower_type_bound(bound, interner_ty, false).for_each(|pred| { - bounds.push(pred); - }); + let item_args = GenericArgs::identity_for_item(interner, def_id); + let interner_ty = Ty::new_projection_from_args(interner, def_id, item_args); + + let mut bounds = Vec::new(); + for bound in &type_alias_data.bounds { + ctx.lower_type_bound(bound, interner_ty, false).for_each(|pred| { + bounds.push(pred); + }); + } + + if !ctx.unsized_types.contains(&interner_ty) { + let sized_trait = ctx.lang_items.Sized; + if let Some(sized_trait) = sized_trait { + let trait_ref = TraitRef::new_from_args( + interner, + sized_trait.into(), + GenericArgs::new_from_slice(&[interner_ty.into()]), + ); + bounds.push(trait_ref.upcast(interner)); + }; + } + + ( + StoredEarlyBinder::bind(Clauses::new_from_slice(&bounds).store()), + create_diagnostics(ctx.diagnostics), + ) } - - if !ctx.unsized_types.contains(&interner_ty) { - let sized_trait = ctx.lang_items.Sized; - if let Some(sized_trait) = sized_trait { - let trait_ref = TraitRef::new_from_args( - interner, - sized_trait.into(), - GenericArgs::new_from_iter(interner, [interner_ty.into()]), - ); - bounds.push(trait_ref.upcast(interner)); - }; - } - - (EarlyBinder::bind(bounds.into_boxed_slice()), create_diagnostics(ctx.diagnostics)) } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct GenericPredicates<'db> { +pub struct GenericPredicates { // The order is the following: first, if `parent_is_trait == true`, comes the implicit trait predicate for the // parent. Then come the explicit predicates for the parent, then the explicit trait predicate for the child, // then the implicit trait predicate for the child, if `is_trait` is `true`. - predicates: EarlyBinder<'db, Box<[Clause<'db>]>>, + predicates: StoredEarlyBinder, own_predicates_start: u32, is_trait: bool, parent_is_trait: bool, } #[salsa::tracked] -impl<'db> GenericPredicates<'db> { +impl<'db> GenericPredicates { /// Resolve the where clause(s) of an item with generics. /// /// Diagnostics are computed only for this item's predicates, not for parents. - #[salsa::tracked(returns(ref), unsafe(non_update_types))] + #[salsa::tracked(returns(ref))] pub fn query_with_diagnostics( db: &'db dyn HirDatabase, def: GenericDefId, - ) -> (GenericPredicates<'db>, Diagnostics) { + ) -> (GenericPredicates, Diagnostics) { generic_predicates_filtered_by(db, def, PredicateFilter::All, |_| true) } } -impl<'db> GenericPredicates<'db> { +impl GenericPredicates { #[inline] - pub fn query(db: &'db dyn HirDatabase, def: GenericDefId) -> &'db GenericPredicates<'db> { + pub fn query(db: &dyn HirDatabase, def: GenericDefId) -> &GenericPredicates { &Self::query_with_diagnostics(db, def).0 } #[inline] - pub fn query_all( + pub fn query_all<'db>( db: &'db dyn HirDatabase, def: GenericDefId, ) -> EarlyBinder<'db, &'db [Clause<'db>]> { @@ -1710,7 +1802,7 @@ impl<'db> GenericPredicates<'db> { } #[inline] - pub fn query_own( + pub fn query_own<'db>( db: &'db dyn HirDatabase, def: GenericDefId, ) -> EarlyBinder<'db, &'db [Clause<'db>]> { @@ -1718,7 +1810,7 @@ impl<'db> GenericPredicates<'db> { } #[inline] - pub fn query_explicit( + pub fn query_explicit<'db>( db: &'db dyn HirDatabase, def: GenericDefId, ) -> EarlyBinder<'db, &'db [Clause<'db>]> { @@ -1726,20 +1818,20 @@ impl<'db> GenericPredicates<'db> { } #[inline] - pub fn all_predicates(&self) -> EarlyBinder<'db, &[Clause<'db>]> { - self.predicates.as_ref().map_bound(|it| &**it) + pub fn all_predicates(&self) -> EarlyBinder<'_, &[Clause<'_>]> { + self.predicates.get().map_bound(|it| it.as_slice()) } #[inline] - pub fn own_predicates(&self) -> EarlyBinder<'db, &[Clause<'db>]> { - self.predicates.as_ref().map_bound(|it| &it[self.own_predicates_start as usize..]) + pub fn own_predicates(&self) -> EarlyBinder<'_, &[Clause<'_>]> { + self.predicates.get().map_bound(|it| &it.as_slice()[self.own_predicates_start as usize..]) } /// Returns the predicates, minus the implicit `Self: Trait` predicate for a trait. #[inline] - pub fn explicit_predicates(&self) -> EarlyBinder<'db, &[Clause<'db>]> { - self.predicates.as_ref().map_bound(|it| { - &it[usize::from(self.parent_is_trait)..it.len() - usize::from(self.is_trait)] + pub fn explicit_predicates(&self) -> EarlyBinder<'_, &[Clause<'_>]> { + self.predicates.get().map_bound(|it| { + &it.as_slice()[usize::from(self.parent_is_trait)..it.len() - usize::from(self.is_trait)] }) } } @@ -1754,18 +1846,24 @@ pub(crate) fn trait_environment_for_body_query( db.trait_environment(def) } -pub(crate) fn trait_environment_query<'db>( - db: &'db dyn HirDatabase, - def: GenericDefId, -) -> ParamEnv<'db> { - let module = def.module(db); - let interner = DbInterner::new_with(db, module.krate(db)); - let predicates = GenericPredicates::query_all(db, def); - let clauses = rustc_type_ir::elaborate::elaborate(interner, predicates.iter_identity_copied()); - let clauses = Clauses::new_from_iter(interner, clauses); +pub(crate) fn trait_environment<'db>(db: &'db dyn HirDatabase, def: GenericDefId) -> ParamEnv<'db> { + return ParamEnv { clauses: trait_environment_query(db, def).as_ref() }; - // FIXME: We should normalize projections here, like rustc does. - ParamEnv { clauses } + #[salsa::tracked(returns(ref))] + pub(crate) fn trait_environment_query<'db>( + db: &'db dyn HirDatabase, + def: GenericDefId, + ) -> StoredClauses { + let module = def.module(db); + let interner = DbInterner::new_with(db, module.krate(db)); + let predicates = GenericPredicates::query_all(db, def); + let clauses = + rustc_type_ir::elaborate::elaborate(interner, predicates.iter_identity_copied()); + let clauses = Clauses::new_from_iter(interner, clauses); + + // FIXME: We should normalize projections here, like rustc does. + clauses.store() + } } #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -1777,12 +1875,12 @@ pub(crate) enum PredicateFilter { /// Resolve the where clause(s) of an item with generics, /// with a given filter #[tracing::instrument(skip(db, filter), ret)] -pub(crate) fn generic_predicates_filtered_by<'db, F>( - db: &'db dyn HirDatabase, +pub(crate) fn generic_predicates_filtered_by( + db: &dyn HirDatabase, def: GenericDefId, predicate_filter: PredicateFilter, filter: F, -) -> (GenericPredicates<'db>, Diagnostics) +) -> (GenericPredicates, Diagnostics) where F: Fn(GenericDefId) -> bool, { @@ -1856,7 +1954,7 @@ where let trait_ref = TraitRef::new_from_args( interner, sized_trait.into(), - GenericArgs::new_from_iter(interner, [param_ty.into()]), + GenericArgs::new_from_slice(&[param_ty.into()]), ); let clause = Clause(Predicate::new( interner, @@ -1899,7 +1997,7 @@ where own_predicates_start, is_trait, parent_is_trait, - predicates: EarlyBinder::bind(predicates.into_boxed_slice()), + predicates: StoredEarlyBinder::bind(Clauses::new_from_slice(&predicates).store()), }; return (predicates, diagnostics); @@ -1988,7 +2086,7 @@ fn implicitly_sized_clauses<'a, 'subst, 'db>( let trait_ref = TraitRef::new_from_args( interner, sized_trait.into(), - GenericArgs::new_from_iter(interner, [self_ty.into()]), + GenericArgs::new_from_slice(&[self_ty.into()]), ); Clause(Predicate::new( interner, @@ -2004,19 +2102,16 @@ fn implicitly_sized_clauses<'a, 'subst, 'db>( } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct GenericDefaults<'db>(Option>>]>>); +pub struct GenericDefaults(Option>]>>); -impl<'db> GenericDefaults<'db> { +impl GenericDefaults { #[inline] - pub fn get(&self, idx: usize) -> Option>> { - self.0.as_ref()?[idx] + pub fn get<'db>(&self, idx: usize) -> Option>> { + Some(self.0.as_ref()?[idx].as_ref()?.get_with(|it| it.as_ref())) } } -pub(crate) fn generic_defaults_query( - db: &dyn HirDatabase, - def: GenericDefId, -) -> GenericDefaults<'_> { +pub(crate) fn generic_defaults_query(db: &dyn HirDatabase, def: GenericDefId) -> GenericDefaults { db.generic_defaults_with_diagnostics(def).0 } @@ -2026,7 +2121,7 @@ pub(crate) fn generic_defaults_query( pub(crate) fn generic_defaults_with_diagnostics_query( db: &dyn HirDatabase, def: GenericDefId, -) -> (GenericDefaults<'_>, Diagnostics) { +) -> (GenericDefaults, Diagnostics) { let generic_params = generics(db, def); if generic_params.is_empty() { return (GenericDefaults(None), None); @@ -2072,20 +2167,23 @@ pub(crate) fn generic_defaults_with_diagnostics_query( ctx: &mut TyLoweringContext<'db, '_>, idx: usize, p: GenericParamDataRef<'_>, - ) -> (Option>>, bool) { + ) -> (Option>, bool) { ctx.lowering_param_default(idx as u32); match p { GenericParamDataRef::TypeParamData(p) => { let ty = p.default.map(|ty| ctx.lower_ty(ty)); - (ty.map(|ty| EarlyBinder::bind(ty.into())), p.default.is_some()) + ( + ty.map(|ty| StoredEarlyBinder::bind(GenericArg::from(ty).store())), + p.default.is_some(), + ) } GenericParamDataRef::ConstParamData(p) => { let val = p.default.map(|c| { let param_ty = ctx.lower_ty(p.ty); let c = ctx.lower_const(c, param_ty); - c.into() + GenericArg::from(c).store() }); - (val.map(EarlyBinder::bind), p.default.is_some()) + (val.map(StoredEarlyBinder::bind), p.default.is_some()) } GenericParamDataRef::LifetimeParamData(_) => (None, false), } @@ -2096,26 +2194,31 @@ pub(crate) fn generic_defaults_with_diagnostics_cycle_result( _db: &dyn HirDatabase, _: salsa::Id, _def: GenericDefId, -) -> (GenericDefaults<'_>, Diagnostics) { +) -> (GenericDefaults, Diagnostics) { (GenericDefaults(None), None) } /// Build the signature of a callable item (function, struct or enum variant). -pub(crate) fn callable_item_signature_query<'db>( +pub(crate) fn callable_item_signature<'db>( db: &'db dyn HirDatabase, def: CallableDefId, ) -> EarlyBinder<'db, PolyFnSig<'db>> { - match def { - CallableDefId::FunctionId(f) => fn_sig_for_fn(db, f), - CallableDefId::StructId(s) => fn_sig_for_struct_constructor(db, s), - CallableDefId::EnumVariantId(e) => fn_sig_for_enum_variant_constructor(db, e), + return callable_item_signature_query(db, def).get_with(|sig| sig.get()); + + #[salsa::tracked(returns(ref))] + pub(crate) fn callable_item_signature_query<'db>( + db: &'db dyn HirDatabase, + def: CallableDefId, + ) -> StoredEarlyBinder { + match def { + CallableDefId::FunctionId(f) => fn_sig_for_fn(db, f), + CallableDefId::StructId(s) => fn_sig_for_struct_constructor(db, s), + CallableDefId::EnumVariantId(e) => fn_sig_for_enum_variant_constructor(db, e), + } } } -fn fn_sig_for_fn<'db>( - db: &'db dyn HirDatabase, - def: FunctionId, -) -> EarlyBinder<'db, PolyFnSig<'db>> { +fn fn_sig_for_fn(db: &dyn HirDatabase, def: FunctionId) -> StoredEarlyBinder { let data = db.function_signature(def); let resolver = def.resolver(db); let interner = DbInterner::new_no_crate(db); @@ -2145,56 +2248,56 @@ fn fn_sig_for_fn<'db>( let inputs_and_output = Tys::new_from_iter(interner, params.chain(Some(ret))); // If/when we track late bound vars, we need to switch this to not be `dummy` - EarlyBinder::bind(rustc_type_ir::Binder::dummy(FnSig { + StoredEarlyBinder::bind(StoredPolyFnSig::new(Binder::dummy(FnSig { abi: data.abi.as_ref().map_or(FnAbi::Rust, FnAbi::from_symbol), c_variadic: data.is_varargs(), safety: if data.is_unsafe() { Safety::Unsafe } else { Safety::Safe }, inputs_and_output, - })) + }))) } -fn type_for_adt<'db>(db: &'db dyn HirDatabase, adt: AdtId) -> EarlyBinder<'db, Ty<'db>> { +fn type_for_adt(db: &dyn HirDatabase, adt: AdtId) -> StoredEarlyBinder { let interner = DbInterner::new_no_crate(db); let args = GenericArgs::identity_for_item(interner, adt.into()); let ty = Ty::new_adt(interner, adt, args); - EarlyBinder::bind(ty) + StoredEarlyBinder::bind(ty.store()) } -fn fn_sig_for_struct_constructor<'db>( - db: &'db dyn HirDatabase, +fn fn_sig_for_struct_constructor( + db: &dyn HirDatabase, def: StructId, -) -> EarlyBinder<'db, PolyFnSig<'db>> { +) -> StoredEarlyBinder { let field_tys = db.field_types(def.into()); - let params = field_tys.iter().map(|(_, ty)| ty.skip_binder()); + let params = field_tys.iter().map(|(_, ty)| ty.get().skip_binder()); let ret = type_for_adt(db, def.into()).skip_binder(); let inputs_and_output = - Tys::new_from_iter(DbInterner::new_no_crate(db), params.chain(Some(ret))); - EarlyBinder::bind(Binder::dummy(FnSig { + Tys::new_from_iter(DbInterner::new_no_crate(db), params.chain(Some(ret.as_ref()))); + StoredEarlyBinder::bind(StoredPolyFnSig::new(Binder::dummy(FnSig { abi: FnAbi::RustCall, c_variadic: false, safety: Safety::Safe, inputs_and_output, - })) + }))) } -fn fn_sig_for_enum_variant_constructor<'db>( - db: &'db dyn HirDatabase, +fn fn_sig_for_enum_variant_constructor( + db: &dyn HirDatabase, def: EnumVariantId, -) -> EarlyBinder<'db, PolyFnSig<'db>> { +) -> StoredEarlyBinder { let field_tys = db.field_types(def.into()); - let params = field_tys.iter().map(|(_, ty)| ty.skip_binder()); + let params = field_tys.iter().map(|(_, ty)| ty.get().skip_binder()); let parent = def.lookup(db).parent; let ret = type_for_adt(db, parent.into()).skip_binder(); let inputs_and_output = - Tys::new_from_iter(DbInterner::new_no_crate(db), params.chain(Some(ret))); - EarlyBinder::bind(Binder::dummy(FnSig { + Tys::new_from_iter(DbInterner::new_no_crate(db), params.chain(Some(ret.as_ref()))); + StoredEarlyBinder::bind(StoredPolyFnSig::new(Binder::dummy(FnSig { abi: FnAbi::RustCall, c_variadic: false, safety: Safety::Safe, inputs_and_output, - })) + }))) } // FIXME(next-solver): should merge this with `explicit_item_bounds` in some way @@ -2341,7 +2444,7 @@ fn named_associated_type_shorthand_candidates<'db, R>( if let Some(alias) = check_trait(trait_ref) { return Some(alias); } - for pred in generic_predicates_filtered_by( + let predicates = generic_predicates_filtered_by( db, GenericDefId::TraitId(trait_ref.def_id.0), PredicateFilter::SelfTrait, @@ -2352,9 +2455,8 @@ fn named_associated_type_shorthand_candidates<'db, R>( |pred| pred != def && pred == GenericDefId::TraitId(trait_ref.def_id.0), ) .0 - .predicates - .instantiate_identity() - { + .predicates; + for pred in predicates.get().instantiate_identity() { tracing::debug!(?pred); let sup_trait_ref = match pred.kind().skip_binder() { rustc_type_ir::ClauseKind::Trait(pred) => pred.trait_ref, @@ -2401,8 +2503,8 @@ fn named_associated_type_shorthand_candidates<'db, R>( let predicates = generic_predicates_for_param(db, def, param_id.into(), assoc_name.clone()); predicates - .as_ref() - .iter_identity_copied() + .get() + .iter_identity() .find_map(|pred| match pred.kind().skip_binder() { rustc_type_ir::ClauseKind::Trait(trait_predicate) => Some(trait_predicate), _ => None, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs index fe96b6832e08..fba176bcb1ab 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs @@ -20,7 +20,7 @@ use hir_def::{ use hir_expand::name::Name; use rustc_type_ir::{ AliasTerm, AliasTy, AliasTyKind, - inherent::{GenericArgs as _, Region as _, SliceLike, Ty as _}, + inherent::{GenericArgs as _, Region as _, Ty as _}, }; use smallvec::SmallVec; use stdx::never; @@ -45,17 +45,15 @@ use super::{ const_param_ty_query, ty_query, }; -type CallbackData<'a, 'db> = Either< - PathDiagnosticCallbackData, - crate::infer::diagnostics::PathDiagnosticCallbackData<'a, 'db>, ->; +type CallbackData<'a> = + Either>; // We cannot use `&mut dyn FnMut()` because of lifetime issues, and we don't want to use `Box` // because of the allocation, so we create a lifetime-less callback, tailored for our needs. pub(crate) struct PathDiagnosticCallback<'a, 'db> { - pub(crate) data: CallbackData<'a, 'db>, + pub(crate) data: CallbackData<'a>, pub(crate) callback: - fn(&CallbackData<'_, 'db>, &mut TyLoweringContext<'db, '_>, PathLoweringDiagnostic), + fn(&CallbackData<'_>, &mut TyLoweringContext<'db, '_>, PathLoweringDiagnostic), } pub(crate) struct PathLoweringContext<'a, 'b, 'db> { @@ -555,7 +553,7 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> { ValueTyDefId::UnionId(it) => it.into(), ValueTyDefId::ConstId(it) => it.into(), ValueTyDefId::StaticId(_) => { - return GenericArgs::new_from_iter(interner, []); + return GenericArgs::empty(interner); } ValueTyDefId::EnumVariantId(var) => { // the generic args for an enum variant may be either specified diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs index d66a386bcdeb..aaa3cce4fad9 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs @@ -26,7 +26,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use rustc_type_ir::{ TypeVisitableExt, fast_reject::{TreatParams, simplify_type}, - inherent::{BoundExistentialPredicates, IntoKind, SliceLike}, + inherent::{BoundExistentialPredicates, IntoKind}, }; use stdx::impl_from; use triomphe::Arc; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs index 6d6515a45782..9292928f99fc 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs @@ -9,7 +9,7 @@ use hir_def::{ use rustc_type_ir::{ TypeFoldable, elaborate::elaborate, - inherent::{BoundExistentialPredicates, IntoKind, SliceLike, Ty as _}, + inherent::{BoundExistentialPredicates, IntoKind, Ty as _}, }; use tracing::debug; @@ -45,7 +45,7 @@ struct ConfirmContext<'a, 'b, 'db> { pub(crate) struct ConfirmResult<'db> { pub(crate) callee: MethodCallee<'db>, pub(crate) illegal_sized_bound: bool, - pub(crate) adjustments: Box<[Adjustment<'db>]>, + pub(crate) adjustments: Box<[Adjustment]>, } impl<'a, 'db> InferenceContext<'a, 'db> { @@ -177,7 +177,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> { &mut self, unadjusted_self_ty: Ty<'db>, pick: &probe::Pick<'db>, - ) -> (Ty<'db>, Box<[Adjustment<'db>]>) { + ) -> (Ty<'db>, Box<[Adjustment]>) { // Commit the autoderefs by calling `autoderef` again, but this // time writing the results into the various typeck results. let mut autoderef = self.ctx.table.autoderef_with_tracking(unadjusted_self_ty); @@ -200,8 +200,10 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> { // for two-phase borrows. let mutbl = AutoBorrowMutability::new(mutbl, AllowTwoPhase::Yes); - adjustments - .push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), target }); + adjustments.push(Adjustment { + kind: Adjust::Borrow(AutoBorrow::Ref(mutbl)), + target: target.store(), + }); if unsize { let unsized_ty = if let TyKind::Array(elem_ty, _) = base_ty.kind() { @@ -213,8 +215,10 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> { ) }; target = Ty::new_ref(self.interner(), region, unsized_ty, mutbl.into()); - adjustments - .push(Adjustment { kind: Adjust::Pointer(PointerCast::Unsize), target }); + adjustments.push(Adjustment { + kind: Adjust::Pointer(PointerCast::Unsize), + target: target.store(), + }); } } Some(probe::AutorefOrPtrAdjustment::ToConstPtr) => { @@ -228,7 +232,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> { adjustments.push(Adjustment { kind: Adjust::Pointer(PointerCast::MutToConstPointer), - target, + target: target.store(), }); } None => {} @@ -482,7 +486,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> { if self.ctx.unstable_features.arbitrary_self_types { self.ctx.result.type_mismatches.get_or_insert_default().insert( self.expr.into(), - TypeMismatch { expected: method_self_ty, actual: self_ty }, + TypeMismatch { expected: method_self_ty.store(), actual: self_ty.store() }, ); } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs index 9ea0d500a5f4..cdffcd9383ca 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs @@ -14,7 +14,7 @@ use rustc_type_ir::{ InferTy, TypeVisitableExt, Upcast, Variance, elaborate::{self, supertrait_def_ids}, fast_reject::{DeepRejectCtxt, TreatParams, simplify_type}, - inherent::{AdtDef as _, BoundExistentialPredicates as _, IntoKind, SliceLike, Ty as _}, + inherent::{AdtDef as _, BoundExistentialPredicates as _, IntoKind, Ty as _}, }; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir.rs index 836c20a43348..664238601108 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir.rs @@ -12,7 +12,7 @@ use hir_def::{ use la_arena::{Arena, ArenaMap, Idx, RawIdx}; use rustc_ast_ir::Mutability; use rustc_hash::FxHashMap; -use rustc_type_ir::inherent::{GenericArgs as _, IntoKind, SliceLike, Ty as _}; +use rustc_type_ir::inherent::{GenericArgs as _, IntoKind, Ty as _}; use smallvec::{SmallVec, smallvec}; use stdx::{impl_from, never}; @@ -23,7 +23,8 @@ use crate::{ display::{DisplayTarget, HirDisplay}, infer::PointerCast, next_solver::{ - Const, DbInterner, ErrorGuaranteed, GenericArgs, ParamEnv, Ty, TyKind, + Const, DbInterner, ErrorGuaranteed, GenericArgs, ParamEnv, StoredConst, StoredGenericArgs, + StoredTy, Ty, TyKind, infer::{InferCtxt, traits::ObligationCause}, obligation_ctxt::ObligationCtxt, }, @@ -49,16 +50,16 @@ pub(crate) use monomorphization::monomorphized_mir_body_cycle_result; use super::consteval::try_const_usize; -pub type BasicBlockId<'db> = Idx>; -pub type LocalId<'db> = Idx>; +pub type BasicBlockId = Idx; +pub type LocalId = Idx; -fn return_slot<'db>() -> LocalId<'db> { +fn return_slot() -> LocalId { LocalId::from_raw(RawIdx::from(0)) } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct Local<'db> { - pub ty: Ty<'db>, +pub struct Local { + pub ty: StoredTy, } /// An operand in MIR represents a "value" in Rust, the definition of which is undecided and part of @@ -80,19 +81,19 @@ pub struct Local<'db> { /// currently implements it, but it seems like this may be something to check against in the /// validator. #[derive(Debug, PartialEq, Eq, Clone)] -pub struct Operand<'db> { - kind: OperandKind<'db>, +pub struct Operand { + kind: OperandKind, // FIXME : This should actually just be of type `MirSpan`. span: Option, } #[derive(Debug, PartialEq, Eq, Clone)] -pub enum OperandKind<'db> { +pub enum OperandKind { /// Creates a value by loading the given place. /// /// Before drop elaboration, the type of the place must be `Copy`. After drop elaboration there /// is no such requirement. - Copy(Place<'db>), + Copy(Place), /// Creates a value by performing loading the place, just like the `Copy` operand. /// @@ -101,21 +102,21 @@ pub enum OperandKind<'db> { /// place without first re-initializing it. /// /// [UCG#188]: https://github.com/rust-lang/unsafe-code-guidelines/issues/188 - Move(Place<'db>), + Move(Place), /// Constants are already semantically values, and remain unchanged. - Constant { konst: Const<'db>, ty: Ty<'db> }, + Constant { konst: StoredConst, ty: StoredTy }, /// NON STANDARD: This kind of operand returns an immutable reference to that static memory. Rustc /// handles it with the `Constant` variant somehow. Static(StaticId), } -impl<'db> Operand<'db> { +impl<'db> Operand { fn from_concrete_const(data: Box<[u8]>, memory_map: MemoryMap<'db>, ty: Ty<'db>) -> Self { let interner = DbInterner::conjure(); Operand { kind: OperandKind::Constant { - konst: Const::new_valtree(interner, ty, data, memory_map), - ty, + konst: Const::new_valtree(interner, ty, data, memory_map).store(), + ty: ty.store(), }, span: None, } @@ -125,7 +126,7 @@ impl<'db> Operand<'db> { Operand::from_concrete_const(data, MemoryMap::default(), ty) } - fn const_zst(ty: Ty<'db>) -> Operand<'db> { + fn const_zst(ty: Ty<'db>) -> Operand { Self::from_bytes(Box::default(), ty) } @@ -133,28 +134,28 @@ impl<'db> Operand<'db> { db: &'db dyn HirDatabase, func_id: hir_def::FunctionId, generic_args: GenericArgs<'db>, - ) -> Operand<'db> { + ) -> Operand { let interner = DbInterner::new_no_crate(db); let ty = Ty::new_fn_def(interner, CallableDefId::FunctionId(func_id).into(), generic_args); Operand::from_bytes(Box::default(), ty) } } -#[derive(Debug, Clone, PartialEq, Eq, Hash, salsa::Update)] -pub enum ProjectionElem<'db, V: PartialEq> { +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum ProjectionElem { Deref, Field(Either), // FIXME: get rid of this, and use FieldId for tuples and closures ClosureField(usize), - Index(#[update(unsafe(with(crate::utils::unsafe_update_eq)))] V), + Index(V), ConstantIndex { offset: u64, from_end: bool }, Subslice { from: u64, to: u64 }, //Downcast(Option, VariantIdx), - OpaqueCast(Ty<'db>), + OpaqueCast(StoredTy), } -impl<'db, V: PartialEq> ProjectionElem<'db, V> { - pub fn projected_ty( +impl ProjectionElem { + pub fn projected_ty<'db>( &self, infcx: &InferCtxt<'db>, env: ParamEnv<'db>, @@ -194,7 +195,7 @@ impl<'db, V: PartialEq> ProjectionElem<'db, V> { }, ProjectionElem::Field(Either::Left(f)) => match base.kind() { TyKind::Adt(_, subst) => { - db.field_types(f.parent)[f.local_id].instantiate(interner, subst) + db.field_types(f.parent)[f.local_id].get().instantiate(interner, subst) } ty => { never!("Only adt has field, found {:?}", ty); @@ -253,18 +254,18 @@ impl<'db, V: PartialEq> ProjectionElem<'db, V> { } } -type PlaceElem<'db> = ProjectionElem<'db, LocalId<'db>>; +type PlaceElem = ProjectionElem; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ProjectionId(u32); #[derive(Debug, Clone, PartialEq, Eq)] -pub struct ProjectionStore<'db> { - id_to_proj: FxHashMap]>>, - proj_to_id: FxHashMap]>, ProjectionId>, +pub struct ProjectionStore { + id_to_proj: FxHashMap>, + proj_to_id: FxHashMap, ProjectionId>, } -impl Default for ProjectionStore<'_> { +impl Default for ProjectionStore { fn default() -> Self { let mut this = Self { id_to_proj: Default::default(), proj_to_id: Default::default() }; // Ensure that [] will get the id 0 which is used in `ProjectionId::Empty` @@ -273,17 +274,17 @@ impl Default for ProjectionStore<'_> { } } -impl<'db> ProjectionStore<'db> { +impl ProjectionStore { pub fn shrink_to_fit(&mut self) { self.id_to_proj.shrink_to_fit(); self.proj_to_id.shrink_to_fit(); } - pub fn intern_if_exist(&self, projection: &[PlaceElem<'db>]) -> Option { + pub fn intern_if_exist(&self, projection: &[PlaceElem]) -> Option { self.proj_to_id.get(projection).copied() } - pub fn intern(&mut self, projection: Box<[PlaceElem<'db>]>) -> ProjectionId { + pub fn intern(&mut self, projection: Box<[PlaceElem]>) -> ProjectionId { let new_id = ProjectionId(self.proj_to_id.len() as u32); match self.proj_to_id.entry(projection) { Entry::Occupied(id) => *id.get(), @@ -304,15 +305,11 @@ impl ProjectionId { self == ProjectionId::EMPTY } - pub fn lookup<'a, 'db>(self, store: &'a ProjectionStore<'db>) -> &'a [PlaceElem<'db>] { + pub fn lookup(self, store: &ProjectionStore) -> &[PlaceElem] { store.id_to_proj.get(&self).unwrap() } - pub fn project<'db>( - self, - projection: PlaceElem<'db>, - store: &mut ProjectionStore<'db>, - ) -> ProjectionId { + pub fn project(self, projection: PlaceElem, store: &mut ProjectionStore) -> ProjectionId { let mut current = self.lookup(store).to_vec(); current.push(projection); store.intern(current.into()) @@ -320,13 +317,13 @@ impl ProjectionId { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct Place<'db> { - pub local: LocalId<'db>, +pub struct Place { + pub local: LocalId, pub projection: ProjectionId, } -impl<'db> Place<'db> { - fn is_parent(&self, child: &Place<'db>, store: &ProjectionStore<'db>) -> bool { +impl Place { + fn is_parent(&self, child: &Place, store: &ProjectionStore) -> bool { self.local == child.local && child.projection.lookup(store).starts_with(self.projection.lookup(store)) } @@ -334,39 +331,39 @@ impl<'db> Place<'db> { /// The place itself is not included fn iterate_over_parents<'a>( &'a self, - store: &'a ProjectionStore<'db>, - ) -> impl Iterator> + 'a { + store: &'a ProjectionStore, + ) -> impl Iterator + 'a { let projection = self.projection.lookup(store); (0..projection.len()).map(|x| &projection[0..x]).filter_map(move |x| { Some(Place { local: self.local, projection: store.intern_if_exist(x)? }) }) } - fn project(&self, projection: PlaceElem<'db>, store: &mut ProjectionStore<'db>) -> Place<'db> { + fn project(&self, projection: PlaceElem, store: &mut ProjectionStore) -> Place { Place { local: self.local, projection: self.projection.project(projection, store) } } } -impl<'db> From> for Place<'db> { - fn from(local: LocalId<'db>) -> Self { +impl From for Place { + fn from(local: LocalId) -> Self { Self { local, projection: ProjectionId::EMPTY } } } #[derive(Debug, PartialEq, Eq, Clone)] -pub enum AggregateKind<'db> { +pub enum AggregateKind { /// The type is of the element - Array(Ty<'db>), + Array(StoredTy), /// The type is of the tuple - Tuple(Ty<'db>), - Adt(VariantId, GenericArgs<'db>), + Tuple(StoredTy), + Adt(VariantId, StoredGenericArgs), Union(UnionId, FieldId), - Closure(Ty<'db>), + Closure(StoredTy), //Coroutine(LocalDefId, SubstsRef, Movability), } #[derive(Debug, Clone, Hash, PartialEq, Eq)] -pub struct SwitchTargets<'db> { +pub struct SwitchTargets { /// Possible values. The locations to branch to in each case /// are found in the corresponding indices from the `targets` vector. values: SmallVec<[u128; 1]>, @@ -383,17 +380,17 @@ pub struct SwitchTargets<'db> { // // However we’ve decided to keep this as-is until we figure a case // where some other approach seems to be strictly better than other. - targets: SmallVec<[BasicBlockId<'db>; 2]>, + targets: SmallVec<[BasicBlockId; 2]>, } -impl<'db> SwitchTargets<'db> { +impl SwitchTargets { /// Creates switch targets from an iterator of values and target blocks. /// /// The iterator may be empty, in which case the `SwitchInt` instruction is equivalent to /// `goto otherwise;`. pub fn new( - targets: impl Iterator)>, - otherwise: BasicBlockId<'db>, + targets: impl Iterator, + otherwise: BasicBlockId, ) -> Self { let (values, mut targets): (SmallVec<_>, SmallVec<_>) = targets.unzip(); targets.push(otherwise); @@ -402,12 +399,12 @@ impl<'db> SwitchTargets<'db> { /// Builds a switch targets definition that jumps to `then` if the tested value equals `value`, /// and to `else_` if not. - pub fn static_if(value: u128, then: BasicBlockId<'db>, else_: BasicBlockId<'db>) -> Self { + pub fn static_if(value: u128, then: BasicBlockId, else_: BasicBlockId) -> Self { Self { values: smallvec![value], targets: smallvec![then, else_] } } /// Returns the fallback target that is jumped to when none of the values match the operand. - pub fn otherwise(&self) -> BasicBlockId<'db> { + pub fn otherwise(&self) -> BasicBlockId { *self.targets.last().unwrap() } @@ -417,33 +414,33 @@ impl<'db> SwitchTargets<'db> { /// including the `otherwise` fallback target. /// /// Note that this may yield 0 elements. Only the `otherwise` branch is mandatory. - pub fn iter(&self) -> impl Iterator)> + '_ { + pub fn iter(&self) -> impl Iterator + '_ { iter::zip(&self.values, &self.targets).map(|(x, y)| (*x, *y)) } /// Returns a slice with all possible jump targets (including the fallback target). - pub fn all_targets(&self) -> &[BasicBlockId<'db>] { + pub fn all_targets(&self) -> &[BasicBlockId] { &self.targets } /// Finds the `BasicBlock` to which this `SwitchInt` will branch given the /// specific value. This cannot fail, as it'll return the `otherwise` /// branch if there's not a specific match for the value. - pub fn target_for_value(&self, value: u128) -> BasicBlockId<'db> { + pub fn target_for_value(&self, value: u128) -> BasicBlockId { self.iter().find_map(|(v, t)| (v == value).then_some(t)).unwrap_or_else(|| self.otherwise()) } } #[derive(Debug, PartialEq, Eq, Clone)] -pub struct Terminator<'db> { +pub struct Terminator { pub span: MirSpan, - pub kind: TerminatorKind<'db>, + pub kind: TerminatorKind, } #[derive(Debug, PartialEq, Eq, Clone)] -pub enum TerminatorKind<'db> { +pub enum TerminatorKind { /// Block has one successor; we continue execution there. - Goto { target: BasicBlockId<'db> }, + Goto { target: BasicBlockId }, /// Switches based on the computed value. /// @@ -455,9 +452,9 @@ pub enum TerminatorKind<'db> { /// Target values may not appear more than once. SwitchInt { /// The discriminant value being tested. - discr: Operand<'db>, + discr: Operand, - targets: SwitchTargets<'db>, + targets: SwitchTargets, }, /// Indicates that the landing pad is finished and that the process should continue unwinding. @@ -508,7 +505,7 @@ pub enum TerminatorKind<'db> { /// > The drop glue is executed if, among all statements executed within this `Body`, an assignment to /// > the place or one of its "parents" occurred more recently than a move out of it. This does not /// > consider indirect assignments. - Drop { place: Place<'db>, target: BasicBlockId<'db>, unwind: Option> }, + Drop { place: Place, target: BasicBlockId, unwind: Option }, /// Drops the place and assigns a new value to it. /// @@ -541,10 +538,10 @@ pub enum TerminatorKind<'db> { /// /// Disallowed after drop elaboration. DropAndReplace { - place: Place<'db>, - value: Operand<'db>, - target: BasicBlockId<'db>, - unwind: Option>, + place: Place, + value: Operand, + target: BasicBlockId, + unwind: Option, }, /// Roughly speaking, evaluates the `func` operand and the arguments, and starts execution of @@ -559,18 +556,18 @@ pub enum TerminatorKind<'db> { /// [#71117]: https://github.com/rust-lang/rust/issues/71117 Call { /// The function that’s being called. - func: Operand<'db>, + func: Operand, /// Arguments the function is called with. /// These are owned by the callee, which is free to modify them. /// This allows the memory occupied by "by-value" arguments to be /// reused across function calls without duplicating the contents. - args: Box<[Operand<'db>]>, + args: Box<[Operand]>, /// Where the returned value will be written - destination: Place<'db>, + destination: Place, /// Where to go after this call returns. If none, the call necessarily diverges. - target: Option>, + target: Option, /// Cleanups to be done if the call unwinds. - cleanup: Option>, + cleanup: Option, /// `true` if this is from a call in HIR rather than from an overloaded /// operator. True for overloaded function call. from_hir_call: bool, @@ -586,11 +583,11 @@ pub enum TerminatorKind<'db> { /// necessarily executed even in the case of a panic, for example in `-C panic=abort`. If the /// assertion does not fail, execution continues at the specified basic block. Assert { - cond: Operand<'db>, + cond: Operand, expected: bool, //msg: AssertMessage, - target: BasicBlockId<'db>, - cleanup: Option>, + target: BasicBlockId, + cleanup: Option, }, /// Marks a suspend point. @@ -607,13 +604,13 @@ pub enum TerminatorKind<'db> { /// **Needs clarification**: What about the evaluation order of the `resume_arg` and `value`? Yield { /// The value to return. - value: Operand<'db>, + value: Operand, /// Where to resume to. - resume: BasicBlockId<'db>, + resume: BasicBlockId, /// The place to store the resume argument in. - resume_arg: Place<'db>, + resume_arg: Place, /// Cleanup to be done if the coroutine is dropped at this suspend point. - drop: Option>, + drop: Option, }, /// Indicates the end of dropping a coroutine. @@ -636,10 +633,10 @@ pub enum TerminatorKind<'db> { /// Disallowed after drop elaboration. FalseEdge { /// The target normal control flow will take. - real_target: BasicBlockId<'db>, + real_target: BasicBlockId, /// A block control flow could conceptually jump to, but won't in /// practice. - imaginary_target: BasicBlockId<'db>, + imaginary_target: BasicBlockId, }, /// A terminator for blocks that only take one path in reality, but where we reserve the right @@ -651,14 +648,14 @@ pub enum TerminatorKind<'db> { /// Disallowed after drop elaboration. FalseUnwind { /// The target normal control flow will take. - real_target: BasicBlockId<'db>, + real_target: BasicBlockId, /// The imaginary cleanup block link. This particular path will never be taken /// in practice, but in order to avoid fragility we want to always /// consider it in borrowck. We don't want to accept programs which /// pass borrowck only when `panic=abort` or some assertions are disabled /// due to release vs. debug mode builds. This needs to be an `Option` because /// of the `remove_noop_landing_pads` and `abort_unwinding_calls` passes. - unwind: Option>, + unwind: Option, }, } @@ -845,8 +842,8 @@ impl From for BinOp { } } -impl<'db> From> for Rvalue<'db> { - fn from(x: Operand<'db>) -> Self { +impl From for Rvalue { + fn from(x: Operand) -> Self { Self::Use(x) } } @@ -875,14 +872,14 @@ pub enum CastKind { } #[derive(Debug, PartialEq, Eq, Clone)] -pub enum Rvalue<'db> { +pub enum Rvalue { /// Yields the operand unchanged - Use(Operand<'db>), + Use(Operand), /// Creates an array where each element is the value of the operand. /// /// Corresponds to source code like `[x; 32]`. - Repeat(Operand<'db>, Const<'db>), + Repeat(Operand, StoredConst), /// Creates a reference of the indicated kind to the place. /// @@ -891,7 +888,7 @@ pub enum Rvalue<'db> { /// exactly what the behavior of this operation should be. /// /// `Shallow` borrows are disallowed after drop lowering. - Ref(BorrowKind, Place<'db>), + Ref(BorrowKind, Place), /// Creates a pointer/reference to the given thread local. /// @@ -922,7 +919,7 @@ pub enum Rvalue<'db> { /// If the type of the place is an array, this is the array length. For slices (`[T]`, not /// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is /// ill-formed for places of other types. - Len(Place<'db>), + Len(Place), /// Performs essentially all of the casts that can be performed via `as`. /// @@ -930,7 +927,7 @@ pub enum Rvalue<'db> { /// /// **FIXME**: Document exactly which `CastKind`s allow which types of casts. Figure out why /// `ArrayToPointer` and `MutToConstPointer` are special. - Cast(CastKind, Operand<'db>, Ty<'db>), + Cast(CastKind, Operand, StoredTy), // FIXME link to `pointer::offset` when it hits stable. /// * `Offset` has the same semantics as `pointer::offset`, except that the second @@ -962,7 +959,7 @@ pub enum Rvalue<'db> { /// when the value of right-hand side is negative. /// /// Other combinations of types and operators are unsupported. - CheckedBinaryOp(BinOp, Operand<'db>, Operand<'db>), + CheckedBinaryOp(BinOp, Operand, Operand), /// Computes a value as described by the operation. //NullaryOp(NullOp, Ty), @@ -973,7 +970,7 @@ pub enum Rvalue<'db> { /// Also does two's-complement arithmetic. Negation requires a signed integer or a float; /// bitwise not requires a signed integer, unsigned integer, or bool. Both operation kinds /// return a value with the same type as their operand. - UnaryOp(UnOp, Operand<'db>), + UnaryOp(UnOp, Operand), /// Computes the discriminant of the place, returning it as an integer of type /// `discriminant_ty`. Returns zero for types without discriminant. @@ -983,7 +980,7 @@ pub enum Rvalue<'db> { /// variant index; use `discriminant_for_variant` to convert. /// /// [#91095]: https://github.com/rust-lang/rust/issues/91095 - Discriminant(Place<'db>), + Discriminant(Place), /// Creates an aggregate value, like a tuple or struct. /// @@ -993,17 +990,17 @@ pub enum Rvalue<'db> { /// /// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After /// coroutine lowering, `Coroutine` aggregate kinds are disallowed too. - Aggregate(AggregateKind<'db>, Box<[Operand<'db>]>), + Aggregate(AggregateKind, Box<[Operand]>), /// Transmutes a `*mut u8` into shallow-initialized `Box`. /// /// This is different from a normal transmute because dataflow analysis will treat the box as /// initialized but its content as uninitialized. Like other pointer casts, this in general /// affects alias analysis. - ShallowInitBox(Operand<'db>, Ty<'db>), + ShallowInitBox(Operand, StoredTy), /// NON STANDARD: allocates memory with the type's layout, and shallow init the box with the resulting pointer. - ShallowInitBoxWithAlloc(Ty<'db>), + ShallowInitBoxWithAlloc(StoredTy), /// A CopyForDeref is equivalent to a read from a place at the /// codegen level, but is treated specially by drop elaboration. When such a read happens, it @@ -1013,41 +1010,41 @@ pub enum Rvalue<'db> { /// read never happened and just projects further. This allows simplifying various MIR /// optimizations and codegen backends that previously had to handle deref operations anywhere /// in a place. - CopyForDeref(Place<'db>), + CopyForDeref(Place), } #[derive(Debug, PartialEq, Eq, Clone)] -pub enum StatementKind<'db> { - Assign(Place<'db>, Rvalue<'db>), - FakeRead(Place<'db>), +pub enum StatementKind { + Assign(Place, Rvalue), + FakeRead(Place), //SetDiscriminant { // place: Box, // variant_index: VariantIdx, //}, - Deinit(Place<'db>), - StorageLive(LocalId<'db>), - StorageDead(LocalId<'db>), + Deinit(Place), + StorageLive(LocalId), + StorageDead(LocalId), //Retag(RetagKind, Box), //AscribeUserType(Place, UserTypeProjection, Variance), //Intrinsic(Box), Nop, } -impl<'db> StatementKind<'db> { - fn with_span(self, span: MirSpan) -> Statement<'db> { +impl StatementKind { + fn with_span(self, span: MirSpan) -> Statement { Statement { kind: self, span } } } #[derive(Debug, PartialEq, Eq, Clone)] -pub struct Statement<'db> { - pub kind: StatementKind<'db>, +pub struct Statement { + pub kind: StatementKind, pub span: MirSpan, } #[derive(Debug, Default, Clone, PartialEq, Eq)] -pub struct BasicBlock<'db> { +pub struct BasicBlock { /// List of statements in this block. - pub statements: Vec>, + pub statements: Vec, /// Terminator for this block. /// @@ -1057,7 +1054,7 @@ pub struct BasicBlock<'db> { /// exception is that certain passes, such as `simplify_cfg`, swap /// out the terminator temporarily with `None` while they continue /// to recurse over the set of basic blocks. - pub terminator: Option>, + pub terminator: Option, /// If true, this block lies on an unwind path. This is used /// during codegen where distinct kinds of basic blocks may be @@ -1067,29 +1064,29 @@ pub struct BasicBlock<'db> { } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct MirBody<'db> { - pub projection_store: ProjectionStore<'db>, - pub basic_blocks: Arena>, - pub locals: Arena>, - pub start_block: BasicBlockId<'db>, +pub struct MirBody { + pub projection_store: ProjectionStore, + pub basic_blocks: Arena, + pub locals: Arena, + pub start_block: BasicBlockId, pub owner: DefWithBodyId, - pub binding_locals: ArenaMap>, - pub param_locals: Vec>, + pub binding_locals: ArenaMap, + pub param_locals: Vec, /// This field stores the closures directly owned by this body. It is used /// in traversing every mir body. pub closures: Vec, } -impl<'db> MirBody<'db> { - pub fn local_to_binding_map(&self) -> ArenaMap, BindingId> { +impl MirBody { + pub fn local_to_binding_map(&self) -> ArenaMap { self.binding_locals.iter().map(|(it, y)| (*y, it)).collect() } - fn walk_places(&mut self, mut f: impl FnMut(&mut Place<'db>, &mut ProjectionStore<'db>)) { - fn for_operand<'db>( - op: &mut Operand<'db>, - f: &mut impl FnMut(&mut Place<'db>, &mut ProjectionStore<'db>), - store: &mut ProjectionStore<'db>, + fn walk_places(&mut self, mut f: impl FnMut(&mut Place, &mut ProjectionStore)) { + fn for_operand( + op: &mut Operand, + f: &mut impl FnMut(&mut Place, &mut ProjectionStore), + store: &mut ProjectionStore, ) { match &mut op.kind { OperandKind::Copy(p) | OperandKind::Move(p) => { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/borrowck.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/borrowck.rs index b39c9bc06559..941b6c75bfe7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/borrowck.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/borrowck.rs @@ -17,7 +17,7 @@ use crate::{ display::DisplayTarget, mir::OperandKind, next_solver::{ - DbInterner, GenericArgs, ParamEnv, Ty, TypingMode, + DbInterner, GenericArgs, ParamEnv, StoredTy, Ty, TypingMode, infer::{DbInternerInferExt, InferCtxt}, }, }; @@ -36,44 +36,44 @@ pub enum MutabilityReason { } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct MovedOutOfRef<'db> { - pub ty: Ty<'db>, +pub struct MovedOutOfRef { + pub ty: StoredTy, pub span: MirSpan, } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct PartiallyMoved<'db> { - pub ty: Ty<'db>, +pub struct PartiallyMoved { + pub ty: StoredTy, pub span: MirSpan, - pub local: LocalId<'db>, + pub local: LocalId, } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct BorrowRegion<'db> { - pub local: LocalId<'db>, +pub struct BorrowRegion { + pub local: LocalId, pub kind: BorrowKind, pub places: Vec, } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct BorrowckResult<'db> { - pub mir_body: Arc>, - pub mutability_of_locals: ArenaMap, MutabilityReason>, - pub moved_out_of_ref: Vec>, - pub partially_moved: Vec>, - pub borrow_regions: Vec>, +pub struct BorrowckResult { + pub mir_body: Arc, + pub mutability_of_locals: ArenaMap, + pub moved_out_of_ref: Vec, + pub partially_moved: Vec, + pub borrow_regions: Vec, } -fn all_mir_bodies<'db>( - db: &'db dyn HirDatabase, +fn all_mir_bodies( + db: &dyn HirDatabase, def: DefWithBodyId, - mut cb: impl FnMut(Arc>), -) -> Result<(), MirLowerError<'db>> { - fn for_closure<'db>( - db: &'db dyn HirDatabase, + mut cb: impl FnMut(Arc), +) -> Result<(), MirLowerError> { + fn for_closure( + db: &dyn HirDatabase, c: InternedClosureId, - cb: &mut impl FnMut(Arc>), - ) -> Result<(), MirLowerError<'db>> { + cb: &mut impl FnMut(Arc), + ) -> Result<(), MirLowerError> { match db.mir_body_for_closure(c) { Ok(body) => { cb(body.clone()); @@ -91,10 +91,10 @@ fn all_mir_bodies<'db>( } } -pub fn borrowck_query<'db>( - db: &'db dyn HirDatabase, +pub fn borrowck_query( + db: &dyn HirDatabase, def: DefWithBodyId, -) -> Result]>, MirLowerError<'db>> { +) -> Result, MirLowerError> { let _p = tracing::info_span!("borrowck_query").entered(); let module = def.module(db); let interner = DbInterner::new_with(db, module.krate(db)); @@ -125,20 +125,20 @@ fn make_fetch_closure_field<'db>( let (captures, _) = infer.closure_info(c); let parent_subst = subst.split_closure_args_untupled().parent_args; let interner = DbInterner::new_no_crate(db); - captures.get(f).expect("broken closure field").ty.instantiate(interner, parent_subst) + captures.get(f).expect("broken closure field").ty.get().instantiate(interner, parent_subst) } } fn moved_out_of_ref<'db>( infcx: &InferCtxt<'db>, env: ParamEnv<'db>, - body: &MirBody<'db>, -) -> Vec> { + body: &MirBody, +) -> Vec { let db = infcx.interner.db; let mut result = vec![]; - let mut for_operand = |op: &Operand<'db>, span: MirSpan| match op.kind { + let mut for_operand = |op: &Operand, span: MirSpan| match op.kind { OperandKind::Copy(p) | OperandKind::Move(p) => { - let mut ty: Ty<'db> = body.locals[p.local].ty; + let mut ty: Ty<'db> = body.locals[p.local].ty.as_ref(); let mut is_dereference_of_ref = false; for proj in p.projection.lookup(&body.projection_store) { if *proj == ProjectionElem::Deref && ty.as_reference().is_some() { @@ -156,7 +156,7 @@ fn moved_out_of_ref<'db>( && !infcx.type_is_copy_modulo_regions(env, ty) && !ty.references_non_lt_error() { - result.push(MovedOutOfRef { span: op.span.unwrap_or(span), ty }); + result.push(MovedOutOfRef { span: op.span.unwrap_or(span), ty: ty.store() }); } } OperandKind::Constant { .. } | OperandKind::Static(_) => (), @@ -233,13 +233,13 @@ fn moved_out_of_ref<'db>( fn partially_moved<'db>( infcx: &InferCtxt<'db>, env: ParamEnv<'db>, - body: &MirBody<'db>, -) -> Vec> { + body: &MirBody, +) -> Vec { let db = infcx.interner.db; let mut result = vec![]; - let mut for_operand = |op: &Operand<'db>, span: MirSpan| match op.kind { + let mut for_operand = |op: &Operand, span: MirSpan| match op.kind { OperandKind::Copy(p) | OperandKind::Move(p) => { - let mut ty: Ty<'db> = body.locals[p.local].ty; + let mut ty: Ty<'db> = body.locals[p.local].ty.as_ref(); for proj in p.projection.lookup(&body.projection_store) { ty = proj.projected_ty( infcx, @@ -250,7 +250,7 @@ fn partially_moved<'db>( ); } if !infcx.type_is_copy_modulo_regions(env, ty) && !ty.references_non_lt_error() { - result.push(PartiallyMoved { span, ty, local: p.local }); + result.push(PartiallyMoved { span, ty: ty.store(), local: p.local }); } } OperandKind::Constant { .. } | OperandKind::Static(_) => (), @@ -324,7 +324,7 @@ fn partially_moved<'db>( result } -fn borrow_regions<'db>(db: &'db dyn HirDatabase, body: &MirBody<'db>) -> Vec> { +fn borrow_regions(db: &dyn HirDatabase, body: &MirBody) -> Vec { let mut borrows = FxHashMap::default(); for (_, block) in body.basic_blocks.iter() { db.unwind_if_revision_cancelled(); @@ -332,7 +332,7 @@ fn borrow_regions<'db>(db: &'db dyn HirDatabase, body: &MirBody<'db>) -> Vec| { + .and_modify(|it: &mut BorrowRegion| { it.places.push(statement.span); }) .or_insert_with(|| BorrowRegion { @@ -377,12 +377,12 @@ enum ProjectionCase { fn place_case<'db>( infcx: &InferCtxt<'db>, env: ParamEnv<'db>, - body: &MirBody<'db>, - lvalue: &Place<'db>, + body: &MirBody, + lvalue: &Place, ) -> ProjectionCase { let db = infcx.interner.db; let mut is_part_of = false; - let mut ty = body.locals[lvalue.local].ty; + let mut ty = body.locals[lvalue.local].ty.as_ref(); for proj in lvalue.projection.lookup(&body.projection_store).iter() { match proj { ProjectionElem::Deref if ty.as_adt().is_none() => return ProjectionCase::Indirect, // It's indirect in case of reference and raw @@ -410,18 +410,18 @@ fn place_case<'db>( /// Returns a map from basic blocks to the set of locals that might be ever initialized before /// the start of the block. Only `StorageDead` can remove something from this map, and we ignore /// `Uninit` and `drop` and similar after initialization. -fn ever_initialized_map<'db>( - db: &'db dyn HirDatabase, - body: &MirBody<'db>, -) -> ArenaMap, ArenaMap, bool>> { - let mut result: ArenaMap, ArenaMap, bool>> = +fn ever_initialized_map( + db: &dyn HirDatabase, + body: &MirBody, +) -> ArenaMap> { + let mut result: ArenaMap> = body.basic_blocks.iter().map(|it| (it.0, ArenaMap::default())).collect(); - fn dfs<'db>( - db: &'db dyn HirDatabase, - body: &MirBody<'db>, - l: LocalId<'db>, - stack: &mut Vec>, - result: &mut ArenaMap, ArenaMap, bool>>, + fn dfs( + db: &dyn HirDatabase, + body: &MirBody, + l: LocalId, + stack: &mut Vec, + result: &mut ArenaMap>, ) { while let Some(b) = stack.pop() { let mut is_ever_initialized = result[b][l]; // It must be filled, as we use it as mark for dfs @@ -509,11 +509,7 @@ fn ever_initialized_map<'db>( result } -fn push_mut_span<'db>( - local: LocalId<'db>, - span: MirSpan, - result: &mut ArenaMap, MutabilityReason>, -) { +fn push_mut_span(local: LocalId, span: MirSpan, result: &mut ArenaMap) { match &mut result[local] { MutabilityReason::Mut { spans } => spans.push(span), it @ (MutabilityReason::Not | MutabilityReason::Unused) => { @@ -522,16 +518,13 @@ fn push_mut_span<'db>( }; } -fn record_usage<'db>(local: LocalId<'db>, result: &mut ArenaMap, MutabilityReason>) { +fn record_usage(local: LocalId, result: &mut ArenaMap) { if let it @ MutabilityReason::Unused = &mut result[local] { *it = MutabilityReason::Not; }; } -fn record_usage_for_operand<'db>( - arg: &Operand<'db>, - result: &mut ArenaMap, MutabilityReason>, -) { +fn record_usage_for_operand(arg: &Operand, result: &mut ArenaMap) { if let OperandKind::Copy(p) | OperandKind::Move(p) = arg.kind { record_usage(p.local, result); } @@ -540,10 +533,10 @@ fn record_usage_for_operand<'db>( fn mutability_of_locals<'db>( infcx: &InferCtxt<'db>, env: ParamEnv<'db>, - body: &MirBody<'db>, -) -> ArenaMap, MutabilityReason> { + body: &MirBody, +) -> ArenaMap { let db = infcx.interner.db; - let mut result: ArenaMap, MutabilityReason> = + let mut result: ArenaMap = body.locals.iter().map(|it| (it.0, MutabilityReason::Unused)).collect(); let ever_init_maps = ever_initialized_map(db, body); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs index 3b4913cae3fb..b78e610b49e8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs @@ -17,6 +17,7 @@ use hir_def::{ use hir_expand::{InFile, mod_path::path, name::Name}; use intern::sym; use la_arena::ArenaMap; +use macros::GenericTypeVisitable; use rustc_abi::TargetDataLayout; use rustc_apfloat::{ Float, @@ -42,8 +43,8 @@ use crate::{ layout::{Layout, LayoutError, RustcEnumVariantIdx}, method_resolution::{is_dyn_method, lookup_impl_const}, next_solver::{ - Const, ConstBytes, ConstKind, DbInterner, ErrorGuaranteed, GenericArgs, Region, Ty, TyKind, - TypingMode, UnevaluatedConst, ValueConst, + Const, ConstBytes, ConstKind, DbInterner, ErrorGuaranteed, GenericArgs, Region, + StoredConst, StoredTy, Ty, TyKind, TypingMode, UnevaluatedConst, ValueConst, infer::{DbInternerInferExt, InferCtxt, traits::ObligationCause}, obligation_ctxt::ObligationCtxt, }, @@ -83,7 +84,7 @@ macro_rules! not_supported { }; } -#[derive(Debug, Default, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq, Eq, GenericTypeVisitable)] pub struct VTableMap<'db> { ty_to_id: FxHashMap, usize>, id_to_ty: Vec>, @@ -150,16 +151,16 @@ impl TlsData { } } -struct StackFrame<'db> { - locals: Locals<'db>, - destination: Option>, +struct StackFrame { + locals: Locals, + destination: Option, prev_stack_ptr: usize, span: (MirSpan, DefWithBodyId), } #[derive(Clone)] -enum MirOrDynIndex<'db> { - Mir(Arc>), +enum MirOrDynIndex { + Mir(Arc), Dyn(usize), } @@ -169,7 +170,7 @@ pub struct Evaluator<'db> { target_data_layout: Arc, stack: Vec, heap: Vec, - code_stack: Vec>, + code_stack: Vec, /// Stores the global location of the statics. We const evaluate every static first time we need it /// and see it's missing, then we add it to this to reuse. static_locations: FxHashMap, @@ -182,13 +183,13 @@ pub struct Evaluator<'db> { stdout: Vec, stderr: Vec, layout_cache: RefCell, Arc>>, - projected_ty_cache: RefCell, PlaceElem<'db>), Ty<'db>>>, + projected_ty_cache: RefCell, PlaceElem), Ty<'db>>>, not_special_fn_cache: RefCell>, - mir_or_dyn_index_cache: RefCell), MirOrDynIndex<'db>>>, - /// Constantly dropping and creating `Locals<'db>` is very costly. We store + mir_or_dyn_index_cache: RefCell), MirOrDynIndex>>, + /// Constantly dropping and creating `Locals` is very costly. We store /// old locals that we normally want to drop here, to reuse their allocations /// later. - unused_locals_store: RefCell>>>, + unused_locals_store: RefCell>>, cached_ptr_size: usize, cached_fn_trait_func: Option, cached_fn_mut_trait_func: Option, @@ -261,7 +262,7 @@ impl<'db> IntervalAndTy<'db> { addr: Address, ty: Ty<'db>, evaluator: &Evaluator<'db>, - locals: &Locals<'db>, + locals: &Locals, ) -> Result<'db, IntervalAndTy<'db>> { let size = evaluator.size_of_sized(ty, locals, "type of interval")?; Ok(IntervalAndTy { interval: Interval { addr, size }, ty }) @@ -340,22 +341,22 @@ impl Address { } #[derive(Clone, PartialEq, Eq)] -pub enum MirEvalError<'db> { - ConstEvalError(String, Box>), - LayoutError(LayoutError, Ty<'db>), +pub enum MirEvalError { + ConstEvalError(String, Box), + LayoutError(LayoutError, StoredTy), TargetDataLayoutNotAvailable(TargetLoadError), /// Means that code had undefined behavior. We don't try to actively detect UB, but if it was detected /// then use this type of error. UndefinedBehavior(String), Panic(String), // FIXME: This should be folded into ConstEvalError? - MirLowerError(FunctionId, MirLowerError<'db>), - MirLowerErrorForClosure(InternedClosureId, MirLowerError<'db>), - TypeIsUnsized(Ty<'db>, &'static str), + MirLowerError(FunctionId, MirLowerError), + MirLowerErrorForClosure(InternedClosureId, MirLowerError), + TypeIsUnsized(StoredTy, &'static str), NotSupported(String), - InvalidConst(Const<'db>), + InvalidConst(StoredConst), InFunction( - Box>, + Box, Vec<(Either, MirSpan, DefWithBodyId)>, ), ExecutionLimitExceeded, @@ -363,12 +364,12 @@ pub enum MirEvalError<'db> { /// FIXME: Fold this into InternalError InvalidVTableId(usize), /// ? - CoerceUnsizedError(Ty<'db>), + CoerceUnsizedError(StoredTy), /// These should not occur, usually indicates a bug in mir lowering. InternalError(Box), } -impl MirEvalError<'_> { +impl MirEvalError { pub fn pretty_print( &self, f: &mut String, @@ -432,7 +433,9 @@ impl MirEvalError<'_> { write!( f, "Layout for type `{}` is not available due {err:?}", - ty.display(db, display_target).with_closure_style(ClosureStyle::ClosureWithId) + ty.as_ref() + .display(db, display_target) + .with_closure_style(ClosureStyle::ClosureWithId) )?; } MirEvalError::MirLowerError(func, err) => { @@ -495,7 +498,7 @@ impl MirEvalError<'_> { } } -impl std::fmt::Debug for MirEvalError<'_> { +impl std::fmt::Debug for MirEvalError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::ConstEvalError(arg0, arg1) => { @@ -534,15 +537,15 @@ impl std::fmt::Debug for MirEvalError<'_> { } } -type Result<'db, T> = std::result::Result>; +type Result<'db, T> = std::result::Result; #[derive(Debug, Default)] -struct DropFlags<'db> { - need_drop: FxHashSet>, +struct DropFlags { + need_drop: FxHashSet, } -impl<'db> DropFlags<'db> { - fn add_place(&mut self, p: Place<'db>, store: &ProjectionStore<'db>) { +impl DropFlags { + fn add_place(&mut self, p: Place, store: &ProjectionStore) { if p.iterate_over_parents(store).any(|it| self.need_drop.contains(&it)) { return; } @@ -550,7 +553,7 @@ impl<'db> DropFlags<'db> { self.need_drop.insert(p); } - fn remove_place(&mut self, p: &Place<'db>, store: &ProjectionStore<'db>) -> bool { + fn remove_place(&mut self, p: &Place, store: &ProjectionStore) -> bool { // FIXME: replace parents with parts if let Some(parent) = p.iterate_over_parents(store).find(|it| self.need_drop.contains(it)) { self.need_drop.remove(&parent); @@ -565,10 +568,10 @@ impl<'db> DropFlags<'db> { } #[derive(Debug)] -struct Locals<'db> { - ptr: ArenaMap, Interval>, - body: Arc>, - drop_flags: DropFlags<'db>, +struct Locals { + ptr: ArenaMap, + body: Arc, + drop_flags: DropFlags, } pub struct MirOutput { @@ -587,7 +590,7 @@ impl MirOutput { pub fn interpret_mir<'db>( db: &'db dyn HirDatabase, - body: Arc>, + body: Arc, // FIXME: This is workaround. Ideally, const generics should have a separate body (issue #7434), but now // they share their body with their parent, so in MIR lowering we have locals of the parent body, which // might have placeholders. With this argument, we (wrongly) assume that every placeholder type has @@ -596,7 +599,7 @@ pub fn interpret_mir<'db>( assert_placeholder_ty_is_unused: bool, trait_env: Option>, ) -> Result<'db, (Result<'db, Const<'db>>, MirOutput)> { - let ty = body.locals[return_slot()].ty; + let ty = body.locals[return_slot()].ty.as_ref(); let mut evaluator = Evaluator::new(db, body.owner, assert_placeholder_ty_is_unused, trait_env)?; let it: Result<'db, Const<'db>> = (|| { if evaluator.ptr_size() != size_of::() { @@ -694,11 +697,11 @@ impl<'db> Evaluator<'db> { self.infcx.interner.lang_items() } - fn place_addr(&self, p: &Place<'db>, locals: &Locals<'db>) -> Result<'db, Address> { + fn place_addr(&self, p: &Place, locals: &Locals) -> Result<'db, Address> { Ok(self.place_addr_and_ty_and_metadata(p, locals)?.0) } - fn place_interval(&self, p: &Place<'db>, locals: &Locals<'db>) -> Result<'db, Interval> { + fn place_interval(&self, p: &Place, locals: &Locals) -> Result<'db, Interval> { let place_addr_and_ty = self.place_addr_and_ty_and_metadata(p, locals)?; Ok(Interval { addr: place_addr_and_ty.0, @@ -714,7 +717,7 @@ impl<'db> Evaluator<'db> { self.cached_ptr_size } - fn projected_ty(&self, ty: Ty<'db>, proj: PlaceElem<'db>) -> Ty<'db> { + fn projected_ty(&self, ty: Ty<'db>, proj: PlaceElem) -> Ty<'db> { let pair = (ty, proj); if let Some(r) = self.projected_ty_cache.borrow().get(&pair) { return *r; @@ -733,6 +736,7 @@ impl<'db> Evaluator<'db> { .get(f) .expect("broken closure field") .ty + .get() .instantiate(self.interner(), parent_subst) }, self.crate_id, @@ -743,11 +747,11 @@ impl<'db> Evaluator<'db> { fn place_addr_and_ty_and_metadata<'a>( &'a self, - p: &Place<'db>, - locals: &'a Locals<'db>, + p: &Place, + locals: &'a Locals, ) -> Result<'db, (Address, Ty<'db>, Option)> { let mut addr = locals.ptr[p.local].addr; - let mut ty: Ty<'db> = locals.body.locals[p.local].ty; + let mut ty: Ty<'db> = locals.body.locals[p.local].ty.as_ref(); let mut metadata: Option = None; // locals are always sized for proj in p.projection.lookup(&locals.body.projection_store) { let prev_ty = ty; @@ -868,8 +872,8 @@ impl<'db> Evaluator<'db> { } let r = self .db - .layout_of_ty(ty, self.param_env) - .map_err(|e| MirEvalError::LayoutError(e, ty))?; + .layout_of_ty(ty.store(), self.param_env.store()) + .map_err(|e| MirEvalError::LayoutError(e, ty.store()))?; self.layout_cache.borrow_mut().insert(ty, r.clone()); Ok(r) } @@ -878,17 +882,17 @@ impl<'db> Evaluator<'db> { self.layout(Ty::new_adt(self.interner(), adt, subst)) } - fn place_ty<'a>(&'a self, p: &Place<'db>, locals: &'a Locals<'db>) -> Result<'db, Ty<'db>> { + fn place_ty<'a>(&'a self, p: &Place, locals: &'a Locals) -> Result<'db, Ty<'db>> { Ok(self.place_addr_and_ty_and_metadata(p, locals)?.1) } - fn operand_ty(&self, o: &Operand<'db>, locals: &Locals<'db>) -> Result<'db, Ty<'db>> { + fn operand_ty(&self, o: &Operand, locals: &Locals) -> Result<'db, Ty<'db>> { Ok(match &o.kind { OperandKind::Copy(p) | OperandKind::Move(p) => self.place_ty(p, locals)?, - OperandKind::Constant { konst: _, ty } => *ty, + OperandKind::Constant { konst: _, ty } => ty.as_ref(), &OperandKind::Static(s) => { - let ty = - InferenceResult::for_body(self.db, s.into())[self.db.body(s.into()).body_expr]; + let ty = InferenceResult::for_body(self.db, s.into()) + .expr_ty(self.db.body(s.into()).body_expr); Ty::new_ref( self.interner(), Region::new_static(self.interner()), @@ -901,8 +905,8 @@ impl<'db> Evaluator<'db> { fn operand_ty_and_eval( &mut self, - o: &Operand<'db>, - locals: &mut Locals<'db>, + o: &Operand, + locals: &mut Locals, ) -> Result<'db, IntervalAndTy<'db>> { Ok(IntervalAndTy { interval: self.eval_operand(o, locals)?, @@ -912,7 +916,7 @@ impl<'db> Evaluator<'db> { fn interpret_mir( &mut self, - body: Arc>, + body: Arc, args: impl Iterator, ) -> Result<'db, Interval> { if let Some(it) = self.stack_depth_limit.checked_sub(1) { @@ -1076,8 +1080,8 @@ impl<'db> Evaluator<'db> { fn fill_locals_for_body( &mut self, - body: &MirBody<'db>, - locals: &mut Locals<'db>, + body: &MirBody, + locals: &mut Locals, args: impl Iterator, ) -> Result<'db, ()> { let mut remain_args = body.param_locals.len(); @@ -1100,9 +1104,9 @@ impl<'db> Evaluator<'db> { fn create_locals_for_body( &mut self, - body: &Arc>, + body: &Arc, destination: Option, - ) -> Result<'db, (Locals<'db>, usize)> { + ) -> Result<'db, (Locals, usize)> { let mut locals = match self.unused_locals_store.borrow_mut().entry(body.owner).or_default().pop() { None => Locals { @@ -1126,7 +1130,7 @@ impl<'db> Evaluator<'db> { continue; } let (size, align) = self.size_align_of_sized( - it.ty, + it.ty.as_ref(), &locals, "no unsized local in extending stack", )?; @@ -1149,11 +1153,7 @@ impl<'db> Evaluator<'db> { Ok((locals, prev_stack_pointer)) } - fn eval_rvalue( - &mut self, - r: &Rvalue<'db>, - locals: &mut Locals<'db>, - ) -> Result<'db, IntervalOrOwned> { + fn eval_rvalue(&mut self, r: &Rvalue, locals: &mut Locals) -> Result<'db, IntervalOrOwned> { use IntervalOrOwned::*; Ok(match r { Rvalue::Use(it) => Borrowed(self.eval_operand(it, locals)?), @@ -1445,7 +1445,7 @@ impl<'db> Evaluator<'db> { Owned(result.to_le_bytes().to_vec()) } Rvalue::Repeat(it, len) => { - let len = match try_const_usize(self.db, *len) { + let len = match try_const_usize(self.db, len.as_ref()) { Some(it) => it as usize, None => not_supported!("non evaluatable array len in repeat Rvalue"), }; @@ -1455,7 +1455,7 @@ impl<'db> Evaluator<'db> { } Rvalue::ShallowInitBox(_, _) => not_supported!("shallow init box"), Rvalue::ShallowInitBoxWithAlloc(ty) => { - let Some((size, align)) = self.size_align_of(*ty, locals)? else { + let Some((size, align)) = self.size_align_of(ty.as_ref(), locals)? else { not_supported!("unsized box initialization"); }; let addr = self.heap_allocate(size, align)?; @@ -1477,7 +1477,7 @@ impl<'db> Evaluator<'db> { Owned(r) } AggregateKind::Tuple(ty) => { - let layout = self.layout(*ty)?; + let layout = self.layout(ty.as_ref())?; Owned(self.construct_with_layout( layout.size.bytes_usize(), &layout, @@ -1486,10 +1486,8 @@ impl<'db> Evaluator<'db> { )?) } AggregateKind::Union(it, f) => { - let layout = self.layout_adt( - (*it).into(), - GenericArgs::new_from_iter(self.interner(), []), - )?; + let layout = + self.layout_adt((*it).into(), GenericArgs::empty(self.interner()))?; let offset = layout .fields .offset(u32::from(f.local_id.into_raw()) as usize) @@ -1501,7 +1499,7 @@ impl<'db> Evaluator<'db> { } AggregateKind::Adt(it, subst) => { let (size, variant_layout, tag) = - self.layout_of_variant(*it, *subst, locals)?; + self.layout_of_variant(*it, subst.as_ref(), locals)?; Owned(self.construct_with_layout( size, &variant_layout, @@ -1510,7 +1508,7 @@ impl<'db> Evaluator<'db> { )?) } AggregateKind::Closure(ty) => { - let layout = self.layout(*ty)?; + let layout = self.layout(ty.as_ref())?; Owned(self.construct_with_layout( layout.size.bytes_usize(), &layout, @@ -1537,7 +1535,7 @@ impl<'db> Evaluator<'db> { PointerCast::Unsize => { let current_ty = self.operand_ty(operand, locals)?; let addr = self.eval_operand(operand, locals)?; - self.coerce_unsized(addr, current_ty, *target_ty)? + self.coerce_unsized(addr, current_ty, target_ty.as_ref())? } PointerCast::MutToConstPointer | PointerCast::UnsafeFnPointer => { // This is no-op @@ -1556,8 +1554,11 @@ impl<'db> Evaluator<'db> { let current_ty = self.operand_ty(operand, locals)?; let is_signed = matches!(current_ty.kind(), TyKind::Int(_)); let current = pad16(self.eval_operand(operand, locals)?.get(self)?, is_signed); - let dest_size = - self.size_of_sized(*target_ty, locals, "destination of int to int cast")?; + let dest_size = self.size_of_sized( + target_ty.as_ref(), + locals, + "destination of int to int cast", + )?; Owned(current[0..dest_size].to_vec()) } CastKind::FloatToInt => { @@ -1579,9 +1580,12 @@ impl<'db> Evaluator<'db> { not_supported!("unstable floating point type f16 and f128"); } }; - let is_signed = matches!(target_ty.kind(), TyKind::Int(_)); - let dest_size = - self.size_of_sized(*target_ty, locals, "destination of float to int cast")?; + let is_signed = matches!(target_ty.as_ref().kind(), TyKind::Int(_)); + let dest_size = self.size_of_sized( + target_ty.as_ref(), + locals, + "destination of float to int cast", + )?; let dest_bits = dest_size * 8; let (max, min) = if dest_bits == 128 { (i128::MAX, i128::MIN) @@ -1614,7 +1618,7 @@ impl<'db> Evaluator<'db> { not_supported!("unstable floating point type f16 and f128"); } }; - let TyKind::Float(target_ty) = target_ty.kind() else { + let TyKind::Float(target_ty) = target_ty.as_ref().kind() else { not_supported!("invalid float to float cast"); }; match target_ty { @@ -1630,7 +1634,7 @@ impl<'db> Evaluator<'db> { let is_signed = matches!(current_ty.kind(), TyKind::Int(_)); let value = pad16(self.eval_operand(operand, locals)?.get(self)?, is_signed); let value = i128::from_le_bytes(value); - let TyKind::Float(target_ty) = target_ty.kind() else { + let TyKind::Float(target_ty) = target_ty.as_ref().kind() else { not_supported!("invalid int to float cast"); }; match target_ty { @@ -1709,12 +1713,12 @@ impl<'db> Evaluator<'db> { { let field_types = self.db.field_types(struct_id.into()); if let Some(ty) = - field_types.iter().last().map(|it| it.1.instantiate(self.interner(), subst)) + field_types.iter().last().map(|it| it.1.get().instantiate(self.interner(), subst)) { return self.coerce_unsized_look_through_fields(ty, goal); } } - Err(MirEvalError::CoerceUnsizedError(ty)) + Err(MirEvalError::CoerceUnsizedError(ty.store())) } fn coerce_unsized( @@ -1787,8 +1791,10 @@ impl<'db> Evaluator<'db> { not_supported!("unsizing struct without field"); }; let target_last_field = self.db.field_types(id.into())[last_field] + .get() .instantiate(self.interner(), target_subst); let current_last_field = self.db.field_types(id.into())[last_field] + .get() .instantiate(self.interner(), current_subst); return self.unsizing_ptr_from_addr( target_last_field, @@ -1806,7 +1812,7 @@ impl<'db> Evaluator<'db> { &mut self, it: VariantId, subst: GenericArgs<'db>, - locals: &Locals<'db>, + locals: &Locals, ) -> Result<'db, (usize, Arc, Option<(usize, usize, i128)>)> { let adt = it.adt_id(self.db); if let DefWithBodyId::VariantId(f) = locals.body.owner @@ -1900,11 +1906,7 @@ impl<'db> Evaluator<'db> { Ok(result) } - fn eval_operand( - &mut self, - it: &Operand<'db>, - locals: &mut Locals<'db>, - ) -> Result<'db, Interval> { + fn eval_operand(&mut self, it: &Operand, locals: &mut Locals) -> Result<'db, Interval> { Ok(match &it.kind { OperandKind::Copy(p) | OperandKind::Move(p) => { locals.drop_flags.remove_place(p, &locals.body.projection_store); @@ -1914,14 +1916,16 @@ impl<'db> Evaluator<'db> { let addr = self.eval_static(*st, locals)?; Interval::new(addr, self.ptr_size()) } - OperandKind::Constant { konst, .. } => self.allocate_const_in_heap(locals, *konst)?, + OperandKind::Constant { konst, .. } => { + self.allocate_const_in_heap(locals, konst.as_ref())? + } }) } #[allow(clippy::double_parens)] fn allocate_const_in_heap( &mut self, - locals: &Locals<'db>, + locals: &Locals, konst: Const<'db>, ) -> Result<'db, Interval> { let result_owner; @@ -1971,7 +1975,7 @@ impl<'db> Evaluator<'db> { } else if size < 16 && v.len() == 16 { Cow::Borrowed(&v[0..size]) } else { - return Err(MirEvalError::InvalidConst(konst)); + return Err(MirEvalError::InvalidConst(konst.store())); } } else { Cow::Borrowed(v) @@ -1993,7 +1997,7 @@ impl<'db> Evaluator<'db> { Ok(Interval::new(addr, size)) } - fn eval_place(&mut self, p: &Place<'db>, locals: &Locals<'db>) -> Result<'db, Interval> { + fn eval_place(&mut self, p: &Place, locals: &Locals) -> Result<'db, Interval> { let addr = self.place_addr(p, locals)?; Ok(Interval::new( addr, @@ -2093,11 +2097,7 @@ impl<'db> Evaluator<'db> { Ok(()) } - fn size_align_of( - &self, - ty: Ty<'db>, - locals: &Locals<'db>, - ) -> Result<'db, Option<(usize, usize)>> { + fn size_align_of(&self, ty: Ty<'db>, locals: &Locals) -> Result<'db, Option<(usize, usize)>> { if let Some(layout) = self.layout_cache.borrow().get(&ty) { return Ok(layout .is_sized() @@ -2126,12 +2126,12 @@ impl<'db> Evaluator<'db> { fn size_of_sized( &self, ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, what: &'static str, ) -> Result<'db, usize> { match self.size_align_of(ty, locals)? { Some(it) => Ok(it.0), - None => Err(MirEvalError::TypeIsUnsized(ty, what)), + None => Err(MirEvalError::TypeIsUnsized(ty.store(), what)), } } @@ -2140,12 +2140,12 @@ impl<'db> Evaluator<'db> { fn size_align_of_sized( &self, ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, what: &'static str, ) -> Result<'db, (usize, usize)> { match self.size_align_of(ty, locals)? { Some(it) => Ok(it), - None => Err(MirEvalError::TypeIsUnsized(ty, what)), + None => Err(MirEvalError::TypeIsUnsized(ty.store(), what)), } } @@ -2181,13 +2181,13 @@ impl<'db> Evaluator<'db> { &self, bytes: &[u8], ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, ) -> Result<'db, ComplexMemoryMap<'db>> { fn rec<'db>( this: &Evaluator<'db>, bytes: &[u8], ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, mm: &mut ComplexMemoryMap<'db>, stack_depth_limit: usize, ) -> Result<'db, ()> { @@ -2288,7 +2288,7 @@ impl<'db> Evaluator<'db> { .fields .offset(u32::from(f.into_raw()) as usize) .bytes_usize(); - let ty = field_types[f].instantiate(this.interner(), subst); + let ty = field_types[f].get().instantiate(this.interner(), subst); let size = this.layout(ty)?.size.bytes_usize(); rec( this, @@ -2314,7 +2314,7 @@ impl<'db> Evaluator<'db> { for (f, _) in data.fields().iter() { let offset = l.fields.offset(u32::from(f.into_raw()) as usize).bytes_usize(); - let ty = field_types[f].instantiate(this.interner(), subst); + let ty = field_types[f].get().instantiate(this.interner(), subst); let size = this.layout(ty)?.size.bytes_usize(); rec( this, @@ -2356,7 +2356,7 @@ impl<'db> Evaluator<'db> { ty_of_bytes: impl Fn(&[u8]) -> Result<'db, Ty<'db>> + Copy, addr: Address, ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, ) -> Result<'db, ()> { // FIXME: support indirect references let layout = self.layout(ty)?; @@ -2389,7 +2389,7 @@ impl<'db> Evaluator<'db> { AdtId::StructId(s) => { for (i, (_, ty)) in self.db.field_types(s.into()).iter().enumerate() { let offset = layout.fields.offset(i).bytes_usize(); - let ty = ty.instantiate(self.interner(), args); + let ty = ty.get().instantiate(self.interner(), args); self.patch_addresses( patch_map, ty_of_bytes, @@ -2410,7 +2410,7 @@ impl<'db> Evaluator<'db> { ) { for (i, (_, ty)) in self.db.field_types(ev.into()).iter().enumerate() { let offset = layout.fields.offset(i).bytes_usize(); - let ty = ty.instantiate(self.interner(), args); + let ty = ty.get().instantiate(self.interner(), args); self.patch_addresses( patch_map, ty_of_bytes, @@ -2477,10 +2477,10 @@ impl<'db> Evaluator<'db> { bytes: Interval, destination: Interval, args: &[IntervalAndTy<'db>], - locals: &Locals<'db>, - target_bb: Option>, + locals: &Locals, + target_bb: Option, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { let id = from_bytes!(usize, bytes.get(self)?); let next_ty = self.vtable_map.ty(id)?; use rustc_type_ir::TyKind; @@ -2508,19 +2508,23 @@ impl<'db> Evaluator<'db> { generic_args: GenericArgs<'db>, destination: Interval, args: &[IntervalAndTy<'db>], - locals: &Locals<'db>, + locals: &Locals, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { let mir_body = self .db - .monomorphized_mir_body_for_closure(closure, generic_args, self.param_env) + .monomorphized_mir_body_for_closure( + closure, + generic_args.store(), + self.param_env.store(), + ) .map_err(|it| MirEvalError::MirLowerErrorForClosure(closure, it))?; - let closure_data = if mir_body.locals[mir_body.param_locals[0]].ty.as_reference().is_some() - { - closure_data.addr.to_bytes().to_vec() - } else { - closure_data.get(self)?.to_owned() - }; + let closure_data = + if mir_body.locals[mir_body.param_locals[0]].ty.as_ref().as_reference().is_some() { + closure_data.addr.to_bytes().to_vec() + } else { + closure_data.get(self)?.to_owned() + }; let arg_bytes = iter::once(Ok(closure_data)) .chain(args.iter().map(|it| Ok(it.get(self)?.to_owned()))) .collect::>>()?; @@ -2542,10 +2546,10 @@ impl<'db> Evaluator<'db> { generic_args: GenericArgs<'db>, destination: Interval, args: &[IntervalAndTy<'db>], - locals: &Locals<'db>, - target_bb: Option>, + locals: &Locals, + target_bb: Option, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { match def { CallableDefId::FunctionId(def) => { if self.detect_fn_trait(def).is_some() { @@ -2600,9 +2604,9 @@ impl<'db> Evaluator<'db> { &self, def: FunctionId, generic_args: GenericArgs<'db>, - locals: &Locals<'db>, + locals: &Locals, span: MirSpan, - ) -> Result<'db, MirOrDynIndex<'db>> { + ) -> Result<'db, MirOrDynIndex> { let pair = (def, generic_args); if let Some(r) = self.mir_or_dyn_index_cache.borrow().get(&pair) { return Ok(r.clone()); @@ -2621,7 +2625,7 @@ impl<'db> Evaluator<'db> { let mir_body = self .db - .monomorphized_mir_body(imp.into(), generic_args, self.param_env) + .monomorphized_mir_body(imp.into(), generic_args.store(), self.param_env.store()) .map_err(|e| { MirEvalError::InFunction( Box::new(MirEvalError::MirLowerError(imp, e)), @@ -2639,11 +2643,11 @@ impl<'db> Evaluator<'db> { mut def: FunctionId, args: &[IntervalAndTy<'db>], generic_args: GenericArgs<'db>, - locals: &Locals<'db>, + locals: &Locals, destination: Interval, - target_bb: Option>, + target_bb: Option, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { if self.detect_and_exec_special_function( def, args, @@ -2705,14 +2709,14 @@ impl<'db> Evaluator<'db> { fn exec_looked_up_function( &mut self, - mir_body: Arc>, - locals: &Locals<'db>, + mir_body: Arc, + locals: &Locals, def: FunctionId, arg_bytes: impl Iterator, span: MirSpan, destination: Interval, - target_bb: Option>, - ) -> Result<'db, Option>> { + target_bb: Option, + ) -> Result<'db, Option> { Ok(if let Some(target_bb) = target_bb { let (mut locals, prev_stack_ptr) = self.create_locals_for_body(&mir_body, Some(destination))?; @@ -2736,11 +2740,11 @@ impl<'db> Evaluator<'db> { def: FunctionId, args: &[IntervalAndTy<'db>], generic_args: GenericArgs<'db>, - locals: &Locals<'db>, + locals: &Locals, destination: Interval, - target_bb: Option>, + target_bb: Option, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { let func = args .first() .ok_or_else(|| MirEvalError::InternalError("fn trait with no arg".into()))?; @@ -2805,7 +2809,7 @@ impl<'db> Evaluator<'db> { } } - fn eval_static(&mut self, st: StaticId, locals: &Locals<'db>) -> Result<'db, Address> { + fn eval_static(&mut self, st: StaticId, locals: &Locals) -> Result<'db, Address> { if let Some(o) = self.static_locations.get(&st) { return Ok(*o); }; @@ -2816,8 +2820,8 @@ impl<'db> Evaluator<'db> { })?; self.allocate_const_in_heap(locals, konst)? } else { - let ty = - InferenceResult::for_body(self.db, st.into())[self.db.body(st.into()).body_expr]; + let ty = InferenceResult::for_body(self.db, st.into()) + .expr_ty(self.db.body(st.into()).body_expr); let Some((size, align)) = self.size_align_of(ty, locals)? else { not_supported!("unsized extern static"); }; @@ -2852,12 +2856,7 @@ impl<'db> Evaluator<'db> { } } - fn drop_place( - &mut self, - place: &Place<'db>, - locals: &mut Locals<'db>, - span: MirSpan, - ) -> Result<'db, ()> { + fn drop_place(&mut self, place: &Place, locals: &mut Locals, span: MirSpan) -> Result<'db, ()> { let (addr, ty, metadata) = self.place_addr_and_ty_and_metadata(place, locals)?; if !locals.drop_flags.remove_place(place, &locals.body.projection_store) { return Ok(()); @@ -2872,7 +2871,7 @@ impl<'db> Evaluator<'db> { fn run_drop_glue_deep( &mut self, ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, addr: Address, _metadata: &[u8], span: MirSpan, @@ -2886,7 +2885,7 @@ impl<'db> Evaluator<'db> { return Ok(()); }; - let generic_args = GenericArgs::new_from_iter(self.interner(), [ty.into()]); + let generic_args = GenericArgs::new_from_slice(&[ty.into()]); if let Ok(MirOrDynIndex::Mir(body)) = self.get_mir_or_dyn_index(drop_fn, generic_args, locals, span) { @@ -2920,7 +2919,9 @@ impl<'db> Evaluator<'db> { .offset(u32::from(field.into_raw()) as usize) .bytes_usize(); let addr = addr.offset(offset); - let ty = field_types[field].instantiate(self.interner(), subst); + let ty = field_types[field] + .get() + .instantiate(self.interner(), subst); self.run_drop_glue_deep(ty, locals, addr, &[], span)?; } } @@ -3011,7 +3012,7 @@ pub fn render_const_using_debug_impl<'db>( let debug_fmt_fn_ptr = evaluator.vtable_map.id(Ty::new_fn_def( evaluator.interner(), CallableDefId::FunctionId(debug_fmt_fn).into(), - GenericArgs::new_from_iter(evaluator.interner(), [ty.into()]), + GenericArgs::new_from_slice(&[ty.into()]), )); evaluator.write_memory(a2.offset(evaluator.ptr_size()), &debug_fmt_fn_ptr.to_le_bytes())?; // a3 = ::core::fmt::Arguments::new_v1(a1, a2) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim.rs index 42c11113ee30..a47a8c440007 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim.rs @@ -52,7 +52,7 @@ impl<'db> Evaluator<'db> { def: FunctionId, args: &[IntervalAndTy<'db>], generic_args: GenericArgs<'db>, - locals: &Locals<'db>, + locals: &Locals, destination: Interval, span: MirSpan, ) -> Result<'db, bool> { @@ -149,7 +149,7 @@ impl<'db> Evaluator<'db> { def: FunctionId, args: &[IntervalAndTy<'db>], self_ty: Ty<'db>, - locals: &Locals<'db>, + locals: &Locals, destination: Interval, span: MirSpan, ) -> Result<'db, ()> { @@ -195,7 +195,7 @@ impl<'db> Evaluator<'db> { self.exec_fn_with_args( def, args, - GenericArgs::new_from_iter(self.interner(), [self_ty.into()]), + GenericArgs::new_from_slice(&[self_ty.into()]), locals, destination, None, @@ -212,7 +212,7 @@ impl<'db> Evaluator<'db> { layout: Arc, addr: Address, def: FunctionId, - locals: &Locals<'db>, + locals: &Locals, destination: Interval, span: MirSpan, ) -> Result<'db, ()> { @@ -318,7 +318,7 @@ impl<'db> Evaluator<'db> { it: EvalLangItem, generic_args: GenericArgs<'db>, args: &[IntervalAndTy<'db>], - locals: &Locals<'db>, + locals: &Locals, span: MirSpan, ) -> Result<'db, Vec> { use EvalLangItem::*; @@ -390,7 +390,7 @@ impl<'db> Evaluator<'db> { id: i64, args: &[IntervalAndTy<'db>], destination: Interval, - _locals: &Locals<'db>, + _locals: &Locals, _span: MirSpan, ) -> Result<'db, ()> { match id { @@ -421,7 +421,7 @@ impl<'db> Evaluator<'db> { args: &[IntervalAndTy<'db>], _generic_args: GenericArgs<'db>, destination: Interval, - locals: &Locals<'db>, + locals: &Locals, span: MirSpan, ) -> Result<'db, ()> { match as_str { @@ -587,7 +587,7 @@ impl<'db> Evaluator<'db> { args: &[IntervalAndTy<'db>], generic_args: GenericArgs<'db>, destination: Interval, - locals: &Locals<'db>, + locals: &Locals, span: MirSpan, needs_override: bool, ) -> Result<'db, bool> { @@ -1235,7 +1235,7 @@ impl<'db> Evaluator<'db> { def, &args, // FIXME: wrong for manual impls of `FnOnce` - GenericArgs::new_from_iter(self.interner(), []), + GenericArgs::empty(self.interner()), locals, destination, None, @@ -1369,7 +1369,7 @@ impl<'db> Evaluator<'db> { &mut self, ty: Ty<'db>, metadata: Interval, - locals: &Locals<'db>, + locals: &Locals, ) -> Result<'db, (usize, usize)> { Ok(match ty.kind() { TyKind::Str => (from_bytes!(usize, metadata.get(self)?), 1), @@ -1391,8 +1391,13 @@ impl<'db> Evaluator<'db> { _ => not_supported!("unsized enum or union"), }; let field_types = self.db.field_types(id.into()); - let last_field_ty = - field_types.iter().next_back().unwrap().1.instantiate(self.interner(), subst); + let last_field_ty = field_types + .iter() + .next_back() + .unwrap() + .1 + .get() + .instantiate(self.interner(), subst); let sized_part_size = layout.fields.offset(field_types.iter().count() - 1).bytes_usize(); let sized_part_align = layout.align.bytes() as usize; @@ -1423,7 +1428,7 @@ impl<'db> Evaluator<'db> { args: &[IntervalAndTy<'db>], generic_args: GenericArgs<'db>, destination: Interval, - locals: &Locals<'db>, + locals: &Locals, _span: MirSpan, ) -> Result<'db, ()> { // We are a single threaded runtime with no UB checking and no optimization, so diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim/simd.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim/simd.rs index 4c64a70a7a62..3896917cab1a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim/simd.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim/simd.rs @@ -35,6 +35,7 @@ impl<'db> Evaluator<'db> { not_supported!("simd type with no field"); }; let field_ty = self.db.field_types(id.into())[first_field] + .get() .instantiate(self.interner(), subst); return Ok((fields.len(), field_ty)); } @@ -67,7 +68,7 @@ impl<'db> Evaluator<'db> { args: &[IntervalAndTy<'db>], _generic_args: GenericArgs<'db>, destination: Interval, - _locals: &Locals<'db>, + _locals: &Locals, _span: MirSpan, ) -> Result<'db, ()> { match name { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/tests.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/tests.rs index c13b76c12579..61dd7757c90b 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/tests.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/tests.rs @@ -15,7 +15,7 @@ use crate::{ use super::{MirEvalError, interpret_mir}; -fn eval_main(db: &TestDB, file_id: EditionedFileId) -> Result<(String, String), MirEvalError<'_>> { +fn eval_main(db: &TestDB, file_id: EditionedFileId) -> Result<(String, String), MirEvalError> { crate::attach_db(db, || { let interner = DbInterner::new_no_crate(db); let module_id = db.module_for_file(file_id.file_id(db)); @@ -39,11 +39,12 @@ fn eval_main(db: &TestDB, file_id: EditionedFileId) -> Result<(String, String), let body = db .monomorphized_mir_body( func_id.into(), - GenericArgs::new_from_iter(interner, []), + GenericArgs::empty(interner).store(), crate::ParamEnvAndCrate { param_env: db.trait_environment(func_id.into()), krate: func_id.krate(db), - }, + } + .store(), ) .map_err(|e| MirEvalError::MirLowerError(func_id, e))?; @@ -122,7 +123,7 @@ fn check_panic(#[rust_analyzer::rust_fixture] ra_fixture: &str, expected_panic: fn check_error_with( #[rust_analyzer::rust_fixture] ra_fixture: &str, - expect_err: impl FnOnce(MirEvalError<'_>) -> bool, + expect_err: impl FnOnce(MirEvalError) -> bool, ) { let (db, file_ids) = TestDB::with_many_files(ra_fixture); crate::attach_db(&db, || { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs index d7a8c18614a4..ef2a13848ca6 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs @@ -19,7 +19,7 @@ use hir_expand::name::Name; use la_arena::ArenaMap; use rustc_apfloat::Float; use rustc_hash::FxHashMap; -use rustc_type_ir::inherent::{Const as _, IntoKind, SliceLike, Ty as _}; +use rustc_type_ir::inherent::{Const as _, IntoKind, Ty as _}; use span::{Edition, FileId}; use syntax::TextRange; use triomphe::Arc; @@ -42,7 +42,8 @@ use crate::{ TupleFieldId, Ty, UnOp, VariantId, return_slot, }, next_solver::{ - Const, DbInterner, ParamConst, ParamEnv, Region, TyKind, TypingMode, UnevaluatedConst, + Const, DbInterner, ParamConst, ParamEnv, Region, StoredGenericArgs, StoredTy, TyKind, + TypingMode, UnevaluatedConst, infer::{DbInternerInferExt, InferCtxt}, }, traits::FnTrait, @@ -56,39 +57,39 @@ mod pattern_matching; mod tests; #[derive(Debug, Clone)] -struct LoopBlocks<'db> { - begin: BasicBlockId<'db>, +struct LoopBlocks { + begin: BasicBlockId, /// `None` for loops that are not terminating - end: Option>, - place: Place<'db>, + end: Option, + place: Place, drop_scope_index: usize, } #[derive(Debug, Clone, Default)] -struct DropScope<'db> { +struct DropScope { /// locals, in order of definition (so we should run drop glues in reverse order) - locals: Vec>, + locals: Vec, } struct MirLowerCtx<'a, 'db> { - result: MirBody<'db>, + result: MirBody, owner: DefWithBodyId, - current_loop_blocks: Option>, - labeled_loop_blocks: FxHashMap>, - discr_temp: Option>, + current_loop_blocks: Option, + labeled_loop_blocks: FxHashMap, + discr_temp: Option, db: &'db dyn HirDatabase, body: &'a Body, - infer: &'a InferenceResult<'db>, + infer: &'a InferenceResult, resolver: Resolver<'db>, - drop_scopes: Vec>, + drop_scopes: Vec, env: ParamEnv<'db>, infcx: InferCtxt<'db>, } // FIXME: Make this smaller, its stored in database queries #[derive(Debug, Clone, PartialEq, Eq)] -pub enum MirLowerError<'db> { - ConstEvalError(Box, Box>), +pub enum MirLowerError { + ConstEvalError(Box, Box), LayoutError(LayoutError), IncompleteExpr, IncompletePattern, @@ -98,9 +99,9 @@ pub enum MirLowerError<'db> { RecordLiteralWithoutPath, UnresolvedMethod(String), UnresolvedField, - UnsizedTemporary(Ty<'db>), + UnsizedTemporary(StoredTy), MissingFunctionDefinition(DefWithBodyId, ExprId), - TypeMismatch(TypeMismatch<'db>), + TypeMismatch(TypeMismatch), HasErrors, /// This should never happen. Type mismatch should catch everything. TypeError(&'static str), @@ -113,11 +114,11 @@ pub enum MirLowerError<'db> { LangItemNotFound, MutatingRvalue, UnresolvedLabel, - UnresolvedUpvar(Place<'db>), + UnresolvedUpvar(Place), InaccessibleLocal, // monomorphization errors: - GenericArgNotProvided(GenericParamId, GenericArgs<'db>), + GenericArgNotProvided(GenericParamId, StoredGenericArgs), } /// A token to ensuring that each drop scope is popped at most once, thanks to the compiler that checks moves. @@ -126,9 +127,9 @@ impl DropScopeToken { fn pop_and_drop<'db>( self, ctx: &mut MirLowerCtx<'_, 'db>, - current: BasicBlockId<'db>, + current: BasicBlockId, span: MirSpan, - ) -> BasicBlockId<'db> { + ) -> BasicBlockId { std::mem::forget(self); ctx.pop_drop_scope_internal(current, span) } @@ -158,7 +159,7 @@ impl Drop for DropScopeToken { // } // } -impl MirLowerError<'_> { +impl MirLowerError { pub fn pretty_print( &self, f: &mut String, @@ -190,8 +191,8 @@ impl MirLowerError<'_> { MirLowerError::TypeMismatch(e) => writeln!( f, "Type mismatch: Expected {}, found {}", - e.expected.display(db, display_target), - e.actual.display(db, display_target), + e.expected.as_ref().display(db, display_target), + e.actual.as_ref().display(db, display_target), )?, MirLowerError::GenericArgNotProvided(id, subst) => { let param_name = match *id { @@ -211,7 +212,7 @@ impl MirLowerError<'_> { param_name.unwrap_or(Name::missing()).display(db, display_target.edition) )?; writeln!(f, "Provided args: [")?; - for g in subst.iter() { + for g in subst.as_ref() { write!(f, " {},", g.display(db, display_target))?; } writeln!(f, "]")?; @@ -254,13 +255,13 @@ macro_rules! implementation_error { }}; } -impl From for MirLowerError<'_> { +impl From for MirLowerError { fn from(value: LayoutError) -> Self { MirLowerError::LayoutError(value) } } -impl MirLowerError<'_> { +impl MirLowerError { fn unresolved_path( db: &dyn HirDatabase, p: &Path, @@ -273,14 +274,14 @@ impl MirLowerError<'_> { } } -type Result<'db, T> = std::result::Result>; +type Result<'db, T> = std::result::Result; impl<'a, 'db> MirLowerCtx<'a, 'db> { fn new( db: &'db dyn HirDatabase, owner: DefWithBodyId, body: &'a Body, - infer: &'a InferenceResult<'db>, + infer: &'a InferenceResult, ) -> Self { let mut basic_blocks = Arena::new(); let start_block = basic_blocks.alloc(BasicBlock { @@ -289,7 +290,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { is_cleanup: false, }); let locals = Arena::new(); - let binding_locals: ArenaMap> = ArenaMap::new(); + let binding_locals: ArenaMap = ArenaMap::new(); let mir = MirBody { projection_store: ProjectionStore::default(), basic_blocks, @@ -332,16 +333,11 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { self.infcx.interner.lang_items() } - fn temp( - &mut self, - ty: Ty<'db>, - current: BasicBlockId<'db>, - span: MirSpan, - ) -> Result<'db, LocalId<'db>> { + fn temp(&mut self, ty: Ty<'db>, current: BasicBlockId, span: MirSpan) -> Result<'db, LocalId> { if matches!(ty.kind(), TyKind::Slice(_) | TyKind::Dynamic(..)) { - return Err(MirLowerError::UnsizedTemporary(ty)); + return Err(MirLowerError::UnsizedTemporary(ty.store())); } - let l = self.result.locals.alloc(Local { ty }); + let l = self.result.locals.alloc(Local { ty: ty.store() }); self.push_storage_live_for_local(l, current, span)?; Ok(l) } @@ -349,8 +345,8 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_expr_to_some_operand( &mut self, expr_id: ExprId, - current: BasicBlockId<'db>, - ) -> Result<'db, Option<(Operand<'db>, BasicBlockId<'db>)>> { + current: BasicBlockId, + ) -> Result<'db, Option<(Operand, BasicBlockId)>> { if !self.has_adjustments(expr_id) && let Expr::Literal(l) = &self.body[expr_id] { @@ -366,10 +362,10 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_expr_to_place_with_adjust( &mut self, expr_id: ExprId, - place: Place<'db>, - current: BasicBlockId<'db>, - adjustments: &[Adjustment<'db>], - ) -> Result<'db, Option>> { + place: Place, + current: BasicBlockId, + adjustments: &[Adjustment], + ) -> Result<'db, Option> { match adjustments.split_last() { Some((last, rest)) => match &last.kind { Adjust::NeverToAny => { @@ -416,7 +412,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { Rvalue::Cast( CastKind::PointerCoercion(*cast), Operand { kind: OperandKind::Copy(p), span: None }, - last.target, + last.target.clone(), ), expr_id.into(), ); @@ -430,11 +426,11 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_expr_to_place_with_borrow_adjust( &mut self, expr_id: ExprId, - place: Place<'db>, - current: BasicBlockId<'db>, - rest: &[Adjustment<'db>], + place: Place, + current: BasicBlockId, + rest: &[Adjustment], m: Mutability, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { let Some((p, current)) = self.lower_expr_as_place_with_adjust(current, expr_id, true, rest)? else { @@ -448,9 +444,9 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_expr_to_place( &mut self, expr_id: ExprId, - place: Place<'db>, - prev_block: BasicBlockId<'db>, - ) -> Result<'db, Option>> { + place: Place, + prev_block: BasicBlockId, + ) -> Result<'db, Option> { if let Some(adjustments) = self.infer.expr_adjustments.get(&expr_id) { return self.lower_expr_to_place_with_adjust(expr_id, place, prev_block, adjustments); } @@ -460,9 +456,9 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_expr_to_place_without_adjust( &mut self, expr_id: ExprId, - place: Place<'db>, - mut current: BasicBlockId<'db>, - ) -> Result<'db, Option>> { + place: Place, + mut current: BasicBlockId, + ) -> Result<'db, Option> { match &self.body[expr_id] { Expr::OffsetOf(_) => { not_supported!("builtin#offset_of") @@ -537,7 +533,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { const_id.into(), current, place, - GenericArgs::new_from_iter(self.interner(), []), + GenericArgs::empty(self.interner()), expr_id.into(), )?; Ok(Some(current)) @@ -545,7 +541,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { ValueNs::EnumVariantId(variant_id) => { let variant_fields = variant_id.fields(self.db); if variant_fields.shape == FieldsShape::Unit { - let ty = self.infer.type_of_expr[expr_id]; + let ty = self.infer.expr_ty(expr_id); current = self.lower_enum_variant( variant_id, current, @@ -575,8 +571,9 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { konst: Const::new_param( self.interner(), ParamConst { id: p, index }, - ), - ty: self.db.const_param_ty_ns(p), + ) + .store(), + ty: self.db.const_param_ty_ns(p).store(), }, span: None, }), @@ -907,7 +904,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { operands[u32::from(field_id.into_raw()) as usize] = Some(op); } let rvalue = Rvalue::Aggregate( - AggregateKind::Adt(variant_id, subst), + AggregateKind::Adt(variant_id, subst.store()), match spread_place { Some(sp) => operands .into_iter() @@ -978,15 +975,15 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { let rvalue = if self.infer.coercion_casts.contains(expr) { Rvalue::Use(it) } else { - let source_ty = self.infer[*expr]; - let target_ty = self.infer[expr_id]; + let source_ty = self.infer.expr_ty(*expr); + let target_ty = self.infer.expr_ty(expr_id); let cast_kind = if source_ty.as_reference().is_some() { CastKind::PointerCoercion(PointerCast::ArrayToPointer) } else { cast_kind(self.db, source_ty, target_ty)? }; - Rvalue::Cast(cast_kind, it, target_ty) + Rvalue::Cast(cast_kind, it, target_ty.store()) }; self.push_assignment(current, place, rvalue, expr_id.into()); Ok(Some(current)) @@ -1004,7 +1001,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { self.push_assignment( current, place, - Rvalue::ShallowInitBoxWithAlloc(ty), + Rvalue::ShallowInitBoxWithAlloc(ty.store()), expr_id.into(), ); let Some((operand, current)) = self.lower_expr_to_some_operand(*expr, current)? @@ -1222,7 +1219,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { current, place, Rvalue::Aggregate( - AggregateKind::Adt(st.into(), subst), + AggregateKind::Adt(st.into(), subst.store()), st.fields(self.db) .fields() .iter() @@ -1284,11 +1281,10 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { }; match &capture.kind { CaptureKind::ByRef(bk) => { - let tmp_ty = capture.ty.instantiate_identity(); + let tmp_ty = capture.ty.get().instantiate_identity(); // FIXME: Handle more than one span. let capture_spans = capture.spans(); - let tmp: Place<'db> = - self.temp(tmp_ty, current, capture_spans[0])?.into(); + let tmp: Place = self.temp(tmp_ty, current, capture_spans[0])?.into(); self.push_assignment( current, tmp, @@ -1305,7 +1301,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { self.push_assignment( current, place, - Rvalue::Aggregate(AggregateKind::Closure(ty), operands.into()), + Rvalue::Aggregate(AggregateKind::Closure(ty.store()), operands.into()), expr_id.into(), ); Ok(Some(current)) @@ -1325,7 +1321,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { return Ok(None); }; let r = Rvalue::Aggregate( - AggregateKind::Tuple(self.expr_ty_without_adjust(expr_id)), + AggregateKind::Tuple(self.expr_ty_without_adjust(expr_id).store()), values, ); self.push_assignment(current, place, r, expr_id.into()); @@ -1355,7 +1351,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { else { return Ok(None); }; - let r = Rvalue::Aggregate(AggregateKind::Array(elem_ty), values); + let r = Rvalue::Aggregate(AggregateKind::Array(elem_ty.store()), values); self.push_assignment(current, place, r, expr_id.into()); Ok(Some(current)) } @@ -1373,7 +1369,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { )); } }; - let r = Rvalue::Repeat(init, len); + let r = Rvalue::Repeat(init, len.store()); self.push_assignment(current, place, r, expr_id.into()); Ok(Some(current)) } @@ -1388,11 +1384,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { } } - fn push_field_projection( - &mut self, - place: &mut Place<'db>, - expr_id: ExprId, - ) -> Result<'db, ()> { + fn push_field_projection(&mut self, place: &mut Place, expr_id: ExprId) -> Result<'db, ()> { if let Expr::Field { expr, name } = &self.body[expr_id] { if let TyKind::Tuple(..) = self.expr_ty_after_adjustments(*expr).kind() { let index = @@ -1421,7 +1413,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { &mut self, ty: Ty<'db>, loc: &ExprId, - ) -> Result<'db, Operand<'db>> { + ) -> Result<'db, Operand> { match &self.body[*loc] { Expr::Literal(l) => self.lower_literal_to_operand(ty, l), Expr::Path(c) => { @@ -1443,7 +1435,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { ResolveValueResult::ValueNs(v, _) => { if let ValueNs::ConstId(c) = v { self.lower_const_to_operand( - GenericArgs::new_from_iter(self.interner(), []), + GenericArgs::empty(self.interner()), c.into(), ) } else { @@ -1461,10 +1453,13 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { } } - fn lower_literal_to_operand(&mut self, ty: Ty<'db>, l: &Literal) -> Result<'db, Operand<'db>> { + fn lower_literal_to_operand(&mut self, ty: Ty<'db>, l: &Literal) -> Result<'db, Operand> { let size = || { self.db - .layout_of_ty(ty, ParamEnvAndCrate { param_env: self.env, krate: self.krate() }) + .layout_of_ty( + ty.store(), + ParamEnvAndCrate { param_env: self.env, krate: self.krate() }.store(), + ) .map(|it| it.size.bytes_usize()) }; const USIZE_SIZE: usize = size_of::(); @@ -1512,15 +1507,15 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { Ok(Operand::from_concrete_const(bytes, MemoryMap::default(), ty)) } - fn new_basic_block(&mut self) -> BasicBlockId<'db> { + fn new_basic_block(&mut self) -> BasicBlockId { self.result.basic_blocks.alloc(BasicBlock::default()) } fn lower_const( &mut self, const_id: GeneralConstId, - prev_block: BasicBlockId<'db>, - place: Place<'db>, + prev_block: BasicBlockId, + place: Place, subst: GenericArgs<'db>, span: MirSpan, ) -> Result<'db, ()> { @@ -1533,8 +1528,8 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { &mut self, subst: GenericArgs<'db>, const_id: GeneralConstId, - ) -> Result<'db, Operand<'db>> { - let konst = if subst.len() != 0 { + ) -> Result<'db, Operand> { + let konst = if !subst.is_empty() { // We can't evaluate constant with substitution now, as generics are not monomorphized in lowering. Const::new_unevaluated( self.interner(), @@ -1564,13 +1559,16 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { }) .unwrap() .instantiate(self.interner(), subst); - Ok(Operand { kind: OperandKind::Constant { konst, ty }, span: None }) + Ok(Operand { + kind: OperandKind::Constant { konst: konst.store(), ty: ty.store() }, + span: None, + }) } fn write_bytes_to_place( &mut self, - prev_block: BasicBlockId<'db>, - place: Place<'db>, + prev_block: BasicBlockId, + place: Place, cv: Box<[u8]>, ty: Ty<'db>, span: MirSpan, @@ -1582,12 +1580,12 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_enum_variant( &mut self, variant_id: EnumVariantId, - prev_block: BasicBlockId<'db>, - place: Place<'db>, + prev_block: BasicBlockId, + place: Place, ty: Ty<'db>, - fields: Box<[Operand<'db>]>, + fields: Box<[Operand]>, span: MirSpan, - ) -> Result<'db, BasicBlockId<'db>> { + ) -> Result<'db, BasicBlockId> { let subst = match ty.kind() { TyKind::Adt(_, subst) => subst, _ => implementation_error!("Non ADT enum"), @@ -1595,7 +1593,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { self.push_assignment( prev_block, place, - Rvalue::Aggregate(AggregateKind::Adt(variant_id.into(), subst), fields), + Rvalue::Aggregate(AggregateKind::Adt(variant_id.into(), subst.store()), fields), span, ); Ok(prev_block) @@ -1603,13 +1601,13 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_call_and_args( &mut self, - func: Operand<'db>, + func: Operand, args: impl Iterator, - place: Place<'db>, - mut current: BasicBlockId<'db>, + place: Place, + mut current: BasicBlockId, is_uninhabited: bool, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { let Some(args) = args .map(|arg| { if let Some((temp, c)) = self.lower_expr_to_some_operand(arg, current)? { @@ -1628,13 +1626,13 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_call( &mut self, - func: Operand<'db>, - args: Box<[Operand<'db>]>, - place: Place<'db>, - current: BasicBlockId<'db>, + func: Operand, + args: Box<[Operand]>, + place: Place, + current: BasicBlockId, is_uninhabited: bool, span: MirSpan, - ) -> Result<'db, Option>> { + ) -> Result<'db, Option> { let b = if is_uninhabited { None } else { Some(self.new_basic_block()) }; self.set_terminator( current, @@ -1651,25 +1649,20 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { Ok(b) } - fn is_unterminated(&mut self, source: BasicBlockId<'db>) -> bool { + fn is_unterminated(&mut self, source: BasicBlockId) -> bool { self.result.basic_blocks[source].terminator.is_none() } - fn set_terminator( - &mut self, - source: BasicBlockId<'db>, - terminator: TerminatorKind<'db>, - span: MirSpan, - ) { + fn set_terminator(&mut self, source: BasicBlockId, terminator: TerminatorKind, span: MirSpan) { self.result.basic_blocks[source].terminator = Some(Terminator { span, kind: terminator }); } - fn set_goto(&mut self, source: BasicBlockId<'db>, target: BasicBlockId<'db>, span: MirSpan) { + fn set_goto(&mut self, source: BasicBlockId, target: BasicBlockId, span: MirSpan) { self.set_terminator(source, TerminatorKind::Goto { target }, span); } fn expr_ty_without_adjust(&self, e: ExprId) -> Ty<'db> { - self.infer[e] + self.infer.expr_ty(e) } fn expr_ty_after_adjustments(&self, e: ExprId) -> Ty<'db> { @@ -1677,36 +1670,36 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { if let Some(it) = self.infer.expr_adjustments.get(&e) && let Some(it) = it.last() { - ty = Some(it.target); + ty = Some(it.target.as_ref()); } ty.unwrap_or_else(|| self.expr_ty_without_adjust(e)) } - fn push_statement(&mut self, block: BasicBlockId<'db>, statement: Statement<'db>) { + fn push_statement(&mut self, block: BasicBlockId, statement: Statement) { self.result.basic_blocks[block].statements.push(statement); } - fn push_fake_read(&mut self, block: BasicBlockId<'db>, p: Place<'db>, span: MirSpan) { + fn push_fake_read(&mut self, block: BasicBlockId, p: Place, span: MirSpan) { self.push_statement(block, StatementKind::FakeRead(p).with_span(span)); } fn push_assignment( &mut self, - block: BasicBlockId<'db>, - place: Place<'db>, - rvalue: Rvalue<'db>, + block: BasicBlockId, + place: Place, + rvalue: Rvalue, span: MirSpan, ) { self.push_statement(block, StatementKind::Assign(place, rvalue).with_span(span)); } - fn discr_temp_place(&mut self, current: BasicBlockId<'db>) -> Place<'db> { + fn discr_temp_place(&mut self, current: BasicBlockId) -> Place { match &self.discr_temp { Some(it) => *it, None => { // FIXME: rustc's ty is dependent on the adt type, maybe we need to do that as well let discr_ty = Ty::new_int(self.interner(), rustc_type_ir::IntTy::I128); - let tmp: Place<'db> = self + let tmp: Place = self .temp(discr_ty, current, MirSpan::Unknown) .expect("discr_ty is never unsized") .into(); @@ -1718,12 +1711,12 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_loop( &mut self, - prev_block: BasicBlockId<'db>, - place: Place<'db>, + prev_block: BasicBlockId, + place: Place, label: Option, span: MirSpan, - f: impl FnOnce(&mut MirLowerCtx<'_, 'db>, BasicBlockId<'db>) -> Result<'db, ()>, - ) -> Result<'db, Option>> { + f: impl FnOnce(&mut MirLowerCtx<'_, 'db>, BasicBlockId) -> Result<'db, ()>, + ) -> Result<'db, Option> { let begin = self.new_basic_block(); let prev = self.current_loop_blocks.replace(LoopBlocks { begin, @@ -1758,10 +1751,10 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn merge_blocks( &mut self, - b1: Option>, - b2: Option>, + b1: Option, + b2: Option, span: MirSpan, - ) -> Option> { + ) -> Option { match (b1, b2) { (None, None) => None, (None, Some(b)) | (Some(b), None) => Some(b), @@ -1774,7 +1767,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { } } - fn current_loop_end(&mut self) -> Result<'db, BasicBlockId<'db>> { + fn current_loop_end(&mut self) -> Result<'db, BasicBlockId> { let r = match self .current_loop_blocks .as_mut() @@ -1801,7 +1794,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn is_uninhabited(&self, expr_id: ExprId) -> bool { is_ty_uninhabited_from( &self.infcx, - self.infer[expr_id], + self.infer.expr_ty(expr_id), self.owner.module(self.db), self.env, ) @@ -1809,15 +1802,15 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { /// This function push `StorageLive` statement for the binding, and applies changes to add `StorageDead` and /// `Drop` in the appropriated places. - fn push_storage_live(&mut self, b: BindingId, current: BasicBlockId<'db>) -> Result<'db, ()> { + fn push_storage_live(&mut self, b: BindingId, current: BasicBlockId) -> Result<'db, ()> { let l = self.binding_local(b)?; self.push_storage_live_for_local(l, current, MirSpan::BindingId(b)) } fn push_storage_live_for_local( &mut self, - l: LocalId<'db>, - current: BasicBlockId<'db>, + l: LocalId, + current: BasicBlockId, span: MirSpan, ) -> Result<'db, ()> { self.drop_scopes.last_mut().unwrap().locals.push(l); @@ -1828,11 +1821,11 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn lower_block_to_place( &mut self, statements: &[hir_def::hir::Statement], - mut current: BasicBlockId<'db>, + mut current: BasicBlockId, tail: Option, - place: Place<'db>, + place: Place, span: MirSpan, - ) -> Result<'db, Option>>> { + ) -> Result<'db, Option>> { let scope = self.push_drop_scope(); for statement in statements.iter() { match statement { @@ -1908,11 +1901,11 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { params: impl Iterator)> + Clone, self_binding: Option<(BindingId, Ty<'db>)>, pick_binding: impl Fn(BindingId) -> bool, - ) -> Result<'db, BasicBlockId<'db>> { + ) -> Result<'db, BasicBlockId> { let base_param_count = self.result.param_locals.len(); let self_binding = match self_binding { Some((self_binding, ty)) => { - let local_id = self.result.locals.alloc(Local { ty }); + let local_id = self.result.locals.alloc(Local { ty: ty.store() }); self.drop_scopes.last_mut().unwrap().locals.push(local_id); self.result.binding_locals.insert(self_binding, local_id); self.result.param_locals.push(local_id); @@ -1921,7 +1914,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { None => None, }; self.result.param_locals.extend(params.clone().map(|(it, ty)| { - let local_id = self.result.locals.alloc(Local { ty }); + let local_id = self.result.locals.alloc(Local { ty: ty.store() }); self.drop_scopes.last_mut().unwrap().locals.push(local_id); if let Pat::Bind { id, subpat: None } = self.body[it] && matches!( @@ -1939,9 +1932,10 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { continue; } if !self.result.binding_locals.contains_idx(id) { - self.result - .binding_locals - .insert(id, self.result.locals.alloc(Local { ty: self.infer[id] })); + self.result.binding_locals.insert( + id, + self.result.locals.alloc(Local { ty: self.infer.binding_ty(id).store() }), + ); } } let mut current = self.result.start_block; @@ -1976,7 +1970,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { Ok(current) } - fn binding_local(&self, b: BindingId) -> Result<'db, LocalId<'db>> { + fn binding_local(&self, b: BindingId) -> Result<'db, LocalId> { match self.result.binding_locals.get(b) { Some(it) => Ok(*it), None => { @@ -2025,9 +2019,9 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn drop_until_scope( &mut self, scope_index: usize, - mut current: BasicBlockId<'db>, + mut current: BasicBlockId, span: MirSpan, - ) -> BasicBlockId<'db> { + ) -> BasicBlockId { for scope in self.drop_scopes[scope_index..].to_vec().iter().rev() { self.emit_drop_and_storage_dead_for_scope(scope, &mut current, span); } @@ -2047,9 +2041,9 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { /// Don't call directly fn pop_drop_scope_internal( &mut self, - mut current: BasicBlockId<'db>, + mut current: BasicBlockId, span: MirSpan, - ) -> BasicBlockId<'db> { + ) -> BasicBlockId { let scope = self.drop_scopes.pop().unwrap(); self.emit_drop_and_storage_dead_for_scope(&scope, &mut current, span); current @@ -2057,9 +2051,9 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn pop_drop_scope_assert_finished( &mut self, - mut current: BasicBlockId<'db>, + mut current: BasicBlockId, span: MirSpan, - ) -> Result<'db, BasicBlockId<'db>> { + ) -> Result<'db, BasicBlockId> { current = self.pop_drop_scope_internal(current, span); if !self.drop_scopes.is_empty() { implementation_error!("Mismatched count between drop scope push and pops"); @@ -2069,12 +2063,13 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { fn emit_drop_and_storage_dead_for_scope( &mut self, - scope: &DropScope<'db>, - current: &mut Idx>, + scope: &DropScope, + current: &mut Idx, span: MirSpan, ) { for &l in scope.locals.iter().rev() { - if !self.infcx.type_is_copy_modulo_regions(self.env, self.result.locals[l].ty) { + if !self.infcx.type_is_copy_modulo_regions(self.env, self.result.locals[l].ty.as_ref()) + { let prev = std::mem::replace(current, self.new_basic_block()); self.set_terminator( prev, @@ -2112,36 +2107,37 @@ fn cast_kind<'db>( pub fn mir_body_for_closure_query<'db>( db: &'db dyn HirDatabase, closure: InternedClosureId, -) -> Result<'db, Arc>> { +) -> Result<'db, Arc> { let InternedClosure(owner, expr) = db.lookup_intern_closure(closure); let body = db.body(owner); let infer = InferenceResult::for_body(db, owner); let Expr::Closure { args, body: root, .. } = &body[expr] else { implementation_error!("closure expression is not closure"); }; - let crate::next_solver::TyKind::Closure(_, substs) = infer[expr].kind() else { + let crate::next_solver::TyKind::Closure(_, substs) = infer.expr_ty(expr).kind() else { implementation_error!("closure expression is not closure"); }; let (captures, kind) = infer.closure_info(closure); let mut ctx = MirLowerCtx::new(db, owner, &body, infer); // 0 is return local - ctx.result.locals.alloc(Local { ty: infer[*root] }); + ctx.result.locals.alloc(Local { ty: infer.expr_ty(*root).store() }); let closure_local = ctx.result.locals.alloc(Local { ty: match kind { - FnTrait::FnOnce | FnTrait::AsyncFnOnce => infer[expr], + FnTrait::FnOnce | FnTrait::AsyncFnOnce => infer.expr_ty(expr), FnTrait::FnMut | FnTrait::AsyncFnMut => Ty::new_ref( ctx.interner(), Region::error(ctx.interner()), - infer[expr], + infer.expr_ty(expr), Mutability::Mut, ), FnTrait::Fn | FnTrait::AsyncFn => Ty::new_ref( ctx.interner(), Region::error(ctx.interner()), - infer[expr], + infer.expr_ty(expr), Mutability::Not, ), - }, + } + .store(), }); ctx.result.param_locals.push(closure_local); let Some(sig) = @@ -2160,8 +2156,7 @@ pub fn mir_body_for_closure_query<'db>( let current = ctx.pop_drop_scope_assert_finished(current, root.into())?; ctx.set_terminator(current, TerminatorKind::Return, (*root).into()); } - let mut upvar_map: FxHashMap, Vec<(&CapturedItem<'_>, usize)>> = - FxHashMap::default(); + let mut upvar_map: FxHashMap> = FxHashMap::default(); for (i, capture) in captures.iter().enumerate() { let local = ctx.binding_local(capture.place.local)?; upvar_map.entry(local).or_default().push((capture, i)); @@ -2226,7 +2221,7 @@ pub fn mir_body_for_closure_query<'db>( pub fn mir_body_query<'db>( db: &'db dyn HirDatabase, def: DefWithBodyId, -) -> Result<'db, Arc>> { +) -> Result<'db, Arc> { let krate = def.krate(db); let edition = krate.data(db).edition; let detail = match def { @@ -2263,7 +2258,7 @@ pub(crate) fn mir_body_cycle_result<'db>( _db: &'db dyn HirDatabase, _: salsa::Id, _def: DefWithBodyId, -) -> Result<'db, Arc>> { +) -> Result<'db, Arc> { Err(MirLowerError::Loop) } @@ -2271,17 +2266,17 @@ pub fn lower_to_mir<'db>( db: &'db dyn HirDatabase, owner: DefWithBodyId, body: &Body, - infer: &InferenceResult<'db>, + infer: &InferenceResult, // FIXME: root_expr should always be the body.body_expr, but since `X` in `[(); X]` doesn't have its own specific body yet, we // need to take this input explicitly. root_expr: ExprId, -) -> Result<'db, MirBody<'db>> { +) -> Result<'db, MirBody> { if infer.type_mismatches().next().is_some() || infer.is_erroneous() { return Err(MirLowerError::HasErrors); } let mut ctx = MirLowerCtx::new(db, owner, body, infer); // 0 is return local - ctx.result.locals.alloc(Local { ty: ctx.expr_ty_after_adjustments(root_expr) }); + ctx.result.locals.alloc(Local { ty: ctx.expr_ty_after_adjustments(root_expr).store() }); let binding_picker = |b: BindingId| { let owner = ctx.body.binding_owner(b); if root_expr == body.body_expr { owner.is_none() } else { owner == Some(root_expr) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs index 40c6c5de795a..cf05ec27ac37 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/as_place.rs @@ -20,8 +20,8 @@ impl<'db> MirLowerCtx<'_, 'db> { fn lower_expr_to_some_place_without_adjust( &mut self, expr_id: ExprId, - prev_block: BasicBlockId<'db>, - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + prev_block: BasicBlockId, + ) -> Result<'db, Option<(Place, BasicBlockId)>> { let ty = self.expr_ty_without_adjust(expr_id); let place = self.temp(ty, prev_block, expr_id.into())?; let Some(current) = @@ -35,12 +35,12 @@ impl<'db> MirLowerCtx<'_, 'db> { fn lower_expr_to_some_place_with_adjust( &mut self, expr_id: ExprId, - prev_block: BasicBlockId<'db>, - adjustments: &[Adjustment<'db>], - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + prev_block: BasicBlockId, + adjustments: &[Adjustment], + ) -> Result<'db, Option<(Place, BasicBlockId)>> { let ty = adjustments .last() - .map(|it| it.target) + .map(|it| it.target.as_ref()) .unwrap_or_else(|| self.expr_ty_without_adjust(expr_id)); let place = self.temp(ty, prev_block, expr_id.into())?; let Some(current) = @@ -53,11 +53,11 @@ impl<'db> MirLowerCtx<'_, 'db> { pub(super) fn lower_expr_as_place_with_adjust( &mut self, - current: BasicBlockId<'db>, + current: BasicBlockId, expr_id: ExprId, upgrade_rvalue: bool, - adjustments: &[Adjustment<'db>], - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + adjustments: &[Adjustment], + ) -> Result<'db, Option<(Place, BasicBlockId)>> { let try_rvalue = |this: &mut MirLowerCtx<'_, 'db>| { if !upgrade_rvalue { return Err(MirLowerError::MutatingRvalue); @@ -93,9 +93,9 @@ impl<'db> MirLowerCtx<'_, 'db> { current, r, rest.last() - .map(|it| it.target) + .map(|it| it.target.as_ref()) .unwrap_or_else(|| self.expr_ty_without_adjust(expr_id)), - last.target, + last.target.as_ref(), expr_id.into(), match od.0 { Some(Mutability::Mut) => true, @@ -115,10 +115,10 @@ impl<'db> MirLowerCtx<'_, 'db> { pub(super) fn lower_expr_as_place( &mut self, - current: BasicBlockId<'db>, + current: BasicBlockId, expr_id: ExprId, upgrade_rvalue: bool, - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + ) -> Result<'db, Option<(Place, BasicBlockId)>> { match self.infer.expr_adjustments.get(&expr_id) { Some(a) => self.lower_expr_as_place_with_adjust(current, expr_id, upgrade_rvalue, a), None => self.lower_expr_as_place_without_adjust(current, expr_id, upgrade_rvalue), @@ -127,10 +127,10 @@ impl<'db> MirLowerCtx<'_, 'db> { pub(super) fn lower_expr_as_place_without_adjust( &mut self, - current: BasicBlockId<'db>, + current: BasicBlockId, expr_id: ExprId, upgrade_rvalue: bool, - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + ) -> Result<'db, Option<(Place, BasicBlockId)>> { let try_rvalue = |this: &mut MirLowerCtx<'_, 'db>| { if !upgrade_rvalue { return Err(MirLowerError::MutatingRvalue); @@ -159,7 +159,7 @@ impl<'db> MirLowerCtx<'_, 'db> { ty, Mutability::Not, ); - let temp: Place<'db> = self.temp(ref_ty, current, expr_id.into())?.into(); + let temp: Place = self.temp(ref_ty, current, expr_id.into())?.into(); self.push_assignment( current, temp, @@ -279,21 +279,21 @@ impl<'db> MirLowerCtx<'_, 'db> { fn lower_overloaded_index( &mut self, - current: BasicBlockId<'db>, - place: Place<'db>, + current: BasicBlockId, + place: Place, base_ty: Ty<'db>, result_ty: Ty<'db>, - index_operand: Operand<'db>, + index_operand: Operand, span: MirSpan, index_fn: (FunctionId, GenericArgs<'db>), - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + ) -> Result<'db, Option<(Place, BasicBlockId)>> { let mutability = match base_ty.as_reference() { Some((_, _, mutability)) => mutability, None => Mutability::Not, }; let result_ref = Ty::new_ref(self.interner(), Region::error(self.interner()), result_ty, mutability); - let mut result: Place<'db> = self.temp(result_ref, current, span)?.into(); + let mut result: Place = self.temp(result_ref, current, span)?.into(); let index_fn_op = Operand::const_zst(Ty::new_fn_def( self.interner(), CallableDefId::FunctionId(index_fn.0).into(), @@ -316,13 +316,13 @@ impl<'db> MirLowerCtx<'_, 'db> { fn lower_overloaded_deref( &mut self, - current: BasicBlockId<'db>, - place: Place<'db>, + current: BasicBlockId, + place: Place, source_ty: Ty<'db>, target_ty: Ty<'db>, span: MirSpan, mutability: bool, - ) -> Result<'db, Option<(Place<'db>, BasicBlockId<'db>)>> { + ) -> Result<'db, Option<(Place, BasicBlockId)>> { let lang_items = self.lang_items(); let (mutability, trait_lang_item, trait_method_name, borrow_kind) = if !mutability { ( @@ -342,7 +342,7 @@ impl<'db> MirLowerCtx<'_, 'db> { let error_region = Region::error(self.interner()); let ty_ref = Ty::new_ref(self.interner(), error_region, source_ty, mutability); let target_ty_ref = Ty::new_ref(self.interner(), error_region, target_ty, mutability); - let ref_place: Place<'db> = self.temp(ty_ref, current, span)?.into(); + let ref_place: Place = self.temp(ty_ref, current, span)?.into(); self.push_assignment(current, ref_place, Rvalue::Ref(borrow_kind, place), span); let deref_trait = trait_lang_item.ok_or(MirLowerError::LangItemNotFound)?; let deref_fn = deref_trait @@ -352,9 +352,9 @@ impl<'db> MirLowerCtx<'_, 'db> { let deref_fn_op = Operand::const_zst(Ty::new_fn_def( self.interner(), CallableDefId::FunctionId(deref_fn).into(), - GenericArgs::new_from_iter(self.interner(), [source_ty.into()]), + GenericArgs::new_from_slice(&[source_ty.into()]), )); - let mut result: Place<'db> = self.temp(target_ty_ref, current, span)?.into(); + let mut result: Place = self.temp(target_ty_ref, current, span)?.into(); let Some(current) = self.lower_call( deref_fn_op, Box::new([Operand { kind: OperandKind::Copy(ref_place), span: None }]), diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs index c3a4814a3ab4..a8aacbff16fa 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower/pattern_matching.rs @@ -1,7 +1,7 @@ //! MIR lowering for patterns use hir_def::{hir::ExprId, signatures::VariantFields}; -use rustc_type_ir::inherent::{IntoKind, SliceLike, Ty as _}; +use rustc_type_ir::inherent::{IntoKind, Ty as _}; use crate::{ BindingMode, @@ -63,11 +63,11 @@ impl<'db> MirLowerCtx<'_, 'db> { /// so it should be an empty block. pub(super) fn pattern_match( &mut self, - current: BasicBlockId<'db>, - current_else: Option>, - cond_place: Place<'db>, + current: BasicBlockId, + current_else: Option, + cond_place: Place, pattern: PatId, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { let (current, current_else) = self.pattern_match_inner( current, current_else, @@ -87,10 +87,10 @@ impl<'db> MirLowerCtx<'_, 'db> { pub(super) fn pattern_match_assignment( &mut self, - current: BasicBlockId<'db>, - value: Place<'db>, + current: BasicBlockId, + value: Place, pattern: PatId, - ) -> Result<'db, BasicBlockId<'db>> { + ) -> Result<'db, BasicBlockId> { let (current, _) = self.pattern_match_inner(current, None, value, pattern, MatchingMode::Assign)?; Ok(current) @@ -99,9 +99,9 @@ impl<'db> MirLowerCtx<'_, 'db> { pub(super) fn match_self_param( &mut self, id: BindingId, - current: BasicBlockId<'db>, - local: LocalId<'db>, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + current: BasicBlockId, + local: LocalId, + ) -> Result<'db, (BasicBlockId, Option)> { self.pattern_match_binding( id, BindingMode::Move, @@ -114,12 +114,12 @@ impl<'db> MirLowerCtx<'_, 'db> { fn pattern_match_inner( &mut self, - mut current: BasicBlockId<'db>, - mut current_else: Option>, - mut cond_place: Place<'db>, + mut current: BasicBlockId, + mut current_else: Option, + mut cond_place: Place, pattern: PatId, mode: MatchingMode, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { let cnt = self.infer.pat_adjustments.get(&pattern).map(|x| x.len()).unwrap_or_default(); cond_place.projection = self.result.projection_store.intern( cond_place @@ -135,7 +135,7 @@ impl<'db> MirLowerCtx<'_, 'db> { Pat::Missing => return Err(MirLowerError::IncompletePattern), Pat::Wild => (current, current_else), Pat::Tuple { args, ellipsis } => { - let subst = match self.infer[pattern].kind() { + let subst = match self.infer.pat_ty(pattern).kind() { TyKind::Tuple(s) => s, _ => { return Err(MirLowerError::TypeError( @@ -209,10 +209,11 @@ impl<'db> MirLowerCtx<'_, 'db> { } Pat::Range { start, end, range_type: _ } => { let mut add_check = |l: &ExprId, binop| -> Result<'db, ()> { - let lv = self.lower_literal_or_const_to_operand(self.infer[pattern], l)?; + let lv = + self.lower_literal_or_const_to_operand(self.infer.pat_ty(pattern), l)?; let else_target = *current_else.get_or_insert_with(|| self.new_basic_block()); let next = self.new_basic_block(); - let discr: Place<'db> = + let discr: Place = self.temp(Ty::new_bool(self.interner()), current, pattern.into())?.into(); self.push_assignment( current, @@ -249,9 +250,9 @@ impl<'db> MirLowerCtx<'_, 'db> { Pat::Slice { prefix, slice, suffix } => { if mode == MatchingMode::Check { // emit runtime length check for slice - if let TyKind::Slice(_) = self.infer[pattern].kind() { + if let TyKind::Slice(_) = self.infer.pat_ty(pattern).kind() { let pattern_len = prefix.len() + suffix.len(); - let place_len: Place<'db> = self + let place_len: Place = self .temp(Ty::new_usize(self.interner()), current, pattern.into())? .into(); self.push_assignment( @@ -285,7 +286,7 @@ impl<'db> MirLowerCtx<'_, 'db> { MemoryMap::default(), Ty::new_usize(self.interner()), ); - let discr: Place<'db> = self + let discr: Place = self .temp(Ty::new_bool(self.interner()), current, pattern.into())? .into(); self.push_assignment( @@ -398,15 +399,15 @@ impl<'db> MirLowerCtx<'_, 'db> { break 'b (c, x.1); } if let ResolveValueResult::ValueNs(ValueNs::ConstId(c), _) = pr { - break 'b (c, GenericArgs::new_from_iter(self.interner(), [])); + break 'b (c, GenericArgs::empty(self.interner())); } not_supported!("path in pattern position that is not const or variant") }; - let tmp: Place<'db> = - self.temp(self.infer[pattern], current, pattern.into())?.into(); + let tmp: Place = + self.temp(self.infer.pat_ty(pattern), current, pattern.into())?.into(); let span = pattern.into(); self.lower_const(c.into(), current, tmp, subst, span)?; - let tmp2: Place<'db> = + let tmp2: Place = self.temp(Ty::new_bool(self.interner()), current, pattern.into())?.into(); self.push_assignment( current, @@ -434,7 +435,7 @@ impl<'db> MirLowerCtx<'_, 'db> { Pat::Lit(l) => match &self.body[*l] { Expr::Literal(l) => { if mode == MatchingMode::Check { - let c = self.lower_literal_to_operand(self.infer[pattern], l)?; + let c = self.lower_literal_to_operand(self.infer.pat_ty(pattern), l)?; self.pattern_match_const(current_else, current, c, cond_place, pattern)? } else { (current, current_else) @@ -506,11 +507,11 @@ impl<'db> MirLowerCtx<'_, 'db> { &mut self, id: BindingId, mode: BindingMode, - cond_place: Place<'db>, + cond_place: Place, span: MirSpan, - current: BasicBlockId<'db>, - current_else: Option>, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + current: BasicBlockId, + current_else: Option, + ) -> Result<'db, (BasicBlockId, Option)> { let target_place = self.binding_local(id)?; self.push_storage_live(id, current)?; self.push_match_assignment(current, target_place, mode, cond_place, span); @@ -519,10 +520,10 @@ impl<'db> MirLowerCtx<'_, 'db> { fn push_match_assignment( &mut self, - current: BasicBlockId<'db>, - target_place: LocalId<'db>, + current: BasicBlockId, + target_place: LocalId, mode: BindingMode, - cond_place: Place<'db>, + cond_place: Place, span: MirSpan, ) { self.push_assignment( @@ -545,15 +546,15 @@ impl<'db> MirLowerCtx<'_, 'db> { fn pattern_match_const( &mut self, - current_else: Option>, - current: BasicBlockId<'db>, - c: Operand<'db>, - cond_place: Place<'db>, + current_else: Option, + current: BasicBlockId, + c: Operand, + cond_place: Place, pattern: Idx, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { let then_target = self.new_basic_block(); let else_target = current_else.unwrap_or_else(|| self.new_basic_block()); - let discr: Place<'db> = + let discr: Place = self.temp(Ty::new_bool(self.interner()), current, pattern.into())?.into(); self.push_assignment( current, @@ -579,14 +580,14 @@ impl<'db> MirLowerCtx<'_, 'db> { fn pattern_matching_variant( &mut self, - cond_place: Place<'db>, + cond_place: Place, variant: VariantId, - mut current: BasicBlockId<'db>, + mut current: BasicBlockId, span: MirSpan, - mut current_else: Option>, + mut current_else: Option, shape: AdtPatternShape<'_>, mode: MatchingMode, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { Ok(match variant { VariantId::EnumVariantId(v) => { if mode == MatchingMode::Check { @@ -635,11 +636,11 @@ impl<'db> MirLowerCtx<'_, 'db> { shape: AdtPatternShape<'_>, variant_data: &VariantFields, v: VariantId, - current: BasicBlockId<'db>, - current_else: Option>, - cond_place: &Place<'db>, + current: BasicBlockId, + current_else: Option, + cond_place: &Place, mode: MatchingMode, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { Ok(match shape { AdtPatternShape::Record { args } => { let it = args @@ -678,12 +679,12 @@ impl<'db> MirLowerCtx<'_, 'db> { fn pattern_match_adt( &mut self, - mut current: BasicBlockId<'db>, - mut current_else: Option>, - args: impl Iterator, PatId)>, - cond_place: &Place<'db>, + mut current: BasicBlockId, + mut current_else: Option, + args: impl Iterator, + cond_place: &Place, mode: MatchingMode, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { for (proj, arg) in args { let cond_place = cond_place.project(proj, &mut self.result.projection_store); (current, current_else) = @@ -694,14 +695,14 @@ impl<'db> MirLowerCtx<'_, 'db> { fn pattern_match_tuple_like( &mut self, - current: BasicBlockId<'db>, - current_else: Option>, + current: BasicBlockId, + current_else: Option, args: &[PatId], ellipsis: Option, - fields: impl DoubleEndedIterator> + Clone, - cond_place: &Place<'db>, + fields: impl DoubleEndedIterator + Clone, + cond_place: &Place, mode: MatchingMode, - ) -> Result<'db, (BasicBlockId<'db>, Option>)> { + ) -> Result<'db, (BasicBlockId, Option)> { let (al, ar) = args.split_at(ellipsis.map_or(args.len(), |it| it as usize)); let it = al .iter() diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs index beb0003c31ca..5752a3d7fae4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/monomorphization.rs @@ -8,7 +8,7 @@ //! So the monomorphization should be called even if the substitution is empty. use hir_def::DefWithBodyId; -use rustc_type_ir::inherent::{IntoKind, SliceLike}; +use rustc_type_ir::inherent::IntoKind; use rustc_type_ir::{ FallibleTypeFolder, TypeFlags, TypeFoldable, TypeSuperFoldable, TypeVisitableExt, }; @@ -16,7 +16,8 @@ use triomphe::Arc; use crate::{ ParamEnvAndCrate, - next_solver::{Const, ConstKind, Region, RegionKind}, + next_solver::{Const, ConstKind, Region, RegionKind, StoredConst, StoredGenericArgs, StoredTy}, + traits::StoredParamEnvAndCrate, }; use crate::{ db::{HirDatabase, InternedClosureId}, @@ -37,7 +38,7 @@ struct Filler<'db> { } impl<'db> FallibleTypeFolder> for Filler<'db> { - type Error = MirLowerError<'db>; + type Error = MirLowerError; fn cx(&self) -> DbInterner<'db> { self.infcx.interner @@ -69,7 +70,7 @@ impl<'db> FallibleTypeFolder> for Filler<'db> { .get(param.index as usize) .and_then(|arg| arg.ty()) .ok_or_else(|| { - MirLowerError::GenericArgNotProvided(param.id.into(), self.subst) + MirLowerError::GenericArgNotProvided(param.id.into(), self.subst.store()) })?), _ => ty.try_super_fold_with(self), } @@ -79,22 +80,18 @@ impl<'db> FallibleTypeFolder> for Filler<'db> { let ConstKind::Param(param) = ct.kind() else { return ct.try_super_fold_with(self); }; - self.subst - .as_slice() - .get(param.index as usize) - .and_then(|arg| arg.konst()) - .ok_or_else(|| MirLowerError::GenericArgNotProvided(param.id.into(), self.subst)) + self.subst.as_slice().get(param.index as usize).and_then(|arg| arg.konst()).ok_or_else( + || MirLowerError::GenericArgNotProvided(param.id.into(), self.subst.store()), + ) } fn try_fold_region(&mut self, region: Region<'db>) -> Result, Self::Error> { let RegionKind::ReEarlyParam(param) = region.kind() else { return Ok(region); }; - self.subst - .as_slice() - .get(param.index as usize) - .and_then(|arg| arg.region()) - .ok_or_else(|| MirLowerError::GenericArgNotProvided(param.id.into(), self.subst)) + self.subst.as_slice().get(param.index as usize).and_then(|arg| arg.region()).ok_or_else( + || MirLowerError::GenericArgNotProvided(param.id.into(), self.subst.store()), + ) } } @@ -105,33 +102,50 @@ impl<'db> Filler<'db> { Self { infcx, trait_env: env, subst } } - fn fill> + Copy>( - &mut self, - t: &mut T, - ) -> Result<(), MirLowerError<'db>> { + fn fill_ty(&mut self, t: &mut StoredTy) -> Result<(), MirLowerError> { // Can't deep normalized as that'll try to normalize consts and fail. - *t = t.try_fold_with(self)?; - if references_non_lt_error(t) { + *t = t.as_ref().try_fold_with(self)?.store(); + if references_non_lt_error(&t.as_ref()) { Err(MirLowerError::NotSupported("monomorphization resulted in errors".to_owned())) } else { Ok(()) } } - fn fill_operand(&mut self, op: &mut Operand<'db>) -> Result<(), MirLowerError<'db>> { + fn fill_const(&mut self, t: &mut StoredConst) -> Result<(), MirLowerError> { + // Can't deep normalized as that'll try to normalize consts and fail. + *t = t.as_ref().try_fold_with(self)?.store(); + if references_non_lt_error(&t.as_ref()) { + Err(MirLowerError::NotSupported("monomorphization resulted in errors".to_owned())) + } else { + Ok(()) + } + } + + fn fill_args(&mut self, t: &mut StoredGenericArgs) -> Result<(), MirLowerError> { + // Can't deep normalized as that'll try to normalize consts and fail. + *t = t.as_ref().try_fold_with(self)?.store(); + if references_non_lt_error(&t.as_ref()) { + Err(MirLowerError::NotSupported("monomorphization resulted in errors".to_owned())) + } else { + Ok(()) + } + } + + fn fill_operand(&mut self, op: &mut Operand) -> Result<(), MirLowerError> { match &mut op.kind { OperandKind::Constant { konst, ty } => { - self.fill(konst)?; - self.fill(ty)?; + self.fill_const(konst)?; + self.fill_ty(ty)?; } OperandKind::Copy(_) | OperandKind::Move(_) | OperandKind::Static(_) => (), } Ok(()) } - fn fill_body(&mut self, body: &mut MirBody<'db>) -> Result<(), MirLowerError<'db>> { + fn fill_body(&mut self, body: &mut MirBody) -> Result<(), MirLowerError> { for (_, l) in body.locals.iter_mut() { - self.fill(&mut l.ty)?; + self.fill_ty(&mut l.ty)?; } for (_, bb) in body.basic_blocks.iter_mut() { for statement in &mut bb.statements { @@ -144,20 +158,20 @@ impl<'db> Filler<'db> { match ak { super::AggregateKind::Array(ty) | super::AggregateKind::Tuple(ty) - | super::AggregateKind::Closure(ty) => self.fill(ty)?, - super::AggregateKind::Adt(_, subst) => self.fill(subst)?, + | super::AggregateKind::Closure(ty) => self.fill_ty(ty)?, + super::AggregateKind::Adt(_, subst) => self.fill_args(subst)?, super::AggregateKind::Union(_, _) => (), } } Rvalue::ShallowInitBox(_, ty) | Rvalue::ShallowInitBoxWithAlloc(ty) => { - self.fill(ty)?; + self.fill_ty(ty)?; } Rvalue::Use(op) => { self.fill_operand(op)?; } Rvalue::Repeat(op, len) => { self.fill_operand(op)?; - self.fill(len)?; + self.fill_const(len)?; } Rvalue::Ref(_, _) | Rvalue::Len(_) @@ -208,36 +222,36 @@ impl<'db> Filler<'db> { } } -pub fn monomorphized_mir_body_query<'db>( - db: &'db dyn HirDatabase, +pub fn monomorphized_mir_body_query( + db: &dyn HirDatabase, owner: DefWithBodyId, - subst: GenericArgs<'db>, - trait_env: ParamEnvAndCrate<'db>, -) -> Result>, MirLowerError<'db>> { - let mut filler = Filler::new(db, trait_env, subst); + subst: StoredGenericArgs, + trait_env: StoredParamEnvAndCrate, +) -> Result, MirLowerError> { + let mut filler = Filler::new(db, trait_env.as_ref(), subst.as_ref()); let body = db.mir_body(owner)?; let mut body = (*body).clone(); filler.fill_body(&mut body)?; Ok(Arc::new(body)) } -pub(crate) fn monomorphized_mir_body_cycle_result<'db>( - _db: &'db dyn HirDatabase, +pub(crate) fn monomorphized_mir_body_cycle_result( + _db: &dyn HirDatabase, _: salsa::Id, _: DefWithBodyId, - _: GenericArgs<'db>, - _: ParamEnvAndCrate<'db>, -) -> Result>, MirLowerError<'db>> { + _: StoredGenericArgs, + _: StoredParamEnvAndCrate, +) -> Result, MirLowerError> { Err(MirLowerError::Loop) } -pub fn monomorphized_mir_body_for_closure_query<'db>( - db: &'db dyn HirDatabase, +pub fn monomorphized_mir_body_for_closure_query( + db: &dyn HirDatabase, closure: InternedClosureId, - subst: GenericArgs<'db>, - trait_env: ParamEnvAndCrate<'db>, -) -> Result>, MirLowerError<'db>> { - let mut filler = Filler::new(db, trait_env, subst); + subst: StoredGenericArgs, + trait_env: StoredParamEnvAndCrate, +) -> Result, MirLowerError> { + let mut filler = Filler::new(db, trait_env.as_ref(), subst.as_ref()); let body = db.mir_body_for_closure(closure)?; let mut body = (*body).clone(); filler.fill_body(&mut body)?; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/pretty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/pretty.rs index 0c5a64935e49..96b90a3f4074 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/pretty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/pretty.rs @@ -36,8 +36,8 @@ macro_rules! wln { }; } -impl<'db> MirBody<'db> { - pub fn pretty_print(&self, db: &'db dyn HirDatabase, display_target: DisplayTarget) -> String { +impl MirBody { + pub fn pretty_print(&self, db: &dyn HirDatabase, display_target: DisplayTarget) -> String { let hir_body = db.body(self.owner); let mut ctx = MirPrettyCtx::new(self, &hir_body, db, display_target); ctx.for_body(|this| match ctx.body.owner { @@ -80,7 +80,7 @@ impl<'db> MirBody<'db> { // String with lines is rendered poorly in `dbg` macros, which I use very much, so this // function exists to solve that. - pub fn dbg(&self, db: &'db dyn HirDatabase, display_target: DisplayTarget) -> impl Debug { + pub fn dbg(&self, db: &dyn HirDatabase, display_target: DisplayTarget) -> impl Debug { struct StringDbg(String); impl Debug for StringDbg { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -92,12 +92,12 @@ impl<'db> MirBody<'db> { } struct MirPrettyCtx<'a, 'db> { - body: &'a MirBody<'db>, + body: &'a MirBody, hir_body: &'a Body, db: &'db dyn HirDatabase, result: String, indent: String, - local_to_binding: ArenaMap, BindingId>, + local_to_binding: ArenaMap, display_target: DisplayTarget, } @@ -113,12 +113,12 @@ impl Write for MirPrettyCtx<'_, '_> { } } -enum LocalName<'db> { - Unknown(LocalId<'db>), - Binding(Name, LocalId<'db>), +enum LocalName { + Unknown(LocalId), + Binding(Name, LocalId), } -impl<'db> HirDisplay<'db> for LocalName<'db> { +impl<'db> HirDisplay<'db> for LocalName { fn hir_fmt( &self, f: &mut crate::display::HirFormatter<'_, 'db>, @@ -179,7 +179,7 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { } fn new( - body: &'a MirBody<'db>, + body: &'a MirBody, hir_body: &'a Body, db: &'db dyn HirDatabase, display_target: DisplayTarget, @@ -211,19 +211,19 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { self, "let {}: {};", self.local_name(id).display_test(self.db, self.display_target), - self.hir_display(&local.ty) + self.hir_display(&local.ty.as_ref()) ); } } - fn local_name(&self, local: LocalId<'db>) -> LocalName<'db> { + fn local_name(&self, local: LocalId) -> LocalName { match self.local_to_binding.get(local) { Some(b) => LocalName::Binding(self.hir_body[*b].name.clone(), local), None => LocalName::Unknown(local), } } - fn basic_block_id(&self, basic_block_id: BasicBlockId<'db>) -> String { + fn basic_block_id(&self, basic_block_id: BasicBlockId) -> String { format!("'bb{}", u32::from(basic_block_id.into_raw())) } @@ -311,12 +311,8 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { } } - fn place(&mut self, p: &Place<'db>) { - fn f<'db>( - this: &mut MirPrettyCtx<'_, 'db>, - local: LocalId<'db>, - projections: &[PlaceElem<'db>], - ) { + fn place(&mut self, p: &Place) { + fn f<'db>(this: &mut MirPrettyCtx<'_, 'db>, local: LocalId, projections: &[PlaceElem]) { let Some((last, head)) = projections.split_last() else { // no projection w!(this, "{}", this.local_name(local).display_test(this.db, this.display_target)); @@ -376,19 +372,21 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { f(self, p.local, p.projection.lookup(&self.body.projection_store)); } - fn operand(&mut self, r: &Operand<'db>) { + fn operand(&mut self, r: &Operand) { match &r.kind { OperandKind::Copy(p) | OperandKind::Move(p) => { // MIR at the time of writing doesn't have difference between move and copy, so we show them // equally. Feel free to change it. self.place(p); } - OperandKind::Constant { konst, .. } => w!(self, "Const({})", self.hir_display(konst)), + OperandKind::Constant { konst, .. } => { + w!(self, "Const({})", self.hir_display(&konst.as_ref())) + } OperandKind::Static(s) => w!(self, "Static({:?})", s), } } - fn rvalue(&mut self, r: &Rvalue<'db>) { + fn rvalue(&mut self, r: &Rvalue) { match r { Rvalue::Use(op) => self.operand(op), Rvalue::Ref(r, p) => { @@ -415,7 +413,7 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { Rvalue::Repeat(op, len) => { w!(self, "["); self.operand(op); - w!(self, "; {}]", len.display_test(self.db, self.display_target)); + w!(self, "; {}]", len.as_ref().display_test(self.db, self.display_target)); } Rvalue::Aggregate(AggregateKind::Adt(_, _), it) => { w!(self, "Adt("); @@ -440,7 +438,7 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { Rvalue::Cast(ck, op, ty) => { w!(self, "Cast({ck:?}, "); self.operand(op); - w!(self, ", {})", self.hir_display(ty)); + w!(self, ", {})", self.hir_display(&ty.as_ref())); } Rvalue::CheckedBinaryOp(b, o1, o2) => { self.operand(o1); @@ -478,7 +476,7 @@ impl<'a, 'db> MirPrettyCtx<'a, 'db> { } } - fn operand_list(&mut self, it: &[Operand<'db>]) { + fn operand_list(&mut self, it: &[Operand]) { let mut it = it.iter(); if let Some(first) = it.next() { self.operand(first); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs index 8c52a847d1e9..539d09a8f5df 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs @@ -1,6 +1,7 @@ //! Things relevant to the next trait solver. pub mod abi; +mod binder; mod consts; mod def_id; pub mod fold; @@ -21,6 +22,7 @@ mod structural_normalize; mod ty; pub mod util; +pub use binder::*; pub use consts::*; pub use def_id::*; pub use generic_arg::*; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/binder.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/binder.rs new file mode 100644 index 000000000000..3645f8096cfd --- /dev/null +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/binder.rs @@ -0,0 +1,83 @@ +use crate::{ + FnAbi, + next_solver::{ + Binder, Clauses, EarlyBinder, FnSig, PolyFnSig, StoredBoundVarKinds, StoredClauses, + StoredTy, StoredTys, Ty, abi::Safety, + }, +}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct StoredEarlyBinder(T); + +impl StoredEarlyBinder { + #[inline] + pub fn bind(value: T) -> Self { + Self(value) + } + + #[inline] + pub fn skip_binder(self) -> T { + self.0 + } + + #[inline] + pub fn as_ref(&self) -> StoredEarlyBinder<&T> { + StoredEarlyBinder(&self.0) + } + + #[inline] + pub fn get_with<'db, 'a, R>(&'a self, f: impl FnOnce(&'a T) -> R) -> EarlyBinder<'db, R> { + EarlyBinder::bind(f(&self.0)) + } +} + +impl StoredEarlyBinder { + #[inline] + pub fn get<'db>(&self) -> EarlyBinder<'db, Ty<'db>> { + self.get_with(|it| it.as_ref()) + } +} + +impl StoredEarlyBinder { + #[inline] + pub fn get<'db>(&self) -> EarlyBinder<'db, Clauses<'db>> { + self.get_with(|it| it.as_ref()) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct StoredPolyFnSig { + bound_vars: StoredBoundVarKinds, + inputs_and_output: StoredTys, + c_variadic: bool, + safety: Safety, + abi: FnAbi, +} + +impl StoredPolyFnSig { + #[inline] + pub fn new(sig: PolyFnSig<'_>) -> Self { + let bound_vars = sig.bound_vars().store(); + let sig = sig.skip_binder(); + Self { + bound_vars, + inputs_and_output: sig.inputs_and_output.store(), + c_variadic: sig.c_variadic, + safety: sig.safety, + abi: sig.abi, + } + } + + #[inline] + pub fn get(&self) -> PolyFnSig<'_> { + Binder::bind_with_vars( + FnSig { + inputs_and_output: self.inputs_and_output.as_ref(), + c_variadic: self.c_variadic, + safety: self.safety, + abi: self.abi, + }, + self.bound_vars.as_ref(), + ) + } +} diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs index 3a32cf8b1fef..8417e145a46d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs @@ -3,19 +3,20 @@ use std::hash::Hash; use hir_def::ConstParamId; -use macros::{TypeFoldable, TypeVisitable}; +use intern::{Interned, InternedRef, impl_internable}; +use macros::{GenericTypeVisitable, TypeFoldable, TypeVisitable}; use rustc_ast_ir::visit::VisitorResult; use rustc_type_ir::{ - BoundVar, BoundVarIndexKind, ConstVid, DebruijnIndex, FlagComputation, Flags, InferConst, - TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, - WithCachedTypeInfo, + BoundVar, BoundVarIndexKind, ConstVid, DebruijnIndex, FlagComputation, Flags, + GenericTypeVisitable, InferConst, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, + TypeVisitable, TypeVisitableExt, WithCachedTypeInfo, inherent::{IntoKind, ParamEnv as _, PlaceholderLike, SliceLike}, relate::Relate, }; use crate::{ MemoryMap, - next_solver::{ClauseKind, ParamEnv, interner::InternedWrapperNoDebug}, + next_solver::{ClauseKind, ParamEnv, impl_stored_interned}, }; use super::{BoundVarKind, DbInterner, ErrorGuaranteed, GenericArgs, Placeholder, Ty}; @@ -23,30 +24,43 @@ use super::{BoundVarKind, DbInterner, ErrorGuaranteed, GenericArgs, Placeholder, pub type ConstKind<'db> = rustc_type_ir::ConstKind>; pub type UnevaluatedConst<'db> = rustc_type_ir::UnevaluatedConst>; -#[salsa::interned(constructor = new_, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Const<'db> { - #[returns(ref)] - kind_: InternedWrapperNoDebug>>, + pub(super) interned: InternedRef<'db, ConstInterned>, } +#[derive(PartialEq, Eq, Hash)] +#[repr(align(4))] // Required for `GenericArg` bit-tagging. +pub(super) struct ConstInterned(WithCachedTypeInfo>); + +impl_internable!(gc; ConstInterned); +impl_stored_interned!(ConstInterned, Const, StoredConst); + +const _: () = { + const fn is_copy() {} + is_copy::>(); +}; + impl<'db> Const<'db> { - pub fn new(interner: DbInterner<'db>, kind: ConstKind<'db>) -> Self { + pub fn new(_interner: DbInterner<'db>, kind: ConstKind<'db>) -> Self { + let kind = unsafe { std::mem::transmute::, ConstKind<'static>>(kind) }; let flags = FlagComputation::for_const_kind(&kind); let cached = WithCachedTypeInfo { internee: kind, flags: flags.flags, outer_exclusive_binder: flags.outer_exclusive_binder, }; - Const::new_(interner.db(), InternedWrapperNoDebug(cached)) + Self { interned: Interned::new_gc(ConstInterned(cached)) } } pub fn inner(&self) -> &WithCachedTypeInfo> { - crate::with_attached_db(|db| { - let inner = &self.kind_(db).0; - // SAFETY: The caller already has access to a `Const<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute(inner) } - }) + let inner = &self.interned.0; + unsafe { + std::mem::transmute::< + &WithCachedTypeInfo>, + &WithCachedTypeInfo>, + >(inner) + } } pub fn error(interner: DbInterner<'db>) -> Self { @@ -106,12 +120,6 @@ impl<'db> std::fmt::Debug for Const<'db> { } } -impl<'db> std::fmt::Debug for InternedWrapperNoDebug>> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.internee.fmt(f) - } -} - pub type PlaceholderConst = Placeholder; #[derive(Copy, Clone, Hash, Eq, PartialEq)] @@ -164,7 +172,9 @@ impl ParamConst { /// A type-level constant value. /// /// Represents a typed, fully evaluated constant. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, TypeFoldable, TypeVisitable)] +#[derive( + Debug, Copy, Clone, Eq, PartialEq, Hash, TypeFoldable, TypeVisitable, GenericTypeVisitable, +)] pub struct ValueConst<'db> { pub ty: Ty<'db>, // FIXME: Should we ignore this for TypeVisitable, TypeFoldable? @@ -190,7 +200,7 @@ impl<'db> rustc_type_ir::inherent::ValueConst> for ValueConst<'d } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, GenericTypeVisitable)] pub struct ConstBytes<'db> { pub memory: Box<[u8]>, pub memory_map: MemoryMap<'db>, @@ -202,31 +212,53 @@ impl Hash for ConstBytes<'_> { } } -#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Valtree<'db> { - #[returns(ref)] - bytes_: ConstBytes<'db>, + interned: InternedRef<'db, ValtreeInterned>, } +impl<'db, V: super::WorldExposer> GenericTypeVisitable for Valtree<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned(self.interned); + self.inner().generic_visit_with(visitor); + } +} + +#[derive(Debug, PartialEq, Eq, Hash)] +struct ValtreeInterned { + bytes: ConstBytes<'static>, +} + +impl_internable!(gc; ValtreeInterned); + +const _: () = { + const fn is_copy() {} + is_copy::>(); +}; + impl<'db> Valtree<'db> { + #[inline] pub fn new(bytes: ConstBytes<'db>) -> Self { - crate::with_attached_db(|db| unsafe { - // SAFETY: ¯\_(ツ)_/¯ - std::mem::transmute(Valtree::new_(db, bytes)) - }) + let bytes = unsafe { std::mem::transmute::, ConstBytes<'static>>(bytes) }; + Self { interned: Interned::new_gc(ValtreeInterned { bytes }) } } + #[inline] pub fn inner(&self) -> &ConstBytes<'db> { - crate::with_attached_db(|db| { - let inner = self.bytes_(db); - // SAFETY: The caller already has access to a `Valtree<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute(inner) } - }) + let inner = &self.interned.bytes; + unsafe { std::mem::transmute::<&ConstBytes<'static>, &ConstBytes<'db>>(inner) } } } -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeVisitable, TypeFoldable)] +impl std::fmt::Debug for Valtree<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.interned.fmt(f) + } +} + +#[derive( + Copy, Clone, Debug, Hash, PartialEq, Eq, TypeVisitable, TypeFoldable, GenericTypeVisitable, +)] pub struct ExprConst; impl rustc_type_ir::inherent::ParamLike for ParamConst { @@ -243,6 +275,13 @@ impl<'db> IntoKind for Const<'db> { } } +impl<'db, V: super::WorldExposer> GenericTypeVisitable for Const<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned(self.interned); + self.kind().generic_visit_with(visitor); + } +} + impl<'db> TypeVisitable> for Const<'db> { fn visit_with>>( &self, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs index 40cc84e0c0ed..4a19e30c64f7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs @@ -249,7 +249,7 @@ impl<'db> FulfillmentCtxt<'db> { | TypingMode::PostBorrowckAnalysis { defined_opaque_types: _ } | TypingMode::PostAnalysis => return Default::default(), }; - let stalled_coroutines = stalled_coroutines.inner(); + let stalled_coroutines = stalled_coroutines.as_slice(); if stalled_coroutines.is_empty() { return Default::default(); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill/errors.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill/errors.rs index 8495af4b755e..8f798b4ade24 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill/errors.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill/errors.rs @@ -9,7 +9,7 @@ use rustc_next_trait_solver::solve::{GoalEvaluation, SolverDelegateEvalExt}; use rustc_type_ir::{ AliasRelationDirection, AliasTermKind, HostEffectPredicate, Interner, PredicatePolarity, error::ExpectedFound, - inherent::{IntoKind, SliceLike, Span as _}, + inherent::{IntoKind, Span as _}, lang_items::SolverTraitLangItem, solve::{Certainty, GoalSource, MaybeCause, NoSolution}, }; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs index 10f2ba2b119b..f31b487eaed5 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs @@ -1,41 +1,209 @@ //! Things related to generic args in the next-trait-solver. +use std::{hint::unreachable_unchecked, marker::PhantomData, ptr::NonNull}; + use hir_def::{GenericDefId, GenericParamId}; -use macros::{TypeFoldable, TypeVisitable}; +use intern::InternedRef; use rustc_type_ir::{ - ClosureArgs, CollectAndApply, ConstVid, CoroutineArgs, CoroutineClosureArgs, FnSigTys, - GenericArgKind, Interner, TermKind, TyKind, TyVid, Variance, + ClosureArgs, ConstVid, CoroutineArgs, CoroutineClosureArgs, FallibleTypeFolder, FnSigTys, + GenericTypeVisitable, Interner, TyKind, TyVid, TypeFoldable, TypeFolder, TypeVisitable, + TypeVisitor, Variance, inherent::{GenericArg as _, GenericsOf, IntoKind, SliceLike, Term as _, Ty as _}, relate::{Relate, VarianceDiagInfo}, walk::TypeWalker, }; use smallvec::SmallVec; -use crate::next_solver::{PolyFnSig, interned_vec_db}; +use crate::next_solver::{ + ConstInterned, PolyFnSig, RegionInterned, TyInterned, impl_foldable_for_interned_slice, + impl_stored_interned_slice, interned_slice, +}; use super::{ Const, DbInterner, EarlyParamRegion, ErrorGuaranteed, ParamConst, Region, SolverDefId, Ty, Tys, generics::Generics, }; -#[derive(Copy, Clone, PartialEq, Eq, Hash, TypeVisitable, TypeFoldable, salsa::Supertype)] -pub enum GenericArg<'db> { - Ty(Ty<'db>), - Lifetime(Region<'db>), - Const(Const<'db>), +pub type GenericArgKind<'db> = rustc_type_ir::GenericArgKind>; +pub type TermKind<'db> = rustc_type_ir::TermKind>; + +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +struct GenericArgImpl<'db> { + ptr: NonNull<()>, + _marker: PhantomData<(Ty<'db>, Const<'db>, Region<'db>)>, +} + +unsafe impl Send for GenericArgImpl<'_> {} +unsafe impl Sync for GenericArgImpl<'_> {} + +impl<'db> GenericArgImpl<'db> { + const KIND_MASK: usize = 0b11; + const PTR_MASK: usize = !Self::KIND_MASK; + const TY_TAG: usize = 0b00; + const CONST_TAG: usize = 0b01; + const REGION_TAG: usize = 0b10; + + #[inline] + fn new_ty(ty: Ty<'db>) -> Self { + Self { + ptr: unsafe { + NonNull::new_unchecked( + ty.interned + .as_raw() + .cast::<()>() + .cast_mut() + .map_addr(|addr| addr | Self::TY_TAG), + ) + }, + _marker: PhantomData, + } + } + + #[inline] + fn new_const(ty: Const<'db>) -> Self { + Self { + ptr: unsafe { + NonNull::new_unchecked( + ty.interned + .as_raw() + .cast::<()>() + .cast_mut() + .map_addr(|addr| addr | Self::CONST_TAG), + ) + }, + _marker: PhantomData, + } + } + + #[inline] + fn new_region(ty: Region<'db>) -> Self { + Self { + ptr: unsafe { + NonNull::new_unchecked( + ty.interned + .as_raw() + .cast::<()>() + .cast_mut() + .map_addr(|addr| addr | Self::REGION_TAG), + ) + }, + _marker: PhantomData, + } + } + + #[inline] + fn kind(self) -> GenericArgKind<'db> { + let ptr = self.ptr.as_ptr().map_addr(|addr| addr & Self::PTR_MASK); + unsafe { + match self.ptr.addr().get() & Self::KIND_MASK { + Self::TY_TAG => GenericArgKind::Type(Ty { + interned: InternedRef::from_raw(ptr.cast::()), + }), + Self::CONST_TAG => GenericArgKind::Const(Const { + interned: InternedRef::from_raw(ptr.cast::()), + }), + Self::REGION_TAG => GenericArgKind::Lifetime(Region { + interned: InternedRef::from_raw(ptr.cast::()), + }), + _ => unreachable_unchecked(), + } + } + } + + #[inline] + fn term_kind(self) -> TermKind<'db> { + let ptr = self.ptr.as_ptr().map_addr(|addr| addr & Self::PTR_MASK); + unsafe { + match self.ptr.addr().get() & Self::KIND_MASK { + Self::TY_TAG => { + TermKind::Ty(Ty { interned: InternedRef::from_raw(ptr.cast::()) }) + } + Self::CONST_TAG => TermKind::Const(Const { + interned: InternedRef::from_raw(ptr.cast::()), + }), + _ => unreachable_unchecked(), + } + } + } +} + +#[derive(PartialEq, Eq, Hash)] +pub struct StoredGenericArg { + ptr: GenericArgImpl<'static>, +} + +impl Clone for StoredGenericArg { + #[inline] + fn clone(&self) -> Self { + match self.ptr.kind() { + GenericArgKind::Lifetime(it) => std::mem::forget(it.interned.to_owned()), + GenericArgKind::Type(it) => std::mem::forget(it.interned.to_owned()), + GenericArgKind::Const(it) => std::mem::forget(it.interned.to_owned()), + } + Self { ptr: self.ptr } + } +} + +impl Drop for StoredGenericArg { + #[inline] + fn drop(&mut self) { + unsafe { + match self.ptr.kind() { + GenericArgKind::Lifetime(it) => it.interned.decrement_refcount(), + GenericArgKind::Type(it) => it.interned.decrement_refcount(), + GenericArgKind::Const(it) => it.interned.decrement_refcount(), + } + } + } +} + +impl StoredGenericArg { + #[inline] + fn new(value: GenericArg<'_>) -> Self { + let result = Self { ptr: GenericArgImpl { ptr: value.ptr.ptr, _marker: PhantomData } }; + // Increase refcount. + std::mem::forget(result.clone()); + result + } + + #[inline] + pub fn as_ref<'db>(&self) -> GenericArg<'db> { + GenericArg { ptr: self.ptr } + } +} + +impl std::fmt::Debug for StoredGenericArg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.as_ref().fmt(f) + } +} + +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +pub struct GenericArg<'db> { + ptr: GenericArgImpl<'db>, } impl<'db> std::fmt::Debug for GenericArg<'db> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Ty(t) => std::fmt::Debug::fmt(t, f), - Self::Lifetime(r) => std::fmt::Debug::fmt(r, f), - Self::Const(c) => std::fmt::Debug::fmt(c, f), + match self.kind() { + GenericArgKind::Type(t) => std::fmt::Debug::fmt(&t, f), + GenericArgKind::Lifetime(r) => std::fmt::Debug::fmt(&r, f), + GenericArgKind::Const(c) => std::fmt::Debug::fmt(&c, f), } } } impl<'db> GenericArg<'db> { + #[inline] + pub fn store(self) -> StoredGenericArg { + StoredGenericArg::new(self) + } + + #[inline] + pub fn kind(self) -> GenericArgKind<'db> { + self.ptr.kind() + } + pub fn ty(self) -> Option> { match self.kind() { GenericArgKind::Type(ty) => Some(ty), @@ -66,8 +234,8 @@ impl<'db> GenericArg<'db> { #[inline] pub(crate) fn expect_region(self) -> Region<'db> { - match self { - GenericArg::Lifetime(region) => region, + match self.kind() { + GenericArgKind::Lifetime(region) => region, _ => panic!("expected a region, got {self:?}"), } } @@ -87,30 +255,32 @@ impl<'db> GenericArg<'db> { } impl<'db> From> for GenericArg<'db> { + #[inline] fn from(value: Term<'db>) -> Self { - match value { - Term::Ty(ty) => GenericArg::Ty(ty), - Term::Const(c) => GenericArg::Const(c), - } + GenericArg { ptr: value.ptr } } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, TypeVisitable, TypeFoldable)] -pub enum Term<'db> { - Ty(Ty<'db>), - Const(Const<'db>), +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +pub struct Term<'db> { + ptr: GenericArgImpl<'db>, } impl<'db> std::fmt::Debug for Term<'db> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Ty(t) => std::fmt::Debug::fmt(t, f), - Self::Const(c) => std::fmt::Debug::fmt(c, f), + match self.kind() { + TermKind::Ty(t) => std::fmt::Debug::fmt(&t, f), + TermKind::Const(c) => std::fmt::Debug::fmt(&c, f), } } } impl<'db> Term<'db> { + #[inline] + pub fn kind(self) -> TermKind<'db> { + self.ptr.term_kind() + } + pub fn expect_type(&self) -> Ty<'db> { self.as_type().expect("expected a type, but found a const") } @@ -124,31 +294,108 @@ impl<'db> Term<'db> { } impl<'db> From> for GenericArg<'db> { + #[inline] fn from(value: Ty<'db>) -> Self { - Self::Ty(value) + GenericArg { ptr: GenericArgImpl::new_ty(value) } } } impl<'db> From> for GenericArg<'db> { + #[inline] fn from(value: Region<'db>) -> Self { - Self::Lifetime(value) + GenericArg { ptr: GenericArgImpl::new_region(value) } } } impl<'db> From> for GenericArg<'db> { + #[inline] fn from(value: Const<'db>) -> Self { - Self::Const(value) + GenericArg { ptr: GenericArgImpl::new_const(value) } } } impl<'db> IntoKind for GenericArg<'db> { - type Kind = GenericArgKind>; + type Kind = GenericArgKind<'db>; + #[inline] fn kind(self) -> Self::Kind { - match self { - GenericArg::Ty(ty) => GenericArgKind::Type(ty), - GenericArg::Lifetime(region) => GenericArgKind::Lifetime(region), - GenericArg::Const(c) => GenericArgKind::Const(c), + self.ptr.kind() + } +} + +impl<'db, V> GenericTypeVisitable for GenericArg<'db> +where + GenericArgKind<'db>: GenericTypeVisitable, +{ + fn generic_visit_with(&self, visitor: &mut V) { + self.kind().generic_visit_with(visitor); + } +} + +impl<'db, V> GenericTypeVisitable for Term<'db> +where + TermKind<'db>: GenericTypeVisitable, +{ + fn generic_visit_with(&self, visitor: &mut V) { + self.kind().generic_visit_with(visitor); + } +} + +impl<'db> TypeVisitable> for GenericArg<'db> { + fn visit_with>>(&self, visitor: &mut V) -> V::Result { + match self.kind() { + GenericArgKind::Lifetime(it) => it.visit_with(visitor), + GenericArgKind::Type(it) => it.visit_with(visitor), + GenericArgKind::Const(it) => it.visit_with(visitor), + } + } +} + +impl<'db> TypeVisitable> for Term<'db> { + fn visit_with>>(&self, visitor: &mut V) -> V::Result { + match self.kind() { + TermKind::Ty(it) => it.visit_with(visitor), + TermKind::Const(it) => it.visit_with(visitor), + } + } +} + +impl<'db> TypeFoldable> for GenericArg<'db> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + Ok(match self.kind() { + GenericArgKind::Lifetime(it) => it.try_fold_with(folder)?.into(), + GenericArgKind::Type(it) => it.try_fold_with(folder)?.into(), + GenericArgKind::Const(it) => it.try_fold_with(folder)?.into(), + }) + } + + fn fold_with>>(self, folder: &mut F) -> Self { + match self.kind() { + GenericArgKind::Lifetime(it) => it.fold_with(folder).into(), + GenericArgKind::Type(it) => it.fold_with(folder).into(), + GenericArgKind::Const(it) => it.fold_with(folder).into(), + } + } +} + +impl<'db> TypeFoldable> for Term<'db> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + Ok(match self.kind() { + TermKind::Ty(it) => it.try_fold_with(folder)?.into(), + TermKind::Const(it) => it.try_fold_with(folder)?.into(), + }) + } + + fn fold_with>>(self, folder: &mut F) -> Self { + match self.kind() { + TermKind::Ty(it) => it.fold_with(folder).into(), + TermKind::Const(it) => it.fold_with(folder).into(), } } } @@ -182,7 +429,9 @@ impl<'db> Relate> for GenericArg<'db> { } } -interned_vec_db!(GenericArgs, GenericArg); +interned_slice!(GenericArgsStorage, GenericArgs, GenericArg<'db>, GenericArg<'static>,); +impl_foldable_for_interned_slice!(GenericArgs); +impl_stored_interned_slice!(GenericArgsStorage, GenericArgs, StoredGenericArgs); impl<'db> rustc_type_ir::inherent::GenericArg> for GenericArg<'db> {} @@ -306,7 +555,7 @@ impl<'db> GenericArgs<'db> { /// A "sensible" `.split_closure_args()`, where the arguments are not in a tuple. pub fn split_closure_args_untupled(self) -> rustc_type_ir::ClosureArgsParts> { // FIXME: should use `ClosureSubst` when possible - match self.inner().as_slice() { + match self.as_slice() { [parent_args @ .., closure_kind_ty, sig_ty, tupled_upvars_ty] => { let interner = DbInterner::conjure(); rustc_type_ir::ClosureArgsParts { @@ -341,8 +590,8 @@ impl<'db> rustc_type_ir::relate::Relate> for GenericArgs<'db> { a: Self, b: Self, ) -> rustc_type_ir::relate::RelateResult, Self> { - let interner = relation.cx(); - CollectAndApply::collect_and_apply( + GenericArgs::new_from_iter( + relation.cx(), std::iter::zip(a.iter(), b.iter()).map(|(a, b)| { relation.relate_with_variance( Variance::Invariant, @@ -351,7 +600,6 @@ impl<'db> rustc_type_ir::relate::Relate> for GenericArgs<'db> { b, ) }), - |g| GenericArgs::new_from_iter(interner, g.iter().cloned()), ) } } @@ -397,29 +645,26 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< }) } fn type_at(self, i: usize) -> as rustc_type_ir::Interner>::Ty { - self.inner() - .get(i) + self.get(i) .and_then(|g| g.as_type()) .unwrap_or_else(|| Ty::new_error(DbInterner::conjure(), ErrorGuaranteed)) } fn region_at(self, i: usize) -> as rustc_type_ir::Interner>::Region { - self.inner() - .get(i) + self.get(i) .and_then(|g| g.as_region()) .unwrap_or_else(|| Region::error(DbInterner::conjure())) } fn const_at(self, i: usize) -> as rustc_type_ir::Interner>::Const { - self.inner() - .get(i) + self.get(i) .and_then(|g| g.as_const()) .unwrap_or_else(|| Const::error(DbInterner::conjure())) } fn split_closure_args(self) -> rustc_type_ir::ClosureArgsParts> { // FIXME: should use `ClosureSubst` when possible - match self.inner().as_slice() { + match self.as_slice() { [parent_args @ .., closure_kind_ty, sig_ty, tupled_upvars_ty] => { let interner = DbInterner::conjure(); // This is stupid, but the next solver expects the first input to actually be a tuple @@ -458,7 +703,7 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< fn split_coroutine_closure_args( self, ) -> rustc_type_ir::CoroutineClosureArgsParts> { - match self.inner().as_slice() { + match self.as_slice() { [ parent_args @ .., closure_kind_ty, @@ -481,7 +726,7 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< fn split_coroutine_args(self) -> rustc_type_ir::CoroutineArgsParts> { let interner = DbInterner::conjure(); - match self.inner().as_slice() { + match self.as_slice() { [parent_args @ .., kind_ty, resume_ty, yield_ty, return_ty, tupled_upvars_ty] => { rustc_type_ir::CoroutineArgsParts { parent_args: GenericArgs::new_from_iter(interner, parent_args.iter().cloned()), @@ -518,25 +763,25 @@ pub fn error_for_param_kind<'db>(id: GenericParamId, interner: DbInterner<'db>) } impl<'db> IntoKind for Term<'db> { - type Kind = TermKind>; + type Kind = TermKind<'db>; + #[inline] fn kind(self) -> Self::Kind { - match self { - Term::Ty(ty) => TermKind::Ty(ty), - Term::Const(c) => TermKind::Const(c), - } + self.ptr.term_kind() } } impl<'db> From> for Term<'db> { + #[inline] fn from(value: Ty<'db>) -> Self { - Self::Ty(value) + Term { ptr: GenericArgImpl::new_ty(value) } } } impl<'db> From> for Term<'db> { + #[inline] fn from(value: Const<'db>) -> Self { - Self::Const(value) + Term { ptr: GenericArgImpl::new_const(value) } } } @@ -583,7 +828,7 @@ impl From for TermVid { impl<'db> DbInterner<'db> { pub(super) fn mk_args(self, args: &[GenericArg<'db>]) -> GenericArgs<'db> { - GenericArgs::new_from_iter(self, args.iter().cloned()) + GenericArgs::new_from_slice(args) } pub(super) fn mk_args_from_iter(self, iter: I) -> T::Output diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs index 70b659406f86..6ba1aae2d486 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs @@ -28,7 +28,7 @@ use rustc_type_ir::{ FnSig, GenericArgKind, TypeFoldable, TypingMode, Variance, error::ExpectedFound, - inherent::{IntoKind, Span as _}, + inherent::Span as _, relate::{Relate, TypeRelation, solver_relating::RelateExt}, }; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs index 1029a7ff39e8..4422eeaa9a4b 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs @@ -8,7 +8,7 @@ use rustc_hash::FxHashMap; use rustc_index::Idx; use rustc_type_ir::InferTy::{self, FloatVar, IntVar, TyVar}; -use rustc_type_ir::inherent::{Const as _, IntoKind as _, Region as _, SliceLike, Ty as _}; +use rustc_type_ir::inherent::{Const as _, IntoKind as _, Region as _, Ty as _}; use rustc_type_ir::{ BoundVar, BoundVarIndexKind, DebruijnIndex, Flags, InferConst, RegionKind, TyVid, TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UniverseIndex, @@ -498,7 +498,7 @@ impl<'cx, 'db> Canonicalizer<'cx, 'db> { { let base = Canonical { max_universe: UniverseIndex::ROOT, - variables: CanonicalVars::new_from_iter(tcx, []), + variables: CanonicalVars::empty(tcx), value: (), }; Canonicalizer::canonicalize_with_base( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/instantiate.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/instantiate.rs index 13c620cfdbc9..b758042e85b0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/instantiate.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/instantiate.rs @@ -23,7 +23,7 @@ use rustc_index::{Idx as _, IndexVec}; use rustc_type_ir::{ BoundVar, BoundVarIndexKind, GenericArgKind, TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UniverseIndex, - inherent::{GenericArg as _, IntoKind, SliceLike}, + inherent::{GenericArg as _, IntoKind}, }; use tracing::{debug, instrument}; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/outlives/obligations.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/outlives/obligations.rs index befb2001b1b9..617dbda1338b 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/outlives/obligations.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/outlives/obligations.rs @@ -3,7 +3,7 @@ use rustc_type_ir::{OutlivesPredicate, TypeVisitableExt}; use tracing::{debug, instrument}; use crate::next_solver::{ - ArgOutlivesPredicate, GenericArg, Region, RegionOutlivesPredicate, Ty, + ArgOutlivesPredicate, GenericArgKind, Region, RegionOutlivesPredicate, Ty, infer::{InferCtxt, TypeOutlivesConstraint, snapshot::undo_log::UndoLog}, }; @@ -12,14 +12,14 @@ impl<'db> InferCtxt<'db> { &self, OutlivesPredicate(arg, r2): ArgOutlivesPredicate<'db>, ) { - match arg { - GenericArg::Lifetime(r1) => { + match arg.kind() { + GenericArgKind::Lifetime(r1) => { self.register_region_outlives_constraint(OutlivesPredicate(r1, r2)); } - GenericArg::Ty(ty1) => { + GenericArgKind::Type(ty1) => { self.register_type_outlives_constraint(ty1, r2); } - GenericArg::Const(_) => unreachable!(), + GenericArgKind::Const(_) => unreachable!(), } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index 4d3c028879a1..1a946cb90817 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -2,6 +2,7 @@ use std::fmt; +use intern::{Interned, InternedRef, InternedSliceRef, impl_internable}; use rustc_ast_ir::{FloatTy, IntTy, UintTy}; pub use tls_cache::clear_tls_solver_cache; pub use tls_db::{attach_db, attach_db_allow_change, with_attached_db}; @@ -57,155 +58,18 @@ use super::{ util::sizedness_constraint_for_ty, }; -#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Clone)] -pub struct InternedWrapperNoDebug(pub(crate) T); +macro_rules! interned_slice { + ($storage:ident, $name:ident, $ty_db:ty, $ty_static:ty $(,)?) => { + const _: () = { + #[allow(unused_lifetimes)] + fn _ensure_correct_types<'db: 'static>(v: $ty_db) -> $ty_static { v } + }; -#[macro_export] -#[doc(hidden)] -macro_rules! _interned_vec_nolifetime_salsa { - ($name:ident, $ty:ty) => { - interned_vec_nolifetime_salsa!($name, $ty, nofold); + ::intern::impl_slice_internable!(gc; $storage, (), $ty_static); - impl<'db> rustc_type_ir::TypeFoldable> for $name<'db> { - fn try_fold_with>>( - self, - folder: &mut F, - ) -> Result { - use rustc_type_ir::inherent::SliceLike as _; - let inner: smallvec::SmallVec<[_; 2]> = - self.iter().map(|v| v.try_fold_with(folder)).collect::>()?; - Ok($name::new_(folder.cx().db(), inner)) - } - fn fold_with>>( - self, - folder: &mut F, - ) -> Self { - use rustc_type_ir::inherent::SliceLike as _; - let inner: smallvec::SmallVec<[_; 2]> = - self.iter().map(|v| v.fold_with(folder)).collect(); - $name::new_(folder.cx().db(), inner) - } - } - - impl<'db> rustc_type_ir::TypeVisitable> for $name<'db> { - fn visit_with>>( - &self, - visitor: &mut V, - ) -> V::Result { - use rustc_ast_ir::visit::VisitorResult; - use rustc_type_ir::inherent::SliceLike as _; - rustc_ast_ir::walk_visitable_list!(visitor, self.as_slice().iter()); - V::Result::output() - } - } - }; - ($name:ident, $ty:ty, nofold) => { - #[salsa::interned(constructor = new_)] - pub struct $name { - #[returns(ref)] - inner_: smallvec::SmallVec<[$ty; 2]>, - } - - impl<'db> $name<'db> { - pub fn new_from_iter( - interner: DbInterner<'db>, - data: impl IntoIterator, - ) -> Self { - $name::new_(interner.db(), data.into_iter().collect::>()) - } - - pub fn inner(&self) -> &smallvec::SmallVec<[$ty; 2]> { - // SAFETY: ¯\_(ツ)_/¯ - $crate::with_attached_db(|db| { - let inner = self.inner_(db); - unsafe { std::mem::transmute(inner) } - }) - } - } - - impl<'db> std::fmt::Debug for $name<'db> { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.as_slice().fmt(fmt) - } - } - - impl<'db> rustc_type_ir::inherent::SliceLike for $name<'db> { - type Item = $ty; - - type IntoIter = as IntoIterator>::IntoIter; - - fn iter(self) -> Self::IntoIter { - self.inner().clone().into_iter() - } - - fn as_slice(&self) -> &[Self::Item] { - self.inner().as_slice() - } - } - - impl<'db> IntoIterator for $name<'db> { - type Item = $ty; - type IntoIter = ::IntoIter; - - fn into_iter(self) -> Self::IntoIter { - rustc_type_ir::inherent::SliceLike::iter(self) - } - } - - impl<'db> Default for $name<'db> { - fn default() -> Self { - $name::new_from_iter(DbInterner::conjure(), []) - } - } - }; -} - -pub use crate::_interned_vec_nolifetime_salsa as interned_vec_nolifetime_salsa; - -#[macro_export] -#[doc(hidden)] -macro_rules! _interned_vec_db { - ($name:ident, $ty:ident) => { - interned_vec_db!($name, $ty, nofold); - - impl<'db> rustc_type_ir::TypeFoldable> for $name<'db> { - fn try_fold_with>>( - self, - folder: &mut F, - ) -> Result { - use rustc_type_ir::inherent::SliceLike as _; - let inner: smallvec::SmallVec<[_; 2]> = - self.iter().map(|v| v.try_fold_with(folder)).collect::>()?; - Ok($name::new_(folder.cx().db(), inner)) - } - fn fold_with>>( - self, - folder: &mut F, - ) -> Self { - use rustc_type_ir::inherent::SliceLike as _; - let inner: smallvec::SmallVec<[_; 2]> = - self.iter().map(|v| v.fold_with(folder)).collect(); - $name::new_(folder.cx().db(), inner) - } - } - - impl<'db> rustc_type_ir::TypeVisitable> for $name<'db> { - fn visit_with>>( - &self, - visitor: &mut V, - ) -> V::Result { - use rustc_ast_ir::visit::VisitorResult; - use rustc_type_ir::inherent::SliceLike as _; - rustc_ast_ir::walk_visitable_list!(visitor, self.as_slice().iter()); - V::Result::output() - } - } - }; - ($name:ident, $ty:ident, nofold) => { - #[salsa::interned(constructor = new_, unsafe(non_update_types))] + #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct $name<'db> { - #[returns(ref)] - inner_: smallvec::SmallVec<[$ty<'db>; 2]>, + interned: ::intern::InternedSliceRef<'db, $storage>, } impl<'db> std::fmt::Debug for $name<'db> { @@ -215,58 +79,223 @@ macro_rules! _interned_vec_db { } impl<'db> $name<'db> { - pub fn empty(interner: DbInterner<'db>) -> Self { - $name::new_(interner.db(), smallvec::SmallVec::new()) + #[inline] + pub fn empty(_interner: DbInterner<'db>) -> Self { + // FIXME: Get from a static. + Self::new_from_slice(&[]) } - pub fn new_from_iter( - interner: DbInterner<'db>, - data: impl IntoIterator>, - ) -> Self { - $name::new_(interner.db(), data.into_iter().collect::>()) + #[inline] + pub fn new_from_slice(slice: &[$ty_db]) -> Self { + let slice = unsafe { ::std::mem::transmute::<&[$ty_db], &[$ty_static]>(slice) }; + Self { interned: ::intern::InternedSlice::from_header_and_slice((), slice) } } - pub fn inner(&self) -> &smallvec::SmallVec<[$ty<'db>; 2]> { - // SAFETY: ¯\_(ツ)_/¯ - $crate::with_attached_db(|db| { - let inner = self.inner_(db); - unsafe { std::mem::transmute(inner) } + #[inline] + pub fn new_from_iter(_interner: DbInterner<'db>, args: I) -> T::Output + where + I: IntoIterator, + T: ::rustc_type_ir::CollectAndApply<$ty_db, Self>, + { + ::rustc_type_ir::CollectAndApply::collect_and_apply(args.into_iter(), |g| { + Self::new_from_slice(g) }) } - } - impl<'db> rustc_type_ir::inherent::SliceLike for $name<'db> { - type Item = $ty<'db>; - - type IntoIter = ; 2]> as IntoIterator>::IntoIter; - - fn iter(self) -> Self::IntoIter { - self.inner().clone().into_iter() + #[inline] + pub fn as_slice(self) -> &'db [$ty_db] { + let slice = &self.interned.get().slice; + unsafe { ::std::mem::transmute::<&[$ty_static], &[$ty_db]>(slice) } } - fn as_slice(&self) -> &[Self::Item] { - self.inner().as_slice() + #[inline] + pub fn iter(self) -> ::std::iter::Copied<::std::slice::Iter<'db, $ty_db>> { + self.as_slice().iter().copied() + } + + #[inline] + pub fn len(self) -> usize { + self.as_slice().len() + } + + #[inline] + pub fn is_empty(self) -> bool { + self.as_slice().is_empty() } } impl<'db> IntoIterator for $name<'db> { - type Item = $ty<'db>; - type IntoIter = ::IntoIter; + type IntoIter = ::std::iter::Copied<::std::slice::Iter<'db, $ty_db>>; + type Item = $ty_db; + #[inline] + fn into_iter(self) -> Self::IntoIter { self.iter() } + } - fn into_iter(self) -> Self::IntoIter { - rustc_type_ir::inherent::SliceLike::iter(self) + impl<'db> ::std::ops::Deref for $name<'db> { + type Target = [$ty_db]; + + #[inline] + fn deref(&self) -> &Self::Target { + (*self).as_slice() + } + } + + impl<'db> rustc_type_ir::inherent::SliceLike for $name<'db> { + type Item = $ty_db; + + type IntoIter = ::std::iter::Copied<::std::slice::Iter<'db, $ty_db>>; + + #[inline] + fn iter(self) -> Self::IntoIter { + self.iter() + } + + #[inline] + fn as_slice(&self) -> &[Self::Item] { + (*self).as_slice() } } impl<'db> Default for $name<'db> { + #[inline] fn default() -> Self { - $name::new_from_iter(DbInterner::conjure(), []) + $name::empty(DbInterner::conjure()) + } + } + + + impl<'db, V: $crate::next_solver::interner::WorldExposer> + rustc_type_ir::GenericTypeVisitable for $name<'db> + { + #[inline] + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned_slice(self.interned); + self.as_slice().iter().for_each(|it| it.generic_visit_with(visitor)); } } }; } +pub(crate) use interned_slice; -pub use crate::_interned_vec_db as interned_vec_db; +macro_rules! impl_foldable_for_interned_slice { + ($name:ident) => { + impl<'db> ::rustc_type_ir::TypeVisitable> for $name<'db> { + fn visit_with>>( + &self, + visitor: &mut V, + ) -> V::Result { + use rustc_ast_ir::visit::VisitorResult; + rustc_ast_ir::walk_visitable_list!(visitor, (*self).iter()); + V::Result::output() + } + } + + impl<'db> rustc_type_ir::TypeFoldable> for $name<'db> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + Self::new_from_iter(folder.cx(), self.iter().map(|it| it.try_fold_with(folder))) + } + fn fold_with>>( + self, + folder: &mut F, + ) -> Self { + Self::new_from_iter(folder.cx(), self.iter().map(|it| it.fold_with(folder))) + } + } + }; +} +pub(crate) use impl_foldable_for_interned_slice; + +macro_rules! impl_stored_interned_slice { + ( $storage:ident, $name:ident, $stored_name:ident $(,)? ) => { + #[derive(Clone, PartialEq, Eq, Hash)] + pub struct $stored_name { + interned: ::intern::InternedSlice<$storage>, + } + + impl $stored_name { + #[inline] + fn new(it: $name<'_>) -> Self { + Self { interned: it.interned.to_owned() } + } + + #[inline] + pub fn as_ref<'a, 'db>(&'a self) -> $name<'db> { + let it = $name { interned: self.interned.as_ref() }; + unsafe { std::mem::transmute::<$name<'a>, $name<'db>>(it) } + } + } + + unsafe impl salsa::Update for $stored_name { + unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool { + unsafe { crate::utils::unsafe_update_eq(old_pointer, new_value) } + } + } + + impl std::fmt::Debug for $stored_name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.as_ref().fmt(f) + } + } + + impl $name<'_> { + #[inline] + pub fn store(self) -> $stored_name { + $stored_name::new(self) + } + } + }; +} +pub(crate) use impl_stored_interned_slice; + +macro_rules! impl_stored_interned { + ( $storage:ident, $name:ident, $stored_name:ident $(,)? ) => { + #[derive(Clone, PartialEq, Eq, Hash)] + pub struct $stored_name { + interned: ::intern::Interned<$storage>, + } + + impl $stored_name { + #[inline] + fn new(it: $name<'_>) -> Self { + Self { interned: it.interned.to_owned() } + } + + #[inline] + pub fn as_ref<'a, 'db>(&'a self) -> $name<'db> { + let it = $name { interned: self.interned.as_ref() }; + unsafe { std::mem::transmute::<$name<'a>, $name<'db>>(it) } + } + } + + unsafe impl salsa::Update for $stored_name { + unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool { + unsafe { crate::utils::unsafe_update_eq(old_pointer, new_value) } + } + } + + impl std::fmt::Debug for $stored_name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.as_ref().fmt(f) + } + } + + impl $name<'_> { + #[inline] + pub fn store(self) -> $stored_name { + $stored_name::new(self) + } + } + }; +} +pub(crate) use impl_stored_interned; + +pub trait WorldExposer { + fn on_interned(&mut self, interned: InternedRef<'_, T>); + fn on_interned_slice(&mut self, interned: InternedSliceRef<'_, T>); +} #[derive(Debug, Copy, Clone)] pub struct DbInterner<'db> { @@ -333,7 +362,8 @@ impl<'db> inherent::Span> for Span { } } -interned_vec_nolifetime_salsa!(BoundVarKinds, BoundVarKind, nofold); +interned_slice!(BoundVarKindsStorage, BoundVarKinds, BoundVarKind, BoundVarKind); +impl_stored_interned_slice!(BoundVarKindsStorage, BoundVarKinds, StoredBoundVarKinds); #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum BoundVarKind { @@ -365,7 +395,12 @@ impl BoundVarKind { } } -interned_vec_db!(CanonicalVars, CanonicalVarKind, nofold); +interned_slice!( + CanonicalVarsStorage, + CanonicalVars, + CanonicalVarKind<'db>, + CanonicalVarKind<'static> +); pub struct DepNodeIndex; @@ -391,7 +426,8 @@ impl std::fmt::Debug for Placeholder { #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub struct AllocId; -interned_vec_nolifetime_salsa!(VariancesOf, Variance, nofold); +interned_slice!(VariancesOfStorage, VariancesOf, Variance, Variance); +impl_stored_interned_slice!(VariancesOfStorage, VariancesOf, StoredVariancesOf); #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct VariantIdx(usize); @@ -658,7 +694,7 @@ impl<'db> inherent::AdtDef> for AdtDef { let id: VariantId = struct_id.into(); let field_types = interner.db().field_types(id); - field_types.iter().last().map(|f| *f.1) + field_types.iter().last().map(|f| f.1.get()) } fn all_field_tys( @@ -668,7 +704,7 @@ impl<'db> inherent::AdtDef> for AdtDef { let db = interner.db(); // FIXME: this is disabled just to match the behavior with chalk right now let _field_tys = |id: VariantId| { - db.field_types(id).iter().map(|(_, ty)| ty.skip_binder()).collect::>() + db.field_types(id).iter().map(|(_, ty)| ty.get().skip_binder()).collect::>() }; let field_tys = |_id: VariantId| vec![]; let tys: Vec<_> = match self.inner().id { @@ -762,30 +798,36 @@ impl std::ops::Deref for UnsizingParams { pub type PatternKind<'db> = rustc_type_ir::PatternKind>; -#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Pattern<'db> { - #[returns(ref)] - kind_: InternedWrapperNoDebug>, + interned: InternedRef<'db, PatternInterned>, } -impl<'db> std::fmt::Debug for InternedWrapperNoDebug> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(f) - } -} +#[derive(PartialEq, Eq, Hash)] +struct PatternInterned(PatternKind<'static>); + +impl_internable!(gc; PatternInterned); + +const _: () = { + const fn is_copy() {} + is_copy::>(); +}; impl<'db> Pattern<'db> { - pub fn new(interner: DbInterner<'db>, kind: PatternKind<'db>) -> Self { - Pattern::new_(interner.db(), InternedWrapperNoDebug(kind)) + pub fn new(_interner: DbInterner<'db>, kind: PatternKind<'db>) -> Self { + let kind = unsafe { std::mem::transmute::, PatternKind<'static>>(kind) }; + Self { interned: Interned::new_gc(PatternInterned(kind)) } } pub fn inner(&self) -> &PatternKind<'db> { - crate::with_attached_db(|db| { - let inner = &self.kind_(db).0; - // SAFETY: The caller already has access to a `Ty<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute(inner) } - }) + let inner = &self.interned.0; + unsafe { std::mem::transmute::<&PatternKind<'static>, &PatternKind<'db>>(inner) } + } +} + +impl<'db> std::fmt::Debug for Pattern<'db> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.kind().fmt(f) } } @@ -831,6 +873,35 @@ impl<'db> rustc_type_ir::inherent::IntoKind for Pattern<'db> { } } +impl<'db> rustc_type_ir::TypeVisitable> for Pattern<'db> { + fn visit_with>>( + &self, + visitor: &mut V, + ) -> V::Result { + self.kind().visit_with(visitor) + } +} + +impl<'db, V: WorldExposer> rustc_type_ir::GenericTypeVisitable for Pattern<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned(self.interned); + self.kind().generic_visit_with(visitor); + } +} + +impl<'db> rustc_type_ir::TypeFoldable> for Pattern<'db> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + Ok(Pattern::new(folder.cx(), self.kind().try_fold_with(folder)?)) + } + + fn fold_with>>(self, folder: &mut F) -> Self { + Pattern::new(folder.cx(), self.kind().fold_with(folder)) + } +} + impl<'db> rustc_type_ir::relate::Relate> for Pattern<'db> { fn relate>>( relation: &mut R, @@ -851,9 +922,9 @@ impl<'db> rustc_type_ir::relate::Relate> for Pattern<'db> { if a.len() != b.len() { return Err(TypeError::Mismatch); } - let pats = CollectAndApply::collect_and_apply( + let pats = PatList::new_from_iter( + relation.cx(), std::iter::zip(a.iter(), b.iter()).map(|(a, b)| relation.relate(a, b)), - |g| PatList::new_from_iter(tcx, g.iter().cloned()), )?; Ok(Pattern::new(tcx, PatternKind::Or(pats))) } @@ -865,7 +936,8 @@ impl<'db> rustc_type_ir::relate::Relate> for Pattern<'db> { } } -interned_vec_db!(PatList, Pattern); +interned_slice!(PatListStorage, PatList, Pattern<'db>, Pattern<'static>); +impl_foldable_for_interned_slice!(PatList); macro_rules! as_lang_item { ( @@ -941,7 +1013,7 @@ impl<'db> Interner for DbInterner<'db> { self, data: &[(OpaqueTypeKey<'db>, Self::Ty)], ) -> Self::PredefinedOpaques { - PredefinedOpaques::new_from_iter(self, data.iter().cloned()) + PredefinedOpaques::new_from_slice(data) } type CanonicalVarKinds = CanonicalVars<'db>; @@ -950,7 +1022,7 @@ impl<'db> Interner for DbInterner<'db> { self, kinds: &[rustc_type_ir::CanonicalVarKind], ) -> Self::CanonicalVarKinds { - CanonicalVars::new_from_iter(self, kinds.iter().cloned()) + CanonicalVars::new_from_slice(kinds) } type ExternalConstraints = ExternalConstraints<'db>; @@ -1012,7 +1084,7 @@ impl<'db> Interner for DbInterner<'db> { type Features = Features; fn mk_args(self, args: &[Self::GenericArg]) -> Self::GenericArgs { - GenericArgs::new_from_iter(self, args.iter().cloned()) + GenericArgs::new_from_slice(args) } fn mk_args_from_iter(self, args: I) -> T::Output @@ -1020,9 +1092,7 @@ impl<'db> Interner for DbInterner<'db> { I: Iterator, T: rustc_type_ir::CollectAndApply, { - CollectAndApply::collect_and_apply(args, |g| { - GenericArgs::new_from_iter(self, g.iter().cloned()) - }) + GenericArgs::new_from_iter(self, args) } type UnsizingParams = UnsizingParams; @@ -1096,7 +1166,7 @@ impl<'db> Interner for DbInterner<'db> { | SolverDefId::ImplId(_) | SolverDefId::InternedClosureId(_) | SolverDefId::InternedCoroutineId(_) => { - return VariancesOf::new_from_iter(self, []); + return VariancesOf::empty(self); } }; self.db.variances_of(generic_def) @@ -1202,7 +1272,7 @@ impl<'db> Interner for DbInterner<'db> { I: Iterator, T: rustc_type_ir::CollectAndApply, { - CollectAndApply::collect_and_apply(args, |g| Tys::new_from_iter(self, g.iter().cloned())) + Tys::new_from_iter(self, args) } fn parent(self, def_id: Self::DefId) -> Self::DefId { @@ -1338,7 +1408,7 @@ impl<'db> Interner for DbInterner<'db> { let own_bounds: FxHashSet<_> = self.item_self_bounds(def_id).skip_binder().into_iter().collect(); if all_bounds.len() == own_bounds.len() { - EarlyBinder::bind(Clauses::new_from_iter(self, [])) + EarlyBinder::bind(Clauses::empty(self)) } else { EarlyBinder::bind(Clauses::new_from_iter( self, @@ -1952,7 +2022,7 @@ impl<'db> Interner for DbInterner<'db> { let field_types = self.db().field_types(variant.id()); let mut unsizing_params = DenseBitSet::new_empty(num_params); - let ty = field_types[tail_field.0]; + let ty = field_types[tail_field.0].get(); for arg in ty.instantiate_identity().walk() { if let Some(i) = maybe_unsizing_param_idx(arg) { unsizing_params.insert(i); @@ -1962,7 +2032,7 @@ impl<'db> Interner for DbInterner<'db> { // Ensure none of the other fields mention the parameters used // in unsizing. for field in prefix_fields { - for arg in field_types[field.0].instantiate_identity().walk() { + for arg in field_types[field.0].get().instantiate_identity().walk() { if let Some(i) = maybe_unsizing_param_idx(arg) { unsizing_params.remove(i); } @@ -2022,7 +2092,7 @@ impl<'db> Interner for DbInterner<'db> { }; let mut result = Vec::new(); crate::opaques::opaque_types_defined_by(self.db, def_id, &mut result); - SolverDefIds::new_from_iter(self, result) + SolverDefIds::new_from_slice(&result) } fn opaque_types_and_coroutines_defined_by(self, def_id: Self::LocalDefId) -> Self::LocalDefIds { @@ -2051,7 +2121,7 @@ impl<'db> Interner for DbInterner<'db> { } }); - SolverDefIds::new_from_iter(self, result) + SolverDefIds::new_from_slice(&result) } fn alias_has_const_conditions(self, _def_id: Self::DefId) -> bool { @@ -2096,10 +2166,10 @@ impl<'db> Interner for DbInterner<'db> { let impl_trait_id = self.db().lookup_intern_impl_trait_id(opaque); match impl_trait_id { crate::ImplTraitId::ReturnTypeImplTrait(func, idx) => { - crate::opaques::rpit_hidden_types(self.db, func)[idx] + crate::opaques::rpit_hidden_types(self.db, func)[idx].get() } crate::ImplTraitId::TypeAliasImplTrait(type_alias, idx) => { - crate::opaques::tait_hidden_types(self.db, type_alias)[idx] + crate::opaques::tait_hidden_types(self.db, type_alias)[idx].get() } } } @@ -2288,6 +2358,11 @@ macro_rules! TrivialTypeTraversalImpls { ::output() } } + + impl rustc_type_ir::GenericTypeVisitable for $ty { + #[inline] + fn generic_visit_with(&self, _visitor: &mut V) {} + } )+ }; } @@ -2302,17 +2377,22 @@ TrivialTypeTraversalImpls! { AdtIdWrapper, ImplIdWrapper, GeneralConstIdWrapper, - Pattern<'db>, Safety, FnAbi, Span, ParamConst, ParamTy, BoundRegion, - BoundVar, Placeholder, Placeholder, Placeholder, + Placeholder, + BoundVarKind, + EarlyParamRegion, + LateParamRegion, + AdtDef, + BoundTy, + BoundConst, } mod tls_db { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs index dab0fe9e4a90..998aab5a3fff 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ir_print.rs @@ -2,7 +2,6 @@ use std::any::type_name_of_val; -use rustc_type_ir::inherent::SliceLike; use rustc_type_ir::{self as ty, ir_print::IrPrint}; use super::SolverDefId; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs index 4fbeb76adaad..7e1d6b7328cd 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs @@ -1,37 +1,64 @@ //! Things related to opaques in the next-trait-solver. +use intern::{Interned, InternedRef, impl_internable}; use rustc_ast_ir::try_visit; use rustc_type_ir::inherent::SliceLike; -use super::{DbInterner, SolverDefId, Ty, interned_vec_db, interned_vec_nolifetime_salsa}; +use crate::next_solver::{impl_foldable_for_interned_slice, interned_slice}; + +use super::{DbInterner, SolverDefId, Ty}; pub type OpaqueTypeKey<'db> = rustc_type_ir::OpaqueTypeKey>; type PredefinedOpaque<'db> = (OpaqueTypeKey<'db>, Ty<'db>); -interned_vec_db!(PredefinedOpaques, PredefinedOpaque); +interned_slice!( + PredefinedOpaquesStorage, + PredefinedOpaques, + PredefinedOpaque<'db>, + PredefinedOpaque<'static>, +); +impl_foldable_for_interned_slice!(PredefinedOpaques); pub type ExternalConstraintsData<'db> = rustc_type_ir::solve::ExternalConstraintsData>; -interned_vec_nolifetime_salsa!(SolverDefIds, SolverDefId); +interned_slice!(SolverDefIdsStorage, SolverDefIds, SolverDefId, SolverDefId); +impl_foldable_for_interned_slice!(SolverDefIds); -#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct ExternalConstraints<'db> { - #[returns(ref)] - kind_: rustc_type_ir::solve::ExternalConstraintsData>, + interned: InternedRef<'db, ExternalConstraintsInterned>, } +#[derive(PartialEq, Eq, Hash)] +struct ExternalConstraintsInterned(ExternalConstraintsData<'static>); + +impl_internable!(gc; ExternalConstraintsInterned); + +const _: () = { + const fn is_copy() {} + is_copy::>(); +}; + impl<'db> ExternalConstraints<'db> { - pub fn new(interner: DbInterner<'db>, data: ExternalConstraintsData<'db>) -> Self { - ExternalConstraints::new_(interner.db(), data) + #[inline] + pub fn new(_interner: DbInterner<'db>, data: ExternalConstraintsData<'db>) -> Self { + let data = unsafe { + std::mem::transmute::, ExternalConstraintsData<'static>>( + data, + ) + }; + Self { interned: Interned::new_gc(ExternalConstraintsInterned(data)) } } + #[inline] pub fn inner(&self) -> &ExternalConstraintsData<'db> { - crate::with_attached_db(|db| { - let inner = self.kind_(db); - // SAFETY: ¯\_(ツ)_/¯ - unsafe { std::mem::transmute(inner) } - }) + let inner = &self.interned.0; + unsafe { + std::mem::transmute::<&ExternalConstraintsData<'static>, &ExternalConstraintsData<'db>>( + inner, + ) + } } } @@ -43,6 +70,12 @@ impl<'db> std::ops::Deref for ExternalConstraints<'db> { } } +impl std::fmt::Debug for ExternalConstraints<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.inner().fmt(f) + } +} + impl<'db> rustc_type_ir::TypeVisitable> for ExternalConstraints<'db> { fn visit_with>>( &self, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs index 71d9b0b55a30..95b48c73c12f 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs @@ -2,20 +2,25 @@ use std::cmp::Ordering; -use macros::{TypeFoldable, TypeVisitable}; +use intern::{ + Interned, InternedRef, InternedSlice, InternedSliceRef, impl_internable, impl_slice_internable, +}; +use macros::{GenericTypeVisitable, TypeFoldable, TypeVisitable}; use rustc_type_ir::{ - self as ty, CollectAndApply, DebruijnIndex, EarlyBinder, FlagComputation, Flags, - PredicatePolarity, TypeFlags, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, - TypeVisitable, Upcast, UpcastFrom, WithCachedTypeInfo, + self as ty, CollectAndApply, EarlyBinder, FlagComputation, Flags, GenericTypeVisitable, + PredicatePolarity, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, Upcast, + UpcastFrom, WithCachedTypeInfo, elaborate::Elaboratable, error::{ExpectedFound, TypeError}, inherent::{IntoKind, SliceLike}, }; -use smallvec::SmallVec; -use crate::next_solver::{GenericArg, InternedWrapperNoDebug, TraitIdWrapper}; +use crate::next_solver::{ + GenericArg, TraitIdWrapper, impl_foldable_for_interned_slice, impl_stored_interned_slice, + interned_slice, +}; -use super::{Binder, BoundVarKinds, DbInterner, Region, Ty, interned_vec_db}; +use super::{Binder, BoundVarKinds, DbInterner, Region, Ty}; pub type BoundExistentialPredicate<'db> = Binder<'db, ExistentialPredicate<'db>>; @@ -68,7 +73,13 @@ fn stable_cmp_existential_predicate<'db>( (ExistentialPredicate::AutoTrait(_), _) => Ordering::Greater, } } -interned_vec_db!(BoundExistentialPredicates, BoundExistentialPredicate); +interned_slice!( + BoundExistentialPredicatesStorage, + BoundExistentialPredicates, + BoundExistentialPredicate<'db>, + BoundExistentialPredicate<'static>, +); +impl_foldable_for_interned_slice!(BoundExistentialPredicates); impl<'db> rustc_type_ir::inherent::BoundExistentialPredicates> for BoundExistentialPredicates<'db> @@ -82,7 +93,7 @@ impl<'db> rustc_type_ir::inherent::BoundExistentialPredicates> ) -> Option< rustc_type_ir::Binder, rustc_type_ir::ExistentialTraitRef>>, > { - self.inner()[0] + self[0] .map_bound(|this| match this { ExistentialPredicate::Trait(tr) => Some(tr), _ => None, @@ -166,74 +177,50 @@ impl<'db> rustc_type_ir::relate::Relate> for BoundExistentialPre }, ); - CollectAndApply::collect_and_apply(v, |g| { - BoundExistentialPredicates::new_from_iter(interner, g.iter().cloned()) - }) + BoundExistentialPredicates::new_from_iter(interner, v) } } -#[salsa::interned(constructor = new_, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Predicate<'db> { - #[returns(ref)] - kind_: InternedWrapperNoDebug>>>, + interned: InternedRef<'db, PredicateInterned>, } -impl<'db> std::fmt::Debug for Predicate<'db> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.inner().internee.fmt(f) - } -} +#[derive(PartialEq, Eq, Hash)] +struct PredicateInterned(WithCachedTypeInfo>>); -impl<'db> std::fmt::Debug - for InternedWrapperNoDebug>>> -{ - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Binder<")?; - match self.0.internee.skip_binder() { - rustc_type_ir::PredicateKind::Clause(clause_kind) => { - write!(f, "{clause_kind:?}") - } - rustc_type_ir::PredicateKind::DynCompatible(trait_def_id) => { - write!(f, "the trait `{trait_def_id:?}` is dyn-compatible") - } - rustc_type_ir::PredicateKind::Subtype(subtype_predicate) => { - write!(f, "{subtype_predicate:?}") - } - rustc_type_ir::PredicateKind::Coerce(coerce_predicate) => { - write!(f, "{coerce_predicate:?}") - } - rustc_type_ir::PredicateKind::ConstEquate(c1, c2) => { - write!(f, "the constant `{c1:?}` equals `{c2:?}`") - } - rustc_type_ir::PredicateKind::Ambiguous => write!(f, "ambiguous"), - rustc_type_ir::PredicateKind::NormalizesTo(data) => write!(f, "{data:?}"), - rustc_type_ir::PredicateKind::AliasRelate(t1, t2, dir) => { - write!(f, "{t1:?} {dir:?} {t2:?}") - } - }?; - write!(f, ", [{:?}]>", self.0.internee.bound_vars())?; - Ok(()) - } -} +impl_internable!(gc; PredicateInterned); + +const _: () = { + const fn is_copy() {} + is_copy::>(); +}; impl<'db> Predicate<'db> { - pub fn new(interner: DbInterner<'db>, kind: Binder<'db, PredicateKind<'db>>) -> Self { + pub fn new(_interner: DbInterner<'db>, kind: Binder<'db, PredicateKind<'db>>) -> Self { + let kind = unsafe { + std::mem::transmute::< + Binder<'db, PredicateKind<'db>>, + Binder<'static, PredicateKind<'static>>, + >(kind) + }; let flags = FlagComputation::for_predicate(kind); let cached = WithCachedTypeInfo { internee: kind, flags: flags.flags, outer_exclusive_binder: flags.outer_exclusive_binder, }; - Predicate::new_(interner.db(), InternedWrapperNoDebug(cached)) + Self { interned: Interned::new_gc(PredicateInterned(cached)) } } pub fn inner(&self) -> &WithCachedTypeInfo>> { - crate::with_attached_db(|db| { - let inner = &self.kind_(db).0; - // SAFETY: The caller already has access to a `Predicate<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute(inner) } - }) + let inner = &self.interned.0; + unsafe { + std::mem::transmute::< + &WithCachedTypeInfo>>, + &WithCachedTypeInfo>>, + >(inner) + } } /// Flips the polarity of a Predicate. @@ -259,110 +246,132 @@ impl<'db> Predicate<'db> { } } -// FIXME: should make a "header" in interned_vec - -#[derive(Debug, Clone)] -pub struct InternedClausesWrapper<'db>(SmallVec<[Clause<'db>; 2]>, TypeFlags, DebruijnIndex); - -impl<'db> PartialEq for InternedClausesWrapper<'db> { - fn eq(&self, other: &Self) -> bool { - self.0.eq(&other.0) +impl<'db> std::fmt::Debug for Predicate<'db> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.kind().fmt(f) } } -impl<'db> Eq for InternedClausesWrapper<'db> {} +impl_slice_internable!(gc; ClausesStorage, WithCachedTypeInfo<()>, Clause<'static>); +impl_stored_interned_slice!(ClausesStorage, Clauses, StoredClauses); -impl<'db> std::hash::Hash for InternedClausesWrapper<'db> { - fn hash(&self, state: &mut H) { - self.0.hash(state) - } -} - -#[salsa::interned(constructor = new_, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Clauses<'db> { - #[returns(ref)] - inner_: InternedClausesWrapper<'db>, -} - -impl<'db> Clauses<'db> { - pub fn new_from_iter( - interner: DbInterner<'db>, - data: impl IntoIterator>, - ) -> Self { - let clauses: SmallVec<_> = data.into_iter().collect(); - let flags = FlagComputation::>::for_clauses(&clauses); - let wrapper = InternedClausesWrapper(clauses, flags.flags, flags.outer_exclusive_binder); - Clauses::new_(interner.db(), wrapper) - } - - pub fn inner(&self) -> &InternedClausesWrapper<'db> { - crate::with_attached_db(|db| { - let inner = self.inner_(db); - // SAFETY: The caller already has access to a `Clauses<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute(inner) } - }) - } + interned: InternedSliceRef<'db, ClausesStorage>, } impl<'db> std::fmt::Debug for Clauses<'db> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.inner().0.fmt(f) + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.as_slice().fmt(fmt) } } -impl<'db> rustc_type_ir::inherent::Clauses> for Clauses<'db> {} - -impl<'db> rustc_type_ir::inherent::SliceLike for Clauses<'db> { - type Item = Clause<'db>; - - type IntoIter = ; 2]> as IntoIterator>::IntoIter; - - fn iter(self) -> Self::IntoIter { - self.inner().0.clone().into_iter() +impl<'db> Clauses<'db> { + #[inline] + pub fn empty(_interner: DbInterner<'db>) -> Self { + // FIXME: Get from a static. + Self::new_from_slice(&[]) } - fn as_slice(&self) -> &[Self::Item] { - self.inner().0.as_slice() + #[inline] + pub fn new_from_slice(slice: &[Clause<'db>]) -> Self { + let slice = unsafe { ::std::mem::transmute::<&[Clause<'db>], &[Clause<'static>]>(slice) }; + let flags = FlagComputation::>::for_clauses(slice); + let flags = WithCachedTypeInfo { + internee: (), + flags: flags.flags, + outer_exclusive_binder: flags.outer_exclusive_binder, + }; + Self { interned: InternedSlice::from_header_and_slice(flags, slice) } + } + + #[inline] + pub fn new_from_iter(_interner: DbInterner<'db>, args: I) -> T::Output + where + I: IntoIterator, + T: CollectAndApply, Self>, + { + CollectAndApply::collect_and_apply(args.into_iter(), Self::new_from_slice) + } + + #[inline] + pub fn as_slice(self) -> &'db [Clause<'db>] { + let slice = &self.interned.get().slice; + unsafe { ::std::mem::transmute::<&[Clause<'static>], &[Clause<'db>]>(slice) } + } + + #[inline] + pub fn iter(self) -> ::std::iter::Copied<::std::slice::Iter<'db, Clause<'db>>> { + self.as_slice().iter().copied() + } + + #[inline] + pub fn len(self) -> usize { + self.as_slice().len() + } + + #[inline] + pub fn is_empty(self) -> bool { + self.as_slice().is_empty() } } impl<'db> IntoIterator for Clauses<'db> { + type IntoIter = ::std::iter::Copied<::std::slice::Iter<'db, Clause<'db>>>; type Item = Clause<'db>; - type IntoIter = ::IntoIter; - + #[inline] fn into_iter(self) -> Self::IntoIter { - rustc_type_ir::inherent::SliceLike::iter(self) + self.iter() + } +} + +impl<'db> std::ops::Deref for Clauses<'db> { + type Target = [Clause<'db>]; + + #[inline] + fn deref(&self) -> &Self::Target { + (*self).as_slice() + } +} + +impl<'db> rustc_type_ir::inherent::SliceLike for Clauses<'db> { + type Item = Clause<'db>; + + type IntoIter = ::std::iter::Copied<::std::slice::Iter<'db, Clause<'db>>>; + + #[inline] + fn iter(self) -> Self::IntoIter { + self.iter() + } + + #[inline] + fn as_slice(&self) -> &[Self::Item] { + (*self).as_slice() } } impl<'db> Default for Clauses<'db> { + #[inline] fn default() -> Self { - Clauses::new_from_iter(DbInterner::conjure(), []) + Clauses::empty(DbInterner::conjure()) } } +impl<'db> rustc_type_ir::inherent::Clauses> for Clauses<'db> {} + impl<'db> rustc_type_ir::TypeSuperFoldable> for Clauses<'db> { fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { - let mut clauses: SmallVec<[_; 2]> = SmallVec::with_capacity(self.inner().0.len()); - for c in self { - clauses.push(c.try_fold_with(folder)?); - } - Ok(Clauses::new_from_iter(folder.cx(), clauses)) + Clauses::new_from_iter(folder.cx(), self.iter().map(|clause| clause.try_fold_with(folder))) } fn super_fold_with>>( self, folder: &mut F, ) -> Self { - let mut clauses: SmallVec<[_; 2]> = SmallVec::with_capacity(self.inner().0.len()); - for c in self { - clauses.push(c.fold_with(folder)); - } - Clauses::new_from_iter(folder.cx(), clauses) + Clauses::new_from_iter(folder.cx(), self.iter().map(|clause| clause.fold_with(folder))) } } @@ -371,15 +380,10 @@ impl<'db> rustc_type_ir::TypeFoldable> for Clauses<'db> { self, folder: &mut F, ) -> Result { - use rustc_type_ir::inherent::SliceLike as _; - let inner: smallvec::SmallVec<[_; 2]> = - self.iter().map(|v| v.try_fold_with(folder)).collect::>()?; - Ok(Clauses::new_from_iter(folder.cx(), inner)) + self.try_super_fold_with(folder) } fn fold_with>>(self, folder: &mut F) -> Self { - use rustc_type_ir::inherent::SliceLike as _; - let inner: smallvec::SmallVec<[_; 2]> = self.iter().map(|v| v.fold_with(folder)).collect(); - Clauses::new_from_iter(folder.cx(), inner) + self.super_fold_with(folder) } } @@ -389,19 +393,27 @@ impl<'db> rustc_type_ir::TypeVisitable> for Clauses<'db> { visitor: &mut V, ) -> V::Result { use rustc_ast_ir::visit::VisitorResult; - use rustc_type_ir::inherent::SliceLike as _; - rustc_ast_ir::walk_visitable_list!(visitor, self.as_slice().iter()); + rustc_ast_ir::walk_visitable_list!(visitor, self.iter()); V::Result::output() } } +impl<'db, V: super::WorldExposer> rustc_type_ir::GenericTypeVisitable for Clauses<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned_slice(self.interned); + self.as_slice().iter().for_each(|it| it.generic_visit_with(visitor)); + } +} + impl<'db> rustc_type_ir::Flags for Clauses<'db> { + #[inline] fn flags(&self) -> rustc_type_ir::TypeFlags { - self.inner().1 + self.interned.header.header.flags } + #[inline] fn outer_exclusive_binder(&self) -> rustc_type_ir::DebruijnIndex { - self.inner().2 + self.interned.header.header.outer_exclusive_binder } } @@ -414,7 +426,7 @@ impl<'db> rustc_type_ir::TypeSuperVisitable> for Clauses<'db> { } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] // TODO implement Debug by hand +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, GenericTypeVisitable)] // TODO implement Debug by hand pub struct Clause<'db>(pub(crate) Predicate<'db>); // We could cram the reveal into the clauses like rustc does, probably @@ -425,7 +437,7 @@ pub struct ParamEnv<'db> { impl<'db> ParamEnv<'db> { pub fn empty() -> Self { - ParamEnv { clauses: Clauses::new_from_iter(DbInterner::conjure(), []) } + ParamEnv { clauses: Clauses::empty(DbInterner::conjure()) } } pub fn clauses(self) -> Clauses<'db> { @@ -460,6 +472,13 @@ impl<'db> TypeVisitable> for Predicate<'db> { } } +impl<'db, V: super::WorldExposer> GenericTypeVisitable for Predicate<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned(self.interned); + self.kind().generic_visit_with(visitor); + } +} + impl<'db> TypeSuperVisitable> for Predicate<'db> { fn super_visit_with>>( &self, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs index 3be715ab07d3..dee7953ae36c 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs @@ -1,47 +1,50 @@ //! Things related to regions. use hir_def::LifetimeParamId; -use intern::Symbol; +use intern::{Interned, InternedRef, Symbol, impl_internable}; use rustc_type_ir::{ - BoundVar, BoundVarIndexKind, DebruijnIndex, Flags, INNERMOST, RegionVid, TypeFlags, - TypeFoldable, TypeVisitable, + BoundVar, BoundVarIndexKind, DebruijnIndex, Flags, GenericTypeVisitable, INNERMOST, RegionVid, + TypeFlags, TypeFoldable, TypeVisitable, inherent::{IntoKind, PlaceholderLike, SliceLike}, relate::Relate, }; -use crate::next_solver::{GenericArg, OutlivesPredicate}; +use crate::next_solver::{ + GenericArg, OutlivesPredicate, impl_foldable_for_interned_slice, interned_slice, +}; use super::{ - ErrorGuaranteed, SolverDefId, interned_vec_db, + ErrorGuaranteed, SolverDefId, interner::{BoundVarKind, DbInterner, Placeholder}, }; pub type RegionKind<'db> = rustc_type_ir::RegionKind>; -#[salsa::interned(constructor = new_, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Region<'db> { - #[returns(ref)] - kind_: RegionKind<'db>, + pub(super) interned: InternedRef<'db, RegionInterned>, } -impl std::fmt::Debug for Region<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.kind().fmt(f) - } -} +#[derive(PartialEq, Eq, Hash)] +#[repr(align(4))] // Required for `GenericArg` bit-tagging. +pub(super) struct RegionInterned(RegionKind<'static>); + +impl_internable!(gc; RegionInterned); + +const _: () = { + const fn is_copy() {} + is_copy::>(); +}; impl<'db> Region<'db> { - pub fn new(interner: DbInterner<'db>, kind: RegionKind<'db>) -> Self { - Region::new_(interner.db(), kind) + pub fn new(_interner: DbInterner<'db>, kind: RegionKind<'db>) -> Self { + let kind = unsafe { std::mem::transmute::, RegionKind<'static>>(kind) }; + Self { interned: Interned::new_gc(RegionInterned(kind)) } } pub fn inner(&self) -> &RegionKind<'db> { - crate::with_attached_db(|db| { - let inner = self.kind_(db); - // SAFETY: The caller already has access to a `Region<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute::<&RegionKind<'_>, &RegionKind<'db>>(inner) } - }) + let inner = &self.interned.0; + unsafe { std::mem::transmute::<&RegionKind<'static>, &RegionKind<'db>>(inner) } } pub fn new_early_param( @@ -256,6 +259,12 @@ impl BoundRegionKind { } } +impl std::fmt::Debug for Region<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.kind().fmt(f) + } +} + impl<'db> IntoKind for Region<'db> { type Kind = RegionKind<'db>; @@ -377,6 +386,19 @@ impl<'db> PlaceholderLike> for PlaceholderRegion { } } +impl<'db, V: super::WorldExposer> GenericTypeVisitable for Region<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned(self.interned); + self.kind().generic_visit_with(visitor); + } +} + type GenericArgOutlivesPredicate<'db> = OutlivesPredicate<'db, GenericArg<'db>>; -interned_vec_db!(RegionAssumptions, GenericArgOutlivesPredicate); +interned_slice!( + RegionAssumptionsStorage, + RegionAssumptions, + GenericArgOutlivesPredicate<'db>, + GenericArgOutlivesPredicate<'static>, +); +impl_foldable_for_interned_slice!(RegionAssumptions); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs index 40a3f17cf169..d800925ba4e9 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs @@ -5,7 +5,7 @@ use rustc_next_trait_solver::delegate::SolverDelegate; use rustc_type_ir::{ AliasTyKind, GenericArgKind, InferCtxtLike, Interner, PredicatePolarity, TypeFlags, TypeVisitableExt, - inherent::{IntoKind, SliceLike, Term as _, Ty as _}, + inherent::{IntoKind, Term as _, Ty as _}, lang_items::SolverTraitLangItem, solve::{Certainty, NoSolution}, }; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs index 7dcb8567c2e4..305da50b6d9f 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs @@ -7,13 +7,14 @@ use hir_def::{ hir::generics::{TypeOrConstParamData, TypeParamProvenance}, }; use hir_def::{TraitId, type_ref::Rawness}; +use intern::{Interned, InternedRef, impl_internable}; use rustc_abi::{Float, Integer, Size}; use rustc_ast_ir::{Mutability, try_visit, visit::VisitorResult}; use rustc_type_ir::{ AliasTyKind, BoundVar, BoundVarIndexKind, ClosureKind, CoroutineArgs, CoroutineArgsParts, - DebruijnIndex, FlagComputation, Flags, FloatTy, FloatVid, InferTy, IntTy, IntVid, Interner, - TyVid, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, - TypeVisitor, UintTy, Upcast, WithCachedTypeInfo, + DebruijnIndex, FlagComputation, Flags, FloatTy, FloatVid, GenericTypeVisitable, InferTy, IntTy, + IntVid, Interner, TyVid, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, + TypeVisitableExt, TypeVisitor, UintTy, Upcast, WithCachedTypeInfo, inherent::{ AdtDef as _, BoundExistentialPredicates, BoundVarLike, Const as _, GenericArgs as _, IntoKind, ParamLike, PlaceholderLike, Safety as _, SliceLike, Ty as _, @@ -28,15 +29,16 @@ use crate::{ lower::GenericPredicates, next_solver::{ AdtDef, AliasTy, Binder, CallableIdWrapper, Clause, ClauseKind, ClosureIdWrapper, Const, - CoroutineIdWrapper, FnSig, GenericArg, PolyFnSig, Region, TraitRef, TypeAliasIdWrapper, + CoroutineIdWrapper, FnSig, GenericArgKind, PolyFnSig, Region, TraitRef, TypeAliasIdWrapper, abi::Safety, - interner::InternedWrapperNoDebug, + impl_foldable_for_interned_slice, impl_stored_interned, impl_stored_interned_slice, + interned_slice, util::{CoroutineArgsExt, IntegerTypeExt}, }, }; use super::{ - BoundVarKind, DbInterner, GenericArgs, Placeholder, SolverDefId, interned_vec_db, + BoundVarKind, DbInterner, GenericArgs, Placeholder, SolverDefId, util::{FloatExt, IntegerExt}, }; @@ -44,35 +46,45 @@ pub type SimplifiedType = rustc_type_ir::fast_reject::SimplifiedType = rustc_type_ir::TyKind>; pub type FnHeader<'db> = rustc_type_ir::FnHeader>; -#[salsa::interned(constructor = new_, unsafe(non_update_types))] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Ty<'db> { - #[returns(ref)] - kind_: InternedWrapperNoDebug>>, + pub(super) interned: InternedRef<'db, TyInterned>, } +#[derive(PartialEq, Eq, Hash)] +#[repr(align(4))] // Required for `GenericArg` bit-tagging. +pub(super) struct TyInterned(WithCachedTypeInfo>); + +impl_internable!(gc; TyInterned); +impl_stored_interned!(TyInterned, Ty, StoredTy); + const _: () = { const fn is_copy() {} is_copy::>(); }; impl<'db> Ty<'db> { - pub fn new(interner: DbInterner<'db>, kind: TyKind<'db>) -> Self { + #[inline] + pub fn new(_interner: DbInterner<'db>, kind: TyKind<'db>) -> Self { + let kind = unsafe { std::mem::transmute::, TyKind<'static>>(kind) }; let flags = FlagComputation::for_kind(&kind); let cached = WithCachedTypeInfo { internee: kind, flags: flags.flags, outer_exclusive_binder: flags.outer_exclusive_binder, }; - Ty::new_(interner.db(), InternedWrapperNoDebug(cached)) + Self { interned: Interned::new_gc(TyInterned(cached)) } } + #[inline] pub fn inner(&self) -> &WithCachedTypeInfo> { - crate::with_attached_db(|db| { - let inner = &self.kind_(db).0; - // SAFETY: The caller already has access to a `Ty<'db>`, so borrowchecking will - // make sure that our returned value is valid for the lifetime `'db`. - unsafe { std::mem::transmute(inner) } - }) + let inner = &self.interned.0; + unsafe { + std::mem::transmute::< + &WithCachedTypeInfo>, + &WithCachedTypeInfo>, + >(inner) + } } pub fn new_adt(interner: DbInterner<'db>, adt_id: AdtId, args: GenericArgs<'db>) -> Self { @@ -383,7 +395,7 @@ impl<'db> Ty<'db> { #[inline] pub fn is_unit(self) -> bool { - matches!(self.kind(), TyKind::Tuple(tys) if tys.inner().is_empty()) + matches!(self.kind(), TyKind::Tuple(tys) if tys.is_empty()) } #[inline] @@ -661,12 +673,9 @@ impl<'db> Ty<'db> { // This is only used by type walking. // Parameters will be walked outside, and projection predicate is not used. // So just provide the Future trait. - let impl_bound = TraitRef::new( - interner, - future_trait.into(), - GenericArgs::new_from_iter(interner, []), - ) - .upcast(interner); + let impl_bound = + TraitRef::new(interner, future_trait.into(), GenericArgs::empty(interner)) + .upcast(interner); Some(vec![impl_bound]) } else { None @@ -730,20 +739,22 @@ impl<'db> std::fmt::Debug for Ty<'db> { } } -impl<'db> std::fmt::Debug for InternedWrapperNoDebug>> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.internee.fmt(f) - } -} - impl<'db> IntoKind for Ty<'db> { type Kind = TyKind<'db>; + #[inline] fn kind(self) -> Self::Kind { self.inner().internee } } +impl<'db, V: super::WorldExposer> GenericTypeVisitable for Ty<'db> { + fn generic_visit_with(&self, visitor: &mut V) { + visitor.on_interned(self.interned); + self.kind().generic_visit_with(visitor); + } +} + impl<'db> TypeVisitable> for Ty<'db> { fn visit_with>>( &self, @@ -1068,9 +1079,9 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { // to unnecessary overflows in async code. See the issue: // . let coroutine_args = interner.mk_args_from_iter(coroutine_args.iter().map(|arg| { - match arg { - GenericArg::Ty(_) | GenericArg::Const(_) => arg, - GenericArg::Lifetime(_) => { + match arg.kind() { + GenericArgKind::Type(_) | GenericArgKind::Const(_) => arg, + GenericArgKind::Lifetime(_) => { crate::next_solver::Region::new(interner, rustc_type_ir::RegionKind::ReErased) .into() } @@ -1254,10 +1265,13 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { } } -interned_vec_db!(Tys, Ty); +interned_slice!(TysStorage, Tys, Ty<'db>, Ty<'static>); +impl_foldable_for_interned_slice!(Tys); +impl_stored_interned_slice!(TysStorage, Tys, StoredTys); impl<'db> Tys<'db> { - pub fn inputs(&self) -> &[Ty<'db>] { + #[inline] + pub fn inputs(self) -> &'db [Ty<'db>] { self.as_slice().split_last().unwrap().1 } } @@ -1323,6 +1337,10 @@ pub enum BoundTyKind { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub struct ErrorGuaranteed; +impl GenericTypeVisitable for ErrorGuaranteed { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + impl<'db> TypeVisitable> for ErrorGuaranteed { fn visit_with>>( &self, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs index 76a6207e2338..27ae5e39d55b 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/opaques.rs @@ -13,7 +13,7 @@ use crate::{ db::{HirDatabase, InternedOpaqueTyId}, lower::{ImplTraitIdx, ImplTraits}, next_solver::{ - DbInterner, EarlyBinder, ErrorGuaranteed, SolverDefId, Ty, TypingMode, + DbInterner, ErrorGuaranteed, SolverDefId, StoredEarlyBinder, StoredTy, Ty, TypingMode, infer::{DbInternerInferExt, traits::ObligationCause}, obligation_ctxt::ObligationCtxt, }, @@ -72,10 +72,10 @@ pub(crate) fn opaque_types_defined_by( // FIXME: Collect opaques from `#[define_opaque]`. - fn extend_with_opaques<'db>( - db: &'db dyn HirDatabase, - opaques: &Option>>>, - mut make_impl_trait: impl FnMut(ImplTraitIdx<'db>) -> ImplTraitId<'db>, + fn extend_with_opaques( + db: &dyn HirDatabase, + opaques: &Option>>, + mut make_impl_trait: impl FnMut(ImplTraitIdx) -> ImplTraitId, result: &mut Vec, ) { if let Some(opaques) = opaques { @@ -89,25 +89,25 @@ pub(crate) fn opaque_types_defined_by( // These are firewall queries to prevent drawing dependencies between infers: -#[salsa::tracked(returns(ref), unsafe(non_update_types))] +#[salsa::tracked(returns(ref))] pub(crate) fn rpit_hidden_types<'db>( db: &'db dyn HirDatabase, function: FunctionId, -) -> ArenaMap, EarlyBinder<'db, Ty<'db>>> { +) -> ArenaMap> { let infer = InferenceResult::for_body(db, function.into()); let mut result = ArenaMap::new(); for (opaque, hidden_type) in infer.return_position_impl_trait_types(db) { - result.insert(opaque, EarlyBinder::bind(hidden_type)); + result.insert(opaque, StoredEarlyBinder::bind(hidden_type.store())); } result.shrink_to_fit(); result } -#[salsa::tracked(returns(ref), unsafe(non_update_types))] +#[salsa::tracked(returns(ref))] pub(crate) fn tait_hidden_types<'db>( db: &'db dyn HirDatabase, type_alias: TypeAliasId, -) -> ArenaMap, EarlyBinder<'db, Ty<'db>>> { +) -> ArenaMap> { // Call this first, to not perform redundant work if there are no TAITs. let Some(taits_count) = ImplTraits::type_alias_impl_traits(db, type_alias) .as_deref() @@ -129,7 +129,7 @@ pub(crate) fn tait_hidden_types<'db>( let mut result = ArenaMap::with_capacity(taits_count); for defining_body in defining_bodies { let infer = InferenceResult::for_body(db, defining_body); - for (&opaque, &hidden_type) in &infer.type_of_opaque { + for (&opaque, hidden_type) in &infer.type_of_opaque { let ImplTraitId::TypeAliasImplTrait(opaque_owner, opaque_idx) = opaque.loc(db) else { continue; }; @@ -138,13 +138,18 @@ pub(crate) fn tait_hidden_types<'db>( } // In the presence of errors, we attempt to create a unified type from all // types. rustc doesn't do that, but this should improve the experience. - let hidden_type = infcx.insert_type_vars(hidden_type); + let hidden_type = infcx.insert_type_vars(hidden_type.as_ref()); match result.entry(opaque_idx) { la_arena::Entry::Vacant(entry) => { - entry.insert(EarlyBinder::bind(hidden_type)); + entry.insert(StoredEarlyBinder::bind(hidden_type.store())); } la_arena::Entry::Occupied(entry) => { - _ = ocx.eq(&cause, param_env, entry.get().instantiate_identity(), hidden_type); + _ = ocx.eq( + &cause, + param_env, + entry.get().get().instantiate_identity(), + hidden_type, + ); } } } @@ -157,12 +162,15 @@ pub(crate) fn tait_hidden_types<'db>( let idx = la_arena::Idx::from_raw(la_arena::RawIdx::from_u32(idx as u32)); match result.entry(idx) { la_arena::Entry::Vacant(entry) => { - entry.insert(EarlyBinder::bind(Ty::new_error(interner, ErrorGuaranteed))); + entry.insert(StoredEarlyBinder::bind( + Ty::new_error(interner, ErrorGuaranteed).store(), + )); } la_arena::Entry::Occupied(mut entry) => { - *entry.get_mut() = entry.get().map_bound(|hidden_type| { - infcx.resolve_vars_if_possible(hidden_type).replace_infer_with_error(interner) - }); + let hidden_type = entry.get().get().skip_binder(); + let hidden_type = + infcx.resolve_vars_if_possible(hidden_type).replace_infer_with_error(interner); + *entry.get_mut() = StoredEarlyBinder::bind(hidden_type.store()); } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs b/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs index 4164e39e6592..d97a35549ca4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/specialization.rs @@ -2,7 +2,6 @@ use hir_def::{HasModule, ImplId, nameres::crate_def_map}; use intern::sym; -use rustc_type_ir::inherent::SliceLike; use tracing::debug; use crate::{ diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests.rs index a31353f1e336..67ab89f5ec8f 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/tests.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests.rs @@ -149,9 +149,10 @@ fn check_impl( let (body, body_source_map) = db.body_with_source_map(def); let inference_result = InferenceResult::for_body(&db, def); - for (pat, mut ty) in inference_result.type_of_pat.iter() { + for (pat, ty) in inference_result.type_of_pat.iter() { + let mut ty = ty.as_ref(); if let Pat::Bind { id, .. } = body[pat] { - ty = &inference_result.type_of_binding[id]; + ty = inference_result.type_of_binding[id].as_ref(); } let node = match pat_node(&body_source_map, pat, &db) { Some(value) => value, @@ -169,6 +170,7 @@ fn check_impl( } for (expr, ty) in inference_result.type_of_expr.iter() { + let ty = ty.as_ref(); let node = match expr_node(&body_source_map, expr, &db) { Some(value) => value, None => continue, @@ -209,8 +211,8 @@ fn check_impl( let range = node.as_ref().original_file_range_rooted(&db); let actual = format!( "expected {}, got {}", - mismatch.expected.display_test(&db, display_target), - mismatch.actual.display_test(&db, display_target) + mismatch.expected.as_ref().display_test(&db, display_target), + mismatch.actual.as_ref().display_test(&db, display_target) ); match mismatches.remove(&range) { Some(annotation) => assert_eq!(actual, annotation), @@ -318,20 +320,20 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { crate::attach_db(&db, || { let mut buf = String::new(); - let mut infer_def = |inference_result: &InferenceResult<'_>, + let mut infer_def = |inference_result: &InferenceResult, body: Arc, body_source_map: Arc, krate: Crate| { let display_target = DisplayTarget::from_crate(&db, krate); - let mut types: Vec<(InFile, &Ty<'_>)> = Vec::new(); - let mut mismatches: Vec<(InFile, &TypeMismatch<'_>)> = Vec::new(); + let mut types: Vec<(InFile, Ty<'_>)> = Vec::new(); + let mut mismatches: Vec<(InFile, &TypeMismatch)> = Vec::new(); if let Some(self_param) = body.self_param { let ty = &inference_result.type_of_binding[self_param]; if let Some(syntax_ptr) = body_source_map.self_param_syntax() { let root = db.parse_or_expand(syntax_ptr.file_id); let node = syntax_ptr.map(|ptr| ptr.to_node(&root).syntax().clone()); - types.push((node, ty)); + types.push((node, ty.as_ref())); } } @@ -346,7 +348,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { } Err(SyntheticSyntax) => continue, }; - types.push((node.clone(), ty)); + types.push((node.clone(), ty.as_ref())); if let Some(mismatch) = inference_result.type_mismatch_for_pat(pat) { mismatches.push((node, mismatch)); } @@ -360,7 +362,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { } Err(SyntheticSyntax) => continue, }; - types.push((node.clone(), ty)); + types.push((node.clone(), ty.as_ref())); if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr) { mismatches.push((node, mismatch)); } @@ -401,8 +403,8 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { "{}{:?}: expected {}, got {}\n", macro_prefix, range, - mismatch.expected.display_test(&db, display_target), - mismatch.actual.display_test(&db, display_target), + mismatch.expected.as_ref().display_test(&db, display_target), + mismatch.actual.as_ref().display_test(&db, display_target), ); } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/closure_captures.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/closure_captures.rs index ff55ff54cefb..3bdc72d01500 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/closure_captures.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/closure_captures.rs @@ -74,6 +74,7 @@ fn check_closure_captures(#[rust_analyzer::rust_fixture] ra_fixture: &str, expec let place = capture.display_place(closure.0, db); let capture_ty = capture .ty + .get() .skip_binder() .display_test(db, DisplayTarget::from_crate(db, module.krate(db))) .to_string(); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs index 7b0c1d35442e..6558d2179fba 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs @@ -28,7 +28,7 @@ fn foo() -> i32 { } }); }, - &[("InferenceResult < 'db >::for_body_", 1)], + &[("InferenceResult::for_body_", 1)], expect_test::expect![[r#" [ "crate_local_def_map", @@ -36,17 +36,17 @@ fn foo() -> i32 { "ast_id_map_shim", "parse_shim", "real_span_map_shim", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "function_signature_shim", "function_signature_with_source_map_shim", "AttrFlags::query_", "body_shim", "body_with_source_map_shim", - "trait_environment_shim", + "trait_environment_query", "lang_items", "crate_lang_items", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", "expr_scopes_shim", ] "#]], @@ -72,7 +72,7 @@ fn foo() -> i32 { } }); }, - &[("InferenceResult < 'db >::for_body_", 0)], + &[("InferenceResult::for_body_", 0)], expect_test::expect![[r#" [ "parse_shim", @@ -115,7 +115,7 @@ fn baz() -> i32 { } }); }, - &[("InferenceResult < 'db >::for_body_", 3)], + &[("InferenceResult::for_body_", 3)], expect_test::expect![[r#" [ "crate_local_def_map", @@ -123,37 +123,37 @@ fn baz() -> i32 { "ast_id_map_shim", "parse_shim", "real_span_map_shim", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "function_signature_shim", "function_signature_with_source_map_shim", "AttrFlags::query_", "body_shim", "body_with_source_map_shim", - "trait_environment_shim", + "trait_environment_query", "lang_items", "crate_lang_items", "AttrFlags::query_", "AttrFlags::query_", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", "expr_scopes_shim", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "function_signature_shim", "function_signature_with_source_map_shim", "body_shim", "body_with_source_map_shim", - "trait_environment_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", + "trait_environment_query", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", "expr_scopes_shim", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "function_signature_shim", "function_signature_with_source_map_shim", "body_shim", "body_with_source_map_shim", - "trait_environment_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", + "trait_environment_query", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", "expr_scopes_shim", ] "#]], @@ -184,7 +184,7 @@ fn baz() -> i32 { } }); }, - &[("InferenceResult < 'db >::for_body_", 1)], + &[("InferenceResult::for_body_", 1)], expect_test::expect![[r#" [ "parse_shim", @@ -202,7 +202,7 @@ fn baz() -> i32 { "function_signature_shim", "body_with_source_map_shim", "body_shim", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "expr_scopes_shim", "function_signature_with_source_map_shim", "function_signature_shim", @@ -502,7 +502,7 @@ impl SomeStruct { "crate_local_def_map", "TraitImpls::for_crate_", "AttrFlags::query_", - "impl_trait_with_diagnostics_shim", + "impl_trait_with_diagnostics_query", "impl_signature_shim", "impl_signature_with_source_map_shim", "lang_items", @@ -512,7 +512,7 @@ impl SomeStruct { "AttrFlags::query_", "AttrFlags::query_", "AttrFlags::query_", - "impl_self_ty_with_diagnostics_shim", + "impl_self_ty_with_diagnostics_query", "struct_signature_shim", "struct_signature_with_source_map_shim", ] @@ -574,7 +574,7 @@ fn main() { "body_with_source_map_shim", "AttrFlags::query_", "ImplItems::of_", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "trait_signature_shim", "trait_signature_with_source_map_shim", "AttrFlags::query_", @@ -583,36 +583,36 @@ fn main() { "AttrFlags::query_", "body_shim", "body_with_source_map_shim", - "trait_environment_shim", + "trait_environment_query", "lang_items", "crate_lang_items", "AttrFlags::query_", "AttrFlags::query_", - "GenericPredicates < 'db >::query_with_diagnostics_", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", - "InferenceResult < 'db >::for_body_", + "GenericPredicates::query_with_diagnostics_", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", + "InferenceResult::for_body_", "function_signature_shim", "function_signature_with_source_map_shim", - "trait_environment_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", + "trait_environment_query", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", "expr_scopes_shim", "struct_signature_shim", "struct_signature_with_source_map_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", - "value_ty_shim", + "GenericPredicates::query_with_diagnostics_", + "value_ty_query", "VariantFields::firewall_", "VariantFields::query_", "InherentImpls::for_crate_", "impl_signature_shim", "impl_signature_with_source_map_shim", - "callable_item_signature_shim", + "callable_item_signature_query", "TraitImpls::for_crate_and_deps_", "TraitImpls::for_crate_", - "impl_trait_with_diagnostics_shim", - "impl_self_ty_with_diagnostics_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", + "impl_trait_with_diagnostics_query", + "impl_self_ty_with_diagnostics_query", + "GenericPredicates::query_with_diagnostics_", ] "#]], ); @@ -671,7 +671,7 @@ fn main() { "AttrFlags::query_", "body_shim", "ImplItems::of_", - "InferenceResult < 'db >::for_body_", + "InferenceResult::for_body_", "AttrFlags::query_", "trait_signature_with_source_map_shim", "AttrFlags::query_", @@ -683,25 +683,25 @@ fn main() { "AttrFlags::query_", "AttrFlags::query_", "AttrFlags::query_", - "GenericPredicates < 'db >::query_with_diagnostics_", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", - "InferenceResult < 'db >::for_body_", + "GenericPredicates::query_with_diagnostics_", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", + "InferenceResult::for_body_", "function_signature_with_source_map_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", - "ImplTraits < 'db >::return_type_impl_traits_", + "GenericPredicates::query_with_diagnostics_", + "ImplTraits::return_type_impl_traits_", "expr_scopes_shim", "struct_signature_with_source_map_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", + "GenericPredicates::query_with_diagnostics_", "VariantFields::query_", "InherentImpls::for_crate_", "impl_signature_with_source_map_shim", "impl_signature_shim", - "callable_item_signature_shim", + "callable_item_signature_query", "TraitImpls::for_crate_", - "impl_trait_with_diagnostics_shim", - "impl_self_ty_with_diagnostics_shim", - "GenericPredicates < 'db >::query_with_diagnostics_", + "impl_trait_with_diagnostics_query", + "impl_self_ty_with_diagnostics_query", + "GenericPredicates::query_with_diagnostics_", ] "#]], ); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs b/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs index 2f8c31ec6074..ad8de293d5a5 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs @@ -21,8 +21,8 @@ use rustc_type_ir::{ use crate::{ db::HirDatabase, next_solver::{ - Canonical, DbInterner, GenericArgs, Goal, ParamEnv, Predicate, SolverContext, Span, Ty, - TyKind, + Canonical, DbInterner, GenericArgs, Goal, ParamEnv, Predicate, SolverContext, Span, + StoredClauses, Ty, TyKind, infer::{DbInternerInferExt, InferCtxt, traits::ObligationCause}, obligation_ctxt::ObligationCtxt, }, @@ -35,6 +35,31 @@ pub struct ParamEnvAndCrate<'db> { pub krate: Crate, } +impl<'db> ParamEnvAndCrate<'db> { + #[inline] + pub fn store(self) -> StoredParamEnvAndCrate { + StoredParamEnvAndCrate { param_env: self.param_env.clauses.store(), krate: self.krate } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct StoredParamEnvAndCrate { + param_env: StoredClauses, + pub krate: Crate, +} + +impl StoredParamEnvAndCrate { + #[inline] + pub fn param_env(&self) -> ParamEnv<'_> { + ParamEnv { clauses: self.param_env.as_ref() } + } + + #[inline] + pub fn as_ref(&self) -> ParamEnvAndCrate<'_> { + ParamEnvAndCrate { param_env: self.param_env(), krate: self.krate } + } +} + /// This should be used in `hir` only. pub fn structurally_normalize_ty<'db>( infcx: &InferCtxt<'db>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs index b32180d41247..bfb9a3f77e94 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs @@ -17,7 +17,7 @@ use hir_def::{AdtId, GenericDefId, GenericParamId, VariantId, signatures::Struct use rustc_ast_ir::Mutability; use rustc_type_ir::{ Variance, - inherent::{AdtDef, IntoKind, SliceLike}, + inherent::{AdtDef, IntoKind}, }; use stdx::never; @@ -25,12 +25,22 @@ use crate::{ db::HirDatabase, generics::{Generics, generics}, next_solver::{ - Const, ConstKind, DbInterner, ExistentialPredicate, GenericArg, GenericArgs, Region, - RegionKind, Term, Ty, TyKind, VariancesOf, + Const, ConstKind, DbInterner, ExistentialPredicate, GenericArgKind, GenericArgs, Region, + RegionKind, StoredVariancesOf, TermKind, Ty, TyKind, VariancesOf, }, }; pub(crate) fn variances_of(db: &dyn HirDatabase, def: GenericDefId) -> VariancesOf<'_> { + variances_of_query(db, def).as_ref() +} + +#[salsa::tracked( + returns(ref), + // cycle_fn = crate::variance::variances_of_cycle_fn, + // cycle_initial = crate::variance::variances_of_cycle_initial, + cycle_result = crate::variance::variances_of_cycle_initial, +)] +fn variances_of_query(db: &dyn HirDatabase, def: GenericDefId) -> StoredVariancesOf { tracing::debug!("variances_of(def={:?})", def); let interner = DbInterner::new_no_crate(db); match def { @@ -39,19 +49,19 @@ pub(crate) fn variances_of(db: &dyn HirDatabase, def: GenericDefId) -> Variances if let AdtId::StructId(id) = adt { let flags = &db.struct_signature(id).flags; if flags.contains(StructFlags::IS_UNSAFE_CELL) { - return VariancesOf::new_from_iter(interner, [Variance::Invariant]); + return VariancesOf::new_from_iter(interner, [Variance::Invariant]).store(); } else if flags.contains(StructFlags::IS_PHANTOM_DATA) { - return VariancesOf::new_from_iter(interner, [Variance::Covariant]); + return VariancesOf::new_from_iter(interner, [Variance::Covariant]).store(); } } } - _ => return VariancesOf::new_from_iter(interner, []), + _ => return VariancesOf::empty(interner).store(), } let generics = generics(db, def); let count = generics.len(); if count == 0 { - return VariancesOf::new_from_iter(interner, []); + return VariancesOf::empty(interner).store(); } let mut variances = Context { generics, variances: vec![Variance::Bivariant; count], db }.solve(); @@ -71,7 +81,7 @@ pub(crate) fn variances_of(db: &dyn HirDatabase, def: GenericDefId) -> Variances } } - VariancesOf::new_from_iter(interner, variances) + VariancesOf::new_from_iter(interner, variances).store() } // pub(crate) fn variances_of_cycle_fn( @@ -107,13 +117,13 @@ pub(crate) fn variances_of_cycle_initial( db: &dyn HirDatabase, _: salsa::Id, def: GenericDefId, -) -> VariancesOf<'_> { +) -> StoredVariancesOf { let interner = DbInterner::new_no_crate(db); let generics = generics(db, def); let count = generics.len(); // FIXME(next-solver): Returns `Invariance` and not `Bivariance` here, see the comment in the main query. - VariancesOf::new_from_iter(interner, std::iter::repeat_n(Variance::Invariant, count)) + VariancesOf::new_from_iter(interner, std::iter::repeat_n(Variance::Invariant, count)).store() } struct Context<'db> { @@ -131,7 +141,7 @@ impl<'db> Context<'db> { let mut add_constraints_from_variant = |variant| { for (_, field) in db.field_types(variant).iter() { self.add_constraints_from_ty( - field.instantiate_identity(), + field.get().instantiate_identity(), Variance::Covariant, ); } @@ -233,11 +243,11 @@ impl<'db> Context<'db> { } ExistentialPredicate::Projection(projection) => { self.add_constraints_from_invariant_args(projection.args); - match projection.term { - Term::Ty(ty) => { + match projection.term.kind() { + TermKind::Ty(ty) => { self.add_constraints_from_ty(ty, Variance::Invariant) } - Term::Const(konst) => self.add_constraints_from_const(konst), + TermKind::Const(konst) => self.add_constraints_from_const(konst), } } ExistentialPredicate::AutoTrait(_) => {} @@ -267,12 +277,12 @@ impl<'db> Context<'db> { fn add_constraints_from_invariant_args(&mut self, args: GenericArgs<'db>) { for k in args.iter() { - match k { - GenericArg::Lifetime(lt) => { + match k.kind() { + GenericArgKind::Lifetime(lt) => { self.add_constraints_from_region(lt, Variance::Invariant) } - GenericArg::Ty(ty) => self.add_constraints_from_ty(ty, Variance::Invariant), - GenericArg::Const(val) => self.add_constraints_from_const(val), + GenericArgKind::Type(ty) => self.add_constraints_from_ty(ty, Variance::Invariant), + GenericArgKind::Const(val) => self.add_constraints_from_const(val), } } } @@ -291,10 +301,12 @@ impl<'db> Context<'db> { let variances = self.db.variances_of(def_id); for (k, v) in args.iter().zip(variances) { - match k { - GenericArg::Lifetime(lt) => self.add_constraints_from_region(lt, variance.xform(v)), - GenericArg::Ty(ty) => self.add_constraints_from_ty(ty, variance.xform(v)), - GenericArg::Const(val) => self.add_constraints_from_const(val), + match k.kind() { + GenericArgKind::Lifetime(lt) => { + self.add_constraints_from_region(lt, variance.xform(v)) + } + GenericArgKind::Type(ty) => self.add_constraints_from_ty(ty, variance.xform(v)), + GenericArgKind::Const(val) => self.add_constraints_from_const(val), } } } @@ -388,7 +400,7 @@ mod tests { AdtId, GenericDefId, ModuleDefId, hir::generics::GenericParamDataRef, src::HasSource, }; use itertools::Itertools; - use rustc_type_ir::{Variance, inherent::SliceLike}; + use rustc_type_ir::Variance; use stdx::format_to; use syntax::{AstNode, ast::HasName}; use test_fixture::WithFixture; diff --git a/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs b/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs index 6ef6ea272e58..050777a4806d 100644 --- a/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs @@ -617,7 +617,7 @@ impl<'db> AnyDiagnostic<'db> { pub(crate) fn inference_diagnostic( db: &'db dyn HirDatabase, def: DefWithBodyId, - d: &InferenceDiagnostic<'db>, + d: &InferenceDiagnostic, source_map: &hir_def::expr_store::BodySourceMap, sig_map: &hir_def::expr_store::ExpressionStoreSourceMap, ) -> Option> { @@ -663,7 +663,8 @@ impl<'db> AnyDiagnostic<'db> { } InferenceDiagnostic::ExpectedFunction { call_expr, found } => { let call_expr = expr_syntax(*call_expr)?; - ExpectedFunction { call: call_expr, found: Type::new(db, def, *found) }.into() + ExpectedFunction { call: call_expr, found: Type::new(db, def, found.as_ref()) } + .into() } InferenceDiagnostic::UnresolvedField { expr, @@ -675,7 +676,7 @@ impl<'db> AnyDiagnostic<'db> { UnresolvedField { expr, name: name.clone(), - receiver: Type::new(db, def, *receiver), + receiver: Type::new(db, def, receiver.as_ref()), method_with_same_name_exists: *method_with_same_name_exists, } .into() @@ -691,8 +692,10 @@ impl<'db> AnyDiagnostic<'db> { UnresolvedMethodCall { expr, name: name.clone(), - receiver: Type::new(db, def, *receiver), - field_with_same_name: (*field_with_same_name).map(|ty| Type::new(db, def, ty)), + receiver: Type::new(db, def, receiver.as_ref()), + field_with_same_name: field_with_same_name + .as_ref() + .map(|ty| Type::new(db, def, ty.as_ref())), assoc_func_with_same_name: assoc_func_with_same_name.map(Into::into), } .into() @@ -719,7 +722,7 @@ impl<'db> AnyDiagnostic<'db> { } InferenceDiagnostic::TypedHole { expr, expected } => { let expr = expr_syntax(*expr)?; - TypedHole { expr, expected: Type::new(db, def, *expected) }.into() + TypedHole { expr, expected: Type::new(db, def, expected.as_ref()) }.into() } &InferenceDiagnostic::MismatchedTupleStructPatArgCount { pat, expected, found } => { let expr_or_pat = match pat { @@ -736,12 +739,12 @@ impl<'db> AnyDiagnostic<'db> { } InferenceDiagnostic::CastToUnsized { expr, cast_ty } => { let expr = expr_syntax(*expr)?; - CastToUnsized { expr, cast_ty: Type::new(db, def, *cast_ty) }.into() + CastToUnsized { expr, cast_ty: Type::new(db, def, cast_ty.as_ref()) }.into() } InferenceDiagnostic::InvalidCast { expr, error, expr_ty, cast_ty } => { let expr = expr_syntax(*expr)?; - let expr_ty = Type::new(db, def, *expr_ty); - let cast_ty = Type::new(db, def, *cast_ty); + let expr_ty = Type::new(db, def, expr_ty.as_ref()); + let cast_ty = Type::new(db, def, cast_ty.as_ref()); InvalidCast { expr, error: *error, expr_ty, cast_ty }.into() } InferenceDiagnostic::TyDiagnostic { source, diag } => { diff --git a/src/tools/rust-analyzer/crates/hir/src/lib.rs b/src/tools/rust-analyzer/crates/hir/src/lib.rs index ae7e4aa6c8ac..3532220b72ae 100644 --- a/src/tools/rust-analyzer/crates/hir/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir/src/lib.rs @@ -102,7 +102,7 @@ use rustc_type_ir::{ }; use smallvec::SmallVec; use span::{AstIdNode, Edition, FileId}; -use stdx::{format_to, impl_from, never}; +use stdx::{format_to, impl_from, never, variance::PhantomCovariantLifetime}; use syntax::{ AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr, TextRange, ToSmolStr, ast::{self, HasName, HasVisibility as _}, @@ -697,7 +697,7 @@ impl Module { push_ty_diagnostics( db, acc, - db.field_types_with_diagnostics(s.id.into()).1, + db.field_types_with_diagnostics(s.id.into()).1.clone(), source_map, ); } @@ -709,7 +709,7 @@ impl Module { push_ty_diagnostics( db, acc, - db.field_types_with_diagnostics(u.id.into()).1, + db.field_types_with_diagnostics(u.id.into()).1.clone(), source_map, ); } @@ -739,7 +739,7 @@ impl Module { push_ty_diagnostics( db, acc, - db.field_types_with_diagnostics(v.into()).1, + db.field_types_with_diagnostics(v.into()).1.clone(), source_map, ); expr_store_diagnostics(db, acc, source_map); @@ -1219,7 +1219,7 @@ impl<'db> InstantiatedField<'db> { let interner = DbInterner::new_no_crate(db); let var_id = self.inner.parent.into(); - let field = db.field_types(var_id)[self.inner.id]; + let field = db.field_types(var_id)[self.inner.id].get(); let ty = field.instantiate(interner, self.args); TypeNs::new(db, var_id, ty) } @@ -1297,7 +1297,7 @@ impl Field { /// context of the field definition. pub fn ty<'db>(&self, db: &'db dyn HirDatabase) -> TypeNs<'db> { let var_id = self.parent.into(); - let ty = db.field_types(var_id)[self.id].skip_binder(); + let ty = db.field_types(var_id)[self.id].get().skip_binder(); TypeNs::new(db, var_id, ty) } @@ -1315,13 +1315,13 @@ impl Field { }; let interner = DbInterner::new_no_crate(db); let args = generic_args_from_tys(interner, def_id.into(), generics.map(|ty| ty.ty)); - let ty = db.field_types(var_id)[self.id].instantiate(interner, args); + let ty = db.field_types(var_id)[self.id].get().instantiate(interner, args); Type::new(db, var_id, ty) } pub fn layout(&self, db: &dyn HirDatabase) -> Result { db.layout_of_ty( - self.ty(db).ty, + self.ty(db).ty.store(), param_env_from_has_crate( db, match hir_def::VariantId::from(self.parent) { @@ -1331,7 +1331,8 @@ impl Field { hir_def::VariantId::StructId(id) => GenericDefId::AdtId(id.into()), hir_def::VariantId::UnionId(id) => GenericDefId::AdtId(id.into()), }, - ), + ) + .store(), ) .map(|layout| Layout(layout, db.target_data_layout(self.krate(db).into()).unwrap())) } @@ -1662,7 +1663,7 @@ impl Variant { self.source(db)?.value.expr() } - pub fn eval(self, db: &dyn HirDatabase) -> Result> { + pub fn eval(self, db: &dyn HirDatabase) -> Result { db.const_eval_discriminant(self.into()) } @@ -1753,7 +1754,7 @@ impl Adt { let args = GenericArgs::for_item_with_defaults(interner, adt_id.into(), |_, id, _| { GenericArg::error_from_id(interner, id) }); - db.layout_of_adt(adt_id, args, param_env_from_has_crate(db, adt_id)) + db.layout_of_adt(adt_id, args.store(), param_env_from_has_crate(db, adt_id).store()) .map(|layout| Layout(layout, db.target_data_layout(self.krate(db).id).unwrap())) } @@ -1988,8 +1989,8 @@ impl DefWithBody { acc.push( TypeMismatch { expr_or_pat, - expected: Type::new(db, DefWithBodyId::from(self), mismatch.expected), - actual: Type::new(db, DefWithBodyId::from(self), mismatch.actual), + expected: Type::new(db, DefWithBodyId::from(self), mismatch.expected.as_ref()), + actual: Type::new(db, DefWithBodyId::from(self), mismatch.actual.as_ref()), } .into(), ); @@ -2059,7 +2060,10 @@ impl DefWithBody { } mir::MirSpan::Unknown => continue, }; - acc.push(MovedOutOfRef { ty: Type::new_for_crate(krate, moof.ty), span }.into()) + acc.push( + MovedOutOfRef { ty: Type::new_for_crate(krate, moof.ty.as_ref()), span } + .into(), + ) } let mol = &borrowck_result.mutability_of_locals; for (binding_id, binding_data) in body.bindings() { @@ -2468,15 +2472,16 @@ impl Function { self, db: &dyn HirDatabase, span_formatter: impl Fn(FileId, TextRange) -> String, - ) -> Result> { + ) -> Result { let interner = DbInterner::new_no_crate(db); let body = db.monomorphized_mir_body( self.id.into(), - GenericArgs::new_from_iter(interner, []), + GenericArgs::empty(interner).store(), ParamEnvAndCrate { param_env: db.trait_environment(self.id.into()), krate: self.id.module(db).krate(db), - }, + } + .store(), )?; let (result, output) = interpret_mir(db, body, false, None)?; let mut text = match result { @@ -2728,11 +2733,14 @@ impl Const { } /// Evaluate the constant. - pub fn eval(self, db: &dyn HirDatabase) -> Result, ConstEvalError<'_>> { + pub fn eval(self, db: &dyn HirDatabase) -> Result, ConstEvalError> { let interner = DbInterner::new_no_crate(db); let ty = db.value_ty(self.id.into()).unwrap().instantiate_identity(); - db.const_eval(self.id, GenericArgs::new_from_iter(interner, []), None) - .map(|it| EvaluatedConst { const_: it, def: self.id.into(), ty }) + db.const_eval(self.id, GenericArgs::empty(interner), None).map(|it| EvaluatedConst { + const_: it, + def: self.id.into(), + ty, + }) } } @@ -2753,7 +2761,7 @@ impl<'db> EvaluatedConst<'db> { format!("{}", self.const_.display(db, display_target)) } - pub fn render_debug(&self, db: &'db dyn HirDatabase) -> Result> { + pub fn render_debug(&self, db: &'db dyn HirDatabase) -> Result { let kind = self.const_.kind(); if let ConstKind::Value(c) = kind && let ty = c.ty.kind() @@ -2809,7 +2817,7 @@ impl Static { } /// Evaluate the static initializer. - pub fn eval(self, db: &dyn HirDatabase) -> Result, ConstEvalError<'_>> { + pub fn eval(self, db: &dyn HirDatabase) -> Result, ConstEvalError> { let ty = db.value_ty(self.id.into()).unwrap().instantiate_identity(); db.const_eval_static(self.id).map(|it| EvaluatedConst { const_: it, @@ -3847,7 +3855,7 @@ impl Local { pub fn ty(self, db: &dyn HirDatabase) -> Type<'_> { let def = self.parent; let infer = InferenceResult::for_body(db, def); - let ty = infer[self.binding_id]; + let ty = infer.binding_ty(self.binding_id); Type::new(db, def, ty) } @@ -4152,8 +4160,8 @@ impl TypeParam { pub fn default(self, db: &dyn HirDatabase) -> Option> { let ty = generic_arg_from_param(db, self.id.into())?; let resolver = self.id.parent().resolver(db); - match ty { - GenericArg::Ty(it) if !it.is_ty_error() => { + match ty.kind() { + rustc_type_ir::GenericArgKind::Type(it) if !it.is_ty_error() => { Some(Type::new_with_resolver_inner(db, &resolver, it)) } _ => None, @@ -4545,7 +4553,12 @@ impl<'db> Closure<'db> { info.0 .iter() .cloned() - .map(|capture| ClosureCapture { owner, closure: id, capture }) + .map(|capture| ClosureCapture { + owner, + closure: id, + capture, + _marker: PhantomCovariantLifetime::new(), + }) .collect() } @@ -4650,7 +4663,8 @@ impl FnTrait { pub struct ClosureCapture<'db> { owner: DefWithBodyId, closure: InternedClosureId, - capture: hir_ty::CapturedItem<'db>, + capture: hir_ty::CapturedItem, + _marker: PhantomCovariantLifetime<'db>, } impl<'db> ClosureCapture<'db> { @@ -4917,7 +4931,7 @@ impl<'db> Type<'db> { .fields() .iter() .map(|(idx, _)| { - field_types[idx].instantiate(self.interner, args) + field_types[idx].get().instantiate(self.interner, args) }) .filter(|it| !it.references_non_lt_error()) .collect() @@ -5241,7 +5255,7 @@ impl<'db> Type<'db> { .iter() .map(|(local_id, ty)| { let def = Field { parent: variant_id.into(), id: local_id }; - let ty = ty.instantiate(interner, substs); + let ty = ty.get().instantiate(interner, substs); (def, self.derived(ty)) }) .collect() @@ -5399,12 +5413,14 @@ impl<'db> Type<'db> { .as_adt() .into_iter() .flat_map(|(_, substs)| substs.iter()) - .filter_map(move |arg| match arg { - GenericArg::Ty(ty) => Some(format_smolstr!("{}", ty.display(db, display_target))), - GenericArg::Const(const_) => { + .filter_map(move |arg| match arg.kind() { + rustc_type_ir::GenericArgKind::Type(ty) => { + Some(format_smolstr!("{}", ty.display(db, display_target))) + } + rustc_type_ir::GenericArgKind::Const(const_) => { Some(format_smolstr!("{}", const_.display(db, display_target))) } - GenericArg::Lifetime(_) => None, + rustc_type_ir::GenericArgKind::Lifetime(_) => None, }) } @@ -5808,7 +5824,7 @@ impl<'db> Type<'db> { } pub fn layout(&self, db: &'db dyn HirDatabase) -> Result { - db.layout_of_ty(self.ty, self.env) + db.layout_of_ty(self.ty.store(), self.env.store()) .map(|layout| Layout(layout, db.target_data_layout(self.env.krate).unwrap())) } @@ -5840,7 +5856,7 @@ impl<'db> TypeNs<'db> { pub fn impls_trait(&self, infcx: InferCtxt<'db>, trait_: Trait, args: &[TypeNs<'db>]) -> bool { let args = GenericArgs::new_from_iter( infcx.interner, - [self.ty].into_iter().chain(args.iter().map(|t| t.ty)).map(|t| t.into()), + [self.ty].into_iter().chain(args.iter().map(|t| t.ty)).map(GenericArg::from), ); let trait_ref = hir_ty::next_solver::TraitRef::new(infcx.interner, trait_.id.into(), args); diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs index b65a24d61c6e..fd08528e86ab 100644 --- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs @@ -1653,8 +1653,11 @@ impl<'db> SemanticsImpl<'db> { analyzer.expr_adjustments(expr).map(|it| { it.iter() .map(|adjust| { - let target = - Type::new_with_resolver(self.db, &analyzer.resolver, adjust.target); + let target = Type::new_with_resolver( + self.db, + &analyzer.resolver, + adjust.target.as_ref(), + ); let kind = match adjust.kind { hir_ty::Adjust::NeverToAny => Adjust::NeverToAny, hir_ty::Adjust::Deref(Some(hir_ty::OverloadedDeref(m))) => { diff --git a/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs b/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs index b90eb97d8791..848ad3380133 100644 --- a/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs +++ b/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs @@ -79,7 +79,7 @@ pub(crate) enum BodyOrSig<'db> { def: DefWithBodyId, body: Arc, source_map: Arc, - infer: Option<&'db InferenceResult<'db>>, + infer: Option<&'db InferenceResult>, }, // To be folded into body once it is considered one VariantFields { @@ -119,7 +119,7 @@ impl<'db> SourceAnalyzer<'db> { def: DefWithBodyId, node @ InFile { file_id, .. }: InFile<&SyntaxNode>, offset: Option, - infer: Option<&'db InferenceResult<'db>>, + infer: Option<&'db InferenceResult>, ) -> SourceAnalyzer<'db> { let (body, source_map) = db.body_with_source_map(def); let scopes = db.expr_scopes(def); @@ -185,9 +185,7 @@ impl<'db> SourceAnalyzer<'db> { } // FIXME: Remove this - fn body_( - &self, - ) -> Option<(DefWithBodyId, &Body, &BodySourceMap, Option<&InferenceResult<'db>>)> { + fn body_(&self) -> Option<(DefWithBodyId, &Body, &BodySourceMap, Option<&InferenceResult>)> { self.body_or_sig.as_ref().and_then(|it| match it { BodyOrSig::Body { def, body, source_map, infer } => { Some((*def, &**body, &**source_map, infer.as_deref())) @@ -196,7 +194,7 @@ impl<'db> SourceAnalyzer<'db> { }) } - fn infer(&self) -> Option<&InferenceResult<'db>> { + fn infer(&self) -> Option<&InferenceResult> { self.body_or_sig.as_ref().and_then(|it| match it { BodyOrSig::Sig { .. } => None, BodyOrSig::VariantFields { .. } => None, @@ -260,7 +258,7 @@ impl<'db> SourceAnalyzer<'db> { if let Pat::Bind { id, .. } = self.store()?[pat_id.as_pat()?] { Some(id) } else { None } } - pub(crate) fn expr_adjustments(&self, expr: &ast::Expr) -> Option<&[Adjustment<'db>]> { + pub(crate) fn expr_adjustments(&self, expr: &ast::Expr) -> Option<&[Adjustment]> { // It is safe to omit destructuring assignments here because they have no adjustments (neither // expressions nor patterns). let expr_id = self.expr_id(expr.clone())?.as_expr()?; @@ -326,8 +324,8 @@ impl<'db> SourceAnalyzer<'db> { let coerced = expr_id .as_expr() .and_then(|expr_id| infer.expr_adjustment(expr_id)) - .and_then(|adjusts| adjusts.last().map(|adjust| adjust.target)); - let ty = infer[expr_id]; + .and_then(|adjusts| adjusts.last().map(|adjust| adjust.target.as_ref())); + let ty = infer.expr_or_pat_ty(expr_id); let mk_ty = |ty: Ty<'db>| Type::new_with_resolver(db, &self.resolver, ty); Some((mk_ty(ty), coerced.map(mk_ty))) } @@ -342,14 +340,15 @@ impl<'db> SourceAnalyzer<'db> { let coerced = match expr_or_pat_id { ExprOrPatId::ExprId(idx) => infer .expr_adjustment(idx) - .and_then(|adjusts| adjusts.last().cloned()) - .map(|adjust| adjust.target), - ExprOrPatId::PatId(idx) => { - infer.pat_adjustment(idx).and_then(|adjusts| adjusts.last().cloned()) - } + .and_then(|adjusts| adjusts.last()) + .map(|adjust| adjust.target.as_ref()), + ExprOrPatId::PatId(idx) => infer + .pat_adjustment(idx) + .and_then(|adjusts| adjusts.last()) + .map(|adjust| adjust.as_ref()), }; - let ty = infer[expr_or_pat_id]; + let ty = infer.expr_or_pat_ty(expr_or_pat_id); let mk_ty = |ty: Ty<'db>| Type::new_with_resolver(db, &self.resolver, ty); Some((mk_ty(ty), coerced.map(mk_ty))) } @@ -361,7 +360,7 @@ impl<'db> SourceAnalyzer<'db> { ) -> Option> { let binding_id = self.binding_id_of_pat(pat)?; let infer = self.infer()?; - let ty = infer[binding_id]; + let ty = infer.binding_ty(binding_id); let mk_ty = |ty: Ty<'db>| Type::new_with_resolver(db, &self.resolver, ty); Some(mk_ty(ty)) } @@ -372,7 +371,7 @@ impl<'db> SourceAnalyzer<'db> { _param: &ast::SelfParam, ) -> Option> { let binding = self.body()?.self_param?; - let ty = self.infer()?[binding]; + let ty = self.infer()?.binding_ty(binding); Some(Type::new_with_resolver(db, &self.resolver, ty)) } @@ -404,7 +403,7 @@ impl<'db> SourceAnalyzer<'db> { infer .pat_adjustment(pat_id.as_pat()?)? .iter() - .map(|ty| Type::new_with_resolver(db, &self.resolver, *ty)) + .map(|ty| Type::new_with_resolver(db, &self.resolver, ty.as_ref())) .collect(), ) } @@ -482,7 +481,7 @@ impl<'db> SourceAnalyzer<'db> { fn field_subst( &self, field_expr: ExprId, - infer: &InferenceResult<'db>, + infer: &InferenceResult, db: &'db dyn HirDatabase, ) -> Option> { let body = self.store()?; @@ -598,8 +597,7 @@ impl<'db> SourceAnalyzer<'db> { let poll_fn = self.lang_items(db).FuturePoll?; // HACK: subst for `poll()` coincides with that for `Future` because `poll()` itself // doesn't have any generic parameters, so we skip building another subst for `poll()`. - let interner = DbInterner::new_no_crate(db); - let substs = GenericArgs::new_from_iter(interner, [ty.into()]); + let substs = GenericArgs::new_from_slice(&[ty.into()]); Some(self.resolve_impl_method_or_trait_def(db, poll_fn, substs)) } @@ -641,10 +639,9 @@ impl<'db> SourceAnalyzer<'db> { let ty = self.ty_of_expr(prefix_expr.expr()?)?; - let interner = DbInterner::new_no_crate(db); // HACK: subst for all methods coincides with that for their trait because the methods // don't have any generic parameters, so we skip building another subst for the methods. - let substs = GenericArgs::new_from_iter(interner, [ty.into()]); + let substs = GenericArgs::new_from_slice(&[ty.into()]); Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } @@ -674,8 +671,7 @@ impl<'db> SourceAnalyzer<'db> { .unwrap_or(index_fn); // HACK: subst for all methods coincides with that for their trait because the methods // don't have any generic parameters, so we skip building another subst for the methods. - let interner = DbInterner::new_no_crate(db); - let substs = GenericArgs::new_from_iter(interner, [base_ty.into(), index_ty.into()]); + let substs = GenericArgs::new_from_slice(&[base_ty.into(), index_ty.into()]); Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } @@ -694,8 +690,7 @@ impl<'db> SourceAnalyzer<'db> { })?; // HACK: subst for `index()` coincides with that for `Index` because `index()` itself // doesn't have any generic parameters, so we skip building another subst for `index()`. - let interner = DbInterner::new_no_crate(db); - let substs = GenericArgs::new_from_iter(interner, [lhs.into(), rhs.into()]); + let substs = GenericArgs::new_from_slice(&[lhs.into(), rhs.into()]); Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } @@ -710,8 +705,7 @@ impl<'db> SourceAnalyzer<'db> { let op_fn = self.lang_items(db).TryTraitBranch?; // HACK: subst for `branch()` coincides with that for `Try` because `branch()` itself // doesn't have any generic parameters, so we skip building another subst for `branch()`. - let interner = DbInterner::new_no_crate(db); - let substs = GenericArgs::new_from_iter(interner, [ty.into()]); + let substs = GenericArgs::new_from_slice(&[ty.into()]); Some(self.resolve_impl_method_or_trait_def(db, op_fn, substs)) } @@ -751,7 +745,8 @@ impl<'db> SourceAnalyzer<'db> { let variant = self.infer()?.variant_resolution_for_expr_or_pat(expr_id)?; let variant_data = variant.fields(db); let field = FieldId { parent: variant, local_id: variant_data.field(&local_name)? }; - let field_ty = (*db.field_types(variant).get(field.local_id)?).instantiate(interner, subst); + let field_ty = + (*db.field_types(variant).get(field.local_id)?).get().instantiate(interner, subst); Some(( field.into(), local, @@ -772,8 +767,9 @@ impl<'db> SourceAnalyzer<'db> { let variant = self.infer()?.variant_resolution_for_pat(pat_id.as_pat()?)?; let variant_data = variant.fields(db); let field = FieldId { parent: variant, local_id: variant_data.field(&field_name)? }; - let (adt, subst) = self.infer()?[pat_id.as_pat()?].as_adt()?; - let field_ty = (*db.field_types(variant).get(field.local_id)?).instantiate(interner, subst); + let (adt, subst) = self.infer()?.pat_ty(pat_id.as_pat()?).as_adt()?; + let field_ty = + (*db.field_types(variant).get(field.local_id)?).get().instantiate(interner, subst); Some(( field.into(), Type::new_with_resolver(db, &self.resolver, field_ty), @@ -835,23 +831,24 @@ impl<'db> SourceAnalyzer<'db> { if let Either::Right(container) = &mut container { *container = structurally_normalize_ty(&infcx, *container, trait_env.param_env); } - let handle_variants = - |variant: VariantId, subst: GenericArgs<'db>, container: &mut _| { - let fields = variant.fields(db); - let field = fields.field(&field_name.as_name())?; - let field_types = db.field_types(variant); - *container = Either::Right(field_types[field].instantiate(interner, subst)); - let generic_def = match variant { - VariantId::EnumVariantId(it) => it.loc(db).parent.into(), - VariantId::StructId(it) => it.into(), - VariantId::UnionId(it) => it.into(), - }; - Some(( - Either::Right(Field { parent: variant.into(), id: field }), - generic_def, - subst, - )) + let handle_variants = |variant: VariantId, + subst: GenericArgs<'db>, + container: &mut _| { + let fields = variant.fields(db); + let field = fields.field(&field_name.as_name())?; + let field_types = db.field_types(variant); + *container = Either::Right(field_types[field].get().instantiate(interner, subst)); + let generic_def = match variant { + VariantId::EnumVariantId(it) => it.loc(db).parent.into(), + VariantId::StructId(it) => it.into(), + VariantId::UnionId(it) => it.into(), }; + Some(( + Either::Right(Field { parent: variant.into(), id: field }), + generic_def, + subst, + )) + }; let temp_ty = Ty::new_error(interner, ErrorGuaranteed); let (field_def, generic_def, subst) = match std::mem::replace(&mut container, Either::Right(temp_ty)) { @@ -1173,7 +1170,7 @@ impl<'db> SourceAnalyzer<'db> { self.infer()?.type_of_expr_or_pat(expr_id)? } else if let Some(pat) = ast::Pat::cast(parent) { let pat_id = self.pat_id(&pat)?; - self.infer()?[pat_id] + self.infer()?.expr_or_pat_ty(pat_id) } else { return None; }; @@ -1245,7 +1242,7 @@ impl<'db> SourceAnalyzer<'db> { let infer = self.infer()?; let expr_id = self.expr_id(literal.clone().into())?; - let substs = infer[expr_id].as_adt()?.1; + let substs = infer.expr_or_pat_ty(expr_id).as_adt()?.1; let (variant, missing_fields, _exhaustive) = match expr_id { ExprOrPatId::ExprId(expr_id) => { @@ -1268,7 +1265,7 @@ impl<'db> SourceAnalyzer<'db> { let infer = self.infer()?; let pat_id = self.pat_id(&pattern.clone().into())?.as_pat()?; - let substs = infer[pat_id].as_adt()?.1; + let substs = infer.pat_ty(pat_id).as_adt()?.1; let (variant, missing_fields, _exhaustive) = record_pattern_missing_fields(db, infer, pat_id, &body[pat_id])?; @@ -1290,7 +1287,7 @@ impl<'db> SourceAnalyzer<'db> { .into_iter() .map(|local_id| { let field = FieldId { parent: variant, local_id }; - let ty = field_types[local_id].instantiate(interner, substs); + let ty = field_types[local_id].get().instantiate(interner, substs); (field.into(), Type::new_with_resolver_inner(db, &self.resolver, ty)) }) .collect() diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs index 951a672d4b79..1317684a0877 100644 --- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs +++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs @@ -46,7 +46,7 @@ pub(super) fn hints( if !place.projection.is_empty() { continue; // Ignore complex cases for now } - if mir.locals[place.local].ty.as_adt().is_none() { + if mir.locals[place.local].ty.as_ref().as_adt().is_none() { continue; // Arguably only ADTs have significant drop impls } let Some(&binding_idx) = local_to_binding.get(place.local) else { diff --git a/src/tools/rust-analyzer/crates/ide/src/interpret.rs b/src/tools/rust-analyzer/crates/ide/src/interpret.rs index 791da00bb695..3741822547e4 100644 --- a/src/tools/rust-analyzer/crates/ide/src/interpret.rs +++ b/src/tools/rust-analyzer/crates/ide/src/interpret.rs @@ -60,7 +60,7 @@ fn find_and_interpret(db: &RootDatabase, position: FilePosition) -> Option<(Dura pub(crate) fn render_const_eval_error( db: &RootDatabase, - e: ConstEvalError<'_>, + e: ConstEvalError, display_target: DisplayTarget, ) -> String { let span_formatter = |file_id, text_range: TextRange| { diff --git a/src/tools/rust-analyzer/crates/intern/Cargo.toml b/src/tools/rust-analyzer/crates/intern/Cargo.toml index 81b6703deef5..44621031ab8e 100644 --- a/src/tools/rust-analyzer/crates/intern/Cargo.toml +++ b/src/tools/rust-analyzer/crates/intern/Cargo.toml @@ -18,6 +18,7 @@ dashmap.workspace = true hashbrown.workspace = true rustc-hash.workspace = true triomphe.workspace = true +smallvec.workspace = true [lints] workspace = true diff --git a/src/tools/rust-analyzer/crates/intern/src/intern.rs b/src/tools/rust-analyzer/crates/intern/src/intern.rs new file mode 100644 index 000000000000..fdefb936560e --- /dev/null +++ b/src/tools/rust-analyzer/crates/intern/src/intern.rs @@ -0,0 +1,331 @@ +//! Interning of single values. + +use std::{ + fmt::{self, Debug, Display}, + hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, + ops::Deref, + ptr, + sync::OnceLock, +}; + +use dashmap::{DashMap, SharedValue}; +use hashbrown::raw::RawTable; +use rustc_hash::FxHasher; +use triomphe::{Arc, ArcBorrow}; + +type InternMap = DashMap, (), BuildHasherDefault>; +type Guard = dashmap::RwLockWriteGuard<'static, RawTable<(Arc, SharedValue<()>)>>; + +pub struct Interned { + arc: Arc, +} + +unsafe impl Send for Interned {} +unsafe impl Sync for Interned {} + +impl Interned { + #[inline] + pub fn new(obj: T) -> Self { + let storage = T::storage().get(); + let (mut shard, hash) = Self::select(storage, &obj); + // Atomically, + // - check if `obj` is already in the map + // - if so, clone its `Arc` and return it + // - if not, box it up, insert it, and return a clone + // This needs to be atomic (locking the shard) to avoid races with other thread, which could + // insert the same object between us looking it up and inserting it. + let bucket = match shard.find_or_find_insert_slot( + hash, + |(other, _)| **other == obj, + |(x, _)| Self::hash(storage, x), + ) { + Ok(bucket) => bucket, + // SAFETY: The slot came from `find_or_find_insert_slot()`, and the table wasn't modified since then. + Err(insert_slot) => unsafe { + shard.insert_in_slot(hash, insert_slot, (Arc::new(obj), SharedValue::new(()))) + }, + }; + // SAFETY: We just retrieved/inserted this bucket. + unsafe { Self { arc: bucket.as_ref().0.clone() } } + } + + #[inline] + pub fn new_gc<'a>(obj: T) -> InternedRef<'a, T> { + const { assert!(T::USE_GC) }; + + let storage = T::storage().get(); + let (mut shard, hash) = Self::select(storage, &obj); + // Atomically, + // - check if `obj` is already in the map + // - if so, clone its `Arc` and return it + // - if not, box it up, insert it, and return a clone + // This needs to be atomic (locking the shard) to avoid races with other thread, which could + // insert the same object between us looking it up and inserting it. + let bucket = match shard.find_or_find_insert_slot( + hash, + |(other, _)| **other == obj, + |(x, _)| Self::hash(storage, x), + ) { + Ok(bucket) => bucket, + // SAFETY: The slot came from `find_or_find_insert_slot()`, and the table wasn't modified since then. + Err(insert_slot) => unsafe { + shard.insert_in_slot(hash, insert_slot, (Arc::new(obj), SharedValue::new(()))) + }, + }; + // SAFETY: We just retrieved/inserted this bucket. + unsafe { InternedRef { arc: Arc::borrow_arc(&bucket.as_ref().0) } } + } + + #[inline] + fn select(storage: &'static InternMap, obj: &T) -> (Guard, u64) { + let hash = Self::hash(storage, obj); + let shard_idx = storage.determine_shard(hash as usize); + let shard = &storage.shards()[shard_idx]; + (shard.write(), hash) + } + + #[inline] + fn hash(storage: &'static InternMap, obj: &T) -> u64 { + storage.hasher().hash_one(obj) + } + + /// # Safety + /// + /// The pointer should originate from an `Interned` or an `InternedRef`. + #[inline] + pub unsafe fn from_raw(ptr: *const T) -> Self { + Self { arc: unsafe { Arc::from_raw(ptr) } } + } + + #[inline] + pub fn as_ref(&self) -> InternedRef<'_, T> { + InternedRef { arc: self.arc.borrow_arc() } + } +} + +impl Drop for Interned { + #[inline] + fn drop(&mut self) { + // When the last `Ref` is dropped, remove the object from the global map. + if !T::USE_GC && Arc::count(&self.arc) == 2 { + // Only `self` and the global map point to the object. + + self.drop_slow(); + } + } +} + +impl Interned { + #[cold] + fn drop_slow(&mut self) { + let storage = T::storage().get(); + let (mut shard, hash) = Self::select(storage, &self.arc); + + if Arc::count(&self.arc) != 2 { + // Another thread has interned another copy + return; + } + + shard.remove_entry(hash, |(other, _)| **other == **self); + + // Shrink the backing storage if the shard is less than 50% occupied. + if shard.len() * 2 < shard.capacity() { + let len = shard.len(); + shard.shrink_to(len, |(x, _)| Self::hash(storage, x)); + } + } +} + +/// Compares interned `Ref`s using pointer equality. +impl PartialEq for Interned { + // NOTE: No `?Sized` because `ptr_eq` doesn't work right with trait objects. + + #[inline] + fn eq(&self, other: &Self) -> bool { + Arc::ptr_eq(&self.arc, &other.arc) + } +} + +impl Eq for Interned {} + +impl Hash for Interned { + #[inline] + fn hash(&self, state: &mut H) { + state.write_usize(self.arc.as_ptr().addr()) + } +} + +impl AsRef for Interned { + #[inline] + fn as_ref(&self) -> &T { + self + } +} + +impl Deref for Interned { + type Target = T; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.arc + } +} + +impl Clone for Interned { + #[inline] + fn clone(&self) -> Self { + Self { arc: self.arc.clone() } + } +} + +impl Debug for Interned { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ::fmt(&**self, f) + } +} + +impl Display for Interned { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ::fmt(&**self, f) + } +} + +#[repr(transparent)] +pub struct InternedRef<'a, T> { + arc: ArcBorrow<'a, T>, +} + +impl<'a, T: Internable> InternedRef<'a, T> { + #[inline] + pub fn as_raw(self) -> *const T { + // Not `ptr::from_ref(&*self.arc)`, because we need to keep the provenance. + self.arc.with_arc(|arc| Arc::as_ptr(arc)) + } + + /// # Safety + /// + /// The pointer needs to originate from `Interned` or `InternedRef`. + #[inline] + pub unsafe fn from_raw(ptr: *const T) -> Self { + Self { arc: unsafe { ArcBorrow::from_ptr(ptr) } } + } + + #[inline] + pub fn to_owned(self) -> Interned { + Interned { arc: self.arc.clone_arc() } + } + + #[inline] + pub fn get(self) -> &'a T { + self.arc.get() + } + + /// # Safety + /// + /// You have to make sure the data is not referenced after the refcount reaches zero; beware the interning + /// map also keeps a reference to the value. + #[inline] + pub unsafe fn decrement_refcount(self) { + unsafe { drop(Arc::from_raw(self.as_raw())) } + } +} + +impl Clone for InternedRef<'_, T> { + #[inline] + fn clone(&self) -> Self { + *self + } +} + +impl Copy for InternedRef<'_, T> {} + +impl Hash for InternedRef<'_, T> { + #[inline] + fn hash(&self, state: &mut H) { + let ptr = ptr::from_ref::(&*self.arc); + state.write_usize(ptr.addr()); + } +} + +impl PartialEq for InternedRef<'_, T> { + #[inline] + fn eq(&self, other: &Self) -> bool { + ArcBorrow::ptr_eq(&self.arc, &other.arc) + } +} + +impl Eq for InternedRef<'_, T> {} + +impl Deref for InternedRef<'_, T> { + type Target = T; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.arc + } +} + +impl Debug for InternedRef<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (*self.arc).fmt(f) + } +} + +impl Display for InternedRef<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (*self.arc).fmt(f) + } +} + +pub struct InternStorage { + map: OnceLock>, +} + +#[allow( + clippy::new_without_default, + reason = "this a const fn, so it can't be default yet. See " +)] +impl InternStorage { + pub const fn new() -> Self { + Self { map: OnceLock::new() } + } +} + +impl InternStorage { + fn get(&self) -> &InternMap { + self.map.get_or_init(DashMap::default) + } +} + +pub trait Internable: Hash + Eq + 'static { + const USE_GC: bool; + + fn storage() -> &'static InternStorage; +} + +/// Implements `Internable` for a given list of types, making them usable with `Interned`. +#[macro_export] +#[doc(hidden)] +macro_rules! _impl_internable { + ( gc; $($t:ty),+ $(,)? ) => { $( + impl $crate::Internable for $t { + const USE_GC: bool = true; + + fn storage() -> &'static $crate::InternStorage { + static STORAGE: $crate::InternStorage<$t> = $crate::InternStorage::new(); + &STORAGE + } + } + )+ }; + ( $($t:ty),+ $(,)? ) => { $( + impl $crate::Internable for $t { + const USE_GC: bool = false; + + fn storage() -> &'static $crate::InternStorage { + static STORAGE: $crate::InternStorage<$t> = $crate::InternStorage::new(); + &STORAGE + } + } + )+ }; +} +pub use crate::_impl_internable as impl_internable; diff --git a/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs b/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs new file mode 100644 index 000000000000..989a21e70cf0 --- /dev/null +++ b/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs @@ -0,0 +1,351 @@ +//! Interning of slices, potentially with a header. + +use std::{ + borrow::Borrow, + ffi::c_void, + fmt::{self, Debug}, + hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, + marker::PhantomData, + mem::ManuallyDrop, + ops::Deref, + ptr::{self, NonNull}, + sync::OnceLock, +}; + +use dashmap::{DashMap, SharedValue}; +use hashbrown::raw::RawTable; +use rustc_hash::FxHasher; +use triomphe::{HeaderSlice, HeaderWithLength, ThinArc}; + +type InternMap = DashMap< + ThinArc<::Header, ::SliceType>, + (), + BuildHasherDefault, +>; +type Guard = dashmap::RwLockWriteGuard< + 'static, + RawTable<( + ThinArc<::Header, ::SliceType>, + SharedValue<()>, + )>, +>; +type Pointee = HeaderSlice< + HeaderWithLength<::Header>, + [::SliceType], +>; + +pub struct InternedSlice { + arc: ThinArc, +} + +impl InternedSlice { + #[inline] + fn new<'a>( + header: T::Header, + slice: impl Borrow<[T::SliceType]> + + IntoIterator, + ) -> InternedSliceRef<'a, T> { + const { assert!(T::USE_GC) }; + let storage = T::storage().get(); + let (mut shard, hash) = Self::select(storage, &header, slice.borrow()); + // Atomically, + // - check if `obj` is already in the map + // - if so, clone its `Arc` and return it + // - if not, box it up, insert it, and return a clone + // This needs to be atomic (locking the shard) to avoid races with other thread, which could + // insert the same object between us looking it up and inserting it. + let bucket = match shard.find_or_find_insert_slot( + hash, + |(other, _)| other.header.header == header && other.slice == *slice.borrow(), + |(x, _)| storage.hasher().hash_one(x), + ) { + Ok(bucket) => bucket, + // SAFETY: The slot came from `find_or_find_insert_slot()`, and the table wasn't modified since then. + Err(insert_slot) => unsafe { + shard.insert_in_slot( + hash, + insert_slot, + ( + ThinArc::from_header_and_iter(header, slice.into_iter()), + SharedValue::new(()), + ), + ) + }, + }; + // SAFETY: We just retrieved/inserted this bucket. + unsafe { + InternedSliceRef { + ptr: NonNull::new_unchecked(ThinArc::as_ptr(&bucket.as_ref().0).cast_mut()), + _marker: PhantomData, + } + } + } + + #[inline] + pub fn from_header_and_slice<'a>( + header: T::Header, + slice: &[T::SliceType], + ) -> InternedSliceRef<'a, T> + where + T::SliceType: Clone, + { + return Self::new(header, Iter(slice)); + + struct Iter<'a, T>(&'a [T]); + + impl<'a, T: Clone> IntoIterator for Iter<'a, T> { + type IntoIter = std::iter::Cloned>; + type Item = T; + #[inline] + fn into_iter(self) -> Self::IntoIter { + self.0.iter().cloned() + } + } + + impl Borrow<[T]> for Iter<'_, T> { + #[inline] + fn borrow(&self) -> &[T] { + self.0 + } + } + } + + #[inline] + fn select( + storage: &'static InternMap, + header: &T::Header, + slice: &[T::SliceType], + ) -> (Guard, u64) { + let hash = Self::hash(storage, header, slice); + let shard_idx = storage.determine_shard(hash as usize); + let shard = &storage.shards()[shard_idx]; + (shard.write(), hash) + } + + #[inline] + fn hash(storage: &'static InternMap, header: &T::Header, slice: &[T::SliceType]) -> u64 { + storage.hasher().hash_one(HeaderSlice { + header: HeaderWithLength { header, length: slice.len() }, + slice, + }) + } + + #[inline(always)] + fn ptr(&self) -> *const c_void { + unsafe { ptr::from_ref(&self.arc).read().into_raw() } + } + + #[inline] + pub fn as_ref(&self) -> InternedSliceRef<'_, T> { + InternedSliceRef { + ptr: unsafe { NonNull::new_unchecked(self.ptr().cast_mut()) }, + _marker: PhantomData, + } + } +} + +impl Drop for InternedSlice { + #[inline] + fn drop(&mut self) { + // When the last `Ref` is dropped, remove the object from the global map. + if !T::USE_GC && ThinArc::strong_count(&self.arc) == 2 { + // Only `self` and the global map point to the object. + + self.drop_slow(); + } + } +} + +impl InternedSlice { + #[cold] + fn drop_slow(&mut self) { + let storage = T::storage().get(); + let (mut shard, hash) = Self::select(storage, &self.arc.header.header, &self.arc.slice); + + if ThinArc::strong_count(&self.arc) != 2 { + // Another thread has interned another copy + return; + } + + shard.remove_entry(hash, |(other, _)| **other == *self.arc); + + // Shrink the backing storage if the shard is less than 50% occupied. + if shard.len() * 2 < shard.capacity() { + let len = shard.len(); + shard.shrink_to(len, |(x, _)| storage.hasher().hash_one(x)); + } + } +} + +/// Compares interned `Ref`s using pointer equality. +impl PartialEq for InternedSlice { + // NOTE: No `?Sized` because `ptr_eq` doesn't work right with trait objects. + + #[inline] + fn eq(&self, other: &Self) -> bool { + self.arc.as_ptr() == other.arc.as_ptr() + } +} + +impl Eq for InternedSlice {} + +impl Hash for InternedSlice { + #[inline] + fn hash(&self, state: &mut H) { + state.write_usize(self.ptr().addr()) + } +} + +impl Deref for InternedSlice { + type Target = Pointee; + + #[inline] + fn deref(&self) -> &Self::Target { + &self.arc + } +} + +impl Clone for InternedSlice { + #[inline] + fn clone(&self) -> Self { + Self { arc: self.arc.clone() } + } +} + +impl Debug for InternedSlice +where + T: SliceInternable, + T::SliceType: Debug, + T::Header: Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (*self.arc).fmt(f) + } +} + +#[repr(transparent)] +pub struct InternedSliceRef<'a, T> { + ptr: NonNull, + _marker: PhantomData<&'a T>, +} + +unsafe impl Send for InternedSliceRef<'_, T> {} +unsafe impl Sync for InternedSliceRef<'_, T> {} + +impl<'a, T: SliceInternable> InternedSliceRef<'a, T> { + #[inline(always)] + fn arc(self) -> ManuallyDrop> { + unsafe { ManuallyDrop::new(ThinArc::from_raw(self.ptr.as_ptr())) } + } + + #[inline] + pub fn to_owned(self) -> InternedSlice { + InternedSlice { arc: (*self.arc()).clone() } + } + + #[inline] + pub fn get(self) -> &'a Pointee { + unsafe { &*ptr::from_ref::>(&*self.arc()) } + } + + /// # Safety + /// + /// You have to make sure the data is not referenced after the refcount reaches zero; beware the interning + /// map also keeps a reference to the value. + #[inline] + pub unsafe fn decrement_refcount(self) { + drop(ManuallyDrop::into_inner(self.arc())); + } +} + +impl Clone for InternedSliceRef<'_, T> { + #[inline] + fn clone(&self) -> Self { + *self + } +} + +impl Copy for InternedSliceRef<'_, T> {} + +impl Hash for InternedSliceRef<'_, T> { + #[inline] + fn hash(&self, state: &mut H) { + state.write_usize(self.ptr.as_ptr().addr()); + } +} + +impl PartialEq for InternedSliceRef<'_, T> { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.ptr == other.ptr + } +} + +impl Eq for InternedSliceRef<'_, T> {} + +impl Deref for InternedSliceRef<'_, T> { + type Target = Pointee; + + #[inline] + fn deref(&self) -> &Self::Target { + self.get() + } +} + +impl Debug for InternedSliceRef<'_, T> +where + T: SliceInternable, + T::SliceType: Debug, + T::Header: Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +pub struct InternSliceStorage { + map: OnceLock>, +} + +#[allow( + clippy::new_without_default, + reason = "this a const fn, so it can't be default yet. See " +)] +impl InternSliceStorage { + pub const fn new() -> Self { + Self { map: OnceLock::new() } + } +} + +impl InternSliceStorage { + fn get(&self) -> &InternMap { + self.map.get_or_init(DashMap::default) + } +} + +pub trait SliceInternable: Sized + 'static { + const USE_GC: bool; + type Header: Eq + Hash; + type SliceType: Eq + Hash + 'static; + fn storage() -> &'static InternSliceStorage; +} + +/// Implements `SliceInternable` for a given list of types, making them usable with `InternedSlice`. +#[macro_export] +#[doc(hidden)] +macro_rules! _impl_slice_internable { + ( gc; $tag:ident, $h:ty, $t:ty $(,)? ) => { + pub struct $tag; + impl $crate::SliceInternable for $tag { + const USE_GC: bool = true; + type Header = $h; + type SliceType = $t; + fn storage() -> &'static $crate::InternSliceStorage { + static STORAGE: $crate::InternSliceStorage<$tag> = + $crate::InternSliceStorage::new(); + &STORAGE + } + } + }; +} +pub use crate::_impl_slice_internable as impl_slice_internable; diff --git a/src/tools/rust-analyzer/crates/intern/src/lib.rs b/src/tools/rust-analyzer/crates/intern/src/lib.rs index 398d224c07ad..c5b42a860ac4 100644 --- a/src/tools/rust-analyzer/crates/intern/src/lib.rs +++ b/src/tools/rust-analyzer/crates/intern/src/lib.rs @@ -2,219 +2,12 @@ //! //! Eventually this should probably be replaced with salsa-based interning. -use std::{ - borrow::Borrow, - fmt::{self, Debug, Display}, - hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, - ops::Deref, - sync::OnceLock, -}; - -use dashmap::{DashMap, SharedValue}; -use hashbrown::raw::RawTable; -use rustc_hash::FxHasher; -use triomphe::Arc; - -type InternMap = DashMap, (), BuildHasherDefault>; -type Guard = dashmap::RwLockWriteGuard<'static, RawTable<(Arc, SharedValue<()>)>>; - +mod intern; +mod intern_slice; mod symbol; + +pub use self::intern::{InternStorage, Internable, Interned, InternedRef, impl_internable}; +pub use self::intern_slice::{ + InternSliceStorage, InternedSlice, InternedSliceRef, SliceInternable, impl_slice_internable, +}; pub use self::symbol::{Symbol, symbols as sym}; - -pub struct Interned { - arc: Arc, -} - -impl Interned { - #[inline] - pub fn new(obj: T) -> Self { - Self::new_generic(obj) - } -} - -impl Interned { - #[inline] - pub fn new_str(s: &str) -> Self { - Self::new_generic(s) - } -} - -impl Interned { - #[inline] - pub fn new_generic(obj: U) -> Self - where - U: Borrow, - Arc: From, - { - let storage = T::storage().get(); - let (mut shard, hash) = Self::select(storage, obj.borrow()); - // Atomically, - // - check if `obj` is already in the map - // - if so, clone its `Arc` and return it - // - if not, box it up, insert it, and return a clone - // This needs to be atomic (locking the shard) to avoid races with other thread, which could - // insert the same object between us looking it up and inserting it. - let bucket = match shard.find_or_find_insert_slot( - hash, - |(other, _)| **other == *obj.borrow(), - |(x, _)| Self::hash(storage, x), - ) { - Ok(bucket) => bucket, - // SAFETY: The slot came from `find_or_find_insert_slot()`, and the table wasn't modified since then. - Err(insert_slot) => unsafe { - shard.insert_in_slot(hash, insert_slot, (Arc::from(obj), SharedValue::new(()))) - }, - }; - // SAFETY: We just retrieved/inserted this bucket. - unsafe { Self { arc: bucket.as_ref().0.clone() } } - } - - #[inline] - fn select(storage: &'static InternMap, obj: &T) -> (Guard, u64) { - let hash = Self::hash(storage, obj); - let shard_idx = storage.determine_shard(hash as usize); - let shard = &storage.shards()[shard_idx]; - (shard.write(), hash) - } - - #[inline] - fn hash(storage: &'static InternMap, obj: &T) -> u64 { - storage.hasher().hash_one(obj) - } -} - -impl Drop for Interned { - #[inline] - fn drop(&mut self) { - // When the last `Ref` is dropped, remove the object from the global map. - if Arc::count(&self.arc) == 2 { - // Only `self` and the global map point to the object. - - self.drop_slow(); - } - } -} - -impl Interned { - #[cold] - fn drop_slow(&mut self) { - let storage = T::storage().get(); - let (mut shard, hash) = Self::select(storage, &self.arc); - - if Arc::count(&self.arc) != 2 { - // Another thread has interned another copy - return; - } - - shard.remove_entry(hash, |(other, _)| **other == *self.arc); - - // Shrink the backing storage if the shard is less than 50% occupied. - if shard.len() * 2 < shard.capacity() { - let len = shard.len(); - shard.shrink_to(len, |(x, _)| Self::hash(storage, x)); - } - } -} - -/// Compares interned `Ref`s using pointer equality. -impl PartialEq for Interned { - // NOTE: No `?Sized` because `ptr_eq` doesn't work right with trait objects. - - #[inline] - fn eq(&self, other: &Self) -> bool { - Arc::ptr_eq(&self.arc, &other.arc) - } -} - -impl Eq for Interned {} - -impl PartialEq for Interned { - fn eq(&self, other: &Self) -> bool { - Arc::ptr_eq(&self.arc, &other.arc) - } -} - -impl Eq for Interned {} - -impl Hash for Interned { - fn hash(&self, state: &mut H) { - // NOTE: Cast disposes vtable pointer / slice/str length. - state.write_usize(Arc::as_ptr(&self.arc) as *const () as usize) - } -} - -impl AsRef for Interned { - #[inline] - fn as_ref(&self) -> &T { - &self.arc - } -} - -impl Deref for Interned { - type Target = T; - - #[inline] - fn deref(&self) -> &Self::Target { - &self.arc - } -} - -impl Clone for Interned { - fn clone(&self) -> Self { - Self { arc: self.arc.clone() } - } -} - -impl Debug for Interned { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (*self.arc).fmt(f) - } -} - -impl Display for Interned { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (*self.arc).fmt(f) - } -} - -pub struct InternStorage { - map: OnceLock>, -} - -#[allow( - clippy::new_without_default, - reason = "this a const fn, so it can't be default yet. See " -)] -impl InternStorage { - pub const fn new() -> Self { - Self { map: OnceLock::new() } - } -} - -impl InternStorage { - fn get(&self) -> &InternMap { - self.map.get_or_init(DashMap::default) - } -} - -pub trait Internable: Hash + Eq + 'static { - fn storage() -> &'static InternStorage; -} - -/// Implements `Internable` for a given list of types, making them usable with `Interned`. -#[macro_export] -#[doc(hidden)] -macro_rules! _impl_internable { - ( $($t:path),+ $(,)? ) => { $( - impl $crate::Internable for $t { - fn storage() -> &'static $crate::InternStorage { - static STORAGE: $crate::InternStorage<$t> = $crate::InternStorage::new(); - &STORAGE - } - } - )+ }; -} - -pub use crate::_impl_internable as impl_internable; - -impl_internable!(str,); diff --git a/src/tools/rust-analyzer/crates/macros/src/lib.rs b/src/tools/rust-analyzer/crates/macros/src/lib.rs index 3f90ecc8f902..de8c3f2e55f1 100644 --- a/src/tools/rust-analyzer/crates/macros/src/lib.rs +++ b/src/tools/rust-analyzer/crates/macros/src/lib.rs @@ -25,6 +25,9 @@ decl_derive!( /// visited (and its type is not required to implement `TypeVisitable`). type_visitable_derive ); +decl_derive!( + [GenericTypeVisitable] => generic_type_visitable_derive +); fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { if let syn::Data::Union(_) = s.ast().data { @@ -163,6 +166,33 @@ fn has_ignore_attr(attrs: &[syn::Attribute], name: &'static str, meta: &'static ignored } +fn generic_type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { + if let syn::Data::Union(_) = s.ast().data { + panic!("cannot derive on union") + } + + s.add_bounds(synstructure::AddBounds::Fields); + s.bind_with(|_| synstructure::BindStyle::Move); + s.add_impl_generic(parse_quote!(__V: hir_ty::next_solver::interner::WorldExposer)); + let body_visit = s.each(|bind| { + quote! { + ::rustc_type_ir::GenericTypeVisitable::<__V>::generic_visit_with(#bind, __visitor); + } + }); + + s.bound_impl( + quote!(::rustc_type_ir::GenericTypeVisitable<__V>), + quote! { + fn generic_visit_with( + &self, + __visitor: &mut __V + ) { + match self { #body_visit } + } + }, + ) +} + decl_derive!( [UpmapFromRaFixture] => upmap_from_ra_fixture ); diff --git a/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs b/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs index fe932ac133a0..83ce8902d0c9 100644 --- a/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs +++ b/src/tools/rust-analyzer/crates/query-group-macro/src/queries.rs @@ -48,8 +48,7 @@ impl ToTokens for TrackedQuery { quote!(#(#options),*) }) .into_iter() - .chain(self.lru.map(|lru| quote!(lru = #lru))) - .chain(Some(quote!(unsafe(non_update_types)))); + .chain(self.lru.map(|lru| quote!(lru = #lru))); let annotation = quote!(#[salsa_macros::tracked( #(#options),* )]); let pat_and_tys = &self.pat_and_tys; diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs index 1a6cd784cf2f..f863a7ee8d04 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -390,11 +390,12 @@ impl flags::AnalysisStats { all += 1; let Err(e) = db.layout_of_adt( hir_def::AdtId::from(a), - GenericArgs::new_from_iter(interner, []), + GenericArgs::empty(interner).store(), hir_ty::ParamEnvAndCrate { param_env: db.trait_environment(a.into()), krate: a.krate(db).into(), - }, + } + .store(), ) else { continue; }; @@ -830,7 +831,7 @@ impl flags::AnalysisStats { let (previous_exprs, previous_unknown, previous_partially_unknown) = (num_exprs, num_exprs_unknown, num_exprs_partially_unknown); for (expr_id, _) in body.exprs() { - let ty = &inference_result[expr_id]; + let ty = inference_result.expr_ty(expr_id); num_exprs += 1; let unknown_or_partial = if ty.is_ty_error() { num_exprs_unknown += 1; @@ -897,15 +898,15 @@ impl flags::AnalysisStats { start.col, end.line + 1, end.col, - mismatch.expected.display(db, display_target), - mismatch.actual.display(db, display_target) + mismatch.expected.as_ref().display(db, display_target), + mismatch.actual.as_ref().display(db, display_target) )); } else { bar.println(format!( "{}: Expected {}, got {}", name.display(db, Edition::LATEST), - mismatch.expected.display(db, display_target), - mismatch.actual.display(db, display_target) + mismatch.expected.as_ref().display(db, display_target), + mismatch.actual.as_ref().display(db, display_target) )); } } @@ -913,8 +914,8 @@ impl flags::AnalysisStats { println!( r#"{},mismatch,"{}","{}""#, location_csv_expr(db, vfs, &sm(), expr_id), - mismatch.expected.display(db, display_target), - mismatch.actual.display(db, display_target) + mismatch.expected.as_ref().display(db, display_target), + mismatch.actual.as_ref().display(db, display_target) ); } } @@ -934,7 +935,7 @@ impl flags::AnalysisStats { let (previous_pats, previous_unknown, previous_partially_unknown) = (num_pats, num_pats_unknown, num_pats_partially_unknown); for (pat_id, _) in body.pats() { - let ty = &inference_result[pat_id]; + let ty = inference_result.pat_ty(pat_id); num_pats += 1; let unknown_or_partial = if ty.is_ty_error() { num_pats_unknown += 1; @@ -999,15 +1000,15 @@ impl flags::AnalysisStats { start.col, end.line + 1, end.col, - mismatch.expected.display(db, display_target), - mismatch.actual.display(db, display_target) + mismatch.expected.as_ref().display(db, display_target), + mismatch.actual.as_ref().display(db, display_target) )); } else { bar.println(format!( "{}: Expected {}, got {}", name.display(db, Edition::LATEST), - mismatch.expected.display(db, display_target), - mismatch.actual.display(db, display_target) + mismatch.expected.as_ref().display(db, display_target), + mismatch.actual.as_ref().display(db, display_target) )); } } @@ -1015,8 +1016,8 @@ impl flags::AnalysisStats { println!( r#"{},mismatch,"{}","{}""#, location_csv_pat(db, vfs, &sm(), pat_id), - mismatch.expected.display(db, display_target), - mismatch.actual.display(db, display_target) + mismatch.expected.as_ref().display(db, display_target), + mismatch.actual.as_ref().display(db, display_target) ); } } From b9ed61fea1d176edb5f594c7947cd11020f0e261 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Wed, 10 Dec 2025 08:44:05 +0200 Subject: [PATCH 297/489] GC support for solver types A GC is triggered every X revisions, and is synchronous, unfortunately. --- src/tools/rust-analyzer/Cargo.lock | 1 + .../crates/hir-ty/src/next_solver/consts.rs | 24 +- .../crates/hir-ty/src/next_solver/interner.rs | 132 ++++++- .../crates/hir-ty/src/next_solver/opaques.rs | 5 +- .../hir-ty/src/next_solver/predicate.rs | 31 +- .../crates/hir-ty/src/next_solver/region.rs | 8 +- .../crates/hir-ty/src/next_solver/ty.rs | 8 +- src/tools/rust-analyzer/crates/hir/src/lib.rs | 2 +- .../rust-analyzer/crates/intern/Cargo.toml | 1 + .../rust-analyzer/crates/intern/src/gc.rs | 325 ++++++++++++++++++ .../rust-analyzer/crates/intern/src/intern.rs | 11 +- .../crates/intern/src/intern_slice.rs | 17 +- .../rust-analyzer/crates/intern/src/lib.rs | 2 + .../rust-analyzer/src/cli/analysis_stats.rs | 1 + .../crates/rust-analyzer/src/config.rs | 13 +- .../crates/rust-analyzer/src/global_state.rs | 13 + .../docs/book/src/configuration_generated.md | 11 + .../rust-analyzer/editors/code/package.json | 11 + 18 files changed, 566 insertions(+), 50 deletions(-) create mode 100644 src/tools/rust-analyzer/crates/intern/src/gc.rs diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index 081c7d66f1d8..7ada91d2b65b 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -1214,6 +1214,7 @@ version = "0.0.0" dependencies = [ "dashmap", "hashbrown 0.14.5", + "rayon", "rustc-hash 2.1.1", "smallvec", "triomphe", diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs index 8417e145a46d..c2fc4d18bbae 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs @@ -29,9 +29,9 @@ pub struct Const<'db> { pub(super) interned: InternedRef<'db, ConstInterned>, } -#[derive(PartialEq, Eq, Hash)] +#[derive(PartialEq, Eq, Hash, GenericTypeVisitable)] #[repr(align(4))] // Required for `GenericArg` bit-tagging. -pub(super) struct ConstInterned(WithCachedTypeInfo>); +pub(super) struct ConstInterned(pub(super) WithCachedTypeInfo>); impl_internable!(gc; ConstInterned); impl_stored_interned!(ConstInterned, Const, StoredConst); @@ -219,15 +219,14 @@ pub struct Valtree<'db> { impl<'db, V: super::WorldExposer> GenericTypeVisitable for Valtree<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned(self.interned); - self.inner().generic_visit_with(visitor); + if visitor.on_interned(self.interned).is_continue() { + self.inner().generic_visit_with(visitor); + } } } -#[derive(Debug, PartialEq, Eq, Hash)] -struct ValtreeInterned { - bytes: ConstBytes<'static>, -} +#[derive(Debug, PartialEq, Eq, Hash, GenericTypeVisitable)] +pub(super) struct ValtreeInterned(ConstBytes<'static>); impl_internable!(gc; ValtreeInterned); @@ -240,12 +239,12 @@ impl<'db> Valtree<'db> { #[inline] pub fn new(bytes: ConstBytes<'db>) -> Self { let bytes = unsafe { std::mem::transmute::, ConstBytes<'static>>(bytes) }; - Self { interned: Interned::new_gc(ValtreeInterned { bytes }) } + Self { interned: Interned::new_gc(ValtreeInterned(bytes)) } } #[inline] pub fn inner(&self) -> &ConstBytes<'db> { - let inner = &self.interned.bytes; + let inner = &self.interned.0; unsafe { std::mem::transmute::<&ConstBytes<'static>, &ConstBytes<'db>>(inner) } } } @@ -277,8 +276,9 @@ impl<'db> IntoKind for Const<'db> { impl<'db, V: super::WorldExposer> GenericTypeVisitable for Const<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned(self.interned); - self.kind().generic_visit_with(visitor); + if visitor.on_interned(self.interned).is_continue() { + self.kind().generic_visit_with(visitor); + } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index 1a946cb90817..f2dacd16dbf9 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -1,8 +1,9 @@ //! Things related to the Interner in the next-trait-solver. -use std::fmt; +use std::{fmt, ops::ControlFlow}; use intern::{Interned, InternedRef, InternedSliceRef, impl_internable}; +use macros::GenericTypeVisitable; use rustc_ast_ir::{FloatTy, IntTy, UintTy}; pub use tls_cache::clear_tls_solver_cache; pub use tls_db::{attach_db, attach_db_allow_change, with_attached_db}; @@ -21,8 +22,8 @@ use rustc_hash::FxHashSet; use rustc_index::bit_set::DenseBitSet; use rustc_type_ir::{ AliasTermKind, AliasTyKind, BoundVar, CollectAndApply, CoroutineWitnessTypes, DebruijnIndex, - EarlyBinder, FlagComputation, Flags, GenericArgKind, ImplPolarity, InferTy, Interner, TraitRef, - TypeFlags, TypeVisitableExt, UniverseIndex, Upcast, Variance, + EarlyBinder, FlagComputation, Flags, GenericArgKind, GenericTypeVisitable, ImplPolarity, + InferTy, Interner, TraitRef, TypeFlags, TypeVisitableExt, UniverseIndex, Upcast, Variance, elaborate::elaborate, error::TypeError, fast_reject, @@ -169,8 +170,9 @@ macro_rules! interned_slice { { #[inline] fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned_slice(self.interned); - self.as_slice().iter().for_each(|it| it.generic_visit_with(visitor)); + if visitor.on_interned_slice(self.interned).is_continue() { + self.as_slice().iter().for_each(|it| it.generic_visit_with(visitor)); + } } } }; @@ -293,8 +295,14 @@ macro_rules! impl_stored_interned { pub(crate) use impl_stored_interned; pub trait WorldExposer { - fn on_interned(&mut self, interned: InternedRef<'_, T>); - fn on_interned_slice(&mut self, interned: InternedSliceRef<'_, T>); + fn on_interned( + &mut self, + interned: InternedRef<'_, T>, + ) -> ControlFlow<()>; + fn on_interned_slice( + &mut self, + interned: InternedSliceRef<'_, T>, + ) -> ControlFlow<()>; } #[derive(Debug, Copy, Clone)] @@ -803,7 +811,7 @@ pub struct Pattern<'db> { interned: InternedRef<'db, PatternInterned>, } -#[derive(PartialEq, Eq, Hash)] +#[derive(PartialEq, Eq, Hash, GenericTypeVisitable)] struct PatternInterned(PatternKind<'static>); impl_internable!(gc; PatternInterned); @@ -884,8 +892,9 @@ impl<'db> rustc_type_ir::TypeVisitable> for Pattern<'db> { impl<'db, V: WorldExposer> rustc_type_ir::GenericTypeVisitable for Pattern<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned(self.interned); - self.kind().generic_visit_with(visitor); + if visitor.on_interned(self.interned).is_continue() { + self.kind().generic_visit_with(visitor); + } } } @@ -2559,3 +2568,106 @@ mod tls_cache { GLOBAL_CACHE.with_borrow_mut(|handle| *handle = None); } } + +impl WorldExposer for intern::GarbageCollector { + fn on_interned( + &mut self, + interned: InternedRef<'_, T>, + ) -> ControlFlow<()> { + self.mark_interned_alive(interned) + } + + fn on_interned_slice( + &mut self, + interned: InternedSliceRef<'_, T>, + ) -> ControlFlow<()> { + self.mark_interned_slice_alive(interned) + } +} + +/// # Safety +/// +/// This cannot be called if there are some not-yet-recorded type values. Generally, if you have a mutable +/// reference to the database, and there are no other database - then you can call this safely, but you +/// also need to make sure to maintain the mutable reference while this is running. +pub unsafe fn collect_ty_garbage() { + let mut gc = intern::GarbageCollector::default(); + + gc.add_storage::(); + gc.add_storage::(); + gc.add_storage::(); + gc.add_storage::(); + gc.add_storage::(); + gc.add_storage::(); + gc.add_storage::(); + + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + gc.add_slice_storage::(); + + unsafe { gc.collect() }; +} + +macro_rules! impl_gc_visit { + ( $($ty:ty),* $(,)? ) => { + $( + impl ::intern::GcInternedVisit for $ty { + #[inline] + fn visit_with(&self, gc: &mut ::intern::GarbageCollector) { + self.generic_visit_with(gc); + } + } + )* + }; +} + +impl_gc_visit!( + super::consts::ConstInterned, + super::consts::ValtreeInterned, + PatternInterned, + super::opaques::ExternalConstraintsInterned, + super::predicate::PredicateInterned, + super::region::RegionInterned, + super::ty::TyInterned, + super::predicate::ClausesCachedTypeInfo, +); + +macro_rules! impl_gc_visit_slice { + ( $($ty:ty),* $(,)? ) => { + $( + impl ::intern::GcInternedSliceVisit for $ty { + #[inline] + fn visit_header(header: &::Header, gc: &mut ::intern::GarbageCollector) { + header.generic_visit_with(gc); + } + + #[inline] + fn visit_slice(header: &[::SliceType], gc: &mut ::intern::GarbageCollector) { + header.generic_visit_with(gc); + } + } + )* + }; +} + +impl_gc_visit_slice!( + super::predicate::ClausesStorage, + super::generic_arg::GenericArgsStorage, + BoundVarKindsStorage, + VariancesOfStorage, + CanonicalVarsStorage, + PatListStorage, + super::opaques::PredefinedOpaquesStorage, + super::opaques::SolverDefIdsStorage, + super::predicate::BoundExistentialPredicatesStorage, + super::region::RegionAssumptionsStorage, + super::ty::TysStorage, +); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs index 7e1d6b7328cd..230469c21ab8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs @@ -1,6 +1,7 @@ //! Things related to opaques in the next-trait-solver. use intern::{Interned, InternedRef, impl_internable}; +use macros::GenericTypeVisitable; use rustc_ast_ir::try_visit; use rustc_type_ir::inherent::SliceLike; @@ -30,8 +31,8 @@ pub struct ExternalConstraints<'db> { interned: InternedRef<'db, ExternalConstraintsInterned>, } -#[derive(PartialEq, Eq, Hash)] -struct ExternalConstraintsInterned(ExternalConstraintsData<'static>); +#[derive(PartialEq, Eq, Hash, GenericTypeVisitable)] +pub(super) struct ExternalConstraintsInterned(ExternalConstraintsData<'static>); impl_internable!(gc; ExternalConstraintsInterned); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs index 95b48c73c12f..6d7539575fbc 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs @@ -186,8 +186,8 @@ pub struct Predicate<'db> { interned: InternedRef<'db, PredicateInterned>, } -#[derive(PartialEq, Eq, Hash)] -struct PredicateInterned(WithCachedTypeInfo>>); +#[derive(PartialEq, Eq, Hash, GenericTypeVisitable)] +pub(super) struct PredicateInterned(WithCachedTypeInfo>>); impl_internable!(gc; PredicateInterned); @@ -252,7 +252,10 @@ impl<'db> std::fmt::Debug for Predicate<'db> { } } -impl_slice_internable!(gc; ClausesStorage, WithCachedTypeInfo<()>, Clause<'static>); +#[derive(Clone, Copy, PartialEq, Eq, Hash, GenericTypeVisitable)] +pub struct ClausesCachedTypeInfo(WithCachedTypeInfo<()>); + +impl_slice_internable!(gc; ClausesStorage, ClausesCachedTypeInfo, Clause<'static>); impl_stored_interned_slice!(ClausesStorage, Clauses, StoredClauses); #[derive(Clone, Copy, PartialEq, Eq, Hash)] @@ -277,11 +280,11 @@ impl<'db> Clauses<'db> { pub fn new_from_slice(slice: &[Clause<'db>]) -> Self { let slice = unsafe { ::std::mem::transmute::<&[Clause<'db>], &[Clause<'static>]>(slice) }; let flags = FlagComputation::>::for_clauses(slice); - let flags = WithCachedTypeInfo { + let flags = ClausesCachedTypeInfo(WithCachedTypeInfo { internee: (), flags: flags.flags, outer_exclusive_binder: flags.outer_exclusive_binder, - }; + }); Self { interned: InternedSlice::from_header_and_slice(flags, slice) } } @@ -400,20 +403,21 @@ impl<'db> rustc_type_ir::TypeVisitable> for Clauses<'db> { impl<'db, V: super::WorldExposer> rustc_type_ir::GenericTypeVisitable for Clauses<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned_slice(self.interned); - self.as_slice().iter().for_each(|it| it.generic_visit_with(visitor)); + if visitor.on_interned_slice(self.interned).is_continue() { + self.as_slice().iter().for_each(|it| it.generic_visit_with(visitor)); + } } } impl<'db> rustc_type_ir::Flags for Clauses<'db> { #[inline] fn flags(&self) -> rustc_type_ir::TypeFlags { - self.interned.header.header.flags + self.interned.header.header.0.flags } #[inline] fn outer_exclusive_binder(&self) -> rustc_type_ir::DebruijnIndex { - self.interned.header.header.outer_exclusive_binder + self.interned.header.header.0.outer_exclusive_binder } } @@ -430,7 +434,9 @@ impl<'db> rustc_type_ir::TypeSuperVisitable> for Clauses<'db> { pub struct Clause<'db>(pub(crate) Predicate<'db>); // We could cram the reveal into the clauses like rustc does, probably -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, TypeVisitable, TypeFoldable)] +#[derive( + Copy, Clone, Debug, Hash, PartialEq, Eq, TypeVisitable, TypeFoldable, GenericTypeVisitable, +)] pub struct ParamEnv<'db> { pub(crate) clauses: Clauses<'db>, } @@ -474,8 +480,9 @@ impl<'db> TypeVisitable> for Predicate<'db> { impl<'db, V: super::WorldExposer> GenericTypeVisitable for Predicate<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned(self.interned); - self.kind().generic_visit_with(visitor); + if visitor.on_interned(self.interned).is_continue() { + self.kind().generic_visit_with(visitor); + } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs index dee7953ae36c..e34e87601fd7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs @@ -2,6 +2,7 @@ use hir_def::LifetimeParamId; use intern::{Interned, InternedRef, Symbol, impl_internable}; +use macros::GenericTypeVisitable; use rustc_type_ir::{ BoundVar, BoundVarIndexKind, DebruijnIndex, Flags, GenericTypeVisitable, INNERMOST, RegionVid, TypeFlags, TypeFoldable, TypeVisitable, @@ -25,7 +26,7 @@ pub struct Region<'db> { pub(super) interned: InternedRef<'db, RegionInterned>, } -#[derive(PartialEq, Eq, Hash)] +#[derive(PartialEq, Eq, Hash, GenericTypeVisitable)] #[repr(align(4))] // Required for `GenericArg` bit-tagging. pub(super) struct RegionInterned(RegionKind<'static>); @@ -388,8 +389,9 @@ impl<'db> PlaceholderLike> for PlaceholderRegion { impl<'db, V: super::WorldExposer> GenericTypeVisitable for Region<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned(self.interned); - self.kind().generic_visit_with(visitor); + if visitor.on_interned(self.interned).is_continue() { + self.kind().generic_visit_with(visitor); + } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs index 305da50b6d9f..85534e42a823 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs @@ -8,6 +8,7 @@ use hir_def::{ }; use hir_def::{TraitId, type_ref::Rawness}; use intern::{Interned, InternedRef, impl_internable}; +use macros::GenericTypeVisitable; use rustc_abi::{Float, Integer, Size}; use rustc_ast_ir::{Mutability, try_visit, visit::VisitorResult}; use rustc_type_ir::{ @@ -51,7 +52,7 @@ pub struct Ty<'db> { pub(super) interned: InternedRef<'db, TyInterned>, } -#[derive(PartialEq, Eq, Hash)] +#[derive(PartialEq, Eq, Hash, GenericTypeVisitable)] #[repr(align(4))] // Required for `GenericArg` bit-tagging. pub(super) struct TyInterned(WithCachedTypeInfo>); @@ -750,8 +751,9 @@ impl<'db> IntoKind for Ty<'db> { impl<'db, V: super::WorldExposer> GenericTypeVisitable for Ty<'db> { fn generic_visit_with(&self, visitor: &mut V) { - visitor.on_interned(self.interned); - self.kind().generic_visit_with(visitor); + if visitor.on_interned(self.interned).is_continue() { + self.kind().generic_visit_with(visitor); + } } } diff --git a/src/tools/rust-analyzer/crates/hir/src/lib.rs b/src/tools/rust-analyzer/crates/hir/src/lib.rs index 3532220b72ae..933dd6af1d52 100644 --- a/src/tools/rust-analyzer/crates/hir/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir/src/lib.rs @@ -175,7 +175,7 @@ pub use { layout::LayoutError, mir::{MirEvalError, MirLowerError}, next_solver::abi::Safety, - next_solver::clear_tls_solver_cache, + next_solver::{clear_tls_solver_cache, collect_ty_garbage}, }, // FIXME: These are needed for import assets, properly encapsulate them. hir_ty::{method_resolution::TraitImpls, next_solver::SimplifiedType}, diff --git a/src/tools/rust-analyzer/crates/intern/Cargo.toml b/src/tools/rust-analyzer/crates/intern/Cargo.toml index 44621031ab8e..6414f091783c 100644 --- a/src/tools/rust-analyzer/crates/intern/Cargo.toml +++ b/src/tools/rust-analyzer/crates/intern/Cargo.toml @@ -19,6 +19,7 @@ hashbrown.workspace = true rustc-hash.workspace = true triomphe.workspace = true smallvec.workspace = true +rayon.workspace = true [lints] workspace = true diff --git a/src/tools/rust-analyzer/crates/intern/src/gc.rs b/src/tools/rust-analyzer/crates/intern/src/gc.rs new file mode 100644 index 000000000000..e559d1dc5710 --- /dev/null +++ b/src/tools/rust-analyzer/crates/intern/src/gc.rs @@ -0,0 +1,325 @@ +//! Garbage collection of interned values. + +use std::{marker::PhantomData, ops::ControlFlow}; + +use hashbrown::raw::RawTable; +use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; +use rustc_hash::{FxBuildHasher, FxHashSet}; +use triomphe::{Arc, ThinArc}; + +use crate::{Internable, InternedRef, InternedSliceRef, SliceInternable}; + +trait Storage { + fn len(&self) -> usize; + + fn mark(&self, gc: &mut GarbageCollector); + + fn sweep(&self, gc: &GarbageCollector); +} + +struct InternedStorage(PhantomData T>); + +impl Storage for InternedStorage { + fn len(&self) -> usize { + T::storage().get().len() + } + + fn mark(&self, gc: &mut GarbageCollector) { + let storage = T::storage().get(); + for item in storage { + let item = item.key(); + let addr = Arc::as_ptr(item).addr(); + if Arc::strong_count(item) > 1 { + // The item is referenced from the outside. + gc.alive.insert(addr); + item.visit_with(gc); + } + } + } + + fn sweep(&self, gc: &GarbageCollector) { + let storage = T::storage().get(); + if cfg!(miri) { + storage.shards().iter().for_each(|shard| { + gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) + }); + } else { + storage.shards().par_iter().for_each(|shard| { + gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) + }); + } + } +} + +struct InternedSliceStorage(PhantomData T>); + +impl Storage for InternedSliceStorage { + fn len(&self) -> usize { + T::storage().get().len() + } + + fn mark(&self, gc: &mut GarbageCollector) { + let storage = T::storage().get(); + for item in storage { + let item = item.key(); + let addr = ThinArc::as_ptr(item).addr(); + if ThinArc::strong_count(item) > 1 { + // The item is referenced from the outside. + gc.alive.insert(addr); + T::visit_header(&item.header.header, gc); + T::visit_slice(&item.slice, gc); + } + } + } + + fn sweep(&self, gc: &GarbageCollector) { + let storage = T::storage().get(); + if cfg!(miri) { + storage.shards().iter().for_each(|shard| { + gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) + }); + } else { + storage.shards().par_iter().for_each(|shard| { + gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) + }); + } + } +} + +pub trait GcInternedVisit { + fn visit_with(&self, gc: &mut GarbageCollector); +} + +pub trait GcInternedSliceVisit: SliceInternable { + fn visit_header(header: &Self::Header, gc: &mut GarbageCollector); + fn visit_slice(header: &[Self::SliceType], gc: &mut GarbageCollector); +} + +#[derive(Default)] +pub struct GarbageCollector { + alive: FxHashSet, + storages: Vec>, +} + +impl GarbageCollector { + pub fn add_storage(&mut self) { + const { assert!(T::USE_GC) }; + + self.storages.push(Box::new(InternedStorage::(PhantomData))); + } + + pub fn add_slice_storage(&mut self) { + const { assert!(T::USE_GC) }; + + self.storages.push(Box::new(InternedSliceStorage::(PhantomData))); + } + + /// # Safety + /// + /// This cannot be called if there are some not-yet-recorded type values. + pub unsafe fn collect(mut self) { + let total_nodes = self.storages.iter().map(|storage| storage.len()).sum(); + self.alive = FxHashSet::with_capacity_and_hasher(total_nodes, FxBuildHasher); + + let storages = std::mem::take(&mut self.storages); + + for storage in &storages { + storage.mark(&mut self); + } + + if cfg!(miri) { + storages.iter().for_each(|storage| storage.sweep(&self)); + } else { + storages.par_iter().for_each(|storage| storage.sweep(&self)); + } + } + + pub fn mark_interned_alive( + &mut self, + interned: InternedRef<'_, T>, + ) -> ControlFlow<()> { + if interned.strong_count() > 1 { + // It will be visited anyway, so short-circuit + return ControlFlow::Break(()); + } + let addr = interned.as_raw().addr(); + if !self.alive.insert(addr) { ControlFlow::Break(()) } else { ControlFlow::Continue(()) } + } + + pub fn mark_interned_slice_alive( + &mut self, + interned: InternedSliceRef<'_, T>, + ) -> ControlFlow<()> { + if interned.strong_count() > 1 { + // It will be visited anyway, so short-circuit + return ControlFlow::Break(()); + } + let addr = interned.as_raw().addr(); + if !self.alive.insert(addr) { ControlFlow::Break(()) } else { ControlFlow::Continue(()) } + } + + #[inline] + fn retain_only_alive(&self, map: &mut RawTable, mut get_addr: impl FnMut(&T) -> usize) { + unsafe { + // Here we only use `iter` as a temporary, preventing use-after-free + for bucket in map.iter() { + let item = bucket.as_mut(); + let addr = get_addr(item); + if !self.alive.contains(&addr) { + map.erase(bucket); + } + } + } + } +} + +#[cfg(test)] +mod tests { + use crate::{ + GarbageCollector, GcInternedSliceVisit, GcInternedVisit, Interned, InternedSliceRef, + }; + + crate::impl_internable!(String); + + #[test] + fn simple_interned() { + let a = Interned::new("abc".to_owned()); + let b = Interned::new("abc".to_owned()); + assert_eq!(a, b); + assert_eq!(a.as_ref(), b.as_ref()); + assert_eq!(a.as_ref(), a.as_ref()); + assert_eq!(a, a.clone()); + assert_eq!(a, a.clone().clone()); + assert_eq!(b.clone(), a.clone().clone()); + assert_eq!(*a, "abc"); + assert_eq!(*b, "abc"); + assert_eq!(b.as_ref().to_owned(), a); + let c = Interned::new("def".to_owned()); + assert_ne!(a, c); + assert_ne!(b, c); + assert_ne!(b.as_ref(), c.as_ref()); + assert_eq!(*c.as_ref(), "def"); + drop(c); + assert_eq!(*a, "abc"); + assert_eq!(*b, "abc"); + drop(a); + assert_eq!(*b, "abc"); + drop(b); + } + + #[test] + fn simple_gc() { + #[derive(Debug, PartialEq, Eq, Hash)] + struct GcString(String); + + crate::impl_internable!(gc; GcString); + + impl GcInternedVisit for GcString { + fn visit_with(&self, _gc: &mut GarbageCollector) {} + } + + crate::impl_slice_internable!(gc; StringSlice, String, String); + type InternedSlice = crate::InternedSlice; + + impl GcInternedSliceVisit for StringSlice { + fn visit_header(_header: &Self::Header, _gc: &mut GarbageCollector) {} + + fn visit_slice(_header: &[Self::SliceType], _gc: &mut GarbageCollector) {} + } + + let (a, d) = { + let a = Interned::new_gc(GcString("abc".to_owned())).to_owned(); + let b = Interned::new_gc(GcString("abc".to_owned())).to_owned(); + assert_eq!(a, b); + assert_eq!(a.as_ref(), b.as_ref()); + assert_eq!(a.as_ref(), a.as_ref()); + assert_eq!(a, a.clone()); + assert_eq!(a, a.clone().clone()); + assert_eq!(b.clone(), a.clone().clone()); + assert_eq!(a.0, "abc"); + assert_eq!(b.0, "abc"); + assert_eq!(b.as_ref().to_owned(), a); + let c = Interned::new_gc(GcString("def".to_owned())).to_owned(); + assert_ne!(a, c); + assert_ne!(b, c); + assert_ne!(b.as_ref(), c.as_ref()); + assert_eq!(c.as_ref().0, "def"); + + let d = InternedSlice::from_header_and_slice( + "abc".to_owned(), + &["def".to_owned(), "123".to_owned()], + ); + let e = InternedSlice::from_header_and_slice( + "abc".to_owned(), + &["def".to_owned(), "123".to_owned()], + ); + assert_eq!(d, e); + assert_eq!(d.to_owned(), e.to_owned()); + assert_eq!(d.header.length, 2); + assert_eq!(d.header.header, "abc"); + assert_eq!(d.slice, ["def", "123"]); + (a, d.to_owned()) + }; + + let mut gc = GarbageCollector::default(); + gc.add_slice_storage::(); + gc.add_storage::(); + unsafe { gc.collect() }; + + assert_eq!(a.0, "abc"); + assert_eq!(d.header.length, 2); + assert_eq!(d.header.header, "abc"); + assert_eq!(d.slice, ["def", "123"]); + + drop(a); + drop(d); + + let mut gc = GarbageCollector::default(); + gc.add_slice_storage::(); + gc.add_storage::(); + unsafe { gc.collect() }; + } + + #[test] + fn gc_visit() { + #[derive(PartialEq, Eq, Hash)] + struct GcInterned(InternedSliceRef<'static, StringSlice>); + + crate::impl_internable!(gc; GcInterned); + + impl GcInternedVisit for GcInterned { + fn visit_with(&self, gc: &mut GarbageCollector) { + _ = gc.mark_interned_slice_alive(self.0); + } + } + + crate::impl_slice_internable!(gc; StringSlice, String, i32); + type InternedSlice = crate::InternedSlice; + + impl GcInternedSliceVisit for StringSlice { + fn visit_header(_header: &Self::Header, _gc: &mut GarbageCollector) {} + + fn visit_slice(_header: &[Self::SliceType], _gc: &mut GarbageCollector) {} + } + + let outer = { + let inner = InternedSlice::from_header_and_slice("abc".to_owned(), &[123, 456, 789]); + Interned::new_gc(GcInterned(inner)).to_owned() + }; + + let mut gc = GarbageCollector::default(); + gc.add_slice_storage::(); + gc.add_storage::(); + unsafe { gc.collect() }; + + assert_eq!(outer.0.header.header, "abc"); + assert_eq!(outer.0.slice, [123, 456, 789]); + + drop(outer); + + let mut gc = GarbageCollector::default(); + gc.add_slice_storage::(); + gc.add_storage::(); + unsafe { gc.collect() }; + } +} diff --git a/src/tools/rust-analyzer/crates/intern/src/intern.rs b/src/tools/rust-analyzer/crates/intern/src/intern.rs index fdefb936560e..5d4d00118512 100644 --- a/src/tools/rust-analyzer/crates/intern/src/intern.rs +++ b/src/tools/rust-analyzer/crates/intern/src/intern.rs @@ -26,6 +26,8 @@ unsafe impl Sync for Interned {} impl Interned { #[inline] pub fn new(obj: T) -> Self { + const { assert!(!T::USE_GC) }; + let storage = T::storage().get(); let (mut shard, hash) = Self::select(storage, &obj); // Atomically, @@ -228,6 +230,11 @@ impl<'a, T: Internable> InternedRef<'a, T> { pub unsafe fn decrement_refcount(self) { unsafe { drop(Arc::from_raw(self.as_raw())) } } + + #[inline] + pub(crate) fn strong_count(self) -> usize { + ArcBorrow::strong_count(&self.arc) + } } impl Clone for InternedRef<'_, T> { @@ -292,12 +299,12 @@ impl InternStorage { } impl InternStorage { - fn get(&self) -> &InternMap { + pub(crate) fn get(&self) -> &InternMap { self.map.get_or_init(DashMap::default) } } -pub trait Internable: Hash + Eq + 'static { +pub trait Internable: Hash + Eq + Send + Sync + 'static { const USE_GC: bool; fn storage() -> &'static InternStorage; diff --git a/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs b/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs index 989a21e70cf0..7f2159ee664e 100644 --- a/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs +++ b/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs @@ -256,6 +256,16 @@ impl<'a, T: SliceInternable> InternedSliceRef<'a, T> { pub unsafe fn decrement_refcount(self) { drop(ManuallyDrop::into_inner(self.arc())); } + + #[inline] + pub(crate) fn strong_count(self) -> usize { + ThinArc::strong_count(&self.arc()) + } + + #[inline] + pub(crate) fn as_raw(self) -> *const c_void { + self.arc().as_ptr() + } } impl Clone for InternedSliceRef<'_, T> { @@ -318,15 +328,15 @@ impl InternSliceStorage { } impl InternSliceStorage { - fn get(&self) -> &InternMap { + pub(crate) fn get(&self) -> &InternMap { self.map.get_or_init(DashMap::default) } } pub trait SliceInternable: Sized + 'static { const USE_GC: bool; - type Header: Eq + Hash; - type SliceType: Eq + Hash + 'static; + type Header: Eq + Hash + Send + Sync; + type SliceType: Eq + Hash + Send + Sync + 'static; fn storage() -> &'static InternSliceStorage; } @@ -335,6 +345,7 @@ pub trait SliceInternable: Sized + 'static { #[doc(hidden)] macro_rules! _impl_slice_internable { ( gc; $tag:ident, $h:ty, $t:ty $(,)? ) => { + #[allow(unreachable_pub)] pub struct $tag; impl $crate::SliceInternable for $tag { const USE_GC: bool = true; diff --git a/src/tools/rust-analyzer/crates/intern/src/lib.rs b/src/tools/rust-analyzer/crates/intern/src/lib.rs index c5b42a860ac4..0c0b12427d21 100644 --- a/src/tools/rust-analyzer/crates/intern/src/lib.rs +++ b/src/tools/rust-analyzer/crates/intern/src/lib.rs @@ -2,10 +2,12 @@ //! //! Eventually this should probably be replaced with salsa-based interning. +mod gc; mod intern; mod intern_slice; mod symbol; +pub use self::gc::{GarbageCollector, GcInternedSliceVisit, GcInternedVisit}; pub use self::intern::{InternStorage, Internable, Interned, InternedRef, impl_internable}; pub use self::intern_slice::{ InternSliceStorage, InternedSlice, InternedSliceRef, SliceInternable, impl_slice_internable, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs index f863a7ee8d04..76256b0a2253 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -355,6 +355,7 @@ impl flags::AnalysisStats { } hir::clear_tls_solver_cache(); + unsafe { hir::collect_ty_garbage() }; let db = host.raw_database_mut(); db.trigger_lru_eviction(); diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 007725be7406..2371f7a65649 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -98,6 +98,13 @@ config_data! { /// Code's `files.watcherExclude`. files_exclude | files_excludeDirs: Vec = vec![], + /// This config controls the frequency in which rust-analyzer will perform its internal Garbage + /// Collection. It is specified in revisions, roughly equivalent to number of changes. The default + /// is 1000. + /// + /// Setting a smaller value may help limit peak memory usage at the expense of speed. + gc_frequency: usize = 1000, + /// If this is `true`, when "Goto Implementations" and in "Implementations" lens, are triggered on a `struct` or `enum` or `union`, we filter out trait implementations that originate from `derive`s above the type. gotoImplementations_filterAdjacentDerives: bool = false, @@ -1701,9 +1708,11 @@ impl Config { pub fn caps(&self) -> &ClientCapabilities { &self.caps } -} -impl Config { + pub fn gc_freq(&self) -> usize { + *self.gc_frequency() + } + pub fn assist(&self, source_root: Option) -> AssistConfig { AssistConfig { snippet_cap: self.snippet_cap(), diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs index 7828f5084433..41783584a9ba 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs @@ -193,6 +193,8 @@ pub(crate) struct GlobalState { /// which will usually end up causing a bunch of incorrect diagnostics on startup. pub(crate) incomplete_crate_graph: bool, + pub(crate) revisions_until_next_gc: usize, + pub(crate) minicore: MiniCoreRustAnalyzerInternalOnly, } @@ -319,6 +321,8 @@ impl GlobalState { incomplete_crate_graph: false, minicore: MiniCoreRustAnalyzerInternalOnly::default(), + + revisions_until_next_gc: config.gc_freq(), }; // Apply any required database inputs from the config. this.update_configuration(config); @@ -435,6 +439,15 @@ impl GlobalState { }); self.analysis_host.apply_change(change); + + if self.revisions_until_next_gc == 0 { + // SAFETY: Just changed some database inputs, all queries were canceled. + unsafe { hir::collect_ty_garbage() }; + self.revisions_until_next_gc = self.config.gc_freq(); + } else { + self.revisions_until_next_gc -= 1; + } + if !modified_ratoml_files.is_empty() || !self.config.same_source_root_parent_map(&self.local_roots_parent_map) { diff --git a/src/tools/rust-analyzer/docs/book/src/configuration_generated.md b/src/tools/rust-analyzer/docs/book/src/configuration_generated.md index 1f5c672233ae..6b7ef049645c 100644 --- a/src/tools/rust-analyzer/docs/book/src/configuration_generated.md +++ b/src/tools/rust-analyzer/docs/book/src/configuration_generated.md @@ -635,6 +635,17 @@ Default: `"client"` Controls file watching implementation. +## rust-analyzer.gc.frequency {#gc.frequency} + +Default: `1000` + +This config controls the frequency in which rust-analyzer will perform its internal Garbage +Collection. It is specified in revisions, roughly equivalent to number of changes. The default +is 1000. + +Setting a smaller value may help limit peak memory usage at the expense of speed. + + ## rust-analyzer.gotoImplementations.filterAdjacentDerives {#gotoImplementations.filterAdjacentDerives} Default: `false` diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index 98fe6a558b80..97db1322dd71 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -1627,6 +1627,17 @@ } } }, + { + "title": "Gc", + "properties": { + "rust-analyzer.gc.frequency": { + "markdownDescription": "This config controls the frequency in which rust-analyzer will perform its internal Garbage\nCollection. It is specified in revisions, roughly equivalent to number of changes. The default\nis 1000.\n\nSetting a smaller value may help limit peak memory usage at the expense of speed.", + "default": 1000, + "type": "integer", + "minimum": 0 + } + } + }, { "title": "Goto Implementations", "properties": { From 1dff3e71a46c4bdde01ba52c37c07902ed089c6e Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 18 Dec 2025 01:25:57 -0800 Subject: [PATCH 298/489] stabilization_guide: add missing `)` in prose --- src/doc/rustc-dev-guide/src/stabilization_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/stabilization_guide.md b/src/doc/rustc-dev-guide/src/stabilization_guide.md index 19296b22cecf..6167546a2bc8 100644 --- a/src/doc/rustc-dev-guide/src/stabilization_guide.md +++ b/src/doc/rustc-dev-guide/src/stabilization_guide.md @@ -64,7 +64,7 @@ Before the stabilization will be considered by the lang team, there must be a co There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`]. Search for the `declare_features!` macro. There should be an entry for the feature you are aiming to stabilize, -something like the following (taken from [rust-lang/rust#32409]: +something like the following (taken from [rust-lang/rust#32409]): ```rust,ignore // pub(restricted) visibilities (RFC 1422) From 957169399012bd3474b6b9b4c90048996f7c53b3 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 18 Dec 2025 01:32:49 -0800 Subject: [PATCH 299/489] unstable.rs: fix typos in comments (implementatble -> implementable) --- compiler/rustc_feature/src/unstable.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index fe053935f9e6..f0a1f1416859 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -221,7 +221,7 @@ declare_features! ( (internal, compiler_builtins, "1.13.0", None), /// Allows writing custom MIR (internal, custom_mir, "1.65.0", None), - /// Implementation details of externally implementatble items + /// Implementation details of externally implementable items (internal, eii_internals, "CURRENT_RUSTC_VERSION", None), /// Outputs useful `assert!` messages (unstable, generic_assert, "1.63.0", None), @@ -503,7 +503,7 @@ declare_features! ( (incomplete, explicit_tail_calls, "1.72.0", Some(112788)), /// Allows using `#[export_stable]` which indicates that an item is exportable. (incomplete, export_stable, "1.88.0", Some(139939)), - /// Externally implementatble items + /// Externally implementable items (unstable, extern_item_impls, "CURRENT_RUSTC_VERSION", Some(125418)), /// Allows defining `extern type`s. (unstable, extern_types, "1.23.0", Some(43467)), From 6396521fdbcda3c9e79dd7c6f698d6589eeaf5ce Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 18 Dec 2025 10:52:32 +0000 Subject: [PATCH 300/489] Rustup to rustc 1.94.0-nightly (f794a0873 2025-12-17) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4d3fe30e7d47..6ce49eb4ccf0 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2025-12-16" +channel = "nightly-2025-12-18" components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"] profile = "minimal" From 8de4afd39ba48f25be98684cdb7a96ec6da89d10 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:09:12 +0000 Subject: [PATCH 301/489] Fix rustc testsuite --- scripts/test_rustc_tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index 69c6099c3ab8..b25269d1430a 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -35,6 +35,7 @@ git checkout -- tests/ui/entry-point/auxiliary/bad_main_functions.rs rm tests/ui/asm/x86_64/evex512-implicit-feature.rs # unimplemented AVX512 x86 vendor intrinsic rm tests/ui/simd/dont-invalid-bitcast-x86_64.rs # unimplemented llvm.x86.sse41.round.ps rm tests/ui/simd/intrinsic/generic-arithmetic-pass.rs # unimplemented simd_funnel_{shl,shr} +rm -r tests/ui/scalable-vectors # scalable vectors are unsupported # exotic linkages rm tests/incremental/hashes/function_interfaces.rs @@ -159,6 +160,7 @@ rm tests/ui/lint/use-redundant/use-redundant-issue-71450.rs # same rm tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs # same rm tests/ui/specialization/const_trait_impl.rs # same rm tests/ui/thir-print/offset_of.rs # same +rm tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.rs # same # genuine bugs # ============ From fe34b17c2a626df957d26b6c2e0bbcf6e0565311 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Thu, 18 Dec 2025 11:39:40 +0100 Subject: [PATCH 302/489] Port `#[rustc_lint_opt_deny_field_access]` to attribute parser --- .../src/attributes/rustc_internal.rs | 24 +++++++++++++++++++ compiler/rustc_attr_parsing/src/context.rs | 7 +++--- .../rustc_hir/src/attrs/data_structures.rs | 3 +++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/internal.rs | 9 ++----- compiler/rustc_passes/messages.ftl | 3 --- compiler/rustc_passes/src/check_attr.rs | 16 +------------ compiler/rustc_passes/src/errors.rs | 9 ------- 8 files changed, 35 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 7910443787b4..72c6d9e9851f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -117,6 +117,30 @@ impl SingleAttributeParser for RustcLegacyConstGenericsParser { } } +pub(crate) struct RustcLintOptDenyFieldAccessParser; + +impl SingleAttributeParser for RustcLintOptDenyFieldAccessParser { + const PATH: &[Symbol] = &[sym::rustc_lint_opt_deny_field_access]; + const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Field)]); + const TEMPLATE: AttributeTemplate = template!(Word); + fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { + let Some(arg) = args.list().and_then(MetaItemListParser::single) else { + cx.expected_single_argument(cx.attr_span); + return None; + }; + + let MetaItemOrLitParser::Lit(MetaItemLit { kind: LitKind::Str(lint_message, _), .. }) = arg + else { + cx.expected_string_literal(arg.span(), arg.lit()); + return None; + }; + + Some(AttributeKind::RustcLintOptDenyFieldAccess { lint_message: *lint_message }) + } +} + pub(crate) struct RustcLintOptTyParser; impl NoArgsAttributeParser for RustcLintOptTyParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index b4854c430cae..e5448e7792a8 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,9 +61,9 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser, - RustcMainParser, RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, - RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, + RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, + RustcLintQueryInstabilityParser, RustcMainParser, RustcNeverReturnsNullPointerParser, + RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; @@ -213,6 +213,7 @@ attribute_parsers!( Single, Single, Single, + Single, Single, Single, Single, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 5e650fbb9bd0..5991fb5ab24e 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -931,6 +931,9 @@ pub enum AttributeKind { /// Represents `#[rustc_legacy_const_generics]` RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span }, + /// Represents `#[rustc_lint_opt_deny_field_access]` + RustcLintOptDenyFieldAccess { lint_message: Symbol }, + /// Represents `#[rustc_lint_opt_ty]` RustcLintOptTy, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index f99069e416bd..64aa9c2a45bc 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -94,6 +94,7 @@ impl AttributeKind { RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, + RustcLintOptDenyFieldAccess { .. } => Yes, RustcLintOptTy => Yes, RustcLintQueryInstability => Yes, RustcMain => No, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index c32fed3674fc..d6f20a4c85a4 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -668,17 +668,12 @@ impl LateLintPass<'_> for BadOptAccess { for field in adt_def.all_fields() { if field.name == target.name - && let Some(attr) = - cx.tcx.get_attr(field.did, sym::rustc_lint_opt_deny_field_access) - && let Some(items) = attr.meta_item_list() - && let Some(item) = items.first() - && let Some(lit) = item.lit() - && let ast::LitKind::Str(val, _) = lit.kind + && let Some(lint_message) = find_attr!(cx.tcx.get_all_attrs(field.did), AttributeKind::RustcLintOptDenyFieldAccess { lint_message, } => lint_message) { cx.emit_span_lint( BAD_OPT_ACCESS, expr.span, - BadOptAccessDiag { msg: val.as_str() }, + BadOptAccessDiag { msg: lint_message.as_str() }, ); } } diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 5a9b75957517..7ebfca91d499 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -473,9 +473,6 @@ passes_rustc_legacy_const_generics_only = #[rustc_legacy_const_generics] functions must only have const generics .label = non-const generic parameter -passes_rustc_lint_opt_deny_field_access = - `#[rustc_lint_opt_deny_field_access]` should be applied to a field - .label = not a field passes_rustc_pub_transparent = attribute should be applied to `#[repr(transparent)]` types diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d03da2e06cf1..33a3477bcf69 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -258,6 +258,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcNoImplicitAutorefs | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) + | AttributeKind::RustcLintOptDenyFieldAccess { .. } | AttributeKind::RustcLintOptTy | AttributeKind::RustcLintQueryInstability | AttributeKind::RustcNeverReturnsNullPointer @@ -314,9 +315,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { [sym::rustc_lint_diagnostics, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } - [sym::rustc_lint_opt_deny_field_access, ..] => { - self.check_rustc_lint_opt_deny_field_access(attr, span, target) - } [sym::rustc_clean, ..] | [sym::rustc_dirty, ..] | [sym::rustc_if_this_changed, ..] @@ -1251,18 +1249,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks that the `#[rustc_lint_opt_deny_field_access]` attribute is only applied to a field. - fn check_rustc_lint_opt_deny_field_access(&self, attr: &Attribute, span: Span, target: Target) { - match target { - Target::Field => {} - _ => { - self.tcx - .dcx() - .emit_err(errors::RustcLintOptDenyFieldAccess { attr_span: attr.span(), span }); - } - } - } - /// Checks that the dep-graph debugging attributes are only present when the query-dep-graph /// option is passed to the compiler. fn check_rustc_dirty_clean(&self, attr: &Attribute) { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index f2b7d3740cb6..895cefe672ba 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -412,15 +412,6 @@ pub(crate) struct UnusedMultiple { pub name: Symbol, } -#[derive(Diagnostic)] -#[diag(passes_rustc_lint_opt_deny_field_access)] -pub(crate) struct RustcLintOptDenyFieldAccess { - #[primary_span] - pub attr_span: Span, - #[label] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(passes_collapse_debuginfo)] pub(crate) struct CollapseDebuginfo { From cd4d899862bf23ce325c55310537b326d349bcd4 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Thu, 18 Dec 2025 12:30:05 +0100 Subject: [PATCH 303/489] make all parsed rustc attributes error on duplicate --- compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 72c6d9e9851f..8005dd76b2a3 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -145,7 +145,7 @@ pub(crate) struct RustcLintOptTyParser; impl NoArgsAttributeParser for RustcLintOptTyParser { const PATH: &[Symbol] = &[sym::rustc_lint_opt_ty]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]); const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintOptTy; } @@ -154,7 +154,7 @@ pub(crate) struct RustcLintQueryInstabilityParser; impl NoArgsAttributeParser for RustcLintQueryInstabilityParser { const PATH: &[Symbol] = &[sym::rustc_lint_query_instability]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ Allow(Target::Fn), Allow(Target::Method(MethodKind::Inherent)), From 45671b42e6b951c065d73b9f7ccaa0ff576cf9cb Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:50:08 +0000 Subject: [PATCH 304/489] Merge commit '8de4afd39ba48f25be98684cdb7a96ec6da89d10' into sync_cg_clif-2025-12-18 --- .github/workflows/main.yml | 8 ++++---- .github/workflows/rustc.yml | 4 ++-- example/std_example.rs | 18 ++++++++++++++++++ rust-toolchain | 4 ---- rust-toolchain.toml | 4 ++++ scripts/rustup.sh | 5 ++--- scripts/test_rustc_tests.sh | 29 ++++++++++++++++++++++++----- src/driver/jit.rs | 2 +- src/intrinsics/llvm_x86.rs | 29 +++++++++++++++++++++++++++++ triagebot.toml | 3 --- 10 files changed, 84 insertions(+), 22 deletions(-) delete mode 100644 rust-toolchain create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0930b924d177..07d9af4a9b54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: - name: Avoid installing rustc-dev run: | - sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain + sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain.toml rustfmt -v - name: Rustfmt @@ -88,7 +88,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - name: Set MinGW as the default toolchain if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' @@ -158,7 +158,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - name: Install hyperfine run: | @@ -207,7 +207,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain.toml', '**/Cargo.lock') }} - name: Set MinGW as the default toolchain if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' diff --git a/.github/workflows/rustc.yml b/.github/workflows/rustc.yml index 9253ab96353c..b22725fdc9d4 100644 --- a/.github/workflows/rustc.yml +++ b/.github/workflows/rustc.yml @@ -20,7 +20,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain', 'Cargo.lock') }} + key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }} - name: Test run: ./scripts/test_bootstrap.sh @@ -40,7 +40,7 @@ jobs: uses: actions/cache@v4 with: path: build/cg_clif - key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain', 'Cargo.lock') }} + key: ${{ runner.os }}-rustc-test-cargo-build-target-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock') }} - name: Install ripgrep run: | diff --git a/example/std_example.rs b/example/std_example.rs index c569ef0ef829..33db75f0943a 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -259,6 +259,9 @@ unsafe fn test_simd() { test_mm_cvttps_epi32(); test_mm_cvtsi128_si64(); + #[cfg(not(jit))] + test_mm_cvtps_ph(); + test_mm_extract_epi8(); test_mm_insert_epi16(); test_mm_shuffle_epi8(); @@ -558,6 +561,21 @@ unsafe fn test_mm_cvttps_epi32() { } } +#[cfg(target_arch = "x86_64")] +#[target_feature(enable = "f16c")] +#[cfg(not(jit))] +unsafe fn test_mm_cvtps_ph() { + const F16_ONE: i16 = 0x3c00; + const F16_TWO: i16 = 0x4000; + const F16_THREE: i16 = 0x4200; + const F16_FOUR: i16 = 0x4400; + + let a = _mm_set_ps(1.0, 2.0, 3.0, 4.0); + let r = _mm_cvtps_ph::<_MM_FROUND_CUR_DIRECTION>(a); + let e = _mm_set_epi16(0, 0, 0, 0, F16_ONE, F16_TWO, F16_THREE, F16_FOUR); + assert_eq_m128i(r, e); +} + fn test_checked_mul() { let u: Option = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 461dbcdb0fb5..000000000000 --- a/rust-toolchain +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly-2025-12-08" -components = ["rust-src", "rustc-dev", "llvm-tools"] -profile = "minimal" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000000..6ce49eb4ccf0 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2025-12-18" +components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"] +profile = "minimal" diff --git a/scripts/rustup.sh b/scripts/rustup.sh index 1a82193303e2..e26be307328f 100755 --- a/scripts/rustup.sh +++ b/scripts/rustup.sh @@ -22,8 +22,7 @@ case $1 in "prepare") echo "=> Installing new nightly" rustup toolchain install --profile minimal "nightly-${TOOLCHAIN}" # Sanity check to see if the nightly exists - sed -i "s/\"nightly-.*\"/\"nightly-${TOOLCHAIN}\"/" rust-toolchain - rustup component add rustfmt || true + sed -i "s/\"nightly-.*\"/\"nightly-${TOOLCHAIN}\"/" rust-toolchain.toml echo "=> Uninstalling all old nightlies" for nightly in $(rustup toolchain list | grep nightly | grep -v "$TOOLCHAIN" | grep -v nightly-x86_64); do @@ -35,7 +34,7 @@ case $1 in ./y.sh prepare ;; "commit") - git add rust-toolchain + git add rust-toolchain.toml git commit -m "Rustup to $(rustc -V)" ;; "push") diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index b5af585a732e..b25269d1430a 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -35,6 +35,7 @@ git checkout -- tests/ui/entry-point/auxiliary/bad_main_functions.rs rm tests/ui/asm/x86_64/evex512-implicit-feature.rs # unimplemented AVX512 x86 vendor intrinsic rm tests/ui/simd/dont-invalid-bitcast-x86_64.rs # unimplemented llvm.x86.sse41.round.ps rm tests/ui/simd/intrinsic/generic-arithmetic-pass.rs # unimplemented simd_funnel_{shl,shr} +rm -r tests/ui/scalable-vectors # scalable vectors are unsupported # exotic linkages rm tests/incremental/hashes/function_interfaces.rs @@ -53,23 +54,29 @@ rm tests/ui/sanitizer/kcfi-c-variadic.rs # same rm tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs # variadics for calling conventions other than C unsupported rm tests/ui/delegation/fn-header.rs +# inline assembly features +rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly +rm tests/ui/asm/global-asm-mono-sym-fn.rs # same +rm tests/ui/asm/naked-asm-mono-sym-fn.rs # same +rm tests/ui/asm/x86_64/goto.rs # inline asm labels not supported +rm tests/ui/asm/label-operand.rs # same +rm tests/ui/asm/may_unwind.rs # asm unwinding not supported +rm tests/ui/asm/aarch64/may_unwind.rs # same + # misc unimplemented things rm tests/ui/target-feature/missing-plusminus.rs # error not implemented rm -r tests/run-make/repr128-dwarf # debuginfo test rm -r tests/run-make/split-debuginfo # same rm -r tests/run-make/target-specs # i686 not supported by Cranelift rm -r tests/run-make/mismatching-target-triples # same -rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly -rm tests/ui/asm/global-asm-mono-sym-fn.rs # same -rm tests/ui/asm/naked-asm-mono-sym-fn.rs # same -rm tests/ui/asm/x86_64/goto.rs # inline asm labels not supported -rm tests/ui/asm/label-operand.rs # same rm tests/ui/simd/simd-bitmask-notpow2.rs # non-pow-of-2 simd vector sizes rm -r tests/run-make/used-proc-macro # used(linker) isn't supported yet rm tests/ui/linking/no-gc-encapsulation-symbols.rs # same rm tests/ui/attributes/fn-align-dyn.rs # per-function alignment not supported rm -r tests/ui/explicit-tail-calls # tail calls rm -r tests/run-make/pointer-auth-link-with-c # pointer auth +rm -r tests/ui/eii # EII not yet implemented +rm -r tests/run-make/forced-unwind-terminate-pof # forced unwinding doesn't take precedence # requires LTO rm -r tests/run-make/cdylib @@ -78,6 +85,7 @@ rm -r tests/run-make/lto-* rm -r tests/run-make/reproducible-build-2 rm -r tests/run-make/no-builtins-lto rm -r tests/run-make/reachable-extern-fn-available-lto +rm -r tests/run-make/no-builtins-linker-plugin-lto # coverage instrumentation rm tests/ui/consts/precise-drop-with-coverage.rs @@ -87,6 +95,7 @@ rm -r tests/ui/instrument-coverage/ # ================== rm tests/ui/codegen/issue-28950.rs # depends on stack size optimizations rm tests/ui/codegen/init-large-type.rs # same +rm tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs # same rm tests/ui/statics/const_generics.rs # tests an optimization rm tests/ui/linking/executable-no-mangle-strip.rs # requires --gc-sections to work for statics @@ -143,6 +152,15 @@ rm tests/ui/errors/remap-path-prefix-sysroot.rs # different sysroot source path rm -r tests/run-make/export/extern-opt # something about rustc version mismatches rm -r tests/run-make/export # same rm -r tests/ui/compiletest-self-test/compile-flags-incremental.rs # needs compiletest compiled with panic=unwind +rm tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs # something going wrong with stdlib source remapping +rm tests/ui/consts/miri_unleashed/drop.rs # same +rm tests/ui/error-emitter/multiline-removal-suggestion.rs # same +rm tests/ui/lint/lint-const-item-mutation.rs # same +rm tests/ui/lint/use-redundant/use-redundant-issue-71450.rs # same +rm tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.rs # same +rm tests/ui/specialization/const_trait_impl.rs # same +rm tests/ui/thir-print/offset_of.rs # same +rm tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.rs # same # genuine bugs # ============ @@ -157,6 +175,7 @@ rm tests/ui/lint/non-snake-case/lint-non-snake-case-crate.rs # same rm tests/ui/async-await/async-drop/async-drop-initial.rs # same (rust-lang/rust#140493) rm -r tests/ui/codegen/equal-pointers-unequal # make incorrect assumptions about the location of stack variables rm -r tests/run-make-cargo/rustdoc-scrape-examples-paths # FIXME(rust-lang/rust#145580) incr comp bug +rm -r tests/incremental/extern_static/issue-49153.rs # assumes reference to undefined static gets optimized away rm tests/ui/intrinsics/panic-uninitialized-zeroed.rs # really slow with unoptimized libstd rm tests/ui/process/process-panic-after-fork.rs # same diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 9dba46363936..3a8ca25a5fc0 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -190,7 +190,7 @@ fn dep_symbol_lookup_fn( diag.emit(); } Linkage::Dynamic => { - dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); + dylib_paths.push(src.dylib.as_ref().unwrap().clone()); } } } diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index 37fbe4be1b0f..61f48fa97743 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -1313,6 +1313,35 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( ret.write_cvalue_transmute(fx, res); } + "llvm.x86.vcvtps2ph.128" => { + // https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_cvtps_ph + intrinsic_args!(fx, args => (a, _imm8); intrinsic); + let a = a.load_scalar(fx); + + let imm8 = + if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[1].node) { + imm8 + } else { + fx.tcx + .dcx() + .span_fatal(span, "Index argument for `_mm_cvtps_ph` is not a constant"); + }; + + let imm8 = imm8.to_u32(); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String(format!("vcvtps2ph xmm0, xmm0, {imm8}").into())], + &[CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::xmm0)), + _late: true, + in_value: a, + out_place: Some(ret), + }], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + _ => { fx.tcx .dcx() diff --git a/triagebot.toml b/triagebot.toml index 13da0a87def3..eb0c7b011f60 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -2,6 +2,3 @@ # Prevents un-canonicalized issue links (to avoid wrong issues being linked in r-l/rust) [issue-links] - -# Prevents mentions in commits to avoid users being spammed -[no-mentions] From e1e8e0648cebb900fd0a1c44057caa1513bba126 Mon Sep 17 00:00:00 2001 From: Redddy Date: Thu, 18 Dec 2025 21:13:17 +0900 Subject: [PATCH 305/489] fix typo Co-authored-by: Tshepang Mbambo --- src/doc/rustc-dev-guide/src/serialization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index fcea4f3e605b..0fb7870c3a5f 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -126,9 +126,9 @@ and `Encodable`. all `Encoders` and `Decoders`. These should be used in crates that don't depend on [`rustc_middle`], or that have to be serialized by a type that does not implement `TyEncoder`. -- [`MetadataEncodable`] generate implementations that +- [`MetadataEncodable`] generates implementations that only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`]. -- [`BlobDecodable`] and [`LazyDecodable`] generate implementations that decode +- [`BlobDecodable`] and [`LazyDecodable`] generates implementations that decode with the metadata blob decoders in [`rustc_metadata::rmeta`]; use `BlobDecodable` when the type has no lazy metadata handles, and `LazyDecodable` when it does. - `TyEncodable` and `TyDecodable` generate implementation that apply to any From 54a25b152642d5e72b367a45e1080d255b5a6314 Mon Sep 17 00:00:00 2001 From: Redddy Date: Thu, 18 Dec 2025 23:54:18 +0900 Subject: [PATCH 306/489] Clarify descriptions for BlobDecodable and LazyDecodable --- src/doc/rustc-dev-guide/src/serialization.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/serialization.md b/src/doc/rustc-dev-guide/src/serialization.md index 0fb7870c3a5f..91b2cc92125e 100644 --- a/src/doc/rustc-dev-guide/src/serialization.md +++ b/src/doc/rustc-dev-guide/src/serialization.md @@ -128,9 +128,10 @@ and `Encodable`. not implement `TyEncoder`. - [`MetadataEncodable`] generates implementations that only allow decoding by [`rustc_metadata::rmeta::encoder::EncodeContext`]. -- [`BlobDecodable`] and [`LazyDecodable`] generates implementations that decode - with the metadata blob decoders in [`rustc_metadata::rmeta`]; use `BlobDecodable` - when the type has no lazy metadata handles, and `LazyDecodable` when it does. +- [`BlobDecodable`] and [`LazyDecodable`] serve as the decoding counterparts to + `MetadataEncodable`. They generate implementations that decode with the + metadata blob decoders in `rustc_metadata::rmeta`; use `BlobDecodable` when + the type has no lazy metadata handles, and `LazyDecodable` when it does. - `TyEncodable` and `TyDecodable` generate implementation that apply to any `TyEncoder` or `TyDecoder`. These should be used for types that are only serialized in crate metadata and/or the incremental cache, which is most From 83d8750aead21f4acd494d9889e131dde499d348 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Thu, 18 Dec 2025 17:28:03 +0200 Subject: [PATCH 307/489] Add extensive docs for the unsafe operations --- .../crates/hir-ty/src/next_solver.rs | 4 + .../hir-ty/src/next_solver/generic_arg.rs | 19 ++- .../crates/hir-ty/src/next_solver/interner.rs | 8 ++ .../rust-analyzer/crates/intern/src/gc.rs | 67 +++++----- .../rust-analyzer/crates/intern/src/intern.rs | 46 ++++++- .../crates/intern/src/intern_slice.rs | 117 ++++++------------ 6 files changed, 146 insertions(+), 115 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs index 539d09a8f5df..e91864bd8759 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs @@ -1,5 +1,9 @@ //! Things relevant to the next trait solver. +// Note: in interned types defined in this module, we generally treat the lifetime as advisory +// and transmute it as needed. This is because no real memory unsafety can be caused from an +// incorrect lifetime here. + pub mod abi; mod binder; mod consts; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs index f31b487eaed5..b600f6000d9e 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs @@ -1,4 +1,10 @@ -//! Things related to generic args in the next-trait-solver. +//! Things related to generic args in the next-trait-solver (`GenericArg`, `GenericArgs`, `Term`). +//! +//! Implementations of `GenericArg` and `Term` are pointer-tagged instead of an enum (rustc does +//! the same). This is done to save memory (which also helps speed) - one `GenericArg` is a machine +//! word instead of two, while matching on it is basically as cheap. The implementation for both +//! `GenericArg` and `Term` is shared in [`GenericArgImpl`]. This both simplifies the implementation, +//! as well as enables a noop conversion from `Term` to `GenericArg`. use std::{hint::unreachable_unchecked, marker::PhantomData, ptr::NonNull}; @@ -29,10 +35,14 @@ pub type TermKind<'db> = rustc_type_ir::TermKind>; #[derive(Clone, Copy, PartialEq, Eq, Hash)] struct GenericArgImpl<'db> { + /// # Invariant + /// + /// Contains an [`InternedRef`] of a [`Ty`], [`Const`] or [`Region`], bit-tagged as per the consts below. ptr: NonNull<()>, _marker: PhantomData<(Ty<'db>, Const<'db>, Region<'db>)>, } +// SAFETY: We essentially own the `Ty`, `Const` or `Region`, and they are `Send + Sync`. unsafe impl Send for GenericArgImpl<'_> {} unsafe impl Sync for GenericArgImpl<'_> {} @@ -46,6 +56,7 @@ impl<'db> GenericArgImpl<'db> { #[inline] fn new_ty(ty: Ty<'db>) -> Self { Self { + // SAFETY: We create it from an `InternedRef`, and it's never null. ptr: unsafe { NonNull::new_unchecked( ty.interned @@ -62,6 +73,7 @@ impl<'db> GenericArgImpl<'db> { #[inline] fn new_const(ty: Const<'db>) -> Self { Self { + // SAFETY: We create it from an `InternedRef`, and it's never null. ptr: unsafe { NonNull::new_unchecked( ty.interned @@ -78,6 +90,7 @@ impl<'db> GenericArgImpl<'db> { #[inline] fn new_region(ty: Region<'db>) -> Self { Self { + // SAFETY: We create it from an `InternedRef`, and it's never null. ptr: unsafe { NonNull::new_unchecked( ty.interned @@ -94,6 +107,7 @@ impl<'db> GenericArgImpl<'db> { #[inline] fn kind(self) -> GenericArgKind<'db> { let ptr = self.ptr.as_ptr().map_addr(|addr| addr & Self::PTR_MASK); + // SAFETY: We can only be created from a `Ty`, a `Const` or a `Region`, and the tag will match. unsafe { match self.ptr.addr().get() & Self::KIND_MASK { Self::TY_TAG => GenericArgKind::Type(Ty { @@ -113,6 +127,9 @@ impl<'db> GenericArgImpl<'db> { #[inline] fn term_kind(self) -> TermKind<'db> { let ptr = self.ptr.as_ptr().map_addr(|addr| addr & Self::PTR_MASK); + // SAFETY: We can only be created from a `Ty`, a `Const` or a `Region`, and the tag will match. + // It is the caller's responsibility (encapsulated within this module) to only call this with + // `Term`, which cannot be constructed from a `Region`. unsafe { match self.ptr.addr().get() & Self::KIND_MASK { Self::TY_TAG => { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index f2dacd16dbf9..6b97d110ee3e 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -230,8 +230,10 @@ macro_rules! impl_stored_interned_slice { } } + // SAFETY: It is safe to store this type in queries (but not `$name`). unsafe impl salsa::Update for $stored_name { unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool { + // SAFETY: Comparing by (pointer) equality is safe. unsafe { crate::utils::unsafe_update_eq(old_pointer, new_value) } } } @@ -294,6 +296,8 @@ macro_rules! impl_stored_interned { } pub(crate) use impl_stored_interned; +/// This is a visitor trait that treats any interned thing specifically. Visitables are expected to call +/// the trait's methods when encountering an interned. This is used to implement marking in GC. pub trait WorldExposer { fn on_interned( &mut self, @@ -2613,6 +2617,10 @@ pub unsafe fn collect_ty_garbage() { gc.add_slice_storage::(); gc.add_slice_storage::(); + // SAFETY: + // - By our precondition, there are no unrecorded types. + // - We implement `GcInternedVisit` and `GcInternedSliceVisit` correctly for all types. + // - We added all storages (FIXME: it's too easy to forget to add a new storage here). unsafe { gc.collect() }; } diff --git a/src/tools/rust-analyzer/crates/intern/src/gc.rs b/src/tools/rust-analyzer/crates/intern/src/gc.rs index e559d1dc5710..0d500a9714e4 100644 --- a/src/tools/rust-analyzer/crates/intern/src/gc.rs +++ b/src/tools/rust-analyzer/crates/intern/src/gc.rs @@ -1,7 +1,12 @@ //! Garbage collection of interned values. +//! +//! The GC is a simple mark-and-sweep GC: you first mark all storages, then the +//! GC visits them, and each live value they refer, recursively, then removes +//! those not marked. The sweep phase is done in parallel. -use std::{marker::PhantomData, ops::ControlFlow}; +use std::{hash::Hash, marker::PhantomData, ops::ControlFlow}; +use dashmap::DashMap; use hashbrown::raw::RawTable; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use rustc_hash::{FxBuildHasher, FxHashSet}; @@ -39,15 +44,7 @@ impl Storage for InternedStorage { fn sweep(&self, gc: &GarbageCollector) { let storage = T::storage().get(); - if cfg!(miri) { - storage.shards().iter().for_each(|shard| { - gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) - }); - } else { - storage.shards().par_iter().for_each(|shard| { - gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) - }); - } + gc.sweep_storage(storage, |item| item.as_ptr().addr()); } } @@ -74,15 +71,7 @@ impl Storage for InternedSliceStorage fn sweep(&self, gc: &GarbageCollector) { let storage = T::storage().get(); - if cfg!(miri) { - storage.shards().iter().for_each(|shard| { - gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) - }); - } else { - storage.shards().par_iter().for_each(|shard| { - gc.retain_only_alive(&mut *shard.write(), |item| item.0.as_ptr().addr()) - }); - } + gc.sweep_storage(storage, |item| item.as_ptr().addr()); } } @@ -116,7 +105,10 @@ impl GarbageCollector { /// # Safety /// - /// This cannot be called if there are some not-yet-recorded type values. + /// - This cannot be called if there are some not-yet-recorded type values. + /// - All relevant storages must have been added; that is, within the full graph of values, + /// the added storages must form a DAG. + /// - [`GcInternedVisit`] and [`GcInternedSliceVisit`] must mark all values reachable from the node. pub unsafe fn collect(mut self) { let total_nodes = self.storages.iter().map(|storage| storage.len()).sum(); self.alive = FxHashSet::with_capacity_and_hasher(total_nodes, FxBuildHasher); @@ -127,6 +119,7 @@ impl GarbageCollector { storage.mark(&mut self); } + // Miri doesn't support rayon. if cfg!(miri) { storages.iter().for_each(|storage| storage.sweep(&self)); } else { @@ -158,8 +151,26 @@ impl GarbageCollector { if !self.alive.insert(addr) { ControlFlow::Break(()) } else { ControlFlow::Continue(()) } } + fn sweep_storage( + &self, + storage: &DashMap, + get_addr: impl Fn(&T) -> usize + Send + Sync, + ) { + // Miri doesn't support rayon. + if cfg!(miri) { + storage.shards().iter().for_each(|shard| { + self.retain_only_alive(&mut *shard.write(), |item| get_addr(&item.0)) + }); + } else { + storage.shards().par_iter().for_each(|shard| { + self.retain_only_alive(&mut *shard.write(), |item| get_addr(&item.0)) + }); + } + } + #[inline] fn retain_only_alive(&self, map: &mut RawTable, mut get_addr: impl FnMut(&T) -> usize) { + // This code was copied from DashMap's retain() - which we can't use because we want to run in parallel. unsafe { // Here we only use `iter` as a temporary, preventing use-after-free for bucket in map.iter() { @@ -218,7 +229,7 @@ mod tests { fn visit_with(&self, _gc: &mut GarbageCollector) {} } - crate::impl_slice_internable!(gc; StringSlice, String, String); + crate::impl_slice_internable!(gc; StringSlice, String, u32); type InternedSlice = crate::InternedSlice; impl GcInternedSliceVisit for StringSlice { @@ -245,19 +256,13 @@ mod tests { assert_ne!(b.as_ref(), c.as_ref()); assert_eq!(c.as_ref().0, "def"); - let d = InternedSlice::from_header_and_slice( - "abc".to_owned(), - &["def".to_owned(), "123".to_owned()], - ); - let e = InternedSlice::from_header_and_slice( - "abc".to_owned(), - &["def".to_owned(), "123".to_owned()], - ); + let d = InternedSlice::from_header_and_slice("abc".to_owned(), &[123, 456]); + let e = InternedSlice::from_header_and_slice("abc".to_owned(), &[123, 456]); assert_eq!(d, e); assert_eq!(d.to_owned(), e.to_owned()); assert_eq!(d.header.length, 2); assert_eq!(d.header.header, "abc"); - assert_eq!(d.slice, ["def", "123"]); + assert_eq!(d.slice, [123, 456]); (a, d.to_owned()) }; @@ -269,7 +274,7 @@ mod tests { assert_eq!(a.0, "abc"); assert_eq!(d.header.length, 2); assert_eq!(d.header.header, "abc"); - assert_eq!(d.slice, ["def", "123"]); + assert_eq!(d.slice, [123, 456]); drop(a); drop(d); diff --git a/src/tools/rust-analyzer/crates/intern/src/intern.rs b/src/tools/rust-analyzer/crates/intern/src/intern.rs index 5d4d00118512..b7acd6624b99 100644 --- a/src/tools/rust-analyzer/crates/intern/src/intern.rs +++ b/src/tools/rust-analyzer/crates/intern/src/intern.rs @@ -1,8 +1,31 @@ //! Interning of single values. +//! +//! Interning supports two modes: GC and non-GC. +//! +//! In non-GC mode, you create [`Interned`]s, and can create `Copy` handles to them +//! that can still be upgraded back to [`Interned`] ([`InternedRef`]) via [`Interned::as_ref`]. +//! Generally, letting the [`InternedRef`] to outlive the [`Interned`] is a soundness bug and can +//! lead to UB. When all [`Interned`]s of some value are dropped, the value is freed (newer interns +//! may re-create it, not necessarily in the same place). +//! +//! In GC mode, you generally operate on [`InternedRef`]s. They are `Copy` and comfortable. To intern +//! a value you call [`Interned::new_gc`], which returns an [`InternedRef`]. Having all [`Interned`]s +//! of some value be dropped will *not* immediately free the value. Instead, a mark-and-sweep GC can +//! be initiated, which will free all values which have no live [`Interned`]s. +//! +//! Generally, in GC mode, you operate on [`InternedRef`], but when you need to store some long-term +//! value (e.g. a Salsa query output), you convert it to an [`Interned`]. This ensures that an eventual +//! GC will not free it as long as it is alive. +//! +//! Making mistakes is hard due to GC [`InternedRef`] wrappers not implementing `salsa::Update`, meaning +//! Salsa will ensure you do not store them in queries or Salsa-interneds. However it's still *possible* +//! without unsafe code (for example, by storing them in a `static`), which is why triggering GC is unsafe. +//! +//! For more information about GC see [`crate::gc`]. use std::{ fmt::{self, Debug, Display}, - hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, + hash::{BuildHasher, Hash, Hasher}, ops::Deref, ptr, sync::OnceLock, @@ -10,19 +33,16 @@ use std::{ use dashmap::{DashMap, SharedValue}; use hashbrown::raw::RawTable; -use rustc_hash::FxHasher; +use rustc_hash::FxBuildHasher; use triomphe::{Arc, ArcBorrow}; -type InternMap = DashMap, (), BuildHasherDefault>; +type InternMap = DashMap, (), FxBuildHasher>; type Guard = dashmap::RwLockWriteGuard<'static, RawTable<(Arc, SharedValue<()>)>>; pub struct Interned { arc: Arc, } -unsafe impl Send for Interned {} -unsafe impl Sync for Interned {} - impl Interned { #[inline] pub fn new(obj: T) -> Self { @@ -96,6 +116,7 @@ impl Interned { /// The pointer should originate from an `Interned` or an `InternedRef`. #[inline] pub unsafe fn from_raw(ptr: *const T) -> Self { + // SAFETY: Our precondition. Self { arc: unsafe { Arc::from_raw(ptr) } } } @@ -209,6 +230,7 @@ impl<'a, T: Internable> InternedRef<'a, T> { /// The pointer needs to originate from `Interned` or `InternedRef`. #[inline] pub unsafe fn from_raw(ptr: *const T) -> Self { + // SAFETY: Our precondition. Self { arc: unsafe { ArcBorrow::from_ptr(ptr) } } } @@ -228,6 +250,7 @@ impl<'a, T: Internable> InternedRef<'a, T> { /// map also keeps a reference to the value. #[inline] pub unsafe fn decrement_refcount(self) { + // SAFETY: Our precondition. unsafe { drop(Arc::from_raw(self.as_raw())) } } @@ -235,6 +258,17 @@ impl<'a, T: Internable> InternedRef<'a, T> { pub(crate) fn strong_count(self) -> usize { ArcBorrow::strong_count(&self.arc) } + + /// **Available only on GC mode**. + /// + /// Changes the attached lifetime, as in GC mode, the lifetime is more kind of a lint to prevent misuse + /// than actual soundness check. + #[inline] + pub fn change_lifetime<'b>(self) -> InternedRef<'b, T> { + const { assert!(T::USE_GC) }; + // SAFETY: The lifetime on `InternedRef` is essentially advisory only for GCed types. + unsafe { std::mem::transmute::, InternedRef<'b, T>>(self) } + } } impl Clone for InternedRef<'_, T> { diff --git a/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs b/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs index 7f2159ee664e..58de6e17bdff 100644 --- a/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs +++ b/src/tools/rust-analyzer/crates/intern/src/intern_slice.rs @@ -1,10 +1,16 @@ //! Interning of slices, potentially with a header. +//! +//! See [`crate::intern`] for an explanation of interning modes. Note that slice interning is currently +//! available only in GC mode (there is no other need). +//! +//! [`InternedSlice`] and [`InternedSliceRef`] are essentially [`Interned<(Header, Box<[SliceType]>)>`][crate::Interned] +//! and [`InternedRef`][crate::InternedRef] with the same types, but more optimized. There is only one +//! allocation and the pointer is thin. use std::{ - borrow::Borrow, ffi::c_void, fmt::{self, Debug}, - hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, + hash::{BuildHasher, Hash, Hasher}, marker::PhantomData, mem::ManuallyDrop, ops::Deref, @@ -14,13 +20,13 @@ use std::{ use dashmap::{DashMap, SharedValue}; use hashbrown::raw::RawTable; -use rustc_hash::FxHasher; +use rustc_hash::FxBuildHasher; use triomphe::{HeaderSlice, HeaderWithLength, ThinArc}; type InternMap = DashMap< ThinArc<::Header, ::SliceType>, (), - BuildHasherDefault, + FxBuildHasher, >; type Guard = dashmap::RwLockWriteGuard< 'static, @@ -40,14 +46,14 @@ pub struct InternedSlice { impl InternedSlice { #[inline] - fn new<'a>( + pub fn from_header_and_slice<'a>( header: T::Header, - slice: impl Borrow<[T::SliceType]> - + IntoIterator, + slice: &[T::SliceType], ) -> InternedSliceRef<'a, T> { const { assert!(T::USE_GC) }; + let storage = T::storage().get(); - let (mut shard, hash) = Self::select(storage, &header, slice.borrow()); + let (mut shard, hash) = Self::select(storage, &header, slice); // Atomically, // - check if `obj` is already in the map // - if so, clone its `Arc` and return it @@ -56,7 +62,7 @@ impl InternedSlice { // insert the same object between us looking it up and inserting it. let bucket = match shard.find_or_find_insert_slot( hash, - |(other, _)| other.header.header == header && other.slice == *slice.borrow(), + |(other, _)| other.header.header == header && other.slice == *slice, |(x, _)| storage.hasher().hash_one(x), ) { Ok(bucket) => bucket, @@ -65,51 +71,21 @@ impl InternedSlice { shard.insert_in_slot( hash, insert_slot, - ( - ThinArc::from_header_and_iter(header, slice.into_iter()), - SharedValue::new(()), - ), + (ThinArc::from_header_and_slice(header, slice), SharedValue::new(())), ) }, }; // SAFETY: We just retrieved/inserted this bucket. + // `NonNull::new_unchecked()` is safe because the pointer originates from a `ThinArc`. unsafe { InternedSliceRef { + // INVARIANT: We create it from a `ThinArc`. ptr: NonNull::new_unchecked(ThinArc::as_ptr(&bucket.as_ref().0).cast_mut()), _marker: PhantomData, } } } - #[inline] - pub fn from_header_and_slice<'a>( - header: T::Header, - slice: &[T::SliceType], - ) -> InternedSliceRef<'a, T> - where - T::SliceType: Clone, - { - return Self::new(header, Iter(slice)); - - struct Iter<'a, T>(&'a [T]); - - impl<'a, T: Clone> IntoIterator for Iter<'a, T> { - type IntoIter = std::iter::Cloned>; - type Item = T; - #[inline] - fn into_iter(self) -> Self::IntoIter { - self.0.iter().cloned() - } - } - - impl Borrow<[T]> for Iter<'_, T> { - #[inline] - fn borrow(&self) -> &[T] { - self.0 - } - } - } - #[inline] fn select( storage: &'static InternMap, @@ -132,51 +108,20 @@ impl InternedSlice { #[inline(always)] fn ptr(&self) -> *const c_void { - unsafe { ptr::from_ref(&self.arc).read().into_raw() } + self.arc.as_ptr() } #[inline] pub fn as_ref(&self) -> InternedSliceRef<'_, T> { InternedSliceRef { + // SAFETY: `self.ptr` comes from a valid `ThinArc`, so non null. + // INVARIANT: We create it from a `ThinArc`. ptr: unsafe { NonNull::new_unchecked(self.ptr().cast_mut()) }, _marker: PhantomData, } } } -impl Drop for InternedSlice { - #[inline] - fn drop(&mut self) { - // When the last `Ref` is dropped, remove the object from the global map. - if !T::USE_GC && ThinArc::strong_count(&self.arc) == 2 { - // Only `self` and the global map point to the object. - - self.drop_slow(); - } - } -} - -impl InternedSlice { - #[cold] - fn drop_slow(&mut self) { - let storage = T::storage().get(); - let (mut shard, hash) = Self::select(storage, &self.arc.header.header, &self.arc.slice); - - if ThinArc::strong_count(&self.arc) != 2 { - // Another thread has interned another copy - return; - } - - shard.remove_entry(hash, |(other, _)| **other == *self.arc); - - // Shrink the backing storage if the shard is less than 50% occupied. - if shard.len() * 2 < shard.capacity() { - let len = shard.len(); - shard.shrink_to(len, |(x, _)| storage.hasher().hash_one(x)); - } - } -} - /// Compares interned `Ref`s using pointer equality. impl PartialEq for InternedSlice { // NOTE: No `?Sized` because `ptr_eq` doesn't work right with trait objects. @@ -225,16 +170,22 @@ where #[repr(transparent)] pub struct InternedSliceRef<'a, T> { + /// # Invariant + /// + /// There is no `ThinArcBorrow` unfortunately, so this is basically a `ManuallyDrop`, + /// except that can't be `Copy`, so we store a raw pointer instead. ptr: NonNull, _marker: PhantomData<&'a T>, } +// SAFETY: This is essentially a `ThinArc`, implemented as a raw pointer because there is no `ThinArcBorrowed`. unsafe impl Send for InternedSliceRef<'_, T> {} unsafe impl Sync for InternedSliceRef<'_, T> {} impl<'a, T: SliceInternable> InternedSliceRef<'a, T> { #[inline(always)] fn arc(self) -> ManuallyDrop> { + // SAFETY: `self.ptr`'s invariant. unsafe { ManuallyDrop::new(ThinArc::from_raw(self.ptr.as_ptr())) } } @@ -245,6 +196,7 @@ impl<'a, T: SliceInternable> InternedSliceRef<'a, T> { #[inline] pub fn get(self) -> &'a Pointee { + // SAFETY: This is a lifetime extension, valid because we live for `'a`. unsafe { &*ptr::from_ref::>(&*self.arc()) } } @@ -266,6 +218,17 @@ impl<'a, T: SliceInternable> InternedSliceRef<'a, T> { pub(crate) fn as_raw(self) -> *const c_void { self.arc().as_ptr() } + + /// **Available only on GC mode**. + /// + /// Changes the attached lifetime, as in GC mode, the lifetime is more kind of a lint to prevent misuse + /// than actual soundness check. + #[inline] + pub fn change_lifetime<'b>(self) -> InternedSliceRef<'b, T> { + const { assert!(T::USE_GC) }; + // SAFETY: The lifetime on `InternedSliceRef` is essentially advisory only for GCed types. + unsafe { std::mem::transmute::, InternedSliceRef<'b, T>>(self) } + } } impl Clone for InternedSliceRef<'_, T> { @@ -336,7 +299,7 @@ impl InternSliceStorage { pub trait SliceInternable: Sized + 'static { const USE_GC: bool; type Header: Eq + Hash + Send + Sync; - type SliceType: Eq + Hash + Send + Sync + 'static; + type SliceType: Eq + Hash + Send + Sync + Copy + 'static; fn storage() -> &'static InternSliceStorage; } From a079cb98cd4dfd2839b45cecd72f5c1a6c3297ab Mon Sep 17 00:00:00 2001 From: jackh726 Date: Wed, 17 Dec 2025 17:27:17 +0000 Subject: [PATCH 308/489] Remove Expressions (and just use a Vec) --- compiler/rustc_hir_typeck/src/_match.rs | 13 +- compiler/rustc_hir_typeck/src/coercion.rs | 123 ++++-------------- compiler/rustc_hir_typeck/src/expr.rs | 6 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 6 +- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 6 +- compiler/rustc_hir_typeck/src/lib.rs | 4 +- 6 files changed, 38 insertions(+), 120 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 6467adb54dab..ded03c88a16e 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -10,7 +10,7 @@ use rustc_trait_selection::traits::{ }; use tracing::{debug, instrument}; -use crate::coercion::{AsCoercionSite, CoerceMany}; +use crate::coercion::CoerceMany; use crate::{Diverges, Expectation, FnCtxt, GatherLocalsVisitor, Needs}; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { @@ -73,7 +73,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Expectation::ExpectHasType(ety) if ety != tcx.types.unit => ety, _ => self.next_ty_var(expr.span), }; - CoerceMany::with_coercion_sites(coerce_first, arms) + CoerceMany::with_capacity(coerce_first, arms.len()) }; let mut prior_non_diverging_arms = vec![]; // Used only for diagnostics. @@ -269,16 +269,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Handle the fallback arm of a desugared if(-let) like a missing else. /// /// Returns `true` if there was an error forcing the coercion to the `()` type. - pub(super) fn if_fallback_coercion( + pub(super) fn if_fallback_coercion( &self, if_span: Span, cond_expr: &'tcx hir::Expr<'tcx>, then_expr: &'tcx hir::Expr<'tcx>, - coercion: &mut CoerceMany<'tcx, '_, T>, - ) -> bool - where - T: AsCoercionSite, - { + coercion: &mut CoerceMany<'tcx>, + ) -> bool { // If this `if` expr is the parent's function return expr, // the cause of the type coercion is the return type, point at it. (#25228) let hir_id = self.tcx.parent_hir_id(self.tcx.parent_hir_id(then_expr.hir_id)); diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 127965cb4b30..b4a43548dcda 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1165,17 +1165,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// /// This is really an internal helper. From outside the coercion /// module, you should instantiate a `CoerceMany` instance. - fn try_find_coercion_lub( + fn try_find_coercion_lub( &self, cause: &ObligationCause<'tcx>, - exprs: &[E], + exprs: &[&'tcx hir::Expr<'tcx>], prev_ty: Ty<'tcx>, new: &hir::Expr<'_>, new_ty: Ty<'tcx>, - ) -> RelateResult<'tcx, Ty<'tcx>> - where - E: AsCoercionSite, - { + ) -> RelateResult<'tcx, Ty<'tcx>> { let prev_ty = self.try_structurally_resolve_type(cause.span, prev_ty); let new_ty = self.try_structurally_resolve_type(new.span, new_ty); debug!( @@ -1269,7 +1266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer(sig.safety())), _ => span_bug!(new.span, "should not try to coerce a {new_ty} to a fn pointer"), }; - for expr in exprs.iter().map(|e| e.as_coercion_site()) { + for expr in exprs.iter() { self.apply_adjustments( expr, vec![Adjustment { kind: prev_adjustment.clone(), target: fn_ptr }], @@ -1316,7 +1313,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (adjustments, target) = self.register_infer_ok_obligations(ok); for expr in exprs { - let expr = expr.as_coercion_site(); self.apply_adjustments(expr, adjustments.clone()); } debug!( @@ -1382,41 +1378,23 @@ pub fn can_coerce<'tcx>( /// } /// let final_ty = coerce.complete(fcx); /// ``` -pub(crate) struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> { +pub(crate) struct CoerceMany<'tcx> { expected_ty: Ty<'tcx>, final_ty: Option>, - expressions: Expressions<'tcx, 'exprs, E>, - pushed: usize, + expressions: Vec<&'tcx hir::Expr<'tcx>>, } -/// The type of a `CoerceMany` that is storing up the expressions into -/// a buffer. We use this in `check/mod.rs` for things like `break`. -pub(crate) type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, &'tcx hir::Expr<'tcx>>; - -enum Expressions<'tcx, 'exprs, E: AsCoercionSite> { - Dynamic(Vec<&'tcx hir::Expr<'tcx>>), - UpFront(&'exprs [E]), -} - -impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { - /// The usual case; collect the set of expressions dynamically. - /// If the full set of coercion sites is known before hand, - /// consider `with_coercion_sites()` instead to avoid allocation. +impl<'tcx> CoerceMany<'tcx> { + /// Creates a `CoerceMany` with a default capacity of 1. If the full set of + /// coercion sites is known before hand, consider `with_capacity()` instead + /// to avoid allocation. pub(crate) fn new(expected_ty: Ty<'tcx>) -> Self { - Self::make(expected_ty, Expressions::Dynamic(vec![])) + Self::with_capacity(expected_ty, 1) } - /// As an optimization, you can create a `CoerceMany` with a - /// preexisting slice of expressions. In this case, you are - /// expected to pass each element in the slice to `coerce(...)` in - /// order. This is used with arrays in particular to avoid - /// needlessly cloning the slice. - pub(crate) fn with_coercion_sites(expected_ty: Ty<'tcx>, coercion_sites: &'exprs [E]) -> Self { - Self::make(expected_ty, Expressions::UpFront(coercion_sites)) - } - - fn make(expected_ty: Ty<'tcx>, expressions: Expressions<'tcx, 'exprs, E>) -> Self { - CoerceMany { expected_ty, final_ty: None, expressions, pushed: 0 } + /// Creates a `CoerceMany` with a given capacity. + pub(crate) fn with_capacity(expected_ty: Ty<'tcx>, capacity: usize) -> Self { + CoerceMany { expected_ty, final_ty: None, expressions: Vec::with_capacity(capacity) } } /// Returns the "expected type" with which this coercion was @@ -1529,7 +1507,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { // Handle the actual type unification etc. let result = if let Some(expression) = expression { - if self.pushed == 0 { + if self.expressions.is_empty() { // Special-case the first expression we are coercing. // To be honest, I'm not entirely sure why we do this. // We don't allow two-phase borrows, see comment in try_find_coercion_lub for why @@ -1541,22 +1519,13 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { Some(cause.clone()), ) } else { - match self.expressions { - Expressions::Dynamic(ref exprs) => fcx.try_find_coercion_lub( - cause, - exprs, - self.merged_ty(), - expression, - expression_ty, - ), - Expressions::UpFront(coercion_sites) => fcx.try_find_coercion_lub( - cause, - &coercion_sites[0..self.pushed], - self.merged_ty(), - expression, - expression_ty, - ), - } + fcx.try_find_coercion_lub( + cause, + &self.expressions, + self.merged_ty(), + expression, + expression_ty, + ) } } else { // this is a hack for cases where we default to `()` because @@ -1591,18 +1560,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { Ok(v) => { self.final_ty = Some(v); if let Some(e) = expression { - match self.expressions { - Expressions::Dynamic(ref mut buffer) => buffer.push(e), - Expressions::UpFront(coercion_sites) => { - // if the user gave us an array to validate, check that we got - // the next expression in the list, as expected - assert_eq!( - coercion_sites[self.pushed].as_coercion_site().hir_id, - e.hir_id - ); - } - } - self.pushed += 1; + self.expressions.push(e); } } Err(coercion_error) => { @@ -1955,45 +1913,12 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { } else { // If we only had inputs that were of type `!` (or no // inputs at all), then the final type is `!`. - assert_eq!(self.pushed, 0); + assert!(self.expressions.is_empty()); fcx.tcx.types.never } } } -/// Something that can be converted into an expression to which we can -/// apply a coercion. -pub(crate) trait AsCoercionSite { - fn as_coercion_site(&self) -> &hir::Expr<'_>; -} - -impl AsCoercionSite for hir::Expr<'_> { - fn as_coercion_site(&self) -> &hir::Expr<'_> { - self - } -} - -impl<'a, T> AsCoercionSite for &'a T -where - T: AsCoercionSite, -{ - fn as_coercion_site(&self) -> &hir::Expr<'_> { - (**self).as_coercion_site() - } -} - -impl AsCoercionSite for ! { - fn as_coercion_site(&self) -> &hir::Expr<'_> { - *self - } -} - -impl AsCoercionSite for hir::Arm<'_> { - fn as_coercion_site(&self) -> &hir::Expr<'_> { - self.body - } -} - /// Recursively visit goals to decide whether an unsizing is possible. /// `Break`s when it isn't, and an error should be raised. /// `Continue`s when an unsizing ok based on an implementation of the `Unsize` trait / lang item. diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 48082560bb83..c4fa39c6c2c8 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -40,7 +40,7 @@ use tracing::{debug, instrument, trace}; use {rustc_ast as ast, rustc_hir as hir}; use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation}; -use crate::coercion::{CoerceMany, DynamicCoerceMany}; +use crate::coercion::CoerceMany; use crate::errors::{ AddressOfTemporaryTaken, BaseExpressionDoubleDot, BaseExpressionDoubleDotAddExpr, BaseExpressionDoubleDotRemove, CantDereference, FieldMultiplySpecifiedInInitializer, @@ -1227,7 +1227,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // (`only_has_type`); otherwise, we just go with a // fresh type variable. let coerce_to_ty = expected.coercion_target_type(self, sp); - let mut coerce: DynamicCoerceMany<'_> = CoerceMany::new(coerce_to_ty); + let mut coerce = CoerceMany::with_capacity(coerce_to_ty, 2); coerce.coerce(self, &self.misc(sp), then_expr, then_ty); @@ -1681,7 +1681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .to_option(self) .and_then(|uty| self.try_structurally_resolve_type(expr.span, uty).builtin_index()) .unwrap_or_else(|| self.next_ty_var(expr.span)); - let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args); + let mut coerce = CoerceMany::with_capacity(coerce_to, args.len()); for e in args { let e_ty = self.check_expr_with_hint(e, coerce_to); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index d04133ccee97..c07cbfae256d 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1033,11 +1033,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // break 'a 22; }` would not force the type of the block // to be `()`). let coerce_to_ty = expected.coercion_target_type(self, blk.span); - let coerce = if blk.targeted_by_break { - CoerceMany::new(coerce_to_ty) - } else { - CoerceMany::with_coercion_sites(coerce_to_ty, blk.expr.as_slice()) - }; + let coerce = CoerceMany::new(coerce_to_ty); let prev_diverges = self.diverges.get(); let ctxt = BreakableCtxt { coerce: Some(coerce), may_break: false }; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 998c5e6cd25a..c875e2e50d70 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -25,7 +25,7 @@ use rustc_trait_selection::traits::{ self, FulfillmentError, ObligationCause, ObligationCauseCode, ObligationCtxt, }; -use crate::coercion::DynamicCoerceMany; +use crate::coercion::CoerceMany; use crate::fallback::DivergingFallbackBehavior; use crate::fn_ctxt::checks::DivergingBlockBehavior; use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt}; @@ -56,13 +56,13 @@ pub(crate) struct FnCtxt<'a, 'tcx> { /// expressions. If `None`, this is in a context where return is /// inappropriate, such as a const expression. /// - /// This is a `RefCell`, which means that we + /// This is a `RefCell`, which means that we /// can track all the return expressions and then use them to /// compute a useful coercion from the set, similar to a match /// expression or other branching context. You can use methods /// like `expected_ty` to access the declared return type (if /// any). - pub(super) ret_coercion: Option>>, + pub(super) ret_coercion: Option>>, /// First span of a return site that we find. Used in error messages. pub(super) ret_coercion_span: Cell>, diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 9ca5ddd494ae..6f9e91bca45a 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -62,7 +62,7 @@ use tracing::{debug, instrument}; use typeck_root_ctxt::TypeckRootCtxt; use crate::check::check_fn; -use crate::coercion::DynamicCoerceMany; +use crate::coercion::CoerceMany; use crate::diverges::Diverges; use crate::expectation::Expectation; use crate::fn_ctxt::LoweredTy; @@ -350,7 +350,7 @@ pub struct BreakableCtxt<'tcx> { // this is `null` for loops where break with a value is illegal, // such as `while`, `for`, and `while let` - coerce: Option>, + coerce: Option>, } pub struct EnclosingBreakables<'tcx> { From 0acc8463874c665c42d5659ef10e44b58e74cb68 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 18 Dec 2025 21:18:05 +0100 Subject: [PATCH 309/489] Normalize away the maybe remapped paths to the compiler and std --- tests/ui/extern/extern-types-field-offset.rs | 1 + tests/ui/hygiene/panic-location.rs | 1 + tests/ui/mir/lint/storage-live.rs | 1 + tests/ui/mir/lint/storage-live.stderr | 4 ++-- tests/ui/panics/panic-in-cleanup.rs | 1 + tests/ui/panics/panic-in-cleanup.run.stderr | 4 ++-- tests/ui/panics/panic-in-ffi.rs | 1 + tests/ui/panics/panic-in-ffi.run.stderr | 2 +- tests/ui/process/println-with-broken-pipe.rs | 1 + .../ui/resolve/multiple_definitions_attribute_merging.rs | 1 + .../resolve/multiple_definitions_attribute_merging.stderr | 8 ++++---- tests/ui/resolve/proc_macro_generated_packed.rs | 1 + tests/ui/resolve/proc_macro_generated_packed.stderr | 6 +++--- tests/ui/track-diagnostics/track.rs | 1 + tests/ui/track-diagnostics/track2.rs | 1 + tests/ui/track-diagnostics/track3.rs | 1 + tests/ui/track-diagnostics/track4.rs | 1 + tests/ui/track-diagnostics/track5.rs | 1 + tests/ui/track-diagnostics/track6.rs | 4 ++-- .../bad_const_generics_args_on_const_param.rs | 1 + .../bad_const_generics_args_on_const_param.stderr | 4 ++-- 21 files changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/ui/extern/extern-types-field-offset.rs b/tests/ui/extern/extern-types-field-offset.rs index 470ae07a0b55..9fe1cdf3bc47 100644 --- a/tests/ui/extern/extern-types-field-offset.rs +++ b/tests/ui/extern/extern-types-field-offset.rs @@ -2,6 +2,7 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=0 //@ normalize-stderr: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ ignore-backends: gcc #![feature(extern_types)] diff --git a/tests/ui/hygiene/panic-location.rs b/tests/ui/hygiene/panic-location.rs index 4731d8e1d538..27850f3e4c3a 100644 --- a/tests/ui/hygiene/panic-location.rs +++ b/tests/ui/hygiene/panic-location.rs @@ -2,6 +2,7 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=0 //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" // // Regression test for issue #70963 // The reported panic location should not be `<::core::macros::panic macros>`. diff --git a/tests/ui/mir/lint/storage-live.rs b/tests/ui/mir/lint/storage-live.rs index 32bd32754ddd..047ceaaf82c6 100644 --- a/tests/ui/mir/lint/storage-live.rs +++ b/tests/ui/mir/lint/storage-live.rs @@ -4,6 +4,7 @@ //@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "storage_live\[....\]" -> "storage_live[HASH]" //@ normalize-stderr: "(delayed at [^:]+):\d+:\d+ - " -> "$1:LL:CC - " +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![feature(custom_mir, core_intrinsics)] diff --git a/tests/ui/mir/lint/storage-live.stderr b/tests/ui/mir/lint/storage-live.stderr index 50df9ae061fc..ef0d253b15a8 100644 --- a/tests/ui/mir/lint/storage-live.stderr +++ b/tests/ui/mir/lint/storage-live.stderr @@ -1,12 +1,12 @@ error: internal compiler error: broken MIR in Item(DefId(0:8 ~ storage_live[HASH]::multiple_storage)) (after pass CheckForceInline) at bb0[1]: StorageLive(_1) which already has storage here - --> $DIR/storage-live.rs:21:13 + --> $DIR/storage-live.rs:22:13 | LL | StorageLive(a); | ^^^^^^^^^^^^^^ | note: delayed at compiler/rustc_mir_transform/src/lint.rs:LL:CC - disabled backtrace - --> $DIR/storage-live.rs:21:13 + --> $DIR/storage-live.rs:22:13 | LL | StorageLive(a); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/panics/panic-in-cleanup.rs b/tests/ui/panics/panic-in-cleanup.rs index 2e307de43939..23430d1f496e 100644 --- a/tests/ui/panics/panic-in-cleanup.rs +++ b/tests/ui/panics/panic-in-cleanup.rs @@ -5,6 +5,7 @@ //@ normalize-stderr: "\n +[0-9]+:[^\n]+" -> "" //@ normalize-stderr: "\n +at [^\n]+" -> "" //@ normalize-stderr: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ needs-unwind //@ ignore-emscripten "RuntimeError" junk in output //@ ignore-msvc SEH doesn't do panic-during-cleanup the same way as everyone else diff --git a/tests/ui/panics/panic-in-cleanup.run.stderr b/tests/ui/panics/panic-in-cleanup.run.stderr index bfe3dc8c9d73..b6b396d8617d 100644 --- a/tests/ui/panics/panic-in-cleanup.run.stderr +++ b/tests/ui/panics/panic-in-cleanup.run.stderr @@ -1,9 +1,9 @@ -thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:22:5: +thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:23:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:16:9: +thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:17:9: BOOM stack backtrace: diff --git a/tests/ui/panics/panic-in-ffi.rs b/tests/ui/panics/panic-in-ffi.rs index b926d0fa7761..ef40a3b6f7d6 100644 --- a/tests/ui/panics/panic-in-ffi.rs +++ b/tests/ui/panics/panic-in-ffi.rs @@ -6,6 +6,7 @@ //@ normalize-stderr: "\n +[0-9]+:[^\n]+" -> "" //@ normalize-stderr: "\n +at [^\n]+" -> "" //@ normalize-stderr: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ needs-unwind //@ ignore-emscripten "RuntimeError" junk in output diff --git a/tests/ui/panics/panic-in-ffi.run.stderr b/tests/ui/panics/panic-in-ffi.run.stderr index ce907d64358f..49eb92ef7c91 100644 --- a/tests/ui/panics/panic-in-ffi.run.stderr +++ b/tests/ui/panics/panic-in-ffi.run.stderr @@ -1,5 +1,5 @@ -thread 'main' ($TID) panicked at $DIR/panic-in-ffi.rs:21:5: +thread 'main' ($TID) panicked at $DIR/panic-in-ffi.rs:22:5: Test note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Noisy Drop diff --git a/tests/ui/process/println-with-broken-pipe.rs b/tests/ui/process/println-with-broken-pipe.rs index e87e20773702..51521f1dcf42 100644 --- a/tests/ui/process/println-with-broken-pipe.rs +++ b/tests/ui/process/println-with-broken-pipe.rs @@ -11,6 +11,7 @@ //@ ignore-visionos no 'head' //@ ignore-backends: gcc //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ compile-flags: -Zon-broken-pipe=error // Test what the error message looks like when `println!()` panics because of diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.rs b/tests/ui/resolve/multiple_definitions_attribute_merging.rs index 519b989fbe87..9f1bff51a3d4 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.rs +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.rs @@ -7,6 +7,7 @@ //@ normalize-stderr: "note: .*\n\n" -> "" //@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ rustc-env:RUST_BACKTRACE=0 #[repr(packed)] diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr index 10ce68e506e6..b8b33e3417bf 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `Dealigned` is defined multiple times - --> $DIR/multiple_definitions_attribute_merging.rs:17:1 + --> $DIR/multiple_definitions_attribute_merging.rs:18:1 | LL | struct Dealigned(u8, T); | --------------------------- previous definition of the type `Dealigned` here @@ -8,7 +8,7 @@ LL | struct Dealigned(u8, T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Dealigned` redefined here | = error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:LL:CC: builtin derive created an unaligned reference - --> $DIR/multiple_definitions_attribute_merging.rs:17:25 + --> $DIR/multiple_definitions_attribute_merging.rs:18:25 | LL | #[derive(PartialEq)] | --------- in this derive macro expansion @@ -19,8 +19,8 @@ LL | struct Dealigned(u8, T); Box query stack during panic: -#0 [mir_built] building MIR for `::eq` -#1 [check_unsafety] unsafety-checking `::eq` +#0 [mir_built] building MIR for `::eq` +#1 [check_unsafety] unsafety-checking `::eq` ... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/proc_macro_generated_packed.rs b/tests/ui/resolve/proc_macro_generated_packed.rs index 41236c732bbd..a8175895af04 100644 --- a/tests/ui/resolve/proc_macro_generated_packed.rs +++ b/tests/ui/resolve/proc_macro_generated_packed.rs @@ -7,6 +7,7 @@ //@ normalize-stderr: "note: .*\n\n" -> "" //@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ rustc-env:RUST_BACKTRACE=0 extern crate proc_macro_generate_packed; diff --git a/tests/ui/resolve/proc_macro_generated_packed.stderr b/tests/ui/resolve/proc_macro_generated_packed.stderr index 47de5be82ddf..d8e160d0c6a0 100644 --- a/tests/ui/resolve/proc_macro_generated_packed.stderr +++ b/tests/ui/resolve/proc_macro_generated_packed.stderr @@ -1,5 +1,5 @@ error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:LL:CC: builtin derive created an unaligned reference - --> $DIR/proc_macro_generated_packed.rs:18:25 + --> $DIR/proc_macro_generated_packed.rs:19:25 | LL | #[derive(PartialEq)] | --------- in this derive macro expansion @@ -10,8 +10,8 @@ LL | struct Dealigned(u8, T); Box query stack during panic: -#0 [mir_built] building MIR for `::eq` -#1 [check_unsafety] unsafety-checking `::eq` +#0 [mir_built] building MIR for `::eq` +#1 [check_unsafety] unsafety-checking `::eq` ... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack error: aborting due to 1 previous error diff --git a/tests/ui/track-diagnostics/track.rs b/tests/ui/track-diagnostics/track.rs index 2d6d6170fe0b..09864a6e3090 100644 --- a/tests/ui/track-diagnostics/track.rs +++ b/tests/ui/track-diagnostics/track.rs @@ -7,6 +7,7 @@ // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" //@ normalize-stderr: "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" // The test becomes too flaky if we care about exact args. If `-Z ui-testing` // from compiletest and `-Z track-diagnostics` from `// compile-flags` at the diff --git a/tests/ui/track-diagnostics/track2.rs b/tests/ui/track-diagnostics/track2.rs index 591b84f330b7..145b2a3e5d57 100644 --- a/tests/ui/track-diagnostics/track2.rs +++ b/tests/ui/track-diagnostics/track2.rs @@ -4,6 +4,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" fn main() { let _moved @ _from = String::from("foo"); diff --git a/tests/ui/track-diagnostics/track3.rs b/tests/ui/track-diagnostics/track3.rs index a39e71915d90..144f2794e910 100644 --- a/tests/ui/track-diagnostics/track3.rs +++ b/tests/ui/track-diagnostics/track3.rs @@ -4,6 +4,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" fn main() { let _unimported = Blah { field: u8 }; diff --git a/tests/ui/track-diagnostics/track4.rs b/tests/ui/track-diagnostics/track4.rs index 0038c616aa55..2ab7d5423303 100644 --- a/tests/ui/track-diagnostics/track4.rs +++ b/tests/ui/track-diagnostics/track4.rs @@ -4,6 +4,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" pub onion { //~^ ERROR missing `enum` for enum definition diff --git a/tests/ui/track-diagnostics/track5.rs b/tests/ui/track-diagnostics/track5.rs index 09fda4eb5273..4d47f56e5806 100644 --- a/tests/ui/track-diagnostics/track5.rs +++ b/tests/ui/track-diagnostics/track5.rs @@ -4,6 +4,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" } //~^ ERROR unexpected closing delimiter: `}` diff --git a/tests/ui/track-diagnostics/track6.rs b/tests/ui/track-diagnostics/track6.rs index 11d3b7e9764b..aa75c5691e5f 100644 --- a/tests/ui/track-diagnostics/track6.rs +++ b/tests/ui/track-diagnostics/track6.rs @@ -4,13 +4,13 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" - +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" pub trait Foo { fn bar(); } -impl Foo for T { +impl Foo for T { default fn bar() {} //~^ ERROR specialization is unstable //~| NOTE created at diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs index ff99ac98926c..29f193a4d7f3 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs @@ -3,6 +3,7 @@ //@ normalize-stderr: "note: .*\n\n" -> "" //@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![feature(pattern_types, pattern_type_macro, generic_const_exprs)] diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr index ffc6068eb17e..d053d8aed062 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr @@ -1,12 +1,12 @@ warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad_const_generics_args_on_const_param.rs:8:47 + --> $DIR/bad_const_generics_args_on_const_param.rs:9:47 | LL | #![feature(pattern_types, pattern_type_macro, generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 for more information = error: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:LL:CC: try_lower_anon_const_lit: received const param which shouldn't be possible - --> $DIR/bad_const_generics_args_on_const_param.rs:12:36 + --> $DIR/bad_const_generics_args_on_const_param.rs:13:36 | LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); | ^^^^^^^^^^^^^^^^^^^ From b31ee3af9c67c777143c0b6707a4439c78391b69 Mon Sep 17 00:00:00 2001 From: Moulins Date: Thu, 18 Dec 2025 00:27:02 +0100 Subject: [PATCH 310/489] layout: Store inverse memory index in `FieldsShape::Arbitrary` All usages of `memory_index` start by calling `invert_bijective_mapping`, so storing the inverted mapping directly saves some work and simplifies the code. --- compiler/rustc_abi/src/layout.rs | 46 ++++++++---------- compiler/rustc_abi/src/layout/coroutine.rs | 46 +++++++++--------- compiler/rustc_abi/src/layout/simple.rs | 6 +-- compiler/rustc_abi/src/lib.rs | 47 ++----------------- .../src/pretty_clif.rs | 4 +- .../rustc_const_eval/src/interpret/visitor.rs | 18 +++---- compiler/rustc_index/src/slice.rs | 3 -- compiler/rustc_transmute/src/layout/tree.rs | 5 +- compiler/rustc_ty_utils/src/layout.rs | 4 +- src/tools/miri/src/helpers.rs | 7 ++- tests/ui/abi/c-zst.aarch64-darwin.stderr | 4 +- tests/ui/abi/c-zst.powerpc-linux.stderr | 4 +- tests/ui/abi/c-zst.s390x-linux.stderr | 4 +- tests/ui/abi/c-zst.sparc64-linux.stderr | 4 +- tests/ui/abi/c-zst.x86_64-linux.stderr | 4 +- .../ui/abi/c-zst.x86_64-pc-windows-gnu.stderr | 4 +- tests/ui/abi/debug.generic.stderr | 20 ++++---- tests/ui/abi/debug.loongarch64.stderr | 20 ++++---- tests/ui/abi/debug.riscv64.stderr | 20 ++++---- tests/ui/abi/pass-indirectly-attr.stderr | 8 ++-- tests/ui/abi/sysv64-zst.stderr | 4 +- .../pass-by-value-abi.aarch64.stderr | 4 +- tests/ui/c-variadic/pass-by-value-abi.rs | 2 +- .../c-variadic/pass-by-value-abi.win.stderr | 4 +- .../pass-by-value-abi.x86_64.stderr | 12 ++--- .../enum-discriminant/wrapping_niche.stderr | 16 +++---- tests/ui/layout/debug.stderr | 14 +++--- tests/ui/layout/hexagon-enum.stderr | 20 ++++---- ...-scalarpair-payload-might-be-uninit.stderr | 34 +++++++------- .../issue-96185-overaligned-enum.stderr | 12 ++--- tests/ui/layout/thumb-enum.stderr | 20 ++++---- .../layout/zero-sized-array-enum-niche.stderr | 26 +++++----- ...-variants.aarch64-unknown-linux-gnu.stderr | 16 +++---- ...-c-dead-variants.armebv7r-none-eabi.stderr | 16 +++---- ...-dead-variants.i686-pc-windows-msvc.stderr | 16 +++---- ...d-variants.x86_64-unknown-linux-gnu.stderr | 16 +++---- tests/ui/repr/repr-c-int-dead-variants.stderr | 16 +++---- tests/ui/type/pattern_types/non_null.stderr | 10 ++-- .../ui/type/pattern_types/or_patterns.stderr | 4 +- .../type/pattern_types/range_patterns.stderr | 22 ++++----- 40 files changed, 254 insertions(+), 308 deletions(-) diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index b852d71b8008..4f1594d02a82 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -714,7 +714,7 @@ impl LayoutCalculator { }, fields: FieldsShape::Arbitrary { offsets: [niche_offset].into(), - memory_index: [0].into(), + in_memory_order: [FieldIdx::new(0)].into(), }, backend_repr: abi, largest_niche, @@ -1008,8 +1008,8 @@ impl LayoutCalculator { let pair = LayoutData::::scalar_pair(&self.cx, tag, prim_scalar); let pair_offsets = match pair.fields { - FieldsShape::Arbitrary { ref offsets, ref memory_index } => { - assert_eq!(memory_index.raw, [0, 1]); + FieldsShape::Arbitrary { ref offsets, ref in_memory_order } => { + assert_eq!(in_memory_order.raw, [FieldIdx::new(0), FieldIdx::new(1)]); offsets } _ => panic!("encountered a non-arbitrary layout during enum layout"), @@ -1061,7 +1061,7 @@ impl LayoutCalculator { }, fields: FieldsShape::Arbitrary { offsets: [Size::ZERO].into(), - memory_index: [0].into(), + in_memory_order: [FieldIdx::new(0)].into(), }, largest_niche, uninhabited, @@ -1110,10 +1110,10 @@ impl LayoutCalculator { let pack = repr.pack; let mut align = if pack.is_some() { dl.i8_align } else { dl.aggregate_align }; let mut max_repr_align = repr.align; - let mut inverse_memory_index: IndexVec = fields.indices().collect(); + let mut in_memory_order: IndexVec = fields.indices().collect(); let optimize_field_order = !repr.inhibit_struct_field_reordering(); let end = if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() }; - let optimizing = &mut inverse_memory_index.raw[..end]; + let optimizing = &mut in_memory_order.raw[..end]; let fields_excluding_tail = &fields.raw[..end]; // unsizable tail fields are excluded so that we use the same seed for the sized and unsized layouts. let field_seed = fields_excluding_tail @@ -1248,12 +1248,10 @@ impl LayoutCalculator { // regardless of the status of `-Z randomize-layout` } } - // inverse_memory_index holds field indices by increasing memory offset. - // That is, if field 5 has offset 0, the first element of inverse_memory_index is 5. + // in_memory_order holds field indices by increasing memory offset. + // That is, if field 5 has offset 0, the first element of in_memory_order is 5. // We now write field offsets to the corresponding offset slot; // field 5 with offset 0 puts 0 in offsets[5]. - // At the bottom of this function, we invert `inverse_memory_index` to - // produce `memory_index` (see `invert_mapping`). let mut unsized_field = None::<&F>; let mut offsets = IndexVec::from_elem(Size::ZERO, fields); let mut offset = Size::ZERO; @@ -1265,7 +1263,7 @@ impl LayoutCalculator { align = align.max(prefix_align); offset = prefix_size.align_to(prefix_align); } - for &i in &inverse_memory_index { + for &i in &in_memory_order { let field = &fields[i]; if let Some(unsized_field) = unsized_field { return Err(LayoutCalculatorError::UnexpectedUnsized(*unsized_field)); @@ -1322,18 +1320,6 @@ impl LayoutCalculator { debug!("univariant min_size: {:?}", offset); let min_size = offset; - // As stated above, inverse_memory_index holds field indices by increasing offset. - // This makes it an already-sorted view of the offsets vec. - // To invert it, consider: - // If field 5 has offset 0, offsets[0] is 5, and memory_index[5] should be 0. - // Field 5 would be the first element, so memory_index is i: - // Note: if we didn't optimize, it's already right. - let memory_index = if optimize_field_order { - inverse_memory_index.invert_bijective_mapping() - } else { - debug_assert!(inverse_memory_index.iter().copied().eq(fields.indices())); - inverse_memory_index.into_iter().map(|it| it.index() as u32).collect() - }; let size = min_size.align_to(align); // FIXME(oli-obk): deduplicate and harden these checks if size.bytes() >= dl.obj_size_bound() { @@ -1389,8 +1375,11 @@ impl LayoutCalculator { let pair = LayoutData::::scalar_pair(&self.cx, a, b); let pair_offsets = match pair.fields { - FieldsShape::Arbitrary { ref offsets, ref memory_index } => { - assert_eq!(memory_index.raw, [0, 1]); + FieldsShape::Arbitrary { ref offsets, ref in_memory_order } => { + assert_eq!( + in_memory_order.raw, + [FieldIdx::new(0), FieldIdx::new(1)] + ); offsets } FieldsShape::Primitive @@ -1434,7 +1423,7 @@ impl LayoutCalculator { Ok(LayoutData { variants: Variants::Single { index: VariantIdx::new(0) }, - fields: FieldsShape::Arbitrary { offsets, memory_index }, + fields: FieldsShape::Arbitrary { offsets, in_memory_order }, backend_repr: abi, largest_niche, uninhabited, @@ -1530,7 +1519,10 @@ where Ok(LayoutData { variants: Variants::Single { index: VariantIdx::new(0) }, - fields: FieldsShape::Arbitrary { offsets: [Size::ZERO].into(), memory_index: [0].into() }, + fields: FieldsShape::Arbitrary { + offsets: [Size::ZERO].into(), + in_memory_order: [FieldIdx::new(0)].into(), + }, backend_repr: repr, largest_niche: elt.largest_niche, uninhabited: false, diff --git a/compiler/rustc_abi/src/layout/coroutine.rs b/compiler/rustc_abi/src/layout/coroutine.rs index 2b22276d4aed..815cf1e28a08 100644 --- a/compiler/rustc_abi/src/layout/coroutine.rs +++ b/compiler/rustc_abi/src/layout/coroutine.rs @@ -182,33 +182,29 @@ pub(super) fn layout< // CoroutineLayout. debug!("prefix = {:#?}", prefix); let (outer_fields, promoted_offsets, promoted_memory_index) = match prefix.fields { - FieldsShape::Arbitrary { mut offsets, memory_index } => { - let mut inverse_memory_index = memory_index.invert_bijective_mapping(); - + FieldsShape::Arbitrary { mut offsets, in_memory_order } => { // "a" (`0..b_start`) and "b" (`b_start..`) correspond to // "outer" and "promoted" fields respectively. let b_start = tag_index.plus(1); let offsets_b = IndexVec::from_raw(offsets.raw.split_off(b_start.index())); let offsets_a = offsets; - // Disentangle the "a" and "b" components of `inverse_memory_index` + // Disentangle the "a" and "b" components of `in_memory_order` // by preserving the order but keeping only one disjoint "half" each. // FIXME(eddyb) build a better abstraction for permutations, if possible. - let inverse_memory_index_b: IndexVec = inverse_memory_index - .iter() - .filter_map(|&i| i.index().checked_sub(b_start.index()).map(FieldIdx::new)) - .collect(); - inverse_memory_index.raw.retain(|&i| i.index() < b_start.index()); - let inverse_memory_index_a = inverse_memory_index; - - // Since `inverse_memory_index_{a,b}` each only refer to their - // respective fields, they can be safely inverted - let memory_index_a = inverse_memory_index_a.invert_bijective_mapping(); - let memory_index_b = inverse_memory_index_b.invert_bijective_mapping(); + let mut in_memory_order_a = IndexVec::::new(); + let mut in_memory_order_b = IndexVec::::new(); + for i in in_memory_order { + if let Some(j) = i.index().checked_sub(b_start.index()) { + in_memory_order_b.push(FieldIdx::new(j)); + } else { + in_memory_order_a.push(i); + } + } let outer_fields = - FieldsShape::Arbitrary { offsets: offsets_a, memory_index: memory_index_a }; - (outer_fields, offsets_b, memory_index_b) + FieldsShape::Arbitrary { offsets: offsets_a, in_memory_order: in_memory_order_a }; + (outer_fields, offsets_b, in_memory_order_b.invert_bijective_mapping()) } _ => unreachable!(), }; @@ -236,7 +232,7 @@ pub(super) fn layout< )?; variant.variants = Variants::Single { index }; - let FieldsShape::Arbitrary { offsets, memory_index } = variant.fields else { + let FieldsShape::Arbitrary { offsets, in_memory_order } = variant.fields else { unreachable!(); }; @@ -249,8 +245,9 @@ pub(super) fn layout< // promoted fields were being used, but leave the elements not in the // subset as `invalid_field_idx`, which we can filter out later to // obtain a valid (bijective) mapping. + let memory_index = in_memory_order.invert_bijective_mapping(); let invalid_field_idx = promoted_memory_index.len() + memory_index.len(); - let mut combined_inverse_memory_index = + let mut combined_in_memory_order = IndexVec::from_elem_n(FieldIdx::new(invalid_field_idx), invalid_field_idx); let mut offsets_and_memory_index = iter::zip(offsets, memory_index); @@ -268,19 +265,18 @@ pub(super) fn layout< (promoted_offsets[field_idx], promoted_memory_index[field_idx]) } }; - combined_inverse_memory_index[memory_index] = i; + combined_in_memory_order[memory_index] = i; offset }) .collect(); - // Remove the unused slots and invert the mapping to obtain the - // combined `memory_index` (also see previous comment). - combined_inverse_memory_index.raw.retain(|&i| i.index() != invalid_field_idx); - let combined_memory_index = combined_inverse_memory_index.invert_bijective_mapping(); + // Remove the unused slots to obtain the combined `in_memory_order` + // (also see previous comment). + combined_in_memory_order.raw.retain(|&i| i.index() != invalid_field_idx); variant.fields = FieldsShape::Arbitrary { offsets: combined_offsets, - memory_index: combined_memory_index, + in_memory_order: combined_in_memory_order, }; size = size.max(variant.size); diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index b3807c872739..3784611b157b 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -16,7 +16,7 @@ impl LayoutData { variants: Variants::Single { index: VariantIdx::new(0) }, fields: FieldsShape::Arbitrary { offsets: IndexVec::new(), - memory_index: IndexVec::new(), + in_memory_order: IndexVec::new(), }, backend_repr: BackendRepr::Memory { sized }, largest_niche: None, @@ -108,7 +108,7 @@ impl LayoutData { variants: Variants::Single { index: VariantIdx::new(0) }, fields: FieldsShape::Arbitrary { offsets: [Size::ZERO, b_offset].into(), - memory_index: [0, 1].into(), + in_memory_order: [FieldIdx::new(0), FieldIdx::new(1)].into(), }, backend_repr: BackendRepr::ScalarPair(a, b), largest_niche, @@ -133,7 +133,7 @@ impl LayoutData { Some(fields) => FieldsShape::Union(fields), None => FieldsShape::Arbitrary { offsets: IndexVec::new(), - memory_index: IndexVec::new(), + in_memory_order: IndexVec::new(), }, }, backend_repr: BackendRepr::Memory { sized: true }, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 53b2c3f36dfc..061ad8617893 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1636,19 +1636,14 @@ pub enum FieldsShape { // FIXME(eddyb) use small vector optimization for the common case. offsets: IndexVec, - /// Maps source order field indices to memory order indices, + /// Maps memory order field indices to source order indices, /// depending on how the fields were reordered (if at all). /// This is a permutation, with both the source order and the /// memory order using the same (0..n) index ranges. /// - /// Note that during computation of `memory_index`, sometimes - /// it is easier to operate on the inverse mapping (that is, - /// from memory order to source order), and that is usually - /// named `inverse_memory_index`. - /// // FIXME(eddyb) build a better abstraction for permutations, if possible. // FIXME(camlorn) also consider small vector optimization here. - memory_index: IndexVec, + in_memory_order: IndexVec, }, } @@ -1682,51 +1677,17 @@ impl FieldsShape { } } - #[inline] - pub fn memory_index(&self, i: usize) -> usize { - match *self { - FieldsShape::Primitive => { - unreachable!("FieldsShape::memory_index: `Primitive`s have no fields") - } - FieldsShape::Union(_) | FieldsShape::Array { .. } => i, - FieldsShape::Arbitrary { ref memory_index, .. } => { - memory_index[FieldIdx::new(i)].try_into().unwrap() - } - } - } - /// Gets source indices of the fields by increasing offsets. #[inline] pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator { - let mut inverse_small = [0u8; 64]; - let mut inverse_big = IndexVec::new(); - let use_small = self.count() <= inverse_small.len(); - - // We have to write this logic twice in order to keep the array small. - if let FieldsShape::Arbitrary { ref memory_index, .. } = *self { - if use_small { - for (field_idx, &mem_idx) in memory_index.iter_enumerated() { - inverse_small[mem_idx as usize] = field_idx.index() as u8; - } - } else { - inverse_big = memory_index.invert_bijective_mapping(); - } - } - // Primitives don't really have fields in the way that structs do, // but having this return an empty iterator for them is unhelpful // since that makes them look kinda like ZSTs, which they're not. let pseudofield_count = if let FieldsShape::Primitive = self { 1 } else { self.count() }; - (0..pseudofield_count).map(move |i| match *self { + (0..pseudofield_count).map(move |i| match self { FieldsShape::Primitive | FieldsShape::Union(_) | FieldsShape::Array { .. } => i, - FieldsShape::Arbitrary { .. } => { - if use_small { - inverse_small[i] as usize - } else { - inverse_big[i as u32].index() - } - } + FieldsShape::Arbitrary { in_memory_order, .. } => in_memory_order[i as u32].index(), }) } } diff --git a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs index 2878fa7aa298..65779b38ad1c 100644 --- a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs +++ b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs @@ -10,7 +10,7 @@ //! function u0:22(i64) -> i8, i8 system_v { //! ; symbol _ZN97_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$RF$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17hd361e9f5c3d1c4deE //! ; instance Instance { def: Item(DefId(0:42 ~ example[3895]::{impl#0}::call_once)), args: ['{erased}, '{erased}] } -//! ; abi FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: IsNotEmpty, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 12266848898570219025 } }, mode: Ignore }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } +//! ; abi FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: IsNotEmpty, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], in_memory_order: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 12266848898570219025 } }, mode: Ignore }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], in_memory_order: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } //! //! ; kind loc.idx param pass mode ty //! ; ssa _0 (u8, u8) 2b 1 var=(0, 1) @@ -41,7 +41,7 @@ //! ; //! ; _0 = >::call_mut(move _3, copy _2) //! v2 = stack_load.i64 ss0 -//! ; abi: FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: &mut IsNotEmpty, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(1 bytes)) }) }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } +//! ; abi: FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: &mut IsNotEmpty, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(1 bytes)) }) }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], in_memory_order: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } //! v3, v4 = call fn0(v1, v2) ; v1 = 1 //! v5 -> v3 //! v6 -> v4 diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index b5de10c7dcd1..95106c7c143b 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -4,7 +4,7 @@ use std::num::NonZero; use rustc_abi::{FieldIdx, FieldsShape, VariantIdx, Variants}; -use rustc_index::IndexVec; +use rustc_index::{Idx as _, IndexVec}; use rustc_middle::mir::interpret::InterpResult; use rustc_middle::ty::{self, Ty}; use tracing::trace; @@ -27,13 +27,15 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { /// This function provides the chance to reorder the order in which fields are visited for /// `FieldsShape::Aggregate`. /// - /// The default means we iterate in source declaration order; alternatively this can do some - /// work with `memory_index` to iterate in memory order. + /// The default means we iterate in source declaration order; alternatively this can use + /// `in_memory_order` to iterate in memory order. #[inline(always)] fn aggregate_field_iter( - memory_index: &IndexVec, - ) -> impl Iterator + 'static { - memory_index.indices() + in_memory_order: &IndexVec, + ) -> impl Iterator { + // Allow the optimizer to elide the bounds checking when creating each index. + let _ = FieldIdx::new(in_memory_order.len()); + (0..in_memory_order.len()).map(FieldIdx::new) } // Recursive actions, ready to be overloaded. @@ -168,8 +170,8 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { &FieldsShape::Union(fields) => { self.visit_union(v, fields)?; } - FieldsShape::Arbitrary { memory_index, .. } => { - for idx in Self::aggregate_field_iter(memory_index) { + FieldsShape::Arbitrary { in_memory_order, .. } => { + for idx in Self::aggregate_field_iter(in_memory_order) { let field = self.ecx().project_field(v, idx)?; self.visit_field(v, idx.as_usize(), &field)?; } diff --git a/compiler/rustc_index/src/slice.rs b/compiler/rustc_index/src/slice.rs index d2702bdb0571..415fe370b702 100644 --- a/compiler/rustc_index/src/slice.rs +++ b/compiler/rustc_index/src/slice.rs @@ -181,9 +181,6 @@ impl IndexSlice { /// Invert a bijective mapping, i.e. `invert(map)[y] = x` if `map[x] = y`, /// assuming the values in `self` are a permutation of `0..self.len()`. /// - /// This is used to go between `memory_index` (source field order to memory order) - /// and `inverse_memory_index` (memory order to source field order). - /// See also `FieldsShape::Arbitrary::memory_index` for more details. // FIXME(eddyb) build a better abstraction for permutations, if possible. pub fn invert_bijective_mapping(&self) -> IndexVec { debug_assert_eq!( diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index d9ebdadf3b79..1202ed238431 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -491,7 +491,7 @@ pub(crate) mod rustc { ) -> Result { // This constructor does not support non-`FieldsShape::Arbitrary` // layouts. - let FieldsShape::Arbitrary { offsets, memory_index } = layout.fields() else { + let FieldsShape::Arbitrary { offsets, in_memory_order } = layout.fields() else { return Err(Err::NotYetSupported); }; @@ -519,8 +519,7 @@ pub(crate) mod rustc { } // Append the fields, in memory order, to the layout. - let inverse_memory_index = memory_index.invert_bijective_mapping(); - for &field_idx in inverse_memory_index.iter() { + for &field_idx in in_memory_order.iter() { // Add interfield padding. let padding_needed = offsets[field_idx] - size; let padding = Self::padding(padding_needed.bytes_usize()); diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 6962eeddf137..62f3667ad7f4 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -9,7 +9,7 @@ use rustc_abi::{ use rustc_hashes::Hash64; use rustc_hir::attrs::AttributeKind; use rustc_hir::find_attr; -use rustc_index::IndexVec; +use rustc_index::{Idx as _, IndexVec}; use rustc_middle::bug; use rustc_middle::query::Providers; use rustc_middle::traits::ObligationCause; @@ -374,7 +374,7 @@ fn layout_of_uncached<'tcx>( // specifically care about pattern types will have to handle it. layout.fields = FieldsShape::Arbitrary { offsets: [Size::ZERO].into_iter().collect(), - memory_index: [0].into_iter().collect(), + in_memory_order: [FieldIdx::new(0)].into_iter().collect(), }; tcx.mk_layout(layout) } diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index f11860f4a1ad..218e4ffe5e2f 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -584,10 +584,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } fn aggregate_field_iter( - memory_index: &IndexVec, - ) -> impl Iterator + 'static { - let inverse_memory_index = memory_index.invert_bijective_mapping(); - inverse_memory_index.into_iter() + in_memory_order: &IndexVec, + ) -> impl Iterator { + in_memory_order.iter().copied() } // Hook to detect `UnsafeCell`. diff --git a/tests/ui/abi/c-zst.aarch64-darwin.stderr b/tests/ui/abi/c-zst.aarch64-darwin.stderr index d050bfcbaa17..6d2ac90c0c97 100644 --- a/tests/ui/abi/c-zst.aarch64-darwin.stderr +++ b/tests/ui/abi/c-zst.aarch64-darwin.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -41,7 +41,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr index 816addd79576..f297aa984dd2 100644 --- a/tests/ui/abi/c-zst.powerpc-linux.stderr +++ b/tests/ui/abi/c-zst.powerpc-linux.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -52,7 +52,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr index 816addd79576..f297aa984dd2 100644 --- a/tests/ui/abi/c-zst.s390x-linux.stderr +++ b/tests/ui/abi/c-zst.s390x-linux.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -52,7 +52,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr index 816addd79576..f297aa984dd2 100644 --- a/tests/ui/abi/c-zst.sparc64-linux.stderr +++ b/tests/ui/abi/c-zst.sparc64-linux.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -52,7 +52,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/c-zst.x86_64-linux.stderr b/tests/ui/abi/c-zst.x86_64-linux.stderr index d050bfcbaa17..6d2ac90c0c97 100644 --- a/tests/ui/abi/c-zst.x86_64-linux.stderr +++ b/tests/ui/abi/c-zst.x86_64-linux.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -41,7 +41,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr index 816addd79576..f297aa984dd2 100644 --- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr +++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -52,7 +52,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/debug.generic.stderr b/tests/ui/abi/debug.generic.stderr index 04d6f50872a3..8a031b79780a 100644 --- a/tests/ui/abi/debug.generic.stderr +++ b/tests/ui/abi/debug.generic.stderr @@ -244,7 +244,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -328,7 +328,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -400,7 +400,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -479,7 +479,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -552,7 +552,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -629,7 +629,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -701,7 +701,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -779,7 +779,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -851,7 +851,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -962,7 +962,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/debug.loongarch64.stderr b/tests/ui/abi/debug.loongarch64.stderr index 85c888c4fae0..00bd3febde4e 100644 --- a/tests/ui/abi/debug.loongarch64.stderr +++ b/tests/ui/abi/debug.loongarch64.stderr @@ -244,7 +244,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -328,7 +328,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -400,7 +400,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -479,7 +479,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -552,7 +552,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -629,7 +629,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -701,7 +701,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -779,7 +779,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -851,7 +851,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -962,7 +962,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/debug.riscv64.stderr b/tests/ui/abi/debug.riscv64.stderr index 85c888c4fae0..00bd3febde4e 100644 --- a/tests/ui/abi/debug.riscv64.stderr +++ b/tests/ui/abi/debug.riscv64.stderr @@ -244,7 +244,7 @@ error: fn_abi_of(test_generic) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -328,7 +328,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -400,7 +400,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -479,7 +479,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -552,7 +552,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -629,7 +629,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -701,7 +701,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -779,7 +779,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -851,7 +851,7 @@ error: ABIs are not compatible }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -962,7 +962,7 @@ error: fn_abi_of(assoc_test) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/pass-indirectly-attr.stderr b/tests/ui/abi/pass-indirectly-attr.stderr index a93982dacfa1..03fe9ea46a4b 100644 --- a/tests/ui/abi/pass-indirectly-attr.stderr +++ b/tests/ui/abi/pass-indirectly-attr.stderr @@ -24,7 +24,7 @@ error: fn_abi_of(extern_c) = FnAbi { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -65,7 +65,7 @@ error: fn_abi_of(extern_c) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -106,7 +106,7 @@ error: fn_abi_of(extern_rust) = FnAbi { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -165,7 +165,7 @@ error: fn_abi_of(extern_rust) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/abi/sysv64-zst.stderr b/tests/ui/abi/sysv64-zst.stderr index 2233e8e4f623..82d3793c3532 100644 --- a/tests/ui/abi/sysv64-zst.stderr +++ b/tests/ui/abi/sysv64-zst.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -41,7 +41,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr index a86b28d98ecc..584416f58f86 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, fields: Arbitrary { offsets: $OFFSETS, - memory_index: $MEMORY_INDEX, + in_memory_order: $MEMORY_INDEX, }, largest_niche: None, uninhabited: false, @@ -52,7 +52,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/c-variadic/pass-by-value-abi.rs b/tests/ui/c-variadic/pass-by-value-abi.rs index 1e3935067cc2..a7cf37295a74 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.rs +++ b/tests/ui/c-variadic/pass-by-value-abi.rs @@ -1,7 +1,7 @@ //@ check-fail //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" //@ normalize-stderr: "valid_range: 0\.\.=\d+" -> "valid_range: 0..=$$MAX" -//@ normalize-stderr: "memory_index: \[[^\]]+\]" -> "memory_index: $$MEMORY_INDEX" +//@ normalize-stderr: "in_memory_order: \[[^\]]+\]" -> "in_memory_order: $$MEMORY_INDEX" //@ normalize-stderr: "offsets: \[[^\]]+\]" -> "offsets: $$OFFSETS" //@ revisions: x86_64 aarch64 win //@ compile-flags: -O diff --git a/tests/ui/c-variadic/pass-by-value-abi.win.stderr b/tests/ui/c-variadic/pass-by-value-abi.win.stderr index 8ff93961f667..b8e3f699b30e 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.win.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.win.stderr @@ -20,7 +20,7 @@ error: fn_abi_of(take_va_list) = FnAbi { ), fields: Arbitrary { offsets: $OFFSETS, - memory_index: $MEMORY_INDEX, + in_memory_order: $MEMORY_INDEX, }, largest_niche: None, uninhabited: false, @@ -55,7 +55,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr index aafe89d59e33..b5e0e8589af1 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr +++ b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr @@ -13,7 +13,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, fields: Arbitrary { offsets: $OFFSETS, - memory_index: $MEMORY_INDEX, + in_memory_order: $MEMORY_INDEX, }, largest_niche: None, uninhabited: false, @@ -52,7 +52,7 @@ error: fn_abi_of(take_va_list) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -91,7 +91,7 @@ error: fn_abi_of(take_va_list_sysv64) = FnAbi { }, fields: Arbitrary { offsets: $OFFSETS, - memory_index: $MEMORY_INDEX, + in_memory_order: $MEMORY_INDEX, }, largest_niche: None, uninhabited: false, @@ -130,7 +130,7 @@ error: fn_abi_of(take_va_list_sysv64) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -171,7 +171,7 @@ error: fn_abi_of(take_va_list_win64) = FnAbi { }, fields: Arbitrary { offsets: $OFFSETS, - memory_index: $MEMORY_INDEX, + in_memory_order: $MEMORY_INDEX, }, largest_niche: None, uninhabited: false, @@ -210,7 +210,7 @@ error: fn_abi_of(take_va_list_win64) = FnAbi { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/enum-discriminant/wrapping_niche.stderr b/tests/ui/enum-discriminant/wrapping_niche.stderr index e3e1755e14dd..9b97ad4aeac7 100644 --- a/tests/ui/enum-discriminant/wrapping_niche.stderr +++ b/tests/ui/enum-discriminant/wrapping_niche.stderr @@ -16,7 +16,7 @@ error: layout_of(UnsignedAroundZero) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -52,7 +52,7 @@ error: layout_of(UnsignedAroundZero) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -73,7 +73,7 @@ error: layout_of(UnsignedAroundZero) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -94,7 +94,7 @@ error: layout_of(UnsignedAroundZero) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -134,7 +134,7 @@ error: layout_of(SignedAroundZero) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -170,7 +170,7 @@ error: layout_of(SignedAroundZero) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -191,7 +191,7 @@ error: layout_of(SignedAroundZero) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -212,7 +212,7 @@ error: layout_of(SignedAroundZero) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index b2ce6385ab65..79ce21eb532b 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -16,7 +16,7 @@ error: layout_of(E) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -52,7 +52,7 @@ error: layout_of(E) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -77,7 +77,7 @@ error: layout_of(E) = Layout { Size(4 bytes), Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, 2, @@ -130,7 +130,7 @@ error: layout_of(S) = Layout { Size(8 bytes), Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, 2, 1, @@ -200,7 +200,7 @@ error: layout_of(Result) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -251,7 +251,7 @@ error: layout_of(Result) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -289,7 +289,7 @@ error: layout_of(Result) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 659013c8a6f1..20e0a8642a66 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -16,7 +16,7 @@ error: layout_of(A) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -52,7 +52,7 @@ error: layout_of(A) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -92,7 +92,7 @@ error: layout_of(B) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -128,7 +128,7 @@ error: layout_of(B) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -168,7 +168,7 @@ error: layout_of(C) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -204,7 +204,7 @@ error: layout_of(C) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -244,7 +244,7 @@ error: layout_of(P) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -280,7 +280,7 @@ error: layout_of(P) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -320,7 +320,7 @@ error: layout_of(T) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -356,7 +356,7 @@ error: layout_of(T) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 2087fedeb19b..61cfcbdc07f7 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -22,7 +22,7 @@ error: layout_of(MissingPayloadField) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -72,7 +72,7 @@ error: layout_of(MissingPayloadField) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -95,7 +95,7 @@ error: layout_of(MissingPayloadField) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -142,7 +142,7 @@ error: layout_of(CommonPayloadField) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -193,7 +193,7 @@ error: layout_of(CommonPayloadField) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -231,7 +231,7 @@ error: layout_of(CommonPayloadField) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -279,7 +279,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -329,7 +329,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -366,7 +366,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -414,7 +414,7 @@ error: layout_of(NicheFirst) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -470,7 +470,7 @@ error: layout_of(NicheFirst) = Layout { Size(0 bytes), Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, ], @@ -503,7 +503,7 @@ error: layout_of(NicheFirst) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -524,7 +524,7 @@ error: layout_of(NicheFirst) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -570,7 +570,7 @@ error: layout_of(NicheSecond) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -626,7 +626,7 @@ error: layout_of(NicheSecond) = Layout { Size(1 bytes), Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 1, 0, ], @@ -659,7 +659,7 @@ error: layout_of(NicheSecond) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -680,7 +680,7 @@ error: layout_of(NicheSecond) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 6bcc5b4906b5..64e2f42c042f 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -10,7 +10,7 @@ error: layout_of(Aligned1) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -46,7 +46,7 @@ error: layout_of(Aligned1) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -69,7 +69,7 @@ error: layout_of(Aligned1) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -113,7 +113,7 @@ error: layout_of(Aligned2) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -149,7 +149,7 @@ error: layout_of(Aligned2) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -172,7 +172,7 @@ error: layout_of(Aligned2) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 1ef22daf2a9d..a6e603652123 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -16,7 +16,7 @@ error: layout_of(A) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -52,7 +52,7 @@ error: layout_of(A) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -92,7 +92,7 @@ error: layout_of(B) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -128,7 +128,7 @@ error: layout_of(B) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -168,7 +168,7 @@ error: layout_of(C) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -204,7 +204,7 @@ error: layout_of(C) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -244,7 +244,7 @@ error: layout_of(P) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -280,7 +280,7 @@ error: layout_of(P) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -320,7 +320,7 @@ error: layout_of(T) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -356,7 +356,7 @@ error: layout_of(T) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index 1707b8aff81c..23f909277808 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -10,7 +10,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -48,7 +48,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -73,7 +73,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -118,7 +118,7 @@ error: layout_of(MultipleAlignments) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -156,7 +156,7 @@ error: layout_of(MultipleAlignments) = Layout { offsets: [ Size(2 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -181,7 +181,7 @@ error: layout_of(MultipleAlignments) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -206,7 +206,7 @@ error: layout_of(MultipleAlignments) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -251,7 +251,7 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -289,7 +289,7 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -314,7 +314,7 @@ error: layout_of(Result<[u32; 0], Packed>>) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -359,7 +359,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -401,7 +401,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -426,7 +426,7 @@ error: layout_of(Result<[u32; 0], Packed>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 1a1929c530ff..62f6ec92d493 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -16,7 +16,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -60,7 +60,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -108,7 +108,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -158,7 +158,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -195,7 +195,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -231,7 +231,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -270,7 +270,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Size(8 bytes), Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, ], @@ -298,7 +298,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 67729e9fcef9..3e0efad974cd 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -16,7 +16,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -60,7 +60,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -108,7 +108,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -158,7 +158,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -195,7 +195,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -231,7 +231,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -270,7 +270,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Size(8 bytes), Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, ], @@ -298,7 +298,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 1a1929c530ff..62f6ec92d493 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -16,7 +16,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -60,7 +60,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -108,7 +108,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -158,7 +158,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -195,7 +195,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -231,7 +231,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -270,7 +270,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Size(8 bytes), Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, ], @@ -298,7 +298,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 1a1929c530ff..62f6ec92d493 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -16,7 +16,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -60,7 +60,7 @@ error: layout_of(Univariant) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -108,7 +108,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -158,7 +158,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -195,7 +195,7 @@ error: layout_of(TwoVariants) = Layout { offsets: [ Size(4 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -231,7 +231,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -270,7 +270,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { Size(8 bytes), Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, ], @@ -298,7 +298,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { offsets: [ Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index d88a842f8848..b25e4a9b7b6f 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -16,7 +16,7 @@ error: layout_of(UnivariantU8) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -60,7 +60,7 @@ error: layout_of(UnivariantU8) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -108,7 +108,7 @@ error: layout_of(TwoVariantsU8) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -158,7 +158,7 @@ error: layout_of(TwoVariantsU8) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -195,7 +195,7 @@ error: layout_of(TwoVariantsU8) = Layout { offsets: [ Size(1 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -231,7 +231,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -270,7 +270,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { Size(8 bytes), Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, 1, ], @@ -298,7 +298,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { offsets: [ Size(8 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/type/pattern_types/non_null.stderr b/tests/ui/type/pattern_types/non_null.stderr index ad61e9a59147..0847af2d086f 100644 --- a/tests/ui/type/pattern_types/non_null.stderr +++ b/tests/ui/type/pattern_types/non_null.stderr @@ -17,7 +17,7 @@ error: layout_of((*const T) is !null) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -64,7 +64,7 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -96,7 +96,7 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -126,7 +126,7 @@ error: layout_of(Option<(*const ()) is !null>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -186,7 +186,7 @@ error: layout_of((*const [u8]) is !null) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/type/pattern_types/or_patterns.stderr b/tests/ui/type/pattern_types/or_patterns.stderr index adc7320829b9..7206c570187b 100644 --- a/tests/ui/type/pattern_types/or_patterns.stderr +++ b/tests/ui/type/pattern_types/or_patterns.stderr @@ -57,7 +57,7 @@ error: layout_of((i8) is (i8::MIN..=-1 | 1..)) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -102,7 +102,7 @@ error: layout_of((i8) is (i8::MIN..=-2 | 0..)) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index c9a846e22f58..6c9acac7eb7b 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -16,7 +16,7 @@ error: layout_of(NonZero) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -61,7 +61,7 @@ error: layout_of((u32) is 1..) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -106,7 +106,7 @@ error: layout_of(Option<(u32) is 1..>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -137,7 +137,7 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -166,7 +166,7 @@ error: layout_of(Option<(u32) is 1..>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -217,7 +217,7 @@ error: layout_of(Option>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -248,7 +248,7 @@ error: layout_of(Option>) = Layout { }, fields: Arbitrary { offsets: [], - memory_index: [], + in_memory_order: [], }, largest_niche: None, uninhabited: false, @@ -277,7 +277,7 @@ error: layout_of(Option>) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -328,7 +328,7 @@ error: layout_of(NonZeroU32New) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -401,7 +401,7 @@ error: layout_of((i8) is -10..=10) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, @@ -446,7 +446,7 @@ error: layout_of((i8) is i8::MIN..=0) = Layout { offsets: [ Size(0 bytes), ], - memory_index: [ + in_memory_order: [ 0, ], }, From 005046ddd4f990f48dee63a24f49fb47de992646 Mon Sep 17 00:00:00 2001 From: Moulins Date: Thu, 18 Dec 2025 00:27:02 +0100 Subject: [PATCH 311/489] layout: Store inverse memory index in `FieldsShape::Arbitrary` All usages of `memory_index` start by calling `invert_bijective_mapping`, so storing the inverted mapping directly saves some work and simplifies the code. --- src/pretty_clif.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 2878fa7aa298..65779b38ad1c 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -10,7 +10,7 @@ //! function u0:22(i64) -> i8, i8 system_v { //! ; symbol _ZN97_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$RF$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17hd361e9f5c3d1c4deE //! ; instance Instance { def: Item(DefId(0:42 ~ example[3895]::{impl#0}::call_once)), args: ['{erased}, '{erased}] } -//! ; abi FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: IsNotEmpty, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], memory_index: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 12266848898570219025 } }, mode: Ignore }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } +//! ; abi FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: IsNotEmpty, layout: Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [], in_memory_order: [] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 12266848898570219025 } }, mode: Ignore }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], in_memory_order: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } //! //! ; kind loc.idx param pass mode ty //! ; ssa _0 (u8, u8) 2b 1 var=(0, 1) @@ -41,7 +41,7 @@ //! ; //! ; _0 = >::call_mut(move _3, copy _2) //! v2 = stack_load.i64 ss0 -//! ; abi: FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: &mut IsNotEmpty, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(1 bytes)) }) }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], memory_index: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } +//! ; abi: FnAbi { args: [ArgAbi { layout: TyAndLayout { ty: &mut IsNotEmpty, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(1 bytes)) }) }, ArgAbi { layout: TyAndLayout { ty: &&[u16], layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, backend_repr: Scalar(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 281492156579847 } }, mode: Direct(ArgAttributes { regular: NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some(Align(8 bytes)) }) }], ret: ArgAbi { layout: TyAndLayout { ty: (u8, u8), layout: Layout { size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: Align(8 bytes) }, backend_repr: ScalarPair(Initialized { value: Int(I8, false), valid_range: 0..=255 }, Initialized { value: Int(I8, false), valid_range: 0..=255 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(1 bytes)], in_memory_order: [0, 1] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 71776127651151873 } }, mode: Pair(ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }, ArgAttributes { regular: NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None }) }, c_variadic: false, fixed_count: 1, conv: Rust, can_unwind: false } //! v3, v4 = call fn0(v1, v2) ; v1 = 1 //! v5 -> v3 //! v6 -> v4 From 5277241d277e1cb5a577bb0ae297c63f23d5dd3d Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Thu, 18 Dec 2025 12:12:31 +0100 Subject: [PATCH 312/489] Port `#[rustc_lint_untracked_query_information]` to attribute parser --- .../src/attributes/rustc_internal.rs | 16 ++++++++++++++++ compiler/rustc_attr_parsing/src/context.rs | 6 ++++-- compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/internal.rs | 5 ++++- compiler/rustc_passes/src/check_attr.rs | 4 +--- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 8005dd76b2a3..ea73b7ad60ef 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -165,6 +165,22 @@ impl NoArgsAttributeParser for RustcLintQueryInstabilityParser { const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintQueryInstability; } +pub(crate) struct RustcLintUntrackedQueryInformationParser; + +impl NoArgsAttributeParser for RustcLintUntrackedQueryInformationParser { + const PATH: &[Symbol] = &[sym::rustc_lint_untracked_query_information]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintUntrackedQueryInformation; +} + pub(crate) struct RustcObjectLifetimeDefaultParser; impl SingleAttributeParser for RustcObjectLifetimeDefaultParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index e5448e7792a8..9b9bd94e1143 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -62,8 +62,9 @@ use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, - RustcLintQueryInstabilityParser, RustcMainParser, RustcNeverReturnsNullPointerParser, - RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, + RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser, + RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, + RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; @@ -259,6 +260,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 5991fb5ab24e..afc458e2775f 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -940,6 +940,9 @@ pub enum AttributeKind { /// Represents `#[rustc_lint_query_instability]` RustcLintQueryInstability, + /// Represents `#[rustc_lint_untracked_query_information]` + RustcLintUntrackedQueryInformation, + /// Represents `#[rustc_main]`. RustcMain, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 64aa9c2a45bc..1899fe12ecdc 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -97,6 +97,7 @@ impl AttributeKind { RustcLintOptDenyFieldAccess { .. } => Yes, RustcLintOptTy => Yes, RustcLintQueryInstability => Yes, + RustcLintUntrackedQueryInformation => Yes, RustcMain => No, RustcNeverReturnsNullPointer => Yes, RustcNoImplicitAutorefs => Yes, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index d6f20a4c85a4..a2fcbd75f50f 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -106,7 +106,10 @@ impl<'tcx> LateLintPass<'tcx> for QueryStability { ); } - if cx.tcx.has_attr(def_id, sym::rustc_lint_untracked_query_information) { + if find_attr!( + cx.tcx.get_all_attrs(def_id), + AttributeKind::RustcLintUntrackedQueryInformation + ) { cx.emit_span_lint( UNTRACKED_QUERY_INFORMATION, span, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 33a3477bcf69..7c89982f8077 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -261,6 +261,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcLintOptDenyFieldAccess { .. } | AttributeKind::RustcLintOptTy | AttributeKind::RustcLintQueryInstability + | AttributeKind::RustcLintUntrackedQueryInformation | AttributeKind::RustcNeverReturnsNullPointer | AttributeKind::RustcScalableVector { .. } | AttributeKind::RustcSimdMonomorphizeLaneLimit(..) @@ -309,9 +310,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } [sym::thread_local, ..] => self.check_thread_local(attr, span, target), - [sym::rustc_lint_untracked_query_information, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } [sym::rustc_lint_diagnostics, ..] => { self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) } From 44cfed7465684c092d7a054bd4accdb8618cca3e Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Thu, 18 Dec 2025 14:20:26 +0100 Subject: [PATCH 313/489] Port `#[rustc_lint_diagnostics]` to attribute parser --- .../src/attributes/rustc_internal.rs | 15 ++++++++++++ compiler/rustc_attr_parsing/src/context.rs | 9 ++++---- .../rustc_hir/src/attrs/data_structures.rs | 3 +++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_lint/src/internal.rs | 6 ++--- compiler/rustc_passes/messages.ftl | 7 ------ compiler/rustc_passes/src/check_attr.rs | 23 +------------------ compiler/rustc_passes/src/errors.rs | 10 -------- .../internal-lints/diagnostics_incorrect.rs | 2 +- .../diagnostics_incorrect.stderr | 23 +++++++++++-------- 10 files changed, 42 insertions(+), 57 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index ea73b7ad60ef..be4e2210c5ee 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -117,6 +117,21 @@ impl SingleAttributeParser for RustcLegacyConstGenericsParser { } } +pub(crate) struct RustcLintDiagnosticsParser; + +impl NoArgsAttributeParser for RustcLintDiagnosticsParser { + const PATH: &[Symbol] = &[sym::rustc_lint_diagnostics]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Fn), + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::Trait { body: false })), + Allow(Target::Method(MethodKind::Trait { body: true })), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintDiagnostics; +} + pub(crate) struct RustcLintOptDenyFieldAccessParser; impl SingleAttributeParser for RustcLintOptDenyFieldAccessParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9b9bd94e1143..a752869c2eb2 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,10 +61,10 @@ use crate::attributes::prototype::CustomMirParser; use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser}; use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, - RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, - RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser, - RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, - RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, + RustcLegacyConstGenericsParser, RustcLintDiagnosticsParser, RustcLintOptDenyFieldAccessParser, + RustcLintOptTyParser, RustcLintQueryInstabilityParser, + RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcNeverReturnsNullPointerParser, + RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; @@ -258,6 +258,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index afc458e2775f..1a382d8f124b 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -931,6 +931,9 @@ pub enum AttributeKind { /// Represents `#[rustc_legacy_const_generics]` RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span }, + /// Represents `#[rustc_lint_diagnostics]` + RustcLintDiagnostics, + /// Represents `#[rustc_lint_opt_deny_field_access]` RustcLintOptDenyFieldAccess { lint_message: Symbol }, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 1899fe12ecdc..7c1e71f258be 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -94,6 +94,7 @@ impl AttributeKind { RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, RustcLegacyConstGenerics { .. } => Yes, + RustcLintDiagnostics => Yes, RustcLintOptDenyFieldAccess { .. } => Yes, RustcLintOptTy => Yes, RustcLintQueryInstability => Yes, diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index a2fcbd75f50f..68885e14f40d 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -609,14 +609,14 @@ impl Diagnostics { else { return; }; - let has_attr = cx.tcx.has_attr(inst.def_id(), sym::rustc_lint_diagnostics); - if !has_attr { + + if !find_attr!(cx.tcx.get_all_attrs(inst.def_id()), AttributeKind::RustcLintDiagnostics) { return; }; for (hir_id, _parent) in cx.tcx.hir_parent_iter(current_id) { if let Some(owner_did) = hir_id.as_owner() - && cx.tcx.has_attr(owner_did, sym::rustc_lint_diagnostics) + && find_attr!(cx.tcx.get_all_attrs(owner_did), AttributeKind::RustcLintDiagnostics) { // The parent method is marked with `#[rustc_lint_diagnostics]` return; diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 7ebfca91d499..c0106ea0c627 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -484,13 +484,6 @@ passes_sanitize_attribute_not_allowed = .no_body = function has no body .help = sanitize attribute can be applied to a function (with body), impl block, or module -passes_should_be_applied_to_fn = - attribute should be applied to a function definition - .label = {$on_crate -> - [true] cannot be applied to crates - *[false] not a function definition - } - passes_should_be_applied_to_static = attribute should be applied to a static .label = not a static diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 7c89982f8077..945dcec798e3 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -258,6 +258,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcNoImplicitAutorefs | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) + | AttributeKind::RustcLintDiagnostics | AttributeKind::RustcLintOptDenyFieldAccess { .. } | AttributeKind::RustcLintOptTy | AttributeKind::RustcLintQueryInstability @@ -310,9 +311,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } [sym::thread_local, ..] => self.check_thread_local(attr, span, target), - [sym::rustc_lint_diagnostics, ..] => { - self.check_applied_to_fn_or_method(hir_id, attr.span(), span, target) - } [sym::rustc_clean, ..] | [sym::rustc_dirty, ..] | [sym::rustc_if_this_changed, ..] @@ -1228,25 +1226,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Helper function for checking that the provided attribute is only applied to a function or - /// method. - fn check_applied_to_fn_or_method( - &self, - hir_id: HirId, - attr_span: Span, - defn_span: Span, - target: Target, - ) { - let is_function = matches!(target, Target::Fn | Target::Method(..)); - if !is_function { - self.dcx().emit_err(errors::AttrShouldBeAppliedToFn { - attr_span, - defn_span, - on_crate: hir_id == CRATE_HIR_ID, - }); - } - } - /// Checks that the dep-graph debugging attributes are only present when the query-dep-graph /// option is passed to the compiler. fn check_rustc_dirty_clean(&self, attr: &Attribute) { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 895cefe672ba..4f97f74c7804 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -80,16 +80,6 @@ pub(crate) struct OuterCrateLevelAttrSuggestion { #[diag(passes_inner_crate_level_attr)] pub(crate) struct InnerCrateLevelAttr; -#[derive(Diagnostic)] -#[diag(passes_should_be_applied_to_fn)] -pub(crate) struct AttrShouldBeAppliedToFn { - #[primary_span] - pub attr_span: Span, - #[label] - pub defn_span: Span, - pub on_crate: bool, -} - #[derive(Diagnostic)] #[diag(passes_non_exhaustive_with_default_field_values)] pub(crate) struct NonExhaustiveWithDefaultFieldValues { diff --git a/tests/ui/internal-lints/diagnostics_incorrect.rs b/tests/ui/internal-lints/diagnostics_incorrect.rs index c1532aa9d57e..787acdad3884 100644 --- a/tests/ui/internal-lints/diagnostics_incorrect.rs +++ b/tests/ui/internal-lints/diagnostics_incorrect.rs @@ -3,7 +3,7 @@ #![feature(rustc_attrs)] #[rustc_lint_diagnostics] -//~^ ERROR attribute should be applied to a function +//~^ ERROR `#[rustc_lint_diagnostics]` attribute cannot be used on structs struct Foo; impl Foo { diff --git a/tests/ui/internal-lints/diagnostics_incorrect.stderr b/tests/ui/internal-lints/diagnostics_incorrect.stderr index e849ca2829e4..4d509acec790 100644 --- a/tests/ui/internal-lints/diagnostics_incorrect.stderr +++ b/tests/ui/internal-lints/diagnostics_incorrect.stderr @@ -1,17 +1,20 @@ -error: malformed `rustc_lint_diagnostics` attribute input - --> $DIR/diagnostics_incorrect.rs:10:5 - | -LL | #[rustc_lint_diagnostics(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_diagnostics]` - -error: attribute should be applied to a function definition +error: `#[rustc_lint_diagnostics]` attribute cannot be used on structs --> $DIR/diagnostics_incorrect.rs:5:1 | LL | #[rustc_lint_diagnostics] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Foo; - | ----------- not a function definition + | + = help: `#[rustc_lint_diagnostics]` can only be applied to functions + +error[E0565]: malformed `rustc_lint_diagnostics` attribute input + --> $DIR/diagnostics_incorrect.rs:10:5 + | +LL | #[rustc_lint_diagnostics(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_lint_diagnostics]` error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0565`. From 4ff2c5c9f54bb33702b76013a2464cb31f6efa4f Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 25 Oct 2023 17:33:43 -0400 Subject: [PATCH 314/489] Don't treat asserts as a call in cross-crate inlining --- .../src/cross_crate_inline.rs | 35 +++++++++++++++---- .../cross-crate-inlining/auxiliary/leaf.rs | 5 +++ .../cross-crate-inlining/leaf-inlining.rs | 9 +++++ .../item-collection/implicit-panic-call.rs | 1 + 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 69248cf91f24..71bdafa958ca 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -1,6 +1,7 @@ use rustc_hir::attrs::InlineAttr; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; +use rustc_middle::bug; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::*; use rustc_middle::query::Providers; @@ -110,6 +111,15 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { && checker.statements <= threshold } +// The threshold that CostChecker computes is balancing the desire to make more things +// inlinable cross crates against the growth in incremental CGU size that happens when too many +// things in the sysroot are made inlinable. +// Permitting calls causes the size of some incremental CGUs to grow, because more functions are +// made inlinable out of the sysroot or dependencies. +// Assert terminators are similar to calls, but do not have the same impact on compile time, so +// those are just treated as statements. +// A threshold exists at all because we don't want to blindly mark a huge function as inlinable. + struct CostChecker<'b, 'tcx> { tcx: TyCtxt<'tcx>, callee_body: &'b Body<'tcx>, @@ -129,9 +139,10 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { } fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, _: Location) { + self.statements += 1; let tcx = self.tcx; - match terminator.kind { - TerminatorKind::Drop { ref place, unwind, .. } => { + match &terminator.kind { + TerminatorKind::Drop { place, unwind, .. } => { let ty = place.ty(self.callee_body, tcx).ty; if !ty.is_trivially_pure_clone_copy() { self.calls += 1; @@ -140,7 +151,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { } } } - TerminatorKind::Call { ref func, unwind, .. } => { + TerminatorKind::Call { func, unwind, .. } => { // We track calls because they make our function not a leaf (and in theory, the // number of calls indicates how likely this function is to perturb other CGUs). // But intrinsics don't have a body that gets assigned to a CGU, so they are @@ -155,21 +166,31 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { self.landing_pads += 1; } } - TerminatorKind::Assert { unwind, .. } => { + TerminatorKind::TailCall { .. } => { self.calls += 1; + } + TerminatorKind::Assert { unwind, .. } => { if let UnwindAction::Cleanup(_) = unwind { self.landing_pads += 1; } } TerminatorKind::UnwindResume => self.resumes += 1, TerminatorKind::InlineAsm { unwind, .. } => { - self.statements += 1; if let UnwindAction::Cleanup(_) = unwind { self.landing_pads += 1; } } - TerminatorKind::Return => {} - _ => self.statements += 1, + TerminatorKind::Return + | TerminatorKind::Goto { .. } + | TerminatorKind::SwitchInt { .. } + | TerminatorKind::Unreachable + | TerminatorKind::UnwindTerminate(_) => {} + kind @ (TerminatorKind::FalseUnwind { .. } + | TerminatorKind::FalseEdge { .. } + | TerminatorKind::Yield { .. } + | TerminatorKind::CoroutineDrop) => { + bug!("{kind:?} should not be in runtime MIR"); + } } } } diff --git a/tests/codegen-llvm/cross-crate-inlining/auxiliary/leaf.rs b/tests/codegen-llvm/cross-crate-inlining/auxiliary/leaf.rs index 7b5679c3f4de..5b3cd34a7fa5 100644 --- a/tests/codegen-llvm/cross-crate-inlining/auxiliary/leaf.rs +++ b/tests/codegen-llvm/cross-crate-inlining/auxiliary/leaf.rs @@ -23,3 +23,8 @@ fn inner() -> String { pub fn leaf_with_intrinsic(a: &[u64; 2], b: &[u64; 2]) -> bool { a == b } + +// This function's optimized MIR contains assert terminators, not calls. +pub fn leaf_with_assert(a: i32, b: i32) -> i32 { + a / b +} diff --git a/tests/codegen-llvm/cross-crate-inlining/leaf-inlining.rs b/tests/codegen-llvm/cross-crate-inlining/leaf-inlining.rs index 5e7912791ad6..3173adbd03ee 100644 --- a/tests/codegen-llvm/cross-crate-inlining/leaf-inlining.rs +++ b/tests/codegen-llvm/cross-crate-inlining/leaf-inlining.rs @@ -25,3 +25,12 @@ pub fn leaf_with_intrinsic_outer(a: &[u64; 2], b: &[u64; 2]) -> bool { // CHECK-NOT: call {{.*}}leaf_with_intrinsic leaf::leaf_with_intrinsic(a, b) } + +// Check that we inline functions with assert terminators +#[no_mangle] +pub fn leaf_with_assert(a: i32, b: i32) -> i32 { + // CHECK-NOT: call {{.*}}leaf_with_assert + // CHECK: sdiv i32 %a, %b + // CHECK-NOT: call {{.*}}leaf_with_assert + leaf::leaf_with_assert(a, b) +} diff --git a/tests/codegen-units/item-collection/implicit-panic-call.rs b/tests/codegen-units/item-collection/implicit-panic-call.rs index 612132f056be..3b442942cc5c 100644 --- a/tests/codegen-units/item-collection/implicit-panic-call.rs +++ b/tests/codegen-units/item-collection/implicit-panic-call.rs @@ -1,5 +1,6 @@ // rust-lang/rust#90405 // Ensure implicit panic calls are collected +//@ compile-flags: -Zcross-crate-inline-threshold=never #![feature(lang_items)] #![feature(no_core)] From c2f8ee9bbab1f64cdbf0f3bb02ea09f201fdbc04 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 6 Oct 2025 13:38:00 +1100 Subject: [PATCH 315/489] Remove inherent methods from `llvm::TypeKind` --- .../src/llvm/conversions.rs | 40 ++++++++++++++++++- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 27 ------------- compiler/rustc_codegen_llvm/src/type_.rs | 2 +- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm/conversions.rs b/compiler/rustc_codegen_llvm/src/llvm/conversions.rs index 9e9f9339ade8..3bc790ca7cff 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/conversions.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/conversions.rs @@ -1,6 +1,6 @@ //! Conversions from backend-independent data types to/from LLVM FFI types. -use rustc_codegen_ssa::common::{AtomicRmwBinOp, IntPredicate, RealPredicate}; +use rustc_codegen_ssa::common::{AtomicRmwBinOp, IntPredicate, RealPredicate, TypeKind}; use rustc_middle::ty::AtomicOrdering; use rustc_session::config::DebugInfo; use rustc_target::spec::SymbolVisibility; @@ -9,10 +9,22 @@ use crate::llvm; /// Helper trait for converting backend-independent types to LLVM-specific /// types, for FFI purposes. +/// +/// FIXME(#147327): These trait/method names were chosen to avoid churn in +/// existing code, but are not great and could probably be made clearer. pub(crate) trait FromGeneric { fn from_generic(other: T) -> Self; } +/// Helper trait for converting LLVM-specific types to backend-independent +/// types, for FFI purposes. +/// +/// FIXME(#147327): These trait/method names were chosen to avoid churn in +/// existing code, but are not great and could probably be made clearer. +pub(crate) trait ToGeneric { + fn to_generic(&self) -> T; +} + impl FromGeneric for llvm::Visibility { fn from_generic(visibility: SymbolVisibility) -> Self { match visibility { @@ -113,3 +125,29 @@ impl FromGeneric for llvm::debuginfo::DebugEmissionKind { } } } + +impl ToGeneric for llvm::TypeKind { + fn to_generic(&self) -> TypeKind { + match self { + Self::Void => TypeKind::Void, + Self::Half => TypeKind::Half, + Self::Float => TypeKind::Float, + Self::Double => TypeKind::Double, + Self::X86_FP80 => TypeKind::X86_FP80, + Self::FP128 => TypeKind::FP128, + Self::PPC_FP128 => TypeKind::PPC_FP128, + Self::Label => TypeKind::Label, + Self::Integer => TypeKind::Integer, + Self::Function => TypeKind::Function, + Self::Struct => TypeKind::Struct, + Self::Array => TypeKind::Array, + Self::Pointer => TypeKind::Pointer, + Self::Vector => TypeKind::Vector, + Self::Metadata => TypeKind::Metadata, + Self::Token => TypeKind::Token, + Self::ScalableVector => TypeKind::ScalableVector, + Self::BFloat => TypeKind::BFloat, + Self::X86_AMX => TypeKind::X86_AMX, + } + } +} diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 2f53a1995248..10cb9390a764 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -363,33 +363,6 @@ pub(crate) enum TypeKind { X86_AMX = 19, } -impl TypeKind { - pub(crate) fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind { - use rustc_codegen_ssa::common::TypeKind as Common; - match self { - Self::Void => Common::Void, - Self::Half => Common::Half, - Self::Float => Common::Float, - Self::Double => Common::Double, - Self::X86_FP80 => Common::X86_FP80, - Self::FP128 => Common::FP128, - Self::PPC_FP128 => Common::PPC_FP128, - Self::Label => Common::Label, - Self::Integer => Common::Integer, - Self::Function => Common::Function, - Self::Struct => Common::Struct, - Self::Array => Common::Array, - Self::Pointer => Common::Pointer, - Self::Vector => Common::Vector, - Self::Metadata => Common::Metadata, - Self::Token => Common::Token, - Self::ScalableVector => Common::ScalableVector, - Self::BFloat => Common::BFloat, - Self::X86_AMX => Common::X86_AMX, - } - } -} - /// LLVMAtomicRmwBinOp #[derive(Copy, Clone)] #[repr(C)] diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index 83d7fa0c9153..d8b77369a34f 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -15,7 +15,7 @@ use rustc_target::callconv::{CastTarget, FnAbi}; use crate::abi::{FnAbiLlvmExt, LlvmType}; use crate::common; use crate::context::{CodegenCx, GenericCx, SCx}; -use crate::llvm::{self, FALSE, Metadata, TRUE, ToLlvmBool, Type, Value}; +use crate::llvm::{self, FALSE, Metadata, TRUE, ToGeneric, ToLlvmBool, Type, Value}; use crate::type_of::LayoutLlvmExt; impl PartialEq for Type { From 735a98069309e91b859a5e888ca3403733f2278a Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 6 Oct 2025 13:42:39 +1100 Subject: [PATCH 316/489] Move `DIBuilderBox` out of `ffi.rs` --- .../src/debuginfo/di_builder.rs | 31 ++++++++++++++++++- .../rustc_codegen_llvm/src/debuginfo/mod.rs | 3 +- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 30 ------------------ 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs b/compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs index 5d874631ca1a..0b5ef6c68740 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs @@ -1,8 +1,37 @@ +use std::ptr; + use libc::c_uint; use rustc_abi::Align; use crate::llvm::debuginfo::DIBuilder; -use crate::llvm::{self, ToLlvmBool}; +use crate::llvm::{self, Module, ToLlvmBool}; + +/// Owning pointer to a `DIBuilder<'ll>` that will dispose of the builder +/// when dropped. Use `.as_ref()` to get the underlying `&DIBuilder` +/// needed for debuginfo FFI calls. +pub(crate) struct DIBuilderBox<'ll> { + raw: ptr::NonNull>, +} + +impl<'ll> DIBuilderBox<'ll> { + pub(crate) fn new(llmod: &'ll Module) -> Self { + let raw = unsafe { llvm::LLVMCreateDIBuilder(llmod) }; + let raw = ptr::NonNull::new(raw).unwrap(); + Self { raw } + } + + pub(crate) fn as_ref(&self) -> &DIBuilder<'ll> { + // SAFETY: This is an owning pointer, so `&DIBuilder` is valid + // for as long as `&self` is. + unsafe { self.raw.as_ref() } + } +} + +impl<'ll> Drop for DIBuilderBox<'ll> { + fn drop(&mut self) { + unsafe { llvm::LLVMDisposeDIBuilder(self.raw) }; + } +} /// Extension trait for defining safe wrappers and helper methods on /// `&DIBuilder<'ll>`, without requiring it to be defined in the same crate. diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index c2c55ee2b64f..1c63bbcd1710 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -38,8 +38,9 @@ use self::namespace::mangled_name_of_instance; use self::utils::{DIB, create_DIArray, is_node_local_to_unit}; use crate::builder::Builder; use crate::common::{AsCCharPtr, CodegenCx}; +use crate::debuginfo::di_builder::DIBuilderBox; use crate::llvm::debuginfo::{ - DIArray, DIBuilderBox, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, + DIArray, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DITemplateTypeParameter, DIType, DIVariable, }; use crate::llvm::{self, Value}; diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 10cb9390a764..a86b4cc38915 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -711,12 +711,9 @@ unsafe extern "C" { pub(crate) type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void); pub(crate) mod debuginfo { - use std::ptr; - use bitflags::bitflags; use super::{InvariantOpaque, Metadata}; - use crate::llvm::{self, Module}; /// Opaque target type for references to an LLVM debuginfo builder. /// @@ -729,33 +726,6 @@ pub(crate) mod debuginfo { #[repr(C)] pub(crate) struct DIBuilder<'ll>(InvariantOpaque<'ll>); - /// Owning pointer to a `DIBuilder<'ll>` that will dispose of the builder - /// when dropped. Use `.as_ref()` to get the underlying `&DIBuilder` - /// needed for debuginfo FFI calls. - pub(crate) struct DIBuilderBox<'ll> { - raw: ptr::NonNull>, - } - - impl<'ll> DIBuilderBox<'ll> { - pub(crate) fn new(llmod: &'ll Module) -> Self { - let raw = unsafe { llvm::LLVMCreateDIBuilder(llmod) }; - let raw = ptr::NonNull::new(raw).unwrap(); - Self { raw } - } - - pub(crate) fn as_ref(&self) -> &DIBuilder<'ll> { - // SAFETY: This is an owning pointer, so `&DIBuilder` is valid - // for as long as `&self` is. - unsafe { self.raw.as_ref() } - } - } - - impl<'ll> Drop for DIBuilderBox<'ll> { - fn drop(&mut self) { - unsafe { llvm::LLVMDisposeDIBuilder(self.raw) }; - } - } - pub(crate) type DIDescriptor = Metadata; pub(crate) type DILocation = Metadata; pub(crate) type DIScope = DIDescriptor; From ef494feccca725d5e5148a721e64a2655763be6f Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Fri, 19 Dec 2025 04:58:34 +0000 Subject: [PATCH 317/489] Prepare for merging from rust-lang/rust This updates the rust-version file to 526a91cbcc4601b92b0587405015e07b9c0d79f6. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 11c138c28c24..d4fbfacf4eda 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -686f9cefc37c5bdec069a75357f0277b390657ca +526a91cbcc4601b92b0587405015e07b9c0d79f6 From 8870bb8d9c07f0c2e110dfca17794eef0c474eae Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Fri, 19 Dec 2025 05:07:13 +0000 Subject: [PATCH 318/489] fmt --- src/tools/miri/tests/fail/closures/deref-in-pattern.rs | 7 ++++--- .../miri/tests/fail/closures/deref-in-pattern.stderr | 2 +- src/tools/miri/tests/fail/closures/partial-pattern.rs | 9 +++++---- .../miri/tests/fail/closures/partial-pattern.stderr | 2 +- .../miri/tests/fail/closures/uninhabited-variant.rs | 9 +++++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/tools/miri/tests/fail/closures/deref-in-pattern.rs b/src/tools/miri/tests/fail/closures/deref-in-pattern.rs index c729469c78b0..27915a9a489b 100644 --- a/src/tools/miri/tests/fail/closures/deref-in-pattern.rs +++ b/src/tools/miri/tests/fail/closures/deref-in-pattern.rs @@ -9,12 +9,13 @@ fn main() { // the inner reference is dangling let x: &&u32 = unsafe { let x: u32 = 42; - &&* &raw const x + &&*&raw const x }; - let _ = || { //~ ERROR: encountered a dangling reference + //~v ERROR: encountered a dangling reference + let _ = || { match x { - &&_y => {}, + &&_y => {} } }; } diff --git a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr index 1264f4e3fb95..fae2d286c487 100644 --- a/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr +++ b/src/tools/miri/tests/fail/closures/deref-in-pattern.stderr @@ -4,7 +4,7 @@ error: Undefined Behavior: constructing invalid value: encountered a dangling re LL | let _ = || { | _____________^ LL | | match x { -LL | | &&_y => {}, +LL | | &&_y => {} LL | | } LL | | }; | |_____^ Undefined Behavior occurred here diff --git a/src/tools/miri/tests/fail/closures/partial-pattern.rs b/src/tools/miri/tests/fail/closures/partial-pattern.rs index cb6446208180..f70fe096fd80 100644 --- a/src/tools/miri/tests/fail/closures/partial-pattern.rs +++ b/src/tools/miri/tests/fail/closures/partial-pattern.rs @@ -15,14 +15,15 @@ fn main() { let x: &(&u32, &u32) = unsafe { let a = 21; let b = 37; - let ra = &* &raw const a; - let rb = &* &raw const b; + let ra = &*&raw const a; + let rb = &*&raw const b; &(ra, rb) }; - let _ = || { //~ ERROR: encountered a dangling reference + //~v ERROR: encountered a dangling reference + let _ = || { match x { - (&_y, _) => {}, + (&_y, _) => {} } }; } diff --git a/src/tools/miri/tests/fail/closures/partial-pattern.stderr b/src/tools/miri/tests/fail/closures/partial-pattern.stderr index 5b7ee35ecc73..8dea4d4d8c64 100644 --- a/src/tools/miri/tests/fail/closures/partial-pattern.stderr +++ b/src/tools/miri/tests/fail/closures/partial-pattern.stderr @@ -4,7 +4,7 @@ error: Undefined Behavior: constructing invalid value: encountered a dangling re LL | let _ = || { | _____________^ LL | | match x { -LL | | (&_y, _) => {}, +LL | | (&_y, _) => {} LL | | } LL | | }; | |_____^ Undefined Behavior occurred here diff --git a/src/tools/miri/tests/fail/closures/uninhabited-variant.rs b/src/tools/miri/tests/fail/closures/uninhabited-variant.rs index 9c50fdc13a35..0a2dfe9a7f64 100644 --- a/src/tools/miri/tests/fail/closures/uninhabited-variant.rs +++ b/src/tools/miri/tests/fail/closures/uninhabited-variant.rs @@ -5,9 +5,9 @@ #[repr(C)] #[allow(dead_code)] enum E { - V0, // discriminant: 0 - V1, // 1 - V2(!), // 2 + V0, // discriminant: 0 + V1, // 1 + V2(!), // 2 } fn main() { @@ -20,7 +20,8 @@ fn main() { // After rust-lang/rust#138961, constructing the closure performs a reborrow of r. // Nevertheless, the discriminant is only actually inspected when the closure // is called. - match r { //~ ERROR: read discriminant of an uninhabited enum variant + match r { + //~^ ERROR: read discriminant of an uninhabited enum variant E::V0 => {} E::V1 => {} E::V2(_) => {} From 7e63bc07de1e638ceab5894f9163fdd8dc289359 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 19 Dec 2025 17:30:47 +1100 Subject: [PATCH 319/489] mir_build: Remove unnecessary lifetime from `PatCtxt` It turns out that lifetime `'a` is just `'tcx` in disguise. --- .../src/thir/pattern/const_to_pat.rs | 4 ++-- compiler/rustc_mir_build/src/thir/pattern/mod.rs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 6316ccf1b8c5..c3c4c455b965 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -28,7 +28,7 @@ use crate::errors::{ PointerPattern, TypeNotPartialEq, TypeNotStructural, UnionPattern, UnsizedPattern, }; -impl<'a, 'tcx> PatCtxt<'a, 'tcx> { +impl<'tcx> PatCtxt<'tcx> { /// Converts a constant to a pattern (if possible). /// This means aggregate values (like structs and enums) are converted /// to a pattern that matches the value (as if you'd compared via structural equality). @@ -64,7 +64,7 @@ struct ConstToPat<'tcx> { } impl<'tcx> ConstToPat<'tcx> { - fn new(pat_ctxt: &PatCtxt<'_, 'tcx>, id: hir::HirId, span: Span, c: ty::Const<'tcx>) -> Self { + fn new(pat_ctxt: &PatCtxt<'tcx>, id: hir::HirId, span: Span, c: ty::Const<'tcx>) -> Self { trace!(?pat_ctxt.typeck_results.hir_owner); ConstToPat { tcx: pat_ctxt.tcx, typing_env: pat_ctxt.typing_env, span, id, c } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 02e6f8d6ce71..ca43bd00185c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -30,19 +30,20 @@ pub(crate) use self::check_match::check_match; use self::migration::PatMigration; use crate::errors::*; -struct PatCtxt<'a, 'tcx> { +/// Context for lowering HIR patterns to THIR patterns. +struct PatCtxt<'tcx> { tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, - typeck_results: &'a ty::TypeckResults<'tcx>, + typeck_results: &'tcx ty::TypeckResults<'tcx>, /// Used by the Rust 2024 migration lint. - rust_2024_migration: Option>, + rust_2024_migration: Option>, } -pub(super) fn pat_from_hir<'a, 'tcx>( +pub(super) fn pat_from_hir<'tcx>( tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, - typeck_results: &'a ty::TypeckResults<'tcx>, + typeck_results: &'tcx ty::TypeckResults<'tcx>, pat: &'tcx hir::Pat<'tcx>, ) -> Box> { let mut pcx = PatCtxt { @@ -62,7 +63,7 @@ pub(super) fn pat_from_hir<'a, 'tcx>( result } -impl<'a, 'tcx> PatCtxt<'a, 'tcx> { +impl<'tcx> PatCtxt<'tcx> { fn lower_pattern(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Box> { let adjustments: &[PatAdjustment<'tcx>] = self.typeck_results.pat_adjustments().get(pat.hir_id).map_or(&[], |v| &**v); From 7d88ed1f19f25b3e2abaa4515aaeee539983624d Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 19 Dec 2025 10:25:43 +0100 Subject: [PATCH 320/489] Use actions/checkout@v6 consistently Two places were not updated from v5 to v6. --- .github/workflows/clippy_dev.yml | 2 +- .github/workflows/clippy_pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clippy_dev.yml b/.github/workflows/clippy_dev.yml index d530eb6c73a3..3a99d65233d3 100644 --- a/.github/workflows/clippy_dev.yml +++ b/.github/workflows/clippy_dev.yml @@ -16,7 +16,7 @@ jobs: steps: # Setup - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: # Unsetting this would make so that any malicious package could get our Github Token persist-credentials: false diff --git a/.github/workflows/clippy_pr.yml b/.github/workflows/clippy_pr.yml index d91c638a8fb5..f9e882d9757c 100644 --- a/.github/workflows/clippy_pr.yml +++ b/.github/workflows/clippy_pr.yml @@ -24,7 +24,7 @@ jobs: steps: # Setup - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: # Unsetting this would make so that any malicious package could get our Github Token persist-credentials: false From 76457e60d76612856d44674c1103a3af5372cae6 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 19 Dec 2025 10:38:46 +0100 Subject: [PATCH 321/489] Reenable some tests on "apple" targets Those tests appear to be passing on "apple" targets as well. --- tests/ui/crashes/ice-7410.rs | 2 +- tests/ui/def_id_nocore.rs | 2 -- tests/ui/def_id_nocore.stderr | 2 +- tests/ui/empty_loop_no_std.rs | 2 -- tests/ui/empty_loop_no_std.stderr | 2 +- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/ui/crashes/ice-7410.rs b/tests/ui/crashes/ice-7410.rs index 71f00fb9aede..7b39f7ffc01a 100644 --- a/tests/ui/crashes/ice-7410.rs +++ b/tests/ui/crashes/ice-7410.rs @@ -1,6 +1,6 @@ //@ check-pass //@compile-flags: -Clink-arg=-nostartfiles -//@ignore-target: apple windows +//@ignore-target: windows #![crate_type = "lib"] #![no_std] diff --git a/tests/ui/def_id_nocore.rs b/tests/ui/def_id_nocore.rs index 5c13d8622767..6aa023a8d450 100644 --- a/tests/ui/def_id_nocore.rs +++ b/tests/ui/def_id_nocore.rs @@ -1,5 +1,3 @@ -//@ignore-target: apple - #![feature(no_core, lang_items)] #![no_core] #![allow(clippy::missing_safety_doc)] diff --git a/tests/ui/def_id_nocore.stderr b/tests/ui/def_id_nocore.stderr index 175dd0754081..bf022fb56a36 100644 --- a/tests/ui/def_id_nocore.stderr +++ b/tests/ui/def_id_nocore.stderr @@ -1,5 +1,5 @@ error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> tests/ui/def_id_nocore.rs:33:19 + --> tests/ui/def_id_nocore.rs:31:19 | LL | pub fn as_ref(self) -> &'static str { | ^^^^ diff --git a/tests/ui/empty_loop_no_std.rs b/tests/ui/empty_loop_no_std.rs index 6407bd678f9c..1ea96abbcd8b 100644 --- a/tests/ui/empty_loop_no_std.rs +++ b/tests/ui/empty_loop_no_std.rs @@ -1,6 +1,4 @@ //@compile-flags: -Clink-arg=-nostartfiles -//@ignore-target: apple - #![warn(clippy::empty_loop)] #![crate_type = "lib"] #![no_std] diff --git a/tests/ui/empty_loop_no_std.stderr b/tests/ui/empty_loop_no_std.stderr index f36fb9d9e3f2..e34b50ed1aef 100644 --- a/tests/ui/empty_loop_no_std.stderr +++ b/tests/ui/empty_loop_no_std.stderr @@ -1,5 +1,5 @@ error: empty `loop {}` wastes CPU cycles - --> tests/ui/empty_loop_no_std.rs:10:5 + --> tests/ui/empty_loop_no_std.rs:8:5 | LL | loop {} | ^^^^^^^ From c040bb1c7eeb21e5e9dfb2843eba75a8168e0791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Fri, 19 Dec 2025 12:36:26 +0100 Subject: [PATCH 322/489] move eii tests --- .../{wrong_target.rs => attribute_targets.rs} | 0 ...target.stderr => attribute_targets.stderr} | 36 +++++++++---------- tests/ui/eii/{ => type_checking}/subtype_1.rs | 0 .../eii/{ => type_checking}/subtype_1.stderr | 0 tests/ui/eii/{ => type_checking}/subtype_2.rs | 0 .../eii/{ => type_checking}/subtype_2.stderr | 0 tests/ui/eii/{ => type_checking}/subtype_3.rs | 0 tests/ui/eii/{ => type_checking}/subtype_4.rs | 0 .../eii/{ => type_checking}/wrong_ret_ty.rs | 0 .../{ => type_checking}/wrong_ret_ty.stderr | 0 tests/ui/eii/{ => type_checking}/wrong_ty.rs | 0 .../eii/{ => type_checking}/wrong_ty.stderr | 0 .../ui/eii/{ => type_checking}/wrong_ty_2.rs | 0 .../eii/{ => type_checking}/wrong_ty_2.stderr | 0 14 files changed, 18 insertions(+), 18 deletions(-) rename tests/ui/eii/{wrong_target.rs => attribute_targets.rs} (100%) rename tests/ui/eii/{wrong_target.stderr => attribute_targets.stderr} (67%) rename tests/ui/eii/{ => type_checking}/subtype_1.rs (100%) rename tests/ui/eii/{ => type_checking}/subtype_1.stderr (100%) rename tests/ui/eii/{ => type_checking}/subtype_2.rs (100%) rename tests/ui/eii/{ => type_checking}/subtype_2.stderr (100%) rename tests/ui/eii/{ => type_checking}/subtype_3.rs (100%) rename tests/ui/eii/{ => type_checking}/subtype_4.rs (100%) rename tests/ui/eii/{ => type_checking}/wrong_ret_ty.rs (100%) rename tests/ui/eii/{ => type_checking}/wrong_ret_ty.stderr (100%) rename tests/ui/eii/{ => type_checking}/wrong_ty.rs (100%) rename tests/ui/eii/{ => type_checking}/wrong_ty.stderr (100%) rename tests/ui/eii/{ => type_checking}/wrong_ty_2.rs (100%) rename tests/ui/eii/{ => type_checking}/wrong_ty_2.stderr (100%) diff --git a/tests/ui/eii/wrong_target.rs b/tests/ui/eii/attribute_targets.rs similarity index 100% rename from tests/ui/eii/wrong_target.rs rename to tests/ui/eii/attribute_targets.rs diff --git a/tests/ui/eii/wrong_target.stderr b/tests/ui/eii/attribute_targets.stderr similarity index 67% rename from tests/ui/eii/wrong_target.stderr rename to tests/ui/eii/attribute_targets.stderr index 9b27f49fb302..bf04c323c95c 100644 --- a/tests/ui/eii/wrong_target.stderr +++ b/tests/ui/eii/attribute_targets.stderr @@ -1,107 +1,107 @@ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:7:1 + --> $DIR/attribute_targets.rs:7:1 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:9:1 + --> $DIR/attribute_targets.rs:9:1 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:13:1 + --> $DIR/attribute_targets.rs:13:1 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:15:1 + --> $DIR/attribute_targets.rs:15:1 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:21:1 + --> $DIR/attribute_targets.rs:21:1 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:23:1 + --> $DIR/attribute_targets.rs:23:1 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:27:1 + --> $DIR/attribute_targets.rs:27:1 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:29:1 + --> $DIR/attribute_targets.rs:29:1 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:32:5 + --> $DIR/attribute_targets.rs:32:5 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:34:5 + --> $DIR/attribute_targets.rs:34:5 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:39:1 + --> $DIR/attribute_targets.rs:39:1 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:41:1 + --> $DIR/attribute_targets.rs:41:1 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:44:5 + --> $DIR/attribute_targets.rs:44:5 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:46:5 + --> $DIR/attribute_targets.rs:46:5 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:51:1 + --> $DIR/attribute_targets.rs:51:1 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:53:1 + --> $DIR/attribute_targets.rs:53:1 | LL | #[eii] | ^^^^^^ error: `#[foo]` is only valid on functions - --> $DIR/wrong_target.rs:56:5 + --> $DIR/attribute_targets.rs:56:5 | LL | #[foo] | ^^^^^^ error: `#[eii]` is only valid on functions - --> $DIR/wrong_target.rs:58:5 + --> $DIR/attribute_targets.rs:58:5 | LL | #[eii] | ^^^^^^ diff --git a/tests/ui/eii/subtype_1.rs b/tests/ui/eii/type_checking/subtype_1.rs similarity index 100% rename from tests/ui/eii/subtype_1.rs rename to tests/ui/eii/type_checking/subtype_1.rs diff --git a/tests/ui/eii/subtype_1.stderr b/tests/ui/eii/type_checking/subtype_1.stderr similarity index 100% rename from tests/ui/eii/subtype_1.stderr rename to tests/ui/eii/type_checking/subtype_1.stderr diff --git a/tests/ui/eii/subtype_2.rs b/tests/ui/eii/type_checking/subtype_2.rs similarity index 100% rename from tests/ui/eii/subtype_2.rs rename to tests/ui/eii/type_checking/subtype_2.rs diff --git a/tests/ui/eii/subtype_2.stderr b/tests/ui/eii/type_checking/subtype_2.stderr similarity index 100% rename from tests/ui/eii/subtype_2.stderr rename to tests/ui/eii/type_checking/subtype_2.stderr diff --git a/tests/ui/eii/subtype_3.rs b/tests/ui/eii/type_checking/subtype_3.rs similarity index 100% rename from tests/ui/eii/subtype_3.rs rename to tests/ui/eii/type_checking/subtype_3.rs diff --git a/tests/ui/eii/subtype_4.rs b/tests/ui/eii/type_checking/subtype_4.rs similarity index 100% rename from tests/ui/eii/subtype_4.rs rename to tests/ui/eii/type_checking/subtype_4.rs diff --git a/tests/ui/eii/wrong_ret_ty.rs b/tests/ui/eii/type_checking/wrong_ret_ty.rs similarity index 100% rename from tests/ui/eii/wrong_ret_ty.rs rename to tests/ui/eii/type_checking/wrong_ret_ty.rs diff --git a/tests/ui/eii/wrong_ret_ty.stderr b/tests/ui/eii/type_checking/wrong_ret_ty.stderr similarity index 100% rename from tests/ui/eii/wrong_ret_ty.stderr rename to tests/ui/eii/type_checking/wrong_ret_ty.stderr diff --git a/tests/ui/eii/wrong_ty.rs b/tests/ui/eii/type_checking/wrong_ty.rs similarity index 100% rename from tests/ui/eii/wrong_ty.rs rename to tests/ui/eii/type_checking/wrong_ty.rs diff --git a/tests/ui/eii/wrong_ty.stderr b/tests/ui/eii/type_checking/wrong_ty.stderr similarity index 100% rename from tests/ui/eii/wrong_ty.stderr rename to tests/ui/eii/type_checking/wrong_ty.stderr diff --git a/tests/ui/eii/wrong_ty_2.rs b/tests/ui/eii/type_checking/wrong_ty_2.rs similarity index 100% rename from tests/ui/eii/wrong_ty_2.rs rename to tests/ui/eii/type_checking/wrong_ty_2.rs diff --git a/tests/ui/eii/wrong_ty_2.stderr b/tests/ui/eii/type_checking/wrong_ty_2.stderr similarity index 100% rename from tests/ui/eii/wrong_ty_2.stderr rename to tests/ui/eii/type_checking/wrong_ty_2.stderr From 3e4944d573af5bae3def57572fb0ed16e152ca88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Dom=C3=ADnguez?= Date: Mon, 8 Dec 2025 20:47:53 +0100 Subject: [PATCH 323/489] Split runtime global logic and cache kernel specific one --- compiler/rustc_codegen_llvm/src/base.rs | 16 +- .../src/builder/gpu_offload.rs | 186 ++++++++++++------ compiler/rustc_codegen_llvm/src/context.rs | 9 + compiler/rustc_codegen_llvm/src/intrinsic.rs | 25 ++- compiler/rustc_feature/src/builtin_attrs.rs | 2 +- tests/codegen-llvm/gpu_offload/gpu_host.rs | 18 +- 6 files changed, 171 insertions(+), 85 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 6cbddfec4631..16455b4c79cd 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -23,13 +23,14 @@ use rustc_middle::dep_graph; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrs, SanitizerFnAttrs}; use rustc_middle::mir::mono::Visibility; use rustc_middle::ty::TyCtxt; -use rustc_session::config::DebugInfo; +use rustc_session::config::{DebugInfo, Offload}; use rustc_span::Symbol; use rustc_target::spec::SanitizerSet; use super::ModuleLlvm; use crate::attributes; use crate::builder::Builder; +use crate::builder::gpu_offload::OffloadGlobals; use crate::context::CodegenCx; use crate::llvm::{self, Value}; @@ -85,6 +86,19 @@ pub(crate) fn compile_codegen_unit( let llvm_module = ModuleLlvm::new(tcx, cgu_name.as_str()); { let mut cx = CodegenCx::new(tcx, cgu, &llvm_module); + + // Declare and store globals shared by all offload kernels + // + // These globals are left in the LLVM-IR host module so all kernels can access them. + // They are necessary for correct offload execution. We do this here to simplify the + // `offload` intrinsic, avoiding the need for tracking whether it's the first + // intrinsic call or not. + if cx.sess().opts.unstable_opts.offload.contains(&Offload::Enable) + && !cx.sess().target.is_like_gpu + { + cx.offload_globals.replace(Some(OffloadGlobals::declare(&cx))); + } + let mono_items = cx.codegen_unit.items_in_deterministic_order(cx.tcx); for &(mono_item, data) in &mono_items { mono_item.predefine::>( diff --git a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs index 5d1ddd057d88..f28037fb9cff 100644 --- a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs +++ b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs @@ -2,17 +2,76 @@ use std::ffi::CString; use llvm::Linkage::*; use rustc_abi::Align; -use rustc_codegen_ssa::traits::BaseTypeCodegenMethods; +use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, BuilderMethods}; use rustc_middle::ty::offload_meta::OffloadMetadata; -use crate::builder::SBuilder; +use crate::builder::Builder; +use crate::common::CodegenCx; use crate::llvm::AttributePlace::Function; -use crate::llvm::{self, BasicBlock, Linkage, Type, Value}; +use crate::llvm::{self, Linkage, Type, Value}; use crate::{SimpleCx, attributes}; +// LLVM kernel-independent globals required for offloading +pub(crate) struct OffloadGlobals<'ll> { + pub launcher_fn: &'ll llvm::Value, + pub launcher_ty: &'ll llvm::Type, + + pub bin_desc: &'ll llvm::Type, + + pub kernel_args_ty: &'ll llvm::Type, + + pub offload_entry_ty: &'ll llvm::Type, + + pub begin_mapper: &'ll llvm::Value, + pub end_mapper: &'ll llvm::Value, + pub mapper_fn_ty: &'ll llvm::Type, + + pub ident_t_global: &'ll llvm::Value, + + pub register_lib: &'ll llvm::Value, + pub unregister_lib: &'ll llvm::Value, + pub init_rtls: &'ll llvm::Value, +} + +impl<'ll> OffloadGlobals<'ll> { + pub(crate) fn declare(cx: &CodegenCx<'ll, '_>) -> Self { + let (launcher_fn, launcher_ty) = generate_launcher(cx); + let kernel_args_ty = KernelArgsTy::new_decl(cx); + let offload_entry_ty = TgtOffloadEntry::new_decl(cx); + let (begin_mapper, _, end_mapper, mapper_fn_ty) = gen_tgt_data_mappers(cx); + let ident_t_global = generate_at_one(cx); + + let tptr = cx.type_ptr(); + let ti32 = cx.type_i32(); + let tgt_bin_desc_ty = vec![ti32, tptr, tptr, tptr]; + let bin_desc = cx.type_named_struct("struct.__tgt_bin_desc"); + cx.set_struct_body(bin_desc, &tgt_bin_desc_ty, false); + + let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", mapper_fn_ty); + let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", mapper_fn_ty); + let init_ty = cx.type_func(&[], cx.type_void()); + let init_rtls = declare_offload_fn(cx, "__tgt_init_all_rtls", init_ty); + + OffloadGlobals { + launcher_fn, + launcher_ty, + bin_desc, + kernel_args_ty, + offload_entry_ty, + begin_mapper, + end_mapper, + mapper_fn_ty, + ident_t_global, + register_lib, + unregister_lib, + init_rtls, + } + } +} + // ; Function Attrs: nounwind // declare i32 @__tgt_target_kernel(ptr, i64, i32, i32, ptr, ptr) #2 -fn generate_launcher<'ll>(cx: &'ll SimpleCx<'_>) -> (&'ll llvm::Value, &'ll llvm::Type) { +fn generate_launcher<'ll>(cx: &CodegenCx<'ll, '_>) -> (&'ll llvm::Value, &'ll llvm::Type) { let tptr = cx.type_ptr(); let ti64 = cx.type_i64(); let ti32 = cx.type_i32(); @@ -30,7 +89,7 @@ fn generate_launcher<'ll>(cx: &'ll SimpleCx<'_>) -> (&'ll llvm::Value, &'ll llvm // @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8 // FIXME(offload): @0 should include the file name (e.g. lib.rs) in which the function to be // offloaded was defined. -fn generate_at_one<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll llvm::Value { +pub(crate) fn generate_at_one<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll llvm::Value { let unknown_txt = ";unknown;unknown;0;0;;"; let c_entry_name = CString::new(unknown_txt).unwrap(); let c_val = c_entry_name.as_bytes_with_nul(); @@ -68,7 +127,7 @@ pub(crate) struct TgtOffloadEntry { } impl TgtOffloadEntry { - pub(crate) fn new_decl<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll llvm::Type { + pub(crate) fn new_decl<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll llvm::Type { let offload_entry_ty = cx.type_named_struct("struct.__tgt_offload_entry"); let tptr = cx.type_ptr(); let ti64 = cx.type_i64(); @@ -82,7 +141,7 @@ impl TgtOffloadEntry { } fn new<'ll>( - cx: &'ll SimpleCx<'_>, + cx: &CodegenCx<'ll, '_>, region_id: &'ll Value, llglobal: &'ll Value, ) -> [&'ll Value; 9] { @@ -126,7 +185,7 @@ impl KernelArgsTy { const OFFLOAD_VERSION: u64 = 3; const FLAGS: u64 = 0; const TRIPCOUNT: u64 = 0; - fn new_decl<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll Type { + fn new_decl<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll Type { let kernel_arguments_ty = cx.type_named_struct("struct.__tgt_kernel_arguments"); let tptr = cx.type_ptr(); let ti64 = cx.type_i64(); @@ -140,8 +199,8 @@ impl KernelArgsTy { kernel_arguments_ty } - fn new<'ll>( - cx: &'ll SimpleCx<'_>, + fn new<'ll, 'tcx>( + cx: &CodegenCx<'ll, 'tcx>, num_args: u64, memtransfer_types: &'ll Value, geps: [&'ll Value; 3], @@ -171,7 +230,8 @@ impl KernelArgsTy { } // Contains LLVM values needed to manage offloading for a single kernel. -pub(crate) struct OffloadKernelData<'ll> { +#[derive(Copy, Clone)] +pub(crate) struct OffloadKernelGlobals<'ll> { pub offload_sizes: &'ll llvm::Value, pub memtransfer_types: &'ll llvm::Value, pub region_id: &'ll llvm::Value, @@ -179,7 +239,7 @@ pub(crate) struct OffloadKernelData<'ll> { } fn gen_tgt_data_mappers<'ll>( - cx: &'ll SimpleCx<'_>, + cx: &CodegenCx<'ll, '_>, ) -> (&'ll llvm::Value, &'ll llvm::Value, &'ll llvm::Value, &'ll llvm::Type) { let tptr = cx.type_ptr(); let ti64 = cx.type_i64(); @@ -241,12 +301,18 @@ pub(crate) fn add_global<'ll>( // mapped to/from the gpu. It also returns a region_id with the name of this kernel, to be // concatenated into the list of region_ids. pub(crate) fn gen_define_handling<'ll>( - cx: &SimpleCx<'ll>, - offload_entry_ty: &'ll llvm::Type, + cx: &CodegenCx<'ll, '_>, metadata: &[OffloadMetadata], - types: &[&Type], - symbol: &str, -) -> OffloadKernelData<'ll> { + types: &[&'ll Type], + symbol: String, + offload_globals: &OffloadGlobals<'ll>, +) -> OffloadKernelGlobals<'ll> { + if let Some(entry) = cx.offload_kernel_cache.borrow().get(&symbol) { + return *entry; + } + + let offload_entry_ty = offload_globals.offload_entry_ty; + // It seems like non-pointer values are automatically mapped. So here, we focus on pointer (or // reference) types. let ptr_meta = types.iter().zip(metadata).filter_map(|(&x, meta)| match cx.type_kind(x) { @@ -274,7 +340,7 @@ pub(crate) fn gen_define_handling<'ll>( let initializer = cx.get_const_i8(0); let region_id = add_unnamed_global(&cx, &name, initializer, WeakAnyLinkage); - let c_entry_name = CString::new(symbol).unwrap(); + let c_entry_name = CString::new(symbol.clone()).unwrap(); let c_val = c_entry_name.as_bytes_with_nul(); let offload_entry_name = format!(".offloading.entry_name.{symbol}"); @@ -298,11 +364,16 @@ pub(crate) fn gen_define_handling<'ll>( let c_section_name = CString::new("llvm_offload_entries").unwrap(); llvm::set_section(offload_entry, &c_section_name); - OffloadKernelData { offload_sizes, memtransfer_types, region_id, offload_entry } + let result = + OffloadKernelGlobals { offload_sizes, memtransfer_types, region_id, offload_entry }; + + cx.offload_kernel_cache.borrow_mut().insert(symbol, result); + + result } fn declare_offload_fn<'ll>( - cx: &'ll SimpleCx<'_>, + cx: &CodegenCx<'ll, '_>, name: &str, ty: &'ll llvm::Type, ) -> &'ll llvm::Value { @@ -335,28 +406,28 @@ fn declare_offload_fn<'ll>( // 4. set insert point after kernel call. // 5. generate all the GEPS and stores, to be used in 6) // 6. generate __tgt_target_data_end calls to move data from the GPU -pub(crate) fn gen_call_handling<'ll>( - cx: &SimpleCx<'ll>, - bb: &BasicBlock, - offload_data: &OffloadKernelData<'ll>, +pub(crate) fn gen_call_handling<'ll, 'tcx>( + builder: &mut Builder<'_, 'll, 'tcx>, + offload_data: &OffloadKernelGlobals<'ll>, args: &[&'ll Value], types: &[&Type], metadata: &[OffloadMetadata], + offload_globals: &OffloadGlobals<'ll>, ) { - let OffloadKernelData { offload_sizes, offload_entry, memtransfer_types, region_id } = + let cx = builder.cx; + let OffloadKernelGlobals { offload_sizes, offload_entry, memtransfer_types, region_id } = offload_data; - let (tgt_decl, tgt_target_kernel_ty) = generate_launcher(&cx); + + let tgt_decl = offload_globals.launcher_fn; + let tgt_target_kernel_ty = offload_globals.launcher_ty; + // %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } - let tptr = cx.type_ptr(); - let ti32 = cx.type_i32(); - let tgt_bin_desc_ty = vec![ti32, tptr, tptr, tptr]; - let tgt_bin_desc = cx.type_named_struct("struct.__tgt_bin_desc"); - cx.set_struct_body(tgt_bin_desc, &tgt_bin_desc_ty, false); + let tgt_bin_desc = offload_globals.bin_desc; - let tgt_kernel_decl = KernelArgsTy::new_decl(&cx); - let (begin_mapper_decl, _, end_mapper_decl, fn_ty) = gen_tgt_data_mappers(&cx); - - let mut builder = SBuilder::build(cx, bb); + let tgt_kernel_decl = offload_globals.kernel_args_ty; + let begin_mapper_decl = offload_globals.begin_mapper; + let end_mapper_decl = offload_globals.end_mapper; + let fn_ty = offload_globals.mapper_fn_ty; let num_args = types.len() as u64; let ip = unsafe { llvm::LLVMRustGetInsertPoint(&builder.llbuilder) }; @@ -378,9 +449,8 @@ pub(crate) fn gen_call_handling<'ll>( // Step 0) // %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } // %6 = alloca %struct.__tgt_bin_desc, align 8 - let llfn = unsafe { llvm::LLVMGetBasicBlockParent(bb) }; unsafe { - llvm::LLVMRustPositionBuilderPastAllocas(&builder.llbuilder, llfn); + llvm::LLVMRustPositionBuilderPastAllocas(&builder.llbuilder, builder.llfn()); } let tgt_bin_desc_alloca = builder.direct_alloca(tgt_bin_desc, Align::EIGHT, "EmptyDesc"); @@ -413,16 +483,16 @@ pub(crate) fn gen_call_handling<'ll>( } let mapper_fn_ty = cx.type_func(&[cx.type_ptr()], cx.type_void()); - let register_lib_decl = declare_offload_fn(&cx, "__tgt_register_lib", mapper_fn_ty); - let unregister_lib_decl = declare_offload_fn(&cx, "__tgt_unregister_lib", mapper_fn_ty); + let register_lib_decl = offload_globals.register_lib; + let unregister_lib_decl = offload_globals.unregister_lib; let init_ty = cx.type_func(&[], cx.type_void()); - let init_rtls_decl = declare_offload_fn(cx, "__tgt_init_all_rtls", init_ty); + let init_rtls_decl = offload_globals.init_rtls; // FIXME(offload): Later we want to add them to the wrapper code, rather than our main function. // call void @__tgt_register_lib(ptr noundef %6) - builder.call(mapper_fn_ty, register_lib_decl, &[tgt_bin_desc_alloca], None); + builder.call(mapper_fn_ty, None, None, register_lib_decl, &[tgt_bin_desc_alloca], None, None); // call void @__tgt_init_all_rtls() - builder.call(init_ty, init_rtls_decl, &[], None); + builder.call(init_ty, None, None, init_rtls_decl, &[], None, None); for i in 0..num_args { let idx = cx.get_const_i32(i); @@ -437,15 +507,15 @@ pub(crate) fn gen_call_handling<'ll>( // For now we have a very simplistic indexing scheme into our // offload_{baseptrs,ptrs,sizes}. We will probably improve this along with our gpu frontend pr. - fn get_geps<'a, 'll>( - builder: &mut SBuilder<'a, 'll>, - cx: &'ll SimpleCx<'ll>, + fn get_geps<'ll, 'tcx>( + builder: &mut Builder<'_, 'll, 'tcx>, ty: &'ll Type, ty2: &'ll Type, a1: &'ll Value, a2: &'ll Value, a4: &'ll Value, ) -> [&'ll Value; 3] { + let cx = builder.cx; let i32_0 = cx.get_const_i32(0); let gep1 = builder.inbounds_gep(ty, a1, &[i32_0, i32_0]); @@ -454,9 +524,8 @@ pub(crate) fn gen_call_handling<'ll>( [gep1, gep2, gep3] } - fn generate_mapper_call<'a, 'll>( - builder: &mut SBuilder<'a, 'll>, - cx: &'ll SimpleCx<'ll>, + fn generate_mapper_call<'ll, 'tcx>( + builder: &mut Builder<'_, 'll, 'tcx>, geps: [&'ll Value; 3], o_type: &'ll Value, fn_to_call: &'ll Value, @@ -464,20 +533,20 @@ pub(crate) fn gen_call_handling<'ll>( num_args: u64, s_ident_t: &'ll Value, ) { + let cx = builder.cx; let nullptr = cx.const_null(cx.type_ptr()); let i64_max = cx.get_const_i64(u64::MAX); let num_args = cx.get_const_i32(num_args); let args = vec![s_ident_t, i64_max, num_args, geps[0], geps[1], geps[2], o_type, nullptr, nullptr]; - builder.call(fn_ty, fn_to_call, &args, None); + builder.call(fn_ty, None, None, fn_to_call, &args, None, None); } // Step 2) - let s_ident_t = generate_at_one(&cx); - let geps = get_geps(&mut builder, &cx, ty, ty2, a1, a2, a4); + let s_ident_t = offload_globals.ident_t_global; + let geps = get_geps(builder, ty, ty2, a1, a2, a4); generate_mapper_call( - &mut builder, - &cx, + builder, geps, memtransfer_types, begin_mapper_decl, @@ -504,14 +573,13 @@ pub(crate) fn gen_call_handling<'ll>( region_id, a5, ]; - builder.call(tgt_target_kernel_ty, tgt_decl, &args, None); + builder.call(tgt_target_kernel_ty, None, None, tgt_decl, &args, None, None); // %41 = call i32 @__tgt_target_kernel(ptr @1, i64 -1, i32 2097152, i32 256, ptr @.kernel_1.region_id, ptr %kernel_args) // Step 4) - let geps = get_geps(&mut builder, &cx, ty, ty2, a1, a2, a4); + let geps = get_geps(builder, ty, ty2, a1, a2, a4); generate_mapper_call( - &mut builder, - &cx, + builder, geps, memtransfer_types, end_mapper_decl, @@ -520,7 +588,5 @@ pub(crate) fn gen_call_handling<'ll>( s_ident_t, ); - builder.call(mapper_fn_ty, unregister_lib_decl, &[tgt_bin_desc_alloca], None); - - drop(builder); + builder.call(mapper_fn_ty, None, None, unregister_lib_decl, &[tgt_bin_desc_alloca], None, None); } diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 6caf60e3cc41..03da70d48f7d 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -35,6 +35,7 @@ use smallvec::SmallVec; use crate::abi::to_llvm_calling_convention; use crate::back::write::to_llvm_code_model; +use crate::builder::gpu_offload::{OffloadGlobals, OffloadKernelGlobals}; use crate::callee::get_fn; use crate::debuginfo::metadata::apply_vcall_visibility_metadata; use crate::llvm::{self, Metadata, MetadataKindId, Module, Type, Value}; @@ -156,6 +157,12 @@ pub(crate) struct FullCx<'ll, 'tcx> { /// Cache of Objective-C selector references pub objc_selrefs: RefCell>, + + /// Globals shared by the offloading runtime + pub offload_globals: RefCell>>, + + /// Cache of kernel-specific globals + pub offload_kernel_cache: RefCell>>, } fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode { @@ -639,6 +646,8 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { objc_class_t: Cell::new(None), objc_classrefs: Default::default(), objc_selrefs: Default::default(), + offload_globals: Default::default(), + offload_kernel_cache: Default::default(), }, PhantomData, ) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 33541f7b695f..46a7c55a7baa 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -26,7 +26,7 @@ use tracing::debug; use crate::abi::FnAbiLlvmExt; use crate::builder::Builder; use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call}; -use crate::builder::gpu_offload::TgtOffloadEntry; +use crate::builder::gpu_offload::{gen_call_handling, gen_define_handling}; use crate::context::CodegenCx; use crate::errors::{ AutoDiffWithoutEnable, AutoDiffWithoutLto, OffloadWithoutEnable, OffloadWithoutFatLTO, @@ -1287,8 +1287,6 @@ fn codegen_offload<'ll, 'tcx>( let args = get_args_from_tuple(bx, args[1], fn_target); let target_symbol = symbol_name_for_instance_in_crate(tcx, fn_target, LOCAL_CRATE); - let offload_entry_ty = TgtOffloadEntry::new_decl(&cx); - let sig = tcx.fn_sig(fn_target.def_id()).skip_binder().skip_binder(); let inputs = sig.inputs(); @@ -1296,17 +1294,16 @@ fn codegen_offload<'ll, 'tcx>( let types = inputs.iter().map(|ty| cx.layout_of(*ty).llvm_type(cx)).collect::>(); - let offload_data = crate::builder::gpu_offload::gen_define_handling( - cx, - offload_entry_ty, - &metadata, - &types, - &target_symbol, - ); - - // FIXME(Sa4dUs): pass the original builder once we separate kernel launch logic from globals - let bb = unsafe { llvm::LLVMGetInsertBlock(bx.llbuilder) }; - crate::builder::gpu_offload::gen_call_handling(cx, bb, &offload_data, &args, &types, &metadata); + let offload_globals_ref = cx.offload_globals.borrow(); + let offload_globals = match offload_globals_ref.as_ref() { + Some(globals) => globals, + None => { + // Offload is not initialized, cannot continue + return; + } + }; + let offload_data = gen_define_handling(&cx, &metadata, &types, target_symbol, offload_globals); + gen_call_handling(bx, &offload_data, &args, &types, &metadata, offload_globals); } fn get_args_from_tuple<'ll, 'tcx>( diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 6eefb2f48d12..c8245b0e43bd 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -1118,7 +1118,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(Word, List: &[r#""...""#]), DuplicatesOk, EncodeCrossCrate::Yes, ), - rustc_attr!( + rustc_attr!( rustc_offload_kernel, Normal, template!(Word), DuplicatesOk, EncodeCrossCrate::Yes, diff --git a/tests/codegen-llvm/gpu_offload/gpu_host.rs b/tests/codegen-llvm/gpu_offload/gpu_host.rs index b0f83c825705..06bb2d92d8ba 100644 --- a/tests/codegen-llvm/gpu_offload/gpu_host.rs +++ b/tests/codegen-llvm/gpu_offload/gpu_host.rs @@ -11,6 +11,7 @@ // when inside of a function called main. This, too, is a temporary workaround for not having a // frontend. +#![feature(rustc_attrs)] #![feature(core_intrinsics)] #![no_main] @@ -21,29 +22,31 @@ fn main() { core::hint::black_box(&x); } -// CHECK: %struct.__tgt_offload_entry = type { i64, i16, i16, i32, ptr, ptr, i64, i64, ptr } // CHECK: %struct.ident_t = type { i32, i32, i32, i32, ptr } +// CHECK: %struct.__tgt_offload_entry = type { i64, i16, i16, i32, ptr, ptr, i64, i64, ptr } // CHECK: %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } // CHECK: %struct.__tgt_kernel_arguments = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, [3 x i32], [3 x i32], i32 } +// CHECK: @anon.{{.*}}.0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 +// CHECK: @anon.{{.*}}.1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @anon.{{.*}}.0 }, align 8 + // CHECK: @.offload_sizes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 1024] // CHECK: @.offload_maptypes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 35] // CHECK: @._kernel_1.region_id = internal unnamed_addr constant i8 0 // CHECK: @.offloading.entry_name._kernel_1 = internal unnamed_addr constant [10 x i8] c"_kernel_1\00", section ".llvm.rodata.offloading", align 1 // CHECK: @.offloading.entry._kernel_1 = internal constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @._kernel_1.region_id, ptr @.offloading.entry_name._kernel_1, i64 0, i64 0, ptr null }, section "llvm_offload_entries", align 8 -// CHECK: @anon.{{.*}}.0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 -// CHECK: @anon.{{.*}}.1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @anon.{{.*}}.0 }, align 8 +// CHECK: Function Attrs: nounwind +// CHECK: declare i32 @__tgt_target_kernel(ptr, i64, i32, i32, ptr, ptr) -// CHECK: Function Attrs: -// CHECK-NEXT: define{{( dso_local)?}} void @main() +// CHECK: define{{( dso_local)?}} void @main() // CHECK-NEXT: start: // CHECK-NEXT: %0 = alloca [8 x i8], align 8 // CHECK-NEXT: %x = alloca [1024 x i8], align 16 // CHECK: call void @kernel_1(ptr noalias noundef nonnull align 4 dereferenceable(1024) %x) // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) // CHECK-NEXT: store ptr %x, ptr %0, align 8 -// CHECK-NEXT: call void asm sideeffect "", "r,~{memory}"(ptr nonnull %0) #4, !srcloc !4 +// CHECK-NEXT: call void asm sideeffect "", "r,~{memory}"(ptr nonnull %0) // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) // CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %x) // CHECK-NEXT: ret void @@ -92,9 +95,6 @@ fn main() { // CHECK-NEXT: ret void // CHECK-NEXT: } -// CHECK: Function Attrs: nounwind -// CHECK: declare i32 @__tgt_target_kernel(ptr, i64, i32, i32, ptr, ptr) - #[unsafe(no_mangle)] #[inline(never)] pub fn kernel_1(x: &mut [f32; 256]) { From 8bafb632026871b4e6849f80d63b3f4d8a5fb517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Dom=C3=ADnguez?= Date: Mon, 8 Dec 2025 22:47:05 +0100 Subject: [PATCH 324/489] Remove outdated comment --- compiler/rustc_codegen_llvm/src/back/write.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index c0c01b80372f..c6a1440c86da 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -710,8 +710,7 @@ pub(crate) unsafe fn llvm_optimize( if cgcx.target_is_like_gpu && config.offload.contains(&config::Offload::Enable) { let cx = SimpleCx::new(module.module_llvm.llmod(), module.module_llvm.llcx, cgcx.pointer_size); - // For now we only support up to 10 kernels named kernel_0 ... kernel_9, a follow-up PR is - // introducing a proper offload intrinsic to solve this limitation. + for func in cx.get_functions() { let offload_kernel = "offload-kernel"; if attributes::has_string_attr(func, offload_kernel) { From 04c2d2be1379cd67521d04d7142d3edd680d6b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Dom=C3=ADnguez?= Date: Thu, 18 Dec 2025 13:14:41 +0100 Subject: [PATCH 325/489] Remove `region_id` unnamed attr --- compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs | 2 +- tests/codegen-llvm/gpu_offload/gpu_host.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs index f28037fb9cff..046501d08c48 100644 --- a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs +++ b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs @@ -338,7 +338,7 @@ pub(crate) fn gen_define_handling<'ll>( let name = format!(".{symbol}.region_id"); let initializer = cx.get_const_i8(0); - let region_id = add_unnamed_global(&cx, &name, initializer, WeakAnyLinkage); + let region_id = add_global(&cx, &name, initializer, WeakAnyLinkage); let c_entry_name = CString::new(symbol.clone()).unwrap(); let c_val = c_entry_name.as_bytes_with_nul(); diff --git a/tests/codegen-llvm/gpu_offload/gpu_host.rs b/tests/codegen-llvm/gpu_offload/gpu_host.rs index 06bb2d92d8ba..ac179a65828d 100644 --- a/tests/codegen-llvm/gpu_offload/gpu_host.rs +++ b/tests/codegen-llvm/gpu_offload/gpu_host.rs @@ -32,7 +32,7 @@ fn main() { // CHECK: @.offload_sizes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 1024] // CHECK: @.offload_maptypes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 35] -// CHECK: @._kernel_1.region_id = internal unnamed_addr constant i8 0 +// CHECK: @._kernel_1.region_id = internal constant i8 0 // CHECK: @.offloading.entry_name._kernel_1 = internal unnamed_addr constant [10 x i8] c"_kernel_1\00", section ".llvm.rodata.offloading", align 1 // CHECK: @.offloading.entry._kernel_1 = internal constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @._kernel_1.region_id, ptr @.offloading.entry_name._kernel_1, i64 0, i64 0, ptr null }, section "llvm_offload_entries", align 8 From 678f58151e36741d0588e150cc46cda14263bedb Mon Sep 17 00:00:00 2001 From: Aditya-PS-05 Date: Fri, 19 Dec 2025 18:05:11 +0530 Subject: [PATCH 326/489] fix ICE when {{root}} appears in import suggestions --- compiler/rustc_resolve/src/diagnostics.rs | 6 +++++- .../nested-import-root-symbol-150103.rs | 13 ++++++++++++ .../nested-import-root-symbol-150103.stderr | 20 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/ui/imports/nested-import-root-symbol-150103.rs create mode 100644 tests/ui/imports/nested-import-root-symbol-150103.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 3eccbd4682da..b0cdfe8ab87d 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2223,7 +2223,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { match binding.kind { NameBindingKind::Import { import, .. } => { for segment in import.module_path.iter().skip(1) { - path.push(segment.ident); + // Don't include `{{root}}` in suggestions - it's an internal symbol + // that should never be shown to users. + if segment.ident.name != kw::PathRoot { + path.push(segment.ident); + } } sugg_paths.push(( path.iter().cloned().chain(std::iter::once(ident)).collect::>(), diff --git a/tests/ui/imports/nested-import-root-symbol-150103.rs b/tests/ui/imports/nested-import-root-symbol-150103.rs new file mode 100644 index 000000000000..066ed37d8bbb --- /dev/null +++ b/tests/ui/imports/nested-import-root-symbol-150103.rs @@ -0,0 +1,13 @@ +// Issue: https://github.com/rust-lang/rust/issues/150103 +// ICE when using `::` at start of nested imports +// caused by `{{root}}` appearing in diagnostic suggestions + +mod A { + use Iuse::{ ::Fish }; //~ ERROR failed to resolve: use of unresolved module or unlinked crate +} + +mod B { + use A::{::Fish}; //~ ERROR failed to resolve: crate root in paths can only be used in start position +} + +fn main() {} diff --git a/tests/ui/imports/nested-import-root-symbol-150103.stderr b/tests/ui/imports/nested-import-root-symbol-150103.stderr new file mode 100644 index 000000000000..be8b8c12d218 --- /dev/null +++ b/tests/ui/imports/nested-import-root-symbol-150103.stderr @@ -0,0 +1,20 @@ +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `Iuse` + --> $DIR/nested-import-root-symbol-150103.rs:6:9 + | +LL | use Iuse::{ ::Fish }; + | ^^^^ use of unresolved module or unlinked crate `Iuse` + | +help: you might be missing a crate named `Iuse`, add it to your project and import it in your code + | +LL + extern crate Iuse; + | + +error[E0433]: failed to resolve: crate root in paths can only be used in start position + --> $DIR/nested-import-root-symbol-150103.rs:10:13 + | +LL | use A::{::Fish}; + | ^ crate root in paths can only be used in start position + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. From a45b2ba60be6e0f89aa05eb9c4b444477b3b15b6 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 19 Dec 2025 15:19:39 +0100 Subject: [PATCH 327/489] Set myself on vacation --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index 09dec7675e7e..5f637205fa65 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -63,6 +63,7 @@ users_on_vacation = [ "Alexendoo", "y21", "blyxyas", + "samueltardieu", ] [assign.owners] From a287c66721cc088ee0fec6c93f94e94ee03ee11f Mon Sep 17 00:00:00 2001 From: Nelli Skogman Date: Sun, 12 Oct 2025 16:07:11 +0200 Subject: [PATCH 328/489] Fix an incorrect error message regarding the size of `isize` and `usize` --- clippy_lints/src/casts/cast_precision_loss.rs | 22 ++++++------------- tests/ui/cast.stderr | 12 +++++----- tests/ui/cast_size.r32bit.stderr | 12 +++++----- tests/ui/cast_size.r64bit.stderr | 12 +++++----- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/clippy_lints/src/casts/cast_precision_loss.rs b/clippy_lints/src/casts/cast_precision_loss.rs index 712e38db499f..748ab3163496 100644 --- a/clippy_lints/src/casts/cast_precision_loss.rs +++ b/clippy_lints/src/casts/cast_precision_loss.rs @@ -23,15 +23,11 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca let cast_to_f64 = to_nbits == 64; let mantissa_nbits = if cast_to_f64 { 52 } else { 23 }; - let arch_dependent = is_isize_or_usize(cast_from) && cast_to_f64; - let arch_dependent_str = "on targets with 64-bit wide pointers "; - let from_nbits_str = if arch_dependent { - "64".to_owned() - } else if is_isize_or_usize(cast_from) { - // FIXME: handle 16 bits `usize` type - "32 or 64".to_owned() + + let has_width = if is_isize_or_usize(cast_from) { + "can be up to 64 bits wide depending on the target architecture".to_owned() } else { - from_nbits.to_string() + format!("is {from_nbits} bits wide") }; span_lint( @@ -39,13 +35,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca CAST_PRECISION_LOSS, expr.span, format!( - "casting `{0}` to `{1}` causes a loss of precision {2}(`{0}` is {3} bits wide, \ - but `{1}`'s mantissa is only {4} bits wide)", - cast_from, - if cast_to_f64 { "f64" } else { "f32" }, - if arch_dependent { arch_dependent_str } else { "" }, - from_nbits_str, - mantissa_nbits + "casting `{cast_from}` to `{cast_to}` may cause a loss of precision \ + (`{cast_from}` {has_width}, \ + but `{cast_to}`'s mantissa is only {mantissa_nbits} bits wide)", ), ); } diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 0ff1dc11c3ac..14b84b1ff1ef 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,4 +1,4 @@ -error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `i32` to `f32` may cause a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast.rs:23:5 | LL | x0 as f32; @@ -7,31 +7,31 @@ LL | x0 as f32; = note: `-D clippy::cast-precision-loss` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` -error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `i64` to `f32` may cause a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast.rs:27:5 | LL | x1 as f32; | ^^^^^^^^^ -error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `i64` to `f64` may cause a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast.rs:30:5 | LL | x1 as f64; | ^^^^^^^^^ -error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `u32` to `f32` may cause a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast.rs:34:5 | LL | x2 as f32; | ^^^^^^^^^ -error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `u64` to `f32` may cause a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast.rs:38:5 | LL | x3 as f32; | ^^^^^^^^^ -error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `u64` to `f64` may cause a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast.rs:41:5 | LL | x3 as f64; diff --git a/tests/ui/cast_size.r32bit.stderr b/tests/ui/cast_size.r32bit.stderr index 5811cb3607ba..2f7eeda385e5 100644 --- a/tests/ui/cast_size.r32bit.stderr +++ b/tests/ui/cast_size.r32bit.stderr @@ -13,7 +13,7 @@ LL - 1isize as i8; LL + i8::try_from(1isize); | -error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `isize` to `f32` may cause a loss of precision (`isize` can be up to 64 bits wide depending on the target architecture, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast_size.rs:24:5 | LL | x0 as f32; @@ -22,19 +22,19 @@ LL | x0 as f32; = note: `-D clippy::cast-precision-loss` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` -error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `usize` to `f32` may cause a loss of precision (`usize` can be up to 64 bits wide depending on the target architecture, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast_size.rs:26:5 | LL | x1 as f32; | ^^^^^^^^^ -error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `isize` to `f64` may cause a loss of precision (`isize` can be up to 64 bits wide depending on the target architecture, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast_size.rs:28:5 | LL | x0 as f64; | ^^^^^^^^^ -error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `usize` to `f64` may cause a loss of precision (`usize` can be up to 64 bits wide depending on the target architecture, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast_size.rs:30:5 | LL | x1 as f64; @@ -165,13 +165,13 @@ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit LL | 1u32 as isize; | ^^^^^^^^^^^^^ -error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `i32` to `f32` may cause a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast_size.rs:61:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ -error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `usize` to `f64` may cause a loss of precision (`usize` can be up to 64 bits wide depending on the target architecture, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast_size.rs:63:5 | LL | 9_999_999_999_999_999usize as f64; diff --git a/tests/ui/cast_size.r64bit.stderr b/tests/ui/cast_size.r64bit.stderr index ba1419583aeb..8e5f38137602 100644 --- a/tests/ui/cast_size.r64bit.stderr +++ b/tests/ui/cast_size.r64bit.stderr @@ -13,7 +13,7 @@ LL - 1isize as i8; LL + i8::try_from(1isize); | -error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `isize` to `f32` may cause a loss of precision (`isize` can be up to 64 bits wide depending on the target architecture, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast_size.rs:24:5 | LL | x0 as f32; @@ -22,19 +22,19 @@ LL | x0 as f32; = note: `-D clippy::cast-precision-loss` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` -error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `usize` to `f32` may cause a loss of precision (`usize` can be up to 64 bits wide depending on the target architecture, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast_size.rs:26:5 | LL | x1 as f32; | ^^^^^^^^^ -error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `isize` to `f64` may cause a loss of precision (`isize` can be up to 64 bits wide depending on the target architecture, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast_size.rs:28:5 | LL | x0 as f64; | ^^^^^^^^^ -error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `usize` to `f64` may cause a loss of precision (`usize` can be up to 64 bits wide depending on the target architecture, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast_size.rs:30:5 | LL | x1 as f64; @@ -165,13 +165,13 @@ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit LL | 1u32 as isize; | ^^^^^^^^^^^^^ -error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +error: casting `i32` to `f32` may cause a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> tests/ui/cast_size.rs:61:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ -error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +error: casting `usize` to `f64` may cause a loss of precision (`usize` can be up to 64 bits wide depending on the target architecture, but `f64`'s mantissa is only 52 bits wide) --> tests/ui/cast_size.rs:63:5 | LL | 9_999_999_999_999_999usize as f64; From 0bc29cec45412ee3cc68a1ef1556814885543d55 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 Dec 2025 17:55:19 +0100 Subject: [PATCH 329/489] Add regression test for `const_item_interior_mutations` deref FP --- ...nst-item-interior-mutations-const-deref.rs | 30 +++++++++++++++ ...item-interior-mutations-const-deref.stderr | 37 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/ui/lint/const-item-interior-mutations-const-deref.rs create mode 100644 tests/ui/lint/const-item-interior-mutations-const-deref.stderr diff --git a/tests/ui/lint/const-item-interior-mutations-const-deref.rs b/tests/ui/lint/const-item-interior-mutations-const-deref.rs new file mode 100644 index 000000000000..ce684abacccd --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-deref.rs @@ -0,0 +1,30 @@ +// Regression test for +// +// We shouldn't lint on user types, including through deref. + +//@ check-pass + +use std::cell::Cell; +use std::ops::Deref; + +// Cut down version of the issue reproducer without the thread local to just a Deref +pub struct LocalKey { + inner: T, +} + +impl Deref for LocalKey { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +const LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; + +fn main() { + let count = LOCAL_COUNT.get(); + //~^ WARN mutation of an interior mutable `const` + LOCAL_COUNT.set(count); + //~^ WARN mutation of an interior mutable `const` +} diff --git a/tests/ui/lint/const-item-interior-mutations-const-deref.stderr b/tests/ui/lint/const-item-interior-mutations-const-deref.stderr new file mode 100644 index 000000000000..35696d0ba100 --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-deref.stderr @@ -0,0 +1,37 @@ +warning: mutation of an interior mutable `const` item with call to `get` + --> $DIR/const-item-interior-mutations-const-deref.rs:26:17 + | +LL | let count = LOCAL_COUNT.get(); + | -----------^^^^^^ + | | + | `LOCAL_COUNT` is a interior mutable `const` item of type `LocalKey>` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const LOCAL_COUNT` will be modified + = help: for more details on interior mutability see + = note: `#[warn(const_item_interior_mutations)]` on by default +help: for a shared instance of `LOCAL_COUNT`, consider making it a `static` item instead + | +LL - const LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; +LL + static LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; + | + +warning: mutation of an interior mutable `const` item with call to `set` + --> $DIR/const-item-interior-mutations-const-deref.rs:28:5 + | +LL | LOCAL_COUNT.set(count); + | -----------^^^^^^^^^^^ + | | + | `LOCAL_COUNT` is a interior mutable `const` item of type `LocalKey>` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const LOCAL_COUNT` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `LOCAL_COUNT`, consider making it a `static` item instead + | +LL - const LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; +LL + static LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; + | + +warning: 2 warnings emitted + From 7431c38ec9cae9b77b7554d62d9d7776bb0f587f Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 19 Dec 2025 17:58:08 +0100 Subject: [PATCH 330/489] Add amdgpu intrinsics Add intrinsics for the amdgpu architecture. --- library/stdarch/.github/workflows/main.yml | 15 +- .../ci/docker/amdgcn-amd-amdhsa/Dockerfile | 5 + library/stdarch/ci/dox.sh | 10 + library/stdarch/ci/run.sh | 3 + .../crates/core_arch/src/amdgpu/mod.rs | 1053 +++++++++++++++++ .../crates/core_arch/src/core_arch_docs.md | 2 + library/stdarch/crates/core_arch/src/mod.rs | 14 + 7 files changed, 1100 insertions(+), 2 deletions(-) create mode 100644 library/stdarch/ci/docker/amdgcn-amd-amdhsa/Dockerfile create mode 100644 library/stdarch/crates/core_arch/src/amdgpu/mod.rs diff --git a/library/stdarch/.github/workflows/main.yml b/library/stdarch/.github/workflows/main.yml index 28c15cf4734a..6c8a5694f332 100644 --- a/library/stdarch/.github/workflows/main.yml +++ b/library/stdarch/.github/workflows/main.yml @@ -84,6 +84,8 @@ jobs: os: ubuntu-latest - tuple: nvptx64-nvidia-cuda os: ubuntu-latest + - tuple: amdgcn-amd-amdhsa + os: ubuntu-latest - tuple: thumbv6m-none-eabi os: ubuntu-latest - tuple: thumbv7m-none-eabi @@ -201,6 +203,10 @@ jobs: tuple: aarch64-apple-ios-macabi os: macos-15 norun: true # https://github.com/rust-lang/stdarch/issues/1206 + - target: + tuple: amdgcn-amd-amdhsa + os: ubuntu-latest + norun: true steps: - uses: actions/checkout@v4 @@ -212,12 +218,17 @@ jobs: - run: rustup target add ${{ matrix.target.tuple }} shell: bash - if: matrix.build_std == '' + if: matrix.build_std == '' && matrix.target.tuple != 'amdgcn-amd-amdhsa' - run: | rustup component add rust-src echo "CARGO_UNSTABLE_BUILD_STD=std" >> $GITHUB_ENV shell: bash if: matrix.build_std != '' + - run: | + rustup component add rust-src + echo "CARGO_UNSTABLE_BUILD_STD=core,alloc" >> $GITHUB_ENV + shell: bash + if: matrix.target.tuple == 'amdgcn-amd-amdhsa' # Configure some env vars based on matrix configuration - run: echo "PROFILE=--profile=${{matrix.profile}}" >> $GITHUB_ENV @@ -233,7 +244,7 @@ jobs: if: matrix.disable_assert_instr != '' - run: echo "NOSTD=1" >> $GITHUB_ENV shell: bash - if: startsWith(matrix.target.tuple, 'thumb') || matrix.target.tuple == 'nvptx64-nvidia-cuda' + if: startsWith(matrix.target.tuple, 'thumb') || matrix.target.tuple == 'nvptx64-nvidia-cuda' || matrix.target.tuple == 'amdgcn-amd-amdhsa' # Windows & OSX go straight to `run.sh` ... - run: ./ci/run.sh diff --git a/library/stdarch/ci/docker/amdgcn-amd-amdhsa/Dockerfile b/library/stdarch/ci/docker/amdgcn-amd-amdhsa/Dockerfile new file mode 100644 index 000000000000..65cf281b1477 --- /dev/null +++ b/library/stdarch/ci/docker/amdgcn-amd-amdhsa/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:25.10 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libc6-dev \ + ca-certificates diff --git a/library/stdarch/ci/dox.sh b/library/stdarch/ci/dox.sh index 94d76d430472..9803f7e37111 100755 --- a/library/stdarch/ci/dox.sh +++ b/library/stdarch/ci/dox.sh @@ -15,6 +15,15 @@ dox() { cargo clean --target "${1}" + if [ "${1}" == "amdgcn-amd-amdhsa" ]; then + if [ "$CI" != "" ]; then + rustup component add rust-src + fi + export CARGO_UNSTABLE_BUILD_STD=core + # amdgpu needs a target-cpu, any is fine + export RUSTFLAGS="${RUSTFLAGS} -Ctarget-cpu=gfx900" + fi + cargo build --verbose --target "${1}" --manifest-path crates/core_arch/Cargo.toml cargo doc --verbose --target "${1}" --manifest-path crates/core_arch/Cargo.toml } @@ -33,6 +42,7 @@ if [ -z "$1" ]; then #dox mips64-unknown-linux-gnuabi64 dox wasm32-unknown-unknown dox nvptx64-nvidia-cuda + dox amdgcn-amd-amdhsa else dox "${1}" fi diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index 2bb77bae256f..22c6593132eb 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -42,6 +42,9 @@ case ${TARGET} in armv7-*eabihf | thumbv7-*eabihf) export RUSTFLAGS="${RUSTFLAGS} -Ctarget-feature=+neon" ;; + amdgcn-*) + export RUSTFLAGS="${RUSTFLAGS} -Ctarget-cpu=gfx1200" + ;; # Some of our test dependencies use the deprecated `gcc` crates which # doesn't detect RISC-V compilers automatically, so do it manually here. riscv*) diff --git a/library/stdarch/crates/core_arch/src/amdgpu/mod.rs b/library/stdarch/crates/core_arch/src/amdgpu/mod.rs new file mode 100644 index 000000000000..40274e4d794f --- /dev/null +++ b/library/stdarch/crates/core_arch/src/amdgpu/mod.rs @@ -0,0 +1,1053 @@ +//! amdgpu intrinsics +//! +//! The reference is the [LLVM amdgpu guide] and the [LLVM implementation]. +//! The order of intrinsics here follows the order in the [LLVM implementation]. +//! +//! [LLVM amdgpu guide]: https://llvm.org/docs/AMDGPUUsage.html#llvm-ir-intrinsics +//! [LLVM implementation]: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/IntrinsicsAMDGPU.td + +#[allow(improper_ctypes)] +unsafe extern "unadjusted" { + #[link_name = "llvm.amdgcn.workitem.id.x"] + safe fn llvm_workitem_id_x() -> u32; + #[link_name = "llvm.amdgcn.workitem.id.y"] + safe fn llvm_workitem_id_y() -> u32; + #[link_name = "llvm.amdgcn.workitem.id.z"] + safe fn llvm_workitem_id_z() -> u32; + + #[link_name = "llvm.amdgcn.workgroup.id.x"] + safe fn llvm_workgroup_id_x() -> u32; + #[link_name = "llvm.amdgcn.workgroup.id.y"] + safe fn llvm_workgroup_id_y() -> u32; + #[link_name = "llvm.amdgcn.workgroup.id.z"] + safe fn llvm_workgroup_id_z() -> u32; + + #[link_name = "llvm.amdgcn.groupstaticsize"] + safe fn llvm_groupstaticsize() -> u32; + #[link_name = "llvm.amdgcn.dispatch.id"] + safe fn llvm_dispatch_id() -> u64; + + #[link_name = "llvm.amdgcn.wavefrontsize"] + safe fn llvm_wavefrontsize() -> u32; + + #[link_name = "llvm.amdgcn.s.barrier"] + safe fn llvm_s_barrier(); + #[link_name = "llvm.amdgcn.s.barrier.signal"] + fn llvm_s_barrier_signal(barrier_type: i32); + #[link_name = "llvm.amdgcn.s.barrier.signal.isfirst"] + fn llvm_s_barrier_signal_isfirst(barrier_type: i32) -> bool; + #[link_name = "llvm.amdgcn.s.barrier.wait"] + fn llvm_s_barrier_wait(barrier_type: i16); + #[link_name = "llvm.amdgcn.s.get.barrier.state"] + fn llvm_s_get_barrier_state(barrier_type: i32) -> u32; + #[link_name = "llvm.amdgcn.wave.barrier"] + safe fn llvm_wave_barrier(); + #[link_name = "llvm.amdgcn.sched.barrier"] + fn llvm_sched_barrier(mask: u32); + #[link_name = "llvm.amdgcn.sched.group.barrier"] + fn llvm_sched_group_barrier(mask: u32, size: u32, sync_id: u32); + + #[link_name = "llvm.amdgcn.s.sleep"] + safe fn llvm_s_sleep(count: u32); + + #[link_name = "llvm.amdgcn.s.sethalt"] + safe fn llvm_s_sethalt(value: u32) -> !; + + #[link_name = "llvm.amdgcn.s.getpc"] + safe fn llvm_s_getpc() -> i64; + + #[link_name = "llvm.amdgcn.mbcnt.lo"] + safe fn llvm_mbcnt_lo(value: u32, init: u32) -> u32; + #[link_name = "llvm.amdgcn.mbcnt.hi"] + safe fn llvm_mbcnt_hi(value: u32, init: u32) -> u32; + + #[link_name = "llvm.amdgcn.ballot"] + safe fn llvm_ballot(b: bool) -> u64; + + #[link_name = "llvm.amdgcn.inverse.ballot"] + safe fn llvm_inverse_ballot(value: u64) -> bool; + + #[link_name = "llvm.amdgcn.wave.reduce.umin"] + safe fn llvm_wave_reduce_umin(value: u32, strategy: u32) -> u32; + #[link_name = "llvm.amdgcn.wave.reduce.min"] + safe fn llvm_wave_reduce_min(value: i32, strategy: u32) -> i32; + #[link_name = "llvm.amdgcn.wave.reduce.umax"] + safe fn llvm_wave_reduce_umax(value: u32, strategy: u32) -> u32; + #[link_name = "llvm.amdgcn.wave.reduce.max"] + safe fn llvm_wave_reduce_max(value: i32, strategy: u32) -> i32; + #[link_name = "llvm.amdgcn.wave.reduce.add"] + safe fn llvm_wave_reduce_add(value: u32, strategy: u32) -> u32; + #[link_name = "llvm.amdgcn.wave.reduce.and"] + safe fn llvm_wave_reduce_and(value: u32, strategy: u32) -> u32; + #[link_name = "llvm.amdgcn.wave.reduce.or"] + safe fn llvm_wave_reduce_or(value: u32, strategy: u32) -> u32; + #[link_name = "llvm.amdgcn.wave.reduce.xor"] + safe fn llvm_wave_reduce_xor(value: u32, strategy: u32) -> u32; + + // The following intrinsics can have multiple sizes + + #[link_name = "llvm.amdgcn.readfirstlane.i32"] + safe fn llvm_readfirstlane_u32(value: u32) -> u32; + #[link_name = "llvm.amdgcn.readfirstlane.i64"] + safe fn llvm_readfirstlane_u64(value: u64) -> u64; + #[link_name = "llvm.amdgcn.readlane.i32"] + fn llvm_readlane_u32(value: u32, lane: u32) -> u32; + #[link_name = "llvm.amdgcn.readlane.i64"] + fn llvm_readlane_u64(value: u64, lane: u32) -> u64; + #[link_name = "llvm.amdgcn.writelane.i32"] + fn llvm_writelane_u32(value: u32, lane: u32, default: u32) -> u32; + #[link_name = "llvm.amdgcn.writelane.i64"] + fn llvm_writelane_u64(value: u64, lane: u32, default: u64) -> u64; + + #[link_name = "llvm.amdgcn.endpgm"] + safe fn llvm_endpgm() -> !; + + #[link_name = "llvm.amdgcn.update.dpp.i32"] + fn llvm_update_dpp( + old: u32, + src: u32, + dpp_ctrl: u32, + row_mask: u32, + bank_mask: u32, + bound_control: bool, + ) -> u32; + + #[link_name = "llvm.amdgcn.s.memrealtime"] + safe fn llvm_s_memrealtime() -> u64; + + #[link_name = "llvm.amdgcn.ds.permute"] + fn llvm_ds_permute(lane: u32, value: u32) -> u32; + #[link_name = "llvm.amdgcn.ds.bpermute"] + fn llvm_ds_bpermute(lane: u32, value: u32) -> u32; + #[link_name = "llvm.amdgcn.perm"] + fn llvm_perm(src0: u32, src1: u32, selector: u32) -> u32; + + // gfx10 + #[link_name = "llvm.amdgcn.permlane16.i32"] + fn llvm_permlane16_u32( + old: u32, + src0: u32, + src1: u32, + src2: u32, + fi: bool, + bound_control: bool, + ) -> u32; + + // gfx10 + #[link_name = "llvm.amdgcn.permlanex16.i32"] + fn llvm_permlanex16_u32( + old: u32, + src0: u32, + src1: u32, + src2: u32, + fi: bool, + bound_control: bool, + ) -> u32; + + #[link_name = "llvm.amdgcn.s.get.waveid.in.workgroup"] + safe fn llvm_s_get_waveid_in_workgroup() -> u32; + + // gfx11 + #[link_name = "llvm.amdgcn.permlane64.i32"] + fn llvm_permlane64_u32(value: u32) -> u32; + + // gfx12 + #[link_name = "llvm.amdgcn.permlane16.var"] + fn llvm_permlane16_var(old: u32, src0: u32, src1: u32, fi: bool, bound_control: bool) -> u32; + + // gfx12 + #[link_name = "llvm.amdgcn.permlanex16.var"] + fn llvm_permlanex16_var(old: u32, src0: u32, src1: u32, fi: bool, bound_control: bool) -> u32; + + #[link_name = "llvm.amdgcn.wave.id"] + safe fn llvm_wave_id() -> u32; + + // gfx950 + #[link_name = "llvm.amdgcn.permlane16.swap"] + fn llvm_permlane16_swap( + vdst_old: u32, + vsrc_src0: u32, + fi: bool, + bound_control: bool, + ) -> (u32, u32); + + // gfx950 + #[link_name = "llvm.amdgcn.permlane32.swap"] + fn llvm_permlane32_swap( + vdst_old: u32, + vsrc_src0: u32, + fi: bool, + bound_control: bool, + ) -> (u32, u32); +} + +/// Returns the x coordinate of the workitem index within the workgroup. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn workitem_id_x() -> u32 { + llvm_workitem_id_x() +} +/// Returns the y coordinate of the workitem index within the workgroup. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn workitem_id_y() -> u32 { + llvm_workitem_id_y() +} +/// Returns the z coordinate of the workitem index within the workgroup. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn workitem_id_z() -> u32 { + llvm_workitem_id_z() +} + +/// Returns the x coordinate of the workgroup index within the dispatch. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn workgroup_id_x() -> u32 { + llvm_workgroup_id_x() +} +/// Returns the y coordinate of the workgroup index within the dispatch. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn workgroup_id_y() -> u32 { + llvm_workgroup_id_y() +} +/// Returns the z coordinate of the workgroup index within the dispatch. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn workgroup_id_z() -> u32 { + llvm_workgroup_id_z() +} + +/// Returns the size of statically allocated shared memory for this program in bytes. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn groupstaticsize() -> u32 { + llvm_groupstaticsize() +} +/// Returns the id of the dispatch that is currently executed. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn dispatch_id() -> u64 { + llvm_dispatch_id() +} + +/// Returns the number of threads in a wavefront. +/// +/// Is always a power of 2. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wavefrontsize() -> u32 { + llvm_wavefrontsize() +} + +/// Synchronize all wavefronts in a workgroup. +/// +/// Each wavefronts in a workgroup waits at the barrier until all wavefronts in the workgroup arrive at a barrier. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn s_barrier() { + llvm_s_barrier() +} + +/// Signal a specific barrier type. +/// +/// Only for non-named barriers. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn s_barrier_signal() { + unsafe { llvm_s_barrier_signal(BARRIER_TYPE) } +} + +/// Signal a specific barrier type. +/// +/// Only for non-named barriers. +/// Provides access to the s_barrier_signal_first instruction; +/// additionally ensures that the result value is valid even when +/// the intrinsic is used from a wavefront that is not running in a workgroup. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn s_barrier_signal_isfirst() -> bool { + unsafe { llvm_s_barrier_signal_isfirst(BARRIER_TYPE) } +} + +/// Wait for a specific barrier type. +/// +/// Only for non-named barriers. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn s_barrier_wait() { + unsafe { llvm_s_barrier_wait(BARRIER_TYPE) } +} + +/// Get the state of a specific barrier type. +/// +/// The `barrier_type` argument must be uniform, otherwise behavior is undefined. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn s_get_barrier_state() -> u32 { + unsafe { llvm_s_get_barrier_state(BARRIER_TYPE) } +} + +/// A barrier for only the threads within the current wavefront. +/// +/// Does not result in an instruction but restricts the compiler. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_barrier() { + llvm_wave_barrier() +} + +/// Prevent movement of some instruction types. +/// +/// Controls the types of instructions that may be allowed to cross the intrinsic during instruction scheduling. +/// The parameter is a mask for the instruction types that can cross the intrinsic. +/// +/// - 0x0000: No instructions may be scheduled across `sched_barrier`. +/// - 0x0001: All, non-memory, non-side-effect producing instructions may be scheduled across `sched_barrier`, i.e. allow ALU instructions to pass. +/// - 0x0002: VALU instructions may be scheduled across `sched_barrier`. +/// - 0x0004: SALU instructions may be scheduled across `sched_barrier`. +/// - 0x0008: MFMA/WMMA instructions may be scheduled across `sched_barrier`. +/// - 0x0010: All VMEM instructions may be scheduled across `sched_barrier`. +/// - 0x0020: VMEM read instructions may be scheduled across `sched_barrier`. +/// - 0x0040: VMEM write instructions may be scheduled across `sched_barrier`. +/// - 0x0080: All DS instructions may be scheduled across `sched_barrier`. +/// - 0x0100: All DS read instructions may be scheduled across `sched_barrier`. +/// - 0x0200: All DS write instructions may be scheduled across `sched_barrier`. +/// - 0x0400: All Transcendental (e.g. V_EXP) instructions may be scheduled across `sched_barrier`. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn sched_barrier() { + static_assert_uimm_bits!(MASK, 11); + unsafe { llvm_sched_barrier(MASK) } +} + +/// Creates schedule groups with specific properties to create custom scheduling pipelines. +/// +/// The ordering between groups is enforced by the instruction scheduler. +/// The intrinsic applies to the code that precedes the intrinsic. +/// The intrinsic takes three values that control the behavior of the schedule groups. +/// +/// - `mask`: Classify instruction groups using the [`sched_barrier`] mask values. +/// - `size`: The number of instructions that are in the group. +/// - `sync_id`: Order is enforced between groups with matching values. +/// +/// The mask can include multiple instruction types. It is undefined behavior to set values beyond the range of valid masks. +/// +/// Combining multiple `sched_group_barrier` intrinsics enables an ordering of specific instruction types during instruction scheduling. +/// For example, the following enforces a sequence of 1 VMEM read, followed by 1 VALU instruction, followed by 5 MFMA instructions. +/// +/// ```rust +/// // 1 VMEM read +/// sched_group_barrier::<32, 1, 0>() +/// // 1 VALU +/// sched_group_barrier::<2, 1, 0>() +/// // 5 MFMA +/// sched_group_barrier::<8, 5, 0>() +/// ``` +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn sched_group_barrier() { + static_assert_uimm_bits!(MASK, 11); + unsafe { llvm_sched_group_barrier(MASK, SIZE, SYNC_ID) } +} + +/// Sleeps for approximately `COUNT * 64` cycles. +/// +/// `COUNT` must be a constant. +/// Only the lower 7 bits of `COUNT` are used. +/// If `COUNT == 0x8000`, sleep forever until woken up, or killed. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn s_sleep() { + llvm_s_sleep(COUNT) +} + +/// Stop execution of the kernel. +/// +/// This usually signals an error state. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn s_sethalt() -> ! { + static_assert_uimm_bits!(VALUE, 3); + llvm_s_sethalt(VALUE) +} + +/// Returns the current process counter. +/// +/// Provides access to the s_getpc_b64 instruction, but with the return value sign-extended +/// from the width of the underlying PC hardware register even on processors where the +/// s_getpc_b64 instruction returns a zero-extended value. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn s_getpc() -> i64 { + llvm_s_getpc() +} + +/// Masked bit count, low 32 lanes. +/// +/// Computes the number of bits set in `value`, masked with a thread mask +/// which contains 1 for all active threads less than the current thread within a wavefront. +/// `init` is added to the result. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn mbcnt_lo(value: u32, init: u32) -> u32 { + llvm_mbcnt_lo(value, init) +} +/// Masked bit count, high 32 lanes. +/// +/// Computes the number of bits set in `value`, masked with a thread mask +/// which contains 1 for all active threads less than the current thread within a wavefront. +/// `init` is added to the result. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn mbcnt_hi(value: u32, init: u32) -> u32 { + llvm_mbcnt_hi(value, init) +} + +/// Returns a bitfield (`u32` or `u64`) containing the result of its i1 argument +/// in all active lanes, and zero in all inactive lanes. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn ballot(b: bool) -> u64 { + llvm_ballot(b) +} + +/// Indexes into the `value` with the current lane id and returns for each lane +/// if the corresponding bit is set. +/// +/// While [`ballot`] converts a `bool` to a mask, `inverse_ballot` converts a mask back to a `bool`. +/// This means `inverse_ballot(ballot(b)) == b`. +/// The inverse of `ballot(inverse_ballot(value)) ~= value` is not always true as inactive lanes are set to zero by `ballot`. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn inverse_ballot(value: u64) -> bool { + llvm_inverse_ballot(value) +} + +/// Performs an arithmetic min reduction on the unsigned values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_umin(value: u32) -> u32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_umin(value, STRATEGY) +} +/// Performs an arithmetic min reduction on the signed values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_min(value: i32) -> i32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_min(value, STRATEGY) +} + +/// Performs an arithmetic max reduction on the unsigned values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_umax(value: u32) -> u32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_umax(value, STRATEGY) +} +/// Performs an arithmetic max reduction on the signed values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_max(value: i32) -> i32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_max(value, STRATEGY) +} + +/// Performs an arithmetic add reduction on the values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_add(value: u32) -> u32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_add(value, STRATEGY) +} + +/// Performs a logical and reduction on the unsigned values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_and(value: u32) -> u32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_and(value, STRATEGY) +} +/// Performs a logical or reduction on the unsigned values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_or(value: u32) -> u32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_or(value, STRATEGY) +} +/// Performs a logical xor reduction on the unsigned values provided by each lane in the wavefront. +/// +/// The `STRATEGY` argument is a hint for the reduction strategy. +/// - 0: Target default preference +/// - 1: Iterative strategy +/// - 2: DPP +/// +/// If target does not support the DPP operations (e.g. gfx6/7), reduction will be performed using default iterative strategy. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_reduce_xor(value: u32) -> u32 { + static_assert!(STRATEGY <= 2); + llvm_wave_reduce_xor(value, STRATEGY) +} + +// The following intrinsics can have multiple sizes + +/// Get `value` from the first active lane in the wavefront. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn readfirstlane_u32(value: u32) -> u32 { + llvm_readfirstlane_u32(value) +} +/// Get `value` from the first active lane in the wavefront. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn readfirstlane_u64(value: u64) -> u64 { + llvm_readfirstlane_u64(value) +} +/// Get `value` from the lane at index `lane` in the wavefront. +/// +/// The lane argument must be uniform across the currently active threads +/// of the current wavefront. Otherwise, the result is undefined. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn readlane_u32(value: u32, lane: u32) -> u32 { + unsafe { llvm_readlane_u32(value, lane) } +} +/// Get `value` from the lane at index `lane` in the wavefront. +/// +/// The lane argument must be uniform across the currently active threads +/// of the current wavefront. Otherwise, the result is undefined. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn readlane_u64(value: u64, lane: u32) -> u64 { + unsafe { llvm_readlane_u64(value, lane) } +} +/// Return `value` for the lane at index `lane` in the wavefront. +/// Return `default` for all other lanes. +/// +/// The value to write and lane select arguments must be uniform across the +/// currently active threads of the current wavefront. Otherwise, the result is +/// undefined. +/// +/// `value` is the value returned by `lane`. +/// `default` is the value returned by all lanes other than `lane`. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn writelane_u32(value: u32, lane: u32, default: u32) -> u32 { + unsafe { llvm_writelane_u32(value, lane, default) } +} +/// Return `value` for the lane at index `lane` in the wavefront. +/// Return `default` for all other lanes. +/// +/// The value to write and lane select arguments must be uniform across the +/// currently active threads of the current wavefront. Otherwise, the result is +/// undefined. +/// +/// `value` is the value returned by `lane`. +/// `default` is the value returned by all lanes other than `lane`. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn writelane_u64(value: u64, lane: u32, default: u64) -> u64 { + unsafe { llvm_writelane_u64(value, lane, default) } +} + +/// Stop execution of the wavefront. +/// +/// This usually signals the end of a successful execution. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn endpgm() -> ! { + llvm_endpgm() +} + +/// The `update_dpp` intrinsic represents the `update.dpp` operation in AMDGPU. +/// It takes an old value, a source operand, a DPP control operand, a row mask, a bank mask, and a bound control. +/// This operation is equivalent to a sequence of `v_mov_b32` operations. +/// +/// `llvm.amdgcn.update.dpp.i32 ` +/// Should be equivalent to: +/// ```asm +/// v_mov_b32 +/// v_mov_b32 +/// ``` +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn update_dpp< + const DPP_CTRL: u32, + const ROW_MASK: u32, + const BANK_MASK: u32, + const BOUND_CONTROL: bool, +>( + old: u32, + src: u32, +) -> u32 { + unsafe { llvm_update_dpp(old, src, DPP_CTRL, ROW_MASK, BANK_MASK, BOUND_CONTROL) } +} + +/// Measures time based on a fixed frequency. +/// +/// Provides a real-time clock counter that runs at constant speed (typically 100 MHz) independent of ALU clock speeds. +/// The clock is consistent across the chip, so can be used for measuring between different wavefronts. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn s_memrealtime() -> u64 { + llvm_s_memrealtime() +} + +/// Scatter data across all lanes in a wavefront. +/// +/// Writes `value` to the lane `lane`. +/// +/// Reading from inactive lanes returns `0`. +/// In case multiple values get written to the same `lane`, the value from the source lane with the higher index is taken. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn ds_permute(lane: u32, value: u32) -> u32 { + unsafe { llvm_ds_permute(lane, value) } +} +/// Gather data across all lanes in a wavefront. +/// +/// Returns the `value` given to `ds_permute` by lane `lane`. +/// +/// Reading from inactive lanes returns `0`. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn ds_bpermute(lane: u32, value: u32) -> u32 { + unsafe { llvm_ds_bpermute(lane, value) } +} +/// Permute a 64-bit value. +/// +/// `selector` selects between different patterns in which the 64-bit values represented by `src0` and `src1` are permuted. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn perm(src0: u32, src1: u32, selector: u32) -> u32 { + unsafe { llvm_perm(src0, src1, selector) } +} + +// gfx10 +/// Performs arbitrary gather-style operation within a row (16 contiguous lanes) of the second input operand. +/// +/// The third and fourth inputs must be uniform across the current wavefront. +/// These are combined into a single 64-bit value representing lane selects used to swizzle within each row. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlane16_u32( + old: u32, + src0: u32, + src1: u32, + src2: u32, +) -> u32 { + unsafe { llvm_permlane16_u32(old, src0, src1, src2, FI, BOUND_CONTROL) } +} + +// gfx10 +/// Performs arbitrary gather-style operation across two rows (16 contiguous lanes) of the second input operand. +/// +/// The third and fourth inputs must be uniform across the current wavefront. +/// These are combined into a single 64-bit value representing lane selects used to swizzle within each row. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlanex16_u32( + old: u32, + src0: u32, + src1: u32, + src2: u32, +) -> u32 { + unsafe { llvm_permlanex16_u32(old, src0, src1, src2, FI, BOUND_CONTROL) } +} + +/// Get the index of the current wavefront in the workgroup. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn s_get_waveid_in_workgroup() -> u32 { + llvm_s_get_waveid_in_workgroup() +} + +// gfx11 +/// Swap `value` between upper and lower 32 lanes in a wavefront. +/// +/// Does nothing for wave32. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlane64_u32(value: u32) -> u32 { + unsafe { llvm_permlane64_u32(value) } +} + +// gfx12 +/// Performs arbitrary gather-style operation within a row (16 contiguous lanes) of the second input operand. +/// +/// In contrast to [`permlane16_u32`], allows each lane to specify its own gather lane. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlane16_var( + old: u32, + src0: u32, + src1: u32, +) -> u32 { + unsafe { llvm_permlane16_var(old, src0, src1, FI, BOUND_CONTROL) } +} + +// gfx12 +/// Performs arbitrary gather-style operation across two rows (16 contiguous lanes) of the second input operand. +/// +/// In contrast to [`permlanex16_u32`], allows each lane to specify its own gather lane. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlanex16_var( + old: u32, + src0: u32, + src1: u32, +) -> u32 { + unsafe { llvm_permlanex16_var(old, src0, src1, FI, BOUND_CONTROL) } +} + +/// Get the index of the current wavefront in the workgroup. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub fn wave_id() -> u32 { + llvm_wave_id() +} + +// gfx950 +/// Provide direct access to `v_permlane16_swap_b32` instruction on supported targets. +/// +/// Swaps the values across lanes of first 2 operands. +/// Odd rows of the first operand are swapped with even rows of the second operand (one row is 16 lanes). +/// Returns a pair for the swapped registers. +/// The first element of the return corresponds to the swapped element of the first argument. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlane16_swap( + vdst_old: u32, + vsrc_src0: u32, +) -> (u32, u32) { + unsafe { llvm_permlane16_swap(vdst_old, vsrc_src0, FI, BOUND_CONTROL) } +} + +// gfx950 +/// Provide direct access to `v_permlane32_swap_b32` instruction on supported targets. +/// +/// Swaps the values across lanes of first 2 operands. +/// Rows 2 and 3 of the first operand are swapped with rows 0 and 1 of the second operand (one row is 16 lanes). +/// Returns a pair for the swapped registers. +/// The first element of the return corresponds to the swapped element of the first argument. +#[inline] +#[unstable(feature = "stdarch_amdgpu", issue = "149988")] +pub unsafe fn permlane32_swap( + vdst_old: u32, + vsrc_src0: u32, +) -> (u32, u32) { + unsafe { llvm_permlane32_swap(vdst_old, vsrc_src0, FI, BOUND_CONTROL) } +} + +// Functions to generate code, used to check that the intrinsics build. +// Marked as no_mangle, so the compiler does not remove the functions. +// To test, uncomment the `#[cfg(test)]` line below and run +// NORUN=1 NOSTD=1 TARGET=amdgcn-amd-amdhsa CARGO_UNSTABLE_BUILD_STD=core ci/run.sh +// +// Note that depending on the target-cpu set in run.sh, some of these intrinsics are not available +// and compilation fails with `Cannot select: intrinsic %llvm.amdgcn...`. +// Uncomment these intrinsics to check. +#[cfg(test)] +mod tests { + use super::*; + + #[unsafe(no_mangle)] + fn test_workitem_id_x() -> u32 { + workitem_id_x() + } + #[unsafe(no_mangle)] + fn test_workitem_id_y() -> u32 { + workitem_id_y() + } + #[unsafe(no_mangle)] + fn test_workitem_id_z() -> u32 { + workitem_id_z() + } + + #[unsafe(no_mangle)] + fn test_workgroup_id_x() -> u32 { + workgroup_id_x() + } + #[unsafe(no_mangle)] + fn test_workgroup_id_y() -> u32 { + workgroup_id_y() + } + #[unsafe(no_mangle)] + fn test_workgroup_id_z() -> u32 { + workgroup_id_z() + } + + #[unsafe(no_mangle)] + fn test_groupstaticsize() -> u32 { + groupstaticsize() + } + #[unsafe(no_mangle)] + fn test_dispatch_id() -> u64 { + dispatch_id() + } + + #[unsafe(no_mangle)] + fn test_wavefrontsize() -> u32 { + wavefrontsize() + } + + #[unsafe(no_mangle)] + fn test_s_barrier() { + s_barrier() + } + + #[unsafe(no_mangle)] + fn test_s_barrier_signal() { + unsafe { s_barrier_signal::<-1>() } + } + + #[unsafe(no_mangle)] + fn test_s_barrier_signal_isfirst() -> bool { + unsafe { s_barrier_signal_isfirst::<-1>() } + } + + #[unsafe(no_mangle)] + fn test_s_barrier_wait() { + unsafe { s_barrier_wait::<-1>() } + } + + #[unsafe(no_mangle)] + fn test_s_get_barrier_state() -> u32 { + unsafe { s_get_barrier_state::<-1>() } + } + + #[unsafe(no_mangle)] + fn test_wave_barrier() { + wave_barrier() + } + + #[unsafe(no_mangle)] + fn test_sched_barrier() { + unsafe { sched_barrier::<1>() } + } + + #[unsafe(no_mangle)] + fn test_sched_group_barrier() { + unsafe { sched_group_barrier::<1, 1, 0>() } + } + + #[unsafe(no_mangle)] + fn test_s_sleep() { + s_sleep::<1>() + } + + #[unsafe(no_mangle)] + fn test_s_sethalt() -> ! { + s_sethalt::<1>() + } + + #[unsafe(no_mangle)] + fn test_s_getpc() -> i64 { + s_getpc() + } + + #[unsafe(no_mangle)] + fn test_mbcnt_lo(value: u32, init: u32) -> u32 { + mbcnt_lo(value, init) + } + #[unsafe(no_mangle)] + fn test_mbcnt_hi(value: u32, init: u32) -> u32 { + mbcnt_hi(value, init) + } + + #[unsafe(no_mangle)] + fn test_ballot(b: bool) -> u64 { + ballot(b) + } + + #[unsafe(no_mangle)] + fn test_inverse_ballot(value: u64) -> bool { + inverse_ballot(value) + } + + #[unsafe(no_mangle)] + fn test_wave_reduce_umin(value: u32) -> u32 { + wave_reduce_umin::<0>(value) + } + #[unsafe(no_mangle)] + fn test_wave_reduce_min(value: i32) -> i32 { + wave_reduce_min::<0>(value) + } + + #[unsafe(no_mangle)] + fn test_wave_reduce_umax(value: u32) -> u32 { + wave_reduce_umax::<0>(value) + } + #[unsafe(no_mangle)] + fn test_wave_reduce_max(value: i32) -> i32 { + wave_reduce_max::<0>(value) + } + + #[unsafe(no_mangle)] + fn test_wave_reduce_add(value: u32) -> u32 { + wave_reduce_add::<0>(value) + } + + #[unsafe(no_mangle)] + fn test_wave_reduce_and(value: u32) -> u32 { + wave_reduce_and::<0>(value) + } + #[unsafe(no_mangle)] + fn test_wave_reduce_or(value: u32) -> u32 { + wave_reduce_or::<0>(value) + } + #[unsafe(no_mangle)] + fn test_wave_reduce_xor(value: u32) -> u32 { + wave_reduce_xor::<0>(value) + } + + #[unsafe(no_mangle)] + fn test_readfirstlane_u32(value: u32) -> u32 { + readfirstlane_u32(value) + } + #[unsafe(no_mangle)] + fn test_readfirstlane_u64(value: u64) -> u64 { + readfirstlane_u64(value) + } + #[unsafe(no_mangle)] + fn test_readlane_u32(value: u32, lane: u32) -> u32 { + unsafe { readlane_u32(value, lane) } + } + #[unsafe(no_mangle)] + fn test_readlane_u64(value: u64, lane: u32) -> u64 { + unsafe { readlane_u64(value, lane) } + } + #[unsafe(no_mangle)] + fn test_writelane_u32(value: u32, lane: u32, default: u32) -> u32 { + unsafe { writelane_u32(value, lane, default) } + } + #[unsafe(no_mangle)] + fn test_writelane_u64(value: u64, lane: u32, default: u64) -> u64 { + unsafe { writelane_u64(value, lane, default) } + } + + #[unsafe(no_mangle)] + fn test_endpgm() -> ! { + endpgm() + } + + #[unsafe(no_mangle)] + fn test_update_dpp(old: u32, src: u32) -> u32 { + unsafe { update_dpp::<0, 0, 0, true>(old, src) } + } + + #[unsafe(no_mangle)] + fn test_s_memrealtime() -> u64 { + s_memrealtime() + } + + #[unsafe(no_mangle)] + fn test_ds_permute(lane: u32, value: u32) -> u32 { + unsafe { ds_permute(lane, value) } + } + #[unsafe(no_mangle)] + fn test_ds_bpermute(lane: u32, value: u32) -> u32 { + unsafe { ds_bpermute(lane, value) } + } + #[unsafe(no_mangle)] + fn test_perm(src0: u32, src1: u32, selector: u32) -> u32 { + unsafe { perm(src0, src1, selector) } + } + + #[unsafe(no_mangle)] + fn test_permlane16_u32(old: u32, src0: u32, src1: u32, src2: u32) -> u32 { + unsafe { permlane16_u32::(old, src0, src1, src2) } + } + + #[unsafe(no_mangle)] + fn test_permlanex16_u32(old: u32, src0: u32, src1: u32, src2: u32) -> u32 { + unsafe { permlanex16_u32::(old, src0, src1, src2) } + } + + #[unsafe(no_mangle)] + fn test_s_get_waveid_in_workgroup() -> u32 { + s_get_waveid_in_workgroup() + } + + #[unsafe(no_mangle)] + fn test_permlane64_u32(value: u32) -> u32 { + unsafe { permlane64_u32(value) } + } + + #[unsafe(no_mangle)] + fn test_permlane16_var(old: u32, src0: u32, src1: u32) -> u32 { + unsafe { permlane16_var::(old, src0, src1) } + } + + #[unsafe(no_mangle)] + fn test_permlanex16_var(old: u32, src0: u32, src1: u32) -> u32 { + unsafe { permlanex16_var::(old, src0, src1) } + } + + #[unsafe(no_mangle)] + fn test_wave_id() -> u32 { + wave_id() + } + + #[unsafe(no_mangle)] + fn test_permlane16_swap(vdst_old: u32, vsrc_src0: u32) -> (u32, u32) { + unsafe { permlane16_swap::(vdst_old, vsrc_src0) } + } + + #[unsafe(no_mangle)] + fn test_permlane32_swap(vdst_old: u32, vsrc_src0: u32) -> (u32, u32) { + unsafe { permlane32_swap::(vdst_old, vsrc_src0) } + } +} diff --git a/library/stdarch/crates/core_arch/src/core_arch_docs.md b/library/stdarch/crates/core_arch/src/core_arch_docs.md index 6aea2b461846..707594575497 100644 --- a/library/stdarch/crates/core_arch/src/core_arch_docs.md +++ b/library/stdarch/crates/core_arch/src/core_arch_docs.md @@ -185,6 +185,7 @@ others at: * [`x86_64`] * [`arm`] * [`aarch64`] +* [`amdgpu`] * [`riscv32`] * [`riscv64`] * [`mips`] @@ -201,6 +202,7 @@ others at: [`x86_64`]: ../../core/arch/x86_64/index.html [`arm`]: ../../core/arch/arm/index.html [`aarch64`]: ../../core/arch/aarch64/index.html +[`amdgpu`]: ../../core/arch/amdgpu/index.html [`riscv32`]: ../../core/arch/riscv32/index.html [`riscv64`]: ../../core/arch/riscv64/index.html [`mips`]: ../../core/arch/mips/index.html diff --git a/library/stdarch/crates/core_arch/src/mod.rs b/library/stdarch/crates/core_arch/src/mod.rs index 2105cca1b438..fbb8562d318e 100644 --- a/library/stdarch/crates/core_arch/src/mod.rs +++ b/library/stdarch/crates/core_arch/src/mod.rs @@ -274,6 +274,16 @@ pub mod arch { pub use crate::core_arch::nvptx::*; } + /// Platform-specific intrinsics for the `amdgpu` platform. + /// + /// See the [module documentation](../index.html) for more details. + #[cfg(any(target_arch = "amdgpu", doc))] + #[doc(cfg(target_arch = "amdgpu"))] + #[unstable(feature = "stdarch_amdgpu", issue = "149988")] + pub mod amdgpu { + pub use crate::core_arch::amdgpu::*; + } + /// Platform-specific intrinsics for the `loongarch32` platform. /// /// See the [module documentation](../index.html) for more details. @@ -349,6 +359,10 @@ mod powerpc64; #[doc(cfg(target_arch = "nvptx64"))] mod nvptx; +#[cfg(any(target_arch = "amdgpu", doc))] +#[doc(cfg(target_arch = "amdgpu"))] +mod amdgpu; + #[cfg(any(target_arch = "loongarch32", doc))] #[doc(cfg(target_arch = "loongarch32"))] mod loongarch32; From 675fd681aa19cc45d27051416db847438efd0f76 Mon Sep 17 00:00:00 2001 From: irelaxcn Date: Fri, 19 Dec 2025 01:17:16 +0800 Subject: [PATCH 331/489] Fix `println_empty_string` suggestion caused error when there is a `,` after arg. Make `writeln_empty_string` don't provide an auto-fix suggestion when there is a comment in the macro call span. --- clippy_lints/src/write/empty_string.rs | 42 +++++---- tests/ui/crashes/ice-10148.stderr | 2 +- tests/ui/println_empty_string.fixed | 20 +++++ tests/ui/println_empty_string.rs | 24 ++++++ tests/ui/println_empty_string.stderr | 39 ++++++++- tests/ui/println_empty_string_unfixable.rs | 30 +++++++ .../ui/println_empty_string_unfixable.stderr | 85 +++++++++++++++++++ tests/ui/writeln_empty_string_unfixable.rs | 26 ++++++ .../ui/writeln_empty_string_unfixable.stderr | 47 ++++++++++ 9 files changed, 295 insertions(+), 20 deletions(-) create mode 100644 tests/ui/println_empty_string_unfixable.rs create mode 100644 tests/ui/println_empty_string_unfixable.stderr create mode 100644 tests/ui/writeln_empty_string_unfixable.rs create mode 100644 tests/ui/writeln_empty_string_unfixable.stderr diff --git a/clippy_lints/src/write/empty_string.rs b/clippy_lints/src/write/empty_string.rs index e7eb99eb34ec..1291f2489a21 100644 --- a/clippy_lints/src/write/empty_string.rs +++ b/clippy_lints/src/write/empty_string.rs @@ -1,37 +1,43 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::macros::MacroCall; use clippy_utils::source::expand_past_previous_comma; -use clippy_utils::sym; +use clippy_utils::{span_extract_comments, sym}; use rustc_ast::{FormatArgs, FormatArgsPiece}; use rustc_errors::Applicability; -use rustc_lint::LateContext; +use rustc_lint::{LateContext, LintContext}; use super::{PRINTLN_EMPTY_STRING, WRITELN_EMPTY_STRING}; pub(super) fn check(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call: &MacroCall, name: &str) { if let [FormatArgsPiece::Literal(sym::LF)] = &format_args.template[..] { - let mut span = format_args.span; - - let lint = if name == "writeln" { - span = expand_past_previous_comma(cx, span); - - WRITELN_EMPTY_STRING - } else { - PRINTLN_EMPTY_STRING - }; + let is_writeln = name == "writeln"; span_lint_and_then( cx, - lint, + if is_writeln { + WRITELN_EMPTY_STRING + } else { + PRINTLN_EMPTY_STRING + }, macro_call.span, format!("empty string literal in `{name}!`"), |diag| { - diag.span_suggestion( - span, - "remove the empty string", - String::new(), - Applicability::MachineApplicable, - ); + if span_extract_comments(cx.sess().source_map(), macro_call.span).is_empty() { + let closing_paren = cx.sess().source_map().span_extend_to_prev_char_before( + macro_call.span.shrink_to_hi(), + ')', + false, + ); + let mut span = format_args.span.with_hi(closing_paren.lo()); + if is_writeln { + span = expand_past_previous_comma(cx, span); + } + + diag.span_suggestion(span, "remove the empty string", "", Applicability::MachineApplicable); + } else { + // If there is a comment in the span of macro call, we don't provide an auto-fix suggestion. + diag.span_note(format_args.span, "remove the empty string"); + } }, ); } diff --git a/tests/ui/crashes/ice-10148.stderr b/tests/ui/crashes/ice-10148.stderr index 639cf2dd442b..e91fb3778a31 100644 --- a/tests/ui/crashes/ice-10148.stderr +++ b/tests/ui/crashes/ice-10148.stderr @@ -2,7 +2,7 @@ error: empty string literal in `println!` --> tests/ui/crashes/ice-10148.rs:8:5 | LL | println!(with_span!(""something "")); - | ^^^^^^^^^^^^^^^^^^^^-----------^^^^^ + | ^^^^^^^^^^^^^^^^^^^^---------------^ | | | help: remove the empty string | diff --git a/tests/ui/println_empty_string.fixed b/tests/ui/println_empty_string.fixed index 05e262ec7786..6b1039ee8020 100644 --- a/tests/ui/println_empty_string.fixed +++ b/tests/ui/println_empty_string.fixed @@ -19,3 +19,23 @@ fn main() { //~^ println_empty_string } } + +#[rustfmt::skip] +fn issue_16167() { + //~v println_empty_string + println!( + ); + + match "a" { + _ => println!(), // there is a space between "" and comma + //~^ println_empty_string + } + + eprintln!(); // there is a tab between "" and comma + //~^ println_empty_string + + match "a" { + _ => eprintln!(), // tab and space between "" and comma + //~^ println_empty_string + } +} diff --git a/tests/ui/println_empty_string.rs b/tests/ui/println_empty_string.rs index 028ddb60dbce..db3b8e1a0eac 100644 --- a/tests/ui/println_empty_string.rs +++ b/tests/ui/println_empty_string.rs @@ -19,3 +19,27 @@ fn main() { //~^ println_empty_string } } + +#[rustfmt::skip] +fn issue_16167() { + //~v println_empty_string + println!( + "\ + \ + " + , + ); + + match "a" { + _ => println!("" ,), // there is a space between "" and comma + //~^ println_empty_string + } + + eprintln!("" ,); // there is a tab between "" and comma + //~^ println_empty_string + + match "a" { + _ => eprintln!("" ,), // tab and space between "" and comma + //~^ println_empty_string + } +} diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index 8b997aef9069..bdac1bb3b8ef 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -33,5 +33,42 @@ LL | _ => eprintln!(""), | | | help: remove the empty string -error: aborting due to 4 previous errors +error: empty string literal in `println!` + --> tests/ui/println_empty_string.rs:26:5 + | +LL | / println!( +LL | |/ "\ +LL | || \ +LL | || " +LL | || , +LL | || ); + | ||____-^ + | |____| + | help: remove the empty string + +error: empty string literal in `println!` + --> tests/ui/println_empty_string.rs:34:14 + | +LL | _ => println!("" ,), // there is a space between "" and comma + | ^^^^^^^^^----^ + | | + | help: remove the empty string + +error: empty string literal in `eprintln!` + --> tests/ui/println_empty_string.rs:38:5 + | +LL | eprintln!("" ,); // there is a tab between "" and comma + | ^^^^^^^^^^-------^ + | | + | help: remove the empty string + +error: empty string literal in `eprintln!` + --> tests/ui/println_empty_string.rs:42:14 + | +LL | _ => eprintln!("" ,), // tab and space between "" and comma + | ^^^^^^^^^^--------^ + | | + | help: remove the empty string + +error: aborting due to 8 previous errors diff --git a/tests/ui/println_empty_string_unfixable.rs b/tests/ui/println_empty_string_unfixable.rs new file mode 100644 index 000000000000..d6c30f627a58 --- /dev/null +++ b/tests/ui/println_empty_string_unfixable.rs @@ -0,0 +1,30 @@ +#![allow(clippy::match_single_binding)] + +// If there is a comment in the span of macro call, we don't provide an auto-fix suggestion. +#[rustfmt::skip] +fn issue_16167() { + //~v println_empty_string + println!("" /* comment */); + //~v println_empty_string + eprintln!("" /* comment */); + + //~v println_empty_string + println!( // comment + ""); + //~v println_empty_string + eprintln!( // comment + ""); + + //~v println_empty_string + println!("", /* comment */); + + //~v println_empty_string + println!( + "\ + \ + ", + + // there is a comment in the macro span regardless of its position + + ); +} diff --git a/tests/ui/println_empty_string_unfixable.stderr b/tests/ui/println_empty_string_unfixable.stderr new file mode 100644 index 000000000000..648fd7cdbccd --- /dev/null +++ b/tests/ui/println_empty_string_unfixable.stderr @@ -0,0 +1,85 @@ +error: empty string literal in `println!` + --> tests/ui/println_empty_string_unfixable.rs:7:5 + | +LL | println!("" /* comment */); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: remove the empty string + --> tests/ui/println_empty_string_unfixable.rs:7:14 + | +LL | println!("" /* comment */); + | ^^ + = note: `-D clippy::println-empty-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::println_empty_string)]` + +error: empty string literal in `eprintln!` + --> tests/ui/println_empty_string_unfixable.rs:9:5 + | +LL | eprintln!("" /* comment */); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: remove the empty string + --> tests/ui/println_empty_string_unfixable.rs:9:15 + | +LL | eprintln!("" /* comment */); + | ^^ + +error: empty string literal in `println!` + --> tests/ui/println_empty_string_unfixable.rs:12:5 + | +LL | / println!( // comment +LL | | ""); + | |___________________^ + | +note: remove the empty string + --> tests/ui/println_empty_string_unfixable.rs:13:17 + | +LL | ""); + | ^^ + +error: empty string literal in `eprintln!` + --> tests/ui/println_empty_string_unfixable.rs:15:5 + | +LL | / eprintln!( // comment +LL | | ""); + | |___________________^ + | +note: remove the empty string + --> tests/ui/println_empty_string_unfixable.rs:16:17 + | +LL | ""); + | ^^ + +error: empty string literal in `println!` + --> tests/ui/println_empty_string_unfixable.rs:19:5 + | +LL | println!("", /* comment */); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: remove the empty string + --> tests/ui/println_empty_string_unfixable.rs:19:14 + | +LL | println!("", /* comment */); + | ^^ + +error: empty string literal in `println!` + --> tests/ui/println_empty_string_unfixable.rs:22:5 + | +LL | / println!( +LL | | "\ +LL | | \ +LL | | ", +... | +LL | | ); + | |_____^ + | +note: remove the empty string + --> tests/ui/println_empty_string_unfixable.rs:23:9 + | +LL | / "\ +LL | | \ +LL | | ", + | |_____________^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/writeln_empty_string_unfixable.rs b/tests/ui/writeln_empty_string_unfixable.rs new file mode 100644 index 000000000000..ca570fd1fc7b --- /dev/null +++ b/tests/ui/writeln_empty_string_unfixable.rs @@ -0,0 +1,26 @@ +#![allow(unused_must_use)] +#![warn(clippy::writeln_empty_string)] + +use std::io::Write; + +// If there is a comment in the span of macro call, we don't provide an auto-fix suggestion. +#[rustfmt::skip] +fn issue_16251() { + let mut v = Vec::new(); + + writeln!(v, /* comment */ ""); + //~^ writeln_empty_string + + writeln!(v, "" /* comment */); + //~^ writeln_empty_string + + //~v writeln_empty_string + writeln!(v, + "\ + \ + " + + // there is a comment in the macro span regardless of its position + + ); +} diff --git a/tests/ui/writeln_empty_string_unfixable.stderr b/tests/ui/writeln_empty_string_unfixable.stderr new file mode 100644 index 000000000000..0ed802ba84ba --- /dev/null +++ b/tests/ui/writeln_empty_string_unfixable.stderr @@ -0,0 +1,47 @@ +error: empty string literal in `writeln!` + --> tests/ui/writeln_empty_string_unfixable.rs:11:5 + | +LL | writeln!(v, /* comment */ ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: remove the empty string + --> tests/ui/writeln_empty_string_unfixable.rs:11:31 + | +LL | writeln!(v, /* comment */ ""); + | ^^ + = note: `-D clippy::writeln-empty-string` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::writeln_empty_string)]` + +error: empty string literal in `writeln!` + --> tests/ui/writeln_empty_string_unfixable.rs:14:5 + | +LL | writeln!(v, "" /* comment */); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: remove the empty string + --> tests/ui/writeln_empty_string_unfixable.rs:14:17 + | +LL | writeln!(v, "" /* comment */); + | ^^ + +error: empty string literal in `writeln!` + --> tests/ui/writeln_empty_string_unfixable.rs:18:5 + | +LL | / writeln!(v, +LL | | "\ +LL | | \ +LL | | " +... | +LL | | ); + | |_____^ + | +note: remove the empty string + --> tests/ui/writeln_empty_string_unfixable.rs:19:9 + | +LL | / "\ +LL | | \ +LL | | " + | |_____________^ + +error: aborting due to 3 previous errors + From 897e88c63ded83e8b6be47ea09c661f7bd8c0ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Fri, 19 Dec 2025 12:34:59 +0100 Subject: [PATCH 332/489] add test for 149980 --- tests/ui/eii/error_statement_position.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/ui/eii/error_statement_position.rs diff --git a/tests/ui/eii/error_statement_position.rs b/tests/ui/eii/error_statement_position.rs new file mode 100644 index 000000000000..a9c606991574 --- /dev/null +++ b/tests/ui/eii/error_statement_position.rs @@ -0,0 +1,6 @@ +#![feature(extern_item_impls)] + +fn main() { + #[eii] + impl Bar {} +} From 6608f6ace7a0267cff3920216f1b697cabc3ca67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Fri, 19 Dec 2025 13:57:34 +0100 Subject: [PATCH 333/489] split up expansion code of eii macro into functions --- compiler/rustc_builtin_macros/src/eii.rs | 416 +++++++++++++---------- 1 file changed, 244 insertions(+), 172 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/eii.rs b/compiler/rustc_builtin_macros/src/eii.rs index b97cb1daec53..e29b29fc6ccb 100644 --- a/compiler/rustc_builtin_macros/src/eii.rs +++ b/compiler/rustc_builtin_macros/src/eii.rs @@ -1,11 +1,12 @@ use rustc_ast::token::{Delimiter, TokenKind}; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_ast::{ - DUMMY_NODE_ID, EiiExternTarget, EiiImpl, ItemKind, Stmt, StmtKind, ast, token, tokenstream, + Attribute, DUMMY_NODE_ID, EiiExternTarget, EiiImpl, ItemKind, MetaItem, Path, Stmt, StmtKind, + Visibility, ast, }; use rustc_ast_pretty::pprust::path_to_string; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::{Ident, Span, kw, sym}; +use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym}; use thin_vec::{ThinVec, thin_vec}; use crate::errors::{ @@ -52,12 +53,12 @@ pub(crate) fn unsafe_eii( fn eii_( ecx: &mut ExtCtxt<'_>, - span: Span, + eii_attr_span: Span, meta_item: &ast::MetaItem, item: Annotatable, impl_unsafe: bool, ) -> Vec { - let span = ecx.with_def_site_ctxt(span); + let eii_attr_span = ecx.with_def_site_ctxt(eii_attr_span); let (item, stmt) = if let Annotatable::Item(item) = item { (item, false) @@ -67,7 +68,7 @@ fn eii_( (item.clone(), true) } else { ecx.dcx().emit_err(EiiSharedMacroExpectedFunction { - span, + span: eii_attr_span, name: path_to_string(&meta_item.path), }); return vec![item]; @@ -77,113 +78,218 @@ fn eii_( let item = *item; - let ast::Item { attrs, id: _, span: item_span, vis, kind: ItemKind::Fn(mut func), tokens: _ } = - item - else { + let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } = item else { ecx.dcx().emit_err(EiiSharedMacroExpectedFunction { - span, + span: eii_attr_span, name: path_to_string(&meta_item.path), }); return vec![Annotatable::Item(Box::new(item))]; }; - // Detect when this is the *second* eii attribute on an item. - let mut new_attrs = ThinVec::new(); - for i in attrs { - if i.has_name(sym::eii) { - ecx.dcx().emit_err(EiiOnlyOnce { - span: i.span, - first_span: span, - name: path_to_string(&meta_item.path), - }); - } else { - new_attrs.push(i); - } - } - let attrs = new_attrs; + let attrs_from_decl = + filter_attrs_for_multiple_eii_attr(ecx, attrs, eii_attr_span, &meta_item.path); - let macro_name = if meta_item.is_word() { - func.ident - } else if let Some([first]) = meta_item.meta_item_list() - && let Some(m) = first.meta_item() - && m.path.segments.len() == 1 - { - m.path.segments[0].ident - } else { - ecx.dcx().emit_err(EiiMacroExpectedMaxOneArgument { - span: meta_item.span, - name: path_to_string(&meta_item.path), - }); + let Ok(macro_name) = name_for_impl_macro(ecx, &func, &meta_item) else { return vec![Annotatable::Item(orig_item)]; }; + // span of the declaring item without attributes + let item_span = func.sig.span; + // span of the eii attribute and the item below it, i.e. the full declaration + let decl_span = eii_attr_span.to(item_span); + let foreign_item_name = func.ident; + let mut return_items = Vec::new(); if func.body.is_some() { - let mut default_func = func.clone(); - func.body = None; - default_func.eii_impls.push(ast::EiiImpl { - node_id: DUMMY_NODE_ID, - eii_macro_path: ast::Path::from_ident(macro_name), - impl_safety: if impl_unsafe { ast::Safety::Unsafe(span) } else { ast::Safety::Default }, - span, - inner_span: macro_name.span, - is_default: true, // important! - }); - - return_items.push(Box::new(ast::Item { - attrs: ThinVec::new(), - id: ast::DUMMY_NODE_ID, - span, - vis: ast::Visibility { span, kind: ast::VisibilityKind::Inherited, tokens: None }, - kind: ast::ItemKind::Const(Box::new(ast::ConstItem { - ident: Ident { name: kw::Underscore, span }, - defaultness: ast::Defaultness::Final, - generics: ast::Generics::default(), - ty: Box::new(ast::Ty { - id: DUMMY_NODE_ID, - kind: ast::TyKind::Tup(ThinVec::new()), - span, - tokens: None, - }), - rhs: Some(ast::ConstItemRhs::Body(Box::new(ast::Expr { - id: DUMMY_NODE_ID, - kind: ast::ExprKind::Block( - Box::new(ast::Block { - stmts: thin_vec![ast::Stmt { - id: DUMMY_NODE_ID, - kind: ast::StmtKind::Item(Box::new(ast::Item { - attrs: thin_vec![], // FIXME: re-add some original attrs - id: DUMMY_NODE_ID, - span: item_span, - vis: ast::Visibility { - span, - kind: ast::VisibilityKind::Inherited, - tokens: None - }, - kind: ItemKind::Fn(default_func), - tokens: None, - })), - span - }], - id: DUMMY_NODE_ID, - rules: ast::BlockCheckMode::Default, - span, - tokens: None, - }), - None, - ), - span, - attrs: ThinVec::new(), - tokens: None, - }))), - define_opaque: None, - })), - tokens: None, - })) + return_items.push(Box::new(generate_default_impl( + &func, + impl_unsafe, + macro_name, + eii_attr_span, + item_span, + ))) } - let decl_span = span.to(func.sig.span); + return_items.push(Box::new(generate_foreign_item( + ecx, + eii_attr_span, + item_span, + *func, + vis, + &attrs_from_decl, + ))); + return_items.push(Box::new(generate_attribute_macro_to_implement( + ecx, + eii_attr_span, + macro_name, + foreign_item_name, + impl_unsafe, + decl_span, + ))); + + if stmt { + return_items + .into_iter() + .map(|i| { + Annotatable::Stmt(Box::new(Stmt { + id: DUMMY_NODE_ID, + kind: StmtKind::Item(i), + span: eii_attr_span, + })) + }) + .collect() + } else { + return_items.into_iter().map(|i| Annotatable::Item(i)).collect() + } +} + +/// Decide on the name of the macro that can be used to implement the EII. +/// This is either an explicitly given name, or the name of the item in the +/// declaration of the EII. +fn name_for_impl_macro( + ecx: &mut ExtCtxt<'_>, + func: &ast::Fn, + meta_item: &MetaItem, +) -> Result { + if meta_item.is_word() { + Ok(func.ident) + } else if let Some([first]) = meta_item.meta_item_list() + && let Some(m) = first.meta_item() + && m.path.segments.len() == 1 + { + Ok(m.path.segments[0].ident) + } else { + Err(ecx.dcx().emit_err(EiiMacroExpectedMaxOneArgument { + span: meta_item.span, + name: path_to_string(&meta_item.path), + })) + } +} + +/// Ensure that in the list of attrs, there's only a single `eii` attribute. +fn filter_attrs_for_multiple_eii_attr( + ecx: &mut ExtCtxt<'_>, + attrs: ThinVec, + eii_attr_span: Span, + eii_attr_path: &Path, +) -> ThinVec { + attrs + .into_iter() + .filter(|i| { + if i.has_name(sym::eii) { + ecx.dcx().emit_err(EiiOnlyOnce { + span: i.span, + first_span: eii_attr_span, + name: path_to_string(eii_attr_path), + }); + false + } else { + true + } + }) + .collect() +} + +fn generate_default_impl( + func: &ast::Fn, + impl_unsafe: bool, + macro_name: Ident, + eii_attr_span: Span, + item_span: Span, +) -> ast::Item { + // FIXME: re-add some original attrs + let attrs = ThinVec::new(); + + let mut default_func = func.clone(); + default_func.eii_impls.push(EiiImpl { + node_id: DUMMY_NODE_ID, + inner_span: macro_name.span, + eii_macro_path: ast::Path::from_ident(macro_name), + impl_safety: if impl_unsafe { + ast::Safety::Unsafe(eii_attr_span) + } else { + ast::Safety::Default + }, + span: eii_attr_span, + is_default: true, + }); + + ast::Item { + attrs: ThinVec::new(), + id: ast::DUMMY_NODE_ID, + span: eii_attr_span, + vis: ast::Visibility { + span: eii_attr_span, + kind: ast::VisibilityKind::Inherited, + tokens: None, + }, + kind: ast::ItemKind::Const(Box::new(ast::ConstItem { + ident: Ident { name: kw::Underscore, span: eii_attr_span }, + defaultness: ast::Defaultness::Final, + generics: ast::Generics::default(), + ty: Box::new(ast::Ty { + id: DUMMY_NODE_ID, + kind: ast::TyKind::Tup(ThinVec::new()), + span: eii_attr_span, + tokens: None, + }), + rhs: Some(ast::ConstItemRhs::Body(Box::new(ast::Expr { + id: DUMMY_NODE_ID, + kind: ast::ExprKind::Block( + Box::new(ast::Block { + stmts: thin_vec![ast::Stmt { + id: DUMMY_NODE_ID, + kind: ast::StmtKind::Item(Box::new(ast::Item { + attrs, + id: DUMMY_NODE_ID, + span: item_span, + vis: ast::Visibility { + span: eii_attr_span, + kind: ast::VisibilityKind::Inherited, + tokens: None + }, + kind: ItemKind::Fn(Box::new(default_func)), + tokens: None, + })), + span: eii_attr_span + }], + id: DUMMY_NODE_ID, + rules: ast::BlockCheckMode::Default, + span: eii_attr_span, + tokens: None, + }), + None, + ), + span: eii_attr_span, + attrs: ThinVec::new(), + tokens: None, + }))), + define_opaque: None, + })), + tokens: None, + } +} + +/// Generates a foreign item, like +/// +/// ```rust, ignore +/// extern "…" { safe fn item(); } +/// ``` +fn generate_foreign_item( + ecx: &mut ExtCtxt<'_>, + eii_attr_span: Span, + item_span: Span, + mut func: ast::Fn, + vis: Visibility, + attrs_from_decl: &[Attribute], +) -> ast::Item { + let mut foreign_item_attrs = ThinVec::new(); + foreign_item_attrs.extend_from_slice(attrs_from_decl); + + // Add the rustc_eii_extern_item on the foreign item. Usually, foreign items are mangled. + // This attribute makes sure that we later know that this foreign item's symbol should not be. + foreign_item_attrs.push(ecx.attr_word(sym::rustc_eii_extern_item, eii_attr_span)); let abi = match func.sig.header.ext { // extern "X" fn => extern "X" {} @@ -196,85 +302,69 @@ fn eii_( suffix: None, symbol_unescaped: sym::Rust, style: ast::StrStyle::Cooked, - span, + span: eii_attr_span, }), }; // ABI has been moved to the extern {} block, so we remove it from the fn item. func.sig.header.ext = ast::Extern::None; + func.body = None; // And mark safe functions explicitly as `safe fn`. if func.sig.header.safety == ast::Safety::Default { func.sig.header.safety = ast::Safety::Safe(func.sig.span); } - // extern "…" { safe fn item(); } - let mut extern_item_attrs = attrs.clone(); - extern_item_attrs.push(ast::Attribute { - kind: ast::AttrKind::Normal(Box::new(ast::NormalAttr { - item: ast::AttrItem { - unsafety: ast::Safety::Default, - // Add the rustc_eii_extern_item on the foreign item. Usually, foreign items are mangled. - // This attribute makes sure that we later know that this foreign item's symbol should not be. - path: ast::Path::from_ident(Ident::new(sym::rustc_eii_extern_item, span)), - args: ast::AttrArgs::Empty, - tokens: None, - }, - tokens: None, - })), - id: ecx.sess.psess.attr_id_generator.mk_attr_id(), - style: ast::AttrStyle::Outer, - span, - }); - - let extern_block = Box::new(ast::Item { + ast::Item { attrs: ast::AttrVec::default(), id: ast::DUMMY_NODE_ID, - span, - vis: ast::Visibility { span, kind: ast::VisibilityKind::Inherited, tokens: None }, + span: eii_attr_span, + vis: ast::Visibility { + span: eii_attr_span, + kind: ast::VisibilityKind::Inherited, + tokens: None, + }, kind: ast::ItemKind::ForeignMod(ast::ForeignMod { - extern_span: span, - safety: ast::Safety::Unsafe(span), + extern_span: eii_attr_span, + safety: ast::Safety::Unsafe(eii_attr_span), abi, items: From::from([Box::new(ast::ForeignItem { - attrs: extern_item_attrs, + attrs: foreign_item_attrs, id: ast::DUMMY_NODE_ID, span: item_span, vis, - kind: ast::ForeignItemKind::Fn(func.clone()), + kind: ast::ForeignItemKind::Fn(Box::new(func.clone())), tokens: None, })]), }), tokens: None, - }); + } +} - let mut macro_attrs = attrs.clone(); - macro_attrs.push( - // #[builtin_macro(eii_shared_macro)] - ast::Attribute { - kind: ast::AttrKind::Normal(Box::new(ast::NormalAttr { - item: ast::AttrItem { - unsafety: ast::Safety::Default, - path: ast::Path::from_ident(Ident::new(sym::rustc_builtin_macro, span)), - args: ast::AttrArgs::Delimited(ast::DelimArgs { - dspan: DelimSpan::from_single(span), - delim: Delimiter::Parenthesis, - tokens: TokenStream::new(vec![tokenstream::TokenTree::token_alone( - token::TokenKind::Ident(sym::eii_shared_macro, token::IdentIsRaw::No), - span, - )]), - }), - tokens: None, - }, - tokens: None, - })), - id: ecx.sess.psess.attr_id_generator.mk_attr_id(), - style: ast::AttrStyle::Outer, - span, - }, - ); +/// Generate a stub macro (a bit like in core) that will roughly look like: +/// +/// ```rust, ignore, example +/// // Since this a stub macro, the actual code that expands it lives in the compiler. +/// // This attribute tells the compiler that +/// #[builtin_macro(eii_shared_macro)] +/// // the metadata to link this macro to the generated foreign item. +/// #[eii_extern_target()] +/// macro macro_name { () => {} } +/// ``` +fn generate_attribute_macro_to_implement( + ecx: &mut ExtCtxt<'_>, + span: Span, + macro_name: Ident, + foreign_item_name: Ident, + impl_unsafe: bool, + decl_span: Span, +) -> ast::Item { + let mut macro_attrs = ThinVec::new(); - let macro_def = Box::new(ast::Item { + // #[builtin_macro(eii_shared_macro)] + macro_attrs.push(ecx.attr_nested_word(sym::rustc_builtin_macro, sym::eii_shared_macro, span)); + + ast::Item { attrs: macro_attrs, id: ast::DUMMY_NODE_ID, span, @@ -305,33 +395,15 @@ fn eii_( ]), }), macro_rules: false, - // #[eii_extern_target(func.ident)] + // #[eii_extern_target(foreign_item_ident)] eii_extern_target: Some(ast::EiiExternTarget { - extern_item_path: ast::Path::from_ident(func.ident), + extern_item_path: ast::Path::from_ident(foreign_item_name), impl_unsafe, span: decl_span, }), }, ), tokens: None, - }); - - return_items.push(extern_block); - return_items.push(macro_def); - - if stmt { - return_items - .into_iter() - .map(|i| { - Annotatable::Stmt(Box::new(Stmt { - id: DUMMY_NODE_ID, - kind: StmtKind::Item(i), - span, - })) - }) - .collect() - } else { - return_items.into_iter().map(|i| Annotatable::Item(i)).collect() } } @@ -436,10 +508,10 @@ pub(crate) fn eii_shared_macro( f.eii_impls.push(EiiImpl { node_id: DUMMY_NODE_ID, + inner_span: meta_item.path.span, eii_macro_path: meta_item.path.clone(), impl_safety: meta_item.unsafety, span, - inner_span: meta_item.path.span, is_default, }); From c316c05dc512bba366d461e1719f0a8620a07453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Fri, 19 Dec 2025 14:42:20 +0100 Subject: [PATCH 334/489] refactor how eii expansion is wrapped fixing 149980 --- compiler/rustc_builtin_macros/src/eii.rs | 45 +++++++++----------- tests/ui/eii/error_statement_position.rs | 10 +++++ tests/ui/eii/error_statement_position.stderr | 8 ++++ 3 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 tests/ui/eii/error_statement_position.stderr diff --git a/compiler/rustc_builtin_macros/src/eii.rs b/compiler/rustc_builtin_macros/src/eii.rs index e29b29fc6ccb..9049639925dd 100644 --- a/compiler/rustc_builtin_macros/src/eii.rs +++ b/compiler/rustc_builtin_macros/src/eii.rs @@ -60,12 +60,18 @@ fn eii_( ) -> Vec { let eii_attr_span = ecx.with_def_site_ctxt(eii_attr_span); - let (item, stmt) = if let Annotatable::Item(item) = item { - (item, false) + let (item, wrap_item): (_, &dyn Fn(_) -> _) = if let Annotatable::Item(item) = item { + (item, &Annotatable::Item) } else if let Annotatable::Stmt(ref stmt) = item && let StmtKind::Item(ref item) = stmt.kind { - (item.clone(), true) + (item.clone(), &|item| { + Annotatable::Stmt(Box::new(Stmt { + id: DUMMY_NODE_ID, + kind: StmtKind::Item(item), + span: eii_attr_span, + })) + }) } else { ecx.dcx().emit_err(EiiSharedMacroExpectedFunction { span: eii_attr_span, @@ -74,23 +80,25 @@ fn eii_( return vec![item]; }; - let orig_item = item.clone(); - - let item = *item; - - let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } = item else { + let ast::Item { attrs, id: _, span: _, vis, kind: ItemKind::Fn(func), tokens: _ } = + item.as_ref() + else { ecx.dcx().emit_err(EiiSharedMacroExpectedFunction { span: eii_attr_span, name: path_to_string(&meta_item.path), }); - return vec![Annotatable::Item(Box::new(item))]; + return vec![wrap_item(item)]; }; + // only clone what we need + let attrs = attrs.clone(); + let func = (**func).clone(); + let vis = vis.clone(); let attrs_from_decl = filter_attrs_for_multiple_eii_attr(ecx, attrs, eii_attr_span, &meta_item.path); let Ok(macro_name) = name_for_impl_macro(ecx, &func, &meta_item) else { - return vec![Annotatable::Item(orig_item)]; + return vec![wrap_item(item)]; }; // span of the declaring item without attributes @@ -115,7 +123,7 @@ fn eii_( ecx, eii_attr_span, item_span, - *func, + func, vis, &attrs_from_decl, ))); @@ -128,20 +136,7 @@ fn eii_( decl_span, ))); - if stmt { - return_items - .into_iter() - .map(|i| { - Annotatable::Stmt(Box::new(Stmt { - id: DUMMY_NODE_ID, - kind: StmtKind::Item(i), - span: eii_attr_span, - })) - }) - .collect() - } else { - return_items.into_iter().map(|i| Annotatable::Item(i)).collect() - } + return_items.into_iter().map(wrap_item).collect() } /// Decide on the name of the macro that can be used to implement the EII. diff --git a/tests/ui/eii/error_statement_position.rs b/tests/ui/eii/error_statement_position.rs index a9c606991574..cf81e7e6a8b2 100644 --- a/tests/ui/eii/error_statement_position.rs +++ b/tests/ui/eii/error_statement_position.rs @@ -1,6 +1,16 @@ #![feature(extern_item_impls)] +// EIIs can, despite not being super useful, be declared in statement position +// nested inside items. Items in statement position, when expanded as part of a macro, +// need to be wrapped slightly differently (in an `ast::Statement`). +// We did this on the happy path (no errors), but when there was an error, we'd +// replace it with *just* an `ast::Item` not wrapped in an `ast::Statement`. +// This caused an ICE (https://github.com/rust-lang/rust/issues/149980). +// this test fails to build, but demonstrates that no ICE is produced. fn main() { + struct Bar; + #[eii] + //~^ ERROR `#[eii]` is only valid on functions impl Bar {} } diff --git a/tests/ui/eii/error_statement_position.stderr b/tests/ui/eii/error_statement_position.stderr new file mode 100644 index 000000000000..01b7394ef00f --- /dev/null +++ b/tests/ui/eii/error_statement_position.stderr @@ -0,0 +1,8 @@ +error: `#[eii]` is only valid on functions + --> $DIR/error_statement_position.rs:13:5 + | +LL | #[eii] + | ^^^^^^ + +error: aborting due to 1 previous error + From c34ea6e56dcea96bed3739c37580bd559c75c0e8 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Fri, 19 Dec 2025 11:02:57 -0800 Subject: [PATCH 335/489] remove llvm_enzyme and enzyme fallbacks from most places, enable the autodiff frontend on nightly --- compiler/rustc_builtin_macros/messages.ftl | 1 - compiler/rustc_builtin_macros/src/autodiff.rs | 5 - compiler/rustc_builtin_macros/src/errors.rs | 11 -- compiler/rustc_codegen_llvm/Cargo.toml | 4 +- compiler/rustc_codegen_llvm/src/back/lto.rs | 1 - compiler/rustc_codegen_llvm/src/back/write.rs | 6 +- compiler/rustc_codegen_llvm/src/errors.rs | 1 - compiler/rustc_codegen_llvm/src/lib.rs | 4 +- .../rustc_codegen_llvm/src/llvm/enzyme_ffi.rs | 143 ------------------ compiler/rustc_codegen_llvm/src/typetree.rs | 36 ++--- tests/pretty/autodiff/autodiff_forward.pp | 2 +- tests/pretty/autodiff/autodiff_forward.rs | 2 +- tests/pretty/autodiff/autodiff_reverse.pp | 2 +- tests/pretty/autodiff/autodiff_reverse.rs | 2 +- tests/pretty/autodiff/inherent_impl.pp | 2 +- tests/pretty/autodiff/inherent_impl.rs | 2 +- tests/ui/autodiff/visibility.rs | 2 +- .../autodiff/visibility.std_autodiff.stderr | 10 +- ... feature-gate-autodiff-use.nightly.stderr} | 2 +- .../feature-gate-autodiff-use.rs | 21 ++- ...> feature-gate-autodiff-use.stable.stderr} | 10 +- 21 files changed, 46 insertions(+), 223 deletions(-) rename tests/ui/feature-gates/{feature-gate-autodiff-use.has_support.stderr => feature-gate-autodiff-use.nightly.stderr} (95%) rename tests/ui/feature-gates/{feature-gate-autodiff-use.no_support.stderr => feature-gate-autodiff-use.stable.stderr} (78%) diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index 542f34d9d831..f0f6f2dcf82c 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -55,7 +55,6 @@ builtin_macros_assert_requires_expression = macro requires an expression as an a builtin_macros_autodiff = autodiff must be applied to function builtin_macros_autodiff_missing_config = autodiff requires at least a name and mode builtin_macros_autodiff_mode_activity = {$act} can not be used in {$mode} Mode -builtin_macros_autodiff_not_build = this rustc version does not support autodiff builtin_macros_autodiff_number_activities = expected {$expected} activities, but found {$found} builtin_macros_autodiff_ret_activity = invalid return activity {$act} in {$mode} Mode builtin_macros_autodiff_ty_activity = {$act} can not be used for this type diff --git a/compiler/rustc_builtin_macros/src/autodiff.rs b/compiler/rustc_builtin_macros/src/autodiff.rs index 6bf985fcc9f0..39abb66df30c 100644 --- a/compiler/rustc_builtin_macros/src/autodiff.rs +++ b/compiler/rustc_builtin_macros/src/autodiff.rs @@ -209,11 +209,6 @@ mod llvm_enzyme { mut item: Annotatable, mode: DiffMode, ) -> Vec { - // FIXME(bjorn3) maybe have the backend directly tell if autodiff is supported? - if cfg!(not(feature = "llvm_enzyme")) { - ecx.sess.dcx().emit_err(errors::AutoDiffSupportNotBuild { span: meta_item.span }); - return vec![item]; - } let dcx = ecx.sess.dcx(); // first get information about the annotable item: visibility, signature, name and generic diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index 2a4c499349ad..ad31eae10f60 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -216,17 +216,6 @@ mod autodiff { } } -pub(crate) use ad_fallback::*; -mod ad_fallback { - use super::*; - #[derive(Diagnostic)] - #[diag(builtin_macros_autodiff_not_build)] - pub(crate) struct AutoDiffSupportNotBuild { - #[primary_span] - pub(crate) span: Span, - } -} - #[derive(Diagnostic)] #[diag(builtin_macros_concat_bytes_invalid)] pub(crate) struct ConcatBytesInvalid { diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 076ec5e59eb6..b40962b759d8 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -14,7 +14,7 @@ bitflags = "2.4.1" gimli = "0.31" itertools = "0.12" libc = "0.2" -libloading = { version = "0.9.0", optional = true } +libloading = { version = "0.9.0" } measureme = "12.0.1" object = { version = "0.37.0", default-features = false, features = ["std", "read"] } rustc-demangle = "0.1.21" @@ -47,7 +47,7 @@ tracing = "0.1" [features] # tidy-alphabetical-start check_only = ["rustc_llvm/check_only"] -llvm_enzyme = ["dep:libloading"] +llvm_enzyme = [] llvm_offload = [] # tidy-alphabetical-end diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 314e64272ffe..52c2ca7b1696 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -528,7 +528,6 @@ fn thin_lto( } } -#[cfg(feature = "llvm_enzyme")] pub(crate) fn enable_autodiff_settings(ad: &[config::AutoDiff]) { let mut enzyme = llvm::EnzymeWrapper::get_instance(); diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 18da945f5a31..f5566cc84ce9 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -568,8 +568,7 @@ pub(crate) unsafe fn llvm_optimize( // FIXME(ZuseZ4): In a future update we could figure out how to only optimize individual functions getting // differentiated. - let consider_ad = - cfg!(feature = "llvm_enzyme") && config.autodiff.contains(&config::AutoDiff::Enable); + let consider_ad = config.autodiff.contains(&config::AutoDiff::Enable); let run_enzyme = autodiff_stage == AutodiffStage::DuringAD; let print_before_enzyme = config.autodiff.contains(&config::AutoDiff::PrintModBefore); let print_after_enzyme = config.autodiff.contains(&config::AutoDiff::PrintModAfter); @@ -819,8 +818,7 @@ pub(crate) fn optimize( // If we know that we will later run AD, then we disable vectorization and loop unrolling. // Otherwise we pretend AD is already done and run the normal opt pipeline (=PostAD). - let consider_ad = - cfg!(feature = "llvm_enzyme") && config.autodiff.contains(&config::AutoDiff::Enable); + let consider_ad = config.autodiff.contains(&config::AutoDiff::Enable); let autodiff_stage = if consider_ad { AutodiffStage::PreAD } else { AutodiffStage::PostAD }; // The embedded bitcode is used to run LTO/ThinLTO. // The bitcode obtained during the `codegen` phase is no longer suitable for performing LTO. diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index f2e147b1ee0a..b59067b9745b 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -32,7 +32,6 @@ impl Diagnostic<'_, G> for ParseTargetMachineConfig<'_> { } } -#[cfg(feature = "llvm_enzyme")] #[derive(Diagnostic)] #[diag(codegen_llvm_autodiff_component_unavailable)] pub(crate) struct AutoDiffComponentUnavailable; diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 4d0f8dbb9302..d96d7d13e7cc 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -242,7 +242,9 @@ impl CodegenBackend for LlvmCodegenBackend { fn init(&self, sess: &Session) { llvm_util::init(sess); // Make sure llvm is inited - #[cfg(feature = "llvm_enzyme")] + // autodiff is based on Enzyme, a library which we might not have available, when it was + // neither build, nor downloaded via rustup. If autodiff is used, but not available we emit + // an early error here and abort compilation. { use rustc_session::config::AutoDiff; diff --git a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs index 956a4e43a7de..b11310b970d0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs @@ -86,10 +86,8 @@ pub(crate) enum LLVMRustVerifierFailureAction { LLVMReturnStatusAction = 2, } -#[cfg(feature = "llvm_enzyme")] pub(crate) use self::Enzyme_AD::*; -#[cfg(feature = "llvm_enzyme")] pub(crate) mod Enzyme_AD { use std::ffi::{c_char, c_void}; use std::sync::{Mutex, MutexGuard, OnceLock}; @@ -450,147 +448,6 @@ pub(crate) mod Enzyme_AD { } } -#[cfg(not(feature = "llvm_enzyme"))] -pub(crate) use self::Fallback_AD::*; - -#[cfg(not(feature = "llvm_enzyme"))] -pub(crate) mod Fallback_AD { - #![allow(unused_variables)] - - use std::ffi::c_void; - use std::sync::{Mutex, MutexGuard}; - - use libc::c_char; - use rustc_codegen_ssa::back::write::CodegenContext; - use rustc_codegen_ssa::traits::WriteBackendMethods; - - use super::{CConcreteType, CTypeTreeRef, Context, EnzymeTypeTree}; - - pub(crate) struct EnzymeWrapper { - pub registerEnzymeAndPassPipeline: *const c_void, - } - - impl EnzymeWrapper { - pub(crate) fn get_or_init( - _sysroot: &rustc_session::config::Sysroot, - ) -> Result, Box> { - unimplemented!("Enzyme not available: build with llvm_enzyme feature") - } - - pub(crate) fn init<'a, B: WriteBackendMethods>( - _cgcx: &'a CodegenContext, - ) -> &'static Mutex { - unimplemented!("Enzyme not available: build with llvm_enzyme feature") - } - - pub(crate) fn get_instance() -> MutexGuard<'static, Self> { - unimplemented!("Enzyme not available: build with llvm_enzyme feature") - } - - pub(crate) fn new_type_tree(&self) -> CTypeTreeRef { - unimplemented!() - } - - pub(crate) fn new_type_tree_ct( - &self, - t: CConcreteType, - ctx: &Context, - ) -> *mut EnzymeTypeTree { - unimplemented!() - } - - pub(crate) fn new_type_tree_tr(&self, tree: CTypeTreeRef) -> CTypeTreeRef { - unimplemented!() - } - - pub(crate) fn free_type_tree(&self, tree: CTypeTreeRef) { - unimplemented!() - } - - pub(crate) fn merge_type_tree(&self, tree1: CTypeTreeRef, tree2: CTypeTreeRef) -> bool { - unimplemented!() - } - - pub(crate) fn tree_only_eq(&self, tree: CTypeTreeRef, num: i64) { - unimplemented!() - } - - pub(crate) fn tree_data0_eq(&self, tree: CTypeTreeRef) { - unimplemented!() - } - - pub(crate) fn shift_indicies_eq( - &self, - tree: CTypeTreeRef, - data_layout: *const c_char, - offset: i64, - max_size: i64, - add_offset: u64, - ) { - unimplemented!() - } - - pub(crate) fn tree_insert_eq( - &self, - tree: CTypeTreeRef, - indices: *const i64, - len: usize, - ct: CConcreteType, - ctx: &Context, - ) { - unimplemented!() - } - - pub(crate) fn tree_to_string(&self, tree: *mut EnzymeTypeTree) -> *const c_char { - unimplemented!() - } - - pub(crate) fn tree_to_string_free(&self, ch: *const c_char) { - unimplemented!() - } - - pub(crate) fn get_max_type_depth(&self) -> usize { - unimplemented!() - } - - pub(crate) fn set_inline(&mut self, val: bool) { - unimplemented!() - } - - pub(crate) fn set_print_perf(&mut self, print: bool) { - unimplemented!() - } - - pub(crate) fn set_print_activity(&mut self, print: bool) { - unimplemented!() - } - - pub(crate) fn set_print_type(&mut self, print: bool) { - unimplemented!() - } - - pub(crate) fn set_print_type_fun(&mut self, fun_name: &str) { - unimplemented!() - } - - pub(crate) fn set_print(&mut self, print: bool) { - unimplemented!() - } - - pub(crate) fn set_strict_aliasing(&mut self, strict: bool) { - unimplemented!() - } - - pub(crate) fn set_loose_types(&mut self, loose: bool) { - unimplemented!() - } - - pub(crate) fn set_rust_rules(&mut self, val: bool) { - unimplemented!() - } - } -} - impl TypeTree { pub(crate) fn new() -> TypeTree { let wrapper = EnzymeWrapper::get_instance(); diff --git a/compiler/rustc_codegen_llvm/src/typetree.rs b/compiler/rustc_codegen_llvm/src/typetree.rs index 513a832e7fe8..4f433f273c8c 100644 --- a/compiler/rustc_codegen_llvm/src/typetree.rs +++ b/compiler/rustc_codegen_llvm/src/typetree.rs @@ -1,15 +1,10 @@ -use rustc_ast::expand::typetree::FncTree; -#[cfg(feature = "llvm_enzyme")] -use { - crate::attributes, - crate::llvm::EnzymeWrapper, - rustc_ast::expand::typetree::TypeTree as RustTypeTree, - std::ffi::{CString, c_char, c_uint}, -}; +use std::ffi::{CString, c_char, c_uint}; -use crate::llvm::{self, Value}; +use rustc_ast::expand::typetree::{FncTree, TypeTree as RustTypeTree}; + +use crate::attributes; +use crate::llvm::{self, EnzymeWrapper, Value}; -#[cfg(feature = "llvm_enzyme")] fn to_enzyme_typetree( rust_typetree: RustTypeTree, _data_layout: &str, @@ -19,7 +14,6 @@ fn to_enzyme_typetree( process_typetree_recursive(&mut enzyme_tt, &rust_typetree, &[], llcx); enzyme_tt } -#[cfg(feature = "llvm_enzyme")] fn process_typetree_recursive( enzyme_tt: &mut llvm::TypeTree, rust_typetree: &RustTypeTree, @@ -57,13 +51,21 @@ fn process_typetree_recursive( } } -#[cfg(feature = "llvm_enzyme")] +#[cfg_attr(not(feature = "llvm_enzyme"), allow(unused))] pub(crate) fn add_tt<'ll>( llmod: &'ll llvm::Module, llcx: &'ll llvm::Context, fn_def: &'ll Value, tt: FncTree, ) { + // TypeTree processing uses functions from Enzyme, which we might not have available if we did + // not build this compiler with `llvm_enzyme`. This feature is not strictly necessary, but + // skipping this function increases the chance that Enzyme fails to compile some code. + // FIXME(autodiff): In the future we should conditionally run this function even without the + // `llvm_enzyme` feature, in case that libEnzyme was provided via rustup. + #[cfg(not(feature = "llvm_enzyme"))] + return; + let inputs = tt.args; let ret_tt: RustTypeTree = tt.ret; @@ -113,13 +115,3 @@ pub(crate) fn add_tt<'ll>( enzyme_wrapper.tree_to_string_free(c_str.as_ptr()); } } - -#[cfg(not(feature = "llvm_enzyme"))] -pub(crate) fn add_tt<'ll>( - _llmod: &'ll llvm::Module, - _llcx: &'ll llvm::Context, - _fn_def: &'ll Value, - _tt: FncTree, -) { - unimplemented!() -} diff --git a/tests/pretty/autodiff/autodiff_forward.pp b/tests/pretty/autodiff/autodiff_forward.pp index 6eddb5669c7a..ea4e294f1ac3 100644 --- a/tests/pretty/autodiff/autodiff_forward.pp +++ b/tests/pretty/autodiff/autodiff_forward.pp @@ -1,6 +1,6 @@ #![feature(prelude_import)] #![no_std] -//@ needs-enzyme +//@ only-nightly #![feature(autodiff)] #[macro_use] diff --git a/tests/pretty/autodiff/autodiff_forward.rs b/tests/pretty/autodiff/autodiff_forward.rs index e23a1b3e241e..4fa02bc85e3e 100644 --- a/tests/pretty/autodiff/autodiff_forward.rs +++ b/tests/pretty/autodiff/autodiff_forward.rs @@ -1,4 +1,4 @@ -//@ needs-enzyme +//@ only-nightly #![feature(autodiff)] //@ pretty-mode:expanded diff --git a/tests/pretty/autodiff/autodiff_reverse.pp b/tests/pretty/autodiff/autodiff_reverse.pp index 8f598b865c7b..9202e0a76635 100644 --- a/tests/pretty/autodiff/autodiff_reverse.pp +++ b/tests/pretty/autodiff/autodiff_reverse.pp @@ -1,6 +1,6 @@ #![feature(prelude_import)] #![no_std] -//@ needs-enzyme +//@ only-nightly #![feature(autodiff)] #[macro_use] diff --git a/tests/pretty/autodiff/autodiff_reverse.rs b/tests/pretty/autodiff/autodiff_reverse.rs index c50b81d7780d..f1a8f9b50a77 100644 --- a/tests/pretty/autodiff/autodiff_reverse.rs +++ b/tests/pretty/autodiff/autodiff_reverse.rs @@ -1,4 +1,4 @@ -//@ needs-enzyme +//@ only-nightly #![feature(autodiff)] //@ pretty-mode:expanded diff --git a/tests/pretty/autodiff/inherent_impl.pp b/tests/pretty/autodiff/inherent_impl.pp index 36a9222640ae..bc70c4076121 100644 --- a/tests/pretty/autodiff/inherent_impl.pp +++ b/tests/pretty/autodiff/inherent_impl.pp @@ -1,6 +1,6 @@ #![feature(prelude_import)] #![no_std] -//@ needs-enzyme +//@ only-nightly #![feature(autodiff)] #[macro_use] diff --git a/tests/pretty/autodiff/inherent_impl.rs b/tests/pretty/autodiff/inherent_impl.rs index 11ff209f9d89..e2702b7e51f6 100644 --- a/tests/pretty/autodiff/inherent_impl.rs +++ b/tests/pretty/autodiff/inherent_impl.rs @@ -1,4 +1,4 @@ -//@ needs-enzyme +//@ only-nightly #![feature(autodiff)] //@ pretty-mode:expanded diff --git a/tests/ui/autodiff/visibility.rs b/tests/ui/autodiff/visibility.rs index a84df75e7996..3cf13b5b5dce 100644 --- a/tests/ui/autodiff/visibility.rs +++ b/tests/ui/autodiff/visibility.rs @@ -1,5 +1,6 @@ //@ ignore-enzyme //@ revisions: std_autodiff no_std_autodiff +//@ only-nightly //@[no_std_autodiff] check-pass //@ proc-macro: my_macro.rs #![crate_type = "lib"] @@ -12,5 +13,4 @@ use my_macro::autodiff_forward; // bring `autodiff_forward` in scope #[autodiff_forward(dfoo)] //[std_autodiff]~^^^ ERROR the name `autodiff_forward` is defined multiple times -//[std_autodiff]~^^ ERROR this rustc version does not support autodiff fn foo() {} diff --git a/tests/ui/autodiff/visibility.std_autodiff.stderr b/tests/ui/autodiff/visibility.std_autodiff.stderr index e45f1139012a..6a0cdd492e2d 100644 --- a/tests/ui/autodiff/visibility.std_autodiff.stderr +++ b/tests/ui/autodiff/visibility.std_autodiff.stderr @@ -1,5 +1,5 @@ error[E0252]: the name `autodiff_forward` is defined multiple times - --> $DIR/visibility.rs:11:5 + --> $DIR/visibility.rs:12:5 | LL | use std::autodiff::autodiff_forward; | ------------------------------- previous import of the macro `autodiff_forward` here @@ -13,12 +13,6 @@ help: you can use `as` to change the binding name of the import LL | use my_macro::autodiff_forward as other_autodiff_forward; // bring `autodiff_forward` in scope | +++++++++++++++++++++++++ -error: this rustc version does not support autodiff - --> $DIR/visibility.rs:13:1 - | -LL | #[autodiff_forward(dfoo)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0252`. diff --git a/tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr b/tests/ui/feature-gates/feature-gate-autodiff-use.nightly.stderr similarity index 95% rename from tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr rename to tests/ui/feature-gates/feature-gate-autodiff-use.nightly.stderr index e5edd8e45e6c..ca724632063d 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr +++ b/tests/ui/feature-gates/feature-gate-autodiff-use.nightly.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `autodiff` - --> $DIR/feature-gate-autodiff-use.rs:13:3 + --> $DIR/feature-gate-autodiff-use.rs:16:3 | LL | #[autodiff_reverse(dfoo)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-autodiff-use.rs b/tests/ui/feature-gates/feature-gate-autodiff-use.rs index 2864b786c121..d97c06de7de5 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff-use.rs +++ b/tests/ui/feature-gates/feature-gate-autodiff-use.rs @@ -1,17 +1,22 @@ -//@ revisions: has_support no_support -//@[no_support] ignore-enzyme -//@[has_support] needs-enzyme +//@ revisions: nightly stable +//@[nightly] only-nightly +//@[stable] only-stable // This checks that without enabling the autodiff feature, we can't import std::autodiff::autodiff; #![crate_type = "lib"] use std::autodiff::autodiff_reverse; -//[has_support]~^ ERROR use of unstable library feature `autodiff` -//[no_support]~^^ ERROR use of unstable library feature `autodiff` +//[nightly]~^ ERROR use of unstable library feature `autodiff` +//[stable]~^^ ERROR use of unstable library feature `autodiff` +//[stable]~| NOTE see issue #124509 for more information +//[stable]~| HELP add `#![feature(autodiff)]` to the crate attributes to enable +//[stable]~| NOTE this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date #[autodiff_reverse(dfoo)] -//[has_support]~^ ERROR use of unstable library feature `autodiff` [E0658] -//[no_support]~^^ ERROR use of unstable library feature `autodiff` [E0658] -//[no_support]~| ERROR this rustc version does not support autodiff +//[nightly]~^ ERROR use of unstable library feature `autodiff` [E0658] +//[stable]~^^ ERROR use of unstable library feature `autodiff` [E0658] +//[stable]~| NOTE see issue #124509 for more information +//[stable]~| HELP add `#![feature(autodiff)]` to the crate attributes to enable +//[stable]~| NOTE this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date fn foo() {} diff --git a/tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr b/tests/ui/feature-gates/feature-gate-autodiff-use.stable.stderr similarity index 78% rename from tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr rename to tests/ui/feature-gates/feature-gate-autodiff-use.stable.stderr index 65ba033b3589..ca724632063d 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr +++ b/tests/ui/feature-gates/feature-gate-autodiff-use.stable.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `autodiff` - --> $DIR/feature-gate-autodiff-use.rs:13:3 + --> $DIR/feature-gate-autodiff-use.rs:16:3 | LL | #[autodiff_reverse(dfoo)] | ^^^^^^^^^^^^^^^^ @@ -8,12 +8,6 @@ LL | #[autodiff_reverse(dfoo)] = help: add `#![feature(autodiff)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: this rustc version does not support autodiff - --> $DIR/feature-gate-autodiff-use.rs:13:1 - | -LL | #[autodiff_reverse(dfoo)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0658]: use of unstable library feature `autodiff` --> $DIR/feature-gate-autodiff-use.rs:9:5 | @@ -24,6 +18,6 @@ LL | use std::autodiff::autodiff_reverse; = help: add `#![feature(autodiff)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. From 4ee01c4e4c9a8aea2ded93eca66785fbb0a5f014 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 19 Dec 2025 20:17:46 +0100 Subject: [PATCH 336/489] Add `target_feature = "gc"` for Wasm --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 4 ++++ compiler/rustc_target/src/target_features.rs | 1 + tests/ui/check-cfg/target_feature.stderr | 1 + 3 files changed, 6 insertions(+) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 682484595a89..2e1d0cfada5b 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -266,6 +266,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option Some(LLVMFeature::new("hasleoncasa")), s => Some(LLVMFeature::new(s)), }, + Arch::Wasm32 | Arch::Wasm64 => match s { + "gc" if major < 22 => None, + s => Some(LLVMFeature::new(s)), + }, Arch::X86 | Arch::X86_64 => { match s { "sse4.2" => Some(LLVMFeature::with_dependencies( diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index e516a31d1e66..35cfeba2bffd 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -745,6 +745,7 @@ static WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("bulk-memory", Stable, &[]), ("exception-handling", Unstable(sym::wasm_target_feature), &[]), ("extended-const", Stable, &[]), + ("gc", Unstable(sym::wasm_target_feature), &["reference-types"]), ("multivalue", Stable, &[]), ("mutable-globals", Stable, &[]), ("nontrapping-fptoint", Stable, &[]), diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index d25e7f094964..72edc03e10a4 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -121,6 +121,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `frecipe` `frintts` `fxsr` +`gc` `gfni` `guarded-storage` `hard-float` From cbc05da116b9ebc7a35fb57fcda4c8079bdd4316 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 20 Dec 2025 05:04:58 +0900 Subject: [PATCH 337/489] fix test case --- .../macro_expansion_tests/mbe/regression.rs | 36 +++++++++++++++++++ .../rust-analyzer/crates/mbe/src/expander.rs | 13 +++++-- .../crates/mbe/src/expander/matcher.rs | 27 ++++++++------ .../crates/mbe/src/expander/transcriber.rs | 11 ++++-- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs index e2022c7967d8..ddabb50251a4 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs @@ -108,6 +108,42 @@ fn main() { ); } +#[test] +fn ty_fragment_followed_by_expr() { + check( + r#" +macro_rules! a { + ($t:tt) => {}; +} + +macro_rules! b { + ($t:ty) => { + a!($t); + }; +} + +fn main() { + b!(&'static str); +} +"#, + expect![[r#" +macro_rules! a { + ($t:tt) => {}; +} + +macro_rules! b { + ($t:ty) => { + a!($t); + }; +} + +fn main() { + a!(&'static str);; +} +"#]], + ); +} + #[test] fn test_winapi_struct() { // from https://github.com/retep998/winapi-rs/blob/a7ef2bca086aae76cf6c4ce4c2552988ed9798ad/src/macros.rs#L366 diff --git a/src/tools/rust-analyzer/crates/mbe/src/expander.rs b/src/tools/rust-analyzer/crates/mbe/src/expander.rs index 6510fefcb6ad..274b779c1b2e 100644 --- a/src/tools/rust-analyzer/crates/mbe/src/expander.rs +++ b/src/tools/rust-analyzer/crates/mbe/src/expander.rs @@ -128,7 +128,10 @@ enum Fragment<'a> { #[default] Empty, /// token fragments are just copy-pasted into the output - Tokens(tt::TokenTreesView<'a, Span>), + Tokens { + tree: tt::TokenTreesView<'a, Span>, + origin: TokensOrigin, + }, /// Expr ast fragments are surrounded with `()` on transcription to preserve precedence. /// Note that this impl is different from the one currently in `rustc` -- /// `rustc` doesn't translate fragments into token trees at all. @@ -156,10 +159,16 @@ impl Fragment<'_> { fn is_empty(&self) -> bool { match self { Fragment::Empty => true, - Fragment::Tokens(it) => it.len() == 0, + Fragment::Tokens { tree, .. } => tree.len() == 0, Fragment::Expr(it) => it.len() == 0, Fragment::Path(it) => it.len() == 0, Fragment::TokensOwned(it) => it.0.is_empty(), } } } + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum TokensOrigin { + Raw, + Ast, +} diff --git a/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs b/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs index 4da8b309f005..a21468fbb0d5 100644 --- a/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs +++ b/src/tools/rust-analyzer/crates/mbe/src/expander/matcher.rs @@ -71,7 +71,7 @@ use tt::{ use crate::{ ExpandError, ExpandErrorKind, MetaTemplate, ValueResult, - expander::{Binding, Bindings, ExpandResult, Fragment}, + expander::{Binding, Bindings, ExpandResult, Fragment, TokensOrigin}, expect_fragment, parser::{ExprKind, MetaVarKind, Op, RepeatKind, Separator}, }; @@ -842,18 +842,23 @@ fn match_meta_var<'t>( } .err(); let tt_result = input.from_savepoint(savepoint); - return ValueResult { value: Fragment::Tokens(tt_result), err }; + return ValueResult { + value: Fragment::Tokens { tree: tt_result, origin: TokensOrigin::Raw }, + err, + }; } - MetaVarKind::Ty => parser::PrefixEntryPoint::Ty, - MetaVarKind::Pat => parser::PrefixEntryPoint::PatTop, - MetaVarKind::PatParam => parser::PrefixEntryPoint::Pat, - MetaVarKind::Stmt => parser::PrefixEntryPoint::Stmt, - MetaVarKind::Block => parser::PrefixEntryPoint::Block, - MetaVarKind::Meta => parser::PrefixEntryPoint::MetaItem, - MetaVarKind::Item => parser::PrefixEntryPoint::Item, - MetaVarKind::Vis => parser::PrefixEntryPoint::Vis, + MetaVarKind::Ty => (parser::PrefixEntryPoint::Ty, TokensOrigin::Ast), + MetaVarKind::Pat => (parser::PrefixEntryPoint::PatTop, TokensOrigin::Ast), + MetaVarKind::PatParam => (parser::PrefixEntryPoint::Pat, TokensOrigin::Ast), + MetaVarKind::Stmt => (parser::PrefixEntryPoint::Stmt, TokensOrigin::Ast), + MetaVarKind::Block => (parser::PrefixEntryPoint::Block, TokensOrigin::Ast), + MetaVarKind::Meta => (parser::PrefixEntryPoint::MetaItem, TokensOrigin::Ast), + MetaVarKind::Item => (parser::PrefixEntryPoint::Item, TokensOrigin::Ast), + MetaVarKind::Vis => (parser::PrefixEntryPoint::Vis, TokensOrigin::Ast), }; - expect_fragment(db, input, fragment, delim_span).map(Fragment::Tokens) + let (entry_point, origin) = fragment; + expect_fragment(db, input, entry_point, delim_span) + .map(|tree| Fragment::Tokens { tree, origin }) } fn collect_vars(collector_fun: &mut impl FnMut(Symbol), pattern: &MetaTemplate) { diff --git a/src/tools/rust-analyzer/crates/mbe/src/expander/transcriber.rs b/src/tools/rust-analyzer/crates/mbe/src/expander/transcriber.rs index 3e4ab8bdc1d8..006ef1af806e 100644 --- a/src/tools/rust-analyzer/crates/mbe/src/expander/transcriber.rs +++ b/src/tools/rust-analyzer/crates/mbe/src/expander/transcriber.rs @@ -5,6 +5,7 @@ use intern::{Symbol, sym}; use span::{Edition, Span}; use tt::{Delimiter, TopSubtreeBuilder, iter::TtElement}; +use super::TokensOrigin; use crate::{ ExpandError, ExpandErrorKind, ExpandResult, MetaTemplate, expander::{Binding, Bindings, Fragment}, @@ -313,7 +314,7 @@ fn expand_subtree( } }; let values = match &var_value { - Fragment::Tokens(tokens) => { + Fragment::Tokens { tree: tokens, .. } => { let mut iter = tokens.iter(); (iter.next(), iter.next()) } @@ -393,7 +394,13 @@ fn expand_var( // rustc spacing is not like ours. Ours is like proc macros', it dictates how puncts will actually be joined. // rustc uses them mostly for pretty printing. So we have to deviate a bit from what rustc does here. // Basically, a metavariable can never be joined with whatever after it. - Fragment::Tokens(tt) => builder.extend_with_tt_alone(tt.strip_invisible()), + Fragment::Tokens { tree, origin } => { + let view = match origin { + TokensOrigin::Raw => tree.strip_invisible(), + TokensOrigin::Ast => tree, + }; + builder.extend_with_tt_alone(view); + } Fragment::TokensOwned(tt) => { builder.extend_with_tt_alone(tt.view().strip_invisible()) } From 746acc47a1d068792faebd5d3a1b8ed2ac9f9ae8 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 4 Nov 2025 18:22:56 +0100 Subject: [PATCH 338/489] Nvptx: Use llbc as default linker --- compiler/rustc_target/src/spec/mod.rs | 5 ----- .../rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs | 4 +--- src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md | 4 ++-- tests/assembly-llvm/nvptx-arch-default.rs | 2 +- tests/assembly-llvm/nvptx-arch-target-cpu.rs | 2 +- tests/assembly-llvm/nvptx-c-abi-arg-v7.rs | 2 +- tests/assembly-llvm/nvptx-c-abi-ret-v7.rs | 2 +- .../nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs | 2 +- tests/assembly-llvm/nvptx-safe-naming.rs | 2 +- 9 files changed, 9 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 3d500694c978..b06339f59425 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2956,11 +2956,6 @@ impl Target { matches!(self.linker_flavor, LinkerFlavor::Bpf), "`linker_flavor` must be `bpf` if and only if `arch` is `bpf`" ); - check_eq!( - self.arch == Arch::Nvptx64, - matches!(self.linker_flavor, LinkerFlavor::Ptx), - "`linker_flavor` must be `ptc` if and only if `arch` is `nvptx64`" - ); for args in [ &self.pre_link_args, diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs index 35003c4d4dd6..be09681b1f35 100644 --- a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -19,9 +19,7 @@ pub(crate) fn target() -> Target { options: TargetOptions { os: Os::Cuda, vendor: "nvidia".into(), - linker_flavor: LinkerFlavor::Ptx, - // The linker can be installed from `crates.io`. - linker: Some("rust-ptx-linker".into()), + linker_flavor: LinkerFlavor::Llbc, // With `ptx-linker` approach, it can be later overridden via link flags. cpu: "sm_30".into(), diff --git a/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md b/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md index 36598982481b..0eb7e1d84bd0 100644 --- a/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md +++ b/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md @@ -12,7 +12,7 @@ platform. ## Requirements -This target is `no_std` and will typically be built with crate-type `cdylib` and `-C linker-flavor=llbc`, which generates PTX. +This target is `no_std`, and uses the `llvm-bitcode-linker` by default. For PTX output, build with crate-type `cdylib`. The necessary components for this workflow are: - `rustup toolchain add nightly` @@ -38,7 +38,7 @@ While the compiler accepts `#[target_feature(enable = "ptx80", enable = "sm_89") A `no_std` crate containing one or more functions with `extern "ptx-kernel"` can be compiled to PTX using a command like the following. ```console -$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib -- -Clinker-flavor=llbc -Zunstable-options +$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib ``` Intrinsics in `core::arch::nvptx` may use `#[cfg(target_feature = "...")]`, thus it's necessary to use `-Zbuild-std=core` with appropriate `RUSTFLAGS`. The following components are needed for this workflow: diff --git a/tests/assembly-llvm/nvptx-arch-default.rs b/tests/assembly-llvm/nvptx-arch-default.rs index a621fd6dcb29..22b4a680e322 100644 --- a/tests/assembly-llvm/nvptx-arch-default.rs +++ b/tests/assembly-llvm/nvptx-arch-default.rs @@ -1,5 +1,5 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc +//@ compile-flags: --crate-type cdylib //@ only-nvptx64 #![no_std] diff --git a/tests/assembly-llvm/nvptx-arch-target-cpu.rs b/tests/assembly-llvm/nvptx-arch-target-cpu.rs index 609ab297e636..e02ad0d558a9 100644 --- a/tests/assembly-llvm/nvptx-arch-target-cpu.rs +++ b/tests/assembly-llvm/nvptx-arch-target-cpu.rs @@ -1,5 +1,5 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 -Z unstable-options -Clinker-flavor=llbc +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 //@ only-nvptx64 #![no_std] diff --git a/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs b/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs index be98b167470a..6f5ef792e9b3 100644 --- a/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs +++ b/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs @@ -1,5 +1,5 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 // The PTX ABI stability is tied to major versions of the PTX ISA diff --git a/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs b/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs index c68c71c872c2..02ec9facee7a 100644 --- a/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs +++ b/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs @@ -1,5 +1,5 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 // The PTX ABI stability is tied to major versions of the PTX ISA diff --git a/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index f245b4460f2b..00f6fe9332d9 100644 --- a/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -1,5 +1,5 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 // The following ABI tests are made with nvcc 11.6 does. diff --git a/tests/assembly-llvm/nvptx-safe-naming.rs b/tests/assembly-llvm/nvptx-safe-naming.rs index c70c63b7ee7c..85415b6ca5b5 100644 --- a/tests/assembly-llvm/nvptx-safe-naming.rs +++ b/tests/assembly-llvm/nvptx-safe-naming.rs @@ -1,5 +1,5 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc +//@ compile-flags: --crate-type cdylib //@ only-nvptx64 //@ revisions: LLVM20 LLVM21 //@ [LLVM21] min-llvm-version: 21 From 81d86bf0ebe38897ba1c79cb9a340a1342e0f22a Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 Dec 2025 22:03:57 +0100 Subject: [PATCH 339/489] Add regression test for remap-path-prefix handling in rustdoc for deps --- tests/rustdoc/auxiliary/remapped-paths.rs | 11 +++++++++++ tests/rustdoc/import-remapped-paths.rs | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/rustdoc/auxiliary/remapped-paths.rs create mode 100644 tests/rustdoc/import-remapped-paths.rs diff --git a/tests/rustdoc/auxiliary/remapped-paths.rs b/tests/rustdoc/auxiliary/remapped-paths.rs new file mode 100644 index 000000000000..f31d2d316f3a --- /dev/null +++ b/tests/rustdoc/auxiliary/remapped-paths.rs @@ -0,0 +1,11 @@ +//@ compile-flags:-Zunstable-options --remap-path-prefix={{src-base}}= + +pub struct MyStruct { + field: u32, +} + +impl MyStruct { + pub fn new() -> MyStruct { + MyStruct { field: 3 } + } +} diff --git a/tests/rustdoc/import-remapped-paths.rs b/tests/rustdoc/import-remapped-paths.rs new file mode 100644 index 000000000000..c90ef4df1c0f --- /dev/null +++ b/tests/rustdoc/import-remapped-paths.rs @@ -0,0 +1,20 @@ +// This is a regression for `--remap-path-prefix` in an auxiliary dependency. +// +// We want to make sure that we can still have the "Source" links to the dependency +// even if it's paths are remapped. +// +// See also rust-lang/rust#150100 + +//@ aux-build:remapped-paths.rs +//@ build-aux-docs + +#![crate_name = "foo"] + +extern crate remapped_paths; + +//@ has foo/struct.MyStruct.html +// FIXME: Doesn't work! +//@ has - '//a[@href="../src/remapped_paths/remapped-paths.rs.html#3"]' 'Source' +//@ has - '//a[@href="../src/remapped_paths/remapped-paths.rs.html#8"]' 'Source' + +pub use remapped_paths::MyStruct; From 811c241b3d873880fe9bd4b9b36b37a3cdf3f70d Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 18 Dec 2025 23:37:51 +0100 Subject: [PATCH 340/489] Handle remapped paths correctly when generating "Source" links --- src/librustdoc/html/render/context.rs | 17 +++++++++++------ tests/rustdoc/import-remapped-paths.rs | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index ee71564a1417..4d9e352595a1 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -14,7 +14,7 @@ use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; -use rustc_span::{BytePos, FileName, Symbol}; +use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Symbol}; use tracing::info; use super::print_item::{full_path, print_item, print_item_path}; @@ -365,7 +365,10 @@ impl<'tcx> Context<'tcx> { // We can safely ignore synthetic `SourceFile`s. let file = match span.filename(self.sess()) { - FileName::Real(ref path) => path.local_path()?.to_path_buf(), + FileName::Real(ref path) => path + .local_path() + .unwrap_or(path.path(RemapPathScopeComponents::MACRO)) + .to_path_buf(), _ => return None, }; let file = &file; @@ -499,10 +502,12 @@ impl<'tcx> Context<'tcx> { } = options; let src_root = match krate.src(tcx) { - FileName::Real(ref p) => match p.local_path().map(|p| p.parent()).flatten() { - Some(p) => p.to_path_buf(), - None => PathBuf::new(), - }, + FileName::Real(ref p) => { + match p.local_path().unwrap_or(p.path(RemapPathScopeComponents::MACRO)).parent() { + Some(p) => p.to_path_buf(), + None => PathBuf::new(), + } + } _ => PathBuf::new(), }; // If user passed in `--playground-url` arg, we fill in crate name here diff --git a/tests/rustdoc/import-remapped-paths.rs b/tests/rustdoc/import-remapped-paths.rs index c90ef4df1c0f..bce3d782b9c2 100644 --- a/tests/rustdoc/import-remapped-paths.rs +++ b/tests/rustdoc/import-remapped-paths.rs @@ -13,7 +13,6 @@ extern crate remapped_paths; //@ has foo/struct.MyStruct.html -// FIXME: Doesn't work! //@ has - '//a[@href="../src/remapped_paths/remapped-paths.rs.html#3"]' 'Source' //@ has - '//a[@href="../src/remapped_paths/remapped-paths.rs.html#8"]' 'Source' From 2581c2571c904c180ec8dc2b0242413a5b251358 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 Dec 2025 18:13:07 +0100 Subject: [PATCH 341/489] Don't lint on interior mutable `const` item coming from derefs --- .../rustc_lint/src/interior_mutable_consts.rs | 8 ++++ ...nst-item-interior-mutations-const-deref.rs | 2 - ...item-interior-mutations-const-deref.stderr | 37 ------------------- 3 files changed, 8 insertions(+), 39 deletions(-) delete mode 100644 tests/ui/lint/const-item-interior-mutations-const-deref.stderr diff --git a/compiler/rustc_lint/src/interior_mutable_consts.rs b/compiler/rustc_lint/src/interior_mutable_consts.rs index 8576698dec33..4c7d2c6af93b 100644 --- a/compiler/rustc_lint/src/interior_mutable_consts.rs +++ b/compiler/rustc_lint/src/interior_mutable_consts.rs @@ -1,6 +1,7 @@ use rustc_hir::attrs::AttributeKind; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Expr, ExprKind, ItemKind, Node, find_attr}; +use rustc_middle::ty::adjustment::Adjust; use rustc_session::{declare_lint, declare_lint_pass}; use crate::lints::{ConstItemInteriorMutationsDiag, ConstItemInteriorMutationsSuggestionStatic}; @@ -77,6 +78,13 @@ impl<'tcx> LateLintPass<'tcx> for InteriorMutableConsts { if let ExprKind::Path(qpath) = &receiver.kind && let Res::Def(DefKind::Const | DefKind::AssocConst, const_did) = typeck.qpath_res(qpath, receiver.hir_id) + // Don't consider derefs as those can do arbitrary things + // like using thread local (see rust-lang/rust#150157) + && !cx + .typeck_results() + .expr_adjustments(receiver) + .into_iter() + .any(|adj| matches!(adj.kind, Adjust::Deref(_))) // Let's do the attribute check after the other checks for perf reasons && find_attr!( cx.tcx.get_all_attrs(method_did), diff --git a/tests/ui/lint/const-item-interior-mutations-const-deref.rs b/tests/ui/lint/const-item-interior-mutations-const-deref.rs index ce684abacccd..021e0952da70 100644 --- a/tests/ui/lint/const-item-interior-mutations-const-deref.rs +++ b/tests/ui/lint/const-item-interior-mutations-const-deref.rs @@ -24,7 +24,5 @@ const LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; fn main() { let count = LOCAL_COUNT.get(); - //~^ WARN mutation of an interior mutable `const` LOCAL_COUNT.set(count); - //~^ WARN mutation of an interior mutable `const` } diff --git a/tests/ui/lint/const-item-interior-mutations-const-deref.stderr b/tests/ui/lint/const-item-interior-mutations-const-deref.stderr deleted file mode 100644 index 35696d0ba100..000000000000 --- a/tests/ui/lint/const-item-interior-mutations-const-deref.stderr +++ /dev/null @@ -1,37 +0,0 @@ -warning: mutation of an interior mutable `const` item with call to `get` - --> $DIR/const-item-interior-mutations-const-deref.rs:26:17 - | -LL | let count = LOCAL_COUNT.get(); - | -----------^^^^^^ - | | - | `LOCAL_COUNT` is a interior mutable `const` item of type `LocalKey>` - | - = note: each usage of a `const` item creates a new temporary - = note: only the temporaries and never the original `const LOCAL_COUNT` will be modified - = help: for more details on interior mutability see - = note: `#[warn(const_item_interior_mutations)]` on by default -help: for a shared instance of `LOCAL_COUNT`, consider making it a `static` item instead - | -LL - const LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; -LL + static LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; - | - -warning: mutation of an interior mutable `const` item with call to `set` - --> $DIR/const-item-interior-mutations-const-deref.rs:28:5 - | -LL | LOCAL_COUNT.set(count); - | -----------^^^^^^^^^^^ - | | - | `LOCAL_COUNT` is a interior mutable `const` item of type `LocalKey>` - | - = note: each usage of a `const` item creates a new temporary - = note: only the temporaries and never the original `const LOCAL_COUNT` will be modified - = help: for more details on interior mutability see -help: for a shared instance of `LOCAL_COUNT`, consider making it a `static` item instead - | -LL - const LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; -LL + static LOCAL_COUNT: LocalKey> = LocalKey { inner: Cell::new(8) }; - | - -warning: 2 warnings emitted - From 90a33f69f4dce50ff60e5f8744f9174a31095edc Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Mon, 8 Dec 2025 10:08:32 +0000 Subject: [PATCH 342/489] replace version placeholder --- compiler/rustc_feature/src/accepted.rs | 6 ++--- compiler/rustc_feature/src/removed.rs | 2 +- compiler/rustc_feature/src/unstable.rs | 4 +-- .../alloc/src/collections/vec_deque/mod.rs | 4 +-- library/alloc/src/fmt.rs | 2 +- library/alloc/src/string.rs | 2 +- library/alloc/src/vec/mod.rs | 2 +- library/core/src/char/methods.rs | 4 +-- library/core/src/fmt/builders.rs | 8 +++--- library/core/src/fmt/mod.rs | 2 +- library/core/src/mem/maybe_uninit.rs | 16 ++++++------ library/core/src/num/int_macros.rs | 12 ++++----- library/core/src/num/uint_macros.rs | 8 +++--- library/core/src/ptr/const_ptr.rs | 4 +-- library/core/src/ptr/mut_ptr.rs | 4 +-- library/core/src/slice/mod.rs | 8 +++--- library/core/src/time.rs | 4 +-- library/std/src/lib.rs | 2 +- library/std_detect/src/detect/arch/mod.rs | 2 +- library/std_detect/src/detect/arch/s390x.rs | 26 +++++++++---------- 20 files changed, 61 insertions(+), 61 deletions(-) diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 7e765918d7b6..13c1f2219bed 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -61,7 +61,7 @@ declare_features! ( /// Allows explicit discriminants on non-unit enum variants. (accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)), /// Allows #[cfg(...)] on inline assembly templates and operands. - (accepted, asm_cfg, "CURRENT_RUSTC_VERSION", Some(140364)), + (accepted, asm_cfg, "1.93.0", Some(140364)), /// Allows using `const` operands in inline assembly. (accepted, asm_const, "1.82.0", Some(93332)), /// Allows using `label` operands in inline assembly. @@ -218,7 +218,7 @@ declare_features! ( /// Allows access to crate names passed via `--extern` through prelude. (accepted, extern_prelude, "1.30.0", Some(44660)), /// Allows using `system` as a calling convention with varargs. - (accepted, extern_system_varargs, "CURRENT_RUSTC_VERSION", Some(136946)), + (accepted, extern_system_varargs, "1.93.0", Some(136946)), /// Allows using F16C intrinsics from `core::arch::{x86, x86_64}`. (accepted, f16c_target_feature, "1.68.0", Some(44839)), /// Allows field shorthands (`x` meaning `x: x`) in struct literal expressions. @@ -392,7 +392,7 @@ declare_features! ( /// Allows code like `let x: &'static u32 = &42` to work (RFC 1414). (accepted, rvalue_static_promotion, "1.21.0", Some(38865)), /// Allows use of the `vector` and related s390x target features. - (accepted, s390x_target_feature_vector, "CURRENT_RUSTC_VERSION", Some(145649)), + (accepted, s390x_target_feature_vector, "1.93.0", Some(145649)), /// Allows `Self` in type definitions (RFC 2300). (accepted, self_in_typedefs, "1.32.0", Some(49303)), /// Allows `Self` struct constructor (RFC 2302). diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index cd61facb39bb..e5d66364c2a6 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -190,7 +190,7 @@ declare_features! ( /// Allows use of unary negate on unsigned integers, e.g., -e for e: u8 (removed, negate_unsigned, "1.0.0", Some(29645), None), /// Allows diverging expressions to fall back to `!` rather than `()`. - (removed, never_type_fallback, "CURRENT_RUSTC_VERSION", Some(65992), Some("removed in favor of unconditional fallback"), 148871), + (removed, never_type_fallback, "1.93.0", Some(65992), Some("removed in favor of unconditional fallback"), 148871), /// Allows `#[no_coverage]` on functions. /// The feature was renamed to `coverage_attribute` and the attribute to `#[coverage(on|off)]` (removed, no_coverage, "1.74.0", Some(84605), Some("renamed to `coverage_attribute`"), 114656), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index f0a1f1416859..692cba8035c4 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -412,7 +412,7 @@ declare_features! ( (unstable, c_variadic, "1.34.0", Some(44930)), /// Allows defining c-variadic naked functions with any extern ABI that is allowed /// on c-variadic foreign functions. - (unstable, c_variadic_naked_functions, "CURRENT_RUSTC_VERSION", Some(148767)), + (unstable, c_variadic_naked_functions, "1.93.0", Some(148767)), /// Allows the use of `#[cfg(contract_checks)` to check if contract checks are enabled. (unstable, cfg_contract_checks, "1.86.0", Some(128044)), /// Allows the use of `#[cfg(overflow_checks)` to check if integer overflow behaviour. @@ -486,7 +486,7 @@ declare_features! ( /// Allows deriving the From trait on single-field structs. (unstable, derive_from, "1.91.0", Some(144889)), /// Allows giving non-const impls custom diagnostic messages if attempted to be used as const - (unstable, diagnostic_on_const, "CURRENT_RUSTC_VERSION", Some(143874)), + (unstable, diagnostic_on_const, "1.93.0", Some(143874)), /// Allows `#[doc(cfg(...))]`. (unstable, doc_cfg, "1.21.0", Some(43781)), /// Allows `#[doc(masked)]`. diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index ea9d5b128ebe..0e01d0d19e7a 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2053,7 +2053,7 @@ impl VecDeque { /// assert_eq!(deque, [1, 2, 3, 4]); /// assert_eq!(deque.pop_front_if(pred), None); /// ``` - #[stable(feature = "vec_deque_pop_if", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "vec_deque_pop_if", since = "1.93.0")] pub fn pop_front_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option { let first = self.front_mut()?; if predicate(first) { self.pop_front() } else { None } @@ -2075,7 +2075,7 @@ impl VecDeque { /// assert_eq!(deque, [0, 1, 2, 3]); /// assert_eq!(deque.pop_back_if(pred), None); /// ``` - #[stable(feature = "vec_deque_pop_if", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "vec_deque_pop_if", since = "1.93.0")] pub fn pop_back_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option { let last = self.back_mut()?; if predicate(last) { self.pop_back() } else { None } diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 4d6fe220a09a..3d7c580be8c9 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -602,7 +602,7 @@ pub use core::fmt::{DebugAsHex, FormattingOptions, Sign}; pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::fmt::{Formatter, Result, Write}; -#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "fmt_from_fn", since = "1.93.0")] pub use core::fmt::{FromFn, from_fn}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::fmt::{LowerExp, UpperExp}; diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 64abdca32d21..e400fc9e00ed 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -934,7 +934,7 @@ impl String { /// assert_eq!(rebuilt, "hello"); /// ``` #[must_use = "losing the pointer will leak memory"] - #[stable(feature = "vec_into_raw_parts", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "vec_into_raw_parts", since = "1.93.0")] pub fn into_raw_parts(self) -> (*mut u8, usize, usize) { self.vec.into_raw_parts() } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index d2bc5d9bce39..f8a96e358d6d 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -834,7 +834,7 @@ impl Vec { /// assert_eq!(rebuilt, [4294967295, 0, 1]); /// ``` #[must_use = "losing the pointer will leak memory"] - #[stable(feature = "vec_into_raw_parts", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "vec_into_raw_parts", since = "1.93.0")] pub fn into_raw_parts(self) -> (*mut T, usize, usize) { let mut me = ManuallyDrop::new(self); (me.as_mut_ptr(), me.len(), me.capacity()) diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index d1de2c560615..89cb06972392 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -74,12 +74,12 @@ impl char { /// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to /// UTF-8 encoding. - #[stable(feature = "char_max_len_assoc", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "char_max_len_assoc", since = "1.93.0")] pub const MAX_LEN_UTF8: usize = 4; /// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char` /// to UTF-16 encoding. - #[stable(feature = "char_max_len_assoc", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "char_max_len_assoc", since = "1.93.0")] pub const MAX_LEN_UTF16: usize = 2; /// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index 4ea6c6ba8fb9..197cddd3fa9d 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -1226,7 +1226,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// assert_eq!(format!("{}", wrapped), "'a'"); /// assert_eq!(format!("{:?}", wrapped), "'a'"); /// ``` -#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "fmt_from_fn", since = "1.93.0")] #[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"] pub fn from_fn) -> fmt::Result>(f: F) -> FromFn { FromFn(f) @@ -1235,10 +1235,10 @@ pub fn from_fn) -> fmt::Result>(f: F) -> FromFn /// Implements [`fmt::Debug`] and [`fmt::Display`] via the provided closure. /// /// Created with [`from_fn`]. -#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "fmt_from_fn", since = "1.93.0")] pub struct FromFn(F); -#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "fmt_from_fn", since = "1.93.0")] impl fmt::Debug for FromFn where F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result, @@ -1248,7 +1248,7 @@ where } } -#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "fmt_from_fn", since = "1.93.0")] impl fmt::Display for FromFn where F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result, diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 7a80023ce64e..e20109c3cc9a 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -41,7 +41,7 @@ pub use num_buffer::{NumBuffer, NumBufferTrait}; #[stable(feature = "debug_builders", since = "1.2.0")] pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; -#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")] +#[stable(feature = "fmt_from_fn", since = "1.93.0")] pub use self::builders::{FromFn, from_fn}; /// The type returned by formatter methods. diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 1f066697fa48..e0001153a6e7 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -1139,8 +1139,8 @@ impl [MaybeUninit] { /// ``` /// /// [`write_clone_of_slice`]: slice::write_clone_of_slice - #[stable(feature = "maybe_uninit_write_slice", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "maybe_uninit_write_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "maybe_uninit_write_slice", since = "1.93.0")] + #[rustc_const_stable(feature = "maybe_uninit_write_slice", since = "1.93.0")] pub const fn write_copy_of_slice(&mut self, src: &[T]) -> &mut [T] where T: Copy, @@ -1200,7 +1200,7 @@ impl [MaybeUninit] { /// ``` /// /// [`write_copy_of_slice`]: slice::write_copy_of_slice - #[stable(feature = "maybe_uninit_write_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "maybe_uninit_write_slice", since = "1.93.0")] pub fn write_clone_of_slice(&mut self, src: &[T]) -> &mut [T] where T: Clone, @@ -1462,7 +1462,7 @@ impl [MaybeUninit] { /// requirement the compiler knows about it is that the data pointer must be /// non-null. Dropping such a `Vec` however will cause undefined /// behaviour. - #[stable(feature = "maybe_uninit_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "maybe_uninit_slice", since = "1.93.0")] #[inline(always)] #[rustc_const_unstable(feature = "const_drop_in_place", issue = "109342")] pub const unsafe fn assume_init_drop(&mut self) @@ -1484,8 +1484,8 @@ impl [MaybeUninit] { /// Calling this when the content is not yet fully initialized causes undefined /// behavior: it is up to the caller to guarantee that every `MaybeUninit` in /// the slice really is in an initialized state. - #[stable(feature = "maybe_uninit_slice", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "maybe_uninit_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "maybe_uninit_slice", since = "1.93.0")] + #[rustc_const_stable(feature = "maybe_uninit_slice", since = "1.93.0")] #[inline(always)] pub const unsafe fn assume_init_ref(&self) -> &[T] { // SAFETY: casting `slice` to a `*const [T]` is safe since the caller guarantees that @@ -1503,8 +1503,8 @@ impl [MaybeUninit] { /// behavior: it is up to the caller to guarantee that every `MaybeUninit` in the /// slice really is in an initialized state. For instance, `.assume_init_mut()` cannot /// be used to initialize a `MaybeUninit` slice. - #[stable(feature = "maybe_uninit_slice", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "maybe_uninit_slice", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "maybe_uninit_slice", since = "1.93.0")] + #[rustc_const_stable(feature = "maybe_uninit_slice", since = "1.93.0")] #[inline(always)] pub const unsafe fn assume_init_mut(&mut self) -> &mut [T] { // SAFETY: similar to safety notes for `slice_get_ref`, but we have a diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index f5672f7106e5..f49f5f3c3afb 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -1275,8 +1275,8 @@ macro_rules! int_impl { /// i.e. when [`checked_neg`] would return `None`. /// #[doc = concat!("[`checked_neg`]: ", stringify!($SelfT), "::checked_neg")] - #[stable(feature = "unchecked_neg", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "unchecked_neg", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unchecked_neg", since = "1.93.0")] + #[rustc_const_stable(feature = "unchecked_neg", since = "1.93.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -1392,8 +1392,8 @@ macro_rules! int_impl { /// i.e. when [`checked_shl`] would return `None`. /// #[doc = concat!("[`checked_shl`]: ", stringify!($SelfT), "::checked_shl")] - #[stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unchecked_shifts", since = "1.93.0")] + #[rustc_const_stable(feature = "unchecked_shifts", since = "1.93.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -1564,8 +1564,8 @@ macro_rules! int_impl { /// i.e. when [`checked_shr`] would return `None`. /// #[doc = concat!("[`checked_shr`]: ", stringify!($SelfT), "::checked_shr")] - #[stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unchecked_shifts", since = "1.93.0")] + #[rustc_const_stable(feature = "unchecked_shifts", since = "1.93.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index f129fc56a77c..bf901c9b4ad3 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -1851,8 +1851,8 @@ macro_rules! uint_impl { /// i.e. when [`checked_shl`] would return `None`. /// #[doc = concat!("[`checked_shl`]: ", stringify!($SelfT), "::checked_shl")] - #[stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unchecked_shifts", since = "1.93.0")] + #[rustc_const_stable(feature = "unchecked_shifts", since = "1.93.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -2020,8 +2020,8 @@ macro_rules! uint_impl { /// i.e. when [`checked_shr`] would return `None`. /// #[doc = concat!("[`checked_shr`]: ", stringify!($SelfT), "::checked_shr")] - #[stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "unchecked_shifts", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "unchecked_shifts", since = "1.93.0")] + #[rustc_const_stable(feature = "unchecked_shifts", since = "1.93.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 2860bf0a6e69..00b71f9a997c 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1462,8 +1462,8 @@ impl *const [T] { /// Gets a raw pointer to the underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "core_slice_as_array", since = "1.93.0")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "1.93.0")] #[inline] #[must_use] pub const fn as_array(self) -> Option<*const [T; N]> { diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index f8dc6ef7ed71..8976154c61db 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1712,8 +1712,8 @@ impl *mut [T] { /// Gets a raw, mutable pointer to the underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "core_slice_as_array", since = "1.93.0")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "1.93.0")] #[inline] #[must_use] pub const fn as_mut_array(self) -> Option<*mut [T; N]> { diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 256252f73e0b..889fd4cd65df 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -842,8 +842,8 @@ impl [T] { /// Gets a reference to the underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "core_slice_as_array", since = "1.93.0")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "1.93.0")] #[inline] #[must_use] pub const fn as_array(&self) -> Option<&[T; N]> { @@ -861,8 +861,8 @@ impl [T] { /// Gets a mutable reference to the slice's underlying array. /// /// If `N` is not exactly equal to the length of `self`, then this method returns `None`. - #[stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "core_slice_as_array", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "core_slice_as_array", since = "1.93.0")] + #[rustc_const_stable(feature = "core_slice_as_array", since = "1.93.0")] #[inline] #[must_use] pub const fn as_mut_array(&mut self) -> Option<&mut [T; N]> { diff --git a/library/core/src/time.rs b/library/core/src/time.rs index b85179e925d1..940129d68816 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -325,8 +325,8 @@ impl Duration { /// assert_eq!(10_u64.pow(15), duration.as_secs()); /// assert_eq!(321, duration.subsec_nanos()); /// ``` - #[stable(feature = "duration_from_nanos_u128", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "duration_from_nanos_u128", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "duration_from_nanos_u128", since = "1.93.0")] + #[rustc_const_stable(feature = "duration_from_nanos_u128", since = "1.93.0")] #[must_use] #[inline] #[track_caller] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 8fb1b1b05d20..508a6ed85261 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -667,7 +667,7 @@ pub mod arch { pub use std_detect::is_loongarch_feature_detected; #[unstable(feature = "is_riscv_feature_detected", issue = "111192")] pub use std_detect::is_riscv_feature_detected; - #[stable(feature = "stdarch_s390x_feature_detection", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")] pub use std_detect::is_s390x_feature_detected; #[stable(feature = "simd_x86", since = "1.27.0")] pub use std_detect::is_x86_feature_detected; diff --git a/library/std_detect/src/detect/arch/mod.rs b/library/std_detect/src/detect/arch/mod.rs index 23e7a30b985b..2be7f091c285 100644 --- a/library/std_detect/src/detect/arch/mod.rs +++ b/library/std_detect/src/detect/arch/mod.rs @@ -60,7 +60,7 @@ cfg_select! { pub use loongarch::*; } target_arch = "s390x" => { - #[stable(feature = "stdarch_s390x_feature_detection", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")] pub use s390x::*; } _ => { diff --git a/library/std_detect/src/detect/arch/s390x.rs b/library/std_detect/src/detect/arch/s390x.rs index 6122e8f5b837..a04283f90a02 100644 --- a/library/std_detect/src/detect/arch/s390x.rs +++ b/library/std_detect/src/detect/arch/s390x.rs @@ -9,7 +9,7 @@ features! { /// /// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`) /// the macro expands to `true`. - #[stable(feature = "stdarch_s390x_feature_detection", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")] @FEATURE: #[unstable(feature = "s390x_target_feature", issue = "44839")] concurrent_functions: "concurrent-functions"; /// s390x concurrent-functions facility @FEATURE: #[unstable(feature = "s390x_target_feature", issue = "44839")] deflate_conversion: "deflate-conversion"; @@ -32,30 +32,30 @@ features! { /// s390x message-security-assist-extension9 facility @FEATURE: #[unstable(feature = "s390x_target_feature", issue = "44839")] message_security_assist_extension12: "message-security-assist-extension12"; /// s390x message-security-assist-extension12 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] miscellaneous_extensions_2: "miscellaneous-extensions-2"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] miscellaneous_extensions_2: "miscellaneous-extensions-2"; /// s390x miscellaneous-extensions-2 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] miscellaneous_extensions_3: "miscellaneous-extensions-3"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] miscellaneous_extensions_3: "miscellaneous-extensions-3"; /// s390x miscellaneous-extensions-3 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] miscellaneous_extensions_4: "miscellaneous-extensions-4"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] miscellaneous_extensions_4: "miscellaneous-extensions-4"; /// s390x miscellaneous-extensions-4 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] nnp_assist: "nnp-assist"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] nnp_assist: "nnp-assist"; /// s390x nnp-assist facility @FEATURE: #[unstable(feature = "s390x_target_feature", issue = "44839")] transactional_execution: "transactional-execution"; /// s390x transactional-execution facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector: "vector"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector: "vector"; /// s390x vector facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_enhancements_1: "vector-enhancements-1"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_enhancements_1: "vector-enhancements-1"; /// s390x vector-enhancements-1 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_enhancements_2: "vector-enhancements-2"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_enhancements_2: "vector-enhancements-2"; /// s390x vector-enhancements-2 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_enhancements_3: "vector-enhancements-3"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_enhancements_3: "vector-enhancements-3"; /// s390x vector-enhancements-3 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_packed_decimal: "vector-packed-decimal"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal: "vector-packed-decimal"; /// s390x vector-packed-decimal facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_packed_decimal_enhancement: "vector-packed-decimal-enhancement"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal_enhancement: "vector-packed-decimal-enhancement"; /// s390x vector-packed-decimal-enhancement facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_packed_decimal_enhancement_2: "vector-packed-decimal-enhancement-2"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal_enhancement_2: "vector-packed-decimal-enhancement-2"; /// s390x vector-packed-decimal-enhancement-2 facility - @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "CURRENT_RUSTC_VERSION")] vector_packed_decimal_enhancement_3: "vector-packed-decimal-enhancement-3"; + @FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal_enhancement_3: "vector-packed-decimal-enhancement-3"; /// s390x vector-packed-decimal-enhancement-3 facility } From 93fc20360622338bafa1d94184dfff7278e20e00 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 10 Dec 2025 05:41:49 +0000 Subject: [PATCH 343/489] bump stage0 --- src/stage0 | 1060 ++++++++++++++++++++++++++-------------------------- 1 file changed, 538 insertions(+), 522 deletions(-) diff --git a/src/stage0 b/src/stage0 index 0e4e9eb1c4b9..66b652a844f3 100644 --- a/src/stage0 +++ b/src/stage0 @@ -13,528 +13,544 @@ nightly_branch=main # All changes below this comment will be overridden the next time the # tool is executed. -compiler_channel_manifest_hash=d8adf7e1722d2dc8ebdb327ee661e58a58145464bfcd9bb3cab66d652cc7bb90 -compiler_git_commit_hash=3b4dd9bf1410f8da6329baa36ce5e37673cbbd1f -compiler_date=2025-10-28 +compiler_channel_manifest_hash=936fefc9b8e88ef79db59e6dee693b757f35a98c87698b65206dca1118850996 +compiler_git_commit_hash=1b6e21e163baa0b20f119e17e3871910978a60b6 +compiler_date=2025-12-09 compiler_version=beta -rustfmt_channel_manifest_hash=108599f303463cabaef3b53ab5e0c0e560a6a5a97f606d75a802efb595141baf -rustfmt_git_commit_hash=adaa838976ff99a4f0661136322f64cb466b58a0 -rustfmt_date=2025-10-28 +rustfmt_channel_manifest_hash=8a4b2700918bd32bda5cbab3da25fc4ea1bee06bb24ef24d1df890997ef35a51 +rustfmt_git_commit_hash=c61a3a44d1a5bee35914cada6c788a05e0808f5b +rustfmt_date=2025-12-10 rustfmt_version=nightly -dist/2025-10-28/rustc-beta-aarch64-apple-darwin.tar.gz=5d971d3a1c127d314f94f41440f0717b51692176630fef7f05a70d9bcd3bae44 -dist/2025-10-28/rustc-beta-aarch64-apple-darwin.tar.xz=2cedfc3a96acc9ebe82c5cf5bcf5355902a5726e1c28e7d50b15cfa2ee343174 -dist/2025-10-28/rustc-beta-aarch64-pc-windows-gnullvm.tar.gz=1875833b43088879444902023cc76682fa58f39520a1135e438afaacf3605f88 -dist/2025-10-28/rustc-beta-aarch64-pc-windows-gnullvm.tar.xz=a925fb02b296b8ce753ff7b1fae583a27fb2ef6de582a80f1428678a2f61a466 -dist/2025-10-28/rustc-beta-aarch64-pc-windows-msvc.tar.gz=28f423bb7db80232b887bd0d47243341a50611eca913c17c305dd55fa6bd3f12 -dist/2025-10-28/rustc-beta-aarch64-pc-windows-msvc.tar.xz=3be7d39a956afd591ba4b22785b4851fd6c0c7afd23d045c54d6b603cc14bc2d -dist/2025-10-28/rustc-beta-aarch64-unknown-linux-gnu.tar.gz=8b98b7e04ef03c3b2bc95e0d6e3a92ad7849bad8d5a8969d6c9eefe169673066 -dist/2025-10-28/rustc-beta-aarch64-unknown-linux-gnu.tar.xz=1b35688d58c10fdd1f1d02325022ae9eb36ee139f76ae753e16a0f4524d0f6d4 -dist/2025-10-28/rustc-beta-aarch64-unknown-linux-musl.tar.gz=c1de08dbaff419f08f82aef49972965d87e02054822e83e6e7f73714afbc4155 -dist/2025-10-28/rustc-beta-aarch64-unknown-linux-musl.tar.xz=2755a71cee31227e4638499dc882347ed9ecf0698cc64a177ff8a94c6ff3be8c -dist/2025-10-28/rustc-beta-arm-unknown-linux-gnueabi.tar.gz=dac50bed8e2bb5d65b5f6ea52963d2b268829c9f79800304a225e058152be0bd -dist/2025-10-28/rustc-beta-arm-unknown-linux-gnueabi.tar.xz=f818783e566cebc2ac392f923efd0ae8f51ae77ce6ade284514a57c21d288b7e -dist/2025-10-28/rustc-beta-arm-unknown-linux-gnueabihf.tar.gz=922d9d3aba6c5ac4da95ab9310d0f33ec7da4830a7d424b83d6f0181af96bccb -dist/2025-10-28/rustc-beta-arm-unknown-linux-gnueabihf.tar.xz=746a200dab88eec922dc08ea244ae818c27a0ca91360278e578ab9fc433bd3be -dist/2025-10-28/rustc-beta-armv7-unknown-linux-gnueabihf.tar.gz=ac45fe7547dc1064286de6704a9343e95fa760163247ac02ff88ebf2bf4d7d8c -dist/2025-10-28/rustc-beta-armv7-unknown-linux-gnueabihf.tar.xz=35ab727f335242d588742f79f29fb94590ac0c3bef29d012538f2e925cb9f96f -dist/2025-10-28/rustc-beta-i686-pc-windows-gnu.tar.gz=42eab38b498e0b8efd7fae51facd7caaf253e1bc341f915f978b484065e4c812 -dist/2025-10-28/rustc-beta-i686-pc-windows-gnu.tar.xz=d663982b6293285fa1ffcc5987ded64569216c0133476243b5525768cd6123bb -dist/2025-10-28/rustc-beta-i686-pc-windows-msvc.tar.gz=571eeccc9c1f25c4b9c2c6f45d15dbd9730bf6c0ac0f75a5b49652b6d4e98f68 -dist/2025-10-28/rustc-beta-i686-pc-windows-msvc.tar.xz=595a8b6b74910fa53a947ddde81f5519152f8c773a41a2f5b0d663540bc913fa -dist/2025-10-28/rustc-beta-i686-unknown-linux-gnu.tar.gz=3f2261279e5c16b0a4b572e799e2d3079aa33192e7713803214011e14c5c6707 -dist/2025-10-28/rustc-beta-i686-unknown-linux-gnu.tar.xz=c49c0e84b4b43aa6b72dc355173b4b5dc41563f3f76e882c405a8625c00befbc -dist/2025-10-28/rustc-beta-loongarch64-unknown-linux-gnu.tar.gz=92cea4e2708fbd86b35bc798b25a69ab10b62f28e972ff0624709e6e8268db60 -dist/2025-10-28/rustc-beta-loongarch64-unknown-linux-gnu.tar.xz=224f6e9896d19e00e369da70bc0e0dbd545d04033ff6ecff12b3f2d2bfe73fc8 -dist/2025-10-28/rustc-beta-loongarch64-unknown-linux-musl.tar.gz=74901d397d5f6695df197520d16851986df2a5c5d432b8f24da1a5c3a5c0474b -dist/2025-10-28/rustc-beta-loongarch64-unknown-linux-musl.tar.xz=02d8962da7234bfd365147b4177497a99c8f1f12f6841160abede61332edd35f -dist/2025-10-28/rustc-beta-powerpc-unknown-linux-gnu.tar.gz=b8d810c76102a325cdecb98e7d7fab480a8d349328ce8a275366018a627fa4bf -dist/2025-10-28/rustc-beta-powerpc-unknown-linux-gnu.tar.xz=f09c4e8d4a4ae4cf490e55bcd29ab00b6f7c1aed09c93b63f10fc3f812f415e7 -dist/2025-10-28/rustc-beta-powerpc64-unknown-linux-gnu.tar.gz=6c71850444d597cdc07a7169bd5d2564cbd99d1a34ec806ac8b818b39c9fd529 -dist/2025-10-28/rustc-beta-powerpc64-unknown-linux-gnu.tar.xz=01f3537787f41c2fd2ed1f955520ff0852bb27d899141cf44de3ae126abf8808 -dist/2025-10-28/rustc-beta-powerpc64le-unknown-linux-gnu.tar.gz=833dcfab6dc87d375154d593c8e53cd5c74b3029f8b94c753928de718185283c -dist/2025-10-28/rustc-beta-powerpc64le-unknown-linux-gnu.tar.xz=cf99a56b49b3db107d33f5c6e668310317aaeb2b2ca3c80a0ea2b30a09b453dd -dist/2025-10-28/rustc-beta-powerpc64le-unknown-linux-musl.tar.gz=55b1db794a4bb0f535e46a2c4a85eb7ea0016482b7086b6deae033746a42a69d -dist/2025-10-28/rustc-beta-powerpc64le-unknown-linux-musl.tar.xz=a741b18a92f5fa35cab2ed93d90782175b70e3ef5a127e21fde7acabb6228b59 -dist/2025-10-28/rustc-beta-riscv64gc-unknown-linux-gnu.tar.gz=97335caa2ace3f33cd959dc35f01ec8a3d2de5699518b93fd191766eda3fe318 -dist/2025-10-28/rustc-beta-riscv64gc-unknown-linux-gnu.tar.xz=2127853b7b4e2b3cf906ef292e9c7e370ec3f3760ce5576b447ed7902048794f -dist/2025-10-28/rustc-beta-s390x-unknown-linux-gnu.tar.gz=eb3df84c1a840cc69799ef0649972e5312afe59144700ba3652bd6083f48074a -dist/2025-10-28/rustc-beta-s390x-unknown-linux-gnu.tar.xz=16942680ea11ead1ab4d9d46d31389a14f237637a6877b278cd30a608446b787 -dist/2025-10-28/rustc-beta-sparcv9-sun-solaris.tar.gz=5c7848ab2b2cb181bd7f64cdbdc3b5b659b61850c14604a7977c35b9807daa48 -dist/2025-10-28/rustc-beta-sparcv9-sun-solaris.tar.xz=0f12cb118e253206ea74e7b1dabdda6e95bb0b10d47657aa4c560fa9ca28cf83 -dist/2025-10-28/rustc-beta-x86_64-apple-darwin.tar.gz=3c34e03deee0445864c7f5ebc89883db051a3c69b874a2daff658fb5dd364aba -dist/2025-10-28/rustc-beta-x86_64-apple-darwin.tar.xz=292d40e5ea57295ecd921a07fa11796771953d38793edcea9841a95e79d94ac2 -dist/2025-10-28/rustc-beta-x86_64-pc-solaris.tar.gz=6ac79775ff166ba76e663e8760ddf9625e06a28e5033d4d8cc570dcca73ca725 -dist/2025-10-28/rustc-beta-x86_64-pc-solaris.tar.xz=46c214af2c11ccb17529a991201624bad044d59c171c6f872468acb8523b6f96 -dist/2025-10-28/rustc-beta-x86_64-pc-windows-gnu.tar.gz=29067fc4a5e0f123c34a045a1b0d55f88170bc9f658584d50e32219cd5945854 -dist/2025-10-28/rustc-beta-x86_64-pc-windows-gnu.tar.xz=30c20794d0c244bd04dbd4de304ef3aea5ba11e26882f2a004680281f21e05b0 -dist/2025-10-28/rustc-beta-x86_64-pc-windows-gnullvm.tar.gz=6c6c7614b538d9bad498b3642321adf0b2b6cdd3b24706903a8eb2125c0c122a -dist/2025-10-28/rustc-beta-x86_64-pc-windows-gnullvm.tar.xz=09822c7d5bbf218d5113e902968b37719949997fd788523bf80400274f428986 -dist/2025-10-28/rustc-beta-x86_64-pc-windows-msvc.tar.gz=fcf05b8150cf7199e100f560854f6acb6874985a5cfbb00ead36914dc3fb66e9 -dist/2025-10-28/rustc-beta-x86_64-pc-windows-msvc.tar.xz=f5259f5b521ea10f093c522abd5bcec4e9dfb94ce3e384e3b53865a223e700d0 -dist/2025-10-28/rustc-beta-x86_64-unknown-freebsd.tar.gz=c3719366a9687d243483431231b86140e268bf2ce99e1ea1759a611524ea8ade -dist/2025-10-28/rustc-beta-x86_64-unknown-freebsd.tar.xz=015e02fb99098c31d502738e9e525d48ac6ca386e16f3ecb55235c7268d4abe7 -dist/2025-10-28/rustc-beta-x86_64-unknown-illumos.tar.gz=508acec5f2b092d09d55590e7fe921f7415aacc13c535532997776c4ebb86483 -dist/2025-10-28/rustc-beta-x86_64-unknown-illumos.tar.xz=f7437c9b0e747b0eccd7755a3ef551fa81194f23304ddb40ae44bca5782dda4b -dist/2025-10-28/rustc-beta-x86_64-unknown-linux-gnu.tar.gz=cd985cf21af999dbb76e25cb6c9b5ac5723e8cda8625cf511e7df2c98e7e735a -dist/2025-10-28/rustc-beta-x86_64-unknown-linux-gnu.tar.xz=d30acafe9f3ddfd25148abdd3078deaaafb6bb62f7979252e9e7880abc260b23 -dist/2025-10-28/rustc-beta-x86_64-unknown-linux-musl.tar.gz=1778c649d790e52b8462d5ea377339443e607b2434fa9b579236b465f63748c7 -dist/2025-10-28/rustc-beta-x86_64-unknown-linux-musl.tar.xz=909808e6e3a10cd3fc2c0927f47dbe4ac8de4653b4e771c9c44b8e58cbe5fe2d -dist/2025-10-28/rustc-beta-x86_64-unknown-netbsd.tar.gz=8584d5ad71c7cedcf6e64b0f83ed2cfa82346e88a1000acac677f464dbb0e6f6 -dist/2025-10-28/rustc-beta-x86_64-unknown-netbsd.tar.xz=7b85928ce5f6908ad82895097ba07fad70990b7810aa23c63725d7ecbbf54d54 -dist/2025-10-28/rust-std-beta-aarch64-apple-darwin.tar.gz=312c1121edf001f03ea169e8fff9668efd1925a45962b282b32d5f126bd6b010 -dist/2025-10-28/rust-std-beta-aarch64-apple-darwin.tar.xz=11e0fd642939358a892e66ebeea7f1737a009ad23692da486c7427cdce60c37d -dist/2025-10-28/rust-std-beta-aarch64-apple-ios.tar.gz=d7086698f3414ebf1410f79f8167ef2e4cf8e9143dc7e3704200d67e64252080 -dist/2025-10-28/rust-std-beta-aarch64-apple-ios.tar.xz=a71fd039b0bfa2fa7a1abd13c622c89371f7af273fc44b3c210b1ead6a1f9156 -dist/2025-10-28/rust-std-beta-aarch64-apple-ios-macabi.tar.gz=52795cad4c58b32c3f36fb7b596c25a8e3277c85c165e161445d1fc81e0c4200 -dist/2025-10-28/rust-std-beta-aarch64-apple-ios-macabi.tar.xz=7db4e584f7890bd05d7cf8a991f539be249e0f04526e30743575129dada977c2 -dist/2025-10-28/rust-std-beta-aarch64-apple-ios-sim.tar.gz=575b6d5185a71a4f4d29dc881f5dea5fe492d7b21a01c0bd9987cc212bb8ca25 -dist/2025-10-28/rust-std-beta-aarch64-apple-ios-sim.tar.xz=ea1c7896e21d0a89da399405611a25ec447ff71495a4b5d48501c9f8129b2a20 -dist/2025-10-28/rust-std-beta-aarch64-linux-android.tar.gz=f7a85a478dd9d55491a2395dda9539ab7898385782ef5be479362ba35e8be837 -dist/2025-10-28/rust-std-beta-aarch64-linux-android.tar.xz=4fc53a2be557540332410446f6f43f5e6339d10d8010c153d99d707df64a5ef1 -dist/2025-10-28/rust-std-beta-aarch64-pc-windows-gnullvm.tar.gz=99b3f95696883f18e3734d02c75a5dc91edac003b6d9627c5a32baac41f3c69c -dist/2025-10-28/rust-std-beta-aarch64-pc-windows-gnullvm.tar.xz=375db4717baaac6a784d8f53f84035f99d5f76f9a3f7df7dd385ee2d93027368 -dist/2025-10-28/rust-std-beta-aarch64-pc-windows-msvc.tar.gz=b650ca7708ae5b05fc82c7aa483f9aaa42be83d6bcc6c524690da745f32f6f60 -dist/2025-10-28/rust-std-beta-aarch64-pc-windows-msvc.tar.xz=1683d5a33387dd546ff641222b501e90049241df0f52c2f1a5dc568b35594135 -dist/2025-10-28/rust-std-beta-aarch64-unknown-fuchsia.tar.gz=3e2d64dd8d2fdedb30b25f899f8ed8deff653c4d3f3f7e16e534ab7e1eec8a66 -dist/2025-10-28/rust-std-beta-aarch64-unknown-fuchsia.tar.xz=e83d63666e0372f27d404a4ddf48de7abc5b646d9f087ebf8856bcbfe6f86362 -dist/2025-10-28/rust-std-beta-aarch64-unknown-linux-gnu.tar.gz=8a99f5fbaf869f68bced6435acf18127ac8880193fb23e44cb5791546bc795d7 -dist/2025-10-28/rust-std-beta-aarch64-unknown-linux-gnu.tar.xz=53be5ecbcb4d47e6a1fb811a6e8b4ecec7fd6ae2b6efac7d9934dee4cfb19dce -dist/2025-10-28/rust-std-beta-aarch64-unknown-linux-musl.tar.gz=f61af59bc40a53dddf0a85b5205bec90d287a41ee3ac32345a97d21861ae6546 -dist/2025-10-28/rust-std-beta-aarch64-unknown-linux-musl.tar.xz=9ed2894300f6ac917ac33d0724133ba2fada2ab2e42a0b21a9bd994d70c942f4 -dist/2025-10-28/rust-std-beta-aarch64-unknown-linux-ohos.tar.gz=70ad473c7d4934bab123afb8cff98773993fdbb73b4941f6022a25ef2942a223 -dist/2025-10-28/rust-std-beta-aarch64-unknown-linux-ohos.tar.xz=d0a06230a38c725ceed103c89e8031b541b7bc15a3646a1a3662d8147901b2fd -dist/2025-10-28/rust-std-beta-aarch64-unknown-none.tar.gz=90d4484a1e390e0d3edf25331d41f9b419730bd2e318e8927c4a891b2c035652 -dist/2025-10-28/rust-std-beta-aarch64-unknown-none.tar.xz=5b795b7378b6753fb2a8ea0ecef760009ffa05c9a4778815d2d2b4085baffe14 -dist/2025-10-28/rust-std-beta-aarch64-unknown-none-softfloat.tar.gz=52d0e13f1dc2083787d3294d5c3569b11227724ab4ced4ba9905ac0a5f25bde0 -dist/2025-10-28/rust-std-beta-aarch64-unknown-none-softfloat.tar.xz=981dca064b73d6617039bb35a32a17111445bc1ed9ba957525d227d3be9e8f6d -dist/2025-10-28/rust-std-beta-aarch64-unknown-uefi.tar.gz=fbb7066da0824513e4441bb59d4c6a6d4c8bc34f67ed79f67da3b8ec69ff3a4c -dist/2025-10-28/rust-std-beta-aarch64-unknown-uefi.tar.xz=c0bb51d8c513c0b5d597cbc00260bf2764595b12244906606c20ae6f98e0fc66 -dist/2025-10-28/rust-std-beta-arm-linux-androideabi.tar.gz=7cd5763f202c5679dc1bdc0e6551dc8093ee95a9b2d405ad8cbd31fcf232332c -dist/2025-10-28/rust-std-beta-arm-linux-androideabi.tar.xz=126b3a04432a3f6f5f1aef6f5e22deec98629da4a0809b0c7739911ae5e4b6cc -dist/2025-10-28/rust-std-beta-arm-unknown-linux-gnueabi.tar.gz=01bc31ad9812edeb11dc4b6c15d4bf80a325e286390829babd85176b91c38cfa -dist/2025-10-28/rust-std-beta-arm-unknown-linux-gnueabi.tar.xz=0b1c799856c8314afddfaa5109535535c36df31bb9188a319c1e45f4968a7079 -dist/2025-10-28/rust-std-beta-arm-unknown-linux-gnueabihf.tar.gz=8792d0115ba1d9b0e3bfefbd7a9ddf7859f7bbf8431ef32530b05ec7cf9c68b8 -dist/2025-10-28/rust-std-beta-arm-unknown-linux-gnueabihf.tar.xz=fc470db282fb0fab537e4b93a9498d4b4fc65cf014536905654cc2c14f82d245 -dist/2025-10-28/rust-std-beta-arm-unknown-linux-musleabi.tar.gz=fe82493d2a7f4a9566916beefcd7fb26301bd13b8b838b5251398ecac0c867ef -dist/2025-10-28/rust-std-beta-arm-unknown-linux-musleabi.tar.xz=b7cd0514db083e115d8aacceb3f7998da11f26e9f2be44137e8af2e2f9ac786e -dist/2025-10-28/rust-std-beta-arm-unknown-linux-musleabihf.tar.gz=0adc4e2e0f5bee4c28c81ba2cfd9796268e830d23b23b80c71121c30f08e3326 -dist/2025-10-28/rust-std-beta-arm-unknown-linux-musleabihf.tar.xz=8c98799e7b4c454cad130d0eb87e8ed59e0e7e64bb0513af8beb6d1d5f8e3ac7 -dist/2025-10-28/rust-std-beta-arm64ec-pc-windows-msvc.tar.gz=bb1da273578b508b9f397074438ecb2527a729e404d2820bd34d67dc8824106a -dist/2025-10-28/rust-std-beta-arm64ec-pc-windows-msvc.tar.xz=e004d91a9732284851d613a3c488909bc7d457b2053a1af45710aa4bbe3169e9 -dist/2025-10-28/rust-std-beta-armv5te-unknown-linux-gnueabi.tar.gz=7e6b5d4266306001366003cdc4fd4b60d700e86ec5dce01b58b0e73bd6a50c42 -dist/2025-10-28/rust-std-beta-armv5te-unknown-linux-gnueabi.tar.xz=170b32ea83d21436e744d11a56ea8e298278f8b9aa58fd82d6d788ff1e3258f3 -dist/2025-10-28/rust-std-beta-armv5te-unknown-linux-musleabi.tar.gz=8ee71b71a8e90b21d580f9e64cc115f182db8582cd6238f946e24fc32de27e65 -dist/2025-10-28/rust-std-beta-armv5te-unknown-linux-musleabi.tar.xz=9319475d974dce729182c3d99696bd5cf6a36257b1b80186f261d2885610ddb9 -dist/2025-10-28/rust-std-beta-armv7-linux-androideabi.tar.gz=71db2b02df33e229899f0dafc675572f2b4041400954f9145796edee7cd923d4 -dist/2025-10-28/rust-std-beta-armv7-linux-androideabi.tar.xz=0f331806b4523d61204f38f2d7ddd07e6f3dcda8a15806a9f01cb1747a587e8f -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-gnueabi.tar.gz=52f331579373b749fb1c7a6302a770a4be33008cdd9db4a5640208ba1ba7b540 -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-gnueabi.tar.xz=1e8c5dcc4cb672c4e8ba2862549cd281ea6802fb73701c885eaf5423673ab233 -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-gnueabihf.tar.gz=2d0dded898f567cbfa5605dcc09b1e44970e345a030ef91c806eafcac4470258 -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-gnueabihf.tar.xz=3a63913c874f30c8a68d5cbb62dc654ec9c3bf2f4488e1098034f60c51824bb7 -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-musleabi.tar.gz=24c341427a9b5a4d883e7f322a9c7760446896e8c2eeb1f8654b80cef00db6ea -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-musleabi.tar.xz=53c5607351479ad76c3450bcc81353633f2587aafda473487bb11e42f80d8523 -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-musleabihf.tar.gz=beda2ede28453b81588d639c18b36fa6e935e586723159e39ab9b714291c680a -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-musleabihf.tar.xz=f175a55fc81159e9a40407b1d97ea658239014cf0f5191a3533318e53ee1ff7f -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-ohos.tar.gz=db1f0cfd65d795d23a60d29e44f24e6174a0a516b998e65bd1964230c9c6c03c -dist/2025-10-28/rust-std-beta-armv7-unknown-linux-ohos.tar.xz=264efedfd340c095dfe08fc95a35c36392eda0d1c2c179e56c75b27685b90d7e -dist/2025-10-28/rust-std-beta-armv7a-none-eabi.tar.gz=578fe97f24afa73c155290bf7386594e8b18a4652f54477d7a4e3f6f3ada0b5a -dist/2025-10-28/rust-std-beta-armv7a-none-eabi.tar.xz=a373109143f701d266ba53b3fff32206d88f5dfabdd888ac988606fade0b4928 -dist/2025-10-28/rust-std-beta-armv7a-none-eabihf.tar.gz=b3d6ec33c14a034c621aaf7de6ec81f0a916e18f5acc933713cc479fc21af755 -dist/2025-10-28/rust-std-beta-armv7a-none-eabihf.tar.xz=6550b2a97ce84884aa0da9133b81703e08b6e57b65c2e93f310fad2559ea4a08 -dist/2025-10-28/rust-std-beta-armv7r-none-eabi.tar.gz=b50984f65ee8a9e8c1b62158d8e91cb976f7c36f6ebc3c70ccfcab2a3da26533 -dist/2025-10-28/rust-std-beta-armv7r-none-eabi.tar.xz=0227fe58cacca86a04d85860a1de852a29ab9ac1bfea7bc50c2f560b73951d8b -dist/2025-10-28/rust-std-beta-armv7r-none-eabihf.tar.gz=da5e26a7cb5b91d3b8ec4f1a02c81b0f538dbb416e10e9453f3fd9d5cfc08129 -dist/2025-10-28/rust-std-beta-armv7r-none-eabihf.tar.xz=9132e8a69bf5dbd144def8bc647c659304fa785612a0f68f2e1a2df5dc195e33 -dist/2025-10-28/rust-std-beta-armv8r-none-eabihf.tar.gz=a312253ad16ccffacd0d840cba85d290fb5d2580865de99887990eff96f58b45 -dist/2025-10-28/rust-std-beta-armv8r-none-eabihf.tar.xz=474813a75bd586e562cf76705bdabf37a915cda6edb45afe029cbcbe54be3cb5 -dist/2025-10-28/rust-std-beta-i586-unknown-linux-gnu.tar.gz=4be0898bb9da3e8d75cb9b4851d5119efdd3136eb10cf31a42109f188781b6ea -dist/2025-10-28/rust-std-beta-i586-unknown-linux-gnu.tar.xz=5a51fb1f2da0dd645c1eb6ce19f37f16f356042ba176ab109f8bcd4ad3514ad3 -dist/2025-10-28/rust-std-beta-i586-unknown-linux-musl.tar.gz=96f621043d426d00f6baec72f66db5d91940215ba3e6985bb823c7b02acbd7ff -dist/2025-10-28/rust-std-beta-i586-unknown-linux-musl.tar.xz=2e62b9a670e3ca1d892ab18da1cd4b2bd946395e35c3b7829dd4b03726a73e4c -dist/2025-10-28/rust-std-beta-i686-linux-android.tar.gz=6c3b0e8796cb87e1a0369b55a91e49d5129af929deb4b63a623cf68219679543 -dist/2025-10-28/rust-std-beta-i686-linux-android.tar.xz=682747e9ab2706e90b5071ce13e8bff21160987d42ed0565f8e0012acded5f40 -dist/2025-10-28/rust-std-beta-i686-pc-windows-gnu.tar.gz=e7afe1e6ccb84fcf03114a6a3fd7232b40d7b2005f31a00a02d9c8e092af8b5d -dist/2025-10-28/rust-std-beta-i686-pc-windows-gnu.tar.xz=99d64d295d7bc0befe84a1da5d888de3ee0daa67a027c8628f78c36ab53eb7b4 -dist/2025-10-28/rust-std-beta-i686-pc-windows-gnullvm.tar.gz=1b36e3979b73348b46a01961a2515bc6ae19a54924e63272cb1bca709a07bcf0 -dist/2025-10-28/rust-std-beta-i686-pc-windows-gnullvm.tar.xz=f579f144f9f653df8be318e4f5ba363116a538b840030d3cd5305f87e03b9e23 -dist/2025-10-28/rust-std-beta-i686-pc-windows-msvc.tar.gz=79de79f2ed569a93dcd57aba35c7995582dde8b633bafbf0fc43ab6a8fb9d152 -dist/2025-10-28/rust-std-beta-i686-pc-windows-msvc.tar.xz=8c3fdbeb815085aaa9d484f1b22d0adbcc829a88511df5930bb518b139d20801 -dist/2025-10-28/rust-std-beta-i686-unknown-freebsd.tar.gz=d25fbb684148778444743e9d651a6d36dc4527d42367bfa67eebc43200e6cc0f -dist/2025-10-28/rust-std-beta-i686-unknown-freebsd.tar.xz=32c6d84e419a72cb862294a110fc79a88b123c4180a3a64bd53c38b200c60f9a -dist/2025-10-28/rust-std-beta-i686-unknown-linux-gnu.tar.gz=577cec0f5fb83cd22a9256dcf7c74529d95572976f102a8a63eb1cb9550f0a6c -dist/2025-10-28/rust-std-beta-i686-unknown-linux-gnu.tar.xz=dc537d7c09efaeb054d2954689842c813b5e9d646fcad912005f4b10e137181d -dist/2025-10-28/rust-std-beta-i686-unknown-linux-musl.tar.gz=5713f1784a424f509f47f70e0bce2bf8ae82e1a16efab8cd771677988b37516b -dist/2025-10-28/rust-std-beta-i686-unknown-linux-musl.tar.xz=1a3dc46f4cb4e4c8e4f96e9835b1188242addcb7a5a8ebbe3ef614c3aef862c4 -dist/2025-10-28/rust-std-beta-i686-unknown-uefi.tar.gz=4c32dcb28c1fbaeb910c9c7c60ea7dfe50e6556663eb3f002b66ec3ed42bd7ed -dist/2025-10-28/rust-std-beta-i686-unknown-uefi.tar.xz=1683c1c2838a2693b2f08a9daf0626675623d6bccbc4c996fcda8489eac853a1 -dist/2025-10-28/rust-std-beta-loongarch64-unknown-linux-gnu.tar.gz=401945e68f2246d1f502d4ac63666d5443ca7fa2f81ce38e76fbb0647fed4643 -dist/2025-10-28/rust-std-beta-loongarch64-unknown-linux-gnu.tar.xz=9b8d7d2f8a4ebf1369718d8bd3ae6973c977cdcb7030ccea0542f9e28970c281 -dist/2025-10-28/rust-std-beta-loongarch64-unknown-linux-musl.tar.gz=ae351e8f921f0c3b8bcccafa0c84402e15ced7591debf82287e63bac0965801b -dist/2025-10-28/rust-std-beta-loongarch64-unknown-linux-musl.tar.xz=7d64ee15508ebb610abe61e1aa03607140302fdbe41200e82070be85312d4a07 -dist/2025-10-28/rust-std-beta-loongarch64-unknown-none.tar.gz=9f951f51a32a4f037f3548935a07208e14f3e67d29100954ae6fbf61a8e56c06 -dist/2025-10-28/rust-std-beta-loongarch64-unknown-none.tar.xz=80494d9d9e02d7a6f56a638d93253d087a4edb83d4662b4771bd1d5c2cba97b3 -dist/2025-10-28/rust-std-beta-loongarch64-unknown-none-softfloat.tar.gz=f23fd6331ba600a3a4350565ad11f51129ad13a248f35c37b9d485fab725b4ac -dist/2025-10-28/rust-std-beta-loongarch64-unknown-none-softfloat.tar.xz=03d765256191ab9fac9f37102fa4252f7efb05261c8d2464745826232351dcd7 -dist/2025-10-28/rust-std-beta-nvptx64-nvidia-cuda.tar.gz=509bcbeb245d69fcb828bf9f3fa4413d1d4d59a0e85ed28c4f412929c734aacf -dist/2025-10-28/rust-std-beta-nvptx64-nvidia-cuda.tar.xz=543aa41bd2ae544c0114cca0e5a50c15eb7ed78d3d132bf5b48f93f2f92b502d -dist/2025-10-28/rust-std-beta-powerpc-unknown-linux-gnu.tar.gz=d67670d0b9385f4433635a473548031d083fe14e1a407766fb1ae5c4762da93e -dist/2025-10-28/rust-std-beta-powerpc-unknown-linux-gnu.tar.xz=e2f403936d191b38347bbad4e9b9bd66270b23e9df238ba9b5d52f81aaebfdb8 -dist/2025-10-28/rust-std-beta-powerpc64-unknown-linux-gnu.tar.gz=15ef51a8fc10b2298db444d68130ef350414722133097d670b8106e8de68609b -dist/2025-10-28/rust-std-beta-powerpc64-unknown-linux-gnu.tar.xz=515151364a93fc458ab5f11831797d2d708b22d9a71c78f717cf89e4e593417a -dist/2025-10-28/rust-std-beta-powerpc64le-unknown-linux-gnu.tar.gz=8ea0204c3ac93828c5a72f671c12167d0b5120cde99bb797c8d839caeb3ba3d8 -dist/2025-10-28/rust-std-beta-powerpc64le-unknown-linux-gnu.tar.xz=138969d2a43b6c4d736a950f8ba5bc0ed5fc7868c7044623d389d8278727e759 -dist/2025-10-28/rust-std-beta-powerpc64le-unknown-linux-musl.tar.gz=a3423e7917b59232faaf855ad9b9cd3b23e5d2188aeb8636e2cef324d405beb4 -dist/2025-10-28/rust-std-beta-powerpc64le-unknown-linux-musl.tar.xz=36914d3ce6a2e5a56a2a394d2c5a461a7c8a40fc235b3552a658ab1ed7d786f6 -dist/2025-10-28/rust-std-beta-riscv32i-unknown-none-elf.tar.gz=dbc0b69f7eba79726bc08a0a6b357f9d818623d3cbe153dff5f2fcb31aeea61b -dist/2025-10-28/rust-std-beta-riscv32i-unknown-none-elf.tar.xz=39def1e42a80080159347b5e85bc666830a3a346c9b0e83eea8207e94659ed94 -dist/2025-10-28/rust-std-beta-riscv32im-unknown-none-elf.tar.gz=7aebf847c08b0eee42c77da8defc6b30439f4b6d29e4122802f02d029518a31e -dist/2025-10-28/rust-std-beta-riscv32im-unknown-none-elf.tar.xz=35c49b2df4b3e18e0ec8ac20ec8b9a4a81b69f026921d85a666e0a97a671045b -dist/2025-10-28/rust-std-beta-riscv32imac-unknown-none-elf.tar.gz=b10e9e0a0457db1441a9bfeb3c4b9a8b2af4d33518bc58a8ee1d3fa7546c0bb5 -dist/2025-10-28/rust-std-beta-riscv32imac-unknown-none-elf.tar.xz=8e210b59b95b3c8db109d978ea73a540478315fb49d4515ccf248aafa7517617 -dist/2025-10-28/rust-std-beta-riscv32imafc-unknown-none-elf.tar.gz=e2bfdac9e858f144db5e9ae79b494f1e09b2a012b18f0eaac96ce684a6a43e25 -dist/2025-10-28/rust-std-beta-riscv32imafc-unknown-none-elf.tar.xz=6d2f5e60af9f6824fe2078a58a6cb804e61116e4848e1502289e08b0b9a5196c -dist/2025-10-28/rust-std-beta-riscv32imc-unknown-none-elf.tar.gz=382f448ea95627ee9fbb3d42c32ab9ecffe21ea12c00810e4eb8e94553d463a9 -dist/2025-10-28/rust-std-beta-riscv32imc-unknown-none-elf.tar.xz=ad7f534565c1b97495bf29054c202d8fada0a0ddfa0cca110c14a8221c654cb9 -dist/2025-10-28/rust-std-beta-riscv64gc-unknown-linux-gnu.tar.gz=7c8cf6afaa4edb589259dcc61ec5e1e667a5deeace8e277f752a433f20bcbf8d -dist/2025-10-28/rust-std-beta-riscv64gc-unknown-linux-gnu.tar.xz=8a396e9db63f1352bfde7a0d51446dabe6873c9a0a46e3c74f59ee775092e2af -dist/2025-10-28/rust-std-beta-riscv64gc-unknown-linux-musl.tar.gz=551d398055ee522ec4a67a9173daca7a1f0f537ab006383ed2ada6b00cc81cbc -dist/2025-10-28/rust-std-beta-riscv64gc-unknown-linux-musl.tar.xz=cf08dcb74f961bff041ad52efcae0c8e239e6439ecdcb32f869eb57b1a3aea1d -dist/2025-10-28/rust-std-beta-riscv64gc-unknown-none-elf.tar.gz=fd4e49a23ea0d512ed32bbaaefc1e5ea32c837e9a371513b94643966afabc521 -dist/2025-10-28/rust-std-beta-riscv64gc-unknown-none-elf.tar.xz=10700fa42e00a3b58ddcd664c0179016b837b43a31476fe4c56e8124619e4a22 -dist/2025-10-28/rust-std-beta-riscv64imac-unknown-none-elf.tar.gz=ea2f2873255dcc73185490b2c396abb4bcd5f1623f7749f77885426f753ce29f -dist/2025-10-28/rust-std-beta-riscv64imac-unknown-none-elf.tar.xz=7c02315d003cf65ac1246e3ac21b6da39cb1d99e61078ba9941647ae48bf9aa5 -dist/2025-10-28/rust-std-beta-s390x-unknown-linux-gnu.tar.gz=008321f0ccd9b96e77829b709c2683c0053acbb19ae86f2fccef49c2cb964531 -dist/2025-10-28/rust-std-beta-s390x-unknown-linux-gnu.tar.xz=047db35903bec7fee6c1d9deee5b4dc21db546a06e11c30d8372ffaf09814c59 -dist/2025-10-28/rust-std-beta-sparc64-unknown-linux-gnu.tar.gz=19677dc6495a139eac6c5827cb765e54e3b099d64f83e92273190f09ead7dab7 -dist/2025-10-28/rust-std-beta-sparc64-unknown-linux-gnu.tar.xz=d5815d1eb4906a442da0a0b56fe61cf94767dda29479da447d94a23803f9cf0e -dist/2025-10-28/rust-std-beta-sparcv9-sun-solaris.tar.gz=184424d0d18c2c49ce1c819e49804d7667edf2bce34fafedd4eeb6d4f427ae5e -dist/2025-10-28/rust-std-beta-sparcv9-sun-solaris.tar.xz=30ad3f9e3eaf48af0eb700d528b330118ad39f221a7beaab1a42e52b1ffa8531 -dist/2025-10-28/rust-std-beta-thumbv6m-none-eabi.tar.gz=c9a72ea7a13651f1b9bc6e509d9d6d32e56a4659d541e20f571ef9f6dd858480 -dist/2025-10-28/rust-std-beta-thumbv6m-none-eabi.tar.xz=6dd3a25ee5060cdf4631d8b0b7f16aa569bf611ef392d93826e88846053779e5 -dist/2025-10-28/rust-std-beta-thumbv7em-none-eabi.tar.gz=ccf8d09ba0bed60fecc775689649f2de31bab68cff273d796378d213c9d1e44a -dist/2025-10-28/rust-std-beta-thumbv7em-none-eabi.tar.xz=b7a972a9b972a2e0665387cd825491bf0ee9581ff26a586806c986014f0ae742 -dist/2025-10-28/rust-std-beta-thumbv7em-none-eabihf.tar.gz=26baa00580268fb5b7aba63a069c187dcca43dcf29161a0c1b849ef3765bbbda -dist/2025-10-28/rust-std-beta-thumbv7em-none-eabihf.tar.xz=dcd67a3ad1f2c553fb90009c630a8edcd8f571e28e5fcef0ade63c624fa11037 -dist/2025-10-28/rust-std-beta-thumbv7m-none-eabi.tar.gz=cef72caa89fcd3d48c070b1aae2fe85f29547c9b615446af2d51767ef42b5045 -dist/2025-10-28/rust-std-beta-thumbv7m-none-eabi.tar.xz=70ad20d0016c6c81b4526ccf89bbd96f4bc0a97b904b2c06487fd0a0368d7a17 -dist/2025-10-28/rust-std-beta-thumbv7neon-linux-androideabi.tar.gz=f22aeb9cdd40a4a465525fca7e6520aaa74b5fbfb41f45777e1376742f711c59 -dist/2025-10-28/rust-std-beta-thumbv7neon-linux-androideabi.tar.xz=48410a5a2f05c80f3d76b9f0b3e0eb89521495b273a854b40386048f27b553c2 -dist/2025-10-28/rust-std-beta-thumbv7neon-unknown-linux-gnueabihf.tar.gz=a791f5442467819c154f943c3126de1dd8f5fdd6b62527aadd88260ecb8c380b -dist/2025-10-28/rust-std-beta-thumbv7neon-unknown-linux-gnueabihf.tar.xz=cf43ec766a353cad48150d47d108d8df4b1561101b2c95241b909d4a5ec47bce -dist/2025-10-28/rust-std-beta-thumbv8m.base-none-eabi.tar.gz=3699e5b727abc016ab9fa78f40655ef7d88ff157e46759297cd80e5c169136f8 -dist/2025-10-28/rust-std-beta-thumbv8m.base-none-eabi.tar.xz=a6942c04a569f68cf1c5126e520400c51dfccd9e18a1d3941e28d7a8e63ae648 -dist/2025-10-28/rust-std-beta-thumbv8m.main-none-eabi.tar.gz=eb27f46d3ee51e4f71316a75087d4ca2493f55ed5e0b720f0dfa3564c8f19a67 -dist/2025-10-28/rust-std-beta-thumbv8m.main-none-eabi.tar.xz=f50b7fa2830844fd27041ced4c96eaa68ae6595b370eef1c958e3542c718d5aa -dist/2025-10-28/rust-std-beta-thumbv8m.main-none-eabihf.tar.gz=398556eca8a50c1d905ef7e2bf3f25d75f8dcf1d9b679af87b565f5f58af5c2b -dist/2025-10-28/rust-std-beta-thumbv8m.main-none-eabihf.tar.xz=8dc4a5036cfda5725120a8d7e7d0cd05151230ed967ff77fa028c4b73dde6885 -dist/2025-10-28/rust-std-beta-wasm32-unknown-emscripten.tar.gz=212f761263b9a4c72a53aba0b76986f70b3d624557f34d36af2e7d935702359d -dist/2025-10-28/rust-std-beta-wasm32-unknown-emscripten.tar.xz=89c0dae14955afab89b8fa2892944325ff154987c863fd36f93089f29ef993b6 -dist/2025-10-28/rust-std-beta-wasm32-unknown-unknown.tar.gz=92159d52588bb1ca6346025f894dce5520b42d89cb54a78a3ff42ee119c1e90b -dist/2025-10-28/rust-std-beta-wasm32-unknown-unknown.tar.xz=a187e36833f587ad5f117b012a5d9ddacb3122b39b902bc2a9d9d03b5aba27a2 -dist/2025-10-28/rust-std-beta-wasm32-wasip1.tar.gz=fa8971fcd7c22f5d382f4239fa8742238ec967f70fa40180ac9d8a39bffc28b3 -dist/2025-10-28/rust-std-beta-wasm32-wasip1.tar.xz=0603acb7e6fa5540fb458cf363fe473889b0abba91ec0c124ce380ffb1869cbf -dist/2025-10-28/rust-std-beta-wasm32-wasip1-threads.tar.gz=7651d409d4a89dab576cabf51cdd2947f877b77f09f668c6f9b8826dccd5c322 -dist/2025-10-28/rust-std-beta-wasm32-wasip1-threads.tar.xz=a6c3bc7f7f2e6a4cee6db2aa16f74af80cdd17ca92dcfcb1ab1e0c06bbaddd79 -dist/2025-10-28/rust-std-beta-wasm32-wasip2.tar.gz=77537c7a4518e62cb592e5e9d41df02d1ec8a3038b87cdfe082c98ae578973d5 -dist/2025-10-28/rust-std-beta-wasm32-wasip2.tar.xz=794a3c2e08edd74b7a004489017172c30a3242f7f0c5538c3b033937787da332 -dist/2025-10-28/rust-std-beta-wasm32v1-none.tar.gz=746ac6eb726ea2d2996b68be881d5c5fbeeba2bec1fbe57e6c315d4953cccba1 -dist/2025-10-28/rust-std-beta-wasm32v1-none.tar.xz=8bdbcf0cc2b598cbb2098f113128e6f94085dfdaea3ed3d5e15cfd0a82262b56 -dist/2025-10-28/rust-std-beta-x86_64-apple-darwin.tar.gz=2082bcdfd0e837163aec012cba1ae674825f52f5891c8cf3d4d00c619d5bd27b -dist/2025-10-28/rust-std-beta-x86_64-apple-darwin.tar.xz=b2267e0df76f21bcfbb55ab323c58015501d3a3060c4127a005e29fa0e628a7b -dist/2025-10-28/rust-std-beta-x86_64-apple-ios.tar.gz=6a48b60d0aa883ffad612a657d9de232ad1df92f937a5166532a7ee4e655fcc7 -dist/2025-10-28/rust-std-beta-x86_64-apple-ios.tar.xz=81ee2cdad7fd25b56be24d919268d0dc61c1d44d50bccb4c1811e30e85b97869 -dist/2025-10-28/rust-std-beta-x86_64-apple-ios-macabi.tar.gz=01d5952f0970508064fa24196e126cb09aca5085ad6258c53397c3b23b006217 -dist/2025-10-28/rust-std-beta-x86_64-apple-ios-macabi.tar.xz=3c10717be0087060ffb0e5b83c86ce69bff8b0dee9dee95b1be6a44f4238b5c5 -dist/2025-10-28/rust-std-beta-x86_64-fortanix-unknown-sgx.tar.gz=ce87a282ea73eb83015a321b208abfa9d4afdf4a797c799d9efeb1a246e4a64d -dist/2025-10-28/rust-std-beta-x86_64-fortanix-unknown-sgx.tar.xz=5c8866ec1cb4ec7826a94510c00f5cbc7f31822dd7e01ec2fe6b781b25e2afa8 -dist/2025-10-28/rust-std-beta-x86_64-linux-android.tar.gz=19538e0dd74d638b3ac1ac9ed679b8ebc6c058f661d7f167f957eb0866f7cb65 -dist/2025-10-28/rust-std-beta-x86_64-linux-android.tar.xz=15554ba8cc8d1d1c4c46e0438503170aff5a5519eb8bedef07a32d187ca32915 -dist/2025-10-28/rust-std-beta-x86_64-pc-solaris.tar.gz=41a6db659dff188414e33595448dc9c2b99103dbbdedab53d74c6aeccbb76458 -dist/2025-10-28/rust-std-beta-x86_64-pc-solaris.tar.xz=2bbcb13b8271c39a48ac2774e7444fdce883a283622400085623c161f8be405d -dist/2025-10-28/rust-std-beta-x86_64-pc-windows-gnu.tar.gz=e2390bf5da8a91f056df7133020d053d5d90c84c81763738efe8a862864318ae -dist/2025-10-28/rust-std-beta-x86_64-pc-windows-gnu.tar.xz=5d6fb692f2a1d2bad7b550b79e1288223ec598a46975848d07f2a5105b36cb4d -dist/2025-10-28/rust-std-beta-x86_64-pc-windows-gnullvm.tar.gz=30c66f64c7343388f3205e172e64e51dc2930214fae46eb3b21648285092c944 -dist/2025-10-28/rust-std-beta-x86_64-pc-windows-gnullvm.tar.xz=25788901f6fc13a4963bba4e985d619e0739b1239a5679406229a2bd5eaafbaa -dist/2025-10-28/rust-std-beta-x86_64-pc-windows-msvc.tar.gz=9fab4a6cc38c2f06113ae9f0620e40ff5e9134f83562c32576c1e82048ad3bc8 -dist/2025-10-28/rust-std-beta-x86_64-pc-windows-msvc.tar.xz=1b7007f9bc3619cfba09bfa92c3b1e5460316501fee4ae7c8492703a79517f4a -dist/2025-10-28/rust-std-beta-x86_64-unknown-freebsd.tar.gz=461036ed77e332851e88fb6f0f5c64068aef0b177b27662f326d157c06c7115a -dist/2025-10-28/rust-std-beta-x86_64-unknown-freebsd.tar.xz=fd7c7b75a50833650f131a6a676df90dcd57c4784654aee12ce594846da1c219 -dist/2025-10-28/rust-std-beta-x86_64-unknown-fuchsia.tar.gz=882fe895b376384d9b1b1d9c01d9b641ab56b1405d63d7a83266f228b4b759d7 -dist/2025-10-28/rust-std-beta-x86_64-unknown-fuchsia.tar.xz=e9d1fdbd0ba327b6d4e618622c0336eb6895e0e188005423710d514e145baac7 -dist/2025-10-28/rust-std-beta-x86_64-unknown-illumos.tar.gz=aade9f95b362cf13ee48e1d7608eb8487229cf86cc72082afe21fef533e45f5d -dist/2025-10-28/rust-std-beta-x86_64-unknown-illumos.tar.xz=de92c9cf00a2413d5481e96e1db5157c5cb3814851951076e4881b9269651cb9 -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz=04f6feb37de8305d17e7aacc6174395bd55447340963303767c5a66a63200149 -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz=2838910a0ef0084245a69fefdc67845ea579f49629cd24fa051b4db0bdc76d98 -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-gnux32.tar.gz=d2f88d608fdccd0aecbcd83cc184d157d93159e29ad525583188013f327572d1 -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-gnux32.tar.xz=b5e7ae18377727f93fece51d9ee5704ffd5a9ccd00c540b38ebbf3b9155cf20a -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-musl.tar.gz=40a52cf3527090a12095b0ed4ad8d35fa5e3cef39146a9a8bff9009cf5772dc1 -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-musl.tar.xz=28be865d06f9bd744aaad2e82ab8bdb87045e6e2d7ee6fceef2024fa620ba920 -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-ohos.tar.gz=e0afdd5422adac97fe8c6943470a8561847a614d3e367cb983f28250c0e2e34c -dist/2025-10-28/rust-std-beta-x86_64-unknown-linux-ohos.tar.xz=3007d13a0640d915eca622260c6b8b6a8936788a1228011b90df817b6888155c -dist/2025-10-28/rust-std-beta-x86_64-unknown-netbsd.tar.gz=1744c2485854792601518dcf7855d4223db63e9f3693e2d06c1ac285b92ba33b -dist/2025-10-28/rust-std-beta-x86_64-unknown-netbsd.tar.xz=757803d3cfb8db12dd7c9528852c1e28fb3a9ba97e4230d1e29dbf1834cf3f84 -dist/2025-10-28/rust-std-beta-x86_64-unknown-none.tar.gz=21d5de489cc22d849f246225909278f123483a446e1a3c68b14b8b992c104082 -dist/2025-10-28/rust-std-beta-x86_64-unknown-none.tar.xz=62755ecf24c0a2423b4d05c09ec8e8d38737e6762312d1ba993e1a9417083ba9 -dist/2025-10-28/rust-std-beta-x86_64-unknown-redox.tar.gz=0339d37d857f7f5ecb1607e8c53c499623f0c3563e3b68f2b939ee960d31b270 -dist/2025-10-28/rust-std-beta-x86_64-unknown-redox.tar.xz=613b5ca94e5c33c46d9f29cb557d1e512abd1104c5d81f1897915f6153175cc5 -dist/2025-10-28/rust-std-beta-x86_64-unknown-uefi.tar.gz=1da6167f0a2652b1622cae5ac815d55e307dbd639e4901005a3b225150dcafa7 -dist/2025-10-28/rust-std-beta-x86_64-unknown-uefi.tar.xz=6fca79a15c1ef9f8a3974f84af805106ab453099bdb6f652f584abcd7c8174be -dist/2025-10-28/cargo-beta-aarch64-apple-darwin.tar.gz=e66d076303fe8010c27fdbf8a9e31f47223508a280cd2ffcfea698aede848986 -dist/2025-10-28/cargo-beta-aarch64-apple-darwin.tar.xz=f4e87741a4070fe5bc4ad59ecfd324785cd9a477c539543d6a4fc1675afa8111 -dist/2025-10-28/cargo-beta-aarch64-pc-windows-gnullvm.tar.gz=5e9213968960bab07ad28408563b46d01c1d881c26ccd07651bdb527440461cb -dist/2025-10-28/cargo-beta-aarch64-pc-windows-gnullvm.tar.xz=ec01099da59fab595f8ed8a2f6fb308fbaaabf563cf50c103d47fad4595d72ec -dist/2025-10-28/cargo-beta-aarch64-pc-windows-msvc.tar.gz=ed3cd99db73648bb87c5a25556da30993346f1acc665f9dc906094639370282a -dist/2025-10-28/cargo-beta-aarch64-pc-windows-msvc.tar.xz=c5f89cae65188a7d1b5b5a93f8645774f878db6a14032abb8fd960fa9f4cdb06 -dist/2025-10-28/cargo-beta-aarch64-unknown-linux-gnu.tar.gz=2c85f1c5b1a8bb9532194a16ceb8b04f1586d0ade14442f45e740f3e85022924 -dist/2025-10-28/cargo-beta-aarch64-unknown-linux-gnu.tar.xz=a675601cf6552783625b79c33c1d42715c3918a08078e6eed01236910bafc4b4 -dist/2025-10-28/cargo-beta-aarch64-unknown-linux-musl.tar.gz=e5f2cc9f31b927e2e02117c38a5822c39993242459a057c48e7e11695dabe5a5 -dist/2025-10-28/cargo-beta-aarch64-unknown-linux-musl.tar.xz=1830b8b7e43fc03f0348503ae036b30d0e906cb024bc2257e717a58df95ac222 -dist/2025-10-28/cargo-beta-arm-unknown-linux-gnueabi.tar.gz=eef6f553184a8177525a1ee932d6e293f42eaed6986c1c83f7d76d579f02b867 -dist/2025-10-28/cargo-beta-arm-unknown-linux-gnueabi.tar.xz=13c81e5874532e490c987dbc46b19cf3a7eac14fefdffc30d0c5493a84f8a257 -dist/2025-10-28/cargo-beta-arm-unknown-linux-gnueabihf.tar.gz=56d7f1b41af4d72091c8a99b9a583f24d5aa3912f6dfcbfeeae4eb47bfbf158e -dist/2025-10-28/cargo-beta-arm-unknown-linux-gnueabihf.tar.xz=010292117dca5b10b71b7aabe38d1e8c2f0180ab54e9bf072a9ca8bab3f40ced -dist/2025-10-28/cargo-beta-armv7-unknown-linux-gnueabihf.tar.gz=91671bdd6438df48e4c529e5897afe57b91e8575c12d40c3cb3280493599c0d9 -dist/2025-10-28/cargo-beta-armv7-unknown-linux-gnueabihf.tar.xz=0da8474db35ef547b28f123e8c98ec84dcc4a4a5c4a487a222ac006e809ceb80 -dist/2025-10-28/cargo-beta-i686-pc-windows-gnu.tar.gz=5d9ce7ba82e8d694e53ac877214c0873b0dd78a60c8eabcfe9128433d199d12e -dist/2025-10-28/cargo-beta-i686-pc-windows-gnu.tar.xz=209100fad49e274457d8299360a4c2e83803411a69fec69898a03d9a2bdee955 -dist/2025-10-28/cargo-beta-i686-pc-windows-msvc.tar.gz=edca4ca03b055b40d0c4778e325b93e3759123f207a6d32d7ff42cfa0f323604 -dist/2025-10-28/cargo-beta-i686-pc-windows-msvc.tar.xz=5146440d030e04450de61bd6022cd7ad6364fd06f9cec28bbb7889bad171e579 -dist/2025-10-28/cargo-beta-i686-unknown-linux-gnu.tar.gz=d1045ab266d914060e24224b0e74ea865f4bf4cd527d9a09c5631441c40f48a3 -dist/2025-10-28/cargo-beta-i686-unknown-linux-gnu.tar.xz=caed7a0786cc9f476d1b9fb5367c67a02397ccb12ed18a357b5ed04fe77fb12f -dist/2025-10-28/cargo-beta-loongarch64-unknown-linux-gnu.tar.gz=017335d6ca97cbe4bf93e2ffb4def850b05a8efa0367b008de4cc8b55f1af3cf -dist/2025-10-28/cargo-beta-loongarch64-unknown-linux-gnu.tar.xz=f5671ec0dee9841d4a482183f56ccb986f358a80d043d1ec4b05bc8a356f8ad7 -dist/2025-10-28/cargo-beta-loongarch64-unknown-linux-musl.tar.gz=0a280ebc1b5aab8452f1445fe858ad4808fd7035dd498510951d8b7caa13edc8 -dist/2025-10-28/cargo-beta-loongarch64-unknown-linux-musl.tar.xz=8ab41df2264470d6ed0a6d82b665992f76f9065046a153bc8ee1eda9ca81eaae -dist/2025-10-28/cargo-beta-powerpc-unknown-linux-gnu.tar.gz=7368d0d297fa06108271b03138a9dda0cfbdbe5463a614ebf6fb5b573dde08d7 -dist/2025-10-28/cargo-beta-powerpc-unknown-linux-gnu.tar.xz=1ad0b7d4e3173150768db7105b1a691e8c85db3e9c6a391390e2f5df7844d420 -dist/2025-10-28/cargo-beta-powerpc64-unknown-linux-gnu.tar.gz=75740d0b1847f73777894f484e085f70f24d981b0ef69d00cb5b0c29d276c5b5 -dist/2025-10-28/cargo-beta-powerpc64-unknown-linux-gnu.tar.xz=1ca71e60a6fa9752dd27bfe4f354a1b732b67e55c9e645021e6041a2450b7994 -dist/2025-10-28/cargo-beta-powerpc64le-unknown-linux-gnu.tar.gz=ab37e6d39ccb7fe33c55bf62836c2174f1a4197f02cbe9d88d118b81ec6d49e2 -dist/2025-10-28/cargo-beta-powerpc64le-unknown-linux-gnu.tar.xz=77cc38c5b89fc65fb7453dcc3c3212e0a512923497420b7782ffbfd88f00b39f -dist/2025-10-28/cargo-beta-powerpc64le-unknown-linux-musl.tar.gz=29a2dd23fe30b2d1741e1d4032d4250b4f7f0e2af5ae718b309f2d271e13ef41 -dist/2025-10-28/cargo-beta-powerpc64le-unknown-linux-musl.tar.xz=bac42c5d4af02abbb4db1a9dd4664340d686e4c23f923f372d3b08e090bd105c -dist/2025-10-28/cargo-beta-riscv64gc-unknown-linux-gnu.tar.gz=3b396bf0ddede9f4964bc9fb27b52e628db1d9ccc38dbc5d5e06c316ba8bef87 -dist/2025-10-28/cargo-beta-riscv64gc-unknown-linux-gnu.tar.xz=e706521e4496c79bb677d7d06d79fc1ae2770cdba4a81d8c28ede81ab4ee7909 -dist/2025-10-28/cargo-beta-s390x-unknown-linux-gnu.tar.gz=2fa6ecf04d1cb20dde5f700a0e425ea186d628c5704885e84e197e4494af101f -dist/2025-10-28/cargo-beta-s390x-unknown-linux-gnu.tar.xz=e8810699e679fd0306d4e6c95608970ec5a1d1ccffcdd707fe4a4508518a0e6d -dist/2025-10-28/cargo-beta-sparcv9-sun-solaris.tar.gz=2fcae7eb2f538d84545944c744bbac39e28b3bd58e8d2bdc862d5f66df7068e7 -dist/2025-10-28/cargo-beta-sparcv9-sun-solaris.tar.xz=2fe42f27469fdc23a9e45ec025c60a09f00be07a239cd8c8df74ce52e94b4cab -dist/2025-10-28/cargo-beta-x86_64-apple-darwin.tar.gz=c92c1a580eb85d96f973df4dd9cf4440eb661f8fab9c632b5f0621cf0839badc -dist/2025-10-28/cargo-beta-x86_64-apple-darwin.tar.xz=6c2b13253e1066e49fc52f3cb1654776d5d38853a15e8022652b4a2cb6845daa -dist/2025-10-28/cargo-beta-x86_64-pc-solaris.tar.gz=ca98af5dcaae734ccc02fde2807dca8d95947918eb753d407c12dd05ae937568 -dist/2025-10-28/cargo-beta-x86_64-pc-solaris.tar.xz=864ed5842890359e9f767b4050b8a27ec9c27c88a8cef20993b8f775c213d394 -dist/2025-10-28/cargo-beta-x86_64-pc-windows-gnu.tar.gz=ec8a9e8436f83388736f16f7ad9962a1d9b72673c3da56b8233a6b39dde54534 -dist/2025-10-28/cargo-beta-x86_64-pc-windows-gnu.tar.xz=1f059aae8e6faedcc56663d833a07417e07eededdc2776b2762822987a010131 -dist/2025-10-28/cargo-beta-x86_64-pc-windows-gnullvm.tar.gz=f364bf2f20f35c7ff0381cbd34c88a256849a1b9a27267436e14bc01b7bacfbd -dist/2025-10-28/cargo-beta-x86_64-pc-windows-gnullvm.tar.xz=451f18d049f1c47bfa0c010481e499afa1baaffb889de11534cf451578c62f76 -dist/2025-10-28/cargo-beta-x86_64-pc-windows-msvc.tar.gz=96ca48b12b27b8e933cbb426e7123873a1120bd884a62d150aceb6a26bfc7694 -dist/2025-10-28/cargo-beta-x86_64-pc-windows-msvc.tar.xz=dfe14d019f5c1744a312da8d926059147974de0b5bcdcd869526b5257a1112b3 -dist/2025-10-28/cargo-beta-x86_64-unknown-freebsd.tar.gz=7ef3d3edb6b536382f5063a5de5aaf036d6ba09bf7bd1ff770b87d8942110c2a -dist/2025-10-28/cargo-beta-x86_64-unknown-freebsd.tar.xz=beb5587235e8ff471a8eb9fd84ae5cf4380e7ec9b00ab03dc0c549be0e661dd0 -dist/2025-10-28/cargo-beta-x86_64-unknown-illumos.tar.gz=b97f511486ad044dae0c8b50df8430e489887ac36b770155f163d8e4216cd9c9 -dist/2025-10-28/cargo-beta-x86_64-unknown-illumos.tar.xz=21fc84a42fa988632fb9b0d9dccdf6ab2fbbd06a6780076282fc9bea56567559 -dist/2025-10-28/cargo-beta-x86_64-unknown-linux-gnu.tar.gz=d5b05dc398716909df77415b4a68233b68a5d578855e0e91dcf423f2985fc1cd -dist/2025-10-28/cargo-beta-x86_64-unknown-linux-gnu.tar.xz=21e79bba772e93a6fd910e9d6ee833b55a53b80088f8280525717a4cd800c21b -dist/2025-10-28/cargo-beta-x86_64-unknown-linux-musl.tar.gz=4d126f2591652ddea26884973c1ae1f1e25246cc5f60baeb3a52d6ff45a1aa15 -dist/2025-10-28/cargo-beta-x86_64-unknown-linux-musl.tar.xz=62113a7383f7ff8a9bee099155ca55c3c69d16bf135fc06046f672b2102deafa -dist/2025-10-28/cargo-beta-x86_64-unknown-netbsd.tar.gz=e9a07f035f308d4b9cf5f1b0ab4ef969cad1c41528adea2fca81d8dfe45ebff0 -dist/2025-10-28/cargo-beta-x86_64-unknown-netbsd.tar.xz=3f3d87269072d8e219e7213ca878a7fd441aaf74e4d052ca44ccc7ad75e83eee -dist/2025-10-28/clippy-beta-aarch64-apple-darwin.tar.gz=a44daddb30309be19856b9572679569ffc2ab2c30318706ad59aa2dc14887587 -dist/2025-10-28/clippy-beta-aarch64-apple-darwin.tar.xz=00576ad0f30db5be96e6434e22a2fcdd167067d65ab85199df06a6d11d1ef6c0 -dist/2025-10-28/clippy-beta-aarch64-pc-windows-gnullvm.tar.gz=24fb3dc6680e845c84e535f9c14be5e3d4052ef3ccc800e0fd81815edccb4836 -dist/2025-10-28/clippy-beta-aarch64-pc-windows-gnullvm.tar.xz=20d2ebdb6e2a902eb74ad502a14a2a66e6a9316d5f94513ec9781d146c323d9d -dist/2025-10-28/clippy-beta-aarch64-pc-windows-msvc.tar.gz=652e5bdffbb89ba281cbd5efe3a2cf103adea6af7ba56a21cb6bb538a2ea6536 -dist/2025-10-28/clippy-beta-aarch64-pc-windows-msvc.tar.xz=59d0fb72db77c484571ebab8c992303659225735d3f820ed7048122d8f96d764 -dist/2025-10-28/clippy-beta-aarch64-unknown-linux-gnu.tar.gz=6bf6fb7279ecf5df6edca6014db5f8ba0427fd8cd32f073630b6b02e2e69feaf -dist/2025-10-28/clippy-beta-aarch64-unknown-linux-gnu.tar.xz=0a8d19bca62dc38e64cf527b239106901fa2e0642ca5c2ef1cde070faaa901b0 -dist/2025-10-28/clippy-beta-aarch64-unknown-linux-musl.tar.gz=663581dbd93b22b3b20d281486c8dc0580e43ceca42d9455d78f2d2c341cc758 -dist/2025-10-28/clippy-beta-aarch64-unknown-linux-musl.tar.xz=49548d8ee0561ab96629e354ad055ed5f0c6f3f60c1559ca2a27352b441ff848 -dist/2025-10-28/clippy-beta-arm-unknown-linux-gnueabi.tar.gz=b3d44866b1f909576e0e586aa34b480f1170aa3eba28209ac5bcb929f544d07c -dist/2025-10-28/clippy-beta-arm-unknown-linux-gnueabi.tar.xz=717397166acd760e391c251b1c308657f45deadd928035d2860c772c8b377b91 -dist/2025-10-28/clippy-beta-arm-unknown-linux-gnueabihf.tar.gz=8911fa3347ca26a2afed6140bc4cafa629830740b8e4ff5e648c517f6ea43c6b -dist/2025-10-28/clippy-beta-arm-unknown-linux-gnueabihf.tar.xz=e7360c728068520ec7bd712d57357ce30bbfbb629ec69cfdcf6596002751d93b -dist/2025-10-28/clippy-beta-armv7-unknown-linux-gnueabihf.tar.gz=6d94df05e43804f1054d17542db72cfd3f2df27eedc275c810b35362f9d581c1 -dist/2025-10-28/clippy-beta-armv7-unknown-linux-gnueabihf.tar.xz=25c33744d9722aad4f9fc80674233d16eb653adb17d0deadcd3be8f16a79ecb7 -dist/2025-10-28/clippy-beta-i686-pc-windows-gnu.tar.gz=dfb9ba0cc842b7c92f1dda8bb88bd1db9beeac746c3ca3d144dd4d66d91ff6ff -dist/2025-10-28/clippy-beta-i686-pc-windows-gnu.tar.xz=20f3cf3fe6b52b8f54391be7edd11331a376313c37b674f4987589f50eac68d0 -dist/2025-10-28/clippy-beta-i686-pc-windows-msvc.tar.gz=bcabe1f7679e1ae416c7ed56afd74ad224ff47cd9b5413dececb0e6f503ce393 -dist/2025-10-28/clippy-beta-i686-pc-windows-msvc.tar.xz=f8ebfef39e7119b45a4f714e91b47964aeb6653fbdaf9b01786ef629cbaf3d31 -dist/2025-10-28/clippy-beta-i686-unknown-linux-gnu.tar.gz=f0fc318e90de4f45f6ca7d0d6ca3ed5d044db75f97254d792cdea9a7b196042e -dist/2025-10-28/clippy-beta-i686-unknown-linux-gnu.tar.xz=27c9adb19a7f84edb19ff4c8ce34dd836fb8d10e8786999591e41ec9c60e4602 -dist/2025-10-28/clippy-beta-loongarch64-unknown-linux-gnu.tar.gz=04673347c7e13eee9e301ffc1640ce7a5ed733915c29d90750706829d6b02884 -dist/2025-10-28/clippy-beta-loongarch64-unknown-linux-gnu.tar.xz=2484f24346fbbd2d48f69d86ab7710ef65a5952bb5ea0141f3388f616c7d6d0c -dist/2025-10-28/clippy-beta-loongarch64-unknown-linux-musl.tar.gz=656eb1b94dd2324958e6ba0b1c7a37281abe24dac7d87b0e406fc10931ea0d29 -dist/2025-10-28/clippy-beta-loongarch64-unknown-linux-musl.tar.xz=3349952da5d2693554d2e1ae60bb7ff9cd64451719cadf4227095b73377228c1 -dist/2025-10-28/clippy-beta-powerpc-unknown-linux-gnu.tar.gz=40eeba3b2807a1d807ed25c3bc0482d5b91135a769d2281a894ec8cb8bb52a35 -dist/2025-10-28/clippy-beta-powerpc-unknown-linux-gnu.tar.xz=0a6e79cea6655d6b3e1ff1218651c627886d8f06a5d36e9c3bd3c9c45b375f57 -dist/2025-10-28/clippy-beta-powerpc64-unknown-linux-gnu.tar.gz=b11f919fce34d70816a6dfa0884e37939c38336bad6261fccf5d67d25935852c -dist/2025-10-28/clippy-beta-powerpc64-unknown-linux-gnu.tar.xz=ead91ce4260d07d4e4f950092e94ae224f067ae3c711efe2ccedc9250b2f3dd7 -dist/2025-10-28/clippy-beta-powerpc64le-unknown-linux-gnu.tar.gz=481a2e3b45751e2d86c30d4fb3897f0a7a18e9eadde2c9a3ad1a8b0259fa2066 -dist/2025-10-28/clippy-beta-powerpc64le-unknown-linux-gnu.tar.xz=d5d6529cfc89c29443d9e87041a5f93b746e5bc5791016242e2f271be5bcb557 -dist/2025-10-28/clippy-beta-powerpc64le-unknown-linux-musl.tar.gz=a70d30948f5e95cdd454fa2b3284b97f29134f59e98e130fc2877781f3b62e89 -dist/2025-10-28/clippy-beta-powerpc64le-unknown-linux-musl.tar.xz=8dddfc0b1b2ca8e8866a11a1c95b8601c50150f1e52adbd3803cca2fabb386e9 -dist/2025-10-28/clippy-beta-riscv64gc-unknown-linux-gnu.tar.gz=bd1b28dd79a52de657515ba5c25063b0b6015eb30ee3b0ee05511567b429c992 -dist/2025-10-28/clippy-beta-riscv64gc-unknown-linux-gnu.tar.xz=5262011db6be068ef70905a28939b1838a2fd2b719d38d59e80754695049269b -dist/2025-10-28/clippy-beta-s390x-unknown-linux-gnu.tar.gz=6d3d83d03c46e1de2cc6b6f204e701acc9dddb6d4baef80fada9d868b7eb86cc -dist/2025-10-28/clippy-beta-s390x-unknown-linux-gnu.tar.xz=e57ac819f962d9b431b699b40a047d3e2530f76f2670c5a04747b7de11c3d5e2 -dist/2025-10-28/clippy-beta-sparcv9-sun-solaris.tar.gz=7a492d27b49facb9554248935728cba483eb7ecf3de317751a7445c3932932e6 -dist/2025-10-28/clippy-beta-sparcv9-sun-solaris.tar.xz=cc02f4f971b9e5eb63ca65ff6947cf3490101bfb40ea9fb2b310283bb6d10b27 -dist/2025-10-28/clippy-beta-x86_64-apple-darwin.tar.gz=56f11b8ca012467ef6aa8dc3458a5bf45950f1de062a616a01f6c0aae412d0fd -dist/2025-10-28/clippy-beta-x86_64-apple-darwin.tar.xz=01fe53ec63d71a8427fa3220d037313fc31f8d0fa33a64305b01109344aac21a -dist/2025-10-28/clippy-beta-x86_64-pc-solaris.tar.gz=d222cfda8613bba09b0ac1d02fad99c0d081d10733f0f9253d809221ffdda506 -dist/2025-10-28/clippy-beta-x86_64-pc-solaris.tar.xz=918706ee8ed38bf398cbf0dad85333e3082dc461fff2fb2399b96e840dc24766 -dist/2025-10-28/clippy-beta-x86_64-pc-windows-gnu.tar.gz=7764df051100b08b4b4e5c434d5ced1aaa84d9665f6a4401c9ed6350db983b70 -dist/2025-10-28/clippy-beta-x86_64-pc-windows-gnu.tar.xz=4a43dee6ce0279de929566f844fa4987d10fa5ca856bb2a2cbea4327eef3308e -dist/2025-10-28/clippy-beta-x86_64-pc-windows-gnullvm.tar.gz=add2532fe4e8afb8b53aee8a729fde0c0b36f83a8f6a859c39ae25f3d01e8dd6 -dist/2025-10-28/clippy-beta-x86_64-pc-windows-gnullvm.tar.xz=7117f0afc57ac09c277ba99be4a7de80d62ffaebe4174706910d5ab6501ec9f7 -dist/2025-10-28/clippy-beta-x86_64-pc-windows-msvc.tar.gz=e71d45b8bdb5346d89f769b4698b404b293884878a7f697680318c72829c1d6f -dist/2025-10-28/clippy-beta-x86_64-pc-windows-msvc.tar.xz=67be8cf6580a4a6e36eff94bfe19fdad290eae5db598d2a016dfcc7516178e14 -dist/2025-10-28/clippy-beta-x86_64-unknown-freebsd.tar.gz=03b78bad90efe98cab6416ecc641b7da0c9a2be5950edbb4c520c0758cdb90a8 -dist/2025-10-28/clippy-beta-x86_64-unknown-freebsd.tar.xz=056aecae34c8ae10a41516834809d983bd6126bd0374a7bf0857710492f0d0a5 -dist/2025-10-28/clippy-beta-x86_64-unknown-illumos.tar.gz=a67147c647da8a9b68a507087b66610ed19e65b94538b08326b000e66c170260 -dist/2025-10-28/clippy-beta-x86_64-unknown-illumos.tar.xz=09bd43034d7bc1e9ad1873610237f98543751809ebe63d8255813eadf4a00e70 -dist/2025-10-28/clippy-beta-x86_64-unknown-linux-gnu.tar.gz=9397e5c3b1f45ce949b8e3420233e8b86f95a887667c917b8e7615218989820f -dist/2025-10-28/clippy-beta-x86_64-unknown-linux-gnu.tar.xz=5b67e9eb803c180d101e799f6d7c2a6ea7ec07a93a6395b4f688bf2592bc30d5 -dist/2025-10-28/clippy-beta-x86_64-unknown-linux-musl.tar.gz=b255c33a89b0b1bd666ffb584c20554daa3a7c48123de75eae5e1b4cbc53e1aa -dist/2025-10-28/clippy-beta-x86_64-unknown-linux-musl.tar.xz=bc7f3f7d59f9c52370849092541a9368632f390ed9bc88f2566f1e3700f4da80 -dist/2025-10-28/clippy-beta-x86_64-unknown-netbsd.tar.gz=a8f366918520cc5a82c9bcfbb419570e6792712455ec5c04655e6557a657e949 -dist/2025-10-28/clippy-beta-x86_64-unknown-netbsd.tar.xz=dad3555be56e7c8d042f65dfced7915856f9f23cec13a7a633a4aad38c634247 -dist/2025-10-28/rust-beta-aarch64-pc-windows-msvc.msi=943683af0d464ecd36678e1c87b1207a67105820cb3d1516eeebaae450a2928b -dist/2025-10-28/rust-beta-i686-pc-windows-gnu.msi=8532743b3406fbf2926e5c6643300194eaace9de492e7f2ad0caa6f7d040f8db -dist/2025-10-28/rust-beta-i686-pc-windows-msvc.msi=1b3b15aa90c3dca73e9d72d53d214eb3c02b97386c83d8755a03f571cc09de4e -dist/2025-10-28/rust-beta-x86_64-pc-windows-gnu.msi=6249ad7cfcfe78b541e4935ed18dc4cfb10130252885668383a4c8f5046ecc2d -dist/2025-10-28/rust-beta-x86_64-pc-windows-msvc.msi=700f63a1baf0de2f0d1972454486f890af15b3700481698ffb0daf403778390a -dist/2025-10-28/rust-beta-aarch64-apple-darwin.pkg=1f2862fd5dbf8a9c7a765e75391cfffc5a3cd6837066b29f95778b5a346f0f59 -dist/2025-10-28/rust-beta-x86_64-apple-darwin.pkg=ffa2c6275b401c73575a5158911bc53edfece2edc03f6b3f6a140823cf870ee4 -dist/2025-10-28/rustc-beta-src.tar.gz=dbbae9e1c0b5e914b588ba5b659b7fb6af3d5b422831aba028d64b00c7161417 -dist/2025-10-28/rustc-beta-src.tar.xz=aa771d2b1ea8c933444c962c03c384bf2511bdeddf90edcaac8f45bd49f5232c -dist/2025-10-28/rustfmt-nightly-aarch64-apple-darwin.tar.gz=5a5e525f45010fd3e30503f408f21eef78cafa54e42adf9709cff50f6cb29720 -dist/2025-10-28/rustfmt-nightly-aarch64-apple-darwin.tar.xz=b6f92173abde0be1f4f3378c682e42016390e6e5e20df7e84cbd7804a6161114 -dist/2025-10-28/rustfmt-nightly-aarch64-pc-windows-gnullvm.tar.gz=430775c6856f4aea6a2b83e245904d5527f6ace134a9375dc7172f77ecd328f6 -dist/2025-10-28/rustfmt-nightly-aarch64-pc-windows-gnullvm.tar.xz=3d14ccf194d04ad5767a5fc3df6f9c1427cd0e282671887d2264b8314586e168 -dist/2025-10-28/rustfmt-nightly-aarch64-pc-windows-msvc.tar.gz=251f7fa0b78fdad3be1977ffd6a2f563d1524b6423d2bab73d1741aec97b4717 -dist/2025-10-28/rustfmt-nightly-aarch64-pc-windows-msvc.tar.xz=534cacc40024fec78c02916e7e2d46cde8b8153d303efc1b805af8789f25fb1e -dist/2025-10-28/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.gz=5663e413cd9ae9f403a4b5c5e9a9862c00d57bcd68bde9161c91e852115e45cd -dist/2025-10-28/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz=3625b287a83796cb71741b9a4b002eb4517950d386f97a91470c0acd5aed835c -dist/2025-10-28/rustfmt-nightly-aarch64-unknown-linux-musl.tar.gz=657b0774a95a925eb38d039ef11bc23d15c4733d0b322f172f0b8236bc7410f6 -dist/2025-10-28/rustfmt-nightly-aarch64-unknown-linux-musl.tar.xz=4e058f11346ec86801bc9cdb830c6dec2620b81fe2cd4b439b275a5145859dfa -dist/2025-10-28/rustfmt-nightly-arm-unknown-linux-gnueabi.tar.gz=820ece81e455d11f65ddf09093b6bf97359cc803959d951bd199c70a79ae117e -dist/2025-10-28/rustfmt-nightly-arm-unknown-linux-gnueabi.tar.xz=8a72a3e715ab2427fc120f8af20d67f722881ee9e13bf482e45ef07f5fb2bf86 -dist/2025-10-28/rustfmt-nightly-arm-unknown-linux-gnueabihf.tar.gz=fb583c846e1a11663a1fc525f02c0146dc70e7b4da12c264c8b00cf7927ad9c9 -dist/2025-10-28/rustfmt-nightly-arm-unknown-linux-gnueabihf.tar.xz=8a15430000d48b702142cc4569a5eef3aba59c07f33f69cfb6966250fae18178 -dist/2025-10-28/rustfmt-nightly-armv7-unknown-linux-gnueabihf.tar.gz=c470dd9f35b1b701e8475716e61cfadee5475fa29a2994f407d532a794c0ef82 -dist/2025-10-28/rustfmt-nightly-armv7-unknown-linux-gnueabihf.tar.xz=774898dd43893b99e4e11d004c52244d78d2fb08aaa6fa242cf1d7070d9ff8ac -dist/2025-10-28/rustfmt-nightly-i686-pc-windows-gnu.tar.gz=31ef71bea5f5ce3668b903fabb1582dc256fe6e2f97e5c23ca468e05f3deb7c9 -dist/2025-10-28/rustfmt-nightly-i686-pc-windows-gnu.tar.xz=232351f0a578f9973b536eb587b2e90cb01ca5f76ad376c09d7dd225c09810b0 -dist/2025-10-28/rustfmt-nightly-i686-pc-windows-msvc.tar.gz=eb469e8475af339d36e1381474f931e326ef1f095a6f56f44730019c5f6422fb -dist/2025-10-28/rustfmt-nightly-i686-pc-windows-msvc.tar.xz=42c5f2e88f81cdcc375d26c4ab6d9ec03b387b8de632af8a3fa75bcbfcbf56da -dist/2025-10-28/rustfmt-nightly-i686-unknown-linux-gnu.tar.gz=79e06c14b8f18927b1c24cc4ea97e55a805355137a9bdbe3ba616e334878d85a -dist/2025-10-28/rustfmt-nightly-i686-unknown-linux-gnu.tar.xz=3883c297de03da522a20b893f24970305fadaf726dd9388f89196e1f284115e9 -dist/2025-10-28/rustfmt-nightly-loongarch64-unknown-linux-gnu.tar.gz=b3ddf283d7964a4c261668df7685bc47b469c7294325f975436d465cb7d44163 -dist/2025-10-28/rustfmt-nightly-loongarch64-unknown-linux-gnu.tar.xz=9e63e1bd8b4c52943092e91942737be9b3ee9c128dfbeafdc01d3dc732058165 -dist/2025-10-28/rustfmt-nightly-loongarch64-unknown-linux-musl.tar.gz=83845c5809a9b525655565b3e3b4889e2a07562587c6f046280a44dcbb809094 -dist/2025-10-28/rustfmt-nightly-loongarch64-unknown-linux-musl.tar.xz=533113ead2985a36cf685cfbd6645d43f1a7e2e66b6eaadbde2ff5a72d10c5dd -dist/2025-10-28/rustfmt-nightly-powerpc-unknown-linux-gnu.tar.gz=82c6aa57adb0f03b96982f51edc65aebfac3811cd2845d280b7bf5fb81cbe92a -dist/2025-10-28/rustfmt-nightly-powerpc-unknown-linux-gnu.tar.xz=8f4b3c91072d56ba80ba4702e611dbc6fe66163666e6ee35d74602ef36fe9839 -dist/2025-10-28/rustfmt-nightly-powerpc64-unknown-linux-gnu.tar.gz=4fe0b85296e2249b36a0b021d6b82e7c31c40a5f717a5f447b6bf9b9524069a2 -dist/2025-10-28/rustfmt-nightly-powerpc64-unknown-linux-gnu.tar.xz=9257bb295a58a7df3fbbda809bafc74a8601618afd0fd41467439a8972278cae -dist/2025-10-28/rustfmt-nightly-powerpc64le-unknown-linux-gnu.tar.gz=d3a5851060a66a0e027ba142dbdb6e827f4f5f5116b5fdb0b8e86ee56616d682 -dist/2025-10-28/rustfmt-nightly-powerpc64le-unknown-linux-gnu.tar.xz=fe1e9e4e3a234ba8cb656b08b7bbf5349f5068906cb60a4c5c53f7fe3e214487 -dist/2025-10-28/rustfmt-nightly-powerpc64le-unknown-linux-musl.tar.gz=2187f1ccbd4e638efaf9f05566998b579b32729fd9ee4332964a3c54556c3a20 -dist/2025-10-28/rustfmt-nightly-powerpc64le-unknown-linux-musl.tar.xz=88526ca6af21bdbc6c46130012cb5fdde25fd44e6372187e66d273067efbc052 -dist/2025-10-28/rustfmt-nightly-riscv64gc-unknown-linux-gnu.tar.gz=9299c8d4dfc320cf331dc4005c36a0108961a6d5ad750a5b0a6be8c7cda77953 -dist/2025-10-28/rustfmt-nightly-riscv64gc-unknown-linux-gnu.tar.xz=7da58822a9ba4d65258ca0cd514b9abcc85070baa195ce65d40ed9d9de049049 -dist/2025-10-28/rustfmt-nightly-s390x-unknown-linux-gnu.tar.gz=e07cc8f1166bb39aada202559c1e2ee9190cf85fc11b4d4abb921cab352748f8 -dist/2025-10-28/rustfmt-nightly-s390x-unknown-linux-gnu.tar.xz=ebcb49b4ee1e8dded5e6569c7edea1578a369e92aac9030a51d11e95bd8bb8b1 -dist/2025-10-28/rustfmt-nightly-sparcv9-sun-solaris.tar.gz=247ce6a1fb10911b8f38bc8f88617d9a7dd2147e1f1896710b0b610f8bb4b86e -dist/2025-10-28/rustfmt-nightly-sparcv9-sun-solaris.tar.xz=020d64391c730a61f4c61d802b432a463d4909d0e4d5fe4756db4683df6e000c -dist/2025-10-28/rustfmt-nightly-x86_64-apple-darwin.tar.gz=547d7711acee55435e271fca1cebead82045375b0fb136404be7df379b0d404b -dist/2025-10-28/rustfmt-nightly-x86_64-apple-darwin.tar.xz=e8ef4fa56be91b642fd3a8c29afb9dfb3fb7601c8fbd24393be4f3dea1802163 -dist/2025-10-28/rustfmt-nightly-x86_64-pc-solaris.tar.gz=0e41caa314927c9a8656d16b6623c95463a64f07a23941d03597a17582c224d6 -dist/2025-10-28/rustfmt-nightly-x86_64-pc-solaris.tar.xz=d73dcd42d9110befbdf64c46b9e4e8bad07839302cec49e2d8cd99ab436d4bbf -dist/2025-10-28/rustfmt-nightly-x86_64-pc-windows-gnu.tar.gz=8e821c45dc91d5df1b9f8487554cadc4deb86a9ef3db25f4e21b38eab3cc8ed2 -dist/2025-10-28/rustfmt-nightly-x86_64-pc-windows-gnu.tar.xz=f98ccfcc37b7412788a546cbafe5f09b90c26f823e3cad17e71432df4ba910ef -dist/2025-10-28/rustfmt-nightly-x86_64-pc-windows-gnullvm.tar.gz=762e15406bac23f0f41dae2b1b3370458b92e8be771868b4f8f536f53cb26fc3 -dist/2025-10-28/rustfmt-nightly-x86_64-pc-windows-gnullvm.tar.xz=cd87b4a4c2af3edea8ba09ce9bb8704449d8f51c5dee8ba10161e0ce2ec2aa19 -dist/2025-10-28/rustfmt-nightly-x86_64-pc-windows-msvc.tar.gz=7de2ee69be5384656024a6d7c3481315fe90abc9ba9a26726f1eab09aae2c818 -dist/2025-10-28/rustfmt-nightly-x86_64-pc-windows-msvc.tar.xz=16377ae5474e30b6c11ba886579ef13db4039d0b9f43240db00aacf7366b37d7 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-freebsd.tar.gz=d98fd17080ed5a4fda444719011540a80320001a0b0dc36148f2e3f78e5f5c33 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-freebsd.tar.xz=c825c2b46f43fe71f4452494fb422cd9565ec6454857835a6c77081553081523 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-illumos.tar.gz=8844743cc05351b1f6ba8fb50ac1d86161a285775eb4c0e474308aec71b631c7 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-illumos.tar.xz=172dc660ceb00e7003e855a09f46d9f83096773495ed6d7b8b1ed6b9e770912f -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.gz=2710450c26834b07a5eb80bf990dc67a6db89f87e26d6b613ed96116c28958d4 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz=bbb8eac454e0ba3b23c9803d8201fa341d0f0af509aa9e8b530c9b98a1d9886c -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-linux-musl.tar.gz=e6bb6a67878c9cbbbbc96f1a1858500403ecc3b8c951366e18ace0f2601f41cb -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-linux-musl.tar.xz=f6509af9551e73ac16c425c53e667382bf7b6b48be65f4779485ee7843e68030 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-netbsd.tar.gz=3915f1907939fbfcd82012efa4293e7ddf22bd5bf1484efffacb31c805e6cf68 -dist/2025-10-28/rustfmt-nightly-x86_64-unknown-netbsd.tar.xz=cca6182ce9f2906a8b16971741a8435dbcf60d9ef6020cc7d6f7909525a73dc2 -dist/2025-10-28/rustc-nightly-aarch64-apple-darwin.tar.gz=876004fa16a6154ea8ea46cd1bb60a06fc14b24e72e26e20e42fde4e32882b46 -dist/2025-10-28/rustc-nightly-aarch64-apple-darwin.tar.xz=0a98f29bb6a2a1555f6ceaa161ecdd2e599ffe879b98bc98c6066e257fc12362 -dist/2025-10-28/rustc-nightly-aarch64-pc-windows-gnullvm.tar.gz=b07b2f7975b463970cbb4a8c92e51788ac63c3a46d3ae6c8cb54c7024161d899 -dist/2025-10-28/rustc-nightly-aarch64-pc-windows-gnullvm.tar.xz=5445b2e30804733fe2a7d07f66a77c2e3ec5e7c71bb55403541b8d365cf91870 -dist/2025-10-28/rustc-nightly-aarch64-pc-windows-msvc.tar.gz=d2cff6b8cb52172f4bb394f8ca891897c774ece1b87f9d30729aa236dfa24900 -dist/2025-10-28/rustc-nightly-aarch64-pc-windows-msvc.tar.xz=a6d0c00367b49654c91d4b71b33819854f628d51b7193c2475b9f737258a575a -dist/2025-10-28/rustc-nightly-aarch64-unknown-linux-gnu.tar.gz=c30649c2360aef41d97bdbf76d55bbfe674a1225161bc125a8215d3954656cda -dist/2025-10-28/rustc-nightly-aarch64-unknown-linux-gnu.tar.xz=3b204fb1461f47b4e2a79a67923abcf8610ab7ab006ee3f9a70cdc87458f81c5 -dist/2025-10-28/rustc-nightly-aarch64-unknown-linux-musl.tar.gz=949f55697b50db7d70a6465b100ae4458d2f676b818ca7227014ddc9c5f707e5 -dist/2025-10-28/rustc-nightly-aarch64-unknown-linux-musl.tar.xz=ff500cd8f318f0316936af462264254df2aa1bd5a2b368ad3c5758e9079eaf71 -dist/2025-10-28/rustc-nightly-arm-unknown-linux-gnueabi.tar.gz=231c4cfa37df03a0e0517843bd115a0f0b13ec259397d6e4dfb4014d3a0d4d9f -dist/2025-10-28/rustc-nightly-arm-unknown-linux-gnueabi.tar.xz=50f4d7060d02833949ffc970b88c5ad2183fabd3c498334bf63d87d0c9602720 -dist/2025-10-28/rustc-nightly-arm-unknown-linux-gnueabihf.tar.gz=f89586ea5bac722a06c225a50d7d603b4895aea89297509f248a1cb51a5cf0ed -dist/2025-10-28/rustc-nightly-arm-unknown-linux-gnueabihf.tar.xz=0de0552ae68cb9b61f2c5031cdbefae5ccde39c4003441e93c2e4e704d3751aa -dist/2025-10-28/rustc-nightly-armv7-unknown-linux-gnueabihf.tar.gz=019bbb267d1c0520a715287e0a1a680b58dd5e9ece2071f3ebd6f2b1d8eb2228 -dist/2025-10-28/rustc-nightly-armv7-unknown-linux-gnueabihf.tar.xz=069bcd46adfb5e14786fd8aced5ceb74af24cc05dfa2bd41ebd81ac146122598 -dist/2025-10-28/rustc-nightly-i686-pc-windows-gnu.tar.gz=911eb977b10aa4bb1f25124f08f3397fb3ac65f36666865be40bf44259b5d77a -dist/2025-10-28/rustc-nightly-i686-pc-windows-gnu.tar.xz=14ed0abc8708a90e8bbaf0c0de2aec1a4ed60c63b4db00fd4a732f3c808c125b -dist/2025-10-28/rustc-nightly-i686-pc-windows-msvc.tar.gz=8917e6dd4786f0f413908e9db4c92e060bce525f91b9cc0d43b453d26057435d -dist/2025-10-28/rustc-nightly-i686-pc-windows-msvc.tar.xz=86a8580a180de9224c176beb1ada2c69acc37fc73ae0e7c7780bbbded842365c -dist/2025-10-28/rustc-nightly-i686-unknown-linux-gnu.tar.gz=0d29e999ccbc46ff6b0c50a5648e0c5c8f767daa9a0d1fc86dff30c6e0078dd5 -dist/2025-10-28/rustc-nightly-i686-unknown-linux-gnu.tar.xz=bcafb54ca3f587d3cc9302c057da2fbdb4531e2279ef462fc8682e82e1046561 -dist/2025-10-28/rustc-nightly-loongarch64-unknown-linux-gnu.tar.gz=0a5bfd49a7a2fb98fe06815a2a50d9dc859722da3cc107928e36596c7b8c7f8e -dist/2025-10-28/rustc-nightly-loongarch64-unknown-linux-gnu.tar.xz=b8ec7898e087577b78ef1b716f8935c7023d740b389234f38075a09b2c7b494a -dist/2025-10-28/rustc-nightly-loongarch64-unknown-linux-musl.tar.gz=5cab6709c372feed484b5148ec642cf9767e7fe051146023459467012f2e0b64 -dist/2025-10-28/rustc-nightly-loongarch64-unknown-linux-musl.tar.xz=e42a3c007bdf7e8179c597daffc61d7a6bd8eac782b8d81d0b883267bc226f86 -dist/2025-10-28/rustc-nightly-powerpc-unknown-linux-gnu.tar.gz=a7cb220770ebd482ff9737d787d04e2e1274c46b7da0809041d06712e27f69ae -dist/2025-10-28/rustc-nightly-powerpc-unknown-linux-gnu.tar.xz=088b1d0898bc5b5d83d0fe20edfdadc2d1c0865c39108d11a5d078074aa37a1f -dist/2025-10-28/rustc-nightly-powerpc64-unknown-linux-gnu.tar.gz=90a3b28ca667187fb18eee8b87f5aebdb2c2e457acbe5b7b088d9b9a39314a1a -dist/2025-10-28/rustc-nightly-powerpc64-unknown-linux-gnu.tar.xz=4eb8f1d20b2eeb85a2b78d3e28a1d665e1171e1271540bdd8453833818d53c30 -dist/2025-10-28/rustc-nightly-powerpc64le-unknown-linux-gnu.tar.gz=e4fc106d7d4e098912b4dc0ac0211769ecc1f01731e118bf6c0bca33c7ceb9f5 -dist/2025-10-28/rustc-nightly-powerpc64le-unknown-linux-gnu.tar.xz=74bf23136731240e8dac7497d8b1a244fc35cd529d12f77fff308099354f3aef -dist/2025-10-28/rustc-nightly-powerpc64le-unknown-linux-musl.tar.gz=85ada50366246530a0dcbd462aef31a6edac600d22074d97bfc07321569eafdf -dist/2025-10-28/rustc-nightly-powerpc64le-unknown-linux-musl.tar.xz=f0cb51df2f6639fc65091608d569b9ac0730f5a8d88e27079d87bc8a8834b1e4 -dist/2025-10-28/rustc-nightly-riscv64gc-unknown-linux-gnu.tar.gz=c37432d8d8db7aaad9132e1301025dd5bf3671bad0ac1fea0f04e9aae238cae3 -dist/2025-10-28/rustc-nightly-riscv64gc-unknown-linux-gnu.tar.xz=57f72896f0309149a4b376a21d56ea28e65316db08065bfe32cdbd750bbc9657 -dist/2025-10-28/rustc-nightly-s390x-unknown-linux-gnu.tar.gz=170776eefa09f01859af0b3694c013ebfab04e9fcf8fb44233593ef4a763bd38 -dist/2025-10-28/rustc-nightly-s390x-unknown-linux-gnu.tar.xz=29335ffe7d88b758ec1a7a067056e35fe8f24430e8d899df3256b4e2d19ac16e -dist/2025-10-28/rustc-nightly-sparcv9-sun-solaris.tar.gz=14b5cfe710c92e8691aaad99de891695ef025638eca065587107c075a31215bf -dist/2025-10-28/rustc-nightly-sparcv9-sun-solaris.tar.xz=d21bb41b4abdaededefd199192bc257424295ec74d482693d032ca67f02dee15 -dist/2025-10-28/rustc-nightly-x86_64-apple-darwin.tar.gz=09c7d0777ea308ad552ea1e958f5c65fa3380c9cb93efa1e6edec3a29fc30b5c -dist/2025-10-28/rustc-nightly-x86_64-apple-darwin.tar.xz=923ef47f5bd9608d277b6636b8c798c5b2760460264fa6f0c0836f317746a89c -dist/2025-10-28/rustc-nightly-x86_64-pc-solaris.tar.gz=805643ab958df449ffd8dd5557e43c5e7060a10a3deab2238096b721ab451f08 -dist/2025-10-28/rustc-nightly-x86_64-pc-solaris.tar.xz=f2fb0c0643808bd9f483bf9bf66ead4444285f2e50bc1264b4861deddfaa9c62 -dist/2025-10-28/rustc-nightly-x86_64-pc-windows-gnu.tar.gz=05b7ee4041b2cdcee1739da7a22e4083acc24c043d11cb3f61d0c22237a9f42a -dist/2025-10-28/rustc-nightly-x86_64-pc-windows-gnu.tar.xz=2f3b04d56dd929ab5997711bc52395fa700247ff38b9362cda375b685c740337 -dist/2025-10-28/rustc-nightly-x86_64-pc-windows-gnullvm.tar.gz=52575038868d91349b40434ec8faf9836a0aa0a4f77c2decc634a9ba02796c07 -dist/2025-10-28/rustc-nightly-x86_64-pc-windows-gnullvm.tar.xz=d2d1f2a0d26cc3dc86d88ae46a9dcaa5f0ce694ebac3f46b7466fb058a1a76e5 -dist/2025-10-28/rustc-nightly-x86_64-pc-windows-msvc.tar.gz=5469701cbe03939a82ce5ec50dc166342ab968d2f96cb372dee8f29dfd6e4362 -dist/2025-10-28/rustc-nightly-x86_64-pc-windows-msvc.tar.xz=e6d18f7b7fa3a3613f1aa129f4a14820d4fa1977550689cd99b7dad12054edab -dist/2025-10-28/rustc-nightly-x86_64-unknown-freebsd.tar.gz=e2a5ff9df2b07f8c939fdb885da717faf19a5b3e63ab780962dc288f832cba6f -dist/2025-10-28/rustc-nightly-x86_64-unknown-freebsd.tar.xz=b577558a8f1b42d6bbbc80804e3b72835a85979c98659696db32832595283d04 -dist/2025-10-28/rustc-nightly-x86_64-unknown-illumos.tar.gz=5535a693d5b8edf3fae7e1da97c20596a1f60135fefe22835109ed3648765a16 -dist/2025-10-28/rustc-nightly-x86_64-unknown-illumos.tar.xz=bfc15f0678099ea110135d4e7bcb1b9a545f041e5810f6528d49e0b5451a29bb -dist/2025-10-28/rustc-nightly-x86_64-unknown-linux-gnu.tar.gz=877bf56730551f851e2ce5279c105f231906959bcf904aa2fc29acaba5160cc5 -dist/2025-10-28/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz=911bf7891d7687675f9200d3bd51946e21df3762b5320b7d31bd49d58526a8a7 -dist/2025-10-28/rustc-nightly-x86_64-unknown-linux-musl.tar.gz=c0c26704d16d6612d0d99ad078bbcb2ac0ed86419a0404a9e08739990acc5ad9 -dist/2025-10-28/rustc-nightly-x86_64-unknown-linux-musl.tar.xz=677f5c6126262b64126b5fc7c3c527cbc9e8ba62aaf4376c924149b6d05e16db -dist/2025-10-28/rustc-nightly-x86_64-unknown-netbsd.tar.gz=84c82523969ff1b987a09d5f7401e9a773b3110f51f00d708a4791ef6615272b -dist/2025-10-28/rustc-nightly-x86_64-unknown-netbsd.tar.xz=680eb70467d5695e986b013b3d16dbd0c0b0b7bc85cf8df4a3392c100f97eff9 -dist/2025-10-28/rust-nightly-aarch64-pc-windows-msvc.msi=a8f7ef71113d5ca8094d9433f23d5bab8ae910803e0cc23110d4fd0e04816bf3 -dist/2025-10-28/rust-nightly-i686-pc-windows-gnu.msi=6c4c49c2c2303f94a39d5c598c4f75b9d2c894b1c30aa6b49c8ab7ca674c8ca9 -dist/2025-10-28/rust-nightly-i686-pc-windows-msvc.msi=f7c80d8c614f5b53a596bfd8a263fc0e680b554ec47630e36e23354afb7fd426 -dist/2025-10-28/rust-nightly-x86_64-pc-windows-gnu.msi=2f830bf3391a7da78de14ba4ffd82de8a49652262fcc7a3ae377a3703fe7ab93 -dist/2025-10-28/rust-nightly-x86_64-pc-windows-msvc.msi=c9b61b50bace832fc504853a5ea5dacd869909946c04d1d9c95b15385e98fd47 -dist/2025-10-28/rust-nightly-aarch64-apple-darwin.pkg=8d7cb75018220eac497ffa180c94b210e2e53e8e8c36ab8a39d6c4c6234fe72b -dist/2025-10-28/rust-nightly-x86_64-apple-darwin.pkg=82e9979fe0cdbac0e008f46cd2d7da70e9fa2caa0d4f1df56654cf57114c993a -dist/2025-10-28/rustc-nightly-src.tar.gz=f6da3a086dd47e5ace7eec9f03879d4c3082503912fe631e54e38168dac60f22 -dist/2025-10-28/rustc-nightly-src.tar.xz=523289ae9e6a87f076decc1beb412897184e728302826882bf53dfde4df4ce15 +dist/2025-12-09/rustc-beta-aarch64-apple-darwin.tar.gz=a91d96a219d1c3a195b064ea786a693ddf3987afa20b4117352526e04d27a76e +dist/2025-12-09/rustc-beta-aarch64-apple-darwin.tar.xz=40e55dd62ba38d106cf6a53044d38ddeb41721a4f301a2dc54d8cc64b31e3ba7 +dist/2025-12-09/rustc-beta-aarch64-pc-windows-gnullvm.tar.gz=4747203b5f3387abea65d9076eb790c2d1cde3bcf1e058bf072149c4c08768be +dist/2025-12-09/rustc-beta-aarch64-pc-windows-gnullvm.tar.xz=07889f4d4a975817f64d3ca7fc3625159edcd58ed0f2121edc4be6c781318c8a +dist/2025-12-09/rustc-beta-aarch64-pc-windows-msvc.tar.gz=7c4a21a4a66b1a652a9f2ab7026f98d00b8bb792e9d35e43acbbb9e721e2fc1c +dist/2025-12-09/rustc-beta-aarch64-pc-windows-msvc.tar.xz=744d6df884551fc14c1284390378b6f133c8b971055d30f86c0f42d6864e958f +dist/2025-12-09/rustc-beta-aarch64-unknown-linux-gnu.tar.gz=b13dcb3bb092ad1cbca6ff91e9ca3c92eb363fdecc6b9c16175b07ce32435c6c +dist/2025-12-09/rustc-beta-aarch64-unknown-linux-gnu.tar.xz=36e6ca5ca171c09b3c5a4c36d877163674b9a4bb5562a1dc9a66c5af39d3f37f +dist/2025-12-09/rustc-beta-aarch64-unknown-linux-musl.tar.gz=047b25aca0b1d4f4d630db240f12c96433c25ee5d0a149499a715df120c73f10 +dist/2025-12-09/rustc-beta-aarch64-unknown-linux-musl.tar.xz=6a0332f6a824e8f25942178fb1eb562297a7dc31205d17b7dd11a2d9c64cc3f1 +dist/2025-12-09/rustc-beta-aarch64-unknown-linux-ohos.tar.gz=4f80108f65a8a05067972263acfc1756e06283ebb0bdac86974c96298dfb8ce6 +dist/2025-12-09/rustc-beta-aarch64-unknown-linux-ohos.tar.xz=71ac8ab1ef7624171a2d50c00577fa7a734146099e7d9e8bac10a784831a877d +dist/2025-12-09/rustc-beta-arm-unknown-linux-gnueabi.tar.gz=4beca02231720f3de8c3f11d97a69962c3049c2812d98c043df03e50d97cfb4d +dist/2025-12-09/rustc-beta-arm-unknown-linux-gnueabi.tar.xz=b1edced09ff9ea6a94cfd029578dc0b04e75713b25b7ba211907d398e4be4857 +dist/2025-12-09/rustc-beta-arm-unknown-linux-gnueabihf.tar.gz=bdeb895d3d69b7405c773af4c9e941e4c97d2e8916c5e381f2bfb9ee1e3d1533 +dist/2025-12-09/rustc-beta-arm-unknown-linux-gnueabihf.tar.xz=53f9efbc64431efed920f9f0ee5ced9ad18589237fe080983730d6536c0e94b9 +dist/2025-12-09/rustc-beta-armv7-unknown-linux-gnueabihf.tar.gz=bd65ec758f8a0bfade3daa30a3478424e0e59d2f18890545453dae1cd0410107 +dist/2025-12-09/rustc-beta-armv7-unknown-linux-gnueabihf.tar.xz=1180f684a647091ba857bf74a921933711f5dd3970995860ea7c12ecb4e25660 +dist/2025-12-09/rustc-beta-i686-pc-windows-gnu.tar.gz=386934445fce601578146f052dc042cf23292f6a9dbe22f1333ae93cf0872820 +dist/2025-12-09/rustc-beta-i686-pc-windows-gnu.tar.xz=64731c7e3c61ed0791c6a985d61207e3d687555f6d95abff73e9c051246c65bc +dist/2025-12-09/rustc-beta-i686-pc-windows-msvc.tar.gz=8b5df3cc0e53b36b32317461fe89ee7afc8333ee7e11184dc09ba2b96405e6ed +dist/2025-12-09/rustc-beta-i686-pc-windows-msvc.tar.xz=11273df779687a10be4c99e9175d8d4396580c1439d7a8ce27b6b4a674b3c401 +dist/2025-12-09/rustc-beta-i686-unknown-linux-gnu.tar.gz=e31368fbc85656ab864046539978da6b6635a6ee2cc15c48c617b988b84c0d8b +dist/2025-12-09/rustc-beta-i686-unknown-linux-gnu.tar.xz=de94f1f65cd3afc9c7caf554a50e3a1c7e8d730413c3dd4d9916618e7aabb3af +dist/2025-12-09/rustc-beta-loongarch64-unknown-linux-gnu.tar.gz=af6be7ca8e4b43b87a754bc63be169b392e4fdbccb9217fe19960bdd87278703 +dist/2025-12-09/rustc-beta-loongarch64-unknown-linux-gnu.tar.xz=caa7e16901ff848b2083ccf5b684c9e1975da3dad46bbbd72b127c9420508f57 +dist/2025-12-09/rustc-beta-loongarch64-unknown-linux-musl.tar.gz=8652e6f5e68146d3483dd7baa8e215b7ec003a626547cf087a541c78ed98fd67 +dist/2025-12-09/rustc-beta-loongarch64-unknown-linux-musl.tar.xz=d3853bfd0bfdbe96996764f27451154c0f0b4b135728c25a2be48b7ce069440d +dist/2025-12-09/rustc-beta-powerpc-unknown-linux-gnu.tar.gz=828e8cc488d70fc966bcc1196b019b74a7610cbc4b0947b04eea684da8e77f35 +dist/2025-12-09/rustc-beta-powerpc-unknown-linux-gnu.tar.xz=47bdc9313660ca1a29525155f3a7773ffa4021219dac5cfd309f5ec692ab1821 +dist/2025-12-09/rustc-beta-powerpc64-unknown-linux-gnu.tar.gz=f7b8dc496326a38d47f9769631b9893c803acb21cf7021e7ee200e81bffd0f2c +dist/2025-12-09/rustc-beta-powerpc64-unknown-linux-gnu.tar.xz=1d4ec35a9ee7cad99458db77f8787dee2c90556e56a21c8681984a09798f1e7f +dist/2025-12-09/rustc-beta-powerpc64le-unknown-linux-gnu.tar.gz=8dad2a1f7f9667270fb7e8d0917c77b251f2079251e46bf012d640754a46e0a6 +dist/2025-12-09/rustc-beta-powerpc64le-unknown-linux-gnu.tar.xz=259c2b9add30c03a6f91c4aaebfe4f052f0342bcc32df79af1121316ee5aafc8 +dist/2025-12-09/rustc-beta-powerpc64le-unknown-linux-musl.tar.gz=01b1b5bc19b82caa031c0ff2fe4d9d4ef27aa17a918ea15853c3680f3d1eea8a +dist/2025-12-09/rustc-beta-powerpc64le-unknown-linux-musl.tar.xz=4a410356d19e7e5b46a276c0ed015df3afa2af8aa5837feba11149212a4b4208 +dist/2025-12-09/rustc-beta-riscv64gc-unknown-linux-gnu.tar.gz=a0530a7ca051e0fd0ae303f479f0962e0d3bd0065be3cc42bf29272322ce4893 +dist/2025-12-09/rustc-beta-riscv64gc-unknown-linux-gnu.tar.xz=1e1ab9ce2619c6430e785c00cccf689fde5c20b4b81dd6281deba15615cdf9fe +dist/2025-12-09/rustc-beta-s390x-unknown-linux-gnu.tar.gz=bc0e4f9ba5f99fc9b849e95901140957d58cda12e980edf84a6a05544a32c80b +dist/2025-12-09/rustc-beta-s390x-unknown-linux-gnu.tar.xz=9ba83613dab2ffa00b581f5927abfb8398e3854fe21d2b685830ff57f609324f +dist/2025-12-09/rustc-beta-sparcv9-sun-solaris.tar.gz=8ed8158201b4f55d68bb5e89bcea83763803c5b592864495c5b614bea1cf717a +dist/2025-12-09/rustc-beta-sparcv9-sun-solaris.tar.xz=51e54052960f878e4e8d028917db9b02c0650350d50e537cd873c0c812a85957 +dist/2025-12-09/rustc-beta-x86_64-apple-darwin.tar.gz=ff615c109d69ff4beb505968210112b1307893824f410b3b461b9c3236b082b3 +dist/2025-12-09/rustc-beta-x86_64-apple-darwin.tar.xz=0a60addd526bd5964ae9710692a472edf6b9af88cbe6e671764dcd0fa7a785db +dist/2025-12-09/rustc-beta-x86_64-pc-solaris.tar.gz=e2c75e77f4f2582b2d3e7336daae2dd06a8d3a14de2ca954d8b65dc809cd774b +dist/2025-12-09/rustc-beta-x86_64-pc-solaris.tar.xz=2264bc2facde878befdddc8c47c7eb795ce5b2777a1d8fa48cbf5bb81e214475 +dist/2025-12-09/rustc-beta-x86_64-pc-windows-gnu.tar.gz=7e4a2a3cdfc7aa744b90a09dd6c0a98164898a7ff04c8a15ec61b91fe9efdcd7 +dist/2025-12-09/rustc-beta-x86_64-pc-windows-gnu.tar.xz=50b143dae27df2e923bf0d498e6ef155b95a89ad1548b6bb859e1c95fe1b9a92 +dist/2025-12-09/rustc-beta-x86_64-pc-windows-gnullvm.tar.gz=6e71c2b948b20319ef43242af469e241ce9567586fd6d872fd85751c8db1ca16 +dist/2025-12-09/rustc-beta-x86_64-pc-windows-gnullvm.tar.xz=a9b72e9897a93981b9c9f166f1f4072560c1eb4f9e0f5a5a6c2eb0ab742bd020 +dist/2025-12-09/rustc-beta-x86_64-pc-windows-msvc.tar.gz=e975eed4f35220c1cd0b7e19c2ad48ce9f57cb2d07b90a2331a16e2502d1289e +dist/2025-12-09/rustc-beta-x86_64-pc-windows-msvc.tar.xz=11a8f8d49f946bf4e1ebcf9e21ccc8d75de627c84776aba1041082f676cb029c +dist/2025-12-09/rustc-beta-x86_64-unknown-freebsd.tar.gz=94c7e7b64d00c24ffe18cd5b1c96ad9d55019acc98e9ad23d798974e7936780c +dist/2025-12-09/rustc-beta-x86_64-unknown-freebsd.tar.xz=ef33215967034bce1217f5587d9454dba543260ff38c2c80f8ecb1292f9c063b +dist/2025-12-09/rustc-beta-x86_64-unknown-illumos.tar.gz=45e2f150ac9a4aee63437d7621b5ad8782c4248f8dda30062b1a001a9f9c7a32 +dist/2025-12-09/rustc-beta-x86_64-unknown-illumos.tar.xz=e0196e2bccbad5d1e520f0e711a8d79ebc6296f8946421fc80c7c1b51115e9bd +dist/2025-12-09/rustc-beta-x86_64-unknown-linux-gnu.tar.gz=2d14a960636bae79f0ace6ae5b91ba2a07f8897512a5e7ce9b72601d4c0aabc6 +dist/2025-12-09/rustc-beta-x86_64-unknown-linux-gnu.tar.xz=d80990444597aeef8a956bb71ed468d874f1b47316e51afafe509442803ebae4 +dist/2025-12-09/rustc-beta-x86_64-unknown-linux-musl.tar.gz=e6bcc1ad145b9154560ef41d0e664dbf133980226983c334f5c3ffe1350892ae +dist/2025-12-09/rustc-beta-x86_64-unknown-linux-musl.tar.xz=1dbe4c0222aee37c45b8bb53dd563a56c4f7f198e97b25e22ea5590bb4bc47c2 +dist/2025-12-09/rustc-beta-x86_64-unknown-netbsd.tar.gz=618cbe2bd888669e7b0ee73b127f4a68bc1a30976ae41cfebbe806be794eb143 +dist/2025-12-09/rustc-beta-x86_64-unknown-netbsd.tar.xz=ecfde3d55928deeeabe49e31a5263ade8119897f9f82aafe594406d5ec2fc1a9 +dist/2025-12-09/rust-std-beta-aarch64-apple-darwin.tar.gz=71485c941dacf6a9f2acebfb7506eca5802aba23fc941208d1563fd0a6b74876 +dist/2025-12-09/rust-std-beta-aarch64-apple-darwin.tar.xz=2bec6cbb4c6249fa5a5384ef67dfed9c5b2149589efb086f18b675eca472c255 +dist/2025-12-09/rust-std-beta-aarch64-apple-ios.tar.gz=62701f83e7d374f318756720f6a7ca14a9dd94935df92bb635da718a724e91a9 +dist/2025-12-09/rust-std-beta-aarch64-apple-ios.tar.xz=b596278416039b70cdca751482255b16708bde9ad008b08a49362456231904d6 +dist/2025-12-09/rust-std-beta-aarch64-apple-ios-macabi.tar.gz=38bea00e6057cd52d98b7a707f36d091877b8a8dc38c4aa3e8e08a57e95caa75 +dist/2025-12-09/rust-std-beta-aarch64-apple-ios-macabi.tar.xz=45a01da54adc3c02e0e5837ca30a1e5d2f284958d6622d048c2b76442026ceae +dist/2025-12-09/rust-std-beta-aarch64-apple-ios-sim.tar.gz=40b32df24c2b916d829868fcf7694c9cc00a5853edf8addf586ed346ee29e2bc +dist/2025-12-09/rust-std-beta-aarch64-apple-ios-sim.tar.xz=7d9683d5614f0fa59641e299d169275f7e26d1ab8e4c1510216eb15307e6c63f +dist/2025-12-09/rust-std-beta-aarch64-linux-android.tar.gz=97ddf7807abbd7494c9c0053a6d1b6ef9b5a02329a572eb6ac56c58843d6e558 +dist/2025-12-09/rust-std-beta-aarch64-linux-android.tar.xz=b971a8c8a44a3fa048752e23232335e7896e3c4ef2cdf8636a3d3504e2a8ddaf +dist/2025-12-09/rust-std-beta-aarch64-pc-windows-gnullvm.tar.gz=d3acb91f5bb97c0272c2d61b2abc6ba0a717808c89b201273f4b8a6a9aca08ff +dist/2025-12-09/rust-std-beta-aarch64-pc-windows-gnullvm.tar.xz=3cc8c607b8289748cec9b3470ca37fab63be4f5a48cf3fb3dd48c5e7983b3682 +dist/2025-12-09/rust-std-beta-aarch64-pc-windows-msvc.tar.gz=d65621d42ac27885ab47ae95cc5feae4aa6ededc61b7d3206f9ddf930da08d41 +dist/2025-12-09/rust-std-beta-aarch64-pc-windows-msvc.tar.xz=8f96ad5facfb3f4b03bb84fb49b014505795764dbb49a66497c753bdbcea6fa1 +dist/2025-12-09/rust-std-beta-aarch64-unknown-fuchsia.tar.gz=e5ae9120a770ee03254ea202031d11cc5d0f06260c3818334d4afd586ba619a0 +dist/2025-12-09/rust-std-beta-aarch64-unknown-fuchsia.tar.xz=1fb8e830cf4dfa2df68b3d730cb709e4225fe13002e4bf768d875be7c330b892 +dist/2025-12-09/rust-std-beta-aarch64-unknown-linux-gnu.tar.gz=21d61a5e4e7a84d87b8d371900300b0a9bc4afbfd1b8fc6e6500be338a8f40cf +dist/2025-12-09/rust-std-beta-aarch64-unknown-linux-gnu.tar.xz=82783445c68a553bfe1cdb25161073c03deb2a9733e5811f29ff03d86879df56 +dist/2025-12-09/rust-std-beta-aarch64-unknown-linux-musl.tar.gz=69855bba4ddd7e77fadf35cb2fb3e4c6ae9684a3ed68c7b6a949d03b3a2ba2dd +dist/2025-12-09/rust-std-beta-aarch64-unknown-linux-musl.tar.xz=37ccb03697edc787ab7d07e7e77ee328b8dcae8ce5d9d328dcda28489bb4bf6e +dist/2025-12-09/rust-std-beta-aarch64-unknown-linux-ohos.tar.gz=81f3a854fb1af8271abbf4332993b755d3746ad3878066544a0187f80d0d2ab3 +dist/2025-12-09/rust-std-beta-aarch64-unknown-linux-ohos.tar.xz=054666e60b05826046760bce5a1f6b6aa8991205c912cf4faa6630e98808e3a7 +dist/2025-12-09/rust-std-beta-aarch64-unknown-none.tar.gz=e382fedc0bedfaea97ab7d8e2228fe3d437143812fffff224ae14fc434059157 +dist/2025-12-09/rust-std-beta-aarch64-unknown-none.tar.xz=72aec0eb4181535516597e859fd8f10b2216cedec0659b6d322ee353226e5623 +dist/2025-12-09/rust-std-beta-aarch64-unknown-none-softfloat.tar.gz=2e4e1fb234fe8734d884bc180790632be460cedb35fefabf453be6efaca39aff +dist/2025-12-09/rust-std-beta-aarch64-unknown-none-softfloat.tar.xz=f8aa1f77cbcb85def86b725263a70f4d714cbf8c838a563a4fc272aacc2f3ba6 +dist/2025-12-09/rust-std-beta-aarch64-unknown-uefi.tar.gz=65ff64a57050f3be4b64f49c630aca871b448db30ffad76e601cec5306cbef8f +dist/2025-12-09/rust-std-beta-aarch64-unknown-uefi.tar.xz=261f0af0b1b991f59235b0dc05745b51641d649b1b59af7f5f6469ba0a273b0e +dist/2025-12-09/rust-std-beta-arm-linux-androideabi.tar.gz=c8b5c64541286f0b0a9675083bf2c37fdd39577b362efac149cd261bc19fbdc6 +dist/2025-12-09/rust-std-beta-arm-linux-androideabi.tar.xz=4d43c454ea36de0dc391de15d6cc54f0e24982d5b6f6b0574775b68317003c03 +dist/2025-12-09/rust-std-beta-arm-unknown-linux-gnueabi.tar.gz=acdb7e966699acafa86b4873dfda34724fb53f2688ff3a76edf4c0f638443648 +dist/2025-12-09/rust-std-beta-arm-unknown-linux-gnueabi.tar.xz=fa2d71b3d23572172fcede867b6ffe95135576c696ad2b7f7642bc97d9cb59f7 +dist/2025-12-09/rust-std-beta-arm-unknown-linux-gnueabihf.tar.gz=c07bb539390c033df181ece6cd12ff3e9495719d7ea24e8410815436c8d43d4b +dist/2025-12-09/rust-std-beta-arm-unknown-linux-gnueabihf.tar.xz=d1bfaa712e3687f1a24e0733666e6f78593b2ec66e7edd4a90183e15afacc38f +dist/2025-12-09/rust-std-beta-arm-unknown-linux-musleabi.tar.gz=19fc80ca30e77eace2e2c0d37ebe93efe5423ab08852832c18e5be5f9a49b994 +dist/2025-12-09/rust-std-beta-arm-unknown-linux-musleabi.tar.xz=046322601ea0962b6ca9587731a1d3270fd229d18161f02c056bfe882c77481d +dist/2025-12-09/rust-std-beta-arm-unknown-linux-musleabihf.tar.gz=0689439e1518597b6ebb5e1c0e4bcb61a741c0e4f540c03fdc92a5abdb177608 +dist/2025-12-09/rust-std-beta-arm-unknown-linux-musleabihf.tar.xz=00c3dbc2f78f4e372557b59004139708347c543c61c485d8ef6f673840482b01 +dist/2025-12-09/rust-std-beta-arm64ec-pc-windows-msvc.tar.gz=597fb79132dcc86f20b52a7e3694e2aca4e0b1310f2936ec1eda102f0dbff0b4 +dist/2025-12-09/rust-std-beta-arm64ec-pc-windows-msvc.tar.xz=a2e4f7a5026ebd05fed1aa1a925347db043bb03afe5e16cac09cbca6c6ca88e0 +dist/2025-12-09/rust-std-beta-armv5te-unknown-linux-gnueabi.tar.gz=476a217d51c05c3b192bf668db05270e2ad48004635a29194eeb1268c6cf86fe +dist/2025-12-09/rust-std-beta-armv5te-unknown-linux-gnueabi.tar.xz=12a59c08179d0bdbf6811b90aee922b5744a1cc8110ef04db71eb8315e950208 +dist/2025-12-09/rust-std-beta-armv5te-unknown-linux-musleabi.tar.gz=0acdd625672417f897e3381383e2e7982d4b1d29ac418bd4fd864a969532693f +dist/2025-12-09/rust-std-beta-armv5te-unknown-linux-musleabi.tar.xz=515626a896f9d9bc1fcc6ec33adda205b609fe6a41c1462fec0e74bf3c50ff75 +dist/2025-12-09/rust-std-beta-armv7-linux-androideabi.tar.gz=167e74b6f5cb8283ecb53e596c1728d8f91846cbf1b30c7d640dee9b20d433b3 +dist/2025-12-09/rust-std-beta-armv7-linux-androideabi.tar.xz=c2e69b04d4cd86a83aa9b9c3ec37adf3cda2d06c1a4ec977068d216a48681d2a +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-gnueabi.tar.gz=91866669e8946c1949aa48781df52854b5fe537026f9a93c9adf67fd2189ae19 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-gnueabi.tar.xz=95633a5ba9bc81093b56f5c318d97c50a27f0d553b7e878f039a3a12df4c7e4a +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-gnueabihf.tar.gz=c9746beaf4896937c708143270278c0e6b4b40d7155cf5746443f0f03fee705f +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-gnueabihf.tar.xz=defaafa063c1c57bb5f9ff0320a1f26e4dc7bc626ac31e2d028ef16c81fa3301 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-musleabi.tar.gz=630af0d305dc441dfa2c04ede30f5d11d154ee04be72f6507f321123ed6bc741 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-musleabi.tar.xz=b875e2f68624a8149115a1e86b66a279931305816efce81b005ef0479c898528 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-musleabihf.tar.gz=6f751bf3da85ab19ace00fdac387a60ee6f2ce4b55f5b52efab2a7a7e0d679a7 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-musleabihf.tar.xz=b10cf3d867407de5c93c2bd65c616d0d5dcba4997c25ad396b5814af86f09d73 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-ohos.tar.gz=98a4971ed72aad245ca31a7409ec0e33b4304ed3fe470df12b35f83642022883 +dist/2025-12-09/rust-std-beta-armv7-unknown-linux-ohos.tar.xz=f89afd1dab7a482e0d1984fe8852b1a78b2e708d348ddce3978687190e205e84 +dist/2025-12-09/rust-std-beta-armv7a-none-eabi.tar.gz=5801642b53256e015e216b98e1791d9d286e8da496d8a3d0b006f4328b73c814 +dist/2025-12-09/rust-std-beta-armv7a-none-eabi.tar.xz=eee727983344340eab73c430a9ca66763a743c59c2e34b84d2937979e9c02801 +dist/2025-12-09/rust-std-beta-armv7a-none-eabihf.tar.gz=b934350dc0ef04038d0c4cf7924f0d573f559e5925d476cee743a9a74301e953 +dist/2025-12-09/rust-std-beta-armv7a-none-eabihf.tar.xz=46fb1485ebdb726e33e4e2cdeb260578a19ade553caba9190beb3a1ca9d190fb +dist/2025-12-09/rust-std-beta-armv7r-none-eabi.tar.gz=5957cf630fbfb7e3758e151607f2b0d87736f90255822ddd37d8761582f28a58 +dist/2025-12-09/rust-std-beta-armv7r-none-eabi.tar.xz=63b92037e86a526c734461c02d8450c83136b05fef17e8d80e998d513bba9caa +dist/2025-12-09/rust-std-beta-armv7r-none-eabihf.tar.gz=35360bb54ca208dc4b819ec1151d99daf5a2bc7c7f31b81b24f06df1e994b644 +dist/2025-12-09/rust-std-beta-armv7r-none-eabihf.tar.xz=3bb49e862d38d34b5ac52eac27d65eb0c2913cc4d486c83004c485c1a93f36b4 +dist/2025-12-09/rust-std-beta-armv8r-none-eabihf.tar.gz=77c0a3b6a3d57c40012a1bc1818fafaf8b3591c6ac451ea4a05cc599da96e8b6 +dist/2025-12-09/rust-std-beta-armv8r-none-eabihf.tar.xz=add26a701346661f3b16d4ba1db9c8ec795c58427b5a8d1081c7a55faf3813a2 +dist/2025-12-09/rust-std-beta-i586-unknown-linux-gnu.tar.gz=525031f51d2c92301692c0798b48534d2b845eba44e01f7f8e7e7ce4fb6f9379 +dist/2025-12-09/rust-std-beta-i586-unknown-linux-gnu.tar.xz=a882f765539da05de5f8782a6bd6cccc34c5179b6b4ae845eb27a8e9a354fc82 +dist/2025-12-09/rust-std-beta-i586-unknown-linux-musl.tar.gz=0ba2fbbb2cb8aba07122bdeb8ed94e061b256d747c5ad679ddad701601d51211 +dist/2025-12-09/rust-std-beta-i586-unknown-linux-musl.tar.xz=5554b861765e43f530b23595622f399bc83ad04900123f366aeedad71c2e957d +dist/2025-12-09/rust-std-beta-i686-linux-android.tar.gz=039a001036cca4cd22fb42cc60777fac2e2cc9553d0987096c285efc87c53a3f +dist/2025-12-09/rust-std-beta-i686-linux-android.tar.xz=b9ce40f48e695b60a98debff5de341a7303bb8dead8d4f33ca9d9dd0cd5d692a +dist/2025-12-09/rust-std-beta-i686-pc-windows-gnu.tar.gz=34138dba519fe8d3c45326b22091e29d68c4df53c404f1ce90e8d50d9412b5c8 +dist/2025-12-09/rust-std-beta-i686-pc-windows-gnu.tar.xz=ea604b3b0204605f8973c7b257f95c0095a549a221b5166a4fab36fde21fb4ed +dist/2025-12-09/rust-std-beta-i686-pc-windows-gnullvm.tar.gz=6ff8d19ce86de968e10e8449e87528f81979e3470e5ebdbf7c1a089f4896b01b +dist/2025-12-09/rust-std-beta-i686-pc-windows-gnullvm.tar.xz=1659e5a260362e596f26bc55807e8ed407c2603203ddb8201bb6993873fb1cbb +dist/2025-12-09/rust-std-beta-i686-pc-windows-msvc.tar.gz=e2afe62459e655796c3a1c61d6342dbb43eec597a322be633bf4f6ebb3e60faf +dist/2025-12-09/rust-std-beta-i686-pc-windows-msvc.tar.xz=c6e8d9df8fc459d10e7382d4d324604ffbe0f4f18c595684e38c83df149eacb2 +dist/2025-12-09/rust-std-beta-i686-unknown-freebsd.tar.gz=12c3d52726261b7c714e69773d5eba430683f1b5daa5ebbfa728367f2073a9e3 +dist/2025-12-09/rust-std-beta-i686-unknown-freebsd.tar.xz=6e62b81aa735b8f99668fa15741a9b20201e51abc976143b894d867160c2b9a4 +dist/2025-12-09/rust-std-beta-i686-unknown-linux-gnu.tar.gz=f55362021acbf7ce28291f535210d21807caa63811aaa2206d5ceff0e0cb789e +dist/2025-12-09/rust-std-beta-i686-unknown-linux-gnu.tar.xz=c1c9b90c8586805b02d74465d5293ec3d286a07e646e51cfb91505a7d407cf90 +dist/2025-12-09/rust-std-beta-i686-unknown-linux-musl.tar.gz=5df73e6eb6ac56c1866d123852864ae5946be38e97131e0fc23cfbc0ca807a9e +dist/2025-12-09/rust-std-beta-i686-unknown-linux-musl.tar.xz=cb7a6d7060cc9fbc01e54546377d3ee5076ba36b46203acb0aa44fa75ea10c15 +dist/2025-12-09/rust-std-beta-i686-unknown-uefi.tar.gz=3616a3ed2eb921f2075b53c1b04134b1668e4b6d692d50c66ce2d37e7b96740b +dist/2025-12-09/rust-std-beta-i686-unknown-uefi.tar.xz=ac64b54721d8f6b218a9f8a50197b4a8d62d48bfbcd90c4bfca75117f2d359ce +dist/2025-12-09/rust-std-beta-loongarch64-unknown-linux-gnu.tar.gz=219729c628f9729d415680c688704d7561e1550b8ecd1d508b103c204ce47f35 +dist/2025-12-09/rust-std-beta-loongarch64-unknown-linux-gnu.tar.xz=73ecff3074ebc9abe9efec380c75c8c717df50a08b339dd0aece8538b58daa04 +dist/2025-12-09/rust-std-beta-loongarch64-unknown-linux-musl.tar.gz=481877f357877619d950d0826197843e47204d3b57aee11b7880ce4559da5dba +dist/2025-12-09/rust-std-beta-loongarch64-unknown-linux-musl.tar.xz=60674e9092592803e2bbb2a36d8793e3c88f56187f43f289d5a63ddb10cad23c +dist/2025-12-09/rust-std-beta-loongarch64-unknown-none.tar.gz=2651b85be9f606f7d769433f716e482921cbfd39c3318fcedc0a42b35eea5bd4 +dist/2025-12-09/rust-std-beta-loongarch64-unknown-none.tar.xz=b304b09ff87242b78ea524c3a3c8dcf5d30d4889f7d103318df9316bc65d051c +dist/2025-12-09/rust-std-beta-loongarch64-unknown-none-softfloat.tar.gz=6a1735d9a1d6fed323a659ee39a88dcdcce72385b9b306135b7ec24c3e3f6cd0 +dist/2025-12-09/rust-std-beta-loongarch64-unknown-none-softfloat.tar.xz=d0b1ec1cb5a97e60b3a805f60b75d06e8572d9f513310da72e7029e23449d457 +dist/2025-12-09/rust-std-beta-nvptx64-nvidia-cuda.tar.gz=bcf45185cb5475a179c4402f787fd6780545512f3afa33dca71c6862e83240c3 +dist/2025-12-09/rust-std-beta-nvptx64-nvidia-cuda.tar.xz=aee86a13753c9be073a18dce28384921f2a5519d272802791e1d5b96ed00cd2c +dist/2025-12-09/rust-std-beta-powerpc-unknown-linux-gnu.tar.gz=2da51021239ce4c3dcc36c02107f4abc70df7b157784e7c9dbb4aa9d83014e49 +dist/2025-12-09/rust-std-beta-powerpc-unknown-linux-gnu.tar.xz=3c54a7b9cf2318589f9d52109b0083df2eb7193f2c4d45d166c1912353ac0812 +dist/2025-12-09/rust-std-beta-powerpc64-unknown-linux-gnu.tar.gz=49107f7d7290c8779161095c2f7218e929cf4498b04cb8717b2e04ef00d04139 +dist/2025-12-09/rust-std-beta-powerpc64-unknown-linux-gnu.tar.xz=26539ea11b3838de5c530c0462c38f31aa5ae889abd65e5eb18a8817353207e0 +dist/2025-12-09/rust-std-beta-powerpc64le-unknown-linux-gnu.tar.gz=198b5e4b994c18e096a0c24a1ede2ef180183780f1456d3af3ef46d516fface0 +dist/2025-12-09/rust-std-beta-powerpc64le-unknown-linux-gnu.tar.xz=9c31f5d881ea898da452d628bc0a1e2e27434e8c6b3f5561e0e326024dd91d9a +dist/2025-12-09/rust-std-beta-powerpc64le-unknown-linux-musl.tar.gz=e796cbfca385de190e7b56fe4c5e8b76a22410fc1e303c55dd22db03df5eb15e +dist/2025-12-09/rust-std-beta-powerpc64le-unknown-linux-musl.tar.xz=056cbacb291248e2ff71e6d051119bc3b6f4157cb0e9349b4a69bc71165ee978 +dist/2025-12-09/rust-std-beta-riscv32i-unknown-none-elf.tar.gz=f28ca9d74bbf52ab554f83f70e42e55f050610a49f1c57230ca65fa7088b1b48 +dist/2025-12-09/rust-std-beta-riscv32i-unknown-none-elf.tar.xz=3a5637edd1179cf15143250ee5e152a1e21c0eb0aa725f05f4a0a7d902b04ddf +dist/2025-12-09/rust-std-beta-riscv32im-unknown-none-elf.tar.gz=202251567a7cac42470061f4fbfe7e465d94838b492654256992960ba746b27e +dist/2025-12-09/rust-std-beta-riscv32im-unknown-none-elf.tar.xz=faca8810a93a0c916f75643c60a6dfc873c4521647b4f2d3a288e510885f7e70 +dist/2025-12-09/rust-std-beta-riscv32imac-unknown-none-elf.tar.gz=226c5737b033bc3acec904593845f484d32451e2a1309250cfe6c1910013f9e7 +dist/2025-12-09/rust-std-beta-riscv32imac-unknown-none-elf.tar.xz=99f33be2da6e9da57ca13cc50cc2c27f769189cb0d28f8d4576c9d1cdd3784dd +dist/2025-12-09/rust-std-beta-riscv32imafc-unknown-none-elf.tar.gz=8ff0b8eb19a4007dad61364ec7957d25fd7778c4c2801dc324ef0638cb874a81 +dist/2025-12-09/rust-std-beta-riscv32imafc-unknown-none-elf.tar.xz=3f4d1f9cbd0db9de6cd0657bcd1844726dd268de71fba893194be76827a1c77d +dist/2025-12-09/rust-std-beta-riscv32imc-unknown-none-elf.tar.gz=f455e8855d37ccf35f86964d91a62ef3fd3ba167fd722e4ac5195b6516fa8c5c +dist/2025-12-09/rust-std-beta-riscv32imc-unknown-none-elf.tar.xz=e698357e974ba32256663c9c0c98209f5f7303f415acce2a6f821d5af4175a20 +dist/2025-12-09/rust-std-beta-riscv64a23-unknown-linux-gnu.tar.gz=57af63ea6f6944a2f6a3311f2ccfbb1d77e2fcb1a8c7d2a3e0bc7db0f3c2b63f +dist/2025-12-09/rust-std-beta-riscv64a23-unknown-linux-gnu.tar.xz=e0779b0a0d2321967350831c1e32bb04abf555667c6666bf137f821bd1858792 +dist/2025-12-09/rust-std-beta-riscv64gc-unknown-linux-gnu.tar.gz=eb3a1f13c27c2d8e2f016385af36b4fe7ae6a879f3440328abcd85986287a190 +dist/2025-12-09/rust-std-beta-riscv64gc-unknown-linux-gnu.tar.xz=cc96484aed4fb6e0e6f5df5326ab9e6647e3d2367752d25f5717f007fcbba6a1 +dist/2025-12-09/rust-std-beta-riscv64gc-unknown-linux-musl.tar.gz=ef8c620a7bd4aae0db5b4b6b97ccb03cb818362e782c845f191f6049e74fa222 +dist/2025-12-09/rust-std-beta-riscv64gc-unknown-linux-musl.tar.xz=ff3405403beb6d794e0f7866c15664a8a8b927c924f99af3f03dbd2d7449eed9 +dist/2025-12-09/rust-std-beta-riscv64gc-unknown-none-elf.tar.gz=dcd2e20de8a9064e569f59092b81385fab67456ef86d5e4b25ee39a6fcdf52d1 +dist/2025-12-09/rust-std-beta-riscv64gc-unknown-none-elf.tar.xz=39f8802cc4106bfa67b6a0cad88534af350619d66718458dbc3912b0ec12f369 +dist/2025-12-09/rust-std-beta-riscv64imac-unknown-none-elf.tar.gz=a7453854d101abc9cb8ee0075c3575eabda972911def34919c5437be79326b32 +dist/2025-12-09/rust-std-beta-riscv64imac-unknown-none-elf.tar.xz=d00175adb49aabe0d6a76592df30558ac745f62fa2e9a62887141a2fbc7304f4 +dist/2025-12-09/rust-std-beta-s390x-unknown-linux-gnu.tar.gz=1725461c9399c95aab95c7963d1f351c7b0d487a96a1d60043b3fd223cfa550c +dist/2025-12-09/rust-std-beta-s390x-unknown-linux-gnu.tar.xz=5157be3919659a14beec82ab274b9fefcea8d7eb56d35de2c7278e21cf4e10f5 +dist/2025-12-09/rust-std-beta-sparc64-unknown-linux-gnu.tar.gz=5380c9bac880edaaf16de8e5fdfdd8deb2b645e4933c18b4928c96755ddbd604 +dist/2025-12-09/rust-std-beta-sparc64-unknown-linux-gnu.tar.xz=0700f10b4c8dce6bf86df94fa7413c95596aab6b70ca89437b226b33a1b5cf22 +dist/2025-12-09/rust-std-beta-sparcv9-sun-solaris.tar.gz=0b3e6a7b49dba2ed53a59ba733ac35094a06e2b1896b88442c72aba36f5c4038 +dist/2025-12-09/rust-std-beta-sparcv9-sun-solaris.tar.xz=18d6ca35ca291af5873d726db3494e3f64fd57f0ca7ed5a60003f7a769f29ce0 +dist/2025-12-09/rust-std-beta-thumbv6m-none-eabi.tar.gz=227f530497142eea0e3906b517c0d93bdba0a598ed469553b7928f094dbd5673 +dist/2025-12-09/rust-std-beta-thumbv6m-none-eabi.tar.xz=b68840c4e61887c593ced00dddb707f95538c72b70c1f5c729086f95604c3d89 +dist/2025-12-09/rust-std-beta-thumbv7em-none-eabi.tar.gz=ed01c5d7941e37e930e5689523a38aa1c8560b99ff90f20443a687e62cff4f51 +dist/2025-12-09/rust-std-beta-thumbv7em-none-eabi.tar.xz=c4170568ef0f5127c55544bd0ca32d5a0f8bd485218fad54129df1c9ca9d806d +dist/2025-12-09/rust-std-beta-thumbv7em-none-eabihf.tar.gz=1bab00737022c44c767ecce5e84f4f0d995ec0358ea50d813b8397e0a4ecb6a3 +dist/2025-12-09/rust-std-beta-thumbv7em-none-eabihf.tar.xz=ad3fd09b465f7a8420be64e43d7ca50f83aa0aaf38fcf30593be6a067593c438 +dist/2025-12-09/rust-std-beta-thumbv7m-none-eabi.tar.gz=fd5f2111dbaef4bee091d09df11f241e7d687fd4dbcbca87348302caef107cc5 +dist/2025-12-09/rust-std-beta-thumbv7m-none-eabi.tar.xz=ab409331b70f565143a34575745f8a25d2eceb1f878aab0c51453fd37cb3be33 +dist/2025-12-09/rust-std-beta-thumbv7neon-linux-androideabi.tar.gz=845ee997875c5a78f80d967894efaf3ebce89306756166513f2a291c9de9920e +dist/2025-12-09/rust-std-beta-thumbv7neon-linux-androideabi.tar.xz=d47c061768ed88a67755597a4c592213f9ab65c1899086d1f6932042d9c61cc3 +dist/2025-12-09/rust-std-beta-thumbv7neon-unknown-linux-gnueabihf.tar.gz=ebc31ccfd49f8583e3c8ea5c0dc0bd1574edbc486bf3b48f8941599ce37207a8 +dist/2025-12-09/rust-std-beta-thumbv7neon-unknown-linux-gnueabihf.tar.xz=79204e81dfd8a46122222ddaf24c9c0931876b8965b54523138764510d6516cf +dist/2025-12-09/rust-std-beta-thumbv8m.base-none-eabi.tar.gz=8f55906a80c91d1e6836513826931185de79dd5c653b8bfeb1e48e37397face3 +dist/2025-12-09/rust-std-beta-thumbv8m.base-none-eabi.tar.xz=2492a0f81dd79b0bf667ab068a36bd7223832ea91737c025d70da36677b74d22 +dist/2025-12-09/rust-std-beta-thumbv8m.main-none-eabi.tar.gz=217d7f3d7b421cda819bd2723738caac2fac06c1b2e3aa3316e9a310f3ac913f +dist/2025-12-09/rust-std-beta-thumbv8m.main-none-eabi.tar.xz=cca4be68e522ccfcd51b08d356d7a8e01d1a29b47a1f1ad224da08ca478fafb0 +dist/2025-12-09/rust-std-beta-thumbv8m.main-none-eabihf.tar.gz=8440d1030be1a5963bdb37c690c001046d369e43ce2fbba9a5823cacc17d16f2 +dist/2025-12-09/rust-std-beta-thumbv8m.main-none-eabihf.tar.xz=41836a990ab6fff97ca35e8b42e345179c475e87f684b166dfd1a40e65da773e +dist/2025-12-09/rust-std-beta-wasm32-unknown-emscripten.tar.gz=ec25fd98026b960e04ffb28b5a21bd9574dda359aa0f6f905f17cdcaa45c86d0 +dist/2025-12-09/rust-std-beta-wasm32-unknown-emscripten.tar.xz=ea4d554a967e035a5d03ab3098eed7d0d493ac46a75c5bdb4f8b294b98f6092c +dist/2025-12-09/rust-std-beta-wasm32-unknown-unknown.tar.gz=ecb7f66836e8745663c346d5de957fef96583e36053a94e3171813746edd79aa +dist/2025-12-09/rust-std-beta-wasm32-unknown-unknown.tar.xz=639c98dea1d0db49b827e96404d1126e604bcfa111ea4bf6519c67232f588600 +dist/2025-12-09/rust-std-beta-wasm32-wasip1.tar.gz=436dc6f6eb37ef3c956c8f020d5eecd51034e5cf4df5940b8295d6bfbe00202d +dist/2025-12-09/rust-std-beta-wasm32-wasip1.tar.xz=65e96ffd02b3735a2b84a00bc3872ea0f574096f56de6c77fb00b3e1d7a0e1fa +dist/2025-12-09/rust-std-beta-wasm32-wasip1-threads.tar.gz=71f8c5f5bdebd64ded342df43f98493d8ecd52434201cad2f6160e06eccf15fd +dist/2025-12-09/rust-std-beta-wasm32-wasip1-threads.tar.xz=81ccdab9aa05a1839fea2498ec7eac882b4c56ae3c573ca43132ac450c48738c +dist/2025-12-09/rust-std-beta-wasm32-wasip2.tar.gz=29b92754da126ee7e8bb1b71b7ee98255c52b53b842923ad29a97d4d54b06737 +dist/2025-12-09/rust-std-beta-wasm32-wasip2.tar.xz=c6fe278fbf360f03e5dc13a7e9de2b9eef4a8cb65e543e63c4e299df155a6018 +dist/2025-12-09/rust-std-beta-wasm32v1-none.tar.gz=a0645d157f59d1bf2e97f89e0453e13f02ec114ab28a07aa2d5746b15073f2e2 +dist/2025-12-09/rust-std-beta-wasm32v1-none.tar.xz=7120f968949be0ec4f89312135f36adda1b75db3d2070d6548a71324e57755b4 +dist/2025-12-09/rust-std-beta-x86_64-apple-darwin.tar.gz=07b68e518da8d290c26d8917f18f31c4c0b8c00f2aa83b4d70bd057e42264d1c +dist/2025-12-09/rust-std-beta-x86_64-apple-darwin.tar.xz=00785f17e51985fcf66185547c4996da73cfac13dfef10e3143491fa0a50bdf4 +dist/2025-12-09/rust-std-beta-x86_64-apple-ios.tar.gz=09aa4217e1fa44ca41f0711374b3dd194849f7eabe988275915c6a3cc9a5b34d +dist/2025-12-09/rust-std-beta-x86_64-apple-ios.tar.xz=cc7723d874929dc474643287905165b6ebc2d5b5d488b00a4239436f65bb0373 +dist/2025-12-09/rust-std-beta-x86_64-apple-ios-macabi.tar.gz=7893661c4998ba8c53e25770d2ee63cc5c52583a7c3a65c8289697a9b3c734c5 +dist/2025-12-09/rust-std-beta-x86_64-apple-ios-macabi.tar.xz=f07589b38e0f48d6d349c71b029347a006f52a9777e53779e933df296dd5fd41 +dist/2025-12-09/rust-std-beta-x86_64-fortanix-unknown-sgx.tar.gz=6bf1078f18c314bbda2e8e61c6d7bd821875d7cd6945fc00b25b7c1b951a734c +dist/2025-12-09/rust-std-beta-x86_64-fortanix-unknown-sgx.tar.xz=740bbd92e86c8c2809c8922e696c5cc8bce48454d40b486ded2f4b3922815b98 +dist/2025-12-09/rust-std-beta-x86_64-linux-android.tar.gz=752f3f17da55e9aa2fc810b01566828ca94cff8af422f8d85f82029c862f0a48 +dist/2025-12-09/rust-std-beta-x86_64-linux-android.tar.xz=c6f7d6d01c04a8370db9b28e0f1b7fcc20cde35dc1bcf668d667268129341f32 +dist/2025-12-09/rust-std-beta-x86_64-pc-solaris.tar.gz=96b14f03be37a8f94190fe9c78fe12e6423954499ddbe8f6a7375cd72ab345f2 +dist/2025-12-09/rust-std-beta-x86_64-pc-solaris.tar.xz=70d6a32f6b740bdb0aecdf7ef8811c94ec31905737ee144573e72a56fad93dba +dist/2025-12-09/rust-std-beta-x86_64-pc-windows-gnu.tar.gz=6ccec82d1cc57a83afd857b7bfa02bfd0aba6908deaff8319322148cb11145a5 +dist/2025-12-09/rust-std-beta-x86_64-pc-windows-gnu.tar.xz=932c90d8de3d8b1e1b705862e2d7570b5fa09c2fcc210aeb6d054c61980b61ca +dist/2025-12-09/rust-std-beta-x86_64-pc-windows-gnullvm.tar.gz=454d9ebd2ae8baa0350d452023cef119dfc2a6ce2035d6caee2a6aaf51445e08 +dist/2025-12-09/rust-std-beta-x86_64-pc-windows-gnullvm.tar.xz=b11035387f7bd20a12f249a3b527ef6e6bb21e55c8bfc17eb43fe8ed2aeb2d01 +dist/2025-12-09/rust-std-beta-x86_64-pc-windows-msvc.tar.gz=5fa38e0b4568da60d8bacb77d667bca269a62a806245fa1b3c5154868ce8c0e9 +dist/2025-12-09/rust-std-beta-x86_64-pc-windows-msvc.tar.xz=3afde6b9cadc0f0782b342cea124ec9b6196e85f99b317d5365bc8d6f0886f57 +dist/2025-12-09/rust-std-beta-x86_64-unknown-freebsd.tar.gz=6fce2224f59084e4e256a42437f49bbb01523827aad5b0c9406fd23c7117d62c +dist/2025-12-09/rust-std-beta-x86_64-unknown-freebsd.tar.xz=3ae24b5b8acc95e1a3659451bdf8c12c02a3c576b51311ca87636dee0fbe8162 +dist/2025-12-09/rust-std-beta-x86_64-unknown-fuchsia.tar.gz=49f82f4a9b54861c304a89a32667d87ddaa5045920effd2f8a51d27495538f58 +dist/2025-12-09/rust-std-beta-x86_64-unknown-fuchsia.tar.xz=7f5d52c6c6263a47a496a4d915be1b91418c3e16a06ccd0255d94577d71a1786 +dist/2025-12-09/rust-std-beta-x86_64-unknown-illumos.tar.gz=a1e12868fccdf88c54eced9793d8c4b292a4e2ab336b14ad3aef1529e6bbf427 +dist/2025-12-09/rust-std-beta-x86_64-unknown-illumos.tar.xz=2be5a86894132b2ddcde9127aca6ddd366e6a6b928d0bbefcfad155afd2c6a8f +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz=552bcdb9041169ab431674f7536107af05ef4b9f85351757ec890c0779f5ef1d +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz=393e345443c8c16e9b796ffd1d1867650702c75db3a1d541396ad7d035eba249 +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-gnux32.tar.gz=91bf07d6ae7cc836aa4f5440a639a89cc0c706e11145a2dd9e1a46d87a85a8f3 +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-gnux32.tar.xz=5acb8a3606a14d6ba23296d1dba83fbdc9e10d33c4a0859ae675a8910963661f +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-musl.tar.gz=7d5307cdbc388a9635bad36081d067e3bb1ea6b30f53fddcb7a7b4a5046ad86e +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-musl.tar.xz=33087e52b9683d0653e3c3315b03d39b7e7cf6b0f1d1a4a11a1ae21949a62765 +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-ohos.tar.gz=c4bd53291e41545a9e48c3951d591ffd3ef3c549b644a333913dd3770ce4020f +dist/2025-12-09/rust-std-beta-x86_64-unknown-linux-ohos.tar.xz=dc70e5c4e567962bc98a62a2f492828ee5f0420b9f44f6bd4279d2e59efe4433 +dist/2025-12-09/rust-std-beta-x86_64-unknown-netbsd.tar.gz=b08307db96fdc7777825ed9a2f09c1fe9b2bd3bcc8862a10ee31c8306ffd45ae +dist/2025-12-09/rust-std-beta-x86_64-unknown-netbsd.tar.xz=8e2fcfd80f0a678a91df324c198609bee2b02a76fdff6e861fa166be7964e03e +dist/2025-12-09/rust-std-beta-x86_64-unknown-none.tar.gz=c459a4cf0b0b38282bad8a80f42af8bd7567613432106396246f1751b3e1b187 +dist/2025-12-09/rust-std-beta-x86_64-unknown-none.tar.xz=da43d6038f9b0ea443c5a317e2d3414df076ae5f6e59433c4371289ed3852a46 +dist/2025-12-09/rust-std-beta-x86_64-unknown-redox.tar.gz=20cd456f8d9012aefe5ea5fc639ff18142614af45f00b101526587fedc735382 +dist/2025-12-09/rust-std-beta-x86_64-unknown-redox.tar.xz=7d31c1346facd16accb3a58dcae5fc62af5db3c99c26ba5915839a3118571208 +dist/2025-12-09/rust-std-beta-x86_64-unknown-uefi.tar.gz=7c738b0354a7d25b5d931d2e73b1207d452d027935f034a7ae106e4119ebcae8 +dist/2025-12-09/rust-std-beta-x86_64-unknown-uefi.tar.xz=e0640c8cfb01603576e58142829e96f06b650ad9131b8bfa8ecc76d26a49fbd1 +dist/2025-12-09/cargo-beta-aarch64-apple-darwin.tar.gz=9f75819749c4cc87f7435e765ac987f0816e8a17636828a152bba7dd02b46b6a +dist/2025-12-09/cargo-beta-aarch64-apple-darwin.tar.xz=38b8c3e43121c5a1f93e6b81d53598185d0c42c41933db4e09bb402aacf719d9 +dist/2025-12-09/cargo-beta-aarch64-pc-windows-gnullvm.tar.gz=5823f511f5e81e2b4cb72a9dc5955b311b31c7e07ac84be7c81a2ab537e20ec8 +dist/2025-12-09/cargo-beta-aarch64-pc-windows-gnullvm.tar.xz=e1cc29549af4fc472a1edc603de3ec9e575d4c18d67346b2b3b17ec1f3d4d140 +dist/2025-12-09/cargo-beta-aarch64-pc-windows-msvc.tar.gz=e7486bdbd06111ef8e0c328a0ba4e8a5a56d710054a17dc2b9ffbaf05c7c4e17 +dist/2025-12-09/cargo-beta-aarch64-pc-windows-msvc.tar.xz=18c81a2a41051362e1e0a040bb8615f4e3b3ed671147ad585ae9befd17e41c94 +dist/2025-12-09/cargo-beta-aarch64-unknown-linux-gnu.tar.gz=5f846b7dbb282195160213f282e4746c874e60f6cff5ecef2083f0805765ec72 +dist/2025-12-09/cargo-beta-aarch64-unknown-linux-gnu.tar.xz=c9eaf314667d3d0bb3da48857720be60c715a9fc3344bec15a7fb1b92c6214d6 +dist/2025-12-09/cargo-beta-aarch64-unknown-linux-musl.tar.gz=0394e35c668e58e9e6b2cf5eef24981ab97356f857546090a9af321b27fa9631 +dist/2025-12-09/cargo-beta-aarch64-unknown-linux-musl.tar.xz=cb3b9b54402f919244572eeee0cee0c16908fd80de7a07357eaa3fbde21852c5 +dist/2025-12-09/cargo-beta-aarch64-unknown-linux-ohos.tar.gz=9845a957510458b2fee44efbde72b71e7575a557687f07f76f71f343e746aef3 +dist/2025-12-09/cargo-beta-aarch64-unknown-linux-ohos.tar.xz=4ef90f7bc4c9eb87e259ba52f492ff100926ca0d5c874bf00f6e28f256dd9f32 +dist/2025-12-09/cargo-beta-arm-unknown-linux-gnueabi.tar.gz=c5e609db1371ceeb9a9c817fffa90b59aa5d88a2931100e68e5e5fcc49f98f7a +dist/2025-12-09/cargo-beta-arm-unknown-linux-gnueabi.tar.xz=aa454892dac6baaf4a51e6afaf41c9acb81e50bdd7a5de6c85045e2fad7d37c3 +dist/2025-12-09/cargo-beta-arm-unknown-linux-gnueabihf.tar.gz=5e8b574d1b758f045c7938439e44d173065525a1b99cdeb1f4ae822fd1dc7a31 +dist/2025-12-09/cargo-beta-arm-unknown-linux-gnueabihf.tar.xz=6eb4178b85a3c6e7eaf324c28496e8701af2268151590ccd361853e8f52078da +dist/2025-12-09/cargo-beta-armv7-unknown-linux-gnueabihf.tar.gz=c4817681243ebeca687abc59fc0f1035d898ffc03b339634435fcdb6ac0563ba +dist/2025-12-09/cargo-beta-armv7-unknown-linux-gnueabihf.tar.xz=74867e0de7d5eb96c10888c2aa536dbcf140e94190f42b3462a483fc3a17eea0 +dist/2025-12-09/cargo-beta-i686-pc-windows-gnu.tar.gz=4182caa439db0b6cb9ebed815d27de38d492904e9e4d05523b64de77657549f5 +dist/2025-12-09/cargo-beta-i686-pc-windows-gnu.tar.xz=12963ebddf340691ad70b4c1cb71ca1dbe9ea7b20e969ddaa1b01199519eed97 +dist/2025-12-09/cargo-beta-i686-pc-windows-msvc.tar.gz=5ad903382865f5e03659c8c128b33e8afb4288d52c515de1aee00ef119f1dc59 +dist/2025-12-09/cargo-beta-i686-pc-windows-msvc.tar.xz=4abf8df988ac23a7c2f3a974dc3f3ac2c5babf13c13a7089366813bb0e177d2b +dist/2025-12-09/cargo-beta-i686-unknown-linux-gnu.tar.gz=8e161351713a615e0625ea79e20915427c4daa006be76336c45f0fb90a2d2a1f +dist/2025-12-09/cargo-beta-i686-unknown-linux-gnu.tar.xz=3b550c261bd105fc5f3d027dcc90b37b343be3187ff2b1d84912b09faf0f976f +dist/2025-12-09/cargo-beta-loongarch64-unknown-linux-gnu.tar.gz=cc345ca12eb88366b95de1c40ca182ca14f260cca7cfb857e775f011bc9c3adc +dist/2025-12-09/cargo-beta-loongarch64-unknown-linux-gnu.tar.xz=b6a3a0ab898dcf2b35556642f812870ee15e62bed465e33ed4e8bf1094444b52 +dist/2025-12-09/cargo-beta-loongarch64-unknown-linux-musl.tar.gz=a7ccd2f9f0dd4b7dfeacf06c42812471bdd24d2795f3533e41db872183157a14 +dist/2025-12-09/cargo-beta-loongarch64-unknown-linux-musl.tar.xz=b2a75d4597b62f9d2fd3534b0972a8f0f6447d8da14e887d6207f3869d8df4dc +dist/2025-12-09/cargo-beta-powerpc-unknown-linux-gnu.tar.gz=0b8db0062b3220806d215eab392bde104a4846f16b07b14130efa456352f0610 +dist/2025-12-09/cargo-beta-powerpc-unknown-linux-gnu.tar.xz=51991f325aa8d01393c59af81d92d32fddb90a0e153178fa6d574f113a33376b +dist/2025-12-09/cargo-beta-powerpc64-unknown-linux-gnu.tar.gz=ae8d26626ff486f360f8b7d8178844024d4f458eca5997c9305825f3010f679c +dist/2025-12-09/cargo-beta-powerpc64-unknown-linux-gnu.tar.xz=b40b3f43472ab0bfc46f821c12a1df17dd41aa0ff6375522861abcb77aabd68b +dist/2025-12-09/cargo-beta-powerpc64le-unknown-linux-gnu.tar.gz=362ca45ba28f18d3667416b2c81fc03d6b424d6d8d778f3d7a31dcb89f6f7fb8 +dist/2025-12-09/cargo-beta-powerpc64le-unknown-linux-gnu.tar.xz=4513dafaf90abb9eba29f578b1ca1c57934ce78f0ad05ea0f45be5b6e39da7a9 +dist/2025-12-09/cargo-beta-powerpc64le-unknown-linux-musl.tar.gz=d77e406f0e0056a24db4afe70addff520059bfcf2e4441d4e3972dc20953ed0d +dist/2025-12-09/cargo-beta-powerpc64le-unknown-linux-musl.tar.xz=17e2a1f489fcd6920543e46fdf08c54a63e9bba1490d6daa800e225c6b753fd1 +dist/2025-12-09/cargo-beta-riscv64gc-unknown-linux-gnu.tar.gz=469db45a320665a6a285bdfaf45791715a8c546c61cea3a35066b43b8d410c16 +dist/2025-12-09/cargo-beta-riscv64gc-unknown-linux-gnu.tar.xz=0e2200fed953b69b4709ddc4df060e9718f09d062ae7184f51479ae684137e01 +dist/2025-12-09/cargo-beta-s390x-unknown-linux-gnu.tar.gz=dd3f998f36bf93541072e3c5a6d93ab7cca773e93ec436f2202d791e009ce6fd +dist/2025-12-09/cargo-beta-s390x-unknown-linux-gnu.tar.xz=f7c2707a6e855eb6ef6fa34da58c838db64a48ecf4baf84f62a3d676dc90a794 +dist/2025-12-09/cargo-beta-sparcv9-sun-solaris.tar.gz=646cc26a6cb13d404832ab6b10ba30c88ae232fdcf84ff2e524a61f6a8d3a3ad +dist/2025-12-09/cargo-beta-sparcv9-sun-solaris.tar.xz=833dfe8175a28e9ba9997dddcdff73c17ca54a685805a00fa8d6b3e2b688b532 +dist/2025-12-09/cargo-beta-x86_64-apple-darwin.tar.gz=4c73238ea769c53061b56937baad41e724669159a83b29b2ad71fd61a3e9b83c +dist/2025-12-09/cargo-beta-x86_64-apple-darwin.tar.xz=6eba917c9c319e082437bd402c933f27a0cd855619ccd7bc0eecef0745008714 +dist/2025-12-09/cargo-beta-x86_64-pc-solaris.tar.gz=dbe7b52b7f4e5bacfd465918eae271981eb01d40906152da88fd65ac4aa915e9 +dist/2025-12-09/cargo-beta-x86_64-pc-solaris.tar.xz=1a7addf40be3044cb9cc78574936ea3479466f573dca89c188a0e4fc367e70b8 +dist/2025-12-09/cargo-beta-x86_64-pc-windows-gnu.tar.gz=7a4c5d11c78f79dbd83ea36b8d9f50b8dcc70345d4ded5c25727540d49f8c317 +dist/2025-12-09/cargo-beta-x86_64-pc-windows-gnu.tar.xz=ea5c2c141cf5977cd230a28e7e64eb573090f9df58e694f9587cabbb24630b6a +dist/2025-12-09/cargo-beta-x86_64-pc-windows-gnullvm.tar.gz=6cf2d9cb061376f636ff23c42d4f70f6a7506f2d52a80995a4c0eb9e7011ca0f +dist/2025-12-09/cargo-beta-x86_64-pc-windows-gnullvm.tar.xz=854904ff28e8138e5d6b4a07698aa762a199f18692666962172b70d3f98085ef +dist/2025-12-09/cargo-beta-x86_64-pc-windows-msvc.tar.gz=ffcf63ab2b6a5ab9291e79a7c0bb4b0404a6b0f662c8fee5400871e57030ba86 +dist/2025-12-09/cargo-beta-x86_64-pc-windows-msvc.tar.xz=be6a9ebc401ba2e57dda2c278ac0fb04f07af05bae279df12a6db6cd92dd5fc8 +dist/2025-12-09/cargo-beta-x86_64-unknown-freebsd.tar.gz=194e7c211473bf17a00924a60e87edf95e50c29610ad66b01e03d7a57192bbac +dist/2025-12-09/cargo-beta-x86_64-unknown-freebsd.tar.xz=ecf5f9e48deac7b3bb4207b24607904f084f78e1cbe099b6bf49623361bc2399 +dist/2025-12-09/cargo-beta-x86_64-unknown-illumos.tar.gz=e3b16e0e31260123c60e8061b72b10d5e655f778f6f852feec9ea87816d677b4 +dist/2025-12-09/cargo-beta-x86_64-unknown-illumos.tar.xz=6d1065cc19ae1d09f72740e53640502c3337613f210733fec561ba977dda28a4 +dist/2025-12-09/cargo-beta-x86_64-unknown-linux-gnu.tar.gz=2e1b3cf1ff6d6ebd72f309046c7a764fc3d689ab2cf3f66340a42c98cda06a9c +dist/2025-12-09/cargo-beta-x86_64-unknown-linux-gnu.tar.xz=54f2e54197e4340aab81e4d81d9dff836473d098a0bc12b5f944581cca90567f +dist/2025-12-09/cargo-beta-x86_64-unknown-linux-musl.tar.gz=f34964cfe1432e2af127d62824bcb6be68ee40e41c190774efc56347bb72164f +dist/2025-12-09/cargo-beta-x86_64-unknown-linux-musl.tar.xz=40434b0a6609149823262f2a788a3f15c0343769286b8fd1addc9662fbd26825 +dist/2025-12-09/cargo-beta-x86_64-unknown-netbsd.tar.gz=3c2356d84ecee2197db0963bc67b3c896a90175c1a33c1f0c7df98354a1c17a0 +dist/2025-12-09/cargo-beta-x86_64-unknown-netbsd.tar.xz=bf5fc50b555ed8b1dfa1d06b811c5d0bed790cc0d6ab159fb59ca65604f08a73 +dist/2025-12-09/clippy-beta-aarch64-apple-darwin.tar.gz=07d985d4094b51973607b4857c32cca8371f2c9ea219309e25a8bbc09e7b6f19 +dist/2025-12-09/clippy-beta-aarch64-apple-darwin.tar.xz=022457737252bc7ae1293c523cdaaae68a1952ecd43546c642f0bbf5721bb327 +dist/2025-12-09/clippy-beta-aarch64-pc-windows-gnullvm.tar.gz=77d9f6e425be1a19e684b609971f30373eba3d57f7afec837d41041318acf942 +dist/2025-12-09/clippy-beta-aarch64-pc-windows-gnullvm.tar.xz=2e785a6dd171a22c5e7d57e4692d396256c286e429646f12c5b9ea883ad29c59 +dist/2025-12-09/clippy-beta-aarch64-pc-windows-msvc.tar.gz=df3230490829d3f85e9089c0270436b64984c5c83009e4b7be856cc1533ac697 +dist/2025-12-09/clippy-beta-aarch64-pc-windows-msvc.tar.xz=69d8f5ba926d82d71084ed00be6088bb1537d77a90b24af8218b8995547d1214 +dist/2025-12-09/clippy-beta-aarch64-unknown-linux-gnu.tar.gz=9f23282495c4c598c21795c5938c3b072367d27c56f1ef6c5e9c81e0116a6736 +dist/2025-12-09/clippy-beta-aarch64-unknown-linux-gnu.tar.xz=edca9027570949403f14f0e719249095ccd4b8d59296a41b4a72af54c020ef17 +dist/2025-12-09/clippy-beta-aarch64-unknown-linux-musl.tar.gz=651b5d61d641cf146799a747d4cfd35e18a43638f65765104bbfca1a61f89b60 +dist/2025-12-09/clippy-beta-aarch64-unknown-linux-musl.tar.xz=afee1d8d0b1c2b0a395ad5522e935e2d03c6bb88f2d0a496d8c453b2aaf65838 +dist/2025-12-09/clippy-beta-aarch64-unknown-linux-ohos.tar.gz=871a039f625ae3e2fcd69249b4fbe7211bc57ffa460dbdba95f433731aed00ee +dist/2025-12-09/clippy-beta-aarch64-unknown-linux-ohos.tar.xz=3a6413eac375103258fda9ecaeb79276144e96b1a7526932ff372b39676bf4e8 +dist/2025-12-09/clippy-beta-arm-unknown-linux-gnueabi.tar.gz=c4143ceb6c644d73c7bdf36dc12184ee0545e56c17762e310163f32d171142e3 +dist/2025-12-09/clippy-beta-arm-unknown-linux-gnueabi.tar.xz=ea1d55e762194001dd67ecb9f36b6e88023174d2afc11c270560133122127004 +dist/2025-12-09/clippy-beta-arm-unknown-linux-gnueabihf.tar.gz=84619076b88d498a9db44f9b1a4e18646412becf406a9c0e3ca53266e1cc63e0 +dist/2025-12-09/clippy-beta-arm-unknown-linux-gnueabihf.tar.xz=518f0d5578fa1a3be13da7c74a4388db0a1e30a212e07e005f54a964af9e3b6e +dist/2025-12-09/clippy-beta-armv7-unknown-linux-gnueabihf.tar.gz=71f1b0fa2d6353bd15a3e71e37705cfc05b32f1a995ceed6661860846156b6bb +dist/2025-12-09/clippy-beta-armv7-unknown-linux-gnueabihf.tar.xz=071d5f6a7726c049e8779ff0348a82e617faa2f0271d6a48785a829511f2ccd9 +dist/2025-12-09/clippy-beta-i686-pc-windows-gnu.tar.gz=1b0b74ad7374811536e8dee6276d95c00e93d5ff8582f47904311a801a4a457b +dist/2025-12-09/clippy-beta-i686-pc-windows-gnu.tar.xz=3909a6759b946bd26db078785ce2816d8e7ecc6b91f0a93da8e1215101315ec2 +dist/2025-12-09/clippy-beta-i686-pc-windows-msvc.tar.gz=20daed7b47df1a6edc52f4e513a9d8a3fd9adcbb57193584967908062e0b5f5a +dist/2025-12-09/clippy-beta-i686-pc-windows-msvc.tar.xz=726cc91501ad1618b960bfa8ef2fb48aedae7b6bce2e579ee97c2feaf731e63f +dist/2025-12-09/clippy-beta-i686-unknown-linux-gnu.tar.gz=76f33f847f9ca954ab4728d0ba59fc51eb45a19fb75162c37363a31d9cc81fbd +dist/2025-12-09/clippy-beta-i686-unknown-linux-gnu.tar.xz=fb2e996550d4c50d2e932b947b730c1be9a237de5b30bf88d51f02d4fb3aace4 +dist/2025-12-09/clippy-beta-loongarch64-unknown-linux-gnu.tar.gz=23bdfce50ecf66d373a029b97fb5ada2bf302b39245a7f2c2673b21d13889cec +dist/2025-12-09/clippy-beta-loongarch64-unknown-linux-gnu.tar.xz=e3d80cd58be9c50fd9316b1e19fac0b27246bf32264db5c765a04bfe11acdfe0 +dist/2025-12-09/clippy-beta-loongarch64-unknown-linux-musl.tar.gz=c531fe17d77ae42393b7fd556ce8508f9450f393dd612085977707bec106f402 +dist/2025-12-09/clippy-beta-loongarch64-unknown-linux-musl.tar.xz=805b2c4321e59d1d0d2f4dd6eb12920a472fa1422517bf506d41a09f887eb981 +dist/2025-12-09/clippy-beta-powerpc-unknown-linux-gnu.tar.gz=8b82b14f74241aba3f65b80d726c3c43ff5d3452ea0268905eaa8247efd2e75c +dist/2025-12-09/clippy-beta-powerpc-unknown-linux-gnu.tar.xz=5868780ae5c0cf07a613c3247b8339e6e5d0fb209ca279211061c20520a1916d +dist/2025-12-09/clippy-beta-powerpc64-unknown-linux-gnu.tar.gz=f40011b8c9868f0f20e55d0be4600c277e1391ab5fdc832c0ba3261299680d4c +dist/2025-12-09/clippy-beta-powerpc64-unknown-linux-gnu.tar.xz=09ad15c8d179d38424c64a697af9d256b3905fa27aa21fffe0dcf60e18821376 +dist/2025-12-09/clippy-beta-powerpc64le-unknown-linux-gnu.tar.gz=5dccee69021050129a301aed0e2a092768aba58c0922f8265fc42172e55ef930 +dist/2025-12-09/clippy-beta-powerpc64le-unknown-linux-gnu.tar.xz=3961d80cea94e31f8f571e962478fcc842a22163ed6e853b08b19063a56fb601 +dist/2025-12-09/clippy-beta-powerpc64le-unknown-linux-musl.tar.gz=d814ee9c7af0889b37ea08e4b2d059bc54d3bf3919b5d445d8a812ecd6bc122a +dist/2025-12-09/clippy-beta-powerpc64le-unknown-linux-musl.tar.xz=0ddea2966b675892b6f2f3161590af8adf4d9c278c4b50ac1d51bc82473a898a +dist/2025-12-09/clippy-beta-riscv64gc-unknown-linux-gnu.tar.gz=e31bbd06adf63ab0b0abb357f3362d4398f7e6550aed91d7f5578e3a03cd55a7 +dist/2025-12-09/clippy-beta-riscv64gc-unknown-linux-gnu.tar.xz=25affee87f7ec9b8b91368a64d9f5ce17f22a0c40f6bf1f6b51fadb43dec05b2 +dist/2025-12-09/clippy-beta-s390x-unknown-linux-gnu.tar.gz=001b23bb4d8e88f96d3fc1fbaab7e8b6a64de4d8d5767334ac3e9db9d79e56b5 +dist/2025-12-09/clippy-beta-s390x-unknown-linux-gnu.tar.xz=5f137aa245a5a168e71abef128e2181c4df0675666abad895d28df917ca9f0ff +dist/2025-12-09/clippy-beta-sparcv9-sun-solaris.tar.gz=1db02f7429b6594a0c5e33fdf273a827429ce928d37a48f06d1f9908be04bd8a +dist/2025-12-09/clippy-beta-sparcv9-sun-solaris.tar.xz=802755153ad5af276df68592784206cbf49f49a8b678ec6dd621e46699e391c8 +dist/2025-12-09/clippy-beta-x86_64-apple-darwin.tar.gz=3e5cf614a5dcc33b7a570f3b58d89bc930c84aacd05c8df00b40d1d813d13a9a +dist/2025-12-09/clippy-beta-x86_64-apple-darwin.tar.xz=aef870bd83eeb4b26ea3754a4ac3b11d81acfc74f9af97a006079445fb068069 +dist/2025-12-09/clippy-beta-x86_64-pc-solaris.tar.gz=6d1f58fcc6ebbfcec039a06375c09fdbad426e1bc4ed68881a63a19ea4edcc6d +dist/2025-12-09/clippy-beta-x86_64-pc-solaris.tar.xz=7309a240bca719dddc7d9c2e04906e765256407c397a759ee22ba6c6034beb28 +dist/2025-12-09/clippy-beta-x86_64-pc-windows-gnu.tar.gz=ebd0d50c7ad0f975be1862f8b025f1c577bf0b969fc50da679165041fdff5de2 +dist/2025-12-09/clippy-beta-x86_64-pc-windows-gnu.tar.xz=dd9fecb16743aa7584ac6c2e36e202194b51517cb86cd4a454a97dd63a83cf12 +dist/2025-12-09/clippy-beta-x86_64-pc-windows-gnullvm.tar.gz=50eec7195970f99f0ba0f493e3c12b0cb8dfa9fbe60fef436c64a318bad0a6f4 +dist/2025-12-09/clippy-beta-x86_64-pc-windows-gnullvm.tar.xz=e6090190aa83a26b4d71c66422e6332d873580fe807be6a3f2aa9dd56cf53e7d +dist/2025-12-09/clippy-beta-x86_64-pc-windows-msvc.tar.gz=e187f226606301670326e70f4f616d784d89fbe40be755f14a29e6df03e3fafd +dist/2025-12-09/clippy-beta-x86_64-pc-windows-msvc.tar.xz=0f69c54b1c112a276f5f538dcb007e34070e9a75681875d926d6f8f446692cae +dist/2025-12-09/clippy-beta-x86_64-unknown-freebsd.tar.gz=c107ed25ed5a09deb390b175e16a5102dafb21b12405cd227328f2e199a656e7 +dist/2025-12-09/clippy-beta-x86_64-unknown-freebsd.tar.xz=8d8927b64fec353a5cf987457f059995f16e1b36e96ca8b1f8be8e016f49962c +dist/2025-12-09/clippy-beta-x86_64-unknown-illumos.tar.gz=697d12dd34cb0176a839a1d08834fede0b39209f9b5ce102e40b3a41b4bab363 +dist/2025-12-09/clippy-beta-x86_64-unknown-illumos.tar.xz=c31578a3ebb692541cab846d81662ae554169d95018a4697c39fe1249c4e5154 +dist/2025-12-09/clippy-beta-x86_64-unknown-linux-gnu.tar.gz=58b7c72e976dabeb431b897eaa921557b3460c5dc6c12a5ad908f2fcdaf697b8 +dist/2025-12-09/clippy-beta-x86_64-unknown-linux-gnu.tar.xz=649b10e076d03f2428b3284391c67a2a1f7daf3b58185a797973121fc5b4c337 +dist/2025-12-09/clippy-beta-x86_64-unknown-linux-musl.tar.gz=c8f5c1c9990714c20ee85ff6d449caa0519e291b8068e6a5d27c6be1701c6a10 +dist/2025-12-09/clippy-beta-x86_64-unknown-linux-musl.tar.xz=2ff9d03902202060d6059f78872f9606c67357a839dc1d84d0dabc9b0dc79e61 +dist/2025-12-09/clippy-beta-x86_64-unknown-netbsd.tar.gz=95f9c12acabbeca6eb1fe6abee785909009b39d2119c45e8c54f0aa4aee09ab9 +dist/2025-12-09/clippy-beta-x86_64-unknown-netbsd.tar.xz=a8fc86de0d51cbe8ffc9622c539de5ec958948e8d510d113d4d86da0ff512a45 +dist/2025-12-09/rust-beta-aarch64-pc-windows-gnullvm.msi=0decc8436fecf2946138123ba94002507c4e9e0883db90aec5639dadd2fe0fa6 +dist/2025-12-09/rust-beta-aarch64-pc-windows-msvc.msi=d094d7636cc4ab90b00539cf2fd63339dea88e2cce4ed1e6079d925c5102bbb2 +dist/2025-12-09/rust-beta-i686-pc-windows-gnu.msi=546214c69cdb5ebcc1b30a0919e13ce15ee5bab0a6a3f5b2ba09506a7f1ccba8 +dist/2025-12-09/rust-beta-i686-pc-windows-msvc.msi=9f93d409def886c556de52c35dae811e6d5d59cb88c4447bef80f126b08af64b +dist/2025-12-09/rust-beta-x86_64-pc-windows-gnu.msi=a348502a2cbd16752b792f69c24e49cdc1b241aabfb629e25d4136d34e1d7403 +dist/2025-12-09/rust-beta-x86_64-pc-windows-gnullvm.msi=04b4c3d704d742b840bd1bc60aae178a87b6d04eeb970dbe5d84dcbe503cdd8c +dist/2025-12-09/rust-beta-x86_64-pc-windows-msvc.msi=660b04aeef50fac72ab4e53a524af5632ba5d43bcd37fe95c1a2a6e7704e8789 +dist/2025-12-09/rust-beta-aarch64-apple-darwin.pkg=fc4889fa5dabb9e2a54535e33bb82aa658dadf2b53061b0cd5a47ad58e42cdf3 +dist/2025-12-09/rust-beta-x86_64-apple-darwin.pkg=5224a904cef4284950d8c193c89e4f826ed5a5fb77a9b05fba3fcf6b8a107dfb +dist/2025-12-09/rustc-beta-src.tar.gz=2ba3a82da54f472c3eb8253c0eee35f9d121f8027d34869455e9b10635a7b648 +dist/2025-12-09/rustc-beta-src.tar.xz=af3e7fe0843ecfff1168dba08615b7e500a8f9aa82926c422d01754156ca38f6 +dist/2025-12-10/rustfmt-nightly-aarch64-apple-darwin.tar.gz=24ec825bd10f04ebef571174b08cd6f4041cba5da0255811b1eba58771f8ee84 +dist/2025-12-10/rustfmt-nightly-aarch64-apple-darwin.tar.xz=4a80862cc5f685c325650b364361cb7d4b80faab1688988fc6d3e585cb37b133 +dist/2025-12-10/rustfmt-nightly-aarch64-pc-windows-gnullvm.tar.gz=2322573bee75a407302fd18cea373975dad8d3bc77ae52fb4a65ab89a85ad8d1 +dist/2025-12-10/rustfmt-nightly-aarch64-pc-windows-gnullvm.tar.xz=cefab5e313a8e184a243ecb7429acf2c9338396279467e4eb74b42dd0d74d588 +dist/2025-12-10/rustfmt-nightly-aarch64-pc-windows-msvc.tar.gz=9c61e4763b7d5a378684cbf323522b18721be552f19b61303b0fcc257aad94fd +dist/2025-12-10/rustfmt-nightly-aarch64-pc-windows-msvc.tar.xz=960c96b8b5d5b1ae2b01103c59bd761b7ead18470795fac7d9de5b8ed635abd3 +dist/2025-12-10/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.gz=c7ab92e0faba8c29ac42aec6be553f2a98b6eb552a2327e7eea27fa90d324287 +dist/2025-12-10/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz=8245467e46eaf068f560c63e43e14de233be6481fa47a663dfc03e0343a21a24 +dist/2025-12-10/rustfmt-nightly-aarch64-unknown-linux-musl.tar.gz=4f73b7d59a7f43f9732bb37779224d289dd9bfedd98963387e968283dd09959c +dist/2025-12-10/rustfmt-nightly-aarch64-unknown-linux-musl.tar.xz=4deeab8e28f00f7dfb11fc9fcffef9bfc866ec7a67e6da4cf0c2a68ced8eea7b +dist/2025-12-10/rustfmt-nightly-aarch64-unknown-linux-ohos.tar.gz=d7cfae90e1d3ee3c7e30a39e2cc789b045498e282eab5831a538910ae4c878fe +dist/2025-12-10/rustfmt-nightly-aarch64-unknown-linux-ohos.tar.xz=674460a55e04a6d1e505957bc1bbc560351f4143bcacdd93f86e301c0a7415b6 +dist/2025-12-10/rustfmt-nightly-arm-unknown-linux-gnueabi.tar.gz=c745ef65f257d48dbaabb5aefa2ac0b2a51a3f2185f542f0e6017fd5378c1bc6 +dist/2025-12-10/rustfmt-nightly-arm-unknown-linux-gnueabi.tar.xz=0765fe91b4ff940575c819259c2b2e328c81a7ff02a1a283ec2e6844bd026e85 +dist/2025-12-10/rustfmt-nightly-arm-unknown-linux-gnueabihf.tar.gz=7b01938f5c56be23e682b7cbdbefe0da87e41a136029f09a38362aac4df05bc2 +dist/2025-12-10/rustfmt-nightly-arm-unknown-linux-gnueabihf.tar.xz=f90fa659f11e39ce6145689cd3284fec95d7e4219e4e8c5b14876357b3892e4c +dist/2025-12-10/rustfmt-nightly-armv7-unknown-linux-gnueabihf.tar.gz=c168b4f52d9e4f17234a824e49e257577f3a2f2643cf5cfac8e28395d3c6a7c8 +dist/2025-12-10/rustfmt-nightly-armv7-unknown-linux-gnueabihf.tar.xz=0a9cd71999664d67f83bb9c3f87415656329086f0e3503953992b1cbe34d9a5e +dist/2025-12-10/rustfmt-nightly-i686-pc-windows-gnu.tar.gz=207f1343fd0a348344b9866e99b80ff7112a9b48a2ff63168e133913fe161425 +dist/2025-12-10/rustfmt-nightly-i686-pc-windows-gnu.tar.xz=83147ebb6c01438b55d2973759821178a6e109eb91146d96386c504070248769 +dist/2025-12-10/rustfmt-nightly-i686-pc-windows-msvc.tar.gz=a59c45a3ab6601db73a1628266ff6dec37cc04bb964096116df21595aa53d358 +dist/2025-12-10/rustfmt-nightly-i686-pc-windows-msvc.tar.xz=b1da98ed515858fe2659e42a31c9b9cd4adb60c3080ec154f3829859855c324e +dist/2025-12-10/rustfmt-nightly-i686-unknown-linux-gnu.tar.gz=59fd2ab17d3215a6bd6e34ec2e61146a48cb273754003d561df7ac2a7a3d131e +dist/2025-12-10/rustfmt-nightly-i686-unknown-linux-gnu.tar.xz=1b3aae40df398d2456ac82fd9ff86e83870b9ce46247a164eba82365c5624569 +dist/2025-12-10/rustfmt-nightly-loongarch64-unknown-linux-gnu.tar.gz=f9f43f82d73e136a2f40dcdc41bd3c7e106a94a0a4e5edac661ba7a72a883a09 +dist/2025-12-10/rustfmt-nightly-loongarch64-unknown-linux-gnu.tar.xz=bd4912cd32a56cffcf4b019a08b4b751d4a5006c754fa349cc5f38c396fc2e88 +dist/2025-12-10/rustfmt-nightly-loongarch64-unknown-linux-musl.tar.gz=cc65c029ab8d0a5efbadf00b40b5bc8e4e737ce0eaa3f2bd24ff145725384038 +dist/2025-12-10/rustfmt-nightly-loongarch64-unknown-linux-musl.tar.xz=0bc6580c37977c55c259e0da12732f0a3ff072fe629615ec3602c510129db20f +dist/2025-12-10/rustfmt-nightly-powerpc-unknown-linux-gnu.tar.gz=9837287d443e9519759e541f7d60128f535eb0990ca49cf107a6d7f8e13fb33c +dist/2025-12-10/rustfmt-nightly-powerpc-unknown-linux-gnu.tar.xz=55b0b24b2e33b6ed5eb8eaab1e6ef9b0cb7c64280d8f4a46fb8c644291bc72cb +dist/2025-12-10/rustfmt-nightly-powerpc64-unknown-linux-gnu.tar.gz=29510416f023edabd18ebb9a5f6fd96e55a07dc968a33922b68749d17a51df71 +dist/2025-12-10/rustfmt-nightly-powerpc64-unknown-linux-gnu.tar.xz=aa9a16c99748912c2d9aa17ea1fd3d34afa87f352b922ebf5939e41ec4b2bc7f +dist/2025-12-10/rustfmt-nightly-powerpc64le-unknown-linux-gnu.tar.gz=9a0642853b345aa058dd7ed7bb3777fcb1bb6d8d15893bedf40595c7513beb67 +dist/2025-12-10/rustfmt-nightly-powerpc64le-unknown-linux-gnu.tar.xz=5b4f5226d11cc8811d92a7ddd601fc6e0a7f1cafb973def40efa5c5a3b29fff1 +dist/2025-12-10/rustfmt-nightly-powerpc64le-unknown-linux-musl.tar.gz=e6ed9a58e3d8b3e215d9e24cd47c363b5659cf32e9cb4c104a35cfaeeee1a6c0 +dist/2025-12-10/rustfmt-nightly-powerpc64le-unknown-linux-musl.tar.xz=760ab76dfa17332f1c3b3330fec0774ae5a07599aaad838c946df4f588993f71 +dist/2025-12-10/rustfmt-nightly-riscv64gc-unknown-linux-gnu.tar.gz=8f0bc4bd2bc633afff10982328f5a2b6d0a37faadadc7cbbf761a106a3a9ba71 +dist/2025-12-10/rustfmt-nightly-riscv64gc-unknown-linux-gnu.tar.xz=9e0e069e0c57c2c07768b3fa4a9c38cc6f914a23b84e8efe6fabb250d6e99e34 +dist/2025-12-10/rustfmt-nightly-s390x-unknown-linux-gnu.tar.gz=4a23ff6f2d3f2df2afa21ceaccf118c1711e4553090cac6caf116b567080f396 +dist/2025-12-10/rustfmt-nightly-s390x-unknown-linux-gnu.tar.xz=98c672887a5d8ef1a9d356e5a53acb21ff9771b122f67e6fde8c1c362dfdfd21 +dist/2025-12-10/rustfmt-nightly-sparcv9-sun-solaris.tar.gz=92dd3c460488e73cfa5a4162b910a9db64b3fb3952c32039fa1bb24dabbebec5 +dist/2025-12-10/rustfmt-nightly-sparcv9-sun-solaris.tar.xz=231d454a308af3a1deafca579bbf82fd630bd42df903e47c3e48f84be588bf3c +dist/2025-12-10/rustfmt-nightly-x86_64-apple-darwin.tar.gz=e57059b13d749c0b671fd5bc4bf03b1162afe5d258304f80bd67b75a7dba7361 +dist/2025-12-10/rustfmt-nightly-x86_64-apple-darwin.tar.xz=f837b268e872681f2cfad6c485a0e28647ac826ebe9d0ce2d01520f294ad0037 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-solaris.tar.gz=d5890236f6963d2a9a16a4edb3e6515216ea9f96f2996da298ed9756c75bbed8 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-solaris.tar.xz=789e877ca7a2fba536a62bc27d1034399a75c5df0c0fb677ee6aad8dfc8c0e1e +dist/2025-12-10/rustfmt-nightly-x86_64-pc-windows-gnu.tar.gz=eefadcc6be10ba4b41c21c60cd1fdb818389b17bfe09b97d41be64fba9643f35 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-windows-gnu.tar.xz=d9904734a9ba86930c4680f167c4c6d3b3c5c49d6274a47c1e25f3557a19e672 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-windows-gnullvm.tar.gz=b9d556aa1f760b6acfa6257a77fc489b4efaff3627a80ea25b1cb759786b9182 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-windows-gnullvm.tar.xz=3230a9ab8bfea6e9d90a444aedb546040fc743b6ae9f3e7830ecad35eb343896 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-windows-msvc.tar.gz=9cdb560c8941551b371f898f8d385a4952794aad27d27786d263b3ff02069cd7 +dist/2025-12-10/rustfmt-nightly-x86_64-pc-windows-msvc.tar.xz=ec4b17c6c8aedc5bec3afdcda9a5f85b932e94c8711d03f06171c36ea9349b1c +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-freebsd.tar.gz=bf5a2486465ee6848b2a145c6a16bb5116b893e8d22d3897c78c2930617e8e65 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-freebsd.tar.xz=c71effbcbb3e1b2b90384799b1079658118e24a60408c482d75aaedc3628a6ef +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-illumos.tar.gz=867a4ba29283c658f6a3db55e0edace19cd0102f17409338c75827d3dbceeed8 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-illumos.tar.xz=ea07fe1ecc5480b246387a228a8ea342616385bf9ec25e40d3de9806e06e1e07 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.gz=8457f82703b5dd5cf1c8ec74011b666239268f1151b0800209a5312274b99151 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz=31f203fc0623c23d41cd64ec4928f0a8d330aeba0f28d0f451683e94da873f28 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-linux-musl.tar.gz=5d752c9879b464b385c14c38ce2b6dad2542d3e4932337ce76d5fcf77b2d3d39 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-linux-musl.tar.xz=797ed8b8c2f2f5764ab2965b7701d73dac4f3ea01a431b1b337dece0e718c940 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-netbsd.tar.gz=a4eed85109f7d76a11e9bcfcb27550636c47c09a10e12f92d76778f6989ffff9 +dist/2025-12-10/rustfmt-nightly-x86_64-unknown-netbsd.tar.xz=fdb91ee8d9edc3824426268654efa77a7366ee436b5969366b7f924e1efc8082 +dist/2025-12-10/rustc-nightly-aarch64-apple-darwin.tar.gz=1debf4ac8bcc013d4a4a6f000a308bf69b1b99609e841f4eb5f63fb22edb68c4 +dist/2025-12-10/rustc-nightly-aarch64-apple-darwin.tar.xz=460eb2dc63c9b2da77a9e12eeaacf3302fa0b2276cf6fab1b1875465fed221cf +dist/2025-12-10/rustc-nightly-aarch64-pc-windows-gnullvm.tar.gz=b9dfa64737763a506ba08a1485c7ba1cf985c1b3e68c282b0515cc646bcd7852 +dist/2025-12-10/rustc-nightly-aarch64-pc-windows-gnullvm.tar.xz=f7aaf99ffb316c72fe1121344ae55f65e94448f6ae324ec00f6f73960360bcef +dist/2025-12-10/rustc-nightly-aarch64-pc-windows-msvc.tar.gz=832410daf93d83d489586bd9823b06c53cfd284072274b43e6db4514dc2c5c2c +dist/2025-12-10/rustc-nightly-aarch64-pc-windows-msvc.tar.xz=4e1a2e537f0daf6c000bfaedba3a306d3e9017574dba0ff53c08ad208f5a3326 +dist/2025-12-10/rustc-nightly-aarch64-unknown-linux-gnu.tar.gz=f520d2e5ea92519c99ad80fd61af4621c5f6a3ecd1dcd6bcf797aff679ccc403 +dist/2025-12-10/rustc-nightly-aarch64-unknown-linux-gnu.tar.xz=73120c237a0a19f6b5ca52fe02ea1c2300d5204861a6f7f5a5d059925a780a9e +dist/2025-12-10/rustc-nightly-aarch64-unknown-linux-musl.tar.gz=5121387c446ff2e3f766ed1f117526d21768e84dc07512cc738ef19870bddfed +dist/2025-12-10/rustc-nightly-aarch64-unknown-linux-musl.tar.xz=3deae487826308f70a7855adf612c4c87121ca2df8f890b744e738f667696883 +dist/2025-12-10/rustc-nightly-aarch64-unknown-linux-ohos.tar.gz=ed6c93be35e43f787ab6838c468d984b6f3ccaf561a48bf6b4928e4d5bb17b75 +dist/2025-12-10/rustc-nightly-aarch64-unknown-linux-ohos.tar.xz=76b40a2678643983781508a6fda99de7a3dd7b6269b410bf5f3638fd2db596e4 +dist/2025-12-10/rustc-nightly-arm-unknown-linux-gnueabi.tar.gz=a0e75393de8ace2e7c40ed54a127e5dc25242914a31313f2520fc634f3e400e8 +dist/2025-12-10/rustc-nightly-arm-unknown-linux-gnueabi.tar.xz=03ed745c4940c088893ceb36f563f43ecab1c6f17d3983e28ceb4e89d8234331 +dist/2025-12-10/rustc-nightly-arm-unknown-linux-gnueabihf.tar.gz=4d473526c3e46f04550f2623542568fad0c397dfdb6194e2528cc21975bcb64e +dist/2025-12-10/rustc-nightly-arm-unknown-linux-gnueabihf.tar.xz=6dc10f3407d80a7ecb9594620ca070291e192275434daa6e49888484f0c1b9c7 +dist/2025-12-10/rustc-nightly-armv7-unknown-linux-gnueabihf.tar.gz=3929d09ab864e5669b38f5b5a308fe637b22e88ad25e339bdd3e2df15e77a18a +dist/2025-12-10/rustc-nightly-armv7-unknown-linux-gnueabihf.tar.xz=2d674373dfbb2ac0caeab3e5fe053073f8313aa3d3c5937b982abcc5d467af22 +dist/2025-12-10/rustc-nightly-i686-pc-windows-gnu.tar.gz=e7abc330e9f8554f29fce9c984ab624498c55b4f66aea12836564e097569a753 +dist/2025-12-10/rustc-nightly-i686-pc-windows-gnu.tar.xz=887d766a9996d9b956e5d61bcb3166a5f5923ca37d114814e3a85db83bff30d7 +dist/2025-12-10/rustc-nightly-i686-pc-windows-msvc.tar.gz=00854c8dfcd94264a88483241cfe79e9357f97ad5fd9ca1a59f49a54806e1b1f +dist/2025-12-10/rustc-nightly-i686-pc-windows-msvc.tar.xz=cbcf96dbb3250cd9d54e66858fa2af4c2506fe81ec2239b2ebbbeba1ef1b4911 +dist/2025-12-10/rustc-nightly-i686-unknown-linux-gnu.tar.gz=42f92a1d712bfca3b365b8627d5a5266e0b35f8a6af67cd77ad7a78bd6dcc4db +dist/2025-12-10/rustc-nightly-i686-unknown-linux-gnu.tar.xz=a762070fe4c322916daccacca0e14793bd91339f5803d981fd83e8f2511d9eaf +dist/2025-12-10/rustc-nightly-loongarch64-unknown-linux-gnu.tar.gz=a621f4811d670ae885d63dbce5ced336cb26662527e5ad16a020bd31e0ffc4df +dist/2025-12-10/rustc-nightly-loongarch64-unknown-linux-gnu.tar.xz=b20f98c90930205966d88771dbf3ffed04f701be0d7dbe074791f63ae9d563ab +dist/2025-12-10/rustc-nightly-loongarch64-unknown-linux-musl.tar.gz=a8be28df240832939d2988af21a15b06dcd550ef6de9a468e8d1241f96a9d548 +dist/2025-12-10/rustc-nightly-loongarch64-unknown-linux-musl.tar.xz=b4d883ddd22480c6adf1a9f448124532b50f8bc3d1da54e17ce30e1e07bdeac7 +dist/2025-12-10/rustc-nightly-powerpc-unknown-linux-gnu.tar.gz=f15a8266370bbf23e5c33afd1dbde578eed56ef1d8b0dfd0f4a689cc90a55890 +dist/2025-12-10/rustc-nightly-powerpc-unknown-linux-gnu.tar.xz=c4f63b2adebf61896681df4d8e4015bc510dfe83a7d99ffd0df996ceb56333d4 +dist/2025-12-10/rustc-nightly-powerpc64-unknown-linux-gnu.tar.gz=864210b8ed936a21532ba16ed2c12538ab802bb1f678f4175738957949090515 +dist/2025-12-10/rustc-nightly-powerpc64-unknown-linux-gnu.tar.xz=4dfa49bbc7e9bdc4edb33e8b21a4fde9dac6f178845bc0f86baec1cf0cccc661 +dist/2025-12-10/rustc-nightly-powerpc64le-unknown-linux-gnu.tar.gz=4234e6dfc10b54510d4caa7266ddd2776cb6ac4a463f5fc0e105b56f90fe25a0 +dist/2025-12-10/rustc-nightly-powerpc64le-unknown-linux-gnu.tar.xz=707e947a1a6afb285918f5116a7a821fcbfb5448e9dde4f93aecfd49d0ec206a +dist/2025-12-10/rustc-nightly-powerpc64le-unknown-linux-musl.tar.gz=9f2968856d329a2a87f3d6e035b75d78036941f30c7e5b9b99a8f2e18329d135 +dist/2025-12-10/rustc-nightly-powerpc64le-unknown-linux-musl.tar.xz=138635257545931c183a5c6c41345391190c3bc5b64caf3192f05053f1243f87 +dist/2025-12-10/rustc-nightly-riscv64gc-unknown-linux-gnu.tar.gz=31edf819c4374e2d56a9a3fb125e2879e78067695c05bb165f0246846968fc09 +dist/2025-12-10/rustc-nightly-riscv64gc-unknown-linux-gnu.tar.xz=84c92f5bc6ebd0904db0e91a17163e4aadf93478b09681d7f659b2733e7ec7dd +dist/2025-12-10/rustc-nightly-s390x-unknown-linux-gnu.tar.gz=dd5bb23c59ef383fa51bc59e4dd869d8c195a02512306fa0010c00b0f13c0ad1 +dist/2025-12-10/rustc-nightly-s390x-unknown-linux-gnu.tar.xz=48d041d57df47c4d99fc0ebc0a10b7cb374f664303ea8b4ffca4c08aab20289e +dist/2025-12-10/rustc-nightly-sparcv9-sun-solaris.tar.gz=006f8d00e4bf719a84f3f8244bf7587f6b7fa141d0659941fb1c0bef7e1c0f5c +dist/2025-12-10/rustc-nightly-sparcv9-sun-solaris.tar.xz=dc9b5086fb6f00164fd676baacccfe030af279e75c339162cb666ebba0f76692 +dist/2025-12-10/rustc-nightly-x86_64-apple-darwin.tar.gz=71604d26e35b1d8d47edfa5744e1f56d99ae780ff39780f2e6f91dcd744881e7 +dist/2025-12-10/rustc-nightly-x86_64-apple-darwin.tar.xz=67d9b818da84cae669f13e24e3be2e16036286f4ad3ba82965dbfc6a9cc0bd21 +dist/2025-12-10/rustc-nightly-x86_64-pc-solaris.tar.gz=5b7eb8e65fc1c3f173e640487dce7778167710dfa403bb877905bdfda1f3e6c9 +dist/2025-12-10/rustc-nightly-x86_64-pc-solaris.tar.xz=fdf2bd54e7278c1f601a894fd8e10a22bfef06aac7bd062e08ed08fdffc9d1a4 +dist/2025-12-10/rustc-nightly-x86_64-pc-windows-gnu.tar.gz=4165469f2326441c64874ddddaec7897386e8f7808dbe48762f4e394319c33dd +dist/2025-12-10/rustc-nightly-x86_64-pc-windows-gnu.tar.xz=d60b8e47a871874a1e21b3b3e79255d818596364295b4fc7ab31ebd45576f66a +dist/2025-12-10/rustc-nightly-x86_64-pc-windows-gnullvm.tar.gz=2f6de03a3af0fb2c66eb7a2a01a425435dd3f6025aa9d83073798f37a0311c77 +dist/2025-12-10/rustc-nightly-x86_64-pc-windows-gnullvm.tar.xz=0a4b940cfadddf0c1dd3c6ac44e1db9a48e71578803a1690d92ff35bf062eac0 +dist/2025-12-10/rustc-nightly-x86_64-pc-windows-msvc.tar.gz=08b6ea3a88f0ed773edb97f02995a05afa142f08054a4c076dcfe07d6d95d406 +dist/2025-12-10/rustc-nightly-x86_64-pc-windows-msvc.tar.xz=ed07457a628abfb45c5e1e290cd3df284d7aad4caa2fa72e1042b9c0fd0e8375 +dist/2025-12-10/rustc-nightly-x86_64-unknown-freebsd.tar.gz=2dd8158c9a0f5715c20bc325100f89a8bf73703d426ae7222d86ffc4fc4b1f4f +dist/2025-12-10/rustc-nightly-x86_64-unknown-freebsd.tar.xz=35eca84b519cad4bcbd46cc40bde94ac22bf7e62af32bc802a8a3f05c82ab35d +dist/2025-12-10/rustc-nightly-x86_64-unknown-illumos.tar.gz=f41e19ee9031fd636b8b6ccac51949b0f52a884e866f75a04645f57a24f13216 +dist/2025-12-10/rustc-nightly-x86_64-unknown-illumos.tar.xz=63a3c093db358866ec31c38a872f6024a02a611c5729127d5bff91b394f2b5ab +dist/2025-12-10/rustc-nightly-x86_64-unknown-linux-gnu.tar.gz=056872dae473bc6e843a5272698ab2de04a8d08aa1a510753f4dd46058601b1d +dist/2025-12-10/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz=5342e6efe17f2ffbd2625f758e7389f201c15eff59288c3a929743ae9eb33d95 +dist/2025-12-10/rustc-nightly-x86_64-unknown-linux-musl.tar.gz=9076cb3c1aeacd2e11bb6a2790b6b83234aae46cc956ae615eac171471f2c94f +dist/2025-12-10/rustc-nightly-x86_64-unknown-linux-musl.tar.xz=23ac96d176e79490597c80205c51b51682e7bb0f24e1020367958ec737614722 +dist/2025-12-10/rustc-nightly-x86_64-unknown-netbsd.tar.gz=03c1c5fe68c45392a93774a228ff18abcc1b29fc1e83c3a901604594ef2e78fd +dist/2025-12-10/rustc-nightly-x86_64-unknown-netbsd.tar.xz=274cbef82373e1687534e81c53d2dc909ad8200c21062363bd2c892b528209d8 +dist/2025-12-10/rust-nightly-aarch64-pc-windows-gnullvm.msi=0ad2a86241f5a786e7afeacbed7225f904748c62b0c2a91cc72123392834a234 +dist/2025-12-10/rust-nightly-aarch64-pc-windows-msvc.msi=21b3530f3615448adfe61ce4e28c47fbf0b2f15e674d73b5a11e966476a9473e +dist/2025-12-10/rust-nightly-i686-pc-windows-gnu.msi=93d58d311e7bb3a75903e8539dd34bc65b85b951bf9eff5594f539f79bc65c72 +dist/2025-12-10/rust-nightly-i686-pc-windows-msvc.msi=22ba8e3dfd93267d0c4660cf889951208c17ef0050538206a5fe7f799e24a2fd +dist/2025-12-10/rust-nightly-x86_64-pc-windows-gnu.msi=d8e6963725b2b8fb1c92cec90830a1cd73968450b676ddcd4ccd90b9006281a7 +dist/2025-12-10/rust-nightly-x86_64-pc-windows-gnullvm.msi=d4c1af5399e97ec877d06ad0ef978ba08fb9994b2588b3195316a36c58915151 +dist/2025-12-10/rust-nightly-x86_64-pc-windows-msvc.msi=c738f27b64f63b8702646effaddb4af8398bd2d2ef810ef6b2ac1cee4997c692 +dist/2025-12-10/rust-nightly-aarch64-apple-darwin.pkg=6d35933519ae62d24b8c772aa43483d9e40138f7bb5894fe42fbe6e48299efe8 +dist/2025-12-10/rust-nightly-x86_64-apple-darwin.pkg=388c57b33f3fb46bbf1f194e5bd899316eddf6a067103792e0df64861bbb193e +dist/2025-12-10/rustc-nightly-src.tar.gz=1cb5229e21c945bf992fc9e0eb8c5cbf3516fd7d4caea9969e8515971c45483a +dist/2025-12-10/rustc-nightly-src.tar.xz=96ce631d5b33858d220d686bb2c1388e3f055680366f94833ba4c2a026cfc796 From 2ffb1d55efd648145b069a51fd4bbbc22c2db55f Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 10 Dec 2025 05:55:31 +0000 Subject: [PATCH 344/489] Handle bootstrap cfgs --- compiler/rustc_arena/src/lib.rs | 1 - compiler/rustc_codegen_llvm/src/lib.rs | 1 - compiler/rustc_hir/src/lib.rs | 1 - compiler/rustc_hir_analysis/src/lib.rs | 1 - compiler/rustc_lint/src/builtin.rs | 1 - compiler/rustc_lint_defs/src/builtin.rs | 18 ++++++------------ compiler/rustc_target/src/lib.rs | 1 - library/proc_macro/src/lib.rs | 1 - src/librustdoc/lib.rs | 1 - src/tools/miri/src/lib.rs | 1 - 10 files changed, 6 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 5151c358774e..a0350dd6ff31 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -10,7 +10,6 @@ // tidy-alphabetical-start #![allow(clippy::mut_from_ref)] // Arena allocators are one place where this pattern is fine. #![allow(internal_features)] -#![cfg_attr(bootstrap, feature(maybe_uninit_slice))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] #![doc(test(no_crate_inject, attr(deny(warnings), allow(internal_features))))] diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 4d0f8dbb9302..65e1bc5c8434 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -5,7 +5,6 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(slice_as_array))] #![feature(assert_matches)] #![feature(extern_types)] #![feature(file_buffered)] diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 7a5776f0d5a9..7c9c15c16df4 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -3,7 +3,6 @@ //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(debug_closure_helpers))] #![feature(associated_type_defaults)] #![feature(closure_track_caller)] #![feature(const_default)] diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 538fb8c7df1e..65f6a11e8e9b 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -58,7 +58,6 @@ This API is completely unstable and subject to change. // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -#![cfg_attr(bootstrap, feature(debug_closure_helpers))] #![feature(assert_matches)] #![feature(gen_blocks)] #![feature(if_let_guard)] diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 810760e9f53e..e2a061cab680 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2683,7 +2683,6 @@ declare_lint! { /// /// ```rust,compile_fail /// # #![allow(unused)] - /// # #![cfg_attr(bootstrap, deny(deref_nullptr))] /// use std::ptr; /// unsafe { /// let x = &*ptr::null::(); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 99cce0c44b86..6bd0efd5d751 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2346,8 +2346,7 @@ declare_lint! { /// [sanitize]: https://doc.rust-lang.org/nightly/unstable-book/language-features/no-sanitize.html /// ### Example /// - #[cfg_attr(bootstrap, doc = "```ignore")] - #[cfg_attr(not(bootstrap), doc = "```rust,no_run")] + /// ```rust,no_run /// #![feature(sanitize)] /// /// #[sanitize(realtime = "nonblocking")] @@ -2356,8 +2355,7 @@ declare_lint! { /// fn main() { /// x(); /// } - #[cfg_attr(bootstrap, doc = "```")] - #[cfg_attr(not(bootstrap), doc = "```")] + /// ``` /// /// {{produces}} /// @@ -4907,8 +4905,7 @@ declare_lint! { /// /// ### Example /// - #[cfg_attr(bootstrap, doc = "```ignore")] - #[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")] + /// ```rust,compile_fail /// #![feature(supertrait_item_shadowing)] /// #![deny(resolving_to_items_shadowing_supertrait_items)] /// @@ -4924,8 +4921,7 @@ declare_lint! { /// /// struct MyType; /// MyType.hello(); - #[cfg_attr(bootstrap, doc = "```")] - #[cfg_attr(not(bootstrap), doc = "```")] + /// ``` /// /// {{produces}} /// @@ -4951,8 +4947,7 @@ declare_lint! { /// /// ### Example /// - #[cfg_attr(bootstrap, doc = "```ignore")] - #[cfg_attr(not(bootstrap), doc = "```rust,compile_fail")] + /// ```rust,compile_fail" /// #![feature(supertrait_item_shadowing)] /// #![deny(shadowing_supertrait_items)] /// @@ -4965,8 +4960,7 @@ declare_lint! { /// fn hello(&self) {} /// } /// impl Downstream for T {} - #[cfg_attr(bootstrap, doc = "```")] - #[cfg_attr(not(bootstrap), doc = "```")] + /// ``` /// /// {{produces}} /// diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index 1210169b3a5c..dfa1b2320718 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -8,7 +8,6 @@ //! LLVM. // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(debug_closure_helpers))] #![expect(internal_features)] #![feature(iter_intersperse)] #![feature(rustc_attrs)] diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 9287807c43e3..a0b6656c8ded 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -22,7 +22,6 @@ #![feature(staged_api)] #![feature(allow_internal_unstable)] #![feature(decl_macro)] -#![cfg_attr(bootstrap, feature(maybe_uninit_write_slice))] #![feature(negative_impls)] #![feature(panic_can_unwind)] #![feature(restricted_std)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index c74c556b6210..137319ae0c06 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,5 +1,4 @@ // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(debug_closure_helpers))] #![doc( html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/" diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 743caed6dbb6..7ce2ab3b3a43 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -17,7 +17,6 @@ #![feature(derive_coerce_pointee)] #![feature(arbitrary_self_types)] #![feature(iter_advance_by)] -#![cfg_attr(bootstrap, feature(duration_from_nanos_u128))] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, From 8321ad2369fc23fc64d8e63cce938d646bbe3808 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 10 Dec 2025 05:56:40 +0000 Subject: [PATCH 345/489] update missing targets list --- src/bootstrap/src/core/sanity.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index d1f706fd9c3e..932a58c954df 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -34,15 +34,8 @@ pub struct Finder { // // Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap). const STAGE0_MISSING_TARGETS: &[&str] = &[ - "aarch64-unknown-helenos", - "i686-unknown-helenos", - "x86_64-unknown-helenos", - "powerpc-unknown-helenos", - "sparc64-unknown-helenos", // just a dummy comment so the list doesn't get onelined - "riscv64gc-unknown-redox", "riscv64im-unknown-none-elf", - "hexagon-unknown-qurt", ]; /// Minimum version threshold for libstdc++ required when using prebuilt LLVM From df780f87c733f115f394279eb0a6a058e8815a4e Mon Sep 17 00:00:00 2001 From: Boxy Date: Wed, 10 Dec 2025 07:50:44 +0000 Subject: [PATCH 346/489] Update compiler/rustc_lint_defs/src/builtin.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: León Orell Valerian Liehr --- compiler/rustc_lint_defs/src/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 6bd0efd5d751..8c69cc089caf 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4947,7 +4947,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail" + /// ```rust,compile_fail /// #![feature(supertrait_item_shadowing)] /// #![deny(shadowing_supertrait_items)] /// From b22b343fafaf0540797b0099ff6e06ed85c184bc Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 19 Dec 2025 15:06:11 -0800 Subject: [PATCH 347/489] Revert "Generate macro expansion for rust compiler crates docs" This reverts commit c820f461228ba5d8d6bc6879e5a311a45673fb84 due to an ICE encountered while bumping the bootstrap compiler to 1.93-beta. --- src/bootstrap/src/core/build_steps/doc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index fa36a6471cae..b86582807f72 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -932,7 +932,6 @@ impl Step for Rustc { // see https://github.com/rust-lang/rust/pull/122066#issuecomment-1983049222 // If there is any bug, please comment out the next line. cargo.rustdocflag("--generate-link-to-definition"); - cargo.rustdocflag("--generate-macro-expansion"); compile::rustc_cargo(builder, &mut cargo, target, &build_compiler, &self.crates); cargo.arg("-Zskip-rustdoc-fingerprint"); From c039edd41416c209b6bcdfa02d152a8db64102ba Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 20 Dec 2025 00:32:56 +0100 Subject: [PATCH 348/489] Fix typo --- tests/rustdoc/import-remapped-paths.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rustdoc/import-remapped-paths.rs b/tests/rustdoc/import-remapped-paths.rs index bce3d782b9c2..9e7518f7c017 100644 --- a/tests/rustdoc/import-remapped-paths.rs +++ b/tests/rustdoc/import-remapped-paths.rs @@ -1,7 +1,7 @@ // This is a regression for `--remap-path-prefix` in an auxiliary dependency. // // We want to make sure that we can still have the "Source" links to the dependency -// even if it's paths are remapped. +// even if its paths are remapped. // // See also rust-lang/rust#150100 From 361888f763b707f982e02419684c716771d2146c Mon Sep 17 00:00:00 2001 From: dianqk Date: Sat, 20 Dec 2025 09:53:08 +0800 Subject: [PATCH 349/489] Update LLVM submodule --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 85a90d119deb..00d23d10dc48 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 85a90d119deb25b518867cd37d62c7b93b575a6f +Subproject commit 00d23d10dc48c6bb9d57ba96d4a748d85d77d0c7 From 3e5b12ed9a7d175a07c72fe7fa56c022264988bb Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 19 Dec 2025 15:22:28 -0500 Subject: [PATCH 350/489] Update cargo submodule --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index e91b2baa632c..3861f60f6b58 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit e91b2baa632c0c7e84216c91ecfe107c37d887c1 +Subproject commit 3861f60f6b58f57524c0e7aab1f5c1ad83e35409 From c3bd76b7afc20bb46c503d1a4edab9da82484f13 Mon Sep 17 00:00:00 2001 From: Redddy Date: Sat, 20 Dec 2025 15:22:41 +0900 Subject: [PATCH 351/489] Add Rustc Explore video link --- src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md b/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md index 90c4097cc3e6..0bd4c6eb1339 100644 --- a/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md +++ b/src/doc/rustc-dev-guide/src/appendix/compiler-lecture.md @@ -6,6 +6,7 @@ These are videos where various experts explain different parts of the compiler: - [January 2019: Tom Tromey discusses debugging support in rustc](https://www.youtube.com/watch?v=elBxMRSNYr4) - [June 2019: Responsive compilers - Nicholas Matsakis - PLISS 2019](https://www.youtube.com/watch?v=N6b44kMS6OM) - [June 2019: Things I Learned (TIL) - Nicholas Matsakis - PLISS 2019](https://www.youtube.com/watch?v=LIYkT3p5gTs) +- [October 2022: Rustc Explore](https://www.youtube.com/playlist?list=PL85XCvVPmGQj3-MujOJ0jcoSqQ6Yi6Rkk) ## Rust Analyzer - [January 2019: How Salsa Works](https://www.youtube.com/watch?v=_muY4HjSqVw) @@ -46,4 +47,4 @@ These are videos where various experts explain different parts of the compiler: ## Code Generation - [January 2019: Cranelift](https://www.youtube.com/watch?v=9OIA7DTFQWU) -- [December 2024: LLVM Developers' Meeting - Rust ❤️ LLVM](https://www.youtube.com/watch?v=Kqz-umsAnk8) \ No newline at end of file +- [December 2024: LLVM Developers' Meeting - Rust ❤️ LLVM](https://www.youtube.com/watch?v=Kqz-umsAnk8) From 69c43e838df4d097c63079513edf3404f9541f0b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 20 Dec 2025 08:12:48 +0100 Subject: [PATCH 352/489] Prepare for merging from rust-lang/rust This updates the rust-version file to f51d1bcdc69f9bba47cc1656260ff76e6ff5fba3. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index d4fbfacf4eda..de0270f31fe5 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -526a91cbcc4601b92b0587405015e07b9c0d79f6 +f51d1bcdc69f9bba47cc1656260ff76e6ff5fba3 From 572ca1eb748f14b29b240a5028d72908fc4517f9 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 19 Sep 2025 04:58:26 +0000 Subject: [PATCH 353/489] rustc_codegen_llvm: Split "Fixed in LLVM 20" cases ... in `update_target_reliable_float_cfg`, based on the actual changes. The AArch64 issue is fixed on LLVM 20.1.1 while the MIPS issue is fixed on LLVM 20.1.0 (the first LLVM 20 release). This commit distinguishes two separate cases. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 2e1d0cfada5b..adb1ac09a633 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -364,11 +364,12 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { let target_abi = &sess.target.options.abi; let target_pointer_width = sess.target.pointer_width; let version = get_version(); + let lt_20_1_0 = version < (20, 1, 0); let lt_20_1_1 = version < (20, 1, 1); let lt_21_0_0 = version < (21, 0, 0); cfg.has_reliable_f16 = match (target_arch, target_os) { - // LLVM crash without neon (fixed in llvm20) + // LLVM crash without neon (fixed in LLVM 20.1.1) (Arch::AArch64, _) if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 => { @@ -395,8 +396,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { cfg.has_reliable_f128 = match (target_arch, target_os) { // Unsupported (Arch::Arm64EC, _) => false, - // Selection bug (fixed in llvm20) - (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_1 => false, + // Selection bug (fixed in LLVM 20.1.0) + (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_0 => false, // Selection bug . This issue is closed // but basic math still does not work. (Arch::Nvptx64, _) => false, From 28203e182f0d74577fee90d4fccd52fa98f72f07 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 19 Sep 2025 04:14:10 +0000 Subject: [PATCH 354/489] rustc_codegen_llvm: Simplify `update_target_reliable_float_cfg` This commit simplifies floating type handling through `update_target_reliable_float_cfg` based on several facts: 1. Major changes in behavior normally occurs only on the major LLVM upgrade. 2. The first release of LLVM 20.x.x is 20.1.0. Due to the first fact, we can normally ignore minor and patch releases of LLVM and we can remove obscure variables like `lt_xx_x_x` (still, there is a case where checking for patch version is required). The second fact is missed when the minimum LLVM version is raised to LLVM 20 and one "fixed in LLVM 20" case can be safely removed. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index adb1ac09a633..a3b1de9c3878 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -364,26 +364,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { let target_abi = &sess.target.options.abi; let target_pointer_width = sess.target.pointer_width; let version = get_version(); - let lt_20_1_0 = version < (20, 1, 0); - let lt_20_1_1 = version < (20, 1, 1); - let lt_21_0_0 = version < (21, 0, 0); + let (major, _, _) = version; cfg.has_reliable_f16 = match (target_arch, target_os) { // LLVM crash without neon (fixed in LLVM 20.1.1) (Arch::AArch64, _) - if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 => + if !cfg.target_features.iter().any(|f| f.as_str() == "neon") + && version < (20, 1, 1) => { false } // Unsupported (Arch::Arm64EC, _) => false, // Selection failure (fixed in llvm21) - (Arch::S390x, _) if lt_21_0_0 => false, + (Arch::S390x, _) if major < 21 => false, // MinGW ABI bugs (Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false, // Infinite recursion (Arch::CSky, _) => false, - (Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21) + (Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21) (Arch::PowerPC | Arch::PowerPC64, _) => false, (Arch::Sparc | Arch::Sparc64, _) => false, (Arch::Wasm32 | Arch::Wasm64, _) => false, @@ -397,7 +396,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // Unsupported (Arch::Arm64EC, _) => false, // Selection bug (fixed in LLVM 20.1.0) - (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_0 => false, + (Arch::Mips64 | Arch::Mips64r6, _) if version < (20, 1, 0) => false, // Selection bug . This issue is closed // but basic math still does not work. (Arch::Nvptx64, _) => false, @@ -410,7 +409,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { (Arch::Sparc, _) => false, // Stack alignment bug . NB: tests may // not fail if our compiler-builtins is linked. (fixed in llvm21) - (Arch::X86, _) if lt_21_0_0 => false, + (Arch::X86, _) if major < 21 => false, // MinGW ABI bugs (Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false, // There are no known problems on other platforms, so the only requirement is that symbols From 42d9f099e0f703bf681ab5e5fa502193bab7ad9e Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 19 Sep 2025 04:14:10 +0000 Subject: [PATCH 355/489] rustc_codegen_llvm: Reorder by arch in `update_target_reliable_float_cfg` This commit reorders certain match clauses in `update_target_reliable_float_cfg` by the architecture when there's no problems reordering it. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a3b1de9c3878..a5a8f8e6a25e 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -393,6 +393,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { }; cfg.has_reliable_f128 = match (target_arch, target_os) { + // Unsupported https://github.com/llvm/llvm-project/issues/121122 + (Arch::AmdGpu, _) => false, // Unsupported (Arch::Arm64EC, _) => false, // Selection bug (fixed in LLVM 20.1.0) @@ -400,8 +402,6 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // Selection bug . This issue is closed // but basic math still does not work. (Arch::Nvptx64, _) => false, - // Unsupported https://github.com/llvm/llvm-project/issues/121122 - (Arch::AmdGpu, _) => false, // ABI bugs et al. (full // list at ) (Arch::PowerPC | Arch::PowerPC64, _) => false, From d11ac79eeffab870de09ab62de1ef1383f38b429 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 20 Dec 2025 08:22:15 +0100 Subject: [PATCH 356/489] normalize file name changes away --- src/tools/miri/tests/panic/mir-validation.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/miri/tests/panic/mir-validation.rs b/src/tools/miri/tests/panic/mir-validation.rs index 11c4e395920c..4c863c5a9de8 100644 --- a/src/tools/miri/tests/panic/mir-validation.rs +++ b/src/tools/miri/tests/panic/mir-validation.rs @@ -5,6 +5,8 @@ //@normalize-stderr-test: "\n +\[\.\.\. omitted [0-9]+ frames? \.\.\.\].*" -> "" //@normalize-stderr-test: "\n[ =]*note:.*" -> "" //@normalize-stderr-test: "DefId\([^()]*\)" -> "DefId" +// Paths differ between bootstrap and stand-alone Miri runs, normalize them to be the same +//@normalize-stderr-test: "/rustc-dev/[^/]*/" -> "" // Somehow on rustc Windows CI, the "Miri caused an ICE" message is not shown // and we don't even get a regular panic; rustc aborts with a different exit code instead. //@ignore-host: windows From 19f74f46f999fda8910a596746dd595337be7139 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 20 Dec 2025 18:26:02 +1100 Subject: [PATCH 357/489] Use the same length type for `TestableCase::Slice` and `TestKind::Len` If we convert the minimum length to `u64` up-front when creating `TestableCase::Slice`, we can avoid more conversions to `u64` later. --- compiler/rustc_mir_build/src/builder/matches/buckets.rs | 4 ++-- compiler/rustc_mir_build/src/builder/matches/match_pair.rs | 2 +- compiler/rustc_mir_build/src/builder/matches/mod.rs | 2 +- compiler/rustc_mir_build/src/builder/matches/test.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/buckets.rs b/compiler/rustc_mir_build/src/builder/matches/buckets.rs index 6c5f0ed28a82..8cbbb8e14095 100644 --- a/compiler/rustc_mir_build/src/builder/matches/buckets.rs +++ b/compiler/rustc_mir_build/src/builder/matches/buckets.rs @@ -218,7 +218,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &TestKind::Len { len: test_len, op: BinOp::Eq }, &TestableCase::Slice { len, variable_length }, ) => { - match (test_len.cmp(&(len as u64)), variable_length) { + match (test_len.cmp(&len), variable_length) { (Ordering::Equal, false) => { // on true, min_len = len = $actual_length, // on false, len != $actual_length @@ -251,7 +251,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &TestableCase::Slice { len, variable_length }, ) => { // the test is `$actual_len >= test_len` - match (test_len.cmp(&(len as u64)), variable_length) { + match (test_len.cmp(&len), variable_length) { (Ordering::Equal, true) => { // $actual_len >= test_len = pat_len, // so we can match. diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index 6b4ba9243479..9b9ee1836956 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -256,7 +256,7 @@ impl<'tcx> MatchPairTree<'tcx> { None } else { Some(TestableCase::Slice { - len: prefix.len() + suffix.len(), + len: u64::try_from(prefix.len() + suffix.len()).unwrap(), variable_length: slice.is_some(), }) } diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 66e36a99d3c4..8897ca7c7210 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1264,7 +1264,7 @@ enum TestableCase<'tcx> { Variant { adt_def: ty::AdtDef<'tcx>, variant_index: VariantIdx }, Constant { value: ty::Value<'tcx> }, Range(Arc>), - Slice { len: usize, variable_length: bool }, + Slice { len: u64, variable_length: bool }, Deref { temp: Place<'tcx>, mutability: Mutability }, Never, Or { pats: Box<[FlatPat<'tcx>]> }, diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index 55e21ff18aae..402587bff7e8 100644 --- a/compiler/rustc_mir_build/src/builder/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -47,7 +47,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { TestableCase::Slice { len, variable_length } => { let op = if variable_length { BinOp::Ge } else { BinOp::Eq }; - TestKind::Len { len: len as u64, op } + TestKind::Len { len, op } } TestableCase::Deref { temp, mutability } => TestKind::Deref { temp, mutability }, From 354adbce4463b460e77d3bcb45789b1a5688af63 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 20 Dec 2025 09:14:50 +0100 Subject: [PATCH 358/489] Do not attempt to use `nth` with non-usize argument --- clippy_lints/src/methods/needless_collect.rs | 4 +++- tests/ui/needless_collect.fixed | 5 +++++ tests/ui/needless_collect.rs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/methods/needless_collect.rs b/clippy_lints/src/methods/needless_collect.rs index 055fdcabdd21..0e2012319147 100644 --- a/clippy_lints/src/methods/needless_collect.rs +++ b/clippy_lints/src/methods/needless_collect.rs @@ -81,7 +81,9 @@ pub(super) fn check<'tcx>( }, _ => return, }; - } else if let ExprKind::Index(_, index, _) = parent.kind { + } else if let ExprKind::Index(_, index, _) = parent.kind + && cx.typeck_results().expr_ty(index).is_usize() + { app = Applicability::MaybeIncorrect; let snip = snippet_with_applicability(cx, index.span, "_", &mut app); sugg = format!("nth({snip}).unwrap()"); diff --git a/tests/ui/needless_collect.fixed b/tests/ui/needless_collect.fixed index ba1451bf9704..99027e79b664 100644 --- a/tests/ui/needless_collect.fixed +++ b/tests/ui/needless_collect.fixed @@ -214,3 +214,8 @@ mod issue8055_regression { .len(); } } + +fn issue16270() { + // Do not lint, `..` implements `Index` but is not `usize` + _ = &(1..3).collect::>()[..]; +} diff --git a/tests/ui/needless_collect.rs b/tests/ui/needless_collect.rs index e054cd01e6f5..683cc49c9af3 100644 --- a/tests/ui/needless_collect.rs +++ b/tests/ui/needless_collect.rs @@ -214,3 +214,8 @@ mod issue8055_regression { .len(); } } + +fn issue16270() { + // Do not lint, `..` implements `Index` but is not `usize` + _ = &(1..3).collect::>()[..]; +} From c97d202d20c641b32c051e1ccbb37d45ee2702c5 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 20 Dec 2025 09:41:52 +0100 Subject: [PATCH 359/489] Preserve explicit lifetime information when removing `mut` Rather than trying to reconstruct the reference type without the `mut`, remove the `mut` itself so that user-inserted lifetime information is preserved. The message has been changed from "consider changing to [NON-MUT REF]" to "remove this `mut`" --- clippy_lints/src/needless_pass_by_ref_mut.rs | 19 ++- .../needless_pass_by_ref_mut.stderr | 4 +- tests/ui/needless_pass_by_ref_mut.stderr | 136 +++++++++++++----- tests/ui/needless_pass_by_ref_mut2.fixed | 6 + tests/ui/needless_pass_by_ref_mut2.rs | 6 + tests/ui/needless_pass_by_ref_mut2.stderr | 18 ++- 6 files changed, 146 insertions(+), 43 deletions(-) diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index 3d2285efbe18..904ff538ba36 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -1,7 +1,7 @@ use super::needless_pass_by_value::requires_exact_signature; use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_hir_and_then; -use clippy_utils::source::snippet; +use clippy_utils::source::HasSession as _; use clippy_utils::visitors::for_each_expr; use clippy_utils::{inherits_cfg, is_from_proc_macro, is_self}; use core::ops::ControlFlow; @@ -18,9 +18,9 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{self, Ty, TyCtxt, UpvarId, UpvarPath}; use rustc_session::impl_lint_pass; -use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; +use rustc_span::{BytePos, Span}; declare_clippy_lint! { /// ### What it does @@ -269,6 +269,15 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> { // If the argument is never used mutably, we emit the warning. let sp = input.span; if let rustc_hir::TyKind::Ref(_, inner_ty) = input.kind { + let Some(after_mut_span) = cx.sess().source_map().span_extend_to_prev_str( + inner_ty.ty.span.shrink_to_lo(), + "mut", + true, + true, + ) else { + return; + }; + let mut_span = after_mut_span.with_lo(after_mut_span.lo() - BytePos(3)); let is_cfged = is_cfged.get_or_insert_with(|| inherits_cfg(cx.tcx, *fn_def_id)); span_lint_hir_and_then( cx, @@ -278,9 +287,9 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> { "this argument is a mutable reference, but not used mutably", |diag| { diag.span_suggestion( - sp, - "consider changing to".to_string(), - format!("&{}", snippet(cx, cx.tcx.hir_span(inner_ty.ty.hir_id), "_"),), + mut_span, + "consider removing this `mut`", + "", Applicability::Unspecified, ); if cx.effective_visibilities.is_exported(*fn_def_id) { diff --git a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr index c10607bf4bab..f79b20ec69fc 100644 --- a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr +++ b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr @@ -2,7 +2,9 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.rs:5:19 | LL | pub fn pub_foo(s: &mut Vec, b: &u32, x: &mut u32) { - | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` + | ^----^^^^^^^^ + | | + | help: consider removing this `mut` | = warning: changing this function will impact semver compatibility = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` diff --git a/tests/ui/needless_pass_by_ref_mut.stderr b/tests/ui/needless_pass_by_ref_mut.stderr index 94d98f0e9b12..90d99b9f0cf6 100644 --- a/tests/ui/needless_pass_by_ref_mut.stderr +++ b/tests/ui/needless_pass_by_ref_mut.stderr @@ -2,7 +2,9 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:12:11 | LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { - | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` + | ^----^^^^^^^^ + | | + | help: consider removing this `mut` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` @@ -11,79 +13,105 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:38:12 | LL | fn foo6(s: &mut Vec) { - | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` + | ^----^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:49:12 | LL | fn bar(&mut self) {} - | ^^^^^^^^^ help: consider changing to: `&self` + | ^----^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:52:29 | LL | fn mushroom(&self, vec: &mut Vec) -> usize { - | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` + | ^----^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:130:16 | LL | async fn a1(x: &mut i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:135:16 | LL | async fn a2(x: &mut i32, y: String) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:140:16 | LL | async fn a3(x: &mut i32, y: String, z: String) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:145:16 | LL | async fn a4(x: &mut i32, y: i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:150:24 | LL | async fn a5(x: i32, y: &mut i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:155:24 | LL | async fn a6(x: i32, y: &mut i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:160:32 | LL | async fn a7(x: i32, y: i32, z: &mut i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:165:24 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:165:45 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:201:16 | LL | fn cfg_warn(s: &mut u32) {} - | ^^^^^^^^ help: consider changing to: `&u32` + | ^----^^^ + | | + | help: consider removing this `mut` | = note: this is cfg-gated and may require further changes @@ -91,7 +119,9 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:206:20 | LL | fn cfg_warn(s: &mut u32) {} - | ^^^^^^^^ help: consider changing to: `&u32` + | ^----^^^ + | | + | help: consider removing this `mut` | = note: this is cfg-gated and may require further changes @@ -99,115 +129,153 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:219:39 | LL | async fn inner_async2(x: &mut i32, y: &mut u32) { - | ^^^^^^^^ help: consider changing to: `&u32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:228:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:248:30 | LL | async fn call_in_closure1(n: &mut str) { - | ^^^^^^^^ help: consider changing to: `&str` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:268:16 | LL | fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { - | ^^^^^^^^^^ help: consider changing to: `&usize` + | ^----^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:280:22 | LL | async fn closure4(n: &mut usize) { - | ^^^^^^^^^^ help: consider changing to: `&usize` + | ^----^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:335:12 | LL | fn bar(&mut self) {} - | ^^^^^^^^^ help: consider changing to: `&self` + | ^----^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:338:18 | LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { - | ^^^^^^^^^ help: consider changing to: `&self` + | ^----^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:338:45 | LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { - | ^^^^^^^^ help: consider changing to: `&u32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:347:46 | LL | async fn foo2(&mut self, u: &mut i32, v: &mut u32) { - | ^^^^^^^^ help: consider changing to: `&u32` + | ^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:364:18 | LL | fn _empty_tup(x: &mut (())) {} - | ^^^^^^^^^ help: consider changing to: `&()` + | ^^----^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:366:19 | LL | fn _single_tup(x: &mut ((i32,))) {} - | ^^^^^^^^^^^^^ help: consider changing to: `&(i32,)` + | ^^----^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:368:18 | LL | fn _multi_tup(x: &mut ((i32, u32))) {} - | ^^^^^^^^^^^^^^^^^ help: consider changing to: `&(i32, u32)` + | ^^----^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:370:11 | LL | fn _fn(x: &mut (fn())) {} - | ^^^^^^^^^^^ help: consider changing to: `&fn()` + | ^^----^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:373:23 | LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "Rust" fn()` + | ^----^^^^^^^^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:375:20 | LL | fn _extern_c_fn(x: &mut extern "C" fn()) {} - | ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "C" fn()` + | ^----^^^^^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:377:18 | LL | fn _unsafe_fn(x: &mut unsafe fn()) {} - | ^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe fn()` + | ^----^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:379:25 | LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn()` + | ^----^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:381:20 | LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn(i32)` + | ^----^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:383:20 | LL | fn _fn_with_ret(x: &mut unsafe extern "C" fn() -> (i32)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn() -> (i32)` + | ^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: consider removing this `mut` error: aborting due to 34 previous errors diff --git a/tests/ui/needless_pass_by_ref_mut2.fixed b/tests/ui/needless_pass_by_ref_mut2.fixed index 0e2ac0202364..c462f1cc8d87 100644 --- a/tests/ui/needless_pass_by_ref_mut2.fixed +++ b/tests/ui/needless_pass_by_ref_mut2.fixed @@ -24,3 +24,9 @@ async fn inner_async4(u: &mut i32, v: &u32) { } fn main() {} + +//~v needless_pass_by_ref_mut +fn issue16267<'a>(msg: &str, slice: &'a [i32]) -> &'a [i32] { + println!("{msg}"); + &slice[0..5] +} diff --git a/tests/ui/needless_pass_by_ref_mut2.rs b/tests/ui/needless_pass_by_ref_mut2.rs index 9201d9a27298..b00f294c57f0 100644 --- a/tests/ui/needless_pass_by_ref_mut2.rs +++ b/tests/ui/needless_pass_by_ref_mut2.rs @@ -24,3 +24,9 @@ async fn inner_async4(u: &mut i32, v: &mut u32) { } fn main() {} + +//~v needless_pass_by_ref_mut +fn issue16267<'a>(msg: &str, slice: &'a mut [i32]) -> &'a [i32] { + println!("{msg}"); + &slice[0..5] +} diff --git a/tests/ui/needless_pass_by_ref_mut2.stderr b/tests/ui/needless_pass_by_ref_mut2.stderr index 9876a6b50718..6af8a4d4a2b5 100644 --- a/tests/ui/needless_pass_by_ref_mut2.stderr +++ b/tests/ui/needless_pass_by_ref_mut2.stderr @@ -2,7 +2,9 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut2.rs:8:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { - | ^^^^^^^^ help: consider changing to: `&i32` + | ^----^^^ + | | + | help: consider removing this `mut` | = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` @@ -11,7 +13,17 @@ error: this argument is a mutable reference, but not used mutably --> tests/ui/needless_pass_by_ref_mut2.rs:17:39 | LL | async fn inner_async4(u: &mut i32, v: &mut u32) { - | ^^^^^^^^ help: consider changing to: `&u32` + | ^----^^^ + | | + | help: consider removing this `mut` -error: aborting due to 2 previous errors +error: this argument is a mutable reference, but not used mutably + --> tests/ui/needless_pass_by_ref_mut2.rs:29:37 + | +LL | fn issue16267<'a>(msg: &str, slice: &'a mut [i32]) -> &'a [i32] { + | ^^^^----^^^^^ + | | + | help: consider removing this `mut` + +error: aborting due to 3 previous errors From 889ad15b62c46ed81187d27df8cc762226ae4520 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 20 Dec 2025 11:02:37 +0100 Subject: [PATCH 360/489] interpreter/visitor: always iterate in in-memory order --- .../rustc_const_eval/src/interpret/visitor.rs | 17 +---------------- src/tools/miri/src/helpers.rs | 7 ------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index 95106c7c143b..a8d472bc2ea2 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -4,7 +4,6 @@ use std::num::NonZero; use rustc_abi::{FieldIdx, FieldsShape, VariantIdx, Variants}; -use rustc_index::{Idx as _, IndexVec}; use rustc_middle::mir::interpret::InterpResult; use rustc_middle::ty::{self, Ty}; use tracing::trace; @@ -24,20 +23,6 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { self.ecx().read_discriminant(&v.to_op(self.ecx())?) } - /// This function provides the chance to reorder the order in which fields are visited for - /// `FieldsShape::Aggregate`. - /// - /// The default means we iterate in source declaration order; alternatively this can use - /// `in_memory_order` to iterate in memory order. - #[inline(always)] - fn aggregate_field_iter( - in_memory_order: &IndexVec, - ) -> impl Iterator { - // Allow the optimizer to elide the bounds checking when creating each index. - let _ = FieldIdx::new(in_memory_order.len()); - (0..in_memory_order.len()).map(FieldIdx::new) - } - // Recursive actions, ready to be overloaded. /// Visits the given value, dispatching as appropriate to more specialized visitors. #[inline(always)] @@ -171,7 +156,7 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { self.visit_union(v, fields)?; } FieldsShape::Arbitrary { in_memory_order, .. } => { - for idx in Self::aggregate_field_iter(in_memory_order) { + for idx in in_memory_order.iter().copied() { let field = self.ecx().project_field(v, idx)?; self.visit_field(v, idx.as_usize(), &field)?; } diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 218e4ffe5e2f..f4fc478481a7 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -10,7 +10,6 @@ use rustc_data_structures::fx::{FxBuildHasher, FxHashSet}; use rustc_hir::Safety; use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE}; -use rustc_index::IndexVec; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::ExportedSymbol; @@ -583,12 +582,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { self.ecx } - fn aggregate_field_iter( - in_memory_order: &IndexVec, - ) -> impl Iterator { - in_memory_order.iter().copied() - } - // Hook to detect `UnsafeCell`. fn visit_value(&mut self, v: &MPlaceTy<'tcx>) -> InterpResult<'tcx> { trace!("UnsafeCellVisitor: {:?} {:?}", *v, v.layout.ty); From 462a8b34104a9b58932654937e55ed82e492b4f2 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Mon, 3 Nov 2025 07:45:02 +0200 Subject: [PATCH 361/489] Dogfood `strip_circumfix` --- compiler/rustc_metadata/src/errors.rs | 4 +--- compiler/rustc_metadata/src/lib.rs | 1 + .../rustc_trait_selection/src/error_reporting/infer/mod.rs | 5 ++--- compiler/rustc_trait_selection/src/lib.rs | 1 + 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index abfd078f7462..af8ff5643f2c 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -251,9 +251,7 @@ impl<'a> MissingNativeLibrary<'a> { // if it looks like the user has provided a complete filename rather just the bare lib name, // then provide a note that they might want to try trimming the name let suggested_name = if !verbatim { - if let Some(libname) = libname.strip_prefix("lib") - && let Some(libname) = libname.strip_suffix(".a") - { + if let Some(libname) = libname.strip_circumfix("lib", ".a") { // this is a unix style filename so trim prefix & suffix Some(libname) } else if let Some(libname) = libname.strip_suffix(".lib") { diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index f31c4938e118..f3b738f93d2d 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -10,6 +10,7 @@ #![feature(never_type)] #![feature(proc_macro_internals)] #![feature(result_option_map_or_default)] +#![feature(strip_circumfix)] #![feature(trusted_len)] // tidy-alphabetical-end diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index 32be23eed765..4de3ba3e2781 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -1758,8 +1758,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // specify a byte literal (ty::Uint(ty::UintTy::U8), ty::Char) => { if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) - && let Some(code) = - code.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')) + && let Some(code) = code.strip_circumfix('\'', '\'') // forbid all Unicode escapes && !code.starts_with("\\u") // forbids literal Unicode characters beyond ASCII @@ -1776,7 +1775,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // specify a character literal (issue #92479) (ty::Char, ty::Ref(_, r, _)) if r.is_str() => { if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) - && let Some(code) = code.strip_prefix('"').and_then(|s| s.strip_suffix('"')) + && let Some(code) = code.strip_circumfix('"', '"') && code.chars().count() == 1 { suggestions.push(TypeErrorAdditionalDiags::MeantCharLiteral { diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 0184b2ccde78..6705d271bc7d 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -22,6 +22,7 @@ #![feature(iter_intersperse)] #![feature(iterator_try_reduce)] #![feature(never_type)] +#![feature(strip_circumfix)] #![feature(try_blocks)] #![feature(unwrap_infallible)] #![feature(yeet_expr)] From 5d8a096afeb4cd9b7ef7693aa6692afe71fbf5bc Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 19 Dec 2025 14:46:18 +0000 Subject: [PATCH 362/489] change non-canonical clone impl to {*self}, fix some doc comments --- compiler/rustc_graphviz/src/lib.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 2 +- compiler/rustc_pattern_analysis/src/lib.rs | 2 +- compiler/rustc_pattern_analysis/src/pat.rs | 5 +---- compiler/rustc_pattern_analysis/src/usefulness.rs | 2 +- compiler/rustc_thread_pool/src/registry.rs | 14 ++++++-------- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index 9f75578aa636..cd1e573ea28d 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -416,7 +416,7 @@ impl<'a> Id<'a> { /// it in the generated .dot file. They can also provide more /// elaborate (and non-unique) label text that is used in the graphviz /// rendered output. - +/// /// The graph instance is responsible for providing the DOT compatible /// identifiers for the nodes and (optionally) rendered labels for the nodes and /// edges, as well as an identifier for the graph itself. diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 471bd1d937e9..9e4692b96418 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2654,7 +2654,7 @@ struct InternedInSet<'tcx, T: ?Sized + PointeeSized>(&'tcx T); impl<'tcx, T: 'tcx + ?Sized + PointeeSized> Clone for InternedInSet<'tcx, T> { fn clone(&self) -> Self { - InternedInSet(self.0) + *self } } diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index d9bb93a829b5..f3308086ddc6 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -141,7 +141,7 @@ pub struct MatchArm<'p, Cx: PatCx> { impl<'p, Cx: PatCx> Clone for MatchArm<'p, Cx> { fn clone(&self) -> Self { - Self { pat: self.pat, has_guard: self.has_guard, arm_data: self.arm_data } + *self } } diff --git a/compiler/rustc_pattern_analysis/src/pat.rs b/compiler/rustc_pattern_analysis/src/pat.rs index 901b72e53995..51d0703f9c5c 100644 --- a/compiler/rustc_pattern_analysis/src/pat.rs +++ b/compiler/rustc_pattern_analysis/src/pat.rs @@ -174,10 +174,7 @@ pub(crate) enum PatOrWild<'p, Cx: PatCx> { impl<'p, Cx: PatCx> Clone for PatOrWild<'p, Cx> { fn clone(&self) -> Self { - match self { - PatOrWild::Wild => PatOrWild::Wild, - PatOrWild::Pat(pat) => PatOrWild::Pat(pat), - } + *self } } diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index 19446a1efe9c..971616b18914 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -824,7 +824,7 @@ struct PlaceCtxt<'a, Cx: PatCx> { impl<'a, Cx: PatCx> Copy for PlaceCtxt<'a, Cx> {} impl<'a, Cx: PatCx> Clone for PlaceCtxt<'a, Cx> { fn clone(&self) -> Self { - Self { cx: self.cx, ty: self.ty } + *self } } diff --git a/compiler/rustc_thread_pool/src/registry.rs b/compiler/rustc_thread_pool/src/registry.rs index 4a018ea743ae..92bb8961e7df 100644 --- a/compiler/rustc_thread_pool/src/registry.rs +++ b/compiler/rustc_thread_pool/src/registry.rs @@ -153,8 +153,8 @@ pub struct Registry { terminate_count: AtomicUsize, } -/// //////////////////////////////////////////////////////////////////////// -/// Initialization +/////////////////////////////////////////////////////////////////////////// +// Initialization static mut THE_REGISTRY: Option> = None; static THE_REGISTRY_SET: Once = Once::new(); @@ -407,12 +407,12 @@ impl Registry { } } - /// //////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// /// MAIN LOOP /// /// So long as all of the worker threads are hanging out in their /// top-level loop, there is no work to be done. - + /// /// Push a job into the given `registry`. If we are running on a /// worker thread for the registry, this will push onto the /// deque. Else, it will inject from the outside (which is slower). @@ -668,8 +668,8 @@ impl ThreadInfo { } } -/// //////////////////////////////////////////////////////////////////////// -/// WorkerThread identifiers +/////////////////////////////////////////////////////////////////////////// +// WorkerThread identifiers pub(super) struct WorkerThread { /// the "worker" half of our local deque @@ -1019,8 +1019,6 @@ impl WorkerThread { } } -/// //////////////////////////////////////////////////////////////////////// - unsafe fn main_loop(thread: ThreadBuilder) { let worker_thread = &WorkerThread::from(thread); unsafe { WorkerThread::set_current(worker_thread) }; From 120f0d4f07ef21a615ac40362e0acb4d803fcb37 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Sat, 20 Dec 2025 15:35:52 +0100 Subject: [PATCH 363/489] Port `#[thread_local]` to attribute parser --- .../src/attributes/codegen_attrs.rs | 10 ++++++ compiler/rustc_attr_parsing/src/context.rs | 3 +- .../rustc_codegen_ssa/src/codegen_attrs.rs | 4 ++- .../rustc_hir/src/attrs/data_structures.rs | 3 ++ .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_passes/messages.ftl | 4 --- compiler/rustc_passes/src/check_attr.rs | 15 +------- compiler/rustc_passes/src/errors.rs | 9 ----- tests/ui/attributes/malformed-attrs.stderr | 15 ++++---- tests/ui/thread-local/non-static.rs | 8 ++--- tests/ui/thread-local/non-static.stderr | 34 ++++++++----------- 11 files changed, 48 insertions(+), 58 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index e59f70877c94..c68c66b27185 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -690,6 +690,16 @@ impl SingleAttributeParser for SanitizeParser { } } +pub(crate) struct ThreadLocalParser; + +impl NoArgsAttributeParser for ThreadLocalParser { + const PATH: &[Symbol] = &[sym::thread_local]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::WarnButFutureError; + const ALLOWED_TARGETS: AllowedTargets = + AllowedTargets::AllowList(&[Allow(Target::Static), Allow(Target::ForeignStatic)]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ThreadLocal; +} + pub(crate) struct RustcPassIndirectlyInNonRusticAbisParser; impl NoArgsAttributeParser for RustcPassIndirectlyInNonRusticAbisParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index a752869c2eb2..df4970d8aa90 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -23,7 +23,7 @@ use crate::attributes::codegen_attrs::{ ColdParser, CoverageParser, EiiExternItemParser, ExportNameParser, ForceTargetFeatureParser, NakedParser, NoMangleParser, ObjcClassParser, ObjcSelectorParser, OptimizeParser, RustcPassIndirectlyInNonRusticAbisParser, SanitizeParser, TargetFeatureParser, - TrackCallerParser, UsedParser, + ThreadLocalParser, TrackCallerParser, UsedParser, }; use crate::attributes::confusables::ConfusablesParser; use crate::attributes::crate_level::{ @@ -269,6 +269,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 473598bad394..8135fd43dd93 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -350,6 +350,9 @@ fn process_builtin_attrs( codegen_fn_attrs.flags |= CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM; } } + AttributeKind::ThreadLocal => { + codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL + } _ => {} } } @@ -366,7 +369,6 @@ fn process_builtin_attrs( sym::rustc_allocator_zeroed => { codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR_ZEROED } - sym::thread_local => codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL, sym::instruction_set => { codegen_fn_attrs.instruction_set = parse_instruction_set_attr(tcx, attr) } diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 1a382d8f124b..e9f9b2445deb 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -1010,6 +1010,9 @@ pub enum AttributeKind { /// `#[unsafe(force_target_feature(enable = "...")]`. TargetFeature { features: ThinVec<(Symbol, Span)>, attr_span: Span, was_forced: bool }, + /// Represents `#[thread_local]` + ThreadLocal, + /// Represents `#[track_caller]` TrackCaller(Span), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 7c1e71f258be..68456dfe4c29 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -114,6 +114,7 @@ impl AttributeKind { Stability { .. } => Yes, StdInternalSymbol(..) => No, TargetFeature { .. } => No, + ThreadLocal => No, TrackCaller(..) => Yes, TypeConst(..) => Yes, TypeLengthLimit { .. } => No, diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index c0106ea0c627..cf069b364be8 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -484,10 +484,6 @@ passes_sanitize_attribute_not_allowed = .no_body = function has no body .help = sanitize attribute can be applied to a function (with body), impl block, or module -passes_should_be_applied_to_static = - attribute should be applied to a static - .label = not a static - passes_should_be_applied_to_trait = attribute should be applied to a trait .label = not a trait diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 945dcec798e3..7822614a05cb 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -297,6 +297,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcPassIndirectlyInNonRusticAbis(..) | AttributeKind::PinV2(..) | AttributeKind::WindowsSubsystem(..) + | AttributeKind::ThreadLocal ) => { /* do nothing */ } Attribute::Unparsed(attr_item) => { style = Some(attr_item.style); @@ -310,7 +311,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { [sym::diagnostic, sym::on_const, ..] => { self.check_diagnostic_on_const(attr.span(), hir_id, target, item) } - [sym::thread_local, ..] => self.check_thread_local(attr, span, target), [sym::rustc_clean, ..] | [sym::rustc_dirty, ..] | [sym::rustc_if_this_changed, ..] @@ -768,19 +768,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks if the `#[thread_local]` attribute on `item` is valid. - fn check_thread_local(&self, attr: &Attribute, span: Span, target: Target) { - match target { - Target::ForeignStatic | Target::Static => {} - _ => { - self.dcx().emit_err(errors::AttrShouldBeAppliedToStatic { - attr_span: attr.span(), - defn_span: span, - }); - } - } - } - fn check_doc_alias_value(&self, span: Span, hir_id: HirId, target: Target, alias: Symbol) { if let Some(location) = match target { Target::AssocTy => { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 4f97f74c7804..2b817c6dd106 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -98,15 +98,6 @@ pub(crate) struct AttrShouldBeAppliedToTrait { pub defn_span: Span, } -#[derive(Diagnostic)] -#[diag(passes_should_be_applied_to_static)] -pub(crate) struct AttrShouldBeAppliedToStatic { - #[primary_span] - pub attr_span: Span, - #[label] - pub defn_span: Span, -} - #[derive(Diagnostic)] #[diag(passes_doc_alias_bad_location)] pub(crate) struct DocAliasBadLocation<'a> { diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 228ea12cba8b..d0e5cb631c1e 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -141,12 +141,6 @@ LL | #[forbid(lint1, lint2, ...)] LL | #[forbid(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ -error: malformed `thread_local` attribute input - --> $DIR/malformed-attrs.rs:210:1 - | -LL | #[thread_local()] - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` - error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type --> $DIR/malformed-attrs.rs:105:1 | @@ -618,6 +612,15 @@ LL | #[non_exhaustive = 1] | | didn't expect any arguments here | help: must be of the form: `#[non_exhaustive]` +error[E0565]: malformed `thread_local` attribute input + --> $DIR/malformed-attrs.rs:210:1 + | +LL | #[thread_local()] + | ^^^^^^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[thread_local]` + error[E0565]: malformed `no_link` attribute input --> $DIR/malformed-attrs.rs:214:1 | diff --git a/tests/ui/thread-local/non-static.rs b/tests/ui/thread-local/non-static.rs index f1c4273870bf..f14ff20f449b 100644 --- a/tests/ui/thread-local/non-static.rs +++ b/tests/ui/thread-local/non-static.rs @@ -2,19 +2,19 @@ #![feature(thread_local)] #[thread_local] -//~^ ERROR attribute should be applied to a static +//~^ ERROR `#[thread_local]` attribute cannot be used on constants const A: u32 = 0; #[thread_local] -//~^ ERROR attribute should be applied to a static +//~^ ERROR `#[thread_local]` attribute cannot be used on functions fn main() { #[thread_local] || {}; - //~^ ERROR attribute should be applied to a static + //~^ ERROR `#[thread_local]` attribute cannot be used on closures } struct S { #[thread_local] - //~^ ERROR attribute should be applied to a static + //~^ ERROR `#[thread_local]` attribute cannot be used on struct fields a: String, b: String, } diff --git a/tests/ui/thread-local/non-static.stderr b/tests/ui/thread-local/non-static.stderr index 09a1618d6e71..c83a6beb4c6a 100644 --- a/tests/ui/thread-local/non-static.stderr +++ b/tests/ui/thread-local/non-static.stderr @@ -1,38 +1,34 @@ -error: attribute should be applied to a static +error: `#[thread_local]` attribute cannot be used on constants --> $DIR/non-static.rs:4:1 | LL | #[thread_local] | ^^^^^^^^^^^^^^^ -LL | -LL | const A: u32 = 0; - | ----------------- not a static + | + = help: `#[thread_local]` can be applied to foreign statics and statics -error: attribute should be applied to a static +error: `#[thread_local]` attribute cannot be used on functions --> $DIR/non-static.rs:8:1 | -LL | #[thread_local] - | ^^^^^^^^^^^^^^^ -LL | -LL | / fn main() { -LL | | #[thread_local] || {}; -LL | | -LL | | } - | |_- not a static +LL | #[thread_local] + | ^^^^^^^^^^^^^^^ + | + = help: `#[thread_local]` can be applied to foreign statics and statics -error: attribute should be applied to a static +error: `#[thread_local]` attribute cannot be used on closures --> $DIR/non-static.rs:11:5 | LL | #[thread_local] || {}; - | ^^^^^^^^^^^^^^^ ----- not a static + | ^^^^^^^^^^^^^^^ + | + = help: `#[thread_local]` can be applied to foreign statics and statics -error: attribute should be applied to a static +error: `#[thread_local]` attribute cannot be used on struct fields --> $DIR/non-static.rs:16:5 | LL | #[thread_local] | ^^^^^^^^^^^^^^^ -LL | -LL | a: String, - | --------- not a static + | + = help: `#[thread_local]` can be applied to foreign statics and statics error: aborting due to 4 previous errors From c556e9c2fa0a287f0289dc1548159ac9822c5318 Mon Sep 17 00:00:00 2001 From: Brian Campbell Date: Sat, 20 Dec 2025 03:07:05 -0500 Subject: [PATCH 364/489] [rustdoc] Add missing close tags in extern crate reexports --- src/librustdoc/html/render/print_item.rs | 1 + tests/rustdoc/extern/pub-extern-crate-150176.rs | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tests/rustdoc/extern/pub-extern-crate-150176.rs diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index f88a5b8974fb..0b52c0b56b82 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -439,6 +439,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i )?; } } + write!(w, "")? } clean::ImportItem(ref import) => { let stab_tags = diff --git a/tests/rustdoc/extern/pub-extern-crate-150176.rs b/tests/rustdoc/extern/pub-extern-crate-150176.rs new file mode 100644 index 000000000000..b68619c5a02d --- /dev/null +++ b/tests/rustdoc/extern/pub-extern-crate-150176.rs @@ -0,0 +1,5 @@ +//@ aux-build:pub-extern-crate.rs + +//@ has pub_extern_crate_150176/index.html +//@ hasraw - 'pub extern crate inner;' +pub extern crate inner; From 93fbf3b885fa9d0bd2a0fec2cbb32cfdb91cc5eb Mon Sep 17 00:00:00 2001 From: Justin Geibel Date: Sat, 20 Dec 2025 11:23:38 -0500 Subject: [PATCH 365/489] Drop the From derive macro from the v1 prelude This was accidentally added to the prelude in 3f4dc1e02d759aa3c3807d4efc1f7f6e293536a5. --- library/core/src/prelude/v1.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 977fd1926fd0..a5d9a5352dfc 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -118,13 +118,6 @@ pub use crate::macros::builtin::deref; )] pub use crate::macros::builtin::define_opaque; -#[unstable( - feature = "derive_from", - issue = "144889", - reason = "`derive(From)` is unstable" -)] -pub use crate::macros::builtin::From; - #[unstable(feature = "extern_item_impls", issue = "125418")] pub use crate::macros::builtin::{eii, unsafe_eii}; From 4e7063096a9875f4771f9a5b263644aebb650b19 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Thu, 18 Dec 2025 02:14:59 +0200 Subject: [PATCH 366/489] Use slices for `Interner::FnInputTys` and `Interner::GenericArgsSlice`, not `Tys` and `GenericArgs` respectively This allows us to avoid interning them. --- .../crates/hir-ty/src/display.rs | 4 +-- .../crates/hir-ty/src/dyn_compatibility.rs | 14 ++++----- .../crates/hir-ty/src/infer/closure.rs | 29 +++++++++---------- .../crates/hir-ty/src/infer/expr.rs | 2 +- .../hir-ty/src/method_resolution/confirm.rs | 2 +- .../hir-ty/src/method_resolution/probe.rs | 2 +- .../crates/hir-ty/src/mir/eval.rs | 2 +- .../crates/hir-ty/src/mir/lower.rs | 4 +-- .../hir-ty/src/next_solver/generic_arg.rs | 15 ++++------ .../crates/hir-ty/src/next_solver/interner.rs | 7 ++--- .../crates/hir-ty/src/next_solver/ty.rs | 5 +--- src/tools/rust-analyzer/crates/hir/src/lib.rs | 6 ++-- 12 files changed, 39 insertions(+), 53 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/display.rs b/src/tools/rust-analyzer/crates/hir-ty/src/display.rs index 8e44c14abe23..b9e23464e980 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/display.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/display.rs @@ -1459,7 +1459,7 @@ impl<'db> HirDisplay<'db> for Ty<'db> { }; let coroutine_sig = coroutine_sig.skip_binder(); let coroutine_inputs = coroutine_sig.inputs(); - let TyKind::Tuple(coroutine_inputs) = coroutine_inputs.as_slice()[1].kind() else { + let TyKind::Tuple(coroutine_inputs) = coroutine_inputs[1].kind() else { unreachable!("invalid coroutine closure signature"); }; let TyKind::Tuple(coroutine_output) = coroutine_sig.output().kind() else { @@ -1942,7 +1942,7 @@ fn write_bounds_like_dyn_trait<'db>( let own_args = projection.projection_term.own_args(f.interner); if !own_args.is_empty() { write!(f, "<")?; - hir_fmt_generic_arguments(f, own_args.as_slice(), None)?; + hir_fmt_generic_arguments(f, own_args, None)?; write!(f, ">")?; } write!(f, " = ")?; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs b/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs index ffdc9ca0f85a..59cfd3fdc98c 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs @@ -328,13 +328,9 @@ where } let sig = db.callable_item_signature(func.into()); - if sig - .skip_binder() - .inputs() - .iter() - .skip(1) - .any(|ty| contains_illegal_self_type_reference(db, trait_, &ty, AllowSelfProjection::Yes)) - { + if sig.skip_binder().inputs().iter().skip(1).any(|ty| { + contains_illegal_self_type_reference(db, trait_, ty.skip_binder(), AllowSelfProjection::Yes) + }) { cb(MethodViolationCode::ReferencesSelfInput)?; } @@ -411,11 +407,11 @@ fn receiver_is_dispatchable<'db>( // `self: Self` can't be dispatched on, but this is already considered dyn-compatible // See rustc's comment on https://github.com/rust-lang/rust/blob/3f121b9461cce02a703a0e7e450568849dfaa074/compiler/rustc_trait_selection/src/traits/object_safety.rs#L433-L437 - if sig.inputs().iter().next().is_some_and(|p| p.skip_binder() == self_param_ty) { + if sig.inputs().iter().next().is_some_and(|p| *p.skip_binder() == self_param_ty) { return true; } - let Some(&receiver_ty) = sig.inputs().skip_binder().as_slice().first() else { + let Some(&receiver_ty) = sig.inputs().skip_binder().first() else { return false; }; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs index 14b0c9076c30..82912017c3e4 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs @@ -13,7 +13,7 @@ use rustc_type_ir::{ ClosureArgs, ClosureArgsParts, CoroutineArgs, CoroutineArgsParts, CoroutineClosureArgs, CoroutineClosureArgsParts, Interner, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, - inherent::{BoundExistentialPredicates, GenericArgs as _, IntoKind, SliceLike, Ty as _}, + inherent::{BoundExistentialPredicates, GenericArgs as _, IntoKind, Ty as _}, }; use tracing::debug; @@ -77,11 +77,11 @@ impl<'db> InferenceContext<'_, 'db> { let (id, ty, resume_yield_tys) = match closure_kind { ClosureKind::Coroutine(_) => { let yield_ty = self.table.next_ty_var(); - let resume_ty = liberated_sig.inputs().get(0).unwrap_or(self.types.unit); + let resume_ty = liberated_sig.inputs().first().copied().unwrap_or(self.types.unit); // FIXME: Infer the upvars later. let parts = CoroutineArgsParts { - parent_args, + parent_args: parent_args.as_slice(), kind_ty: self.types.unit, resume_ty, yield_ty, @@ -119,7 +119,7 @@ impl<'db> InferenceContext<'_, 'db> { }; // FIXME: Infer the kind later if needed. let parts = ClosureArgsParts { - parent_args, + parent_args: parent_args.as_slice(), closure_kind_ty: Ty::from_closure_kind( interner, expected_kind.unwrap_or(rustc_type_ir::ClosureKind::Fn), @@ -165,16 +165,13 @@ impl<'db> InferenceContext<'_, 'db> { let closure_args = CoroutineClosureArgs::new( interner, CoroutineClosureArgsParts { - parent_args, + parent_args: parent_args.as_slice(), closure_kind_ty, signature_parts_ty: Ty::new_fn_ptr( interner, bound_sig.map_bound(|sig| { interner.mk_fn_sig( - [ - resume_ty, - Ty::new_tup_from_iter(interner, sig.inputs().iter()), - ], + [resume_ty, Ty::new_tup(interner, sig.inputs())], Ty::new_tup(interner, &[bound_yield_ty, bound_return_ty]), sig.c_variadic, sig.safety, @@ -195,7 +192,7 @@ impl<'db> InferenceContext<'_, 'db> { // Now go through the argument patterns for (arg_pat, arg_ty) in args.iter().zip(bound_sig.skip_binder().inputs()) { - self.infer_top_pat(*arg_pat, arg_ty, None); + self.infer_top_pat(*arg_pat, *arg_ty, None); } // FIXME: lift these out into a struct @@ -668,7 +665,7 @@ impl<'db> InferenceContext<'_, 'db> { assert!(!expected_sig.skip_binder().has_vars_bound_above(rustc_type_ir::INNERMOST)); let bound_sig = expected_sig.map_bound(|sig| { self.interner().mk_fn_sig( - sig.inputs(), + sig.inputs().iter().copied(), sig.output(), sig.c_variadic, Safety::Safe, @@ -744,9 +741,10 @@ impl<'db> InferenceContext<'_, 'db> { // The liberated version of this signature should be a subtype // of the liberated form of the expectation. - for (supplied_ty, expected_ty) in - iter::zip(supplied_sig.inputs(), expected_sigs.liberated_sig.inputs()) - { + for (supplied_ty, expected_ty) in iter::zip( + supplied_sig.inputs().iter().copied(), + expected_sigs.liberated_sig.inputs().iter().copied(), + ) { // Check that E' = S'. let cause = ObligationCause::new(); let InferOk { value: (), obligations } = @@ -765,7 +763,8 @@ impl<'db> InferenceContext<'_, 'db> { let inputs = supplied_sig .inputs() - .into_iter() + .iter() + .copied() .map(|ty| table.infer_ctxt.resolve_vars_if_possible(ty)); expected_sigs.liberated_sig = table.interner().mk_fn_sig( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs index 5eeaeef9d9f6..4d3ca94b22f8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs @@ -1219,7 +1219,7 @@ impl<'db> InferenceContext<'_, 'db> { CoroutineArgs::new( self.interner(), CoroutineArgsParts { - parent_args, + parent_args: parent_args.as_slice(), kind_ty: self.types.unit, // rustc uses a special lang item type for the resume ty. I don't believe this can cause us problems. resume_ty: self.types.unit, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs index 9292928f99fc..0024ca16a594 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/confirm.rs @@ -145,7 +145,7 @@ impl<'a, 'b, 'db> ConfirmContext<'a, 'b, 'db> { // traits, no trait system method can be called before this point because they // could alter our Self-type, except for normalizing the receiver from the // signature (which is also done during probing). - let method_sig_rcvr = method_sig.inputs().as_slice()[0]; + let method_sig_rcvr = method_sig.inputs()[0]; debug!( "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?}", self_ty, method_sig_rcvr, method_sig diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs index cdffcd9383ca..cb9b810686e3 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution/probe.rs @@ -1977,7 +1977,7 @@ impl<'a, 'db, Choice: ProbeChoice<'db>> ProbeContext<'a, 'db, Choice> { && self.mode == Mode::MethodCall { let sig = self.xform_method_sig(item, args); - (sig.inputs().as_slice()[0], Some(sig.output())) + (sig.inputs()[0], Some(sig.output())) } else { (impl_ty, None) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs index b78e610b49e8..c7156bb11ed6 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/eval.rs @@ -2771,7 +2771,7 @@ impl<'db> Evaluator<'db> { TyKind::Closure(closure, subst) => self.exec_closure( closure.0, func_data, - subst.split_closure_args_untupled().parent_args, + GenericArgs::new_from_slice(subst.split_closure_args_untupled().parent_args), destination, &args[1..], locals, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs index ef2a13848ca6..ca198aa71b77 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs @@ -2147,7 +2147,7 @@ pub fn mir_body_for_closure_query<'db>( }; let resolver_guard = ctx.resolver.update_to_inner_scope(db, owner, expr); let current = ctx.lower_params_and_bindings( - args.iter().zip(sig.skip_binder().inputs().iter()).map(|(it, y)| (*it, y)), + args.iter().zip(sig.skip_binder().inputs().iter()).map(|(it, y)| (*it, *y)), None, |_| true, )?; @@ -2289,7 +2289,7 @@ pub fn lower_to_mir<'db>( if let DefWithBodyId::FunctionId(fid) = owner { let callable_sig = db.callable_item_signature(fid.into()).instantiate_identity().skip_binder(); - let mut params = callable_sig.inputs().iter(); + let mut params = callable_sig.inputs().iter().copied(); let self_param = body.self_param.and_then(|id| Some((id, params.next()?))); break 'b ctx.lower_params_and_bindings( body.params.iter().zip(params).map(|(it, y)| (*it, y)), diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs index b600f6000d9e..785d3ef65231 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs @@ -574,9 +574,8 @@ impl<'db> GenericArgs<'db> { // FIXME: should use `ClosureSubst` when possible match self.as_slice() { [parent_args @ .., closure_kind_ty, sig_ty, tupled_upvars_ty] => { - let interner = DbInterner::conjure(); rustc_type_ir::ClosureArgsParts { - parent_args: GenericArgs::new_from_iter(interner, parent_args.iter().cloned()), + parent_args, closure_sig_as_fn_ptr_ty: sig_ty.expect_ty(), closure_kind_ty: closure_kind_ty.expect_ty(), tupled_upvars_ty: tupled_upvars_ty.expect_ty(), @@ -690,7 +689,7 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< interner, TyKind::FnPtr( sig_tys.map_bound(|s| { - let inputs = Ty::new_tup_from_iter(interner, s.inputs().iter()); + let inputs = Ty::new_tup(interner, s.inputs()); let output = s.output(); FnSigTys { inputs_and_output: Tys::new_from_iter( @@ -705,7 +704,7 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< _ => unreachable!("sig_ty should be last"), }; rustc_type_ir::ClosureArgsParts { - parent_args: GenericArgs::new_from_iter(interner, parent_args.iter().cloned()), + parent_args, closure_sig_as_fn_ptr_ty: sig_ty, closure_kind_ty: closure_kind_ty.expect_ty(), tupled_upvars_ty: tupled_upvars_ty.expect_ty(), @@ -728,10 +727,7 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< tupled_upvars_ty, coroutine_captures_by_ref_ty, ] => rustc_type_ir::CoroutineClosureArgsParts { - parent_args: GenericArgs::new_from_iter( - DbInterner::conjure(), - parent_args.iter().cloned(), - ), + parent_args, closure_kind_ty: closure_kind_ty.expect_ty(), signature_parts_ty: signature_parts_ty.expect_ty(), tupled_upvars_ty: tupled_upvars_ty.expect_ty(), @@ -742,11 +738,10 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< } fn split_coroutine_args(self) -> rustc_type_ir::CoroutineArgsParts> { - let interner = DbInterner::conjure(); match self.as_slice() { [parent_args @ .., kind_ty, resume_ty, yield_ty, return_ty, tupled_upvars_ty] => { rustc_type_ir::CoroutineArgsParts { - parent_args: GenericArgs::new_from_iter(interner, parent_args.iter().cloned()), + parent_args, kind_ty: kind_ty.expect_ty(), resume_ty: resume_ty.expect_ty(), yield_ty: yield_ty.expect_ty(), diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index 6b97d110ee3e..0102c2ef6eca 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -1012,7 +1012,7 @@ impl<'db> Interner for DbInterner<'db> { type Span = Span; type GenericArgs = GenericArgs<'db>; - type GenericArgsSlice = GenericArgs<'db>; + type GenericArgsSlice = &'db [GenericArg<'db>]; type GenericArg = GenericArg<'db>; type Term = Term<'db>; @@ -1053,7 +1053,7 @@ impl<'db> Interner for DbInterner<'db> { type Ty = Ty<'db>; type Tys = Tys<'db>; - type FnInputTys = Tys<'db>; + type FnInputTys = &'db [Ty<'db>]; type ParamTy = ParamTy; type BoundTy = BoundTy; type PlaceholderTy = PlaceholderTy; @@ -1261,8 +1261,7 @@ impl<'db> Interner for DbInterner<'db> { self, args.as_slice()[0..trait_generics.own_params.len()].iter().cloned(), ); - let alias_args = - GenericArgs::new_from_iter(self, args.iter().skip(trait_generics.own_params.len())); + let alias_args = &args.as_slice()[trait_generics.own_params.len()..]; (TraitRef::new_from_args(self, trait_def_id.try_into().unwrap(), trait_args), alias_args) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs index 85534e42a823..87cba7aca8e1 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs @@ -1280,10 +1280,7 @@ impl<'db> Tys<'db> { impl<'db> rustc_type_ir::inherent::Tys> for Tys<'db> { fn inputs(self) -> as Interner>::FnInputTys { - Tys::new_from_iter( - DbInterner::conjure(), - self.as_slice().split_last().unwrap().1.iter().copied(), - ) + self.as_slice().split_last().unwrap().1 } fn output(self) -> as Interner>::Ty { diff --git a/src/tools/rust-analyzer/crates/hir/src/lib.rs b/src/tools/rust-analyzer/crates/hir/src/lib.rs index 933dd6af1d52..883f1aa26e44 100644 --- a/src/tools/rust-analyzer/crates/hir/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir/src/lib.rs @@ -2290,7 +2290,7 @@ impl Function { .inputs() .iter() .enumerate() - .map(|(idx, ty)| { + .map(|(idx, &ty)| { let ty = Type { env: environment, ty }; Param { func: Callee::Def(CallableDefId::FunctionId(self.id)), ty, idx } }) @@ -2317,7 +2317,7 @@ impl Function { .iter() .enumerate() .skip(skip) - .map(|(idx, ty)| { + .map(|(idx, &ty)| { let ty = Type { env: environment, ty }; Param { func: Callee::Def(CallableDefId::FunctionId(self.id)), ty, idx } }) @@ -2341,7 +2341,7 @@ impl Function { .iter() .enumerate() .skip(skip) - .map(|(idx, ty)| { + .map(|(idx, &ty)| { let ty = Type { env: environment, ty }; Param { func: Callee::Def(CallableDefId::FunctionId(self.id)), ty, idx } }) From dc81edaa9e8b2a0f164620acd0f0ec90a66b15b3 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Thu, 18 Dec 2025 03:18:39 +0200 Subject: [PATCH 367/489] Pre-intern some common types This is possible now that they are no longer interned with Salsa. --- .../rust-analyzer/crates/hir-ty/src/infer.rs | 113 ++------- .../crates/hir-ty/src/infer/closure.rs | 27 ++- .../hir-ty/src/infer/closure/analysis.rs | 2 +- .../crates/hir-ty/src/infer/coerce.rs | 6 +- .../crates/hir-ty/src/infer/expr.rs | 135 ++++++----- .../crates/hir-ty/src/infer/fallback.rs | 14 +- .../crates/hir-ty/src/infer/op.rs | 20 +- .../crates/hir-ty/src/infer/opaques.rs | 7 +- .../crates/hir-ty/src/infer/pat.rs | 14 +- .../crates/hir-ty/src/infer/path.rs | 2 +- .../crates/hir-ty/src/infer/place_op.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/lower.rs | 4 +- .../crates/hir-ty/src/mir/lower.rs | 8 +- .../crates/hir-ty/src/next_solver.rs | 225 ++++++++++++++++++ .../crates/hir-ty/src/next_solver/consts.rs | 6 +- .../hir-ty/src/next_solver/generic_arg.rs | 12 +- .../crates/hir-ty/src/next_solver/interner.rs | 93 ++++---- .../crates/hir-ty/src/next_solver/opaques.rs | 11 +- .../hir-ty/src/next_solver/predicate.rs | 2 + .../crates/hir-ty/src/next_solver/region.rs | 14 +- .../crates/hir-ty/src/next_solver/ty.rs | 117 +++++---- .../crates/hir-ty/src/next_solver/util.rs | 45 ++-- .../crates/hir-ty/src/variance.rs | 5 +- 23 files changed, 558 insertions(+), 326 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs index bd5fffc4cc65..4f739dc8eee0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs @@ -51,7 +51,7 @@ use rustc_ast_ir::Mutability; use rustc_hash::{FxHashMap, FxHashSet}; use rustc_type_ir::{ AliasTyKind, TypeFoldable, - inherent::{AdtDef, IntoKind, Region as _, Ty as _}, + inherent::{AdtDef, IntoKind, Ty as _}, }; use span::Edition; use stdx::never; @@ -108,23 +108,23 @@ fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult { DefWithBodyId::VariantId(v) => { ctx.return_ty = match EnumSignature::variant_body_type(db, v.lookup(db).parent) { hir_def::layout::IntegerType::Pointer(signed) => match signed { - true => ctx.types.isize, - false => ctx.types.usize, + true => ctx.types.types.isize, + false => ctx.types.types.usize, }, hir_def::layout::IntegerType::Fixed(size, signed) => match signed { true => match size { - Integer::I8 => ctx.types.i8, - Integer::I16 => ctx.types.i16, - Integer::I32 => ctx.types.i32, - Integer::I64 => ctx.types.i64, - Integer::I128 => ctx.types.i128, + Integer::I8 => ctx.types.types.i8, + Integer::I16 => ctx.types.types.i16, + Integer::I32 => ctx.types.types.i32, + Integer::I64 => ctx.types.types.i64, + Integer::I128 => ctx.types.types.i128, }, false => match size { - Integer::I8 => ctx.types.u8, - Integer::I16 => ctx.types.u16, - Integer::I32 => ctx.types.u32, - Integer::I64 => ctx.types.u64, - Integer::I128 => ctx.types.u128, + Integer::I8 => ctx.types.types.u8, + Integer::I16 => ctx.types.types.u16, + Integer::I32 => ctx.types.types.u32, + Integer::I64 => ctx.types.types.u64, + Integer::I128 => ctx.types.types.u128, }, }, }; @@ -738,75 +738,6 @@ impl InferenceResult { } } -#[derive(Debug, Clone)] -struct InternedStandardTypes<'db> { - unit: Ty<'db>, - never: Ty<'db>, - char: Ty<'db>, - bool: Ty<'db>, - i8: Ty<'db>, - i16: Ty<'db>, - i32: Ty<'db>, - i64: Ty<'db>, - i128: Ty<'db>, - isize: Ty<'db>, - u8: Ty<'db>, - u16: Ty<'db>, - u32: Ty<'db>, - u64: Ty<'db>, - u128: Ty<'db>, - usize: Ty<'db>, - f16: Ty<'db>, - f32: Ty<'db>, - f64: Ty<'db>, - f128: Ty<'db>, - static_str_ref: Ty<'db>, - error: Ty<'db>, - - re_static: Region<'db>, - re_error: Region<'db>, - re_erased: Region<'db>, - - empty_args: GenericArgs<'db>, -} - -impl<'db> InternedStandardTypes<'db> { - fn new(interner: DbInterner<'db>) -> Self { - let str = Ty::new(interner, rustc_type_ir::TyKind::Str); - let re_static = Region::new_static(interner); - Self { - unit: Ty::new_unit(interner), - never: Ty::new(interner, TyKind::Never), - char: Ty::new(interner, TyKind::Char), - bool: Ty::new(interner, TyKind::Bool), - i8: Ty::new_int(interner, rustc_type_ir::IntTy::I8), - i16: Ty::new_int(interner, rustc_type_ir::IntTy::I16), - i32: Ty::new_int(interner, rustc_type_ir::IntTy::I32), - i64: Ty::new_int(interner, rustc_type_ir::IntTy::I64), - i128: Ty::new_int(interner, rustc_type_ir::IntTy::I128), - isize: Ty::new_int(interner, rustc_type_ir::IntTy::Isize), - u8: Ty::new_uint(interner, rustc_type_ir::UintTy::U8), - u16: Ty::new_uint(interner, rustc_type_ir::UintTy::U16), - u32: Ty::new_uint(interner, rustc_type_ir::UintTy::U32), - u64: Ty::new_uint(interner, rustc_type_ir::UintTy::U64), - u128: Ty::new_uint(interner, rustc_type_ir::UintTy::U128), - usize: Ty::new_uint(interner, rustc_type_ir::UintTy::Usize), - f16: Ty::new_float(interner, rustc_type_ir::FloatTy::F16), - f32: Ty::new_float(interner, rustc_type_ir::FloatTy::F32), - f64: Ty::new_float(interner, rustc_type_ir::FloatTy::F64), - f128: Ty::new_float(interner, rustc_type_ir::FloatTy::F128), - static_str_ref: Ty::new_ref(interner, re_static, str, Mutability::Not), - error: Ty::new_error(interner, ErrorGuaranteed), - - re_static, - re_error: Region::error(interner), - re_erased: Region::new_erased(interner), - - empty_args: GenericArgs::empty(interner), - } - } -} - /// The inference context contains all information needed during type inference. #[derive(Clone, Debug)] pub(crate) struct InferenceContext<'body, 'db> { @@ -841,7 +772,7 @@ pub(crate) struct InferenceContext<'body, 'db> { resume_yield_tys: Option<(Ty<'db>, Ty<'db>)>, diverges: Diverges, breakables: Vec>, - types: InternedStandardTypes<'db>, + types: &'db crate::next_solver::DefaultAny<'db>, /// Whether we are inside the pattern of a destructuring assignment. inside_assignment: bool, @@ -918,10 +849,10 @@ impl<'body, 'db> InferenceContext<'body, 'db> { ) -> Self { let trait_env = db.trait_environment_for_body(owner); let table = unify::InferenceTable::new(db, trait_env, resolver.krate(), Some(owner)); - let types = InternedStandardTypes::new(table.interner()); + let types = crate::next_solver::default_types(db); InferenceContext { - result: InferenceResult::new(types.error), - return_ty: types.error, // set in collect_* calls + result: InferenceResult::new(types.types.error), + return_ty: types.types.error, // set in collect_* calls types, target_features: OnceCell::new(), unstable_features: MethodResolutionUnstableFeatures::from_def_map( @@ -1153,7 +1084,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { data.type_ref, &data.store, InferenceTyDiagnosticSource::Signature, - LifetimeElisionKind::Elided(self.types.re_static), + LifetimeElisionKind::Elided(self.types.regions.statik), ); self.return_ty = return_ty; @@ -1211,7 +1142,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { ); self.process_user_written_ty(return_ty) } - None => self.types.unit, + None => self.types.types.unit, }; self.return_coercion = Some(CoerceMany::new(self.return_ty)); @@ -1408,7 +1339,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { } fn err_ty(&self) -> Ty<'db> { - self.types.error + self.types.types.error } pub(crate) fn make_body_lifetime(&mut self, lifetime_ref: LifetimeRefId) -> Region<'db> { @@ -1573,7 +1504,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { if let Err(_err) = result { // FIXME: Emit diagnostic. } - result.unwrap_or(self.types.error) + result.unwrap_or(self.types.types.error) } fn expr_ty(&self, expr: ExprId) -> Ty<'db> { @@ -1805,7 +1736,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> { result } else { // FIXME diagnostic - (ctx.types.error, None) + (ctx.types.types.error, None) } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs index 82912017c3e4..19ffa3a9398a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs @@ -22,9 +22,8 @@ use crate::{ db::{InternedClosure, InternedCoroutine}, infer::{BreakableKind, Diverges, coerce::CoerceMany}, next_solver::{ - AliasTy, Binder, BoundRegionKind, BoundVarKind, BoundVarKinds, ClauseKind, DbInterner, - ErrorGuaranteed, FnSig, GenericArgs, PolyFnSig, PolyProjectionPredicate, Predicate, - PredicateKind, SolverDefId, Ty, TyKind, + AliasTy, Binder, ClauseKind, DbInterner, ErrorGuaranteed, FnSig, GenericArgs, PolyFnSig, + PolyProjectionPredicate, Predicate, PredicateKind, SolverDefId, Ty, TyKind, abi::Safety, infer::{ BoundRegionConversionTime, InferOk, InferResult, @@ -73,16 +72,17 @@ impl<'db> InferenceContext<'_, 'db> { let parent_args = GenericArgs::identity_for_item(interner, self.generic_def.into()); // FIXME: Make this an infer var and infer it later. - let tupled_upvars_ty = self.types.unit; + let tupled_upvars_ty = self.types.types.unit; let (id, ty, resume_yield_tys) = match closure_kind { ClosureKind::Coroutine(_) => { let yield_ty = self.table.next_ty_var(); - let resume_ty = liberated_sig.inputs().first().copied().unwrap_or(self.types.unit); + let resume_ty = + liberated_sig.inputs().first().copied().unwrap_or(self.types.types.unit); // FIXME: Infer the upvars later. let parts = CoroutineArgsParts { parent_args: parent_args.as_slice(), - kind_ty: self.types.unit, + kind_ty: self.types.types.unit, resume_ty, yield_ty, return_ty: body_ret_ty, @@ -140,9 +140,9 @@ impl<'db> InferenceContext<'_, 'db> { // async closures always return the type ascribed after the `->` (if present), // and yield `()`. let bound_return_ty = bound_sig.skip_binder().output(); - let bound_yield_ty = self.types.unit; + let bound_yield_ty = self.types.types.unit; // rustc uses a special lang item type for the resume ty. I don't believe this can cause us problems. - let resume_ty = self.types.unit; + let resume_ty = self.types.types.unit; // FIXME: Infer the kind later if needed. let closure_kind_ty = Ty::from_closure_kind( @@ -155,11 +155,14 @@ impl<'db> InferenceContext<'_, 'db> { let coroutine_captures_by_ref_ty = Ty::new_fn_ptr( interner, Binder::bind_with_vars( - interner.mk_fn_sig([], self.types.unit, false, Safety::Safe, FnAbi::Rust), - BoundVarKinds::new_from_iter( - interner, - [BoundVarKind::Region(BoundRegionKind::ClosureEnv)], + interner.mk_fn_sig( + [], + self.types.types.unit, + false, + Safety::Safe, + FnAbi::Rust, ), + self.types.coroutine_captures_by_ref_bound_var_kinds, ), ); let closure_args = CoroutineClosureArgs::new( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs index a7369d606da4..5b0360071d9d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/closure/analysis.rs @@ -289,7 +289,7 @@ impl CapturedItemWithoutTy { BorrowKind::Mut { .. } => Mutability::Mut, _ => Mutability::Not, }; - Ty::new_ref(ctx.interner(), ctx.types.re_error, ty, m) + Ty::new_ref(ctx.interner(), ctx.types.regions.error, ty, m) } }; CapturedItem { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs index 1233543c40f5..bb9cb1c1ca09 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs @@ -1397,7 +1397,7 @@ impl<'db, 'exprs> CoerceMany<'db, 'exprs> { icx, cause, expr, - icx.types.unit, + icx.types.types.unit, true, label_unit_as_expected, expr_is_read, @@ -1512,7 +1512,7 @@ impl<'db, 'exprs> CoerceMany<'db, 'exprs> { // emit or provide suggestions on how to fix the initial error. icx.set_tainted_by_errors(); - self.final_ty = Some(icx.types.error); + self.final_ty = Some(icx.types.types.error); icx.result.type_mismatches.get_or_insert_default().insert( expression.into(), @@ -1535,7 +1535,7 @@ impl<'db, 'exprs> CoerceMany<'db, 'exprs> { // If we only had inputs that were of type `!` (or no // inputs at all), then the final type is `!`. assert_eq!(self.pushed, 0); - icx.types.never + icx.types.types.never } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs index 4d3ca94b22f8..ae69e5176ae5 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs @@ -319,7 +319,7 @@ impl<'db> InferenceContext<'_, 'db> { let expected = &expected.adjust_for_branches(&mut self.table); self.infer_expr_coerce_never( condition, - &Expectation::HasType(self.types.bool), + &Expectation::HasType(self.types.types.bool), ExprIsRead::Yes, ); @@ -375,7 +375,7 @@ impl<'db> InferenceContext<'_, 'db> { input_ty, Some(DeclContext { origin: DeclOrigin::LetExpr }), ); - self.types.bool + self.types.types.bool } Expr::Block { statements, tail, label, id: _ } => { self.infer_block(tgt_expr, statements, *tail, *label, expected) @@ -400,7 +400,7 @@ impl<'db> InferenceContext<'_, 'db> { self.with_breakable_ctx(BreakableKind::Loop, Some(ty), label, |this| { this.infer_expr( body, - &Expectation::HasType(this.types.unit), + &Expectation::HasType(this.types.types.unit), ExprIsRead::Yes, ); }); @@ -410,7 +410,7 @@ impl<'db> InferenceContext<'_, 'db> { self.diverges = Diverges::Maybe; breaks } - None => self.types.never, + None => self.types.types.never, } } Expr::Closure { body, args, ret_type, arg_types, closure_kind, capture_by: _ } => self @@ -451,7 +451,7 @@ impl<'db> InferenceContext<'_, 'db> { if arms.is_empty() { self.diverges = Diverges::Always; - self.types.never + self.types.types.never } else { let matchee_diverges = mem::replace(&mut self.diverges, Diverges::Maybe); let mut all_arms_diverge = Diverges::Always; @@ -463,7 +463,7 @@ impl<'db> InferenceContext<'_, 'db> { let result_ty = match &expected { // We don't coerce to `()` so that if the match expression is a // statement it's branches can have any consistent type. - Expectation::HasType(ty) if *ty != self.types.unit => *ty, + Expectation::HasType(ty) if *ty != self.types.types.unit => *ty, _ => self.table.next_ty_var(), }; let mut coerce = CoerceMany::new(result_ty); @@ -473,7 +473,7 @@ impl<'db> InferenceContext<'_, 'db> { self.diverges = Diverges::Maybe; self.infer_expr_coerce_never( guard_expr, - &Expectation::HasType(self.types.bool), + &Expectation::HasType(self.types.types.bool), ExprIsRead::Yes, ); } @@ -504,7 +504,7 @@ impl<'db> InferenceContext<'_, 'db> { bad_value_break: false, }); }; - self.types.never + self.types.types.never } &Expr::Break { expr, label } => { let val_ty = if let Some(expr) = expr { @@ -528,7 +528,7 @@ impl<'db> InferenceContext<'_, 'db> { ExprIsRead::Yes, ) } else { - self.types.unit + self.types.types.unit }; match find_breakable(&mut self.breakables, label) { @@ -558,7 +558,7 @@ impl<'db> InferenceContext<'_, 'db> { }); } } - self.types.never + self.types.types.never } &Expr::Return { expr } => self.infer_expr_return(tgt_expr, expr), &Expr::Become { expr } => self.infer_expr_become(expr), @@ -571,7 +571,7 @@ impl<'db> InferenceContext<'_, 'db> { ExprIsRead::Yes, ); } else { - let unit = self.types.unit; + let unit = self.types.types.unit; let _ = self.coerce( tgt_expr.into(), unit, @@ -583,14 +583,14 @@ impl<'db> InferenceContext<'_, 'db> { resume_ty } else { // FIXME: report error (yield expr in non-coroutine) - self.types.error + self.types.types.error } } Expr::Yeet { expr } => { if let &Some(expr) = expr { self.infer_expr_no_expect(expr, ExprIsRead::Yes); } - self.types.never + self.types.types.never } Expr::RecordLit { path, fields, spread, .. } => { let (ty, def_id) = self.resolve_variant(tgt_expr.into(), path.as_deref(), false); @@ -599,7 +599,7 @@ impl<'db> InferenceContext<'_, 'db> { self.unify(ty, t); } - let substs = ty.as_adt().map(|(_, s)| s).unwrap_or(self.types.empty_args); + let substs = ty.as_adt().map(|(_, s)| s).unwrap_or(self.types.empty.generic_args); if let Some(variant) = def_id { self.write_variant_resolution(tgt_expr.into(), variant); } @@ -768,7 +768,7 @@ impl<'db> InferenceContext<'_, 'db> { // assignments into blocks. self.table.new_maybe_never_var() } else { - self.types.unit + self.types.types.unit } } Expr::Range { lhs, rhs, range_type } => { @@ -785,7 +785,9 @@ impl<'db> InferenceContext<'_, 'db> { }; match (range_type, lhs_ty, rhs_ty) { (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { - Some(adt) => Ty::new_adt(self.interner(), adt, self.types.empty_args), + Some(adt) => { + Ty::new_adt(self.interner(), adt, self.types.empty.generic_args) + } None => self.err_ty(), }, (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { @@ -834,7 +836,7 @@ impl<'db> InferenceContext<'_, 'db> { trait_element_ty } // FIXME: Report an error. - None => self.types.error, + None => self.types.types.error, } } Expr::Tuple { exprs, .. } => { @@ -859,10 +861,10 @@ impl<'db> InferenceContext<'_, 'db> { } Expr::Array(array) => self.infer_expr_array(array, expected), Expr::Literal(lit) => match lit { - Literal::Bool(..) => self.types.bool, - Literal::String(..) => self.types.static_str_ref, + Literal::Bool(..) => self.types.types.bool, + Literal::String(..) => self.types.types.static_str_ref, Literal::ByteString(bs) => { - let byte_type = self.types.u8; + let byte_type = self.types.types.u8; let len = consteval::usize_const( self.db, @@ -871,35 +873,46 @@ impl<'db> InferenceContext<'_, 'db> { ); let array_type = Ty::new_array_with_const_len(self.interner(), byte_type, len); - Ty::new_ref(self.interner(), self.types.re_static, array_type, Mutability::Not) + Ty::new_ref( + self.interner(), + self.types.regions.statik, + array_type, + Mutability::Not, + ) } Literal::CString(..) => Ty::new_ref( self.interner(), - self.types.re_static, + self.types.regions.statik, self.lang_items.CStr.map_or_else( || self.err_ty(), - |strukt| Ty::new_adt(self.interner(), strukt.into(), self.types.empty_args), + |strukt| { + Ty::new_adt( + self.interner(), + strukt.into(), + self.types.empty.generic_args, + ) + }, ), Mutability::Not, ), - Literal::Char(..) => self.types.char, + Literal::Char(..) => self.types.types.char, Literal::Int(_v, ty) => match ty { Some(int_ty) => match int_ty { - hir_def::builtin_type::BuiltinInt::Isize => self.types.isize, - hir_def::builtin_type::BuiltinInt::I8 => self.types.i8, - hir_def::builtin_type::BuiltinInt::I16 => self.types.i16, - hir_def::builtin_type::BuiltinInt::I32 => self.types.i32, - hir_def::builtin_type::BuiltinInt::I64 => self.types.i64, - hir_def::builtin_type::BuiltinInt::I128 => self.types.i128, + hir_def::builtin_type::BuiltinInt::Isize => self.types.types.isize, + hir_def::builtin_type::BuiltinInt::I8 => self.types.types.i8, + hir_def::builtin_type::BuiltinInt::I16 => self.types.types.i16, + hir_def::builtin_type::BuiltinInt::I32 => self.types.types.i32, + hir_def::builtin_type::BuiltinInt::I64 => self.types.types.i64, + hir_def::builtin_type::BuiltinInt::I128 => self.types.types.i128, }, None => { let expected_ty = expected.to_option(&mut self.table); tracing::debug!(?expected_ty); let opt_ty = match expected_ty.as_ref().map(|it| it.kind()) { Some(TyKind::Int(_) | TyKind::Uint(_)) => expected_ty, - Some(TyKind::Char) => Some(self.types.u8), + Some(TyKind::Char) => Some(self.types.types.u8), Some(TyKind::RawPtr(..) | TyKind::FnDef(..) | TyKind::FnPtr(..)) => { - Some(self.types.usize) + Some(self.types.types.usize) } _ => None, }; @@ -908,20 +921,20 @@ impl<'db> InferenceContext<'_, 'db> { }, Literal::Uint(_v, ty) => match ty { Some(int_ty) => match int_ty { - hir_def::builtin_type::BuiltinUint::Usize => self.types.usize, - hir_def::builtin_type::BuiltinUint::U8 => self.types.u8, - hir_def::builtin_type::BuiltinUint::U16 => self.types.u16, - hir_def::builtin_type::BuiltinUint::U32 => self.types.u32, - hir_def::builtin_type::BuiltinUint::U64 => self.types.u64, - hir_def::builtin_type::BuiltinUint::U128 => self.types.u128, + hir_def::builtin_type::BuiltinUint::Usize => self.types.types.usize, + hir_def::builtin_type::BuiltinUint::U8 => self.types.types.u8, + hir_def::builtin_type::BuiltinUint::U16 => self.types.types.u16, + hir_def::builtin_type::BuiltinUint::U32 => self.types.types.u32, + hir_def::builtin_type::BuiltinUint::U64 => self.types.types.u64, + hir_def::builtin_type::BuiltinUint::U128 => self.types.types.u128, }, None => { let expected_ty = expected.to_option(&mut self.table); let opt_ty = match expected_ty.as_ref().map(|it| it.kind()) { Some(TyKind::Int(_) | TyKind::Uint(_)) => expected_ty, - Some(TyKind::Char) => Some(self.types.u8), + Some(TyKind::Char) => Some(self.types.types.u8), Some(TyKind::RawPtr(..) | TyKind::FnDef(..) | TyKind::FnPtr(..)) => { - Some(self.types.usize) + Some(self.types.types.usize) } _ => None, }; @@ -930,10 +943,10 @@ impl<'db> InferenceContext<'_, 'db> { }, Literal::Float(_v, ty) => match ty { Some(float_ty) => match float_ty { - hir_def::builtin_type::BuiltinFloat::F16 => self.types.f16, - hir_def::builtin_type::BuiltinFloat::F32 => self.types.f32, - hir_def::builtin_type::BuiltinFloat::F64 => self.types.f64, - hir_def::builtin_type::BuiltinFloat::F128 => self.types.f128, + hir_def::builtin_type::BuiltinFloat::F16 => self.types.types.f16, + hir_def::builtin_type::BuiltinFloat::F32 => self.types.types.f32, + hir_def::builtin_type::BuiltinFloat::F64 => self.types.types.f64, + hir_def::builtin_type::BuiltinFloat::F128 => self.types.types.f128, }, None => { let opt_ty = expected @@ -953,7 +966,7 @@ impl<'db> InferenceContext<'_, 'db> { }); expected } - Expr::OffsetOf(_) => self.types.usize, + Expr::OffsetOf(_) => self.types.types.usize, Expr::InlineAsm(asm) => { let check_expr_asm_operand = |this: &mut Self, expr, is_input: bool| { let ty = this.infer_expr_no_expect(expr, ExprIsRead::Yes); @@ -1014,7 +1027,7 @@ impl<'db> InferenceContext<'_, 'db> { AsmOperand::Label(expr) => { self.infer_expr( expr, - &Expectation::HasType(self.types.unit), + &Expectation::HasType(self.types.types.unit), ExprIsRead::No, ); } @@ -1024,7 +1037,7 @@ impl<'db> InferenceContext<'_, 'db> { // FIXME: `sym` should report for things that are not functions or statics. AsmOperand::Sym(_) => (), }); - if diverge { self.types.never } else { self.types.unit } + if diverge { self.types.types.never } else { self.types.types.unit } } }; // use a new type variable if we got unknown here @@ -1146,7 +1159,7 @@ impl<'db> InferenceContext<'_, 'db> { oprnd_t = ty; } else { // FIXME: Report an error. - oprnd_t = self.types.error; + oprnd_t = self.types.types.error; } } UnaryOp::Not => { @@ -1220,13 +1233,13 @@ impl<'db> InferenceContext<'_, 'db> { self.interner(), CoroutineArgsParts { parent_args: parent_args.as_slice(), - kind_ty: self.types.unit, + kind_ty: self.types.types.unit, // rustc uses a special lang item type for the resume ty. I don't believe this can cause us problems. - resume_ty: self.types.unit, - yield_ty: self.types.unit, + resume_ty: self.types.types.unit, + yield_ty: self.types.types.unit, return_ty: inner_ty, // FIXME: Infer upvars. - tupled_upvars_ty: self.types.unit, + tupled_upvars_ty: self.types.types.unit, }, ) .args, @@ -1333,7 +1346,7 @@ impl<'db> InferenceContext<'_, 'db> { &Expectation::has_type(elem_ty), ExprIsRead::Yes, ); - let usize = self.types.usize; + let usize = self.types.types.usize; let len = match self.body[repeat] { Expr::Underscore => { self.write_expr_ty(repeat, usize); @@ -1390,7 +1403,7 @@ impl<'db> InferenceContext<'_, 'db> { } } } - self.types.never + self.types.types.never } fn infer_expr_become(&mut self, expr: ExprId) -> Ty<'db> { @@ -1411,7 +1424,7 @@ impl<'db> InferenceContext<'_, 'db> { } } - self.types.never + self.types.types.never } fn infer_expr_box(&mut self, inner_expr: ExprId, expected: &Expectation<'db>) -> Ty<'db> { @@ -1502,7 +1515,7 @@ impl<'db> InferenceContext<'_, 'db> { mem::replace(&mut this.diverges, Diverges::Maybe); this.infer_expr_coerce( *expr, - &Expectation::HasType(this.types.never), + &Expectation::HasType(this.types.types.never), ExprIsRead::Yes, ); this.diverges = previous_diverges; @@ -1514,7 +1527,7 @@ impl<'db> InferenceContext<'_, 'db> { } else { this.infer_expr_coerce( expr, - &Expectation::HasType(this.types.unit), + &Expectation::HasType(this.types.types.unit), ExprIsRead::Yes, ); } @@ -1541,7 +1554,7 @@ impl<'db> InferenceContext<'_, 'db> { if this .coerce( expr.into(), - this.types.unit, + this.types.types.unit, t, AllowTwoPhase::No, ExprIsRead::Yes, @@ -1552,13 +1565,13 @@ impl<'db> InferenceContext<'_, 'db> { expr.into(), TypeMismatch { expected: t.store(), - actual: this.types.unit.store(), + actual: this.types.types.unit.store(), }, ); } t } else { - this.types.unit + this.types.types.unit } } }); @@ -1927,7 +1940,7 @@ impl<'db> InferenceContext<'_, 'db> { let (formal_receiver_ty, param_tys) = if !sig.inputs_and_output.inputs().is_empty() { (sig.inputs_and_output.as_slice()[0], &sig.inputs_and_output.inputs()[1..]) } else { - (self.types.error, &[] as _) + (self.types.types.error, &[] as _) }; let ret_ty = sig.output(); self.table.unify(formal_receiver_ty, receiver_ty); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/fallback.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/fallback.rs index d0ce8cba7a88..c7669b346fe8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/fallback.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/fallback.rs @@ -151,8 +151,8 @@ impl<'db> InferenceContext<'_, 'db> { // type, `?T` is not considered unsolved, but `?I` is. The // same is true for float variables.) let fallback = match ty.kind() { - TyKind::Infer(rustc_type_ir::IntVar(_)) => self.types.i32, - TyKind::Infer(rustc_type_ir::FloatVar(_)) => self.types.f64, + TyKind::Infer(rustc_type_ir::IntVar(_)) => self.types.types.i32, + TyKind::Infer(rustc_type_ir::FloatVar(_)) => self.types.types.f64, _ => match diverging_fallback.get(&ty) { Some(&fallback_ty) => fallback_ty, None => return false, @@ -337,7 +337,7 @@ impl<'db> InferenceContext<'_, 'db> { match behavior { DivergingFallbackBehavior::ToUnit => { debug!("fallback to () - legacy: {:?}", diverging_vid); - fallback_to(self.types.unit); + fallback_to(self.types.types.unit); } DivergingFallbackBehavior::ContextDependent => { // FIXME: rustc does the following, but given this is only relevant when the unstable @@ -368,14 +368,14 @@ impl<'db> InferenceContext<'_, 'db> { // // set, see the relationship finding module in // // compiler/rustc_trait_selection/src/traits/relationships.rs. // debug!("fallback to () - found trait and projection: {:?}", diverging_vid); - // fallback_to(self.types.unit); + // fallback_to(self.types.types.unit); // } if can_reach_non_diverging { debug!("fallback to () - reached non-diverging: {:?}", diverging_vid); - fallback_to(self.types.unit); + fallback_to(self.types.types.unit); } else { debug!("fallback to ! - all diverging: {:?}", diverging_vid); - fallback_to(self.types.never); + fallback_to(self.types.types.never); } } DivergingFallbackBehavior::ToNever => { @@ -383,7 +383,7 @@ impl<'db> InferenceContext<'_, 'db> { "fallback to ! - `rustc_never_type_mode = \"fallback_to_never\")`: {:?}", diverging_vid ); - fallback_to(self.types.never); + fallback_to(self.types.types.never); } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs index c61b6c9ae53d..c79c828cd442 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/op.rs @@ -39,7 +39,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { && is_builtin_binop(lhs_ty, rhs_ty, category) { self.enforce_builtin_binop_types(lhs_ty, rhs_ty, category); - self.types.unit + self.types.types.unit } else { return_ty }; @@ -67,20 +67,20 @@ impl<'a, 'db> InferenceContext<'a, 'db> { // && and || are a simple case. self.infer_expr_coerce( lhs_expr, - &Expectation::HasType(self.types.bool), + &Expectation::HasType(self.types.types.bool), ExprIsRead::Yes, ); let lhs_diverges = self.diverges; self.infer_expr_coerce( rhs_expr, - &Expectation::HasType(self.types.bool), + &Expectation::HasType(self.types.types.bool), ExprIsRead::Yes, ); // Depending on the LHS' value, the RHS can never execute. self.diverges = lhs_diverges; - self.types.bool + self.types.types.bool } _ => { // Otherwise, we always treat operators as if they are @@ -131,9 +131,9 @@ impl<'a, 'db> InferenceContext<'a, 'db> { match category { BinOpCategory::Shortcircuit => { - self.demand_suptype(self.types.bool, lhs_ty); - self.demand_suptype(self.types.bool, rhs_ty); - self.types.bool + self.demand_suptype(self.types.types.bool, lhs_ty); + self.demand_suptype(self.types.types.bool, rhs_ty); + self.types.types.bool } BinOpCategory::Shift => { @@ -150,7 +150,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { BinOpCategory::Comparison => { // both LHS and RHS and result will have the same type self.demand_suptype(lhs_ty, rhs_ty); - self.types.bool + self.types.types.bool } } } @@ -251,7 +251,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { } Err(_errors) => { // FIXME: Report diagnostic. - self.types.error + self.types.types.error } }; @@ -271,7 +271,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { } Err(_errors) => { // FIXME: Report diagnostic. - self.types.error + self.types.types.error } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs index 1c722897f47b..a39288721b3e 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/opaques.rs @@ -117,7 +117,7 @@ impl<'db> InferenceContext<'_, 'db> { continue; } - self.result.type_of_opaque.insert(def_id, self.types.error.store()); + self.result.type_of_opaque.insert(def_id, self.types.types.error.store()); } } @@ -139,9 +139,10 @@ impl<'db> InferenceContext<'_, 'db> { let at = self.table.infer_ctxt.at(&cause, self.table.param_env); let hidden_type = match at.deeply_normalize(hidden_type) { Ok(hidden_type) => hidden_type, - Err(_errors) => OpaqueHiddenType { ty: self.types.error }, + Err(_errors) => OpaqueHiddenType { ty: self.types.types.error }, }; - let hidden_type = fold_regions(self.interner(), hidden_type, |_, _| self.types.re_erased); + let hidden_type = + fold_regions(self.interner(), hidden_type, |_, _| self.types.regions.erased); UsageKind::HasDefiningUse(hidden_type) } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs index 5eddd4102ba7..1b8ce5ceaf86 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs @@ -234,7 +234,7 @@ impl<'db> InferenceContext<'_, 'db> { } if let Some(uncovered) = elements.get(element_tys.len()..) { for &elem in uncovered { - self.infer_pat(elem, self.types.error, default_bm, decl); + self.infer_pat(elem, self.types.types.error, default_bm, decl); } } pat_ty @@ -375,7 +375,7 @@ impl<'db> InferenceContext<'_, 'db> { Some((adt, subst)) if adt == box_adt => { (subst.type_at(0), subst.as_slice().get(1).and_then(|a| a.as_type())) } - _ => (self.types.error, None), + _ => (self.types.types.error, None), }; let inner_ty = self.infer_pat(*inner, inner_ty, default_bm, decl); @@ -574,10 +574,14 @@ impl<'db> InferenceContext<'_, 'db> { { let inner = self.table.try_structurally_resolve_type(inner); if matches!(inner.kind(), TyKind::Slice(_)) { - let elem_ty = self.types.u8; + let elem_ty = self.types.types.u8; let slice_ty = Ty::new_slice(self.interner(), elem_ty); - let ty = - Ty::new_ref(self.interner(), self.types.re_static, slice_ty, Mutability::Not); + let ty = Ty::new_ref( + self.interner(), + self.types.regions.statik, + slice_ty, + Mutability::Not, + ); self.write_expr_ty(expr, ty); return ty; } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs index a323952494c0..69e6b40a091a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs @@ -102,7 +102,7 @@ impl<'db> InferenceContext<'_, 'db> { // This is something like `TypeAlias::::EnumVariant`. Do not call `substs_from_path()`, // as it'll try to re-lower the previous segment assuming it refers to the enum, but it refers // to the type alias and they may have different generics. - self.types.empty_args + self.types.empty.generic_args } else { self.with_body_ty_lowering(|ctx| { let mut path_ctx = ctx.at_path(path, id); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs index 5bcae21aa11b..1298b3809703 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/place_op.rs @@ -125,7 +125,7 @@ impl<'a, 'db> InferenceContext<'a, 'db> { ctx.interner(), ObligationCause::new(), ctx.table.param_env, - ClauseKind::ConstArgHasType(ct, ctx.types.usize), + ClauseKind::ConstArgHasType(ct, ctx.types.types.usize), )); self_ty = Ty::new_slice(ctx.interner(), element_ty); } else { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs index 50f808affa99..7c38c83628fa 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs @@ -170,6 +170,7 @@ impl<'db> LifetimeElisionKind<'db> { pub struct TyLoweringContext<'db, 'a> { pub db: &'db dyn HirDatabase, interner: DbInterner<'db>, + types: &'db crate::next_solver::DefaultAny<'db>, lang_items: &'db LangItems, resolver: &'a Resolver<'db>, store: &'a ExpressionStore, @@ -201,6 +202,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { db, // Can provide no block since we don't use it for trait solving. interner, + types: crate::next_solver::default_types(db), lang_items: interner.lang_items(), resolver, def, @@ -399,7 +401,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> { let type_ref = &self.store[type_ref_id]; tracing::debug!(?type_ref); let ty = match type_ref { - TypeRef::Never => Ty::new(interner, TyKind::Never), + TypeRef::Never => self.types.types.never, TypeRef::Tuple(inner) => { let inner_tys = inner.iter().map(|&tr| self.lower_ty(tr)); Ty::new_tup_from_iter(interner, inner_tys) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs index ca198aa71b77..e8d42bed9fa7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs @@ -80,6 +80,7 @@ struct MirLowerCtx<'a, 'db> { db: &'db dyn HirDatabase, body: &'a Body, infer: &'a InferenceResult, + types: &'db crate::next_solver::DefaultAny<'db>, resolver: Resolver<'db>, drop_scopes: Vec, env: ParamEnv<'db>, @@ -312,6 +313,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { db, infer, body, + types: crate::next_solver::default_types(db), owner, resolver, current_loop_blocks: None, @@ -369,11 +371,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { match adjustments.split_last() { Some((last, rest)) => match &last.kind { Adjust::NeverToAny => { - let temp = self.temp( - Ty::new(self.interner(), TyKind::Never), - current, - MirSpan::Unknown, - )?; + let temp = self.temp(self.types.types.never, current, MirSpan::Unknown)?; self.lower_expr_to_place_with_adjust(expr_id, temp.into(), current, rest) } Adjust::Deref(_) => { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs index e91864bd8759..298af7d12411 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs @@ -26,6 +26,8 @@ mod structural_normalize; mod ty; pub mod util; +use std::{mem::ManuallyDrop, sync::OnceLock}; + pub use binder::*; pub use consts::*; pub use def_id::*; @@ -37,6 +39,7 @@ pub use region::*; pub use solver::*; pub use ty::*; +use crate::db::HirDatabase; pub use crate::lower::ImplTraitIdx; pub use rustc_ast_ir::Mutability; @@ -53,3 +56,225 @@ pub type TypingMode<'db> = rustc_type_ir::TypingMode>; pub type TypeError<'db> = rustc_type_ir::error::TypeError>; pub type QueryResult<'db> = rustc_type_ir::solve::QueryResult>; pub type FxIndexMap = rustc_type_ir::data_structures::IndexMap; + +pub struct DefaultTypes<'db> { + pub usize: Ty<'db>, + pub u8: Ty<'db>, + pub u16: Ty<'db>, + pub u32: Ty<'db>, + pub u64: Ty<'db>, + pub u128: Ty<'db>, + pub isize: Ty<'db>, + pub i8: Ty<'db>, + pub i16: Ty<'db>, + pub i32: Ty<'db>, + pub i64: Ty<'db>, + pub i128: Ty<'db>, + pub f16: Ty<'db>, + pub f32: Ty<'db>, + pub f64: Ty<'db>, + pub f128: Ty<'db>, + pub unit: Ty<'db>, + pub bool: Ty<'db>, + pub char: Ty<'db>, + pub str: Ty<'db>, + pub never: Ty<'db>, + pub error: Ty<'db>, + /// `&'static str` + pub static_str_ref: Ty<'db>, + /// `*mut ()` + pub mut_unit_ptr: Ty<'db>, +} + +pub struct DefaultConsts<'db> { + pub error: Const<'db>, +} + +pub struct DefaultRegions<'db> { + pub error: Region<'db>, + pub statik: Region<'db>, + pub erased: Region<'db>, +} + +pub struct DefaultEmpty<'db> { + pub tys: Tys<'db>, + pub generic_args: GenericArgs<'db>, + pub bound_var_kinds: BoundVarKinds<'db>, + pub canonical_vars: CanonicalVars<'db>, + pub variances: VariancesOf<'db>, + pub pat_list: PatList<'db>, + pub predefined_opaques: PredefinedOpaques<'db>, + pub def_ids: SolverDefIds<'db>, + pub bound_existential_predicates: BoundExistentialPredicates<'db>, + pub clauses: Clauses<'db>, + pub region_assumptions: RegionAssumptions<'db>, +} + +pub struct DefaultAny<'db> { + pub types: DefaultTypes<'db>, + pub consts: DefaultConsts<'db>, + pub regions: DefaultRegions<'db>, + pub empty: DefaultEmpty<'db>, + /// `[Invariant]` + pub one_invariant: VariancesOf<'db>, + /// `[Covariant]` + pub one_covariant: VariancesOf<'db>, + /// `for<'env>` + pub coroutine_captures_by_ref_bound_var_kinds: BoundVarKinds<'db>, +} + +impl std::fmt::Debug for DefaultAny<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("DefaultAny").finish_non_exhaustive() + } +} + +#[inline] +pub fn default_types<'a, 'db>(db: &'db dyn HirDatabase) -> &'a DefaultAny<'db> { + static TYPES: OnceLock> = OnceLock::new(); + + let interner = DbInterner::new_no_crate(db); + TYPES.get_or_init(|| { + let create_ty = |kind| { + let ty = Ty::new(interner, kind); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_const = |kind| { + let ty = Const::new(interner, kind); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_region = |kind| { + let ty = Region::new(interner, kind); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_generic_args = |slice| { + let ty = GenericArgs::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_bound_var_kinds = |slice| { + let ty = BoundVarKinds::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_canonical_vars = |slice| { + let ty = CanonicalVars::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_variances_of = |slice| { + let ty = VariancesOf::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_pat_list = |slice| { + let ty = PatList::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_predefined_opaques = |slice| { + let ty = PredefinedOpaques::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_solver_def_ids = |slice| { + let ty = SolverDefIds::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_bound_existential_predicates = |slice| { + let ty = BoundExistentialPredicates::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_clauses = |slice| { + let ty = Clauses::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_region_assumptions = |slice| { + let ty = RegionAssumptions::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + let create_tys = |slice| { + let ty = Tys::new_from_slice(slice); + // We need to increase the refcount (forever), so that the types won't be freed. + let ty = ManuallyDrop::new(ty.store()); + ty.as_ref() + }; + + let str = create_ty(TyKind::Str); + let statik = create_region(RegionKind::ReStatic); + let empty_tys = create_tys(&[]); + let unit = create_ty(TyKind::Tuple(empty_tys)); + DefaultAny { + types: DefaultTypes { + usize: create_ty(TyKind::Uint(rustc_ast_ir::UintTy::Usize)), + u8: create_ty(TyKind::Uint(rustc_ast_ir::UintTy::U8)), + u16: create_ty(TyKind::Uint(rustc_ast_ir::UintTy::U16)), + u32: create_ty(TyKind::Uint(rustc_ast_ir::UintTy::U32)), + u64: create_ty(TyKind::Uint(rustc_ast_ir::UintTy::U64)), + u128: create_ty(TyKind::Uint(rustc_ast_ir::UintTy::U128)), + isize: create_ty(TyKind::Int(rustc_ast_ir::IntTy::Isize)), + i8: create_ty(TyKind::Int(rustc_ast_ir::IntTy::I8)), + i16: create_ty(TyKind::Int(rustc_ast_ir::IntTy::I16)), + i32: create_ty(TyKind::Int(rustc_ast_ir::IntTy::I32)), + i64: create_ty(TyKind::Int(rustc_ast_ir::IntTy::I64)), + i128: create_ty(TyKind::Int(rustc_ast_ir::IntTy::I128)), + f16: create_ty(TyKind::Float(rustc_ast_ir::FloatTy::F16)), + f32: create_ty(TyKind::Float(rustc_ast_ir::FloatTy::F32)), + f64: create_ty(TyKind::Float(rustc_ast_ir::FloatTy::F64)), + f128: create_ty(TyKind::Float(rustc_ast_ir::FloatTy::F128)), + unit, + bool: create_ty(TyKind::Bool), + char: create_ty(TyKind::Char), + str, + never: create_ty(TyKind::Never), + error: create_ty(TyKind::Error(ErrorGuaranteed)), + static_str_ref: create_ty(TyKind::Ref(statik, str, rustc_ast_ir::Mutability::Not)), + mut_unit_ptr: create_ty(TyKind::RawPtr(unit, rustc_ast_ir::Mutability::Mut)), + }, + consts: DefaultConsts { error: create_const(ConstKind::Error(ErrorGuaranteed)) }, + regions: DefaultRegions { + error: create_region(RegionKind::ReError(ErrorGuaranteed)), + statik, + erased: create_region(RegionKind::ReErased), + }, + empty: DefaultEmpty { + tys: empty_tys, + generic_args: create_generic_args(&[]), + bound_var_kinds: create_bound_var_kinds(&[]), + canonical_vars: create_canonical_vars(&[]), + variances: create_variances_of(&[]), + pat_list: create_pat_list(&[]), + predefined_opaques: create_predefined_opaques(&[]), + def_ids: create_solver_def_ids(&[]), + bound_existential_predicates: create_bound_existential_predicates(&[]), + clauses: create_clauses(&[]), + region_assumptions: create_region_assumptions(&[]), + }, + one_invariant: create_variances_of(&[rustc_type_ir::Variance::Invariant]), + one_covariant: create_variances_of(&[rustc_type_ir::Variance::Covariant]), + coroutine_captures_by_ref_bound_var_kinds: create_bound_var_kinds(&[ + BoundVarKind::Region(BoundRegionKind::ClosureEnv), + ]), + } + }) +} diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs index c2fc4d18bbae..9643f1ba4c3a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/consts.rs @@ -64,7 +64,7 @@ impl<'db> Const<'db> { } pub fn error(interner: DbInterner<'db>) -> Self { - Const::new(interner, ConstKind::Error(ErrorGuaranteed)) + interner.default_types().consts.error } pub fn new_param(interner: DbInterner<'db>, param: ParamConst) -> Self { @@ -421,8 +421,8 @@ impl<'db> rustc_type_ir::inherent::Const> for Const<'db> { Const::new(interner, ConstKind::Expr(expr)) } - fn new_error(interner: DbInterner<'db>, guar: ErrorGuaranteed) -> Self { - Const::new(interner, ConstKind::Error(guar)) + fn new_error(interner: DbInterner<'db>, _guar: ErrorGuaranteed) -> Self { + Const::error(interner) } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs index 785d3ef65231..6eee7cc27a0e 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs @@ -22,7 +22,7 @@ use smallvec::SmallVec; use crate::next_solver::{ ConstInterned, PolyFnSig, RegionInterned, TyInterned, impl_foldable_for_interned_slice, - impl_stored_interned_slice, interned_slice, + interned_slice, }; use super::{ @@ -446,9 +446,15 @@ impl<'db> Relate> for GenericArg<'db> { } } -interned_slice!(GenericArgsStorage, GenericArgs, GenericArg<'db>, GenericArg<'static>,); +interned_slice!( + GenericArgsStorage, + GenericArgs, + StoredGenericArgs, + generic_args, + GenericArg<'db>, + GenericArg<'static>, +); impl_foldable_for_interned_slice!(GenericArgs); -impl_stored_interned_slice!(GenericArgsStorage, GenericArgs, StoredGenericArgs); impl<'db> rustc_type_ir::inherent::GenericArg> for GenericArg<'db> {} diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index 0102c2ef6eca..fcda02b1faeb 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -60,7 +60,7 @@ use super::{ }; macro_rules! interned_slice { - ($storage:ident, $name:ident, $ty_db:ty, $ty_static:ty $(,)?) => { + ($storage:ident, $name:ident, $stored_name:ident, $default_types_field:ident, $ty_db:ty, $ty_static:ty $(,)?) => { const _: () = { #[allow(unused_lifetimes)] fn _ensure_correct_types<'db: 'static>(v: $ty_db) -> $ty_static { v } @@ -81,9 +81,8 @@ macro_rules! interned_slice { impl<'db> $name<'db> { #[inline] - pub fn empty(_interner: DbInterner<'db>) -> Self { - // FIXME: Get from a static. - Self::new_from_slice(&[]) + pub fn empty(interner: DbInterner<'db>) -> Self { + interner.default_types().empty.$default_types_field } #[inline] @@ -175,41 +174,12 @@ macro_rules! interned_slice { } } } + + $crate::next_solver::interner::impl_stored_interned_slice!($storage, $name, $stored_name); }; } pub(crate) use interned_slice; -macro_rules! impl_foldable_for_interned_slice { - ($name:ident) => { - impl<'db> ::rustc_type_ir::TypeVisitable> for $name<'db> { - fn visit_with>>( - &self, - visitor: &mut V, - ) -> V::Result { - use rustc_ast_ir::visit::VisitorResult; - rustc_ast_ir::walk_visitable_list!(visitor, (*self).iter()); - V::Result::output() - } - } - - impl<'db> rustc_type_ir::TypeFoldable> for $name<'db> { - fn try_fold_with>>( - self, - folder: &mut F, - ) -> Result { - Self::new_from_iter(folder.cx(), self.iter().map(|it| it.try_fold_with(folder))) - } - fn fold_with>>( - self, - folder: &mut F, - ) -> Self { - Self::new_from_iter(folder.cx(), self.iter().map(|it| it.fold_with(folder))) - } - } - }; -} -pub(crate) use impl_foldable_for_interned_slice; - macro_rules! impl_stored_interned_slice { ( $storage:ident, $name:ident, $stored_name:ident $(,)? ) => { #[derive(Clone, PartialEq, Eq, Hash)] @@ -254,6 +224,37 @@ macro_rules! impl_stored_interned_slice { } pub(crate) use impl_stored_interned_slice; +macro_rules! impl_foldable_for_interned_slice { + ($name:ident) => { + impl<'db> ::rustc_type_ir::TypeVisitable> for $name<'db> { + fn visit_with>>( + &self, + visitor: &mut V, + ) -> V::Result { + use rustc_ast_ir::visit::VisitorResult; + rustc_ast_ir::walk_visitable_list!(visitor, (*self).iter()); + V::Result::output() + } + } + + impl<'db> rustc_type_ir::TypeFoldable> for $name<'db> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + Self::new_from_iter(folder.cx(), self.iter().map(|it| it.try_fold_with(folder))) + } + fn fold_with>>( + self, + folder: &mut F, + ) -> Self { + Self::new_from_iter(folder.cx(), self.iter().map(|it| it.fold_with(folder))) + } + } + }; +} +pub(crate) use impl_foldable_for_interned_slice; + macro_rules! impl_stored_interned { ( $storage:ident, $name:ident, $stored_name:ident $(,)? ) => { #[derive(Clone, PartialEq, Eq, Hash)] @@ -362,6 +363,11 @@ impl<'db> DbInterner<'db> { where you should've called `DbInterner::new_with()`", ) } + + #[inline] + pub fn default_types<'a>(&self) -> &'a crate::next_solver::DefaultAny<'db> { + crate::next_solver::default_types(self.db) + } } // This is intentionally left as `()` @@ -374,8 +380,14 @@ impl<'db> inherent::Span> for Span { } } -interned_slice!(BoundVarKindsStorage, BoundVarKinds, BoundVarKind, BoundVarKind); -impl_stored_interned_slice!(BoundVarKindsStorage, BoundVarKinds, StoredBoundVarKinds); +interned_slice!( + BoundVarKindsStorage, + BoundVarKinds, + StoredBoundVarKinds, + bound_var_kinds, + BoundVarKind, + BoundVarKind, +); #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum BoundVarKind { @@ -410,6 +422,8 @@ impl BoundVarKind { interned_slice!( CanonicalVarsStorage, CanonicalVars, + StoredCanonicalVars, + canonical_vars, CanonicalVarKind<'db>, CanonicalVarKind<'static> ); @@ -438,8 +452,7 @@ impl std::fmt::Debug for Placeholder { #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] pub struct AllocId; -interned_slice!(VariancesOfStorage, VariancesOf, Variance, Variance); -impl_stored_interned_slice!(VariancesOfStorage, VariancesOf, StoredVariancesOf); +interned_slice!(VariancesOfStorage, VariancesOf, StoredVariancesOf, variances, Variance, Variance); #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct VariantIdx(usize); @@ -949,7 +962,7 @@ impl<'db> rustc_type_ir::relate::Relate> for Pattern<'db> { } } -interned_slice!(PatListStorage, PatList, Pattern<'db>, Pattern<'static>); +interned_slice!(PatListStorage, PatList, StoredPatList, pat_list, Pattern<'db>, Pattern<'static>); impl_foldable_for_interned_slice!(PatList); macro_rules! as_lang_item { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs index 230469c21ab8..bdb3f3087103 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/opaques.rs @@ -15,6 +15,8 @@ type PredefinedOpaque<'db> = (OpaqueTypeKey<'db>, Ty<'db>); interned_slice!( PredefinedOpaquesStorage, PredefinedOpaques, + StoredPredefinedOpaques, + predefined_opaques, PredefinedOpaque<'db>, PredefinedOpaque<'static>, ); @@ -23,7 +25,14 @@ impl_foldable_for_interned_slice!(PredefinedOpaques); pub type ExternalConstraintsData<'db> = rustc_type_ir::solve::ExternalConstraintsData>; -interned_slice!(SolverDefIdsStorage, SolverDefIds, SolverDefId, SolverDefId); +interned_slice!( + SolverDefIdsStorage, + SolverDefIds, + StoredSolverDefIds, + def_ids, + SolverDefId, + SolverDefId, +); impl_foldable_for_interned_slice!(SolverDefIds); #[derive(Clone, Copy, PartialEq, Eq, Hash)] diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs index 6d7539575fbc..5758e2dc7e93 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/predicate.rs @@ -76,6 +76,8 @@ fn stable_cmp_existential_predicate<'db>( interned_slice!( BoundExistentialPredicatesStorage, BoundExistentialPredicates, + StoredBoundExistentialPredicates, + bound_existential_predicates, BoundExistentialPredicate<'db>, BoundExistentialPredicate<'static>, ); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs index e34e87601fd7..dc2441f76e3a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/region.rs @@ -11,11 +11,12 @@ use rustc_type_ir::{ }; use crate::next_solver::{ - GenericArg, OutlivesPredicate, impl_foldable_for_interned_slice, interned_slice, + GenericArg, OutlivesPredicate, impl_foldable_for_interned_slice, impl_stored_interned, + interned_slice, }; use super::{ - ErrorGuaranteed, SolverDefId, + SolverDefId, interner::{BoundVarKind, DbInterner, Placeholder}, }; @@ -31,6 +32,7 @@ pub struct Region<'db> { pub(super) struct RegionInterned(RegionKind<'static>); impl_internable!(gc; RegionInterned); +impl_stored_interned!(RegionInterned, Region, StoredRegion); const _: () = { const fn is_copy() {} @@ -64,7 +66,7 @@ impl<'db> Region<'db> { } pub fn new_erased(interner: DbInterner<'db>) -> Region<'db> { - Region::new(interner, RegionKind::ReErased) + interner.default_types().regions.erased } pub fn new_bound( @@ -96,7 +98,7 @@ impl<'db> Region<'db> { } pub fn error(interner: DbInterner<'db>) -> Self { - Region::new(interner, RegionKind::ReError(ErrorGuaranteed)) + interner.default_types().regions.error } pub fn type_flags(&self) -> TypeFlags { @@ -352,7 +354,7 @@ impl<'db> rustc_type_ir::inherent::Region> for Region<'db> { } fn new_static(interner: DbInterner<'db>) -> Self { - Region::new(interner, RegionKind::ReStatic) + interner.default_types().regions.statik } fn new_placeholder( @@ -400,6 +402,8 @@ type GenericArgOutlivesPredicate<'db> = OutlivesPredicate<'db, GenericArg<'db>>; interned_slice!( RegionAssumptionsStorage, RegionAssumptions, + StoredRegionAssumptions, + region_assumptions, GenericArgOutlivesPredicate<'db>, GenericArgOutlivesPredicate<'static>, ); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs index 87cba7aca8e1..ee460aff443f 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs @@ -32,8 +32,7 @@ use crate::{ AdtDef, AliasTy, Binder, CallableIdWrapper, Clause, ClauseKind, ClosureIdWrapper, Const, CoroutineIdWrapper, FnSig, GenericArgKind, PolyFnSig, Region, TraitRef, TypeAliasIdWrapper, abi::Safety, - impl_foldable_for_interned_slice, impl_stored_interned, impl_stored_interned_slice, - interned_slice, + impl_foldable_for_interned_slice, impl_stored_interned, interned_slice, util::{CoroutineArgsExt, IntegerTypeExt}, }, }; @@ -112,16 +111,39 @@ impl<'db> Ty<'db> { Ty::new_infer(interner, InferTy::FloatVar(v)) } + #[inline] pub fn new_int(interner: DbInterner<'db>, i: IntTy) -> Self { - Ty::new(interner, TyKind::Int(i)) + let types = interner.default_types(); + match i { + IntTy::Isize => types.types.isize, + IntTy::I8 => types.types.i8, + IntTy::I16 => types.types.i16, + IntTy::I32 => types.types.i32, + IntTy::I64 => types.types.i64, + IntTy::I128 => types.types.i128, + } } pub fn new_uint(interner: DbInterner<'db>, ui: UintTy) -> Self { - Ty::new(interner, TyKind::Uint(ui)) + let types = interner.default_types(); + match ui { + UintTy::Usize => types.types.usize, + UintTy::U8 => types.types.u8, + UintTy::U16 => types.types.u16, + UintTy::U32 => types.types.u32, + UintTy::U64 => types.types.u64, + UintTy::U128 => types.types.u128, + } } pub fn new_float(interner: DbInterner<'db>, f: FloatTy) -> Self { - Ty::new(interner, TyKind::Float(f)) + let types = interner.default_types(); + match f { + FloatTy::F16 => types.types.f16, + FloatTy::F32 => types.types.f32, + FloatTy::F64 => types.types.f64, + FloatTy::F128 => types.types.f128, + } } pub fn new_fresh(interner: DbInterner<'db>, n: u32) -> Self { @@ -137,7 +159,7 @@ impl<'db> Ty<'db> { } pub fn new_empty_tuple(interner: DbInterner<'db>) -> Self { - Ty::new_tup(interner, &[]) + interner.default_types().types.unit } pub fn new_imm_ptr(interner: DbInterner<'db>, ty: Ty<'db>) -> Self { @@ -568,34 +590,34 @@ impl<'db> Ty<'db> { interner: DbInterner<'db>, ty: hir_def::builtin_type::BuiltinType, ) -> Ty<'db> { - let kind = match ty { - hir_def::builtin_type::BuiltinType::Char => TyKind::Char, - hir_def::builtin_type::BuiltinType::Bool => TyKind::Bool, - hir_def::builtin_type::BuiltinType::Str => TyKind::Str, - hir_def::builtin_type::BuiltinType::Int(int) => TyKind::Int(match int { - hir_def::builtin_type::BuiltinInt::Isize => rustc_type_ir::IntTy::Isize, - hir_def::builtin_type::BuiltinInt::I8 => rustc_type_ir::IntTy::I8, - hir_def::builtin_type::BuiltinInt::I16 => rustc_type_ir::IntTy::I16, - hir_def::builtin_type::BuiltinInt::I32 => rustc_type_ir::IntTy::I32, - hir_def::builtin_type::BuiltinInt::I64 => rustc_type_ir::IntTy::I64, - hir_def::builtin_type::BuiltinInt::I128 => rustc_type_ir::IntTy::I128, - }), - hir_def::builtin_type::BuiltinType::Uint(uint) => TyKind::Uint(match uint { - hir_def::builtin_type::BuiltinUint::Usize => rustc_type_ir::UintTy::Usize, - hir_def::builtin_type::BuiltinUint::U8 => rustc_type_ir::UintTy::U8, - hir_def::builtin_type::BuiltinUint::U16 => rustc_type_ir::UintTy::U16, - hir_def::builtin_type::BuiltinUint::U32 => rustc_type_ir::UintTy::U32, - hir_def::builtin_type::BuiltinUint::U64 => rustc_type_ir::UintTy::U64, - hir_def::builtin_type::BuiltinUint::U128 => rustc_type_ir::UintTy::U128, - }), - hir_def::builtin_type::BuiltinType::Float(float) => TyKind::Float(match float { - hir_def::builtin_type::BuiltinFloat::F16 => rustc_type_ir::FloatTy::F16, - hir_def::builtin_type::BuiltinFloat::F32 => rustc_type_ir::FloatTy::F32, - hir_def::builtin_type::BuiltinFloat::F64 => rustc_type_ir::FloatTy::F64, - hir_def::builtin_type::BuiltinFloat::F128 => rustc_type_ir::FloatTy::F128, - }), - }; - Ty::new(interner, kind) + let types = interner.default_types(); + match ty { + hir_def::builtin_type::BuiltinType::Char => types.types.char, + hir_def::builtin_type::BuiltinType::Bool => types.types.bool, + hir_def::builtin_type::BuiltinType::Str => types.types.str, + hir_def::builtin_type::BuiltinType::Int(int) => match int { + hir_def::builtin_type::BuiltinInt::Isize => types.types.isize, + hir_def::builtin_type::BuiltinInt::I8 => types.types.i8, + hir_def::builtin_type::BuiltinInt::I16 => types.types.i16, + hir_def::builtin_type::BuiltinInt::I32 => types.types.i32, + hir_def::builtin_type::BuiltinInt::I64 => types.types.i64, + hir_def::builtin_type::BuiltinInt::I128 => types.types.i128, + }, + hir_def::builtin_type::BuiltinType::Uint(uint) => match uint { + hir_def::builtin_type::BuiltinUint::Usize => types.types.usize, + hir_def::builtin_type::BuiltinUint::U8 => types.types.u8, + hir_def::builtin_type::BuiltinUint::U16 => types.types.u16, + hir_def::builtin_type::BuiltinUint::U32 => types.types.u32, + hir_def::builtin_type::BuiltinUint::U64 => types.types.u64, + hir_def::builtin_type::BuiltinUint::U128 => types.types.u128, + }, + hir_def::builtin_type::BuiltinType::Float(float) => match float { + hir_def::builtin_type::BuiltinFloat::F16 => types.types.f16, + hir_def::builtin_type::BuiltinFloat::F32 => types.types.f32, + hir_def::builtin_type::BuiltinFloat::F64 => types.types.f64, + hir_def::builtin_type::BuiltinFloat::F128 => types.types.f128, + }, + } } pub fn as_builtin(self) -> Option { @@ -955,19 +977,19 @@ impl<'db> Flags for Ty<'db> { impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { fn new_unit(interner: DbInterner<'db>) -> Self { - Ty::new(interner, TyKind::Tuple(Default::default())) + interner.default_types().types.unit } fn new_bool(interner: DbInterner<'db>) -> Self { - Ty::new(interner, TyKind::Bool) + interner.default_types().types.bool } fn new_u8(interner: DbInterner<'db>) -> Self { - Ty::new(interner, TyKind::Uint(rustc_type_ir::UintTy::U8)) + interner.default_types().types.u8 } fn new_usize(interner: DbInterner<'db>) -> Self { - Ty::new(interner, TyKind::Uint(rustc_type_ir::UintTy::Usize)) + interner.default_types().types.usize } fn new_infer(interner: DbInterner<'db>, var: rustc_type_ir::InferTy) -> Self { @@ -1118,7 +1140,7 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { } fn new_tup(interner: DbInterner<'db>, tys: &[ as Interner>::Ty]) -> Self { - Ty::new(interner, TyKind::Tuple(Tys::new_from_iter(interner, tys.iter().cloned()))) + Ty::new(interner, TyKind::Tuple(Tys::new_from_slice(tys))) } fn new_tup_from_iter(interner: DbInterner<'db>, iter: It) -> T::Output @@ -1190,10 +1212,11 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { } fn from_closure_kind(interner: DbInterner<'db>, kind: rustc_type_ir::ClosureKind) -> Self { + let types = interner.default_types(); match kind { - ClosureKind::Fn => Ty::new(interner, TyKind::Int(IntTy::I8)), - ClosureKind::FnMut => Ty::new(interner, TyKind::Int(IntTy::I16)), - ClosureKind::FnOnce => Ty::new(interner, TyKind::Int(IntTy::I32)), + ClosureKind::Fn => types.types.i8, + ClosureKind::FnMut => types.types.i16, + ClosureKind::FnOnce => types.types.i32, } } @@ -1201,9 +1224,10 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { interner: DbInterner<'db>, kind: rustc_type_ir::ClosureKind, ) -> Self { + let types = interner.default_types(); match kind { - ClosureKind::Fn | ClosureKind::FnMut => Ty::new(interner, TyKind::Int(IntTy::I16)), - ClosureKind::FnOnce => Ty::new(interner, TyKind::Int(IntTy::I32)), + ClosureKind::Fn | ClosureKind::FnMut => types.types.i16, + ClosureKind::FnOnce => types.types.i32, } } @@ -1250,7 +1274,7 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { | TyKind::Tuple(_) | TyKind::Error(_) | TyKind::Infer(InferTy::IntVar(_) | InferTy::FloatVar(_)) => { - Ty::new(interner, TyKind::Uint(UintTy::U8)) + interner.default_types().types.u8 } TyKind::Bound(..) @@ -1267,9 +1291,8 @@ impl<'db> rustc_type_ir::inherent::Ty> for Ty<'db> { } } -interned_slice!(TysStorage, Tys, Ty<'db>, Ty<'static>); +interned_slice!(TysStorage, Tys, StoredTys, tys, Ty<'db>, Ty<'static>); impl_foldable_for_interned_slice!(Tys); -impl_stored_interned_slice!(TysStorage, Tys, StoredTys); impl<'db> Tys<'db> { #[inline] diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/util.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/util.rs index bc4b5fdbfc52..34ecfed08f29 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/util.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/util.rs @@ -77,9 +77,10 @@ pub trait IntegerTypeExt { impl IntegerTypeExt for IntegerType { fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db> { + let types = interner.default_types(); match self { - IntegerType::Pointer(true) => Ty::new(interner, TyKind::Int(IntTy::Isize)), - IntegerType::Pointer(false) => Ty::new(interner, TyKind::Uint(UintTy::Usize)), + IntegerType::Pointer(true) => types.types.isize, + IntegerType::Pointer(false) => types.types.usize, IntegerType::Fixed(i, s) => i.to_ty(interner, *s), } } @@ -120,17 +121,18 @@ impl IntegerExt for Integer { #[inline] fn to_ty<'db>(&self, interner: DbInterner<'db>, signed: bool) -> Ty<'db> { use Integer::*; + let types = interner.default_types(); match (*self, signed) { - (I8, false) => Ty::new(interner, TyKind::Uint(UintTy::U8)), - (I16, false) => Ty::new(interner, TyKind::Uint(UintTy::U16)), - (I32, false) => Ty::new(interner, TyKind::Uint(UintTy::U32)), - (I64, false) => Ty::new(interner, TyKind::Uint(UintTy::U64)), - (I128, false) => Ty::new(interner, TyKind::Uint(UintTy::U128)), - (I8, true) => Ty::new(interner, TyKind::Int(IntTy::I8)), - (I16, true) => Ty::new(interner, TyKind::Int(IntTy::I16)), - (I32, true) => Ty::new(interner, TyKind::Int(IntTy::I32)), - (I64, true) => Ty::new(interner, TyKind::Int(IntTy::I64)), - (I128, true) => Ty::new(interner, TyKind::Int(IntTy::I128)), + (I8, false) => types.types.u8, + (I16, false) => types.types.u16, + (I32, false) => types.types.u32, + (I64, false) => types.types.u64, + (I128, false) => types.types.u128, + (I8, true) => types.types.i8, + (I16, true) => types.types.i16, + (I32, true) => types.types.i32, + (I64, true) => types.types.i64, + (I128, true) => types.types.i128, } } @@ -214,11 +216,12 @@ impl FloatExt for Float { #[inline] fn to_ty<'db>(&self, interner: DbInterner<'db>) -> Ty<'db> { use Float::*; + let types = interner.default_types(); match *self { - F16 => Ty::new(interner, TyKind::Float(FloatTy::F16)), - F32 => Ty::new(interner, TyKind::Float(FloatTy::F32)), - F64 => Ty::new(interner, TyKind::Float(FloatTy::F64)), - F128 => Ty::new(interner, TyKind::Float(FloatTy::F128)), + F16 => types.types.f16, + F32 => types.types.f32, + F64 => types.types.f64, + F128 => types.types.f128, } } @@ -244,13 +247,7 @@ impl PrimitiveExt for Primitive { match *self { Primitive::Int(i, signed) => i.to_ty(interner, signed), Primitive::Float(f) => f.to_ty(interner), - Primitive::Pointer(_) => Ty::new( - interner, - TyKind::RawPtr( - Ty::new(interner, TyKind::Tuple(Default::default())), - rustc_ast_ir::Mutability::Mut, - ), - ), + Primitive::Pointer(_) => interner.default_types().types.mut_unit_ptr, } } @@ -283,7 +280,7 @@ impl<'db> CoroutineArgsExt<'db> for CoroutineArgs> { /// The type of the state discriminant used in the coroutine type. #[inline] fn discr_ty(&self, interner: DbInterner<'db>) -> Ty<'db> { - Ty::new(interner, TyKind::Uint(UintTy::U32)) + interner.default_types().types.u32 } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs index bfb9a3f77e94..a050124c90b7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs @@ -48,10 +48,11 @@ fn variances_of_query(db: &dyn HirDatabase, def: GenericDefId) -> StoredVariance GenericDefId::AdtId(adt) => { if let AdtId::StructId(id) = adt { let flags = &db.struct_signature(id).flags; + let types = || crate::next_solver::default_types(db); if flags.contains(StructFlags::IS_UNSAFE_CELL) { - return VariancesOf::new_from_iter(interner, [Variance::Invariant]).store(); + return types().one_invariant.store(); } else if flags.contains(StructFlags::IS_PHANTOM_DATA) { - return VariancesOf::new_from_iter(interner, [Variance::Covariant]).store(); + return types().one_covariant.store(); } } } From d92e6c96884cd0ed22f57e3ea18edffb17037a0c Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Thu, 18 Dec 2025 03:29:12 +0200 Subject: [PATCH 368/489] Convert some `::new_from_iter()` to `new_from_slice()` It's faster, when you have a slice available. --- .../crates/hir-ty/src/infer/expr.rs | 8 +++----- .../crates/hir-ty/src/infer/path.rs | 5 +---- src/tools/rust-analyzer/crates/hir-ty/src/lib.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/lower.rs | 12 +++--------- .../crates/hir-ty/src/lower/path.rs | 2 +- .../crates/hir-ty/src/method_resolution.rs | 8 ++++---- .../crates/hir-ty/src/next_solver/generic_arg.rs | 5 +---- .../next_solver/infer/canonical/canonicalizer.rs | 2 +- .../crates/hir-ty/src/next_solver/interner.rs | 16 ++++++---------- .../rust-analyzer/crates/hir-ty/src/variance.rs | 2 +- 10 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs index ae69e5176ae5..dc4d34f7b5d2 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs @@ -780,7 +780,7 @@ impl<'db> InferenceContext<'_, 'db> { Ty::new_adt( self.interner(), adt, - GenericArgs::new_from_iter(self.interner(), [GenericArg::from(ty)]), + GenericArgs::new_from_slice(&[GenericArg::from(ty)]), ) }; match (range_type, lhs_ty, rhs_ty) { @@ -2164,10 +2164,8 @@ impl<'db> InferenceContext<'_, 'db> { if let ItemContainerId::TraitId(trait_) = f.lookup(self.db).container { // construct a TraitRef let trait_params_len = generics(self.db, trait_.into()).len(); - let substs = GenericArgs::new_from_iter( - self.interner(), - parameters.as_slice()[..trait_params_len].iter().copied(), - ); + let substs = + GenericArgs::new_from_slice(¶meters.as_slice()[..trait_params_len]); self.table.register_predicate(Obligation::new( self.interner(), ObligationCause::new(), diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs index 69e6b40a091a..98a2a2ddc049 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs @@ -240,10 +240,7 @@ impl<'db> InferenceContext<'_, 'db> { if let ItemContainerId::TraitId(trait_) = container { let parent_len = generics(self.db, def).parent_generics().map_or(0, |g| g.len_self()); - let parent_subst = GenericArgs::new_from_iter( - interner, - subst.as_slice()[..parent_len].iter().copied(), - ); + let parent_subst = GenericArgs::new_from_slice(&subst.as_slice()[..parent_len]); let trait_ref = TraitRef::new(interner, trait_.into(), parent_subst); self.table.register_predicate(Obligation::new( interner, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs index 012fd8a10abd..407657299333 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs @@ -469,7 +469,7 @@ where Canonical { value, max_universe: rustc_type_ir::UniverseIndex::ZERO, - variables: CanonicalVars::new_from_iter(interner, error_replacer.vars), + variables: CanonicalVars::new_from_slice(&error_replacer.vars), } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs index 7c38c83628fa..62a5837f349d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs @@ -2336,10 +2336,7 @@ pub(crate) fn associated_ty_item_bounds<'db>( Some(ExistentialPredicate::Trait(ExistentialTraitRef::new_from_args( interner, t.def_id(), - GenericArgs::new_from_iter( - interner, - t.trait_ref.args.iter().skip(1), - ), + GenericArgs::new_from_slice(&t.trait_ref.args[1..]), ))) } } @@ -2347,10 +2344,7 @@ pub(crate) fn associated_ty_item_bounds<'db>( ExistentialPredicate::Projection(ExistentialProjection::new_from_args( interner, p.def_id(), - GenericArgs::new_from_iter( - interner, - p.projection_term.args.iter().skip(1), - ), + GenericArgs::new_from_slice(&p.projection_term.args[1..]), p.term, )), ), @@ -2380,7 +2374,7 @@ pub(crate) fn associated_ty_item_bounds<'db>( bounds.push(sized_clause); } - EarlyBinder::bind(BoundExistentialPredicates::new_from_iter(interner, bounds)) + EarlyBinder::bind(BoundExistentialPredicates::new_from_slice(&bounds)) } pub(crate) fn associated_type_by_name_including_super_traits<'db>( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs index fba176bcb1ab..54ce1f740246 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs @@ -1283,7 +1283,7 @@ pub(crate) fn substs_from_args_and_bindings<'db>( } } - GenericArgs::new_from_iter(interner, substs) + GenericArgs::new_from_slice(&substs) } fn type_looks_like_const( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs index aaa3cce4fad9..fee3f664095e 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs @@ -392,10 +392,10 @@ pub fn is_dyn_method<'db>( }; let trait_params = db.generic_params(trait_id.into()).len(); let fn_params = fn_subst.len() - trait_params; - let trait_ref = TraitRef::new( + let trait_ref = TraitRef::new_from_args( interner, trait_id.into(), - GenericArgs::new_from_iter(interner, fn_subst.iter().take(trait_params)), + GenericArgs::new_from_slice(&fn_subst[..trait_params]), ); let self_ty = trait_ref.self_ty(); if let TyKind::Dynamic(d, _) = self_ty.kind() { @@ -427,10 +427,10 @@ pub(crate) fn lookup_impl_method_query<'db>( return (func, fn_subst); }; let trait_params = db.generic_params(trait_id.into()).len(); - let trait_ref = TraitRef::new( + let trait_ref = TraitRef::new_from_args( interner, trait_id.into(), - GenericArgs::new_from_iter(interner, fn_subst.iter().take(trait_params)), + GenericArgs::new_from_slice(&fn_subst[..trait_params]), ); let name = &db.function_signature(func).name; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs index 6eee7cc27a0e..9936e443210a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/generic_arg.rs @@ -698,10 +698,7 @@ impl<'db> rustc_type_ir::inherent::GenericArgs> for GenericArgs< let inputs = Ty::new_tup(interner, s.inputs()); let output = s.output(); FnSigTys { - inputs_and_output: Tys::new_from_iter( - interner, - [inputs, output], - ), + inputs_and_output: Tys::new_from_slice(&[inputs, output]), } }), header, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs index 4422eeaa9a4b..ccd93590107f 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/canonical/canonicalizer.rs @@ -562,7 +562,7 @@ impl<'cx, 'db> Canonicalizer<'cx, 'db> { debug_assert!(!out_value.has_infer() && !out_value.has_placeholders()); let canonical_variables = - CanonicalVars::new_from_iter(tcx, canonicalizer.universe_canonicalized_variables()); + CanonicalVars::new_from_slice(&canonicalizer.universe_canonicalized_variables()); let max_universe = canonical_variables .iter() diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs index fcda02b1faeb..2ebc5b81ba5c 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs @@ -21,9 +21,9 @@ use rustc_abi::{ReprFlags, ReprOptions}; use rustc_hash::FxHashSet; use rustc_index::bit_set::DenseBitSet; use rustc_type_ir::{ - AliasTermKind, AliasTyKind, BoundVar, CollectAndApply, CoroutineWitnessTypes, DebruijnIndex, - EarlyBinder, FlagComputation, Flags, GenericArgKind, GenericTypeVisitable, ImplPolarity, - InferTy, Interner, TraitRef, TypeFlags, TypeVisitableExt, UniverseIndex, Upcast, Variance, + AliasTermKind, AliasTyKind, BoundVar, CoroutineWitnessTypes, DebruijnIndex, EarlyBinder, + FlagComputation, Flags, GenericArgKind, GenericTypeVisitable, ImplPolarity, InferTy, Interner, + TraitRef, TypeFlags, TypeVisitableExt, UniverseIndex, Upcast, Variance, elaborate::elaborate, error::TypeError, fast_reject, @@ -1270,10 +1270,8 @@ impl<'db> Interner for DbInterner<'db> { ) -> (rustc_type_ir::TraitRef, Self::GenericArgsSlice) { let trait_def_id = self.parent(def_id); let trait_generics = self.generics_of(trait_def_id); - let trait_args = GenericArgs::new_from_iter( - self, - args.as_slice()[0..trait_generics.own_params.len()].iter().cloned(), - ); + let trait_args = + GenericArgs::new_from_slice(&args.as_slice()[0..trait_generics.own_params.len()]); let alias_args = &args.as_slice()[trait_generics.own_params.len()..]; (TraitRef::new_from_args(self, trait_def_id.try_into().unwrap(), trait_args), alias_args) } @@ -2105,9 +2103,7 @@ impl<'db> Interner for DbInterner<'db> { let mut map = Default::default(); let delegate = Anonymize { interner: self, map: &mut map }; let inner = self.replace_escaping_bound_vars_uncached(value.skip_binder(), delegate); - let bound_vars = CollectAndApply::collect_and_apply(map.into_values(), |xs| { - BoundVarKinds::new_from_iter(self, xs.iter().cloned()) - }); + let bound_vars = BoundVarKinds::new_from_iter(self, map.into_values()); Binder::bind_with_vars(inner, bound_vars) } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs index a050124c90b7..5b8122a0a5df 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/variance.rs @@ -82,7 +82,7 @@ fn variances_of_query(db: &dyn HirDatabase, def: GenericDefId) -> StoredVariance } } - VariancesOf::new_from_iter(interner, variances).store() + VariancesOf::new_from_slice(&variances).store() } // pub(crate) fn variances_of_cycle_fn( From 44a9d841f47006c34ccddad7809cca2a21e02e1e Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 19 Dec 2025 21:20:27 -0500 Subject: [PATCH 369/489] Don't export upstream monomorphizations from compiler-builtins --- compiler/rustc_middle/src/ty/context.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 471bd1d937e9..779a5f3f5218 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2272,6 +2272,12 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn local_crate_exports_generics(self) -> bool { + // compiler-builtins has some special treatment in codegen, which can result in confusing + // behavior if another crate ends up calling into its monomorphizations. + // https://github.com/rust-lang/rust/issues/150173 + if self.is_compiler_builtins(LOCAL_CRATE) { + return false; + } self.crate_types().iter().any(|crate_type| { match crate_type { CrateType::Executable From cdcb289c1ab154d1daf27203844a35b1f63c9a47 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Sat, 20 Dec 2025 19:21:57 +0200 Subject: [PATCH 370/489] Replace some `new()` with `new_from_args()` It's faster, when you already have a `GenericArgs`. --- .../rust-analyzer/crates/hir-ty/src/infer/expr.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/infer/path.rs | 4 ++-- .../rust-analyzer/crates/hir-ty/src/infer/unify.rs | 13 ++++++------- src/tools/rust-analyzer/crates/hir-ty/src/lib.rs | 12 ++++++------ .../rust-analyzer/crates/hir-ty/src/lower/path.rs | 2 +- .../crates/hir-ty/src/method_resolution.rs | 2 +- .../crates/hir-ty/src/next_solver/ty.rs | 9 ++++++--- src/tools/rust-analyzer/crates/hir/src/lib.rs | 5 +++-- 8 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs index dc4d34f7b5d2..226e9f5cd667 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs @@ -2170,7 +2170,7 @@ impl<'db> InferenceContext<'_, 'db> { self.interner(), ObligationCause::new(), self.table.param_env, - TraitRef::new(self.interner(), trait_.into(), substs), + TraitRef::new_from_args(self.interner(), trait_.into(), substs), )); } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs index 98a2a2ddc049..b11650bbcd9a 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs @@ -241,7 +241,7 @@ impl<'db> InferenceContext<'_, 'db> { if let ItemContainerId::TraitId(trait_) = container { let parent_len = generics(self.db, def).parent_generics().map_or(0, |g| g.len_self()); let parent_subst = GenericArgs::new_from_slice(&subst.as_slice()[..parent_len]); - let trait_ref = TraitRef::new(interner, trait_.into(), parent_subst); + let trait_ref = TraitRef::new_from_args(interner, trait_.into(), parent_subst); self.table.register_predicate(Obligation::new( interner, ObligationCause::new(), @@ -336,7 +336,7 @@ impl<'db> InferenceContext<'_, 'db> { [ty.into()], |_, id, _| self.table.next_var_for_param(id), ); - let trait_ref = TraitRef::new(self.interner(), trait_.into(), args); + let trait_ref = TraitRef::new_from_args(self.interner(), trait_.into(), args); self.table.register_predicate(Obligation::new( self.interner(), ObligationCause::new(), diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs index ac84797f37a9..d55fc0ab0da6 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/unify.rs @@ -542,16 +542,14 @@ impl<'db> InferenceTable<'db> { }) .take(num_args), ); - let args = [ty, arg_ty]; - let trait_ref = TraitRef::new(self.interner(), fn_trait.into(), args); + let args = GenericArgs::new_from_slice(&[ty.into(), arg_ty.into()]); + let trait_ref = TraitRef::new_from_args(self.interner(), fn_trait.into(), args); - let proj_args = self - .infer_ctxt - .fill_rest_fresh_args(output_assoc_type.into(), args.into_iter().map(Into::into)); + let proj_args = self.infer_ctxt.fill_rest_fresh_args(output_assoc_type.into(), args); let projection = Ty::new_alias( self.interner(), rustc_type_ir::AliasTyKind::Projection, - AliasTy::new(self.interner(), output_assoc_type.into(), proj_args), + AliasTy::new_from_args(self.interner(), output_assoc_type.into(), proj_args), ); let pred = Predicate::upcast_from(trait_ref, self.interner()); @@ -560,7 +558,8 @@ impl<'db> InferenceTable<'db> { let return_ty = self.normalize_alias_ty(projection); for &fn_x in subtraits { let fn_x_trait = fn_x.get_id(lang_items)?; - let trait_ref = TraitRef::new(self.interner(), fn_x_trait.into(), args); + let trait_ref = + TraitRef::new_from_args(self.interner(), fn_x_trait.into(), args); let pred = Predicate::upcast_from(trait_ref, self.interner()); if !self.try_obligation(pred).no_solution() { return Some((fn_x, arg_tys, return_ty)); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs index 407657299333..6081196bacc2 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs @@ -77,8 +77,8 @@ use crate::{ infer::unify::InferenceTable, next_solver::{ AliasTy, Binder, BoundConst, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, Canonical, - CanonicalVarKind, CanonicalVars, Const, ConstKind, DbInterner, FnSig, PolyFnSig, Predicate, - Region, RegionKind, TraitRef, Ty, TyKind, Tys, abi, + CanonicalVarKind, CanonicalVars, Const, ConstKind, DbInterner, FnSig, GenericArgs, + PolyFnSig, Predicate, Region, RegionKind, TraitRef, Ty, TyKind, Tys, abi, }, }; @@ -491,12 +491,12 @@ pub fn callable_sig_from_fn_trait<'db>( // - Self: FnOnce // - >::Output == ?ret_ty let args_ty = table.next_ty_var(); - let args = [self_ty, args_ty]; - let trait_ref = TraitRef::new(table.interner(), fn_once_trait.into(), args); + let args = GenericArgs::new_from_slice(&[self_ty.into(), args_ty.into()]); + let trait_ref = TraitRef::new_from_args(table.interner(), fn_once_trait.into(), args); let projection = Ty::new_alias( table.interner(), rustc_type_ir::AliasTyKind::Projection, - AliasTy::new(table.interner(), output_assoc_type.into(), args), + AliasTy::new_from_args(table.interner(), output_assoc_type.into(), args), ); let pred = Predicate::upcast_from(trait_ref, table.interner()); @@ -505,7 +505,7 @@ pub fn callable_sig_from_fn_trait<'db>( let return_ty = table.normalize_alias_ty(projection); for fn_x in [FnTrait::Fn, FnTrait::FnMut, FnTrait::FnOnce] { let fn_x_trait = fn_x.get_id(lang_items)?; - let trait_ref = TraitRef::new(table.interner(), fn_x_trait.into(), args); + let trait_ref = TraitRef::new_from_args(table.interner(), fn_x_trait.into(), args); if !table .try_obligation(Predicate::upcast_from(trait_ref, table.interner())) .no_solution() diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs index 54ce1f740246..a79f547c2a44 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs @@ -506,7 +506,7 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> { Some(Ty::new_alias( interner, AliasTyKind::Projection, - AliasTy::new(interner, associated_ty.into(), substs), + AliasTy::new_from_args(interner, associated_ty.into(), substs), )) }; named_associated_type_shorthand_candidates( diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs index fee3f664095e..c370330a8717 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/method_resolution.rs @@ -362,7 +362,7 @@ pub fn lookup_impl_const<'db>( ItemContainerId::TraitId(id) => id, _ => return (const_id, subs), }; - let trait_ref = TraitRef::new(interner, trait_id.into(), subs); + let trait_ref = TraitRef::new_from_args(interner, trait_id.into(), subs); let const_signature = db.const_signature(const_id); let name = match const_signature.name.as_ref() { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs index ee460aff443f..c89831bd4077 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/ty.rs @@ -696,9 +696,12 @@ impl<'db> Ty<'db> { // This is only used by type walking. // Parameters will be walked outside, and projection predicate is not used. // So just provide the Future trait. - let impl_bound = - TraitRef::new(interner, future_trait.into(), GenericArgs::empty(interner)) - .upcast(interner); + let impl_bound = TraitRef::new_from_args( + interner, + future_trait.into(), + GenericArgs::empty(interner), + ) + .upcast(interner); Some(vec![impl_bound]) } else { None diff --git a/src/tools/rust-analyzer/crates/hir/src/lib.rs b/src/tools/rust-analyzer/crates/hir/src/lib.rs index 883f1aa26e44..90a0c2b402c0 100644 --- a/src/tools/rust-analyzer/crates/hir/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir/src/lib.rs @@ -5148,7 +5148,7 @@ impl<'db> Type<'db> { let projection = Ty::new_alias( interner, AliasTyKind::Projection, - AliasTy::new(interner, alias.id.into(), args), + AliasTy::new_from_args(interner, alias.id.into(), args), ); let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis); @@ -5858,7 +5858,8 @@ impl<'db> TypeNs<'db> { infcx.interner, [self.ty].into_iter().chain(args.iter().map(|t| t.ty)).map(GenericArg::from), ); - let trait_ref = hir_ty::next_solver::TraitRef::new(infcx.interner, trait_.id.into(), args); + let trait_ref = + hir_ty::next_solver::TraitRef::new_from_args(infcx.interner, trait_.id.into(), args); let pred_kind = rustc_type_ir::Binder::dummy(rustc_type_ir::PredicateKind::Clause( rustc_type_ir::ClauseKind::Trait(rustc_type_ir::TraitPredicate { From b7a0f84a5aef6b097636c29408c8bddf89a711bf Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 20 Dec 2025 20:35:30 +0100 Subject: [PATCH 371/489] tests/debuginfo/function-arg-initialization.rs: Stop disabling SingleUseConsts MIR pass --- tests/debuginfo/function-arg-initialization.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/debuginfo/function-arg-initialization.rs b/tests/debuginfo/function-arg-initialization.rs index c3b7ed81d026..78fecd8a4bfe 100644 --- a/tests/debuginfo/function-arg-initialization.rs +++ b/tests/debuginfo/function-arg-initialization.rs @@ -6,8 +6,7 @@ // function name. //@ min-lldb-version: 1800 -//@ compile-flags:-g -Zmir-enable-passes=-SingleUseConsts -// SingleUseConsts shouldn't need to be disabled, see #128945 +//@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc From 8825e1fe5d3a142228277f0df36dae19310a723f Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 17 Dec 2025 10:32:13 +0100 Subject: [PATCH 372/489] library/coretests/tests/fmt/mod.rs: Add HRTB fn pointer case --- library/coretests/tests/fmt/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/coretests/tests/fmt/mod.rs b/library/coretests/tests/fmt/mod.rs index d0ae7124f474..0fb099ef4191 100644 --- a/library/coretests/tests/fmt/mod.rs +++ b/library/coretests/tests/fmt/mod.rs @@ -30,6 +30,12 @@ fn test_format_flags() { assert_eq!(format!("{:p} {:x}", p, 16), format!("{p:p} 10")); assert_eq!(format!("{: >3}", 'a'), " a"); + + /// Regression test for . + fn show(a: fn() -> f32, b: fn(&Vec) -> f32) { + println!("the two pointers: {:p} {:p}", a, b); + } + show(|| 1.0, |_| 2.0); } #[test] From cd8cc6ff3840825681e1971f8557ddae1baa1559 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Dec 2025 16:43:54 -0500 Subject: [PATCH 373/489] Update to nightly-2025-12-20 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index f9645451e964..86ae738d4483 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-11-24" +channel = "nightly-2025-12-20" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From 93cf63b7899e98df3353f0b119a04f6ae18c7850 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Dec 2025 16:50:34 -0500 Subject: [PATCH 374/489] Move libgccjit.so to the new location within the sysroot --- build_system/src/build.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 27476465d740..9b7ee8380ca5 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -111,14 +111,20 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu // Symlink libgccjit.so to sysroot. let lib_path = start_dir.join("sysroot").join("lib"); + let rustlib_target_path = lib_path + .join("rustlib") + .join(&config.host_triple) + .join("codegen-backends") + .join("lib") + .join(&config.target_triple); let libgccjit_path = PathBuf::from(config.gcc_path.as_ref().expect("libgccjit should be set by this point")) .join("libgccjit.so"); - let libgccjit_in_sysroot_path = lib_path.join("libgccjit.so"); + let libgccjit_in_sysroot_path = rustlib_target_path.join("libgccjit.so"); // First remove the file to be able to create the symlink even when the file already exists. let _ = fs::remove_file(&libgccjit_in_sysroot_path); - create_dir(&lib_path)?; - symlink(libgccjit_path, libgccjit_in_sysroot_path) + create_dir(&rustlib_target_path)?; + symlink(libgccjit_path, &libgccjit_in_sysroot_path) .map_err(|error| format!("Cannot create symlink for libgccjit.so: {}", error))?; let library_dir = start_dir.join("sysroot_src").join("library"); From 1ac26a7b1c757f55c3a5d86691c9a7b105d5d86f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Dec 2025 17:31:53 -0500 Subject: [PATCH 375/489] Add new failing tests --- tests/failing-ui-tests.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index 2380bd0fc137..99a80fa7e4f4 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -88,3 +88,12 @@ tests/ui/test-attrs/test-panic-while-printing.rs tests/ui/thir-print/offset_of.rs tests/ui/iterators/rangefrom-overflow-debug.rs tests/ui/iterators/rangefrom-overflow-overflow-checks.rs +tests/ui/iterators/iter-filter-count-debug-check.rs +tests/ui/eii/codegen_single_crate.rs +tests/ui/eii/codegen_cross_crate.rs +tests/ui/eii/default/local_crate.rs +tests/ui/eii/multiple_impls.rs +tests/ui/eii/default/call_default.rs +tests/ui/eii/same-symbol.rs +tests/ui/eii/privacy1.rs +tests/ui/eii/default/call_impl.rs From 7ba8b145e8e0e93d87e641e5b50a09fc013bf1ad Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sat, 20 Dec 2025 22:43:35 +0000 Subject: [PATCH 376/489] fix: `if_then_some_else_none` suggests wrongly when then ends with comment --- clippy_lints/src/if_then_some_else_none.rs | 16 +++-- tests/ui/if_then_some_else_none.fixed | 42 ++++++++++-- tests/ui/if_then_some_else_none.rs | 13 ++++ tests/ui/if_then_some_else_none.stderr | 78 ++++++++++++++++++++-- 4 files changed, 133 insertions(+), 16 deletions(-) diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 314c8e1dd54c..9e5e4fa58d2f 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -109,13 +109,19 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone { .maybe_paren() .to_string(); let arg_snip = snippet_with_context(cx, then_arg.span, ctxt, "[body]", &mut app).0; - let method_body = if let Some(first_stmt) = then_block.stmts.first() - && let Some(first_stmt_span) = walk_span_to_context(first_stmt.span, ctxt) + let method_body = if let Some(_) = then_block.stmts.first() + && let Some(then_span) = walk_span_to_context(then.span, ctxt) { - let block_snippet = - snippet_with_applicability(cx, first_stmt_span.until(then_expr.span), "..", &mut app); + let block_before_snippet = + snippet_with_applicability(cx, then_span.until(then_expr.span), "..", &mut app); + let block_after_snippet = snippet_with_applicability( + cx, + then_expr.span.shrink_to_hi().until(then_span.shrink_to_hi()), + "..", + &mut app, + ); let closure = if method_name == sym::then { "|| " } else { "" }; - format!("{closure} {{ {} {arg_snip} }}", block_snippet.trim_end()) + format!("{closure}{block_before_snippet}{arg_snip}{block_after_snippet}") } else if method_name == sym::then { (std::borrow::Cow::Borrowed("|| ") + arg_snip).into_owned() } else { diff --git a/tests/ui/if_then_some_else_none.fixed b/tests/ui/if_then_some_else_none.fixed index 9d4cbe6baf07..ce122ac69b12 100644 --- a/tests/ui/if_then_some_else_none.fixed +++ b/tests/ui/if_then_some_else_none.fixed @@ -3,10 +3,20 @@ fn main() { // Should issue an error. - let _ = foo().then(|| { println!("true!"); "foo" }); + let _ = foo().then(|| { + //~^ if_then_some_else_none + + println!("true!"); + "foo" + }); // Should issue an error when macros are used. - let _ = matches!(true, true).then(|| { println!("true!"); matches!(true, false) }); + let _ = matches!(true, true).then(|| { + //~^ if_then_some_else_none + + println!("true!"); + matches!(true, false) + }); // Should issue an error. Binary expression `o < 32` should be parenthesized. let x = Some(5); @@ -71,7 +81,12 @@ fn _msrv_1_49() { #[clippy::msrv = "1.50"] fn _msrv_1_50() { - let _ = foo().then(|| { println!("true!"); 150 }); + let _ = foo().then(|| { + //~^ if_then_some_else_none + + println!("true!"); + 150 + }); } fn foo() -> bool { @@ -182,7 +197,10 @@ fn issue15005() { fn next(&mut self) -> Option { //~v if_then_some_else_none - (self.count < 5).then(|| { self.count += 1; self.count }) + (self.count < 5).then(|| { + self.count += 1; + self.count + }) } } } @@ -195,7 +213,10 @@ fn statements_from_macro() { }; } //~v if_then_some_else_none - let _ = true.then(|| { mac!(); 42 }); + let _ = true.then(|| { + mac!(); + 42 + }); } fn dont_lint_inside_macros() { @@ -228,3 +249,14 @@ mod issue16176 { if cond { Some(foo().await) } else { None } // OK } } + +fn issue16269() -> Option { + use std::cell::UnsafeCell; + + //~v if_then_some_else_none + (1 <= 3).then(|| { + let a = UnsafeCell::new(1); + // SAFETY: `bytes` bytes starting at `new_end` were just reserved. + unsafe { *a.get() } + }) +} diff --git a/tests/ui/if_then_some_else_none.rs b/tests/ui/if_then_some_else_none.rs index 6b1ece61e775..1d6c86d94492 100644 --- a/tests/ui/if_then_some_else_none.rs +++ b/tests/ui/if_then_some_else_none.rs @@ -284,3 +284,16 @@ mod issue16176 { if cond { Some(foo().await) } else { None } // OK } } + +fn issue16269() -> Option { + use std::cell::UnsafeCell; + + //~v if_then_some_else_none + if 1 <= 3 { + let a = UnsafeCell::new(1); + // SAFETY: `bytes` bytes starting at `new_end` were just reserved. + Some(unsafe { *a.get() }) + } else { + None + } +} diff --git a/tests/ui/if_then_some_else_none.stderr b/tests/ui/if_then_some_else_none.stderr index 58651a055942..eff5f8c82dcb 100644 --- a/tests/ui/if_then_some_else_none.stderr +++ b/tests/ui/if_then_some_else_none.stderr @@ -9,10 +9,19 @@ LL | | println!("true!"); ... | LL | | None LL | | }; - | |_____^ help: try: `foo().then(|| { println!("true!"); "foo" })` + | |_____^ | = note: `-D clippy::if-then-some-else-none` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::if_then_some_else_none)]` +help: try + | +LL ~ let _ = foo().then(|| { +LL + +LL + +LL + println!("true!"); +LL + "foo" +LL ~ }); + | error: this could be simplified with `bool::then` --> tests/ui/if_then_some_else_none.rs:16:13 @@ -25,7 +34,17 @@ LL | | println!("true!"); ... | LL | | None LL | | }; - | |_____^ help: try: `matches!(true, true).then(|| { println!("true!"); matches!(true, false) })` + | |_____^ + | +help: try + | +LL ~ let _ = matches!(true, true).then(|| { +LL + +LL + +LL + println!("true!"); +LL + matches!(true, false) +LL ~ }); + | error: this could be simplified with `bool::then_some` --> tests/ui/if_then_some_else_none.rs:27:28 @@ -50,7 +69,17 @@ LL | | println!("true!"); ... | LL | | None LL | | }; - | |_____^ help: try: `foo().then(|| { println!("true!"); 150 })` + | |_____^ + | +help: try + | +LL ~ let _ = foo().then(|| { +LL + +LL + +LL + println!("true!"); +LL + 150 +LL ~ }); + | error: this could be simplified with `bool::then` --> tests/ui/if_then_some_else_none.rs:138:5 @@ -125,7 +154,15 @@ LL | | Some(self.count) LL | | } else { LL | | None LL | | } - | |_____________^ help: try: `(self.count < 5).then(|| { self.count += 1; self.count })` + | |_____________^ + | +help: try + | +LL ~ (self.count < 5).then(|| { +LL + self.count += 1; +LL + self.count +LL + }) + | error: this could be simplified with `bool::then` --> tests/ui/if_then_some_else_none.rs:249:13 @@ -137,7 +174,36 @@ LL | | Some(42) LL | | } else { LL | | None LL | | }; - | |_____^ help: try: `true.then(|| { mac!(); 42 })` + | |_____^ + | +help: try + | +LL ~ let _ = true.then(|| { +LL + mac!(); +LL + 42 +LL ~ }); + | -error: aborting due to 13 previous errors +error: this could be simplified with `bool::then` + --> tests/ui/if_then_some_else_none.rs:292:5 + | +LL | / if 1 <= 3 { +LL | | let a = UnsafeCell::new(1); +LL | | // SAFETY: `bytes` bytes starting at `new_end` were just reserved. +LL | | Some(unsafe { *a.get() }) +LL | | } else { +LL | | None +LL | | } + | |_____^ + | +help: try + | +LL ~ (1 <= 3).then(|| { +LL + let a = UnsafeCell::new(1); +LL + // SAFETY: `bytes` bytes starting at `new_end` were just reserved. +LL + unsafe { *a.get() } +LL + }) + | + +error: aborting due to 14 previous errors From 86d3abf374ac49960b8669301195f57b634e54da Mon Sep 17 00:00:00 2001 From: jackh726 Date: Sat, 6 Dec 2025 18:54:02 +0000 Subject: [PATCH 377/489] Add lsp extension to get failed trait obligations for a given function --- src/tools/rust-analyzer/Cargo.lock | 2 + .../rust-analyzer/crates/hir-ty/Cargo.toml | 1 + .../rust-analyzer/crates/hir-ty/src/infer.rs | 14 ++- .../rust-analyzer/crates/hir-ty/src/lib.rs | 2 +- .../crates/hir-ty/src/next_solver.rs | 1 + .../src/next_solver/format_proof_tree.rs | 93 +++++++++++++++++++ .../crates/hir-ty/src/next_solver/fulfill.rs | 3 + .../crates/hir-ty/src/next_solver/infer/at.rs | 2 + .../hir-ty/src/next_solver/infer/mod.rs | 31 ++++++- .../hir-ty/src/next_solver/infer/traits.rs | 14 ++- .../crates/hir-ty/src/next_solver/inspect.rs | 9 +- .../rust-analyzer/crates/hir-ty/src/traits.rs | 25 ++++- src/tools/rust-analyzer/crates/hir/Cargo.toml | 1 + .../rust-analyzer/crates/hir/src/semantics.rs | 34 ++++++- src/tools/rust-analyzer/crates/ide/src/lib.rs | 14 ++- .../rust-analyzer/src/handlers/request.rs | 16 +++- .../crates/rust-analyzer/src/lsp/ext.rs | 15 +++ .../crates/rust-analyzer/src/main_loop.rs | 1 + .../rust-analyzer/tests/slow-tests/main.rs | 37 ++++++++ .../book/src/contributing/lsp-extensions.md | 13 ++- .../rust-analyzer/editors/code/package.json | 9 ++ .../editors/code/src/commands.ts | 12 +++ .../rust-analyzer/editors/code/src/lsp_ext.ts | 3 + .../rust-analyzer/editors/code/src/main.ts | 1 + 24 files changed, 337 insertions(+), 16 deletions(-) create mode 100644 src/tools/rust-analyzer/crates/hir-ty/src/next_solver/format_proof_tree.rs diff --git a/src/tools/rust-analyzer/Cargo.lock b/src/tools/rust-analyzer/Cargo.lock index 7ada91d2b65b..92a6c3e9764d 100644 --- a/src/tools/rust-analyzer/Cargo.lock +++ b/src/tools/rust-analyzer/Cargo.lock @@ -788,6 +788,7 @@ dependencies = [ "itertools 0.14.0", "ra-ap-rustc_type_ir", "rustc-hash 2.1.1", + "serde_json", "smallvec", "span", "stdx", @@ -901,6 +902,7 @@ dependencies = [ "rustc_apfloat", "salsa", "salsa-macros", + "serde", "smallvec", "span", "stdx", diff --git a/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml b/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml index c60ecef58eaf..e54a6190b44d 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml +++ b/src/tools/rust-analyzer/crates/hir-ty/Cargo.toml @@ -18,6 +18,7 @@ itertools.workspace = true arrayvec.workspace = true smallvec.workspace = true ena = "0.14.3" +serde.workspace = true either.workspace = true oorandom = "11.1.5" tracing = { workspace = true, features = ["attributes"] } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs index 4f739dc8eee0..d527a4ae29c2 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs @@ -75,7 +75,7 @@ use crate::{ AliasTy, Const, DbInterner, ErrorGuaranteed, GenericArg, GenericArgs, Region, StoredGenericArgs, StoredTy, StoredTys, Ty, TyKind, Tys, abi::Safety, - infer::{InferCtxt, traits::ObligationCause}, + infer::{InferCtxt, ObligationInspector, traits::ObligationCause}, }, traits::FnTrait, utils::TargetFeatureIsSafeInTarget, @@ -94,11 +94,23 @@ pub(crate) use closure::analysis::{CaptureKind, CapturedItem, CapturedItemWithou /// The entry point of type inference. fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult { + infer_query_with_inspect(db, def, None) +} + +pub fn infer_query_with_inspect<'db>( + db: &'db dyn HirDatabase, + def: DefWithBodyId, + inspect: Option>, +) -> InferenceResult { let _p = tracing::info_span!("infer_query").entered(); let resolver = def.resolver(db); let body = db.body(def); let mut ctx = InferenceContext::new(db, def, &body, resolver); + if let Some(inspect) = inspect { + ctx.table.infer_ctxt.attach_obligation_inspector(inspect); + } + match def { DefWithBodyId::FunctionId(f) => { ctx.collect_fn(f); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs index 6081196bacc2..1674771413f2 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lib.rs @@ -88,7 +88,7 @@ pub use infer::{ InferenceTyDiagnosticSource, OverloadedDeref, PointerCast, cast::CastError, closure::analysis::{CaptureKind, CapturedItem}, - could_coerce, could_unify, could_unify_deeply, + could_coerce, could_unify, could_unify_deeply, infer_query_with_inspect, }; pub use lower::{ GenericPredicates, ImplTraits, LifetimeElisionKind, TyDefId, TyLoweringContext, ValueTyDefId, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs index 298af7d12411..605e31404c57 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver.rs @@ -9,6 +9,7 @@ mod binder; mod consts; mod def_id; pub mod fold; +pub mod format_proof_tree; pub mod fulfill; mod generic_arg; pub mod generics; diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/format_proof_tree.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/format_proof_tree.rs new file mode 100644 index 000000000000..fa09cda234c1 --- /dev/null +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/format_proof_tree.rs @@ -0,0 +1,93 @@ +use rustc_type_ir::{solve::GoalSource, solve::inspect::GoalEvaluation}; +use serde::{Deserialize, Serialize}; + +use crate::next_solver::infer::InferCtxt; +use crate::next_solver::inspect::{InspectCandidate, InspectGoal}; +use crate::next_solver::{DbInterner, Span}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ProofTreeData { + pub goal: String, + pub result: String, + pub depth: usize, + pub candidates: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CandidateData { + pub kind: String, + pub result: String, + pub impl_header: Option, + pub nested_goals: Vec, +} + +pub fn dump_proof_tree_structured<'db>( + proof_tree: GoalEvaluation>, + _span: Span, + infcx: &InferCtxt<'db>, +) -> ProofTreeData { + let goal_eval = InspectGoal::new(infcx, 0, proof_tree, None, GoalSource::Misc); + let mut serializer = ProofTreeSerializer::new(infcx); + serializer.serialize_goal(&goal_eval) +} + +struct ProofTreeSerializer<'a, 'db> { + infcx: &'a InferCtxt<'db>, +} + +impl<'a, 'db> ProofTreeSerializer<'a, 'db> { + fn new(infcx: &'a InferCtxt<'db>) -> Self { + Self { infcx } + } + + fn serialize_goal(&mut self, goal: &InspectGoal<'_, 'db>) -> ProofTreeData { + let candidates = goal.candidates(); + let candidates_data: Vec = + candidates.iter().map(|c| self.serialize_candidate(c)).collect(); + + ProofTreeData { + goal: format!("{:?}", goal.goal()), + result: format!("{:?}", goal.result()), + depth: goal.depth(), + candidates: candidates_data, + } + } + + fn serialize_candidate(&mut self, candidate: &InspectCandidate<'_, 'db>) -> CandidateData { + let kind = candidate.kind(); + let impl_header = self.get_impl_header(candidate); + + let mut nested = Vec::new(); + self.infcx.probe(|_| { + for nested_goal in candidate.instantiate_nested_goals() { + nested.push(self.serialize_goal(&nested_goal)); + } + }); + + CandidateData { + kind: format!("{:?}", kind), + result: format!("{:?}", candidate.result()), + impl_header, + nested_goals: nested, + } + } + + fn get_impl_header(&self, candidate: &InspectCandidate<'_, 'db>) -> Option { + use rustc_type_ir::solve::inspect::ProbeKind; + match candidate.kind() { + ProbeKind::TraitCandidate { source, .. } => { + use rustc_type_ir::solve::CandidateSource; + match source { + CandidateSource::Impl(impl_def_id) => { + use hir_def::{Lookup, src::HasSource}; + let db = self.infcx.interner.db; + let impl_src = impl_def_id.0.lookup(db).source(db); + Some(impl_src.value.to_string()) + } + _ => None, + } + } + _ => None, + } + } +} diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs index 4a19e30c64f7..0fe073297279 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/fulfill.rs @@ -187,6 +187,9 @@ impl<'db> FulfillmentCtxt<'db> { } let result = delegate.evaluate_root_goal(goal, Span::dummy(), stalled_on); + infcx.inspect_evaluated_obligation(&obligation, &result, || { + Some(delegate.evaluate_root_goal_for_proof_tree(goal, Span::dummy()).1) + }); let GoalEvaluation { goal: _, certainty, has_changed, stalled_on } = match result { Ok(result) => result, Err(NoSolution) => { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs index 6ba1aae2d486..dc0b584084e8 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/at.rs @@ -68,6 +68,7 @@ impl<'db> InferCtxt<'db> { inner: self.inner.clone(), tainted_by_errors: self.tainted_by_errors.clone(), universe: self.universe.clone(), + obligation_inspector: self.obligation_inspector.clone(), } } @@ -84,6 +85,7 @@ impl<'db> InferCtxt<'db> { inner: self.inner.clone(), tainted_by_errors: self.tainted_by_errors.clone(), universe: self.universe.clone(), + obligation_inspector: self.obligation_inspector.clone(), } } } diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs index 14b8a61088d8..2926dc30def7 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/mod.rs @@ -10,8 +10,9 @@ use ena::unify as ut; use hir_def::GenericParamId; use opaque_types::{OpaqueHiddenType, OpaqueTypeStorage}; use region_constraints::{RegionConstraintCollector, RegionConstraintStorage}; -use rustc_next_trait_solver::solve::SolverDelegateEvalExt; +use rustc_next_trait_solver::solve::{GoalEvaluation, SolverDelegateEvalExt}; use rustc_pattern_analysis::Captures; +use rustc_type_ir::solve::{NoSolution, inspect}; use rustc_type_ir::{ ClosureKind, ConstVid, FloatVarValue, FloatVid, GenericArgKind, InferConst, InferTy, IntVarValue, IntVid, OutlivesPredicate, RegionVid, TermKind, TyVid, TypeFoldable, TypeFolder, @@ -27,6 +28,7 @@ use traits::{ObligationCause, PredicateObligations}; use type_variable::TypeVariableOrigin; use unify_key::{ConstVariableOrigin, ConstVariableValue, ConstVidKey}; +pub use crate::next_solver::infer::traits::ObligationInspector; use crate::next_solver::{ ArgOutlivesPredicate, BoundConst, BoundRegion, BoundTy, BoundVarKind, Goal, Predicate, SolverContext, @@ -250,6 +252,8 @@ pub struct InferCtxt<'db> { /// when we enter into a higher-ranked (`for<..>`) type or trait /// bound. universe: Cell, + + obligation_inspector: Cell>>, } /// See the `error_reporting` module for more details. @@ -375,6 +379,7 @@ impl<'db> InferCtxtBuilder<'db> { inner: RefCell::new(InferCtxtInner::new()), tainted_by_errors: Cell::new(None), universe: Cell::new(UniverseIndex::ROOT), + obligation_inspector: Cell::new(None), } } } @@ -1223,6 +1228,30 @@ impl<'db> InferCtxt<'db> { fn sub_unify_ty_vids_raw(&self, a: rustc_type_ir::TyVid, b: rustc_type_ir::TyVid) { self.inner.borrow_mut().type_variables().sub_unify(a, b); } + + /// Attach a callback to be invoked on each root obligation evaluated in the new trait solver. + pub fn attach_obligation_inspector(&self, inspector: ObligationInspector<'db>) { + debug_assert!( + self.obligation_inspector.get().is_none(), + "shouldn't override a set obligation inspector" + ); + self.obligation_inspector.set(Some(inspector)); + } + + pub fn inspect_evaluated_obligation( + &self, + obligation: &PredicateObligation<'db>, + result: &Result>, NoSolution>, + get_proof_tree: impl FnOnce() -> Option>>, + ) { + if let Some(inspector) = self.obligation_inspector.get() { + let result = match result { + Ok(GoalEvaluation { certainty, .. }) => Ok(*certainty), + Err(_) => Err(NoSolution), + }; + (inspector)(self, obligation, result, get_proof_tree()); + } + } } /// Helper for [InferCtxt::ty_or_const_infer_var_changed] (see comment on that), currently diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/traits.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/traits.rs index 3409de17a122..14df42dc2aeb 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/traits.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/traits.rs @@ -9,8 +9,11 @@ use std::{ use hir_def::TraitId; use macros::{TypeFoldable, TypeVisitable}; -use rustc_type_ir::Upcast; use rustc_type_ir::elaborate::Elaboratable; +use rustc_type_ir::{ + Upcast, + solve::{Certainty, NoSolution, inspect}, +}; use tracing::debug; use crate::next_solver::{ @@ -79,6 +82,15 @@ pub struct Obligation<'db, T> { pub recursion_depth: usize, } +/// A callback that can be provided to `inspect_typeck`. Invoked on evaluation +/// of root obligations. +pub type ObligationInspector<'db> = fn( + &InferCtxt<'db>, + &PredicateObligation<'db>, + Result, + Option>>, +); + /// For [`Obligation`], a sub-obligation is combined with the current obligation's /// param-env and cause code. impl<'db> Elaboratable> for PredicateObligation<'db> { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/inspect.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/inspect.rs index d66aa9f277c7..528697754959 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/inspect.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/inspect.rs @@ -74,7 +74,7 @@ impl<'a, 'db> std::fmt::Debug for InspectCandidate<'a, 'db> { /// treat `NormalizesTo` goals as if they apply the expected /// type at the end of each candidate. #[derive(Debug, Copy, Clone)] -struct NormalizesToTermHack<'db> { +pub(crate) struct NormalizesToTermHack<'db> { term: Term<'db>, unconstrained_term: Term<'db>, } @@ -311,10 +311,7 @@ impl<'a, 'db> InspectCandidate<'a, 'db> { /// Visit all nested goals of this candidate, rolling back /// all inference constraints. #[expect(dead_code, reason = "used in rustc")] - pub(crate) fn visit_nested_in_probe>( - &self, - visitor: &mut V, - ) -> V::Result { + fn visit_nested_in_probe>(&self, visitor: &mut V) -> V::Result { self.goal.infcx.probe(|_| self.visit_nested_no_probe(visitor)) } } @@ -430,7 +427,7 @@ impl<'a, 'db> InspectGoal<'a, 'db> { candidates.pop().filter(|_| candidates.is_empty()) } - fn new( + pub(crate) fn new( infcx: &'a InferCtxt<'db>, depth: usize, root: inspect::GoalEvaluation>, diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs b/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs index ad8de293d5a5..fb598fe5acb0 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/traits.rs @@ -23,7 +23,10 @@ use crate::{ next_solver::{ Canonical, DbInterner, GenericArgs, Goal, ParamEnv, Predicate, SolverContext, Span, StoredClauses, Ty, TyKind, - infer::{DbInternerInferExt, InferCtxt, traits::ObligationCause}, + infer::{ + DbInternerInferExt, InferCtxt, + traits::{Obligation, ObligationCause}, + }, obligation_ctxt::ObligationCtxt, }, }; @@ -107,6 +110,16 @@ pub fn next_trait_solve_canonical_in_ctxt<'db>( let res = context.evaluate_root_goal(goal, Span::dummy(), None); + let obligation = Obligation { + cause: ObligationCause::dummy(), + param_env: goal.param_env, + recursion_depth: 0, + predicate: goal.predicate, + }; + infer_ctxt.inspect_evaluated_obligation(&obligation, &res, || { + Some(context.evaluate_root_goal_for_proof_tree(goal, Span::dummy()).1) + }); + let res = res.map(|r| (r.has_changed, r.certainty)); tracing::debug!("solve_nextsolver({:?}) => {:?}", goal, res); @@ -130,6 +143,16 @@ pub fn next_trait_solve_in_ctxt<'db, 'a>( let res = context.evaluate_root_goal(goal, Span::dummy(), None); + let obligation = Obligation { + cause: ObligationCause::dummy(), + param_env: goal.param_env, + recursion_depth: 0, + predicate: goal.predicate, + }; + infer_ctxt.inspect_evaluated_obligation(&obligation, &res, || { + Some(context.evaluate_root_goal_for_proof_tree(goal, Span::dummy()).1) + }); + let res = res.map(|r| (r.has_changed, r.certainty)); tracing::debug!("solve_nextsolver({:?}) => {:?}", goal, res); diff --git a/src/tools/rust-analyzer/crates/hir/Cargo.toml b/src/tools/rust-analyzer/crates/hir/Cargo.toml index 24b2bd9150ee..d20ee1546fa4 100644 --- a/src/tools/rust-analyzer/crates/hir/Cargo.toml +++ b/src/tools/rust-analyzer/crates/hir/Cargo.toml @@ -17,6 +17,7 @@ rustc-hash.workspace = true either.workspace = true arrayvec.workspace = true itertools.workspace = true +serde_json.workspace = true smallvec.workspace = true tracing = { workspace = true, features = ["attributes"] } triomphe.workspace = true diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs index fd08528e86ab..60418b1dad49 100644 --- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs @@ -8,6 +8,7 @@ use std::{ convert::Infallible, fmt, iter, mem, ops::{self, ControlFlow, Not}, + sync::Mutex, }; use base_db::FxIndexSet; @@ -32,11 +33,13 @@ use hir_expand::{ use hir_ty::{ InferenceResult, diagnostics::{unsafe_operations, unsafe_operations_for_body}, - next_solver::DbInterner, + infer_query_with_inspect, + next_solver::{DbInterner, Span, format_proof_tree::dump_proof_tree_structured}, }; use intern::{Interned, Symbol, sym}; use itertools::Itertools; use rustc_hash::{FxHashMap, FxHashSet}; +use rustc_type_ir::inherent::Span as _; use smallvec::{SmallVec, smallvec}; use span::{FileId, SyntaxContext}; use stdx::{TupleExt, always}; @@ -2310,6 +2313,35 @@ impl<'db> SemanticsImpl<'db> { Some(locals) } + + pub fn get_failed_obligations(&self, token: SyntaxToken) -> Option { + let node = token.parent()?; + let node = self.find_file(&node); + + let container = self.with_ctx(|ctx| ctx.find_container(node))?; + + match container { + ChildContainer::DefWithBodyId(def) => { + static RESULT: Mutex = Mutex::new(String::new()); + infer_query_with_inspect( + self.db, + def, + Some(|infer_ctxt, _obligation, result, proof_tree| { + if result.is_err() + && let Some(tree) = proof_tree + { + let data = dump_proof_tree_structured(tree, Span::dummy(), infer_ctxt); + let data = serde_json::to_string_pretty(&data) + .unwrap_or_else(|_| "{}".to_string()); + *RESULT.lock().unwrap() = data; + } + }), + ); + RESULT.lock().ok().map(|s| (*s).clone()) + } + _ => None, + } + } } // FIXME This can't be the best way to do this diff --git a/src/tools/rust-analyzer/crates/ide/src/lib.rs b/src/tools/rust-analyzer/crates/ide/src/lib.rs index 0066ceed21ed..5e4d930393af 100644 --- a/src/tools/rust-analyzer/crates/ide/src/lib.rs +++ b/src/tools/rust-analyzer/crates/ide/src/lib.rs @@ -73,7 +73,7 @@ use ide_db::{ }; use ide_db::{MiniCore, ra_fixture::RaFixtureAnalysis}; use macros::UpmapFromRaFixture; -use syntax::{SourceFile, ast}; +use syntax::{AstNode, SourceFile, ast}; use triomphe::Arc; use view_memory_layout::{RecursiveMemoryLayout, view_memory_layout}; @@ -905,6 +905,18 @@ impl Analysis { self.with_db(|db| view_memory_layout(db, position)) } + pub fn get_failed_obligations(&self, offset: TextSize, file_id: FileId) -> Cancellable { + self.with_db(|db| { + let sema = Semantics::new(db); + let source_file = sema.parse_guess_edition(file_id); + + let Some(token) = source_file.syntax().token_at_offset(offset).next() else { + return String::new(); + }; + sema.get_failed_obligations(token).unwrap_or_default() + }) + } + pub fn editioned_file_id_to_vfs(&self, file_id: hir::EditionedFileId) -> FileId { file_id.file_id(&self.db) } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs index d15b519d6983..4d97505768a2 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs @@ -42,8 +42,8 @@ use crate::{ lsp::{ LspError, completion_item_hash, ext::{ - InternalTestingFetchConfigOption, InternalTestingFetchConfigParams, - InternalTestingFetchConfigResponse, + GetFailedObligationsParams, InternalTestingFetchConfigOption, + InternalTestingFetchConfigParams, InternalTestingFetchConfigResponse, }, from_proto, to_proto, utils::{all_edits_are_disjoint, invalid_params_error}, @@ -2575,6 +2575,18 @@ pub(crate) fn internal_testing_fetch_config( })) } +pub(crate) fn get_failed_obligations( + snap: GlobalStateSnapshot, + params: GetFailedObligationsParams, +) -> anyhow::Result { + let _p = tracing::info_span!("get_failed_obligations").entered(); + let file_id = try_default!(from_proto::file_id(&snap, ¶ms.text_document.uri)?); + let line_index = snap.file_line_index(file_id)?; + let offset = from_proto::offset(&line_index, params.position)?; + + Ok(snap.analysis.get_failed_obligations(offset, file_id)?) +} + /// Searches for the directory of a Rust crate given this crate's root file path. /// /// # Arguments diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs index b132323bec5b..e6493eefef17 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs @@ -864,3 +864,18 @@ pub struct CompletionImport { pub struct ClientCommandOptions { pub commands: Vec, } + +pub enum GetFailedObligations {} + +#[derive(Deserialize, Serialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct GetFailedObligationsParams { + pub text_document: TextDocumentIdentifier, + pub position: Position, +} + +impl Request for GetFailedObligations { + type Params = GetFailedObligationsParams; + type Result = String; + const METHOD: &'static str = "rust-analyzer/getFailedObligations"; +} diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs index 1a1c0182f87a..6e08b7bb88d4 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs @@ -1328,6 +1328,7 @@ impl GlobalState { .on::(handlers::handle_move_item) // .on::(handlers::internal_testing_fetch_config) + .on::(handlers::get_failed_obligations) .finish(); } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs index 48433342d51d..0754e80b1560 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs @@ -1488,3 +1488,40 @@ version = "0.0.0" server.request::(Default::default(), json!([])); } + +#[test] +fn test_get_failed_obligations() { + use expect_test::expect; + if skip_slow_tests() { + return; + } + + let server = Project::with_fixture( + r#" +//- /Cargo.toml +[package] +name = "foo" +version = "0.0.0" + +//- /src/lib.rs +trait Trait {} +fn requires_trait(x: T) {} + +fn test() { + requires_trait(0usize); +} +"#, + ) + .server() + .wait_until_workspace_is_loaded(); + + let res = server.send_request::( + rust_analyzer::lsp::ext::GetFailedObligationsParams { + text_document: server.doc_id("src/lib.rs"), + position: Position::new(4, 19), + }, + ); + + expect![[r#""{\n \"goal\": \"Goal { param_env: ParamEnv { clauses: [] }, predicate: Binder { value: TraitPredicate(usize: Trait, polarity:Positive), bound_vars: [] } }\",\n \"result\": \"Err(NoSolution)\",\n \"depth\": 0,\n \"candidates\": []\n}""#]] + .assert_eq(&res.to_string()); +} diff --git a/src/tools/rust-analyzer/docs/book/src/contributing/lsp-extensions.md b/src/tools/rust-analyzer/docs/book/src/contributing/lsp-extensions.md index 5922f0b551d6..5d21c37806dd 100644 --- a/src/tools/rust-analyzer/docs/book/src/contributing/lsp-extensions.md +++ b/src/tools/rust-analyzer/docs/book/src/contributing/lsp-extensions.md @@ -1,5 +1,5 @@ RUSTLIB/std/src/thread/mod.rs:LL:CC - | -LL | match COUNTER.compare_exchange_weak(last, id, Ordering::Relaxed, Ordering::Relaxed) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GenMC might miss possible behaviors of this code - | - = note: BACKTRACE: - = note: inside `std::thread::ThreadId::new` at RUSTLIB/std/src/thread/mod.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC - = note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC - = note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC - = note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panicking::catch_unwind::` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC - = note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC - -warning: GenMC currently does not model the failure ordering for `compare_exchange`. Due to success ordering 'Acquire', the failure ordering 'Relaxed' is treated like 'Acquire'. Miri with GenMC might miss bugs related to this memory access. - --> RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC - | -LL | || self - | ________________^ -LL | | .state -LL | | .compare_exchange_weak(state, state + READ_LOCKED, Acquire, Relaxed) - | |____________________________________________________________________________________^ GenMC might miss possible behaviors of this code - | - = note: BACKTRACE: - = note: inside `std::sys::sync::PLATFORM::futex::RwLock::read` at RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC - = note: inside `std::sync::RwLock::<()>::read` at RUSTLIB/std/src/sync/poison/rwlock.rs:LL:CC - = note: inside `std::sys::env::PLATFORM::env_read_lock` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC - = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC - = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC - = note: inside `std::sys::env::PLATFORM::getenv` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC - = note: inside `std::env::_var_os` at RUSTLIB/std/src/env.rs:LL:CC - = note: inside `std::env::var_os::<&str>` at RUSTLIB/std/src/env.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/thread/mod.rs:LL:CC -note: inside `main` - --> tests/genmc/fail/shims/exit.rs:LL:CC - | -LL | / std::thread::spawn(|| { -LL | | unsafe { std::hint::unreachable_unchecked() }; -LL | | }); - | |______^ - -warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures. - --> RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC - | -LL | || self - | ________________^ -LL | | .state -LL | | .compare_exchange_weak(state, state + READ_LOCKED, Acquire, Relaxed) - | |____________________________________________________________________________________^ GenMC might miss possible behaviors of this code - | - = note: BACKTRACE: - = note: inside `std::sys::sync::PLATFORM::futex::RwLock::read` at RUSTLIB/std/src/sys/sync/PLATFORM/futex.rs:LL:CC - = note: inside `std::sync::RwLock::<()>::read` at RUSTLIB/std/src/sync/poison/rwlock.rs:LL:CC - = note: inside `std::sys::env::PLATFORM::env_read_lock` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC - = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr_stack::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC - = note: inside `std::sys::pal::PLATFORM::small_c_string::run_with_cstr::>` at RUSTLIB/std/src/sys/pal/PLATFORM/small_c_string.rs:LL:CC - = note: inside `std::sys::env::PLATFORM::getenv` at RUSTLIB/std/src/sys/env/PLATFORM.rs:LL:CC - = note: inside `std::env::_var_os` at RUSTLIB/std/src/env.rs:LL:CC - = note: inside `std::env::var_os::<&str>` at RUSTLIB/std/src/env.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/thread/mod.rs:LL:CC -note: inside `main` - --> tests/genmc/fail/shims/exit.rs:LL:CC - | -LL | / std::thread::spawn(|| { -LL | | unsafe { std::hint::unreachable_unchecked() }; -LL | | }); - | |______^ - -warning: GenMC currently does not model spurious failures of `compare_exchange_weak`. Miri with GenMC might miss bugs related to spurious failures. - --> RUSTLIB/std/src/rt.rs:LL:CC - | -LL | / CLEANUP.call_once(|| unsafe { -LL | | // Flush stdout and disable buffering. -LL | | crate::io::cleanup(); -... | -LL | | }); - | |______^ GenMC might miss possible behaviors of this code - | - = note: BACKTRACE: - = note: inside `std::rt::cleanup` at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::process::exit` at RUSTLIB/std/src/process.rs:LL:CC -note: inside `main` - --> tests/genmc/fail/shims/exit.rs:LL:CC - | -LL | std::process::exit(0); - | ^^^^^^^^^^^^^^^^^^^^^ - -warning: GenMC currently does not model the failure ordering for `compare_exchange`. Due to success ordering 'Acquire', the failure ordering 'Relaxed' is treated like 'Acquire'. Miri with GenMC might miss bugs related to this memory access. - --> RUSTLIB/std/src/sys/exit_guard.rs:LL:CC - | -LL | match EXITING_THREAD_ID.compare_exchange(ptr::null_mut(), this_thread_id, Acquire, Relaxed) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ GenMC might miss possible behaviors of this code - | - = note: BACKTRACE: - = note: inside `std::sys::exit_guard::unique_thread_exit` at RUSTLIB/std/src/sys/exit_guard.rs:LL:CC - = note: inside `std::sys::pal::PLATFORM::os::exit` at RUSTLIB/std/src/sys/pal/PLATFORM/os.rs:LL:CC - = note: inside `std::process::exit` at RUSTLIB/std/src/process.rs:LL:CC -note: inside `main` - --> tests/genmc/fail/shims/exit.rs:LL:CC - | -LL | std::process::exit(0); - | ^^^^^^^^^^^^^^^^^^^^^ - error: Undefined Behavior: entering unreachable code --> tests/genmc/fail/shims/exit.rs:LL:CC | @@ -122,5 +12,5 @@ note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a note: add `-Zmiri-genmc-print-genmc-output` to MIRIFLAGS to see the detailed GenMC error report -error: aborting due to 1 previous error; 5 warnings emitted +error: aborting due to 1 previous error From e1f7a22e50bdf640ecbdc522ec38e8dc8fc436e3 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 21 Dec 2025 14:11:48 +0100 Subject: [PATCH 390/489] Call out feature freeze on IDE assists --- src/tools/rust-analyzer/CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/rust-analyzer/CONTRIBUTING.md b/src/tools/rust-analyzer/CONTRIBUTING.md index cac352feb180..35d03780c1d5 100644 --- a/src/tools/rust-analyzer/CONTRIBUTING.md +++ b/src/tools/rust-analyzer/CONTRIBUTING.md @@ -1,3 +1,8 @@ +> [!IMPORTANT] +> We have enacted a feature freeze for IDE assists to cope with the PR backlog as well as allowing us to prepare for the rowan transition! +> If you submit a PR that **adds** new ide-assists, chances are very high that we will just close it on this basis alone until we have the capacity to deal with them again. + + # Contributing to rust-analyzer Thank you for your interest in contributing to rust-analyzer! There are many ways to contribute From 37af3f647b4f7e464577d8cc3cd5fb080a827ed9 Mon Sep 17 00:00:00 2001 From: dianqk Date: Sun, 21 Dec 2025 21:32:06 +0800 Subject: [PATCH 391/489] GVN: Adds the `insert_unique` method --- compiler/rustc_mir_transform/src/gvn.rs | 43 ++++++++++++------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 526d0e96a36d..0d458402c951 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -420,6 +420,19 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { self.ecx.typing_env() } + fn insert_unique( + &mut self, + ty: Ty<'tcx>, + value: impl FnOnce(VnOpaque) -> Value<'a, 'tcx>, + ) -> VnIndex { + let index = self.values.insert_unique(ty, value); + let _index = self.evaluated.push(None); + debug_assert_eq!(index, _index); + let _index = self.rev_locals.push(SmallVec::new()); + debug_assert_eq!(index, _index); + index + } + #[instrument(level = "trace", skip(self), ret)] fn insert(&mut self, ty: Ty<'tcx>, value: Value<'a, 'tcx>) -> VnIndex { let (index, new) = self.values.insert(ty, value); @@ -437,11 +450,8 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { /// from all the others. #[instrument(level = "trace", skip(self), ret)] fn new_opaque(&mut self, ty: Ty<'tcx>) -> VnIndex { - let index = self.values.insert_unique(ty, Value::Opaque); - let _index = self.evaluated.push(Some(None)); - debug_assert_eq!(index, _index); - let _index = self.rev_locals.push(SmallVec::new()); - debug_assert_eq!(index, _index); + let index = self.insert_unique(ty, Value::Opaque); + self.evaluated[index] = Some(None); index } @@ -470,42 +480,29 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> { projection.map(|proj| proj.try_map(|index| self.locals[index], |ty| ty).ok_or(())); let projection = self.arena.try_alloc_from_iter(projection).ok()?; - let index = self.values.insert_unique(ty, |provenance| Value::Address { + let index = self.insert_unique(ty, |provenance| Value::Address { base, projection, kind, provenance, }); - let _index = self.evaluated.push(None); - debug_assert_eq!(index, _index); - let _index = self.rev_locals.push(SmallVec::new()); - debug_assert_eq!(index, _index); - Some(index) } #[instrument(level = "trace", skip(self), ret)] fn insert_constant(&mut self, value: Const<'tcx>) -> VnIndex { - let (index, new) = if value.is_deterministic() { + if value.is_deterministic() { // The constant is deterministic, no need to disambiguate. let constant = Value::Constant { value, disambiguator: None }; - self.values.insert(value.ty(), constant) + self.insert(value.ty(), constant) } else { // Multiple mentions of this constant will yield different values, // so assign a different `disambiguator` to ensure they do not get the same `VnIndex`. - let index = self.values.insert_unique(value.ty(), |disambiguator| Value::Constant { + self.insert_unique(value.ty(), |disambiguator| Value::Constant { value, disambiguator: Some(disambiguator), - }); - (index, true) - }; - if new { - let _index = self.evaluated.push(None); - debug_assert_eq!(index, _index); - let _index = self.rev_locals.push(SmallVec::new()); - debug_assert_eq!(index, _index); + }) } - index } #[inline] From 74af408790acb796ece9aee438b87408ee15a240 Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Sun, 21 Dec 2025 18:24:44 +0800 Subject: [PATCH 392/489] rustdoc: handle macro expansions in types --- compiler/rustc_ast_pretty/src/pprust/mod.rs | 3 +++ src/librustdoc/html/macro_expansion.rs | 12 +++++++-- .../macro-expansion/type-macro-expansion.rs | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/rustdoc/macro-expansion/type-macro-expansion.rs diff --git a/compiler/rustc_ast_pretty/src/pprust/mod.rs b/compiler/rustc_ast_pretty/src/pprust/mod.rs index a766e2006e59..74ed0405498d 100644 --- a/compiler/rustc_ast_pretty/src/pprust/mod.rs +++ b/compiler/rustc_ast_pretty/src/pprust/mod.rs @@ -33,6 +33,9 @@ pub fn where_bound_predicate_to_string(where_bound_predicate: &ast::WhereBoundPr State::new().where_bound_predicate_to_string(where_bound_predicate) } +/// # Panics +/// +/// Panics if `pat.kind` is `PatKind::Missing`. pub fn pat_to_string(pat: &ast::Pat) -> String { State::new().pat_to_string(pat) } diff --git a/src/librustdoc/html/macro_expansion.rs b/src/librustdoc/html/macro_expansion.rs index 9098e92a5cd4..d3c91be3a280 100644 --- a/src/librustdoc/html/macro_expansion.rs +++ b/src/librustdoc/html/macro_expansion.rs @@ -1,5 +1,5 @@ -use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt}; -use rustc_ast::{Crate, Expr, Item, Pat, Stmt}; +use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt, walk_ty}; +use rustc_ast::{Crate, Expr, Item, Pat, Stmt, Ty}; use rustc_data_structures::fx::FxHashMap; use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, Span}; @@ -153,4 +153,12 @@ impl<'ast> Visitor<'ast> for ExpandedCodeVisitor<'ast> { walk_pat(self, pat); } } + + fn visit_ty(&mut self, ty: &'ast Ty) { + if ty.span.from_expansion() { + self.handle_new_span(ty.span, || rustc_ast_pretty::pprust::ty_to_string(ty)); + } else { + walk_ty(self, ty); + } + } } diff --git a/tests/rustdoc/macro-expansion/type-macro-expansion.rs b/tests/rustdoc/macro-expansion/type-macro-expansion.rs new file mode 100644 index 000000000000..d7d28fdac666 --- /dev/null +++ b/tests/rustdoc/macro-expansion/type-macro-expansion.rs @@ -0,0 +1,27 @@ +// Ensure macro invocations at type position are expanded correctly + +//@ compile-flags: -Zunstable-options --generate-macro-expansion + +#![crate_name = "foo"] + +//@ has 'src/foo/type-macro-expansion.rs.html' + +macro_rules! foo { + () => { + fn(()) + }; + ($_arg:expr) => { + [(); 1] + }; +} + +fn bar() { + //@ has - '//*[@class="expansion"]/*[@class="original"]/*[@class="macro"]' 'foo!' + //@ has - '//*[@class="expansion"]/*[@class="original"]' 'foo!()' + //@ has - '//*[@class="expansion"]/*[@class="expanded"]' 'fn(())' + let _: foo!(); + //@ has - '//*[@class="expansion"]/*[@class="original"]/*[@class="macro"]' 'foo!' + //@ has - '//*[@class="expansion"]/*[@class="original"]' 'foo!(42)' + //@ has - '//*[@class="expansion"]/*[@class="expanded"]' '[(); 1]' + let _: foo!(42); +} From d2eaec9e258f4e02989b23cfecda681e05101307 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sun, 21 Dec 2025 08:46:13 -0700 Subject: [PATCH 393/489] Clean up needlessly complex math and conditions Co-authored-by: Guillaume Gomez --- src/librustdoc/html/static/js/stringdex.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/static/js/stringdex.js b/src/librustdoc/html/static/js/stringdex.js index d04fd6c0e451..e45c8bcd653b 100644 --- a/src/librustdoc/html/static/js/stringdex.js +++ b/src/librustdoc/html/static/js/stringdex.js @@ -57,7 +57,7 @@ class RoaringBitmap { } else if (u8array[i] > 0xe0) { // Special representation of tiny sets that are runs const lspecial = u8array[i] & 0x0f; - this.keysAndCardinalities = new Uint8Array(lspecial * 4); + this.keysAndCardinalities = new Uint8Array(lspecial << 2); i += 1; const key = u8array[i + 2] | (u8array[i + 3] << 8); const value = u8array[i] | (u8array[i + 1] << 8); @@ -74,7 +74,7 @@ class RoaringBitmap { } else if (u8array[i] > 0xd0) { // Special representation of tiny sets that are close together const lspecial = u8array[i] & 0x0f; - this.keysAndCardinalities = new Uint8Array(lspecial * 4); + this.keysAndCardinalities = new Uint8Array(lspecial << 2); let pspecial = i + 1; let key = u8array[pspecial + 2] | (u8array[pspecial + 3] << 8); let value = u8array[pspecial] | (u8array[pspecial + 1] << 8); @@ -93,8 +93,8 @@ class RoaringBitmap { key = entry >> 16; container = this.addToArrayAt(key); const cardinalityOld = container.cardinality; - container.array[cardinalityOld * 2] = value & 0xFF; - container.array[(cardinalityOld * 2) + 1] = (value >> 8) & 0xFF; + container.array[cardinalityOld << 1] = value & 0xFF; + container.array[(cardinalityOld << 1) + 1] = (value >> 8) & 0xFF; container.cardinality = cardinalityOld + 1; pspecial += 1; } @@ -2409,7 +2409,7 @@ function loadDatabase(hooks) { encoded.subarray(i, i + (branch_leaves_count * 2)), ), ]; - i += branch_leaves_count * 2; + i += branch_leaves_count << 1; } branch_nodes.push(Promise.resolve( is_suffixes_only ? @@ -2465,7 +2465,7 @@ function loadDatabase(hooks) { encoded.subarray(i, i + (leaves_count * 2)), ), ]; - i += leaves_count * 2; + i += leaves_count << 1; } } return is_suffixes_only ? @@ -3054,8 +3054,7 @@ function loadDatabase(hooks) { const leaves_count = no_leaves_flag !== 0 ? 0 : ((compression_tag >> 4) & 0x07) + 1; - const leaves_is_run = no_leaves_flag !== 0 ? - false : + const leaves_is_run = no_leaves_flag === 0 && ((compression_tag >> 4) & 0x08) !== 0; const branch_count = is_long_compressed ? ((compression_tag >> 8) & 0xff) + 1 : @@ -3086,7 +3085,7 @@ function loadDatabase(hooks) { if (branch_leaves_is_run) { i += 2; } else { - i += branch_leaves_count * 2; + i += branch_leaves_count << 1; } } // branch keys @@ -3095,7 +3094,7 @@ function loadDatabase(hooks) { if (leaves_is_run) { i += 2; } else { - i += leaves_count * 2; + i += leaves_count << 1; } if (is_data_compressed) { const clen = ( From 38c667265b18caa3b0d0ac2b281c4ea928ee3459 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Sun, 21 Dec 2025 21:35:10 +0100 Subject: [PATCH 394/489] add `expected_non_empty_string_literal` to attribute parser Signed-off-by: Edvin Bryntesson --- compiler/rustc_attr_parsing/src/context.rs | 4 ++++ compiler/rustc_attr_parsing/src/session_diagnostics.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index df4970d8aa90..9aa0729c5790 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -498,6 +498,10 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { self.emit_parse_error(span, AttributeParseErrorReason::ExpectedNameValueOrNoArgs) } + pub(crate) fn expected_non_empty_string_literal(&self, span: Span) -> ErrorGuaranteed { + self.emit_parse_error(span, AttributeParseErrorReason::ExpectedNonEmptyStringLiteral) + } + pub(crate) fn expected_no_args(&self, span: Span) -> ErrorGuaranteed { self.emit_parse_error(span, AttributeParseErrorReason::ExpectedNoArgs) } diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index 73b65193fd34..d9998a15f233 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -521,6 +521,7 @@ pub(crate) enum AttributeParseErrorReason<'a> { ExpectedList, ExpectedListOrNoArgs, ExpectedNameValueOrNoArgs, + ExpectedNonEmptyStringLiteral, UnexpectedLiteral, ExpectedNameValue(Option), DuplicateKey(Symbol), @@ -599,6 +600,9 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> { AttributeParseErrorReason::ExpectedNameValueOrNoArgs => { diag.span_label(self.span, "didn't expect a list here"); } + AttributeParseErrorReason::ExpectedNonEmptyStringLiteral => { + diag.span_label(self.span, "string is not allowed to be empty"); + } AttributeParseErrorReason::DuplicateKey(key) => { diag.span_label(self.span, format!("found `{key}` used as a key more than once")); diag.code(E0538); From d719a49b28a0da4d91c4fd0fd8ccd71cbfa0d491 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Sun, 21 Dec 2025 21:45:15 +0100 Subject: [PATCH 395/489] Port `#[cfi_encoding]` to attribute parser --- .../src/attributes/cfi_encoding.rs | 33 +++++++++ .../rustc_attr_parsing/src/attributes/mod.rs | 1 + compiler/rustc_attr_parsing/src/context.rs | 2 + .../rustc_hir/src/attrs/data_structures.rs | 3 + .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_passes/src/check_attr.rs | 2 +- .../src/cfi/typeid/itanium_cxx_abi/encode.rs | 68 ++++++------------- .../cfi/typeid/itanium_cxx_abi/transform.rs | 11 +-- tests/ui/attributes/malformed-attrs.rs | 2 +- tests/ui/attributes/malformed-attrs.stderr | 15 ++-- .../cfi/invalid-attr-encoding.stderr | 8 ++- 11 files changed, 83 insertions(+), 63 deletions(-) create mode 100644 compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs diff --git a/compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs b/compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs new file mode 100644 index 000000000000..df1e569743c0 --- /dev/null +++ b/compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs @@ -0,0 +1,33 @@ +use super::prelude::*; +pub(crate) struct CfiEncodingParser; +impl SingleAttributeParser for CfiEncodingParser { + const PATH: &[Symbol] = &[sym::cfi_encoding]; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[ + Allow(Target::Struct), + Allow(Target::ForeignTy), + Allow(Target::Enum), + Allow(Target::Union), + ]); + const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const TEMPLATE: AttributeTemplate = template!(NameValueStr: "encoding"); + + fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { + let Some(name_value) = args.name_value() else { + cx.expected_name_value(cx.attr_span, Some(sym::cfi_encoding)); + return None; + }; + + let Some(value_str) = name_value.value_as_str() else { + cx.expected_string_literal(name_value.value_span, None); + return None; + }; + + if value_str.as_str().trim().is_empty() { + cx.expected_non_empty_string_literal(name_value.value_span); + return None; + } + + Some(AttributeKind::CfiEncoding { encoding: value_str }) + } +} diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index f7290bd7e6f2..c39c60ea7e39 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -33,6 +33,7 @@ pub(crate) mod allow_unstable; pub(crate) mod body; pub(crate) mod cfg; pub(crate) mod cfg_select; +pub(crate) mod cfi_encoding; pub(crate) mod codegen_attrs; pub(crate) mod confusables; pub(crate) mod crate_level; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9aa0729c5790..9a443dfbb842 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -19,6 +19,7 @@ use crate::attributes::allow_unstable::{ AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser, }; use crate::attributes::body::CoroutineParser; +use crate::attributes::cfi_encoding::CfiEncodingParser; use crate::attributes::codegen_attrs::{ ColdParser, CoverageParser, EiiExternItemParser, ExportNameParser, ForceTargetFeatureParser, NakedParser, NoMangleParser, ObjcClassParser, ObjcSelectorParser, OptimizeParser, @@ -187,6 +188,7 @@ attribute_parsers!( // tidy-alphabetical-end // tidy-alphabetical-start + Single, Single, Single, Single, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index e9f9b2445deb..39530f5c3f8b 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -703,6 +703,9 @@ pub enum AttributeKind { span: Span, }, + /// Represents `#[cfi_encoding]` + CfiEncoding { encoding: Symbol }, + /// Represents `#[rustc_coinductive]`. Coinductive(Span), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 68456dfe4c29..6d159a6ee68a 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -26,6 +26,7 @@ impl AttributeKind { AsPtr(..) => Yes, AutomaticallyDerived(..) => Yes, BodyStability { .. } => No, + CfiEncoding { .. } => Yes, Coinductive(..) => No, Cold(..) => No, Confusables { .. } => Yes, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 7822614a05cb..fae269bfdcf1 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -298,6 +298,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::PinV2(..) | AttributeKind::WindowsSubsystem(..) | AttributeKind::ThreadLocal + | AttributeKind::CfiEncoding { .. } ) => { /* do nothing */ } Attribute::Unparsed(attr_item) => { style = Some(attr_item.style); @@ -336,7 +337,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | sym::cfg_trace | sym::cfg_attr_trace // need to be fixed - | sym::cfi_encoding // FIXME(cfi_encoding) | sym::instruction_set // broken on stable!!! | sym::patchable_function_entry // FIXME(patchable_function_entry) | sym::deprecated_safe // FIXME(deprecated_safe) diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs index 60b3b42989b7..5505fe82cea6 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs @@ -11,6 +11,8 @@ use rustc_abi::{ExternAbi, Integer}; use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; +use rustc_hir::attrs::AttributeKind; +use rustc_hir::find_attr; use rustc_middle::bug; use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::{ @@ -18,7 +20,6 @@ use rustc_middle::ty::{ IntTy, List, Region, RegionKind, TermKind, Ty, TyCtxt, TypeFoldable, UintTy, }; use rustc_span::def_id::DefId; -use rustc_span::sym; use tracing::instrument; use crate::cfi::typeid::TypeIdOptions; @@ -446,36 +447,20 @@ pub(crate) fn encode_ty<'tcx>( ty::Adt(adt_def, args) => { let mut s = String::new(); let def_id = adt_def.did(); - if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) { + if let Some(encoding) = find_attr!(tcx.get_all_attrs(def_id), AttributeKind::CfiEncoding { encoding } => encoding) + { + let encoding = encoding.as_str().trim(); // Use user-defined CFI encoding for type - if let Some(value_str) = cfi_encoding.value_str() { - let value_str = value_str.as_str().trim(); - if !value_str.is_empty() { - s.push_str(value_str); - // Don't compress user-defined builtin types (see - // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin and - // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression). - let builtin_types = [ - "v", "w", "b", "c", "a", "h", "s", "t", "i", "j", "l", "m", "x", "y", - "n", "o", "f", "d", "e", "g", "z", "Dh", - ]; - if !builtin_types.contains(&value_str) { - compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); - } - } else { - #[allow( - rustc::diagnostic_outside_of_impl, - rustc::untranslatable_diagnostic - )] - tcx.dcx() - .struct_span_err( - cfi_encoding.span(), - format!("invalid `cfi_encoding` for `{:?}`", ty.kind()), - ) - .emit(); - } - } else { - bug!("encode_ty: invalid `cfi_encoding` for `{:?}`", ty.kind()); + s.push_str(&encoding); + // Don't compress user-defined builtin types (see + // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin and + // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression). + let builtin_types = [ + "v", "w", "b", "c", "a", "h", "s", "t", "i", "j", "l", "m", "x", "y", "n", "o", + "f", "d", "e", "g", "z", "Dh", + ]; + if !builtin_types.contains(&encoding) { + compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); } } else if options.contains(EncodeTyOptions::GENERALIZE_REPR_C) && adt_def.repr().c() { // For cross-language LLVM CFI support, the encoding must be compatible at the FFI @@ -508,26 +493,11 @@ pub(crate) fn encode_ty<'tcx>( ty::Foreign(def_id) => { // , where is let mut s = String::new(); - if let Some(cfi_encoding) = tcx.get_attr(*def_id, sym::cfi_encoding) { + + if let Some(encoding) = find_attr!(tcx.get_all_attrs(*def_id), AttributeKind::CfiEncoding {encoding} => encoding) + { // Use user-defined CFI encoding for type - if let Some(value_str) = cfi_encoding.value_str() { - if !value_str.to_string().trim().is_empty() { - s.push_str(value_str.to_string().trim()); - } else { - #[allow( - rustc::diagnostic_outside_of_impl, - rustc::untranslatable_diagnostic - )] - tcx.dcx() - .struct_span_err( - cfi_encoding.span(), - format!("invalid `cfi_encoding` for `{:?}`", ty.kind()), - ) - .emit(); - } - } else { - bug!("encode_ty: invalid `cfi_encoding` for `{:?}`", ty.kind()); - } + s.push_str(encoding.as_str().trim()); } else { let name = tcx.item_name(*def_id).to_string(); let _ = write!(s, "{}{}", name.len(), name); diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs index 28481f3dcdb3..9cea681fcb57 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs @@ -6,15 +6,15 @@ use std::iter; -use rustc_hir as hir; -use rustc_hir::LangItem; +use rustc_hir::attrs::AttributeKind; +use rustc_hir::{self as hir, LangItem, find_attr}; use rustc_middle::bug; use rustc_middle::ty::{ self, AssocContainer, ExistentialPredicateStableCmpExt as _, Instance, IntTy, List, TraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UintTy, }; +use rustc_span::DUMMY_SP; use rustc_span::def_id::DefId; -use rustc_span::{DUMMY_SP, sym}; use rustc_trait_selection::traits; use tracing::{debug, instrument}; @@ -138,7 +138,10 @@ impl<'tcx> TypeFolder> for TransformTy<'tcx> { { // Don't transform repr(transparent) types with an user-defined CFI encoding to // preserve the user-defined CFI encoding. - if let Some(_) = self.tcx.get_attr(adt_def.did(), sym::cfi_encoding) { + if find_attr!( + self.tcx.get_all_attrs(adt_def.did()), + AttributeKind::CfiEncoding { .. } + ) { return t; } let variant = adt_def.non_enum_variant(); diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs index 37ccf9faa1a3..b0d8fd774f74 100644 --- a/tests/ui/attributes/malformed-attrs.rs +++ b/tests/ui/attributes/malformed-attrs.rs @@ -137,7 +137,7 @@ pub fn test3() {} //~^ ERROR malformed #[must_not_suspend()] //~^ ERROR malformed -#[cfi_encoding] +#[cfi_encoding = ""] //~^ ERROR malformed struct Test; diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index d0e5cb631c1e..860dcdb349bf 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -55,12 +55,6 @@ LL - #[must_not_suspend()] LL + #[must_not_suspend] | -error: malformed `cfi_encoding` attribute input - --> $DIR/malformed-attrs.rs:140:1 - | -LL | #[cfi_encoding] - | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` - error: malformed `allow` attribute input --> $DIR/malformed-attrs.rs:184:1 | @@ -530,6 +524,15 @@ LL | #[rustc_layout_scalar_valid_range_end] | expected this to be a list | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` +error[E0539]: malformed `cfi_encoding` attribute input + --> $DIR/malformed-attrs.rs:140:1 + | +LL | #[cfi_encoding = ""] + | ^^^^^^^^^^^^^^^^^--^ + | | | + | | string is not allowed to be empty + | help: must be of the form: `#[cfi_encoding = "encoding"]` + error[E0565]: malformed `marker` attribute input --> $DIR/malformed-attrs.rs:161:1 | diff --git a/tests/ui/sanitizer/cfi/invalid-attr-encoding.stderr b/tests/ui/sanitizer/cfi/invalid-attr-encoding.stderr index 1aa6bef17b1e..e95006c0ef61 100644 --- a/tests/ui/sanitizer/cfi/invalid-attr-encoding.stderr +++ b/tests/ui/sanitizer/cfi/invalid-attr-encoding.stderr @@ -1,8 +1,12 @@ -error: malformed `cfi_encoding` attribute input +error[E0539]: malformed `cfi_encoding` attribute input --> $DIR/invalid-attr-encoding.rs:10:1 | LL | #[cfi_encoding] - | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` + | ^^^^^^^^^^^^^^^ + | | + | expected this to be of the form `cfi_encoding = "..."` + | help: must be of the form: `#[cfi_encoding = "encoding"]` error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0539`. From dcb19a0a1e74d4c8a9f6df825d555ff761314d16 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 21 Dec 2025 22:31:25 +0100 Subject: [PATCH 396/489] Use "parameter" instead of "argument" in the lint message --- clippy_lints/src/needless_pass_by_ref_mut.rs | 2 +- .../needless_pass_by_ref_mut.fixed | 2 +- .../needless_pass_by_ref_mut.rs | 2 +- .../needless_pass_by_ref_mut.stderr | 2 +- tests/ui/needless_pass_by_ref_mut.stderr | 68 +++++++++---------- tests/ui/needless_pass_by_ref_mut2.stderr | 6 +- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index 904ff538ba36..f3e42b1c58f8 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -284,7 +284,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> { NEEDLESS_PASS_BY_REF_MUT, cx.tcx.local_def_id_to_hir_id(*fn_def_id), sp, - "this argument is a mutable reference, but not used mutably", + "this parameter is a mutable reference but is not used mutably", |diag| { diag.span_suggestion( mut_span, diff --git a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.fixed b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.fixed index 40556ca5410f..962a4e00d86e 100644 --- a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.fixed +++ b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.fixed @@ -3,7 +3,7 @@ // Should warn pub fn pub_foo(s: &Vec, b: &u32, x: &mut u32) { - //~^ ERROR: this argument is a mutable reference, but not used mutably + //~^ needless_pass_by_ref_mut *x += *b + s.len() as u32; } diff --git a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.rs b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.rs index bbc63ceb15a3..5f584c6704f2 100644 --- a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.rs +++ b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.rs @@ -3,7 +3,7 @@ // Should warn pub fn pub_foo(s: &mut Vec, b: &u32, x: &mut u32) { - //~^ ERROR: this argument is a mutable reference, but not used mutably + //~^ needless_pass_by_ref_mut *x += *b + s.len() as u32; } diff --git a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr index f79b20ec69fc..57137ab08d1e 100644 --- a/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr +++ b/tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.stderr @@ -1,4 +1,4 @@ -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui-toml/needless_pass_by_ref_mut/needless_pass_by_ref_mut.rs:5:19 | LL | pub fn pub_foo(s: &mut Vec, b: &u32, x: &mut u32) { diff --git a/tests/ui/needless_pass_by_ref_mut.stderr b/tests/ui/needless_pass_by_ref_mut.stderr index 90d99b9f0cf6..c427f4c3e42c 100644 --- a/tests/ui/needless_pass_by_ref_mut.stderr +++ b/tests/ui/needless_pass_by_ref_mut.stderr @@ -1,4 +1,4 @@ -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:12:11 | LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { @@ -9,7 +9,7 @@ LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:38:12 | LL | fn foo6(s: &mut Vec) { @@ -17,7 +17,7 @@ LL | fn foo6(s: &mut Vec) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:49:12 | LL | fn bar(&mut self) {} @@ -25,7 +25,7 @@ LL | fn bar(&mut self) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:52:29 | LL | fn mushroom(&self, vec: &mut Vec) -> usize { @@ -33,7 +33,7 @@ LL | fn mushroom(&self, vec: &mut Vec) -> usize { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:130:16 | LL | async fn a1(x: &mut i32) { @@ -41,7 +41,7 @@ LL | async fn a1(x: &mut i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:135:16 | LL | async fn a2(x: &mut i32, y: String) { @@ -49,7 +49,7 @@ LL | async fn a2(x: &mut i32, y: String) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:140:16 | LL | async fn a3(x: &mut i32, y: String, z: String) { @@ -57,7 +57,7 @@ LL | async fn a3(x: &mut i32, y: String, z: String) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:145:16 | LL | async fn a4(x: &mut i32, y: i32) { @@ -65,7 +65,7 @@ LL | async fn a4(x: &mut i32, y: i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:150:24 | LL | async fn a5(x: i32, y: &mut i32) { @@ -73,7 +73,7 @@ LL | async fn a5(x: i32, y: &mut i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:155:24 | LL | async fn a6(x: i32, y: &mut i32) { @@ -81,7 +81,7 @@ LL | async fn a6(x: i32, y: &mut i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:160:32 | LL | async fn a7(x: i32, y: i32, z: &mut i32) { @@ -89,7 +89,7 @@ LL | async fn a7(x: i32, y: i32, z: &mut i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:165:24 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { @@ -97,7 +97,7 @@ LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:165:45 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { @@ -105,7 +105,7 @@ LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:201:16 | LL | fn cfg_warn(s: &mut u32) {} @@ -115,7 +115,7 @@ LL | fn cfg_warn(s: &mut u32) {} | = note: this is cfg-gated and may require further changes -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:206:20 | LL | fn cfg_warn(s: &mut u32) {} @@ -125,7 +125,7 @@ LL | fn cfg_warn(s: &mut u32) {} | = note: this is cfg-gated and may require further changes -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:219:39 | LL | async fn inner_async2(x: &mut i32, y: &mut u32) { @@ -133,7 +133,7 @@ LL | async fn inner_async2(x: &mut i32, y: &mut u32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:228:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { @@ -141,7 +141,7 @@ LL | async fn inner_async3(x: &mut i32, y: &mut u32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:248:30 | LL | async fn call_in_closure1(n: &mut str) { @@ -149,7 +149,7 @@ LL | async fn call_in_closure1(n: &mut str) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:268:16 | LL | fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { @@ -157,7 +157,7 @@ LL | fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:280:22 | LL | async fn closure4(n: &mut usize) { @@ -165,7 +165,7 @@ LL | async fn closure4(n: &mut usize) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:335:12 | LL | fn bar(&mut self) {} @@ -173,7 +173,7 @@ LL | fn bar(&mut self) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:338:18 | LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { @@ -181,7 +181,7 @@ LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:338:45 | LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { @@ -189,7 +189,7 @@ LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:347:46 | LL | async fn foo2(&mut self, u: &mut i32, v: &mut u32) { @@ -197,7 +197,7 @@ LL | async fn foo2(&mut self, u: &mut i32, v: &mut u32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:364:18 | LL | fn _empty_tup(x: &mut (())) {} @@ -205,7 +205,7 @@ LL | fn _empty_tup(x: &mut (())) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:366:19 | LL | fn _single_tup(x: &mut ((i32,))) {} @@ -213,7 +213,7 @@ LL | fn _single_tup(x: &mut ((i32,))) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:368:18 | LL | fn _multi_tup(x: &mut ((i32, u32))) {} @@ -221,7 +221,7 @@ LL | fn _multi_tup(x: &mut ((i32, u32))) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:370:11 | LL | fn _fn(x: &mut (fn())) {} @@ -229,7 +229,7 @@ LL | fn _fn(x: &mut (fn())) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:373:23 | LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {} @@ -237,7 +237,7 @@ LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:375:20 | LL | fn _extern_c_fn(x: &mut extern "C" fn()) {} @@ -245,7 +245,7 @@ LL | fn _extern_c_fn(x: &mut extern "C" fn()) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:377:18 | LL | fn _unsafe_fn(x: &mut unsafe fn()) {} @@ -253,7 +253,7 @@ LL | fn _unsafe_fn(x: &mut unsafe fn()) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:379:25 | LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {} @@ -261,7 +261,7 @@ LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:381:20 | LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {} @@ -269,7 +269,7 @@ LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {} | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut.rs:383:20 | LL | fn _fn_with_ret(x: &mut unsafe extern "C" fn() -> (i32)) {} diff --git a/tests/ui/needless_pass_by_ref_mut2.stderr b/tests/ui/needless_pass_by_ref_mut2.stderr index 6af8a4d4a2b5..aa5c412adb4d 100644 --- a/tests/ui/needless_pass_by_ref_mut2.stderr +++ b/tests/ui/needless_pass_by_ref_mut2.stderr @@ -1,4 +1,4 @@ -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut2.rs:8:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { @@ -9,7 +9,7 @@ LL | async fn inner_async3(x: &mut i32, y: &mut u32) { = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut2.rs:17:39 | LL | async fn inner_async4(u: &mut i32, v: &mut u32) { @@ -17,7 +17,7 @@ LL | async fn inner_async4(u: &mut i32, v: &mut u32) { | | | help: consider removing this `mut` -error: this argument is a mutable reference, but not used mutably +error: this parameter is a mutable reference but is not used mutably --> tests/ui/needless_pass_by_ref_mut2.rs:29:37 | LL | fn issue16267<'a>(msg: &str, slice: &'a mut [i32]) -> &'a [i32] { From 85998185db03565dd0dcf523220f513f6f0d8d77 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sun, 21 Dec 2025 21:57:03 +0000 Subject: [PATCH 397/489] `cmp_null`: add missing parens and mention of `ptr::null_mut` in its docs --- clippy_lints/src/ptr/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/ptr/mod.rs b/clippy_lints/src/ptr/mod.rs index 6b2647e7b0a2..c4f40a7ffcaa 100644 --- a/clippy_lints/src/ptr/mod.rs +++ b/clippy_lints/src/ptr/mod.rs @@ -45,7 +45,7 @@ declare_clippy_lint! { declare_clippy_lint! { /// ### What it does - /// This lint checks for equality comparisons with `ptr::null` + /// This lint checks for equality comparisons with `ptr::null` or `ptr::null_mut` /// /// ### Why is this bad? /// It's easier and more readable to use the inherent @@ -56,7 +56,7 @@ declare_clippy_lint! { /// ```rust,ignore /// use std::ptr; /// - /// if x == ptr::null { + /// if x == ptr::null() { /// // .. /// } /// ``` From a4e8d41802d65afa3c814f53482d08b4d077c71f Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sun, 21 Dec 2025 22:01:46 +0000 Subject: [PATCH 398/489] fix: `cmp_null` wrongly unmangled macros --- clippy_lints/src/ptr/cmp_null.rs | 7 ++++--- tests/ui/cmp_null.fixed | 20 ++++++++++++++++++++ tests/ui/cmp_null.rs | 20 ++++++++++++++++++++ tests/ui/cmp_null.stderr | 8 +++++++- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/ptr/cmp_null.rs b/clippy_lints/src/ptr/cmp_null.rs index 905b48e6d1d4..f2d1c855eddd 100644 --- a/clippy_lints/src/ptr/cmp_null.rs +++ b/clippy_lints/src/ptr/cmp_null.rs @@ -14,13 +14,14 @@ pub(super) fn check<'tcx>( l: &Expr<'_>, r: &Expr<'_>, ) -> bool { + let mut applicability = Applicability::MachineApplicable; let non_null_path_snippet = match ( is_lint_allowed(cx, CMP_NULL, expr.hir_id), is_null_path(cx, l), is_null_path(cx, r), ) { - (false, true, false) if let Some(sugg) = Sugg::hir_opt(cx, r) => sugg.maybe_paren(), - (false, false, true) if let Some(sugg) = Sugg::hir_opt(cx, l) => sugg.maybe_paren(), + (false, true, false) => Sugg::hir_with_context(cx, r, expr.span.ctxt(), "..", &mut applicability).maybe_paren(), + (false, false, true) => Sugg::hir_with_context(cx, l, expr.span.ctxt(), "..", &mut applicability).maybe_paren(), _ => return false, }; let invert = if op == BinOpKind::Eq { "" } else { "!" }; @@ -32,7 +33,7 @@ pub(super) fn check<'tcx>( "comparing with null is better expressed by the `.is_null()` method", "try", format!("{invert}{non_null_path_snippet}.is_null()",), - Applicability::MachineApplicable, + applicability, ); true } diff --git a/tests/ui/cmp_null.fixed b/tests/ui/cmp_null.fixed index c12279cf12e6..4a0ee439e94a 100644 --- a/tests/ui/cmp_null.fixed +++ b/tests/ui/cmp_null.fixed @@ -38,3 +38,23 @@ fn issue15010() { debug_assert!(!f.is_null()); //~^ cmp_null } + +fn issue16281() { + use std::ptr; + + struct Container { + value: *const i32, + } + let x = Container { value: ptr::null() }; + + macro_rules! dot_value { + ($obj:expr) => { + $obj.value + }; + } + + if dot_value!(x).is_null() { + //~^ cmp_null + todo!() + } +} diff --git a/tests/ui/cmp_null.rs b/tests/ui/cmp_null.rs index 2771a16e00c5..26ea8960e5fb 100644 --- a/tests/ui/cmp_null.rs +++ b/tests/ui/cmp_null.rs @@ -38,3 +38,23 @@ fn issue15010() { debug_assert!(f != std::ptr::null_mut()); //~^ cmp_null } + +fn issue16281() { + use std::ptr; + + struct Container { + value: *const i32, + } + let x = Container { value: ptr::null() }; + + macro_rules! dot_value { + ($obj:expr) => { + $obj.value + }; + } + + if dot_value!(x) == ptr::null() { + //~^ cmp_null + todo!() + } +} diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 381747cb3c65..51b98d2a2320 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -37,5 +37,11 @@ error: comparing with null is better expressed by the `.is_null()` method LL | debug_assert!(f != std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!f.is_null()` -error: aborting due to 6 previous errors +error: comparing with null is better expressed by the `.is_null()` method + --> tests/ui/cmp_null.rs:56:8 + | +LL | if dot_value!(x) == ptr::null() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dot_value!(x).is_null()` + +error: aborting due to 7 previous errors From 3cf9fa54968778d37950ba187b833ef030a693c3 Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Sat, 20 Dec 2025 22:03:16 +0000 Subject: [PATCH 399/489] fix: `result_large_err` FN on closures --- clippy_lints/src/functions/mod.rs | 4 +++ clippy_lints/src/functions/result.rs | 43 ++++++++++++++++++++++++---- tests/ui/result_large_err.rs | 9 ++++++ tests/ui/result_large_err.stderr | 18 +++++++++++- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/functions/mod.rs b/clippy_lints/src/functions/mod.rs index bdc366f6878a..9a7427ea1447 100644 --- a/clippy_lints/src/functions/mod.rs +++ b/clippy_lints/src/functions/mod.rs @@ -596,4 +596,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions { impl_trait_in_params::check_trait_item(cx, item, self.avoid_breaking_exported_api); ref_option::check_trait_item(cx, item, self.avoid_breaking_exported_api); } + + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { + result::check_expr(cx, expr, self.large_error_threshold, &self.large_error_ignored); + } } diff --git a/clippy_lints/src/functions/result.rs b/clippy_lints/src/functions/result.rs index 04e15a1d8a0e..77fec9371425 100644 --- a/clippy_lints/src/functions/result.rs +++ b/clippy_lints/src/functions/result.rs @@ -50,7 +50,7 @@ pub(super) fn check_item<'tcx>( let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); check_result_unit_err(cx, err_ty, fn_header_span, msrv); } - check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold, large_err_ignored); + check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold, large_err_ignored, false); } } @@ -70,7 +70,7 @@ pub(super) fn check_impl_item<'tcx>( let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); check_result_unit_err(cx, err_ty, fn_header_span, msrv); } - check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold, large_err_ignored); + check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold, large_err_ignored, false); } } @@ -87,7 +87,7 @@ pub(super) fn check_trait_item<'tcx>( if cx.effective_visibilities.is_exported(item.owner_id.def_id) { check_result_unit_err(cx, err_ty, fn_header_span, msrv); } - check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold, large_err_ignored); + check_result_large_err(cx, err_ty, hir_ty.span, large_err_threshold, large_err_ignored, false); } } } @@ -111,12 +111,15 @@ fn check_result_large_err<'tcx>( hir_ty_span: Span, large_err_threshold: u64, large_err_ignored: &DefIdSet, + is_closure: bool, ) { if let ty::Adt(adt, _) = err_ty.kind() && large_err_ignored.contains(&adt.did()) { return; } + + let subject = if is_closure { "closure" } else { "function" }; if let ty::Adt(adt, subst) = err_ty.kind() && let Some(local_def_id) = adt.did().as_local() && let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(local_def_id) @@ -130,7 +133,7 @@ fn check_result_large_err<'tcx>( cx, RESULT_LARGE_ERR, hir_ty_span, - "the `Err`-variant returned from this function is very large", + format!("the `Err`-variant returned from this {subject} is very large"), |diag| { diag.span_label( def.variants[first_variant.ind].span, @@ -161,7 +164,7 @@ fn check_result_large_err<'tcx>( cx, RESULT_LARGE_ERR, hir_ty_span, - "the `Err`-variant returned from this function is very large", + format!("the `Err`-variant returned from this {subject} is very large"), |diag: &mut Diag<'_, ()>| { diag.span_label(hir_ty_span, format!("the `Err`-variant is at least {ty_size} bytes")); diag.help(format!("try reducing the size of `{err_ty}`, for example by boxing large elements or replacing it with `Box<{err_ty}>`")); @@ -170,3 +173,33 @@ fn check_result_large_err<'tcx>( } } } + +pub(super) fn check_expr<'tcx>( + cx: &LateContext<'tcx>, + expr: &'tcx hir::Expr<'tcx>, + large_err_threshold: u64, + large_err_ignored: &DefIdSet, +) { + if let hir::ExprKind::Closure(closure) = expr.kind + && let ty::Closure(_, args) = cx.typeck_results().expr_ty(expr).kind() + && let closure_sig = args.as_closure().sig() + && let Ok(err_binder) = closure_sig.output().try_map_bound(|output_ty| { + if let ty::Adt(adt, args) = output_ty.kind() + && let [_, err_arg] = args.as_slice() + && let Some(err_ty) = err_arg.as_type() + && adt.is_diag_item(cx, sym::Result) + { + return Ok(err_ty); + } + + Err(()) + }) + { + let err_ty = cx.tcx.instantiate_bound_regions_with_erased(err_binder); + let hir_ty_span = match closure.fn_decl.output { + hir::FnRetTy::Return(hir_ty) => hir_ty.span, + hir::FnRetTy::DefaultReturn(_) => expr.span, + }; + check_result_large_err(cx, err_ty, hir_ty_span, large_err_threshold, large_err_ignored, true); + } +} diff --git a/tests/ui/result_large_err.rs b/tests/ui/result_large_err.rs index fa57b3f553fc..b4ad050df3b7 100644 --- a/tests/ui/result_large_err.rs +++ b/tests/ui/result_large_err.rs @@ -141,3 +141,12 @@ fn _empty_error() -> Result<(), Empty> { } fn main() {} + +fn issue16249() { + type Large = [u8; 1024]; + + let closure = || -> Result<(), Large> { Ok(()) }; + //~^ result_large_err + let closure = || Ok::<(), Large>(()); + //~^ result_large_err +} diff --git a/tests/ui/result_large_err.stderr b/tests/ui/result_large_err.stderr index 72fbc3f58961..fd39179c61cb 100644 --- a/tests/ui/result_large_err.stderr +++ b/tests/ui/result_large_err.stderr @@ -104,5 +104,21 @@ LL | pub fn array_error() -> Result<(), ArrayError<(i32, T), U>> { | = help: try reducing the size of `ArrayError<(i32, T), U>`, for example by boxing large elements or replacing it with `Box>` -error: aborting due to 12 previous errors +error: the `Err`-variant returned from this closure is very large + --> tests/ui/result_large_err.rs:148:25 + | +LL | let closure = || -> Result<(), Large> { Ok(()) }; + | ^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 1024 bytes + | + = help: try reducing the size of `[u8; 1024]`, for example by boxing large elements or replacing it with `Box<[u8; 1024]>` + +error: the `Err`-variant returned from this closure is very large + --> tests/ui/result_large_err.rs:150:19 + | +LL | let closure = || Ok::<(), Large>(()); + | ^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 1024 bytes + | + = help: try reducing the size of `[u8; 1024]`, for example by boxing large elements or replacing it with `Box<[u8; 1024]>` + +error: aborting due to 14 previous errors From 91dec8008c130254efec7e43931e826b01baf2c3 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Mon, 22 Dec 2025 00:15:50 +0100 Subject: [PATCH 400/489] add `expected_list_with_num_args_or_more` attribute parsing error --- compiler/rustc_attr_parsing/src/context.rs | 4 ++++ compiler/rustc_attr_parsing/src/session_diagnostics.rs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index df4970d8aa90..af0aee0b1e0b 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -490,6 +490,10 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { self.emit_parse_error(span, AttributeParseErrorReason::ExpectedList) } + pub(crate) fn expected_list_with_num_args_or_more(&self, args: usize, span: Span) -> ErrorGuaranteed { + self.emit_parse_error(span, AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args}) + } + pub(crate) fn expected_list_or_no_args(&self, span: Span) -> ErrorGuaranteed { self.emit_parse_error(span, AttributeParseErrorReason::ExpectedListOrNoArgs) } diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index 73b65193fd34..dfa72effa689 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -520,6 +520,9 @@ pub(crate) enum AttributeParseErrorReason<'a> { ExpectedSingleArgument, ExpectedList, ExpectedListOrNoArgs, + ExpectedListWithNumArgsOrMore { + args: usize, + }, ExpectedNameValueOrNoArgs, UnexpectedLiteral, ExpectedNameValue(Option), @@ -596,6 +599,9 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> { AttributeParseErrorReason::ExpectedListOrNoArgs => { diag.span_label(self.span, "expected a list or no arguments here"); } + AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args } => { + diag.span_label(self.span, format!("expected {args} or more items")); + } AttributeParseErrorReason::ExpectedNameValueOrNoArgs => { diag.span_label(self.span, "didn't expect a list here"); } From bdc8894004031b063d9201f5297292211c6df791 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 13 Dec 2025 16:41:26 -0500 Subject: [PATCH 401/489] Write file with channel to S3 This will let rustup-toolchain-install-master gain support for installing stable artifacts, which is currently only possible when explicitly overriding the channel. That in turn will unblock letting Crater kick off a beta run as soon as both a new beta and a new stable artifact are ready, rather than waiting until the actual release. --- src/bootstrap/src/lib.rs | 18 ++++++------------ src/ci/scripts/upload-artifacts.sh | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index adae9a1b8b08..c9358599012c 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1624,26 +1624,20 @@ impl Build { self.release(&self.version) } - /// Returns the "package version" for a component given the `num` release - /// number. + /// Returns the "package version" for a component. /// /// The package version is typically what shows up in the names of tarballs. - /// For channels like beta/nightly it's just the channel name, otherwise - /// it's the `num` provided. - fn package_vers(&self, num: &str) -> String { + /// For channels like beta/nightly it's just the channel name, otherwise it's the release + /// version. + fn rust_package_vers(&self) -> String { match &self.config.channel[..] { - "stable" => num.to_string(), + "stable" => self.version.to_string(), "beta" => "beta".to_string(), "nightly" => "nightly".to_string(), - _ => format!("{num}-dev"), + _ => format!("{}-dev", self.version), } } - /// Returns the value of `package_vers` above for Rust itself. - fn rust_package_vers(&self) -> String { - self.package_vers(&self.version) - } - /// Returns the `version` string associated with this compiler for Rust /// itself. /// diff --git a/src/ci/scripts/upload-artifacts.sh b/src/ci/scripts/upload-artifacts.sh index 975b4c527267..6c916eb90cbe 100755 --- a/src/ci/scripts/upload-artifacts.sh +++ b/src/ci/scripts/upload-artifacts.sh @@ -6,6 +6,7 @@ set -euo pipefail IFS=$'\n\t' +ci_dir=`cd $(dirname $0)/.. && pwd` source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" upload_dir="$(mktemp -d)" @@ -22,6 +23,22 @@ if [[ "${DEPLOY-0}" -eq "1" ]] || [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then mv "${dist_dir}"/* "${upload_dir}" fi +# We write the release channel into the output so that +# `rustup-toolchain-install-master` or other, similar, tools can automatically +# detect the appropriate name to use for downloading artifacts. +# +# For nightly and beta this isn't strictly necessary as just trying both is +# enough, but stable builds produce artifacts with a version (e.g., +# rust-src-1.92.0.tar.xz) which can't be easily guessed otherwise. +channel=$(releaseChannel) +if [[ "$channel" = "stable" ]]; then + # On stable, artifacts use the version number. See rust_package_vers in + # src/bootstrap/src/lib.rs. + cat "$ci_dir/../version" > "${upload_dir}/package-version" +else + echo "$channel" > "${upload_dir}/package-version" +fi + # CPU usage statistics. cp build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv" From 5fc00306a8ed6eb40b470773988c57d494b2596d Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 22 Dec 2025 09:40:21 +0800 Subject: [PATCH 402/489] tidy: skip target-specific check for run-make-cargo too I forgot to change this when implementing the run-make fission. --- src/tools/tidy/src/target_specific_tests.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index 159d7278bb62..11138de5de76 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -52,8 +52,12 @@ pub fn check(tests_path: &Path, tidy_ctx: TidyCtx) { } }); - // Skip run-make tests as revisions are not supported. - if entry.path().strip_prefix(tests_path).is_ok_and(|rest| rest.starts_with("run-make")) { + // Skip run-make/run-make-cargo tests as revisions are not supported. + if entry + .path() + .strip_prefix(tests_path) + .is_ok_and(|rest| rest.starts_with("run-make") || rest.starts_with("run-make-cargo")) + { return; } From 059655298692949f33754ce62c339b84418ed9ff Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sun, 21 Dec 2025 19:35:57 -0700 Subject: [PATCH 403/489] Use arithmetic instead of bitshifts Co-authored-by: Yotam Ofek --- src/librustdoc/html/static/js/stringdex.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/static/js/stringdex.js b/src/librustdoc/html/static/js/stringdex.js index e45c8bcd653b..720ac58e76e0 100644 --- a/src/librustdoc/html/static/js/stringdex.js +++ b/src/librustdoc/html/static/js/stringdex.js @@ -57,7 +57,7 @@ class RoaringBitmap { } else if (u8array[i] > 0xe0) { // Special representation of tiny sets that are runs const lspecial = u8array[i] & 0x0f; - this.keysAndCardinalities = new Uint8Array(lspecial << 2); + this.keysAndCardinalities = new Uint8Array(lspecial * 4); i += 1; const key = u8array[i + 2] | (u8array[i + 3] << 8); const value = u8array[i] | (u8array[i + 1] << 8); @@ -74,7 +74,7 @@ class RoaringBitmap { } else if (u8array[i] > 0xd0) { // Special representation of tiny sets that are close together const lspecial = u8array[i] & 0x0f; - this.keysAndCardinalities = new Uint8Array(lspecial << 2); + this.keysAndCardinalities = new Uint8Array(lspecial * 4); let pspecial = i + 1; let key = u8array[pspecial + 2] | (u8array[pspecial + 3] << 8); let value = u8array[pspecial] | (u8array[pspecial + 1] << 8); @@ -93,8 +93,8 @@ class RoaringBitmap { key = entry >> 16; container = this.addToArrayAt(key); const cardinalityOld = container.cardinality; - container.array[cardinalityOld << 1] = value & 0xFF; - container.array[(cardinalityOld << 1) + 1] = (value >> 8) & 0xFF; + container.array[cardinalityOld * 2] = value & 0xFF; + container.array[(cardinalityOld * 2) + 1] = (value >> 8) & 0xFF; container.cardinality = cardinalityOld + 1; pspecial += 1; } @@ -2409,7 +2409,7 @@ function loadDatabase(hooks) { encoded.subarray(i, i + (branch_leaves_count * 2)), ), ]; - i += branch_leaves_count << 1; + i += branch_leaves_count * 2; } branch_nodes.push(Promise.resolve( is_suffixes_only ? @@ -2465,7 +2465,7 @@ function loadDatabase(hooks) { encoded.subarray(i, i + (leaves_count * 2)), ), ]; - i += leaves_count << 1; + i += leaves_count * 2; } } return is_suffixes_only ? @@ -3085,7 +3085,7 @@ function loadDatabase(hooks) { if (branch_leaves_is_run) { i += 2; } else { - i += branch_leaves_count << 1; + i += branch_leaves_count * 2; } } // branch keys @@ -3094,7 +3094,7 @@ function loadDatabase(hooks) { if (leaves_is_run) { i += 2; } else { - i += leaves_count << 1; + i += leaves_count * 2; } if (is_data_compressed) { const clen = ( From de0945b2a714673a94e068d0cfad72dc40a0e6c8 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Wed, 10 Dec 2025 17:16:36 +0800 Subject: [PATCH 404/489] bootstrap: update comment for `STAGE0_MISSING_TARGETS` --- src/bootstrap/src/core/sanity.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 932a58c954df..67f4eb37b2c1 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -28,11 +28,13 @@ pub struct Finder { path: OsString, } -// During sanity checks, we search for target names to determine if they exist in the compiler's built-in -// target list (`rustc --print target-list`). While a target name may be present in the stage2 compiler, -// it might not yet be included in stage0. In such cases, we handle the targets missing from stage0 in this list. -// -// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap). +/// During sanity checks, we search for target tuples to determine if they exist in the compiler's +/// built-in target list (`rustc --print target-list`). While a target tuple may be present in the +/// in-tree compiler, the stage 0 compiler might not yet know about it (assuming not operating with +/// local-rebuild). In such cases, we handle the targets missing from stage 0 in this list. +/// +/// Targets can be removed from this list during the usual release process bootstrap compiler bumps, +/// when the newly-bumped stage 0 compiler now knows about the formerly-missing targets. const STAGE0_MISSING_TARGETS: &[&str] = &[ // just a dummy comment so the list doesn't get onelined "riscv64im-unknown-none-elf", From 1c26670e64367672f01b02608c0257d518f6a4a5 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Wed, 3 Sep 2025 08:04:14 +0800 Subject: [PATCH 405/489] Fix indent for convert_iter_for_each_to_for Example --- ```rust fn main() { { let it = core::iter::repeat(92); it.$0for_each(|param| match param { (x, y) => println!("x: {}, y: {}", x, y), }); } } ``` **Before this PR**: ```rust fn main() { { let it = core::iter::repeat(92); for param in it { match param { (x, y) => println!("x: {}, y: {}", x, y), } } } } ``` **After this PR**: ```rust fn main() { { let it = core::iter::repeat(92); for param in it { match param { (x, y) => println!("x: {}, y: {}", x, y), } } } } ``` --- .../handlers/convert_iter_for_each_to_for.rs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs index 2eea4f71ed34..63b1a0193bd6 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs @@ -3,7 +3,7 @@ use ide_db::famous_defs::FamousDefs; use stdx::format_to; use syntax::{ AstNode, - ast::{self, HasArgList, HasLoopBody, edit_in_place::Indent, syntax_factory::SyntaxFactory}, + ast::{self, HasArgList, HasLoopBody, edit::AstNodeEdit, syntax_factory::SyntaxFactory}, }; use crate::{AssistContext, AssistId, Assists}; @@ -62,10 +62,10 @@ pub(crate) fn convert_iter_for_each_to_for( stmt.as_ref().map_or_else(|| method.indent_level(), ast::ExprStmt::indent_level); let block = match body { - ast::Expr::BlockExpr(block) => block.clone_for_update(), - _ => make.block_expr(Vec::new(), Some(body)), - }; - block.reindent_to(indent); + ast::Expr::BlockExpr(block) => block.reset_indent(), + _ => make.block_expr(Vec::new(), Some(body.reset_indent().indent(1.into()))), + } + .indent(indent); let expr_for_loop = make.expr_for_loop(param, receiver, block); @@ -285,15 +285,23 @@ fn main() { r#" //- minicore: iterators fn main() { - let it = core::iter::repeat(92); - it.$0for_each(|(x, y)| println!("x: {}, y: {}", x, y)); + { + let it = core::iter::repeat(92); + it.$0for_each(|param| match param { + (x, y) => println!("x: {}, y: {}", x, y), + }); + } } "#, r#" fn main() { - let it = core::iter::repeat(92); - for (x, y) in it { - println!("x: {}, y: {}", x, y) + { + let it = core::iter::repeat(92); + for param in it { + match param { + (x, y) => println!("x: {}, y: {}", x, y), + } + } } } "#, From 646f583b3aa9f4ea1209be8da5e280a1d47d4685 Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Mon, 22 Dec 2025 19:06:46 +1030 Subject: [PATCH 406/489] fix: remove else-if collapse suggestion when all branches contain only an `if {..} else {..}` expression If two `if` arms contain only a single `if {..} else {..}` statement, don't suggest a collapse as this can lead to less readable code. --- clippy_lints/src/collapsible_if.rs | 16 ++++++++++++++++ tests/ui/collapsible_else_if.fixed | 26 ++++++++++++++++++++++++++ tests/ui/collapsible_else_if.rs | 28 ++++++++++++++++++++++++++++ tests/ui/collapsible_else_if.stderr | 24 +++++++++++++++++++++--- 4 files changed, 91 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 0efcb3c77ff6..be07ce1272bd 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -267,6 +267,9 @@ impl LateLintPass<'_> for CollapsibleIf { && !expr.span.from_expansion() { if let Some(else_) = else_ + // Short circuit if both `if` branches contain only a single `if {..} else {}`, as + // collapsing such blocks can lead to less readable code (#4971) + && !(single_inner_if_else(then) && single_inner_if_else(else_)) && let ExprKind::Block(else_, None) = else_.kind { self.check_collapsible_else_if(cx, then.span, else_); @@ -280,6 +283,19 @@ impl LateLintPass<'_> for CollapsibleIf { } } +/// Returns true if `expr` is a block that contains only one `if {..} else {}` statement +fn single_inner_if_else(expr: &Expr<'_>) -> bool { + if let ExprKind::Block(block, None) = expr.kind + && let Some(inner_expr) = expr_block(block) + && let ExprKind::If(_, _, else_) = inner_expr.kind + && else_.is_some() + { + true + } else { + false + } +} + /// If `block` is a block with either one expression or a statement containing an expression, /// return the expression. We don't peel blocks recursively, as extra blocks might be intentional. fn expr_block<'tcx>(block: &Block<'tcx>) -> Option<&'tcx Expr<'tcx>> { diff --git a/tests/ui/collapsible_else_if.fixed b/tests/ui/collapsible_else_if.fixed index d85bbf189075..cd2d9be9f433 100644 --- a/tests/ui/collapsible_else_if.fixed +++ b/tests/ui/collapsible_else_if.fixed @@ -70,6 +70,17 @@ fn main() { } //~^^^^^^^^ collapsible_else_if + if x == "hello" { + if y == "world" { + print!("Hello "); + } else { + println!("world"); + } + } else if let Some(42) = Some(42) { + println!("42"); + } + //~^^^^^ collapsible_else_if + if x == "hello" { print!("Hello "); } else { @@ -78,6 +89,21 @@ fn main() { println!("world!") } } + + if x == "hello" { + if y == "world" { + print!("Hello "); + } else { + println!("world"); + } + } else { + if let Some(42) = Some(42) { + println!("42"); + } else { + println!("!"); + } + } + } #[rustfmt::skip] diff --git a/tests/ui/collapsible_else_if.rs b/tests/ui/collapsible_else_if.rs index 10aef2792adb..75f204328538 100644 --- a/tests/ui/collapsible_else_if.rs +++ b/tests/ui/collapsible_else_if.rs @@ -84,6 +84,19 @@ fn main() { } //~^^^^^^^^ collapsible_else_if + if x == "hello" { + if y == "world" { + print!("Hello "); + } else { + println!("world"); + } + } else { + if let Some(42) = Some(42) { + println!("42"); + } + } + //~^^^^^ collapsible_else_if + if x == "hello" { print!("Hello "); } else { @@ -92,6 +105,21 @@ fn main() { println!("world!") } } + + if x == "hello" { + if y == "world" { + print!("Hello "); + } else { + println!("world"); + } + } else { + if let Some(42) = Some(42) { + println!("42"); + } else { + println!("!"); + } + } + } #[rustfmt::skip] diff --git a/tests/ui/collapsible_else_if.stderr b/tests/ui/collapsible_else_if.stderr index 98109099bae6..ebd78d2b1ffe 100644 --- a/tests/ui/collapsible_else_if.stderr +++ b/tests/ui/collapsible_else_if.stderr @@ -142,7 +142,25 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> tests/ui/collapsible_else_if.rs:100:10 + --> tests/ui/collapsible_else_if.rs:93:12 + | +LL | } else { + | ____________^ +LL | | if let Some(42) = Some(42) { +LL | | println!("42"); +LL | | } +LL | | } + | |_____^ + | +help: collapse nested if block + | +LL ~ } else if let Some(42) = Some(42) { +LL + println!("42"); +LL + } + | + +error: this `else { if .. }` block can be collapsed + --> tests/ui/collapsible_else_if.rs:128:10 | LL | }else{ | __________^ @@ -151,7 +169,7 @@ LL | | } | |_____^ help: collapse nested if block: `if false {}` error: this `else { if .. }` block can be collapsed - --> tests/ui/collapsible_else_if.rs:139:12 + --> tests/ui/collapsible_else_if.rs:167:12 | LL | } else { | ____________^ @@ -159,5 +177,5 @@ LL | | (if y == "world" { println!("world") } else { println!("!") }) LL | | } | |_____^ help: collapse nested if block: `if y == "world" { println!("world") } else { println!("!") }` -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors From 7b427ce4741d19cbd283635ec1301653937fc230 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Sun, 24 Aug 2025 12:02:25 +0800 Subject: [PATCH 407/489] Add BreakExpr completion suggest - Move `ide::goto_definition::find_loops` into `ide_db::syntax_helpers::node_ext::find_loops` --- .../ide-completion/src/context/analysis.rs | 13 +- .../ide-completion/src/context/tests.rs | 119 ++++++++++++++++++ .../ide-db/src/syntax_helpers/node_ext.rs | 42 +++++++ .../crates/ide/src/goto_definition.rs | 53 +------- .../crates/ide/src/highlight_related.rs | 6 +- 5 files changed, 177 insertions(+), 56 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs index ce26d3806cc4..49fb36ad04f8 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/analysis.rs @@ -2,7 +2,9 @@ use std::iter; use hir::{ExpandResult, InFile, Semantics, Type, TypeInfo, Variant}; -use ide_db::{RootDatabase, active_parameter::ActiveParameter}; +use ide_db::{ + RootDatabase, active_parameter::ActiveParameter, syntax_helpers::node_ext::find_loops, +}; use itertools::Either; use stdx::always; use syntax::{ @@ -779,6 +781,12 @@ fn expected_type_and_name<'db>( }); (ty, None) }, + ast::BreakExpr(it) => { + let ty = it.break_token() + .and_then(|it| find_loops(sema, &it)?.next()) + .and_then(|expr| sema.type_of_expr(&expr)); + (ty.map(TypeInfo::original), None) + }, ast::ClosureExpr(it) => { let ty = sema.type_of_expr(&it.into()); ty.and_then(|ty| ty.original.as_callable(sema.db)) @@ -2059,7 +2067,8 @@ fn prev_special_biased_token_at_trivia(mut token: SyntaxToken) -> SyntaxToken { | T![|] | T![return] | T![break] - | T![continue] = prev.kind() + | T![continue] + | T![lifetime_ident] = prev.kind() { token = prev } diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs b/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs index 09a9b6f112f0..e97d9720e3f3 100644 --- a/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs +++ b/src/tools/rust-analyzer/crates/ide-completion/src/context/tests.rs @@ -635,6 +635,125 @@ fn foo() { ); } +#[test] +fn expected_type_break_expr_in_loop() { + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + let _x: State = loop { + { + break State::Stop; + break $0; + } + }; +} +"#, + expect![[r#"ty: State, name: ?"#]], + ); + + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + let _x: State = 'a: loop { + { + break State::Stop; + break $0; + } + }; +} +"#, + expect![[r#"ty: State, name: ?"#]], + ); + + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + let _x: State = 'a: loop { + while true { + break $0; + } + }; +} +"#, + expect![[r#"ty: (), name: ?"#]], + ); +} + +#[test] +fn expected_type_break_expr_in_labeled_loop() { + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + let _x: State = 'a: loop { + let _y: i32 = loop { + { + break 'a State::Stop; + break 'a $0; + } + }; + }; +} +"#, + expect![[r#"ty: State, name: ?"#]], + ); + + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + let _x: State = 'a: loop { + let _y: i32 = loop { + while true { + break 'a State::Stop; + break 'a $0; + } + }; + }; +} +"#, + expect![[r#"ty: State, name: ?"#]], + ); + + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + 'a: while true { + let _x: State = loop { + break State::Stop; + break 'a $0; + }; + } +} +"#, + expect![[r#"ty: (), name: ?"#]], + ); +} + +#[test] +fn expected_type_break_expr_in_labeled_block() { + check_expected_type_and_name( + r#" +enum State { Stop } +fn foo() { + let _x: State = 'a: { + let _y: i32 = 'b: { + { + break 'a State::Stop; + break 'a $0; + }; + }; + }; +} +"#, + expect![[r#"ty: State, name: ?"#]], + ); +} + #[test] fn expected_type_logic_op() { check_expected_type_and_name( diff --git a/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/node_ext.rs b/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/node_ext.rs index e1d140730edc..acce066b8323 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/node_ext.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/node_ext.rs @@ -419,6 +419,48 @@ pub fn eq_label_lt(lt1: &Option, lt2: &Option) -> lt1.as_ref().zip(lt2.as_ref()).is_some_and(|(lt, lbl)| lt.text() == lbl.text()) } +/// Find the loop or block to break or continue, multiple results may be caused by macros. +pub fn find_loops( + sema: &hir::Semantics<'_, crate::RootDatabase>, + token: &syntax::SyntaxToken, +) -> Option> { + let parent = token.parent()?; + let lbl = syntax::match_ast! { + match parent { + ast::BreakExpr(break_) => break_.lifetime(), + ast::ContinueExpr(continue_) => continue_.lifetime(), + _ => None, + } + }; + let label_matches = + move |it: Option| match (lbl.as_ref(), it.and_then(|it| it.lifetime())) { + (Some(lbl), Some(it)) => lbl.text() == it.text(), + (None, _) => true, + (Some(_), None) => false, + }; + + let find_ancestors = move |token| { + for anc in sema.token_ancestors_with_macros(token).filter_map(ast::Expr::cast) { + let node = match &anc { + ast::Expr::LoopExpr(loop_) if label_matches(loop_.label()) => anc, + ast::Expr::WhileExpr(while_) if label_matches(while_.label()) => anc, + ast::Expr::ForExpr(for_) if label_matches(for_.label()) => anc, + ast::Expr::BlockExpr(blk) + if blk.label().is_some() && label_matches(blk.label()) => + { + anc + } + _ => continue, + }; + + return Some(node); + } + None + }; + + sema.descend_into_macros(token.clone()).into_iter().filter_map(find_ancestors).into() +} + struct TreeWithDepthIterator { preorder: Preorder, depth: u32, diff --git a/src/tools/rust-analyzer/crates/ide/src/goto_definition.rs b/src/tools/rust-analyzer/crates/ide/src/goto_definition.rs index b00aa4d0ca67..c0a74380810b 100644 --- a/src/tools/rust-analyzer/crates/ide/src/goto_definition.rs +++ b/src/tools/rust-analyzer/crates/ide/src/goto_definition.rs @@ -16,15 +16,12 @@ use ide_db::{ defs::{Definition, IdentClass}, famous_defs::FamousDefs, helpers::pick_best_token, + syntax_helpers::node_ext::find_loops, }; use itertools::Itertools; use span::FileId; use syntax::{ - AstNode, AstToken, - SyntaxKind::*, - SyntaxNode, SyntaxToken, T, TextRange, - ast::{self, HasLoopBody}, - match_ast, + AstNode, AstToken, SyntaxKind::*, SyntaxNode, SyntaxToken, T, TextRange, ast, match_ast, }; #[derive(Debug)] @@ -510,51 +507,6 @@ fn nav_for_branch_exit_points( Some(navs) } -pub(crate) fn find_loops( - sema: &Semantics<'_, RootDatabase>, - token: &SyntaxToken, -) -> Option> { - let parent = token.parent()?; - let lbl = match_ast! { - match parent { - ast::BreakExpr(break_) => break_.lifetime(), - ast::ContinueExpr(continue_) => continue_.lifetime(), - _ => None, - } - }; - let label_matches = - |it: Option| match (lbl.as_ref(), it.and_then(|it| it.lifetime())) { - (Some(lbl), Some(it)) => lbl.text() == it.text(), - (None, _) => true, - (Some(_), None) => false, - }; - - let find_ancestors = |token: SyntaxToken| { - for anc in sema.token_ancestors_with_macros(token).filter_map(ast::Expr::cast) { - let node = match &anc { - ast::Expr::LoopExpr(loop_) if label_matches(loop_.label()) => anc, - ast::Expr::WhileExpr(while_) if label_matches(while_.label()) => anc, - ast::Expr::ForExpr(for_) if label_matches(for_.label()) => anc, - ast::Expr::BlockExpr(blk) - if blk.label().is_some() && label_matches(blk.label()) => - { - anc - } - _ => continue, - }; - - return Some(node); - } - None - }; - - sema.descend_into_macros(token.clone()) - .into_iter() - .filter_map(find_ancestors) - .collect_vec() - .into() -} - fn nav_for_break_points( sema: &Semantics<'_, RootDatabase>, token: &SyntaxToken, @@ -562,7 +514,6 @@ fn nav_for_break_points( let db = sema.db; let navs = find_loops(sema, token)? - .into_iter() .filter_map(|expr| { let file_id = sema.hir_file_for(expr.syntax()); let expr_in_file = InFile::new(file_id, expr.clone()); diff --git a/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs b/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs index acba573cc00e..fce033382b4b 100644 --- a/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs +++ b/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs @@ -7,8 +7,8 @@ use ide_db::{ helpers::pick_best_token, search::{FileReference, ReferenceCategory, SearchScope}, syntax_helpers::node_ext::{ - eq_label_lt, for_each_tail_expr, full_path_of_name_ref, is_closure_or_blk_with_modif, - preorder_expr_with_ctx_checker, + eq_label_lt, find_loops, for_each_tail_expr, full_path_of_name_ref, + is_closure_or_blk_with_modif, preorder_expr_with_ctx_checker, }, }; use syntax::{ @@ -562,7 +562,7 @@ pub(crate) fn highlight_break_points( Some(highlights) } - let Some(loops) = goto_definition::find_loops(sema, &token) else { + let Some(loops) = find_loops(sema, &token) else { return FxHashMap::default(); }; From 42ec5c7b324f2754453691d93561c2738407db2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 12 Dec 2025 19:52:23 +0000 Subject: [PATCH 408/489] Detail expectation on non-`()` block tail in `if` then condition with no `else` When encountering an `if` expression with no `else` where the then block has a tail expression, we emit an E0308 type error. We now explain why `()` was expected. --- compiler/rustc_hir_typeck/src/coercion.rs | 15 ++++++++++++++- ...e-for-type-mismatch-in-closure-in-async.stderr | 2 +- .../missing-return-in-async-block.stderr | 4 ++-- .../unused/unused-doc-comments-edge-cases.stderr | 2 +- .../ui/loops/dont-suggest-break-thru-item.stderr | 8 ++++---- .../struct-literals-in-invalid-places.stderr | 2 +- .../issue-82612-return-mutable-reference.stderr | 2 +- .../return/tail-expr-as-potential-return.stderr | 6 +++--- tests/ui/return/tail-expr-if-as-return.stderr | 2 +- .../try-operator-dont-suggest-semicolon.rs | 2 +- .../try-operator-dont-suggest-semicolon.stderr | 2 +- 11 files changed, 30 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index b4a43548dcda..5e1e567d103e 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1838,7 +1838,20 @@ impl<'tcx> CoerceMany<'tcx> { hir::ExprKind::Match(.., hir::MatchSource::TryDesugar(_)) ) { - err.span_label(cond_expr.span, "expected this to be `()`"); + if let ObligationCauseCode::BlockTailExpression(hir_id, hir::MatchSource::Normal) = + cause.code() + && let hir::Node::Block(block) = fcx.tcx.hir_node(*hir_id) + && let hir::Node::Expr(expr) = fcx.tcx.parent_hir_node(block.hir_id) + && let hir::Node::Expr(if_expr) = fcx.tcx.parent_hir_node(expr.hir_id) + && let hir::ExprKind::If(_cond, _then, None) = if_expr.kind + { + err.span_label( + cond_expr.span, + "`if` expressions without `else` arms expect their inner expression to be `()`", + ); + } else { + err.span_label(cond_expr.span, "expected this to be `()`"); + } if expr.can_have_side_effects() { fcx.suggest_semicolon_at_end(cond_expr.span, &mut err); } diff --git a/tests/ui/async-await/dont-ice-for-type-mismatch-in-closure-in-async.stderr b/tests/ui/async-await/dont-ice-for-type-mismatch-in-closure-in-async.stderr index ce023397db90..928e1fcaa578 100644 --- a/tests/ui/async-await/dont-ice-for-type-mismatch-in-closure-in-async.stderr +++ b/tests/ui/async-await/dont-ice-for-type-mismatch-in-closure-in-async.stderr @@ -6,7 +6,7 @@ LL | | false | | ^^^^^ expected `()`, found `bool` LL | | LL | | } - | |_________- expected this to be `()` + | |_________- `if` expressions without `else` arms expect their inner expression to be `()` error[E0308]: mismatched types --> $DIR/dont-ice-for-type-mismatch-in-closure-in-async.rs:12:9 diff --git a/tests/ui/async-await/missing-return-in-async-block.stderr b/tests/ui/async-await/missing-return-in-async-block.stderr index 5ea76e5f7bf9..a7d72ab5f33c 100644 --- a/tests/ui/async-await/missing-return-in-async-block.stderr +++ b/tests/ui/async-await/missing-return-in-async-block.stderr @@ -5,7 +5,7 @@ LL | / if true { LL | | Ok(S) | | ^^^^^ expected `()`, found `Result` LL | | } - | |_________- expected this to be `()` + | |_________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result` @@ -21,7 +21,7 @@ LL | / if true { LL | | Ok(S) | | ^^^^^ expected `()`, found `Result` LL | | } - | |_________- expected this to be `()` + | |_________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result` diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr index c07411745549..0f0288c6def6 100644 --- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr +++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr @@ -105,7 +105,7 @@ LL | / if num == 3 { LL | | true | | ^^^^ expected `()`, found `bool` LL | | } - | |_____- expected this to be `()` + | |_____- `if` expressions without `else` arms expect their inner expression to be `()` | help: you might have meant to return this value | diff --git a/tests/ui/loops/dont-suggest-break-thru-item.stderr b/tests/ui/loops/dont-suggest-break-thru-item.stderr index e7ed7ae15015..576bd353520f 100644 --- a/tests/ui/loops/dont-suggest-break-thru-item.stderr +++ b/tests/ui/loops/dont-suggest-break-thru-item.stderr @@ -6,7 +6,7 @@ LL | | Err(1) | | ^^^^^^ expected `()`, found `Result<_, {integer}>` ... | LL | | } - | |_____________- expected this to be `()` + | |_____________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` @@ -23,7 +23,7 @@ LL | | Err(1) | | ^^^^^^ expected `()`, found `Result<_, {integer}>` ... | LL | | } - | |_____________- expected this to be `()` + | |_____________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` @@ -40,7 +40,7 @@ LL | | Err(1) | | ^^^^^^ expected `()`, found `Result<_, {integer}>` LL | | LL | | } - | |_____________- expected this to be `()` + | |_____________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` @@ -53,7 +53,7 @@ LL | | Err(1) | | ^^^^^^ expected `()`, found `Result<_, {integer}>` LL | | LL | | } - | |_____________- expected this to be `()` + | |_____________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` diff --git a/tests/ui/parser/struct-literals-in-invalid-places.stderr b/tests/ui/parser/struct-literals-in-invalid-places.stderr index 39dc2d2efb75..380ecf94d824 100644 --- a/tests/ui/parser/struct-literals-in-invalid-places.stderr +++ b/tests/ui/parser/struct-literals-in-invalid-places.stderr @@ -200,7 +200,7 @@ LL | if x == E::V { field } {} | ---------------^^^^^-- | | | | | expected `()`, found `bool` - | expected this to be `()` + | `if` expressions without `else` arms expect their inner expression to be `()` | help: you might have meant to return this value | diff --git a/tests/ui/return/issue-82612-return-mutable-reference.stderr b/tests/ui/return/issue-82612-return-mutable-reference.stderr index 59a6bb85d0fd..632f366c7551 100644 --- a/tests/ui/return/issue-82612-return-mutable-reference.stderr +++ b/tests/ui/return/issue-82612-return-mutable-reference.stderr @@ -6,7 +6,7 @@ LL | | let value = unsafe { self.values.get_unchecked_mut(index) }; LL | | value.get_or_insert_with(func) | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&mut V` LL | | } - | |_________- expected this to be `()` + | |_________- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found mutable reference `&mut V` diff --git a/tests/ui/return/tail-expr-as-potential-return.stderr b/tests/ui/return/tail-expr-as-potential-return.stderr index 8105b2df3fea..be3d4b5116f2 100644 --- a/tests/ui/return/tail-expr-as-potential-return.stderr +++ b/tests/ui/return/tail-expr-as-potential-return.stderr @@ -6,7 +6,7 @@ LL | | Err(42) | | ^^^^^^^ expected `()`, found `Result<_, {integer}>` ... | LL | | } - | |_____- expected this to be `()` + | |_____- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` @@ -23,7 +23,7 @@ LL | | 1i32 | | ^^^^ expected `()`, found `i32` ... | LL | | } - | |_____- expected this to be `()` + | |_____- `if` expressions without `else` arms expect their inner expression to be `()` | help: you might have meant to return this value | @@ -38,7 +38,7 @@ LL | | Err(42) | | ^^^^^^^ expected `()`, found `Result<_, {integer}>` ... | LL | | } - | |_____- expected this to be `()` + | |_____- `if` expressions without `else` arms expect their inner expression to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` diff --git a/tests/ui/return/tail-expr-if-as-return.stderr b/tests/ui/return/tail-expr-if-as-return.stderr index 2631f1e426de..68acde416bc7 100644 --- a/tests/ui/return/tail-expr-if-as-return.stderr +++ b/tests/ui/return/tail-expr-if-as-return.stderr @@ -5,7 +5,7 @@ LL | / if true { LL | | "" | | ^^ expected `()`, found `&str` LL | | } - | |_____- expected this to be `()` + | |_____- `if` expressions without `else` arms expect their inner expression to be `()` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/try-operator-dont-suggest-semicolon.rs b/tests/ui/suggestions/try-operator-dont-suggest-semicolon.rs index f882a159f983..fdd5dfc8307a 100644 --- a/tests/ui/suggestions/try-operator-dont-suggest-semicolon.rs +++ b/tests/ui/suggestions/try-operator-dont-suggest-semicolon.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), ()> { // Here, we do want to suggest a semicolon: let x = Ok(42); if true { - //~^ NOTE: expected this to be `()` + //~^ NOTE: `if` expressions without `else` arms expect their inner expression to be `()` x? //~^ ERROR: mismatched types [E0308] //~| NOTE: expected `()`, found integer diff --git a/tests/ui/suggestions/try-operator-dont-suggest-semicolon.stderr b/tests/ui/suggestions/try-operator-dont-suggest-semicolon.stderr index a275f0c2fa89..25cd27488c8c 100644 --- a/tests/ui/suggestions/try-operator-dont-suggest-semicolon.stderr +++ b/tests/ui/suggestions/try-operator-dont-suggest-semicolon.stderr @@ -15,7 +15,7 @@ LL | | x? | | ^^ expected `()`, found integer ... | LL | | } - | |_____- expected this to be `()` + | |_____- `if` expressions without `else` arms expect their inner expression to be `()` | help: consider using a semicolon here | From 7eeaa7ad4841b8e0e63bfd2dff5e2fba7d1fadf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 22 Dec 2025 16:31:05 +0200 Subject: [PATCH 409/489] Fix name collision warning --- src/tools/rust-analyzer/crates/hir/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/hir/src/lib.rs b/src/tools/rust-analyzer/crates/hir/src/lib.rs index 90a0c2b402c0..9fc29de4a11c 100644 --- a/src/tools/rust-analyzer/crates/hir/src/lib.rs +++ b/src/tools/rust-analyzer/crates/hir/src/lib.rs @@ -2624,7 +2624,7 @@ impl SelfParam { let callable_sig = db.callable_item_signature(self.func.into()).instantiate_identity().skip_binder(); let environment = param_env_from_has_crate(db, self.func); - let ty = callable_sig.inputs().as_slice()[0]; + let ty = rustc_type_ir::inherent::SliceLike::as_slice(&callable_sig.inputs())[0]; Type { env: environment, ty } } @@ -2639,7 +2639,7 @@ impl SelfParam { let callable_sig = db.callable_item_signature(self.func.into()).instantiate(interner, args).skip_binder(); let environment = param_env_from_has_crate(db, self.func); - let ty = callable_sig.inputs().as_slice()[0]; + let ty = rustc_type_ir::inherent::SliceLike::as_slice(&callable_sig.inputs())[0]; Type { env: environment, ty } } } From 26ef77a94a1ae929c80573509c69117e5b2c3c2b Mon Sep 17 00:00:00 2001 From: Roy Ammerschuber Date: Tue, 2 Dec 2025 17:46:44 +0100 Subject: [PATCH 410/489] tree borrows: detect no_valid_exposed_references errors accurately --- .../src/borrow_tracker/tree_borrows/perms.rs | 12 ++--- .../src/borrow_tracker/tree_borrows/tree.rs | 33 +++++++++++-- .../borrow_tracker/tree_borrows/wildcard.rs | 14 +++++- ...cross_tree_update_main_invalid_exposed2.rs | 48 +++++++++++++++++++ ...s_tree_update_main_invalid_exposed2.stderr | 14 ++++++ 5 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.rs create mode 100644 src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.stderr diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs index bd4573f94013..064c1cc5b95f 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs @@ -374,9 +374,9 @@ impl Permission { self.inner.strongest_idempotent_foreign_access(prot) } - /// Returns the strongest access allowed from a child to this node without + /// Returns the strongest access allowed that is local to this node without /// causing UB (only considers possible transitions to this permission). - pub fn strongest_allowed_child_access(&self, protected: bool) -> WildcardAccessLevel { + pub fn strongest_allowed_local_access(&self, protected: bool) -> WildcardAccessLevel { match self.inner { // Everything except disabled can be accessed by read access. Disabled => WildcardAccessLevel::None, @@ -794,9 +794,9 @@ mod propagation_optimization_checks { /// Checks that `strongest_allowed_child_access` correctly /// represents which transitions are possible. #[test] - fn strongest_allowed_child_access() { + fn strongest_allowed_local_access() { for (permission, protected) in <(Permission, bool)>::exhaustive() { - let strongest_child_access = permission.strongest_allowed_child_access(protected); + let strongest_local_access = permission.strongest_allowed_local_access(protected); let is_read_valid = Permission::perform_access( AccessKind::Read, @@ -814,8 +814,8 @@ mod propagation_optimization_checks { ) .is_some(); - assert_eq!(is_read_valid, strongest_child_access >= WildcardAccessLevel::Read); - assert_eq!(is_write_valid, strongest_child_access >= WildcardAccessLevel::Write); + assert_eq!(is_read_valid, strongest_local_access >= WildcardAccessLevel::Read); + assert_eq!(is_write_valid, strongest_local_access >= WildcardAccessLevel::Write); } } } diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs index 900e9c3729c8..c8e27ebf0ff3 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs @@ -111,7 +111,7 @@ impl LocationState { // We need to update the wildcard state, if the permission // of an exposed pointer changes. if node.is_exposed { - let access_type = self.permission.strongest_allowed_child_access(protected); + let access_type = self.permission.strongest_allowed_local_access(protected); WildcardState::update_exposure(idx, access_type, nodes, wildcard_accesses); } } @@ -1034,6 +1034,9 @@ impl<'tcx> LocationTree { wildcard_state.access_relatedness(access_kind, only_foreign) }; + // Whether there is an exposed node in this tree that allows this access. + let mut has_valid_exposed = false; + // This does a traversal across the tree updating children before their parents. The // difference to `perform_normal_access` is that we take the access relatedness from // the wildcard tracking state of the node instead of from the visitor itself. @@ -1082,6 +1085,17 @@ impl<'tcx> LocationTree { return Err(no_valid_exposed_references_error(diagnostics)); }; + let mut entry = args.data.perms.entry(args.idx); + let perm = entry.or_insert(node.default_location_state()); + + // We only count exposed nodes through which an access could happen. + if node.is_exposed + && perm.permission.strongest_allowed_local_access(protected).allows(access_kind) + && max_local_tag.is_none_or(|max_local_tag| max_local_tag >= node.tag) + { + has_valid_exposed = true; + } + let Some(relatedness) = wildcard_relatedness.to_relatedness() else { // If the access type is Either, then we do not apply any transition // to this node, but we still update each of its children. @@ -1090,8 +1104,6 @@ impl<'tcx> LocationTree { return Ok(()); }; - let mut entry = args.data.perms.entry(args.idx); - let perm = entry.or_insert(node.default_location_state()); // We know the exact relatedness, so we can actually do precise checks. perm.perform_transition( args.idx, @@ -1115,6 +1127,21 @@ impl<'tcx> LocationTree { }) }, )?; + // If there is no exposed node in this tree that allows this access, then the + // access *must* be foreign. So we check if the root of this tree would allow this + // as a foreign access, and if not, then we can error. + // In practice, all wildcard trees accept foreign accesses, but the main tree does + // not, so this catches UB when none of the nodes in the main tree allows this access. + if !has_valid_exposed + && self + .wildcard_accesses + .get(root) + .unwrap() + .access_relatedness(access_kind, /* only_foreign */ true) + .is_none() + { + return Err(no_valid_exposed_references_error(diagnostics)).into(); + } interp_ok(()) } } diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/wildcard.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/wildcard.rs index 3b55a9e36ea6..b5ae0ee4c7d3 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/wildcard.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/wildcard.rs @@ -20,6 +20,16 @@ pub enum WildcardAccessLevel { Read, Write, } +impl WildcardAccessLevel { + /// Weather this access kind is allowed at this level. + pub fn allows(self, kind: AccessKind) -> bool { + let required_level = match kind { + AccessKind::Read => Self::Read, + AccessKind::Write => Self::Write, + }; + required_level <= self + } +} /// Where the access happened relative to the current node. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -430,7 +440,7 @@ impl Tree { .map(|p| p.permission()) .unwrap_or_else(|| node.default_location_state().permission()); - let access_type = perm.strongest_allowed_child_access(protected); + let access_type = perm.strongest_allowed_local_access(protected); WildcardState::update_exposure( id, access_type, @@ -480,7 +490,7 @@ impl Tree { perms.get(id).copied().unwrap_or_else(|| node.default_location_state()); perm.permission() - .strongest_allowed_child_access(protected_tags.contains_key(&node.tag)) + .strongest_allowed_local_access(protected_tags.contains_key(&node.tag)) } else { WildcardAccessLevel::None }; diff --git a/src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.rs b/src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.rs new file mode 100644 index 000000000000..ca430cad1670 --- /dev/null +++ b/src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.rs @@ -0,0 +1,48 @@ +//@compile-flags: -Zmiri-tree-borrows -Zmiri-permissive-provenance +use std::cell::Cell; + +/// Checks how accesses from one subtree affect other subtrees. +/// This test checks that an access from a subtree performs a +/// wildcard access on all earlier trees, and that local +/// accesses are treated as access errors for tags that are +/// larger than the root of the accessed subtree. +/// This tests the case were we have multiple exposed nodes on +/// the main tree that are invalid because their tag is too large. +pub fn main() { + let mut x: u32 = 42; + + let ptr_base = &mut x as *mut u32; + let ref1 = unsafe { &mut *ptr_base }; + let int1 = ref1 as *mut u32 as usize; + let wild = int1 as *mut u32; + + // Activates ref1. + *ref1 = 4; + + let ref2 = unsafe { &mut *wild }; + + // Freezes ref1. + let ref3 = unsafe { &mut *(ptr_base as *mut Cell) }; + let _int3 = ref3 as *mut Cell as usize; + let ref4 = unsafe { &mut *(ptr_base as *mut Cell) }; + let _int4 = ref4 as *mut Cell as usize; + + // ┌──────────────┐ + // │ │ + // │ptr_base(Act) ├───────────┬──────────────────┐ * + // │ │ │ │ │ + // └──────┬───────┘ │ │ │ + // │ │ │ │ + // │ │ │ │ + // ▼ ▼ ▼ ▼ + // ┌─────────────┐ ┌────────────┐ ┌────────────┐ ┌───────────┐ + // │ │ │ │ │ │ │ │ + // │ ref1(Frz)* │ │ ref3(ReIM)*│ │ ref4(ReIM)*│ │ ref2(Res) │ + // │ │ │ │ │ │ │ │ + // └─────────────┘ └────────────┘ └────────────┘ └───────────┘ + + // Performs a wildcard access on the main root. However, as there are + // no exposed tags with write permissions and a tag smaller than ref2 + // this access fails. + *ref2 = 13; //~ ERROR: /write access through .* is forbidden/ +} diff --git a/src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.stderr b/src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.stderr new file mode 100644 index 000000000000..1f7a3d61829c --- /dev/null +++ b/src/tools/miri/tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.stderr @@ -0,0 +1,14 @@ +error: Undefined Behavior: write access through at ALLOC[0x0] is forbidden + --> tests/fail/tree_borrows/wildcard/cross_tree_update_main_invalid_exposed2.rs:LL:CC + | +LL | *ref2 = 13; + | ^^^^^^^^^^ Undefined Behavior occurred here + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information + = help: there are no exposed tags which may perform this access here + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + From 3f8b25771d1074abb391c55dc2c33df3a8278043 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova <58857108+ada4a@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:50:41 +0100 Subject: [PATCH 411/489] Fix typo --- compiler/rustc_ast/src/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 1ea9e0ae7718..7c922417ee29 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1810,7 +1810,7 @@ pub enum ExprKind { /// or a `gen` block (`gen move { ... }`). /// /// The span is the "decl", which is the header before the body `{ }` - /// including the `asyng`/`gen` keywords and possibly `move`. + /// including the `async`/`gen` keywords and possibly `move`. Gen(CaptureBy, Box, GenBlockKind, Span), /// An await expression (`my_future.await`). Span is of await keyword. Await(Box, Span), From 9ae46aa9a3fd63877b04d2d240fc6ff5fe20a38b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 22 Dec 2025 17:23:53 +0100 Subject: [PATCH 412/489] readme: update android state --- src/tools/miri/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 86f190134d45..2832ef50adef 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -219,7 +219,7 @@ degree documented below): - We have unofficial support (not maintained by the Miri team itself) for some further operating systems. - `solaris` / `illumos`: maintained by @devnexen. Supports the entire test suite. - `freebsd`: maintained by @YohDeadfall and @LorrensP-2158466. Supports the entire test suite. - - `android`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works. + - `android`: **maintainer wanted**. Basic OS APIs and concurrency work, but file system access is not supported. - For targets on other operating systems, Miri might fail before even reaching the `main` function. However, even for targets that we do support, the degree of support for accessing platform APIs From 1b8ee46683206a1fe52dd8a7dcdeb8adfc9dc309 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 22 Dec 2025 17:41:53 +0100 Subject: [PATCH 413/489] Add `needs-std-remap-debuginfo` directive to `compiletest` & run-make --- src/bootstrap/src/core/build_steps/test.rs | 4 ++++ .../rustc-dev-guide/src/tests/directives.md | 4 ++++ src/tools/compiletest/src/common.rs | 5 +++++ src/tools/compiletest/src/directives/cfg.rs | 5 +++++ .../src/directives/directive_names.rs | 1 + src/tools/compiletest/src/directives/needs.rs | 5 +++++ src/tools/compiletest/src/directives/tests.rs | 22 +++++++++++++++++++ src/tools/compiletest/src/lib.rs | 3 +++ src/tools/compiletest/src/runtest/run_make.rs | 6 +++++ src/tools/compiletest/src/rustdoc_gui_test.rs | 1 + src/tools/run-make-support/src/env.rs | 8 +++++++ 11 files changed, 64 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 7ca6ae46a8f8..a58739c9e65c 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2257,6 +2257,10 @@ Please disable assertions with `rust.debug-assertions = false`. cmd.arg("--with-std-debug-assertions"); } + if builder.config.rust_remap_debuginfo { + cmd.arg("--with-std-remap-debuginfo"); + } + let mut llvm_components_passed = false; let mut copts_passed = false; if builder.config.llvm_enabled(test_compiler.host) { diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md index 7cf5869b719c..c8b0072dc101 100644 --- a/src/doc/rustc-dev-guide/src/tests/directives.md +++ b/src/doc/rustc-dev-guide/src/tests/directives.md @@ -189,6 +189,10 @@ settings: assertions. - `needs-std-debug-assertions` — ignores if std was not built with debug assertions. +- `ignore-std-remap-debuginfo` — ignores if std was built with remapping of + it's sources. +- `needs-std-remap-debugino` — ignores if std was not built with remapping of + it's sources. - `ignore-rustc-debug-assertions` — ignores if rustc was built with debug assertions. - `needs-rustc-debug-assertions` — ignores if rustc was not built with debug diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index cd0e79f5ab3f..9473e51688cb 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -438,6 +438,11 @@ pub struct Config { /// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`. pub with_std_debug_assertions: bool, + /// Whether *staged* `std` was built with remapping of debuginfo. + /// + /// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`. + pub with_std_remap_debuginfo: bool, + /// Only run tests that match these filters (using `libtest` "test name contains" filter logic). /// /// FIXME(#139660): the current hand-rolled test executor intentionally mimics the `libtest` diff --git a/src/tools/compiletest/src/directives/cfg.rs b/src/tools/compiletest/src/directives/cfg.rs index 62d10f14b98f..e89c1330f467 100644 --- a/src/tools/compiletest/src/directives/cfg.rs +++ b/src/tools/compiletest/src/directives/cfg.rs @@ -202,6 +202,11 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions { config.with_std_debug_assertions, "when std is built with debug assertions", ); + builder.cond( + "std-remap-debuginfo", + config.with_std_remap_debuginfo, + "when std is built with remapping of debuginfo", + ); for &debugger in Debugger::STR_VARIANTS { builder.cond( diff --git a/src/tools/compiletest/src/directives/directive_names.rs b/src/tools/compiletest/src/directives/directive_names.rs index e9824edfef60..282e2a131d93 100644 --- a/src/tools/compiletest/src/directives/directive_names.rs +++ b/src/tools/compiletest/src/directives/directive_names.rs @@ -184,6 +184,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "needs-sanitizer-support", "needs-sanitizer-thread", "needs-std-debug-assertions", + "needs-std-remap-debuginfo", "needs-subprocess", "needs-symlink", "needs-target-has-atomic", diff --git a/src/tools/compiletest/src/directives/needs.rs b/src/tools/compiletest/src/directives/needs.rs index 92b596c70ae9..36c2ca62cd87 100644 --- a/src/tools/compiletest/src/directives/needs.rs +++ b/src/tools/compiletest/src/directives/needs.rs @@ -181,6 +181,11 @@ pub(super) fn handle_needs( condition: config.with_std_debug_assertions, ignore_reason: "ignored if std wasn't built with debug assertions", }, + Need { + name: "needs-std-remap-debuginfo", + condition: config.with_std_remap_debuginfo, + ignore_reason: "ignored if std wasn't built with remapping of debuginfo", + }, Need { name: "needs-target-std", condition: build_helper::targets::target_supports_std(&config.target), diff --git a/src/tools/compiletest/src/directives/tests.rs b/src/tools/compiletest/src/directives/tests.rs index 90e2cb77e304..93f1041a8f41 100644 --- a/src/tools/compiletest/src/directives/tests.rs +++ b/src/tools/compiletest/src/directives/tests.rs @@ -117,6 +117,7 @@ struct ConfigBuilder { profiler_runtime: bool, rustc_debug_assertions: bool, std_debug_assertions: bool, + std_remap_debuginfo: bool, } impl ConfigBuilder { @@ -185,6 +186,11 @@ impl ConfigBuilder { self } + fn std_remap_debuginfo(&mut self, is_enabled: bool) -> &mut Self { + self.std_remap_debuginfo = is_enabled; + self + } + fn build(&mut self) -> Config { let args = &[ "compiletest", @@ -246,6 +252,9 @@ impl ConfigBuilder { if self.std_debug_assertions { args.push("--with-std-debug-assertions".to_owned()); } + if self.std_remap_debuginfo { + args.push("--with-std-remap-debuginfo".to_owned()); + } args.push("--rustc-path".to_string()); args.push(std::env::var("TEST_RUSTC").expect("must be configured by bootstrap")); @@ -400,6 +409,19 @@ fn std_debug_assertions() { assert!(check_ignore(&config, "//@ ignore-std-debug-assertions")); } +#[test] +fn std_remap_debuginfo() { + let config: Config = cfg().std_remap_debuginfo(false).build(); + + assert!(check_ignore(&config, "//@ needs-std-remap-debuginfo")); + assert!(!check_ignore(&config, "//@ ignore-std-remap-debuginfo")); + + let config: Config = cfg().std_remap_debuginfo(true).build(); + + assert!(!check_ignore(&config, "//@ needs-std-remap-debuginfo")); + assert!(check_ignore(&config, "//@ ignore-std-remap-debuginfo")); +} + #[test] fn stage() { let config: Config = cfg().stage(1).stage_id("stage1-x86_64-unknown-linux-gnu").build(); diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 90b1c10308a2..83aee865e010 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -106,6 +106,7 @@ fn parse_config(args: Vec) -> Config { .optflag("", "has-enzyme", "run tests that require enzyme") .optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions") .optflag("", "with-std-debug-assertions", "whether std was built with debug assertions") + .optflag("", "with-std-remap-debuginfo", "whether std was built with remapping") .optmulti( "", "skip", @@ -295,6 +296,7 @@ fn parse_config(args: Vec) -> Config { let run_ignored = matches.opt_present("ignored"); let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions"); let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions"); + let with_std_remap_debuginfo = matches.opt_present("with-std-remap-debuginfo"); let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode"); let has_enzyme = matches.opt_present("has-enzyme"); let filters = if mode == TestMode::RunMake { @@ -402,6 +404,7 @@ fn parse_config(args: Vec) -> Config { run_ignored, with_rustc_debug_assertions, with_std_debug_assertions, + with_std_remap_debuginfo, filters, skip: matches.opt_strs("skip"), filter_exact: matches.opt_present("exact"), diff --git a/src/tools/compiletest/src/runtest/run_make.rs b/src/tools/compiletest/src/runtest/run_make.rs index 68574eb4bfd6..ba3a12347367 100644 --- a/src/tools/compiletest/src/runtest/run_make.rs +++ b/src/tools/compiletest/src/runtest/run_make.rs @@ -243,6 +243,12 @@ impl TestCx<'_> { cmd.env("__STD_DEBUG_ASSERTIONS_ENABLED", "1"); } + cmd.env_remove("__STD_REMAP_DEBUGINFO_ENABLED"); + if self.config.with_std_remap_debuginfo { + // Used for `run_make_support::env::std_remap_debuginfo_enabled`. + cmd.env("__STD_REMAP_DEBUGINFO_ENABLED", "1"); + } + // We don't want RUSTFLAGS set from the outside to interfere with // compiler flags set in the test cases: cmd.env_remove("RUSTFLAGS"); diff --git a/src/tools/compiletest/src/rustdoc_gui_test.rs b/src/tools/compiletest/src/rustdoc_gui_test.rs index c30f3d1e10ea..2b057bb35519 100644 --- a/src/tools/compiletest/src/rustdoc_gui_test.rs +++ b/src/tools/compiletest/src/rustdoc_gui_test.rs @@ -83,6 +83,7 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config { run_ignored: Default::default(), with_rustc_debug_assertions: Default::default(), with_std_debug_assertions: Default::default(), + with_std_remap_debuginfo: Default::default(), filters: Default::default(), skip: Default::default(), filter_exact: Default::default(), diff --git a/src/tools/run-make-support/src/env.rs b/src/tools/run-make-support/src/env.rs index cf1a6f7351a7..507d51471df0 100644 --- a/src/tools/run-make-support/src/env.rs +++ b/src/tools/run-make-support/src/env.rs @@ -34,6 +34,14 @@ pub fn std_debug_assertions_enabled() -> bool { std::env::var_os("__STD_DEBUG_ASSERTIONS_ENABLED").is_some() } +/// Check if staged `std`-under-test was built with remapping of it's sources. +#[track_caller] +#[must_use] +pub fn std_remap_debuginfo_enabled() -> bool { + // Note: we assume this env var is set when the test recipe is being executed. + std::env::var_os("__STD_REMAP_DEBUGINFO_ENABLED").is_some() +} + /// A wrapper around [`std::env::set_current_dir`] which includes the directory /// path in the panic message. #[track_caller] From 4d839da22bd6c543eed854ba048df97ebd2b2150 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 22 Dec 2025 17:41:13 +0100 Subject: [PATCH 414/489] Remap both absolute and relative paths when building rustc and std --- src/bootstrap/src/bin/rustc.rs | 7 ++- src/bootstrap/src/core/builder/cargo.rs | 26 +++++++-- tests/run-make/remap-path-prefix-std/rmake.rs | 53 +++++++++++++++++++ 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 tests/run-make/remap-path-prefix-std/rmake.rs diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index f15b76fa85c9..bb974e4645ea 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -168,8 +168,11 @@ fn main() { } } - if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") { - cmd.arg("--remap-path-prefix").arg(&map); + // The remap flags for the compiler and standard library sources. + if let Ok(maps) = env::var("RUSTC_DEBUGINFO_MAP") { + for map in maps.split('\t') { + cmd.arg("--remap-path-prefix").arg(map); + } } // The remap flags for Cargo registry sources need to be passed after the remapping for the // Rust source code directory, to handle cases when $CARGO_HOME is inside the source directory. diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 4697de7ffe0d..b0a8ce77efe7 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1025,15 +1025,26 @@ impl Builder<'_> { if let Some(ref map_to) = self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler) { + // Tell the compiler which prefix was used for remapping the standard library cargo.env("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR", map_to); } if let Some(ref map_to) = self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::Compiler) { - // When building compiler sources, we want to apply the compiler remap scheme. - cargo.env("RUSTC_DEBUGINFO_MAP", format!("compiler/={map_to}/compiler")); + // Tell the compiler which prefix was used for remapping the compiler it-self cargo.env("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR", map_to); + + // When building compiler sources, we want to apply the compiler remap scheme. + let map = [ + // Cargo use relative paths for workspace members, so let's remap those. + format!("compiler/={map_to}/compiler"), + // rustc creates absolute paths (in part bc of the `rust-src` unremap + // and for working directory) so let's remap the build directory as well. + format!("{}={map_to}", self.build.src.display()), + ] + .join("\t"); + cargo.env("RUSTC_DEBUGINFO_MAP", map); } } Mode::Std @@ -1044,7 +1055,16 @@ impl Builder<'_> { if let Some(ref map_to) = self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler) { - cargo.env("RUSTC_DEBUGINFO_MAP", format!("library/={map_to}/library")); + // When building the standard library sources, we want to apply the std remap scheme. + let map = [ + // Cargo use relative paths for workspace members, so let's remap those. + format!("library/={map_to}/library"), + // rustc creates absolute paths (in part bc of the `rust-src` unremap + // and for working directory) so let's remap the build directory as well. + format!("{}={map_to}", self.build.src.display()), + ] + .join("\t"); + cargo.env("RUSTC_DEBUGINFO_MAP", map); } } } diff --git a/tests/run-make/remap-path-prefix-std/rmake.rs b/tests/run-make/remap-path-prefix-std/rmake.rs new file mode 100644 index 000000000000..f5179038a9b1 --- /dev/null +++ b/tests/run-make/remap-path-prefix-std/rmake.rs @@ -0,0 +1,53 @@ +// This test makes sure that we do not leak paths to the checkout +// (ie. /checkout in CI) in the distributed `libstd` debuginfo. +// +// This test only runs on Linux and dist builder (or with `rust.remap-debuginfo = true` +// set in your `bootstrap.toml`). + +//@ needs-std-remap-debuginfo +//@ only-linux + +use std::path::PathBuf; + +use run_make_support::{llvm_dwarfdump, rfs, rustc, shallow_find_files, source_root}; + +fn main() { + // Find the target libdir for the current target + let target_libdir = { + let output = rustc().print("target-libdir").run(); + let stdout = output.stdout_utf8(); + let path = PathBuf::from(stdout.trim()); + + // Assert that the target-libdir path exists + assert!(path.exists(), "target-libdir: {path:?} does not exists"); + + path + }; + + // Find all the `libstd-.*.rlib` files under the libdir + let libstd_rlibs = shallow_find_files(&target_libdir, |p| { + if let Some(filename) = p.file_name() + && let filename = filename.to_string_lossy() + { + filename.starts_with("libstd-") && filename.ends_with(".rlib") + } else { + false + } + }); + + // Assert that there is only one rlib for the `libstd` + let [libstd_rlib] = &libstd_rlibs[..] else { + unreachable!("multiple libstd rlib: {libstd_rlibs:?} in {target_libdir:?}"); + }; + + // Symlink the libstd rlib here to avoid absolute paths from llvm-dwarfdump own output + // and not from the debuginfo it-self + rfs::symlink_file(libstd_rlib, "libstd.rlib"); + + // Check that there is only `/rustc/` paths and no `/checkout`, `/home`, or whatever + llvm_dwarfdump() + .input("libstd.rlib") + .run() + .assert_stdout_contains("/rustc/") + .assert_stdout_not_contains(source_root().to_string_lossy()); +} From dfbb0fd7dc3e4f02e4102cf0b7f87958a8ca4d0e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 22 Dec 2025 13:13:50 -0800 Subject: [PATCH 415/489] std: Use `usleep` temporarily on WASI targets This fixes some fallout from 147572 where the `thread::sleep` function is is broken on `wasm32-wasip2` after that PR. The cause for this is a broken implementation of `nanosleep` in wasi-libc itself which is being fixed in WebAssembly/wasi-libc/696. Similar to 149999 this avoids the problematic function for now while the wasi-libc changes take some time to propagate into a wasi-sdk release. --- library/std/src/sys/thread/unix.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/thread/unix.rs b/library/std/src/sys/thread/unix.rs index 18cdea0e1b1b..d0396ed71300 100644 --- a/library/std/src/sys/thread/unix.rs +++ b/library/std/src/sys/thread/unix.rs @@ -520,7 +520,7 @@ pub fn set_name(name: &CStr) { debug_assert_eq!(res, libc::OK); } -#[cfg(not(target_os = "espidf"))] +#[cfg(not(any(target_os = "espidf", target_os = "wasi")))] pub fn sleep(dur: Duration) { let mut secs = dur.as_secs(); let mut nsecs = dur.subsec_nanos() as _; @@ -546,7 +546,13 @@ pub fn sleep(dur: Duration) { } } -#[cfg(target_os = "espidf")] +#[cfg(any( + target_os = "espidf", + // wasi-libc prior to WebAssembly/wasi-libc#696 has a broken implementation + // of `nanosleep`, used above by most platforms, so use `usleep` until + // that fix propagates throughout the ecosystem. + target_os = "wasi", +))] pub fn sleep(dur: Duration) { // ESP-IDF does not have `nanosleep`, so we use `usleep` instead. // As per the documentation of `usleep`, it is expected to support From 54062cff4cf06334bc49288afc2391b7dc204e65 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Mon, 22 Dec 2025 12:51:59 -0500 Subject: [PATCH 416/489] move a ui test to coretests unit test It only tests the usage and formatting of `fmt::Pointer`. --- library/coretests/tests/fmt/mod.rs | 19 +++++++++++++++++++ tests/ui/traits/fmt-pointer-trait.rs | 24 ------------------------ 2 files changed, 19 insertions(+), 24 deletions(-) delete mode 100644 tests/ui/traits/fmt-pointer-trait.rs diff --git a/library/coretests/tests/fmt/mod.rs b/library/coretests/tests/fmt/mod.rs index 0fb099ef4191..67ba49db4d91 100644 --- a/library/coretests/tests/fmt/mod.rs +++ b/library/coretests/tests/fmt/mod.rs @@ -76,6 +76,25 @@ fn test_fmt_debug_of_mut_reference() { assert_eq!(format!("{:?}", &mut x), "0"); } +#[test] +fn test_fmt_pointer() { + use std::rc::Rc; + use std::sync::Arc; + let p: *const u8 = std::ptr::null(); + let rc = Rc::new(1usize); + let arc = Arc::new(1usize); + let b = Box::new("hi"); + + let _ = format!("{rc:p}{arc:p}{b:p}"); + + if cfg!(target_pointer_width = "32") { + assert_eq!(format!("{:#p}", p), "0x00000000"); + } else { + assert_eq!(format!("{:#p}", p), "0x0000000000000000"); + } + assert_eq!(format!("{:p}", p), "0x0"); +} + #[test] fn test_default_write_impls() { use core::fmt::Write; diff --git a/tests/ui/traits/fmt-pointer-trait.rs b/tests/ui/traits/fmt-pointer-trait.rs deleted file mode 100644 index edf734597f50..000000000000 --- a/tests/ui/traits/fmt-pointer-trait.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass -use std::ptr; -use std::rc::Rc; -use std::sync::Arc; - -fn main() { - let p: *const u8 = ptr::null(); - let rc = Rc::new(1usize); - let arc = Arc::new(1usize); - let b = Box::new("hi"); - - let _ = format!("{:p}{:p}{:p}", - rc, arc, b); - - if cfg!(target_pointer_width = "32") { - assert_eq!(format!("{:#p}", p), - "0x00000000"); - } else { - assert_eq!(format!("{:#p}", p), - "0x0000000000000000"); - } - assert_eq!(format!("{:p}", p), - "0x0"); -} From 2c0f14cb0c108ac72ea23645694a4abee75babd8 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Tue, 23 Dec 2025 03:33:20 +0000 Subject: [PATCH 417/489] bugfix: Fix compilation error in hermit-abi time.rs Fixes time.rs by updating the MIN and MAX structs appropriately. Signed-off-by: John Nunley --- library/std/src/sys/pal/hermit/time.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/pal/hermit/time.rs b/library/std/src/sys/pal/hermit/time.rs index 53b1f9292b3d..734ad2540a18 100644 --- a/library/std/src/sys/pal/hermit/time.rs +++ b/library/std/src/sys/pal/hermit/time.rs @@ -213,9 +213,9 @@ pub struct SystemTime(Timespec); pub const UNIX_EPOCH: SystemTime = SystemTime(Timespec::zero()); impl SystemTime { - pub const MAX: SystemTime = SystemTime { t: Timespec::MAX }; + pub const MAX: SystemTime = SystemTime(Timespec::MAX); - pub const MIN: SystemTime = SystemTime { t: Timespec::MIN }; + pub const MIN: SystemTime = SystemTime(Timespec::MIN); pub fn new(tv_sec: i64, tv_nsec: i32) -> SystemTime { SystemTime(Timespec::new(tv_sec, tv_nsec)) From d2f42b0ab7c5df475788f908b55e01dbaeff6681 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Mon, 22 Dec 2025 19:58:33 -0800 Subject: [PATCH 418/489] bugfix: Fix compile issue in Vita libstd Unfortunately it looks like the Vita libc does not support the "utimensat" function, which is needed for setting file times. To fix the build, this commit marks Vita as unsupported for the function that sets the file times. Signed-off-by: John Nunley --- library/std/src/sys/fs/unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs index ee3cb54a5ee6..de80f2ed053f 100644 --- a/library/std/src/sys/fs/unix.rs +++ b/library/std/src/sys/fs/unix.rs @@ -2166,7 +2166,7 @@ fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> fn set_times_impl(p: &CStr, times: FileTimes, follow_symlinks: bool) -> io::Result<()> { cfg_select! { - any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "nuttx") => { + any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "nuttx", target_os = "vita") => { let _ = (p, times, follow_symlinks); Err(io::const_error!( io::ErrorKind::Unsupported, From 12610b2ce87a85ab53e2971f9e8e480659a6967c Mon Sep 17 00:00:00 2001 From: Linshu Yang Date: Tue, 23 Dec 2025 05:01:10 +0000 Subject: [PATCH 419/489] fix: `obfuscated_if_else` wrongly unmangled macros --- clippy_lints/src/methods/obfuscated_if_else.rs | 16 +++++++++------- tests/ui/obfuscated_if_else.fixed | 6 ++++++ tests/ui/obfuscated_if_else.rs | 6 ++++++ tests/ui/obfuscated_if_else.stderr | 8 +++++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/methods/obfuscated_if_else.rs b/clippy_lints/src/methods/obfuscated_if_else.rs index b2466bbd982d..69d851e81600 100644 --- a/clippy_lints/src/methods/obfuscated_if_else.rs +++ b/clippy_lints/src/methods/obfuscated_if_else.rs @@ -1,7 +1,7 @@ use super::OBFUSCATED_IF_ELSE; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::eager_or_lazy::switch_to_eager_eval; -use clippy_utils::source::snippet_with_applicability; +use clippy_utils::source::snippet_with_context; use clippy_utils::sugg::Sugg; use clippy_utils::{get_parent_expr, sym}; use rustc_errors::Applicability; @@ -33,20 +33,22 @@ pub(super) fn check<'tcx>( let if_then = match then_method_name { sym::then if let ExprKind::Closure(closure) = then_arg.kind => { let body = cx.tcx.hir_body(closure.body); - snippet_with_applicability(cx, body.value.span, "..", &mut applicability) + snippet_with_context(cx, body.value.span, expr.span.ctxt(), "..", &mut applicability).0 }, - sym::then_some => snippet_with_applicability(cx, then_arg.span, "..", &mut applicability), + sym::then_some => snippet_with_context(cx, then_arg.span, expr.span.ctxt(), "..", &mut applicability).0, _ => return, }; let els = match unwrap { - Unwrap::Or(arg) => snippet_with_applicability(cx, arg.span, "..", &mut applicability), + Unwrap::Or(arg) => snippet_with_context(cx, arg.span, expr.span.ctxt(), "..", &mut applicability).0, Unwrap::OrElse(arg) => match arg.kind { ExprKind::Closure(closure) => { let body = cx.tcx.hir_body(closure.body); - snippet_with_applicability(cx, body.value.span, "..", &mut applicability) + snippet_with_context(cx, body.value.span, expr.span.ctxt(), "..", &mut applicability).0 + }, + ExprKind::Path(_) => { + snippet_with_context(cx, arg.span, expr.span.ctxt(), "_", &mut applicability).0 + "()" }, - ExprKind::Path(_) => snippet_with_applicability(cx, arg.span, "_", &mut applicability) + "()", _ => return, }, Unwrap::OrDefault => "Default::default()".into(), @@ -54,7 +56,7 @@ pub(super) fn check<'tcx>( let sugg = format!( "if {} {{ {} }} else {{ {} }}", - Sugg::hir_with_applicability(cx, then_recv, "..", &mut applicability), + Sugg::hir_with_context(cx, then_recv, expr.span.ctxt(), "..", &mut applicability), if_then, els ); diff --git a/tests/ui/obfuscated_if_else.fixed b/tests/ui/obfuscated_if_else.fixed index 70ae090626b9..6bdb170a4aa9 100644 --- a/tests/ui/obfuscated_if_else.fixed +++ b/tests/ui/obfuscated_if_else.fixed @@ -87,3 +87,9 @@ fn issue11141() { let _ = *if true { &42 } else { &17 } as u8; //~^ obfuscated_if_else } + +#[allow(clippy::useless_format)] +fn issue16288() { + if true { format!("this is a test") } else { Default::default() }; + //~^ obfuscated_if_else +} diff --git a/tests/ui/obfuscated_if_else.rs b/tests/ui/obfuscated_if_else.rs index 8e1f57ca2c02..f7b5ea8c0135 100644 --- a/tests/ui/obfuscated_if_else.rs +++ b/tests/ui/obfuscated_if_else.rs @@ -87,3 +87,9 @@ fn issue11141() { let _ = *true.then_some(&42).unwrap_or(&17) as u8; //~^ obfuscated_if_else } + +#[allow(clippy::useless_format)] +fn issue16288() { + true.then(|| format!("this is a test")).unwrap_or_default(); + //~^ obfuscated_if_else +} diff --git a/tests/ui/obfuscated_if_else.stderr b/tests/ui/obfuscated_if_else.stderr index 0de7259d8bb8..865dca56b97a 100644 --- a/tests/ui/obfuscated_if_else.stderr +++ b/tests/ui/obfuscated_if_else.stderr @@ -139,5 +139,11 @@ error: this method chain can be written more clearly with `if .. else ..` LL | let _ = *true.then_some(&42).unwrap_or(&17) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { &42 } else { &17 }` -error: aborting due to 23 previous errors +error: this method chain can be written more clearly with `if .. else ..` + --> tests/ui/obfuscated_if_else.rs:93:5 + | +LL | true.then(|| format!("this is a test")).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { format!("this is a test") } else { Default::default() }` + +error: aborting due to 24 previous errors From ffd4da296e9238db0379433f111de2a38a50200f Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Mon, 22 Dec 2025 23:33:04 -0600 Subject: [PATCH 420/489] remove unsupported pipe module from VEXos pal --- library/std/src/sys/pal/vexos/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/std/src/sys/pal/vexos/mod.rs b/library/std/src/sys/pal/vexos/mod.rs index 3a37c8f2d488..049b435905d4 100644 --- a/library/std/src/sys/pal/vexos/mod.rs +++ b/library/std/src/sys/pal/vexos/mod.rs @@ -1,6 +1,4 @@ pub mod os; -#[path = "../unsupported/pipe.rs"] -pub mod pipe; pub mod time; #[expect(dead_code)] From ffbb9a59322f57f1e38fe7b992e7b03ad2d00edd Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 20 Dec 2025 18:42:41 +0100 Subject: [PATCH 421/489] compiletest: Add `LineNumber` newtype to avoid `+1` magic here and there Start small. If it works well we can increase usage bit by bit as time passes. Note that we keep using "0" to represent "no specific line" because changing to `Option` everywhere is much bigger and noisier change. That can be done later if wanted. --- src/tools/compiletest/src/directives.rs | 4 +++- src/tools/compiletest/src/directives/file.rs | 3 ++- src/tools/compiletest/src/directives/line.rs | 6 ++++-- .../compiletest/src/directives/line_number.rs | 21 +++++++++++++++++++ src/tools/compiletest/src/directives/tests.rs | 7 ++++--- src/tools/compiletest/src/runtest/debugger.rs | 18 +++++++--------- 6 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 src/tools/compiletest/src/directives/line_number.rs diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index c154886ebcde..d1e0c5d95001 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -29,6 +29,8 @@ mod directive_names; mod file; mod handlers; mod line; +mod line_number; +pub(crate) use line_number::LineNumber; mod needs; #[cfg(test)] mod tests; @@ -591,7 +593,7 @@ fn iter_directives( ]; // Process the extra implied directives, with a dummy line number of 0. for directive_str in extra_directives { - let directive_line = line_directive(testfile, 0, directive_str) + let directive_line = line_directive(testfile, LineNumber::ZERO, directive_str) .unwrap_or_else(|| panic!("bad extra-directive line: {directive_str:?}")); it(&directive_line); } diff --git a/src/tools/compiletest/src/directives/file.rs b/src/tools/compiletest/src/directives/file.rs index 82819ac0c8f0..57186faa56b8 100644 --- a/src/tools/compiletest/src/directives/file.rs +++ b/src/tools/compiletest/src/directives/file.rs @@ -1,5 +1,6 @@ use camino::Utf8Path; +use crate::directives::LineNumber; use crate::directives::line::{DirectiveLine, line_directive}; pub(crate) struct FileDirectives<'a> { @@ -11,7 +12,7 @@ impl<'a> FileDirectives<'a> { pub(crate) fn from_file_contents(path: &'a Utf8Path, file_contents: &'a str) -> Self { let mut lines = vec![]; - for (line_number, ln) in (1..).zip(file_contents.lines()) { + for (line_number, ln) in LineNumber::enumerate().zip(file_contents.lines()) { let ln = ln.trim(); if let Some(directive_line) = line_directive(path, line_number, ln) { diff --git a/src/tools/compiletest/src/directives/line.rs b/src/tools/compiletest/src/directives/line.rs index 16dd9a8de1c0..9cc24c98a859 100644 --- a/src/tools/compiletest/src/directives/line.rs +++ b/src/tools/compiletest/src/directives/line.rs @@ -2,13 +2,15 @@ use std::fmt; use camino::Utf8Path; +use crate::directives::LineNumber; + const COMPILETEST_DIRECTIVE_PREFIX: &str = "//@"; /// If the given line begins with the appropriate comment prefix for a directive, /// returns a struct containing various parts of the directive. pub(crate) fn line_directive<'a>( file_path: &'a Utf8Path, - line_number: usize, + line_number: LineNumber, original_line: &'a str, ) -> Option> { // Ignore lines that don't start with the comment prefix. @@ -60,7 +62,7 @@ pub(crate) struct DirectiveLine<'a> { /// Mostly used for diagnostics, but some directives (e.g. `//@ pp-exact`) /// also use it to compute a value based on the filename. pub(crate) file_path: &'a Utf8Path, - pub(crate) line_number: usize, + pub(crate) line_number: LineNumber, /// Some test directives start with a revision name in square brackets /// (e.g. `[foo]`), and only apply to that revision of the test. diff --git a/src/tools/compiletest/src/directives/line_number.rs b/src/tools/compiletest/src/directives/line_number.rs new file mode 100644 index 000000000000..ce5f200f470c --- /dev/null +++ b/src/tools/compiletest/src/directives/line_number.rs @@ -0,0 +1,21 @@ +/// A line number in a file. Internally the first line has index 1. +/// If it is 0 it means "no specific line" (used e.g. for implied directives). +/// When `Display`:ed, the first line is `1`. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub(crate) struct LineNumber(usize); + +impl LineNumber { + /// This represents "no specific line" (used e.g. for implied directives). + pub(crate) const ZERO: Self = Self(0); + + /// A never ending iterator over line numbers starting from the first line. + pub(crate) fn enumerate() -> impl Iterator { + (1..).map(LineNumber) + } +} + +impl std::fmt::Display for LineNumber { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} diff --git a/src/tools/compiletest/src/directives/tests.rs b/src/tools/compiletest/src/directives/tests.rs index 90e2cb77e304..dfc733cf4e32 100644 --- a/src/tools/compiletest/src/directives/tests.rs +++ b/src/tools/compiletest/src/directives/tests.rs @@ -6,8 +6,8 @@ use semver::Version; use crate::common::{Config, Debugger, TestMode}; use crate::directives::{ self, AuxProps, DIRECTIVE_HANDLERS_MAP, DirectivesCache, EarlyProps, Edition, EditionRange, - FileDirectives, KNOWN_DIRECTIVE_NAMES_SET, extract_llvm_version, extract_version_range, - line_directive, parse_edition, parse_normalize_rule, + FileDirectives, KNOWN_DIRECTIVE_NAMES_SET, LineNumber, extract_llvm_version, + extract_version_range, line_directive, parse_edition, parse_normalize_rule, }; use crate::executor::{CollectedTestDesc, ShouldFail}; @@ -1000,7 +1000,8 @@ fn parse_edition_range(line: &str) -> Option { let config = cfg().build(); let line_with_comment = format!("//@ {line}"); - let line = line_directive(Utf8Path::new("tmp.rs"), 0, &line_with_comment).unwrap(); + let line = + line_directive(Utf8Path::new("tmp.rs"), LineNumber::ZERO, &line_with_comment).unwrap(); super::parse_edition_range(&config, &line) } diff --git a/src/tools/compiletest/src/runtest/debugger.rs b/src/tools/compiletest/src/runtest/debugger.rs index 00935ab57d1c..c83e00c1006e 100644 --- a/src/tools/compiletest/src/runtest/debugger.rs +++ b/src/tools/compiletest/src/runtest/debugger.rs @@ -4,6 +4,7 @@ use std::io::{BufRead, BufReader}; use camino::{Utf8Path, Utf8PathBuf}; +use crate::directives::LineNumber; use crate::runtest::ProcRes; /// Representation of information to invoke a debugger and check its output @@ -11,9 +12,9 @@ pub(super) struct DebuggerCommands { /// Commands for the debuuger pub commands: Vec, /// Lines to insert breakpoints at - pub breakpoint_lines: Vec, + pub breakpoint_lines: Vec, /// Contains the source line number to check and the line itself - check_lines: Vec<(usize, String)>, + check_lines: Vec<(LineNumber, String)>, /// Source file name file: Utf8PathBuf, } @@ -26,15 +27,13 @@ impl DebuggerCommands { let mut breakpoint_lines = vec![]; let mut commands = vec![]; let mut check_lines = vec![]; - let mut counter = 0; let reader = BufReader::new(File::open(file.as_std_path()).unwrap()); - for (line_no, line) in reader.lines().enumerate() { - counter += 1; + for (line_number, line) in LineNumber::enumerate().zip(reader.lines()) { let line = line.map_err(|e| format!("Error while parsing debugger commands: {}", e))?; // Breakpoints appear on lines with actual code, typically at the end of the line. if line.contains("#break") { - breakpoint_lines.push(counter); + breakpoint_lines.push(line_number); continue; } @@ -46,7 +45,7 @@ impl DebuggerCommands { commands.push(command); } if let Some(pattern) = parse_name_value(&line, &check_directive) { - check_lines.push((line_no, pattern)); + check_lines.push((line_number, pattern)); } } @@ -88,15 +87,14 @@ impl DebuggerCommands { ); for (src_lineno, err_line) in missing { - write!(msg, "\n ({fname}:{num}) `{err_line}`", num = src_lineno + 1).unwrap(); + write!(msg, "\n ({fname}:{src_lineno}) `{err_line}`").unwrap(); } if !found.is_empty() { let init = "\nthe following subset of check directive(s) was found successfully:"; msg.push_str(init); for (src_lineno, found_line) in found { - write!(msg, "\n ({fname}:{num}) `{found_line}`", num = src_lineno + 1) - .unwrap(); + write!(msg, "\n ({fname}:{src_lineno}) `{found_line}`").unwrap(); } } From 1de1885a63804bd5e0538ba76ab27278b6acf01f Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Tue, 23 Dec 2025 10:34:23 +0300 Subject: [PATCH 422/489] Support syntax for one-line trait reuse --- compiler/rustc_parse/messages.ftl | 2 + compiler/rustc_parse/src/errors.rs | 7 + compiler/rustc_parse/src/parser/item.rs | 144 +++++++-- tests/pretty/delegation-impl-reuse.pp | 46 +++ tests/pretty/delegation-impl-reuse.rs | 18 ++ tests/ui/delegation/impl-reuse-bad-path.rs | 31 ++ .../ui/delegation/impl-reuse-bad-path.stderr | 52 ++++ tests/ui/delegation/impl-reuse-empty-glob.rs | 14 + .../delegation/impl-reuse-empty-glob.stderr | 8 + .../delegation/impl-reuse-illegal-places.rs | 51 +++ .../impl-reuse-illegal-places.stderr | 92 ++++++ .../delegation/impl-reuse-negative-traits.rs | 19 ++ .../impl-reuse-negative-traits.stderr | 9 + .../delegation/impl-reuse-non-reuse-items.rs | 32 ++ .../impl-reuse-non-reuse-items.stderr | 60 ++++ .../impl-reuse-non-trait-impl-cfg-false.rs | 10 + ...impl-reuse-non-trait-impl-cfg-false.stderr | 8 + .../delegation/impl-reuse-non-trait-impl.rs | 9 + .../impl-reuse-non-trait-impl.stderr | 8 + tests/ui/delegation/impl-reuse-pass.rs | 292 ++++++++++++++++++ 20 files changed, 879 insertions(+), 33 deletions(-) create mode 100644 tests/pretty/delegation-impl-reuse.pp create mode 100644 tests/pretty/delegation-impl-reuse.rs create mode 100644 tests/ui/delegation/impl-reuse-bad-path.rs create mode 100644 tests/ui/delegation/impl-reuse-bad-path.stderr create mode 100644 tests/ui/delegation/impl-reuse-empty-glob.rs create mode 100644 tests/ui/delegation/impl-reuse-empty-glob.stderr create mode 100644 tests/ui/delegation/impl-reuse-illegal-places.rs create mode 100644 tests/ui/delegation/impl-reuse-illegal-places.stderr create mode 100644 tests/ui/delegation/impl-reuse-negative-traits.rs create mode 100644 tests/ui/delegation/impl-reuse-negative-traits.stderr create mode 100644 tests/ui/delegation/impl-reuse-non-reuse-items.rs create mode 100644 tests/ui/delegation/impl-reuse-non-reuse-items.stderr create mode 100644 tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs create mode 100644 tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr create mode 100644 tests/ui/delegation/impl-reuse-non-trait-impl.rs create mode 100644 tests/ui/delegation/impl-reuse-non-trait-impl.stderr create mode 100644 tests/ui/delegation/impl-reuse-pass.rs diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 87d1173c0d48..747895c80469 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -162,6 +162,8 @@ parse_default_not_followed_by_item = `default` is not followed by an item .label = the `default` qualifier .note = only `fn`, `const`, `type`, or `impl` items may be prefixed by `default` +parse_delegation_non_trait_impl_reuse = only trait impls can be reused + parse_do_catch_syntax_removed = found removed `do catch` syntax .note = following RFC #2388, the new non-placeholder syntax is `try` .suggestion = replace with the new syntax diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 698d8f76aaa6..3b72c9802afd 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -3671,3 +3671,10 @@ pub(crate) struct VarargsWithoutPattern { #[suggestion(code = "_: ...", applicability = "machine-applicable")] pub span: Span, } + +#[derive(Diagnostic)] +#[diag(parse_delegation_non_trait_impl_reuse)] +pub(crate) struct ImplReuseInherentImpl { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 33913fd351a1..fb8b76e32209 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -117,6 +117,11 @@ impl<'a> Parser<'a> { } } +enum ReuseKind { + Path, + Impl, +} + impl<'a> Parser<'a> { pub fn parse_item(&mut self, force_collect: ForceCollect) -> PResult<'a, Option>> { let fn_parse_mode = @@ -249,9 +254,9 @@ impl<'a> Parser<'a> { } else if self.check_keyword_case(exp!(Trait), case) || self.check_trait_front_matter() { // TRAIT ITEM self.parse_item_trait(attrs, lo)? - } else if self.check_impl_frontmatter() { + } else if self.check_impl_frontmatter(0) { // IMPL ITEM - self.parse_item_impl(attrs, def_())? + self.parse_item_impl(attrs, def_(), false)? } else if let Const::Yes(const_span) = self.parse_constness(case) { // CONST ITEM self.recover_const_mut(const_span); @@ -265,8 +270,8 @@ impl<'a> Parser<'a> { rhs, define_opaque: None, })) - } else if self.is_reuse_path_item() { - self.parse_item_delegation()? + } else if let Some(kind) = self.is_reuse_item() { + self.parse_item_delegation(attrs, def_(), kind)? } else if self.check_keyword_case(exp!(Mod), case) || self.check_keyword_case(exp!(Unsafe), case) && self.is_keyword_ahead(1, &[kw::Mod]) { @@ -367,16 +372,25 @@ impl<'a> Parser<'a> { /// When parsing a statement, would the start of a path be an item? pub(super) fn is_path_start_item(&mut self) -> bool { self.is_kw_followed_by_ident(kw::Union) // no: `union::b`, yes: `union U { .. }` - || self.is_reuse_path_item() + || self.is_reuse_item().is_some() // yes: `reuse impl Trait for Struct { self.0 }`, yes: `reuse some_path::foo;` || self.check_trait_front_matter() // no: `auto::b`, yes: `auto trait X { .. }` || self.is_async_fn() // no(2015): `async::b`, yes: `async fn` || matches!(self.is_macro_rules_item(), IsMacroRulesItem::Yes{..}) // no: `macro_rules::b`, yes: `macro_rules! mac` } - fn is_reuse_path_item(&mut self) -> bool { + fn is_reuse_item(&mut self) -> Option { + if !self.token.is_keyword(kw::Reuse) { + return None; + } + // no: `reuse ::path` for compatibility reasons with macro invocations - self.token.is_keyword(kw::Reuse) - && self.look_ahead(1, |t| t.is_path_start() && *t != token::PathSep) + if self.look_ahead(1, |t| t.is_path_start() && *t != token::PathSep) { + Some(ReuseKind::Path) + } else if self.check_impl_frontmatter(1) { + Some(ReuseKind::Impl) + } else { + None + } } /// Are we sure this could not possibly be a macro invocation? @@ -560,6 +574,7 @@ impl<'a> Parser<'a> { &mut self, attrs: &mut AttrVec, defaultness: Defaultness, + is_reuse: bool, ) -> PResult<'a, ItemKind> { let mut constness = self.parse_constness(Case::Sensitive); let safety = self.parse_safety(Case::Sensitive); @@ -628,7 +643,11 @@ impl<'a> Parser<'a> { generics.where_clause = self.parse_where_clause()?; - let impl_items = self.parse_item_list(attrs, |p| p.parse_impl_item(ForceCollect::No))?; + let impl_items = if is_reuse { + Default::default() + } else { + self.parse_item_list(attrs, |p| p.parse_impl_item(ForceCollect::No))? + }; let (of_trait, self_ty) = match ty_second { Some(ty_second) => { @@ -699,10 +718,76 @@ impl<'a> Parser<'a> { Ok(ItemKind::Impl(Impl { generics, of_trait, self_ty, items: impl_items, constness })) } - fn parse_item_delegation(&mut self) -> PResult<'a, ItemKind> { + fn parse_item_delegation( + &mut self, + attrs: &mut AttrVec, + defaultness: Defaultness, + kind: ReuseKind, + ) -> PResult<'a, ItemKind> { let span = self.token.span; self.expect_keyword(exp!(Reuse))?; + let item_kind = match kind { + ReuseKind::Path => self.parse_path_like_delegation(), + ReuseKind::Impl => self.parse_impl_delegation(span, attrs, defaultness), + }?; + + self.psess.gated_spans.gate(sym::fn_delegation, span.to(self.prev_token.span)); + + Ok(item_kind) + } + + fn parse_delegation_body(&mut self) -> PResult<'a, Option>> { + Ok(if self.check(exp!(OpenBrace)) { + Some(self.parse_block()?) + } else { + self.expect(exp!(Semi))?; + None + }) + } + + fn parse_impl_delegation( + &mut self, + span: Span, + attrs: &mut AttrVec, + defaultness: Defaultness, + ) -> PResult<'a, ItemKind> { + let mut impl_item = self.parse_item_impl(attrs, defaultness, true)?; + let ItemKind::Impl(Impl { items, of_trait, .. }) = &mut impl_item else { unreachable!() }; + + let until_expr_span = span.to(self.prev_token.span); + + let Some(of_trait) = of_trait else { + return Err(self + .dcx() + .create_err(errors::ImplReuseInherentImpl { span: until_expr_span })); + }; + + let body = self.parse_delegation_body()?; + let whole_reuse_span = span.to(self.prev_token.span); + + items.push(Box::new(AssocItem { + id: DUMMY_NODE_ID, + attrs: Default::default(), + span: whole_reuse_span, + tokens: None, + vis: Visibility { + kind: VisibilityKind::Inherited, + span: whole_reuse_span, + tokens: None, + }, + kind: AssocItemKind::DelegationMac(Box::new(DelegationMac { + qself: None, + prefix: of_trait.trait_ref.path.clone(), + suffixes: None, + body, + })), + })); + + Ok(impl_item) + } + + fn parse_path_like_delegation(&mut self) -> PResult<'a, ItemKind> { let (qself, path) = if self.eat_lt() { let (qself, path) = self.parse_qpath(PathStyle::Expr)?; (Some(qself), path) @@ -713,43 +798,35 @@ impl<'a> Parser<'a> { let rename = |this: &mut Self| { Ok(if this.eat_keyword(exp!(As)) { Some(this.parse_ident()?) } else { None }) }; - let body = |this: &mut Self| { - Ok(if this.check(exp!(OpenBrace)) { - Some(this.parse_block()?) - } else { - this.expect(exp!(Semi))?; - None - }) - }; - let item_kind = if self.eat_path_sep() { + Ok(if self.eat_path_sep() { let suffixes = if self.eat(exp!(Star)) { None } else { let parse_suffix = |p: &mut Self| Ok((p.parse_path_segment_ident()?, rename(p)?)); Some(self.parse_delim_comma_seq(exp!(OpenBrace), exp!(CloseBrace), parse_suffix)?.0) }; - let deleg = DelegationMac { qself, prefix: path, suffixes, body: body(self)? }; - ItemKind::DelegationMac(Box::new(deleg)) + + ItemKind::DelegationMac(Box::new(DelegationMac { + qself, + prefix: path, + suffixes, + body: self.parse_delegation_body()?, + })) } else { let rename = rename(self)?; let ident = rename.unwrap_or_else(|| path.segments.last().unwrap().ident); - let deleg = Delegation { + + ItemKind::Delegation(Box::new(Delegation { id: DUMMY_NODE_ID, qself, path, ident, rename, - body: body(self)?, + body: self.parse_delegation_body()?, from_glob: false, - }; - ItemKind::Delegation(Box::new(deleg)) - }; - - let span = span.to(self.prev_token.span); - self.psess.gated_spans.gate(sym::fn_delegation, span); - - Ok(item_kind) + })) + }) } fn parse_item_list( @@ -2594,7 +2671,7 @@ impl<'a> Parser<'a> { Ok(body) } - fn check_impl_frontmatter(&mut self) -> bool { + fn check_impl_frontmatter(&mut self, look_ahead: usize) -> bool { const ALL_QUALS: &[Symbol] = &[kw::Const, kw::Unsafe]; // In contrast to the loop below, this call inserts `impl` into the // list of expected tokens shown in diagnostics. @@ -2603,7 +2680,7 @@ impl<'a> Parser<'a> { } let mut i = 0; while i < ALL_QUALS.len() { - let action = self.look_ahead(i, |token| { + let action = self.look_ahead(i + look_ahead, |token| { if token.is_keyword(kw::Impl) { return Some(true); } @@ -2618,6 +2695,7 @@ impl<'a> Parser<'a> { } i += 1; } + self.is_keyword_ahead(i, &[kw::Impl]) } diff --git a/tests/pretty/delegation-impl-reuse.pp b/tests/pretty/delegation-impl-reuse.pp new file mode 100644 index 000000000000..72f62de0eacb --- /dev/null +++ b/tests/pretty/delegation-impl-reuse.pp @@ -0,0 +1,46 @@ +#![feature(prelude_import)] +#![no_std] +//@ pretty-compare-only +//@ pretty-mode:expanded +//@ pp-exact:delegation-impl-reuse.pp + +#![allow(incomplete_features)] +#![feature(fn_delegation)] +#[macro_use] +extern crate std; +#[prelude_import] +use ::std::prelude::rust_2015::*; + +trait Trait { + fn foo(&self) {} + fn bar(&self) {} + fn baz(&self) {} +} + +struct S; + +impl Trait<{ + struct S; + 0 + }> for S { + reuse Trait<{ + struct S; + 0 + }>::foo { + self.0 + } + reuse Trait<{ + struct S; + 0 + }>::bar { + self.0 + } + reuse Trait<{ + struct S; + 0 + }>::baz { + self.0 + } +} + +fn main() {} diff --git a/tests/pretty/delegation-impl-reuse.rs b/tests/pretty/delegation-impl-reuse.rs new file mode 100644 index 000000000000..9265ea18a76f --- /dev/null +++ b/tests/pretty/delegation-impl-reuse.rs @@ -0,0 +1,18 @@ +//@ pretty-compare-only +//@ pretty-mode:expanded +//@ pp-exact:delegation-impl-reuse.pp + +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +trait Trait { + fn foo(&self) {} + fn bar(&self) {} + fn baz(&self) {} +} + +struct S; + +reuse impl Trait<{ struct S; 0 }> for S { self.0 } + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-bad-path.rs b/tests/ui/delegation/impl-reuse-bad-path.rs new file mode 100644 index 000000000000..19eb51153468 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-bad-path.rs @@ -0,0 +1,31 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +mod unresolved { + struct S; + reuse impl unresolved for S { self.0 } + //~^ ERROR failed to resolve: use of unresolved module or unlinked crate `unresolved` + //~| ERROR cannot find trait `unresolved` in this scope + + trait T {} + reuse impl T for unresolved { self.0 } + //~^ ERROR empty glob delegation is not supported + //~| ERROR cannot find type `unresolved` in this scope +} + +mod wrong_entities { + trait T {} + struct Trait; + struct S; + + reuse impl Trait for S { self.0 } + //~^ ERROR expected trait, found struct `Trait` + //~| ERROR expected trait, found struct `Trait` + + mod TraitModule {} + reuse impl TraitModule for S { self.0 } + //~^ ERROR expected trait, found module `TraitModule` + //~| ERROR expected trait, found module `TraitModule` +} + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-bad-path.stderr b/tests/ui/delegation/impl-reuse-bad-path.stderr new file mode 100644 index 000000000000..5fadd719ae4d --- /dev/null +++ b/tests/ui/delegation/impl-reuse-bad-path.stderr @@ -0,0 +1,52 @@ +error: empty glob delegation is not supported + --> $DIR/impl-reuse-bad-path.rs:11:5 + | +LL | reuse impl T for unresolved { self.0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: expected trait, found struct `Trait` + --> $DIR/impl-reuse-bad-path.rs:21:16 + | +LL | reuse impl Trait for S { self.0 } + | ^^^^^ not a trait + +error: expected trait, found module `TraitModule` + --> $DIR/impl-reuse-bad-path.rs:26:16 + | +LL | reuse impl TraitModule for S { self.0 } + | ^^^^^^^^^^^ not a trait + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `unresolved` + --> $DIR/impl-reuse-bad-path.rs:6:16 + | +LL | reuse impl unresolved for S { self.0 } + | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` + +error[E0405]: cannot find trait `unresolved` in this scope + --> $DIR/impl-reuse-bad-path.rs:6:16 + | +LL | reuse impl unresolved for S { self.0 } + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `unresolved` in this scope + --> $DIR/impl-reuse-bad-path.rs:11:22 + | +LL | reuse impl T for unresolved { self.0 } + | ^^^^^^^^^^ not found in this scope + +error[E0404]: expected trait, found struct `Trait` + --> $DIR/impl-reuse-bad-path.rs:21:16 + | +LL | reuse impl Trait for S { self.0 } + | ^^^^^ not a trait + +error[E0404]: expected trait, found module `TraitModule` + --> $DIR/impl-reuse-bad-path.rs:26:16 + | +LL | reuse impl TraitModule for S { self.0 } + | ^^^^^^^^^^^ not a trait + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0404, E0405, E0425, E0433. +For more information about an error, try `rustc --explain E0404`. diff --git a/tests/ui/delegation/impl-reuse-empty-glob.rs b/tests/ui/delegation/impl-reuse-empty-glob.rs new file mode 100644 index 000000000000..3f1314c47da6 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-empty-glob.rs @@ -0,0 +1,14 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +mod empty_glob { + trait T {} + + struct S; + + reuse impl T for S { self.0 } + //~^ ERROR empty glob delegation is not supported +} + + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-empty-glob.stderr b/tests/ui/delegation/impl-reuse-empty-glob.stderr new file mode 100644 index 000000000000..bf6bb5876351 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-empty-glob.stderr @@ -0,0 +1,8 @@ +error: empty glob delegation is not supported + --> $DIR/impl-reuse-empty-glob.rs:9:5 + | +LL | reuse impl T for S { self.0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/delegation/impl-reuse-illegal-places.rs b/tests/ui/delegation/impl-reuse-illegal-places.rs new file mode 100644 index 000000000000..361331d41315 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-illegal-places.rs @@ -0,0 +1,51 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +trait T { + fn f(&self) {} +} + +struct S; +impl T for S {} + +struct F(S); + +struct X { + reuse impl T for F { self.0 } + //~^ ERROR expected `:`, found keyword `impl` +} + +impl X { + reuse impl T for F { self.0 } + //~^ ERROR implementation is not supported in `trait`s or `impl`s +} + +trait Trait { + reuse impl T for F { self.0 } + //~^ ERROR implementation is not supported in `trait`s or `impl`s +} + +extern "C" { + reuse impl T for F { self.0 } + //~^ ERROR implementation is not supported in `extern` blocks +} + +mod m { + mod inner { + pub fn foo() {} + } + + reuse inner::{ + reuse impl T for F { self.0 } + //~^ ERROR expected identifier, found keyword `impl` + //~| ERROR expected one of `,`, `as`, or `}`, found keyword `impl` + //~| ERROR expected one of `,`, `as`, or `}`, found `T` + //~| ERROR expected identifier, found keyword `for` + //~| ERROR expected one of `,`, `as`, or `}`, found keyword `for` + //~| ERROR expected one of `,`, `as`, or `}`, found `F` + //~| ERROR expected one of `,`, `as`, or `}`, found `{` + } +} +//~^ ERROR expected item, found `}` + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-illegal-places.stderr b/tests/ui/delegation/impl-reuse-illegal-places.stderr new file mode 100644 index 000000000000..fb17ebdd6cee --- /dev/null +++ b/tests/ui/delegation/impl-reuse-illegal-places.stderr @@ -0,0 +1,92 @@ +error: expected `:`, found keyword `impl` + --> $DIR/impl-reuse-illegal-places.rs:14:11 + | +LL | struct X { + | - while parsing this struct +LL | reuse impl T for F { self.0 } + | ^^^^ expected `:` + +error: implementation is not supported in `trait`s or `impl`s + --> $DIR/impl-reuse-illegal-places.rs:19:5 + | +LL | reuse impl T for F { self.0 } + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider moving the implementation out to a nearby module scope + +error: implementation is not supported in `trait`s or `impl`s + --> $DIR/impl-reuse-illegal-places.rs:24:5 + | +LL | reuse impl T for F { self.0 } + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider moving the implementation out to a nearby module scope + +error: implementation is not supported in `extern` blocks + --> $DIR/impl-reuse-illegal-places.rs:29:5 + | +LL | reuse impl T for F { self.0 } + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider moving the implementation out to a nearby module scope + +error: expected identifier, found keyword `impl` + --> $DIR/impl-reuse-illegal-places.rs:39:15 + | +LL | reuse impl T for F { self.0 } + | ^^^^ expected identifier, found keyword + +error: expected one of `,`, `as`, or `}`, found keyword `impl` + --> $DIR/impl-reuse-illegal-places.rs:39:15 + | +LL | reuse impl T for F { self.0 } + | -^^^^ expected one of `,`, `as`, or `}` + | | + | help: missing `,` + +error: expected one of `,`, `as`, or `}`, found `T` + --> $DIR/impl-reuse-illegal-places.rs:39:20 + | +LL | reuse impl T for F { self.0 } + | -^ expected one of `,`, `as`, or `}` + | | + | help: missing `,` + +error: expected identifier, found keyword `for` + --> $DIR/impl-reuse-illegal-places.rs:39:22 + | +LL | reuse impl T for F { self.0 } + | ^^^ expected identifier, found keyword + +error: expected one of `,`, `as`, or `}`, found keyword `for` + --> $DIR/impl-reuse-illegal-places.rs:39:22 + | +LL | reuse impl T for F { self.0 } + | -^^^ expected one of `,`, `as`, or `}` + | | + | help: missing `,` + +error: expected one of `,`, `as`, or `}`, found `F` + --> $DIR/impl-reuse-illegal-places.rs:39:26 + | +LL | reuse impl T for F { self.0 } + | -^ expected one of `,`, `as`, or `}` + | | + | help: missing `,` + +error: expected one of `,`, `as`, or `}`, found `{` + --> $DIR/impl-reuse-illegal-places.rs:39:28 + | +LL | reuse impl T for F { self.0 } + | ^ expected one of `,`, `as`, or `}` + +error: expected item, found `}` + --> $DIR/impl-reuse-illegal-places.rs:48:1 + | +LL | } + | ^ expected item + | + = note: for a full list of items that can appear in modules, see + +error: aborting due to 12 previous errors + diff --git a/tests/ui/delegation/impl-reuse-negative-traits.rs b/tests/ui/delegation/impl-reuse-negative-traits.rs new file mode 100644 index 000000000000..7bcbc82f03db --- /dev/null +++ b/tests/ui/delegation/impl-reuse-negative-traits.rs @@ -0,0 +1,19 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] +#![feature(negative_impls)] + +trait Trait { + fn foo(&self); + //~^ ERROR negative impls cannot have any items [E0749] +} + +struct S; +impl Trait for S { + fn foo(&self) {} +} + +struct F(S); + +reuse impl !Trait for F { &self.0 } + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-negative-traits.stderr b/tests/ui/delegation/impl-reuse-negative-traits.stderr new file mode 100644 index 000000000000..1be6ef715920 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-negative-traits.stderr @@ -0,0 +1,9 @@ +error[E0749]: negative impls cannot have any items + --> $DIR/impl-reuse-negative-traits.rs:6:8 + | +LL | fn foo(&self); + | ^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0749`. diff --git a/tests/ui/delegation/impl-reuse-non-reuse-items.rs b/tests/ui/delegation/impl-reuse-non-reuse-items.rs new file mode 100644 index 000000000000..de7c92279218 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-non-reuse-items.rs @@ -0,0 +1,32 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +mod non_delegatable_items { + trait Trait { + fn method(&self); + const CONST: u8; + type Type; + #[allow(non_camel_case_types)] + type method; + } + + struct F; + impl Trait for F { + fn method(&self) {} + const CONST: u8 = 0; + type Type = u8; + type method = u8; + } + + struct S(F); + + reuse impl Trait for S { &self.0 } + //~^ ERROR item `CONST` is an associated method, which doesn't match its trait `Trait` + //~| ERROR item `Type` is an associated method, which doesn't match its trait `Trait` + //~| ERROR duplicate definitions with name `method` + //~| ERROR expected function, found associated constant `Trait::CONST` + //~| ERROR expected function, found associated type `Trait::Type` + //~| ERROR not all trait items implemented, missing: `CONST`, `Type`, `method` +} + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-non-reuse-items.stderr b/tests/ui/delegation/impl-reuse-non-reuse-items.stderr new file mode 100644 index 000000000000..9d6b0f638136 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-non-reuse-items.stderr @@ -0,0 +1,60 @@ +error[E0324]: item `CONST` is an associated method, which doesn't match its trait `Trait` + --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + | +LL | const CONST: u8; + | ---------------- item in trait +... +LL | reuse impl Trait for S { &self.0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait + +error[E0324]: item `Type` is an associated method, which doesn't match its trait `Trait` + --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + | +LL | type Type; + | ---------- item in trait +... +LL | reuse impl Trait for S { &self.0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait + +error[E0201]: duplicate definitions with name `method`: + --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + | +LL | fn method(&self); + | ----------------- item in trait +... +LL | reuse impl Trait for S { &self.0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | duplicate definition + | previous definition here + +error[E0423]: expected function, found associated constant `Trait::CONST` + --> $DIR/impl-reuse-non-reuse-items.rs:23:16 + | +LL | reuse impl Trait for S { &self.0 } + | ^^^^^ not a function + +error[E0423]: expected function, found associated type `Trait::Type` + --> $DIR/impl-reuse-non-reuse-items.rs:23:16 + | +LL | reuse impl Trait for S { &self.0 } + | ^^^^^ not a function + +error[E0046]: not all trait items implemented, missing: `CONST`, `Type`, `method` + --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + | +LL | const CONST: u8; + | --------------- `CONST` from trait +LL | type Type; + | --------- `Type` from trait +LL | #[allow(non_camel_case_types)] +LL | type method; + | ----------- `method` from trait +... +LL | reuse impl Trait for S { &self.0 } + | ^^^^^^^^^^^^^^^^^^^^^^ missing `CONST`, `Type`, `method` in implementation + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0046, E0201, E0324, E0423. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs new file mode 100644 index 000000000000..51ef1dc14ba8 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs @@ -0,0 +1,10 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +struct Trait(usize); + +#[cfg(false)] +reuse impl Trait { self.0 } +//~^ ERROR only trait impls can be reused + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr new file mode 100644 index 000000000000..24a138016116 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr @@ -0,0 +1,8 @@ +error: only trait impls can be reused + --> $DIR/impl-reuse-non-trait-impl-cfg-false.rs:7:1 + | +LL | reuse impl Trait { self.0 } + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl.rs b/tests/ui/delegation/impl-reuse-non-trait-impl.rs new file mode 100644 index 000000000000..c7a9813250db --- /dev/null +++ b/tests/ui/delegation/impl-reuse-non-trait-impl.rs @@ -0,0 +1,9 @@ +#![allow(incomplete_features)] +#![feature(fn_delegation)] + +struct Trait(usize); + +reuse impl Trait { self.0 } +//~^ ERROR only trait impls can be reused + +fn main() {} diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl.stderr b/tests/ui/delegation/impl-reuse-non-trait-impl.stderr new file mode 100644 index 000000000000..3987042104c3 --- /dev/null +++ b/tests/ui/delegation/impl-reuse-non-trait-impl.stderr @@ -0,0 +1,8 @@ +error: only trait impls can be reused + --> $DIR/impl-reuse-non-trait-impl.rs:6:1 + | +LL | reuse impl Trait { self.0 } + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/delegation/impl-reuse-pass.rs b/tests/ui/delegation/impl-reuse-pass.rs new file mode 100644 index 000000000000..90060b03f9ef --- /dev/null +++ b/tests/ui/delegation/impl-reuse-pass.rs @@ -0,0 +1,292 @@ +//@ check-pass + +#![allow(incomplete_features)] +#![feature(fn_delegation)] +#![feature(const_trait_impl)] +#![allow(warnings)] + +mod default { + trait T { + fn foo(&self) {} + fn bar(&self) {} + fn goo(&self) {} + } + + struct S; + impl T for S {} + + struct F(S); + reuse impl T for F { self.0 } + + fn f() { + let f = F(S{}); + + f.foo(); + f.bar(); + f.goo(); + } +} + +mod dyn_traits { + trait T { + fn foo(&self) -> Box; + } + + trait SecondTrait { + fn bar(&self); + } + + reuse impl SecondTrait for dyn T { self.foo().as_ref() } +} + +mod complex_path { + pub mod first { + pub mod second { + pub trait T { + fn foo(&self, x: usize); + } + } + } + + struct S; + impl first::second::T for S { + fn foo(&self, x: usize) { } + } + + struct F(S); + reuse impl first::second::T for F { self.0 } + + fn f() { + use complex_path::first::second::T; + + let f = F(S{}); + + f.foo(1); + } +} + +mod no_body_reuse { + trait T { + fn foo(&self) {} + fn bar(&mut self) {} + } + + struct F; + + reuse impl T for F; + + fn foo() { + let mut f = F{}; + + f.foo(); + f.bar(); + } +} + +mod unsafe_trait { + unsafe trait UnsafeTrait { + fn foo(&self) {} + fn bar(&self) {} + fn goo(&self) {} + } + + struct S; + unsafe impl UnsafeTrait for S {} + + struct F(S); + reuse unsafe impl UnsafeTrait for F { self.0 } + + fn f() { + let f = F(S{}); + + f.foo(); + f.bar(); + f.goo(); + } +} + +mod const_trait { + const trait ConstTrait { + fn foo(&self) -> usize { 0 } + fn bar(&self) -> usize { 1 } + } + + struct S; + const impl ConstTrait for S {} + + struct F(S); + reuse const impl ConstTrait for F { self.0 } + + fn f() { + let f = F(S{}); + + f.foo(); + f.bar(); + } +} + +mod different_selves { + trait T: Sized { + fn foo(&self) {} + fn boo(self) {} + fn goo(&mut self) {} + } + + struct S; + impl T for S {} + + struct F(S); + reuse impl T for F { self.0 } + + struct D(S); + macro_rules! self_0 { ($self:ident) => { $self.0 } } + + reuse impl T for D { self_0!(self) } + + fn f() { + let mut f = F(S{}); + f.foo(); + f.goo(); + f.boo(); + + let mut d = D(S{}); + d.foo(); + d.goo(); + d.boo(); + } +} + +mod macros { + trait Trait { + fn foo(&self) -> u8 { 0 } + fn bar(&self) -> u8 { 1 } + } + + impl Trait for u8 {} + struct S(u8); + + macro_rules! self_0_ref { ($self:ident) => { &$self.0 } } + + reuse impl Trait for S { self_0_ref!(self) } + + struct M(u8); + macro_rules! m { () => { M } } + reuse impl Trait for m!() { self_0_ref!(self) } + + struct S1(u8); + macro_rules! one_line_reuse { ($self:ident) => { reuse impl Trait for S1 { $self.0 } } } + one_line_reuse!(self); + + struct S2(u8); + macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { $x } } } + one_line_reuse_expr!(self.0); + + struct S3(u8); + macro_rules! s3 { () => { S3 } } + macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3!() { $x } } } + one_line_reuse_expr2!(self.0); + + fn f() { + let s = S(1); + s.foo(); + s.bar(); + + let m = M(41); + m.foo(); + m.bar(); + + let s1 = S1(2); + s1.foo(); + s1.bar(); + + let s2 = S2(4); + s2.foo(); + s2.bar(); + + let s3 = S3(5); + s3.foo(); + s3.bar(); + } +} + +mod generics { + trait Trait<'a, 'b, A, B, C> { + fn foo(&self, a: &A) {} + fn bar(&self, b: &B) {} + fn goo(&self, c: &C) {} + } + + struct S; + impl<'a, 'b, A, B, C> Trait<'a, 'b, A, B, C> for S {} + + struct F(S); + reuse impl<'a, 'b, A, B, C> Trait<'a, 'b, A, B, C> for F { &self.0 } + + struct S1; + struct F1(S1); + impl<'c, B> Trait<'static, 'c, usize, B, String> for S1 {} + reuse impl<'d, B> Trait<'static, 'd, usize, B, String> for F1 { &self.0 } + + struct S2; + struct F2(S2); + impl Trait<'static, 'static, u8, u16, u32> for S2 {} + reuse impl Trait<'static, 'static, u8, u16, u32> for F2 { &self.0 } + + fn f<'a, 'b, 'c, A, B, C>(a: A, b: B, c: C) { + let f = F(S{}); + + >::foo(&f, &a); + >::bar(&f, &b); + >::goo(&f, &c); + + let f = F1(S1{}); + >::foo(&f, &123); + >::bar(&f, &b); + >::goo(&f, &"s".to_string()); + + let f = F2(S2{}); + >::foo(&f, &1); + >::bar(&f, &2); + >::goo(&f, &3); + } +} + +mod reuse_in_different_places { + trait T { + fn foo(&self, x: usize) {} + } + + struct S; + impl T for S {} + + struct F1(S); + reuse impl T for F1 { + struct F2(S, S, S); + reuse impl T for F2 { self.1 } + + let f2 = F2(S{}, S{}, S{}); + f2.foo(123); + + &self.0 + } + + fn foo() { + struct F(S); + reuse impl T for F { self.0 } + + let f = F(S{}); + f.foo(1); + } + + fn bar() { + || { + struct F(S); + reuse impl T for F { self.0 } + + let f = F(S{}); + f.foo(1); + }; + } +} + +fn main() {} From f289ccf207ede543f23d5998bf5ee6a0b793bdf2 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 22 Dec 2025 23:49:11 -0800 Subject: [PATCH 423/489] `target_features::Stability`: tweak docs of `requires_nightly()` * No method named `allow_toggle()` exists on the type, but based on the documentation of both `requires_nightly()` and `toggle_allowed()` it seems that `toggle_allowed()` is the intended method to mention. * Add `()` to the mention of `in_cfg()` to make it clear that a method is being referred to, and to match the presence of `()` in the mention of `toggle_allowed()`. --- compiler/rustc_target/src/target_features.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 35cfeba2bffd..85c473c5abb2 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -62,8 +62,8 @@ impl Stability { /// the feature gate to actually be enabled when using a nightly compiler.) /// /// Before calling this, ensure the feature is even permitted for this use: - /// - for `#[target_feature]`/`-Ctarget-feature`, check `allow_toggle()` - /// - for `cfg(target_feature)`, check `in_cfg` + /// - for `#[target_feature]`/`-Ctarget-feature`, check `toggle_allowed()` + /// - for `cfg(target_feature)`, check `in_cfg()` pub fn requires_nightly(&self) -> Option { match *self { Stability::Unstable(nightly_feature) => Some(nightly_feature), From 01c23c67be4d11e09d434de31a07c34d962eb980 Mon Sep 17 00:00:00 2001 From: cyrgani Date: Mon, 15 Dec 2025 14:20:35 +0000 Subject: [PATCH 424/489] several `proc_macro` cleanups --- library/proc_macro/src/bridge/symbol.rs | 5 +---- library/proc_macro/src/escape.rs | 3 +-- library/proc_macro/src/lib.rs | 9 +++------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs index 0d6a725fddd9..e070ec07681d 100644 --- a/library/proc_macro/src/bridge/symbol.rs +++ b/library/proc_macro/src/bridge/symbol.rs @@ -77,10 +77,7 @@ impl Symbol { // Mimics the behavior of `Symbol::can_be_raw` from `rustc_span` fn can_be_raw(string: &str) -> bool { - match string { - "_" | "super" | "self" | "Self" | "crate" | "$crate" => false, - _ => true, - } + !matches!(string, "_" | "super" | "self" | "Self" | "crate" | "$crate") } } diff --git a/library/proc_macro/src/escape.rs b/library/proc_macro/src/escape.rs index 87a4d1d50fd4..1f11a6633ff1 100644 --- a/library/proc_macro/src/escape.rs +++ b/library/proc_macro/src/escape.rs @@ -17,8 +17,7 @@ pub(crate) fn escape_bytes(bytes: &[u8], opt: EscapeOptions) -> String { escape_single_byte(byte, opt, &mut repr); } } else { - let mut chunks = bytes.utf8_chunks(); - while let Some(chunk) = chunks.next() { + for chunk in bytes.utf8_chunks() { for ch in chunk.valid().chars() { escape_single_char(ch, opt, &mut repr); } diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index a0b6656c8ded..735986683d11 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -3,7 +3,7 @@ //! This library, provided by the standard distribution, provides the types //! consumed in the interfaces of procedurally defined macro definitions such as //! function-like macros `#[proc_macro]`, macro attributes `#[proc_macro_attribute]` and -//! custom derive attributes`#[proc_macro_derive]`. +//! custom derive attributes `#[proc_macro_derive]`. //! //! See [the book] for more. //! @@ -210,7 +210,6 @@ impl FromStr for TokenStream { /// `TokenTree::Punct`, or `TokenTree::Literal`. #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl fmt::Display for TokenStream { - #[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.0 { Some(ts) => write!(f, "{}", ts.to_string()), @@ -219,7 +218,7 @@ impl fmt::Display for TokenStream { } } -/// Prints token in a form convenient for debugging. +/// Prints tokens in a form convenient for debugging. #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl fmt::Debug for TokenStream { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -571,7 +570,7 @@ impl Span { /// This path should not be embedded in the output of the macro; prefer `file()` instead. #[stable(feature = "proc_macro_span_file", since = "1.88.0")] pub fn local_file(&self) -> Option { - self.0.local_file().map(|s| PathBuf::from(s)) + self.0.local_file().map(PathBuf::from) } /// Creates a new span encompassing `self` and `other`. @@ -750,7 +749,6 @@ impl From for TokenTree { /// `TokenTree::Punct`, or `TokenTree::Literal`. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for TokenTree { - #[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { TokenTree::Group(t) => write!(f, "{t}"), @@ -888,7 +886,6 @@ impl Group { /// with `Delimiter::None` delimiters. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Group { - #[allow(clippy::recursive_format_impl)] // clippy doesn't see the specialization fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", TokenStream::from(TokenTree::from(self.clone()))) } From 82499bac52fe6367b0da4a161d6cc9b6b49d2cc4 Mon Sep 17 00:00:00 2001 From: George Bateman Date: Tue, 23 Dec 2025 10:06:02 +0000 Subject: [PATCH 425/489] Correct terminology in Clone --- library/core/src/clone.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index bf8875098edf..e3d4b5c3331c 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -52,12 +52,12 @@ mod uninit; /// original. /// /// Differs from [`Copy`] in that [`Copy`] is implicit and an inexpensive bit-wise copy, while -/// `Clone` is always explicit and may or may not be expensive. In order to enforce -/// these characteristics, Rust does not allow you to reimplement [`Copy`], but you -/// may reimplement `Clone` and run arbitrary code. +/// `Clone` is always explicit and may or may not be expensive. [`Copy`] has no methods, so you +/// cannot change its behavior, but when implementing `Clone`, the `clone` method you provide +/// may run arbitrary code. /// -/// Since `Clone` is more general than [`Copy`], you can automatically make anything -/// [`Copy`] be `Clone` as well. +/// Since `Clone` is a supertrait of [`Copy`], any type that implements `Copy` must also implement +/// `Clone`. /// /// ## Derivable /// From 7ca2eb9c6f67e694cfc7d762f722c3a510fe59b0 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sat, 20 Dec 2025 23:37:09 +0900 Subject: [PATCH 426/489] moved test --- .../issue-50581.rs => array-slice-vec/array-break-length-2.rs} | 0 .../array-break-length-2.stderr} | 0 .../issue-36400.rs => borrowck/borrow-immutable-deref-box.rs} | 0 .../borrow-immutable-deref-box.stderr} | 0 .../issue-18423.rs => box/box-lifetime-argument-not-allowed.rs} | 0 .../box-lifetime-argument-not-allowed.stderr} | 0 .../cast-rfc0401.rs => cast/cast-rfc0401-fail.rs} | 0 .../cast-rfc0401.stderr => cast/cast-rfc0401-fail.stderr} | 0 tests/ui/{issues/issue-22289.rs => cast/cast-to-dyn-any.rs} | 0 .../ui/{issues/issue-22289.stderr => cast/cast-to-dyn-any.stderr} | 0 .../closure-array-break-length-2.rs} | 0 .../closure-array-break-length-2.stderr} | 0 .../closure-move-use-after-move-diagnostic.rs} | 0 .../closure-move-use-after-move-diagnostic.stderr} | 0 .../{issues/issue-38458.rs => consts/const-return-outside-fn.rs} | 0 .../issue-38458.stderr => consts/const-return-outside-fn.stderr} | 0 .../ui/{issues/issue-28568.rs => drop/drop-conflicting-impls.rs} | 0 .../issue-28568.stderr => drop/drop-conflicting-impls.stderr} | 0 .../issue-23217.rs => enum/enum-discriminant-missing-variant.rs} | 0 .../enum-discriminant-missing-variant.stderr} | 0 .../{issues/issue-21554.rs => mismatched_types/cast-rfc0401-2.rs} | 0 .../issue-21554.stderr => mismatched_types/cast-rfc0401-2.stderr} | 0 .../issue-47184.rs => nll/borrowck-annotate-static-lifetime.rs} | 0 .../borrowck-annotate-static-lifetime.stderr} | 0 tests/ui/{issues/issue-46983.rs => nll/nll-anon-to-static.rs} | 0 .../{issues/issue-46983.stderr => nll/nll-anon-to-static.stderr} | 0 .../issue-45965.rs => parser/missing-operator-after-float.rs} | 0 .../missing-operator-after-float.stderr} | 0 .../{issues/issue-44078.rs => parser/unbalanced-doublequote-2.rs} | 0 .../issue-44078.stderr => parser/unbalanced-doublequote-2.stderr} | 0 .../issue-23173.rs => resolve/missing-associated-items.rs} | 0 .../missing-associated-items.stderr} | 0 tests/ui/{issues/issue-50582.rs => typeck/for-in-const-eval.rs} | 0 .../issue-50582.stderr => typeck/for-in-const-eval.stderr} | 0 34 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-50581.rs => array-slice-vec/array-break-length-2.rs} (100%) rename tests/ui/{issues/issue-50581.stderr => array-slice-vec/array-break-length-2.stderr} (100%) rename tests/ui/{issues/issue-36400.rs => borrowck/borrow-immutable-deref-box.rs} (100%) rename tests/ui/{issues/issue-36400.stderr => borrowck/borrow-immutable-deref-box.stderr} (100%) rename tests/ui/{issues/issue-18423.rs => box/box-lifetime-argument-not-allowed.rs} (100%) rename tests/ui/{issues/issue-18423.stderr => box/box-lifetime-argument-not-allowed.stderr} (100%) rename tests/ui/{mismatched_types/cast-rfc0401.rs => cast/cast-rfc0401-fail.rs} (100%) rename tests/ui/{mismatched_types/cast-rfc0401.stderr => cast/cast-rfc0401-fail.stderr} (100%) rename tests/ui/{issues/issue-22289.rs => cast/cast-to-dyn-any.rs} (100%) rename tests/ui/{issues/issue-22289.stderr => cast/cast-to-dyn-any.stderr} (100%) rename tests/ui/{array-slice-vec/array-break-length.rs => closures/closure-array-break-length-2.rs} (100%) rename tests/ui/{array-slice-vec/array-break-length.stderr => closures/closure-array-break-length-2.stderr} (100%) rename tests/ui/{issues/issue-24357.rs => closures/closure-move-use-after-move-diagnostic.rs} (100%) rename tests/ui/{issues/issue-24357.stderr => closures/closure-move-use-after-move-diagnostic.stderr} (100%) rename tests/ui/{issues/issue-38458.rs => consts/const-return-outside-fn.rs} (100%) rename tests/ui/{issues/issue-38458.stderr => consts/const-return-outside-fn.stderr} (100%) rename tests/ui/{issues/issue-28568.rs => drop/drop-conflicting-impls.rs} (100%) rename tests/ui/{issues/issue-28568.stderr => drop/drop-conflicting-impls.stderr} (100%) rename tests/ui/{issues/issue-23217.rs => enum/enum-discriminant-missing-variant.rs} (100%) rename tests/ui/{issues/issue-23217.stderr => enum/enum-discriminant-missing-variant.stderr} (100%) rename tests/ui/{issues/issue-21554.rs => mismatched_types/cast-rfc0401-2.rs} (100%) rename tests/ui/{issues/issue-21554.stderr => mismatched_types/cast-rfc0401-2.stderr} (100%) rename tests/ui/{issues/issue-47184.rs => nll/borrowck-annotate-static-lifetime.rs} (100%) rename tests/ui/{issues/issue-47184.stderr => nll/borrowck-annotate-static-lifetime.stderr} (100%) rename tests/ui/{issues/issue-46983.rs => nll/nll-anon-to-static.rs} (100%) rename tests/ui/{issues/issue-46983.stderr => nll/nll-anon-to-static.stderr} (100%) rename tests/ui/{issues/issue-45965.rs => parser/missing-operator-after-float.rs} (100%) rename tests/ui/{issues/issue-45965.stderr => parser/missing-operator-after-float.stderr} (100%) rename tests/ui/{issues/issue-44078.rs => parser/unbalanced-doublequote-2.rs} (100%) rename tests/ui/{issues/issue-44078.stderr => parser/unbalanced-doublequote-2.stderr} (100%) rename tests/ui/{issues/issue-23173.rs => resolve/missing-associated-items.rs} (100%) rename tests/ui/{issues/issue-23173.stderr => resolve/missing-associated-items.stderr} (100%) rename tests/ui/{issues/issue-50582.rs => typeck/for-in-const-eval.rs} (100%) rename tests/ui/{issues/issue-50582.stderr => typeck/for-in-const-eval.stderr} (100%) diff --git a/tests/ui/issues/issue-50581.rs b/tests/ui/array-slice-vec/array-break-length-2.rs similarity index 100% rename from tests/ui/issues/issue-50581.rs rename to tests/ui/array-slice-vec/array-break-length-2.rs diff --git a/tests/ui/issues/issue-50581.stderr b/tests/ui/array-slice-vec/array-break-length-2.stderr similarity index 100% rename from tests/ui/issues/issue-50581.stderr rename to tests/ui/array-slice-vec/array-break-length-2.stderr diff --git a/tests/ui/issues/issue-36400.rs b/tests/ui/borrowck/borrow-immutable-deref-box.rs similarity index 100% rename from tests/ui/issues/issue-36400.rs rename to tests/ui/borrowck/borrow-immutable-deref-box.rs diff --git a/tests/ui/issues/issue-36400.stderr b/tests/ui/borrowck/borrow-immutable-deref-box.stderr similarity index 100% rename from tests/ui/issues/issue-36400.stderr rename to tests/ui/borrowck/borrow-immutable-deref-box.stderr diff --git a/tests/ui/issues/issue-18423.rs b/tests/ui/box/box-lifetime-argument-not-allowed.rs similarity index 100% rename from tests/ui/issues/issue-18423.rs rename to tests/ui/box/box-lifetime-argument-not-allowed.rs diff --git a/tests/ui/issues/issue-18423.stderr b/tests/ui/box/box-lifetime-argument-not-allowed.stderr similarity index 100% rename from tests/ui/issues/issue-18423.stderr rename to tests/ui/box/box-lifetime-argument-not-allowed.stderr diff --git a/tests/ui/mismatched_types/cast-rfc0401.rs b/tests/ui/cast/cast-rfc0401-fail.rs similarity index 100% rename from tests/ui/mismatched_types/cast-rfc0401.rs rename to tests/ui/cast/cast-rfc0401-fail.rs diff --git a/tests/ui/mismatched_types/cast-rfc0401.stderr b/tests/ui/cast/cast-rfc0401-fail.stderr similarity index 100% rename from tests/ui/mismatched_types/cast-rfc0401.stderr rename to tests/ui/cast/cast-rfc0401-fail.stderr diff --git a/tests/ui/issues/issue-22289.rs b/tests/ui/cast/cast-to-dyn-any.rs similarity index 100% rename from tests/ui/issues/issue-22289.rs rename to tests/ui/cast/cast-to-dyn-any.rs diff --git a/tests/ui/issues/issue-22289.stderr b/tests/ui/cast/cast-to-dyn-any.stderr similarity index 100% rename from tests/ui/issues/issue-22289.stderr rename to tests/ui/cast/cast-to-dyn-any.stderr diff --git a/tests/ui/array-slice-vec/array-break-length.rs b/tests/ui/closures/closure-array-break-length-2.rs similarity index 100% rename from tests/ui/array-slice-vec/array-break-length.rs rename to tests/ui/closures/closure-array-break-length-2.rs diff --git a/tests/ui/array-slice-vec/array-break-length.stderr b/tests/ui/closures/closure-array-break-length-2.stderr similarity index 100% rename from tests/ui/array-slice-vec/array-break-length.stderr rename to tests/ui/closures/closure-array-break-length-2.stderr diff --git a/tests/ui/issues/issue-24357.rs b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs similarity index 100% rename from tests/ui/issues/issue-24357.rs rename to tests/ui/closures/closure-move-use-after-move-diagnostic.rs diff --git a/tests/ui/issues/issue-24357.stderr b/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr similarity index 100% rename from tests/ui/issues/issue-24357.stderr rename to tests/ui/closures/closure-move-use-after-move-diagnostic.stderr diff --git a/tests/ui/issues/issue-38458.rs b/tests/ui/consts/const-return-outside-fn.rs similarity index 100% rename from tests/ui/issues/issue-38458.rs rename to tests/ui/consts/const-return-outside-fn.rs diff --git a/tests/ui/issues/issue-38458.stderr b/tests/ui/consts/const-return-outside-fn.stderr similarity index 100% rename from tests/ui/issues/issue-38458.stderr rename to tests/ui/consts/const-return-outside-fn.stderr diff --git a/tests/ui/issues/issue-28568.rs b/tests/ui/drop/drop-conflicting-impls.rs similarity index 100% rename from tests/ui/issues/issue-28568.rs rename to tests/ui/drop/drop-conflicting-impls.rs diff --git a/tests/ui/issues/issue-28568.stderr b/tests/ui/drop/drop-conflicting-impls.stderr similarity index 100% rename from tests/ui/issues/issue-28568.stderr rename to tests/ui/drop/drop-conflicting-impls.stderr diff --git a/tests/ui/issues/issue-23217.rs b/tests/ui/enum/enum-discriminant-missing-variant.rs similarity index 100% rename from tests/ui/issues/issue-23217.rs rename to tests/ui/enum/enum-discriminant-missing-variant.rs diff --git a/tests/ui/issues/issue-23217.stderr b/tests/ui/enum/enum-discriminant-missing-variant.stderr similarity index 100% rename from tests/ui/issues/issue-23217.stderr rename to tests/ui/enum/enum-discriminant-missing-variant.stderr diff --git a/tests/ui/issues/issue-21554.rs b/tests/ui/mismatched_types/cast-rfc0401-2.rs similarity index 100% rename from tests/ui/issues/issue-21554.rs rename to tests/ui/mismatched_types/cast-rfc0401-2.rs diff --git a/tests/ui/issues/issue-21554.stderr b/tests/ui/mismatched_types/cast-rfc0401-2.stderr similarity index 100% rename from tests/ui/issues/issue-21554.stderr rename to tests/ui/mismatched_types/cast-rfc0401-2.stderr diff --git a/tests/ui/issues/issue-47184.rs b/tests/ui/nll/borrowck-annotate-static-lifetime.rs similarity index 100% rename from tests/ui/issues/issue-47184.rs rename to tests/ui/nll/borrowck-annotate-static-lifetime.rs diff --git a/tests/ui/issues/issue-47184.stderr b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr similarity index 100% rename from tests/ui/issues/issue-47184.stderr rename to tests/ui/nll/borrowck-annotate-static-lifetime.stderr diff --git a/tests/ui/issues/issue-46983.rs b/tests/ui/nll/nll-anon-to-static.rs similarity index 100% rename from tests/ui/issues/issue-46983.rs rename to tests/ui/nll/nll-anon-to-static.rs diff --git a/tests/ui/issues/issue-46983.stderr b/tests/ui/nll/nll-anon-to-static.stderr similarity index 100% rename from tests/ui/issues/issue-46983.stderr rename to tests/ui/nll/nll-anon-to-static.stderr diff --git a/tests/ui/issues/issue-45965.rs b/tests/ui/parser/missing-operator-after-float.rs similarity index 100% rename from tests/ui/issues/issue-45965.rs rename to tests/ui/parser/missing-operator-after-float.rs diff --git a/tests/ui/issues/issue-45965.stderr b/tests/ui/parser/missing-operator-after-float.stderr similarity index 100% rename from tests/ui/issues/issue-45965.stderr rename to tests/ui/parser/missing-operator-after-float.stderr diff --git a/tests/ui/issues/issue-44078.rs b/tests/ui/parser/unbalanced-doublequote-2.rs similarity index 100% rename from tests/ui/issues/issue-44078.rs rename to tests/ui/parser/unbalanced-doublequote-2.rs diff --git a/tests/ui/issues/issue-44078.stderr b/tests/ui/parser/unbalanced-doublequote-2.stderr similarity index 100% rename from tests/ui/issues/issue-44078.stderr rename to tests/ui/parser/unbalanced-doublequote-2.stderr diff --git a/tests/ui/issues/issue-23173.rs b/tests/ui/resolve/missing-associated-items.rs similarity index 100% rename from tests/ui/issues/issue-23173.rs rename to tests/ui/resolve/missing-associated-items.rs diff --git a/tests/ui/issues/issue-23173.stderr b/tests/ui/resolve/missing-associated-items.stderr similarity index 100% rename from tests/ui/issues/issue-23173.stderr rename to tests/ui/resolve/missing-associated-items.stderr diff --git a/tests/ui/issues/issue-50582.rs b/tests/ui/typeck/for-in-const-eval.rs similarity index 100% rename from tests/ui/issues/issue-50582.rs rename to tests/ui/typeck/for-in-const-eval.rs diff --git a/tests/ui/issues/issue-50582.stderr b/tests/ui/typeck/for-in-const-eval.stderr similarity index 100% rename from tests/ui/issues/issue-50582.stderr rename to tests/ui/typeck/for-in-const-eval.stderr From 4578082361406cdf6836301c127534f1a2317135 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 21 Dec 2025 09:13:49 +0900 Subject: [PATCH 427/489] Cleaned up some tests add comment to closure-move-use-after-move-diagnostic.rs add comment to missing-operator-after-float.rs add comment to closure-array-break-length.rs add comment to box-lifetime-argument-not-allowed.rs add comment to const-return-outside-fn.rs add comment to drop-conflicting-impls.rs add comment to unbalanced-doublequote-2.rs add comment to borrow-immutable-deref-box.rs add comment to for-in-const-eval.rs add comment to borrowck-annotated-static-lifetime.rs cleaned up cast-rfc0401.rs add comment to nll-anon-to-static.rs add comment to cast-to-dyn-any.rs add comment to missing-associated-items.rs add comment to enum-discriminant-missing-variant.rs --- .../array-slice-vec/array-break-length-2.rs | 3 - .../array-break-length-2.stderr | 9 --- .../ui/borrowck/borrow-immutable-deref-box.rs | 1 + .../borrow-immutable-deref-box.stderr | 2 +- .../box/box-lifetime-argument-not-allowed.rs | 7 +- .../box-lifetime-argument-not-allowed.stderr | 4 +- tests/ui/cast/cast-rfc0401-2.rs | 8 -- tests/ui/cast/cast-rfc0401-2.stderr | 15 ---- tests/ui/cast/cast-rfc0401-fail.rs | 29 ++++--- tests/ui/cast/cast-rfc0401-fail.stderr | 76 ++++++++++--------- tests/ui/cast/cast-to-dyn-any.rs | 1 + tests/ui/cast/cast-to-dyn-any.stderr | 2 +- .../closures/closure-array-break-length-2.rs | 9 --- .../closure-array-break-length-2.stderr | 15 ---- .../ui/closures/closure-array-break-length.rs | 11 +++ .../closure-array-break-length.stderr | 26 ++++++- .../closure-move-use-after-move-diagnostic.rs | 21 ++--- ...sure-move-use-after-move-diagnostic.stderr | 25 +++--- tests/ui/consts/const-return-outside-fn.rs | 1 + .../ui/consts/const-return-outside-fn.stderr | 2 +- tests/ui/drop/drop-conflicting-impls.rs | 7 +- tests/ui/drop/drop-conflicting-impls.stderr | 2 +- .../enum/enum-discriminant-missing-variant.rs | 1 + .../enum-discriminant-missing-variant.stderr | 2 +- tests/ui/mismatched_types/cast-rfc0401-2.rs | 6 -- .../ui/mismatched_types/cast-rfc0401-2.stderr | 9 --- .../nll/borrowck-annotate-static-lifetime.rs | 1 + .../borrowck-annotate-static-lifetime.stderr | 2 +- tests/ui/nll/nll-anon-to-static.rs | 1 + tests/ui/nll/nll-anon-to-static.stderr | 2 +- .../ui/parser/missing-operator-after-float.rs | 1 + .../missing-operator-after-float.stderr | 2 +- tests/ui/parser/unbalanced-doublequote-2.rs | 1 + .../ui/parser/unbalanced-doublequote-2.stderr | 2 +- tests/ui/resolve/missing-associated-items.rs | 12 ++- .../resolve/missing-associated-items.stderr | 10 +-- tests/ui/typeck/for-in-const-eval.rs | 1 + tests/ui/typeck/for-in-const-eval.stderr | 2 +- 38 files changed, 160 insertions(+), 171 deletions(-) delete mode 100644 tests/ui/array-slice-vec/array-break-length-2.rs delete mode 100644 tests/ui/array-slice-vec/array-break-length-2.stderr delete mode 100644 tests/ui/cast/cast-rfc0401-2.rs delete mode 100644 tests/ui/cast/cast-rfc0401-2.stderr delete mode 100644 tests/ui/closures/closure-array-break-length-2.rs delete mode 100644 tests/ui/closures/closure-array-break-length-2.stderr delete mode 100644 tests/ui/mismatched_types/cast-rfc0401-2.rs delete mode 100644 tests/ui/mismatched_types/cast-rfc0401-2.stderr diff --git a/tests/ui/array-slice-vec/array-break-length-2.rs b/tests/ui/array-slice-vec/array-break-length-2.rs deleted file mode 100644 index 12bb9930eca4..000000000000 --- a/tests/ui/array-slice-vec/array-break-length-2.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - |_: [u8; break]| (); //~ ERROR [E0268] -} diff --git a/tests/ui/array-slice-vec/array-break-length-2.stderr b/tests/ui/array-slice-vec/array-break-length-2.stderr deleted file mode 100644 index bac1ade3b0c8..000000000000 --- a/tests/ui/array-slice-vec/array-break-length-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0268]: `break` outside of a loop or labeled block - --> $DIR/issue-50581.rs:2:14 - | -LL | |_: [u8; break]| (); - | ^^^^^ cannot `break` outside of a loop or labeled block - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/borrowck/borrow-immutable-deref-box.rs b/tests/ui/borrowck/borrow-immutable-deref-box.rs index a405f9b11352..6d4932b5b4b5 100644 --- a/tests/ui/borrowck/borrow-immutable-deref-box.rs +++ b/tests/ui/borrowck/borrow-immutable-deref-box.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn f(x: &mut u32) {} fn main() { diff --git a/tests/ui/borrowck/borrow-immutable-deref-box.stderr b/tests/ui/borrowck/borrow-immutable-deref-box.stderr index 522fb36e1434..6456dc8a0e5a 100644 --- a/tests/ui/borrowck/borrow-immutable-deref-box.stderr +++ b/tests/ui/borrowck/borrow-immutable-deref-box.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable - --> $DIR/issue-36400.rs:5:7 + --> $DIR/borrow-immutable-deref-box.rs:6:7 | LL | f(&mut *x); | ^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/box/box-lifetime-argument-not-allowed.rs b/tests/ui/box/box-lifetime-argument-not-allowed.rs index 675fd041154b..647fe0917d0a 100644 --- a/tests/ui/box/box-lifetime-argument-not-allowed.rs +++ b/tests/ui/box/box-lifetime-argument-not-allowed.rs @@ -1,8 +1,9 @@ -// Test that `Box` cannot be used with a lifetime argument. +//! Test that `Box` cannot be used with a lifetime argument. +//! regression test for issue struct Foo<'a> { - x: Box<'a, isize> + x: Box<'a, isize>, //~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied } -fn main() { } +fn main() {} diff --git a/tests/ui/box/box-lifetime-argument-not-allowed.stderr b/tests/ui/box/box-lifetime-argument-not-allowed.stderr index b5f19b5c9b23..a597a03023af 100644 --- a/tests/ui/box/box-lifetime-argument-not-allowed.stderr +++ b/tests/ui/box/box-lifetime-argument-not-allowed.stderr @@ -1,7 +1,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/issue-18423.rs:4:8 + --> $DIR/box-lifetime-argument-not-allowed.rs:5:8 | -LL | x: Box<'a, isize> +LL | x: Box<'a, isize>, | ^^^ -- help: remove the lifetime argument | | | expected 0 lifetime arguments diff --git a/tests/ui/cast/cast-rfc0401-2.rs b/tests/ui/cast/cast-rfc0401-2.rs deleted file mode 100644 index 70604a587ea1..000000000000 --- a/tests/ui/cast/cast-rfc0401-2.rs +++ /dev/null @@ -1,8 +0,0 @@ -// RFC 401 test extracted into distinct file. This is because some the -// change to suppress "derived" errors wound up suppressing this error -// message, since the fallback for `3` doesn't occur. - -fn main() { - let _ = 3 as bool; - //~^ ERROR cannot cast `i32` as `bool` -} diff --git a/tests/ui/cast/cast-rfc0401-2.stderr b/tests/ui/cast/cast-rfc0401-2.stderr deleted file mode 100644 index f2956cdfa335..000000000000 --- a/tests/ui/cast/cast-rfc0401-2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0054]: cannot cast `i32` as `bool` - --> $DIR/cast-rfc0401-2.rs:6:13 - | -LL | let _ = 3 as bool; - | ^^^^^^^^^ - | -help: compare with zero instead - | -LL - let _ = 3 as bool; -LL + let _ = 3 != 0; - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0054`. diff --git a/tests/ui/cast/cast-rfc0401-fail.rs b/tests/ui/cast/cast-rfc0401-fail.rs index b2ff5b4a0c06..fb04e3f5f9a0 100644 --- a/tests/ui/cast/cast-rfc0401-fail.rs +++ b/tests/ui/cast/cast-rfc0401-fail.rs @@ -1,29 +1,33 @@ -fn illegal_cast(u: *const U) -> *const V -{ +fn illegal_cast(u: *const U) -> *const V { u as *const V //~ ERROR is invalid } -fn illegal_cast_2(u: *const U) -> *const str -{ +fn illegal_cast_2(u: *const U) -> *const str { u as *const str //~ ERROR is invalid } -trait Foo { fn foo(&self) {} } +trait Foo { + fn foo(&self) {} +} impl Foo for T {} -trait Bar { fn foo(&self) {} } +trait Bar { + fn foo(&self) {} +} impl Bar for T {} enum E { - A, B + A, + B, } -fn main() -{ +struct Inches(i32); + +fn main() { let f: f32 = 1.2; let v = core::ptr::null::(); - let fat_v : *const [u8] = unsafe { &*core::ptr::null::<[u8; 1]>()}; - let fat_sv : *const [i8] = unsafe { &*core::ptr::null::<[i8; 1]>()}; + let fat_v: *const [u8] = unsafe { &*core::ptr::null::<[u8; 1]>() }; + let fat_sv: *const [i8] = unsafe { &*core::ptr::null::<[i8; 1]>() }; let foo: &dyn Foo = &f; let _ = v as &u8; //~ ERROR non-primitive cast @@ -39,6 +43,7 @@ fn main() let _ = 3_i32 as bool; //~ ERROR cannot cast let _ = E::A as bool; //~ ERROR cannot cast let _ = 0x61u32 as char; //~ ERROR can be cast as + let _ = Inches as f32; //~ ERROR is invalid let _ = false as f32; //~ ERROR is invalid let _ = E::A as f32; //~ ERROR is invalid @@ -58,7 +63,7 @@ fn main() let _ = &f as *const f64; //~ ERROR is invalid let _ = fat_sv as usize; //~ ERROR is invalid - let a : *const str = "hello"; + let a: *const str = "hello"; let _ = a as *const dyn Foo; //~ ERROR the size for values of type // check no error cascade diff --git a/tests/ui/cast/cast-rfc0401-fail.stderr b/tests/ui/cast/cast-rfc0401-fail.stderr index a188b7791fdc..c41e6e3612dd 100644 --- a/tests/ui/cast/cast-rfc0401-fail.stderr +++ b/tests/ui/cast/cast-rfc0401-fail.stderr @@ -1,5 +1,5 @@ error[E0606]: casting `*const U` as `*const V` is invalid - --> $DIR/cast-rfc0401.rs:3:5 + --> $DIR/cast-rfc0401-fail.rs:2:5 | LL | u as *const V | ^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | u as *const V = note: the pointers may have different metadata error[E0606]: casting `*const U` as `*const str` is invalid - --> $DIR/cast-rfc0401.rs:8:5 + --> $DIR/cast-rfc0401-fail.rs:6:5 | LL | u as *const str | ^^^^^^^^^^^^^^^ @@ -15,13 +15,13 @@ LL | u as *const str = note: the pointers may have different metadata error[E0609]: no field `f` on type `fn() {main}` - --> $DIR/cast-rfc0401.rs:65:18 + --> $DIR/cast-rfc0401-fail.rs:70:18 | LL | let _ = main.f as *const u32; | ^ unknown field error[E0605]: non-primitive cast: `*const u8` as `&u8` - --> $DIR/cast-rfc0401.rs:29:13 + --> $DIR/cast-rfc0401-fail.rs:33:13 | LL | let _ = v as &u8; | ^^^^^^^^ invalid cast @@ -33,43 +33,43 @@ LL + let _ = &*v; | error[E0605]: non-primitive cast: `*const u8` as `E` - --> $DIR/cast-rfc0401.rs:30:13 + --> $DIR/cast-rfc0401-fail.rs:34:13 | LL | let _ = v as E; | ^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0605]: non-primitive cast: `*const u8` as `fn()` - --> $DIR/cast-rfc0401.rs:31:13 + --> $DIR/cast-rfc0401-fail.rs:35:13 | LL | let _ = v as fn(); | ^^^^^^^^^ invalid cast error[E0605]: non-primitive cast: `*const u8` as `(u32,)` - --> $DIR/cast-rfc0401.rs:32:13 + --> $DIR/cast-rfc0401-fail.rs:36:13 | LL | let _ = v as (u32,); | ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0605]: non-primitive cast: `Option<&*const u8>` as `*const u8` - --> $DIR/cast-rfc0401.rs:33:13 + --> $DIR/cast-rfc0401-fail.rs:37:13 | LL | let _ = Some(&v) as *const u8; | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0606]: casting `*const u8` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:35:13 + --> $DIR/cast-rfc0401-fail.rs:39:13 | LL | let _ = v as f32; | ^^^^^^^^ error[E0606]: casting `fn() {main}` as `f64` is invalid - --> $DIR/cast-rfc0401.rs:36:13 + --> $DIR/cast-rfc0401-fail.rs:40:13 | LL | let _ = main as f64; | ^^^^^^^^^^^ error[E0606]: casting `&*const u8` as `usize` is invalid - --> $DIR/cast-rfc0401.rs:37:13 + --> $DIR/cast-rfc0401-fail.rs:41:13 | LL | let _ = &v as usize; | ^^^^^^^^^^^ @@ -77,13 +77,13 @@ LL | let _ = &v as usize; = help: cast through a raw pointer first error[E0606]: casting `f32` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:38:13 + --> $DIR/cast-rfc0401-fail.rs:42:13 | LL | let _ = f as *const u8; | ^^^^^^^^^^^^^^ error[E0054]: cannot cast `i32` as `bool` - --> $DIR/cast-rfc0401.rs:39:13 + --> $DIR/cast-rfc0401-fail.rs:43:13 | LL | let _ = 3_i32 as bool; | ^^^^^^^^^^^^^ @@ -95,13 +95,13 @@ LL + let _ = 3_i32 != 0; | error[E0054]: cannot cast `E` as `bool` - --> $DIR/cast-rfc0401.rs:40:13 + --> $DIR/cast-rfc0401-fail.rs:44:13 | LL | let _ = E::A as bool; | ^^^^^^^^^^^^ unsupported cast error[E0604]: only `u8` can be cast as `char`, not `u32` - --> $DIR/cast-rfc0401.rs:41:13 + --> $DIR/cast-rfc0401-fail.rs:45:13 | LL | let _ = 0x61u32 as char; | ^^^^^^^^^^^^^^^ invalid cast @@ -112,8 +112,14 @@ LL - let _ = 0x61u32 as char; LL + let _ = char::from_u32(0x61u32); | +error[E0606]: casting `fn(i32) -> Inches {Inches}` as `f32` is invalid + --> $DIR/cast-rfc0401-fail.rs:46:13 + | +LL | let _ = Inches as f32; + | ^^^^^^^^^^^^^ + error[E0606]: casting `bool` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:43:13 + --> $DIR/cast-rfc0401-fail.rs:48:13 | LL | let _ = false as f32; | ^^^^^^^^^^^^ @@ -121,7 +127,7 @@ LL | let _ = false as f32; = help: cast through an integer first error[E0606]: casting `E` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:44:13 + --> $DIR/cast-rfc0401-fail.rs:49:13 | LL | let _ = E::A as f32; | ^^^^^^^^^^^ @@ -129,7 +135,7 @@ LL | let _ = E::A as f32; = help: cast through an integer first error[E0606]: casting `char` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:45:13 + --> $DIR/cast-rfc0401-fail.rs:50:13 | LL | let _ = 'a' as f32; | ^^^^^^^^^^ @@ -137,25 +143,25 @@ LL | let _ = 'a' as f32; = help: cast through an integer first error[E0606]: casting `bool` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:47:13 + --> $DIR/cast-rfc0401-fail.rs:52:13 | LL | let _ = false as *const u8; | ^^^^^^^^^^^^^^^^^^ error[E0606]: casting `E` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:48:13 + --> $DIR/cast-rfc0401-fail.rs:53:13 | LL | let _ = E::A as *const u8; | ^^^^^^^^^^^^^^^^^ error[E0606]: casting `char` as `*const u8` is invalid - --> $DIR/cast-rfc0401.rs:49:13 + --> $DIR/cast-rfc0401-fail.rs:54:13 | LL | let _ = 'a' as *const u8; | ^^^^^^^^^^^^^^^^ error[E0606]: cannot cast `usize` to a pointer that is wide - --> $DIR/cast-rfc0401.rs:51:24 + --> $DIR/cast-rfc0401-fail.rs:56:24 | LL | let _ = 42usize as *const [u8]; | ------- ^^^^^^^^^^^ creating a `*const [u8]` requires both an address and a length @@ -163,43 +169,43 @@ LL | let _ = 42usize as *const [u8]; | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts` error[E0607]: cannot cast thin pointer `*const u8` to wide pointer `*const [u8]` - --> $DIR/cast-rfc0401.rs:52:13 + --> $DIR/cast-rfc0401-fail.rs:57:13 | LL | let _ = v as *const [u8]; | ^^^^^^^^^^^^^^^^ error[E0606]: casting `&dyn Foo` as `*const str` is invalid - --> $DIR/cast-rfc0401.rs:54:13 + --> $DIR/cast-rfc0401-fail.rs:59:13 | LL | let _ = foo as *const str; | ^^^^^^^^^^^^^^^^^ error[E0606]: casting `&dyn Foo` as `*mut str` is invalid - --> $DIR/cast-rfc0401.rs:55:13 + --> $DIR/cast-rfc0401-fail.rs:60:13 | LL | let _ = foo as *mut str; | ^^^^^^^^^^^^^^^ error[E0606]: casting `fn() {main}` as `*mut str` is invalid - --> $DIR/cast-rfc0401.rs:56:13 + --> $DIR/cast-rfc0401-fail.rs:61:13 | LL | let _ = main as *mut str; | ^^^^^^^^^^^^^^^^ error[E0606]: casting `&f32` as `*mut f32` is invalid - --> $DIR/cast-rfc0401.rs:57:13 + --> $DIR/cast-rfc0401-fail.rs:62:13 | LL | let _ = &f as *mut f32; | ^^^^^^^^^^^^^^ error[E0606]: casting `&f32` as `*const f64` is invalid - --> $DIR/cast-rfc0401.rs:58:13 + --> $DIR/cast-rfc0401-fail.rs:63:13 | LL | let _ = &f as *const f64; | ^^^^^^^^^^^^^^^^ error[E0606]: casting `*const [i8]` as `usize` is invalid - --> $DIR/cast-rfc0401.rs:59:13 + --> $DIR/cast-rfc0401-fail.rs:64:13 | LL | let _ = fat_sv as usize; | ^^^^^^^^^^^^^^^ @@ -207,7 +213,7 @@ LL | let _ = fat_sv as usize; = help: cast through a thin pointer first error[E0606]: casting `*const dyn Foo` as `*const [u16]` is invalid - --> $DIR/cast-rfc0401.rs:68:13 + --> $DIR/cast-rfc0401-fail.rs:73:13 | LL | let _ = cf as *const [u16]; | ^^^^^^^^^^^^^^^^^^ @@ -215,7 +221,7 @@ LL | let _ = cf as *const [u16]; = note: the pointers have different metadata error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid - --> $DIR/cast-rfc0401.rs:69:13 + --> $DIR/cast-rfc0401-fail.rs:74:13 | LL | let _ = cf as *const dyn Bar; | ^^^^^^^^^^^^^^^^^^^^ @@ -223,7 +229,7 @@ LL | let _ = cf as *const dyn Bar; = note: the trait objects may have different vtables error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/cast-rfc0401.rs:53:13 + --> $DIR/cast-rfc0401-fail.rs:58:13 | LL | let _ = fat_v as *const dyn Foo; | ^^^^^ doesn't have a size known at compile-time @@ -232,7 +238,7 @@ LL | let _ = fat_v as *const dyn Foo; = note: required for the cast from `*const [u8]` to `*const dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/cast-rfc0401.rs:62:13 + --> $DIR/cast-rfc0401-fail.rs:67:13 | LL | let _ = a as *const dyn Foo; | ^ doesn't have a size known at compile-time @@ -241,7 +247,7 @@ LL | let _ = a as *const dyn Foo; = note: required for the cast from `*const str` to `*const dyn Foo` error[E0606]: casting `&{float}` as `f32` is invalid - --> $DIR/cast-rfc0401.rs:71:30 + --> $DIR/cast-rfc0401-fail.rs:76:30 | LL | vec![0.0].iter().map(|s| s as f32).collect::>(); | ^^^^^^^^ @@ -251,7 +257,7 @@ help: dereference the expression LL | vec![0.0].iter().map(|s| *s as f32).collect::>(); | + -error: aborting due to 34 previous errors +error: aborting due to 35 previous errors Some errors have detailed explanations: E0054, E0277, E0604, E0605, E0606, E0607, E0609. For more information about an error, try `rustc --explain E0054`. diff --git a/tests/ui/cast/cast-to-dyn-any.rs b/tests/ui/cast/cast-to-dyn-any.rs index e1b3dfe5b61b..3180c530209e 100644 --- a/tests/ui/cast/cast-to-dyn-any.rs +++ b/tests/ui/cast/cast-to-dyn-any.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { 0 as &dyn std::any::Any; //~ ERROR non-primitive cast } diff --git a/tests/ui/cast/cast-to-dyn-any.stderr b/tests/ui/cast/cast-to-dyn-any.stderr index 560fbc73bbdc..6ee1098fcf40 100644 --- a/tests/ui/cast/cast-to-dyn-any.stderr +++ b/tests/ui/cast/cast-to-dyn-any.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `i32` as `&(dyn Any + 'static)` - --> $DIR/issue-22289.rs:2:5 + --> $DIR/cast-to-dyn-any.rs:3:5 | LL | 0 as &dyn std::any::Any; | ^^^^^^^^^^^^^^^^^^^^^^^ invalid cast diff --git a/tests/ui/closures/closure-array-break-length-2.rs b/tests/ui/closures/closure-array-break-length-2.rs deleted file mode 100644 index 60589f7c264a..000000000000 --- a/tests/ui/closures/closure-array-break-length-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - loop { - |_: [_; break]| {} //~ ERROR: `break` outside of a loop - } - - loop { - |_: [_; continue]| {} //~ ERROR: `continue` outside of a loop - } -} diff --git a/tests/ui/closures/closure-array-break-length-2.stderr b/tests/ui/closures/closure-array-break-length-2.stderr deleted file mode 100644 index 2df7b6d7f63c..000000000000 --- a/tests/ui/closures/closure-array-break-length-2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0268]: `break` outside of a loop or labeled block - --> $DIR/array-break-length.rs:3:17 - | -LL | |_: [_; break]| {} - | ^^^^^ cannot `break` outside of a loop or labeled block - -error[E0268]: `continue` outside of a loop - --> $DIR/array-break-length.rs:7:17 - | -LL | |_: [_; continue]| {} - | ^^^^^^^^ cannot `continue` outside of a loop - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/closures/closure-array-break-length.rs b/tests/ui/closures/closure-array-break-length.rs index fda590fda022..c90ae6585dca 100644 --- a/tests/ui/closures/closure-array-break-length.rs +++ b/tests/ui/closures/closure-array-break-length.rs @@ -1,7 +1,18 @@ +//! regression test for issue fn main() { |_: [_; continue]| {}; //~ ERROR: `continue` outside of a loop + |_: [_; break]| (); //~ ERROR: `break` outside of a loop or labeled block + while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of a loop while |_: [_; break]| {} {} //~ ERROR: `break` outside of a loop + + loop { + |_: [_; break]| {} //~ ERROR: `break` outside of a loop + } + + loop { + |_: [_; continue]| {} //~ ERROR: `continue` outside of a loop + } } diff --git a/tests/ui/closures/closure-array-break-length.stderr b/tests/ui/closures/closure-array-break-length.stderr index 7e0b0027a6f0..3256c50bb906 100644 --- a/tests/ui/closures/closure-array-break-length.stderr +++ b/tests/ui/closures/closure-array-break-length.stderr @@ -1,21 +1,39 @@ error[E0268]: `continue` outside of a loop - --> $DIR/closure-array-break-length.rs:2:13 + --> $DIR/closure-array-break-length.rs:3:13 | LL | |_: [_; continue]| {}; | ^^^^^^^^ cannot `continue` outside of a loop +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/closure-array-break-length.rs:5:13 + | +LL | |_: [_; break]| (); + | ^^^^^ cannot `break` outside of a loop or labeled block + error[E0268]: `continue` outside of a loop - --> $DIR/closure-array-break-length.rs:4:19 + --> $DIR/closure-array-break-length.rs:7:19 | LL | while |_: [_; continue]| {} {} | ^^^^^^^^ cannot `continue` outside of a loop error[E0268]: `break` outside of a loop or labeled block - --> $DIR/closure-array-break-length.rs:6:19 + --> $DIR/closure-array-break-length.rs:9:19 | LL | while |_: [_; break]| {} {} | ^^^^^ cannot `break` outside of a loop or labeled block -error: aborting due to 3 previous errors +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/closure-array-break-length.rs:12:17 + | +LL | |_: [_; break]| {} + | ^^^^^ cannot `break` outside of a loop or labeled block + +error[E0268]: `continue` outside of a loop + --> $DIR/closure-array-break-length.rs:16:17 + | +LL | |_: [_; continue]| {} + | ^^^^^^^^ cannot `continue` outside of a loop + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/closures/closure-move-use-after-move-diagnostic.rs b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs index 63c061594d87..3326af7486c5 100644 --- a/tests/ui/closures/closure-move-use-after-move-diagnostic.rs +++ b/tests/ui/closures/closure-move-use-after-move-diagnostic.rs @@ -1,13 +1,16 @@ +//! regression test for struct NoCopy; //~ NOTE if `NoCopy` implemented `Clone`, you could clone the value //~^ NOTE consider implementing `Clone` for this type fn main() { - let x = NoCopy; - //~^ NOTE move occurs because `x` has type `NoCopy` - let f = move || { let y = x; }; - //~^ NOTE value moved into closure here - //~| NOTE variable moved due to use in closure - //~| NOTE you could clone this value - let z = x; - //~^ ERROR use of moved value: `x` - //~| NOTE value used here after move + let x = NoCopy; + //~^ NOTE move occurs because `x` has type `NoCopy` + let f = move || { + //~^ NOTE value moved into closure here + let y = x; + //~^ NOTE variable moved due to use in closure + //~| NOTE you could clone this value + }; + let z = x; + //~^ ERROR use of moved value: `x` + //~| NOTE value used here after move } diff --git a/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr b/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr index 2d85077fe4c2..94f80da1b10a 100644 --- a/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr +++ b/tests/ui/closures/closure-move-use-after-move-diagnostic.stderr @@ -1,25 +1,26 @@ error[E0382]: use of moved value: `x` - --> $DIR/issue-24357.rs:10:12 + --> $DIR/closure-move-use-after-move-diagnostic.rs:13:13 | -LL | let x = NoCopy; - | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait +LL | let x = NoCopy; + | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait LL | -LL | let f = move || { let y = x; }; - | ------- - variable moved due to use in closure - | | - | value moved into closure here +LL | let f = move || { + | ------- value moved into closure here +LL | +LL | let y = x; + | - variable moved due to use in closure ... -LL | let z = x; - | ^ value used here after move +LL | let z = x; + | ^ value used here after move | note: if `NoCopy` implemented `Clone`, you could clone the value - --> $DIR/issue-24357.rs:1:1 + --> $DIR/closure-move-use-after-move-diagnostic.rs:2:1 | LL | struct NoCopy; | ^^^^^^^^^^^^^ consider implementing `Clone` for this type ... -LL | let f = move || { let y = x; }; - | - you could clone this value +LL | let y = x; + | - you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-return-outside-fn.rs b/tests/ui/consts/const-return-outside-fn.rs index 665a8fdf8e26..c2ee8642bf4b 100644 --- a/tests/ui/consts/const-return-outside-fn.rs +++ b/tests/ui/consts/const-return-outside-fn.rs @@ -1,3 +1,4 @@ +//! regression test for issue const x: () = { return; //~ ERROR return statement outside of function body }; diff --git a/tests/ui/consts/const-return-outside-fn.stderr b/tests/ui/consts/const-return-outside-fn.stderr index fbf88d503397..131d577a2547 100644 --- a/tests/ui/consts/const-return-outside-fn.stderr +++ b/tests/ui/consts/const-return-outside-fn.stderr @@ -1,5 +1,5 @@ error[E0572]: return statement outside of function body - --> $DIR/issue-38458.rs:2:5 + --> $DIR/const-return-outside-fn.rs:3:5 | LL | return; | ^^^^^^ diff --git a/tests/ui/drop/drop-conflicting-impls.rs b/tests/ui/drop/drop-conflicting-impls.rs index ce511158f005..fba3462a24b2 100644 --- a/tests/ui/drop/drop-conflicting-impls.rs +++ b/tests/ui/drop/drop-conflicting-impls.rs @@ -1,12 +1,13 @@ +//! regression test for issue struct MyStruct; impl Drop for MyStruct { - fn drop(&mut self) { } + fn drop(&mut self) {} } impl Drop for MyStruct { -//~^ ERROR conflicting implementations of trait - fn drop(&mut self) { } + //~^ ERROR conflicting implementations of trait + fn drop(&mut self) {} } fn main() {} diff --git a/tests/ui/drop/drop-conflicting-impls.stderr b/tests/ui/drop/drop-conflicting-impls.stderr index c8db0403e59a..ee310f498d37 100644 --- a/tests/ui/drop/drop-conflicting-impls.stderr +++ b/tests/ui/drop/drop-conflicting-impls.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Drop` for type `MyStruct` - --> $DIR/issue-28568.rs:7:1 + --> $DIR/drop-conflicting-impls.rs:8:1 | LL | impl Drop for MyStruct { | ---------------------- first implementation here diff --git a/tests/ui/enum/enum-discriminant-missing-variant.rs b/tests/ui/enum/enum-discriminant-missing-variant.rs index 09f9ebccf250..1bdbfb1fbcd4 100644 --- a/tests/ui/enum/enum-discriminant-missing-variant.rs +++ b/tests/ui/enum/enum-discriminant-missing-variant.rs @@ -1,3 +1,4 @@ +//! regression test for issue pub enum SomeEnum { B = SomeEnum::A, //~ ERROR no variant or associated item named `A` found } diff --git a/tests/ui/enum/enum-discriminant-missing-variant.stderr b/tests/ui/enum/enum-discriminant-missing-variant.stderr index 830d260f99d7..ef98a93e86f6 100644 --- a/tests/ui/enum/enum-discriminant-missing-variant.stderr +++ b/tests/ui/enum/enum-discriminant-missing-variant.stderr @@ -1,5 +1,5 @@ error[E0599]: no variant or associated item named `A` found for enum `SomeEnum` in the current scope - --> $DIR/issue-23217.rs:2:19 + --> $DIR/enum-discriminant-missing-variant.rs:3:19 | LL | pub enum SomeEnum { | ----------------- variant or associated item `A` not found for this enum diff --git a/tests/ui/mismatched_types/cast-rfc0401-2.rs b/tests/ui/mismatched_types/cast-rfc0401-2.rs deleted file mode 100644 index c176b1247cea..000000000000 --- a/tests/ui/mismatched_types/cast-rfc0401-2.rs +++ /dev/null @@ -1,6 +0,0 @@ -struct Inches(i32); - -fn main() { - Inches as f32; - //~^ ERROR casting -} diff --git a/tests/ui/mismatched_types/cast-rfc0401-2.stderr b/tests/ui/mismatched_types/cast-rfc0401-2.stderr deleted file mode 100644 index b1b59af6ec2b..000000000000 --- a/tests/ui/mismatched_types/cast-rfc0401-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0606]: casting `fn(i32) -> Inches {Inches}` as `f32` is invalid - --> $DIR/issue-21554.rs:4:5 - | -LL | Inches as f32; - | ^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0606`. diff --git a/tests/ui/nll/borrowck-annotate-static-lifetime.rs b/tests/ui/nll/borrowck-annotate-static-lifetime.rs index 2f78ce0002ba..9d849db9b4f3 100644 --- a/tests/ui/nll/borrowck-annotate-static-lifetime.rs +++ b/tests/ui/nll/borrowck-annotate-static-lifetime.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { let _vec: Vec<&'static String> = vec![&String::new()]; //~^ ERROR temporary value dropped while borrowed [E0716] diff --git a/tests/ui/nll/borrowck-annotate-static-lifetime.stderr b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr index d25c6eda9c34..9cb9007d9131 100644 --- a/tests/ui/nll/borrowck-annotate-static-lifetime.stderr +++ b/tests/ui/nll/borrowck-annotate-static-lifetime.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-47184.rs:2:44 + --> $DIR/borrowck-annotate-static-lifetime.rs:3:44 | LL | let _vec: Vec<&'static String> = vec![&String::new()]; | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement diff --git a/tests/ui/nll/nll-anon-to-static.rs b/tests/ui/nll/nll-anon-to-static.rs index 4bd49a8796b3..3dc79950056c 100644 --- a/tests/ui/nll/nll-anon-to-static.rs +++ b/tests/ui/nll/nll-anon-to-static.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn foo(x: &u32) -> &'static u32 { &*x //~^ ERROR lifetime may not live long enough diff --git a/tests/ui/nll/nll-anon-to-static.stderr b/tests/ui/nll/nll-anon-to-static.stderr index f47df306ab84..e431dfd992e1 100644 --- a/tests/ui/nll/nll-anon-to-static.stderr +++ b/tests/ui/nll/nll-anon-to-static.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-46983.rs:2:5 + --> $DIR/nll-anon-to-static.rs:3:5 | LL | fn foo(x: &u32) -> &'static u32 { | - let's call the lifetime of this reference `'1` diff --git a/tests/ui/parser/missing-operator-after-float.rs b/tests/ui/parser/missing-operator-after-float.rs index 15649f777e09..8868689ff81f 100644 --- a/tests/ui/parser/missing-operator-after-float.rs +++ b/tests/ui/parser/missing-operator-after-float.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 }; //~^ ERROR expected function, found `{float}` diff --git a/tests/ui/parser/missing-operator-after-float.stderr b/tests/ui/parser/missing-operator-after-float.stderr index 95a39b1d1980..08878cf098a7 100644 --- a/tests/ui/parser/missing-operator-after-float.stderr +++ b/tests/ui/parser/missing-operator-after-float.stderr @@ -1,5 +1,5 @@ error[E0618]: expected function, found `{float}` - --> $DIR/issue-45965.rs:2:30 + --> $DIR/missing-operator-after-float.rs:3:30 | LL | let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 }; | ^^^---------- diff --git a/tests/ui/parser/unbalanced-doublequote-2.rs b/tests/ui/parser/unbalanced-doublequote-2.rs index b8c0e285ffca..1906f96f6c9b 100644 --- a/tests/ui/parser/unbalanced-doublequote-2.rs +++ b/tests/ui/parser/unbalanced-doublequote-2.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { "😊""; //~ ERROR unterminated double quote } diff --git a/tests/ui/parser/unbalanced-doublequote-2.stderr b/tests/ui/parser/unbalanced-doublequote-2.stderr index 3e12de34e11e..3a6efaf7d4ec 100644 --- a/tests/ui/parser/unbalanced-doublequote-2.stderr +++ b/tests/ui/parser/unbalanced-doublequote-2.stderr @@ -1,5 +1,5 @@ error[E0765]: unterminated double quote string - --> $DIR/issue-44078.rs:2:8 + --> $DIR/unbalanced-doublequote-2.rs:3:8 | LL | "😊""; | _________^ diff --git a/tests/ui/resolve/missing-associated-items.rs b/tests/ui/resolve/missing-associated-items.rs index 92f4c546440a..72d6cbb3f149 100644 --- a/tests/ui/resolve/missing-associated-items.rs +++ b/tests/ui/resolve/missing-associated-items.rs @@ -1,9 +1,17 @@ -enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ } +//! regression test for issue +enum Token { + LeftParen, + RightParen, + Plus, + Minus, /* etc */ +} struct Struct { a: usize, } -fn use_token(token: &Token) { unimplemented!() } +fn use_token(token: &Token) { + unimplemented!() +} fn main() { use_token(&Token::Homura); //~ ERROR no variant or associated item named `Homura` diff --git a/tests/ui/resolve/missing-associated-items.stderr b/tests/ui/resolve/missing-associated-items.stderr index d07d1a7caaf2..d27a3a644aee 100644 --- a/tests/ui/resolve/missing-associated-items.stderr +++ b/tests/ui/resolve/missing-associated-items.stderr @@ -1,14 +1,14 @@ error[E0599]: no variant or associated item named `Homura` found for enum `Token` in the current scope - --> $DIR/issue-23173.rs:9:23 + --> $DIR/missing-associated-items.rs:17:23 | -LL | enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ } +LL | enum Token { | ---------- variant or associated item `Homura` not found for this enum ... LL | use_token(&Token::Homura); | ^^^^^^ variant or associated item not found in `Token` error[E0599]: no function or associated item named `method` found for struct `Struct` in the current scope - --> $DIR/issue-23173.rs:10:13 + --> $DIR/missing-associated-items.rs:18:13 | LL | struct Struct { | ------------- function or associated item `method` not found for this struct @@ -17,7 +17,7 @@ LL | Struct::method(); | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no function or associated item named `method` found for struct `Struct` in the current scope - --> $DIR/issue-23173.rs:11:13 + --> $DIR/missing-associated-items.rs:19:13 | LL | struct Struct { | ------------- function or associated item `method` not found for this struct @@ -26,7 +26,7 @@ LL | Struct::method; | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no associated item named `Assoc` found for struct `Struct` in the current scope - --> $DIR/issue-23173.rs:12:13 + --> $DIR/missing-associated-items.rs:20:13 | LL | struct Struct { | ------------- associated item `Assoc` not found for this struct diff --git a/tests/ui/typeck/for-in-const-eval.rs b/tests/ui/typeck/for-in-const-eval.rs index 1358e0bde4c8..f187a9ef3077 100644 --- a/tests/ui/typeck/for-in-const-eval.rs +++ b/tests/ui/typeck/for-in-const-eval.rs @@ -1,3 +1,4 @@ +//! regression test for issue fn main() { Vec::<[(); 1 + for x in 0..1 {}]>::new(); //~^ ERROR cannot add diff --git a/tests/ui/typeck/for-in-const-eval.stderr b/tests/ui/typeck/for-in-const-eval.stderr index 168f5894fb03..e7a255849581 100644 --- a/tests/ui/typeck/for-in-const-eval.stderr +++ b/tests/ui/typeck/for-in-const-eval.stderr @@ -1,5 +1,5 @@ error[E0277]: cannot add `()` to `{integer}` - --> $DIR/issue-50582.rs:2:18 + --> $DIR/for-in-const-eval.rs:3:18 | LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` From ac448c987d2ed4b8ef50bb2f5422c093c1e161a5 Mon Sep 17 00:00:00 2001 From: delta17920 Date: Tue, 9 Dec 2025 09:36:58 +0000 Subject: [PATCH 428/489] Fix ICE in normalization during closure capture analysis --- compiler/rustc_middle/src/ty/util.rs | 6 +- .../normalization-ice-issue-149746.rs | 17 ++++ .../normalization-ice-issue-149746.stderr | 80 +++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 tests/ui/associated-types/normalization-ice-issue-149746.rs create mode 100644 tests/ui/associated-types/normalization-ice-issue-149746.stderr diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index fc03ad52b4bf..2797f2fcdb72 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1394,8 +1394,10 @@ impl<'tcx> Ty<'tcx> { // This doesn't depend on regions, so try to minimize distinct // query keys used. - let erased = tcx.normalize_erasing_regions(typing_env, query_ty); - tcx.has_significant_drop_raw(typing_env.as_query_input(erased)) + // FIX: Use try_normalize to avoid crashing. If it fails, return true. + tcx.try_normalize_erasing_regions(typing_env, query_ty) + .map(|erased| tcx.has_significant_drop_raw(typing_env.as_query_input(erased))) + .unwrap_or(true) } } } diff --git a/tests/ui/associated-types/normalization-ice-issue-149746.rs b/tests/ui/associated-types/normalization-ice-issue-149746.rs new file mode 100644 index 000000000000..8932d321b7e5 --- /dev/null +++ b/tests/ui/associated-types/normalization-ice-issue-149746.rs @@ -0,0 +1,17 @@ +//@ edition: 2015..2021 +#![warn(rust_2021_incompatible_closure_captures)] +trait Owner { type Ty; } +impl Owner for () { type Ty = T; } +pub struct Warns { + _significant_drop: <() as Owner>::Ty, + //~^ ERROR expected a `FnMut()` closure, found `T` + field: String, +} +pub fn test(w: Warns) { + //~^ ERROR expected a `FnMut()` closure, found `T` + _ = || w.field + //~^ ERROR expected a `FnMut()` closure, found `T` + //~| ERROR expected a `FnMut()` closure, found `T` + //~| WARN: changes to closure capture in Rust 2021 will affect drop order +} +fn main() {} diff --git a/tests/ui/associated-types/normalization-ice-issue-149746.stderr b/tests/ui/associated-types/normalization-ice-issue-149746.stderr new file mode 100644 index 000000000000..7f983d6e14ae --- /dev/null +++ b/tests/ui/associated-types/normalization-ice-issue-149746.stderr @@ -0,0 +1,80 @@ +error[E0277]: expected a `FnMut()` closure, found `T` + --> $DIR/normalization-ice-issue-149746.rs:6:24 + | +LL | _significant_drop: <() as Owner>::Ty, + | ^^^^^^^^^^^^^^^^^^^^ expected an `FnMut()` closure, found `T` + | + = note: wrap the `T` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `Owner::Ty` + --> $DIR/normalization-ice-issue-149746.rs:3:26 + | +LL | trait Owner { type Ty; } + | ^^^^^^^ required by this bound in `Owner::Ty` +help: consider restricting type parameter `T` with trait `FnMut` + | +LL | pub struct Warns { + | +++++++++ + +warning: changes to closure capture in Rust 2021 will affect drop order + --> $DIR/normalization-ice-issue-149746.rs:12:9 + | +LL | _ = || w.field + | ^^ ------- + | | | + | | in Rust 2018, `w` is dropped here, but in Rust 2021, only `w.field` will be dropped here as part of the closure + | in Rust 2018, this closure captures all of `w`, but in Rust 2021, it will only capture `w.field` + | + = note: for more information, see +note: the lint level is defined here + --> $DIR/normalization-ice-issue-149746.rs:2:9 + | +LL | #![warn(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: add a dummy let to cause `w` to be fully captured + | +LL | _ = || { let _ = &w; w.field } + | +++++++++++++ + + +error[E0277]: expected a `FnMut()` closure, found `T` + --> $DIR/normalization-ice-issue-149746.rs:12:9 + | +LL | _ = || w.field + | ^^^^^^^^^^ expected an `FnMut()` closure, found `T` + | + = note: wrap the `T` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `Owner::Ty` + --> $DIR/normalization-ice-issue-149746.rs:3:26 + | +LL | trait Owner { type Ty; } + | ^^^^^^^ required by this bound in `Owner::Ty` + +error[E0277]: expected a `FnMut()` closure, found `T` + --> $DIR/normalization-ice-issue-149746.rs:10:16 + | +LL | pub fn test(w: Warns) { + | ^ expected an `FnMut()` closure, found `T` + | + = note: wrap the `T` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `Owner::Ty` + --> $DIR/normalization-ice-issue-149746.rs:3:26 + | +LL | trait Owner { type Ty; } + | ^^^^^^^ required by this bound in `Owner::Ty` + +error[E0277]: expected a `FnMut()` closure, found `T` + --> $DIR/normalization-ice-issue-149746.rs:12:9 + | +LL | _ = || w.field + | ^^^^^^^^^^ expected an `FnMut()` closure, found `T` + | + = note: wrap the `T` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `Owner::Ty` + --> $DIR/normalization-ice-issue-149746.rs:3:26 + | +LL | trait Owner { type Ty; } + | ^^^^^^^ required by this bound in `Owner::Ty` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. From 75f53dd70e23b09e2557ca7c73bcaa22b9d1a8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Dec 2025 14:16:25 +0100 Subject: [PATCH 429/489] Update bors configuration --- rust-bors.toml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/rust-bors.toml b/rust-bors.toml index e813c6c4b116..996b50b2ea27 100644 --- a/rust-bors.toml +++ b/rust-bors.toml @@ -25,3 +25,42 @@ labels_blocking_approval = [ "S-waiting-on-t-rustdoc-frontend", "S-waiting-on-t-clippy" ] + +# If CI runs quicker than this duration, consider it to be a failure +min_ci_time = 600 + +[labels] +approved = [ + "+S-waiting-on-bors", + "-S-blocked", + "-S-waiting-on-author", + "-S-waiting-on-crater", + "-S-waiting-on-review", + "-S-waiting-on-team" +] +unapproved = [ + "+S-waiting-on-author", + "-S-blocked", + "-S-waiting-on-bors", + "-S-waiting-on-crater", + "-S-waiting-on-review", + "-S-waiting-on-team" +] +try_failed = [ + "+S-waiting-on-author", + "-S-waiting-on-review", + "-S-waiting-on-crater" +] +auto_build_succeeded = ["+merged-by-bors"] +auto_build_failed = [ + "+S-waiting-on-review", + "-S-blocked", + "-S-waiting-on-bors", + "-S-waiting-on-author", + "-S-waiting-on-crater", + "-S-waiting-on-team" +] + +# Flip this two once new bors is used for actual merges on this repository +merge_queue_enabled = false +report_merge_conflicts = true From dfef2e96fe0216e243f458b8fe04a8b82a07065a Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 9 Dec 2025 07:50:30 -0800 Subject: [PATCH 430/489] Remove the need to call clang for std::offload usages --- compiler/rustc_codegen_llvm/src/back/write.rs | 74 ++++++++++++++++++- compiler/rustc_codegen_llvm/src/base.rs | 6 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 8 +- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 22 +++++- compiler/rustc_interface/src/tests.rs | 2 +- .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 32 ++++++-- compiler/rustc_session/src/config.rs | 12 +-- compiler/rustc_session/src/options.rs | 23 +++++- 8 files changed, 149 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index e8da7f68136d..a649ee4bff1c 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -703,10 +703,9 @@ pub(crate) unsafe fn llvm_optimize( llvm::set_value_name(new_fn, &name); } - if cgcx.target_is_like_gpu && config.offload.contains(&config::Offload::Enable) { + if cgcx.target_is_like_gpu && config.offload.contains(&config::Offload::Device) { let cx = SimpleCx::new(module.module_llvm.llmod(), module.module_llvm.llcx, cgcx.pointer_size); - for func in cx.get_functions() { let offload_kernel = "offload-kernel"; if attributes::has_string_attr(func, offload_kernel) { @@ -775,12 +774,79 @@ pub(crate) unsafe fn llvm_optimize( ) }; - if cgcx.target_is_like_gpu && config.offload.contains(&config::Offload::Enable) { + if cgcx.target_is_like_gpu && config.offload.contains(&config::Offload::Device) { + let device_path = cgcx.output_filenames.path(OutputType::Object); + let device_dir = device_path.parent().unwrap(); + let device_out = device_dir.join("host.out"); + let device_out_c = path_to_c_string(device_out.as_path()); unsafe { - llvm::LLVMRustBundleImages(module.module_llvm.llmod(), module.module_llvm.tm.raw()); + // 1) Bundle device module into offload image host.out (device TM) + let ok = llvm::LLVMRustBundleImages( + module.module_llvm.llmod(), + module.module_llvm.tm.raw(), + device_out_c.as_ptr(), + ); + assert!(ok, "LLVMRustBundleImages (device -> host.out) failed"); + if !device_out.exists() { + panic!("BundleImages failed, `host.out` was not created!"); + } } } + // This assumes that we previously compiled our kernels for a gpu target, which created a + // `host.out` artifact. The user is supposed to provide us with a path to this artifact, we + // don't need any other artifacts from the previous run. We will embed this artifact into our + // LLVM-IR host module, to create a `host.o` ObjectFile, which we will write to disk. + // The last, not yet automated steps uses the `clang-linker-wrapper` to process `host.o`. + if !cgcx.target_is_like_gpu { + if let Some(device_path) = config + .offload + .iter() + .find_map(|o| if let config::Offload::Host(path) = o { Some(path) } else { None }) + { + let device_pathbuf = PathBuf::from(device_path); + if device_pathbuf.is_relative() { + panic!("Absolute path is needed"); + } else if device_pathbuf + .file_name() + .and_then(|n| n.to_str()) + .is_some_and(|n| n != "host.out") + { + panic!("Need path to the host.out file"); + } + assert!(device_pathbuf.exists()); + let host_path = cgcx.output_filenames.path(OutputType::Object); + let host_dir = host_path.parent().unwrap(); + let out_obj = host_dir.join("host.o"); + let host_out_c = path_to_c_string(device_pathbuf.as_path()); + + // 2) Finalize host: lib.bc + host.out -> host.o (host TM) + // We create a full clone of our LLVM host module, since we will embed the device IR + // into it, and this might break caching or incremental compilation otherwise. + let llmod2 = llvm::LLVMCloneModule(module.module_llvm.llmod()); + let ok = + unsafe { llvm::LLVMRustOffloadEmbedBufferInModule(llmod2, host_out_c.as_ptr()) }; + assert!(ok, "LLVMRustOffloadEmbedBufferInModule failed"); + write_output_file( + dcx, + module.module_llvm.tm.raw(), + config.no_builtins, + llmod2, + &out_obj, + None, + llvm::FileType::ObjectFile, + &cgcx.prof, + true, + ); + if !out_obj.exists() { + dbg!("{:?} does not exist!", out_obj); + panic!("FinalizeOffload failed!"); + } + // We ignore cgcx.save_temps here and unconditionally always keep our `host.out` artifact. + // Otherwise, recompiling the host code would fail since we deleted that device artifact + // in the previous host compilation, which would be confusing at best. + } + } result.into_result().unwrap_or_else(|()| llvm_err(dcx, LlvmError::RunLlvmPasses)) } diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 16455b4c79cd..388118f9b4f1 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -93,9 +93,9 @@ pub(crate) fn compile_codegen_unit( // They are necessary for correct offload execution. We do this here to simplify the // `offload` intrinsic, avoiding the need for tracking whether it's the first // intrinsic call or not. - if cx.sess().opts.unstable_opts.offload.contains(&Offload::Enable) - && !cx.sess().target.is_like_gpu - { + let has_host_offload = + cx.sess().opts.unstable_opts.offload.iter().any(|o| matches!(o, Offload::Host(_))); + if has_host_offload && !cx.sess().target.is_like_gpu { cx.offload_globals.replace(Some(OffloadGlobals::declare(&cx))); } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 3bc890310cc8..f3d919207477 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -202,13 +202,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { return Ok(()); } sym::offload => { - if !tcx - .sess - .opts - .unstable_opts - .offload - .contains(&rustc_session::config::Offload::Enable) - { + if tcx.sess.opts.unstable_opts.offload.is_empty() { let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutEnable); } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index a86b4cc38915..75b3e5955b78 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1666,7 +1666,15 @@ mod Offload { use super::*; unsafe extern "C" { /// Processes the module and writes it in an offload compatible way into a "host.out" file. - pub(crate) fn LLVMRustBundleImages<'a>(M: &'a Module, TM: &'a TargetMachine) -> bool; + pub(crate) fn LLVMRustBundleImages<'a>( + M: &'a Module, + TM: &'a TargetMachine, + host_out: *const c_char, + ) -> bool; + pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>( + _M: &'a Module, + _host_out: *const c_char, + ) -> bool; pub(crate) fn LLVMRustOffloadMapper<'a>(OldFn: &'a Value, NewFn: &'a Value); } } @@ -1680,7 +1688,17 @@ mod Offload_fallback { /// Processes the module and writes it in an offload compatible way into a "host.out" file. /// Marked as unsafe to match the real offload wrapper which is unsafe due to FFI. #[allow(unused_unsafe)] - pub(crate) unsafe fn LLVMRustBundleImages<'a>(_M: &'a Module, _TM: &'a TargetMachine) -> bool { + pub(crate) unsafe fn LLVMRustBundleImages<'a>( + _M: &'a Module, + _TM: &'a TargetMachine, + _host_out: *const c_char, + ) -> bool { + unimplemented!("This rustc version was not built with LLVM Offload support!"); + } + pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>( + _M: &'a Module, + _host_out: *const c_char, + ) -> bool { unimplemented!("This rustc version was not built with LLVM Offload support!"); } #[allow(unused_unsafe)] diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 8dab3a7f37f5..d075f94ef850 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -837,7 +837,7 @@ fn test_unstable_options_tracking_hash() { tracked!(no_profiler_runtime, true); tracked!(no_trait_vptr, true); tracked!(no_unique_section_names, true); - tracked!(offload, vec![Offload::Enable]); + tracked!(offload, vec![Offload::Device]); tracked!(on_broken_pipe, OnBrokenPipe::Kill); tracked!(osx_rpath_install_name, true); tracked!(packed_bundled_libs, true); diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 0720af0eb7e0..02e6abf24627 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -43,8 +43,10 @@ // available. As such, we only try to build it in the first place, if // llvm.offload is enabled. #ifdef OFFLOAD +#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Object/OffloadBinary.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Transforms/Utils/ModuleUtils.h" #endif // for raw `write` in the bad-alloc handler @@ -174,12 +176,13 @@ static Error writeFile(StringRef Filename, StringRef Data) { // --image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp // The input module is the rust code compiled for a gpu target like amdgpu. // Based on clang/tools/clang-offload-packager/ClangOffloadPackager.cpp -extern "C" bool LLVMRustBundleImages(LLVMModuleRef M, TargetMachine &TM) { +extern "C" bool LLVMRustBundleImages(LLVMModuleRef M, TargetMachine &TM, + const char *HostOutPath) { std::string Storage; llvm::raw_string_ostream OS1(Storage); llvm::WriteBitcodeToFile(*unwrap(M), OS1); OS1.flush(); - auto MB = llvm::MemoryBuffer::getMemBufferCopy(Storage, "module.bc"); + auto MB = llvm::MemoryBuffer::getMemBufferCopy(Storage, "device.bc"); SmallVector BinaryData; raw_svector_ostream OS2(BinaryData); @@ -188,19 +191,38 @@ extern "C" bool LLVMRustBundleImages(LLVMModuleRef M, TargetMachine &TM) { ImageBinary.TheImageKind = object::IMG_Bitcode; ImageBinary.Image = std::move(MB); ImageBinary.TheOffloadKind = object::OFK_OpenMP; - ImageBinary.StringData["triple"] = TM.getTargetTriple().str(); - ImageBinary.StringData["arch"] = TM.getTargetCPU(); + + std::string TripleStr = TM.getTargetTriple().str(); + llvm::StringRef CPURef = TM.getTargetCPU(); + ImageBinary.StringData["triple"] = TripleStr; + ImageBinary.StringData["arch"] = CPURef; llvm::SmallString<0> Buffer = OffloadBinary::write(ImageBinary); if (Buffer.size() % OffloadBinary::getAlignment() != 0) // Offload binary has invalid size alignment return false; OS2 << Buffer; - if (Error E = writeFile("host.out", + if (Error E = writeFile(HostOutPath, StringRef(BinaryData.begin(), BinaryData.size()))) return false; return true; } +extern "C" bool LLVMRustOffloadEmbedBufferInModule(LLVMModuleRef HostM, + const char *HostOutPath) { + auto MBOrErr = MemoryBuffer::getFile(HostOutPath); + if (!MBOrErr) { + auto E = MBOrErr.getError(); + auto _B = errorCodeToError(E); + return false; + } + MemoryBufferRef Buf = (*MBOrErr)->getMemBufferRef(); + Module *M = unwrap(HostM); + StringRef SectionName = ".llvm.offloading"; + Align Alignment = Align(8); + llvm::embedBufferInModule(*M, Buf, SectionName, Alignment); + return true; +} + extern "C" void LLVMRustOffloadMapper(LLVMValueRef OldFn, LLVMValueRef NewFn) { llvm::Function *oldFn = llvm::unwrap(OldFn); llvm::Function *newFn = llvm::unwrap(NewFn); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index a3a97dfec61d..2774333573f6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -190,10 +190,12 @@ pub enum CoverageLevel { } // The different settings that the `-Z offload` flag can have. -#[derive(Clone, Copy, PartialEq, Hash, Debug)] +#[derive(Clone, PartialEq, Hash, Debug)] pub enum Offload { - /// Enable the llvm offload pipeline - Enable, + /// Entry point for `std::offload`, enables kernel compilation for a gpu device + Device, + /// Second step in the offload pipeline, generates the host code to call kernels. + Host(String), } /// The different settings that the `-Z autodiff` flag can have. @@ -2578,9 +2580,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M ) } - if !nightly_options::is_unstable_enabled(matches) - && unstable_opts.offload.contains(&Offload::Enable) - { + if !nightly_options::is_unstable_enabled(matches) && !unstable_opts.offload.is_empty() { early_dcx.early_fatal( "`-Zoffload=Enable` also requires `-Zunstable-options` \ and a nightly compiler", diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index aea0b73ee927..2b83d1225c97 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1451,8 +1451,27 @@ pub mod parse { let mut v: Vec<&str> = v.split(",").collect(); v.sort_unstable(); for &val in v.iter() { - let variant = match val { - "Enable" => Offload::Enable, + // Split each entry on '=' if it has an argument + let (key, arg) = match val.split_once('=') { + Some((k, a)) => (k, Some(a)), + None => (val, None), + }; + + let variant = match key { + "Host" => { + if let Some(p) = arg { + Offload::Host(p.to_string()) + } else { + return false; + } + } + "Device" => { + if let Some(_) = arg { + // Device does not accept a value + return false; + } + Offload::Device + } _ => { // FIXME(ZuseZ4): print an error saying which value is not recognized return false; From 3fdc6da2aad13909f02754d32db85ac69ca86102 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 9 Dec 2025 07:51:04 -0800 Subject: [PATCH 431/489] adding proper error handling for offload --- compiler/rustc_codegen_llvm/messages.ftl | 7 ++++++- compiler/rustc_codegen_llvm/src/back/write.rs | 20 +++++++++---------- compiler/rustc_codegen_llvm/src/errors.rs | 20 +++++++++++++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_llvm/messages.ftl b/compiler/rustc_codegen_llvm/messages.ftl index b3ef9840f5dc..a637ae8184b4 100644 --- a/compiler/rustc_codegen_llvm/messages.ftl +++ b/compiler/rustc_codegen_llvm/messages.ftl @@ -19,7 +19,12 @@ codegen_llvm_lto_bitcode_from_rlib = failed to get bitcode from object file for codegen_llvm_mismatch_data_layout = data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}` -codegen_llvm_offload_without_enable = using the offload feature requires -Z offload=Enable +codegen_llvm_offload_bundleimages_failed = call to BundleImages failed, `host.out` was not created +codegen_llvm_offload_embed_failed = call to EmbedBufferInModule failed, `host.o` was not created +codegen_llvm_offload_no_abs_path = using the `-Z offload=Host=/absolute/path/to/host.out` flag requires an absolute path +codegen_llvm_offload_no_host_out = using the `-Z offload=Host=/absolute/path/to/host.out` flag must point to a `host.out` file +codegen_llvm_offload_nonexisting = the given path/file to `host.out` does not exist. Did you forget to run the device compilation first? +codegen_llvm_offload_without_enable = using the offload feature requires -Z offload= codegen_llvm_offload_without_fat_lto = using the offload feature requires -C lto=fat codegen_llvm_parse_bitcode = failed to parse bitcode for LTO module diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index a649ee4bff1c..d87de8b38467 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -786,9 +786,8 @@ pub(crate) unsafe fn llvm_optimize( module.module_llvm.tm.raw(), device_out_c.as_ptr(), ); - assert!(ok, "LLVMRustBundleImages (device -> host.out) failed"); - if !device_out.exists() { - panic!("BundleImages failed, `host.out` was not created!"); + if !ok || !device_out.exists() { + dcx.emit_err(crate::errors::OffloadBundleImagesFailed); } } } @@ -806,15 +805,16 @@ pub(crate) unsafe fn llvm_optimize( { let device_pathbuf = PathBuf::from(device_path); if device_pathbuf.is_relative() { - panic!("Absolute path is needed"); + dcx.emit_err(crate::errors::OffloadWithoutAbsPath); } else if device_pathbuf .file_name() .and_then(|n| n.to_str()) .is_some_and(|n| n != "host.out") { - panic!("Need path to the host.out file"); + dcx.emit_err(crate::errors::OffloadWrongFileName); + } else if !device_pathbuf.exists() { + dcx.emit_err(crate::errors::OffloadNonexistingPath); } - assert!(device_pathbuf.exists()); let host_path = cgcx.output_filenames.path(OutputType::Object); let host_dir = host_path.parent().unwrap(); let out_obj = host_dir.join("host.o"); @@ -826,7 +826,9 @@ pub(crate) unsafe fn llvm_optimize( let llmod2 = llvm::LLVMCloneModule(module.module_llvm.llmod()); let ok = unsafe { llvm::LLVMRustOffloadEmbedBufferInModule(llmod2, host_out_c.as_ptr()) }; - assert!(ok, "LLVMRustOffloadEmbedBufferInModule failed"); + if !ok { + dcx.emit_err(crate::errors::OffloadEmbedFailed); + } write_output_file( dcx, module.module_llvm.tm.raw(), @@ -838,10 +840,6 @@ pub(crate) unsafe fn llvm_optimize( &cgcx.prof, true, ); - if !out_obj.exists() { - dbg!("{:?} does not exist!", out_obj); - panic!("FinalizeOffload failed!"); - } // We ignore cgcx.save_temps here and unconditionally always keep our `host.out` artifact. // Otherwise, recompiling the host code would fail since we deleted that device artifact // in the previous host compilation, which would be confusing at best. diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index b59067b9745b..c73140e041b6 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -52,6 +52,26 @@ pub(crate) struct OffloadWithoutEnable; #[diag(codegen_llvm_offload_without_fat_lto)] pub(crate) struct OffloadWithoutFatLTO; +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_no_abs_path)] +pub(crate) struct OffloadWithoutAbsPath; + +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_no_host_out)] +pub(crate) struct OffloadWrongFileName; + +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_nonexisting)] +pub(crate) struct OffloadNonexistingPath; + +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_bundleimages_failed)] +pub(crate) struct OffloadBundleImagesFailed; + +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_embed_failed)] +pub(crate) struct OffloadEmbedFailed; + #[derive(Diagnostic)] #[diag(codegen_llvm_lto_bitcode_from_rlib)] pub(crate) struct LtoBitcodeFromRlib { From 8e1d80305fd98ee7da1cb422d5da2495502e995d Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 9 Dec 2025 07:50:48 -0800 Subject: [PATCH 432/489] Update offloading docs to account for simplified usage --- src/doc/rustc-dev-guide/src/offload/usage.md | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/offload/usage.md b/src/doc/rustc-dev-guide/src/offload/usage.md index d934de9049be..062534a4b655 100644 --- a/src/doc/rustc-dev-guide/src/offload/usage.md +++ b/src/doc/rustc-dev-guide/src/offload/usage.md @@ -77,28 +77,25 @@ pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) { ## Compile instructions It is important to use a clang compiler build on the same llvm as rustc. Just calling clang without the full path will likely use your system clang, which probably will be incompatible. So either substitute clang/lld invocations below with absolute path, or set your `PATH` accordingly. -First we generate the host (cpu) code. The first build is just to compile libc, take note of the hashed path. Then we call rustc directly to build our host code, while providing the libc artifact to rustc. +First we generate the device (gpu) code. Replace the target-cpu with the right code for your gpu. ``` -cargo +offload build -r -v -rustc +offload --edition 2024 src/lib.rs -g --crate-type cdylib -C opt-level=3 -C panic=abort -C lto=fat -L dependency=/absolute_path_to/target/release/deps --extern libc=/absolute_path_to/target/release/deps/liblibc-.rlib --emit=llvm-bc,llvm-ir -Zoffload=Enable -Zunstable-options +RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Device -Csave-temps -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core ``` +You might afterwards need to copy your target/release/deps/.bc to lib.bc for now, before the next step. -Now we generate the device code. Replace the target-cpu with the right code for your gpu. +Now we generate the host (cpu) code. ``` -RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Enable -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core +RUSTFLAGS="--emit=llvm-bc,llvm-ir -Csave-temps -Zoffload=Host=/p/lustre1/drehwald1/prog/offload/r/target/amdgcn-amd-amdhsa/release/deps/host.out -Zunstable-options" cargo +offload build -r ``` - +This call also does a lot of work and generates multiple intermediate files for llvm offload. +While we integrated most offload steps into rustc by now, one binary invocation still remains for now: ``` -"clang-21" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-S" "-save-temps=cwd" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "lib.rs" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-resource-dir" "//rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21" "-ferror-limit" "19" "-fopenmp" "-fopenmp-offload-mandatory" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fembed-offload-object=host.out" "-fopenmp-targets=amdgcn-amd-amdhsa" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "host.s" "-x" "ir" "lib.bc" - -"clang-21" "-cc1as" "-triple" "x86_64-unknown-linux-gnu" "-filetype" "obj" "-main-file-name" "lib.rs" "-target-cpu" "x86-64" "-mrelocation-model" "pic" "-o" "host.o" "host.s" - -"clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o" +"clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "target//release/host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o" ``` -Especially for the last three commands I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps. -You can ignore other steps, e.g. the invocation of a "clang-offload-packager". +You can try to find the paths to those files on your system. However, I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps. +It will show multiple steps, just look for the clang-linker-wrapper example. Make sure to still include the path to the `host.o` file, and not whatever tmp file you got when compiling your c++ example with the following call. ``` myclang++ -fuse-ld=lld -O3 -fopenmp -fopenmp-offload-mandatory --offload-arch=gfx90a omp_bare.cpp -o main -### ``` From 8f3a76bd38f903503f29e895c78bab4a685d64ec Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Fri, 14 Nov 2025 08:57:41 +0000 Subject: [PATCH 433/489] mgca always resolve params --- .../src/hir_ty_lowering/mod.rs | 10 ++ compiler/rustc_hir_typeck/src/lib.rs | 12 ++ compiler/rustc_middle/src/hir/map.rs | 48 ++++++++ compiler/rustc_resolve/src/late.rs | 12 +- .../mgca/explicit_anon_consts.rs | 1 + .../mgca/explicit_anon_consts.stderr | 112 ++++++++---------- .../mgca/type_const-on-generic-expr.rs | 1 + .../mgca/type_const-on-generic-expr.stderr | 41 +++---- 8 files changed, 145 insertions(+), 92 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 4db9a4c2bcdd..f7c7cf6634fd 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2378,6 +2378,16 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let expr = &tcx.hir_body(anon.body).value; debug!(?expr); + // If the rhs is an anon const naming generics it shouldn't have + // access to then we lower to `ConstKind::Error`. This prevents + // `try_lower_anon_const_lit` from ICEing on anon consts such as + // `const { N }` which aren't supposed to be legal. + if let ty::AnonConstKind::MCG = tcx.anon_const_kind(anon.def_id) + && let Err(e) = tcx.check_anon_const_invalid_param_uses(anon.def_id) + { + return ty::Const::new_error(tcx, e); + } + // FIXME(generic_const_parameter_types): We should use the proper generic args // here. It's only used as a hint for literals so doesn't matter too much to use the right // generic arguments, just weaker type inference. diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 39c28c4f4e99..b8a587016427 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -115,6 +115,18 @@ fn typeck_with_inspect<'tcx>( return tcx.typeck(typeck_root_def_id); } + // We can't handle bodies containing generic parameters even though + // these generic parameters aren't part of its `generics_of` right now. + // + // See the FIXME on `check_anon_const_invalid_param_uses`. + if tcx.features().min_generic_const_args() + && let DefKind::AnonConst = tcx.def_kind(def_id) + && let ty::AnonConstKind::MCG = tcx.anon_const_kind(def_id) + && let Err(e) = tcx.check_anon_const_invalid_param_uses(def_id) + { + e.raise_fatal(); + } + let id = tcx.local_def_id_to_hir_id(def_id); let node = tcx.hir_node(id); let span = tcx.def_span(def_id); diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 5da762ef8565..9e639b243f28 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -2,6 +2,8 @@ //! eliminated, and all its methods are now on `TyCtxt`. But the module name //! stays as `map` because there isn't an obviously better name for it. +use std::ops::ControlFlow; + use rustc_abi::ExternAbi; use rustc_ast::visit::{VisitorResult, walk_list}; use rustc_data_structures::fingerprint::Fingerprint; @@ -1086,6 +1088,52 @@ impl<'tcx> TyCtxt<'tcx> { None } + + // FIXME(mgca): this is pretty iffy. In the long term we should make + // HIR ty lowering able to return `Error` versions of types/consts when + // lowering them in contexts that aren't supposed to use generic parameters. + // + // This current impl strategy is incomplete and doesn't handle `Self` ty aliases. + pub fn check_anon_const_invalid_param_uses( + self, + anon: LocalDefId, + ) -> Result<(), ErrorGuaranteed> { + struct GenericParamVisitor<'tcx>(TyCtxt<'tcx>); + impl<'tcx> Visitor<'tcx> for GenericParamVisitor<'tcx> { + type NestedFilter = nested_filter::OnlyBodies; + type Result = ControlFlow; + + fn maybe_tcx(&mut self) -> TyCtxt<'tcx> { + self.0 + } + + fn visit_path( + &mut self, + path: &crate::hir::Path<'tcx>, + _id: HirId, + ) -> ControlFlow { + if let Res::Def( + DefKind::TyParam | DefKind::ConstParam | DefKind::LifetimeParam, + _, + ) = path.res + { + let e = self.0.dcx().struct_span_err( + path.span, + "generic parameters may not be used in const operations", + ); + return ControlFlow::Break(e.emit()); + } + + intravisit::walk_path(self, path) + } + } + + let body = self.hir_maybe_body_owned_by(anon).unwrap(); + match GenericParamVisitor(self).visit_expr(&body.value) { + ControlFlow::Break(e) => Err(e), + ControlFlow::Continue(()) => Ok(()), + } + } } impl<'tcx> intravisit::HirTyCtxt<'tcx> for TyCtxt<'tcx> { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index d3428a4af348..4fefcc66b588 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -4879,12 +4879,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { constant, anon_const_kind ); - let is_trivial_const_arg = if self.r.tcx.features().min_generic_const_args() { - matches!(constant.mgca_disambiguation, MgcaDisambiguation::Direct) - } else { - constant.value.is_potential_trivial_const_arg() - }; - + let is_trivial_const_arg = constant.value.is_potential_trivial_const_arg(); self.resolve_anon_const_manual(is_trivial_const_arg, anon_const_kind, |this| { this.resolve_expr(&constant.value, None) }) @@ -4914,7 +4909,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { AnonConstKind::FieldDefaultValue => ConstantHasGenerics::Yes, AnonConstKind::InlineConst => ConstantHasGenerics::Yes, AnonConstKind::ConstArg(_) => { - if self.r.tcx.features().generic_const_exprs() || is_trivial_const_arg { + if self.r.tcx.features().generic_const_exprs() + || self.r.tcx.features().min_generic_const_args() + || is_trivial_const_arg + { ConstantHasGenerics::Yes } else { ConstantHasGenerics::No(NoConstantGenericsReason::NonTrivialConstArg) diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.rs b/tests/ui/const-generics/mgca/explicit_anon_consts.rs index 31391b023bfe..ef17222ebc91 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.rs +++ b/tests/ui/const-generics/mgca/explicit_anon_consts.rs @@ -10,6 +10,7 @@ type Adt1 = Foo; type Adt2 = Foo<{ N }>; type Adt3 = Foo; //~^ ERROR: generic parameters may not be used in const operations +//~^^ ERROR generic parameters may not be used in const operations type Adt4 = Foo<{ 1 + 1 }>; //~^ ERROR: complex const arguments must be placed inside of a `const` block type Adt5 = Foo; diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr index b3d960e315ea..eb200aae3396 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr +++ b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr @@ -1,92 +1,82 @@ -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:11:41 - | -LL | type Adt3 = Foo; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments here, i.e. `N` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:19:42 - | -LL | type Arr3 = [(); const { N }]; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments here, i.e. `N` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:28:27 - | -LL | let _3 = [(); const { N }]; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments here, i.e. `N` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:40:46 - | -LL | const ITEM3: usize = const { N }; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments here, i.e. `N` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:58:31 - | -LL | T3: Trait, - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments here, i.e. `N` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:67:58 - | -LL | struct Default3; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments here, i.e. `N` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions - error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:13:33 + --> $DIR/explicit_anon_consts.rs:14:33 | LL | type Adt4 = Foo<{ 1 + 1 }>; | ^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:21:34 + --> $DIR/explicit_anon_consts.rs:22:34 | LL | type Arr4 = [(); 1 + 1]; | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:30:19 + --> $DIR/explicit_anon_consts.rs:31:19 | LL | let _4 = [(); 1 + 1]; | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:43:38 + --> $DIR/explicit_anon_consts.rs:44:38 | LL | const ITEM4: usize = { 1 + 1 }; | ^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:60:23 + --> $DIR/explicit_anon_consts.rs:61:23 | LL | T4: Trait, | ^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:69:50 + --> $DIR/explicit_anon_consts.rs:70:50 | LL | struct Default4; | ^^^^^^^^^ -error: aborting due to 12 previous errors +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:11:41 + | +LL | type Adt3 = Foo; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:20:42 + | +LL | type Arr3 = [(); const { N }]; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:41:46 + | +LL | const ITEM3: usize = const { N }; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:59:31 + | +LL | T3: Trait, + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:68:58 + | +LL | struct Default3; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:29:27 + | +LL | let _3 = [(); const { N }]; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts.rs:11:41 + | +LL | type Adt3 = Foo; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 13 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs index 577fee084dbd..a1008fae9d16 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs @@ -4,6 +4,7 @@ #[type_const] const FREE1: usize = const { std::mem::size_of::() }; //~^ ERROR generic parameters may not be used in const operations +//~^^ ERROR generic parameters may not be used in const operations #[type_const] const FREE2: usize = const { I + 1 }; //~^ ERROR generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr index 8cef77e5b229..c77be158d0ef 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr @@ -2,46 +2,39 @@ error: generic parameters may not be used in const operations --> $DIR/type_const-on-generic-expr.rs:5:53 | LL | const FREE1: usize = const { std::mem::size_of::() }; - | ^ cannot perform const operation using `T` - | - = note: type parameters may not be used in const expressions - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:8:46 + --> $DIR/type_const-on-generic-expr.rs:9:46 | LL | const FREE2: usize = const { I + 1 }; - | ^ cannot perform const operation using `I` - | - = help: const parameters may only be used as standalone arguments here, i.e. `I` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:24:54 + --> $DIR/type_const-on-generic-expr.rs:25:54 | LL | const N1: usize = const { std::mem::size_of::() }; - | ^ cannot perform const operation using `T` - | - = note: type parameters may not be used in const expressions - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:27:47 + --> $DIR/type_const-on-generic-expr.rs:28:47 | LL | const N2: usize = const { I + 1 }; - | ^ cannot perform const operation using `I` - | - = help: const parameters may only be used as standalone arguments here, i.e. `I` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions + | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:30:35 + --> $DIR/type_const-on-generic-expr.rs:31:35 | LL | const N3: usize = const { 2 & X }; - | ^ cannot perform const operation using `X` + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/type_const-on-generic-expr.rs:5:53 | - = help: const parameters may only be used as standalone arguments here, i.e. `X` - = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions +LL | const FREE1: usize = const { std::mem::size_of::() }; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors From c65551e835f42d6b3cc28ebe37257ae7cfcbfe06 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Thu, 20 Nov 2025 02:16:43 +0000 Subject: [PATCH 434/489] Introduce `hir::ConstArgKind::Struct` --- compiler/rustc_ast_lowering/src/index.rs | 7 ++ compiler/rustc_ast_lowering/src/lib.rs | 41 +++++++++ compiler/rustc_hir/src/hir.rs | 13 +++ compiler/rustc_hir/src/intravisit.rs | 23 +++++ .../src/hir_ty_lowering/mod.rs | 3 + compiler/rustc_hir_pretty/src/lib.rs | 4 + compiler/rustc_metadata/src/rmeta/encoder.rs | 1 + compiler/rustc_middle/src/hir/map.rs | 2 + compiler/rustc_middle/src/hir/mod.rs | 1 + compiler/rustc_resolve/src/def_collector.rs | 89 +++++++++++++++---- compiler/rustc_resolve/src/lib.rs | 9 ++ .../mgca/struct_expr_with_macros.rs | 31 +++++++ 12 files changed, 205 insertions(+), 19 deletions(-) create mode 100644 tests/ui/const-generics/mgca/struct_expr_with_macros.rs diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index 8d7351d3a510..f6edcaa64dfe 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -281,6 +281,13 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { }); } + fn visit_const_arg_expr_field(&mut self, field: &'hir ConstArgExprField<'hir>) { + self.insert(field.span, field.hir_id, Node::ConstArgExprField(field)); + self.with_parent(field.hir_id, |this| { + intravisit::walk_const_arg_expr_field(this, field); + }) + } + fn visit_stmt(&mut self, stmt: &'hir Stmt<'hir>) { self.insert(stmt.span, stmt.hir_id, Node::Stmt(stmt)); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1bc8d7c25bb5..416fef8e3af3 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -2410,6 +2410,47 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Path(qpath) } } + ExprKind::Struct(se) => { + let path = self.lower_qpath( + expr.id, + &se.qself, + &se.path, + // FIXME(mgca): we may want this to be `Optional` instead, but + // we would also need to make sure that HIR ty lowering errors + // when these paths wind up in signatures. + ParamMode::Explicit, + AllowReturnTypeNotation::No, + ImplTraitContext::Disallowed(ImplTraitPosition::Path), + None, + ); + + let fields = self.arena.alloc_from_iter(se.fields.iter().map(|f| { + let hir_id = self.lower_node_id(f.id); + // FIXME(mgca): This might result in lowering attributes that + // then go unused as the `Target::ExprField` is not actually + // corresponding to `Node::ExprField`. + self.lower_attrs(hir_id, &f.attrs, f.span, Target::ExprField); + + let expr = if let ExprKind::ConstBlock(anon_const) = &f.expr.kind { + let def_id = self.local_def_id(anon_const.id); + let def_kind = self.tcx.def_kind(def_id); + assert_eq!(DefKind::AnonConst, def_kind); + + self.lower_anon_const_to_const_arg_direct(anon_const) + } else { + self.lower_expr_to_const_arg_direct(&f.expr) + }; + + &*self.arena.alloc(hir::ConstArgExprField { + hir_id, + field: self.lower_ident(f.ident), + expr: self.arena.alloc(expr), + span: self.lower_span(f.span), + }) + })); + + ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Struct(path, fields) } + } ExprKind::Underscore => ConstArg { hir_id: self.lower_node_id(expr.id), kind: hir::ConstArgKind::Infer(expr.span, ()), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index c60471848c89..e176c703b33e 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -494,6 +494,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> { pub fn span(&self) -> Span { match self.kind { + ConstArgKind::Struct(path, _) => path.span(), ConstArgKind::Path(path) => path.span(), ConstArgKind::Anon(anon) => anon.span, ConstArgKind::Error(span, _) => span, @@ -513,6 +514,8 @@ pub enum ConstArgKind<'hir, Unambig = ()> { /// However, in the future, we'll be using it for all of those. Path(QPath<'hir>), Anon(&'hir AnonConst), + /// Represents construction of struct/struct variants + Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]), /// Error const Error(Span, ErrorGuaranteed), /// This variant is not always used to represent inference consts, sometimes @@ -520,6 +523,14 @@ pub enum ConstArgKind<'hir, Unambig = ()> { Infer(Span, Unambig), } +#[derive(Clone, Copy, Debug, HashStable_Generic)] +pub struct ConstArgExprField<'hir> { + pub hir_id: HirId, + pub span: Span, + pub field: Ident, + pub expr: &'hir ConstArg<'hir>, +} + #[derive(Clone, Copy, Debug, HashStable_Generic)] pub struct InferArg { #[stable_hasher(ignore)] @@ -4714,6 +4725,7 @@ pub enum Node<'hir> { ConstArg(&'hir ConstArg<'hir>), Expr(&'hir Expr<'hir>), ExprField(&'hir ExprField<'hir>), + ConstArgExprField(&'hir ConstArgExprField<'hir>), Stmt(&'hir Stmt<'hir>), PathSegment(&'hir PathSegment<'hir>), Ty(&'hir Ty<'hir>), @@ -4773,6 +4785,7 @@ impl<'hir> Node<'hir> { Node::AssocItemConstraint(c) => Some(c.ident), Node::PatField(f) => Some(f.ident), Node::ExprField(f) => Some(f.ident), + Node::ConstArgExprField(f) => Some(f.field), Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident), Node::Param(..) | Node::AnonConst(..) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index be3cab6461ef..e63f51f8e6a4 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -396,6 +396,9 @@ pub trait Visitor<'v>: Sized { fn visit_expr_field(&mut self, field: &'v ExprField<'v>) -> Self::Result { walk_expr_field(self, field) } + fn visit_const_arg_expr_field(&mut self, field: &'v ConstArgExprField<'v>) -> Self::Result { + walk_const_arg_expr_field(self, field) + } fn visit_pattern_type_pattern(&mut self, p: &'v TyPat<'v>) -> Self::Result { walk_ty_pat(self, p) } @@ -954,6 +957,17 @@ pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField try_visit!(visitor.visit_ident(*ident)); visitor.visit_expr(*expr) } + +pub fn walk_const_arg_expr_field<'v, V: Visitor<'v>>( + visitor: &mut V, + field: &'v ConstArgExprField<'v>, +) -> V::Result { + let ConstArgExprField { hir_id, field, expr, span: _ } = field; + try_visit!(visitor.visit_id(*hir_id)); + try_visit!(visitor.visit_ident(*field)); + visitor.visit_const_arg_unambig(*expr) +} + /// We track whether an infer var is from a [`Ty`], [`ConstArg`], or [`GenericArg`] so that /// HIR visitors overriding [`Visitor::visit_infer`] can determine what kind of infer is being visited pub enum InferKind<'hir> { @@ -1068,6 +1082,15 @@ pub fn walk_const_arg<'v, V: Visitor<'v>>( let ConstArg { hir_id, kind } = const_arg; try_visit!(visitor.visit_id(*hir_id)); match kind { + ConstArgKind::Struct(qpath, field_exprs) => { + try_visit!(visitor.visit_qpath(qpath, *hir_id, qpath.span())); + + for field_expr in *field_exprs { + try_visit!(visitor.visit_const_arg_expr_field(field_expr)); + } + + V::Result::output() + } ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, qpath.span()), ConstArgKind::Anon(anon) => visitor.visit_anon_const(*anon), ConstArgKind::Error(_, _) => V::Result::output(), // errors and spans are not important diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index f7c7cf6634fd..3c1200c812bc 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2263,6 +2263,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ) .unwrap_or_else(|guar| Const::new_error(tcx, guar)) } + hir::ConstArgKind::Struct(..) => { + span_bug!(const_arg.span(), "lowering `{:?}` is not yet implemented", const_arg) + } hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon), hir::ConstArgKind::Infer(span, ()) => self.ct_infer(None, span), hir::ConstArgKind::Error(_, e) => ty::Const::new_error(tcx, e), diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index b3b416955230..f99533922110 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -180,6 +180,8 @@ impl<'a> State<'a> { Node::ConstArg(a) => self.print_const_arg(a), Node::Expr(a) => self.print_expr(a), Node::ExprField(a) => self.print_expr_field(a), + // FIXME(mgca): proper printing for struct exprs + Node::ConstArgExprField(_) => self.word("/* STRUCT EXPR */"), Node::Stmt(a) => self.print_stmt(a), Node::PathSegment(a) => self.print_path_segment(a), Node::Ty(a) => self.print_type(a), @@ -1135,6 +1137,8 @@ impl<'a> State<'a> { fn print_const_arg(&mut self, const_arg: &hir::ConstArg<'_>) { match &const_arg.kind { + // FIXME(mgca): proper printing for struct exprs + ConstArgKind::Struct(..) => self.word("/* STRUCT EXPR */"), ConstArgKind::Path(qpath) => self.print_qpath(qpath, true), ConstArgKind::Anon(anon) => self.print_anon_const(anon), ConstArgKind::Error(_, _) => self.word("/*ERROR*/"), diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 94bc4d3fa530..920c896d5a47 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1440,6 +1440,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { hir::Node::ConstArg(hir::ConstArg { kind, .. }) => match kind { // Skip encoding defs for these as they should not have had a `DefId` created hir::ConstArgKind::Error(..) + | hir::ConstArgKind::Struct(..) | hir::ConstArgKind::Path(..) | hir::ConstArgKind::Infer(..) => true, hir::ConstArgKind::Anon(..) => false, diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 9e639b243f28..d62ddc915d17 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -739,6 +739,7 @@ impl<'tcx> TyCtxt<'tcx> { Node::ConstArg(_) => node_str("const"), Node::Expr(_) => node_str("expr"), Node::ExprField(_) => node_str("expr field"), + Node::ConstArgExprField(_) => node_str("const arg expr field"), Node::Stmt(_) => node_str("stmt"), Node::PathSegment(_) => node_str("path segment"), Node::Ty(_) => node_str("type"), @@ -1007,6 +1008,7 @@ impl<'tcx> TyCtxt<'tcx> { Node::ConstArg(const_arg) => const_arg.span(), Node::Expr(expr) => expr.span, Node::ExprField(field) => field.span, + Node::ConstArgExprField(field) => field.span, Node::Stmt(stmt) => stmt.span, Node::PathSegment(seg) => { let ident_span = seg.ident.span; diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 217ecbab059e..ba2d8febad7c 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -359,6 +359,7 @@ impl<'tcx> TyCtxt<'tcx> { | Node::Infer(_) | Node::WherePredicate(_) | Node::PreciseCapturingNonLifetimeArg(_) + | Node::ConstArgExprField(_) | Node::OpaqueTy(_) => { unreachable!("no sub-expr expected for {parent_node:?}") } diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 71bbd64ddc6c..b50fc201bdb8 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -11,9 +11,9 @@ use rustc_hir::def_id::LocalDefId; use rustc_middle::span_bug; use rustc_span::hygiene::LocalExpnId; use rustc_span::{Span, Symbol, sym}; -use tracing::debug; +use tracing::{debug, instrument}; -use crate::{ImplTraitContext, InvocationParent, Resolver}; +use crate::{ConstArgContext, ImplTraitContext, InvocationParent, Resolver}; pub(crate) fn collect_definitions( resolver: &mut Resolver<'_, '_>, @@ -21,6 +21,7 @@ pub(crate) fn collect_definitions( expansion: LocalExpnId, ) { let invocation_parent = resolver.invocation_parents[&expansion]; + debug!("new fragment to visit with invocation_parent: {invocation_parent:?}"); let mut visitor = DefCollector { resolver, expansion, invocation_parent }; fragment.visit_with(&mut visitor); } @@ -74,6 +75,12 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { self.invocation_parent.impl_trait_context = orig_itc; } + fn with_const_arg(&mut self, ctxt: ConstArgContext, f: F) { + let orig = mem::replace(&mut self.invocation_parent.const_arg_context, ctxt); + f(self); + self.invocation_parent.const_arg_context = orig; + } + fn collect_field(&mut self, field: &'a FieldDef, index: Option) { let index = |this: &Self| { index.unwrap_or_else(|| { @@ -93,7 +100,10 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { } } + #[instrument(level = "debug", skip(self))] fn visit_macro_invoc(&mut self, id: NodeId) { + debug!(?self.invocation_parent); + let id = id.placeholder_to_expn_id(); let old_parent = self.resolver.invocation_parents.insert(id, self.invocation_parent); assert!(old_parent.is_none(), "parent `LocalDefId` is reset for an invocation"); @@ -360,36 +370,77 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { // `MgcaDisambiguation::Direct` is set even when MGCA is disabled, so // to avoid affecting stable we have to feature gate the not creating // anon consts - if let MgcaDisambiguation::Direct = constant.mgca_disambiguation - && self.resolver.tcx.features().min_generic_const_args() - { - visit::walk_anon_const(self, constant); - return; + if !self.resolver.tcx.features().min_generic_const_args() { + let parent = + self.create_def(constant.id, None, DefKind::AnonConst, constant.value.span); + return self.with_parent(parent, |this| visit::walk_anon_const(this, constant)); } - let parent = self.create_def(constant.id, None, DefKind::AnonConst, constant.value.span); - self.with_parent(parent, |this| visit::walk_anon_const(this, constant)); + match constant.mgca_disambiguation { + MgcaDisambiguation::Direct => self.with_const_arg(ConstArgContext::Direct, |this| { + visit::walk_anon_const(this, constant); + }), + MgcaDisambiguation::AnonConst => { + self.with_const_arg(ConstArgContext::NonDirect, |this| { + let parent = + this.create_def(constant.id, None, DefKind::AnonConst, constant.value.span); + this.with_parent(parent, |this| visit::walk_anon_const(this, constant)); + }) + } + }; } + #[instrument(level = "debug", skip(self))] fn visit_expr(&mut self, expr: &'a Expr) { - let parent_def = match expr.kind { + debug!(?self.invocation_parent); + + let parent_def = match &expr.kind { ExprKind::MacCall(..) => return self.visit_macro_invoc(expr.id), ExprKind::Closure(..) | ExprKind::Gen(..) => { self.create_def(expr.id, None, DefKind::Closure, expr.span) } - ExprKind::ConstBlock(ref constant) => { - for attr in &expr.attrs { - visit::walk_attribute(self, attr); - } - let def = - self.create_def(constant.id, None, DefKind::InlineConst, constant.value.span); - self.with_parent(def, |this| visit::walk_anon_const(this, constant)); - return; + ExprKind::ConstBlock(constant) => { + // Under `min_generic_const_args` a `const { }` block sometimes + // corresponds to an anon const rather than an inline const. + let def_kind = match self.invocation_parent.const_arg_context { + ConstArgContext::Direct => DefKind::AnonConst, + ConstArgContext::NonDirect => DefKind::InlineConst, + }; + + return self.with_const_arg(ConstArgContext::NonDirect, |this| { + for attr in &expr.attrs { + visit::walk_attribute(this, attr); + } + + let def = this.create_def(constant.id, None, def_kind, constant.value.span); + this.with_parent(def, |this| visit::walk_anon_const(this, constant)); + }); } + + // Avoid overwriting `const_arg_context` as we may want to treat const blocks + // as being anon consts if we are inside a const argument. + ExprKind::Struct(_) => return visit::walk_expr(self, expr), + // FIXME(mgca): we may want to handle block labels in some manner + ExprKind::Block(block, _) if let [stmt] = block.stmts.as_slice() => match stmt.kind { + // FIXME(mgca): this probably means that mac calls that expand + // to semi'd const blocks are handled differently to just writing + // out a semi'd const block. + StmtKind::Expr(..) | StmtKind::MacCall(..) => return visit::walk_expr(self, expr), + + // Fallback to normal behaviour + StmtKind::Let(..) | StmtKind::Item(..) | StmtKind::Semi(..) | StmtKind::Empty => { + self.invocation_parent.parent_def + } + }, + _ => self.invocation_parent.parent_def, }; - self.with_parent(parent_def, |this| visit::walk_expr(this, expr)) + self.with_const_arg(ConstArgContext::NonDirect, |this| { + // Note in some cases the `parent_def` here may be the existing parent + // and this is actually a no-op `with_parent` call. + this.with_parent(parent_def, |this| visit::walk_expr(this, expr)) + }) } fn visit_ty(&mut self, ty: &'a Ty) { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index c981abe67c1f..57f19f7ea398 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -187,6 +187,7 @@ struct InvocationParent { parent_def: LocalDefId, impl_trait_context: ImplTraitContext, in_attr: bool, + const_arg_context: ConstArgContext, } impl InvocationParent { @@ -194,6 +195,7 @@ impl InvocationParent { parent_def: CRATE_DEF_ID, impl_trait_context: ImplTraitContext::Existential, in_attr: false, + const_arg_context: ConstArgContext::NonDirect, }; } @@ -204,6 +206,13 @@ enum ImplTraitContext { InBinding, } +#[derive(Copy, Clone, Debug)] +enum ConstArgContext { + Direct, + /// Either inside of an `AnonConst` or not inside a const argument at all. + NonDirect, +} + /// Used for tracking import use types which will be used for redundant import checking. /// /// ### Used::Scope Example diff --git a/tests/ui/const-generics/mgca/struct_expr_with_macros.rs b/tests/ui/const-generics/mgca/struct_expr_with_macros.rs new file mode 100644 index 000000000000..b59a73066488 --- /dev/null +++ b/tests/ui/const-generics/mgca/struct_expr_with_macros.rs @@ -0,0 +1,31 @@ +//@ check-pass + +// Test that the def collector makes `AnonConst`s not `InlineConst`s even +// when the const block is obscured via macros. + +#![feature(min_generic_const_args, adt_const_params)] +#![expect(incomplete_features)] + +macro_rules! const_block { + ($e:expr) => { const { + $e + } } +} + +macro_rules! foo_expr { + ($e:expr) => { Foo { + field: $e, + } } +} + +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] +struct Foo { field: u32 } + +fn foo() {} + +fn main() { + foo::<{ Foo { field: const_block!{ 1 + 1 }} }>(); + foo::<{ foo_expr! { const_block! { 1 + 1 }} }>(); +} From 6722805cdc9f0a73aaad56729383510047788320 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 19 Nov 2025 19:30:09 +0000 Subject: [PATCH 435/489] Make `ValTree` recurse through `ty::Const` --- .../src/intrinsics/simd.rs | 17 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 14 +- .../rustc_codegen_ssa/src/mir/constant.rs | 19 +-- .../rustc_codegen_ssa/src/mir/intrinsic.rs | 2 +- .../src/const_eval/valtrees.rs | 31 ++-- .../src/interpret/intrinsics/simd.rs | 12 +- compiler/rustc_middle/src/arena.rs | 2 +- compiler/rustc_middle/src/mir/consts.rs | 27 +-- compiler/rustc_middle/src/thir.rs | 8 +- compiler/rustc_middle/src/ty/consts.rs | 42 ++++- .../rustc_middle/src/ty/consts/valtree.rs | 157 +++++++++--------- compiler/rustc_middle/src/ty/context.rs | 5 +- compiler/rustc_middle/src/ty/mod.rs | 2 +- compiler/rustc_middle/src/ty/pattern.rs | 2 +- .../rustc_middle/src/ty/structural_impls.rs | 33 +++- .../src/builder/custom/parse/instruction.rs | 2 +- .../src/builder/matches/mod.rs | 15 +- .../src/builder/matches/test.rs | 2 +- compiler/rustc_mir_build/src/builder/scope.rs | 9 +- compiler/rustc_mir_build/src/thir/constant.rs | 2 +- .../src/thir/pattern/const_to_pat.rs | 28 ++-- compiler/rustc_pattern_analysis/src/rustc.rs | 20 +-- compiler/rustc_symbol_mangling/src/legacy.rs | 2 +- compiler/rustc_transmute/src/lib.rs | 9 +- compiler/rustc_ty_utils/src/consts.rs | 14 +- compiler/rustc_type_ir/src/const_kind.rs | 73 ++++++++ compiler/rustc_type_ir/src/flags.rs | 12 +- compiler/rustc_type_ir/src/inherent.rs | 6 + compiler/rustc_type_ir/src/interner.rs | 3 +- compiler/rustc_type_ir/src/relate.rs | 16 +- ...transmute_infinitely_recursive_type.stderr | 2 +- 31 files changed, 371 insertions(+), 217 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index 0bce31beb8b8..38e8d2fa9368 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -143,7 +143,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let total_len = lane_count * 2; - let indexes = idx.iter().map(|idx| idx.unwrap_leaf().to_u32()).collect::>(); + let indexes = idx.iter().map(|idx| idx.to_leaf().to_u32()).collect::>(); for &idx in &indexes { assert!(u64::from(idx) < total_len, "idx {} out of range 0..{}", idx, total_len); @@ -961,9 +961,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let lane_clif_ty = fx.clif_type(val_lane_ty).unwrap(); let ptr_val = ptr.load_scalar(fx); - let alignment = generic_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(); + let alignment = + generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); let memflags = match alignment { SimdAlign::Unaligned => MemFlags::new().with_notrap(), @@ -1006,9 +1005,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let lane_clif_ty = fx.clif_type(val_lane_ty).unwrap(); let ret_lane_layout = fx.layout_of(ret_lane_ty); - let alignment = generic_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(); + let alignment = + generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); let memflags = match alignment { SimdAlign::Unaligned => MemFlags::new().with_notrap(), @@ -1059,9 +1057,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let ret_lane_layout = fx.layout_of(ret_lane_ty); let ptr_val = ptr.load_scalar(fx); - let alignment = generic_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(); + let alignment = + generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); let memflags = match alignment { SimdAlign::Unaligned => MemFlags::new().with_notrap(), diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 3bc890310cc8..215738828c98 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -351,7 +351,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { _ => bug!(), }; let ptr = args[0].immediate(); - let locality = fn_args.const_at(1).to_value().valtree.unwrap_leaf().to_i32(); + let locality = fn_args.const_at(1).to_leaf().to_i32(); self.call_intrinsic( "llvm.prefetch", &[self.val_ty(ptr)], @@ -1533,7 +1533,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( } if name == sym::simd_shuffle_const_generic { - let idx = fn_args[2].expect_const().to_value().valtree.unwrap_branch(); + let idx = fn_args[2].expect_const().to_branch(); let n = idx.len() as u64; let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn); @@ -1552,7 +1552,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( .iter() .enumerate() .map(|(arg_idx, val)| { - let idx = val.unwrap_leaf().to_i32(); + let idx = val.to_leaf().to_i32(); if idx >= i32::try_from(total_len).unwrap() { bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds { span, @@ -1964,9 +1964,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( // those lanes whose `mask` bit is enabled. // The memory addresses corresponding to the “off” lanes are not accessed. - let alignment = fn_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(); + let alignment = fn_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); // The element type of the "mask" argument must be a signed integer type of any width let mask_ty = in_ty; @@ -2059,9 +2057,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( // those lanes whose `mask` bit is enabled. // The memory addresses corresponding to the “off” lanes are not accessed. - let alignment = fn_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(); + let alignment = fn_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); // The element type of the "mask" argument must be a signed integer type of any width let mask_ty = in_ty; diff --git a/compiler/rustc_codegen_ssa/src/mir/constant.rs b/compiler/rustc_codegen_ssa/src/mir/constant.rs index 11b6ab3cdf1a..abdac4c7c372 100644 --- a/compiler/rustc_codegen_ssa/src/mir/constant.rs +++ b/compiler/rustc_codegen_ssa/src/mir/constant.rs @@ -77,22 +77,21 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { .flatten() .map(|val| { // A SIMD type has a single field, which is an array. - let fields = val.unwrap_branch(); + let fields = val.to_branch(); assert_eq!(fields.len(), 1); - let array = fields[0].unwrap_branch(); + let array = fields[0].to_branch(); // Iterate over the array elements to obtain the values in the vector. let values: Vec<_> = array .iter() .map(|field| { - if let Some(prim) = field.try_to_scalar() { - let layout = bx.layout_of(field_ty); - let BackendRepr::Scalar(scalar) = layout.backend_repr else { - bug!("from_const: invalid ByVal layout: {:#?}", layout); - }; - bx.scalar_to_backend(prim, scalar, bx.immediate_backend_type(layout)) - } else { + let Some(prim) = field.try_to_scalar() else { bug!("field is not a scalar {:?}", field) - } + }; + let layout = bx.layout_of(field_ty); + let BackendRepr::Scalar(scalar) = layout.backend_repr else { + bug!("from_const: invalid ByVal layout: {:#?}", layout); + }; + bx.scalar_to_backend(prim, scalar, bx.immediate_backend_type(layout)) }) .collect(); bx.const_vector(&values) diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index aeb740118234..f4fae40d8828 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -102,7 +102,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; let parse_atomic_ordering = |ord: ty::Value<'tcx>| { - let discr = ord.valtree.unwrap_branch()[0].unwrap_leaf(); + let discr = ord.to_branch()[0].to_leaf(); discr.to_atomic_ordering() }; diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 7c41258ebfe5..b771addb8df5 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -36,13 +36,17 @@ fn branches<'tcx>( // For enums, we prepend their variant index before the variant's fields so we can figure out // the variant again when just seeing a valtree. if let Some(variant) = variant { - branches.push(ty::ValTree::from_scalar_int(*ecx.tcx, variant.as_u32().into())); + branches.push(ty::Const::new_value( + *ecx.tcx, + ty::ValTree::from_scalar_int(*ecx.tcx, variant.as_u32().into()), + ecx.tcx.types.u32, + )); } for i in 0..field_count { let field = ecx.project_field(&place, FieldIdx::from_usize(i)).unwrap(); let valtree = const_to_valtree_inner(ecx, &field, num_nodes)?; - branches.push(valtree); + branches.push(ty::Const::new_value(*ecx.tcx, valtree, field.layout.ty)); } // Have to account for ZSTs here @@ -65,7 +69,7 @@ fn slice_branches<'tcx>( for i in 0..n { let place_elem = ecx.project_index(place, i).unwrap(); let valtree = const_to_valtree_inner(ecx, &place_elem, num_nodes)?; - elems.push(valtree); + elems.push(ty::Const::new_value(*ecx.tcx, valtree, place_elem.layout.ty)); } Ok(ty::ValTree::from_branches(*ecx.tcx, elems)) @@ -200,8 +204,8 @@ fn reconstruct_place_meta<'tcx>( &ObligationCause::dummy(), |ty| ty, || { - let branches = last_valtree.unwrap_branch(); - last_valtree = *branches.last().unwrap(); + let branches = last_valtree.to_branch(); + last_valtree = branches.last().unwrap().to_value().valtree; debug!(?branches, ?last_valtree); }, ); @@ -212,7 +216,7 @@ fn reconstruct_place_meta<'tcx>( }; // Get the number of elements in the unsized field. - let num_elems = last_valtree.unwrap_branch().len(); + let num_elems = last_valtree.to_branch().len(); MemPlaceMeta::Meta(Scalar::from_target_usize(num_elems as u64, &tcx)) } @@ -274,7 +278,7 @@ pub fn valtree_to_const_value<'tcx>( mir::ConstValue::ZeroSized } ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char | ty::RawPtr(_, _) => { - mir::ConstValue::Scalar(Scalar::Int(cv.valtree.unwrap_leaf())) + mir::ConstValue::Scalar(Scalar::Int(cv.to_leaf())) } ty::Pat(ty, _) => { let cv = ty::Value { valtree: cv.valtree, ty }; @@ -301,12 +305,13 @@ pub fn valtree_to_const_value<'tcx>( || matches!(cv.ty.kind(), ty::Adt(def, _) if def.is_struct())) { // A Scalar tuple/struct; we can avoid creating an allocation. - let branches = cv.valtree.unwrap_branch(); + let branches = cv.to_branch(); // Find the non-ZST field. (There can be aligned ZST!) for (i, &inner_valtree) in branches.iter().enumerate() { let field = layout.field(&LayoutCx::new(tcx, typing_env), i); if !field.is_zst() { - let cv = ty::Value { valtree: inner_valtree, ty: field.ty }; + let cv = + ty::Value { valtree: inner_valtree.to_value().valtree, ty: field.ty }; return valtree_to_const_value(tcx, typing_env, cv); } } @@ -381,7 +386,7 @@ fn valtree_into_mplace<'tcx>( // Zero-sized type, nothing to do. } ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char | ty::RawPtr(..) => { - let scalar_int = valtree.unwrap_leaf(); + let scalar_int = valtree.to_leaf(); debug!("writing trivial valtree {:?} to place {:?}", scalar_int, place); ecx.write_immediate(Immediate::Scalar(scalar_int.into()), place).unwrap(); } @@ -391,13 +396,13 @@ fn valtree_into_mplace<'tcx>( ecx.write_immediate(imm, place).unwrap(); } ty::Adt(_, _) | ty::Tuple(_) | ty::Array(_, _) | ty::Str | ty::Slice(_) => { - let branches = valtree.unwrap_branch(); + let branches = valtree.to_branch(); // Need to downcast place for enums let (place_adjusted, branches, variant_idx) = match ty.kind() { ty::Adt(def, _) if def.is_enum() => { // First element of valtree corresponds to variant - let scalar_int = branches[0].unwrap_leaf(); + let scalar_int = branches[0].to_leaf(); let variant_idx = VariantIdx::from_u32(scalar_int.to_u32()); let variant = def.variant(variant_idx); debug!(?variant); @@ -425,7 +430,7 @@ fn valtree_into_mplace<'tcx>( }; debug!(?place_inner); - valtree_into_mplace(ecx, &place_inner, *inner_valtree); + valtree_into_mplace(ecx, &place_inner, inner_valtree.to_value().valtree); dump_place(ecx, &place_inner); } diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs index 20de47683122..33a115384a88 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs @@ -545,7 +545,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let (right, right_len) = self.project_to_simd(&args[1])?; let (dest, dest_len) = self.project_to_simd(&dest)?; - let index = generic_args[2].expect_const().to_value().valtree.unwrap_branch(); + let index = generic_args[2].expect_const().to_branch(); let index_len = index.len(); assert_eq!(left_len, right_len); @@ -553,7 +553,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { for i in 0..dest_len { let src_index: u64 = - index[usize::try_from(i).unwrap()].unwrap_leaf().to_u32().into(); + index[usize::try_from(i).unwrap()].to_leaf().to_u32().into(); let dest = self.project_index(&dest, i)?; let val = if src_index < left_len { @@ -657,9 +657,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.check_simd_ptr_alignment( ptr, dest_layout, - generic_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(), + generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(), )?; for i in 0..dest_len { @@ -689,9 +687,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.check_simd_ptr_alignment( ptr, args[2].layout, - generic_args[3].expect_const().to_value().valtree.unwrap_branch()[0] - .unwrap_leaf() - .to_simd_alignment(), + generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(), )?; for i in 0..vals_len { diff --git a/compiler/rustc_middle/src/arena.rs b/compiler/rustc_middle/src/arena.rs index d1d4c32184ee..4fa39eb83e9e 100644 --- a/compiler/rustc_middle/src/arena.rs +++ b/compiler/rustc_middle/src/arena.rs @@ -92,7 +92,7 @@ macro_rules! arena_types { [] name_set: rustc_data_structures::unord::UnordSet, [] autodiff_item: rustc_ast::expand::autodiff_attrs::AutoDiffItem, [] ordered_name_set: rustc_data_structures::fx::FxIndexSet, - [] valtree: rustc_middle::ty::ValTreeKind<'tcx>, + [] valtree: rustc_middle::ty::ValTreeKind>, [] stable_order_of_exportable_impls: rustc_data_structures::fx::FxIndexMap, diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index fe352df3b9f0..afe39e4481ef 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -302,15 +302,7 @@ impl<'tcx> Const<'tcx> { #[inline] pub fn try_to_scalar(self) -> Option { match self { - Const::Ty(_, c) => match c.kind() { - ty::ConstKind::Value(cv) if cv.ty.is_primitive() => { - // A valtree of a type where leaves directly represent the scalar const value. - // Just checking whether it is a leaf is insufficient as e.g. references are leafs - // but the leaf value is the value they point to, not the reference itself! - Some(cv.valtree.unwrap_leaf().into()) - } - _ => None, - }, + Const::Ty(_, c) => c.try_to_scalar(), Const::Val(val, _) => val.try_to_scalar(), Const::Unevaluated(..) => None, } @@ -321,10 +313,7 @@ impl<'tcx> Const<'tcx> { // This is equivalent to `self.try_to_scalar()?.try_to_int().ok()`, but measurably faster. match self { Const::Val(ConstValue::Scalar(Scalar::Int(x)), _) => Some(x), - Const::Ty(_, c) => match c.kind() { - ty::ConstKind::Value(cv) if cv.ty.is_primitive() => Some(cv.valtree.unwrap_leaf()), - _ => None, - }, + Const::Ty(_, c) => c.try_to_leaf(), _ => None, } } @@ -377,14 +366,10 @@ impl<'tcx> Const<'tcx> { tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, ) -> Option { - if let Const::Ty(_, c) = self - && let ty::ConstKind::Value(cv) = c.kind() - && cv.ty.is_primitive() - { - // Avoid the `valtree_to_const_val` query. Can only be done on primitive types that - // are valtree leaves, and *not* on references. (References should return the - // pointer here, which valtrees don't represent.) - Some(cv.valtree.unwrap_leaf().into()) + if let Const::Ty(_, c) = self { + // We don't evaluate anything for type system constants as normalizing + // the MIR will handle this for us + c.try_to_scalar() } else { self.eval(tcx, typing_env, DUMMY_SP).ok()?.try_to_scalar() } diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 3d893bf75e0b..31745cae3c06 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -928,7 +928,7 @@ impl<'tcx> PatRange<'tcx> { let lo_is_min = match self.lo { PatRangeBoundary::NegInfinity => true, PatRangeBoundary::Finite(value) => { - let lo = value.try_to_scalar_int().unwrap().to_bits(size) ^ bias; + let lo = value.to_leaf().to_bits(size) ^ bias; lo <= min } PatRangeBoundary::PosInfinity => false, @@ -937,7 +937,7 @@ impl<'tcx> PatRange<'tcx> { let hi_is_max = match self.hi { PatRangeBoundary::NegInfinity => false, PatRangeBoundary::Finite(value) => { - let hi = value.try_to_scalar_int().unwrap().to_bits(size) ^ bias; + let hi = value.to_leaf().to_bits(size) ^ bias; hi > max || hi == max && self.end == RangeEnd::Included } PatRangeBoundary::PosInfinity => true, @@ -1029,7 +1029,7 @@ impl<'tcx> PatRangeBoundary<'tcx> { } pub fn to_bits(self, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> u128 { match self { - Self::Finite(value) => value.try_to_scalar_int().unwrap().to_bits_unchecked(), + Self::Finite(value) => value.to_leaf().to_bits_unchecked(), Self::NegInfinity => { // Unwrap is ok because the type is known to be numeric. ty.numeric_min_and_max_as_bits(tcx).unwrap().0 @@ -1057,7 +1057,7 @@ impl<'tcx> PatRangeBoundary<'tcx> { // many ranges such as '\u{037A}'..='\u{037F}', and chars can be compared // in this way. (Finite(a), Finite(b)) if matches!(ty.kind(), ty::Int(_) | ty::Uint(_) | ty::Char) => { - if let (Some(a), Some(b)) = (a.try_to_scalar_int(), b.try_to_scalar_int()) { + if let (Some(a), Some(b)) = (a.try_to_leaf(), b.try_to_leaf()) { let sz = ty.primitive_size(tcx); let cmp = match ty.kind() { ty::Uint(_) | ty::Char => a.to_uint(sz).cmp(&b.to_uint(sz)), diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index 787ea5f9363d..da3caf0bb210 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -6,6 +6,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable}; use rustc_type_ir::walk::TypeWalker; use rustc_type_ir::{self as ir, TypeFlags, WithCachedTypeInfo}; +use crate::mir::interpret::Scalar; use crate::ty::{self, Ty, TyCtxt}; mod int; @@ -260,7 +261,7 @@ impl<'tcx> Const<'tcx> { /// Attempts to convert to a value. /// - /// Note that this does not evaluate the constant. + /// Note that this does not normalize the constant. pub fn try_to_value(self) -> Option> { match self.kind() { ty::ConstKind::Value(cv) => Some(cv), @@ -268,6 +269,45 @@ impl<'tcx> Const<'tcx> { } } + /// Converts to a `ValTreeKind::Leaf` value, `panic`'ing + /// if this constant is some other kind. + /// + /// Note that this does not normalize the constant. + #[inline] + pub fn to_leaf(self) -> ScalarInt { + self.to_value().to_leaf() + } + + /// Converts to a `ValTreeKind::Branch` value, `panic`'ing + /// if this constant is some other kind. + /// + /// Note that this does not normalize the constant. + #[inline] + pub fn to_branch(self) -> &'tcx [ty::Const<'tcx>] { + self.to_value().to_branch() + } + + /// Attempts to convert to a `ValTreeKind::Leaf` value. + /// + /// Note that this does not normalize the constant. + pub fn try_to_leaf(self) -> Option { + self.try_to_value()?.try_to_leaf() + } + + /// Attempts to convert to a `ValTreeKind::Leaf` value. + /// + /// Note that this does not normalize the constant. + pub fn try_to_scalar(self) -> Option { + self.try_to_leaf().map(Scalar::Int) + } + + /// Attempts to convert to a `ValTreeKind::Branch` value. + /// + /// Note that this does not normalize the constant. + pub fn try_to_branch(self) -> Option<&'tcx [ty::Const<'tcx>]> { + self.try_to_value()?.try_to_branch() + } + /// Convenience method to extract the value of a usize constant, /// useful to get the length of an array type. /// diff --git a/compiler/rustc_middle/src/ty/consts/valtree.rs b/compiler/rustc_middle/src/ty/consts/valtree.rs index a14e47d70821..8afee2dfe3bc 100644 --- a/compiler/rustc_middle/src/ty/consts/valtree.rs +++ b/compiler/rustc_middle/src/ty/consts/valtree.rs @@ -3,89 +3,38 @@ use std::ops::Deref; use rustc_data_structures::intern::Interned; use rustc_hir::def::Namespace; -use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; +use rustc_macros::{ + HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable, extension, +}; use super::ScalarInt; use crate::mir::interpret::{ErrorHandled, Scalar}; use crate::ty::print::{FmtPrinter, PrettyPrinter}; -use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::{self, Ty, TyCtxt, ValTreeKind}; -/// This datastructure is used to represent the value of constants used in the type system. -/// -/// We explicitly choose a different datastructure from the way values are processed within -/// CTFE, as in the type system equal values (according to their `PartialEq`) must also have -/// equal representation (`==` on the rustc data structure, e.g. `ValTree`) and vice versa. -/// Since CTFE uses `AllocId` to represent pointers, it often happens that two different -/// `AllocId`s point to equal values. So we may end up with different representations for -/// two constants whose value is `&42`. Furthermore any kind of struct that has padding will -/// have arbitrary values within that padding, even if the values of the struct are the same. -/// -/// `ValTree` does not have this problem with representation, as it only contains integers or -/// lists of (nested) `ValTree`. -#[derive(Clone, Debug, Hash, Eq, PartialEq)] -#[derive(HashStable, TyEncodable, TyDecodable)] -pub enum ValTreeKind<'tcx> { - /// integers, `bool`, `char` are represented as scalars. - /// See the `ScalarInt` documentation for how `ScalarInt` guarantees that equal values - /// of these types have the same representation. - Leaf(ScalarInt), - - //SliceOrStr(ValSlice<'tcx>), - // don't use SliceOrStr for now - /// The fields of any kind of aggregate. Structs, tuples and arrays are represented by - /// listing their fields' values in order. - /// - /// Enums are represented by storing their variant index as a u32 field, followed by all - /// the fields of the variant. - /// - /// ZST types are represented as an empty slice. - Branch(Box<[ValTree<'tcx>]>), -} - -impl<'tcx> ValTreeKind<'tcx> { - #[inline] - pub fn unwrap_leaf(&self) -> ScalarInt { - match self { - Self::Leaf(s) => *s, - _ => bug!("expected leaf, got {:?}", self), - } - } - - #[inline] - pub fn unwrap_branch(&self) -> &[ValTree<'tcx>] { - match self { - Self::Branch(branch) => &**branch, - _ => bug!("expected branch, got {:?}", self), - } - } - - pub fn try_to_scalar(&self) -> Option { - self.try_to_scalar_int().map(Scalar::Int) - } - - pub fn try_to_scalar_int(&self) -> Option { - match self { - Self::Leaf(s) => Some(*s), - Self::Branch(_) => None, - } - } - - pub fn try_to_branch(&self) -> Option<&[ValTree<'tcx>]> { - match self { - Self::Branch(branch) => Some(&**branch), - Self::Leaf(_) => None, - } +#[extension(pub trait ValTreeKindExt<'tcx>)] +impl<'tcx> ty::ValTreeKind> { + fn try_to_scalar(&self) -> Option { + self.try_to_leaf().map(Scalar::Int) } } /// An interned valtree. Use this rather than `ValTreeKind`, whenever possible. /// -/// See the docs of [`ValTreeKind`] or the [dev guide] for an explanation of this type. +/// See the docs of [`ty::ValTreeKind`] or the [dev guide] for an explanation of this type. /// /// [dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html#valtrees #[derive(Copy, Clone, Hash, Eq, PartialEq)] #[derive(HashStable)] -pub struct ValTree<'tcx>(pub(crate) Interned<'tcx, ValTreeKind<'tcx>>); +// FIXME(mgca): Try not interning here. We already intern `ty::Const` which `ValTreeKind` +// recurses through +pub struct ValTree<'tcx>(pub(crate) Interned<'tcx, ty::ValTreeKind>>); + +impl<'tcx> rustc_type_ir::inherent::ValTree> for ValTree<'tcx> { + fn kind(&self) -> &ty::ValTreeKind> { + &self + } +} impl<'tcx> ValTree<'tcx> { /// Returns the zero-sized valtree: `Branch([])`. @@ -94,28 +43,33 @@ impl<'tcx> ValTree<'tcx> { } pub fn is_zst(self) -> bool { - matches!(*self, ValTreeKind::Branch(box [])) + matches!(*self, ty::ValTreeKind::Branch(box [])) } pub fn from_raw_bytes(tcx: TyCtxt<'tcx>, bytes: &[u8]) -> Self { - let branches = bytes.iter().map(|&b| Self::from_scalar_int(tcx, b.into())); + let branches = bytes.iter().map(|&b| { + ty::Const::new_value(tcx, Self::from_scalar_int(tcx, b.into()), tcx.types.u8) + }); Self::from_branches(tcx, branches) } - pub fn from_branches(tcx: TyCtxt<'tcx>, branches: impl IntoIterator) -> Self { - tcx.intern_valtree(ValTreeKind::Branch(branches.into_iter().collect())) + pub fn from_branches( + tcx: TyCtxt<'tcx>, + branches: impl IntoIterator>, + ) -> Self { + tcx.intern_valtree(ty::ValTreeKind::Branch(branches.into_iter().collect())) } pub fn from_scalar_int(tcx: TyCtxt<'tcx>, i: ScalarInt) -> Self { - tcx.intern_valtree(ValTreeKind::Leaf(i)) + tcx.intern_valtree(ty::ValTreeKind::Leaf(i)) } } impl<'tcx> Deref for ValTree<'tcx> { - type Target = &'tcx ValTreeKind<'tcx>; + type Target = &'tcx ty::ValTreeKind>; #[inline] - fn deref(&self) -> &&'tcx ValTreeKind<'tcx> { + fn deref(&self) -> &&'tcx ty::ValTreeKind> { &self.0.0 } } @@ -154,7 +108,7 @@ impl<'tcx> Value<'tcx> { let (ty::Bool | ty::Char | ty::Uint(_) | ty::Int(_) | ty::Float(_)) = self.ty.kind() else { return None; }; - let scalar = self.valtree.try_to_scalar_int()?; + let scalar = self.try_to_leaf()?; let input = typing_env.with_post_analysis_normalized(tcx).as_query_input(self.ty); let size = tcx.layout_of(input).ok()?.size; Some(scalar.to_bits(size)) @@ -164,14 +118,14 @@ impl<'tcx> Value<'tcx> { if !self.ty.is_bool() { return None; } - self.valtree.try_to_scalar_int()?.try_to_bool().ok() + self.try_to_leaf()?.try_to_bool().ok() } pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option { if !self.ty.is_usize() { return None; } - self.valtree.try_to_scalar_int().map(|s| s.to_target_usize(tcx)) + self.try_to_leaf().map(|s| s.to_target_usize(tcx)) } /// Get the values inside the ValTree as a slice of bytes. This only works for @@ -192,9 +146,48 @@ impl<'tcx> Value<'tcx> { _ => return None, } - Some(tcx.arena.alloc_from_iter( - self.valtree.unwrap_branch().into_iter().map(|v| v.unwrap_leaf().to_u8()), - )) + Some(tcx.arena.alloc_from_iter(self.to_branch().into_iter().map(|ct| ct.to_leaf().to_u8()))) + } + + /// Converts to a `ValTreeKind::Leaf` value, `panic`'ing + /// if this constant is some other kind. + #[inline] + pub fn to_leaf(self) -> ScalarInt { + match &**self.valtree { + ValTreeKind::Leaf(s) => *s, + ValTreeKind::Branch(..) => bug!("expected leaf, got {:?}", self), + } + } + + /// Converts to a `ValTreeKind::Branch` value, `panic`'ing + /// if this constant is some other kind. + #[inline] + pub fn to_branch(self) -> &'tcx [ty::Const<'tcx>] { + match &**self.valtree { + ValTreeKind::Branch(branch) => &**branch, + ValTreeKind::Leaf(..) => bug!("expected branch, got {:?}", self), + } + } + + /// Attempts to convert to a `ValTreeKind::Leaf` value. + pub fn try_to_leaf(self) -> Option { + match &**self.valtree { + ValTreeKind::Leaf(s) => Some(*s), + ValTreeKind::Branch(_) => None, + } + } + + /// Attempts to convert to a `ValTreeKind::Leaf` value. + pub fn try_to_scalar(&self) -> Option { + self.try_to_leaf().map(Scalar::Int) + } + + /// Attempts to convert to a `ValTreeKind::Branch` value. + pub fn try_to_branch(self) -> Option<&'tcx [ty::Const<'tcx>]> { + match &**self.valtree { + ValTreeKind::Branch(branch) => Some(&**branch), + ValTreeKind::Leaf(_) => None, + } } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9e4692b96418..000e7c16098e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -165,6 +165,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> { type ValueConst = ty::Value<'tcx>; type ExprConst = ty::Expr<'tcx>; type ValTree = ty::ValTree<'tcx>; + type ScalarInt = ty::ScalarInt; type Region = Region<'tcx>; type EarlyParamRegion = ty::EarlyParamRegion; @@ -954,7 +955,7 @@ pub struct CtxtInterners<'tcx> { fields: InternedSet<'tcx, List>, local_def_ids: InternedSet<'tcx, List>, captures: InternedSet<'tcx, List<&'tcx ty::CapturedPlace<'tcx>>>, - valtree: InternedSet<'tcx, ty::ValTreeKind<'tcx>>, + valtree: InternedSet<'tcx, ty::ValTreeKind>>, patterns: InternedSet<'tcx, List>>, outlives: InternedSet<'tcx, List>>, } @@ -2777,7 +2778,7 @@ macro_rules! direct_interners { // crate only, and have a corresponding `mk_` function. direct_interners! { region: pub(crate) intern_region(RegionKind<'tcx>): Region -> Region<'tcx>, - valtree: pub(crate) intern_valtree(ValTreeKind<'tcx>): ValTree -> ValTree<'tcx>, + valtree: pub(crate) intern_valtree(ValTreeKind>): ValTree -> ValTree<'tcx>, pat: pub mk_pat(PatternKind<'tcx>): Pattern -> Pattern<'tcx>, const_allocation: pub mk_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>, layout: pub mk_layout(LayoutData): Layout -> Layout<'tcx>, diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 60b6b7024dcd..5cc5ab0d5268 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -77,7 +77,7 @@ pub use self::closure::{ }; pub use self::consts::{ AnonConstKind, AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult, Expr, - ExprKind, ScalarInt, SimdAlign, UnevaluatedConst, ValTree, ValTreeKind, Value, + ExprKind, ScalarInt, SimdAlign, UnevaluatedConst, ValTree, ValTreeKindExt, Value, }; pub use self::context::{ CtxtInterners, CurrentGcx, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls, diff --git a/compiler/rustc_middle/src/ty/pattern.rs b/compiler/rustc_middle/src/ty/pattern.rs index 335e5c064743..6acf0aff800f 100644 --- a/compiler/rustc_middle/src/ty/pattern.rs +++ b/compiler/rustc_middle/src/ty/pattern.rs @@ -72,7 +72,7 @@ impl<'tcx> IrPrint> for TyCtxt<'tcx> { write!(f, "{start}")?; if let Some(c) = end.try_to_value() { - let end = c.valtree.unwrap_leaf(); + let end = c.to_leaf(); let size = end.size(); let max = match c.ty.kind() { ty::Int(_) => { diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 5126d902a6d5..1a5a3f3965fa 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -256,8 +256,8 @@ TrivialTypeTraversalImpls! { crate::ty::AssocItem, crate::ty::AssocKind, crate::ty::BoundRegion, + crate::ty::ScalarInt, crate::ty::UserTypeAnnotationIndex, - crate::ty::ValTree<'tcx>, crate::ty::abstract_const::NotConstEvaluatable, crate::ty::adjustment::AutoBorrowMutability, crate::ty::adjustment::PointerCoercion, @@ -697,6 +697,37 @@ impl<'tcx> TypeSuperVisitable> for ty::Const<'tcx> { } } +impl<'tcx> TypeVisitable> for ty::ValTree<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> V::Result { + let inner: &ty::ValTreeKind> = &*self; + inner.visit_with(visitor) + } +} + +impl<'tcx> TypeFoldable> for ty::ValTree<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + let inner: &ty::ValTreeKind> = &*self; + let new_inner = inner.clone().try_fold_with(folder)?; + + if inner == &new_inner { + Ok(self) + } else { + let valtree = folder.cx().intern_valtree(new_inner); + Ok(valtree) + } + } + + fn fold_with>>(self, folder: &mut F) -> Self { + let inner: &ty::ValTreeKind> = &*self; + let new_inner = inner.clone().fold_with(folder); + + if inner == &new_inner { self } else { folder.cx().intern_valtree(new_inner) } + } +} + impl<'tcx> TypeVisitable> for rustc_span::ErrorGuaranteed { fn visit_with>>(&self, visitor: &mut V) -> V::Result { visitor.visit_error(*self) diff --git a/compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs index b221318bf0b1..ddaa61c6cc91 100644 --- a/compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs @@ -157,7 +157,7 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> { }); } }; - values.push(value.valtree.unwrap_leaf().to_bits_unchecked()); + values.push(value.to_leaf().to_bits_unchecked()); targets.push(self.parse_block(arm.body)?); } diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 8897ca7c7210..465b1db9a164 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -2935,7 +2935,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { bug!("malformed valtree for an enum") }; - let ValTreeKind::Leaf(actual_variant_idx) = ***actual_variant_idx else { + let ValTreeKind::Leaf(actual_variant_idx) = *actual_variant_idx.to_value().valtree + else { bug!("malformed valtree for an enum") }; @@ -2943,7 +2944,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } Constructor::IntRange(int_range) => { let size = pat.ty().primitive_size(self.tcx); - let actual_int = valtree.unwrap_leaf().to_bits(size); + let actual_int = valtree.to_leaf().to_bits(size); let actual_int = if pat.ty().is_signed() { MaybeInfiniteInt::new_finite_int(actual_int, size.bits()) } else { @@ -2951,33 +2952,33 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; IntRange::from_singleton(actual_int).is_subrange(int_range) } - Constructor::Bool(pattern_value) => match valtree.unwrap_leaf().try_to_bool() { + Constructor::Bool(pattern_value) => match valtree.to_leaf().try_to_bool() { Ok(actual_value) => *pattern_value == actual_value, Err(()) => bug!("bool value with invalid bits"), }, Constructor::F16Range(l, h, end) => { - let actual = valtree.unwrap_leaf().to_f16(); + let actual = valtree.to_leaf().to_f16(); match end { RangeEnd::Included => (*l..=*h).contains(&actual), RangeEnd::Excluded => (*l..*h).contains(&actual), } } Constructor::F32Range(l, h, end) => { - let actual = valtree.unwrap_leaf().to_f32(); + let actual = valtree.to_leaf().to_f32(); match end { RangeEnd::Included => (*l..=*h).contains(&actual), RangeEnd::Excluded => (*l..*h).contains(&actual), } } Constructor::F64Range(l, h, end) => { - let actual = valtree.unwrap_leaf().to_f64(); + let actual = valtree.to_leaf().to_f64(); match end { RangeEnd::Included => (*l..=*h).contains(&actual), RangeEnd::Excluded => (*l..*h).contains(&actual), } } Constructor::F128Range(l, h, end) => { - let actual = valtree.unwrap_leaf().to_f128(); + let actual = valtree.to_leaf().to_f128(); match end { RangeEnd::Included => (*l..=*h).contains(&actual), RangeEnd::Excluded => (*l..*h).contains(&actual), diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index 402587bff7e8..2401bc6648ed 100644 --- a/compiler/rustc_mir_build/src/builder/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -116,7 +116,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let switch_targets = SwitchTargets::new( target_blocks.iter().filter_map(|(&branch, &block)| { if let TestBranch::Constant(value) = branch { - let bits = value.valtree.unwrap_leaf().to_bits_unchecked(); + let bits = value.to_leaf().to_bits_unchecked(); Some((bits, block)) } else { None diff --git a/compiler/rustc_mir_build/src/builder/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index a176f3e49a50..981704052536 100644 --- a/compiler/rustc_mir_build/src/builder/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -897,7 +897,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.tcx, ValTree::from_branches( self.tcx, - [ValTree::from_scalar_int(self.tcx, variant_index.as_u32().into())], + [ty::Const::new_value( + self.tcx, + ValTree::from_scalar_int( + self.tcx, + variant_index.as_u32().into(), + ), + self.tcx.types.u32, + )], ), self.thir[value].ty, ), diff --git a/compiler/rustc_mir_build/src/thir/constant.rs b/compiler/rustc_mir_build/src/thir/constant.rs index 6e071fb344c4..563212a51f31 100644 --- a/compiler/rustc_mir_build/src/thir/constant.rs +++ b/compiler/rustc_mir_build/src/thir/constant.rs @@ -63,7 +63,7 @@ pub(crate) fn lit_to_const<'tcx>( // A CStr is a newtype around a byte slice, so we create the inner slice here. // We need a branch for each "level" of the data structure. let bytes = ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()); - ty::ValTree::from_branches(tcx, [bytes]) + ty::ValTree::from_branches(tcx, [ty::Const::new_value(tcx, bytes, *inner_ty)]) } (ast::LitKind::Int(n, _), ty::Uint(ui)) if !neg => { let scalar_int = trunc(n.get(), *ui); diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index c3c4c455b965..ce4c89a8eb2e 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -239,14 +239,14 @@ impl<'tcx> ConstToPat<'tcx> { return self.mk_err(tcx.dcx().create_err(err), ty); } ty::Adt(adt_def, args) if adt_def.is_enum() => { - let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap(); - let variant_index = VariantIdx::from_u32(variant_index.unwrap_leaf().to_u32()); + let (&variant_index, fields) = cv.to_branch().split_first().unwrap(); + let variant_index = VariantIdx::from_u32(variant_index.to_leaf().to_u32()); PatKind::Variant { adt_def: *adt_def, args, variant_index, subpatterns: self.field_pats( - fields.iter().copied().zip( + fields.iter().map(|ct| ct.to_value().valtree).zip( adt_def.variants()[variant_index] .fields .iter() @@ -258,28 +258,32 @@ impl<'tcx> ConstToPat<'tcx> { ty::Adt(def, args) => { assert!(!def.is_union()); // Valtree construction would never succeed for unions. PatKind::Leaf { - subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip( - def.non_enum_variant().fields.iter().map(|field| field.ty(tcx, args)), - )), + subpatterns: self.field_pats( + cv.to_branch().iter().map(|ct| ct.to_value().valtree).zip( + def.non_enum_variant().fields.iter().map(|field| field.ty(tcx, args)), + ), + ), } } ty::Tuple(fields) => PatKind::Leaf { - subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip(fields.iter())), + subpatterns: self.field_pats( + cv.to_branch().iter().map(|ct| ct.to_value().valtree).zip(fields.iter()), + ), }, ty::Slice(elem_ty) => PatKind::Slice { prefix: cv - .unwrap_branch() + .to_branch() .iter() - .map(|val| *self.valtree_to_pat(*val, *elem_ty)) + .map(|val| *self.valtree_to_pat(val.to_value().valtree, *elem_ty)) .collect(), slice: None, suffix: Box::new([]), }, ty::Array(elem_ty, _) => PatKind::Array { prefix: cv - .unwrap_branch() + .to_branch() .iter() - .map(|val| *self.valtree_to_pat(*val, *elem_ty)) + .map(|val| *self.valtree_to_pat(val.to_value().valtree, *elem_ty)) .collect(), slice: None, suffix: Box::new([]), @@ -312,7 +316,7 @@ impl<'tcx> ConstToPat<'tcx> { } }, ty::Float(flt) => { - let v = cv.unwrap_leaf(); + let v = cv.to_leaf(); let is_nan = match flt { ty::FloatTy::F16 => v.to_f16().is_nan(), ty::FloatTy::F32 => v.to_f32().is_nan(), diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index df86233c2b05..d66c303b1726 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -440,7 +440,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { match bdy { PatRangeBoundary::NegInfinity => MaybeInfiniteInt::NegInfinity, PatRangeBoundary::Finite(value) => { - let bits = value.try_to_scalar_int().unwrap().to_bits_unchecked(); + let bits = value.to_leaf().to_bits_unchecked(); match *ty.kind() { ty::Int(ity) => { let size = Integer::from_int_ty(&self.tcx, ity).size().bits(); @@ -540,7 +540,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Char | ty::Int(_) | ty::Uint(_) => { ctor = { - let bits = value.valtree.unwrap_leaf().to_bits_unchecked(); + let bits = value.to_leaf().to_bits_unchecked(); let x = match *ty.kind() { ty::Int(ity) => { let size = Integer::from_int_ty(&cx.tcx, ity).size().bits(); @@ -555,7 +555,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Float(ty::FloatTy::F16) => { use rustc_apfloat::Float; - let bits = value.valtree.unwrap_leaf().to_u16(); + let bits = value.to_leaf().to_u16(); let value = rustc_apfloat::ieee::Half::from_bits(bits.into()); ctor = F16Range(value, value, RangeEnd::Included); fields = vec![]; @@ -563,7 +563,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Float(ty::FloatTy::F32) => { use rustc_apfloat::Float; - let bits = value.valtree.unwrap_leaf().to_u32(); + let bits = value.to_leaf().to_u32(); let value = rustc_apfloat::ieee::Single::from_bits(bits.into()); ctor = F32Range(value, value, RangeEnd::Included); fields = vec![]; @@ -571,7 +571,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Float(ty::FloatTy::F64) => { use rustc_apfloat::Float; - let bits = value.valtree.unwrap_leaf().to_u64(); + let bits = value.to_leaf().to_u64(); let value = rustc_apfloat::ieee::Double::from_bits(bits.into()); ctor = F64Range(value, value, RangeEnd::Included); fields = vec![]; @@ -579,7 +579,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Float(ty::FloatTy::F128) => { use rustc_apfloat::Float; - let bits = value.valtree.unwrap_leaf().to_u128(); + let bits = value.to_leaf().to_u128(); let value = rustc_apfloat::ieee::Quad::from_bits(bits); ctor = F128Range(value, value, RangeEnd::Included); fields = vec![]; @@ -623,12 +623,8 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { } ty::Float(fty) => { use rustc_apfloat::Float; - let lo = lo - .as_finite() - .map(|c| c.try_to_scalar_int().unwrap().to_bits_unchecked()); - let hi = hi - .as_finite() - .map(|c| c.try_to_scalar_int().unwrap().to_bits_unchecked()); + let lo = lo.as_finite().map(|c| c.to_leaf().to_bits_unchecked()); + let hi = hi.as_finite().map(|c| c.to_leaf().to_bits_unchecked()); match fty { ty::FloatTy::F16 => { use rustc_apfloat::ieee::Half; diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index ee2621af8428..ea16231880e2 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -293,7 +293,7 @@ impl<'tcx> Printer<'tcx> for LegacySymbolMangler<'tcx> { ty::ConstKind::Value(cv) if cv.ty.is_integral() => { // The `pretty_print_const` formatting depends on -Zverbose-internals // flag, so we cannot reuse it here. - let scalar = cv.valtree.unwrap_leaf(); + let scalar = cv.to_leaf(); let signed = matches!(cv.ty.kind(), ty::Int(_)); write!( self, diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 36281ff16bce..58cb2eb6556e 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -129,10 +129,7 @@ mod rustc { use rustc_middle::ty::ScalarInt; use rustc_span::sym; - let Some(cv) = ct.try_to_value() else { - return None; - }; - + let cv = ct.try_to_value()?; let adt_def = cv.ty.ty_adt_def()?; if !tcx.is_lang_item(adt_def.did(), LangItem::TransmuteOpts) { @@ -149,7 +146,7 @@ mod rustc { } let variant = adt_def.non_enum_variant(); - let fields = cv.valtree.unwrap_branch(); + let fields = cv.to_branch(); let get_field = |name| { let (field_idx, _) = variant @@ -158,7 +155,7 @@ mod rustc { .enumerate() .find(|(_, field_def)| name == field_def.name) .unwrap_or_else(|| panic!("There were no fields named `{name}`.")); - fields[field_idx].unwrap_leaf() == ScalarInt::TRUE + fields[field_idx].to_leaf() == ScalarInt::TRUE }; Some(Self { diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 4b19d0f16d78..d8d5b7fc75cc 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -25,15 +25,14 @@ fn destructure_const<'tcx>( let ty::ConstKind::Value(cv) = const_.kind() else { bug!("cannot destructure constant {:?}", const_) }; - - let branches = cv.valtree.unwrap_branch(); + let branches = cv.to_branch(); let (fields, variant) = match cv.ty.kind() { ty::Array(inner_ty, _) | ty::Slice(inner_ty) => { // construct the consts for the elements of the array/slice let field_consts = branches .iter() - .map(|b| ty::Const::new_value(tcx, *b, *inner_ty)) + .map(|b| ty::Const::new_value(tcx, b.to_value().valtree, *inner_ty)) .collect::>(); debug!(?field_consts); @@ -43,7 +42,7 @@ fn destructure_const<'tcx>( ty::Adt(def, args) => { let (variant_idx, branches) = if def.is_enum() { let (head, rest) = branches.split_first().unwrap(); - (VariantIdx::from_u32(head.unwrap_leaf().to_u32()), rest) + (VariantIdx::from_u32(head.to_leaf().to_u32()), rest) } else { (FIRST_VARIANT, branches) }; @@ -52,7 +51,8 @@ fn destructure_const<'tcx>( for (field, field_valtree) in iter::zip(fields, branches) { let field_ty = field.ty(tcx, args); - let field_const = ty::Const::new_value(tcx, *field_valtree, field_ty); + let field_const = + ty::Const::new_value(tcx, field_valtree.to_value().valtree, field_ty); field_consts.push(field_const); } debug!(?field_consts); @@ -61,7 +61,9 @@ fn destructure_const<'tcx>( } ty::Tuple(elem_tys) => { let fields = iter::zip(*elem_tys, branches) - .map(|(elem_ty, elem_valtree)| ty::Const::new_value(tcx, *elem_valtree, elem_ty)) + .map(|(elem_ty, elem_valtree)| { + ty::Const::new_value(tcx, elem_valtree.to_value().valtree, elem_ty) + }) .collect::>(); (fields, None) diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index f315e8b3e11c..a5c40d4eb199 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -127,3 +127,76 @@ impl HashStable for InferConst { } } } + +/// This datastructure is used to represent the value of constants used in the type system. +/// +/// We explicitly choose a different datastructure from the way values are processed within +/// CTFE, as in the type system equal values (according to their `PartialEq`) must also have +/// equal representation (`==` on the rustc data structure, e.g. `ValTree`) and vice versa. +/// Since CTFE uses `AllocId` to represent pointers, it often happens that two different +/// `AllocId`s point to equal values. So we may end up with different representations for +/// two constants whose value is `&42`. Furthermore any kind of struct that has padding will +/// have arbitrary values within that padding, even if the values of the struct are the same. +/// +/// `ValTree` does not have this problem with representation, as it only contains integers or +/// lists of (nested) `ty::Const`s (which may indirectly contain more `ValTree`s). +#[derive_where(Clone, Debug, Hash, Eq, PartialEq; I: Interner)] +#[derive(TypeVisitable_Generic, TypeFoldable_Generic)] +#[cfg_attr( + feature = "nightly", + derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext) +)] +pub enum ValTreeKind { + /// integers, `bool`, `char` are represented as scalars. + /// See the `ScalarInt` documentation for how `ScalarInt` guarantees that equal values + /// of these types have the same representation. + Leaf(I::ScalarInt), + + /// The fields of any kind of aggregate. Structs, tuples and arrays are represented by + /// listing their fields' values in order. + /// + /// Enums are represented by storing their variant index as a u32 field, followed by all + /// the fields of the variant. + /// + /// ZST types are represented as an empty slice. + // FIXME(mgca): Use a `List` here instead of a boxed slice + Branch(Box<[I::Const]>), +} + +impl ValTreeKind { + /// Converts to a `ValTreeKind::Leaf` value, `panic`'ing + /// if this valtree is some other kind. + #[inline] + pub fn to_leaf(&self) -> I::ScalarInt { + match self { + ValTreeKind::Leaf(s) => *s, + ValTreeKind::Branch(..) => panic!("expected leaf, got {:?}", self), + } + } + + /// Converts to a `ValTreeKind::Branch` value, `panic`'ing + /// if this valtree is some other kind. + #[inline] + pub fn to_branch(&self) -> &[I::Const] { + match self { + ValTreeKind::Branch(branch) => &**branch, + ValTreeKind::Leaf(..) => panic!("expected branch, got {:?}", self), + } + } + + /// Attempts to convert to a `ValTreeKind::Leaf` value. + pub fn try_to_leaf(&self) -> Option { + match self { + ValTreeKind::Leaf(s) => Some(*s), + ValTreeKind::Branch(_) => None, + } + } + + /// Attempts to convert to a `ValTreeKind::Branch` value. + pub fn try_to_branch(&self) -> Option<&[I::Const]> { + match self { + ValTreeKind::Branch(branch) => Some(&**branch), + ValTreeKind::Leaf(_) => None, + } + } +} diff --git a/compiler/rustc_type_ir/src/flags.rs b/compiler/rustc_type_ir/src/flags.rs index 34b030ee768b..2c1fc7decc3e 100644 --- a/compiler/rustc_type_ir/src/flags.rs +++ b/compiler/rustc_type_ir/src/flags.rs @@ -477,7 +477,17 @@ impl FlagComputation { ty::ConstKind::Placeholder(_) => { self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER); } - ty::ConstKind::Value(cv) => self.add_ty(cv.ty()), + ty::ConstKind::Value(cv) => { + self.add_ty(cv.ty()); + match cv.valtree().kind() { + ty::ValTreeKind::Leaf(_) => (), + ty::ValTreeKind::Branch(cts) => { + for ct in cts { + self.add_const(*ct); + } + } + } + } ty::ConstKind::Expr(e) => self.add_args(e.args().as_slice()), ty::ConstKind::Error(_) => self.add_flags(TypeFlags::HAS_ERROR), } diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index 75ba0231d98c..16f837141e97 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -292,6 +292,12 @@ pub trait ValueConst>: Copy + Debug + Hash + Eq { fn valtree(self) -> I::ValTree; } +// FIXME(mgca): This trait can be removed once we're not using a `Box` in `Branch` +pub trait ValTree>: Copy + Debug + Hash + Eq { + // This isnt' `IntoKind` because then we can't return a reference + fn kind(&self) -> &ty::ValTreeKind; +} + pub trait ExprConst>: Copy + Debug + Hash + Eq + Relate { fn args(self) -> I::GenericArgs; } diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 3884f29a4fc8..03cf738c0598 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -153,7 +153,8 @@ pub trait Interner: type PlaceholderConst: PlaceholderConst; type ValueConst: ValueConst; type ExprConst: ExprConst; - type ValTree: Copy + Debug + Hash + Eq; + type ValTree: ValTree; + type ScalarInt: Copy + Debug + Hash + Eq; // Kinds of regions type Region: Region; diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index 4f843503d1af..4954ebc51cfc 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -582,13 +582,27 @@ pub fn structurally_relate_consts>( } (ty::ConstKind::Placeholder(p1), ty::ConstKind::Placeholder(p2)) => p1 == p2, (ty::ConstKind::Value(a_val), ty::ConstKind::Value(b_val)) => { - a_val.valtree() == b_val.valtree() + match (a_val.valtree().kind(), b_val.valtree().kind()) { + (ty::ValTreeKind::Leaf(scalar_a), ty::ValTreeKind::Leaf(scalar_b)) => { + scalar_a == scalar_b + } + (ty::ValTreeKind::Branch(branches_a), ty::ValTreeKind::Branch(branches_b)) + if branches_a.len() == branches_b.len() => + { + branches_a + .into_iter() + .zip(branches_b) + .all(|(a, b)| relation.relate(*a, *b).is_ok()) + } + _ => false, + } } // While this is slightly incorrect, it shouldn't matter for `min_const_generics` // and is the better alternative to waiting until `generic_const_exprs` can // be stabilized. (ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => { + // FIXME(mgca): remove this if cfg!(debug_assertions) { let a_ty = cx.type_of(au.def.into()).instantiate(cx, au.args); let b_ty = cx.type_of(bu.def.into()).instantiate(cx, bu.args); diff --git a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr index 1a0563b469c1..a96876a2c25a 100644 --- a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr +++ b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr @@ -12,7 +12,7 @@ LL | struct ExplicitlyPadded(Box); 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::TransmuteFrom` + = note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::TransmuteFrom` = 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 From 484480412e7779d364a4d28be0f4ca6c50d9492b Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 19 Nov 2025 19:31:11 +0000 Subject: [PATCH 436/489] Lower `hir::ConstArgKind::Struct` to a `ValTree` --- .../src/hir_ty_lowering/mod.rs | 134 +++++++++++++++--- tests/crashes/127972.rs | 6 - tests/crashes/137888.rs | 11 -- tests/crashes/140275.rs | 5 - .../mgca/adt_expr_arg_simple.rs | 38 +++++ .../mgca/adt_expr_arg_simple.stderr | 14 ++ .../mgca/adt_expr_erroneuous_inits.rs | 26 ++++ .../mgca/adt_expr_erroneuous_inits.stderr | 49 +++++++ .../mgca/adt_expr_fields_type_check.rs | 17 +++ .../mgca/adt_expr_infers_from_value.rs | 45 ++++++ .../mgca/explicit_anon_consts-2.rs | 10 ++ .../mgca/explicit_anon_consts-2.stderr | 8 ++ .../mgca/explicit_anon_consts-3.rs | 10 ++ .../mgca/explicit_anon_consts-3.stderr | 8 ++ .../mgca/explicit_anon_consts-4.rs | 9 ++ .../mgca/explicit_anon_consts-4.stderr | 8 ++ .../mgca/explicit_anon_consts-5.rs | 16 +++ .../mgca/explicit_anon_consts-5.stderr | 8 ++ .../mgca/explicit_anon_consts-6.rs | 8 ++ .../mgca/explicit_anon_consts-6.stderr | 8 ++ .../mgca/explicit_anon_consts.rs | 25 ++-- .../mgca/explicit_anon_consts.stderr | 54 ++----- .../explicit_anon_consts_literals_hack.rs | 18 ++- .../explicit_anon_consts_literals_hack.stderr | 8 ++ .../mgca/type_const-on-generic-expr.rs | 24 ---- .../mgca/type_const-on-generic-expr.stderr | 30 +--- .../mgca/type_const-on-generic_expr-2.rs | 27 ++++ .../mgca/type_const-on-generic_expr-2.stderr | 20 +++ .../bad_const_generics_args_on_const_param.rs | 15 -- ..._const_generics_args_on_const_param.stderr | 21 --- 30 files changed, 491 insertions(+), 189 deletions(-) delete mode 100644 tests/crashes/127972.rs delete mode 100644 tests/crashes/137888.rs delete mode 100644 tests/crashes/140275.rs create mode 100644 tests/ui/const-generics/mgca/adt_expr_arg_simple.rs create mode 100644 tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr create mode 100644 tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs create mode 100644 tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr create mode 100644 tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs create mode 100644 tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-2.rs create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-2.stderr create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-3.rs create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-3.stderr create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-4.rs create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-4.stderr create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-5.rs create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-5.stderr create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-6.rs create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts-6.stderr create mode 100644 tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.stderr create mode 100644 tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs create mode 100644 tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr delete mode 100644 tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs delete mode 100644 tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 3c1200c812bc..23110d2c5c87 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2263,15 +2263,120 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ) .unwrap_or_else(|guar| Const::new_error(tcx, guar)) } - hir::ConstArgKind::Struct(..) => { - span_bug!(const_arg.span(), "lowering `{:?}` is not yet implemented", const_arg) + hir::ConstArgKind::Struct(qpath, inits) => { + self.lower_const_arg_struct(hir_id, qpath, inits, const_arg.span()) } - hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon), + hir::ConstArgKind::Anon(anon) => self.lower_const_arg_anon(anon), hir::ConstArgKind::Infer(span, ()) => self.ct_infer(None, span), hir::ConstArgKind::Error(_, e) => ty::Const::new_error(tcx, e), } } + fn lower_const_arg_struct( + &self, + hir_id: HirId, + qpath: hir::QPath<'tcx>, + inits: &'tcx [&'tcx hir::ConstArgExprField<'tcx>], + span: Span, + ) -> Const<'tcx> { + // FIXME(mgca): try to deduplicate this function with + // the equivalent HIR typeck logic. + let tcx = self.tcx(); + + let non_adt_or_variant_res = || { + let e = tcx.dcx().span_err(span, "struct expression with invalid base path"); + ty::Const::new_error(tcx, e) + }; + + let (ty, variant_did) = match qpath { + hir::QPath::Resolved(maybe_qself, path) => { + debug!(?maybe_qself, ?path); + let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself)); + let ty = + self.lower_resolved_ty_path(opt_self_ty, path, hir_id, PermitVariants::Yes); + let variant_did = match path.res { + Res::Def(DefKind::Variant | DefKind::Struct, did) => did, + _ => return non_adt_or_variant_res(), + }; + + (ty, variant_did) + } + hir::QPath::TypeRelative(hir_self_ty, segment) => { + debug!(?hir_self_ty, ?segment); + let self_ty = self.lower_ty(hir_self_ty); + let opt_res = self.lower_type_relative_ty_path( + self_ty, + hir_self_ty, + segment, + hir_id, + span, + PermitVariants::Yes, + ); + + let (ty, _, res_def_id) = match opt_res { + Ok(r @ (_, DefKind::Variant | DefKind::Struct, _)) => r, + Ok(_) => return non_adt_or_variant_res(), + Err(e) => return ty::Const::new_error(tcx, e), + }; + + (ty, res_def_id) + } + }; + + let ty::Adt(adt_def, adt_args) = ty.kind() else { unreachable!() }; + + let variant_def = adt_def.variant_with_id(variant_did); + let variant_idx = adt_def.variant_index_with_id(variant_did).as_u32(); + + let fields = variant_def + .fields + .iter() + .map(|field_def| { + // FIXME(mgca): we aren't really handling privacy, stability, + // or macro hygeniene but we should. + let mut init_expr = + inits.iter().filter(|init_expr| init_expr.field.name == field_def.name); + + match init_expr.next() { + Some(expr) => { + if let Some(expr) = init_expr.next() { + let e = tcx.dcx().span_err( + expr.span, + format!( + "struct expression with multiple initialisers for `{}`", + field_def.name, + ), + ); + return ty::Const::new_error(tcx, e); + } + + self.lower_const_arg(expr.expr, FeedConstTy::Param(field_def.did, adt_args)) + } + None => { + let e = tcx.dcx().span_err( + span, + format!( + "struct expression with missing field initialiser for `{}`", + field_def.name + ), + ); + ty::Const::new_error(tcx, e) + } + } + }) + .collect::>(); + + let opt_discr_const = if adt_def.is_enum() { + let valtree = ty::ValTree::from_scalar_int(tcx, variant_idx.into()); + Some(ty::Const::new_value(tcx, valtree, tcx.types.u32)) + } else { + None + }; + + let valtree = ty::ValTree::from_branches(tcx, opt_discr_const.into_iter().chain(fields)); + ty::Const::new_value(tcx, valtree, ty) + } + /// Lower a [resolved][hir::QPath::Resolved] path to a (type-level) constant. fn lower_resolved_const_path( &self, @@ -2375,22 +2480,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { /// Literals are eagerly converted to a constant, everything else becomes `Unevaluated`. #[instrument(skip(self), level = "debug")] - fn lower_anon_const(&self, anon: &AnonConst) -> Const<'tcx> { + fn lower_const_arg_anon(&self, anon: &AnonConst) -> Const<'tcx> { let tcx = self.tcx(); let expr = &tcx.hir_body(anon.body).value; debug!(?expr); - // If the rhs is an anon const naming generics it shouldn't have - // access to then we lower to `ConstKind::Error`. This prevents - // `try_lower_anon_const_lit` from ICEing on anon consts such as - // `const { N }` which aren't supposed to be legal. - if let ty::AnonConstKind::MCG = tcx.anon_const_kind(anon.def_id) - && let Err(e) = tcx.check_anon_const_invalid_param_uses(anon.def_id) - { - return ty::Const::new_error(tcx, e); - } - // FIXME(generic_const_parameter_types): We should use the proper generic args // here. It's only used as a hint for literals so doesn't matter too much to use the right // generic arguments, just weaker type inference. @@ -2416,8 +2511,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ) -> Option> { let tcx = self.tcx(); - // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments - // currently have to be wrapped in curly brackets, so it's necessary to special-case. + // Unwrap a block, so that e.g. `{ 1 }` is recognised as a literal. This makes the + // performance optimisation of directly lowering anon consts occur more often. let expr = match &expr.kind { hir::ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() => { block.expr.as_ref().unwrap() @@ -2425,15 +2520,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { _ => expr, }; + // FIXME(mgca): remove this delayed bug once we start checking this + // when lowering `Ty/ConstKind::Param`s more generally. if let hir::ExprKind::Path(hir::QPath::Resolved( _, &hir::Path { res: Res::Def(DefKind::ConstParam, _), .. }, )) = expr.kind { - span_bug!( + let e = tcx.dcx().span_delayed_bug( expr.span, - "try_lower_anon_const_lit: received const param which shouldn't be possible" + "try_lower_anon_const_lit: received const param which shouldn't be possible", ); + return Some(ty::Const::new_error(tcx, e)); }; let lit_input = match expr.kind { diff --git a/tests/crashes/127972.rs b/tests/crashes/127972.rs deleted file mode 100644 index 797dd7e60209..000000000000 --- a/tests/crashes/127972.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ known-bug: #127962 -#![feature(generic_const_exprs, const_arg_path)] - -fn zero_init() -> Substs1<{ (N) }> { - Substs1([0; { (usize) }]) -} diff --git a/tests/crashes/137888.rs b/tests/crashes/137888.rs deleted file mode 100644 index 6c13ae5fa916..000000000000 --- a/tests/crashes/137888.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #137888 -#![feature(generic_const_exprs)] -macro_rules! empty { - () => (); -} -fn bar() -> [(); { - empty! {}; - N - }] { -} -fn main() {} diff --git a/tests/crashes/140275.rs b/tests/crashes/140275.rs deleted file mode 100644 index 5ea04af0c8e0..000000000000 --- a/tests/crashes/140275.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ known-bug: #140275 -#![feature(generic_const_exprs)] -trait T{} -trait V{} -impl T for [i32; N::<&mut V>] {} diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs new file mode 100644 index 000000000000..ffb763da325c --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs @@ -0,0 +1,38 @@ +#![feature(min_generic_const_args, adt_const_params)] +#![expect(incomplete_features)] + +#[derive(Eq, PartialEq, std::marker::ConstParamTy)] +enum Option { + Some(T), + None, +} +use Option::Some; + +fn foo>() {} + +trait Trait { + #[type_const] + const ASSOC: usize; +} + +fn bar() { + // the initializer of `_0` is a `N` which is a legal const argument + // so this is ok. + foo::<{ Some:: { 0: N } }>(); + + // this is allowed as mgca supports uses of assoc consts in the + // type system. ie `::ASSOC` is a legal const argument + foo::<{ Some:: { 0: ::ASSOC } }>(); + + // this on the other hand is not allowed as `N + 1` is not a legal + // const argument + foo::<{ Some:: { 0: N + 1 } }>(); + //~^ ERROR: complex const arguments must be placed inside of a `const` block + + // this also is not allowed as generic parameters cannot be used + // in anon const const args + foo::<{ Some:: { 0: const { N + 1 } } }>(); + //~^ ERROR: generic parameters may not be used in const operations +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr b/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr new file mode 100644 index 000000000000..8b9c228c1ee5 --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr @@ -0,0 +1,14 @@ +error: complex const arguments must be placed inside of a `const` block + --> $DIR/adt_expr_arg_simple.rs:29:30 + | +LL | foo::<{ Some:: { 0: N + 1 } }>(); + | ^^^^^ + +error: generic parameters may not be used in const operations + --> $DIR/adt_expr_arg_simple.rs:34:38 + | +LL | foo::<{ Some:: { 0: const { N + 1 } } }>(); + | ^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs new file mode 100644 index 000000000000..752844e4328f --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs @@ -0,0 +1,26 @@ +#![feature(min_generic_const_args, adt_const_params)] +#![expect(incomplete_features)] +#![crate_type = "lib"] + +// Miscellaneous assortment of invalid cases of directly represented +// `ConstArgKind::Struct`'s under mgca. + +#[derive(Eq, PartialEq, std::marker::ConstParamTy)] +struct Foo { field: T } + +fn NonStruct() {} + +fn accepts>() {} + +fn bar() { + accepts::<{ Foo:: { }}>(); + //~^ ERROR: struct expression with missing field initialiser for `field` + accepts::<{ Foo:: { field: const { 1 }, field: const { 2} }}>(); + //~^ ERROR: struct expression with multiple initialisers for `field` + accepts::<{ Fooo:: { field: const { 1 } }}>(); + //~^ ERROR: cannot find struct, variant or union type `Fooo` in this scope + //~| ERROR: struct expression with invalid base path + accepts::<{ NonStruct { }}>(); + //~^ ERROR: expected struct, variant or union type, found function `NonStruct` + //~| ERROR: struct expression with invalid base path +} diff --git a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr new file mode 100644 index 000000000000..49d3f67003dc --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr @@ -0,0 +1,49 @@ +error[E0422]: cannot find struct, variant or union type `Fooo` in this scope + --> $DIR/adt_expr_erroneuous_inits.rs:20:17 + | +LL | struct Foo { field: T } + | ------------- similarly named struct `Foo` defined here +... +LL | accepts::<{ Fooo:: { field: const { 1 } }}>(); + | ^^^^ + | +help: a struct with a similar name exists + | +LL - accepts::<{ Fooo:: { field: const { 1 } }}>(); +LL + accepts::<{ Foo:: { field: const { 1 } }}>(); + | + +error[E0574]: expected struct, variant or union type, found function `NonStruct` + --> $DIR/adt_expr_erroneuous_inits.rs:23:17 + | +LL | accepts::<{ NonStruct { }}>(); + | ^^^^^^^^^ not a struct, variant or union type + +error: struct expression with missing field initialiser for `field` + --> $DIR/adt_expr_erroneuous_inits.rs:16:17 + | +LL | accepts::<{ Foo:: { }}>(); + | ^^^^^^^^^ + +error: struct expression with multiple initialisers for `field` + --> $DIR/adt_expr_erroneuous_inits.rs:18:49 + | +LL | accepts::<{ Foo:: { field: const { 1 }, field: const { 2} }}>(); + | ^^^^^^^^^^^^^^^^^ + +error: struct expression with invalid base path + --> $DIR/adt_expr_erroneuous_inits.rs:20:17 + | +LL | accepts::<{ Fooo:: { field: const { 1 } }}>(); + | ^^^^^^^^^^ + +error: struct expression with invalid base path + --> $DIR/adt_expr_erroneuous_inits.rs:23:17 + | +LL | accepts::<{ NonStruct { }}>(); + | ^^^^^^^^^ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0422, E0574. +For more information about an error, try `rustc --explain E0422`. diff --git a/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs b/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs new file mode 100644 index 000000000000..eafc8382966b --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_fields_type_check.rs @@ -0,0 +1,17 @@ +//@ check-pass +// FIXME(mgca): This should error + +#![feature(min_generic_const_args, adt_const_params)] +#![expect(incomplete_features)] + +#[derive(Eq, PartialEq, std::marker::ConstParamTy)] +struct Foo { field: T } + +fn accepts>() {} + +fn bar() { + // `N` is not of type `u8` but we don't actually check this anywhere yet + accepts::<{ Foo:: { field: N }}>(); +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs new file mode 100644 index 000000000000..d3c9b655a9e5 --- /dev/null +++ b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs @@ -0,0 +1,45 @@ +//@ check-pass + +#![feature( + generic_const_items, + min_generic_const_args, + adt_const_params, + generic_const_parameter_types, + unsized_const_params, +)] +#![expect(incomplete_features)] + +use std::marker::{PhantomData, ConstParamTy, ConstParamTy_}; + +#[derive(PartialEq, Eq, ConstParamTy)] +struct Foo { + field: T, +} + +#[type_const] +const WRAP: Foo = { Foo:: { + field: N, +} }; + +fn main() { + // What we're trying to accomplish here is winding up with an equality relation + // between two `ty::Const` that looks something like: + // + // ``` + // Foo { field: const { 1 + 2 } } + // eq + // Foo { field: ?x } + // ``` + // + // Note that the `field: _` here means a const argument `_` not a wildcard pattern. + // This tests that we are able to infer `?x=3` even though the first `ty::Const` + // may be a fully evaluated constant, and the latter is not fully evaluatable due + // to inference variables. + let _: PC<_, { WRAP:: }> + = PC::<_, { Foo:: { field: _ }}>; +} + +// "PhantomConst" helper equivalent to "PhantomData" used for testing equalities +// of arbitrarily typed const arguments. +struct PC { _0: PhantomData } +const PC: PC = PC { _0: PhantomData:: }; diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-2.rs b/tests/ui/const-generics/mgca/explicit_anon_consts-2.rs new file mode 100644 index 000000000000..37a3321a291e --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-2.rs @@ -0,0 +1,10 @@ +#![feature(associated_const_equality, generic_const_items, min_generic_const_args)] +#![expect(incomplete_features)] +// library crates exercise weirder code paths around +// DefIds which were created for const args. +#![crate_type = "lib"] + +struct Foo; + +type Alias = Foo; +//~^ ERROR: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-2.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts-2.stderr new file mode 100644 index 000000000000..8d8abd9ef313 --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-2.stderr @@ -0,0 +1,8 @@ +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts-2.rs:9:42 + | +LL | type Alias = Foo; + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-3.rs b/tests/ui/const-generics/mgca/explicit_anon_consts-3.rs new file mode 100644 index 000000000000..ad7ae7c511ff --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-3.rs @@ -0,0 +1,10 @@ +#![feature(associated_const_equality, generic_const_items, min_generic_const_args)] +#![expect(incomplete_features)] +// library crates exercise weirder code paths around +// DefIds which were created for const args. +#![crate_type = "lib"] + +struct Foo; + +type Alias = [(); const { N }]; +//~^ ERROR: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-3.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts-3.stderr new file mode 100644 index 000000000000..fe2c40486aeb --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-3.stderr @@ -0,0 +1,8 @@ +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts-3.rs:9:43 + | +LL | type Alias = [(); const { N }]; + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-4.rs b/tests/ui/const-generics/mgca/explicit_anon_consts-4.rs new file mode 100644 index 000000000000..bcf34bdb13ee --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-4.rs @@ -0,0 +1,9 @@ +#![feature(associated_const_equality, generic_const_items, min_generic_const_args)] +#![expect(incomplete_features)] +// library crates exercise weirder code paths around +// DefIds which were created for const args. +#![crate_type = "lib"] + +#[type_const] +const ITEM3: usize = const { N }; +//~^ ERROR: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-4.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts-4.stderr new file mode 100644 index 000000000000..7fc78257aa2c --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-4.stderr @@ -0,0 +1,8 @@ +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts-4.rs:8:46 + | +LL | const ITEM3: usize = const { N }; + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-5.rs b/tests/ui/const-generics/mgca/explicit_anon_consts-5.rs new file mode 100644 index 000000000000..aa14ec4275e4 --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-5.rs @@ -0,0 +1,16 @@ +#![feature(associated_const_equality, generic_const_items, min_generic_const_args)] +#![expect(incomplete_features)] +// library crates exercise weirder code paths around +// DefIds which were created for const args. +#![crate_type = "lib"] + +trait Trait { + #[type_const] + const ASSOC: usize; +} + +fn ace_bounds< + const N: usize, + T: Trait, + //~^ ERROR: generic parameters may not be used in const operations +>() {} diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-5.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts-5.stderr new file mode 100644 index 000000000000..6d2ab078c8cf --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-5.stderr @@ -0,0 +1,8 @@ +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts-5.rs:14:30 + | +LL | T: Trait, + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-6.rs b/tests/ui/const-generics/mgca/explicit_anon_consts-6.rs new file mode 100644 index 000000000000..600f4b9cd7f9 --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-6.rs @@ -0,0 +1,8 @@ +#![feature(associated_const_equality, generic_const_items, min_generic_const_args)] +#![expect(incomplete_features)] +// library crates exercise weirder code paths around +// DefIds which were created for const args. +#![crate_type = "lib"] + +struct Default3; +//~^ ERROR: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts-6.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts-6.stderr new file mode 100644 index 000000000000..727e478bee8e --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts-6.stderr @@ -0,0 +1,8 @@ +error: generic parameters may not be used in const operations + --> $DIR/explicit_anon_consts-6.rs:7:58 + | +LL | struct Default3; + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.rs b/tests/ui/const-generics/mgca/explicit_anon_consts.rs index ef17222ebc91..f7df3eddfa64 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.rs +++ b/tests/ui/const-generics/mgca/explicit_anon_consts.rs @@ -4,21 +4,22 @@ // DefIds which were created for const args. #![crate_type = "lib"] +// FIXME(mgca): merge the split out parts of this test back in + struct Foo; type Adt1 = Foo; type Adt2 = Foo<{ N }>; -type Adt3 = Foo; -//~^ ERROR: generic parameters may not be used in const operations -//~^^ ERROR generic parameters may not be used in const operations +// explicit_anon_consts-2.rs +// type Adt3 = Foo; type Adt4 = Foo<{ 1 + 1 }>; //~^ ERROR: complex const arguments must be placed inside of a `const` block type Adt5 = Foo; type Arr = [(); N]; type Arr2 = [(); { N }]; -type Arr3 = [(); const { N }]; -//~^ ERROR: generic parameters may not be used in const operations +// explicit_anon_consts-3.rs +// type Arr3 = [(); const { N }]; type Arr4 = [(); 1 + 1]; //~^ ERROR: complex const arguments must be placed inside of a `const` block type Arr5 = [(); const { 1 + 1 }]; @@ -37,9 +38,9 @@ fn repeats() { const ITEM1: usize = N; #[type_const] const ITEM2: usize = { N }; -#[type_const] -const ITEM3: usize = const { N }; -//~^ ERROR: generic parameters may not be used in const operations +// explicit_anon_consts-4.rs +// #[type_const] +// const ITEM3: usize = const { N }; #[type_const] const ITEM4: usize = { 1 + 1 }; //~^ ERROR: complex const arguments must be placed inside of a `const` block @@ -56,8 +57,8 @@ fn ace_bounds< // We skip the T1 case because it doesn't resolve // T1: Trait, T2: Trait, - T3: Trait, - //~^ ERROR: generic parameters may not be used in const operations + // explicit_anon_consts-5.rs + // T3: Trait, T4: Trait, //~^ ERROR: complex const arguments must be placed inside of a `const` block T5: Trait, @@ -65,8 +66,8 @@ fn ace_bounds< struct Default1; struct Default2; -struct Default3; -//~^ ERROR: generic parameters may not be used in const operations +// explicit_anon_consts-6.rs +// struct Default3; struct Default4; //~^ ERROR: complex const arguments must be placed inside of a `const` block struct Default5; diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr index eb200aae3396..1605dd8069d0 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr +++ b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr @@ -1,82 +1,44 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:14:33 + --> $DIR/explicit_anon_consts.rs:15:33 | LL | type Adt4 = Foo<{ 1 + 1 }>; | ^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:22:34 + --> $DIR/explicit_anon_consts.rs:23:34 | LL | type Arr4 = [(); 1 + 1]; | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:31:19 + --> $DIR/explicit_anon_consts.rs:32:19 | LL | let _4 = [(); 1 + 1]; | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:44:38 + --> $DIR/explicit_anon_consts.rs:45:38 | LL | const ITEM4: usize = { 1 + 1 }; | ^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:61:23 + --> $DIR/explicit_anon_consts.rs:62:23 | LL | T4: Trait, | ^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:70:50 + --> $DIR/explicit_anon_consts.rs:71:50 | LL | struct Default4; | ^^^^^^^^^ error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:11:41 - | -LL | type Adt3 = Foo; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:20:42 - | -LL | type Arr3 = [(); const { N }]; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:41:46 - | -LL | const ITEM3: usize = const { N }; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:59:31 - | -LL | T3: Trait, - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:68:58 - | -LL | struct Default3; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:29:27 + --> $DIR/explicit_anon_consts.rs:30:27 | LL | let _3 = [(); const { N }]; | ^ -error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:11:41 - | -LL | type Adt3 = Foo; - | ^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 13 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs b/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs index 979d10331a59..8c8c5c8e8f88 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs +++ b/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs @@ -1,9 +1,10 @@ -//@ check-pass - // We allow for literals to implicitly be anon consts still regardless // of whether a const block is placed around them or not +// +// However, we don't allow so for const arguments in field init positions. +// This is just harder to implement so we did not do so. -#![feature(min_generic_const_args, associated_const_equality)] +#![feature(min_generic_const_args, adt_const_params, associated_const_equality)] #![expect(incomplete_features)] trait Trait { @@ -19,4 +20,15 @@ type ArrLen = [(); 1]; struct Foo; type NormalArg = (Foo<1>, Foo<-1>); +#[derive(Eq, PartialEq, std::marker::ConstParamTy)] +struct ADT { field: u8 } + +fn struct_expr() { + fn takes_n() {} + + takes_n::<{ ADT { field: 1 } }>(); + //~^ ERROR: complex const arguments must be placed inside of a `const` block + takes_n::<{ ADT { field: const { 1 } } }>(); +} + fn main() {} diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.stderr new file mode 100644 index 000000000000..02647fd808cc --- /dev/null +++ b/tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.stderr @@ -0,0 +1,8 @@ +error: complex const arguments must be placed inside of a `const` block + --> $DIR/explicit_anon_consts_literals_hack.rs:29:30 + | +LL | takes_n::<{ ADT { field: 1 } }>(); + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs index a1008fae9d16..ac4c4fb59419 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs @@ -4,32 +4,8 @@ #[type_const] const FREE1: usize = const { std::mem::size_of::() }; //~^ ERROR generic parameters may not be used in const operations -//~^^ ERROR generic parameters may not be used in const operations #[type_const] const FREE2: usize = const { I + 1 }; //~^ ERROR generic parameters may not be used in const operations -pub trait Tr { - #[type_const] - const N1: usize; - #[type_const] - const N2: usize; - #[type_const] - const N3: usize; -} - -pub struct S; - -impl Tr for S { - #[type_const] - const N1: usize = const { std::mem::size_of::() }; - //~^ ERROR generic parameters may not be used in const operations - #[type_const] - const N2: usize = const { I + 1 }; - //~^ ERROR generic parameters may not be used in const operations - #[type_const] - const N3: usize = const { 2 & X }; - //~^ ERROR generic parameters may not be used in const operations -} - fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr index c77be158d0ef..f339e82beeed 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr @@ -5,36 +5,10 @@ LL | const FREE1: usize = const { std::mem::size_of::() }; | ^ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:9:46 + --> $DIR/type_const-on-generic-expr.rs:8:46 | LL | const FREE2: usize = const { I + 1 }; | ^ -error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:25:54 - | -LL | const N1: usize = const { std::mem::size_of::() }; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:28:47 - | -LL | const N2: usize = const { I + 1 }; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:31:35 - | -LL | const N3: usize = const { 2 & X }; - | ^ - -error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:5:53 - | -LL | const FREE1: usize = const { std::mem::size_of::() }; - | ^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs new file mode 100644 index 000000000000..37de4d4a4abb --- /dev/null +++ b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs @@ -0,0 +1,27 @@ +#![expect(incomplete_features)] +#![feature(min_generic_const_args, generic_const_items)] + +pub trait Tr { + #[type_const] + const N1: usize; + #[type_const] + const N2: usize; + #[type_const] + const N3: usize; +} + +pub struct S; + +impl Tr for S { + #[type_const] + const N1: usize = const { std::mem::size_of::() }; + //~^ ERROR generic parameters may not be used in const operations + #[type_const] + const N2: usize = const { I + 1 }; + //~^ ERROR generic parameters may not be used in const operations + #[type_const] + const N3: usize = const { 2 & X }; + //~^ ERROR generic parameters may not be used in const operations +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr new file mode 100644 index 000000000000..9d4e99ca0aaf --- /dev/null +++ b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr @@ -0,0 +1,20 @@ +error: generic parameters may not be used in const operations + --> $DIR/type_const-on-generic_expr-2.rs:17:54 + | +LL | const N1: usize = const { std::mem::size_of::() }; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/type_const-on-generic_expr-2.rs:20:47 + | +LL | const N2: usize = const { I + 1 }; + | ^ + +error: generic parameters may not be used in const operations + --> $DIR/type_const-on-generic_expr-2.rs:23:35 + | +LL | const N3: usize = const { 2 & X }; + | ^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs deleted file mode 100644 index 29f193a4d7f3..000000000000 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@known-bug: #127972 -//@ failure-status: 101 -//@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" -//@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" -//@ rustc-env:RUST_BACKTRACE=0 - -#![feature(pattern_types, pattern_type_macro, generic_const_exprs)] -#![allow(internal_features)] - -type Pat = - std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); - -fn main() {} diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr deleted file mode 100644 index d053d8aed062..000000000000 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad_const_generics_args_on_const_param.rs:9:47 - | -LL | #![feature(pattern_types, pattern_type_macro, generic_const_exprs)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #76560 for more information - = error: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:LL:CC: try_lower_anon_const_lit: received const param which shouldn't be possible - --> $DIR/bad_const_generics_args_on_const_param.rs:13:36 - | -LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); - | ^^^^^^^^^^^^^^^^^^^ - - -Box -query stack during panic: -#0 [type_of] expanding type alias `Pat` -#1 [check_well_formed] checking that `Pat` is well-formed -... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack -error: aborting due to 1 previous error; 1 warning emitted - From 79fd535473f9a2025ee5d09ce9465969da90ae33 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 19 Nov 2025 23:28:50 +0000 Subject: [PATCH 437/489] Fix tools --- .../src/intrinsics/simd.rs | 2 +- src/librustdoc/clean/mod.rs | 6 +++++- src/librustdoc/clean/utils.rs | 2 +- .../clippy/clippy_lints/src/utils/author.rs | 1 + src/tools/clippy/clippy_utils/src/consts.rs | 2 +- .../clippy/clippy_utils/src/hir_utils.rs | 21 +++++++++++++++---- src/tools/miri/src/intrinsics/atomic.rs | 2 +- 7 files changed, 27 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index 38e8d2fa9368..15aef60c5af3 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -130,7 +130,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( return; } - let idx = generic_args[2].expect_const().to_value().valtree.unwrap_branch(); + let idx = generic_args[2].expect_const().to_branch(); assert_eq!(x.layout(), y.layout()); let layout = x.layout(); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 764b3a0acdb6..707b48b355ba 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -319,6 +319,10 @@ pub(crate) fn clean_const<'tcx>(constant: &hir::ConstArg<'tcx>) -> ConstantKind hir::ConstArgKind::Path(qpath) => { ConstantKind::Path { path: qpath_to_string(qpath).into() } } + hir::ConstArgKind::Struct(..) => { + // FIXME(mgca): proper printing :3 + ConstantKind::Path { path: "/* STRUCT EXPR */".to_string().into() } + } hir::ConstArgKind::Anon(anon) => ConstantKind::Anonymous { body: anon.body }, hir::ConstArgKind::Infer(..) | hir::ConstArgKind::Error(..) => ConstantKind::Infer, } @@ -1800,7 +1804,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T let ct = cx.tcx.normalize_erasing_regions(typing_env, ct); print_const(cx, ct) } - hir::ConstArgKind::Path(..) => { + hir::ConstArgKind::Struct(..) | hir::ConstArgKind::Path(..) => { let ct = lower_const_arg_for_rustdoc(cx.tcx, const_arg, FeedConstTy::No); print_const(cx, ct) } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 4c3f26701bab..0f75a332ad6b 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -357,7 +357,7 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String { } // array lengths are obviously usize ty::ConstKind::Value(cv) if *cv.ty.kind() == ty::Uint(ty::UintTy::Usize) => { - cv.valtree.unwrap_leaf().to_string() + cv.to_leaf().to_string() } _ => n.to_string(), } diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index 03cbb0311c6c..685b0a9c0d60 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -319,6 +319,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { chain!(self, "let ConstArgKind::Anon({anon_const}) = {const_arg}.kind"); self.body(field!(anon_const.body)); }, + ConstArgKind::Struct(..) => chain!(self, "let ConstArgKind::Struct(..) = {const_arg}.kind"), ConstArgKind::Infer(..) => chain!(self, "let ConstArgKind::Infer(..) = {const_arg}.kind"), ConstArgKind::Error(..) => chain!(self, "let ConstArgKind::Error(..) = {const_arg}.kind"), } diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index 7e3fa4f9909b..e43b0b95d9f7 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -1139,7 +1139,7 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx ConstItemRhs::Body(body_id) => Some(tcx.hir_body(body_id).value), ConstItemRhs::TypeConst(const_arg) => match const_arg.kind { ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value), - ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) => None, + ConstArgKind::Struct(..) | ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) => None, }, } } diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index c6d82c0e63fa..5cadf5fbb869 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -477,11 +477,18 @@ impl HirEqInterExpr<'_, '_, '_> { (ConstArgKind::Path(l_p), ConstArgKind::Path(r_p)) => self.eq_qpath(l_p, r_p), (ConstArgKind::Anon(l_an), ConstArgKind::Anon(r_an)) => self.eq_body(l_an.body, r_an.body), (ConstArgKind::Infer(..), ConstArgKind::Infer(..)) => true, + (ConstArgKind::Struct(path_a, inits_a), ConstArgKind::Struct(path_b, inits_b)) => { + self.eq_qpath(path_a, path_b) + && inits_a.iter().zip(*inits_b).all(|(init_a, init_b)| { + self.eq_const_arg(init_a.expr, init_b.expr) + }) + } // Use explicit match for now since ConstArg is undergoing flux. - (ConstArgKind::Path(..), ConstArgKind::Anon(..)) - | (ConstArgKind::Anon(..), ConstArgKind::Path(..)) - | (ConstArgKind::Infer(..) | ConstArgKind::Error(..), _) - | (_, ConstArgKind::Infer(..) | ConstArgKind::Error(..)) => false, + (ConstArgKind::Path(..), _) + | (ConstArgKind::Anon(..), _) + | (ConstArgKind::Infer(..), _) + | (ConstArgKind::Struct(..), _) + | (ConstArgKind::Error(..), _) => false, } } @@ -1332,6 +1339,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { match &const_arg.kind { ConstArgKind::Path(path) => self.hash_qpath(path), ConstArgKind::Anon(anon) => self.hash_body(anon.body), + ConstArgKind::Struct(path, inits) => { + self.hash_qpath(path); + for init in *inits { + self.hash_const_arg(init.expr); + } + } ConstArgKind::Infer(..) | ConstArgKind::Error(..) => {}, } } diff --git a/src/tools/miri/src/intrinsics/atomic.rs b/src/tools/miri/src/intrinsics/atomic.rs index 9bb0ab70de23..481b6716c70c 100644 --- a/src/tools/miri/src/intrinsics/atomic.rs +++ b/src/tools/miri/src/intrinsics/atomic.rs @@ -31,7 +31,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let get_ord_at = |i: usize| { let ordering = generic_args.const_at(i).to_value(); - ordering.valtree.unwrap_branch()[0].unwrap_leaf().to_atomic_ordering() + ordering.to_branch()[0].to_value().to_leaf().to_atomic_ordering() }; fn read_ord(ord: AtomicOrdering) -> AtomicReadOrd { From 7a3097f18d704f46572166daedf20c25a237a4c5 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Wed, 19 Nov 2025 23:28:50 +0000 Subject: [PATCH 438/489] Fix tools --- clippy_lints/src/utils/author.rs | 1 + clippy_utils/src/consts.rs | 2 +- clippy_utils/src/hir_utils.rs | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 03cbb0311c6c..685b0a9c0d60 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -319,6 +319,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { chain!(self, "let ConstArgKind::Anon({anon_const}) = {const_arg}.kind"); self.body(field!(anon_const.body)); }, + ConstArgKind::Struct(..) => chain!(self, "let ConstArgKind::Struct(..) = {const_arg}.kind"), ConstArgKind::Infer(..) => chain!(self, "let ConstArgKind::Infer(..) = {const_arg}.kind"), ConstArgKind::Error(..) => chain!(self, "let ConstArgKind::Error(..) = {const_arg}.kind"), } diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 7e3fa4f9909b..e43b0b95d9f7 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -1139,7 +1139,7 @@ pub fn const_item_rhs_to_expr<'tcx>(tcx: TyCtxt<'tcx>, ct_rhs: ConstItemRhs<'tcx ConstItemRhs::Body(body_id) => Some(tcx.hir_body(body_id).value), ConstItemRhs::TypeConst(const_arg) => match const_arg.kind { ConstArgKind::Anon(anon) => Some(tcx.hir_body(anon.body).value), - ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) => None, + ConstArgKind::Struct(..) | ConstArgKind::Path(_) | ConstArgKind::Error(..) | ConstArgKind::Infer(..) => None, }, } } diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index c6d82c0e63fa..5cadf5fbb869 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -477,11 +477,18 @@ impl HirEqInterExpr<'_, '_, '_> { (ConstArgKind::Path(l_p), ConstArgKind::Path(r_p)) => self.eq_qpath(l_p, r_p), (ConstArgKind::Anon(l_an), ConstArgKind::Anon(r_an)) => self.eq_body(l_an.body, r_an.body), (ConstArgKind::Infer(..), ConstArgKind::Infer(..)) => true, + (ConstArgKind::Struct(path_a, inits_a), ConstArgKind::Struct(path_b, inits_b)) => { + self.eq_qpath(path_a, path_b) + && inits_a.iter().zip(*inits_b).all(|(init_a, init_b)| { + self.eq_const_arg(init_a.expr, init_b.expr) + }) + } // Use explicit match for now since ConstArg is undergoing flux. - (ConstArgKind::Path(..), ConstArgKind::Anon(..)) - | (ConstArgKind::Anon(..), ConstArgKind::Path(..)) - | (ConstArgKind::Infer(..) | ConstArgKind::Error(..), _) - | (_, ConstArgKind::Infer(..) | ConstArgKind::Error(..)) => false, + (ConstArgKind::Path(..), _) + | (ConstArgKind::Anon(..), _) + | (ConstArgKind::Infer(..), _) + | (ConstArgKind::Struct(..), _) + | (ConstArgKind::Error(..), _) => false, } } @@ -1332,6 +1339,12 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { match &const_arg.kind { ConstArgKind::Path(path) => self.hash_qpath(path), ConstArgKind::Anon(anon) => self.hash_body(anon.body), + ConstArgKind::Struct(path, inits) => { + self.hash_qpath(path); + for init in *inits { + self.hash_const_arg(init.expr); + } + } ConstArgKind::Infer(..) | ConstArgKind::Error(..) => {}, } } From bbf4ec3b0fd31a813208791dcce4264ed6bdbae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Dec 2025 15:47:03 +0100 Subject: [PATCH 439/489] Add support for `automation/bors/auto` merge branch --- .github/workflows/ci.yml | 7 ++++--- src/ci/citool/src/main.rs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05aa600e649e..bb6bc325a3bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ on: - try - try-perf - automation/bors/try + - automation/bors/auto pull_request: branches: - "**" @@ -56,7 +57,7 @@ jobs: - name: Test citool # Only test citool on the auto branch, to reduce latency of the calculate matrix job # on PR/try builds. - if: ${{ github.ref == 'refs/heads/auto' }} + if: ${{ github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto' }} run: | cd src/ci/citool CARGO_INCREMENTAL=0 cargo test @@ -79,7 +80,7 @@ jobs: # access the environment. # # We only enable the environment for the rust-lang/rust repository, so that CI works on forks. - environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }} + environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }} env: CI_JOB_NAME: ${{ matrix.name }} CI_JOB_DOC_URL: ${{ matrix.doc_url }} @@ -313,7 +314,7 @@ jobs: needs: [ calculate_matrix, job ] # !cancelled() executes the job regardless of whether the previous jobs passed or failed if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }} - environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }} + environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/auto' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }} steps: - name: checkout the source code uses: actions/checkout@v5 diff --git a/src/ci/citool/src/main.rs b/src/ci/citool/src/main.rs index 4fe9cee900ca..d7b491d38f41 100644 --- a/src/ci/citool/src/main.rs +++ b/src/ci/citool/src/main.rs @@ -46,7 +46,9 @@ impl GitHubContext { let patterns = if !patterns.is_empty() { Some(patterns) } else { None }; Some(RunType::TryJob { job_patterns: patterns }) } - ("push", "refs/heads/auto") => Some(RunType::AutoJob), + ("push", "refs/heads/auto" | "refs/heads/automation/bors/auto") => { + Some(RunType::AutoJob) + } ("push", "refs/heads/main") => Some(RunType::MainJob), _ => None, } From c252af5cbbe576acf5ffefa44687c8cf27a5c294 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:30:38 +0000 Subject: [PATCH 440/489] Fix audit workflow --- .github/workflows/audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 27c95572ef87..274b9504beb0 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - sed -i 's/components.*/components = []/' rust-toolchain + sed -i 's/components.*/components = []/' rust-toolchain.toml - uses: rustsec/audit-check@v1.4.1 with: token: ${{ secrets.GITHUB_TOKEN }} From 6bb3a40d535634d9004db49d639d900ecf66fc7f Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 8 Dec 2025 10:48:27 +0000 Subject: [PATCH 441/489] Update to Cranelift 0.127 --- Cargo.lock | 173 ++++++++++++++++------------------------------------- Cargo.toml | 24 ++++---- 2 files changed, 63 insertions(+), 134 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 617c7f0e34cd..3d13b5540e19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,42 +43,42 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cranelift-assembler-x64" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7631e609c97f063f9777aae405e8492abf9bf92336d7aa3f875403dd4ffd7d" +checksum = "8bd963a645179fa33834ba61fa63353998543b07f877e208da9eb47d4a70d1e7" dependencies = [ "cranelift-assembler-x64-meta", ] [[package]] name = "cranelift-assembler-x64-meta" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c030edccdc4a5bbf28fbfe7701b5cd1f9854b4445184dd34af2a7e8f8db6f45" +checksum = "3f6d5739c9dc6b5553ca758d78d87d127dd19f397f776efecf817b8ba8d0bb01" dependencies = [ "cranelift-srcgen", ] [[package]] name = "cranelift-bforest" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb544c1242d0ca98baf01873ebba96c79d5df155d5108d9bb699aefc741f5e6d" +checksum = "ff402c11bb1c9652b67a3e885e84b1b8d00c13472c8fd85211e06a41a63c3e03" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0325aecbafec053d3d3f082edfdca7937e2945e7f09c5ff9672e05198312282" +checksum = "769a0d88c2f5539e9c5536a93a7bf164b0dc68d91e3d00723e5b4ffc1440afdc" [[package]] name = "cranelift-codegen" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb3236fd319ae897ba00c8a25105081de5c1348576def0e96c062ad259f87a7" +checksum = "d4351f721fb3b26add1c180f0a75c7474bab2f903c8b777c6ca65238ded59a78" dependencies = [ "bumpalo", "cranelift-assembler-x64", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b8791c911a361c539130ace34fb726b16aca4216470ec75d75264b1495c8a3a" +checksum = "61f86c0ba5b96713643f4dd0de0df12844de9c7bb137d6829b174b706939aa74" dependencies = [ "cranelift-assembler-x64-meta", "cranelift-codegen-shared", @@ -114,33 +114,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ead718c2a10990870c19b2497b5a04b8aae6024485e33da25b5d02e35819e0" +checksum = "f08605eee8d51fd976a970bd5b16c9529b51b624f8af68f80649ffb172eb85a4" [[package]] name = "cranelift-control" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0a57fc972b5651047efddccb99440d103d9d8c13393ccebde15ddd5b6a1181b" +checksum = "623aab0a09e40f0cf0b5d35eb7832bae4c4f13e3768228e051a6c1a60e88ef5f" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aae980b4a1678b601eab2f52e372ed0b3c9565a31c17f380008cb97b3a699c5" +checksum = "ea0f066e07e3bcbe38884cc5c94c32c7a90267d69df80f187d9dfe421adaa7c4" dependencies = [ "cranelift-bitset", ] [[package]] name = "cranelift-frontend" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78877016b607982ca1708c0dd4ce23bde04581a39854c9b43a1dca43625b54c" +checksum = "40865b02a0e52ca8e580ad64feef530cb1d05f6bb4972b4eef05e3eaeae81701" dependencies = [ "cranelift-codegen", "log", @@ -150,15 +150,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc46a68b46d4f53f9f2f02ab8d3a34b00f03a21c124a7a965b8cbf5fdb6773b" +checksum = "104b3c117ae513e9af1d90679842101193a5ccb96ac9f997966d85ea25be2852" [[package]] name = "cranelift-jit" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df920009af919ad9df52eb7b47b1895145822e0c29da9b715a876fc8ecc6d82" +checksum = "3aa5f855cfb8e4253ed2d0dfc1a0b6ebe4912e67aa8b7ee14026ff55ca17f1fe" dependencies = [ "anyhow", "cranelift-codegen", @@ -171,14 +171,14 @@ dependencies = [ "region", "target-lexicon", "wasmtime-internal-jit-icache-coherence", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "cranelift-module" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddcf313629071ce74de8e59f02092f5453d1a01047607fc4ad36886b8bd1486c" +checksum = "b1d01806b191b59f4fc4680293dd5f554caf2de5b62f95eff5beef7acb46c29c" dependencies = [ "anyhow", "cranelift-codegen", @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03faa07ec8cf373250a8252eb773d098ff88259fa1c19ee1ecde8012839f4097" +checksum = "e5c54e0a358bc05b48f2032e1c320e7f468da068604f2869b77052eab68eb0fe" dependencies = [ "cranelift-codegen", "libc", @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cca62c14f3c2e4f438192562bbf82d1a98a59543cc66ba04fb658ba99f515a6" +checksum = "3d17e0216be5daabab616647c1918e06dae0708474ba5f7b7762ac24ea5eb126" dependencies = [ "anyhow", "cranelift-codegen", @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "cranelift-srcgen" -version = "0.126.0" +version = "0.127.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0484cb32c527a742e1bba09ef174acac0afb1dcf623ef1adda42849200edcd2e" +checksum = "cc6f4b039f453b66c75e9f7886e5a2af96276e151f44dc19b24b58f9a0c98009" [[package]] name = "crc32fast" @@ -293,7 +293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" dependencies = [ "cfg-if", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -469,31 +469,25 @@ checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "wasmtime-internal-jit-icache-coherence" -version = "39.0.0" +version = "40.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f67986f5c499274ae5b2ba5b173bba0b95d1381f5ca70d8eec657f2392117d8" +checksum = "0858b470463f3e7c73acd6049046049e64be17b98901c2db5047450cf83df1fe" dependencies = [ "anyhow", "cfg-if", "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "wasmtime-internal-math" -version = "39.0.0" +version = "40.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a681733e9b5d5d8804ee6cacd59f92c0d87ba2274f42ee1d4e5a943828d0075d" +checksum = "222e1a590ece4e898f20af1e541b61d2cb803f2557e7eaff23e6c1db5434454a" dependencies = [ "libm", ] -[[package]] -name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - [[package]] name = "windows-link" version = "0.2.1" @@ -506,16 +500,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] name = "windows-sys" -version = "0.60.2" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-targets 0.53.3", + "windows-link", ] [[package]] @@ -524,31 +518,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" -dependencies = [ - "windows-link 0.1.3", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -557,92 +534,44 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" diff --git a/Cargo.toml b/Cargo.toml index 58e61cd0b9d7..ee4bde477c47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,12 +8,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.126.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] } -cranelift-frontend = { version = "0.126.0" } -cranelift-module = { version = "0.126.0" } -cranelift-native = { version = "0.126.0" } -cranelift-jit = { version = "0.126.0", optional = true } -cranelift-object = { version = "0.126.0" } +cranelift-codegen = { version = "0.127.0", default-features = false, features = ["std", "timing", "unwind", "all-native-arch"] } +cranelift-frontend = { version = "0.127.0" } +cranelift-module = { version = "0.127.0" } +cranelift-native = { version = "0.127.0" } +cranelift-jit = { version = "0.127.0", optional = true } +cranelift-object = { version = "0.127.0" } target-lexicon = "0.13" gimli = { version = "0.32", default-features = false, features = ["write"] } object = { version = "0.37.3", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } @@ -24,12 +24,12 @@ smallvec = "1.8.1" [patch.crates-io] # Uncomment to use an unreleased version of cranelift -#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } -#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } -#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } -#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } -#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } -#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-39.0.0" } +#cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-40.0.0" } +#cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-40.0.0" } +#cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-40.0.0" } +#cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-40.0.0" } +#cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-40.0.0" } +#cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-40.0.0" } # Uncomment to use local checkout of cranelift #cranelift-codegen = { path = "../wasmtime/cranelift/codegen" } From 6f3f6bdacb75571a87f08e0920d9c191b3d65ded Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 23 Dec 2025 16:22:22 +0000 Subject: [PATCH 442/489] Rustup to rustc 1.94.0-nightly (4f14395c3 2025-12-22) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6ce49eb4ccf0..b157c5879ba7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2025-12-18" +channel = "nightly-2025-12-23" components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"] profile = "minimal" From e7965821e8bb671937e59f99894537d436060fc0 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Tue, 23 Dec 2025 23:35:58 +0200 Subject: [PATCH 443/489] use new term in description of --target --- compiler/rustc_session/src/config.rs | 2 +- src/doc/man/rustc.1 | 4 ++-- src/doc/rustc/src/command-line-arguments.md | 2 +- tests/run-make/rustc-help/help-v.stdout | 2 +- tests/run-make/rustc-help/help.stdout | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 2774333573f6..f326442c0879 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1798,7 +1798,7 @@ pub fn rustc_optgroups() -> Vec { "", ), opt(Stable, Flag, "", "test", "Build a test harness", ""), - opt(Stable, Opt, "", "target", "Target triple for which the code is compiled", ""), + opt(Stable, Opt, "", "target", "Target tuple for which the code is compiled", ""), opt(Stable, Multi, "A", "allow", "Set lint allowed", ""), opt(Stable, Multi, "W", "warn", "Set lint warnings", ""), opt(Stable, Multi, "", "force-warn", "Set lint force-warn", ""), diff --git a/src/doc/man/rustc.1 b/src/doc/man/rustc.1 index 534af3f85bb9..2a91774d671a 100644 --- a/src/doc/man/rustc.1 +++ b/src/doc/man/rustc.1 @@ -79,8 +79,8 @@ Provide a detailed explanation of an error message. Build a test harness. .TP \fB\-\-target\fR \fITARGET\fR -Target triple for which the code is compiled. This option defaults to the host’s target -triple. The target triple has the general format \-\-\-, where: +Target tuple for which the code is compiled. This option defaults to the host’s target +tuple. The target tuple has the general format \-\-\-, where: .RS .TP .B diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 0b15fbc24dfc..507af9e2ffef 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -284,7 +284,7 @@ and instead produce a test harness. See the [Tests chapter](tests/index.md) for more information about tests. -## `--target`: select a target triple to build +## `--target`: select a target tuple to build This controls which [target](targets/index.md) to produce. diff --git a/tests/run-make/rustc-help/help-v.stdout b/tests/run-make/rustc-help/help-v.stdout index c41cb5e3bde8..cf055e220c0d 100644 --- a/tests/run-make/rustc-help/help-v.stdout +++ b/tests/run-make/rustc-help/help-v.stdout @@ -51,7 +51,7 @@ Options: --explain Provide a detailed explanation of an error message --test Build a test harness --target - Target triple for which the code is compiled + Target tuple for which the code is compiled -A, --allow Set lint allowed -W, --warn Set lint warnings --force-warn diff --git a/tests/run-make/rustc-help/help.stdout b/tests/run-make/rustc-help/help.stdout index 5e13a900484d..4075dd028299 100644 --- a/tests/run-make/rustc-help/help.stdout +++ b/tests/run-make/rustc-help/help.stdout @@ -51,7 +51,7 @@ Options: --explain Provide a detailed explanation of an error message --test Build a test harness --target - Target triple for which the code is compiled + Target tuple for which the code is compiled -A, --allow Set lint allowed -W, --warn Set lint warnings --force-warn From b7729998d25a158a6925f737f4c164ec0572ff10 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 20 Dec 2025 14:08:21 +1100 Subject: [PATCH 444/489] Classify `TestableCase::Constant` into multiple sub-kinds --- .../src/builder/matches/buckets.rs | 21 ++++++++------- .../src/builder/matches/match_pair.rs | 26 +++++++++++++++++-- .../src/builder/matches/mod.rs | 21 ++++++++++++++- .../src/builder/matches/test.rs | 15 +++++------ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/buckets.rs b/compiler/rustc_mir_build/src/builder/matches/buckets.rs index 8cbbb8e14095..5275a1bb620e 100644 --- a/compiler/rustc_mir_build/src/builder/matches/buckets.rs +++ b/compiler/rustc_mir_build/src/builder/matches/buckets.rs @@ -6,8 +6,7 @@ use rustc_middle::span_bug; use tracing::debug; use crate::builder::Builder; -use crate::builder::matches::test::is_switch_ty; -use crate::builder::matches::{Candidate, Test, TestBranch, TestKind, TestableCase}; +use crate::builder::matches::{Candidate, PatConstKind, Test, TestBranch, TestKind, TestableCase}; /// Output of [`Builder::partition_candidates_into_buckets`]. pub(crate) struct PartitionedCandidates<'tcx, 'b, 'c> { @@ -157,11 +156,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // // FIXME(#29623) we could use PatKind::Range to rule // things out here, in some cases. - // - // FIXME(Zalathar): Is the `is_switch_ty` test unnecessary? - (TestKind::SwitchInt, &TestableCase::Constant { value }) - if is_switch_ty(match_pair.pattern_ty) => - { + ( + TestKind::SwitchInt, + &TestableCase::Constant { value, kind: PatConstKind::IntOrChar }, + ) => { // An important invariant of candidate bucketing is that a candidate // must not match in multiple branches. For `SwitchInt` tests, adding // a new value might invalidate that property for range patterns that @@ -206,7 +204,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }) } - (TestKind::If, TestableCase::Constant { value }) => { + (TestKind::If, TestableCase::Constant { value, kind: PatConstKind::Bool }) => { fully_matched = true; let value = value.try_to_bool().unwrap_or_else(|| { span_bug!(test.span, "expected boolean value but got {value:?}") @@ -291,7 +289,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if !test.overlaps(pat, self.tcx)? { Some(TestBranch::Failure) } else { None } } } - (TestKind::Range(range), &TestableCase::Constant { value }) => { + (TestKind::Range(range), &TestableCase::Constant { value, kind: _ }) => { fully_matched = false; if !range.contains(value, self.tcx)? { // `value` is not contained in the testing range, @@ -302,7 +300,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - (TestKind::Eq { value: test_val, .. }, TestableCase::Constant { value: case_val }) => { + ( + TestKind::Eq { value: test_val, .. }, + TestableCase::Constant { value: case_val, kind: _ }, + ) => { if test_val == case_val { fully_matched = true; Some(TestBranch::Success) diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index 9b9ee1836956..c8e3628ae346 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -7,7 +7,9 @@ use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use crate::builder::Builder; use crate::builder::expr::as_place::{PlaceBase, PlaceBuilder}; -use crate::builder::matches::{FlatPat, MatchPairTree, PatternExtraData, TestableCase}; +use crate::builder::matches::{ + FlatPat, MatchPairTree, PatConstKind, PatternExtraData, TestableCase, +}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds and pushes [`MatchPairTree`] subtrees, one for each pattern in @@ -156,7 +158,27 @@ impl<'tcx> MatchPairTree<'tcx> { } } - PatKind::Constant { value } => Some(TestableCase::Constant { value }), + PatKind::Constant { value } => { + // CAUTION: The type of the pattern node (`pattern.ty`) is + // _often_ the same as the type of the const value (`value.ty`), + // but there are some cases where those types differ + // (e.g. when `deref!(..)` patterns interact with `String`). + + // Classify the constant-pattern into further kinds, to + // reduce the number of ad-hoc type tests needed later on. + let pat_ty = pattern.ty; + let const_kind = if pat_ty.is_bool() { + PatConstKind::Bool + } else if pat_ty.is_integral() || pat_ty.is_char() { + PatConstKind::IntOrChar + } else { + // FIXME(Zalathar): This still covers several different + // categories (e.g. raw pointer, string, pattern-type) + // which could be split out into their own kinds. + PatConstKind::Other + }; + Some(TestableCase::Constant { value, kind: const_kind }) + } PatKind::AscribeUserType { ascription: Ascription { ref annotation, variance }, diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 8897ca7c7210..04722bf690c4 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1262,7 +1262,7 @@ struct Ascription<'tcx> { #[derive(Debug, Clone)] enum TestableCase<'tcx> { Variant { adt_def: ty::AdtDef<'tcx>, variant_index: VariantIdx }, - Constant { value: ty::Value<'tcx> }, + Constant { value: ty::Value<'tcx>, kind: PatConstKind }, Range(Arc>), Slice { len: u64, variable_length: bool }, Deref { temp: Place<'tcx>, mutability: Mutability }, @@ -1276,6 +1276,25 @@ impl<'tcx> TestableCase<'tcx> { } } +/// Sub-classification of [`TestableCase::Constant`], which helps to avoid +/// some redundant ad-hoc checks when preparing and lowering tests. +#[derive(Debug, Clone)] +enum PatConstKind { + /// The primitive `bool` type, which is like an integer but simpler, + /// having only two values. + Bool, + /// Primitive unsigned/signed integer types, plus `char`. + /// These types interact nicely with `SwitchInt`. + IntOrChar, + /// Any other constant-pattern is usually tested via some kind of equality + /// check. Types that might be encountered here include: + /// - `&str` + /// - floating-point primitives, e.g. `f32`, `f64` + /// - raw pointers derived from integer values + /// - pattern types, e.g. `pattern_type!(u32 is 1..)` + Other, +} + /// Node in a tree of "match pairs", where each pair consists of a place to be /// tested, and a test to perform on that place. /// diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index 402587bff7e8..bc4966404ced 100644 --- a/compiler/rustc_mir_build/src/builder/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -19,7 +19,9 @@ use rustc_span::{DUMMY_SP, Span, Symbol, sym}; use tracing::{debug, instrument}; use crate::builder::Builder; -use crate::builder::matches::{MatchPairTree, Test, TestBranch, TestKind, TestableCase}; +use crate::builder::matches::{ + MatchPairTree, PatConstKind, Test, TestBranch, TestKind, TestableCase, +}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Identifies what test is needed to decide if `match_pair` is applicable. @@ -32,11 +34,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let kind = match match_pair.testable_case { TestableCase::Variant { adt_def, variant_index: _ } => TestKind::Switch { adt_def }, - TestableCase::Constant { .. } if match_pair.pattern_ty.is_bool() => TestKind::If, - TestableCase::Constant { .. } if is_switch_ty(match_pair.pattern_ty) => { + TestableCase::Constant { value: _, kind: PatConstKind::Bool } => TestKind::If, + TestableCase::Constant { value: _, kind: PatConstKind::IntOrChar } => { TestKind::SwitchInt } - TestableCase::Constant { value } => { + TestableCase::Constant { value, kind: PatConstKind::Other } => { TestKind::Eq { value, cast_ty: match_pair.pattern_ty } } @@ -491,11 +493,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } -/// Returns true if this type be used with [`TestKind::SwitchInt`]. -pub(crate) fn is_switch_ty(ty: Ty<'_>) -> bool { - ty.is_integral() || ty.is_char() -} - fn trait_method<'tcx>( tcx: TyCtxt<'tcx>, trait_def_id: DefId, From 1296925d1b71fa9dbf636aa540bd7cced80c3054 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 24 Dec 2025 13:38:07 +1100 Subject: [PATCH 445/489] Split out a separate `PatConstKind::Float` Unlike the other types covered by `PatConstKind::Other`, const-float patterns can also interact with range patterns. --- .../rustc_mir_build/src/builder/matches/buckets.rs | 13 +++++++++++-- .../src/builder/matches/match_pair.rs | 2 ++ compiler/rustc_mir_build/src/builder/matches/mod.rs | 5 ++++- .../rustc_mir_build/src/builder/matches/test.rs | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/buckets.rs b/compiler/rustc_mir_build/src/builder/matches/buckets.rs index 5275a1bb620e..f8af50ee52fe 100644 --- a/compiler/rustc_mir_build/src/builder/matches/buckets.rs +++ b/compiler/rustc_mir_build/src/builder/matches/buckets.rs @@ -289,7 +289,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if !test.overlaps(pat, self.tcx)? { Some(TestBranch::Failure) } else { None } } } - (TestKind::Range(range), &TestableCase::Constant { value, kind: _ }) => { + ( + TestKind::Range(range), + &TestableCase::Constant { + value, + kind: PatConstKind::Bool | PatConstKind::IntOrChar | PatConstKind::Float, + }, + ) => { fully_matched = false; if !range.contains(value, self.tcx)? { // `value` is not contained in the testing range, @@ -302,7 +308,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ( TestKind::Eq { value: test_val, .. }, - TestableCase::Constant { value: case_val, kind: _ }, + TestableCase::Constant { + value: case_val, + kind: PatConstKind::Float | PatConstKind::Other, + }, ) => { if test_val == case_val { fully_matched = true; diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index c8e3628ae346..798110c8b090 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -171,6 +171,8 @@ impl<'tcx> MatchPairTree<'tcx> { PatConstKind::Bool } else if pat_ty.is_integral() || pat_ty.is_char() { PatConstKind::IntOrChar + } else if pat_ty.is_floating_point() { + PatConstKind::Float } else { // FIXME(Zalathar): This still covers several different // categories (e.g. raw pointer, string, pattern-type) diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 04722bf690c4..8128ea946f08 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1286,10 +1286,13 @@ enum PatConstKind { /// Primitive unsigned/signed integer types, plus `char`. /// These types interact nicely with `SwitchInt`. IntOrChar, + /// Floating-point primitives, e.g. `f32`, `f64`. + /// These types don't support `SwitchInt` and require an equality test, + /// but can also interact with range pattern tests. + Float, /// Any other constant-pattern is usually tested via some kind of equality /// check. Types that might be encountered here include: /// - `&str` - /// - floating-point primitives, e.g. `f32`, `f64` /// - raw pointers derived from integer values /// - pattern types, e.g. `pattern_type!(u32 is 1..)` Other, diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index bc4966404ced..f292a8e79d9d 100644 --- a/compiler/rustc_mir_build/src/builder/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -38,6 +38,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { TestableCase::Constant { value: _, kind: PatConstKind::IntOrChar } => { TestKind::SwitchInt } + TestableCase::Constant { value, kind: PatConstKind::Float } => { + TestKind::Eq { value, cast_ty: match_pair.pattern_ty } + } TestableCase::Constant { value, kind: PatConstKind::Other } => { TestKind::Eq { value, cast_ty: match_pair.pattern_ty } } From b5c473e4141c6b1bc7a1babec3e01f894442f436 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 23 Dec 2025 15:50:33 +0000 Subject: [PATCH 446/489] Avoid using env::temp when linking a binary This keeps all build artefacts (even temporary ones) within the build directory. --- compiler/rustc_codegen_ssa/src/back/link.rs | 11 ++++++----- compiler/rustc_fs_util/src/lib.rs | 6 +----- tests/run-make/invalid-tmpdir-env-var/rmake.rs | 8 ++++---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 70db6794742d..ba07345dd43f 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -103,17 +103,18 @@ pub fn link_binary( }); if outputs.outputs.should_link() { - let tmpdir = TempDirBuilder::new() - .prefix("rustc") - .tempdir() - .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); - let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); let output = out_filename( sess, crate_type, outputs, codegen_results.crate_info.local_crate_name, ); + let tmpdir = TempDirBuilder::new() + .prefix("rustc") + .tempdir_in(output.parent().unwrap_or_else(|| Path::new("."))) + .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); + let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); + let crate_name = format!("{}", codegen_results.crate_info.local_crate_name); let out_filename = output.file_for_writing( outputs, diff --git a/compiler/rustc_fs_util/src/lib.rs b/compiler/rustc_fs_util/src/lib.rs index 7a883a13b72d..e21da4cdddf7 100644 --- a/compiler/rustc_fs_util/src/lib.rs +++ b/compiler/rustc_fs_util/src/lib.rs @@ -1,6 +1,6 @@ use std::ffi::{CString, OsStr}; use std::path::{Path, PathBuf, absolute}; -use std::{env, fs, io}; +use std::{fs, io}; use tempfile::TempDir; @@ -139,8 +139,4 @@ impl<'a, 'b> TempDirBuilder<'a, 'b> { } self.builder.tempdir_in(dir) } - - pub fn tempdir(&self) -> io::Result { - self.tempdir_in(env::temp_dir()) - } } diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-env-var/rmake.rs index c5b9dca33a94..a62592757879 100644 --- a/tests/run-make/invalid-tmpdir-env-var/rmake.rs +++ b/tests/run-make/invalid-tmpdir-env-var/rmake.rs @@ -1,9 +1,7 @@ //@ needs-target-std // // When the TMP (on Windows) or TMPDIR (on Unix) variable is set to an invalid -// or non-existing directory, this used to cause an internal compiler error (ICE). After the -// addition of proper error handling in #28430, this test checks that the expected message is -// printed. +// or non-existing directory, this used to cause an internal compiler error (ICE). // See https://github.com/rust-lang/rust/issues/14698 use run_make_support::{is_windows, rustc}; @@ -18,5 +16,7 @@ fn main() { } else { rustc.env("TMPDIR", "fake"); } - rustc.input("foo.rs").run_fail().assert_stderr_contains("couldn't create a temp dir"); + let result = rustc.input("foo.rs").run_unchecked(); + // Ensure that rustc doesn't ICE by checking the exit code isn't 101. + assert_ne!(result.status().code(), Some(101)); } From 6e354544bfe4bc6ce17265bfb8013631d505f1ac Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 23 Dec 2025 17:46:09 +0000 Subject: [PATCH 447/489] Rename invalid-tmpdir-env-var to invalid-tmpdir-no-ice --- .../{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/foo.rs | 0 .../{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/rmake.rs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/run-make/{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/foo.rs (100%) rename tests/run-make/{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/rmake.rs (100%) diff --git a/tests/run-make/invalid-tmpdir-env-var/foo.rs b/tests/run-make/invalid-tmpdir-no-ice/foo.rs similarity index 100% rename from tests/run-make/invalid-tmpdir-env-var/foo.rs rename to tests/run-make/invalid-tmpdir-no-ice/foo.rs diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-no-ice/rmake.rs similarity index 100% rename from tests/run-make/invalid-tmpdir-env-var/rmake.rs rename to tests/run-make/invalid-tmpdir-no-ice/rmake.rs From 855281c8871e43980fc41b54d1d5949a9863103d Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Wed, 24 Dec 2025 16:04:58 +0800 Subject: [PATCH 448/489] Disable f16 on LoongArch for LLVM < 21 The `f16` type works on the LoongArch target starting from LLVM 21. However, the current minimum supported external LLVM version is 20, so `f16` must not be enabled on LoongArch for LLVM version < 21. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a5a8f8e6a25e..01181ce26184 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -383,6 +383,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // Infinite recursion (Arch::CSky, _) => false, (Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21) + (Arch::LoongArch32 | Arch::LoongArch64, _) if major < 21 => false, // (fixed in llvm21) (Arch::PowerPC | Arch::PowerPC64, _) => false, (Arch::Sparc | Arch::Sparc64, _) => false, (Arch::Wasm32 | Arch::Wasm64, _) => false, From 13c6256efe7d426abeb7c86a20b14ba38dc7ad4e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 24 Dec 2025 10:21:07 +0000 Subject: [PATCH 449/489] Include rustc version in ICE messages Rather than only including them in the ICE file. Not every user includes the ICE file in their bug reports, nor do they always list the rustc version. --- compiler/rustc_driver_impl/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 63fc9c96f450..7820198f2dcf 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1531,15 +1531,15 @@ fn report_ice( .map(PathBuf::from) .map(|env_var| session_diagnostics::IcePathErrorEnv { env_var }), }); - dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); None } } } else { - dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); None }; + dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); + if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() { dcx.emit_note(session_diagnostics::IceFlags { flags: flags.join(" ") }); if excluded_cargo_defaults { From 0e0911b5d8261e1a74158b0a611875521704b0cc Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Thu, 18 Dec 2025 18:50:27 +0000 Subject: [PATCH 450/489] Misc cleanups --- compiler/rustc_borrowck/src/lib.rs | 8 +- compiler/rustc_borrowck/src/root_cx.rs | 2 +- .../rustc_borrowck/src/universal_regions.rs | 47 ++--- .../rustc_hir_analysis/src/collect/type_of.rs | 160 +++++++++--------- 4 files changed, 99 insertions(+), 118 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 8d61ffde116c..fa78fb623596 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1,4 +1,4 @@ -//! This query borrow-checks the MIR to (further) ensure it is not broken. +//! This crate implemens MIR typeck and MIR borrowck. // tidy-alphabetical-start #![allow(internal_features)] @@ -111,9 +111,9 @@ pub fn provide(providers: &mut Providers) { *providers = Providers { mir_borrowck, ..*providers }; } -/// Provider for `query mir_borrowck`. Similar to `typeck`, this must -/// only be called for typeck roots which will then borrowck all -/// nested bodies as well. +/// Provider for `query mir_borrowck`. Unlike `typeck`, this must +/// only be called for typeck roots which *similar* to `typeck` will +/// then borrowck all nested bodies as well. fn mir_borrowck( tcx: TyCtxt<'_>, def: LocalDefId, diff --git a/compiler/rustc_borrowck/src/root_cx.rs b/compiler/rustc_borrowck/src/root_cx.rs index c3ff8cba9472..4d42055df168 100644 --- a/compiler/rustc_borrowck/src/root_cx.rs +++ b/compiler/rustc_borrowck/src/root_cx.rs @@ -255,7 +255,7 @@ impl<'tcx> BorrowCheckRootCtxt<'tcx> { } // We now apply the closure requirements of nested bodies modulo - // regions. In case a body does not depend on opaque types, we + // opaques. In case a body does not depend on opaque types, we // eagerly check its region constraints and use the final closure // requirements. // diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index aee1eb94dc81..a0d5e1ce780d 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -1,13 +1,12 @@ //! Code to extract the universally quantified regions declared on a -//! function and the relationships between them. For example: +//! function. For example: //! //! ``` //! fn foo<'a, 'b, 'c: 'b>() { } //! ``` //! //! here we would return a map assigning each of `{'a, 'b, 'c}` -//! to an index, as well as the `FreeRegionMap` which can compute -//! relationships between them. +//! to an index. //! //! The code in this file doesn't *do anything* with those results; it //! just returns them for other code to use. @@ -271,8 +270,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// Creates a new and fully initialized `UniversalRegions` that /// contains indices for all the free regions found in the given /// MIR -- that is, all the regions that appear in the function's - /// signature. This will also compute the relationships that are - /// known between those regions. + /// signature. pub(crate) fn new(infcx: &BorrowckInferCtxt<'tcx>, mir_def: LocalDefId) -> Self { UniversalRegionsBuilder { infcx, mir_def }.build() } @@ -648,17 +646,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(..) => { let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id); - if self.mir_def.to_def_id() == typeck_root_def_id - // Do not ICE when checking default_field_values consts with lifetimes (#135649) - && DefKind::Field != tcx.def_kind(tcx.parent(typeck_root_def_id)) - { + if self.mir_def.to_def_id() == typeck_root_def_id { let args = self.infcx.replace_free_regions_with_nll_infer_vars( NllRegionVariableOrigin::FreeRegion, identity_args, ); DefiningTy::Const(self.mir_def.to_def_id(), args) } else { - // FIXME this line creates a dependency between borrowck and typeck. + // FIXME: this line creates a query dependency between borrowck and typeck. // // This is required for `AscribeUserType` canonical query, which will call // `type_of(inline_const_def_id)`. That `type_of` would inject erased lifetimes @@ -699,30 +694,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let tcx = self.infcx.tcx; let typeck_root_def_id = tcx.typeck_root_def_id(self.mir_def.to_def_id()); let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id); - let fr_args = match defining_ty { - DefiningTy::Closure(_, args) - | DefiningTy::CoroutineClosure(_, args) - | DefiningTy::Coroutine(_, args) - | DefiningTy::InlineConst(_, args) => { - // In the case of closures, we rely on the fact that - // the first N elements in the ClosureArgs are - // inherited from the `typeck_root_def_id`. - // Therefore, when we zip together (below) with - // `identity_args`, we will get only those regions - // that correspond to early-bound regions declared on - // the `typeck_root_def_id`. - assert!(args.len() >= identity_args.len()); - assert_eq!(args.regions().count(), identity_args.regions().count()); - args - } - - DefiningTy::FnDef(_, args) | DefiningTy::Const(_, args) => args, - - DefiningTy::GlobalAsm(_) => ty::List::empty(), - }; + let renumbered_args = defining_ty.args(); let global_mapping = iter::once((tcx.lifetimes.re_static, fr_static)); - let arg_mapping = iter::zip(identity_args.regions(), fr_args.regions().map(|r| r.as_var())); + // This relies on typeck roots being generics_of parents with their + // parameters at the start of nested bodies' generics. + assert!(renumbered_args.len() >= identity_args.len()); + let arg_mapping = + iter::zip(identity_args.regions(), renumbered_args.regions().map(|r| r.as_var())); UniversalRegionIndices { indices: global_mapping.chain(arg_mapping).collect(), @@ -862,8 +841,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { }; // FIXME(#129952): We probably want a more principled approach here. - if let Err(terr) = inputs_and_output.skip_binder().error_reported() { - self.infcx.set_tainted_by_errors(terr); + if let Err(e) = inputs_and_output.error_reported() { + self.infcx.set_tainted_by_errors(e); } inputs_and_output diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 180589340b4c..aa0e5c7fd710 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -10,6 +10,7 @@ use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, DefiningScopeKind, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::{bug, span_bug}; use rustc_span::{DUMMY_SP, Ident, Span}; +use tracing::instrument; use super::{HirPlaceholderCollector, ItemCtxt, bad_placeholder}; use crate::check::wfcheck::check_static_item; @@ -17,85 +18,7 @@ use crate::hir_ty_lowering::HirTyLowerer; mod opaque; -fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { - use hir::*; - use rustc_middle::ty::Ty; - let tcx = icx.tcx; - let hir_id = tcx.local_def_id_to_hir_id(def_id); - - let node = tcx.hir_node(hir_id); - let Node::AnonConst(&AnonConst { span, .. }) = node else { - span_bug!( - tcx.def_span(def_id), - "expected anon const in `anon_const_type_of`, got {node:?}" - ); - }; - - let parent_node_id = tcx.parent_hir_id(hir_id); - let parent_node = tcx.hir_node(parent_node_id); - - match parent_node { - // Anon consts "inside" the type system. - Node::ConstArg(&ConstArg { - hir_id: arg_hir_id, - kind: ConstArgKind::Anon(&AnonConst { hir_id: anon_hir_id, .. }), - .. - }) if anon_hir_id == hir_id => const_arg_anon_type_of(icx, arg_hir_id, span), - - Node::Variant(Variant { disr_expr: Some(e), .. }) if e.hir_id == hir_id => { - tcx.adt_def(tcx.hir_get_parent_item(hir_id)).repr().discr_type().to_ty(tcx) - } - - Node::Field(&hir::FieldDef { default: Some(c), def_id: field_def_id, .. }) - if c.hir_id == hir_id => - { - tcx.type_of(field_def_id).instantiate_identity() - } - - _ => Ty::new_error_with_message( - tcx, - span, - format!("unexpected anon const parent in type_of(): {parent_node:?}"), - ), - } -} - -fn const_arg_anon_type_of<'tcx>(icx: &ItemCtxt<'tcx>, arg_hir_id: HirId, span: Span) -> Ty<'tcx> { - use hir::*; - use rustc_middle::ty::Ty; - - let tcx = icx.tcx; - - match tcx.parent_hir_node(arg_hir_id) { - // Array length const arguments do not have `type_of` fed as there is never a corresponding - // generic parameter definition. - Node::Ty(&hir::Ty { kind: TyKind::Array(_, ref constant), .. }) - | Node::Expr(&Expr { kind: ExprKind::Repeat(_, ref constant), .. }) - if constant.hir_id == arg_hir_id => - { - tcx.types.usize - } - - Node::TyPat(pat) => { - let node = match tcx.parent_hir_node(pat.hir_id) { - // Or patterns can be nested one level deep - Node::TyPat(p) => tcx.parent_hir_node(p.hir_id), - other => other, - }; - let hir::TyKind::Pat(ty, _) = node.expect_ty().kind else { bug!() }; - icx.lower_ty(ty) - } - - // This is not a `bug!` as const arguments in path segments that did not resolve to anything - // will result in `type_of` never being fed. - _ => Ty::new_error_with_message( - tcx, - span, - "`type_of` called on const argument's anon const before the const argument was lowered", - ), - } -} - +#[instrument(level = "debug", skip(tcx), ret)] pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, Ty<'_>> { use rustc_hir::*; use rustc_middle::ty::Ty; @@ -408,6 +331,85 @@ pub(super) fn type_of_opaque_hir_typeck( } } +fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { + use hir::*; + use rustc_middle::ty::Ty; + let tcx = icx.tcx; + let hir_id = tcx.local_def_id_to_hir_id(def_id); + + let node = tcx.hir_node(hir_id); + let Node::AnonConst(&AnonConst { span, .. }) = node else { + span_bug!( + tcx.def_span(def_id), + "expected anon const in `anon_const_type_of`, got {node:?}" + ); + }; + + let parent_node_id = tcx.parent_hir_id(hir_id); + let parent_node = tcx.hir_node(parent_node_id); + + match parent_node { + // Anon consts "inside" the type system. + Node::ConstArg(&ConstArg { + hir_id: arg_hir_id, + kind: ConstArgKind::Anon(&AnonConst { hir_id: anon_hir_id, .. }), + .. + }) if anon_hir_id == hir_id => const_arg_anon_type_of(icx, arg_hir_id, span), + + Node::Variant(Variant { disr_expr: Some(e), .. }) if e.hir_id == hir_id => { + tcx.adt_def(tcx.hir_get_parent_item(hir_id)).repr().discr_type().to_ty(tcx) + } + + Node::Field(&hir::FieldDef { default: Some(c), def_id: field_def_id, .. }) + if c.hir_id == hir_id => + { + tcx.type_of(field_def_id).instantiate_identity() + } + + _ => Ty::new_error_with_message( + tcx, + span, + format!("unexpected anon const parent in type_of(): {parent_node:?}"), + ), + } +} + +fn const_arg_anon_type_of<'tcx>(icx: &ItemCtxt<'tcx>, arg_hir_id: HirId, span: Span) -> Ty<'tcx> { + use hir::*; + use rustc_middle::ty::Ty; + + let tcx = icx.tcx; + + match tcx.parent_hir_node(arg_hir_id) { + // Array length const arguments do not have `type_of` fed as there is never a corresponding + // generic parameter definition. + Node::Ty(&hir::Ty { kind: TyKind::Array(_, ref constant), .. }) + | Node::Expr(&Expr { kind: ExprKind::Repeat(_, ref constant), .. }) + if constant.hir_id == arg_hir_id => + { + tcx.types.usize + } + + Node::TyPat(pat) => { + let node = match tcx.parent_hir_node(pat.hir_id) { + // Or patterns can be nested one level deep + Node::TyPat(p) => tcx.parent_hir_node(p.hir_id), + other => other, + }; + let hir::TyKind::Pat(ty, _) = node.expect_ty().kind else { bug!() }; + icx.lower_ty(ty) + } + + // This is not a `bug!` as const arguments in path segments that did not resolve to anything + // will result in `type_of` never being fed. + _ => Ty::new_error_with_message( + tcx, + span, + "`type_of` called on const argument's anon const before the const argument was lowered", + ), + } +} + fn infer_placeholder_type<'tcx>( cx: &dyn HirTyLowerer<'tcx>, def_id: LocalDefId, From a8c9cb5f77f2d66f85758703610b55a2ae8865e0 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 24 Dec 2025 12:25:30 +0000 Subject: [PATCH 451/489] Fix some divergences with the cg_clif subtree For some reason git-subtree incorrectly synced those changes. --- .../rustc_codegen_cranelift/src/intrinsics/simd.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index 15aef60c5af3..bef9c6747457 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -1005,14 +1005,6 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let lane_clif_ty = fx.clif_type(val_lane_ty).unwrap(); let ret_lane_layout = fx.layout_of(ret_lane_ty); - let alignment = - generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); - - let memflags = match alignment { - SimdAlign::Unaligned => MemFlags::new().with_notrap(), - _ => MemFlags::trusted(), - }; - for lane_idx in 0..ptr_lane_count { let val_lane = val.value_lane(fx, lane_idx).load_scalar(fx); let ptr_lane = ptr.value_lane(fx, lane_idx).load_scalar(fx); @@ -1028,7 +1020,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.bcx.seal_block(if_disabled); fx.bcx.switch_to_block(if_enabled); - let res = fx.bcx.ins().load(lane_clif_ty, memflags, ptr_lane, 0); + let res = fx.bcx.ins().load(lane_clif_ty, MemFlags::trusted(), ptr_lane, 0); fx.bcx.ins().jump(next, &[res.into()]); fx.bcx.switch_to_block(if_disabled); From 851a98e17efa2c3524b761beda8110925f7f3819 Mon Sep 17 00:00:00 2001 From: irelaxcn Date: Thu, 25 Dec 2025 00:44:17 +0800 Subject: [PATCH 452/489] Fix `assertions_on_constants` false positive when there is non-constant value in the condition expr --- clippy_lints/src/assertions_on_constants.rs | 2 ++ tests/ui/assertions_on_constants.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 2586c89bc868..4aa55e53445c 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -3,6 +3,7 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::macros::{find_assert_args, root_macro_call_first_node}; use clippy_utils::msrvs::Msrv; +use clippy_utils::visitors::is_const_evaluatable; use clippy_utils::{is_inside_always_const_context, msrvs}; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind}; @@ -50,6 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { _ => return, } && let Some((condition, _)) = find_assert_args(cx, e, macro_call.expn) + && is_const_evaluatable(cx, condition) && let Some((Constant::Bool(assert_val), const_src)) = ConstEvalCtxt::new(cx).eval_with_source(condition, macro_call.span.ctxt()) && let in_const_context = is_inside_always_const_context(cx.tcx, e.hir_id) diff --git a/tests/ui/assertions_on_constants.rs b/tests/ui/assertions_on_constants.rs index f467d4966aef..1c49b6e6b7b1 100644 --- a/tests/ui/assertions_on_constants.rs +++ b/tests/ui/assertions_on_constants.rs @@ -96,3 +96,8 @@ fn _f4() { assert!(C); //~^ assertions_on_constants } + +fn issue_16242(var: bool) { + // should not lint + assert!(cfg!(feature = "hey") && var); +} From 69f987dbe8a03c8dfef081aa490a15b9e4c0c695 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 24 Dec 2025 19:53:06 -0700 Subject: [PATCH 453/489] Bump stringdex, fix compiler-docs Fixes https://github.com/rust-lang/rust/issues/150346 --- Cargo.lock | 4 ++-- src/librustdoc/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c5053f0c2b7..870259429742 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5357,9 +5357,9 @@ dependencies = [ [[package]] name = "stringdex" -version = "0.0.4" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6204af9e1e433f1ef9b6d44475c7089be33c91111d896463b9dfa20464b87f1" +checksum = "07ab85c3f308f022ce6861ab57576b5b6ebc4835f9577e67e0f35f6c351e3f0a" dependencies = [ "stacker", ] diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index ab75d2dfa429..34b22acdbf72 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -22,7 +22,7 @@ rustdoc-json-types = { path = "../rustdoc-json-types" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" smallvec = "1.8.1" -stringdex = "=0.0.4" +stringdex = "=0.0.5" tempfile = "3" threadpool = "1.8.1" tracing = "0.1" From 83749a4dd447d04cc52ed0524d89a0d5a1408b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Heath=20Dutton=F0=9F=95=B4=EF=B8=8F?= Date: Wed, 24 Dec 2025 22:52:34 -0500 Subject: [PATCH 454/489] rustdoc: fix incorrect type filter name in help popup --- src/librustdoc/html/static/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 476ecd42d6f9..a2bcdeb5d4b0 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1669,7 +1669,7 @@ function preLoadCss(cssUrl) { restrict the search to a given item kind.", "Accepted kinds are: fn, mod, struct, \ enum, trait, type, macro, \ - and const.", + and constant.", "Search functions by type signature (e.g., vec -> usize or \ -> vec or String, enum:Cow -> bool)", "You can look for items with an exact name by putting double quotes around \ From b22b089751099bc9b23ccc35c746c6896dc35a2d Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Thu, 25 Dec 2025 17:09:48 +0800 Subject: [PATCH 455/489] refactor: simplify code --- compiler/rustc_parse/src/lexer/tokentrees.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index 634f4c30b260..f3415aa47d33 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -117,7 +117,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> { candidate = Some(*delimiter_span); } } - let (_, _) = self.diag_info.open_delimiters.pop().unwrap(); + self.diag_info.open_delimiters.pop().unwrap(); self.diag_info.unmatched_delims.push(UnmatchedDelim { found_delim: Some(close_delim), found_span: self.token.span, From 3f477dd71082c6342ae34d32b49a63735ce0bc6f Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Thu, 25 Dec 2025 14:49:01 +0300 Subject: [PATCH 456/489] Recursive delegation improvements --- compiler/rustc_ast_lowering/src/delegation.rs | 240 +++++++++++------- compiler/rustc_middle/src/ty/mod.rs | 22 +- compiler/rustc_resolve/src/late.rs | 76 +++--- compiler/rustc_resolve/src/lib.rs | 10 +- tests/pretty/delegation-inherit-attributes.pp | 64 +++++ tests/pretty/delegation-inherit-attributes.rs | 45 ++++ ...bute.pp => delegation-inline-attribute.pp} | 2 +- ...bute.rs => delegation-inline-attribute.rs} | 2 +- .../recursive-delegation-ice-150152.rs | 31 +++ .../recursive-delegation-ice-150152.stderr | 74 ++++++ .../delegation/recursive-delegation-pass.rs | 98 ++++++- 11 files changed, 522 insertions(+), 142 deletions(-) rename tests/pretty/{delegation_inline_attribute.pp => delegation-inline-attribute.pp} (98%) rename tests/pretty/{delegation_inline_attribute.rs => delegation-inline-attribute.rs} (98%) create mode 100644 tests/ui/delegation/recursive-delegation-ice-150152.rs create mode 100644 tests/ui/delegation/recursive-delegation-ice-150152.stderr diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 532a0ce520cd..5d2531e50393 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -48,11 +48,12 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::ErrorGuaranteed; use rustc_hir::Target; use rustc_hir::attrs::{AttributeKind, InlineAttr}; -use rustc_hir::def_id::DefId; +use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::span_bug; -use rustc_middle::ty::{Asyncness, DelegationFnSigAttrs, ResolverAstLowering}; +use rustc_middle::ty::{Asyncness, DelegationAttrs, DelegationFnSigAttrs, ResolverAstLowering}; use rustc_span::symbol::kw; use rustc_span::{DUMMY_SP, Ident, Span, Symbol}; +use smallvec::SmallVec; use {rustc_ast as ast, rustc_hir as hir}; use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode}; @@ -66,24 +67,24 @@ pub(crate) struct DelegationResults<'hir> { pub generics: &'hir hir::Generics<'hir>, } -struct AttributeAdditionInfo { +struct AttrAdditionInfo { pub equals: fn(&hir::Attribute) -> bool, - pub kind: AttributeAdditionKind, + pub kind: AttrAdditionKind, } -enum AttributeAdditionKind { +enum AttrAdditionKind { Default { factory: fn(Span) -> hir::Attribute }, Inherit { flag: DelegationFnSigAttrs, factory: fn(Span, &hir::Attribute) -> hir::Attribute }, } const PARENT_ID: hir::ItemLocalId = hir::ItemLocalId::ZERO; -static ATTRIBUTES_ADDITIONS: &[AttributeAdditionInfo] = &[ - AttributeAdditionInfo { +static ATTRS_ADDITIONS: &[AttrAdditionInfo] = &[ + AttrAdditionInfo { equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::MustUse { .. })), - kind: AttributeAdditionKind::Inherit { - factory: |span, original_attribute| { - let reason = match original_attribute { + kind: AttrAdditionKind::Inherit { + factory: |span, original_attr| { + let reason = match original_attr { hir::Attribute::Parsed(AttributeKind::MustUse { reason, .. }) => *reason, _ => None, }; @@ -93,14 +94,41 @@ static ATTRIBUTES_ADDITIONS: &[AttributeAdditionInfo] = &[ flag: DelegationFnSigAttrs::MUST_USE, }, }, - AttributeAdditionInfo { + AttrAdditionInfo { equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::Inline(..))), - kind: AttributeAdditionKind::Default { + kind: AttrAdditionKind::Default { factory: |span| hir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span)), }, }, ]; +type DelegationIdsVec = SmallVec<[DefId; 1]>; + +// As delegations can now refer to another delegation, we have a delegation path +// of the following type: reuse (current delegation) <- reuse (delegee_id) <- ... <- reuse <- function (root_function_id). +// In its most basic and widely used form: reuse (current delegation) <- function (delegee_id, root_function_id) +struct DelegationIds { + path: DelegationIdsVec, +} + +impl DelegationIds { + fn new(path: DelegationIdsVec) -> Self { + assert!(!path.is_empty()); + Self { path } + } + + // Id of the first function in (non)local crate that is being reused + fn root_function_id(&self) -> DefId { + *self.path.last().expect("Ids vector can't be empty") + } + + // Id of the first definition which is being reused, + // can be either function, in this case `root_id == delegee_id`, or other delegation + fn delegee_id(&self) -> DefId { + *self.path.first().expect("Ids vector can't be empty") + } +} + impl<'hir> LoweringContext<'_, 'hir> { fn is_method(&self, def_id: DefId, span: Span) -> bool { match self.tcx.def_kind(def_id) { @@ -124,19 +152,36 @@ impl<'hir> LoweringContext<'_, 'hir> { ) -> DelegationResults<'hir> { let span = self.lower_span(delegation.path.segments.last().unwrap().ident.span); - let sig_id = self.get_delegation_sig_id( - self.resolver.delegation_sig_resolution_nodes[&self.local_def_id(item_id)], + let ids = self.get_delegation_ids( + self.resolver.delegation_infos[&self.local_def_id(item_id)].resolution_node, span, ); - match sig_id { - Ok(sig_id) => { - self.add_attributes_if_needed(span, sig_id); + match ids { + Ok(ids) => { + self.add_attrs_if_needed(span, &ids); + + let delegee_id = ids.delegee_id(); + let root_function_id = ids.root_function_id(); + + // `is_method` is used to choose the name of the first parameter (`self` or `arg0`), + // if the original function is not a method (without `self`), then it can not be added + // during chain of reuses, so we use `root_function_id` here + let is_method = self.is_method(root_function_id, span); + + // Here we use `root_function_id` as we can not get params information out of potential delegation reuse, + // we need a function to extract this information + let (param_count, c_variadic) = self.param_count(root_function_id); + + // Here we use `delegee_id`, as this id will then be used to calculate parent for generics + // inheritance, and we want this id to point on a delegee, not on the original + // function (see https://github.com/rust-lang/rust/issues/150152#issuecomment-3674834654) + let decl = self.lower_delegation_decl(delegee_id, param_count, c_variadic, span); + + // Here we pass `root_function_id` as we want to inherit signature (including consts, async) + // from the root function that started delegation + let sig = self.lower_delegation_sig(root_function_id, decl, span); - let is_method = self.is_method(sig_id, span); - let (param_count, c_variadic) = self.param_count(sig_id); - let decl = self.lower_delegation_decl(sig_id, param_count, c_variadic, span); - let sig = self.lower_delegation_sig(sig_id, decl, span); let body_id = self.lower_delegation_body(delegation, is_method, param_count, span); let ident = self.lower_ident(delegation.ident); let generics = self.lower_delegation_generics(span); @@ -146,36 +191,36 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - fn add_attributes_if_needed(&mut self, span: Span, sig_id: DefId) { - let new_attributes = self.create_new_attributes( - ATTRIBUTES_ADDITIONS, - span, - sig_id, - self.attrs.get(&PARENT_ID), - ); + fn add_attrs_if_needed(&mut self, span: Span, ids: &DelegationIds) { + let new_attrs = + self.create_new_attrs(ATTRS_ADDITIONS, span, ids, self.attrs.get(&PARENT_ID)); - if new_attributes.is_empty() { + if new_attrs.is_empty() { return; } - let new_arena_allocated_attributes = match self.attrs.get(&PARENT_ID) { + let new_arena_allocated_attrs = match self.attrs.get(&PARENT_ID) { Some(existing_attrs) => self.arena.alloc_from_iter( - existing_attrs.iter().map(|a| a.clone()).chain(new_attributes.into_iter()), + existing_attrs.iter().map(|a| a.clone()).chain(new_attrs.into_iter()), ), - None => self.arena.alloc_from_iter(new_attributes.into_iter()), + None => self.arena.alloc_from_iter(new_attrs.into_iter()), }; - self.attrs.insert(PARENT_ID, new_arena_allocated_attributes); + self.attrs.insert(PARENT_ID, new_arena_allocated_attrs); } - fn create_new_attributes( + fn create_new_attrs( &self, - candidate_additions: &[AttributeAdditionInfo], + candidate_additions: &[AttrAdditionInfo], span: Span, - sig_id: DefId, + ids: &DelegationIds, existing_attrs: Option<&&[hir::Attribute]>, ) -> Vec { - let local_original_attributes = self.parse_local_original_attributes(sig_id); + let defs_orig_attrs = ids + .path + .iter() + .map(|def_id| (*def_id, self.parse_local_original_attrs(*def_id))) + .collect::>(); candidate_additions .iter() @@ -189,65 +234,81 @@ impl<'hir> LoweringContext<'_, 'hir> { } match addition_info.kind { - AttributeAdditionKind::Default { factory } => Some(factory(span)), - AttributeAdditionKind::Inherit { flag, factory } => { - let original_attribute = match sig_id.as_local() { - Some(local_id) => self - .resolver - .delegation_fn_sigs - .get(&local_id) - .is_some_and(|sig| sig.attrs_flags.contains(flag)) - .then(|| { - local_original_attributes - .as_ref() - .map(|attrs| { - attrs - .iter() - .find(|base_attr| (addition_info.equals)(base_attr)) - }) - .flatten() - }) - .flatten(), - None => self - .tcx - .get_all_attrs(sig_id) - .iter() - .find(|base_attr| (addition_info.equals)(base_attr)), - }; + AttrAdditionKind::Default { factory } => Some(factory(span)), + AttrAdditionKind::Inherit { flag, factory } => { + for (def_id, orig_attrs) in &defs_orig_attrs { + let original_attr = match def_id.as_local() { + Some(local_id) => self + .get_attrs(local_id) + .flags + .contains(flag) + .then(|| { + orig_attrs + .as_ref() + .map(|attrs| { + attrs.iter().find(|base_attr| { + (addition_info.equals)(base_attr) + }) + }) + .flatten() + }) + .flatten(), + None => self + .tcx + .get_all_attrs(*def_id) + .iter() + .find(|base_attr| (addition_info.equals)(base_attr)), + }; - original_attribute.map(|a| factory(span, a)) + if let Some(original_attr) = original_attr { + return Some(factory(span, original_attr)); + } + } + + None } } }) .collect::>() } - fn parse_local_original_attributes(&self, sig_id: DefId) -> Option> { - if let Some(local_id) = sig_id.as_local() - && let Some(info) = self.resolver.delegation_fn_sigs.get(&local_id) - && !info.to_inherit_attrs.is_empty() - { - Some(AttributeParser::parse_limited_all( - self.tcx.sess, - info.to_inherit_attrs.as_slice(), - None, - Target::Fn, - DUMMY_SP, - DUMMY_NODE_ID, - Some(self.tcx.features()), - ShouldEmit::Nothing, - )) + fn parse_local_original_attrs(&self, def_id: DefId) -> Option> { + if let Some(local_id) = def_id.as_local() { + let attrs = &self.get_attrs(local_id).to_inherit; + + if !attrs.is_empty() { + return Some(AttributeParser::parse_limited_all( + self.tcx.sess, + attrs, + None, + Target::Fn, + DUMMY_SP, + DUMMY_NODE_ID, + Some(self.tcx.features()), + ShouldEmit::Nothing, + )); + } + } + + None + } + + fn get_attrs(&self, local_id: LocalDefId) -> &DelegationAttrs { + // local_id can correspond either to a function or other delegation + if let Some(fn_sig) = self.resolver.delegation_fn_sigs.get(&local_id) { + &fn_sig.attrs } else { - None + &self.resolver.delegation_infos[&local_id].attrs } } - fn get_delegation_sig_id( + fn get_delegation_ids( &self, mut node_id: NodeId, span: Span, - ) -> Result { + ) -> Result { let mut visited: FxHashSet = Default::default(); + let mut path: DelegationIdsVec = Default::default(); loop { visited.insert(node_id); @@ -262,14 +323,15 @@ impl<'hir> LoweringContext<'_, 'hir> { )); }; + path.push(def_id); + // If def_id is in local crate and it corresponds to another delegation // it means that we refer to another delegation as a callee, so in order to obtain // a signature DefId we obtain NodeId of the callee delegation and try to get signature from it. if let Some(local_id) = def_id.as_local() - && let Some(next_node_id) = - self.resolver.delegation_sig_resolution_nodes.get(&local_id) + && let Some(delegation_info) = self.resolver.delegation_infos.get(&local_id) { - node_id = *next_node_id; + node_id = delegation_info.resolution_node; if visited.contains(&node_id) { // We encountered a cycle in the resolution, or delegation callee refers to non-existent // entity, in this case emit an error. @@ -279,7 +341,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }); } } else { - return Ok(def_id); + return Ok(DelegationIds::new(path)); } } } @@ -299,14 +361,14 @@ impl<'hir> LoweringContext<'_, 'hir> { } // Function parameter count, including C variadic `...` if present. - fn param_count(&self, sig_id: DefId) -> (usize, bool /*c_variadic*/) { - if let Some(local_sig_id) = sig_id.as_local() { + fn param_count(&self, def_id: DefId) -> (usize, bool /*c_variadic*/) { + if let Some(local_sig_id) = def_id.as_local() { match self.resolver.delegation_fn_sigs.get(&local_sig_id) { Some(sig) => (sig.param_count, sig.c_variadic), None => (0, false), } } else { - let sig = self.tcx.fn_sig(sig_id).skip_binder().skip_binder(); + let sig = self.tcx.fn_sig(def_id).skip_binder().skip_binder(); (sig.inputs().len() + usize::from(sig.c_variadic), sig.c_variadic) } } @@ -356,7 +418,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // We are not forwarding the attributes, as the delegation fn sigs are collected on the ast, // and here we need the hir attributes. let default_safety = - if sig.attrs_flags.contains(DelegationFnSigAttrs::TARGET_FEATURE) + if sig.attrs.flags.contains(DelegationFnSigAttrs::TARGET_FEATURE) || self.tcx.def_kind(parent) == DefKind::ForeignMod { hir::Safety::Unsafe diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 5cc5ab0d5268..cb47869a1351 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -220,9 +220,8 @@ pub struct ResolverAstLowering { /// Information about functions signatures for delegation items expansion pub delegation_fn_sigs: LocalDefIdMap, - // NodeIds (either delegation.id or item_id in case of a trait impl) for signature resolution, - // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914 - pub delegation_sig_resolution_nodes: LocalDefIdMap, + // Information about delegations which is used when handling recursive delegations + pub delegation_infos: LocalDefIdMap, } bitflags::bitflags! { @@ -235,14 +234,27 @@ bitflags::bitflags! { pub const DELEGATION_INHERIT_ATTRS_START: DelegationFnSigAttrs = DelegationFnSigAttrs::MUST_USE; +#[derive(Debug)] +pub struct DelegationInfo { + // NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution, + // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914 + pub resolution_node: ast::NodeId, + pub attrs: DelegationAttrs, +} + +#[derive(Debug)] +pub struct DelegationAttrs { + pub flags: DelegationFnSigAttrs, + pub to_inherit: AttrVec, +} + #[derive(Debug)] pub struct DelegationFnSig { pub header: ast::FnHeader, pub param_count: usize, pub has_self: bool, pub c_variadic: bool, - pub attrs_flags: DelegationFnSigAttrs, - pub to_inherit_attrs: AttrVec, + pub attrs: DelegationAttrs, } #[derive(Clone, Copy, Debug, HashStable)] diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 4fefcc66b588..dd80f5da508c 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -29,7 +29,8 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate}; use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::ty::{ - AssocTag, DELEGATION_INHERIT_ATTRS_START, DelegationFnSig, DelegationFnSigAttrs, Visibility, + AssocTag, DELEGATION_INHERIT_ATTRS_START, DelegationAttrs, DelegationFnSig, + DelegationFnSigAttrs, DelegationInfo, Visibility, }; use rustc_middle::{bug, span_bug}; use rustc_session::config::{CrateType, ResolveDocLinks}; @@ -2928,7 +2929,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { item.id, LifetimeBinderKind::Function, span, - |this| this.resolve_delegation(delegation, item.id, false), + |this| this.resolve_delegation(delegation, item.id, false, &item.attrs), ); } @@ -3257,7 +3258,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { item.id, LifetimeBinderKind::Function, delegation.path.segments.last().unwrap().ident.span, - |this| this.resolve_delegation(delegation, item.id, false), + |this| this.resolve_delegation(delegation, item.id, false, &item.attrs), ); } AssocItemKind::Type(box TyAlias { generics, .. }) => self @@ -3386,7 +3387,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { debug!("resolve_implementation with_self_rib_ns(ValueNS, ...)"); let mut seen_trait_items = Default::default(); for item in impl_items { - this.resolve_impl_item(&**item, &mut seen_trait_items, trait_id); + this.resolve_impl_item(&**item, &mut seen_trait_items, trait_id, of_trait.is_some()); } }); }); @@ -3405,6 +3406,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { item: &'ast AssocItem, seen_trait_items: &mut FxHashMap, trait_id: Option, + is_in_trait_impl: bool, ) { use crate::ResolutionError::*; self.resolve_doc_links(&item.attrs, MaybeExported::ImplItem(trait_id.ok_or(&item.vis))); @@ -3550,7 +3552,9 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |i, s, c| MethodNotMemberOfTrait(i, s, c), ); - this.resolve_delegation(delegation, item.id, trait_id.is_some()); + // Here we don't use `trait_id`, as we can process unresolved trait, however + // in this case we are still in a trait impl, https://github.com/rust-lang/rust/issues/150152 + this.resolve_delegation(delegation, item.id, is_in_trait_impl, &item.attrs); }, ); } @@ -3704,6 +3708,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { delegation: &'ast Delegation, item_id: NodeId, is_in_trait_impl: bool, + attrs: &[Attribute], ) { self.smart_resolve_path( delegation.id, @@ -3718,9 +3723,12 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.visit_path(&delegation.path); - self.r.delegation_sig_resolution_nodes.insert( + self.r.delegation_infos.insert( self.r.local_def_id(item_id), - if is_in_trait_impl { item_id } else { delegation.id }, + DelegationInfo { + attrs: create_delegation_attrs(attrs), + resolution_node: if is_in_trait_impl { item_id } else { delegation.id }, + }, ); let Some(body) = &delegation.body else { return }; @@ -5334,39 +5342,43 @@ impl ItemInfoCollector<'_, '_, '_> { id: NodeId, attrs: &[Attribute], ) { - static NAMES_TO_FLAGS: &[(Symbol, DelegationFnSigAttrs)] = &[ - (sym::target_feature, DelegationFnSigAttrs::TARGET_FEATURE), - (sym::must_use, DelegationFnSigAttrs::MUST_USE), - ]; + self.r.delegation_fn_sigs.insert( + self.r.local_def_id(id), + DelegationFnSig { + header, + param_count: decl.inputs.len(), + has_self: decl.has_self(), + c_variadic: decl.c_variadic(), + attrs: create_delegation_attrs(attrs), + }, + ); + } +} - let mut to_inherit_attrs = AttrVec::new(); - let mut attrs_flags = DelegationFnSigAttrs::empty(); +fn create_delegation_attrs(attrs: &[Attribute]) -> DelegationAttrs { + static NAMES_TO_FLAGS: &[(Symbol, DelegationFnSigAttrs)] = &[ + (sym::target_feature, DelegationFnSigAttrs::TARGET_FEATURE), + (sym::must_use, DelegationFnSigAttrs::MUST_USE), + ]; - 'attrs_loop: for attr in attrs { - for &(name, flag) in NAMES_TO_FLAGS { - if attr.has_name(name) { - attrs_flags.set(flag, true); + let mut to_inherit_attrs = AttrVec::new(); + let mut flags = DelegationFnSigAttrs::empty(); - if flag.bits() >= DELEGATION_INHERIT_ATTRS_START.bits() { - to_inherit_attrs.push(attr.clone()); - } + 'attrs_loop: for attr in attrs { + for &(name, flag) in NAMES_TO_FLAGS { + if attr.has_name(name) { + flags.set(flag, true); - continue 'attrs_loop; + if flag.bits() >= DELEGATION_INHERIT_ATTRS_START.bits() { + to_inherit_attrs.push(attr.clone()); } + + continue 'attrs_loop; } } - - let sig = DelegationFnSig { - header, - param_count: decl.inputs.len(), - has_self: decl.has_self(), - c_variadic: decl.c_variadic(), - attrs_flags, - to_inherit_attrs, - }; - - self.r.delegation_fn_sigs.insert(self.r.local_def_id(id), sig); } + + DelegationAttrs { flags, to_inherit: to_inherit_attrs } } impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 57f19f7ea398..ec030ecf8e13 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -69,8 +69,8 @@ use rustc_middle::middle::privacy::EffectiveVisibilities; use rustc_middle::query::Providers; use rustc_middle::span_bug; use rustc_middle::ty::{ - self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverAstLowering, - ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility, + self, DelegationFnSig, DelegationInfo, Feed, MainDefinition, RegisteredTools, + ResolverAstLowering, ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility, }; use rustc_query_system::ich::StableHashingContext; use rustc_session::config::CrateType; @@ -1283,7 +1283,7 @@ pub struct Resolver<'ra, 'tcx> { /// Amount of lifetime parameters for each item in the crate. item_generics_num_lifetimes: FxHashMap, delegation_fn_sigs: LocalDefIdMap, - delegation_sig_resolution_nodes: LocalDefIdMap, + delegation_infos: LocalDefIdMap, main_def: Option = None, trait_impls: FxIndexMap>, @@ -1701,7 +1701,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { current_crate_outer_attr_insert_span, mods_with_parse_errors: Default::default(), impl_trait_names: Default::default(), - delegation_sig_resolution_nodes: Default::default(), + delegation_infos: Default::default(), .. }; @@ -1829,7 +1829,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { lifetime_elision_allowed: self.lifetime_elision_allowed, lint_buffer: Steal::new(self.lint_buffer), delegation_fn_sigs: self.delegation_fn_sigs, - delegation_sig_resolution_nodes: self.delegation_sig_resolution_nodes, + delegation_infos: self.delegation_infos, }; ResolverOutputs { global_ctxt, ast_lowering } } diff --git a/tests/pretty/delegation-inherit-attributes.pp b/tests/pretty/delegation-inherit-attributes.pp index 772e177b8883..8e30da1ad589 100644 --- a/tests/pretty/delegation-inherit-attributes.pp +++ b/tests/pretty/delegation-inherit-attributes.pp @@ -57,5 +57,69 @@ const fn const_fn_extern() -> _ { to_reuse_functions::const_fn_extern() } #[attr = Inline(Hint)] async fn async_fn_extern() -> _ { to_reuse_functions::async_fn_extern() } +mod recursive { + // Check that `baz` inherit attribute from `foo` + mod first { + fn bar() { } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn foo() -> _ { bar() } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn baz() -> _ { foo() } + } + + // Check that `baz` inherit attribute from `bar` + mod second { + #[attr = MustUse {reason: "some reason"}] + fn bar() { } + + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn foo() -> _ { bar() } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn baz() -> _ { foo() } + } + + // Check that `foo5` don't inherit attribute from `bar` + // and inherit attribute from foo4, check that foo1, foo2 and foo3 + // inherit attribute from bar + mod third { + #[attr = MustUse {reason: "some reason"}] + fn bar() { } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn foo1() -> _ { bar() } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn foo2() -> _ { foo1() } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn foo3() -> _ { foo2() } + #[attr = MustUse {reason: "foo4"}] + #[attr = Inline(Hint)] + fn foo4() -> _ { foo3() } + #[attr = MustUse {reason: "foo4"}] + #[attr = Inline(Hint)] + fn foo5() -> _ { foo4() } + } + + mod fourth { + trait T { + fn foo(&self, x: usize) -> usize { x + 1 } + } + + struct X; + impl T for X { } + + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn foo(self: _, arg1: _) -> _ { ::foo(self + 1, arg1) } + #[attr = MustUse {reason: "some reason"}] + #[attr = Inline(Hint)] + fn bar(self: _, arg1: _) -> _ { foo(self + 1, arg1) } + } +} fn main() { } diff --git a/tests/pretty/delegation-inherit-attributes.rs b/tests/pretty/delegation-inherit-attributes.rs index fe74b9a55a7d..581294d472a3 100644 --- a/tests/pretty/delegation-inherit-attributes.rs +++ b/tests/pretty/delegation-inherit-attributes.rs @@ -52,5 +52,50 @@ reuse to_reuse_functions::const_fn_extern; #[must_use = "some reason"] reuse to_reuse_functions::async_fn_extern; +mod recursive { + // Check that `baz` inherit attribute from `foo` + mod first { + fn bar() {} + #[must_use = "some reason"] + reuse bar as foo; + reuse foo as baz; + } + + // Check that `baz` inherit attribute from `bar` + mod second { + #[must_use = "some reason"] + fn bar() {} + + reuse bar as foo; + reuse foo as baz; + } + + // Check that `foo5` don't inherit attribute from `bar` + // and inherit attribute from foo4, check that foo1, foo2 and foo3 + // inherit attribute from bar + mod third { + #[must_use = "some reason"] + fn bar() {} + reuse bar as foo1; + reuse foo1 as foo2; + reuse foo2 as foo3; + #[must_use = "foo4"] + reuse foo3 as foo4; + reuse foo4 as foo5; + } + + mod fourth { + trait T { + fn foo(&self, x: usize) -> usize { x + 1 } + } + + struct X; + impl T for X {} + + #[must_use = "some reason"] + reuse ::foo { self + 1 } + reuse foo as bar { self + 1 } + } +} fn main() {} diff --git a/tests/pretty/delegation_inline_attribute.pp b/tests/pretty/delegation-inline-attribute.pp similarity index 98% rename from tests/pretty/delegation_inline_attribute.pp rename to tests/pretty/delegation-inline-attribute.pp index 4b3b2aa8f80a..826d099e8155 100644 --- a/tests/pretty/delegation_inline_attribute.pp +++ b/tests/pretty/delegation-inline-attribute.pp @@ -1,6 +1,6 @@ //@ pretty-compare-only //@ pretty-mode:hir -//@ pp-exact:delegation_inline_attribute.pp +//@ pp-exact:delegation-inline-attribute.pp #![allow(incomplete_features)] #![feature(fn_delegation)] diff --git a/tests/pretty/delegation_inline_attribute.rs b/tests/pretty/delegation-inline-attribute.rs similarity index 98% rename from tests/pretty/delegation_inline_attribute.rs rename to tests/pretty/delegation-inline-attribute.rs index 0716cfc51f5d..c79f68f8942d 100644 --- a/tests/pretty/delegation_inline_attribute.rs +++ b/tests/pretty/delegation-inline-attribute.rs @@ -1,6 +1,6 @@ //@ pretty-compare-only //@ pretty-mode:hir -//@ pp-exact:delegation_inline_attribute.pp +//@ pp-exact:delegation-inline-attribute.pp #![allow(incomplete_features)] #![feature(fn_delegation)] diff --git a/tests/ui/delegation/recursive-delegation-ice-150152.rs b/tests/ui/delegation/recursive-delegation-ice-150152.rs new file mode 100644 index 000000000000..565563c9d03d --- /dev/null +++ b/tests/ui/delegation/recursive-delegation-ice-150152.rs @@ -0,0 +1,31 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod first_example { + mod to_reuse { pub fn foo() {} } + struct S< S >; + //~^ ERROR type parameter `S` is never used + + impl Item for S { + //~^ ERROR cannot find trait `Item` in this scope + //~| ERROR missing generics for struct `S` + reuse to_reuse::foo; + } +} + +mod second_example { + trait Trait { + reuse to_reuse::foo; + //~^ ERROR function `foo` is private + } + mod to_reuse { + fn foo() {} + } + impl Trait for S { + //~^ ERROR cannot find type `S` in this scope + reuse foo; + //~^ ERROR cannot find function `foo` in this scope + } +} + +fn main() {} diff --git a/tests/ui/delegation/recursive-delegation-ice-150152.stderr b/tests/ui/delegation/recursive-delegation-ice-150152.stderr new file mode 100644 index 000000000000..c58f0ff09291 --- /dev/null +++ b/tests/ui/delegation/recursive-delegation-ice-150152.stderr @@ -0,0 +1,74 @@ +error[E0405]: cannot find trait `Item` in this scope + --> $DIR/recursive-delegation-ice-150152.rs:9:10 + | +LL | impl Item for S { + | ^^^^ not found in this scope + +error[E0425]: cannot find type `S` in this scope + --> $DIR/recursive-delegation-ice-150152.rs:24:20 + | +LL | impl Trait for S { + | ^ not found in this scope + | +note: struct `first_example::S` exists but is inaccessible + --> $DIR/recursive-delegation-ice-150152.rs:6:5 + | +LL | struct S< S >; + | ^^^^^^^^^^^^^^ not accessible + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/recursive-delegation-ice-150152.rs:26:15 + | +LL | reuse foo; + | ^^^ not found in this scope + | +note: these functions exist but are inaccessible + --> $DIR/recursive-delegation-ice-150152.rs:5:20 + | +LL | mod to_reuse { pub fn foo() {} } + | ^^^^^^^^^^^^ `first_example::to_reuse::foo`: not accessible +... +LL | fn foo() {} + | ^^^^^^^^ `second_example::to_reuse::foo`: not accessible + +error[E0603]: function `foo` is private + --> $DIR/recursive-delegation-ice-150152.rs:18:25 + | +LL | reuse to_reuse::foo; + | ^^^ private function + | +note: the function `foo` is defined here + --> $DIR/recursive-delegation-ice-150152.rs:22:9 + | +LL | fn foo() {} + | ^^^^^^^^ + +error[E0392]: type parameter `S` is never used + --> $DIR/recursive-delegation-ice-150152.rs:6:15 + | +LL | struct S< S >; + | ^ unused type parameter + | + = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `S` to be a const parameter, use `const S: /* Type */` instead + +error[E0107]: missing generics for struct `S` + --> $DIR/recursive-delegation-ice-150152.rs:9:21 + | +LL | impl Item for S { + | ^ expected 1 generic argument + | +note: struct defined here, with 1 generic parameter: `S` + --> $DIR/recursive-delegation-ice-150152.rs:6:12 + | +LL | struct S< S >; + | ^ - +help: add missing generic argument + | +LL | impl Item for S> { + | +++ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0107, E0392, E0405, E0425, E0603. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/delegation/recursive-delegation-pass.rs b/tests/ui/delegation/recursive-delegation-pass.rs index 93f8fa401b55..2a40986d352a 100644 --- a/tests/ui/delegation/recursive-delegation-pass.rs +++ b/tests/ui/delegation/recursive-delegation-pass.rs @@ -1,9 +1,10 @@ -//@ check-pass +//@ run-pass //@ edition:2018 //@ aux-crate:recursive_delegation_aux=recursive-delegation-aux.rs #![feature(fn_delegation)] #![allow(incomplete_features)] +#![allow(warnings)] mod first_mod { pub mod to_reuse { @@ -12,18 +13,35 @@ mod first_mod { } } - mod single_reuse { - reuse crate::first_mod::to_reuse::foo; - reuse foo as bar; - reuse foo as bar1; - reuse bar as goo; - reuse goo as koo; - reuse koo as too; + pub mod single_reuse { + reuse crate::first_mod::to_reuse::foo { self + 1 } + reuse foo as bar { self + 1 } + reuse foo as bar1 { self + 1 } + reuse bar as goo { self + 1 } + reuse goo as koo { self + 1 } + pub reuse koo as too { self + 1 } + + pub fn check() { + assert_eq!(foo(1), 3); + assert_eq!(bar(1), 4); + assert_eq!(bar1(1), 4); + assert_eq!(goo(1), 5); + assert_eq!(koo(1), 6); + assert_eq!(too(1), 7); + } } mod glob_reuse { reuse super::to_reuse::{foo as bar, foo as bar1} { self } reuse super::glob_reuse::{bar as goo, goo as koo, koo as too} { self } + + fn check() { + bar(1); + bar1(1); + goo(1); + koo(1); + too(1); + } } } @@ -44,6 +62,29 @@ mod second_mod { reuse TGlob::{foo1 as bar1, foo3 as bar3, bar1 as bar11, bar11 as bar111} { self.xd() } } + + fn check() { + struct X; + impl T for X { + fn foo(&self) {} + fn bar(&self) {} + fn goo(&self) {} + fn poo(&self) {} + } + + impl TGlob for X { + fn xd(&self) -> &Self { &self } + fn foo1(&self) {} + fn foo2(&self) {} + fn foo3(&self) {} + fn foo4(&self) {} + + fn bar1(&self) {} + fn bar3(&self) {} + fn bar11(&self) {} + fn bar111(&self) {} + } + } } mod third_mod { @@ -63,6 +104,45 @@ mod third_mod { mod fourth_mod { reuse recursive_delegation_aux::goo as bar; reuse bar as foo; + + fn check() { + bar(); + foo(); + } } -fn main() {} +mod fifth_mod { + mod m { + fn foo() { } + pub reuse foo as bar; + } + + trait T { + reuse m::bar as foo; + } + + struct X; + impl T for X {} + + trait T1 { + reuse ::foo as baz; + } + + impl T1 for X {} + + struct Y; + impl T1 for Y { + reuse ::foo as baz; + } + + fn check() { + m::bar(); + ::foo(); + ::baz(); + ::baz(); + } +} + +fn main() { + first_mod::single_reuse::check(); +} From fc6df9cec751da81c2b76b9a7f2647a93800a246 Mon Sep 17 00:00:00 2001 From: maradini77 <140460067+maradini77@users.noreply.github.com> Date: Thu, 25 Dec 2025 11:24:20 +0100 Subject: [PATCH 457/489] fix: typos and grammar errors in README files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix `FIMXE`/`FXIME` typos → `FIXME` - fix grammar: `these terminology are` → `this terminology is` - fix apostrophe: `it's data` → `its data` - remove duplicate word: `less less` → `less` --- src/tools/rust-installer/README.md | 2 +- src/tools/test-float-parse/README.md | 2 +- tests/ui/README.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tools/rust-installer/README.md b/src/tools/rust-installer/README.md index 505ffe4093fc..1f71d45a434c 100644 --- a/src/tools/rust-installer/README.md +++ b/src/tools/rust-installer/README.md @@ -49,7 +49,7 @@ To combine installers. # Future work -* Make install.sh not have to be customized, pull it's data from a +* Make install.sh not have to be customized, pull its data from a config file. * Be more resilient to installation failures, particularly if the disk is full. diff --git a/src/tools/test-float-parse/README.md b/src/tools/test-float-parse/README.md index 5e2c43d1cad6..ac9cbe5d28a2 100644 --- a/src/tools/test-float-parse/README.md +++ b/src/tools/test-float-parse/README.md @@ -36,7 +36,7 @@ For each test case, the following is done: representation with infinite precision. - The rational value then gets checked that it is within the float's representable values (absolute value greater than the smallest number to round - to zero, but less less than the first value to round to infinity). If these + to zero, but less than the first value to round to infinity). If these limits are exceeded, check that the parsed float reflects that. - For real nonzero numbers, the parsed float is converted into a rational using `significand * 2^exponent`. It is then checked against the actual rational diff --git a/tests/ui/README.md b/tests/ui/README.md index da9be2e209ac..b1c813cce93f 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -328,7 +328,7 @@ Tests for crate resolution and loading behavior, including `extern crate` declar ## `tests/ui/cross/`: Various tests related to the concept of "cross" -**FIXME**: The unifying topic of these tests appears to be that their filenames begin with the word "cross". The similarities end there - one test is about "cross-borrowing" a `Box` into `&T`, while another is about a global trait used "across" files. Some of these terminology are really outdated and does not match the current terminology. Additionally, "cross" is also way too generic, it's easy to confuse with cross-compile. +**FIXME**: The unifying topic of these tests appears to be that their filenames begin with the word "cross". The similarities end there - one test is about "cross-borrowing" a `Box` into `&T`, while another is about a global trait used "across" files. Some of this terminology is really outdated and does not match the current terminology. Additionally, "cross" is also way too generic, it's easy to confuse with cross-compile. ## `tests/ui/cross-crate/`: Cross-Crate Interaction @@ -911,7 +911,7 @@ Something is missing which could be added to fix (e.g. suggestions). Tests for checking missing trait bounds, and their diagnostics. -**FIMXE**: Maybe a subdirectory of `ui/trait-bounds` would be more appropriate. +**FIXME**: Maybe a subdirectory of `ui/trait-bounds` would be more appropriate. ## `tests/ui/modules/` @@ -957,7 +957,7 @@ Despite the size of the directory, this is a single test, spawning a sprawling ` A very similar principle as `non_modrs_mods`, but with an added inline `mod` statement inside another `mod`'s code block. -**FXIME**: Consider merge with `tests/ui/modules/`, keeping the directory structure. +**FIXME**: Consider merge with `tests/ui/modules/`, keeping the directory structure. ## `tests/ui/no_std/` From b2f19eac2f139d35d9398ba2e90c2c424e84792b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Heath=20Dutton=F0=9F=95=B4=EF=B8=8F?= Date: Wed, 24 Dec 2025 23:41:40 -0500 Subject: [PATCH 458/489] rustdoc: fix duplicate Re-exports sections When a module contains both `pub extern crate` and `pub use` items, they were being rendered under two separate "Re-exports" section headers instead of one. This happened because the code iterated over each ItemType separately and rendered a section header for each, even though both ExternCrate and Import map to the same ItemSection. This fix tracks the current section and only renders a new header when the section actually changes, consolidating items that belong to the same section under a single header. --- src/librustdoc/html/render/print_item.rs | 39 ++++++++++++++----- .../duplicate-reexports-section-150211.rs | 19 +++++++++ 2 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 tests/rustdoc/extern/duplicate-reexports-section-150211.rs diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 0b52c0b56b82..ccf6490877d6 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -398,18 +398,34 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i let mut types = not_stripped_items.keys().copied().collect::>(); types.sort_unstable_by(|a, b| reorder(*a).cmp(&reorder(*b))); + let mut last_section: Option = None; + for type_ in types { let my_section = item_ty_to_section(type_); - let tag = if my_section == super::ItemSection::Reexports { - REEXPORTS_TABLE_OPEN - } else { - ITEM_TABLE_OPEN - }; - write!( - w, - "{}", - write_section_heading(my_section.name(), &cx.derive_id(my_section.id()), None, tag) - )?; + + // Only render section heading if the section changed + if last_section != Some(my_section) { + // Close the previous section if there was one + if last_section.is_some() { + w.write_str(ITEM_TABLE_CLOSE)?; + } + let tag = if my_section == super::ItemSection::Reexports { + REEXPORTS_TABLE_OPEN + } else { + ITEM_TABLE_OPEN + }; + write!( + w, + "{}", + write_section_heading( + my_section.name(), + &cx.derive_id(my_section.id()), + None, + tag + ) + )?; + last_section = Some(my_section); + } for (_, myitem) in ¬_stripped_items[&type_] { match myitem.kind { @@ -526,6 +542,9 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i } } } + } + // Close the final section + if last_section.is_some() { w.write_str(ITEM_TABLE_CLOSE)?; } diff --git a/tests/rustdoc/extern/duplicate-reexports-section-150211.rs b/tests/rustdoc/extern/duplicate-reexports-section-150211.rs new file mode 100644 index 000000000000..41f80cc6ab75 --- /dev/null +++ b/tests/rustdoc/extern/duplicate-reexports-section-150211.rs @@ -0,0 +1,19 @@ +//@ aux-build:pub-extern-crate.rs + +// Regression test for issue . +// When a module has both `pub extern crate` and `pub use` items, +// they should both appear under a single "Re-exports" section, +// not two separate sections. + +//@ has duplicate_reexports_section_150211/index.html +// Verify there's exactly one Re-exports section header +//@ count - '//h2[@id="reexports"]' 1 +//@ has - '//h2[@id="reexports"]' 'Re-exports' +// Verify both the extern crate and the use item are present +//@ has - '//code' 'pub extern crate inner;' +//@ has - '//code' 'pub use inner::SomeStruct;' + +pub extern crate inner; + +#[doc(no_inline)] +pub use inner::SomeStruct; From b460a1d5e2b6124596f37b49647d7da1aa21f8aa Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Thu, 25 Dec 2025 20:50:52 +0100 Subject: [PATCH 459/489] Bump nightly version -> 2025-12-25 --- clippy_utils/README.md | 2 +- rust-toolchain.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_utils/README.md b/clippy_utils/README.md index dc8695fef9f5..01257c1a3059 100644 --- a/clippy_utils/README.md +++ b/clippy_utils/README.md @@ -8,7 +8,7 @@ This crate is only guaranteed to build with this `nightly` toolchain: ``` -nightly-2025-12-11 +nightly-2025-12-25 ``` diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1384f4078ebe..dbec79e111fb 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] # begin autogenerated nightly -channel = "nightly-2025-12-11" +channel = "nightly-2025-12-25" # end autogenerated nightly components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] profile = "minimal" From 28d62f083376f956f28b6b3910446a2f171959b8 Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Thu, 25 Dec 2025 20:51:01 +0100 Subject: [PATCH 460/489] Don't take rustc-literal-escaper from sysroot This resulted in the following error for me: error[E0464]: multiple candidates for `rlib` dependency `rustc_literal_escaper` found --> clippy_dev/src/lib.rs:25:1 | 25 | extern crate rustc_literal_escaper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: candidate #1: /home/pkrones/.rustup/toolchains/nightly-2025-12-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_literal_escaper-4f30574e01c3dad1.rlib = note: candidate #2: /home/pkrones/.rustup/toolchains/nightly-2025-12-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_literal_escaper-c8a0e29ad1040cee.rmeta Other tools in the Rust repo also take that as an explicit dependency, like rust-analyzer or lint-docs. --- clippy_dev/Cargo.toml | 1 + clippy_dev/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_dev/Cargo.toml b/clippy_dev/Cargo.toml index 10c08dba50b9..c2abbac37535 100644 --- a/clippy_dev/Cargo.toml +++ b/clippy_dev/Cargo.toml @@ -10,6 +10,7 @@ clap = { version = "4.4", features = ["derive"] } indoc = "1.0" itertools = "0.12" opener = "0.7" +rustc-literal-escaper = "0.0.5" walkdir = "2.3" [package.metadata.rust-analyzer] diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index dcca08aee7e6..cd103908be03 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -22,7 +22,6 @@ extern crate rustc_arena; #[expect(unused_extern_crates, reason = "required to link to rustc crates")] extern crate rustc_driver; extern crate rustc_lexer; -extern crate rustc_literal_escaper; pub mod deprecate_lint; pub mod dogfood; From b04a3dce20881d4e846289f5cf34febcaf04a29f Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Thu, 25 Dec 2025 23:25:04 +0100 Subject: [PATCH 461/489] Update Cargo.lock --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index 870259429742..9e4b2915feff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -666,6 +666,7 @@ dependencies = [ "indoc", "itertools", "opener", + "rustc-literal-escaper", "walkdir", ] From 4d43e7808292a687716bfd64c5e90b9862e5ab85 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 15 Oct 2025 09:25:24 +0200 Subject: [PATCH 462/489] Add `dead-code/unused-fn-with-check-pass` UI test --- tests/ui/lint/dead-code/unused-fn-with-check-pass.rs | 8 ++++++++ .../lint/dead-code/unused-fn-with-check-pass.stderr | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/ui/lint/dead-code/unused-fn-with-check-pass.rs create mode 100644 tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr diff --git a/tests/ui/lint/dead-code/unused-fn-with-check-pass.rs b/tests/ui/lint/dead-code/unused-fn-with-check-pass.rs new file mode 100644 index 000000000000..a4853e125a1a --- /dev/null +++ b/tests/ui/lint/dead-code/unused-fn-with-check-pass.rs @@ -0,0 +1,8 @@ +//@ check-pass +//@ compile-flags: -Wunused + +fn foo() -> &'static str { //~ WARN function `foo` is never used + "hello" +} + +fn main() {} diff --git a/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr b/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr new file mode 100644 index 000000000000..0c95c40e5122 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr @@ -0,0 +1,11 @@ +warning: function `foo` is never used + --> $DIR/unused-fn-with-check-pass.rs:4:4 + | +LL | fn foo() -> &'static str { + | ^^^ + | + = note: `-W dead-code` implied by `-W unused` + = help: to override `-W unused` add `#[allow(dead_code)]` + +warning: 1 warning emitted + From d81ff8588cd06e3e10000b4fedd1101175cbe561 Mon Sep 17 00:00:00 2001 From: Redddy Date: Fri, 26 Dec 2025 16:34:49 +0900 Subject: [PATCH 463/489] Update links in compiler/rustc_hir_analysis/README.md for type checking --- compiler/rustc_hir_analysis/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_hir_analysis/README.md b/compiler/rustc_hir_analysis/README.md index b61dbd8c9648..c47271dbdf2b 100644 --- a/compiler/rustc_hir_analysis/README.md +++ b/compiler/rustc_hir_analysis/README.md @@ -1,5 +1,5 @@ For high-level intro to how type checking works in rustc, see the -[type checking] chapter of the [rustc dev guide]. +[hir typeck] chapter of the [rustc dev guide]. -[type checking]: https://rustc-dev-guide.rust-lang.org/type-checking.html +[hir typeck]: https://rustc-dev-guide.rust-lang.org/hir-typeck/summary.html [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/ From 86cef2ff98bfd4aed625cb11229bf9ea70163bb5 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 15 Oct 2025 09:36:04 +0200 Subject: [PATCH 464/489] compiler/middle/lint: Suggest `#[expect(dead_code)]` as alternative to `#[allow(dead_code)]` --- compiler/rustc_middle/src/lint.rs | 13 ++++++++++--- .../ui/derives/derive-debug-uninhabited-enum.stderr | 2 +- .../lint/dead-code/unused-fn-with-check-pass.stderr | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index bed902e8334b..e4715f6e2c10 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -265,9 +265,16 @@ fn explain_lint_level_source( "`{flag} {hyphen_case_lint_name}` implied by `{flag} {hyphen_case_flag_val}`" )); if matches!(orig_level, Level::Warn | Level::Deny) { - err.help_once(format!( - "to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`" - )); + let help = if name == "dead_code" { + format!( + "to override `{flag} {hyphen_case_flag_val}` add `#[expect({name})]` or `#[allow({name})]`" + ) + } else { + format!( + "to override `{flag} {hyphen_case_flag_val}` add `#[allow({name})]`" + ) + }; + err.help_once(help); } } } diff --git a/tests/ui/derives/derive-debug-uninhabited-enum.stderr b/tests/ui/derives/derive-debug-uninhabited-enum.stderr index 4911b6b6cded..90f4d34b1c5c 100644 --- a/tests/ui/derives/derive-debug-uninhabited-enum.stderr +++ b/tests/ui/derives/derive-debug-uninhabited-enum.stderr @@ -9,7 +9,7 @@ LL | Void(Void), | = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis = note: `-W dead-code` implied by `-W unused` - = help: to override `-W unused` add `#[allow(dead_code)]` + = help: to override `-W unused` add `#[expect(dead_code)]` or `#[allow(dead_code)]` warning: 1 warning emitted diff --git a/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr b/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr index 0c95c40e5122..add938553563 100644 --- a/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr +++ b/tests/ui/lint/dead-code/unused-fn-with-check-pass.stderr @@ -5,7 +5,7 @@ LL | fn foo() -> &'static str { | ^^^ | = note: `-W dead-code` implied by `-W unused` - = help: to override `-W unused` add `#[allow(dead_code)]` + = help: to override `-W unused` add `#[expect(dead_code)]` or `#[allow(dead_code)]` warning: 1 warning emitted From 6f06d386b82295b3e19d5bdfb559611b052d03ef Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Fri, 26 Dec 2025 08:46:49 +0100 Subject: [PATCH 465/489] cpuid is safe since the stdarch sync, so remove unsafe from usages --- .../libm/src/math/arch/x86/detect.rs | 12 +++++----- library/std/src/sys/pal/uefi/time.rs | 4 ++-- library/std/src/sys/random/uefi.rs | 4 ++-- library/std_detect/src/detect/os/x86.rs | 23 +++++++++---------- .../src/bin/log/tracing_chrome_instant.rs | 2 +- .../tests/source/cfg_if/detect/os/x86.rs | 10 ++++---- .../tests/target/cfg_if/detect/os/x86.rs | 10 ++++---- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/library/compiler-builtins/libm/src/math/arch/x86/detect.rs b/library/compiler-builtins/libm/src/math/arch/x86/detect.rs index e6d9b040bfaf..5391a68228ed 100644 --- a/library/compiler-builtins/libm/src/math/arch/x86/detect.rs +++ b/library/compiler-builtins/libm/src/math/arch/x86/detect.rs @@ -57,7 +57,7 @@ fn load_x86_features() -> Flags { // (in that order) let mut vendor_id = [0u8; 12]; let max_basic_leaf; - unsafe { + { let CpuidResult { eax, ebx, ecx, edx } = __cpuid(0); max_basic_leaf = eax; vendor_id[0..4].copy_from_slice(&ebx.to_ne_bytes()); @@ -72,7 +72,7 @@ fn load_x86_features() -> Flags { // EAX = 1, ECX = 0: Queries "Processor Info and Feature Bits"; // Contains information about most x86 features. - let CpuidResult { ecx, edx, .. } = unsafe { __cpuid(0x0000_0001_u32) }; + let CpuidResult { ecx, edx, .. } = __cpuid(0x0000_0001_u32); let proc_info_ecx = Flags::from_bits(ecx); let proc_info_edx = Flags::from_bits(edx); @@ -82,23 +82,23 @@ fn load_x86_features() -> Flags { let mut extended_features_edx = Flags::empty(); let mut extended_features_eax_leaf_1 = Flags::empty(); if max_basic_leaf >= 7 { - let CpuidResult { ebx, edx, .. } = unsafe { __cpuid(0x0000_0007_u32) }; + let CpuidResult { ebx, edx, .. } = __cpuid(0x0000_0007_u32); extended_features_ebx = Flags::from_bits(ebx); extended_features_edx = Flags::from_bits(edx); - let CpuidResult { eax, .. } = unsafe { __cpuid_count(0x0000_0007_u32, 0x0000_0001_u32) }; + let CpuidResult { eax, .. } = __cpuid_count(0x0000_0007_u32, 0x0000_0001_u32); extended_features_eax_leaf_1 = Flags::from_bits(eax) } // EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported // - EAX returns the max leaf value for extended information, that is, // `cpuid` calls in range [0x8000_0000; u32::MAX]: - let extended_max_basic_leaf = unsafe { __cpuid(0x8000_0000_u32) }.eax; + let extended_max_basic_leaf = __cpuid(0x8000_0000_u32).eax; // EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature Bits" let mut extended_proc_info_ecx = Flags::empty(); if extended_max_basic_leaf >= 1 { - let CpuidResult { ecx, .. } = unsafe { __cpuid(0x8000_0001_u32) }; + let CpuidResult { ecx, .. } = __cpuid(0x8000_0001_u32); extended_proc_info_ecx = Flags::from_bits(ecx); } diff --git a/library/std/src/sys/pal/uefi/time.rs b/library/std/src/sys/pal/uefi/time.rs index 861b98da18da..06809dc5bac4 100644 --- a/library/std/src/sys/pal/uefi/time.rs +++ b/library/std/src/sys/pal/uefi/time.rs @@ -297,7 +297,7 @@ pub(crate) mod instant_internal { // Inspired by [`edk2/UefiCpuPkg/Library/CpuTimerLib/CpuTimerLib.c`](https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/CpuTimerLib/CpuTimerLib.c) let freq = FREQUENCY .get_or_try_init(|| { - let cpuid = unsafe { crate::arch::x86_64::__cpuid(0x15) }; + let cpuid = crate::arch::x86_64::__cpuid(0x15); if cpuid.eax == 0 || cpuid.ebx == 0 || cpuid.ecx == 0 { return Err(()); } @@ -316,7 +316,7 @@ pub(crate) mod instant_internal { let freq = FREQUENCY .get_or_try_init(|| { - let cpuid = unsafe { crate::arch::x86::__cpuid(0x15) }; + let cpuid = crate::arch::x86::__cpuid(0x15); if cpuid.eax == 0 || cpuid.ebx == 0 || cpuid.ecx == 0 { return Err(()); } diff --git a/library/std/src/sys/random/uefi.rs b/library/std/src/sys/random/uefi.rs index 697933f197b7..f7a760083519 100644 --- a/library/std/src/sys/random/uefi.rs +++ b/library/std/src/sys/random/uefi.rs @@ -107,11 +107,11 @@ mod rdrand { { // SAFETY: All Rust x86 targets are new enough to have CPUID, and we // check that leaf 1 is supported before using it. - let cpuid0 = unsafe { arch::__cpuid(0) }; + let cpuid0 = arch::__cpuid(0); if cpuid0.eax < 1 { return false; } - let cpuid1 = unsafe { arch::__cpuid(1) }; + let cpuid1 = arch::__cpuid(1); let vendor_id = [cpuid0.ebx.to_le_bytes(), cpuid0.edx.to_le_bytes(), cpuid0.ecx.to_le_bytes()]; diff --git a/library/std_detect/src/detect/os/x86.rs b/library/std_detect/src/detect/os/x86.rs index 18925da2b275..f2205ba07dd4 100644 --- a/library/std_detect/src/detect/os/x86.rs +++ b/library/std_detect/src/detect/os/x86.rs @@ -40,10 +40,10 @@ pub(crate) fn detect_features() -> cache::Initializer { // leaf value for subsequent calls of `cpuinfo` in range [0, // 0x8000_0000]. - The vendor ID is stored in 12 u8 ascii chars, // returned in EBX, EDX, and ECX (in that order): - let (max_basic_leaf, vendor_id) = unsafe { + let (max_basic_leaf, vendor_id) = { let CpuidResult { eax: max_basic_leaf, ebx, ecx, edx } = __cpuid(0); let vendor_id: [[u8; 4]; 3] = [ebx.to_ne_bytes(), edx.to_ne_bytes(), ecx.to_ne_bytes()]; - let vendor_id: [u8; 12] = mem::transmute(vendor_id); + let vendor_id: [u8; 12] = unsafe { mem::transmute(vendor_id) }; (max_basic_leaf, vendor_id) }; @@ -54,8 +54,7 @@ pub(crate) fn detect_features() -> cache::Initializer { // EAX = 1, ECX = 0: Queries "Processor Info and Feature Bits"; // Contains information about most x86 features. - let CpuidResult { ecx: proc_info_ecx, edx: proc_info_edx, .. } = - unsafe { __cpuid(0x0000_0001_u32) }; + let CpuidResult { ecx: proc_info_ecx, edx: proc_info_edx, .. } = __cpuid(0x0000_0001_u32); // EAX = 7: Queries "Extended Features"; // Contains information about bmi,bmi2, and avx2 support. @@ -66,9 +65,9 @@ pub(crate) fn detect_features() -> cache::Initializer { extended_features_eax_leaf_1, extended_features_edx_leaf_1, ) = if max_basic_leaf >= 7 { - let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid(0x0000_0007_u32) }; + let CpuidResult { ebx, ecx, edx, .. } = __cpuid(0x0000_0007_u32); let CpuidResult { eax: eax_1, edx: edx_1, .. } = - unsafe { __cpuid_count(0x0000_0007_u32, 0x0000_0001_u32) }; + __cpuid_count(0x0000_0007_u32, 0x0000_0001_u32); (ebx, ecx, edx, eax_1, edx_1) } else { (0, 0, 0, 0, 0) // CPUID does not support "Extended Features" @@ -77,12 +76,12 @@ pub(crate) fn detect_features() -> cache::Initializer { // EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported // - EAX returns the max leaf value for extended information, that is, // `cpuid` calls in range [0x8000_0000; u32::MAX]: - let CpuidResult { eax: extended_max_basic_leaf, .. } = unsafe { __cpuid(0x8000_0000_u32) }; + let CpuidResult { eax: extended_max_basic_leaf, .. } = __cpuid(0x8000_0000_u32); // EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature // Bits" let extended_proc_info_ecx = if extended_max_basic_leaf >= 1 { - let CpuidResult { ecx, .. } = unsafe { __cpuid(0x8000_0001_u32) }; + let CpuidResult { ecx, .. } = __cpuid(0x8000_0001_u32); ecx } else { 0 @@ -132,7 +131,7 @@ pub(crate) fn detect_features() -> cache::Initializer { // Detect if CPUID.19h available if bit::test(extended_features_ecx as usize, 23) { - let CpuidResult { ebx, .. } = unsafe { __cpuid(0x19) }; + let CpuidResult { ebx, .. } = __cpuid(0x19); enable(ebx, 0, Feature::kl); enable(ebx, 2, Feature::widekl); } @@ -223,7 +222,7 @@ pub(crate) fn detect_features() -> cache::Initializer { // ECX = 1): if max_basic_leaf >= 0xd { let CpuidResult { eax: proc_extended_state1_eax, .. } = - unsafe { __cpuid_count(0xd_u32, 1) }; + __cpuid_count(0xd_u32, 1); enable(proc_extended_state1_eax, 0, Feature::xsaveopt); enable(proc_extended_state1_eax, 1, Feature::xsavec); enable(proc_extended_state1_eax, 3, Feature::xsaves); @@ -282,7 +281,7 @@ pub(crate) fn detect_features() -> cache::Initializer { if max_basic_leaf >= 0x1e { let CpuidResult { eax: amx_feature_flags_eax, .. } = - unsafe { __cpuid_count(0x1e_u32, 1) }; + __cpuid_count(0x1e_u32, 1); enable(amx_feature_flags_eax, 4, Feature::amx_fp8); enable(amx_feature_flags_eax, 6, Feature::amx_tf32); @@ -297,7 +296,7 @@ pub(crate) fn detect_features() -> cache::Initializer { let avx10_1 = enable(extended_features_edx_leaf_1, 19, Feature::avx10_1); if avx10_1 { - let CpuidResult { ebx, .. } = unsafe { __cpuid(0x24) }; + let CpuidResult { ebx, .. } = __cpuid(0x24); let avx10_version = ebx & 0xff; if avx10_version >= 2 { value.set(Feature::avx10_2 as u32); diff --git a/src/tools/miri/src/bin/log/tracing_chrome_instant.rs b/src/tools/miri/src/bin/log/tracing_chrome_instant.rs index f400bc20a7b5..b5f00852b82f 100644 --- a/src/tools/miri/src/bin/log/tracing_chrome_instant.rs +++ b/src/tools/miri/src/bin/log/tracing_chrome_instant.rs @@ -151,7 +151,7 @@ mod tsc { // implemented like https://docs.rs/raw-cpuid/latest/src/raw_cpuid/extended.rs.html#965-967 const LEAF: u32 = 0x80000007; // this is the leaf for "advanced power management info" - let cpuid = unsafe { __cpuid(LEAF) }; + let cpuid = __cpuid(LEAF); (cpuid.edx & (1 << 8)) != 0 // EDX bit 8 indicates invariant TSC } diff --git a/src/tools/rustfmt/tests/source/cfg_if/detect/os/x86.rs b/src/tools/rustfmt/tests/source/cfg_if/detect/os/x86.rs index b9adc67221ae..8b45a5bbd269 100644 --- a/src/tools/rustfmt/tests/source/cfg_if/detect/os/x86.rs +++ b/src/tools/rustfmt/tests/source/cfg_if/detect/os/x86.rs @@ -66,13 +66,13 @@ fn detect_features() -> cache::Initializer { ecx: proc_info_ecx, edx: proc_info_edx, .. - } = unsafe { __cpuid(0x0000_0001_u32) }; + } = __cpuid(0x0000_0001_u32); // EAX = 7, ECX = 0: Queries "Extended Features"; // Contains information about bmi,bmi2, and avx2 support. let (extended_features_ebx, extended_features_ecx) = if max_basic_leaf >= 7 { - let CpuidResult { ebx, ecx, .. } = unsafe { __cpuid(0x0000_0007_u32) }; + let CpuidResult { ebx, ecx, .. } = __cpuid(0x0000_0007_u32); (ebx, ecx) } else { (0, 0) // CPUID does not support "Extended Features" @@ -84,12 +84,12 @@ fn detect_features() -> cache::Initializer { let CpuidResult { eax: extended_max_basic_leaf, .. - } = unsafe { __cpuid(0x8000_0000_u32) }; + } = __cpuid(0x8000_0000_u32); // EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature // Bits" let extended_proc_info_ecx = if extended_max_basic_leaf >= 1 { - let CpuidResult { ecx, .. } = unsafe { __cpuid(0x8000_0001_u32) }; + let CpuidResult { ecx, .. } = __cpuid(0x8000_0001_u32); ecx } else { 0 @@ -182,7 +182,7 @@ fn detect_features() -> cache::Initializer { let CpuidResult { eax: proc_extended_state1_eax, .. - } = unsafe { __cpuid_count(0xd_u32, 1) }; + } = __cpuid_count(0xd_u32, 1); enable(proc_extended_state1_eax, 0, Feature::xsaveopt); enable(proc_extended_state1_eax, 1, Feature::xsavec); enable(proc_extended_state1_eax, 3, Feature::xsaves); diff --git a/src/tools/rustfmt/tests/target/cfg_if/detect/os/x86.rs b/src/tools/rustfmt/tests/target/cfg_if/detect/os/x86.rs index 944b51615f8e..fb7136d83911 100644 --- a/src/tools/rustfmt/tests/target/cfg_if/detect/os/x86.rs +++ b/src/tools/rustfmt/tests/target/cfg_if/detect/os/x86.rs @@ -66,12 +66,12 @@ fn detect_features() -> cache::Initializer { ecx: proc_info_ecx, edx: proc_info_edx, .. - } = unsafe { __cpuid(0x0000_0001_u32) }; + } = __cpuid(0x0000_0001_u32); // EAX = 7, ECX = 0: Queries "Extended Features"; // Contains information about bmi,bmi2, and avx2 support. let (extended_features_ebx, extended_features_ecx) = if max_basic_leaf >= 7 { - let CpuidResult { ebx, ecx, .. } = unsafe { __cpuid(0x0000_0007_u32) }; + let CpuidResult { ebx, ecx, .. } = __cpuid(0x0000_0007_u32); (ebx, ecx) } else { (0, 0) // CPUID does not support "Extended Features" @@ -83,12 +83,12 @@ fn detect_features() -> cache::Initializer { let CpuidResult { eax: extended_max_basic_leaf, .. - } = unsafe { __cpuid(0x8000_0000_u32) }; + } = __cpuid(0x8000_0000_u32); // EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature // Bits" let extended_proc_info_ecx = if extended_max_basic_leaf >= 1 { - let CpuidResult { ecx, .. } = unsafe { __cpuid(0x8000_0001_u32) }; + let CpuidResult { ecx, .. } = __cpuid(0x8000_0001_u32); ecx } else { 0 @@ -181,7 +181,7 @@ fn detect_features() -> cache::Initializer { let CpuidResult { eax: proc_extended_state1_eax, .. - } = unsafe { __cpuid_count(0xd_u32, 1) }; + } = __cpuid_count(0xd_u32, 1); enable(proc_extended_state1_eax, 0, Feature::xsaveopt); enable(proc_extended_state1_eax, 1, Feature::xsavec); enable(proc_extended_state1_eax, 3, Feature::xsaves); From 517411f143f43689add7f5739a200fbdf8e2d03a Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Thu, 25 Dec 2025 19:18:32 +0000 Subject: [PATCH 466/489] add const kind match --- compiler/rustc_ty_utils/src/consts.rs | 15 +++-------- .../printing_valtrees_supports_non_values.rs | 27 +++++++++++++++++++ ...inting_valtrees_supports_non_values.stderr | 26 ++++++++++++++++++ 3 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs create mode 100644 tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.stderr diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index d8d5b7fc75cc..9be8a48c740a 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -39,25 +39,16 @@ fn destructure_const<'tcx>( (field_consts, None) } ty::Adt(def, _) if def.variants().is_empty() => bug!("unreachable"), - ty::Adt(def, args) => { - let (variant_idx, branches) = if def.is_enum() { + ty::Adt(def, _) => { + let (variant_idx, field_consts) = if def.is_enum() { let (head, rest) = branches.split_first().unwrap(); (VariantIdx::from_u32(head.to_leaf().to_u32()), rest) } else { (FIRST_VARIANT, branches) }; - let fields = &def.variant(variant_idx).fields; - let mut field_consts = Vec::with_capacity(fields.len()); - - for (field, field_valtree) in iter::zip(fields, branches) { - let field_ty = field.ty(tcx, args); - let field_const = - ty::Const::new_value(tcx, field_valtree.to_value().valtree, field_ty); - field_consts.push(field_const); - } debug!(?field_consts); - (field_consts, Some(variant_idx)) + (field_consts.to_vec(), Some(variant_idx)) } ty::Tuple(elem_tys) => { let fields = iter::zip(*elem_tys, branches) diff --git a/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs new file mode 100644 index 000000000000..fbe310f7de4c --- /dev/null +++ b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs @@ -0,0 +1,27 @@ +//! Regression test for +//@ edition 2024 + +#![allow(incomplete_features)] +#![feature(min_generic_const_args, adt_const_params)] + +#[derive(Eq, PartialEq, core::marker::ConstParamTy)] +struct Foo; + +trait Trait { + #[type_const] + const ASSOC: usize; +} + +fn foo() {} + +fn bar() { + foo::<{ Option::Some:: { 0: N } }>; + //~^ ERROR the constant `Option::::Some(N)` is not of type `Foo` +} + +fn baz() { + foo::<{ Option::Some:: { 0: ::ASSOC } }>(); + //~^ ERROR the constant `Option::::Some(::ASSOC)` is not of type `Foo` +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.stderr b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.stderr new file mode 100644 index 000000000000..8b2871f2b6d3 --- /dev/null +++ b/tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.stderr @@ -0,0 +1,26 @@ +error: the constant `Option::::Some(N)` is not of type `Foo` + --> $DIR/printing_valtrees_supports_non_values.rs:18:13 + | +LL | foo::<{ Option::Some:: { 0: N } }>; + | ^^^^^^^^^^^^^^^^^^^ expected `Foo`, found `Option` + | +note: required by a const generic parameter in `foo` + --> $DIR/printing_valtrees_supports_non_values.rs:15:8 + | +LL | fn foo() {} + | ^^^^^^^^^^^^ required by this const generic parameter in `foo` + +error: the constant `Option::::Some(::ASSOC)` is not of type `Foo` + --> $DIR/printing_valtrees_supports_non_values.rs:23:13 + | +LL | foo::<{ Option::Some:: { 0: ::ASSOC } }>(); + | ^^^^^^^^^^^^^^^^^^^ expected `Foo`, found `Option` + | +note: required by a const generic parameter in `foo` + --> $DIR/printing_valtrees_supports_non_values.rs:15:8 + | +LL | fn foo() {} + | ^^^^^^^^^^^^ required by this const generic parameter in `foo` + +error: aborting due to 2 previous errors + From 90e80f5b81976be03d46264a1b77625b55ae8c22 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 26 Dec 2025 16:38:46 +0100 Subject: [PATCH 467/489] Document relative and absolute paths handling in `--remap-path-prefix` --- src/doc/rustc/src/remap-source-paths.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/doc/rustc/src/remap-source-paths.md b/src/doc/rustc/src/remap-source-paths.md index 03f5d98091cc..ebe92d71158a 100644 --- a/src/doc/rustc/src/remap-source-paths.md +++ b/src/doc/rustc/src/remap-source-paths.md @@ -17,6 +17,20 @@ The replacement is purely textual, with no consideration of the current system's When multiple remappings are given and several of them match, the **last** matching one is applied. +### Relative paths + +Some build systems, such as Cargo, may compile crates using relative paths (for example, +`src/main.rs` instead of `/home/user/project/src/main.rs)`. + +`rustc` preserves these relative paths where possible. However, certain inputs +(like `#[path = "..."]`) and outputs (such as debug information) may still contain absolute paths. + +To ensure consistency, it’s recommended to remap both relative and absolute paths. + +```bash +rustc --remap-path-prefix "src/=/redacted/src" --remap-path-prefix "/home/user/project=/redacted" +``` + ### Example ```bash From 09f57eb96f8a7652eebae41a870e7af0f3fd65e6 Mon Sep 17 00:00:00 2001 From: BioTomateHP Date: Fri, 26 Dec 2025 18:05:59 +0100 Subject: [PATCH 468/489] Update hir.rs: fix typo, conform to max_width --- compiler/rustc_hir/src/hir.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index e176c703b33e..a1fdb81f0ab3 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -150,10 +150,13 @@ impl From for LifetimeSyntax { /// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing` /// — there's no way to "elide" these lifetimes. #[derive(Debug, Copy, Clone, HashStable_Generic)] -// Raise the aligement to at least 4 bytes - this is relied on in other parts of the compiler(for pointer tagging): -// https://github.com/rust-lang/rust/blob/ce5fdd7d42aba9a2925692e11af2bd39cf37798a/compiler/rustc_data_structures/src/tagged_ptr.rs#L163 -// Removing this `repr(4)` will cause the compiler to not build on platforms like `m68k` Linux, where the aligement of u32 and usize is only 2. -// Since `repr(align)` may only raise aligement, this has no effect on platforms where the aligement is already sufficient. +// Raise the alignment to at least 4 bytes. +// This is relied on in other parts of the compiler (for pointer tagging): +// +// Removing this `repr(4)` will cause the compiler to not build on platforms +// like `m68k` Linux, where the alignment of u32 and usize is only 2. +// Since `repr(align)` may only raise alignment, this has no effect on +// platforms where the alignment is already sufficient. #[repr(align(4))] pub struct Lifetime { #[stable_hasher(ignore)] From 94e16291e00883a9c8324f700460f76c9db4fe85 Mon Sep 17 00:00:00 2001 From: Edvin Bryntesson Date: Mon, 22 Dec 2025 00:16:21 +0100 Subject: [PATCH 469/489] Port `#[rustc_must_implement_one_of]` to attribute parser --- .../src/attributes/rustc_internal.rs | 47 ++++++++++ compiler/rustc_attr_parsing/src/context.rs | 17 +++- compiler/rustc_attr_parsing/src/parser.rs | 9 +- .../rustc_hir/src/attrs/data_structures.rs | 3 + .../rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_hir_analysis/messages.ftl | 18 ---- .../rustc_hir_analysis/src/check/check.rs | 4 +- compiler/rustc_hir_analysis/src/collect.rs | 86 ++----------------- compiler/rustc_hir_analysis/src/errors.rs | 60 ------------- compiler/rustc_passes/messages.ftl | 18 +++- compiler/rustc_passes/src/check_attr.rs | 74 +++++++++++++--- compiler/rustc_passes/src/errors.rs | 55 ++++++++++-- compiler/rustc_session/messages.ftl | 2 + compiler/rustc_session/src/errors.rs | 7 ++ .../rustc_must_implement_one_of_misuse.rs | 6 +- .../rustc_must_implement_one_of_misuse.stderr | 37 ++++---- 16 files changed, 236 insertions(+), 208 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index be4e2210c5ee..922a5bd297ac 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -1,4 +1,5 @@ use rustc_ast::{LitIntType, LitKind, MetaItemLit}; +use rustc_session::errors; use super::prelude::*; use super::util::parse_single_integer; @@ -13,6 +14,52 @@ impl NoArgsAttributeParser for RustcMainParser { const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain; } +pub(crate) struct RustcMustImplementOneOfParser; + +impl SingleAttributeParser for RustcMustImplementOneOfParser { + const PATH: &[Symbol] = &[sym::rustc_must_implement_one_of]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]); + const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost; + const TEMPLATE: AttributeTemplate = template!(List: &["function1, function2, ..."]); + fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { + let Some(list) = args.list() else { + cx.expected_list(cx.attr_span, args); + return None; + }; + + let mut fn_names = ThinVec::new(); + + let inputs: Vec<_> = list.mixed().collect(); + + if inputs.len() < 2 { + cx.expected_list_with_num_args_or_more(2, list.span); + return None; + } + + let mut errored = false; + for argument in inputs { + let Some(meta) = argument.meta_item() else { + cx.expected_identifier(argument.span()); + return None; + }; + + let Some(ident) = meta.ident() else { + cx.dcx().emit_err(errors::MustBeNameOfAssociatedFunction { span: meta.span() }); + errored = true; + continue; + }; + + fn_names.push(ident); + } + if errored { + return None; + } + + Some(AttributeKind::RustcMustImplementOneOf { attr_span: cx.attr_span, fn_names }) + } +} + pub(crate) struct RustcNeverReturnsNullPointerParser; impl NoArgsAttributeParser for RustcNeverReturnsNullPointerParser { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index af0aee0b1e0b..1113da0dd5db 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -63,8 +63,9 @@ use crate::attributes::rustc_internal::{ RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser, RustcLintDiagnosticsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser, - RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcNeverReturnsNullPointerParser, - RustcNoImplicitAutorefsParser, RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, + RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcMustImplementOneOfParser, + RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, + RustcObjectLifetimeDefaultParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser, }; use crate::attributes::semantics::MayDangleParser; @@ -215,6 +216,7 @@ attribute_parsers!( Single, Single, Single, + Single, Single, Single, Single, @@ -490,8 +492,15 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { self.emit_parse_error(span, AttributeParseErrorReason::ExpectedList) } - pub(crate) fn expected_list_with_num_args_or_more(&self, args: usize, span: Span) -> ErrorGuaranteed { - self.emit_parse_error(span, AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args}) + pub(crate) fn expected_list_with_num_args_or_more( + &self, + args: usize, + span: Span, + ) -> ErrorGuaranteed { + self.emit_parse_error( + span, + AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args }, + ) } pub(crate) fn expected_list_or_no_args(&self, span: Span) -> ErrorGuaranteed { diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 9551744d5ec5..474f848038d1 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -8,7 +8,9 @@ use std::fmt::{Debug, Display}; use rustc_ast::token::{self, Delimiter, MetaVarKind}; use rustc_ast::tokenstream::TokenStream; -use rustc_ast::{AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, Path, StmtKind, UnOp}; +use rustc_ast::{ + AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, Path, PathSegment, StmtKind, UnOp, +}; use rustc_ast_pretty::pprust; use rustc_errors::{Diag, PResult}; use rustc_hir::{self as hir, AttrPath}; @@ -256,6 +258,11 @@ impl Debug for MetaItemParser { } impl MetaItemParser { + /// For a single-segment meta item, returns its name; otherwise, returns `None`. + pub fn ident(&self) -> Option { + if let [PathSegment { ident, .. }] = self.path.0.segments[..] { Some(ident) } else { None } + } + pub fn span(&self) -> Span { if let Some(other) = self.args.span() { self.path.borrow().span().with_hi(other.hi()) diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index e9f9b2445deb..2c6c0d59b978 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -949,6 +949,9 @@ pub enum AttributeKind { /// Represents `#[rustc_main]`. RustcMain, + /// Represents `#[rustc_must_implement_one_of]` + RustcMustImplementOneOf { attr_span: Span, fn_names: ThinVec }, + /// Represents `#[rustc_never_returns_null_ptr]` RustcNeverReturnsNullPointer, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 68456dfe4c29..7ab23c6207d6 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -100,6 +100,7 @@ impl AttributeKind { RustcLintQueryInstability => Yes, RustcLintUntrackedQueryInformation => Yes, RustcMain => No, + RustcMustImplementOneOf { .. } => No, RustcNeverReturnsNullPointer => Yes, RustcNoImplicitAutorefs => Yes, RustcObjectLifetimeDefault => No, diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index 8022a48ee137..416a6b19edfc 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -208,14 +208,6 @@ hir_analysis_field_already_declared_previous_nested = .previous_decl_label = `{$field_name}` first declared here in this unnamed field .previous_nested_field_decl_note = field `{$field_name}` first declared here -hir_analysis_function_not_found_in_trait = function not found in this trait - -hir_analysis_function_not_have_default_implementation = function doesn't have a default implementation - .note = required by this annotation - -hir_analysis_functions_names_duplicated = functions names are duplicated - .note = all `#[rustc_must_implement_one_of]` arguments must be unique - hir_analysis_generic_args_on_overridden_impl = could not resolve generic parameters on overridden impl hir_analysis_impl_not_marked_default = `{$ident}` specializes an item from a parent `impl`, but that item is not marked `default` @@ -381,16 +373,6 @@ hir_analysis_missing_type_params = *[other] parameters } must be specified on the object type -hir_analysis_must_be_name_of_associated_function = must be a name of an associated function - -hir_analysis_must_implement_not_function = not a function - -hir_analysis_must_implement_not_function_note = all `#[rustc_must_implement_one_of]` arguments must be associated function names - -hir_analysis_must_implement_not_function_span_note = required by this annotation - -hir_analysis_must_implement_one_of_attribute = the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args - hir_analysis_no_variant_named = no variant named `{$ident}` found for enum `{$ty}` hir_analysis_not_supported_delegation = {$descr} diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index a81df02f023f..ad66003a6bf9 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1340,9 +1340,7 @@ fn check_impl_items_against_trait<'tcx>( } if let Some(missing_items) = must_implement_one_of { - let attr_span = tcx - .get_attr(trait_ref.def_id, sym::rustc_must_implement_one_of) - .map(|attr| attr.span()); + let attr_span = find_attr!(tcx.get_all_attrs(trait_ref.def_id), AttributeKind::RustcMustImplementOneOf {attr_span, ..} => *attr_span); missing_items_must_implement_one_of_err( tcx, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 2e06684e0c7a..9343bcd27a33 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -22,7 +22,6 @@ use std::ops::Bound; use rustc_abi::{ExternAbi, Size}; use rustc_ast::Recovered; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; -use rustc_data_structures::unord::UnordMap; use rustc_errors::{ Applicability, Diag, DiagCtxtHandle, E0228, ErrorGuaranteed, StashKey, struct_span_code_err, }; @@ -916,84 +915,15 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef { } else { ty::trait_def::TraitSpecializationKind::None }; - let must_implement_one_of = attrs - .iter() - .find(|attr| attr.has_name(sym::rustc_must_implement_one_of)) - // Check that there are at least 2 arguments of `#[rustc_must_implement_one_of]` - // and that they are all identifiers - .and_then(|attr| match attr.meta_item_list() { - Some(items) if items.len() < 2 => { - tcx.dcx().emit_err(errors::MustImplementOneOfAttribute { span: attr.span() }); - None - } - Some(items) => items - .into_iter() - .map(|item| item.ident().ok_or(item.span())) - .collect::, _>>() - .map_err(|span| { - tcx.dcx().emit_err(errors::MustBeNameOfAssociatedFunction { span }); - }) - .ok() - .zip(Some(attr.span())), - // Error is reported by `rustc_attr!` - None => None, - }) - // Check that all arguments of `#[rustc_must_implement_one_of]` reference - // functions in the trait with default implementations - .and_then(|(list, attr_span)| { - let errors = list.iter().filter_map(|ident| { - let item = tcx - .associated_items(def_id) - .filter_by_name_unhygienic(ident.name) - .find(|item| item.ident(tcx) == *ident); - - match item { - Some(item) if matches!(item.kind, ty::AssocKind::Fn { .. }) => { - if !item.defaultness(tcx).has_value() { - tcx.dcx().emit_err(errors::FunctionNotHaveDefaultImplementation { - span: tcx.def_span(item.def_id), - note_span: attr_span, - }); - - return Some(()); - } - - return None; - } - Some(item) => { - tcx.dcx().emit_err(errors::MustImplementNotFunction { - span: tcx.def_span(item.def_id), - span_note: errors::MustImplementNotFunctionSpanNote { span: attr_span }, - note: errors::MustImplementNotFunctionNote {}, - }); - } - None => { - tcx.dcx().emit_err(errors::FunctionNotFoundInTrait { span: ident.span }); - } - } - - Some(()) - }); - - (errors.count() == 0).then_some(list) - }) - // Check for duplicates - .and_then(|list| { - let mut set: UnordMap = Default::default(); - let mut no_dups = true; - - for ident in &*list { - if let Some(dup) = set.insert(ident.name, ident.span) { - tcx.dcx() - .emit_err(errors::FunctionNamesDuplicated { spans: vec![dup, ident.span] }); - - no_dups = false; - } - } - - no_dups.then_some(list) - }); + let must_implement_one_of = find_attr!( + attrs, + AttributeKind::RustcMustImplementOneOf { fn_names, .. } => + fn_names + .iter() + .cloned() + .collect::>() + ); let deny_explicit_impl = find_attr!(attrs, AttributeKind::DenyExplicitImpl(_)); let implement_via_object = !find_attr!(attrs, AttributeKind::DoNotImplementViaObject(_)); diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 8e17a4962520..b388396ac4fc 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -741,66 +741,6 @@ pub(crate) struct ParenSugarAttribute { pub span: Span, } -#[derive(Diagnostic)] -#[diag(hir_analysis_must_implement_one_of_attribute)] -pub(crate) struct MustImplementOneOfAttribute { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] -#[diag(hir_analysis_must_be_name_of_associated_function)] -pub(crate) struct MustBeNameOfAssociatedFunction { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] -#[diag(hir_analysis_function_not_have_default_implementation)] -pub(crate) struct FunctionNotHaveDefaultImplementation { - #[primary_span] - pub span: Span, - #[note] - pub note_span: Span, -} - -#[derive(Diagnostic)] -#[diag(hir_analysis_must_implement_not_function)] -pub(crate) struct MustImplementNotFunction { - #[primary_span] - pub span: Span, - #[subdiagnostic] - pub span_note: MustImplementNotFunctionSpanNote, - #[subdiagnostic] - pub note: MustImplementNotFunctionNote, -} - -#[derive(Subdiagnostic)] -#[note(hir_analysis_must_implement_not_function_span_note)] -pub(crate) struct MustImplementNotFunctionSpanNote { - #[primary_span] - pub span: Span, -} - -#[derive(Subdiagnostic)] -#[note(hir_analysis_must_implement_not_function_note)] -pub(crate) struct MustImplementNotFunctionNote {} - -#[derive(Diagnostic)] -#[diag(hir_analysis_function_not_found_in_trait)] -pub(crate) struct FunctionNotFoundInTrait { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] -#[diag(hir_analysis_functions_names_duplicated)] -#[note] -pub(crate) struct FunctionNamesDuplicated { - #[primary_span] - pub spans: Vec, -} - #[derive(Diagnostic)] #[diag(hir_analysis_simd_ffi_highly_experimental)] #[help] diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index cf069b364be8..94996c0adb47 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -236,6 +236,14 @@ passes_feature_previously_declared = passes_feature_stable_twice = feature `{$feature}` is declared stable since {$since}, but was previously declared stable since {$prev_since} +passes_function_not_found_in_trait = function not found in this trait + +passes_function_not_have_default_implementation = function doesn't have a default implementation + .note = required by this annotation + +passes_functions_names_duplicated = functions names are duplicated + .note = all `#[rustc_must_implement_one_of]` arguments must be unique + passes_has_incoherent_inherent_impl = `rustc_has_incoherent_inherent_impls` attribute should be applied to types or traits .label = only adts, extern types and traits are supported @@ -370,6 +378,12 @@ passes_multiple_rustc_main = .first = first `#[rustc_main]` function .additional = additional `#[rustc_main]` function +passes_must_implement_not_function = not a function + +passes_must_implement_not_function_note = all `#[rustc_must_implement_one_of]` arguments must be associated function names + +passes_must_implement_not_function_span_note = required by this annotation + passes_must_not_suspend = `must_not_suspend` attribute should be applied to a struct, enum, union, or trait .label = is not a struct, enum, union, or trait @@ -484,10 +498,6 @@ passes_sanitize_attribute_not_allowed = .no_body = function has no body .help = sanitize attribute can be applied to a function (with body), impl block, or module -passes_should_be_applied_to_trait = - attribute should be applied to a trait - .label = not a trait - passes_trait_impl_const_stability_mismatch = const stability on the impl does not match the const stability on the trait passes_trait_impl_const_stability_mismatch_impl_stable = this impl is (implicitly) stable... passes_trait_impl_const_stability_mismatch_impl_unstable = this impl is unstable... diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 7822614a05cb..f422a7939636 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -14,6 +14,7 @@ use rustc_ast::{AttrStyle, MetaItemKind, ast}; use rustc_attr_parsing::{AttributeParser, Late}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::thin_vec::ThinVec; +use rustc_data_structures::unord::UnordMap; use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey}; use rustc_feature::{ ACCEPTED_LANG_FEATURES, AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, @@ -47,7 +48,7 @@ use rustc_session::lint::builtin::{ }; use rustc_session::parse::feature_err; use rustc_span::edition::Edition; -use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, sym}; +use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Symbol, sym}; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs}; use rustc_trait_selection::traits::ObligationCtxt; @@ -219,6 +220,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> { Attribute::Parsed(AttributeKind::EiiImpls(impls)) => { self.check_eii_impl(impls, target) }, + Attribute::Parsed(AttributeKind::RustcMustImplementOneOf { attr_span, fn_names }) => { + self.check_rustc_must_implement_one_of(*attr_span, fn_names, hir_id,target) + }, Attribute::Parsed( AttributeKind::EiiExternTarget { .. } | AttributeKind::EiiExternItem @@ -315,7 +319,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | [sym::rustc_dirty, ..] | [sym::rustc_if_this_changed, ..] | [sym::rustc_then_this_would_need, ..] => self.check_rustc_dirty_clean(attr), - [sym::rustc_must_implement_one_of, ..] => self.check_must_be_applied_to_trait(attr.span(), span, target), [sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target), [sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target), [sym::rustc_has_incoherent_inherent_impls, ..] => { @@ -445,6 +448,63 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_mix_no_mangle_export(hir_id, attrs); } + fn check_rustc_must_implement_one_of( + &self, + attr_span: Span, + list: &ThinVec, + hir_id: HirId, + target: Target, + ) { + // Ignoring invalid targets because TyCtxt::associated_items emits bug if the target isn't valid + // the parser has already produced an error for the target being invalid + if !matches!(target, Target::Trait) { + return; + } + + let def_id = hir_id.owner.def_id; + + let items = self.tcx.associated_items(def_id); + // Check that all arguments of `#[rustc_must_implement_one_of]` reference + // functions in the trait with default implementations + for ident in list { + let item = items + .filter_by_name_unhygienic(ident.name) + .find(|item| item.ident(self.tcx) == *ident); + + match item { + Some(item) if matches!(item.kind, ty::AssocKind::Fn { .. }) => { + if !item.defaultness(self.tcx).has_value() { + self.tcx.dcx().emit_err(errors::FunctionNotHaveDefaultImplementation { + span: self.tcx.def_span(item.def_id), + note_span: attr_span, + }); + } + } + Some(item) => { + self.dcx().emit_err(errors::MustImplementNotFunction { + span: self.tcx.def_span(item.def_id), + span_note: errors::MustImplementNotFunctionSpanNote { span: attr_span }, + note: errors::MustImplementNotFunctionNote {}, + }); + } + None => { + self.dcx().emit_err(errors::FunctionNotFoundInTrait { span: ident.span }); + } + } + } + // Check for duplicates + + let mut set: UnordMap = Default::default(); + + for ident in &*list { + if let Some(dup) = set.insert(ident.name, ident.span) { + self.tcx + .dcx() + .emit_err(errors::FunctionNamesDuplicated { spans: vec![dup, ident.span] }); + } + } + } + fn check_eii_impl(&self, impls: &[EiiImpl], target: Target) { for EiiImpl { span, inner_span, eii_macro, impl_marked_unsafe, is_default: _ } in impls { match target { @@ -1221,16 +1281,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks if the attribute is applied to a trait. - fn check_must_be_applied_to_trait(&self, attr_span: Span, defn_span: Span, target: Target) { - match target { - Target::Trait => {} - _ => { - self.dcx().emit_err(errors::AttrShouldBeAppliedToTrait { attr_span, defn_span }); - } - } - } - /// Checks if the `#[repr]` attributes on `item` are valid. fn check_repr( &self, diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 2b817c6dd106..af5cb29b83d0 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -89,15 +89,6 @@ pub(crate) struct NonExhaustiveWithDefaultFieldValues { pub defn_span: Span, } -#[derive(Diagnostic)] -#[diag(passes_should_be_applied_to_trait)] -pub(crate) struct AttrShouldBeAppliedToTrait { - #[primary_span] - pub attr_span: Span, - #[label] - pub defn_span: Span, -} - #[derive(Diagnostic)] #[diag(passes_doc_alias_bad_location)] pub(crate) struct DocAliasBadLocation<'a> { @@ -1323,3 +1314,49 @@ pub(crate) struct DuplicateEiiImpls { #[help] pub help: (), } + +#[derive(Diagnostic)] +#[diag(passes_function_not_have_default_implementation)] +pub(crate) struct FunctionNotHaveDefaultImplementation { + #[primary_span] + pub span: Span, + #[note] + pub note_span: Span, +} + +#[derive(Diagnostic)] +#[diag(passes_must_implement_not_function)] +pub(crate) struct MustImplementNotFunction { + #[primary_span] + pub span: Span, + #[subdiagnostic] + pub span_note: MustImplementNotFunctionSpanNote, + #[subdiagnostic] + pub note: MustImplementNotFunctionNote, +} + +#[derive(Subdiagnostic)] +#[note(passes_must_implement_not_function_span_note)] +pub(crate) struct MustImplementNotFunctionSpanNote { + #[primary_span] + pub span: Span, +} + +#[derive(Subdiagnostic)] +#[note(passes_must_implement_not_function_note)] +pub(crate) struct MustImplementNotFunctionNote {} + +#[derive(Diagnostic)] +#[diag(passes_function_not_found_in_trait)] +pub(crate) struct FunctionNotFoundInTrait { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(passes_functions_names_duplicated)] +#[note] +pub(crate) struct FunctionNamesDuplicated { + #[primary_span] + pub spans: Vec, +} diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index 2fdce628f0c9..eff55e8e02a2 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -81,6 +81,8 @@ session_invalid_num_literal_suffix = invalid suffix `{$suffix}` for number liter session_linker_plugin_lto_windows_not_supported = linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets +session_must_be_name_of_associated_function = must be a name of an associated function + session_not_circumvent_feature = `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine session_not_supported = not supported diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 1f2d386a23cb..6fd86aec7ad9 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -82,6 +82,13 @@ pub(crate) struct CliFeatureDiagnosticHelp { pub(crate) feature: Symbol, } +#[derive(Diagnostic)] +#[diag(session_must_be_name_of_associated_function)] +pub struct MustBeNameOfAssociatedFunction { + #[primary_span] + pub span: Span, +} + #[derive(Diagnostic)] #[diag(session_not_circumvent_feature)] pub(crate) struct NotCircumventFeature; diff --git a/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs b/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs index 9b2e489c5425..82d0fa36d7ec 100644 --- a/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs +++ b/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs @@ -12,7 +12,7 @@ trait Tr1 { } #[rustc_must_implement_one_of(a)] -//~^ ERROR the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args +//~^ ERROR malformed trait Tr2 { fn a() {} } @@ -36,11 +36,11 @@ trait Tr5 { } #[rustc_must_implement_one_of(abc, xyz)] -//~^ ERROR attribute should be applied to a trait +//~^ ERROR `#[rustc_must_implement_one_of]` attribute cannot be used on functions fn function() {} #[rustc_must_implement_one_of(abc, xyz)] -//~^ ERROR attribute should be applied to a trait +//~^ ERROR `#[rustc_must_implement_one_of]` attribute cannot be used on structs struct Struct {} fn main() {} diff --git a/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr b/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr index cf197d035b38..0d854b4594fa 100644 --- a/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr +++ b/tests/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr @@ -1,26 +1,36 @@ -error: malformed `rustc_must_implement_one_of` attribute input +error[E0539]: malformed `rustc_must_implement_one_of` attribute input + --> $DIR/rustc_must_implement_one_of_misuse.rs:14:1 + | +LL | #[rustc_must_implement_one_of(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | expected 2 or more items + | help: must be of the form: `#[rustc_must_implement_one_of(function1, function2, ...)]` + +error[E0539]: malformed `rustc_must_implement_one_of` attribute input --> $DIR/rustc_must_implement_one_of_misuse.rs:20:1 | LL | #[rustc_must_implement_one_of] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_must_implement_one_of(function1, function2, ...)]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_must_implement_one_of(function1, function2, ...)]` -error: attribute should be applied to a trait +error: `#[rustc_must_implement_one_of]` attribute cannot be used on functions --> $DIR/rustc_must_implement_one_of_misuse.rs:38:1 | LL | #[rustc_must_implement_one_of(abc, xyz)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | fn function() {} - | ---------------- not a trait + | + = help: `#[rustc_must_implement_one_of]` can only be applied to traits -error: attribute should be applied to a trait +error: `#[rustc_must_implement_one_of]` attribute cannot be used on structs --> $DIR/rustc_must_implement_one_of_misuse.rs:42:1 | LL | #[rustc_must_implement_one_of(abc, xyz)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Struct {} - | ---------------- not a trait + | + = help: `#[rustc_must_implement_one_of]` can only be applied to traits error: function not found in this trait --> $DIR/rustc_must_implement_one_of_misuse.rs:3:31 @@ -40,12 +50,6 @@ error: function not found in this trait LL | #[rustc_must_implement_one_of(a, b)] | ^ -error: the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args - --> $DIR/rustc_must_implement_one_of_misuse.rs:14:1 - | -LL | #[rustc_must_implement_one_of(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: not a function --> $DIR/rustc_must_implement_one_of_misuse.rs:26:5 | @@ -98,3 +102,4 @@ LL | #[rustc_must_implement_one_of(a, b)] error: aborting due to 11 previous errors +For more information about this error, try `rustc --explain E0539`. From 7f550f6f37aece6fbf5a8c31beb13d38996f56d7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Dec 2025 16:23:40 +0100 Subject: [PATCH 470/489] Fix "copy code" button --- src/librustdoc/html/static/js/main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 476ecd42d6f9..72bf816e64bd 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -2163,7 +2163,15 @@ function preLoadCss(cssUrl) { // Should never happen, but the world is a dark and dangerous place. return; } - copyContentToClipboard(codeElem.textContent); + let content = ""; + for (const node of codeElem.childNodes) { + // We exclude line numbers. + if (node instanceof HTMLElement && node.hasAttribute("data-nosnippet")) { + continue; + } + content += node.textContent; + } + copyContentToClipboard(content); } /** From c054e52bc9e092dab9a627fea0ad46d08931e881 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Dec 2025 16:57:35 +0100 Subject: [PATCH 471/489] Add GUI test for copying code when line numbers are displayed in code examples --- tests/rustdoc-gui/copy-code.goml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/copy-code.goml b/tests/rustdoc-gui/copy-code.goml index a6fb816c4bd6..14421ab746f5 100644 --- a/tests/rustdoc-gui/copy-code.goml +++ b/tests/rustdoc-gui/copy-code.goml @@ -42,7 +42,31 @@ store-size: (".example-wrap:nth-of-type(1) .copy-button", { }) assert: |copy_height| > 0 && |copy_width| > 0 -// Checking same things for the copy button when there is no run button. + +// We now check that copying code when line numbers are displayed don't include these line numbers. + +// First we ensure that the clipboard is empty. +assert-clipboard: "" +// We make the line numbers appear. +click: "rustdoc-toolbar .settings-menu" +wait-for-css: ("#settings", {"display": "block"}) +// We make the line numbers appear. +click: "#line-numbers" +wait-for-local-storage: {"rustdoc-line-numbers": "true" } +// We close the settings menu. +click: "rustdoc-toolbar .settings-menu" +wait-for-css-false: ("#settings", {"display": "block"}) +// We ensure that there are actually line numbers generated in the DOM. +assert-text: (".example-wrap pre.rust code span[data-nosnippet]", "1") +// We make the copy button appear. +move-cursor-to: ".example-wrap pre.rust code" +wait-for-css: (".example-wrap .button-holder", {"visibility": "visible"}) +// We click on the copy button. +click: ".example-wrap .button-holder .copy-button" +assert-clipboard: 'println!("nothing fancy"); +println!("but with two lines!");' + +// Back to UI checks, checking same things for the copy button when there is no run button. go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" call-function: ("check-copy-button", {}) // Ensure there is no run button. From 9f566f2463ed1b7ec7160d0ab9fda0fba61c8fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 26 Dec 2025 20:08:23 +0000 Subject: [PATCH 472/489] Don't use `matches!` when `==` suffices In the codebase we sometimes use `matches!` for values that can actually just be compared. Replace them with `==`. --- compiler/rustc_const_eval/src/check_consts/check.rs | 2 +- compiler/rustc_const_eval/src/check_consts/qualifs.rs | 2 +- compiler/rustc_const_eval/src/interpret/call.rs | 2 +- compiler/rustc_const_eval/src/interpret/intrinsics.rs | 2 +- compiler/rustc_const_eval/src/interpret/memory.rs | 8 ++++---- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 2 +- compiler/rustc_hir_analysis/src/collect/predicates_of.rs | 2 +- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- compiler/rustc_middle/src/mir/statement.rs | 2 +- .../src/ty/inhabitedness/inhabited_predicate.rs | 4 ++-- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 4 ++-- compiler/rustc_parse/src/parser/asm.rs | 2 +- compiler/rustc_parse/src/parser/expr.rs | 2 +- compiler/rustc_parse/src/parser/item.rs | 2 +- compiler/rustc_parse/src/parser/mod.rs | 2 +- compiler/rustc_parse/src/parser/ty.rs | 4 +--- compiler/rustc_passes/src/check_attr.rs | 8 +++----- compiler/rustc_passes/src/dead.rs | 4 ++-- compiler/rustc_target/src/target_features.rs | 2 +- .../src/error_reporting/infer/mod.rs | 2 +- compiler/rustc_trait_selection/src/traits/effects.rs | 2 +- compiler/rustc_trait_selection/src/traits/select/mod.rs | 4 ++-- 23 files changed, 32 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index ed2c0bd6f98e..b06b407a6085 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -251,7 +251,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { let mut transient = DenseBitSet::new_filled(ccx.body.local_decls.len()); // Make sure to only visit reachable blocks, the dataflow engine can ICE otherwise. for (bb, data) in traversal::reachable(&ccx.body) { - if matches!(data.terminator().kind, TerminatorKind::Return) { + if data.terminator().kind == TerminatorKind::Return { let location = ccx.body.terminator_loc(bb); maybe_storage_live.seek_after_primary_effect(location); // If a local may be live here, it is definitely not transient. diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index 42943648ffdd..113e0d66c48a 100644 --- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs @@ -312,7 +312,7 @@ where // i.e., we treat all qualifs as non-structural for deref projections. Generally, // we can say very little about `*ptr` even if we know that `ptr` satisfies all // sorts of properties. - if matches!(elem, ProjectionElem::Deref) { + if elem == ProjectionElem::Deref { // We have to assume that this qualifies. return true; } diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 312ebe7ddd09..94c6fd1b3238 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -283,7 +283,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { 'tcx: 'y, { assert_eq!(callee_ty, callee_abi.layout.ty); - if matches!(callee_abi.mode, PassMode::Ignore) { + if callee_abi.mode == PassMode::Ignore { // This one is skipped. Still must be made live though! if !already_live { self.storage_live(callee_arg.as_local().unwrap())?; diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 44c817b33184..d70d157d8808 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -861,7 +861,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } } else { // unsigned - if matches!(mir_op, BinOp::Add) { + if mir_op == BinOp::Add { // max unsigned Scalar::from_uint(size.unsigned_int_max(), size) } else { diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index bac3a9da48d9..862fe4779080 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -327,7 +327,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { return Err(ConstEvalErrKind::ConstMakeGlobalWithOffset(ptr)).into(); } - if matches!(self.tcx.try_get_global_alloc(alloc_id), Some(_)) { + if self.tcx.try_get_global_alloc(alloc_id).is_some() { // This points to something outside the current interpreter. return Err(ConstEvalErrKind::ConstMakeGlobalPtrIsNonHeap(ptr)).into(); } @@ -981,7 +981,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { msg: CheckInAllocMsg, ) -> InterpResult<'tcx, (Size, Align)> { let info = self.get_alloc_info(id); - if matches!(info.kind, AllocKind::Dead) { + if info.kind == AllocKind::Dead { throw_ub!(PointerUseAfterFree(id, msg)) } interp_ok((info.size, info.align)) @@ -1072,7 +1072,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // Recurse, if there is data here. // Do this *before* invoking the callback, as the callback might mutate the // allocation and e.g. replace all provenance by wildcards! - if matches!(info.kind, AllocKind::LiveData) { + if info.kind == AllocKind::LiveData { let alloc = self.get_alloc_raw(id)?; for prov in alloc.provenance().provenances() { if let Some(id) = prov.get_alloc_id() { @@ -1605,7 +1605,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { match self.ptr_try_get_alloc_id(ptr, 0) { Ok((alloc_id, offset, _)) => { let info = self.get_alloc_info(alloc_id); - if matches!(info.kind, AllocKind::TypeId) { + if info.kind == AllocKind::TypeId { // We *could* actually precisely answer this question since here, // the offset *is* the integer value. But the entire point of making // this a pointer is not to leak the integer value, so we say everything diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 16f5222f621c..725294dfd377 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -327,7 +327,7 @@ pub(crate) fn check_trait_item<'tcx>( let mut res = Ok(()); - if matches!(tcx.def_kind(def_id), DefKind::AssocFn) { + if tcx.def_kind(def_id) == DefKind::AssocFn { for &assoc_ty_def_id in tcx.associated_types_for_impl_traits_in_associated_fn(def_id.to_def_id()) { diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 2eefe1eb3e92..178c47b09c84 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -543,7 +543,7 @@ pub(super) fn explicit_predicates_of<'tcx>( } } } else { - if matches!(def_kind, DefKind::AnonConst) + if def_kind == DefKind::AnonConst && tcx.features().generic_const_exprs() && let Some(defaulted_param_def_id) = tcx.hir_opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id)) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index da719e615fd7..ff85f53ddf30 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -216,7 +216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Don't write user type annotations for const param types, since we give them // identity args just so that we can trivially substitute their `EarlyBinder`. // We enforce that they match their type in MIR later on. - if matches!(self.tcx.def_kind(def_id), DefKind::ConstParam) { + if self.tcx.def_kind(def_id) == DefKind::ConstParam { return; } diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 1ba1ae3e1531..c1f8c46baddb 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -25,7 +25,7 @@ impl<'tcx> Statement<'tcx> { /// Changes a statement to a nop. This is both faster than deleting instructions and avoids /// invalidating statement indices in `Location`s. pub fn make_nop(&mut self, drop_debuginfo: bool) { - if matches!(self.kind, StatementKind::Nop) { + if self.kind == StatementKind::Nop { return; } let replaced_stmt = std::mem::replace(&mut self.kind, StatementKind::Nop); diff --git a/compiler/rustc_middle/src/ty/inhabitedness/inhabited_predicate.rs b/compiler/rustc_middle/src/ty/inhabitedness/inhabited_predicate.rs index 953ad62be0a8..d03e593e37b9 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/inhabited_predicate.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/inhabited_predicate.rs @@ -160,7 +160,7 @@ impl<'tcx> InhabitedPredicate<'tcx> { pub fn all(tcx: TyCtxt<'tcx>, iter: impl IntoIterator) -> Self { let mut result = Self::True; for pred in iter { - if matches!(pred, Self::False) { + if pred == Self::False { return Self::False; } result = result.and(tcx, pred); @@ -171,7 +171,7 @@ impl<'tcx> InhabitedPredicate<'tcx> { pub fn any(tcx: TyCtxt<'tcx>, iter: impl IntoIterator) -> Self { let mut result = Self::False; for pred in iter { - if matches!(pred, Self::True) { + if pred == Self::True { return Self::True; } result = result.or(tcx, pred); diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index c4f2917ad9e5..f0d5ce492a39 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -3381,7 +3381,7 @@ define_print_and_forward_display! { fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, Namespace, DefId)) { // Iterate all (non-anonymous) local crate items no matter where they are defined. for id in tcx.hir_free_items() { - if matches!(tcx.def_kind(id.owner_id), DefKind::Use) { + if tcx.def_kind(id.owner_id) == DefKind::Use { continue; } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index cd699436e012..4b2f8e03afc1 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1582,7 +1582,7 @@ impl<'v> RootCollector<'_, 'v> { } fn process_impl_item(&mut self, id: hir::ImplItemId) { - if matches!(self.tcx.def_kind(id.owner_id), DefKind::AssocFn) { + if self.tcx.def_kind(id.owner_id) == DefKind::AssocFn { self.push_if_root(id.owner_id.def_id); } } @@ -1720,7 +1720,7 @@ fn create_mono_items_for_default_impls<'tcx>( ) { let impl_ = tcx.impl_trait_header(item.owner_id); - if matches!(impl_.polarity, ty::ImplPolarity::Negative) { + if impl_.polarity == ty::ImplPolarity::Negative { return; } diff --git a/compiler/rustc_parse/src/parser/asm.rs b/compiler/rustc_parse/src/parser/asm.rs index caec877232a6..3fab234adaad 100644 --- a/compiler/rustc_parse/src/parser/asm.rs +++ b/compiler/rustc_parse/src/parser/asm.rs @@ -77,7 +77,7 @@ fn eat_operand_keyword<'a>( exp: ExpKeywordPair, asm_macro: AsmMacro, ) -> PResult<'a, bool> { - if matches!(asm_macro, AsmMacro::Asm) { + if asm_macro == AsmMacro::Asm { Ok(p.eat_keyword(exp)) } else { let span = p.token.span; diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 3f0853a3c54d..efa1027deffd 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3100,7 +3100,7 @@ impl<'a> Parser<'a> { pub(crate) fn eat_label(&mut self) -> Option