diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index ed0cfb1a10d74..cdff6501ec1c4 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -4010,44 +4010,16 @@ pub struct ConstItem { pub ident: Ident, pub generics: Generics, pub ty: Box, - pub rhs_kind: ConstItemRhsKind, + pub body: Option>, + #[visitable(ignore)] + pub kind: ConstItemKind, pub define_opaque: Option>, } -#[derive(Clone, Encodable, Decodable, Debug, Walkable)] -pub enum ConstItemRhsKind { - Body { rhs: Option> }, - TypeConst { rhs: Option }, -} - -impl ConstItemRhsKind { - pub fn new_body(rhs: Box) -> Self { - Self::Body { rhs: Some(rhs) } - } - - pub fn span(&self) -> Option { - Some(self.expr()?.span) - } - - pub fn expr(&self) -> Option<&Expr> { - match self { - Self::Body { rhs: Some(body) } => Some(&body), - Self::TypeConst { rhs: Some(anon) } => Some(&anon.value), - _ => None, - } - } - - pub fn has_expr(&self) -> bool { - match self { - Self::Body { rhs: Some(_) } => true, - Self::TypeConst { rhs: Some(_) } => true, - _ => false, - } - } - - pub fn is_type_const(&self) -> bool { - matches!(self, &Self::TypeConst { .. }) - } +#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Eq)] +pub enum ConstItemKind { + Body, + TypeConst, } #[derive(Clone, Encodable, Decodable, Debug, Walkable)] diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 1c3e881bd47be..aef4561833ccc 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -427,7 +427,6 @@ macro_rules! common_visitor_and_walkers { Const, ConstBlockItem, ConstItem, - ConstItemRhsKind, Defaultness, Delegation, DelegationMac, diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 7e9827c4e494c..5b363c90f3c90 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -270,7 +270,8 @@ impl<'hir> LoweringContext<'_, 'hir> { ident, generics, ty, - rhs_kind, + body, + kind, define_opaque, }) => { let ident = self.lower_ident(*ident); @@ -282,7 +283,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ty, ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy), ); - let rhs = this.lower_const_item_rhs(rhs_kind, span); + let rhs = this.lower_const_item_rhs(body, *kind, span); (ty, rhs) }, ); @@ -918,7 +919,8 @@ impl<'hir> LoweringContext<'_, 'hir> { ident, generics, ty, - rhs_kind, + body, + kind, define_opaque, .. }) => { @@ -931,8 +933,8 @@ impl<'hir> LoweringContext<'_, 'hir> { ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy), ); // Trait associated consts don't need an expression/body. - let rhs = if rhs_kind.has_expr() { - Some(this.lower_const_item_rhs(rhs_kind, i.span)) + let rhs = if body.is_some() { + Some(this.lower_const_item_rhs(body, *kind, i.span)) } else { None }; @@ -941,7 +943,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ); if define_opaque.is_some() { - if rhs_kind.has_expr() { + if body.is_some() { self.lower_define_opaque(hir_id, &define_opaque); } else { self.dcx().span_err( @@ -951,7 +953,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - (*ident, generics, kind, rhs_kind.has_expr()) + (*ident, generics, kind, body.is_some()) } AssocItemKind::Fn(Fn { sig, ident, generics, body: None, define_opaque, .. }) => { // FIXME(contracts): Deny contract here since it won't apply to @@ -1180,7 +1182,8 @@ impl<'hir> LoweringContext<'_, 'hir> { ident, generics, ty, - rhs_kind, + body, + kind, define_opaque, .. }) => ( @@ -1194,7 +1197,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy), ); this.lower_define_opaque(hir_id, &define_opaque); - let rhs = this.lower_const_item_rhs(rhs_kind, i.span); + let rhs = this.lower_const_item_rhs(body, *kind, i.span); hir::ImplItemKind::Const(ty, rhs) }, ), diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index f04b5cfc92724..8a6a2aceedd2f 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -2671,28 +2671,26 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_const_item_rhs( &mut self, - rhs_kind: &ConstItemRhsKind, + body: &Option>, + kind: ConstItemKind, span: Span, ) -> hir::ConstItemRhs<'hir> { - match rhs_kind { - ConstItemRhsKind::Body { rhs: Some(body) } => { - hir::ConstItemRhs::Body(self.lower_const_body(span, Some(body))) + match (body, kind) { + (body, ConstItemKind::Body) => { + hir::ConstItemRhs::Body(self.lower_const_body(span, body.as_deref())) } - ConstItemRhsKind::Body { rhs: None } => { - hir::ConstItemRhs::Body(self.lower_const_body(span, None)) - } - ConstItemRhsKind::TypeConst { rhs: Some(anon) } => { + (Some(body), ConstItemKind::TypeConst) => { hir::ConstItemRhs::TypeConst(self.arena.alloc( match self.can_lower_expr_to_const_arg_direct( - &anon.value, + &body, DirectConstArgContext::MacrolessMinGenericConstArgs, ) { - Ok(()) => self.lower_expr_to_const_arg_direct(&anon.value, Some(anon.id)), + Ok(()) => self.lower_expr_to_const_arg_direct(&body, None), Err(err) => err.emit(self), }, )) } - ConstItemRhsKind::TypeConst { rhs: None } => { + (None, ConstItemKind::TypeConst) => { let const_arg = ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Error( diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 478dbc0dd7684..fe1da820cf74f 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -1544,9 +1544,9 @@ impl Visitor<'_> for AstValidator<'_> { visit::walk_item(this, item) }); } - ItemKind::Const(ConstItem { defaultness, ident, rhs_kind, .. }) => { + ItemKind::Const(ConstItem { defaultness, ident, body, .. }) => { self.check_defaultness(item.span, *defaultness, AllowDefault::No, AllowFinal::No); - if !rhs_kind.has_expr() { + if body.is_none() { self.dcx().emit_err(diagnostics::ConstWithoutBody { span: item.span, replace_span: self.ending_semi_or_hi(item.span), @@ -1941,8 +1941,8 @@ impl Visitor<'_> for AstValidator<'_> { if let AssocCtxt::Impl { .. } = ctxt { match &item.kind { - AssocItemKind::Const(ConstItem { rhs_kind, .. }) => { - if !rhs_kind.has_expr() { + AssocItemKind::Const(ConstItem { body, .. }) => { + if body.is_none() { self.dcx().emit_err(diagnostics::AssocConstWithoutBody { span: item.span, replace_span: self.ending_semi_or_hi(item.span), diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 9411a34f85e6d..bec96621fbfed 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -1,4 +1,4 @@ -use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; +use rustc_ast::visit::{self, AssocCtxt, FnKind, Visitor}; use rustc_ast::{self as ast, AttrVec, GenericBound, NodeId, PatKind, attr, token}; use rustc_attr_parsing::AttributeParser; use rustc_errors::msg; @@ -220,8 +220,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { self.check_impl_trait(ty, false) } ast::ItemKind::Const(ast::ConstItem { - rhs_kind: ast::ConstItemRhsKind::TypeConst { .. }, - .. + kind: ast::ConstItemKind::TypeConst, .. }) => { // Make sure this is only allowed if the feature gate is enabled. // #![feature(min_generic_const_args)] @@ -366,7 +365,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { visit::walk_poly_trait_ref(self, t); } - fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, span: Span, _: NodeId) { + fn visit_fn(&mut self, fn_kind: FnKind<'a>, _: &AttrVec, _: Span, _: NodeId) { if let Some(_header) = fn_kind.header() { // Stability of const fn methods are covered in `visit_assoc_item` below. } @@ -375,10 +374,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { self.check_late_bound_lifetime_defs(generic_params); } - if fn_kind.ctxt() != Some(FnCtxt::Foreign) && fn_kind.decl().c_variadic() { - gate!(self, c_variadic, span, "C-variadic functions are unstable"); - } - visit::walk_fn(self, fn_kind) } @@ -400,7 +395,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { false } ast::AssocItemKind::Const(ast::ConstItem { - rhs_kind: ast::ConstItemRhsKind::TypeConst { rhs }, + body, + kind: ast::ConstItemKind::TypeConst, .. }) => { // Make sure this is only allowed if the feature gate is enabled. @@ -409,7 +405,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // Make sure associated `type const` defaults in traits are only allowed // if the feature gate is enabled. // #![feature(associated_type_defaults)] - if ctxt == AssocCtxt::Trait && rhs.is_some() { + if ctxt == AssocCtxt::Trait && body.is_some() { gate!( self, associated_type_defaults, @@ -730,8 +726,10 @@ fn check_new_solver_banned_features(sess: &Session, features: &Features) { .find(|feat| feat.gate_name == sym::generic_const_exprs) .map(|feat| feat.attr_sp) { + // Abort immediately, otherwise GCE can lower to `ConstKind::Expr`, + // which the new solver intentionally does not support. #[allow(rustc::symbol_intern_string_literal)] - sess.dcx().emit_err(diagnostics::IncompatibleFeatures { + sess.dcx().emit_fatal(diagnostics::IncompatibleFeatures { spans: vec![gce_span], f1: Symbol::intern("-Znext-solver=globally"), f2: sym::generic_const_exprs, diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index 8602a21a43487..e0ce241db5e53 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -229,7 +229,8 @@ impl<'a> State<'a> { ident, generics, ty, - rhs_kind, + body, + kind: _, define_opaque, }) => { self.print_item_const( @@ -237,7 +238,7 @@ impl<'a> State<'a> { None, generics, ty, - rhs_kind.expr(), + body.as_deref(), &item.vis, ast::Safety::Default, *defaultness, @@ -617,7 +618,8 @@ impl<'a> State<'a> { ident, generics, ty, - rhs_kind, + body, + kind: _, define_opaque, }) => { self.print_item_const( @@ -625,7 +627,7 @@ impl<'a> State<'a> { None, generics, ty, - rhs_kind.expr(), + body.as_deref(), vis, ast::Safety::Default, *defaultness, diff --git a/compiler/rustc_attr_parsing/src/attributes/util.rs b/compiler/rustc_attr_parsing/src/attributes/util.rs index 22ae0da908233..47a8ac4ce51a8 100644 --- a/compiler/rustc_attr_parsing/src/attributes/util.rs +++ b/compiler/rustc_attr_parsing/src/attributes/util.rs @@ -1,9 +1,9 @@ use std::num::IntErrorKind; use rustc_ast::{LitKind, ast}; +use rustc_data_structures::Limit; use rustc_feature::is_builtin_attr_name; use rustc_hir::RustcVersion; -use rustc_hir::limit::Limit; use rustc_span::Symbol; use crate::context::AcceptContext; diff --git a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs index 544ad86120356..d50fc78b51e14 100644 --- a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs +++ b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs @@ -43,8 +43,14 @@ pub(crate) fn expand( // Generate anonymous constant serving as container for the allocator methods. let const_ty = ecx.ty(sig_span, TyKind::Tup(ThinVec::new())); - let const_body = ast::ConstItemRhsKind::new_body(ecx.expr_block(ecx.block(span, stmts))); - let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body); + let const_body = ecx.expr_block(ecx.block(span, stmts)); + let const_item = ecx.item_const( + span, + Ident::new(kw::Underscore, span), + const_ty, + Some(const_body), + ast::ConstItemKind::Body, + ); let const_item = if is_stmt { Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item))) } else { diff --git a/compiler/rustc_builtin_macros/src/eii.rs b/compiler/rustc_builtin_macros/src/eii.rs index fae06593f9784..5a28416900372 100644 --- a/compiler/rustc_builtin_macros/src/eii.rs +++ b/compiler/rustc_builtin_macros/src/eii.rs @@ -335,7 +335,8 @@ fn generate_default_impl( span, underscore, unit, - ast::ConstItemRhsKind::new_body(ecx.expr_block(ecx.block(span, stmts))), + Some(ecx.expr_block(ecx.block(span, stmts))), + ast::ConstItemKind::Body, ) }; diff --git a/compiler/rustc_builtin_macros/src/global_allocator.rs b/compiler/rustc_builtin_macros/src/global_allocator.rs index db034f6fb7011..72b493e313326 100644 --- a/compiler/rustc_builtin_macros/src/global_allocator.rs +++ b/compiler/rustc_builtin_macros/src/global_allocator.rs @@ -54,8 +54,14 @@ pub(crate) fn expand( // Generate anonymous constant serving as container for the allocator methods. let const_ty = ecx.ty(ty_span, TyKind::Tup(ThinVec::new())); - let const_body = ast::ConstItemRhsKind::new_body(ecx.expr_block(ecx.block(span, stmts))); - let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body); + let const_body = ecx.expr_block(ecx.block(span, stmts)); + let const_item = ecx.item_const( + span, + Ident::new(kw::Underscore, span), + const_ty, + Some(const_body), + ast::ConstItemKind::Body, + ); let const_item = if is_stmt { Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item))) } else { diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs index 32865f234ef44..404f2358ab863 100644 --- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs +++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs @@ -361,15 +361,16 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> Box { cx.attr_nested_word(sym::allow, sym::deprecated, span), ]); - let block = ast::ConstItemRhsKind::new_body(cx.expr_block( + let block = cx.expr_block( cx.block(span, thin_vec![cx.stmt_item(span, krate), cx.stmt_item(span, decls_static)]), - )); + ); let anon_constant = cx.item_const( span, Ident::new(kw::Underscore, span), cx.ty(span, ast::TyKind::Tup(ThinVec::new())), - block, + Some(block), + ast::ConstItemKind::Body, ); // Integrate the new item into existing module structures. diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index cbab0b7e3010b..25ba01b275964 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -286,8 +286,9 @@ pub(crate) fn expand_test_or_bench( generics: ast::Generics::default(), ty: cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))), define_opaque: None, + kind: ast::ConstItemKind::Body, // test::TestDescAndFn { - rhs_kind: ast::ConstItemRhsKind::new_body( + body: Some( cx.expr_struct( sp, test_path("TestDescAndFn"), diff --git a/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml b/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml index 5cfdc3e8f2936..b10f8493a3fb6 100644 --- a/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml +++ b/compiler/rustc_codegen_cranelift/.github/workflows/cranelift-release-branch.yml @@ -38,6 +38,8 @@ jobs: - name: Patch Cargo.toml to use release branch Cranelift run: | + sed -i -E '/cranelift-/s/"0\.[0-9]+\.0"/"*"/g' Cargo.toml + cat >>Cargo.toml <, bootstrap_host_compiler: &Compiler, - panic_unwind_support: bool, ) { std::fs::create_dir_all(&dirs.download_dir).unwrap(); ABI_CAFE_REPO.fetch(dirs); @@ -29,12 +29,11 @@ pub(crate) fn run( eprintln!("Building sysroot for abi-cafe"); build_sysroot::build_sysroot( dirs, - sysroot_kind, + sysroot_config, cg_clif_dylib, bootstrap_host_compiler, rustup_toolchain_name, bootstrap_host_compiler.triple.clone(), - panic_unwind_support, ); eprintln!("Running abi-cafe"); diff --git a/compiler/rustc_codegen_cranelift/build_system/build_backend.rs b/compiler/rustc_codegen_cranelift/build_system/build_backend.rs index 6b14727cd153e..dc977f0ff3fa8 100644 --- a/compiler/rustc_codegen_cranelift/build_system/build_backend.rs +++ b/compiler/rustc_codegen_cranelift/build_system/build_backend.rs @@ -43,7 +43,7 @@ pub(crate) fn build_backend( cmd.arg("--release"); - cmd.arg("-Zno-embed-metadata"); + cmd.arg("-Zembed-metadata=no"); eprintln!("[BUILD] rustc_codegen_cranelift"); crate::utils::spawn_and_wait(cmd); diff --git a/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs b/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs index 5c8b719ad5404..e4250736e0bb7 100644 --- a/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs +++ b/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs @@ -2,26 +2,38 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::{env, fs}; +use crate::CodegenBackend; use crate::path::{Dirs, RelPath}; use crate::prepare::apply_patches; use crate::rustc_info::{get_default_sysroot, get_file_name}; use crate::utils::{ CargoProject, Compiler, LogGroup, ensure_empty_dir, spawn_and_wait, try_hard_link, }; -use crate::{CodegenBackend, SysrootKind, config}; + +pub(crate) struct SysrootConfig { + pub(crate) sysroot_kind: SysrootKind, + pub(crate) panic_unwind_support: bool, + pub(crate) keep_sysroot: bool, +} + +#[derive(Copy, Clone, Debug)] +pub(crate) enum SysrootKind { + None, + Clif, + Llvm, +} pub(crate) fn build_sysroot( dirs: &Dirs, - sysroot_kind: SysrootKind, + config: &SysrootConfig, cg_clif_dylib_src: &CodegenBackend, bootstrap_host_compiler: &Compiler, rustup_toolchain_name: Option<&str>, target_triple: String, - panic_unwind_support: bool, ) -> Compiler { let _guard = LogGroup::guard("Build sysroot"); - eprintln!("[BUILD] sysroot {:?}", sysroot_kind); + eprintln!("[BUILD] sysroot {:?}", config.sysroot_kind); let dist_dir = &dirs.dist_dir; @@ -54,7 +66,7 @@ pub(crate) fn build_sysroot( .arg(&wrapper_path) .arg("-Cstrip=debuginfo") .arg("--check-cfg=cfg(support_panic_unwind)"); - if panic_unwind_support { + if config.panic_unwind_support { build_cargo_wrapper_cmd.arg("--cfg").arg("support_panic_unwind"); } if let Some(rustup_toolchain_name) = &rustup_toolchain_name { @@ -81,8 +93,7 @@ pub(crate) fn build_sysroot( dirs, bootstrap_host_compiler.clone(), &cg_clif_dylib_path, - sysroot_kind, - panic_unwind_support, + config, ); host.install_into_sysroot(dist_dir); @@ -96,8 +107,7 @@ pub(crate) fn build_sysroot( bootstrap_target_compiler }, &cg_clif_dylib_path, - sysroot_kind, - panic_unwind_support, + config, ) .install_into_sysroot(dist_dir); } @@ -146,14 +156,13 @@ fn build_sysroot_for_triple( dirs: &Dirs, compiler: Compiler, cg_clif_dylib_path: &CodegenBackend, - sysroot_kind: SysrootKind, - panic_unwind_support: bool, + config: &SysrootConfig, ) -> SysrootTarget { - match sysroot_kind { + match config.sysroot_kind { SysrootKind::None => SysrootTarget { triple: compiler.triple, libs: vec![] }, SysrootKind::Llvm => build_llvm_sysroot_for_triple(compiler), SysrootKind::Clif => { - build_clif_sysroot_for_triple(dirs, compiler, cg_clif_dylib_path, panic_unwind_support) + build_clif_sysroot_for_triple(dirs, compiler, cg_clif_dylib_path, config) } } } @@ -194,13 +203,13 @@ fn build_clif_sysroot_for_triple( dirs: &Dirs, mut compiler: Compiler, cg_clif_dylib_path: &CodegenBackend, - panic_unwind_support: bool, + config: &SysrootConfig, ) -> SysrootTarget { let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] }; let build_dir = STANDARD_LIBRARY.target_dir(dirs).join(&compiler.triple).join("release"); - if !config::get_bool("keep_sysroot") { + if !config.keep_sysroot { let sysroot_src_orig = get_default_sysroot(&compiler.rustc).join("lib/rustlib/src/rust"); assert!(sysroot_src_orig.exists()); @@ -213,7 +222,7 @@ fn build_clif_sysroot_for_triple( // Build sysroot let mut rustflags = vec!["-Zforce-unstable-if-unmarked".to_owned()]; - if !panic_unwind_support { + if !config.panic_unwind_support { rustflags.push("-Cpanic=abort".to_owned()); } match cg_clif_dylib_path { @@ -242,7 +251,7 @@ fn build_clif_sysroot_for_triple( build_cmd.arg("--release"); build_cmd.arg("--features").arg("backtrace panic-unwind"); build_cmd.arg(format!("-Zroot-dir={}", STDLIB_SRC.to_path(dirs).display())); - build_cmd.arg("-Zno-embed-metadata"); + build_cmd.arg("-Zembed-metadata=no"); build_cmd.arg("-Zbuild-dir-new-layout"); build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true"); build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif"); diff --git a/compiler/rustc_codegen_cranelift/build_system/main.rs b/compiler/rustc_codegen_cranelift/build_system/main.rs index 852fda950d88b..aa3163cdc7cbe 100644 --- a/compiler/rustc_codegen_cranelift/build_system/main.rs +++ b/compiler/rustc_codegen_cranelift/build_system/main.rs @@ -5,7 +5,8 @@ use std::path::PathBuf; use std::{env, process}; -use self::utils::Compiler; +use crate::build_sysroot::{SysrootConfig, SysrootKind}; +use crate::utils::Compiler; mod abi_cafe; mod bench; @@ -42,13 +43,6 @@ enum Command { CheckTodo, } -#[derive(Copy, Clone, Debug)] -enum SysrootKind { - None, - Clif, - Llvm, -} - #[derive(Clone, Debug)] enum CodegenBackend { Local(PathBuf), @@ -78,9 +72,12 @@ fn main() { let mut out_dir = std::env::current_dir().unwrap(); let mut download_dir = None; - let mut sysroot_kind = SysrootKind::Clif; + let mut sysroot_config = SysrootConfig { + sysroot_kind: SysrootKind::Clif, + panic_unwind_support: false, + keep_sysroot: false, + }; let mut use_unstable_features = true; - let mut panic_unwind_support = false; let mut frozen = false; let mut skip_tests = vec![]; let mut use_backend = None; @@ -97,7 +94,7 @@ fn main() { }))); } "--sysroot" => { - sysroot_kind = match args.next().as_deref() { + sysroot_config.sysroot_kind = match args.next().as_deref() { Some("none") => SysrootKind::None, Some("clif") => SysrootKind::Clif, Some("llvm") => SysrootKind::Llvm, @@ -105,8 +102,9 @@ fn main() { None => arg_error!("--sysroot requires argument"), } } + "--keep-sysroot" => sysroot_config.keep_sysroot = true, "--no-unstable-features" => use_unstable_features = false, - "--panic-unwind-support" => panic_unwind_support = true, + "--panic-unwind-support" => sysroot_config.panic_unwind_support = true, "--frozen" => frozen = true, "--skip-test" => { // FIXME check that all passed in tests actually exist @@ -204,7 +202,7 @@ fn main() { &dirs, &bootstrap_host_compiler, use_unstable_features, - panic_unwind_support, + sysroot_config.panic_unwind_support, )) }; match command { @@ -214,9 +212,8 @@ fn main() { Command::Test => { tests::run_tests( &dirs, - sysroot_kind, + &sysroot_config, use_unstable_features, - panic_unwind_support, &skip_tests.iter().map(|test| &**test).collect::>(), &cg_clif_dylib, &bootstrap_host_compiler, @@ -230,34 +227,31 @@ fn main() { process::exit(1); } abi_cafe::run( - sysroot_kind, + &sysroot_config, &dirs, &cg_clif_dylib, rustup_toolchain_name.as_deref(), &bootstrap_host_compiler, - panic_unwind_support, ); } Command::Build => { build_sysroot::build_sysroot( &dirs, - sysroot_kind, + &sysroot_config, &cg_clif_dylib, &bootstrap_host_compiler, rustup_toolchain_name.as_deref(), target_triple, - panic_unwind_support, ); } Command::Bench => { let compiler = build_sysroot::build_sysroot( &dirs, - sysroot_kind, + &sysroot_config, &cg_clif_dylib, &bootstrap_host_compiler, rustup_toolchain_name.as_deref(), target_triple, - panic_unwind_support, ); bench::benchmark(&dirs, &compiler); } diff --git a/compiler/rustc_codegen_cranelift/build_system/tests.rs b/compiler/rustc_codegen_cranelift/build_system/tests.rs index 685bf8ce9a891..adaae8b24115c 100644 --- a/compiler/rustc_codegen_cranelift/build_system/tests.rs +++ b/compiler/rustc_codegen_cranelift/build_system/tests.rs @@ -2,12 +2,13 @@ use std::ffi::OsStr; use std::path::PathBuf; use std::process::Command; +use crate::build_sysroot::SysrootConfig; use crate::path::{Dirs, RelPath}; use crate::prepare::{GitRepo, apply_patches}; use crate::rustc_info::get_default_sysroot; use crate::shared_utils::rustflags_from_env; use crate::utils::{CargoProject, Compiler, LogGroup, ensure_empty_dir, spawn_and_wait}; -use crate::{CodegenBackend, SysrootKind, build_sysroot, config}; +use crate::{CodegenBackend, build_sysroot, config}; static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::build("example"); @@ -146,9 +147,9 @@ static REGEX: CargoProject = CargoProject::new(REGEX_REPO.source_dir(), "regex_t pub(crate) static GRAVIOLA_REPO: GitRepo = GitRepo::github( "ctz", "graviola", - "c779b83cfd7114c4802293700c92cfb5e05cb4b7", + "7763d0cc617d6f5f66c3bc0fe9b3d8581d781b6a", // v0.4.1 &["thirdparty/cavp", "thirdparty/wycheproof"], - "e0925ceb21a56101", + "7fa5a75b9fb1ac40", "graviola", ); @@ -231,16 +232,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ test_cmd.env("GRAVIOLA_CPU_DISABLE_avx512bw", "1"); test_cmd.env("GRAVIOLA_CPU_DISABLE_avx512vl", "1"); - test_cmd.args([ - "-p", - "graviola", - "--lib", - "--", - "-q", - // FIXME: Disable AVX-512 until intrinsics are supported. - "--skip", - "check_counter512", - ]); + test_cmd.args(["-p", "graviola", "--lib", "--", "-q"]); spawn_and_wait(test_cmd); } else { eprintln!("Cross-Compiling: Not running tests"); @@ -275,9 +267,8 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ pub(crate) fn run_tests( dirs: &Dirs, - sysroot_kind: SysrootKind, + sysroot_config: &SysrootConfig, use_unstable_features: bool, - panic_unwind_support: bool, skip_tests: &[&str], cg_clif_dylib: &CodegenBackend, bootstrap_host_compiler: &Compiler, @@ -291,19 +282,18 @@ pub(crate) fn run_tests( if config::get_bool("testsuite.no_sysroot") && !skip_tests.contains(&"testsuite.no_sysroot") { let target_compiler = build_sysroot::build_sysroot( dirs, - SysrootKind::None, + sysroot_config, cg_clif_dylib, bootstrap_host_compiler, rustup_toolchain_name, target_triple.clone(), - panic_unwind_support, ); let runner = TestRunner::new( dirs.clone(), target_compiler, use_unstable_features, - panic_unwind_support, + sysroot_config.panic_unwind_support, skip_tests, bootstrap_host_compiler.triple == target_triple, stdlib_source.clone(), @@ -325,19 +315,18 @@ pub(crate) fn run_tests( if run_base_sysroot || run_extended_sysroot { let target_compiler = build_sysroot::build_sysroot( dirs, - sysroot_kind, + sysroot_config, cg_clif_dylib, bootstrap_host_compiler, rustup_toolchain_name, target_triple.clone(), - panic_unwind_support, ); let mut runner = TestRunner::new( dirs.clone(), target_compiler, use_unstable_features, - panic_unwind_support, + sysroot_config.panic_unwind_support, skip_tests, bootstrap_host_compiler.triple == target_triple, stdlib_source, diff --git a/compiler/rustc_codegen_cranelift/build_system/usage.txt b/compiler/rustc_codegen_cranelift/build_system/usage.txt index 572fe78058101..62fe14e1d2479 100644 --- a/compiler/rustc_codegen_cranelift/build_system/usage.txt +++ b/compiler/rustc_codegen_cranelift/build_system/usage.txt @@ -15,6 +15,11 @@ OPTIONS: `clif` will build the standard library using Cranelift. `llvm` will use the pre-compiled standard library of rustc which is compiled with LLVM. + --keep-sysroot + Disable cleaning of the sysroot dir to cause old compiled artifacts to be re-used when + the sysroot source hasn't changed. This is useful when the codegen backend hasn't been + modified. + --out-dir DIR Specify the directory in which the download, build and dist directories are stored. By default this is the working directory. diff --git a/compiler/rustc_codegen_cranelift/config.txt b/compiler/rustc_codegen_cranelift/config.txt index 7c516e2164b40..cffd850b794f5 100644 --- a/compiler/rustc_codegen_cranelift/config.txt +++ b/compiler/rustc_codegen_cranelift/config.txt @@ -1,12 +1,5 @@ # This file allows configuring the build system. -# Disables cleaning of the sysroot dir. This will cause old compiled artifacts to be re-used when -# the sysroot source hasn't changed. This is useful when the codegen backend hasn't been modified. -# This option can be changed while the build system is already running for as long as sysroot -# building hasn't started yet. -#keep_sysroot - - # Testsuite # # Each test suite item has a corresponding key here. The default is to run all tests. diff --git a/compiler/rustc_codegen_cranelift/example/neon.rs b/compiler/rustc_codegen_cranelift/example/neon.rs index 1aec5badcbc26..ba63333daa339 100644 --- a/compiler/rustc_codegen_cranelift/example/neon.rs +++ b/compiler/rustc_codegen_cranelift/example/neon.rs @@ -307,6 +307,75 @@ unsafe fn test_vaesimcq_u8() { assert_eq!(r, e); } +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha2")] +unsafe fn test_vsha1cq_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha1c + let a = u32x4::from([0, 1, 2, 3]); + let b = 8; + let c = u32x4::from([4, 5, 6, 7]); + let e = u32x4::from([0x40072911, 0x40003948, 0x80000072, 0x80000003]); + let r: u32x4 = unsafe { transmute(vsha1cq_u32(transmute(a), b, transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha2")] +fn test_vsha1h_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha1h + let a = 8; + let e = 0x00000002; + let r = vsha1h_u32(a); + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha2")] +unsafe fn test_vsha1mq_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha1m + let a = u32x4::from([0, 1, 2, 3]); + let b = 8; + let c = u32x4::from([4, 5, 6, 7]); + let e = u32x4::from([0x4007a107, 0x00003d08, 0x0000007a, 0xc0000003]); + let r: u32x4 = unsafe { transmute(vsha1mq_u32(transmute(a), b, transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha2")] +unsafe fn test_vsha1pq_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha1p + let a = u32x4::from([0, 1, 2, 3]); + let b = 8; + let c = u32x4::from([4, 5, 6, 7]); + let e = u32x4::from([0x80062d18, 0x4000315c, 0x90000062, 0x00000003]); + let r: u32x4 = unsafe { transmute(vsha1pq_u32(transmute(a), b, transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha2")] +unsafe fn test_vsha1su0q_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha1su0 + let a = u32x4::from([0, 1, 2, 3]); + let b = u32x4::from([4, 5, 6, 7]); + let c = u32x4::from([8, 9, 10, 11]); + let e = u32x4::from([0x0000000a, 0x0000000b, 0x0000000c, 0x0000000d]); + let r: u32x4 = unsafe { transmute(vsha1su0q_u32(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha2")] +unsafe fn test_vsha1su1q_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha1su1 + let a = u32x4::from([0, 1, 2, 3]); + let b = u32x4::from([4, 5, 6, 7]); + let e = u32x4::from([0x0000000a, 0x0000000e, 0x0000000a, 0x00000012]); + let r: u32x4 = unsafe { transmute(vsha1su1q_u32(transmute(a), transmute(b))) }; + assert_eq!(r, e); +} + #[cfg(target_arch = "aarch64")] #[target_feature(enable = "sha2")] unsafe fn test_vsha256hq_u32() { @@ -354,6 +423,267 @@ unsafe fn test_vsha256su1q_u32() { assert_eq!(r, e); } +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vsha512hq_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha512h + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let c = u64x2::from([4, 5]); + let e = u64x2::from([0x001c805053800005, 0x0015400002800003]); + let r: u64x2 = unsafe { transmute(vsha512hq_u64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vsha512h2q_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha512h2 + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let c = u64x2::from([4, 5]); + let e = u64x2::from([0x401000514a000405, 0x0000004108000005]); + let r: u64x2 = unsafe { transmute(vsha512h2q_u64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vsha512su0q_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha512su0 + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let e = u64x2::from([0x8100000000000000, 0x0200000000000002]); + let r: u64x2 = unsafe { transmute(vsha512su0q_u64(transmute(a), transmute(b))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vsha512su1q_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.sha512su1 + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let c = u64x2::from([4, 5]); + let e = u64x2::from([0x0000400000000014, 0x000060000000001e]); + let r: u64x2 = unsafe { transmute(vsha512su1q_u64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_s8() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3s.v16i8 + let a = i8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + let b = i8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + let c = i8x16::from([32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]); + let e = i8x16::from([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]); + let r: i8x16 = unsafe { transmute(veor3q_s8(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_s16() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3s.v8i16 + let a = i16x8::from([0, 1, 2, 3, 4, 5, 6, 7]); + let b = i16x8::from([8, 9, 10, 11, 12, 13, 14, 15]); + let c = i16x8::from([16, 17, 18, 19, 20, 21, 22, 23]); + let e = i16x8::from([24, 25, 26, 27, 28, 29, 30, 31]); + let r: i16x8 = unsafe { transmute(veor3q_s16(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_s32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3s.v4i32 + let a = i32x4::from([0, 1, 2, 3]); + let b = i32x4::from([4, 5, 6, 7]); + let c = i32x4::from([8, 9, 10, 11]); + let e = i32x4::from([12, 13, 14, 15]); + let r: i32x4 = unsafe { transmute(veor3q_s32(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_s64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3s.v2i64 + let a = i64x2::from([0, 1]); + let b = i64x2::from([2, 3]); + let c = i64x2::from([4, 5]); + let e = i64x2::from([6, 7]); + let r: i64x2 = unsafe { transmute(veor3q_s64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_u8() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3u.v16i8 + let a = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + let b = u8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + let c = u8x16::from([32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]); + let e = u8x16::from([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]); + let r: u8x16 = unsafe { transmute(veor3q_u8(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_u16() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3u.v8i16 + let a = u16x8::from([0, 1, 2, 3, 4, 5, 6, 7]); + let b = u16x8::from([8, 9, 10, 11, 12, 13, 14, 15]); + let c = u16x8::from([16, 17, 18, 19, 20, 21, 22, 23]); + let e = u16x8::from([24, 25, 26, 27, 28, 29, 30, 31]); + let r: u16x8 = unsafe { transmute(veor3q_u16(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3u.v4i32 + let a = u32x4::from([0, 1, 2, 3]); + let b = u32x4::from([4, 5, 6, 7]); + let c = u32x4::from([8, 9, 10, 11]); + let e = u32x4::from([12, 13, 14, 15]); + let r: u32x4 = unsafe { transmute(veor3q_u32(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_veor3q_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.eor3u.v2i64 + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let c = u64x2::from([4, 5]); + let e = u64x2::from([6, 7]); + let r: u64x2 = unsafe { transmute(veor3q_u64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_s8() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxs.v16i8 + let a = i8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + let b = i8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + let c = i8x16::from([32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]); + let e = i8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + let r: i8x16 = unsafe { transmute(vbcaxq_s8(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_s16() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxs.v8i16 + let a = i16x8::from([0, 1, 2, 3, 4, 5, 6, 7]); + let b = i16x8::from([8, 9, 10, 11, 12, 13, 14, 15]); + let c = i16x8::from([16, 17, 18, 19, 20, 21, 22, 23]); + let e = i16x8::from([8, 9, 10, 11, 12, 13, 14, 15]); + let r: i16x8 = unsafe { transmute(vbcaxq_s16(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_s32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxs.v4i32 + let a = i32x4::from([0, 1, 2, 3]); + let b = i32x4::from([4, 5, 6, 7]); + let c = i32x4::from([8, 9, 10, 11]); + let e = i32x4::from([4, 5, 6, 7]); + let r: i32x4 = unsafe { transmute(vbcaxq_s32(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_s64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxs.v2i64 + let a = i64x2::from([0, 1]); + let b = i64x2::from([2, 3]); + let c = i64x2::from([4, 5]); + let e = i64x2::from([2, 3]); + let r: i64x2 = unsafe { transmute(vbcaxq_s64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_u8() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxu.v16i8 + let a = u8x16::from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + let b = u8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + let c = u8x16::from([32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]); + let e = u8x16::from([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + let r: u8x16 = unsafe { transmute(vbcaxq_u8(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_u16() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxu.v8i16 + let a = u16x8::from([0, 1, 2, 3, 4, 5, 6, 7]); + let b = u16x8::from([8, 9, 10, 11, 12, 13, 14, 15]); + let c = u16x8::from([16, 17, 18, 19, 20, 21, 22, 23]); + let e = u16x8::from([8, 9, 10, 11, 12, 13, 14, 15]); + let r: u16x8 = unsafe { transmute(vbcaxq_u16(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_u32() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxu.v4i32 + let a = u32x4::from([0, 1, 2, 3]); + let b = u32x4::from([4, 5, 6, 7]); + let c = u32x4::from([8, 9, 10, 11]); + let e = u32x4::from([4, 5, 6, 7]); + let r: u32x4 = unsafe { transmute(vbcaxq_u32(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vbcaxq_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.bcaxu.v2i64 + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let c = u64x2::from([4, 5]); + let e = u64x2::from([2, 3]); + let r: u64x2 = unsafe { transmute(vbcaxq_u64(transmute(a), transmute(b), transmute(c))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vrax1q_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.rax1 + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let e = u64x2::from([4, 7]); + let r: u64x2 = unsafe { transmute(vrax1q_u64(transmute(a), transmute(b))) }; + assert_eq!(r, e); +} + +#[cfg(target_arch = "aarch64")] +#[target_feature(enable = "sha3")] +unsafe fn test_vxarq_u64() { + // AArch64 llvm intrinsic: llvm.aarch64.crypto.xar + let a = u64x2::from([0, 1]); + let b = u64x2::from([2, 3]); + let e = u64x2::from([4, 4]); + let r: u64x2 = unsafe { transmute(vxarq_u64::<63>(transmute(a), transmute(b))) }; + assert_eq!(r, e); +} + #[cfg(target_arch = "aarch64")] #[target_feature(enable = "aes")] fn test_vmull_p64() { @@ -565,11 +895,46 @@ fn main() { test_vaesmcq_u8(); test_vaesimcq_u8(); + test_vsha1cq_u32(); + test_vsha1h_u32(); + test_vsha1mq_u32(); + test_vsha1pq_u32(); + test_vsha1su0q_u32(); + test_vsha1su1q_u32(); + test_vsha256hq_u32(); test_vsha256h2q_u32(); test_vsha256su0q_u32(); test_vsha256su1q_u32(); + if std::arch::is_aarch64_feature_detected!("sha3") { + test_vsha512hq_u64(); + test_vsha512h2q_u64(); + test_vsha512su0q_u64(); + test_vsha512su1q_u64(); + + test_veor3q_s8(); + test_veor3q_s16(); + test_veor3q_s32(); + test_veor3q_s64(); + test_veor3q_u8(); + test_veor3q_u16(); + test_veor3q_u32(); + test_veor3q_u64(); + + test_vbcaxq_s8(); + test_vbcaxq_s16(); + test_vbcaxq_s32(); + test_vbcaxq_s64(); + test_vbcaxq_u8(); + test_vbcaxq_u16(); + test_vbcaxq_u32(); + test_vbcaxq_u64(); + + test_vrax1q_u64(); + test_vxarq_u64(); + } + test_vmull_p64(); test_vmull_p8(); diff --git a/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch b/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch index 717495cbcdf33..2268ff9cb266e 100644 --- a/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch +++ b/compiler/rustc_codegen_cranelift/patches/0027-stdlib-128bit-atomic-operations.patch @@ -37,14 +37,15 @@ diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 8a9a0b5..92ed9a6 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs -@@ -3762,42 +3757,6 @@ atomic_int! { +@@ -3762,44 +3757,6 @@ atomic_int! { 8, u64 AtomicU64 } --#[cfg(target_has_atomic_load_store = "128")] +-#[cfg(any(target_has_atomic_load_store = "128", doc))] -atomic_int! { -- cfg(target_has_atomic = "128"), -- cfg(target_has_atomic_primitive_alignment = "128"), +- target_has_atomic_load_store = "128", +- target_has_atomic = "128", +- target_has_atomic_primitive_alignment = "128", - unstable(feature = "integer_atomics", issue = "99069"), - unstable(feature = "integer_atomics", issue = "99069"), - unstable(feature = "integer_atomics", issue = "99069"), @@ -59,10 +60,11 @@ index 8a9a0b5..92ed9a6 100644 - 16, - i128 AtomicI128 -} --#[cfg(target_has_atomic_load_store = "128")] +-#[cfg(any(target_has_atomic_load_store = "128", doc))] -atomic_int! { -- cfg(target_has_atomic = "128"), -- cfg(target_has_atomic_primitive_alignment = "128"), +- target_has_atomic_load_store = "128", +- target_has_atomic = "128", +- target_has_atomic_primitive_alignment = "128", - unstable(feature = "integer_atomics", issue = "99069"), - unstable(feature = "integer_atomics", issue = "99069"), - unstable(feature = "integer_atomics", issue = "99069"), diff --git a/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch b/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch deleted file mode 100644 index 8d21359aa0043..0000000000000 --- a/compiler/rustc_codegen_cranelift/patches/0029-sysroot_tests-disable-f16-math.patch +++ /dev/null @@ -1,582 +0,0 @@ -From 285d5716fcfa6d43a3516d899b73bc85da322c25 Mon Sep 17 00:00:00 2001 -From: xonx <119700621+xonx4l@users.noreply.github.com> -Date: Sun, 15 Feb 2026 14:06:49 +0000 -Subject: [PATCH] Disable f16 math tests for cranelift - ---- - coretests/tests/num/floats.rs | 26 +++++++++++++------------- - 1 file changed, 13 insertions(+), 13 deletions(-) - -diff --git a/coretests/tests/num/floats.rs b/coretests/tests/num/floats.rs -index 1d7956b..01e4caa 100644 ---- a/coretests/tests/num/floats.rs -+++ b/coretests/tests/num/floats.rs -@@ -444,7 +444,7 @@ pub(crate) use float_test; - float_test! { - name: num, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -463,7 +463,7 @@ float_test! { - name: num_rem, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -476,7 +476,7 @@ float_test! { - float_test! { - name: nan, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -496,7 +496,7 @@ float_test! { - float_test! { - name: infinity, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -514,7 +514,7 @@ float_test! { - float_test! { - name: neg_infinity, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -532,7 +532,7 @@ float_test! { - float_test! { - name: zero, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -550,7 +550,7 @@ float_test! { - float_test! { - name: neg_zero, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -570,7 +570,7 @@ float_test! { - float_test! { - name: one, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -588,7 +588,7 @@ float_test! { - float_test! { - name: is_nan, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -609,7 +609,7 @@ float_test! { - float_test! { - name: is_infinite, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -630,7 +630,7 @@ float_test! { - float_test! { - name: is_finite, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -651,7 +651,7 @@ float_test! { - float_test! { - name: is_normal, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -673,7 +673,7 @@ float_test! { - float_test! { - name: classify, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - }, - test { - let nan: Float = Float::NAN; -@@ -695,7 +695,7 @@ float_test! { - name: min, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -737,7 +737,7 @@ float_test! { - name: max, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -780,7 +780,7 @@ float_test! { - name: minimum, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -812,7 +812,7 @@ float_test! { - name: maximum, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -845,7 +845,7 @@ float_test! { - name: midpoint, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -898,7 +898,7 @@ float_test! { - attrs: { - const: #[cfg(false)], - // Needs powi -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -929,7 +929,7 @@ float_test! { - name: abs, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -948,7 +948,7 @@ float_test! { - name: copysign, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -964,7 +964,7 @@ float_test! { - attrs: { - const: #[cfg(false)], - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -982,7 +982,7 @@ float_test! { - attrs: { - const: #[cfg(false)], - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -998,7 +998,7 @@ float_test! { - name: floor, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1028,7 +1028,7 @@ float_test! { - name: ceil, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1058,7 +1058,7 @@ float_test! { - name: round, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1089,7 +1089,7 @@ float_test! { - name: round_ties_even, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1120,7 +1120,7 @@ float_test! { - name: trunc, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1150,7 +1150,7 @@ float_test! { - name: fract, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1182,7 +1182,7 @@ float_test! { - name: signum, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1200,7 +1200,7 @@ float_test! { - float_test! { - name: is_sign_positive, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1219,7 +1219,7 @@ float_test! { - float_test! { - name: is_sign_negative, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1238,7 +1238,7 @@ float_test! { - float_test! { - name: next_up, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1269,7 +1269,7 @@ float_test! { - float_test! { - name: next_down, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1303,7 +1303,7 @@ float_test! { - attrs: { - const: #[cfg(false)], - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1321,7 +1321,7 @@ float_test! { - name: clamp_min_greater_than_max, - attrs: { - const: #[cfg(false)], -- f16: #[should_panic, cfg(target_has_reliable_f16)], -+ f16: #[should_panic, cfg(false)], - f32: #[should_panic], - f64: #[should_panic], - f128: #[should_panic, cfg(target_has_reliable_f128)], -@@ -1335,7 +1335,7 @@ float_test! { - name: clamp_min_is_nan, - attrs: { - const: #[cfg(false)], -- f16: #[should_panic, cfg(target_has_reliable_f16)], -+ f16: #[should_panic, cfg(false)], - f32: #[should_panic], - f64: #[should_panic], - f128: #[should_panic, cfg(target_has_reliable_f128)], -@@ -1349,7 +1349,7 @@ float_test! { - name: clamp_max_is_nan, - attrs: { - const: #[cfg(false)], -- f16: #[should_panic, cfg(target_has_reliable_f16)], -+ f16: #[should_panic, cfg(false)], - f32: #[should_panic], - f64: #[should_panic], - f128: #[should_panic, cfg(target_has_reliable_f128)], -@@ -1363,7 +1363,7 @@ float_test! { - name: total_cmp, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1469,7 +1469,7 @@ float_test! { - attrs: { - const: #[cfg(false)], - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1526,7 +1526,7 @@ float_test! { - name: recip, - attrs: { - // Miri only uses softfloats here, so that always works -- f16: #[cfg(any(miri, target_has_reliable_f16_math))], -+ f16: #[cfg(false)], - f128: #[cfg(any(miri, target_has_reliable_f128_math))], - }, - test { -@@ -1549,7 +1549,7 @@ float_test! { - name: powi, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1570,7 +1570,7 @@ float_test! { - name: powf, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1593,7 +1593,7 @@ float_test! { - name: exp, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1614,7 +1614,7 @@ float_test! { - name: exp2, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1634,7 +1634,7 @@ float_test! { - name: ln, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1656,7 +1656,7 @@ float_test! { - name: log, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1681,7 +1681,7 @@ float_test! { - name: log2, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1704,7 +1704,7 @@ float_test! { - name: log10, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1728,7 +1728,7 @@ float_test! { - name: asinh, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1764,7 +1764,7 @@ float_test! { - name: acosh, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1795,7 +1795,7 @@ float_test! { - name: atanh, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1821,7 +1821,7 @@ float_test! { - name: gamma, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1856,7 +1856,7 @@ float_test! { - name: ln_gamma, - attrs: { - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { -@@ -1874,7 +1874,7 @@ float_test! { - float_test! { - name: to_degrees, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1895,7 +1895,7 @@ float_test! { - float_test! { - name: to_radians, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1916,7 +1916,7 @@ float_test! { - float_test! { - name: to_algebraic, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1940,7 +1940,7 @@ float_test! { - float_test! { - name: to_bits_conv, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -1967,7 +1967,7 @@ float_test! { - float_test! { - name: mul_add, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - // FIXME(#140515): mingw has an incorrect fma https://sourceforge.net/p/mingw-w64/bugs/848/ - f32: #[cfg_attr(all(target_os = "windows", target_env = "gnu", not(target_abi = "llvm")), ignore)], - f64: #[cfg_attr(all(target_os = "windows", target_env = "gnu", not(target_abi = "llvm")), ignore)], -@@ -1992,7 +1992,7 @@ float_test! { - float_test! { - name: from, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -2049,7 +2049,7 @@ float_test! { - float_test! { - name: max_exact_integer_constant, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -2091,7 +2091,7 @@ float_test! { - float_test! { - name: min_exact_integer_constant, - attrs: { -- f16: #[cfg(target_has_reliable_f16)], -+ f16: #[cfg(false)], - f128: #[cfg(target_has_reliable_f128)], - }, - test { -@@ -2156,7 +2156,7 @@ float_test! { - attrs: { - // FIXME(f16_f128): add math tests when available - const: #[cfg(false)], -- f16: #[cfg(target_has_reliable_f16_math)], -+ f16: #[cfg(false)], // FIXME(rust-lang/rustc_codegen_cranelift#1622) - f128: #[cfg(target_has_reliable_f128_math)], - }, - test { --- -2.50.1 diff --git a/compiler/rustc_codegen_cranelift/rust-toolchain.toml b/compiler/rustc_codegen_cranelift/rust-toolchain.toml index faadf08929557..29d009597901f 100644 --- a/compiler/rustc_codegen_cranelift/rust-toolchain.toml +++ b/compiler/rustc_codegen_cranelift/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2026-06-06" +channel = "nightly-2026-07-22" components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"] profile = "minimal" diff --git a/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh b/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh index ab31c43fb1b12..c2b0e37a8eca7 100644 --- a/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh +++ b/compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh @@ -62,6 +62,19 @@ index 2e16f2cf27..3ac3df99a8 100644 # Add RUSTFLAGS_BOOTSTRAP to RUSTFLAGS for bootstrap compilation. # Note that RUSTFLAGS_BOOTSTRAP should always be added to the end of # RUSTFLAGS, since that causes RUSTFLAGS_BOOTSTRAP to override RUSTFLAGS. +diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs +index 6de70c7d70c..d5035b581ce 100644 +--- a/src/bootstrap/src/core/builder/cargo.rs ++++ b/src/bootstrap/src/core/builder/cargo.rs +@@ -1197,7 +1197,7 @@ fn cargo( + cargo.env("RUSTC_BOOTSTRAP", "1"); + + if matches!(mode, Mode::Std) { +- cargo.arg("-Zno-embed-metadata"); ++ cargo.arg("-Zembed-metadata=no"); + } + + if self.config.dump_bootstrap_shims { diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index bc68bfe396..00143ef3ed 100644 --- a/src/bootstrap/src/core/config/config.rs diff --git a/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh b/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh index 683adeb49edd1..9a7769497b169 100755 --- a/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh +++ b/compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh @@ -19,23 +19,22 @@ for test in $(rg -i --files-with-matches "//(\[\w+\])?~[^\|]*\s*ERR|//@ error-pa rm $test done -git checkout -- tests/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed +git checkout -- tests/ui/cross-crate/auxiliary/nested-struct-in-polymorphic-impl-method.rs # contains //~ERROR, but shouldn't be removed git checkout -- tests/ui/entry-point/auxiliary/bad_main_functions.rs # missing features # ================ # vendor intrinsics -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 -r tests/ui/linkage* rm tests/incremental/hashes/function_interfaces.rs rm tests/incremental/hashes/statics.rs rm -r tests/run-make/naked-symbol-visibility +rm tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs # variadic arguments rm tests/ui/abi/mir/mir_codegen_calls_variadic.rs # requires float varargs @@ -53,13 +52,13 @@ rm tests/ui/delegation/fn-header.rs rm tests/ui/c-variadic/roundtrip.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 +rm tests/ui/asm/x86_64/may_unwind.rs # same # misc unimplemented things rm tests/ui/target-feature/missing-plusminus.rs # error not implemented @@ -68,8 +67,6 @@ 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/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 @@ -105,8 +102,7 @@ rm tests/ui/linking/executable-no-mangle-strip.rs # requires --gc-sections to wo # backend specific tests # ====================== -rm tests/incremental/thinlto/cgu_invalidated_when_import_{added,removed}.rs # requires LLVM -rm -r tests/run-make/cross-lang-lto # same +rm -r tests/run-make/cross-lang-lto # requires LLVM rm -r tests/run-make/volatile-intrinsics # same rm -r tests/run-make/llvm-ident # same rm -r tests/run-make/no-builtins-attribute # same @@ -115,8 +111,10 @@ rm -r tests/run-make/llvm-location-discriminator-limit-dummy-span # same rm tests/ui/abi/stack-protector.rs # requires stack protector support rm -r tests/run-make/emit-stack-sizes # requires support for -Z emit-stack-sizes rm -r tests/run-make/optimization-remarks-dir # remarks are LLVM specific -rm -r tests/ui/codegen/remark-flag-functionality.rs # same +rm tests/ui/codegen/remark-flag-functionality.rs # same rm -r tests/run-make/print-to-output # requires --print relocation-models +rm tests/ui/abi/rust-preserve-none-cc.rs # extern "rust-preserve-none" is LLVM specific +rm tests/ui/abi/rust-tail-cc.rs # extern "rust-tail" is LLVM specific # requires asm, llvm-ir and/or llvm-bc emit support # ============================================= @@ -135,20 +133,19 @@ rm -r tests/run-make/artifact-incr-cache-no-obj rm -r tests/run-make/emit rm -r tests/run-make/llvm-outputs rm -r tests/run-make/panic-impl-transitive -rm -r tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs -rm -r tests/ui/statics/issue-91050-1.rs -rm -r tests/ui/statics/issue-91050-2.rs +rm tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs +rm tests/ui/statics/issue-91050-1.rs +rm tests/ui/statics/issue-91050-2.rs # giving different but possibly correct results # ============================================= -rm tests/ui/mir/mir_misc_casts.rs # depends on deduplication of constants rm tests/ui/mir/mir_raw_fat_ptr.rs # same -rm tests/ui/consts/issue-33537.rs # same rm tests/ui/consts/const-mut-refs-crate.rs # same rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift rm -r tests/run-make/short-ice # ICE backtrace begin/end marker mismatch -rm -r tests/run-make/naked-dead-code-elimination # function not eliminated rm tests/ui/codegen/huge-stacks.rs # Cranelift doesn't allow stack frames to exceed 4GB +rm -r tests/run-make/rustdoc/doctest/test_harness # different thread names likely caused by -Zpanic-abort-tests +rm -r tests/run-make/requires-consistent-cpu-no-native # no -Ctarget-cpu=help support # doesn't work due to the way the rustc test suite is invoked. # should work when using ./x.py test the way it is intended @@ -162,25 +159,29 @@ rm -r tests/run-make/missing-unstable-trait-bound # This disables support for un rm -r tests/run-make/const-trait-stable-toolchain # same rm -r tests/run-make/print-request-help-stable-unstable # same rm -r tests/run-make/issue-149402-suggest-unresolve # same +rm -r tests/run-make/const-destruct-stable-toolchain # same rm -r tests/run-make/incr-add-rust-src-component 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 -r tests/ui/extern/extern-types-field-offset.rs # expects /rustc/ rather than /rustc/FAKE_PREFIX -rm -r tests/ui/process/println-with-broken-pipe.rs # same -rm tests/codegen-units/item-collection/opaque-return-impls.rs # extra mono item. possibly due to other configuration +rm -r tests/run-make/export # something about rustc version mismatches +rm tests/ui/compiletest-self-test/compile-flags-incremental.rs # needs compiletest compiled with panic=unwind +rm tests/ui/extern/extern-types-field-offset.rs # expects /rustc/ rather than /rustc/FAKE_PREFIX +rm tests/ui/process/println-with-broken-pipe.rs # same # genuine bugs # ============ rm -r tests/run-make/extern-fn-explicit-align # argument alignment not yet supported rm -r tests/run-make/panic-abort-eh_frame # .eh_frame emitted with panic=abort +rm -r tests/run-make/used-proc-macro # doesn't work on arm64 for some reason # bugs in the test suite # ====================== rm tests/ui/process/nofile-limit.rs # FIXME some AArch64 linking issue rm -r tests/ui/codegen/equal-pointers-unequal # make incorrect assumptions about the location of stack variables -rm -r tests/incremental/extern_static/issue-49153.rs # assumes reference to undefined static gets optimized away +rm tests/incremental/extern_static/issue-49153.rs # assumes reference to undefined static gets optimized away +rm tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs # implicitly depends on libcore getting optimized away to avoid symbol refs +rm tests/ui/thread-local/thread-local-issue-37508.rs # incorrect rust_eh_personality signature +rm -r tests/run-make/staticlib-hide-internal-symbols # missing needs-unwind +rm -r tests/run-make/staticlib-rename-internal-symbols # needs files from staticlib-hide-internal-symbols 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/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 491463865b5db..5e152af835613 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -139,47 +139,56 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { mut returns: Vec, args: &[Value], ) -> Cow<'_, [Value]> { + // FIXME any way to reuse the abi adjustment code in rustc_target? + // Pass i128 arguments by-ref on Windows. - let (params, args): (Vec<_>, Cow<'_, [_]>) = if self.tcx.sess.target.is_like_windows { - let (params, args): (Vec<_>, Vec<_>) = params - .into_iter() - .zip(args) - .map(|(param, &arg)| { - if param.value_type == types::I128 { - let arg_ptr = self.create_stack_slot(16, 16); - arg_ptr.store(self, arg, MemFlags::trusted()); - (AbiParam::new(self.pointer_type), arg_ptr.get_addr(self)) - } else { - (param, arg) - } - }) - .unzip(); + let (params, args): (Vec<_>, Cow<'_, [_]>) = + if self.tcx.sess.target.is_like_windows || self.tcx.sess.target.arch == Arch::S390x { + let (params, args): (Vec<_>, Vec<_>) = params + .into_iter() + .zip(args) + .map(|(param, &arg)| { + if param.value_type == types::I128 + || (self.tcx.sess.target.arch == Arch::S390x + && param.value_type == types::F128) + { + let arg_ptr = self.create_stack_slot(16, 16); + arg_ptr.store(self, arg, MemFlagsData::trusted()); + (AbiParam::new(self.pointer_type), arg_ptr.get_addr(self)) + } else { + (param, arg) + } + }) + .unzip(); - (params, args.into()) - } else { - (params, args.into()) - }; + (params, args.into()) + } else { + (params, args.into()) + }; - let ret_single_i128 = returns.len() == 1 && returns[0].value_type == types::I128; - if ret_single_i128 && self.tcx.sess.target.is_like_windows { + if self.tcx.sess.target.is_like_windows + && matches!(*returns, [AbiParam { value_type: types::I128, .. }]) + { // Return i128 using the vector ABI on Windows returns[0].value_type = types::I64X2; let ret = self.lib_call_unadjusted(name, params, returns, &args)[0]; Cow::Owned(vec![codegen_bitcast(self, types::I128, ret)]) - } else if ret_single_i128 && self.tcx.sess.target.arch == Arch::S390x { - // Return i128 using a return area pointer on s390x. + } else if self.tcx.sess.target.arch == Arch::S390x + && matches!(*returns, [AbiParam { value_type: types::I128 | types::F128, .. }]) + { + // Return i128 and f128 using a return area pointer on s390x. let mut params = params; let mut args = args.to_vec(); - params.insert(0, AbiParam::new(self.pointer_type)); + params.insert(0, AbiParam::special(self.pointer_type, ArgumentPurpose::StructReturn)); let ret_ptr = self.create_stack_slot(16, 16); args.insert(0, ret_ptr.get_addr(self)); self.lib_call_unadjusted(name, params, vec![], &args); - Cow::Owned(vec![ret_ptr.load(self, types::I128, MemFlags::trusted())]) + Cow::Owned(vec![ret_ptr.load(self, types::I128, MemFlagsData::trusted())]) } else { Cow::Borrowed(self.lib_call_unadjusted(name, params, returns, &args)) } @@ -220,7 +229,7 @@ fn make_local_place<'tcx>( ); } let place = if is_ssa { - if let BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } = layout.backend_repr { + if let BackendRepr::ScalarPair { .. } = layout.backend_repr { CPlace::new_var_pair(fx, local, layout) } else { CPlace::new_var(fx, local, layout) @@ -747,7 +756,7 @@ pub(crate) fn codegen_drop<'tcx>( let ptr = ptr.get_addr(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable); - let is_null = fx.bcx.ins().icmp_imm(IntCC::Equal, drop_fn, 0); + let is_null = fx.bcx.ins().icmp_imm_u(IntCC::Equal, drop_fn, 0); let target_block = fx.get_block(target); let continued = fx.bcx.create_block(); fx.bcx.ins().brif(is_null, target_block, &[], continued, &[]); diff --git a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs index 75d7e4d9fd500..c4d4ddcf6b753 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs @@ -211,7 +211,11 @@ pub(super) fn to_casted_value<'tcx>( cast_target_to_abi_params(cast) .into_iter() .map(|(offset, param)| { - ptr.offset_i64(fx, offset.bytes() as i64).load(fx, param.value_type, MemFlags::new()) + ptr.offset_i64(fx, offset.bytes() as i64).load( + fx, + param.value_type, + MemFlagsData::new(), + ) }) .collect() } @@ -237,7 +241,7 @@ pub(super) fn from_casted_value<'tcx>( ptr.offset_i64(fx, offset.bytes() as i64).store( fx, block_params_iter.next().unwrap(), - MemFlags::new(), + MemFlagsData::trusted(), ) } assert_eq!(block_params_iter.next(), None, "Leftover block param"); diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs index 3c18748ee24b4..9133fd738a9d2 100644 --- a/compiler/rustc_codegen_cranelift/src/allocator.rs +++ b/compiler/rustc_codegen_cranelift/src/allocator.rs @@ -73,7 +73,7 @@ pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut dyn Module, methods: &[Alloc bcx.switch_to_block(block); bcx.ins().return_(&[]); bcx.seal_all_blocks(); - bcx.finalize(); + bcx.finalize(module.target_config()); module.define_function(func_id, &mut ctx).unwrap(); } diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 9bf379c03687c..451983a9053b8 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -7,6 +7,7 @@ use cranelift_module::ModuleError; 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_errors::DiagCtxtHandle; use rustc_index::IndexVec; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::adjustment::PointerCoercion; @@ -18,7 +19,7 @@ use rustc_span::Symbol; use crate::constant::ConstantCx; use crate::debuginfo::{FunctionDebugContext, TypeDebugContext}; use crate::prelude::*; -use crate::pretty_clif::CommentWriter; +use crate::pretty_clif::{CommentWriter, format_clif_ir_header}; use crate::{codegen_f16_f128, enable_verifier}; pub(crate) struct CodegenedFunction { @@ -119,7 +120,7 @@ pub(crate) fn codegen_fn<'tcx>( tcx.prof.generic_activity("codegen clif ir").run(|| codegen_fn_body(&mut fx, start_block)); fx.bcx.seal_all_blocks(); - fx.bcx.finalize(); + fx.bcx.finalize(fx.module.target_config()); // Recover all necessary data from fx, before accessing func will prevent future access to it. let symbol_name = fx.symbol_name; @@ -148,6 +149,7 @@ pub(crate) fn codegen_fn<'tcx>( pub(crate) fn compile_fn( prof: &SelfProfilerRef, + dcx: DiagCtxtHandle<'_>, output_filenames: &OutputFilenames, should_write_ir: bool, cached_context: &mut Context, @@ -168,23 +170,15 @@ pub(crate) fn compile_fn( #[cfg(false)] let _clif_guard = { - use std::fmt::Write; - + let isa = module.isa(); + let symbol_name = &codegened_func.symbol_name; let func_clone = context.func.clone(); let clif_comments_clone = clif_comments.clone(); - let mut clif = String::new(); - for flag in module.isa().flags().iter() { - writeln!(clif, "set {}", flag).unwrap(); - } - write!(clif, "target {}", module.isa().triple().architecture.to_string()).unwrap(); - for isa_flag in module.isa().isa_flags().iter() { - write!(clif, " {}", isa_flag).unwrap(); - } - writeln!(clif, "\n").unwrap(); - writeln!(clif, "; symbol {}", codegened_func.symbol_name).unwrap(); + + let clif = crate::pretty_clif::format_clif_ir_header(isa, symbol_name); crate::PrintOnPanic(move || { let mut clif = clif.clone(); - ::cranelift_codegen::write::decorate_function( + cranelift_codegen::write::decorate_function( &mut &clif_comments_clone, &mut clif, &func_clone, @@ -200,28 +194,33 @@ pub(crate) fn compile_fn( match module.define_function(codegened_func.func_id, context) { Ok(()) => {} Err(ModuleError::Compilation(CodegenError::ImplLimitExceeded)) => { - let early_dcx = rustc_session::EarlyDiagCtxt::new( - rustc_session::config::ErrorOutputType::default(), - ); - early_dcx.early_fatal(format!( + dcx.fatal(format!( "backend implementation limit exceeded while compiling {name}", name = codegened_func.symbol_name )); } Err(ModuleError::Compilation(CodegenError::Verifier(err))) => { - let early_dcx = rustc_session::EarlyDiagCtxt::new( - rustc_session::config::ErrorOutputType::default(), - ); - let _ = early_dcx.early_err(format!("{:?}", err)); + dcx.err(format!("{err:?}")); let pretty_error = cranelift_codegen::print_errors::pretty_verifier_error( &context.func, Some(Box::new(&clif_comments)), err, ); - early_dcx.early_fatal(format!("cranelift verify error:\n{}", pretty_error)); + dcx.fatal(format!("cranelift verify error:\n{pretty_error}")); } Err(err) => { - panic!("Error while defining {name}: {err:?}", name = codegened_func.symbol_name); + let mut clif = format_clif_ir_header(module.isa(), &codegened_func.symbol_name); + cranelift_codegen::write::decorate_function( + &mut &clif_comments, + &mut clif, + &context.func, + ) + .unwrap(); + + panic!( + "Error while defining {name}: {err:?}\n\nPost-optimization Cranelift IR:\n{clif}", + name = codegened_func.symbol_name + ); } } }); @@ -639,10 +638,11 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: let ref_ = place.place_ref(fx, lval.layout()); lval.write_cvalue(fx, ref_); } - Rvalue::Reborrow(_, _, place) => { + Rvalue::Reborrow(ty, _, place) => { + assert_eq!(lval.layout().ty, ty); let cplace = codegen_place(fx, place); let val = cplace.to_cvalue(fx); - lval.write_cvalue(fx, val) + lval.write_cvalue_transmute(fx, val) } Rvalue::ThreadLocalRef(def_id) => { let val = crate::constant::codegen_tls_ref(fx, def_id, lval.layout()); @@ -667,7 +667,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: let val = operand.load_scalar(fx); match layout.ty.kind() { ty::Bool => { - let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); + let res = fx.bcx.ins().icmp_imm_u(IntCC::Equal, val, 0); CValue::by_val(res, layout) } ty::Uint(_) | ty::Int(_) => { @@ -695,7 +695,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: } UnOp::PtrMetadata => match layout.backend_repr { BackendRepr::Scalar(_) => CValue::zst(dest_layout), - BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } => { + BackendRepr::ScalarPair { .. } => { CValue::by_val(operand.load_scalar_pair(fx).1, dest_layout) } _ => bug!("Unexpected `PtrToMetadata` operand: {operand:?}"), @@ -855,13 +855,13 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: fx.bcx.ins().jump(loop_block, &[zero.into()]); fx.bcx.switch_to_block(loop_block); - let done = fx.bcx.ins().icmp_imm(IntCC::Equal, index, times as i64); + let done = fx.bcx.ins().icmp_imm_u(IntCC::Equal, index, times as i64); fx.bcx.ins().brif(done, done_block, &[], loop_block2, &[]); fx.bcx.switch_to_block(loop_block2); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); - let index = fx.bcx.ins().iadd_imm(index, 1); + let index = fx.bcx.ins().iadd_imm_u(index, 1); fx.bcx.ins().jump(loop_block, &[index.into()]); fx.bcx.switch_to_block(done_block); @@ -953,7 +953,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: let count = codegen_operand(fx, count).load_scalar(fx); let bytes = if elem_size != 1 { - fx.bcx.ins().imul_imm(count, elem_size as i64) + fx.bcx.ins().imul_imm_u(count, elem_size as i64) } else { count }; @@ -1006,7 +1006,7 @@ pub(crate) fn codegen_place<'tcx>( fx.bcx.ins().iconst(fx.pointer_type, offset as i64) } else { let len = codegen_array_len(fx, cplace); - fx.bcx.ins().iadd_imm(len, -(offset as i64)) + fx.bcx.ins().iadd_imm_s(len, -(offset as i64)) }; cplace = cplace.place_index(fx, index); } @@ -1033,7 +1033,7 @@ pub(crate) fn codegen_place<'tcx>( let (ptr, len) = cplace.to_ptr_unsized(); cplace = CPlace::for_ptr_with_extra( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), - fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), + fx.bcx.ins().iadd_imm_s(len, -(from as i64 + to as i64)), cplace.layout(), ); } diff --git a/compiler/rustc_codegen_cranelift/src/cast.rs b/compiler/rustc_codegen_cranelift/src/cast.rs index 8a725680e7059..f124739d1e154 100644 --- a/compiler/rustc_codegen_cranelift/src/cast.rs +++ b/compiler/rustc_codegen_cranelift/src/cast.rs @@ -133,12 +133,12 @@ pub(crate) fn clif_int_or_float_cast( let max_val = fx.bcx.ins().iconst(types::I32, max); let val = if to_signed { - let has_underflow = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, val, min); - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, val, max); + let has_underflow = fx.bcx.ins().icmp_imm_s(IntCC::SignedLessThan, val, min); + let has_overflow = fx.bcx.ins().icmp_imm_s(IntCC::SignedGreaterThan, val, max); let bottom_capped = fx.bcx.ins().select(has_underflow, min_val, val); fx.bcx.ins().select(has_overflow, max_val, bottom_capped) } else { - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, val, max); + let has_overflow = fx.bcx.ins().icmp_imm_u(IntCC::UnsignedGreaterThan, val, max); fx.bcx.ins().select(has_overflow, max_val, val) }; fx.bcx.ins().ireduce(to_ty, val) diff --git a/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs b/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs index e63e4bebf78a2..089ea87d74f6c 100644 --- a/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs +++ b/compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs @@ -7,7 +7,7 @@ pub(crate) fn f16_to_f32(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value let (value, arg_ty) = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 { ( - fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value), + fx.bcx.ins().bitcast(types::I16, MemFlagsData::new(), value), lib_call_arg_param(fx.tcx, types::I16, false), ) } else { @@ -33,7 +33,11 @@ pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value vec![AbiParam::new(ret_ty)], &[value], )[0]; - if ret_ty == types::I16 { fx.bcx.ins().bitcast(types::F16, MemFlags::new(), ret) } else { ret } + if ret_ty == types::I16 { + fx.bcx.ins().bitcast(types::F16, MemFlagsData::new(), ret) + } else { + ret + } } fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { @@ -48,7 +52,11 @@ fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { vec![AbiParam::new(ret_ty)], &[value], )[0]; - if ret_ty == types::I16 { fx.bcx.ins().bitcast(types::F16, MemFlags::new(), ret) } else { ret } + if ret_ty == types::I16 { + fx.bcx.ins().bitcast(types::F16, MemFlagsData::new(), ret) + } else { + ret + } } // FIXME(bytecodealliance/wasmtime#8312): Remove once backend lowerings have @@ -139,52 +147,52 @@ pub(crate) fn codegen_f128_binop( } pub(crate) fn neg_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { - let bits = fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value); - let bits = fx.bcx.ins().bxor_imm(bits, 0x8000); - fx.bcx.ins().bitcast(types::F16, MemFlags::new(), bits) + let bits = fx.bcx.ins().bitcast(types::I16, MemFlagsData::new(), value); + let bits = fx.bcx.ins().bxor_imm_u(bits, 0x8000); + fx.bcx.ins().bitcast(types::F16, MemFlagsData::new(), bits) } pub(crate) fn neg_f128(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { - let bits = fx.bcx.ins().bitcast(types::I128, MemFlags::new(), value); + let bits = fx.bcx.ins().bitcast(types::I128, MemFlagsData::new(), value); let (low, high) = fx.bcx.ins().isplit(bits); - let high = fx.bcx.ins().bxor_imm(high, 0x8000_0000_0000_0000_u64 as i64); + let high = fx.bcx.ins().bxor_imm_u(high, 0x8000_0000_0000_0000_u64 as i64); let bits = fx.bcx.ins().iconcat(low, high); - fx.bcx.ins().bitcast(types::F128, MemFlags::new(), bits) + fx.bcx.ins().bitcast(types::F128, MemFlagsData::new(), bits) } pub(crate) fn abs_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { - let bits = fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value); - let bits = fx.bcx.ins().band_imm(bits, 0x7fff); - fx.bcx.ins().bitcast(types::F16, MemFlags::new(), bits) + let bits = fx.bcx.ins().bitcast(types::I16, MemFlagsData::new(), value); + let bits = fx.bcx.ins().band_imm_u(bits, 0x7fff); + fx.bcx.ins().bitcast(types::F16, MemFlagsData::new(), bits) } pub(crate) fn abs_f128(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value { - let bits = fx.bcx.ins().bitcast(types::I128, MemFlags::new(), value); + let bits = fx.bcx.ins().bitcast(types::I128, MemFlagsData::new(), value); let (low, high) = fx.bcx.ins().isplit(bits); - let high = fx.bcx.ins().band_imm(high, 0x7fff_ffff_ffff_ffff_u64 as i64); + let high = fx.bcx.ins().band_imm_u(high, 0x7fff_ffff_ffff_ffff_u64 as i64); let bits = fx.bcx.ins().iconcat(low, high); - fx.bcx.ins().bitcast(types::F128, MemFlags::new(), bits) + fx.bcx.ins().bitcast(types::F128, MemFlagsData::new(), bits) } pub(crate) fn copysign_f16(fx: &mut FunctionCx<'_, '_, '_>, lhs: Value, rhs: Value) -> Value { - let lhs = fx.bcx.ins().bitcast(types::I16, MemFlags::new(), lhs); - let rhs = fx.bcx.ins().bitcast(types::I16, MemFlags::new(), rhs); - let res = fx.bcx.ins().band_imm(lhs, 0x7fff); - let sign = fx.bcx.ins().band_imm(rhs, 0x8000); + let lhs = fx.bcx.ins().bitcast(types::I16, MemFlagsData::new(), lhs); + let rhs = fx.bcx.ins().bitcast(types::I16, MemFlagsData::new(), rhs); + let res = fx.bcx.ins().band_imm_u(lhs, 0x7fff); + let sign = fx.bcx.ins().band_imm_u(rhs, 0x8000); let res = fx.bcx.ins().bor(res, sign); - fx.bcx.ins().bitcast(types::F16, MemFlags::new(), res) + fx.bcx.ins().bitcast(types::F16, MemFlagsData::new(), res) } pub(crate) fn copysign_f128(fx: &mut FunctionCx<'_, '_, '_>, lhs: Value, rhs: Value) -> Value { - let lhs = fx.bcx.ins().bitcast(types::I128, MemFlags::new(), lhs); - let rhs = fx.bcx.ins().bitcast(types::I128, MemFlags::new(), rhs); + let lhs = fx.bcx.ins().bitcast(types::I128, MemFlagsData::new(), lhs); + let rhs = fx.bcx.ins().bitcast(types::I128, MemFlagsData::new(), rhs); let (low, lhs_high) = fx.bcx.ins().isplit(lhs); let (_, rhs_high) = fx.bcx.ins().isplit(rhs); - let high = fx.bcx.ins().band_imm(lhs_high, 0x7fff_ffff_ffff_ffff_u64 as i64); - let sign = fx.bcx.ins().band_imm(rhs_high, 0x8000_0000_0000_0000_u64 as i64); + let high = fx.bcx.ins().band_imm_u(lhs_high, 0x7fff_ffff_ffff_ffff_u64 as i64); + let sign = fx.bcx.ins().band_imm_u(rhs_high, 0x8000_0000_0000_0000_u64 as i64); let high = fx.bcx.ins().bor(high, sign); let res = fx.bcx.ins().iconcat(low, high); - fx.bcx.ins().bitcast(types::F128, MemFlags::new(), res) + fx.bcx.ins().bitcast(types::F128, MemFlagsData::new(), res) } pub(crate) fn codegen_cast( @@ -267,12 +275,12 @@ pub(crate) fn codegen_cast( let max_val = fx.bcx.ins().iconst(types::I32, max); let val = if to_signed { - let has_underflow = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, ret, min); - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, ret, max); + let has_underflow = fx.bcx.ins().icmp_imm_s(IntCC::SignedLessThan, ret, min); + let has_overflow = fx.bcx.ins().icmp_imm_s(IntCC::SignedGreaterThan, ret, max); let bottom_capped = fx.bcx.ins().select(has_underflow, min_val, ret); fx.bcx.ins().select(has_overflow, max_val, bottom_capped) } else { - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, ret, max); + let has_overflow = fx.bcx.ins().icmp_imm_u(IntCC::UnsignedGreaterThan, ret, max); fx.bcx.ins().select(has_overflow, max_val, ret) }; fx.bcx.ins().ireduce(to_ty, val) diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index 69e472b33abac..1bdb3efefa1aa 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -116,13 +116,13 @@ pub(crate) fn codegen_icmp_imm( match intcc { IntCC::Equal => { - let lsb_eq = fx.bcx.ins().icmp_imm(IntCC::Equal, lhs_lsb, rhs_lsb); - let msb_eq = fx.bcx.ins().icmp_imm(IntCC::Equal, lhs_msb, rhs_msb); + let lsb_eq = fx.bcx.ins().icmp_imm_u(IntCC::Equal, lhs_lsb, rhs_lsb); + let msb_eq = fx.bcx.ins().icmp_imm_u(IntCC::Equal, lhs_msb, rhs_msb); fx.bcx.ins().band(lsb_eq, msb_eq) } IntCC::NotEqual => { - let lsb_ne = fx.bcx.ins().icmp_imm(IntCC::NotEqual, lhs_lsb, rhs_lsb); - let msb_ne = fx.bcx.ins().icmp_imm(IntCC::NotEqual, lhs_msb, rhs_msb); + let lsb_ne = fx.bcx.ins().icmp_imm_u(IntCC::NotEqual, lhs_lsb, rhs_lsb); + let msb_ne = fx.bcx.ins().icmp_imm_u(IntCC::NotEqual, lhs_msb, rhs_msb); fx.bcx.ins().bor(lsb_ne, msb_ne) } _ => { @@ -132,21 +132,21 @@ pub(crate) fn codegen_icmp_imm( // msb_cc // } - let msb_eq = fx.bcx.ins().icmp_imm(IntCC::Equal, lhs_msb, rhs_msb); - let lsb_cc = fx.bcx.ins().icmp_imm(intcc, lhs_lsb, rhs_lsb); - let msb_cc = fx.bcx.ins().icmp_imm(intcc, lhs_msb, rhs_msb); + let msb_eq = fx.bcx.ins().icmp_imm_u(IntCC::Equal, lhs_msb, rhs_msb); + let lsb_cc = fx.bcx.ins().icmp_imm_u(intcc, lhs_lsb, rhs_lsb); + let msb_cc = fx.bcx.ins().icmp_imm_u(intcc, lhs_msb, rhs_msb); fx.bcx.ins().select(msb_eq, lsb_cc, msb_cc) } } } else { let rhs = rhs as i64; // Truncates on purpose in case rhs is actually an unsigned value - fx.bcx.ins().icmp_imm(intcc, lhs, rhs) + fx.bcx.ins().icmp_imm_u(intcc, lhs, rhs) } } pub(crate) fn codegen_bitcast(fx: &mut FunctionCx<'_, '_, '_>, dst_ty: Type, val: Value) -> Value { - let mut flags = MemFlags::new(); + let mut flags = MemFlagsData::new(); flags.set_endianness(match fx.tcx.data_layout.endian { rustc_abi::Endian::Big => cranelift_codegen::ir::Endianness::Big, rustc_abi::Endian::Little => cranelift_codegen::ir::Endianness::Little, @@ -262,7 +262,7 @@ pub(crate) fn create_wrapper_function( bcx.ins().return_(&results); bcx.seal_all_blocks(); - bcx.finalize(); + bcx.finalize(module.target_config()); } module.define_function(wrapper_func_id, &mut ctx).unwrap(); } @@ -400,8 +400,9 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { 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)); - let realign_offset = self.bcx.ins().irsub_imm(misalign_offset, i64::from(align)); + let misalign_offset = self.bcx.ins().band_imm_u(base_ptr, i64::from(align - 1)); + let align = self.bcx.ins().iconst(self.pointer_type, i64::from(align)); + let realign_offset = self.bcx.ins().isub(align, misalign_offset); Pointer::new(self.bcx.ins().iadd(base_ptr, realign_offset)) } } diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 829e7d0dfb59c..175ca37a3b74e 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -131,7 +131,7 @@ pub(crate) fn codegen_const_value<'tcx>( // FIXME avoid this extra copy to the stack and directly write to the final // destination let place = CPlace::new_stack_slot(fx, layout); - place.to_ptr().store(fx, val, MemFlags::trusted()); + place.to_ptr().store(fx, val, MemFlagsData::trusted()); place.to_cvalue(fx) } } @@ -206,9 +206,10 @@ pub(crate) fn codegen_const_value<'tcx>( } }; let val = if offset.bytes() != 0 { - fx.bcx - .ins() - .iadd_imm(base_addr, fx.tcx.truncate_to_target_usize(offset.bytes()) as i64) + fx.bcx.ins().iadd_imm_u( + base_addr, + fx.tcx.truncate_to_target_usize(offset.bytes()) as i64, + ) } else { base_addr }; diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs index cc1efef287517..14235689a5576 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/emit.rs @@ -81,34 +81,16 @@ impl WriterRelocate { /// Perform the collected relocations to be usable for JIT usage. #[cfg(all(feature = "jit", not(windows)))] pub(super) fn relocate_for_jit(mut self, jit_module: &cranelift_jit::JITModule) -> Vec { - use cranelift_module::Module; - for reloc in self.relocs.drain(..) { match reloc.name { super::DebugRelocName::Section(_) => unreachable!(), super::DebugRelocName::Symbol(sym) => { let addr = if sym & 1 << 31 == 0 { let func_id = FuncId::from_u32(sym.try_into().unwrap()); - // FIXME make JITModule::get_address public and use it here instead. - // HACK rust_eh_personality is likely not defined in the same crate, - // so get_finalized_function won't work. Use the rust_eh_personality - // of cg_clif itself, which is likely ABI compatible. - if jit_module.declarations().get_function_decl(func_id).name.as_deref() - == Some("rust_eh_personality") - { - unsafe extern "C" { - fn rust_eh_personality() -> !; - } - rust_eh_personality as *const u8 - } else { - jit_module.get_finalized_function(func_id) - } + jit_module.get_address(&func_id.into()) } else { - jit_module - .get_finalized_data(DataId::from_u32( - u32::try_from(sym).unwrap() & !(1 << 31), - )) - .0 + let data_id = DataId::from_u32(u32::try_from(sym).unwrap() & !(1 << 31)); + jit_module.get_address(&data_id.into()) }; let val = (addr as u64 as i64 + reloc.addend) as u64; diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index fcaf80d968a49..d6c25cf524a5c 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -17,7 +17,7 @@ use rustc_codegen_ssa::back::write::{ use rustc_codegen_ssa::traits::{ExtraBackendMethods, WriteBackendMethods}; use rustc_codegen_ssa::{CompiledModule, ModuleCodegen, ModuleKind}; use rustc_data_structures::profiling::SelfProfilerRef; -use rustc_errors::DiagCtxt; +use rustc_errors::{DiagCtxt, DiagCtxtHandle}; use rustc_hir::attrs::Linkage as RLinkage; use rustc_middle::dep_graph::WorkProduct; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; @@ -205,6 +205,7 @@ fn codegen_cgu(tcx: TyCtxt<'_>, cgu_name: Symbol) -> AotModule { fn compile_cgu( prof: &SelfProfilerRef, + dcx: DiagCtxtHandle<'_>, output_filenames: &OutputFilenames, should_write_ir: bool, mut aot_module: AotModule, @@ -220,6 +221,7 @@ fn compile_cgu( for codegened_func in aot_module.codegened_functions { crate::base::compile_fn( &prof, + dcx, &output_filenames, should_write_ir, &mut cached_context, @@ -308,11 +310,8 @@ impl ExtraBackendMethods for AotDriver { impl WriteBackendMethods for AotDriver { type Module = AotModule; - - type TargetMachine = (); - type ModuleBuffer = Infallible; - + type TargetMachine = (); type ThinData = Infallible; fn target_machine_factory( @@ -373,18 +372,17 @@ impl WriteBackendMethods for AotDriver { module: ModuleCodegen, config: &ModuleConfig, ) -> CompiledModule { + let dcx = DiagCtxt::new(Box::new(shared_emitter.clone())); compile_cgu( prof, + dcx.handle(), &cgcx.output_filenames, config.emit_ir, module.module_llvm, module.name, module.kind, ) - .unwrap_or_else(|err| { - let dcx = DiagCtxt::new(Box::new(shared_emitter.clone())); - dcx.handle().fatal(err) - }) + .unwrap_or_else(|err| dcx.handle().fatal(err)) } fn serialize_module(_module: Self::Module, _is_thin: bool) -> Self::ModuleBuffer { diff --git a/compiler/rustc_codegen_cranelift/src/driver/jit.rs b/compiler/rustc_codegen_cranelift/src/driver/jit.rs index 7d6ece02e4a62..32f60615844bc 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/jit.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/jit.rs @@ -157,6 +157,7 @@ fn codegen_and_compile_fn<'tcx>( let mut global_asm = String::new(); crate::base::compile_fn( &tcx.prof, + tcx.dcx(), output_filenames, should_write_ir, cached_context, diff --git a/compiler/rustc_codegen_cranelift/src/inline_asm.rs b/compiler/rustc_codegen_cranelift/src/inline_asm.rs index cc849759754ee..1c6888507b65f 100644 --- a/compiler/rustc_codegen_cranelift/src/inline_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/inline_asm.rs @@ -847,7 +847,7 @@ fn call_inline_asm<'tcx>( stack_slot.offset(fx, i32::try_from(offset.bytes()).unwrap().into()).store( fx, value, - MemFlags::trusted(), + MemFlagsData::trusted(), ); } @@ -865,7 +865,7 @@ fn call_inline_asm<'tcx>( let value = stack_slot.offset(fx, i32::try_from(offset.bytes()).unwrap().into()).load( fx, ty, - MemFlags::trusted(), + MemFlagsData::trusted(), ); place.write_cvalue(fx, CValue::by_val(value, place.layout())); } diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_aarch64.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_aarch64.rs index 9da87a5774e8f..b046bf1ee4df9 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_aarch64.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_aarch64.rs @@ -422,11 +422,11 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( for i in 0..8 { let idx_lane = idx.value_lane(fx, i).load_scalar(fx); let is_zero = - fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThanOrEqual, idx_lane, 16); + fx.bcx.ins().icmp_imm_u(IntCC::UnsignedGreaterThanOrEqual, idx_lane, 16); let t_idx = fx.bcx.ins().uextend(fx.pointer_type, idx_lane); let t_lane = t.value_lane_dyn(fx, t_idx).load_scalar(fx); let res = fx.bcx.ins().select(is_zero, zero, t_lane); - ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlags::trusted()); + ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlagsData::trusted()); } } "llvm.aarch64.neon.tbl1.v16i8" => { @@ -436,11 +436,11 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( for i in 0..16 { let idx_lane = idx.value_lane(fx, i).load_scalar(fx); let is_zero = - fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThanOrEqual, idx_lane, 16); + fx.bcx.ins().icmp_imm_u(IntCC::UnsignedGreaterThanOrEqual, idx_lane, 16); let t_idx = fx.bcx.ins().uextend(fx.pointer_type, idx_lane); let t_lane = t.value_lane_dyn(fx, t_idx).load_scalar(fx); let res = fx.bcx.ins().select(is_zero, zero, t_lane); - ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlags::trusted()); + ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlagsData::trusted()); } } @@ -605,6 +605,164 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( ); } + "llvm.aarch64.crypto.sha1c" | "llvm.aarch64.crypto.sha1m" | "llvm.aarch64.crypto.sha1p" => { + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + let a = a.load_scalar(fx); + let b = b.load_scalar(fx); + let c = c.load_scalar(fx); + + let asm = match intrinsic { + "llvm.aarch64.crypto.sha1c" => { + "fmov s2, w1 + sha1c q0, s2, v1.4s" + } + "llvm.aarch64.crypto.sha1m" => { + "fmov s2, w1 + sha1m q0, s2, v1.4s" + } + "llvm.aarch64.crypto.sha1p" => { + "fmov s2, w1 + sha1p q0, s2, v1.4s" + } + _ => unreachable!(), + }; + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String(asm.into())], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::x1, + )), + value: b, + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v1, + )), + value: c, + }, + CInlineAsmOperand::Out { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v2, + )), + late: true, + place: None, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + + "llvm.aarch64.crypto.sha1h" => { + intrinsic_args!(fx, args => (a); intrinsic); + + let a = a.load_scalar(fx); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String( + "fmov s0, w0 + sha1h s0, s0 + fmov w0, s0" + .into(), + )], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::x0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::Out { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + late: true, + place: None, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + + "llvm.aarch64.crypto.sha1su0" => { + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + let a = a.load_scalar(fx); + let b = b.load_scalar(fx); + let c = c.load_scalar(fx); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String("sha1su0 v0.4s, v1.4s, v2.4s".into())], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v1, + )), + value: b, + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v2, + )), + value: c, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + + "llvm.aarch64.crypto.sha1su1" => { + intrinsic_args!(fx, args => (a, b); intrinsic); + + let a = a.load_scalar(fx); + let b = b.load_scalar(fx); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String("sha1su1 v0.4s, v1.4s".into())], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v1, + )), + value: b, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + "llvm.aarch64.crypto.sha256h" | "llvm.aarch64.crypto.sha256h2" => { intrinsic_args!(fx, args => (a, b, c); intrinsic); @@ -712,6 +870,195 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( ); } + "llvm.aarch64.crypto.sha512h" | "llvm.aarch64.crypto.sha512h2" => { + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + let a = a.load_scalar(fx); + let b = b.load_scalar(fx); + let c = c.load_scalar(fx); + + let asm = match intrinsic { + "llvm.aarch64.crypto.sha512h" => "sha512h q0, q1, v2.2d", + "llvm.aarch64.crypto.sha512h2" => "sha512h2 q0, q1, v2.2d", + _ => unreachable!(), + }; + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String(asm.into())], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v1, + )), + value: b, + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v2, + )), + value: c, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + + "llvm.aarch64.crypto.sha512su0" => { + intrinsic_args!(fx, args => (a, b); intrinsic); + + let a = a.load_scalar(fx); + let b = b.load_scalar(fx); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String("sha512su0 v0.2d, v1.2d".into())], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v1, + )), + value: b, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + + "llvm.aarch64.crypto.sha512su1" => { + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + let a = a.load_scalar(fx); + let b = b.load_scalar(fx); + let c = c.load_scalar(fx); + + codegen_inline_asm_inner( + fx, + &[InlineAsmTemplatePiece::String("sha512su1 v0.2d, v1.2d, v2.2d".into())], + &[ + CInlineAsmOperand::InOut { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v0, + )), + _late: true, + in_value: a, + out_place: Some(ret), + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v1, + )), + value: b, + }, + CInlineAsmOperand::In { + reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::AArch64( + AArch64InlineAsmReg::v2, + )), + value: c, + }, + ], + InlineAsmOptions::NOSTACK | InlineAsmOptions::PURE | InlineAsmOptions::NOMEM, + ); + } + + "llvm.aarch64.crypto.eor3s.v2i64" + | "llvm.aarch64.crypto.eor3s.v4i32" + | "llvm.aarch64.crypto.eor3s.v8i16" + | "llvm.aarch64.crypto.eor3s.v16i8" + | "llvm.aarch64.crypto.eor3u.v2i64" + | "llvm.aarch64.crypto.eor3u.v4i32" + | "llvm.aarch64.crypto.eor3u.v8i16" + | "llvm.aarch64.crypto.eor3u.v16i8" => { + // https://developer.arm.com/documentation/ddi0602/2026-03/SIMD-FP-Instructions/EOR3--Three-way-exclusive-OR- + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + simd_trio_for_each_lane( + fx, + a, + b, + c, + ret, + &|fx, _lane_ty, _res_lane_ty, a_lane, b_lane, c_lane| { + let xor = fx.bcx.ins().bxor(a_lane, b_lane); + fx.bcx.ins().bxor(xor, c_lane) + }, + ); + } + + "llvm.aarch64.crypto.bcaxs.v2i64" + | "llvm.aarch64.crypto.bcaxs.v4i32" + | "llvm.aarch64.crypto.bcaxs.v8i16" + | "llvm.aarch64.crypto.bcaxs.v16i8" + | "llvm.aarch64.crypto.bcaxu.v2i64" + | "llvm.aarch64.crypto.bcaxu.v4i32" + | "llvm.aarch64.crypto.bcaxu.v8i16" + | "llvm.aarch64.crypto.bcaxu.v16i8" => { + // https://developer.arm.com/documentation/ddi0602/2026-03/SIMD-FP-Instructions/BCAX--Bit-clear-and-exclusive-OR- + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + simd_trio_for_each_lane( + fx, + a, + b, + c, + ret, + &|fx, _lane_ty, _res_lane_ty, a_lane, b_lane, c_lane| { + let band_not = fx.bcx.ins().band_not(b_lane, c_lane); + fx.bcx.ins().bxor(a_lane, band_not) + }, + ); + } + + "llvm.aarch64.crypto.rax1" => { + // https://developer.arm.com/documentation/ddi0602/2026-03/SIMD-FP-Instructions/RAX1--Rotate-and-exclusive-OR- + intrinsic_args!(fx, args => (a, b); intrinsic); + + simd_pair_for_each_lane( + fx, + a, + b, + ret, + &|fx, _lane_ty, _res_lane_ty, a_lane, b_lane| { + let rot = fx.bcx.ins().rotl_imm_u(b_lane, 1); + fx.bcx.ins().bxor(a_lane, rot) + }, + ); + } + + "llvm.aarch64.crypto.xar" => { + // https://developer.arm.com/documentation/ddi0602/2026-03/SIMD-FP-Instructions/XAR--Exclusive-OR-and-rotate- + intrinsic_args!(fx, args => (a, b, c); intrinsic); + + let c = c.load_scalar(fx); + + simd_pair_for_each_lane( + fx, + a, + b, + ret, + &|fx, _lane_ty, _res_lane_ty, a_lane, b_lane| { + let xor = fx.bcx.ins().bxor(a_lane, b_lane); + fx.bcx.ins().rotr(xor, c) + }, + ); + } + "llvm.aarch64.neon.pmull64" => { intrinsic_args!(fx, args => (a, b); intrinsic); @@ -815,7 +1162,7 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( let a_lane = fx.bcx.ins().sextend(product_ty, a_lane); let b_lane = fx.bcx.ins().sextend(product_ty, b_lane); let product = fx.bcx.ins().imul(a_lane, b_lane); - let product = fx.bcx.ins().sshr_imm(product, shift); + let product = fx.bcx.ins().sshr_imm_u(product, shift); let max = fx.bcx.ins().iconst(product_ty, max); let result = fx.bcx.ins().smin(product, max); fx.bcx.ins().ireduce(result_ty, result) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs index 61f48fa977435..136e98964bc35 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs @@ -117,8 +117,11 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let src_lane = src.value_lane(fx, lane_idx).load_scalar(fx); let index_lane = index.value_lane(fx, lane_idx).load_scalar(fx); let mask_lane = mask.value_lane(fx, lane_idx).load_scalar(fx); - let mask_lane = - fx.bcx.ins().bitcast(mask_lane_clif_ty.as_int(), MemFlags::new(), mask_lane); + let mask_lane = fx.bcx.ins().bitcast( + mask_lane_clif_ty.as_int(), + MemFlagsData::new(), + mask_lane, + ); let if_enabled = fx.bcx.create_block(); let if_disabled = fx.bcx.create_block(); @@ -127,10 +130,10 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let mask_lane = match mask_lane_clif_ty { types::I32 | types::F32 => { - fx.bcx.ins().band_imm(mask_lane, 0x8000_0000u64 as i64) + fx.bcx.ins().band_imm_u(mask_lane, 0x8000_0000u64 as i64) } types::I64 | types::F64 => { - fx.bcx.ins().band_imm(mask_lane, 0x8000_0000_0000_0000u64 as i64) + fx.bcx.ins().band_imm_u(mask_lane, 0x8000_0000_0000_0000u64 as i64) } _ => unreachable!(), }; @@ -146,7 +149,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( }; let offset = fx.bcx.ins().imul(index_lane, scale); let lane_ptr = fx.bcx.ins().iadd(ptr, offset); - let res = fx.bcx.ins().load(lane_clif_ty, MemFlags::trusted(), lane_ptr, 0); + let res = fx.bcx.ins().load(lane_clif_ty, MemFlagsData::trusted(), lane_ptr, 0); fx.bcx.ins().jump(next, &[res.into()]); fx.bcx.switch_to_block(if_disabled); @@ -163,7 +166,8 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( for lane_idx in std::cmp::min(src_lane_count, index_lane_count)..ret_lane_count { let zero_lane = fx.bcx.ins().iconst(mask_lane_clif_ty.as_int(), 0); - let zero_lane = fx.bcx.ins().bitcast(mask_lane_clif_ty, MemFlags::new(), zero_lane); + let zero_lane = + fx.bcx.ins().bitcast(mask_lane_clif_ty, MemFlagsData::new(), zero_lane); ret.place_lane(fx, lane_idx) .write_cvalue(fx, CValue::by_val(zero_lane, ret_lane_layout)); } @@ -320,24 +324,24 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let zero = fx.bcx.ins().iconst(types::I8, 0); for i in 0..16 { let b_lane = b.value_lane(fx, i).load_scalar(fx); - let is_zero = fx.bcx.ins().band_imm(b_lane, 0x80); - let a_idx = fx.bcx.ins().band_imm(b_lane, 0xf); + let is_zero = fx.bcx.ins().band_imm_u(b_lane, 0x80); + let a_idx = fx.bcx.ins().band_imm_u(b_lane, 0xf); let a_idx = fx.bcx.ins().uextend(fx.pointer_type, a_idx); let a_lane = a.value_lane_dyn(fx, a_idx).load_scalar(fx); let res = fx.bcx.ins().select(is_zero, zero, a_lane); - ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlags::trusted()); + ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlagsData::trusted()); } if intrinsic == "llvm.x86.avx2.pshuf.b" { for i in 16..32 { let b_lane = b.value_lane(fx, i).load_scalar(fx); - let is_zero = fx.bcx.ins().band_imm(b_lane, 0x80); - let b_lane_masked = fx.bcx.ins().band_imm(b_lane, 0xf); - let a_idx = fx.bcx.ins().iadd_imm(b_lane_masked, 16); + let is_zero = fx.bcx.ins().band_imm_u(b_lane, 0x80); + let b_lane_masked = fx.bcx.ins().band_imm_u(b_lane, 0xf); + let a_idx = fx.bcx.ins().iadd_imm_u(b_lane_masked, 16); let a_idx = fx.bcx.ins().uextend(fx.pointer_type, a_idx); let a_lane = a.value_lane_dyn(fx, a_idx).load_scalar(fx); let res = fx.bcx.ins().select(is_zero, zero, a_lane); - ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlags::trusted()); + ret.place_lane(fx, i).to_ptr().store(fx, res, MemFlagsData::trusted()); } } } @@ -352,7 +356,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( ret.place_typed_lane(fx, fx.tcx.types.u32, j).to_ptr().store( fx, value, - MemFlags::trusted(), + MemFlagsData::trusted(), ); } } @@ -384,9 +388,9 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( b_low: Value, control: Value, ) -> Value { - let a_or_b = fx.bcx.ins().band_imm(control, 0b0010); - let high_or_low = fx.bcx.ins().band_imm(control, 0b0001); - let is_zero = fx.bcx.ins().band_imm(control, 0b1000); + let a_or_b = fx.bcx.ins().band_imm_u(control, 0b0010); + let high_or_low = fx.bcx.ins().band_imm_u(control, 0b0001); + let is_zero = fx.bcx.ins().band_imm_u(control, 0b1000); let zero = fx.bcx.ins().iconst(types::I64, 0); let zero = fx.bcx.ins().iconcat(zero, zero); @@ -400,18 +404,18 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let control0 = imm8; let res_low = select4(fx, a_high, a_low, b_high, b_low, control0); - let control1 = fx.bcx.ins().ushr_imm(imm8, 4); + let control1 = fx.bcx.ins().ushr_imm_u(imm8, 4); let res_high = select4(fx, a_high, a_low, b_high, b_low, control1); ret.place_typed_lane(fx, fx.tcx.types.u128, 0).to_ptr().store( fx, res_low, - MemFlags::trusted(), + MemFlagsData::trusted(), ); ret.place_typed_lane(fx, fx.tcx.types.u128, 1).to_ptr().store( fx, res_high, - MemFlags::trusted(), + MemFlagsData::trusted(), ); } "llvm.x86.ssse3.pabs.b.128" | "llvm.x86.ssse3.pabs.w.128" | "llvm.x86.ssse3.pabs.d.128" => { @@ -465,7 +469,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let (cb_out, c) = llvm_add_sub(fx, BinOp::Add, c_in, a, b); - Pointer::new(out.load_scalar(fx)).store(fx, c, MemFlags::trusted()); + Pointer::new(out.load_scalar(fx)).store(fx, c, MemFlagsData::trusted()); ret.write_cvalue(fx, CValue::by_val(cb_out, fx.layout_of(fx.tcx.types.u8))); } "llvm.x86.subborrow.32" | "llvm.x86.subborrow.64" => { @@ -493,8 +497,8 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let a_lane = fx.bcx.ins().uextend(lane_ty.double_width().unwrap(), a_lane); let b_lane = fx.bcx.ins().uextend(lane_ty.double_width().unwrap(), b_lane); let sum = fx.bcx.ins().iadd(a_lane, b_lane); - let num_plus_one = fx.bcx.ins().iadd_imm(sum, 1); - let res = fx.bcx.ins().ushr_imm(num_plus_one, 1); + let num_plus_one = fx.bcx.ins().iadd_imm_u(sum, 1); + let res = fx.bcx.ins().ushr_imm_u(num_plus_one, 1); fx.bcx.ins().ireduce(lane_ty, res) }, ); @@ -502,7 +506,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( "llvm.x86.sse2.psra.w" => { intrinsic_args!(fx, args => (a, count); intrinsic); - let count_lane = count.force_stack(fx).0.load(fx, types::I64, MemFlags::trusted()); + let count_lane = count.force_stack(fx).0.load(fx, types::I64, MemFlagsData::trusted()); let lane_ty = fx.clif_type(a.layout().ty.simd_size_and_type(fx.tcx).1).unwrap(); let max_count = fx.bcx.ins().iconst(types::I64, i64::from(lane_ty.bits() - 1)); let saturated_count = fx.bcx.ins().umin(count_lane, max_count); @@ -575,7 +579,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let (val, has_overflow) = fx.bcx.ins().sadd_overflow(mul0, mul1); - let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, mul1, 0); + let rhs_ge_zero = fx.bcx.ins().icmp_imm_s(IntCC::SignedGreaterThanOrEqual, mul1, 0); let min = fx.bcx.ins().iconst(types::I16, i64::from(i16::MIN as u16)); let max = fx.bcx.ins().iconst(types::I16, i64::from(i16::MAX as u16)); @@ -645,9 +649,9 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let b_lane = fx.bcx.ins().sextend(types::I32, b_lane); let mul: Value = fx.bcx.ins().imul(a_lane, b_lane); - let shifted = fx.bcx.ins().ushr_imm(mul, 14); - let incremented = fx.bcx.ins().iadd_imm(shifted, 1); - let shifted_again = fx.bcx.ins().ushr_imm(incremented, 1); + let shifted = fx.bcx.ins().ushr_imm_u(mul, 14); + let incremented = fx.bcx.ins().iadd_imm_u(shifted, 1); + let shifted_again = fx.bcx.ins().ushr_imm_u(incremented, 1); let res_lane = fx.bcx.ins().ireduce(types::I16, shifted_again); let res_lane = CValue::by_val(res_lane, ret_lane_layout); @@ -1275,7 +1279,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>( let all_zero1 = fx.bcx.ins().bor(zero2, zero3); let all_zero = fx.bcx.ins().bor(all_zero0, all_zero1); - let res = fx.bcx.ins().icmp_imm(IntCC::Equal, all_zero, 0); + let res = fx.bcx.ins().icmp_imm_u(IntCC::Equal, all_zero, 0); let res = CValue::by_val( fx.bcx.ins().uextend(types::I32, res), fx.layout_of(fx.tcx.types.i32), diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index d4bb8bd019331..3a8adc261e976 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -229,10 +229,10 @@ fn simd_reduce_bool<'tcx>( assert!(ret.layout().ty.is_bool()); let res_val = val.value_lane(fx, 0).load_scalar(fx); - let mut res_val = fx.bcx.ins().band_imm(res_val, 1); // mask to boolean + let mut res_val = fx.bcx.ins().band_imm_u(res_val, 1); // mask to boolean for lane_idx in 1..lane_count { let lane = val.value_lane(fx, lane_idx).load_scalar(fx); - let lane = fx.bcx.ins().band_imm(lane, 1); // mask to boolean + let lane = fx.bcx.ins().band_imm_u(lane, 1); // mask to boolean res_val = f(fx, res_val, lane); } let res_val = if fx.bcx.func.dfg.value_type(res_val) != types::I8 { @@ -276,6 +276,14 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( target: Option, source_info: mir::SourceInfo, ) -> Result<(), Instance<'tcx>> { + // When `-Zforce-intrinsic-fallback` is enabled, always use the fallback body if it exists, + if fx.tcx.sess.opts.unstable_opts.force_intrinsic_fallback + && let Some(def) = fx.tcx.intrinsic(instance.def_id()) + && !def.must_be_overridden + { + return Err(Instance::new_raw(instance.def_id(), instance.args)); + } + let intrinsic = fx.tcx.item_name(instance.def_id()); let instance_args = instance.args; @@ -314,75 +322,92 @@ fn codegen_float_intrinsic_call<'tcx>( ret: CPlace<'tcx>, ) -> bool { let (name, arg_count, ty, clif_ty) = match intrinsic { - sym::expf16 => ("expf16", 1, fx.tcx.types.f16, types::F16), + sym::expf16 => return false, // has a fallback via f32 sym::expf32 => ("expf", 1, fx.tcx.types.f32, types::F32), sym::expf64 => ("exp", 1, fx.tcx.types.f64, types::F64), sym::expf128 => ("expf128", 1, fx.tcx.types.f128, types::F128), - sym::exp2f16 => ("exp2f16", 1, fx.tcx.types.f16, types::F16), + + sym::exp2f16 => return false, // has a fallback via f32 sym::exp2f32 => ("exp2f", 1, fx.tcx.types.f32, types::F32), sym::exp2f64 => ("exp2", 1, fx.tcx.types.f64, types::F64), sym::exp2f128 => ("exp2f128", 1, fx.tcx.types.f128, types::F128), + sym::sqrtf16 => ("sqrtf16", 1, fx.tcx.types.f16, types::F16), sym::sqrtf32 => ("sqrtf", 1, fx.tcx.types.f32, types::F32), sym::sqrtf64 => ("sqrt", 1, fx.tcx.types.f64, types::F64), sym::sqrtf128 => ("sqrtf128", 1, fx.tcx.types.f128, types::F128), + sym::powif16 => ("__powisf2", 2, fx.tcx.types.f16, types::F16), // compiler-builtins sym::powif32 => ("__powisf2", 2, fx.tcx.types.f32, types::F32), // compiler-builtins sym::powif64 => ("__powidf2", 2, fx.tcx.types.f64, types::F64), // compiler-builtins sym::powif128 => ("__powitf2", 2, fx.tcx.types.f128, types::F128), // compiler-builtins - sym::powf16 => ("powf16", 2, fx.tcx.types.f16, types::F16), + + sym::powf16 => return false, // has a fallback via f32 sym::powf32 => ("powf", 2, fx.tcx.types.f32, types::F32), sym::powf64 => ("pow", 2, fx.tcx.types.f64, types::F64), sym::powf128 => ("powf128", 2, fx.tcx.types.f128, types::F128), - sym::logf16 => ("logf16", 1, fx.tcx.types.f16, types::F16), + + sym::logf16 => return false, // has a fallback via f32 sym::logf32 => ("logf", 1, fx.tcx.types.f32, types::F32), sym::logf64 => ("log", 1, fx.tcx.types.f64, types::F64), sym::logf128 => ("logf128", 1, fx.tcx.types.f128, types::F128), - sym::log2f16 => ("log2f16", 1, fx.tcx.types.f16, types::F16), + + sym::log2f16 => return false, // has a fallback via f32 sym::log2f32 => ("log2f", 1, fx.tcx.types.f32, types::F32), sym::log2f64 => ("log2", 1, fx.tcx.types.f64, types::F64), sym::log2f128 => ("log2f128", 1, fx.tcx.types.f128, types::F128), - sym::log10f16 => ("log10f16", 1, fx.tcx.types.f16, types::F16), + + sym::log10f16 => return false, // has a fallback via f32 sym::log10f32 => ("log10f", 1, fx.tcx.types.f32, types::F32), sym::log10f64 => ("log10", 1, fx.tcx.types.f64, types::F64), sym::log10f128 => ("log10f128", 1, fx.tcx.types.f128, types::F128), + sym::fmaf16 => ("fmaf16", 3, fx.tcx.types.f16, types::F16), sym::fmaf32 => ("fmaf", 3, fx.tcx.types.f32, types::F32), sym::fmaf64 => ("fma", 3, fx.tcx.types.f64, types::F64), sym::fmaf128 => ("fmaf128", 3, fx.tcx.types.f128, types::F128), + // FIXME: calling `fma` from libc without FMA target feature uses expensive sofware emulation sym::fmuladdf16 => ("fmaf16", 3, fx.tcx.types.f16, types::F16), // FIXME: use cranelift intrinsic analogous to llvm.fmuladd.f16 sym::fmuladdf32 => ("fmaf", 3, fx.tcx.types.f32, types::F32), // FIXME: use cranelift intrinsic analogous to llvm.fmuladd.f32 sym::fmuladdf64 => ("fma", 3, fx.tcx.types.f64, types::F64), // FIXME: use cranelift intrinsic analogous to llvm.fmuladd.f64 sym::fmuladdf128 => ("fmaf128", 3, fx.tcx.types.f128, types::F128), // FIXME: use cranelift intrinsic analogous to llvm.fmuladd.f128 + sym::copysignf16 => ("copysignf16", 2, fx.tcx.types.f16, types::F16), sym::copysignf32 => ("copysignf", 2, fx.tcx.types.f32, types::F32), sym::copysignf64 => ("copysign", 2, fx.tcx.types.f64, types::F64), sym::copysignf128 => ("copysignf128", 2, fx.tcx.types.f128, types::F128), + sym::floorf16 => ("floorf16", 1, fx.tcx.types.f16, types::F16), sym::floorf32 => ("floorf", 1, fx.tcx.types.f32, types::F32), sym::floorf64 => ("floor", 1, fx.tcx.types.f64, types::F64), sym::floorf128 => ("floorf128", 1, fx.tcx.types.f128, types::F128), + sym::ceilf16 => ("ceilf16", 1, fx.tcx.types.f16, types::F16), sym::ceilf32 => ("ceilf", 1, fx.tcx.types.f32, types::F32), sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64, types::F64), sym::ceilf128 => ("ceilf128", 1, fx.tcx.types.f128, types::F128), + sym::truncf16 => ("truncf16", 1, fx.tcx.types.f16, types::F16), sym::truncf32 => ("truncf", 1, fx.tcx.types.f32, types::F32), sym::truncf64 => ("trunc", 1, fx.tcx.types.f64, types::F64), sym::truncf128 => ("truncf128", 1, fx.tcx.types.f128, types::F128), + sym::round_ties_even_f16 => ("rintf16", 1, fx.tcx.types.f16, types::F16), sym::round_ties_even_f32 => ("rintf", 1, fx.tcx.types.f32, types::F32), sym::round_ties_even_f64 => ("rint", 1, fx.tcx.types.f64, types::F64), sym::round_ties_even_f128 => ("rintf128", 1, fx.tcx.types.f128, types::F128), + sym::roundf16 => ("roundf16", 1, fx.tcx.types.f16, types::F16), sym::roundf32 => ("roundf", 1, fx.tcx.types.f32, types::F32), sym::roundf64 => ("round", 1, fx.tcx.types.f64, types::F64), sym::roundf128 => ("roundf128", 1, fx.tcx.types.f128, types::F128), + sym::sinf16 => ("sinf16", 1, fx.tcx.types.f16, types::F16), sym::sinf32 => ("sinf", 1, fx.tcx.types.f32, types::F32), sym::sinf64 => ("sin", 1, fx.tcx.types.f64, types::F64), sym::sinf128 => ("sinf128", 1, fx.tcx.types.f128, types::F128), + sym::cosf16 => ("cosf16", 1, fx.tcx.types.f16, types::F16), sym::cosf32 => ("cosf", 1, fx.tcx.types.f32, types::F32), sym::cosf64 => ("cos", 1, fx.tcx.types.f64, types::F64), @@ -481,18 +506,6 @@ fn codegen_float_intrinsic_call<'tcx>( }; CValue::by_val(ret_val, fx.layout_of(ty)) } - sym::powf16 => { - // FIXME(f16_f128): Rust `compiler-builtins` doesn't export `powf16` yet. - let x = codegen_f16_f128::f16_to_f32(fx, args[0]); - let y = codegen_f16_f128::f16_to_f32(fx, args[1]); - let ret_val = fx.lib_call( - "powf", - vec![AbiParam::new(types::F32), AbiParam::new(types::F32)], - vec![AbiParam::new(types::F32)], - &[x, y], - )[0]; - CValue::by_val(codegen_f16_f128::f32_to_f16(fx, ret_val), fx.layout_of(ty)) - } _ => { let input_tys: Vec<_> = args.iter().map(|_| AbiParam::new(clif_ty)).collect(); let ret_val = fx.lib_call(name, input_tys, vec![AbiParam::new(clif_ty)], args)[0]; @@ -538,8 +551,11 @@ fn codegen_regular_intrinsic_call<'tcx>( let elem_ty = generic_args.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); assert_eq!(args.len(), 3); - let byte_amount = - if elem_size != 1 { fx.bcx.ins().imul_imm(count, elem_size as i64) } else { count }; + let byte_amount = if elem_size != 1 { + fx.bcx.ins().imul_imm_u(count, elem_size as i64) + } else { + count + }; // FIXME emit_small_memmove fx.bcx.call_memmove(fx.target_config, dst, src, byte_amount); @@ -554,8 +570,11 @@ fn codegen_regular_intrinsic_call<'tcx>( let elem_ty = generic_args.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); assert_eq!(args.len(), 3); - let byte_amount = - if elem_size != 1 { fx.bcx.ins().imul_imm(count, elem_size as i64) } else { count }; + let byte_amount = if elem_size != 1 { + fx.bcx.ins().imul_imm_u(count, elem_size as i64) + } else { + count + }; // FIXME make the copy actually volatile when using emit_small_mem{cpy,move} if intrinsic == sym::volatile_copy_nonoverlapping_memory { @@ -572,9 +591,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let layout = fx.layout_of(generic_args.type_at(0)); // Note: Can't use is_unsized here as truly unsized types need to take the fixed size // branch - let meta = if let BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } = - ptr.layout().backend_repr - { + let meta = if let BackendRepr::ScalarPair { .. } = ptr.layout().backend_repr { Some(ptr.load_scalar_pair(fx).1) } else { None @@ -588,9 +605,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let layout = fx.layout_of(generic_args.type_at(0)); // Note: Can't use is_unsized here as truly unsized types need to take the fixed size // branch - let meta = if let BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } = - ptr.layout().backend_repr - { + let meta = if let BackendRepr::ScalarPair { .. } = ptr.layout().backend_repr { Some(ptr.load_scalar_pair(fx).1) } else { None @@ -663,7 +678,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let pointee_ty = base.layout().ty.builtin_deref(true).unwrap(); let pointee_size = fx.layout_of(pointee_ty).size.bytes(); let ptr_diff = if pointee_size != 1 { - fx.bcx.ins().imul_imm(offset, pointee_size as i64) + fx.bcx.ins().imul_imm_u(offset, pointee_size as i64) } else { offset }; @@ -689,7 +704,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap(); let pointee_size = fx.layout_of(pointee_ty).size.bytes(); let count = if pointee_size != 1 { - fx.bcx.ins().imul_imm(count, pointee_size as i64) + fx.bcx.ins().imul_imm_u(count, pointee_size as i64) } else { count }; @@ -823,10 +838,16 @@ fn codegen_regular_intrinsic_call<'tcx>( let usize_layout = fx.layout_of(fx.tcx.types.usize); // Because diff_bytes ULE isize::MAX, this would be fine as signed, // but unsigned is slightly easier to codegen, so might as well. - CValue::by_val(fx.bcx.ins().udiv_imm(diff_bytes, pointee_size as i64), usize_layout) + CValue::by_val( + fx.bcx.ins().udiv_imm_u(diff_bytes, pointee_size as i64), + usize_layout, + ) } else { let isize_layout = fx.layout_of(fx.tcx.types.isize); - CValue::by_val(fx.bcx.ins().sdiv_imm(diff_bytes, pointee_size as i64), isize_layout) + CValue::by_val( + fx.bcx.ins().sdiv_imm_u(diff_bytes, pointee_size as i64), + isize_layout, + ) }; ret.write_cvalue(fx, val); } @@ -879,7 +900,7 @@ fn codegen_regular_intrinsic_call<'tcx>( } let clif_ty = fx.clif_type(ty).unwrap(); - let val = fx.bcx.ins().atomic_load(clif_ty, MemFlags::trusted(), ptr); + let val = fx.bcx.ins().atomic_load(clif_ty, MemFlagsData::trusted(), ptr); let val = CValue::by_val(val, fx.layout_of(ty)); ret.write_cvalue(fx, val); @@ -915,7 +936,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let val = val.load_scalar(fx); - fx.bcx.ins().atomic_store(MemFlags::trusted(), val, ptr); + fx.bcx.ins().atomic_store(MemFlagsData::trusted(), val, ptr); } sym::atomic_xchg => { intrinsic_args!(fx, args => (ptr, new); intrinsic); @@ -933,7 +954,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let new = new.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Xchg, ptr, new); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Xchg, ptr, new); let old = CValue::by_val(old, layout); ret.write_cvalue(fx, old); @@ -954,7 +976,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let test_old = test_old.load_scalar(fx); let new = new.load_scalar(fx); - let old = fx.bcx.ins().atomic_cas(MemFlags::trusted(), ptr, test_old, new); + let old = fx.bcx.ins().atomic_cas(MemFlagsData::trusted(), ptr, test_old, new); let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); let ret_val = CValue::by_val_pair(old, is_eq, ret.layout()); @@ -978,7 +1000,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let amount = amount.load_scalar(fx); let old = - fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Add, ptr, amount); + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Add, ptr, amount); let old = CValue::by_val(old, ret.layout()); ret.write_cvalue(fx, old); @@ -1000,7 +1022,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let amount = amount.load_scalar(fx); let old = - fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Sub, ptr, amount); + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Sub, ptr, amount); let old = CValue::by_val(old, ret.layout()); ret.write_cvalue(fx, old); @@ -1021,7 +1043,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::And, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::And, ptr, src); let old = CValue::by_val(old, ret.layout()); ret.write_cvalue(fx, old); @@ -1042,7 +1065,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Or, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Or, ptr, src); let old = CValue::by_val(old, ret.layout()); ret.write_cvalue(fx, old); @@ -1063,7 +1087,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Xor, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Xor, ptr, src); let old = CValue::by_val(old, ret.layout()); ret.write_cvalue(fx, old); @@ -1084,7 +1109,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Nand, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Nand, ptr, src); let old = CValue::by_val(old, ret.layout()); ret.write_cvalue(fx, old); @@ -1105,7 +1131,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Smax, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Smax, ptr, src); let old = CValue::by_val(old, layout); ret.write_cvalue(fx, old); @@ -1126,7 +1153,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Umax, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Umax, ptr, src); let old = CValue::by_val(old, layout); ret.write_cvalue(fx, old); @@ -1147,7 +1175,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Smin, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Smin, ptr, src); let old = CValue::by_val(old, layout); ret.write_cvalue(fx, old); @@ -1168,7 +1197,8 @@ fn codegen_regular_intrinsic_call<'tcx>( let src = src.load_scalar(fx); - let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Umin, ptr, src); + let old = + fx.bcx.ins().atomic_rmw(ty, MemFlagsData::trusted(), AtomicRmwOp::Umin, ptr, src); let old = CValue::by_val(old, layout); ret.write_cvalue(fx, old); @@ -1475,8 +1505,7 @@ fn codegen_regular_intrinsic_call<'tcx>( fx.bcx.ins().iconst(types::I8, 1) } else if let Some(clty) = size.bits().try_into().ok().and_then(Type::int) { // Can't use `trusted` for these loads; they could be unaligned. - let mut flags = MemFlags::new(); - flags.set_notrap(); + let flags = MemFlagsData::new().with_notrap(); let lhs_val = fx.bcx.ins().load(clty, flags, lhs_ref, 0); let rhs_val = fx.bcx.ins().load(clty, flags, rhs_ref, 0); fx.bcx.ins().icmp(IntCC::Equal, lhs_val, rhs_val) @@ -1489,7 +1518,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let returns = vec![AbiParam::new(types::I32)]; let args = &[lhs_ref, rhs_ref, bytes_val]; let cmp = fx.lib_call("memcmp", params, returns, args)[0]; - fx.bcx.ins().icmp_imm(IntCC::Equal, cmp, 0) + fx.bcx.ins().icmp_imm_u(IntCC::Equal, cmp, 0) }; ret.write_cvalue(fx, CValue::by_val(is_eq_value, ret.layout())); } diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index 5d7e457b8e1ba..b754a923dbfe8 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -815,7 +815,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let a_lane = a.value_lane(fx, lane).load_scalar(fx); let b_lane = b.value_lane(fx, lane).load_scalar(fx); - let m_lane = fx.bcx.ins().icmp_imm(IntCC::Equal, m_lane, 0); + let m_lane = fx.bcx.ins().icmp_imm_u(IntCC::Equal, m_lane, 0); let res_lane = CValue::by_val(fx.bcx.ins().select(m_lane, b_lane, a_lane), lane_layout); @@ -850,7 +850,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( m.force_stack(fx).0.load( fx, Type::int(expected_int_bits as u16).unwrap(), - MemFlags::trusted(), + MemFlagsData::trusted(), ) } _ => { @@ -874,12 +874,12 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( Endian::Big => lane_count - 1 - lane, Endian::Little => lane, }; - let m_lane = fx.bcx.ins().ushr_imm(m, mask_lane.cast_signed()); - let m_lane = fx.bcx.ins().band_imm(m_lane, 1); + let m_lane = fx.bcx.ins().ushr_imm_u(m, mask_lane.cast_signed()); + let m_lane = fx.bcx.ins().band_imm_u(m_lane, 1); let a_lane = a.value_lane(fx, lane).load_scalar(fx); let b_lane = b.value_lane(fx, lane).load_scalar(fx); - let m_lane = fx.bcx.ins().icmp_imm(IntCC::Equal, m_lane, 0); + let m_lane = fx.bcx.ins().icmp_imm_u(IntCC::Equal, m_lane, 0); let res_lane = CValue::by_val(fx.bcx.ins().select(m_lane, b_lane, a_lane), lane_layout); @@ -933,11 +933,12 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let a_lane = a.value_lane(fx, lane).load_scalar(fx); // extract sign bit of an int - let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, i64::from(lane_clif_ty.bits() - 1)); + let a_lane_sign = + fx.bcx.ins().ushr_imm_u(a_lane, i64::from(lane_clif_ty.bits() - 1)); // shift sign bit into result let a_lane_sign = clif_intcast(fx, a_lane_sign, res_type, false); - res = fx.bcx.ins().ishl_imm(res, 1); + res = fx.bcx.ins().ishl_imm_u(res, 1); res = fx.bcx.ins().bor(res, a_lane_sign); } @@ -1002,7 +1003,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let offset_lane = offset.value_lane(fx, lane_idx).load_scalar(fx); let ptr_diff = if pointee_size != 1 { - fx.bcx.ins().imul_imm(offset_lane, pointee_size as i64) + fx.bcx.ins().imul_imm_u(offset_lane, pointee_size as i64) } else { offset_lane }; @@ -1026,8 +1027,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( 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(), + SimdAlign::Unaligned => MemFlagsData::new().with_notrap(), + _ => MemFlagsData::trusted(), }; for lane_idx in 0..val_lane_count { @@ -1081,7 +1082,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::trusted(), ptr_lane, 0); + let res = fx.bcx.ins().load(lane_clif_ty, MemFlagsData::trusted(), ptr_lane, 0); fx.bcx.ins().jump(next, &[res.into()]); fx.bcx.switch_to_block(if_disabled); @@ -1114,8 +1115,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( 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(), + SimdAlign::Unaligned => MemFlagsData::new().with_notrap(), + _ => MemFlagsData::trusted(), }; for lane_idx in 0..ret_lane_count { @@ -1170,7 +1171,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.bcx.seal_block(if_enabled); fx.bcx.switch_to_block(if_enabled); - fx.bcx.ins().store(MemFlags::trusted(), val_lane, ptr_lane, 0); + fx.bcx.ins().store(MemFlagsData::trusted(), val_lane, ptr_lane, 0); fx.bcx.ins().jump(next, &[]); fx.bcx.seal_block(next); diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index f5c852a2bf970..ba586f83ba30d 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -83,7 +83,7 @@ mod prelude { pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; pub(crate) use cranelift_codegen::ir::function::Function; pub(crate) use cranelift_codegen::ir::{ - AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, + AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlagsData, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value, types, }; pub(crate) use cranelift_module::{self, DataDescription, FuncId, Linkage, Module}; diff --git a/compiler/rustc_codegen_cranelift/src/main_shim.rs b/compiler/rustc_codegen_cranelift/src/main_shim.rs index dd776f9cfcaee..109933f4d8556 100644 --- a/compiler/rustc_codegen_cranelift/src/main_shim.rs +++ b/compiler/rustc_codegen_cranelift/src/main_shim.rs @@ -156,7 +156,7 @@ pub(crate) fn maybe_create_entry_wrapper( bcx.ins().return_(&[result]); bcx.seal_all_blocks(); - bcx.finalize(); + bcx.finalize(m.target_config()); } if let Err(err) = m.define_function(cmain_func_id, &mut ctx) { diff --git a/compiler/rustc_codegen_cranelift/src/num.rs b/compiler/rustc_codegen_cranelift/src/num.rs index e533c0b631b01..f1c44df1f6886 100644 --- a/compiler/rustc_codegen_cranelift/src/num.rs +++ b/compiler/rustc_codegen_cranelift/src/num.rs @@ -218,7 +218,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( let has_overflow = if !signed { fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let rhs_is_negative = fx.bcx.ins().icmp_imm_s(IntCC::SignedLessThan, rhs, 0); let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); fx.bcx.ins().bxor(rhs_is_negative, slt) }; @@ -232,7 +232,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( let has_overflow = if !signed { fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let rhs_is_negative = fx.bcx.ins().icmp_imm_s(IntCC::SignedLessThan, rhs, 0); let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); fx.bcx.ins().bxor(rhs_is_negative, sgt) }; @@ -249,7 +249,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( let lhs = fx.bcx.ins().uextend(ty.double_width().unwrap(), lhs); let rhs = fx.bcx.ins().uextend(ty.double_width().unwrap(), rhs); let val = fx.bcx.ins().imul(lhs, rhs); - let has_overflow = fx.bcx.ins().icmp_imm( + let has_overflow = fx.bcx.ins().icmp_imm_u( IntCC::UnsignedGreaterThan, val, (1 << ty.bits()) - 1, @@ -261,9 +261,12 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( let lhs = fx.bcx.ins().sextend(ty.double_width().unwrap(), lhs); let rhs = fx.bcx.ins().sextend(ty.double_width().unwrap(), rhs); let val = fx.bcx.ins().imul(lhs, rhs); - let has_underflow = - fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, val, -(1 << (ty.bits() - 1))); - let has_overflow = fx.bcx.ins().icmp_imm( + let has_underflow = fx.bcx.ins().icmp_imm_s( + IntCC::SignedLessThan, + val, + -(1 << (ty.bits() - 1)), + ); + let has_overflow = fx.bcx.ins().icmp_imm_s( IntCC::SignedGreaterThan, val, (1 << (ty.bits() - 1)) - 1, @@ -275,7 +278,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( let val = fx.bcx.ins().imul(lhs, rhs); let has_overflow = if !signed { let val_hi = fx.bcx.ins().umulhi(lhs, rhs); - fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0) + fx.bcx.ins().icmp_imm_u(IntCC::NotEqual, val_hi, 0) } else { // Based on LLVM's instruction sequence for compiling // a.checked_mul(b).is_some() to riscv64gc: @@ -285,9 +288,9 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( // xor a0, a0, a2 // snez a0, a0 let val_hi = fx.bcx.ins().smulhi(lhs, rhs); - let val_sign = fx.bcx.ins().sshr_imm(val, i64::from(ty.bits() - 1)); + let val_sign = fx.bcx.ins().sshr_imm_u(val, i64::from(ty.bits() - 1)); let xor = fx.bcx.ins().bxor(val_hi, val_sign); - fx.bcx.ins().icmp_imm(IntCC::NotEqual, xor, 0) + fx.bcx.ins().icmp_imm_u(IntCC::NotEqual, xor, 0) }; (val, has_overflow) } @@ -324,13 +327,13 @@ pub(crate) fn codegen_saturating_int_binop<'tcx>( (BinOp::Sub, false) => fx.bcx.ins().select(has_overflow, min, val), (BinOp::Add, true) => { let rhs = rhs.load_scalar(fx); - let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, rhs, 0); + let rhs_ge_zero = fx.bcx.ins().icmp_imm_s(IntCC::SignedGreaterThanOrEqual, rhs, 0); let sat_val = fx.bcx.ins().select(rhs_ge_zero, max, min); fx.bcx.ins().select(has_overflow, sat_val, val) } (BinOp::Sub, true) => { let rhs = rhs.load_scalar(fx); - let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, rhs, 0); + let rhs_ge_zero = fx.bcx.ins().icmp_imm_s(IntCC::SignedGreaterThanOrEqual, rhs, 0); let sat_val = fx.bcx.ins().select(rhs_ge_zero, min, max); fx.bcx.ins().select(has_overflow, sat_val, val) } @@ -449,7 +452,7 @@ fn codegen_ptr_binop<'tcx>( let pointee_ty = in_lhs.layout().ty.builtin_deref(true).unwrap(); let (base, offset) = (in_lhs, in_rhs.load_scalar(fx)); let pointee_size = fx.layout_of(pointee_ty).size.bytes(); - let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); + let ptr_diff = fx.bcx.ins().imul_imm_u(offset, pointee_size as i64); let base_val = base.load_scalar(fx); let res = fx.bcx.ins().iadd(base_val, ptr_diff); CValue::by_val(res, base.layout()) diff --git a/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs b/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs index f38c1f96e6ed5..fe301cb85cf75 100644 --- a/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs +++ b/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs @@ -7,17 +7,19 @@ use cranelift_frontend::FunctionBuilder; /// If the given value was produced by the lowering of `Rvalue::Not` return the input and true, /// otherwise return the given value and false. pub(crate) fn maybe_unwrap_bool_not(bcx: &mut FunctionBuilder<'_>, arg: Value) -> (Value, bool) { - if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { - match bcx.func.dfg.insts[arg_inst] { - // This is the lowering of `Rvalue::Not` - InstructionData::IntCompareImm { - opcode: Opcode::IcmpImm, - cond: IntCC::Equal, - arg, - imm, - } if imm.bits() == 0 => (arg, true), - _ => (arg, false), - } + if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) + && let InstructionData::IntCompare { + opcode: Opcode::Icmp, + cond: IntCC::Equal, + args: [icmp_arg, imm], + } = bcx.func.dfg.insts[arg_inst] + && let ValueDef::Result(imm_inst, 0) = bcx.func.dfg.value_def(imm) + && let InstructionData::UnaryImm { opcode: Opcode::Iconst, imm } = + bcx.func.dfg.insts[imm_inst] + && imm.bits() == 0 + { + // This is the lowering of `Rvalue::Not` + (icmp_arg, true) } else { (arg, false) } diff --git a/compiler/rustc_codegen_cranelift/src/pointer.rs b/compiler/rustc_codegen_cranelift/src/pointer.rs index 2750caa216e6b..b9da3ab6c8d40 100644 --- a/compiler/rustc_codegen_cranelift/src/pointer.rs +++ b/compiler/rustc_codegen_cranelift/src/pointer.rs @@ -41,7 +41,7 @@ impl Pointer { match self.base { PointerBase::Addr(base_addr) => { let offset: i64 = self.offset.into(); - if offset == 0 { base_addr } else { fx.bcx.ins().iadd_imm(base_addr, offset) } + if offset == 0 { base_addr } else { fx.bcx.ins().iadd_imm_s(base_addr, offset) } } PointerBase::Stack(stack_slot) => { fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, self.offset) @@ -71,7 +71,7 @@ impl Pointer { fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()) } }; - let addr = fx.bcx.ins().iadd_imm(base_addr, new_offset); + let addr = fx.bcx.ins().iadd_imm_s(base_addr, new_offset); Pointer { base: PointerBase::Addr(addr), offset: Offset32::new(0) } } else { panic!( @@ -106,21 +106,28 @@ impl Pointer { } } - pub(crate) fn load(self, fx: &mut FunctionCx<'_, '_, '_>, ty: Type, flags: MemFlags) -> Value { + pub(crate) fn load( + self, + fx: &mut FunctionCx<'_, '_, '_>, + ty: Type, + flags: MemFlagsData, + ) -> Value { match self.base { PointerBase::Addr(base_addr) => fx.bcx.ins().load(ty, flags, base_addr, self.offset), - PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_load(ty, stack_slot, self.offset), + PointerBase::Stack(stack_slot) => { + fx.bcx.ins().stack_load(fx.pointer_type, ty, stack_slot, self.offset) + } PointerBase::Dangling(_align) => unreachable!(), } } - pub(crate) fn store(self, fx: &mut FunctionCx<'_, '_, '_>, value: Value, flags: MemFlags) { + pub(crate) fn store(self, fx: &mut FunctionCx<'_, '_, '_>, value: Value, flags: MemFlagsData) { match self.base { PointerBase::Addr(base_addr) => { fx.bcx.ins().store(flags, value, base_addr, self.offset); } PointerBase::Stack(stack_slot) => { - fx.bcx.ins().stack_store(value, stack_slot, self.offset); + fx.bcx.ins().stack_store(fx.pointer_type, value, stack_slot, self.offset); } PointerBase::Dangling(_align) => unreachable!(), } diff --git a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs index 918fe3d2a3895..fee3562c7bede 100644 --- a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs +++ b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs @@ -61,6 +61,7 @@ use std::io::Write; use cranelift_codegen::entity::SecondaryMap; use cranelift_codegen::ir::entities::AnyEntity; +use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::write::{FuncWriter, PlainWriter}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_session::Session; @@ -242,6 +243,22 @@ impl FunctionCx<'_, '_, '_> { } } +pub(crate) fn format_clif_ir_header(isa: &dyn TargetIsa, symbol_name: &str) -> String { + use std::fmt::Write; + + let mut header = String::new(); + for flag in isa.flags().iter() { + writeln!(header, "set {}", flag).unwrap(); + } + write!(header, "target {}", isa.triple().architecture.to_string()).unwrap(); + for isa_flag in isa.isa_flags().iter() { + write!(header, " {}", isa_flag).unwrap(); + } + writeln!(header, "\n").unwrap(); + writeln!(header, "; symbol {}", symbol_name).unwrap(); + header +} + pub(crate) fn should_write_ir(sess: &Session) -> bool { sess.opts.output_types.contains_key(&OutputType::LlvmAssembly) } @@ -280,18 +297,9 @@ pub(crate) fn write_clif_file( ) { // FIXME work around filename too long errors write_ir_file(output_filenames, &format!("{}.{}.clif", symbol_name, postfix), |file| { - let mut clif = String::new(); + let mut clif = format_clif_ir_header(isa, symbol_name); cranelift_codegen::write::decorate_function(&mut clif_comments, &mut clif, func).unwrap(); - for flag in isa.flags().iter() { - writeln!(file, "set {}", flag)?; - } - write!(file, "target {}", isa.triple().architecture)?; - for isa_flag in isa.isa_flags().iter() { - write!(file, " {}", isa_flag)?; - } - writeln!(file, "\n")?; - writeln!(file)?; file.write_all(clif.as_bytes())?; Ok(()) }); diff --git a/compiler/rustc_codegen_cranelift/src/unsize.rs b/compiler/rustc_codegen_cranelift/src/unsize.rs index 3dbb689cccd26..48fb0f6c7d4a8 100644 --- a/compiler/rustc_codegen_cranelift/src/unsize.rs +++ b/compiler/rustc_codegen_cranelift/src/unsize.rs @@ -190,7 +190,7 @@ pub(crate) fn size_and_align_of<'tcx>( // The info in this case is the length of the str, so the size is that // times the unit size. ( - fx.bcx.ins().imul_imm(info.unwrap(), unit.size.bytes() as i64), + fx.bcx.ins().imul_imm_u(info.unwrap(), unit.size.bytes() as i64), fx.bcx.ins().iconst(fx.pointer_type, unit.align.bytes() as i64), ) } @@ -282,7 +282,7 @@ pub(crate) fn size_and_align_of<'tcx>( // emulated via the semi-standard fast bit trick: // // `(size + (align-1)) & -align` - let addend = fx.bcx.ins().iadd_imm(full_align, -1); + let addend = fx.bcx.ins().iadd_imm_s(full_align, -1); let add = fx.bcx.ins().iadd(full_size, addend); let neg = fx.bcx.ins().ineg(full_align); let full_size = fx.bcx.ins().band(add, neg); diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index d7248acfafef1..c89ba0e3de9fe 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -45,7 +45,7 @@ fn codegen_field<'tcx>( // Bump the unaligned offset up to the appropriate alignment let one = fx.bcx.ins().iconst(fx.pointer_type, 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); - let and_lhs = fx.bcx.ins().iadd_imm(align_sub_1, unaligned_offset as i64); + let and_lhs = fx.bcx.ins().iadd_imm_u(align_sub_1, unaligned_offset as i64); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); let and_rhs = fx.bcx.ins().isub(zero, unsized_align); let offset = fx.bcx.ins().band(and_lhs, and_rhs); @@ -55,10 +55,6 @@ fn codegen_field<'tcx>( } } -fn scalar_pair_convert_b_offset(b_offset: Size) -> Offset32 { - Offset32::new(b_offset.bytes().try_into().unwrap()) -} - /// A read-only value #[derive(Debug, Copy, Clone)] pub(crate) struct CValue<'tcx>(CValueInner, TyAndLayout<'tcx>); @@ -142,8 +138,7 @@ impl<'tcx> CValue<'tcx> { } _ => unreachable!("{:?}", layout.ty), }; - let mut flags = MemFlags::new(); - flags.set_notrap(); + let flags = MemFlagsData::new().with_notrap(); ptr.load(fx, clif_ty, flags) } CValueInner::ByVal(value) => value, @@ -162,11 +157,10 @@ impl<'tcx> CValue<'tcx> { BackendRepr::ScalarPair { a, b, b_offset } => (a, b, b_offset), _ => unreachable!("load_scalar_pair({:?})", self), }; - let b_offset = scalar_pair_convert_b_offset(b_offset); + let b_offset = Offset32::new(b_offset.bytes().try_into().unwrap()); let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar); let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar); - let mut flags = MemFlags::new(); - flags.set_notrap(); + let flags = MemFlagsData::new().with_notrap(); let val1 = ptr.load(fx, clif_ty1, flags); let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, flags); (val1, val2) @@ -188,7 +182,7 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByVal(_) => unreachable!(), CValueInner::ByValPair(val1, val2) => match layout.backend_repr { - BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } => { + BackendRepr::ScalarPair { .. } => { let val = match field.as_u32() { 0 => val1, 1 => val2, @@ -274,7 +268,8 @@ impl<'tcx> CValue<'tcx> { CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => unreachable!(), CValueInner::ByRef(ptr, None) => { let lane_idx = clif_intcast(fx, lane_idx, fx.pointer_type, false); - let field_offset = fx.bcx.ins().imul_imm(lane_idx, lane_layout.size.bytes() as i64); + let field_offset = + fx.bcx.ins().imul_imm_u(lane_idx, lane_layout.size.bytes() as i64); let field_ptr = ptr.offset_value(fx, field_offset); CValue::by_ref(field_ptr, lane_layout) } @@ -579,7 +574,7 @@ impl<'tcx> CPlace<'tcx> { } CPlaceInner::VarPair(_local, var1, var2) => { let (data1, data2) = match from.1.backend_repr { - BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } => { + BackendRepr::ScalarPair { .. } => { CValue(from.0, dst_layout).load_scalar_pair(fx) } _ => { @@ -598,8 +593,7 @@ impl<'tcx> CPlace<'tcx> { return; } - let mut flags = MemFlags::new(); - flags.set_notrap(); + let flags = MemFlagsData::new().with_notrap(); match from.0 { CValueInner::ByVal(val) => { @@ -607,7 +601,7 @@ impl<'tcx> CPlace<'tcx> { } CValueInner::ByValPair(val1, val2) => match from.layout().backend_repr { BackendRepr::ScalarPair { a: _, b: _, b_offset } => { - let b_offset = scalar_pair_convert_b_offset(b_offset); + let b_offset = Offset32::new(b_offset.bytes().try_into().unwrap()); to_ptr.store(fx, val1, flags); to_ptr.offset(fx, b_offset).store(fx, val2, flags); } @@ -626,7 +620,7 @@ impl<'tcx> CPlace<'tcx> { return; } BackendRepr::ScalarPair { a: _, b: _, b_offset } => { - let b_offset = scalar_pair_convert_b_offset(b_offset); + let b_offset = Offset32::new(b_offset.bytes().try_into().unwrap()); let (val1, val2) = from.load_scalar_pair(fx); to_ptr.store(fx, val1, flags); to_ptr.offset(fx, b_offset).store(fx, val2, flags); @@ -782,7 +776,7 @@ impl<'tcx> CPlace<'tcx> { let field_offset = fx .bcx .ins() - .imul_imm(lane_idx, i64::try_from(lane_layout.size.bytes()).unwrap()); + .imul_imm_u(lane_idx, i64::try_from(lane_layout.size.bytes()).unwrap()); let field_ptr = ptr.offset_value(fx, field_offset); CPlace::for_ptr(field_ptr, lane_layout).write_cvalue(fx, value); } @@ -809,7 +803,7 @@ impl<'tcx> CPlace<'tcx> { _ => bug!("place_index({:?})", self.layout().ty), }; - let offset = fx.bcx.ins().imul_imm(index, elem_layout.size.bytes() as i64); + let offset = fx.bcx.ins().imul_imm_u(index, elem_layout.size.bytes() as i64); CPlace::for_ptr(ptr.offset_value(fx, offset), elem_layout) } diff --git a/compiler/rustc_codegen_cranelift/src/vtable.rs b/compiler/rustc_codegen_cranelift/src/vtable.rs index 3310e4e3a2228..2bb1944cc246b 100644 --- a/compiler/rustc_codegen_cranelift/src/vtable.rs +++ b/compiler/rustc_codegen_cranelift/src/vtable.rs @@ -5,8 +5,8 @@ use crate::constant::data_id_for_vtable; use crate::prelude::*; -pub(crate) fn vtable_memflags() -> MemFlags { - let mut flags = MemFlags::trusted(); // A vtable access is always aligned and will never trap. +pub(crate) fn vtable_memflags() -> MemFlagsData { + let mut flags = MemFlagsData::trusted(); // A vtable access is always aligned and will never trap. flags.set_readonly(); // A vtable is always read-only. flags } @@ -56,14 +56,13 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( } } - let (ptr, vtable) = - if let BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } = arg.layout().backend_repr { - let (ptr, vtable) = arg.load_scalar_pair(fx); - (Pointer::new(ptr), vtable) - } else { - let (ptr, vtable) = arg.try_to_ptr().unwrap(); - (ptr, vtable.unwrap()) - }; + let (ptr, vtable) = if let BackendRepr::ScalarPair { .. } = arg.layout().backend_repr { + let (ptr, vtable) = arg.load_scalar_pair(fx); + (Pointer::new(ptr), vtable) + } else { + let (ptr, vtable) = arg.try_to_ptr().unwrap(); + (ptr, vtable.unwrap()) + }; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 855ff1a318ed6..b6e3f9c3009c6 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -3,9 +3,9 @@ use std::collections::hash_map::Entry; use either::{Left, Right}; use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout}; +use rustc_data_structures::Limit; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; -use rustc_hir::limit::Limit; use rustc_middle::mir::interpret::{ErrorHandled, InvalidMetaKind, ReportedErrorInfo}; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::layout::{ diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 73b0dbd1ceeba..ca418a4473465 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -47,10 +47,10 @@ pub use ena::{snapshot_vec, undo_log, unify}; // (via `ShardedHashMap`), and because it lets other compiler crates use the // lower-level `HashTable` API without a tricky `hashbrown` dependency. pub use hashbrown::hash_table; +pub use limit::Limit; pub use rustc_index::static_assert_size; // Re-export some data-structure crates which are part of our public API. pub use {either, indexmap, smallvec, thin_vec}; - pub mod aligned; pub mod base_n; pub mod binary_search_util; @@ -62,6 +62,7 @@ pub mod fx; pub mod graph; pub mod intern; pub mod jobserver; +mod limit; pub mod marker; pub mod memmap; pub mod obligation_forest; diff --git a/compiler/rustc_hir/src/limit.rs b/compiler/rustc_data_structures/src/limit.rs similarity index 78% rename from compiler/rustc_hir/src/limit.rs rename to compiler/rustc_data_structures/src/limit.rs index 2d41a37266001..ee1588d5112ed 100644 --- a/compiler/rustc_hir/src/limit.rs +++ b/compiler/rustc_data_structures/src/limit.rs @@ -1,12 +1,11 @@ use std::fmt; use std::ops::{Div, Mul}; -use rustc_error_messages::{DiagArgValue, IntoDiagArg}; -use rustc_macros::{Decodable, Encodable, StableHash}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; /// New-type wrapper around `usize` for representing limits. Ensures that comparisons against /// limits are consistent throughout the compiler. -#[derive(Clone, Copy, Debug, StableHash, Encodable, Decodable)] +#[derive(Clone, Copy, Debug, StableHash, Encodable_NoContext, Decodable_NoContext)] pub struct Limit(pub usize); impl Limit { @@ -55,9 +54,3 @@ impl Mul for Limit { Limit::new(self.0 * rhs) } } - -impl IntoDiagArg for Limit { - fn into_diag_arg(self, _: &mut Option) -> DiagArgValue { - self.to_string().into_diag_arg(&mut None) - } -} diff --git a/compiler/rustc_error_messages/src/diagnostic_impls.rs b/compiler/rustc_error_messages/src/diagnostic_impls.rs index 38b086eaa80d3..d2bbdde362156 100644 --- a/compiler/rustc_error_messages/src/diagnostic_impls.rs +++ b/compiler/rustc_error_messages/src/diagnostic_impls.rs @@ -5,6 +5,7 @@ use std::num::ParseIntError; use std::path::{Path, PathBuf}; use std::process::ExitStatus; +use rustc_data_structures::Limit; use rustc_span::edition::Edition; use crate::{DiagArgValue, IntoDiagArg}; @@ -156,3 +157,9 @@ impl IntoDiagArg for Backtrace { DiagArgValue::Str(Cow::from(self.to_string())) } } + +impl IntoDiagArg for Limit { + fn into_diag_arg(self, _: &mut Option) -> DiagArgValue { + self.0.into_diag_arg(&mut None) + } +} diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 93b02989eb8b0..3db017b7f7d8c 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -11,13 +11,12 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast::visit::{AssocCtxt, Visitor}; use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind, Safety}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; -use rustc_data_structures::sync; +use rustc_data_structures::{Limit, sync}; use rustc_errors::{BufferedEarlyLint, DiagCtxtHandle, ErrorGuaranteed, PResult}; use rustc_feature::Features; use rustc_hir as hir; use rustc_hir::attrs::{CfgEntry, CollapseMacroDebuginfo, Deprecation}; use rustc_hir::def::MacroKinds; -use rustc_hir::limit::Limit; use rustc_hir::{Stability, find_attr}; use rustc_lint_defs::RegisteredTools; use rustc_parse::MACRO_ARGUMENTS; diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index 750c1407001f6..b87dfd0198efc 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -719,7 +719,8 @@ impl<'a> ExtCtxt<'a> { span: Span, ident: Ident, ty: Box, - rhs_kind: ast::ConstItemRhsKind, + body: Option>, + kind: ast::ConstItemKind, ) -> Box { let defaultness = ast::Defaultness::Implicit; self.item( @@ -732,7 +733,8 @@ impl<'a> ExtCtxt<'a> { // FIXME(generic_const_items): Pass the generics as a parameter. generics: ast::Generics::default(), ty, - rhs_kind, + body, + kind, define_opaque: None, } .into(), diff --git a/compiler/rustc_expand/src/diagnostics.rs b/compiler/rustc_expand/src/diagnostics.rs index 202a5440b2d47..c715fe4eb0ecf 100644 --- a/compiler/rustc_expand/src/diagnostics.rs +++ b/compiler/rustc_expand/src/diagnostics.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; +use rustc_data_structures::Limit; use rustc_errors::codes::*; -use rustc_hir::limit::Limit; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol}; diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 5718065adcf6e..8b897aa3c5f96 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -18,13 +18,13 @@ use rustc_attr_parsing::{ AttributeParser, AttributeSafety, CFG_TEMPLATE, EvalConfigResult, ShouldEmit, eval_config_entry, parse_cfg, validate_attr, }; +use rustc_data_structures::Limit; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::PResult; use rustc_feature::Features; use rustc_hir::Target; use rustc_hir::def::MacroKinds; -use rustc_hir::limit::Limit; use rustc_parse::parser::{ AllowConstBlockItems, AttemptLocalParseRecovery, CommaRecoveryMode, ForceCollect, Parser, RecoverColon, RecoverComma, Recovery, token_descr, diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 63c35ad4e122b..9f42c5c1e7f0b 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -94,6 +94,8 @@ declare_features! ( (accepted, c_str_literals, "1.77.0", Some(105723)), /// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries and treat `extern "C" fn` as nounwind. (accepted, c_unwind, "1.81.0", Some(74990)), + /// Allows using C-variadics. + (accepted, c_variadic, "CURRENT_RUSTC_VERSION", Some(44930)), /// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`. (accepted, cfg_attr_multi, "1.33.0", Some(54881)), /// Allows the use of `#[cfg()]`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 86cc8bb56c6b5..3649cf24ea822 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -424,8 +424,6 @@ declare_features! ( (unstable, avx10_target_feature, "1.88.0", Some(138843)), /// Target features on bpf. (unstable, bpf_target_feature, "1.54.0", Some(150247)), - /// Allows using C-variadics. - (unstable, c_variadic, "1.34.0", Some(44930)), /// Allows defining c-variadic functions on targets where this feature has not yet /// undergone sufficient testing for stabilization. (unstable, c_variadic_experimental_arch, "1.97.0", Some(155973)), diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 9cf2be337fccb..bbec92786f047 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -9,6 +9,7 @@ use rustc_ast::expand::autodiff_attrs::{DiffActivity, DiffMode}; use rustc_ast::expand::typetree::TypeTree; use rustc_ast::token::DocFragmentKind; use rustc_ast::{AttrStyle, Path, ast}; +use rustc_data_structures::Limit; use rustc_data_structures::fx::FxIndexMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_hir::LangItem; @@ -21,7 +22,6 @@ use thin_vec::ThinVec; use crate::attrs::diagnostic::*; use crate::attrs::pretty_printing::PrintAttribute; -use crate::limit::Limit; use crate::{DefaultBodyStability, PartialConstStability, RustcVersion, Stability}; #[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] diff --git a/compiler/rustc_hir/src/attrs/pretty_printing.rs b/compiler/rustc_hir/src/attrs/pretty_printing.rs index d826aa363f349..1cecd49aa1424 100644 --- a/compiler/rustc_hir/src/attrs/pretty_printing.rs +++ b/compiler/rustc_hir/src/attrs/pretty_printing.rs @@ -10,6 +10,7 @@ use rustc_ast::expand::autodiff_attrs::{DiffActivity, DiffMode}; use rustc_ast::token::{CommentKind, DocFragmentKind}; use rustc_ast::{AttrId, AttrStyle, IntTy, UintTy}; use rustc_ast_pretty::pp::Printer; +use rustc_data_structures::Limit; use rustc_data_structures::fx::FxIndexMap; use rustc_span::def_id::DefId; use rustc_span::hygiene::Transparency; @@ -17,8 +18,6 @@ use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; use rustc_target::spec::SanitizerSet; use thin_vec::ThinVec; -use crate::limit::Limit; - /// This trait is used to print attributes in `rustc_hir_pretty`. /// /// For structs and enums it can be derived using [`rustc_macros::PrintAttribute`]. diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index c1e098b7b7f55..9b976d21d5365 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -29,7 +29,6 @@ mod hir; pub use rustc_hir_id::{self as hir_id, *}; pub mod intravisit; pub mod lang_items; -pub mod limit; pub mod lints; pub mod pat_util; mod stability; diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs index a1a466e82c95e..4075efbd240bc 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -1,4 +1,4 @@ -use rustc_hir::limit::Limit; +use rustc_data_structures::Limit; use rustc_infer::infer::InferCtxt; use rustc_infer::traits::PredicateObligations; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Unnormalized}; diff --git a/compiler/rustc_hir_analysis/src/diagnostics.rs b/compiler/rustc_hir_analysis/src/diagnostics.rs index a671b02b5fa66..a6e274ceb4bc6 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics.rs @@ -1,12 +1,12 @@ //! Errors emitted by `rustc_hir_analysis`. use rustc_abi::ExternAbi; +use rustc_data_structures::Limit; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level, MultiSpan, listify, msg, }; -use rustc_hir::limit::Limit; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::{self, Ty}; use rustc_span::{Ident, Span, Symbol}; 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 b59bed76eadd7..f5b4cee8dedf2 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2933,7 +2933,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { .unwrap_or_else(|guar| Const::new_error(tcx, guar)) } Res::Def(DefKind::Static { .. }, _) => { - span_bug!(span, "use of bare `static` ConstArgKind::Path's not yet supported") + let guar = self + .dcx() + .span_err(path.span, "static items cannot be used as const arguments"); + return Const::new_error(tcx, guar); } // FIXME(const_generics): create real const to allow fn items as const paths Res::Def(DefKind::Fn | DefKind::AssocFn, did) => { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs index cfaa60231379e..bc1dd222c56ca 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs @@ -191,7 +191,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let Some(from_trait) = self.tcx.lang_items().from_trait() else { return UnordSet::new(); }; - let obligations = self.fulfillment_cx.borrow().pending_obligations(); + let obligations = self + .fulfillment_cx + .borrow() + .pending_obligations_potentially_referencing_float_infer(self); debug!(?obligations); let mut vids = UnordSet::new(); for obligation in obligations { @@ -209,6 +212,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } +/// Using an intentionally low depth to minimize the chance of future +/// breaking changes in case we adapt the approach later on. This also +/// avoids any hangs for exponentially growing proof trees. +const MAX_DEPTH_FOR_OBLIGATIONS_VISITORS: usize = 5; + struct NestedObligationsForSelfTy<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, self_ty: ty::TyVid, @@ -223,10 +231,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for NestedObligationsForSelfTy<'_, 'tcx> { } fn config(&self) -> InspectConfig { - // Using an intentionally low depth to minimize the chance of future - // breaking changes in case we adapt the approach later on. This also - // avoids any hangs for exponentially growing proof trees. - InspectConfig { max_depth: 5 } + InspectConfig { max_depth: MAX_DEPTH_FOR_OBLIGATIONS_VISITORS } } fn visit_goal(&mut self, inspect_goal: &InspectGoal<'_, 'tcx>) { @@ -282,23 +287,37 @@ impl<'tcx> ProofTreeVisitor<'tcx> for FindFromFloatForF32RootVids<'_, 'tcx> { } fn config(&self) -> InspectConfig { - // Avoid hang from exponentially growing proof trees (see `cycle-modulo-ambig-aliases.rs`). - // 3 is more than enough for all occurrences in practice (a.k.a. `Into`). - InspectConfig { max_depth: 3 } + InspectConfig { max_depth: MAX_DEPTH_FOR_OBLIGATIONS_VISITORS } } fn visit_goal(&mut self, inspect_goal: &InspectGoal<'_, 'tcx>) { + // No need to walk into goal subtrees that certainly hold, since they + // wouldn't then be stalled on an infer var. + if inspect_goal.result() == Ok(Certainty::Yes) { + return; + } + + // We don't care about any pending goals which don't actually + // use any float infer var. + if !inspect_goal + .orig_values() + .iter() + .filter_map(|arg| arg.as_type()) + .any(|ty| matches!(self.fcx.shallow_resolve(ty).kind(), ty::Infer(ty::FloatVar(_)))) + { + debug!(goal = ?inspect_goal.goal(), "goal does not mention float infer var"); + return; + } + if let Some(vid) = self .fcx .predicate_from_float_for_f32_root_vid(self.from_trait, inspect_goal.goal().predicate) { self.vids.insert(vid); - } else if let Some(candidate) = inspect_goal.unique_applicable_candidate() { - let start_len = self.vids.len(); - let _ = candidate.goal().infcx().commit_if_ok(|_| { - candidate.visit_nested_no_probe(self); - if self.vids.len() > start_len { Ok(()) } else { Err(()) } - }); + } + + if let Some(candidate) = inspect_goal.unique_applicable_candidate() { + candidate.visit_nested_no_probe(self); } } } diff --git a/compiler/rustc_infer/src/traits/engine.rs b/compiler/rustc_infer/src/traits/engine.rs index 38fc991fcfeb6..6adec25be32f0 100644 --- a/compiler/rustc_infer/src/traits/engine.rs +++ b/compiler/rustc_infer/src/traits/engine.rs @@ -120,6 +120,17 @@ pub trait TraitEngine<'tcx, E: 'tcx>: 'tcx { self.pending_obligations() } + /// Pending obligations potentially referencing float inference variables. + /// + /// FIXME: use a generic filter for `pending_obligations_potentially_referencing_sub_root` + /// and this after `TraitEngine` doesn't need to be dyn compatible. + fn pending_obligations_potentially_referencing_float_infer( + &self, + _infcx: &InferCtxt<'tcx>, + ) -> PredicateObligations<'tcx> { + self.pending_obligations() + } + /// Among all pending obligations, collect those are stalled on a inference variable which has /// changed since the last call to `try_evaluate_obligations`. Those obligations are marked as /// successful and returned. diff --git a/compiler/rustc_interface/src/limits.rs b/compiler/rustc_interface/src/limits.rs index 973a01f4658ec..f1f2b1536f806 100644 --- a/compiler/rustc_interface/src/limits.rs +++ b/compiler/rustc_interface/src/limits.rs @@ -8,7 +8,7 @@ //! Users can override these limits via an attribute on the crate like //! `#![recursion_limit="22"]`. This pass just looks for those attributes. -use rustc_hir::limit::Limit; +use rustc_data_structures::Limit; use rustc_hir::{Attribute, find_attr}; use rustc_middle::query::Providers; use rustc_session::{Limits, Session}; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index f17f75dc9d565..2f32a6b208b6c 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -14,7 +14,7 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{ AppendOnlyIndexVec, DynSend, DynSync, FreezeLock, WorkerLocal, par_fns, }; -use rustc_data_structures::thousands; +use rustc_data_structures::{Limit, thousands}; use rustc_errors::timings::TimingSection; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level}; use rustc_expand::base::{ExtCtxt, LintStoreExpand}; @@ -23,7 +23,6 @@ use rustc_fs_util::try_canonicalize; use rustc_hir::attrs::AttributeKind; use rustc_hir::def_id::{LOCAL_CRATE, StableCrateId, StableCrateIdMap}; use rustc_hir::definitions::Definitions; -use rustc_hir::limit::Limit; use rustc_hir::{Attribute, Target, find_attr}; use rustc_incremental::setup_dep_graph; use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore, unerased_lint_store}; diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index a24bf6c20c4eb..c1bf9b3345bc3 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -510,8 +510,8 @@ trait UnusedDelimLint { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) { use ast::ItemKind::*; - let expr = if let Const(ast::ConstItem { rhs_kind, .. }) = &item.kind { - if let Some(e) = rhs_kind.expr() { e } else { return } + let expr = if let Const(ast::ConstItem { body: Some(expr), .. }) = &item.kind { + expr } else if let Static(ast::StaticItem { expr: Some(expr), .. }) = &item.kind { expr } else { diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index 0d199e0d06655..9d90691e51446 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -59,7 +59,7 @@ pub(crate) struct RecursionLimitReached<'tcx> { #[primary_span] pub span: Span, pub ty: Ty<'tcx>, - pub suggested_limit: rustc_hir::limit::Limit, + pub suggested_limit: rustc_data_structures::Limit, } #[derive(Diagnostic)] @@ -71,7 +71,7 @@ pub(crate) struct RecursionLimitReachedSizeSkeleton<'tcx> { #[primary_span] pub span: Span, pub ty: Ty<'tcx>, - pub suggested_limit: rustc_hir::limit::Limit, + pub suggested_limit: rustc_data_structures::Limit, } #[derive(Diagnostic)] @@ -137,7 +137,9 @@ pub(crate) struct MaxNumNodesInValtree { #[derive(Diagnostic)] #[diag("constant {$global_const_id} cannot be used as pattern")] -#[note("constants that reference mutable or external memory cannot be used as patterns")] +#[note( + "constants that reference mutable or external memory or that contain dangling references cannot be used as patterns" +)] pub(crate) struct InvalidConstInValtree { #[primary_span] pub span: Span, diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index d1744f9e6a1ef..4ae165cb015bd 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -17,7 +17,6 @@ use std::{fmt, iter, mem}; use rustc_abi::{ExternAbi, FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx}; use rustc_ast as ast; -use rustc_data_structures::defer; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; use rustc_data_structures::profiling::SelfProfilerRef; @@ -27,13 +26,13 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{ self, DynSend, DynSync, FreezeReadGuard, Lock, RwLock, WorkerLocal, }; +use rustc_data_structures::{Limit, defer}; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, MultiSpan}; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::definitions::{DefPathData, Definitions, PerParentDisambiguatorState}; use rustc_hir::intravisit::VisitorExt; use rustc_hir::lang_items::LangItem; -use rustc_hir::limit::Limit; use rustc_hir::{self as hir, CRATE_HIR_ID, HirId, Node, TraitCandidate, find_attr}; use rustc_index::IndexVec; use rustc_macros::Diagnostic; diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 208e94270a45e..83670daf909fa 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -4,10 +4,10 @@ use std::hash::{DefaultHasher, Hash, Hasher}; use std::io::{Read, Write}; use std::path::PathBuf; +use rustc_data_structures::Limit; use rustc_errors::pluralize; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind}; -use rustc_hir::limit::Limit; use rustc_macros::extension; pub use rustc_type_ir::error::ExpectedFound; diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index a8bae1efc2470..3fb35d48513ad 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -6,6 +6,7 @@ use rustc_abi::{ PointerKind, Primitive, ReprFlags, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, TyAbiInterface, VariantIdx, Variants, }; +use rustc_data_structures::Limit; use rustc_errors::{ Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, }; @@ -353,7 +354,7 @@ impl<'tcx> SizeSkeleton<'tcx> { let recursion_limit = tcx.recursion_limit(); if depth >= recursion_limit.0 { let suggested_limit = match recursion_limit { - hir::limit::Limit(0) => hir::limit::Limit(2), + Limit(0) => Limit(2), limit => limit * 2, }; let reported = tcx.dcx().emit_err(crate::error::RecursionLimitReachedSizeSkeleton { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 385f4329facc6..3c7e3b63ee9b5 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -6,6 +6,7 @@ use std::ops::{Deref, DerefMut}; use rustc_abi::{ExternAbi, Size}; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; +use rustc_data_structures::Limit; use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; use rustc_data_structures::unord::UnordMap; use rustc_hir as hir; @@ -13,7 +14,6 @@ use rustc_hir::LangItem; use rustc_hir::def::{self, CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{DefIdMap, DefIdSet, LOCAL_CRATE, ModId}; use rustc_hir::definitions::{DefKey, DefPathDataName}; -use rustc_hir::limit::Limit; use rustc_macros::{Lift, extension}; use rustc_session::cstore::{ExternCrate, ExternCrateSource}; use rustc_span::{Ident, RemapPathScopeComponents, Symbol, kw, sym}; diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index c4d9ec9f64289..8e84ee6ab03e1 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -4,6 +4,7 @@ use std::{fmt, iter}; use rustc_abi::{Float, Integer, IntegerType, Size}; use rustc_apfloat::Float as _; +use rustc_data_structures::Limit; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hash::{StableHash, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; @@ -11,7 +12,6 @@ use rustc_errors::ErrorGuaranteed; use rustc_hashes::Hash128; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; -use rustc_hir::limit::Limit; use rustc_hir::{self as hir, find_attr}; use rustc_index::bit_set::GrowableBitSet; use rustc_macros::{StableHash, TyDecodable, TyEncodable, extension}; diff --git a/compiler/rustc_mir_dataflow/src/framework/cursor.rs b/compiler/rustc_mir_dataflow/src/framework/cursor.rs index 3c56999fcbdc9..63b2adceb524c 100644 --- a/compiler/rustc_mir_dataflow/src/framework/cursor.rs +++ b/compiler/rustc_mir_dataflow/src/framework/cursor.rs @@ -195,28 +195,20 @@ where debug_assert_eq!(target.block, self.pos.block); let block_data = &self.body[target.block]; - #[rustfmt::skip] - let next_effect = if A::Direction::IS_FORWARD { - self.pos.curr_effect_index.map_or_else( - || Effect::Early.at_index(0), - EffectIndex::next_in_forward_order, - ) - } else { - self.pos.curr_effect_index.map_or_else( - || Effect::Early.at_index(block_data.statements.len()), - EffectIndex::next_in_backward_order, - ) - }; - + let next_effect = self.pos.curr_effect_index.map_or_else( + || A::Direction::first_index(block_data), + |idx| A::Direction::next_index(idx), + ); let target_effect_index = effect.at_index(target.statement_index); - A::Direction::apply_effects_in_range( - &self.results.analysis, - &mut self.state, - target.block, - block_data, - next_effect..=target_effect_index, - ); + let mut idx = next_effect; + loop { + self.results.analysis.apply_effect(&mut self.state, target.block, block_data, idx); + if idx == target_effect_index { + break; + } + idx = A::Direction::next_index(idx); + } self.pos = CursorPosition { block: target.block, curr_effect_index: Some(target_effect_index) }; diff --git a/compiler/rustc_mir_dataflow/src/framework/direction.rs b/compiler/rustc_mir_dataflow/src/framework/direction.rs index 39df33187d3a9..68c8e03de8022 100644 --- a/compiler/rustc_mir_dataflow/src/framework/direction.rs +++ b/compiler/rustc_mir_dataflow/src/framework/direction.rs @@ -1,5 +1,3 @@ -use std::ops::RangeInclusive; - use rustc_middle::bug; use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges}; @@ -10,6 +8,13 @@ pub trait Direction { const IS_FORWARD: bool; const IS_BACKWARD: bool = !Self::IS_FORWARD; + /// Returns the first statement index for this direction. (0 when going forward and + /// `statements.len()` when going backward.) + fn first_index(block_data: &mir::BasicBlockData<'_>) -> EffectIndex; + + /// Returns the next index for this direction. + fn next_index(idx: EffectIndex) -> EffectIndex; + /// Called by `iterate_to_fixpoint` during initial analysis computation. fn apply_effects_in_block<'mir, 'tcx, A>( analysis: &A, @@ -21,19 +26,6 @@ pub trait Direction { ) where A: Analysis<'tcx>; - /// Called by `ResultsCursor` to recompute the domain value for a location - /// in a basic block. Applies all effects between the given `EffectIndex`s. - /// - /// `effects.start()` must precede or equal `effects.end()` in this direction. - fn apply_effects_in_range<'tcx, A>( - analysis: &A, - state: &mut A::Domain, - block: BasicBlock, - block_data: &mir::BasicBlockData<'tcx>, - effects: RangeInclusive, - ) where - A: Analysis<'tcx>; - /// Called by `ResultsVisitor` to recompute the analysis domain values for /// all locations in a basic block (starting from `entry_state` and to /// visit them with `vis`. @@ -53,6 +45,18 @@ pub struct Backward; impl Direction for Backward { const IS_FORWARD: bool = false; + fn first_index(block_data: &mir::BasicBlockData<'_>) -> EffectIndex { + Effect::Early.at_index(block_data.statements.len()) + } + + /// Returns the next index for this direction. + fn next_index(idx: EffectIndex) -> EffectIndex { + match idx.effect { + Effect::Early => Effect::Primary.at_index(idx.statement_index), + Effect::Primary => Effect::Early.at_index(idx.statement_index - 1), + } + } + fn apply_effects_in_block<'mir, 'tcx, A>( analysis: &A, body: &mir::Body<'tcx>, @@ -128,83 +132,6 @@ impl Direction for Backward { } } - fn apply_effects_in_range<'tcx, A>( - analysis: &A, - state: &mut A::Domain, - block: BasicBlock, - block_data: &mir::BasicBlockData<'tcx>, - effects: RangeInclusive, - ) where - A: Analysis<'tcx>, - { - let (from, to) = (*effects.start(), *effects.end()); - let terminator_index = block_data.statements.len(); - - assert!(from.statement_index <= terminator_index); - assert!(!to.precedes_in_backward_order(from)); - - // Handle the statement (or terminator) at `from`. - - let next_effect = match from.effect { - // If we need to apply the terminator effect in all or in part, do so now. - _ if from.statement_index == terminator_index => { - let location = Location { block, statement_index: from.statement_index }; - let terminator = block_data.terminator(); - - if from.effect == Effect::Early { - analysis.apply_early_terminator_effect(state, terminator, location); - if to == Effect::Early.at_index(terminator_index) { - return; - } - } - - analysis.apply_primary_terminator_effect(state, terminator, location); - if to == Effect::Primary.at_index(terminator_index) { - return; - } - - // If `from.statement_index` is `0`, we will have hit one of the earlier comparisons - // with `to`. - from.statement_index - 1 - } - - Effect::Primary => { - let location = Location { block, statement_index: from.statement_index }; - let statement = &block_data.statements[from.statement_index]; - - analysis.apply_primary_statement_effect(state, statement, location); - if to == Effect::Primary.at_index(from.statement_index) { - return; - } - - from.statement_index - 1 - } - - Effect::Early => from.statement_index, - }; - - // Handle all statements between `first_unapplied_idx` and `to.statement_index`. - - for statement_index in (to.statement_index..next_effect).rev().map(|i| i + 1) { - let location = Location { block, statement_index }; - let statement = &block_data.statements[statement_index]; - analysis.apply_early_statement_effect(state, statement, location); - analysis.apply_primary_statement_effect(state, statement, location); - } - - // Handle the statement at `to`. - - let location = Location { block, statement_index: to.statement_index }; - let statement = &block_data.statements[to.statement_index]; - analysis.apply_early_statement_effect(state, statement, location); - - if to.effect == Effect::Early { - return; - } - - analysis.apply_primary_statement_effect(state, statement, location); - } - fn visit_results_in_block<'mir, 'tcx, A>( analysis: &A, state: &mut A::Domain, @@ -214,8 +141,6 @@ impl Direction for Backward { ) where A: Analysis<'tcx>, { - vis.visit_block_end(state); - let loc = Location { block, statement_index: block_data.statements.len() }; let term = block_data.terminator(); analysis.apply_early_terminator_effect(state, term, loc); @@ -230,8 +155,6 @@ impl Direction for Backward { analysis.apply_primary_statement_effect(state, stmt, loc); vis.visit_after_primary_statement_effect(analysis, state, stmt, loc); } - - vis.visit_block_start(state); } } @@ -241,6 +164,18 @@ pub struct Forward; impl Direction for Forward { const IS_FORWARD: bool = true; + fn first_index(_block_data: &mir::BasicBlockData<'_>) -> EffectIndex { + Effect::Early.at_index(0) + } + + /// Returns the next index for this direction. + fn next_index(idx: EffectIndex) -> EffectIndex { + match idx.effect { + Effect::Early => Effect::Primary.at_index(idx.statement_index), + Effect::Primary => Effect::Early.at_index(idx.statement_index + 1), + } + } + fn apply_effects_in_block<'mir, 'tcx, A>( analysis: &A, body: &mir::Body<'tcx>, @@ -310,80 +245,6 @@ impl Direction for Forward { } } - fn apply_effects_in_range<'tcx, A>( - analysis: &A, - state: &mut A::Domain, - block: BasicBlock, - block_data: &mir::BasicBlockData<'tcx>, - effects: RangeInclusive, - ) where - A: Analysis<'tcx>, - { - let (from, to) = (*effects.start(), *effects.end()); - let terminator_index = block_data.statements.len(); - - assert!(to.statement_index <= terminator_index); - assert!(!to.precedes_in_forward_order(from)); - - // If we have applied the before affect of the statement or terminator at `from` but not its - // after effect, do so now and start the loop below from the next statement. - - let first_unapplied_index = match from.effect { - Effect::Early => from.statement_index, - - Effect::Primary if from.statement_index == terminator_index => { - debug_assert_eq!(from, to); - - let location = Location { block, statement_index: terminator_index }; - let terminator = block_data.terminator(); - analysis.apply_primary_terminator_effect(state, terminator, location); - return; - } - - Effect::Primary => { - let location = Location { block, statement_index: from.statement_index }; - let statement = &block_data.statements[from.statement_index]; - analysis.apply_primary_statement_effect(state, statement, location); - - // If we only needed to apply the after effect of the statement at `idx`, we are - // done. - if from == to { - return; - } - - from.statement_index + 1 - } - }; - - // Handle all statements between `from` and `to` whose effects must be applied in full. - - for statement_index in first_unapplied_index..to.statement_index { - let location = Location { block, statement_index }; - let statement = &block_data.statements[statement_index]; - analysis.apply_early_statement_effect(state, statement, location); - analysis.apply_primary_statement_effect(state, statement, location); - } - - // Handle the statement or terminator at `to`. - - let location = Location { block, statement_index: to.statement_index }; - if to.statement_index == terminator_index { - let terminator = block_data.terminator(); - analysis.apply_early_terminator_effect(state, terminator, location); - - if to.effect == Effect::Primary { - analysis.apply_primary_terminator_effect(state, terminator, location); - } - } else { - let statement = &block_data.statements[to.statement_index]; - analysis.apply_early_statement_effect(state, statement, location); - - if to.effect == Effect::Primary { - analysis.apply_primary_statement_effect(state, statement, location); - } - } - } - fn visit_results_in_block<'mir, 'tcx, A>( analysis: &A, state: &mut A::Domain, @@ -393,8 +254,6 @@ impl Direction for Forward { ) where A: Analysis<'tcx>, { - vis.visit_block_start(state); - for (statement_index, stmt) in block_data.statements.iter().enumerate() { let loc = Location { block, statement_index }; analysis.apply_early_statement_effect(state, stmt, loc); @@ -409,7 +268,5 @@ impl Direction for Forward { vis.visit_after_early_terminator_effect(analysis, state, term, loc); analysis.apply_primary_terminator_effect(state, term, loc); vis.visit_after_primary_terminator_effect(analysis, state, term, loc); - - vis.visit_block_end(state); } } diff --git a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs index 6c0f2e8d73058..a95ab44c951d6 100644 --- a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs +++ b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs @@ -633,7 +633,7 @@ struct StateDiffCollector { after: Vec, } -impl StateDiffCollector { +impl StateDiffCollector { fn run<'tcx, A>( body: &Body<'tcx>, block: BasicBlock, @@ -645,7 +645,7 @@ impl StateDiffCollector { D: DebugWithContext, { let mut collector = StateDiffCollector { - prev_state: results.analysis.bottom_value(body), + prev_state: results.entry_states[block].clone(), after: vec![], before: (style == OutputStyle::BeforeAndAfter).then_some(vec![]), }; @@ -660,18 +660,6 @@ where A: Analysis<'tcx>, A::Domain: DebugWithContext, { - fn visit_block_start(&mut self, state: &A::Domain) { - if A::Direction::IS_FORWARD { - self.prev_state.clone_from(state); - } - } - - fn visit_block_end(&mut self, state: &A::Domain) { - if A::Direction::IS_BACKWARD { - self.prev_state.clone_from(state); - } - } - fn visit_after_early_statement_effect( &mut self, analysis: &A, diff --git a/compiler/rustc_mir_dataflow/src/framework/mod.rs b/compiler/rustc_mir_dataflow/src/framework/mod.rs index 6445ba7ad27b6..211a1b8d05b71 100644 --- a/compiler/rustc_mir_dataflow/src/framework/mod.rs +++ b/compiler/rustc_mir_dataflow/src/framework/mod.rs @@ -32,13 +32,13 @@ //! //! [gen-kill]: https://en.wikipedia.org/wiki/Data-flow_analysis#Bit_vector_problems -use std::cmp::Ordering; - use rustc_data_structures::work_queue::WorkQueue; use rustc_index::bit_set::{DenseBitSet, MixedBitSet}; use rustc_index::{Idx, IndexVec}; use rustc_middle::bug; -use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges, traversal}; +use rustc_middle::mir::{ + self, BasicBlock, BasicBlockData, CallReturnPlaces, Location, TerminatorEdges, traversal, +}; use rustc_middle::ty::TyCtxt; use tracing::error; @@ -125,6 +125,40 @@ pub trait Analysis<'tcx> { // `resume`). It's not obvious how to handle `yield` points in coroutines, however. fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain); + /// Given an `EffectIndex`, calls the appropriate `apply_*` method in the + /// {early,primary} x {statement,terminator} space. + /// + /// Do not override this; instead override one or more of the `apply_*` methods. + #[inline] + fn apply_effect<'mir>( + &self, + state: &mut Self::Domain, + block: BasicBlock, + block_data: &'mir BasicBlockData<'tcx>, + idx: EffectIndex, + ) { + let statement_index = idx.statement_index; + let terminator_index = block_data.statements.len(); + let loc = Location { block, statement_index }; + let is_terminator = statement_index == terminator_index; + + if !is_terminator { + let statement = &block_data.statements[statement_index]; + match idx.effect { + Effect::Early => self.apply_early_statement_effect(state, statement, loc), + Effect::Primary => self.apply_primary_statement_effect(state, statement, loc), + } + } else { + let terminator = block_data.terminator(); + match idx.effect { + Effect::Early => self.apply_early_terminator_effect(state, terminator, loc), + Effect::Primary => { + self.apply_primary_terminator_effect(state, terminator, loc); + } + } + } + } + /// Updates the current dataflow state with an "early" effect, i.e. one /// that occurs immediately before the given statement. /// @@ -402,41 +436,5 @@ pub struct EffectIndex { effect: Effect, } -impl EffectIndex { - fn next_in_forward_order(self) -> Self { - match self.effect { - Effect::Early => Effect::Primary.at_index(self.statement_index), - Effect::Primary => Effect::Early.at_index(self.statement_index + 1), - } - } - - fn next_in_backward_order(self) -> Self { - match self.effect { - Effect::Early => Effect::Primary.at_index(self.statement_index), - Effect::Primary => Effect::Early.at_index(self.statement_index - 1), - } - } - - /// Returns `true` if the effect at `self` should be applied earlier than the effect at `other` - /// in forward order. - fn precedes_in_forward_order(self, other: Self) -> bool { - let ord = self - .statement_index - .cmp(&other.statement_index) - .then_with(|| self.effect.cmp(&other.effect)); - ord == Ordering::Less - } - - /// Returns `true` if the effect at `self` should be applied earlier than the effect at `other` - /// in backward order. - fn precedes_in_backward_order(self, other: Self) -> bool { - let ord = other - .statement_index - .cmp(&self.statement_index) - .then_with(|| self.effect.cmp(&other.effect)); - ord == Ordering::Less - } -} - #[cfg(test)] mod tests; diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs index dec273d39dd1a..86ea3a34ae0ea 100644 --- a/compiler/rustc_mir_dataflow/src/framework/tests.rs +++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs @@ -139,11 +139,7 @@ impl MockAnalysis<'_, D> { SeekTarget::After(loc) => Effect::Primary.at_index(loc.statement_index), }; - let mut pos = if D::IS_FORWARD { - Effect::Early.at_index(0) - } else { - Effect::Early.at_index(self.body[block].statements.len()) - }; + let mut pos = D::first_index(&self.body[block]); loop { ret.insert(self.effect(pos)); @@ -152,11 +148,7 @@ impl MockAnalysis<'_, D> { return ret; } - if D::IS_FORWARD { - pos = pos.next_in_forward_order(); - } else { - pos = pos.next_in_backward_order(); - } + pos = D::next_index(pos); } } } diff --git a/compiler/rustc_mir_dataflow/src/framework/visitor.rs b/compiler/rustc_mir_dataflow/src/framework/visitor.rs index 46940c6ab62fc..b6827be3d8beb 100644 --- a/compiler/rustc_mir_dataflow/src/framework/visitor.rs +++ b/compiler/rustc_mir_dataflow/src/framework/visitor.rs @@ -46,8 +46,6 @@ pub trait ResultsVisitor<'tcx, A> where A: Analysis<'tcx>, { - fn visit_block_start(&mut self, _state: &A::Domain) {} - /// Called after the "early" effect of the given statement is applied to `state`. fn visit_after_early_statement_effect( &mut self, @@ -89,6 +87,4 @@ where _location: Location, ) { } - - fn visit_block_end(&mut self, _state: &A::Domain) {} } diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs index 22529d7fcd56f..ce34c6ad07758 100644 --- a/compiler/rustc_mir_transform/src/inline/cycle.rs +++ b/compiler/rustc_mir_transform/src/inline/cycle.rs @@ -1,8 +1,8 @@ +use rustc_data_structures::Limit; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::unord::UnordSet; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::limit::Limit; use rustc_middle::mir::TerminatorKind; use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, ShimKind, TyCtxt, TypeVisitableExt}; use rustc_span::sym; diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 631d28d6cef00..c0059ca2ba852 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -208,6 +208,7 @@ use std::cell::OnceCell; use std::ops::ControlFlow; +use rustc_data_structures::Limit; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync::{Lock, par_for_each_in}; use rustc_data_structures::unord::{UnordMap, UnordSet}; @@ -216,7 +217,6 @@ use rustc_hir::attrs::InlineAttr; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId}; use rustc_hir::lang_items::LangItem; -use rustc_hir::limit::Limit; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::{AllocId, ErrorHandled, GlobalAlloc, Scalar}; use rustc_middle::mir::visit::Visitor as MirVisitor; diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs index 5fa2f49584f2c..fe22f68b861af 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs @@ -1,7 +1,7 @@ use rustc_abi::Size; +use rustc_data_structures::Limit; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; -use rustc_hir::limit::Limit; use rustc_middle::mir::visit::Visitor as MirVisitor; use rustc_middle::mir::{self, Location, traversal}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable}; diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 49e786d7d0683..c6773ef5ba18f 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -324,13 +324,14 @@ impl<'a> Parser<'a> { // CONST ITEM self.recover_const_mut(const_span); self.recover_missing_kw_before_item()?; - let (ident, generics, ty, rhs_kind) = self.parse_const_item(false, const_span)?; + let (ident, generics, ty, body) = self.parse_const_item(const_span)?; ItemKind::Const(Box::new(ConstItem { defaultness: def_(), ident, generics, ty, - rhs_kind, + body, + kind: ConstItemKind::Body, define_opaque: None, })) } else if let Some(kind) = self.is_reuse_item() { @@ -345,7 +346,7 @@ impl<'a> Parser<'a> { // TYPE CONST (mgca) self.recover_const_mut(const_span); self.recover_missing_kw_before_item()?; - let (ident, generics, ty, rhs_kind) = self.parse_const_item(true, const_span)?; + let (ident, generics, ty, body) = self.parse_const_item(const_span)?; // Make sure this is only allowed if the feature gate is enabled. // #![feature(mgca_type_const_syntax)] self.psess.gated_spans.gate(sym::mgca_type_const_syntax, lo.to(const_span)); @@ -354,7 +355,8 @@ impl<'a> Parser<'a> { ident, generics, ty, - rhs_kind, + body, + kind: ConstItemKind::TypeConst, define_opaque: None, })) } else { @@ -1264,7 +1266,8 @@ impl<'a> Parser<'a> { ident, generics: Generics::default(), ty, - rhs_kind: ConstItemRhsKind::Body { rhs: expr }, + body: expr, + kind: ConstItemKind::Body, define_opaque, })) } @@ -1506,7 +1509,7 @@ impl<'a> Parser<'a> { let kind = match ForeignItemKind::try_from(kind) { Ok(kind) => kind, Err(kind) => match kind { - ItemKind::Const(ConstItem { ident, ty, rhs_kind, .. }) => { + ItemKind::Const(ConstItem { ident, ty, body, .. }) => { let const_span = Some(span.with_hi(ident.span.lo())) .filter(|span| span.can_be_used_for_suggestions()); self.dcx().emit_err(diagnostics::ExternItemCannotBeConst { @@ -1517,13 +1520,7 @@ impl<'a> Parser<'a> { ident, ty, mutability: Mutability::Not, - expr: match rhs_kind { - ConstItemRhsKind::Body { rhs } => rhs, - ConstItemRhsKind::TypeConst { rhs: Some(anon) } => { - Some(anon.value) - } - ConstItemRhsKind::TypeConst { rhs: None } => None, - }, + expr: body, safety: Safety::Default, define_opaque: None, eii_impls: ThinVec::default(), @@ -1686,9 +1683,8 @@ impl<'a> Parser<'a> { /// ``` fn parse_const_item( &mut self, - const_arg: bool, const_span: Span, - ) -> PResult<'a, (Ident, Generics, Box, ConstItemRhsKind)> { + ) -> PResult<'a, (Ident, Generics, Box, Option>)> { let ident = self.parse_ident_or_underscore()?; let mut generics = self.parse_generics()?; @@ -1715,14 +1711,7 @@ impl<'a> Parser<'a> { let before_where_clause = if self.may_recover() { self.parse_where_clause()? } else { WhereClause::default() }; - let rhs = match (self.eat(exp!(Eq)), const_arg) { - (true, true) => { - ConstItemRhsKind::TypeConst { rhs: Some(self.parse_expr_anon_const()?) } - } - (true, false) => ConstItemRhsKind::Body { rhs: Some(self.parse_expr()?) }, - (false, true) => ConstItemRhsKind::TypeConst { rhs: None }, - (false, false) => ConstItemRhsKind::Body { rhs: None }, - }; + let rhs = if self.eat(exp!(Eq)) { Some(self.parse_expr()?) } else { None }; let after_where_clause = self.parse_where_clause()?; @@ -1730,18 +1719,18 @@ impl<'a> Parser<'a> { // Users may be tempted to write such code if they are still used to the deprecated // where-clause location on type aliases and associated types. See also #89122. if before_where_clause.has_where_token - && let Some(rhs_span) = rhs.span() + && let Some(rhs) = &rhs { self.dcx().emit_err(diagnostics::WhereClauseBeforeConstBody { span: before_where_clause.span, name: ident.span, - body: rhs_span, + body: rhs.span, sugg: if !after_where_clause.has_where_token { - self.psess.source_map().span_to_snippet(rhs_span).ok().map(|body_s| { + self.psess.source_map().span_to_snippet(rhs.span).ok().map(|body_s| { diagnostics::WhereClauseBeforeConstBodySugg { left: before_where_clause.span.shrink_to_lo(), snippet: body_s, - right: before_where_clause.span.shrink_to_hi().to(rhs_span), + right: before_where_clause.span.shrink_to_hi().to(rhs.span), } }) } else { @@ -1778,7 +1767,7 @@ impl<'a> Parser<'a> { generics.where_clause = where_clause; if let Some(rhs) = self.try_recover_const_missing_semi(&rhs, const_span) { - return Ok((ident, generics, ty, ConstItemRhsKind::Body { rhs: Some(rhs) })); + return Ok((ident, generics, ty, Some(rhs))); } self.expect_semi()?; @@ -3700,13 +3689,13 @@ impl<'a> Parser<'a> { /// Returns a corrected expression if recovery is successful. fn try_recover_const_missing_semi( &mut self, - rhs: &ConstItemRhsKind, + rhs: &Option>, const_span: Span, ) -> Option> { if self.token == TokenKind::Semi { return None; } - let ConstItemRhsKind::Body { rhs: Some(rhs) } = rhs else { + let Some(rhs) = rhs else { return None; }; if !self.in_fn_body || !self.may_recover() || rhs.span.from_expansion() { diff --git a/compiler/rustc_query_impl/src/error.rs b/compiler/rustc_query_impl/src/error.rs index 834c3cec6993e..eee6cea623909 100644 --- a/compiler/rustc_query_impl/src/error.rs +++ b/compiler/rustc_query_impl/src/error.rs @@ -1,5 +1,5 @@ +use rustc_data_structures::Limit; use rustc_errors::codes::*; -use rustc_hir::limit::Limit; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 8b7a2ccb232d0..47f291f64ecf1 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -1,7 +1,7 @@ use std::num::NonZero; +use rustc_data_structures::Limit; use rustc_data_structures::unord::UnordMap; -use rustc_hir::limit::Limit; use rustc_middle::bug; #[expect(unused_imports, reason = "used by doc comments")] use rustc_middle::dep_graph::DepKindVTable; diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index d319cd7ae9281..1ef2414b0af49 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -166,7 +166,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { nested: false, }, ItemKind::Const(citem) => { - let is_type_const = matches!(citem.rhs_kind, ConstItemRhsKind::TypeConst { .. }); + let is_type_const = citem.kind == ConstItemKind::TypeConst; DefKind::Const { is_type_const } } ItemKind::ConstBlock(..) => DefKind::Const { is_type_const: false }, @@ -387,11 +387,9 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { | AssocItemKind::Delegation(Delegation { ident, .. }) => { (*ident, DefKind::AssocFn, ValueNS) } - AssocItemKind::Const(ConstItem { ident, rhs_kind, .. }) => ( + AssocItemKind::Const(ConstItem { ident, kind, .. }) => ( *ident, - DefKind::AssocConst { - is_type_const: matches!(rhs_kind, ConstItemRhsKind::TypeConst { .. }), - }, + DefKind::AssocConst { is_type_const: *kind == ConstItemKind::TypeConst }, ValueNS, ), AssocItemKind::Type(TyAlias { ident, .. }) => (*ident, DefKind::AssocTy, TypeNS), diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 2726598c40894..9fb2cce9785d3 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2971,7 +2971,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { ident, generics, ty, - rhs_kind, + body, + kind, define_opaque, defaultness: _, }) => { @@ -2994,7 +2995,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { this.with_lifetime_rib( LifetimeRibKind::elided(LifetimeRes::Static), |this: &mut LateResolutionVisitor<'a, 'ast, 'ra, 'tcx>| { - if rhs_kind.is_type_const() + if *kind == ast::ConstItemKind::TypeConst && !this.r.features.generic_const_parameter_types() { this.with_rib(TypeNS, RibKind::ConstParamTy, |this| { @@ -3011,10 +3012,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { }, ); - this.resolve_const_item_rhs( - rhs_kind, - Some((*ident, ConstantItemKind::Const)), - ); + this.resolve_const_item_rhs(body, Some((*ident, ConstantItemKind::Const))); }, ); self.resolve_define_opaques(define_opaque); @@ -3379,7 +3377,12 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.resolve_doc_links(&item.attrs, MaybeExported::Ok(item.id)); match &item.kind { AssocItemKind::Const(ast::ConstItem { - generics, ty, rhs_kind, define_opaque, .. + generics, + ty, + body, + kind, + define_opaque, + .. }) => { self.with_generic_param_rib( &generics.params, @@ -3395,7 +3398,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { }, |this| { this.visit_generics(generics); - if rhs_kind.is_type_const() + if *kind == ConstItemKind::TypeConst && !this.r.features.generic_const_parameter_types() { this.with_rib(TypeNS, RibKind::ConstParamTy, |this| { @@ -3418,7 +3421,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // // Type parameters can already be used and as associated consts are // not used as part of the type system, this is far less surprising. - this.resolve_const_item_rhs(rhs_kind, None); + this.resolve_const_item_rhs(body, None); }, ) }, @@ -3595,7 +3598,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { ident, generics, ty, - rhs_kind, + body, + kind, define_opaque, .. }) => { @@ -3627,7 +3631,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { ); this.visit_generics(generics); - if rhs_kind.is_type_const() + if *kind == ConstItemKind::TypeConst && !this.r.tcx.features().generic_const_parameter_types() { this.with_rib(TypeNS, RibKind::ConstParamTy, |this| { @@ -3646,7 +3650,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // // Type parameters can already be used and as associated consts are // not used as part of the type system, this is far less surprising. - this.resolve_const_item_rhs(rhs_kind, None); + this.resolve_const_item_rhs(body, None); }, ) }, @@ -3879,20 +3883,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { fn resolve_const_item_rhs( &mut self, - rhs_kind: &'ast ConstItemRhsKind, + body: &'ast Option>, item: Option<(Ident, ConstantItemKind)>, ) { - self.with_lifetime_rib(LifetimeRibKind::elided(LifetimeRes::Infer), |this| match rhs_kind { - ConstItemRhsKind::TypeConst { rhs: Some(anon_const) } => { - this.resolve_anon_const(anon_const, AnonConstKind::ConstArg(IsRepeatExpr::No)); - } - ConstItemRhsKind::Body { rhs: Some(expr) } => { + if let Some(body) = body { + self.with_lifetime_rib(LifetimeRibKind::elided(LifetimeRes::Infer), |this| { this.with_constant_rib(IsRepeatExpr::No, ConstantHasGenerics::Yes, item, |this| { - this.visit_expr(expr) - }); - } - _ => (), - }) + this.visit_expr(body) + }) + }) + } } fn resolve_delegation( diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 0cf75fe1e2280..eebead6fc1f47 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -5,12 +5,12 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::{env, io}; -use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef}; use rustc_data_structures::sync::{ AppendOnlyVec, DynSend, DynSync, Lock, MappedReadGuard, ReadGuard, RwLock, }; +use rustc_data_structures::{Limit, flock}; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; use rustc_errors::codes::*; use rustc_errors::emitter::{DynEmitter, HumanReadableErrorType, OutputTheme, stderr_destination}; @@ -21,7 +21,6 @@ use rustc_errors::{ TerminalUrl, }; use rustc_feature::UnstableFeatures; -use rustc_hir::limit::Limit; use rustc_macros::StableHash; pub use rustc_span::def_id::StableCrateId; use rustc_span::edition::Edition; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index 45470595def19..b56a95e4fc738 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -1,11 +1,11 @@ use std::fmt; +use rustc_data_structures::Limit; use rustc_data_structures::intern::Interned; use rustc_errors::{Applicability, Diag, IntoDiagArg}; use rustc_hir as hir; use rustc_hir::def::Namespace; use rustc_hir::def_id::{CRATE_DEF_ID, DefId}; -use rustc_hir::limit::Limit; use rustc_middle::bug; use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode}; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs index a5377fc04acef..da73c3e0d687d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs @@ -1,9 +1,9 @@ use std::fmt; +use rustc_data_structures::Limit; use rustc_errors::{Diag, E0275, EmissionGuarantee, ErrorGuaranteed, struct_span_code_err}; use rustc_hir::def::Namespace; use rustc_hir::def_id::LOCAL_CRATE; -use rustc_hir::limit::Limit; use rustc_infer::traits::{Obligation, PredicateObligation}; use rustc_middle::ty::print::{FmtPrinter, Print}; use rustc_middle::ty::{self, TyCtxt, Upcast}; diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 4c2c92ebc5072..8d5d8f26f9dce 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -6,7 +6,7 @@ use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::{ FromSolverError, PredicateObligation, PredicateObligations, TraitEngine, }; -use rustc_middle::ty::{self, TyCtxt, TyVid, TypeVisitableExt, TypingMode}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt, TypingMode}; use rustc_next_trait_solver::solve::fast_path::compute_goal_fast_path; use rustc_next_trait_solver::solve::{ GoalEvaluation, GoalStalledOn, HasChanged, MaybeInfo, SolverDelegateEvalExt as _, @@ -79,33 +79,12 @@ impl<'tcx> ObligationStorage<'tcx> { obligations } - fn clone_pending_potentially_referencing_sub_root( - &self, - infcx: &InferCtxt<'tcx>, - vid: TyVid, - ) -> PredicateObligations<'tcx> { - let mut obligations: PredicateObligations<'tcx> = self - .pending - .iter() - .filter(|(_, stalled_on)| { - let Some(stalled_on) = stalled_on else { return true }; - // Don't reuse the sub-unification roots cached on `stalled_on`: - // a later sub-unification merge can have changed which root - // each stalled var belongs to, so the cached info can be stale. - // Walk `stalled_vars` and recompute the current root instead. - // - // Conservative here: if a stalled var no longer resolves to an - // infer var, some unification happened, so the goal is no longer - // stalled. Include it to be re-evaluated downstream. - stalled_on.stalled_vars.iter().filter_map(|arg| arg.as_type()).any( - |ty| match *infcx.shallow_resolve(ty).kind() { - ty::Infer(ty::TyVar(tv)) => infcx.sub_unification_table_root_var(tv) == vid, - _ => true, - }, - ) - }) - .map(|(o, _)| o.clone()) - .collect(); + fn clone_pending_filtered(&self, f: F) -> PredicateObligations<'tcx> + where + F: FnMut(&&(PredicateObligation<'tcx>, Option>>)) -> bool, + { + let mut obligations: PredicateObligations<'tcx> = + self.pending.iter().filter(f).map(|(o, _)| o.clone()).collect(); obligations.extend(self.overflowed.iter().cloned()); obligations } @@ -310,7 +289,44 @@ where if infcx.tcx.disable_trait_solver_fast_paths() { return self.obligations.clone_pending(); } - self.obligations.clone_pending_potentially_referencing_sub_root(infcx, vid) + self.obligations.clone_pending_filtered(|(_, stalled_on)| { + let Some(stalled_on) = stalled_on else { return true }; + // Don't reuse the sub-unification roots cached on `stalled_on`: + // a later sub-unification merge can have changed which root + // each stalled var belongs to, so the cached info can be stale. + // Walk `stalled_vars` and recompute the current root instead. + // + // Conservative here: if a stalled var no longer resolves to an + // infer var, some unification happened, so the goal is no longer + // stalled. Include it to be re-evaluated downstream. + stalled_on.stalled_vars.iter().filter_map(|arg| arg.as_type()).any(|ty| { + match *infcx.shallow_resolve(ty).kind() { + ty::Infer(ty::TyVar(tv)) => infcx.sub_unification_table_root_var(tv) == vid, + _ => true, + } + }) + }) + } + + fn pending_obligations_potentially_referencing_float_infer( + &self, + infcx: &InferCtxt<'tcx>, + ) -> PredicateObligations<'tcx> { + // `-Zdisable-fast-paths`: same gate as the other new-solver fast paths. + if infcx.tcx.disable_trait_solver_fast_paths() { + return self.obligations.clone_pending(); + } + + self.obligations.clone_pending_filtered(|(_, stalled_on)| { + let Some(stalled_on) = stalled_on else { return true }; + // If the stalled vars don't have float infers, the nested goals won't + // have them either. We only create float infers for user written literals. + stalled_on + .stalled_vars + .iter() + .filter_map(|arg| arg.as_type()) + .any(|ty| matches!(infcx.shallow_resolve(ty).kind(), ty::Infer(ty::FloatVar(_)))) + }) } fn drain_stalled_obligations_for_coroutines( diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 136fe09929eef..ec51304104745 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -1,9 +1,9 @@ //! Check whether a type has (potentially) non-trivial drop glue. +use rustc_data_structures::Limit; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::DefId; use rustc_hir::find_attr; -use rustc_hir::limit::Limit; use rustc_middle::bug; use rustc_middle::query::Providers; use rustc_middle::ty::util::{AlwaysRequiresDrop, needs_drop_components}; diff --git a/library/core/src/ffi/mod.rs b/library/core/src/ffi/mod.rs index 88696fe02da9d..5a36ad121cb6a 100644 --- a/library/core/src/ffi/mod.rs +++ b/library/core/src/ffi/mod.rs @@ -24,11 +24,7 @@ use crate::fmt; pub mod c_str; mod va_list; -#[unstable( - feature = "c_variadic", - issue = "44930", - reason = "the `c_variadic` feature has not been properly tested on all supported platforms" -)] +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] pub use self::va_list::{VaArgSafe, VaList}; mod primitives; diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index cf70e6b3f3177..2bfd69b1b5b02 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -2,12 +2,6 @@ //! //! Better known as "varargs". -#![unstable( - feature = "c_variadic", - issue = "44930", - reason = "the `c_variadic` feature has not been properly tested on all supported platforms" -)] - #[cfg(not(target_arch = "xtensa"))] use crate::ffi::c_void; use crate::fmt; @@ -195,8 +189,6 @@ crate::cfg_select! { /// is automatically initialized (equivalent to calling `va_start` in C). /// /// ``` -/// #![feature(c_variadic)] -/// /// use std::ffi::VaList; /// /// /// # Safety @@ -230,11 +222,13 @@ crate::cfg_select! { /// terms of layout and ABI. #[repr(transparent)] #[lang = "va_list"] +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] pub struct VaList<'a> { inner: VaListInner, _marker: PhantomCovariantLifetime<'a>, } +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for VaList<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // No need to include `_marker` in debug output. @@ -249,6 +243,7 @@ impl VaList<'_> { } } +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")] const impl<'f> Clone for VaList<'f> { /// Clone the [`VaList`], producing a second independent cursor into the variable argument list. @@ -264,6 +259,7 @@ const impl<'f> Clone for VaList<'f> { } } +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")] const impl<'f> Drop for VaList<'f> { /// Drop the [`VaList`]. @@ -316,6 +312,7 @@ const impl<'f> Drop for VaList<'f> { // types with a non-scalar layout. Inline assembly can be used to accept unsupported types in the // meantime. #[lang = "va_arg_safe"] +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] pub impl(self) unsafe trait VaArgSafe: Copy {} crate::cfg_select! { @@ -324,7 +321,9 @@ crate::cfg_select! { // // - i8 is implicitly promoted to c_int in C, and cannot implement `VaArgSafe`. // - u8 is implicitly promoted to c_uint in C, and cannot implement `VaArgSafe`. + #[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for i16 {} + #[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for u16 {} } _ => { @@ -338,6 +337,7 @@ crate::cfg_select! { crate::cfg_select! { target_arch = "avr" => { // c_double is f32 on this target. + #[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for f32 {} } _ => { @@ -347,12 +347,18 @@ crate::cfg_select! { } } +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for i32 {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for i64 {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for isize {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for u32 {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for u64 {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for usize {} // Implement `VaArgSafe` for 128-bit integers on targets where clang provides `__int128`. @@ -403,19 +409,19 @@ cfg_select! { _ => { #[repr(transparent)] #[derive(Clone, Copy)] - struct S(i32); - // When there are no actual implementations on i128, declare the c_variadic_int128 feature // on a private type so that the feature is defined on all targets. #[unstable(feature = "c_variadic_int128", issue = "155752")] - unsafe impl VaArgSafe for S {} - + struct S(i32); } } +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for f64 {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for *mut T {} +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] unsafe impl VaArgSafe for *const T {} // Check that relevant `core::ffi` types implement `VaArgSafe`. @@ -462,6 +468,7 @@ impl<'f> VaList<'f> { /// /// [`c_void`]: core::ffi::c_void #[inline] // Avoid codegen when not used to help backends that don't support VaList. + #[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_c_variadic", issue = "151787")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn next_arg(&mut self) -> T { diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs index 999bd5e63dc45..74d190b8c5eb6 100644 --- a/library/std/src/ffi/mod.rs +++ b/library/std/src/ffi/mod.rs @@ -166,12 +166,7 @@ pub mod c_str; #[stable(feature = "core_c_void", since = "1.30.0")] pub use core::ffi::c_void; -#[unstable( - feature = "c_variadic", - reason = "the `c_variadic` feature has not been properly tested on \ - all supported platforms", - issue = "44930" -)] +#[stable(feature = "c_variadic", since = "CURRENT_RUSTC_VERSION")] pub use core::ffi::{VaArgSafe, VaList}; #[stable(feature = "core_ffi_c", since = "1.64.0")] pub use core::ffi::{ diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index cc1b37313cba9..e1061af1e7d6d 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -427,7 +427,6 @@ // Only for re-exporting: // tidy-alphabetical-start #![feature(async_iterator)] -#![feature(c_variadic)] #![feature(cfg_accessible)] #![feature(cfg_eval)] #![feature(concat_bytes)] diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 9299a47c70c57..df3fb001e5bc5 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -1399,8 +1399,8 @@ impl Step for RustcBook { /// "rustbook" is used to convert it to HTML. fn run(self, builder: &Builder<'_>) { // FIXME: Temporary workaround for https://github.com/rust-lang/rust/issues/158378 - #[cfg(not(test))] // So this check doesn't affect the bootstrap tests - if self.target == "i686-pc-windows-msvc" { + // Make sure this workaround doesn't break unit tests on the affected host. + if cfg!(not(test)) && self.target == "i686-pc-windows-msvc" { eprintln!("WARNING: Skipping rustc book build to work around #158378"); return; } diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs index 34da87a8d1cef..992279fe1e133 100644 --- a/src/bootstrap/src/core/build_steps/gcc.rs +++ b/src/bootstrap/src/core/build_steps/gcc.rs @@ -13,6 +13,8 @@ use std::fs; use std::path::{Path, PathBuf}; use std::sync::OnceLock; +use build_helper::git::PathFreshness; + use crate::core::builder::{Builder, Cargo, Kind, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash}; @@ -135,9 +137,11 @@ pub enum GccBuildStatus { /// Tries to download GCC from CI if it is enabled and GCC artifacts /// are available for the given target. /// Returns a path to the libgccjit.so file. -#[cfg(not(test))] fn try_download_gcc(builder: &Builder<'_>, target_pair: GccTargetPair) -> Option { - use build_helper::git::PathFreshness; + // Don't actually download GCC during unit tests. + if cfg!(test) { + return None; + } // Try to download GCC from CI if configured and available if !matches!(builder.config.gcc_ci_mode, crate::core::config::GccCiMode::DownloadFromCi) { @@ -194,11 +198,6 @@ fn try_download_gcc(builder: &Builder<'_>, target_pair: GccTargetPair) -> Option } } -#[cfg(test)] -fn try_download_gcc(_builder: &Builder<'_>, _target_pair: GccTargetPair) -> Option { - None -} - /// This returns information about whether GCC should be built or if it's already built. /// It transparently handles downloading GCC from CI if needed. /// @@ -367,15 +366,13 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) { } /// The absolute path to the downloaded GCC artifacts. -#[cfg(not(test))] fn ci_gcc_root(config: &crate::Config, target: TargetSelection) -> PathBuf { config.out.join(target).join("ci-gcc") } /// Detect whether GCC sources have been modified locally or not. -#[cfg(not(test))] fn detect_gcc_freshness(config: &crate::Config, is_git: bool) -> build_helper::git::PathFreshness { - use build_helper::git::PathFreshness; + assert!(cfg!(not(test)), "unit tests shouldn't care about GCC freshness"); if is_git { config.check_path_modifications(&["src/gcc", "src/bootstrap/download-ci-gcc-stamp"]) diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 572df47d3a62c..0a13bf5d487b3 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -200,8 +200,9 @@ pub const LLVM_INVALIDATION_PATHS: &[&str] = &[ ]; /// Detect whether LLVM sources have been modified locally or not. -#[cfg_attr(test, expect(dead_code))] pub(crate) fn detect_llvm_freshness(config: &Config, is_git: bool) -> PathFreshness { + assert!(cfg!(not(test)), "unit tests shouldn't care about LLVM freshness"); + if is_git { config.check_path_modifications(LLVM_INVALIDATION_PATHS) } else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) { diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 3318575e1f0e5..a6ecdea06623f 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -1235,7 +1235,6 @@ impl Step for LlvmBitcodeLinker { } #[derive(Debug, Clone, Hash, PartialEq, Eq)] -#[cfg_attr(test, expect(dead_code))] pub struct LibcxxVersionTool { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index fd4a3af74a2be..55f287fa1f8e2 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -57,7 +57,6 @@ use crate::core::download::{ }; use crate::utils::channel; use crate::utils::exec::{ExecutionContext, command}; -#[cfg_attr(test, expect(unused_imports))] use crate::utils::helpers::{exe, fail, get_host_target}; use crate::{ CodegenBackendKind, GitInfo, OnceLock, TargetSelection, check_ci_llvm, exit, helpers, t, @@ -1274,8 +1273,7 @@ impl Config { } // CI should always run stage 2 builds, unless it specifically states otherwise - #[cfg(not(test))] - if flags_stage.is_none() && ci_env.is_running_in_ci() { + if cfg!(not(test)) && flags_stage.is_none() && ci_env.is_running_in_ci() { match flags_cmd { Subcommand::Test { .. } | Subcommand::Miri { .. } @@ -2305,24 +2303,14 @@ fn postprocess_toml( toml.merge(None, &mut Default::default(), override_toml, ReplaceOpt::Override); } -#[cfg(test)] -pub fn check_stage0_version( - _program_path: &Path, - _component_name: &'static str, - _src_dir: &Path, - _exec_ctx: &ExecutionContext, -) { -} - /// check rustc/cargo version is same or lower with 1 apart from the building one -#[cfg(not(test))] pub fn check_stage0_version( program_path: &Path, component_name: &'static str, src_dir: &Path, exec_ctx: &ExecutionContext, ) { - if exec_ctx.dry_run() { + if cfg!(test) || exec_ctx.dry_run() { return; } @@ -2515,8 +2503,9 @@ pub fn parse_download_ci_llvm<'a>( } // Fetching the LLVM submodule is unnecessary for self-tests. - #[cfg(not(test))] - update_submodule(dwn_ctx, rust_info, "src/llvm-project"); + if cfg!(not(test)) { + update_submodule(dwn_ctx, rust_info, "src/llvm-project"); + } // Check for untracked changes in `src/llvm-project` and other important places. let has_changes = has_changes_from_upstream(dwn_ctx, LLVM_INVALIDATION_PATHS); @@ -2537,8 +2526,11 @@ pub fn parse_download_ci_llvm<'a>( ); } - #[cfg(not(test))] - if b && dwn_ctx.is_running_on_ci() && CiEnv::is_rust_lang_managed_ci_job() { + if cfg!(not(test)) + && b + && dwn_ctx.is_running_on_ci() + && CiEnv::is_rust_lang_managed_ci_job() + { // On rust-lang CI, we must always rebuild LLVM if there were any modifications to it panic!( "`llvm.download-ci-llvm` cannot be set to `true` on CI. Use `if-unchanged` instead." diff --git a/src/bootstrap/src/core/config/toml/llvm.rs b/src/bootstrap/src/core/config/toml/llvm.rs index 8bc6b4ef2491c..2538c591df79e 100644 --- a/src/bootstrap/src/core/config/toml/llvm.rs +++ b/src/bootstrap/src/core/config/toml/llvm.rs @@ -4,7 +4,6 @@ use serde::{Deserialize, Deserializer}; use crate::core::config::StringOrBool; -#[cfg_attr(test, expect(unused_imports))] use crate::core::config::toml::{Merge, ReplaceOpt, TomlConfig}; use crate::{HashMap, HashSet, PathBuf, define_config, exit}; @@ -46,7 +45,6 @@ define_config! { /// Compares the current `Llvm` options against those in the CI LLVM builder and detects any incompatible options. /// It does this by destructuring the `Llvm` instance to make sure every `Llvm` field is covered and not missing. -#[cfg(not(test))] pub fn check_incompatible_options_for_ci_llvm( current_config_toml: TomlConfig, ci_config_toml: TomlConfig, diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 76fd2cb0bc14b..d19c928e7c553 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -8,13 +8,16 @@ use std::sync::{Arc, Mutex, OnceLock}; use build_helper::ci::CiEnv; use build_helper::git::PathFreshness; +use build_helper::stage0_parser::VersionMetadata; use xz2::bufread::XzDecoder; +use crate::core::build_steps::llvm::detect_llvm_freshness; +use crate::core::config::toml::llvm::check_incompatible_options_for_ci_llvm; use crate::core::config::{BUILDER_CONFIG_FILENAME, TargetSelection}; use crate::utils::build_stamp::BuildStamp; use crate::utils::exec::{ExecutionContext, command}; use crate::utils::helpers::{exe, hex_encode, move_file}; -use crate::{Config, t}; +use crate::{Config, exit, t}; static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock = OnceLock::new(); @@ -243,16 +246,11 @@ impl Config { download_component(dwn_ctx, &self.out, mode, filename, prefix, key, destination); } - #[cfg(test)] - pub(crate) fn maybe_download_ci_llvm(&self) {} - - #[cfg(not(test))] pub(crate) fn maybe_download_ci_llvm(&self) { - use build_helper::git::PathFreshness; - - use crate::core::build_steps::llvm::detect_llvm_freshness; - use crate::core::config::toml::llvm::check_incompatible_options_for_ci_llvm; - use crate::exit; + // Never try to download CI LLVM during unit tests. + if cfg!(test) { + return; + } if !self.llvm_from_ci { return; @@ -334,8 +332,10 @@ impl Config { }; } - #[cfg(not(test))] fn download_ci_llvm(&self, llvm_sha: &str) { + // For unit tests, downloading should have been blocked by `maybe_download_ci_llvm`. + assert!(cfg!(not(test)), "unit tests shouldn't be downloading CI LLVM"); + let llvm_assertions = self.llvm_assertions; let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}"); @@ -503,22 +503,16 @@ pub(crate) fn is_download_ci_available(target_triple: &str, llvm_assertions: boo } } -#[cfg(test)] -pub(crate) fn maybe_download_rustfmt<'a>( - _dwn_ctx: impl AsRef>, - _out: &Path, -) -> Option { - Some(PathBuf::new()) -} - /// NOTE: rustfmt is a completely different toolchain than the bootstrap compiler, so it can't /// reuse target directories or artifacts -#[cfg(not(test))] pub(crate) fn maybe_download_rustfmt<'a>( dwn_ctx: impl AsRef>, out: &Path, ) -> Option { - use build_helper::stage0_parser::VersionMetadata; + // Don't actually download rustfmt during unit tests. + if cfg!(test) { + return Some(PathBuf::new()); + } let dwn_ctx = dwn_ctx.as_ref(); @@ -573,11 +567,12 @@ pub(crate) fn maybe_download_rustfmt<'a>( Some(rustfmt_path) } -#[cfg(test)] -pub(crate) fn download_beta_toolchain<'a>(_dwn_ctx: impl AsRef>, _out: &Path) {} - -#[cfg(not(test))] pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef>, out: &Path) { + // Don't actually download a beta toolchain during unit tests. + if cfg!(test) { + return; + } + let dwn_ctx = dwn_ctx.as_ref(); dwn_ctx.exec_ctx.do_if_verbose(|| { println!("downloading stage0 beta artifacts"); @@ -600,7 +595,6 @@ pub(crate) fn download_beta_toolchain<'a>(dwn_ctx: impl AsRef( dwn_ctx: impl AsRef>, out: &Path, @@ -611,6 +605,8 @@ fn download_toolchain<'a>( destination: &str, mode: DownloadSource, ) { + assert!(cfg!(not(test)), "unit tests shouldn't be downloading a toolchain"); + let dwn_ctx = dwn_ctx.as_ref(); let host = dwn_ctx.host_target.triple; let bin_root = out.join(host).join(sysroot); @@ -1035,6 +1031,8 @@ fn download_http_with_retries( help_on_error: &str, ) { println!("downloading {url}"); + assert!(cfg!(not(test)), "unit tests shouldn't be downloading things: {url:?}"); + // Try curl. If that fails and we are on windows, fallback to PowerShell. // options should be kept in sync with // src/bootstrap/src/core/download.rs diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 330be66ddebd6..92b1f35b64f2f 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -14,10 +14,7 @@ use std::ffi::{OsStr, OsString}; use std::path::PathBuf; use std::{env, fs}; -#[cfg(not(test))] -use crate::builder::Builder; -use crate::builder::Kind; -#[cfg(not(test))] +use crate::builder::{Builder, Kind}; use crate::core::build_steps::tool; use crate::core::config::{CompilerBuiltins, Target}; use crate::utils::exec::command; @@ -41,7 +38,6 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[ /// Minimum version threshold for libstdc++ required when using prebuilt LLVM /// from CI (with`llvm.download-ci-llvm` option). -#[cfg(not(test))] const LIBSTDCXX_MIN_VERSION_THRESHOLD: usize = 8; impl Finder { @@ -109,8 +105,11 @@ pub fn check(build: &mut Build) { } // Ensure that a compatible version of libstdc++ is available on the system when using `llvm.download-ci-llvm`. - #[cfg(not(test))] - if !build.config.dry_run() && !build.host_target.is_msvc() && build.config.llvm_from_ci { + if cfg!(not(test)) + && !build.config.dry_run() + && !build.host_target.is_msvc() + && build.config.llvm_from_ci + { let builder = Builder::new(build); let libcxx_version = builder.ensure(tool::LibcxxVersionTool { target: build.host_target }); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 5b2da5e4788c4..0035d6f3af668 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -15,6 +15,7 @@ //! //! More documentation can be found in each respective module below, and you can //! also check out the `src/bootstrap/README.md` file for more information. +#![allow(clippy::assertions_on_constants, reason = "false positive for `assert!(cfg!(..))`")] use std::cell::Cell; use std::collections::{BTreeSet, HashMap, HashSet}; diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index c36d43f0cb5a4..394e14c80a1ef 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -595,7 +595,6 @@ pub fn detail_exit(code: i32, is_test: bool) -> ! { } } -#[cfg_attr(test, expect(dead_code))] pub fn fail(s: &str) -> ! { eprintln!("\n\n{s}\n\n"); detail_exit(1, cfg!(test)); diff --git a/src/doc/unstable-book/src/language-features/c-variadic.md b/src/doc/unstable-book/src/language-features/c-variadic.md deleted file mode 100644 index 72980ea91ba28..0000000000000 --- a/src/doc/unstable-book/src/language-features/c-variadic.md +++ /dev/null @@ -1,24 +0,0 @@ -# `c_variadic` - -The tracking issue for this feature is: [#44930] - -[#44930]: https://github.com/rust-lang/rust/issues/44930 - ------------------------- - -The `c_variadic` language feature enables C-variadic functions to be -defined in Rust. They may be called both from within Rust and via FFI. - -## Examples - -```rust -#![feature(c_variadic)] - -pub unsafe extern "C" fn add(n: usize, mut args: ...) -> usize { - let mut sum = 0; - for _ in 0..n { - sum += args.next_arg::(); - } - sum -} -``` diff --git a/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs b/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs index 07c3d2e2f0ffe..85631d5265505 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs @@ -189,7 +189,7 @@ fn eq_expr(l: &Expr, r: &Expr) -> bool { && eq_expr(&lf.iter, &rf.iter) && eq_block(&lf.body, &rf.body) && lf.kind == rf.kind - } + }, (Loop(lt, ll, _), Loop(rt, rl, _)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_block(lt, rt), (Block(lb, ll), Block(rb, rl)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_block(lb, rb), (TryBlock(lb, lt), TryBlock(rb, rt)) => eq_block(lb, rb) && both(lt.as_deref(), rt.as_deref(), eq_ty), @@ -350,7 +350,8 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { ident: li, generics: lg, ty: lt, - rhs_kind: lb, + body: lb, + kind: lk, define_opaque: _, }), Const(box ConstItem { @@ -358,7 +359,9 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { ident: ri, generics: rg, ty: rt, - rhs_kind: rb, + + body: rb, + kind: rk, define_opaque: _, }), ) => { @@ -366,7 +369,8 @@ fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { && eq_id(*li, *ri) && eq_generics(lg, rg) && eq_ty(lt, rt) - && both(Some(lb), Some(rb), eq_const_item_rhs) + && lk == rk + && both(lb.as_deref(), rb.as_deref(), eq_expr) }, ( Fn(box ast::Fn { @@ -615,7 +619,8 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { ident: li, generics: lg, ty: lt, - rhs_kind: lb, + body: lb, + kind: lk, define_opaque: _, }), Const(box ConstItem { @@ -623,7 +628,8 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { ident: ri, generics: rg, ty: rt, - rhs_kind: rb, + body: rb, + kind: rk, define_opaque: _, }), ) => { @@ -631,7 +637,8 @@ fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { && eq_id(*li, *ri) && eq_generics(lg, rg) && eq_ty(lt, rt) - && both(Some(lb), Some(rb), eq_const_item_rhs) + && lk == rk + && both(lb.as_deref(), rb.as_deref(), eq_expr) }, ( Fn(box ast::Fn { @@ -791,21 +798,6 @@ fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool { eq_expr(&l.value, &r.value) } -fn eq_const_item_rhs(l: &ConstItemRhsKind, r: &ConstItemRhsKind) -> bool { - use ConstItemRhsKind::*; - match (l, r) { - (TypeConst { rhs: Some(l) }, TypeConst { rhs: Some(r) }) => eq_anon_const(l, r), - (TypeConst { rhs: None }, TypeConst { rhs: None }) | (Body { rhs: None }, Body { rhs: None }) => true, - (Body { rhs: Some(l) }, Body { rhs: Some(r) }) => eq_expr(l, r), - (TypeConst { rhs: Some(..) }, TypeConst { rhs: None }) - | (TypeConst { rhs: None }, TypeConst { rhs: Some(..) }) - | (Body { rhs: None }, Body { rhs: Some(..) }) - | (Body { rhs: Some(..) }, Body { rhs: None }) - | (TypeConst { .. }, Body { .. }) - | (Body { .. }, TypeConst { .. }) => false, - } -} - fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool { use UseTreeKind::*; match (l, r) { @@ -1003,9 +995,7 @@ fn eq_attr(l: &Attribute, r: &Attribute) -> bool { l.style == r.style && match (&l.kind, &r.kind) { (DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2, - (Normal(l), Normal(r)) => { - eq_path(&l.item.path, &r.item.path) && eq_attr_args(&l.item.args, &r.item.args) - }, + (Normal(l), Normal(r)) => eq_path(&l.item.path, &r.item.path) && eq_attr_args(&l.item.args, &r.item.args), (Synthetic(..), _) | (_, Synthetic(..)) => unreachable!(), _ => false, } diff --git a/src/tools/compiletest/src/cli.rs b/src/tools/compiletest/src/cli.rs index 8a69360575d7a..1325afc2adaa3 100644 --- a/src/tools/compiletest/src/cli.rs +++ b/src/tools/compiletest/src/cli.rs @@ -8,9 +8,7 @@ use std::sync::{Arc, OnceLock}; use camino::{Utf8Path, Utf8PathBuf}; use clap::Parser; -use crate::common::{ - CodegenBackend, CompareMode, Config, Debugger, ForcePassMode, TestMode, TestSuite, -}; +use crate::common::{CodegenBackend, CompareMode, Config, ForcePassMode, TestMode, TestSuite}; use crate::edition::Edition; use crate::{debuggers, directives, early_config_check, run_tests}; @@ -200,9 +198,6 @@ struct Args { /// Default Rust edition. #[arg(long)] edition: Option, - /// Only test a specific debugger in debuginfo tests. - #[arg(long)] - debugger: Option, /// The codegen backend currently used. #[arg(long)] default_codegen_backend: Option, @@ -422,11 +417,6 @@ pub(crate) fn parse_config(args: Vec) -> Config { mode, suite: args.suite, - debugger: args.debugger.map(|debugger| { - debugger - .parse::() - .unwrap_or_else(|_| panic!("unknown `--debugger` option `{debugger}` given")) - }), run_ignored: args.ignored, with_rustc_debug_assertions: args.with_rustc_debug_assertions, with_std_debug_assertions: args.with_std_debug_assertions, diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 0cb8ac6038357..82bfa80b2b9c0 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -11,6 +11,7 @@ use semver::Version; use crate::debuggers::LldbVersion; use crate::edition::Edition; +use crate::executor::TestVariant; use crate::fatal; use crate::util::{Utf8PathBufExt, add_dylib_path, string_enum}; @@ -453,18 +454,6 @@ pub(crate) struct Config { /// [`TestMode::CoverageMap`]. pub(crate) suite: TestSuite, - /// When specified, **only** the specified [`Debugger`] will be used to run against the - /// `tests/debuginfo` test suite. When unspecified, `compiletest` will attempt to find all three - /// of {`lldb`, `cdb`, `gdb`} implicitly, and then try to run the `debuginfo` test suite against - /// all three debuggers. - /// - /// FIXME: this implicit behavior is really nasty, in that it makes it hard for the user to - /// control *which* debugger(s) are available and used to run the debuginfo test suite. We - /// should have `bootstrap` allow the user to *explicitly* configure the debuggers, and *not* - /// try to implicitly discover some random debugger from the user environment. This makes the - /// debuginfo test suite particularly hard to work with. - pub(crate) debugger: Option, - /// Run ignored tests *unconditionally*, overriding their ignore reason. /// /// FIXME: this is wired up through the test execution logic, but **not** accessible from @@ -1307,13 +1296,13 @@ pub(crate) fn output_relative_path(config: &Config, relative_dir: &Utf8Path) -> pub(crate) fn output_testname_unique( config: &Config, testpaths: &TestPaths, - revision: Option<&str>, + variant: &TestVariant, ) -> Utf8PathBuf { let mode = config.compare_mode.as_ref().map_or("", |m| m.to_str()); - let debugger = config.debugger.as_ref().map_or("", |m| m.to_str()); + let debugger = variant.debugger.as_ref().map_or("", |m| m.to_str()); Utf8PathBuf::from(&testpaths.file.file_stem().unwrap()) .with_extra_extension(config.mode.output_dir_disambiguator()) - .with_extra_extension(revision.unwrap_or("")) + .with_extra_extension(variant.revision().unwrap_or("")) .with_extra_extension(mode) .with_extra_extension(debugger) } @@ -1324,10 +1313,10 @@ pub(crate) fn output_testname_unique( pub(crate) fn output_base_dir( config: &Config, testpaths: &TestPaths, - revision: Option<&str>, + variant: &TestVariant, ) -> Utf8PathBuf { output_relative_path(config, &testpaths.relative_dir) - .join(output_testname_unique(config, testpaths, revision)) + .join(output_testname_unique(config, testpaths, variant)) } /// Absolute path to the base filename used as output for the given @@ -1336,9 +1325,9 @@ pub(crate) fn output_base_dir( pub(crate) fn output_base_name( config: &Config, testpaths: &TestPaths, - revision: Option<&str>, + variant: &TestVariant, ) -> Utf8PathBuf { - output_base_dir(config, testpaths, revision).join(testpaths.file.file_stem().unwrap()) + output_base_dir(config, testpaths, variant).join(testpaths.file.file_stem().unwrap()) } /// Absolute path to the directory to use for incremental compilation. Example: @@ -1346,7 +1335,7 @@ pub(crate) fn output_base_name( pub(crate) fn incremental_dir( config: &Config, testpaths: &TestPaths, - revision: Option<&str>, + variant: &TestVariant, ) -> Utf8PathBuf { - output_base_name(config, testpaths, revision).with_extension("inc") + output_base_name(config, testpaths, variant).with_extension("inc") } diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index a6ee7e27a7232..dc10430f038ec 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -20,7 +20,7 @@ use crate::directives::line::DirectiveLine; use crate::directives::needs::PreparedNeedsConditions; use crate::edition::{Edition, parse_edition}; use crate::errors::ErrorKind; -use crate::executor::{CollectedTestDesc, ShouldFail}; +use crate::executor::{CollectedTestDesc, ShouldFail, TestVariant}; use crate::util::static_regex; use crate::{fatal, help}; @@ -892,7 +892,7 @@ pub(crate) fn make_test_description( path: &Utf8Path, filterable_path: &Utf8Path, file_directives: &FileDirectives<'_>, - test_revision: Option<&str>, + variant: &TestVariant, poisoned: &mut bool, aux_props: &mut AuxProps, ) -> CollectedTestDesc { @@ -901,25 +901,25 @@ pub(crate) fn make_test_description( // Perform a per-file (rather than per-line) ignore decision to skip running debuginfo tests // if we don't have a debugger for them available. - // This is needed because we duplicate the Config once for each debugger. - if config.mode == TestMode::DebugInfo { - match &config.debugger { - Some(Debugger::Cdb) => { + // We do this to materialize debuginfo tests for each debugger and explicitly ignore + // the variants that are not supported in our environment. + if let Some(debugger) = variant.debugger.as_ref() { + match debugger { + Debugger::Cdb => { if let Some(msg) = check_cdb_support(config) { ignore_message = Some(Cow::Owned(msg)); } } - Some(Debugger::Gdb) => { + Debugger::Gdb => { if let Some(msg) = check_gdb_support(config) { ignore_message = Some(Cow::Owned(msg)); } } - Some(Debugger::Lldb) => { + Debugger::Lldb => { if let Some(msg) = check_lldb_support(config) { ignore_message = Some(Cow::Owned(msg)); } } - None => {} } } @@ -929,7 +929,7 @@ pub(crate) fn make_test_description( config, file_directives, &mut |ln @ &DirectiveLine { line_number, .. }| { - if !ln.applies_to_test_revision(test_revision) { + if !ln.applies_to_test_revision(variant.revision()) { return; } @@ -958,9 +958,9 @@ pub(crate) fn make_test_description( decision!(ignore_llvm(config, ln)); decision!(ignore_backends(config, ln)); decision!(needs_backends(config, ln)); - decision!(ignore_cdb(config, ln)); - decision!(ignore_gdb(config, ln)); - decision!(ignore_lldb(config, ln)); + decision!(ignore_cdb(config, variant, ln)); + decision!(ignore_gdb(config, variant, ln)); + decision!(ignore_lldb(config, variant, ln)); decision!(ignore_parallel_frontend(config, ln)); if config.target == "wasm32-unknown-unknown" @@ -1019,9 +1019,17 @@ fn check_lldb_support(config: &Config) -> Option { if config.lldb.is_none() { Some("lldb is not available".to_string()) } else { None } } -fn ignore_cdb(config: &Config, line: &DirectiveLine<'_>) -> IgnoreDecision { - if config.debugger != Some(Debugger::Cdb) { - return IgnoreDecision::Continue; +fn ignore_cdb(config: &Config, variant: &TestVariant, line: &DirectiveLine<'_>) -> IgnoreDecision { + if variant.debugger != Some(Debugger::Cdb) { + return if line.name == "only-cdb" { + IgnoreDecision::Ignore { reason: "debugger is not cdb".to_string() } + } else { + IgnoreDecision::Continue + }; + } + + if line.name == "ignore-cdb" { + return IgnoreDecision::Ignore { reason: "debugger is cdb".to_string() }; } if let Some(actual_version) = config.cdb_version { @@ -1044,9 +1052,17 @@ fn ignore_cdb(config: &Config, line: &DirectiveLine<'_>) -> IgnoreDecision { IgnoreDecision::Continue } -fn ignore_gdb(config: &Config, line: &DirectiveLine<'_>) -> IgnoreDecision { - if config.debugger != Some(Debugger::Gdb) { - return IgnoreDecision::Continue; +fn ignore_gdb(config: &Config, variant: &TestVariant, line: &DirectiveLine<'_>) -> IgnoreDecision { + if variant.debugger != Some(Debugger::Gdb) { + return if line.name == "only-gdb" { + IgnoreDecision::Ignore { reason: "debugger is not gdb".to_string() } + } else { + IgnoreDecision::Continue + }; + } + + if line.name == "ignore-gdb" { + return IgnoreDecision::Ignore { reason: "debugger is gdb".to_string() }; } if let Some(actual_version) = config.gdb_version { @@ -1096,9 +1112,17 @@ fn ignore_gdb(config: &Config, line: &DirectiveLine<'_>) -> IgnoreDecision { IgnoreDecision::Continue } -fn ignore_lldb(config: &Config, line: &DirectiveLine<'_>) -> IgnoreDecision { - if config.debugger != Some(Debugger::Lldb) { - return IgnoreDecision::Continue; +fn ignore_lldb(config: &Config, variant: &TestVariant, line: &DirectiveLine<'_>) -> IgnoreDecision { + if variant.debugger != Some(Debugger::Lldb) { + return if line.name == "only-lldb" { + IgnoreDecision::Ignore { reason: "debugger is not lldb".to_string() } + } else { + IgnoreDecision::Continue + }; + } + + if line.name == "ignore-lldb" { + return IgnoreDecision::Ignore { reason: "debugger is lldb".to_string() }; } if let Some(actual_version) = &config.lldb_version { diff --git a/src/tools/compiletest/src/directives/cfg.rs b/src/tools/compiletest/src/directives/cfg.rs index 25ebb86ad28d3..b9036462f3447 100644 --- a/src/tools/compiletest/src/directives/cfg.rs +++ b/src/tools/compiletest/src/directives/cfg.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; use std::sync::{Arc, LazyLock}; -use crate::common::{CompareMode, Config, Debugger}; +use crate::common::{CompareMode, Config}; use crate::directives::{DirectiveLine, IgnoreDecision}; const EXTRA_ARCHS: &[&str] = &["spirv"]; @@ -9,17 +9,33 @@ const EXTRA_ARCHS: &[&str] = &["spirv"]; const EXTERNAL_IGNORES_LIST: &[&str] = &[ // tidy-alphabetical-start "ignore-backends", + "ignore-cdb", + "ignore-gdb", "ignore-gdb-version", + "ignore-lldb", "ignore-llvm-version", "ignore-parallel-frontend", // tidy-alphabetical-end ]; +const EXTERNAL_ONLY_LIST: &[&str] = &[ + // tidy-alphabetical-start + "only-cdb", + "only-gdb", + "only-lldb", + // tidy-alphabetical-end +]; + /// Directive names that begin with `ignore-`, but are disregarded by this /// module because they are handled elsewhere. pub(crate) static EXTERNAL_IGNORES_SET: LazyLock> = LazyLock::new(|| EXTERNAL_IGNORES_LIST.iter().copied().collect()); +/// Directive names that begin with `only-`, but are disregarded by this +/// module because they are handled elsewhere. +pub(crate) static EXTERNAL_ONLY_SET: LazyLock> = + LazyLock::new(|| EXTERNAL_ONLY_LIST.iter().copied().collect()); + pub(super) fn handle_ignore( conditions: &PreparedConditions, line: &DirectiveLine<'_>, @@ -75,6 +91,8 @@ fn parse_cfg_name_directive<'a>( if prefix == "ignore-" && EXTERNAL_IGNORES_SET.contains(line.name) { return ParsedNameDirective::not_handled_here(); + } else if prefix == "only-" && EXTERNAL_ONLY_SET.contains(line.name) { + return ParsedNameDirective::not_handled_here(); } // FIXME(Zalathar): This currently allows either a space or a colon, and @@ -209,14 +227,6 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions { "when std is built with remapping of debuginfo", ); - for &debugger in Debugger::STR_VARIANTS { - builder.cond( - debugger, - Some(debugger) == config.debugger.as_ref().map(Debugger::to_str), - &format!("when the debugger is {debugger}"), - ); - } - for &compare_mode in CompareMode::STR_VARIANTS { builder.cond( &format!("compare-mode-{compare_mode}"), diff --git a/src/tools/compiletest/src/directives/tests.rs b/src/tools/compiletest/src/directives/tests.rs index 8ef03d1ac1468..992ace208a42f 100644 --- a/src/tools/compiletest/src/directives/tests.rs +++ b/src/tools/compiletest/src/directives/tests.rs @@ -9,7 +9,7 @@ use crate::directives::{ FileDirectives, KNOWN_DIRECTIVE_NAMES_SET, LineNumber, extract_llvm_version, extract_version_range, line_directive, parse_edition, parse_normalize_rule, }; -use crate::executor::{CollectedTestDesc, ShouldFail}; +use crate::executor::{CollectedTestDesc, ShouldFail, TestVariant}; /// All directive handlers should have a name that is also in `KNOWN_DIRECTIVE_NAMES_SET`. #[test] @@ -46,11 +46,14 @@ fn make_test_description( filterable_path: &Utf8Path, file_contents: &str, revision: Option<&str>, + debugger: Option, ) -> CollectedTestDesc { let cache = DirectivesCache::load(config); let mut poisoned = false; let file_directives = FileDirectives::from_file_contents(path, file_contents); + let variant = TestVariant { revision: revision.map(str::to_owned), debugger }; + let mut aux_props = AuxProps::default(); let test = crate::directives::make_test_description( config, @@ -59,7 +62,7 @@ fn make_test_description( path, filterable_path, &file_directives, - revision, + &variant, &mut poisoned, &mut aux_props, ); @@ -283,7 +286,14 @@ fn parse_early_props(config: &Config, contents: &str) -> EarlyProps { fn check_ignore(config: &Config, contents: &str) -> bool { let tn = String::new(); let p = Utf8Path::new("a.rs"); - let d = make_test_description(&config, tn, p, p, contents, None); + let d = make_test_description(&config, tn, p, p, contents, None, None); + d.is_ignored() +} + +fn check_ignore_debugger(config: &Config, contents: &str, debugger: Option) -> bool { + let tn = String::new(); + let p = Utf8Path::new("a.rs"); + let d = make_test_description(&config, tn, p, p, contents, None, debugger); d.is_ignored() } @@ -293,9 +303,9 @@ fn should_fail() { let tn = String::new(); let p = Utf8Path::new("a.rs"); - let d = make_test_description(&config, tn.clone(), p, p, "", None); + let d = make_test_description(&config, tn.clone(), p, p, "", None, None); assert_eq!(d.should_fail, ShouldFail::No); - let d = make_test_description(&config, tn, p, p, "//@ should-fail", None); + let d = make_test_description(&config, tn, p, p, "//@ should-fail", None, None); assert_eq!(d.should_fail, ShouldFail::Yes); } @@ -449,18 +459,11 @@ fn cross_compile() { #[test] fn debugger() { - let mut config = cfg().build(); - config.debugger = None; - assert!(!check_ignore(&config, "//@ ignore-cdb")); - - config.debugger = Some(Debugger::Cdb); - assert!(check_ignore(&config, "//@ ignore-cdb")); - - config.debugger = Some(Debugger::Gdb); - assert!(check_ignore(&config, "//@ ignore-gdb")); - - config.debugger = Some(Debugger::Lldb); - assert!(check_ignore(&config, "//@ ignore-lldb")); + let config = cfg().build(); + assert!(!check_ignore_debugger(&config, "//@ ignore-cdb", None)); + assert!(check_ignore_debugger(&config, "//@ ignore-cdb", Some(Debugger::Cdb))); + assert!(check_ignore_debugger(&config, "//@ ignore-gdb", Some(Debugger::Gdb))); + assert!(check_ignore_debugger(&config, "//@ ignore-lldb", Some(Debugger::Lldb))); } #[test] diff --git a/src/tools/compiletest/src/executor.rs b/src/tools/compiletest/src/executor.rs index 78303438b3a37..d094363d5e498 100644 --- a/src/tools/compiletest/src/executor.rs +++ b/src/tools/compiletest/src/executor.rs @@ -14,7 +14,7 @@ use std::{env, hint, mem, panic, thread}; use camino::Utf8PathBuf; -use crate::common::{Config, TestPaths}; +use crate::common::{Config, Debugger, TestPaths}; use crate::output_capture::{self, ConsoleOut}; use crate::panic_hook; @@ -111,7 +111,7 @@ fn spawn_test_thread( id, config: Arc::clone(&test.config), testpaths: test.testpaths.clone(), - revision: test.revision.clone(), + variant: test.variant.clone(), should_fail: test.desc.should_fail, completion_sender, }; @@ -126,7 +126,7 @@ struct TestThreadArgs { config: Arc, testpaths: TestPaths, - revision: Option, + variant: TestVariant, should_fail: ShouldFail, completion_sender: mpsc::Sender, @@ -152,13 +152,7 @@ fn test_thread_main(args: TestThreadArgs) { // require a major overhaul of error handling in the test runners. let panic_payload = panic::catch_unwind(|| { __rust_begin_short_backtrace(|| { - crate::runtest::run( - &args.config, - stdout, - stderr, - &args.testpaths, - args.revision.as_deref(), - ); + crate::runtest::run(&args.config, stdout, stderr, &args.testpaths, &args.variant); }); }) .err(); @@ -324,12 +318,25 @@ fn get_concurrency() -> usize { } } +/// Data related to a specific variant of a test. +#[derive(Clone, Debug)] +pub(crate) struct TestVariant { + pub(crate) revision: Option, + pub(crate) debugger: Option, +} + +impl TestVariant { + pub(crate) fn revision(&self) -> Option<&str> { + self.revision.as_deref() + } +} + /// Information that was historically needed to create a libtest `TestDescAndFn`. pub(crate) struct CollectedTest { pub(crate) desc: CollectedTestDesc, pub(crate) config: Arc, pub(crate) testpaths: TestPaths, - pub(crate) revision: Option, + pub(crate) variant: TestVariant, } /// Information that was historically needed to create a libtest `TestDesc`. diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index b7beaa6f18c2c..70408f13a5cf8 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -43,7 +43,7 @@ use crate::common::{ output_base_dir, output_relative_path, }; use crate::directives::{AuxProps, DirectivesCache, FileDirectives}; -use crate::executor::CollectedTest; +use crate::executor::{CollectedTest, TestVariant}; /// Called by `main` after the config has been parsed. fn run_tests(config: Arc) { @@ -76,43 +76,31 @@ fn run_tests(config: Arc) { // SAFETY: at this point we're still single-threaded. unsafe { env::set_var("__COMPAT_LAYER", "RunAsInvoker") }; - let mut configs = Vec::new(); + // Debugging emscripten code doesn't make sense today + let ignore_tests = config.mode == TestMode::DebugInfo && config.target.contains("emscripten"); + if let TestMode::DebugInfo = config.mode { - // Debugging emscripten code doesn't make sense today - if !config.target.contains("emscripten") { - // FIXME: ideally, we would just have one config, and then have some mechanism of - // generating multiple variants of a test, one for each debugger (something like - // debuginfo revisions). But for now, we just create three configs. - configs.extend([ - Arc::new(Config { debugger: Some(Debugger::Cdb), ..config.as_ref().clone() }), - Arc::new(Config { debugger: Some(Debugger::Gdb), ..config.as_ref().clone() }), - Arc::new(Config { debugger: Some(Debugger::Lldb), ..config.as_ref().clone() }), - ]); - - // FIXME: this should ideally happen somewhere else.. - if config.target.contains("android") { - println!("{} debug-info test uses tcp 5039 port. please reserve it", config.target); - - // android debug-info test uses remote debugger so, we test 1 thread - // at once as they're all sharing the same TCP port to communicate - // over. - // - // we should figure out how to lift this restriction! (run them all - // on different ports allocated dynamically). - // - // SAFETY: at this point we are still single-threaded. - unsafe { env::set_var("RUST_TEST_THREADS", "1") }; - } + // FIXME: this should ideally happen somewhere else.. + if config.target.contains("android") { + println!("{} debug-info test uses tcp 5039 port. please reserve it", config.target); + + // android debug-info test uses remote debugger so, we test 1 thread + // at once as they're all sharing the same TCP port to communicate + // over. + // + // we should figure out how to lift this restriction! (run them all + // on different ports allocated dynamically). + // + // SAFETY: at this point we are still single-threaded. + unsafe { env::set_var("RUST_TEST_THREADS", "1") }; } - } else { - configs.push(config.clone()); }; // Discover all of the tests in the test suite directory, and build a `CollectedTest` // structure for each test (or each revision of a multi-revision test). let mut tests = Vec::new(); - for c in configs { - tests.extend(collect_and_make_tests(c)); + if !ignore_tests { + tests.extend(collect_and_make_tests(config.clone())); } tests.sort_by(|a, b| Ord::cmp(&a.desc.name, &b.desc.name)); @@ -446,56 +434,68 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te early_props.revisions.iter().map(|r| Some(r.as_str())).collect() }; - // For each revision (or the sole dummy revision), create and append a - // `CollectedTest` that can be handed over to the test executor. - collector.tests.extend(revisions.into_iter().map(|revision| { - // Create a test name and description to hand over to the executor. - let (test_name, filterable_path) = - make_test_name_and_filterable_path(&cx.config, testpaths, revision); - - // While scanning for ignore/only/needs directives, also collect aux - // paths for up-to-date checking. - let mut aux_props = AuxProps::default(); - - // Create a description struct for the test/revision. - // This is where `ignore-*`/`only-*`/`needs-*` directives are handled, - // because they historically needed to set the libtest ignored flag. - let mut desc = make_test_description( - &cx.config, - &cx.cache, - test_name, - &test_path, - &filterable_path, - &file_directives, - revision, - &mut collector.poisoned, - &mut aux_props, - ); + // For debuginfo tests, we have to run them once for each debugger. + // We thus create a cartesian product of each revision and each supported debugger here. + let debuggers = if cx.config.mode == TestMode::DebugInfo { + vec![Some(Debugger::Cdb), Some(Debugger::Gdb), Some(Debugger::Lldb)] + } else { + vec![None] + }; - // If a test's inputs haven't changed since the last time it ran, - // mark it as ignored so that the executor will skip it. - if !desc.is_ignored() - && !cx.config.force_rerun - && is_up_to_date(cx, testpaths, &aux_props, revision) - { - // Keep this in sync with the "up-to-date" message detected by bootstrap. - // FIXME(Zalathar): Now that we are no longer tied to libtest, we could - // find a less fragile way to communicate this status to bootstrap. - desc.ignore_message = Some("up-to-date".into()); - } + // For each revision (or the sole dummy revision) and each debugger, create and append a + // `CollectedTest` that can be handed over to the test executor. + for debugger in debuggers { + collector.tests.extend(revisions.iter().map(|&revision| { + let revision = revision.map(str::to_owned); + let variant = TestVariant { revision, debugger }; + + // Create a test name and description to hand over to the executor. + let (test_name, filterable_path) = + make_test_name_and_filterable_path(&cx.config, testpaths, &variant); + + // While scanning for ignore/only/needs directives, also collect aux + // paths for up-to-date checking. + let mut aux_props = AuxProps::default(); + + // Create a description struct for the test/revision. + // This is where `ignore-*`/`only-*`/`needs-*` directives are handled, + // because they historically needed to set the libtest ignored flag. + let mut desc = make_test_description( + &cx.config, + &cx.cache, + test_name, + &test_path, + &filterable_path, + &file_directives, + &variant, + &mut collector.poisoned, + &mut aux_props, + ); + + // If a test's inputs haven't changed since the last time it ran, + // mark it as ignored so that the executor will skip it. + if !desc.is_ignored() + && !cx.config.force_rerun + && is_up_to_date(cx, testpaths, &aux_props, &variant) + { + // Keep this in sync with the "up-to-date" message detected by bootstrap. + // FIXME(Zalathar): Now that we are no longer tied to libtest, we could + // find a less fragile way to communicate this status to bootstrap. + desc.ignore_message = Some("up-to-date".into()); + } - let config = Arc::clone(&cx.config); - let testpaths = testpaths.clone(); - let revision = revision.map(str::to_owned); + let config = Arc::clone(&cx.config); + let testpaths = testpaths.clone(); - CollectedTest { desc, config, testpaths, revision } - })); + CollectedTest { desc, config, testpaths, variant } + })); + } } /// The path of the `stamp` file that gets created or updated whenever a /// particular test completes successfully. -fn stamp_file_path(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Utf8PathBuf { - output_base_dir(config, testpaths, revision).join("stamp") +fn stamp_file_path(config: &Config, testpaths: &TestPaths, variant: &TestVariant) -> Utf8PathBuf { + output_base_dir(config, testpaths, variant).join("stamp") } /// Returns a list of files that, if modified, would cause this test to no @@ -552,9 +552,9 @@ fn is_up_to_date( cx: &TestCollectorCx, testpaths: &TestPaths, aux_props: &AuxProps, - revision: Option<&str>, + variant: &TestVariant, ) -> bool { - let stamp_file_path = stamp_file_path(&cx.config, testpaths, revision); + let stamp_file_path = stamp_file_path(&cx.config, testpaths, variant); // Check the config hash inside the stamp file. let contents = match fs::read_to_string(&stamp_file_path) { Ok(f) => f, @@ -562,7 +562,7 @@ fn is_up_to_date( // The test hasn't succeeded yet, so it is not up-to-date. Err(_) => return false, }; - let expected_hash = runtest::compute_stamp_hash(&cx.config); + let expected_hash = runtest::compute_stamp_hash(&cx.config, variant); if contents != expected_hash { // Some part of compiletest configuration has changed since the test // last succeeded, so it is not up-to-date. @@ -572,7 +572,7 @@ fn is_up_to_date( // Check the timestamp of the stamp file against the last modified time // of all files known to be relevant to the test. let mut inputs_stamp = cx.common_inputs_stamp.clone(); - for path in files_related_to_test(&cx.config, testpaths, aux_props, revision) { + for path in files_related_to_test(&cx.config, testpaths, aux_props, variant.revision()) { inputs_stamp.add_path(&path); } @@ -627,12 +627,12 @@ impl Stamp { fn make_test_name_and_filterable_path( config: &Config, testpaths: &TestPaths, - revision: Option<&str>, + variant: &TestVariant, ) -> (String, Utf8PathBuf) { // Print the name of the file, relative to the sources root. let path = testpaths.file.strip_prefix(&config.src_root).unwrap(); - let debugger = match config.debugger { - Some(d) => format!("-{}", d), + let debugger = match variant.debugger.as_ref() { + Some(d) => format!("-{d}"), None => String::new(), }; let mode_suffix = match config.compare_mode { @@ -646,7 +646,7 @@ fn make_test_name_and_filterable_path( debugger, mode_suffix, path, - revision.map_or("".to_string(), |rev| format!("#{}", rev)) + variant.revision().map_or("".to_string(), |rev| format!("#{}", rev)) ); // `path` is the full path from the repo root like, `tests/ui/foo/bar.rs`. diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4243c60001244..a4fa28e13b911 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -20,6 +20,7 @@ use crate::common::{ }; use crate::directives::{AuxCrate, TestProps}; use crate::errors::{Error, ErrorKind, load_errors}; +use crate::executor::TestVariant; use crate::output_capture::ConsoleOut; use crate::read2::{Truncated, read2_abbreviated}; use crate::runtest::compute_diff::{DiffLine, diff_by_lines, make_diff, write_diff}; @@ -111,7 +112,7 @@ pub(crate) fn run( stdout: &dyn ConsoleOut, stderr: &dyn ConsoleOut, testpaths: &TestPaths, - revision: Option<&str>, + variant: &TestVariant, ) { match &*config.target { "arm-linux-androideabi" @@ -122,15 +123,7 @@ pub(crate) fn run( panic!("android device not available"); } } - - _ => { - // FIXME: this logic seems strange as well. - - // android has its own gdb handling - if config.debugger == Some(Debugger::Gdb) && config.gdb.is_none() { - panic!("gdb not available but debuginfo gdb debuginfo test requested"); - } - } + _ => {} } if config.verbose { @@ -138,16 +131,16 @@ pub(crate) fn run( write!(stdout, "\n\n"); } debug!("running {}", testpaths.file); - let mut props = TestProps::from_file(&testpaths.file, revision, &config); + let mut props = TestProps::from_file(&testpaths.file, variant.revision(), &config); // For non-incremental (i.e. regular UI) tests, the incremental directory // takes into account the revision name, since the revisions are independent // of each other and can race. if props.incremental { - props.incremental_dir = Some(incremental_dir(&config, testpaths, revision)); + props.incremental_dir = Some(incremental_dir(&config, testpaths, variant)); } - let cx = TestCx { config: &config, stdout, stderr, props: &props, testpaths, revision }; + let cx = TestCx { config: &config, stdout, stderr, props: &props, testpaths, variant }; if let Err(e) = create_dir_all(&cx.output_base_dir()) { panic!("failed to create output base directory {}: {e}", cx.output_base_dir()); @@ -170,7 +163,10 @@ pub(crate) fn run( stderr, props: &revision_props, testpaths, - revision: Some(revision), + variant: &TestVariant { + revision: Some(revision.clone()), + debugger: variant.debugger, + }, }; rev_cx.run_revision(); } @@ -181,13 +177,13 @@ pub(crate) fn run( cx.create_stamp(); } -pub(crate) fn compute_stamp_hash(config: &Config) -> String { +pub(crate) fn compute_stamp_hash(config: &Config, variant: &TestVariant) -> String { let mut hash = DefaultHasher::new(); config.stage_id.hash(&mut hash); config.run.hash(&mut hash); config.edition.hash(&mut hash); - match config.debugger { + match variant.debugger { Some(Debugger::Cdb) => { config.cdb.hash(&mut hash); } @@ -223,7 +219,7 @@ struct TestCx<'test> { stderr: &'test dyn ConsoleOut, props: &'test TestProps, testpaths: &'test TestPaths, - revision: Option<&'test str>, + variant: &'test TestVariant, } enum ReadFrom { @@ -480,7 +476,7 @@ impl<'test> TestCx<'test> { // Otherwise the `--cfg` flag is not valid. let normalize_revision = |revision: &str| revision.to_lowercase().replace("-", "_"); - if let Some(revision) = self.revision { + if let Some(revision) = self.variant.revision() { let normalized_revision = normalize_revision(revision); let cfg_arg = ["--cfg", &normalized_revision]; let arg = format!("--cfg={normalized_revision}"); @@ -660,7 +656,7 @@ impl<'test> TestCx<'test> { /// Check `//~ KIND message` annotations. fn check_expected_errors(&self, proc_res: &ProcRes) { - let expected_errors = load_errors(&self.testpaths.file, self.revision); + let expected_errors = load_errors(&self.testpaths.file, self.variant.revision()); debug!( "check_expected_errors: expected_errors={:?} proc_res.status={:?}", expected_errors, proc_res.status @@ -988,14 +984,15 @@ impl<'test> TestCx<'test> { for rel_ab in &self.props.aux.builds { let aux_path = self.resolve_aux_path(rel_ab); - let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config); + let props_for_aux = + self.props.from_aux_file(&aux_path, self.variant.revision(), self.config); let aux_cx = TestCx { config: self.config, stdout: self.stdout, stderr: self.stderr, props: &props_for_aux, testpaths: self.testpaths, - revision: self.revision, + variant: self.variant, }; // Create the directory for the stdout/stderr files. create_dir_all(aux_cx.output_base_dir()).unwrap(); @@ -1351,7 +1348,8 @@ impl<'test> TestCx<'test> { aux_type: Option, ) -> AuxType { let aux_path = self.resolve_aux_path(source_path); - let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config); + let mut aux_props = + self.props.from_aux_file(&aux_path, self.variant.revision(), self.config); if aux_type == Some(AuxType::ProcMacro) { aux_props.force_host = true; } @@ -1369,7 +1367,7 @@ impl<'test> TestCx<'test> { stderr: self.stderr, props: &aux_props, testpaths: self.testpaths, - revision: self.revision, + variant: self.variant, }; // Create the directory for the stdout/stderr files. create_dir_all(aux_cx.output_base_dir()).unwrap(); @@ -2009,7 +2007,8 @@ impl<'test> TestCx<'test> { } fn dump_output(&self, print_output: bool, proc_name: &str, out: &str, err: &str) { - let revision = if let Some(r) = self.revision { format!("{}.", r) } else { String::new() }; + let revision = + if let Some(r) = self.variant.revision() { format!("{}.", r) } else { String::new() }; self.dump_output_file(out, &format!("{}out", revision)); self.dump_output_file(err, &format!("{}err", revision)); @@ -2066,22 +2065,26 @@ impl<'test> TestCx<'test> { /// The revision, ignored for incremental compilation since it wants all revisions in /// the same directory. - fn safe_revision(&self) -> Option<&str> { - if self.config.mode == TestMode::Incremental { None } else { self.revision } + fn variant_with_safe_revision(&self) -> TestVariant { + if self.config.mode == TestMode::Incremental { + TestVariant { revision: None, debugger: self.variant.debugger } + } else { + self.variant.clone() + } } /// Gets the absolute path to the directory where all output for the given /// test/revision should reside. /// E.g., `/path/to/build/host-tuple/test/ui/relative/testname.revision.mode/`. fn output_base_dir(&self) -> Utf8PathBuf { - output_base_dir(self.config, self.testpaths, self.safe_revision()) + output_base_dir(self.config, self.testpaths, &self.variant_with_safe_revision()) } /// Gets the absolute path to the base filename used as output for the given /// test/revision. /// E.g., `/.../relative/testname.revision.mode/testname`. fn output_base_name(&self) -> Utf8PathBuf { - output_base_name(self.config, self.testpaths, self.safe_revision()) + output_base_name(self.config, self.testpaths, &self.variant_with_safe_revision()) } /// Prints a message to (captured) stdout if `config.verbose` is true. @@ -2100,7 +2103,7 @@ impl<'test> TestCx<'test> { /// includes the revision name for tests that use revisions. #[must_use] fn error_prefix(&self) -> String { - match self.revision { + match self.variant.revision() { Some(rev) => format!("error in revision `{rev}`"), None => format!("error"), } @@ -2177,7 +2180,7 @@ impl<'test> TestCx<'test> { // TL;DR We may not want to conflate `compiletest` revisions and `FileCheck` prefixes. // HACK: tests are allowed to use a revision name as a check prefix. - if let Some(rev) = self.revision { + if let Some(rev) = self.variant.revision() { filecheck.arg("--check-prefix").arg(rev); } @@ -2663,17 +2666,21 @@ impl<'test> TestCx<'test> { } fn expected_output_path(&self, kind: &str) -> Utf8PathBuf { - let mut path = - expected_output_path(&self.testpaths, self.revision, &self.config.compare_mode, kind); + let mut path = expected_output_path( + &self.testpaths, + self.variant.revision(), + &self.config.compare_mode, + kind, + ); if !path.exists() { if let Some(CompareMode::Polonius) = self.config.compare_mode { - path = expected_output_path(&self.testpaths, self.revision, &None, kind); + path = expected_output_path(&self.testpaths, self.variant.revision(), &None, kind); } } if !path.exists() { - path = expected_output_path(&self.testpaths, self.revision, &None, kind); + path = expected_output_path(&self.testpaths, self.variant.revision(), &None, kind); } path @@ -2712,8 +2719,12 @@ impl<'test> TestCx<'test> { actual_unnormalized: &str, expected: &str, ) -> CompareOutcome { - let expected_path = - expected_output_path(self.testpaths, self.revision, &self.config.compare_mode, stream); + let expected_path = expected_output_path( + self.testpaths, + self.variant.revision(), + &self.config.compare_mode, + stream, + ); if self.config.bless && actual.is_empty() && expected_path.exists() { self.delete_file(&expected_path); @@ -2774,7 +2785,7 @@ impl<'test> TestCx<'test> { // Write the actual output to a file in build directory. let actual_path = self .output_base_name() - .with_extra_extension(self.revision.unwrap_or("")) + .with_extra_extension(self.variant.revision().unwrap_or("")) .with_extra_extension( self.config.compare_mode.as_ref().map(|cm| cm.to_str()).unwrap_or(""), ) @@ -2802,7 +2813,7 @@ impl<'test> TestCx<'test> { } else { // Delete non-revision .stderr/.stdout file if revisions are used. // Without this, we'd just generate the new files and leave the old files around. - if self.revision.is_some() { + if self.variant.revision().is_some() { let old = expected_output_path(self.testpaths, None, &self.config.compare_mode, stream); self.delete_file(&old); @@ -2917,7 +2928,7 @@ impl<'test> TestCx<'test> { ) { for kind in UI_EXTENSIONS { let canon_comparison_path = - expected_output_path(&self.testpaths, self.revision, &None, kind); + expected_output_path(&self.testpaths, self.variant.revision(), &None, kind); let canon = match self.load_expected_output_from_path(&canon_comparison_path) { Ok(canon) => canon, @@ -2925,8 +2936,12 @@ impl<'test> TestCx<'test> { }; let bless = self.config.bless; let check_and_prune_duplicate_outputs = |mode: &CompareMode, require_same: bool| { - let examined_path = - expected_output_path(&self.testpaths, self.revision, &Some(mode.clone()), kind); + let examined_path = expected_output_path( + &self.testpaths, + self.variant.revision(), + &Some(mode.clone()), + kind, + ); // If there is no output, there is nothing to do let examined_content = match self.load_expected_output_from_path(&examined_path) { @@ -2962,8 +2977,8 @@ impl<'test> TestCx<'test> { } fn create_stamp(&self) { - let stamp_file_path = stamp_file_path(&self.config, self.testpaths, self.revision); - fs::write(&stamp_file_path, compute_stamp_hash(&self.config)).unwrap(); + let stamp_file_path = stamp_file_path(&self.config, self.testpaths, self.variant); + fs::write(&stamp_file_path, compute_stamp_hash(&self.config, self.variant)).unwrap(); } fn init_incremental_test(&self) { diff --git a/src/tools/compiletest/src/runtest/codegen_units.rs b/src/tools/compiletest/src/runtest/codegen_units.rs index e4c924ed18a31..902835da78c5c 100644 --- a/src/tools/compiletest/src/runtest/codegen_units.rs +++ b/src/tools/compiletest/src/runtest/codegen_units.rs @@ -6,7 +6,7 @@ use crate::{errors, fatal}; impl TestCx<'_> { pub(super) fn run_codegen_units_test(&self) { - assert!(self.revision.is_none(), "revisions not relevant here"); + assert!(self.variant.revision.is_none(), "revisions not relevant here"); let proc_res = self.compile_test(WillExecute::No, Emit::None); diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 574d7618703d2..0f8f5a36c8f11 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -12,7 +12,7 @@ use crate::util::ArgFileCommand; impl TestCx<'_> { pub(super) fn run_debuginfo_test(&self) { - match self.config.debugger.unwrap() { + match self.variant.debugger.as_ref().unwrap() { Debugger::Cdb => self.run_debuginfo_cdb_test(), Debugger::Gdb => self.run_debuginfo_gdb_test(), Debugger::Lldb => self.run_debuginfo_lldb_test(), @@ -46,8 +46,9 @@ impl TestCx<'_> { } // Parse debugger commands etc from test files - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "cdb", self.revision) - .unwrap_or_else(|e| self.fatal(&e)); + let dbg_cmds = + DebuggerCommands::parse_from(&self.testpaths.file, "cdb", self.variant.revision()) + .unwrap_or_else(|e| self.fatal(&e)); // https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands let mut script_str = String::with_capacity(2048); @@ -105,8 +106,9 @@ impl TestCx<'_> { } fn run_debuginfo_gdb_test(&self) { - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "gdb", self.revision) - .unwrap_or_else(|e| self.fatal(&e)); + let dbg_cmds = + DebuggerCommands::parse_from(&self.testpaths.file, "gdb", self.variant.revision()) + .unwrap_or_else(|e| self.fatal(&e)); let mut cmds = dbg_cmds.commands.join("\n"); // compile test file (it should have 'compile-flags:-g' in the directive) @@ -374,8 +376,9 @@ impl TestCx<'_> { } // Parse debugger commands etc from test files - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "lldb", self.revision) - .unwrap_or_else(|e| self.fatal(&e)); + let dbg_cmds = + DebuggerCommands::parse_from(&self.testpaths.file, "lldb", self.variant.revision()) + .unwrap_or_else(|e| self.fatal(&e)); // Write debugger script: // We don't want to hang when calling `quit` while the process is still running diff --git a/src/tools/compiletest/src/runtest/incremental.rs b/src/tools/compiletest/src/runtest/incremental.rs index 6529882715a90..8e573d8cfe308 100644 --- a/src/tools/compiletest/src/runtest/incremental.rs +++ b/src/tools/compiletest/src/runtest/incremental.rs @@ -38,7 +38,8 @@ impl IncrRevKind { impl TestCx<'_> { /// Runs a single revision of an incremental test. pub(super) fn run_incremental_test(&self) { - let revision = self.revision.expect("incremental tests require a list of revisions"); + let revision = + self.variant.revision().expect("incremental tests require a list of revisions"); // Incremental workproduct directory should have already been created. let incremental_dir = self.props.incremental_dir.as_ref().unwrap(); diff --git a/src/tools/compiletest/src/runtest/js_doc.rs b/src/tools/compiletest/src/runtest/js_doc.rs index 1b5d4608f2728..badad93759c26 100644 --- a/src/tools/compiletest/src/runtest/js_doc.rs +++ b/src/tools/compiletest/src/runtest/js_doc.rs @@ -19,7 +19,7 @@ impl TestCx<'_> { .arg("--test-file") .arg(self.testpaths.file.with_extension("js")) .arg("--revision") - .arg(self.revision.unwrap_or_default()); + .arg(self.variant.revision().unwrap_or_default()); let res = self.run_command_to_procres(cmd); if !res.status.success() { self.fatal_proc_rec("rustdoc-js test failed!", &res); diff --git a/src/tools/compiletest/src/runtest/pretty.rs b/src/tools/compiletest/src/runtest/pretty.rs index 2655772723352..9a2ef66e89729 100644 --- a/src/tools/compiletest/src/runtest/pretty.rs +++ b/src/tools/compiletest/src/runtest/pretty.rs @@ -20,7 +20,10 @@ impl TestCx<'_> { let mut round = 0; while round < rounds { - self.logv(format_args!("pretty-printing round {round} revision {:?}", self.revision)); + self.logv(format_args!( + "pretty-printing round {round} revision {:?}", + self.variant.revision + )); let read_from = if round == 0 { ReadFrom::Path } else { ReadFrom::Stdin(srcs[round].to_owned()) }; @@ -29,7 +32,7 @@ impl TestCx<'_> { self.fatal_proc_rec( &format!( "pretty-printing failed in round {} revision {:?}", - round, self.revision + round, self.variant.revision ), &proc_res, ); diff --git a/src/tools/compiletest/src/runtest/rustdoc.rs b/src/tools/compiletest/src/runtest/rustdoc.rs index a6a826a377301..bee5c86ce62ed 100644 --- a/src/tools/compiletest/src/runtest/rustdoc.rs +++ b/src/tools/compiletest/src/runtest/rustdoc.rs @@ -3,7 +3,7 @@ use crate::util::ArgFileCommand; impl TestCx<'_> { pub(super) fn run_rustdoc_html_test(&self) { - assert!(self.revision.is_none(), "revisions not supported in this test suite"); + assert!(self.variant.revision.is_none(), "revisions not supported in this test suite"); let out_dir = self.output_base_dir(); remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| { diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index 29626b1f40c04..311c2c67f2dfa 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -5,7 +5,7 @@ impl TestCx<'_> { pub(super) fn run_rustdoc_json_test(&self) { //FIXME: Add bless option. - assert!(self.revision.is_none(), "revisions not supported in this test suite"); + assert!(self.variant.revision.is_none(), "revisions not supported in this test suite"); let out_dir = self.output_base_dir(); remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| { diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index f8a0c00083aec..a0936e578c6c1 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -259,7 +259,7 @@ impl TestCx<'_> { // (including the revision) here to avoid the test writer having to manually specify a // `#![crate_name = "..."]` as a workaround. This is okay since we're only checking if // the fixed code is compilable. - if self.revision.is_some() { + if self.variant.revision.is_some() { let crate_name = self.testpaths.file.file_stem().expect("test must have a file stem"); // crate name must be alphanumeric or `_`. diff --git a/src/tools/compiletest/src/rustdoc_gui_test.rs b/src/tools/compiletest/src/rustdoc_gui_test.rs index 57ce0c5a6d5f7..215fee768f254 100644 --- a/src/tools/compiletest/src/rustdoc_gui_test.rs +++ b/src/tools/compiletest/src/rustdoc_gui_test.rs @@ -79,7 +79,6 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config { sysroot_base: Utf8PathBuf::default(), stage: Default::default(), stage_id: String::default(), - debugger: Default::default(), run_ignored: Default::default(), with_rustc_debug_assertions: Default::default(), with_std_debug_assertions: Default::default(), diff --git a/src/tools/miri/tests/fail/c-variadic-ignored-argument.rs b/src/tools/miri/tests/fail/c-variadic-ignored-argument.rs index 77dab904fdbba..9c369433d6f06 100644 --- a/src/tools/miri/tests/fail/c-variadic-ignored-argument.rs +++ b/src/tools/miri/tests/fail/c-variadic-ignored-argument.rs @@ -1,5 +1,3 @@ -#![feature(c_variadic)] - // While 1-ZST are currently ignored on most ABIs, we don't guarantee that, and it's UB to // rely on it. diff --git a/src/tools/miri/tests/fail/c-variadic-mismatch-count.rs b/src/tools/miri/tests/fail/c-variadic-mismatch-count.rs index c01860cd1df90..1d1c441194489 100644 --- a/src/tools/miri/tests/fail/c-variadic-mismatch-count.rs +++ b/src/tools/miri/tests/fail/c-variadic-mismatch-count.rs @@ -1,5 +1,3 @@ -#![feature(c_variadic)] - unsafe extern "C" fn helper(_: i32, _: ...) {} fn main() { diff --git a/src/tools/miri/tests/fail/c-variadic-mismatch.rs b/src/tools/miri/tests/fail/c-variadic-mismatch.rs index bf44fb00bceec..8387f6e12d4eb 100644 --- a/src/tools/miri/tests/fail/c-variadic-mismatch.rs +++ b/src/tools/miri/tests/fail/c-variadic-mismatch.rs @@ -1,5 +1,3 @@ -#![feature(c_variadic)] - unsafe extern "C" fn helper(_: i32, _: ...) {} fn main() { diff --git a/src/tools/miri/tests/fail/c-variadic.rs b/src/tools/miri/tests/fail/c-variadic.rs index e0cbf2dc84460..b4731a03ccc70 100644 --- a/src/tools/miri/tests/fail/c-variadic.rs +++ b/src/tools/miri/tests/fail/c-variadic.rs @@ -1,5 +1,3 @@ -#![feature(c_variadic)] - fn read_too_many() { unsafe extern "C" fn variadic(mut ap: ...) { ap.next_arg::(); //~ERROR: more C-variadic arguments read than were passed diff --git a/src/tools/miri/tests/pass/both_borrows/c_variadics.rs b/src/tools/miri/tests/pass/both_borrows/c_variadics.rs index 626022788814d..a581e0b5beebe 100644 --- a/src/tools/miri/tests/pass/both_borrows/c_variadics.rs +++ b/src/tools/miri/tests/pass/both_borrows/c_variadics.rs @@ -1,7 +1,6 @@ //@revisions: stack tree tree_implicit_writes //@[tree_implicit_writes]compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(c_variadic)] fn main() { unsafe extern "C" fn write_with_first_arg(ptr_to_val: *mut i32, _hidden_mut_ref_to_val: ...) { diff --git a/src/tools/miri/tests/pass/c-variadic.rs b/src/tools/miri/tests/pass/c-variadic.rs index df3df008510dd..b2ca703c9c15b 100644 --- a/src/tools/miri/tests/pass/c-variadic.rs +++ b/src/tools/miri/tests/pass/c-variadic.rs @@ -1,5 +1,4 @@ //@run-native -#![feature(c_variadic)] use std::ffi::{CStr, VaList, c_char, c_double, c_int, c_long}; diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index 6268af93d5707..b6abb097e3387 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -2008,7 +2008,7 @@ impl<'a> StaticParts<'a> { ), ast::ItemKind::Const(c) => ( Some(c.defaultness), - if c.rhs_kind.is_type_const() { + if c.kind == ast::ConstItemKind::TypeConst { "type const" } else { "const" @@ -2017,7 +2017,7 @@ impl<'a> StaticParts<'a> { c.ident, &c.ty, ast::Mutability::Not, - c.rhs_kind.expr(), + c.body.as_deref(), Some(&c.generics), ), _ => unreachable!(), @@ -2039,7 +2039,7 @@ impl<'a> StaticParts<'a> { pub(crate) fn from_trait_item(ti: &'a ast::AssocItem, ident: Ident) -> Self { let (defaultness, ty, expr_opt, generics, prefix) = match &ti.kind { ast::AssocItemKind::Const(c) => { - let prefix = if c.rhs_kind.is_type_const() { + let prefix = if c.kind == ast::ConstItemKind::TypeConst { "type const" } else { "const" @@ -2047,7 +2047,7 @@ impl<'a> StaticParts<'a> { ( c.defaultness, &c.ty, - c.rhs_kind.expr(), + c.body.as_deref(), Some(&c.generics), prefix, ) @@ -2071,7 +2071,7 @@ impl<'a> StaticParts<'a> { pub(crate) fn from_impl_item(ii: &'a ast::AssocItem, ident: Ident) -> Self { let (defaultness, ty, expr_opt, generics, prefix) = match &ii.kind { ast::AssocItemKind::Const(c) => { - let prefix = if c.rhs_kind.is_type_const() { + let prefix = if c.kind == ast::ConstItemKind::TypeConst { "type const" } else { "const" @@ -2079,7 +2079,7 @@ impl<'a> StaticParts<'a> { ( c.defaultness, &c.ty, - c.rhs_kind.expr(), + c.body.as_deref(), Some(&c.generics), prefix, ) diff --git a/tests/assembly-llvm/c-variadic/aarch64.rs b/tests/assembly-llvm/c-variadic/aarch64.rs index fcb44d044abb5..436318bee91e4 100644 --- a/tests/assembly-llvm/c-variadic/aarch64.rs +++ b/tests/assembly-llvm/c-variadic/aarch64.rs @@ -12,7 +12,7 @@ //@ [AARCH64_MSVC] needs-llvm-components: aarch64 //@ [ARM64EC_MSVC] compile-flags: -Copt-level=3 --target arm64ec-pc-windows-msvc //@ [ARM64EC_MSVC] needs-llvm-components: aarch64 -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/arm.rs b/tests/assembly-llvm/c-variadic/arm.rs index 682e9736958b1..7f04349138297 100644 --- a/tests/assembly-llvm/c-variadic/arm.rs +++ b/tests/assembly-llvm/c-variadic/arm.rs @@ -5,7 +5,6 @@ //@ ignore-android #![no_std] #![crate_type = "lib"] -#![feature(c_variadic)] // Check that the assembly that rustc generates matches what clang emits. This example in particular // is related to https://github.com/rust-lang/rust/pull/144549 and shows the effect of us correctly diff --git a/tests/assembly-llvm/c-variadic/avr.rs b/tests/assembly-llvm/c-variadic/avr.rs index a5f48a2d0533e..a795e57cb8287 100644 --- a/tests/assembly-llvm/c-variadic/avr.rs +++ b/tests/assembly-llvm/c-variadic/avr.rs @@ -4,7 +4,7 @@ //@ revisions: AVR //@ [AVR] compile-flags: -Copt-level=3 --target=avr-none -Ctarget-cpu=atmega328p //@ [AVR] needs-llvm-components: avr -#![feature(c_variadic, c_variadic_experimental_arch, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(c_variadic_experimental_arch, no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/gpu.rs b/tests/assembly-llvm/c-variadic/gpu.rs index 61dc4aa52c675..0bc9c0f428705 100644 --- a/tests/assembly-llvm/c-variadic/gpu.rs +++ b/tests/assembly-llvm/c-variadic/gpu.rs @@ -7,7 +7,7 @@ //@ [AMDGPU] needs-llvm-components: amdgpu //@ [NVPTX] compile-flags: --crate-type=rlib --target=nvptx64-nvidia-cuda //@ [NVPTX] needs-llvm-components: nvptx -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/mips.rs b/tests/assembly-llvm/c-variadic/mips.rs index fcfd3ccdc24cb..da9c08481fc33 100644 --- a/tests/assembly-llvm/c-variadic/mips.rs +++ b/tests/assembly-llvm/c-variadic/mips.rs @@ -6,7 +6,7 @@ //@ [MIPS] compile-flags: -Copt-level=3 --target mips-unknown-linux-gnu //@ [MIPS64] compile-flags: -Copt-level=3 --target mipsisa64r6-unknown-linux-gnuabi64 //@ [MIPS64EL] compile-flags: -Copt-level=3 --target mips64el-unknown-linux-gnuabi64 -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs, asm_experimental_arch)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs, asm_experimental_arch)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/powerpc.rs b/tests/assembly-llvm/c-variadic/powerpc.rs index 47d35e7579737..896817f628662 100644 --- a/tests/assembly-llvm/c-variadic/powerpc.rs +++ b/tests/assembly-llvm/c-variadic/powerpc.rs @@ -10,7 +10,7 @@ //@ [POWERPC64LE] needs-llvm-components: powerpc //@ [AIX] compile-flags: -Copt-level=3 --target powerpc64-ibm-aix //@ [AIX] needs-llvm-components: powerpc -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/riscv.rs b/tests/assembly-llvm/c-variadic/riscv.rs index a71c1787f1642..989c47a04a58d 100644 --- a/tests/assembly-llvm/c-variadic/riscv.rs +++ b/tests/assembly-llvm/c-variadic/riscv.rs @@ -6,7 +6,7 @@ //@ [RISCV32] needs-llvm-components: riscv //@ [RISCV64] compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu //@ [RISCV64] needs-llvm-components: riscv -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/s390x.rs b/tests/assembly-llvm/c-variadic/s390x.rs index fef239273e2c5..cfa193726f862 100644 --- a/tests/assembly-llvm/c-variadic/s390x.rs +++ b/tests/assembly-llvm/c-variadic/s390x.rs @@ -3,7 +3,7 @@ // //@ compile-flags: -Copt-level=3 --target s390x-unknown-linux-gnu //@ needs-llvm-components: systemz -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/sparc.rs b/tests/assembly-llvm/c-variadic/sparc.rs index 81e3313c244cc..f3a86ed8a1a6c 100644 --- a/tests/assembly-llvm/c-variadic/sparc.rs +++ b/tests/assembly-llvm/c-variadic/sparc.rs @@ -6,7 +6,7 @@ //@ [SPARC] needs-llvm-components: sparc //@ [SPARC64] compile-flags: -Copt-level=3 --target sparc64-unknown-linux-gnu //@ [SPARC64] needs-llvm-components: sparc -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs, asm_experimental_arch)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs, asm_experimental_arch)] #![cfg_attr(target_arch = "sparc", feature(c_variadic_experimental_arch))] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/wasm.rs b/tests/assembly-llvm/c-variadic/wasm.rs index 8d05cdb1923b4..69fd8fa9d18b5 100644 --- a/tests/assembly-llvm/c-variadic/wasm.rs +++ b/tests/assembly-llvm/c-variadic/wasm.rs @@ -6,7 +6,7 @@ //@ [WASM32] needs-llvm-components: webassembly //@ [WASM64] compile-flags: -Copt-level=3 -Zmerge-functions=disabled --target wasm64-unknown-unknown //@ [WASM64] needs-llvm-components: webassembly -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/x86-linux.rs b/tests/assembly-llvm/c-variadic/x86-linux.rs index 8cc4731346b17..70aa729aba7e8 100644 --- a/tests/assembly-llvm/c-variadic/x86-linux.rs +++ b/tests/assembly-llvm/c-variadic/x86-linux.rs @@ -11,7 +11,7 @@ //@ [I686] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel //@ [I686] compile-flags: --target i686-unknown-linux-gnu //@ [I686] needs-llvm-components: x86 -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/x86_64-windows.rs b/tests/assembly-llvm/c-variadic/x86_64-windows.rs index fa40699af80b4..a5f65f7b0f736 100644 --- a/tests/assembly-llvm/c-variadic/x86_64-windows.rs +++ b/tests/assembly-llvm/c-variadic/x86_64-windows.rs @@ -8,7 +8,7 @@ //@ [WINDOWS_MSVC] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel //@ [WINDOWS_MSVC] compile-flags: --target x86_64-pc-windows-msvc //@ [WINDOWS_MSVC] needs-llvm-components: x86 -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/assembly-llvm/c-variadic/xtensa.rs b/tests/assembly-llvm/c-variadic/xtensa.rs index f775dcc4e14dc..0038c4af4eee6 100644 --- a/tests/assembly-llvm/c-variadic/xtensa.rs +++ b/tests/assembly-llvm/c-variadic/xtensa.rs @@ -5,7 +5,7 @@ //@ revisions: XTENSA //@ [XTENSA] compile-flags: -Copt-level=3 --target xtensa-esp32-none-elf //@ [XTENSA] needs-llvm-components: xtensa -#![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, intrinsics, rustc_attrs)] #![no_core] #![crate_type = "lib"] diff --git a/tests/codegen-llvm/c-variadic-lifetime.rs b/tests/codegen-llvm/c-variadic-lifetime.rs index 794b98e03914c..a43e41f79f9eb 100644 --- a/tests/codegen-llvm/c-variadic-lifetime.rs +++ b/tests/codegen-llvm/c-variadic-lifetime.rs @@ -1,6 +1,5 @@ //@ add-minicore //@ compile-flags: -Copt-level=3 -#![feature(c_variadic)] #![crate_type = "lib"] // Check that `%args` explicitly has its lifetime start and end. Being explicit can improve diff --git a/tests/codegen-llvm/c-variadic-va-end.rs b/tests/codegen-llvm/c-variadic-va-end.rs index 0be1c17257c66..00b760b96779a 100644 --- a/tests/codegen-llvm/c-variadic-va-end.rs +++ b/tests/codegen-llvm/c-variadic-va-end.rs @@ -1,6 +1,5 @@ //@ add-minicore //@ compile-flags: -Copt-level=3 -#![feature(c_variadic)] #![crate_type = "lib"] unsafe extern "C" { diff --git a/tests/codegen-llvm/cffi/c-variadic-inline.rs b/tests/codegen-llvm/cffi/c-variadic-inline.rs index 0df5bd4a55b50..a6b23ccf4a42b 100644 --- a/tests/codegen-llvm/cffi/c-variadic-inline.rs +++ b/tests/codegen-llvm/cffi/c-variadic-inline.rs @@ -1,5 +1,4 @@ //@ compile-flags: -C opt-level=3 -#![feature(c_variadic)] // Test that the inline attributes are accepted on C-variadic functions. // diff --git a/tests/codegen-llvm/cffi/c-variadic-naked.rs b/tests/codegen-llvm/cffi/c-variadic-naked.rs index a04d3efca9cd9..9414b04ce5238 100644 --- a/tests/codegen-llvm/cffi/c-variadic-naked.rs +++ b/tests/codegen-llvm/cffi/c-variadic-naked.rs @@ -4,7 +4,6 @@ // tests that `va_start` is not injected into naked functions #![crate_type = "lib"] -#![feature(c_variadic)] #![no_std] #[unsafe(naked)] diff --git a/tests/codegen-llvm/cffi/c-variadic-opt.rs b/tests/codegen-llvm/cffi/c-variadic-opt.rs index 741423efc36da..58de8c98829d2 100644 --- a/tests/codegen-llvm/cffi/c-variadic-opt.rs +++ b/tests/codegen-llvm/cffi/c-variadic-opt.rs @@ -2,7 +2,6 @@ //@ ignore-bpf: BPF does not support C variadics #![crate_type = "lib"] -#![feature(c_variadic)] #![no_std] use core::ffi::VaList; diff --git a/tests/codegen-llvm/cffi/c-variadic-va_list.rs b/tests/codegen-llvm/cffi/c-variadic-va_list.rs index 0b3cda677ce20..1171060209fc4 100644 --- a/tests/codegen-llvm/cffi/c-variadic-va_list.rs +++ b/tests/codegen-llvm/cffi/c-variadic-va_list.rs @@ -2,7 +2,6 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] -#![feature(c_variadic)] #![no_std] use core::ffi::VaList; diff --git a/tests/codegen-llvm/cffi/c-variadic.rs b/tests/codegen-llvm/cffi/c-variadic.rs index 63ed4b211a9a2..8c349bf51c683 100644 --- a/tests/codegen-llvm/cffi/c-variadic.rs +++ b/tests/codegen-llvm/cffi/c-variadic.rs @@ -6,7 +6,6 @@ //@ ignore-pauthtest #![crate_type = "lib"] -#![feature(c_variadic)] #![no_std] use core::ffi::VaList; diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index a894bdf76842d..3f72584017abd 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -5,7 +5,6 @@ #![crate_type = "lib"] #![feature(sanitize)] -#![feature(c_variadic)] #[inline] #[target_feature(enable = "sse2")] diff --git a/tests/pretty/fn-variadic.rs b/tests/pretty/fn-variadic.rs index 88eecee6e380e..3aad4a0dbe2bf 100644 --- a/tests/pretty/fn-variadic.rs +++ b/tests/pretty/fn-variadic.rs @@ -2,7 +2,6 @@ // See issue #58853. //@ pp-exact -#![feature(c_variadic)] extern "C" { pub fn foo(x: i32, ...); diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp index 50ad30f7cc6cd..cdf61d0cb1158 100644 --- a/tests/pretty/hir-fn-variadic.pp +++ b/tests/pretty/hir-fn-variadic.pp @@ -1,4 +1,3 @@ -#![attr = Feature([c_variadic#0])] extern crate std; #[attr = PreludeImport] use ::std::prelude::rust_2015::*; @@ -6,7 +5,6 @@ //@ pretty-mode:hir //@ pp-exact:hir-fn-variadic.pp - extern "C" { unsafe fn foo(x: i32, va1: ...); } diff --git a/tests/pretty/hir-fn-variadic.rs b/tests/pretty/hir-fn-variadic.rs index 4daf8d9aeb525..c85219fda0ed9 100644 --- a/tests/pretty/hir-fn-variadic.rs +++ b/tests/pretty/hir-fn-variadic.rs @@ -2,8 +2,6 @@ //@ pretty-mode:hir //@ pp-exact:hir-fn-variadic.pp -#![feature(c_variadic)] - extern "C" { pub fn foo(x: i32, va1: ...); } diff --git a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs index 9fc7523ecc7f3..6999f7eeb5a5d 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs @@ -1,5 +1,5 @@ #![crate_type = "staticlib"] -#![feature(c_variadic, c_variadic_int128)] +#![feature(c_variadic_int128)] use core::ffi::{CStr, VaList, c_char, c_double, c_int, c_long, c_longlong}; diff --git a/tests/ui-fulldeps/rustc_public/check_abi.rs b/tests/ui-fulldeps/rustc_public/check_abi.rs index d823e76b93cd0..4cf79b1ac8005 100644 --- a/tests/ui-fulldeps/rustc_public/check_abi.rs +++ b/tests/ui-fulldeps/rustc_public/check_abi.rs @@ -185,7 +185,6 @@ fn generate_input(path: &str) -> std::io::Result<()> { write!( file, r#" - #![feature(c_variadic)] #![allow(unused_variables)] use std::num::NonZero; diff --git a/tests/ui/abi/variadic-ffi.rs b/tests/ui/abi/variadic-ffi.rs index 42ff8d0dbb36e..0f6183d6e2d40 100644 --- a/tests/ui/abi/variadic-ffi.rs +++ b/tests/ui/abi/variadic-ffi.rs @@ -1,8 +1,6 @@ //@ run-pass //@ ignore-backends: gcc -#![feature(c_variadic)] - use std::ffi::VaList; #[link(name = "rust_test_helpers", kind = "static")] diff --git a/tests/ui/asm/riscv/riscv32e-registers.riscv32emc.stderr b/tests/ui/asm/riscv/riscv32e-registers.riscv32e_llvm23.stderr similarity index 86% rename from tests/ui/asm/riscv/riscv32e-registers.riscv32emc.stderr rename to tests/ui/asm/riscv/riscv32e-registers.riscv32e_llvm23.stderr index 4ae29b78b54aa..7a6bf6e5176d0 100644 --- a/tests/ui/asm/riscv/riscv32e-registers.riscv32emc.stderr +++ b/tests/ui/asm/riscv/riscv32e-registers.riscv32e_llvm23.stderr @@ -1,5 +1,5 @@ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:43:11 + --> $DIR/riscv32e-registers.rs:57:11 | LL | asm!("li x16, 0"); | ^^^^^^^^^ @@ -11,7 +11,7 @@ LL | li x16, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:46:11 + --> $DIR/riscv32e-registers.rs:61:11 | LL | asm!("li x17, 0"); | ^^^^^^^^^ @@ -23,7 +23,7 @@ LL | li x17, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:49:11 + --> $DIR/riscv32e-registers.rs:65:11 | LL | asm!("li x18, 0"); | ^^^^^^^^^ @@ -35,7 +35,7 @@ LL | li x18, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:52:11 + --> $DIR/riscv32e-registers.rs:69:11 | LL | asm!("li x19, 0"); | ^^^^^^^^^ @@ -47,7 +47,7 @@ LL | li x19, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:55:11 + --> $DIR/riscv32e-registers.rs:73:11 | LL | asm!("li x20, 0"); | ^^^^^^^^^ @@ -59,7 +59,7 @@ LL | li x20, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:58:11 + --> $DIR/riscv32e-registers.rs:77:11 | LL | asm!("li x21, 0"); | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | li x21, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:61:11 + --> $DIR/riscv32e-registers.rs:81:11 | LL | asm!("li x22, 0"); | ^^^^^^^^^ @@ -83,7 +83,7 @@ LL | li x22, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:64:11 + --> $DIR/riscv32e-registers.rs:85:11 | LL | asm!("li x23, 0"); | ^^^^^^^^^ @@ -95,7 +95,7 @@ LL | li x23, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:67:11 + --> $DIR/riscv32e-registers.rs:89:11 | LL | asm!("li x24, 0"); | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | li x24, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:70:11 + --> $DIR/riscv32e-registers.rs:93:11 | LL | asm!("li x25, 0"); | ^^^^^^^^^ @@ -119,7 +119,7 @@ LL | li x25, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:73:11 + --> $DIR/riscv32e-registers.rs:97:11 | LL | asm!("li x26, 0"); | ^^^^^^^^^ @@ -131,7 +131,7 @@ LL | li x26, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:76:11 + --> $DIR/riscv32e-registers.rs:101:11 | LL | asm!("li x27, 0"); | ^^^^^^^^^ @@ -143,7 +143,7 @@ LL | li x27, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:79:11 + --> $DIR/riscv32e-registers.rs:105:11 | LL | asm!("li x28, 0"); | ^^^^^^^^^ @@ -155,7 +155,7 @@ LL | li x28, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:82:11 + --> $DIR/riscv32e-registers.rs:109:11 | LL | asm!("li x29, 0"); | ^^^^^^^^^ @@ -167,7 +167,7 @@ LL | li x29, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:85:11 + --> $DIR/riscv32e-registers.rs:113:11 | LL | asm!("li x30, 0"); | ^^^^^^^^^ @@ -179,7 +179,7 @@ LL | li x30, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:88:11 + --> $DIR/riscv32e-registers.rs:117:11 | LL | asm!("li x31, 0"); | ^^^^^^^^^ diff --git a/tests/ui/asm/riscv/riscv32e-registers.riscv32e_llvm24.stderr b/tests/ui/asm/riscv/riscv32e-registers.riscv32e_llvm24.stderr new file mode 100644 index 0000000000000..94625fabf6750 --- /dev/null +++ b/tests/ui/asm/riscv/riscv32e-registers.riscv32e_llvm24.stderr @@ -0,0 +1,194 @@ +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:57:11 + | +LL | asm!("li x16, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x16, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:61:11 + | +LL | asm!("li x17, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x17, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:65:11 + | +LL | asm!("li x18, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x18, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:69:11 + | +LL | asm!("li x19, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x19, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:73:11 + | +LL | asm!("li x20, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x20, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:77:11 + | +LL | asm!("li x21, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x21, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:81:11 + | +LL | asm!("li x22, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x22, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:85:11 + | +LL | asm!("li x23, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x23, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:89:11 + | +LL | asm!("li x24, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x24, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:93:11 + | +LL | asm!("li x25, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x25, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:97:11 + | +LL | asm!("li x26, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x26, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:101:11 + | +LL | asm!("li x27, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x27, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:105:11 + | +LL | asm!("li x28, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x28, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:109:11 + | +LL | asm!("li x29, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x29, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:113:11 + | +LL | asm!("li x30, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x30, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:117:11 + | +LL | asm!("li x31, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x31, 0 + | ^ + +error: aborting due to 16 previous errors + diff --git a/tests/ui/asm/riscv/riscv32e-registers.riscv32e.stderr b/tests/ui/asm/riscv/riscv32e-registers.riscv32em_llvm23.stderr similarity index 86% rename from tests/ui/asm/riscv/riscv32e-registers.riscv32e.stderr rename to tests/ui/asm/riscv/riscv32e-registers.riscv32em_llvm23.stderr index 4ae29b78b54aa..7a6bf6e5176d0 100644 --- a/tests/ui/asm/riscv/riscv32e-registers.riscv32e.stderr +++ b/tests/ui/asm/riscv/riscv32e-registers.riscv32em_llvm23.stderr @@ -1,5 +1,5 @@ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:43:11 + --> $DIR/riscv32e-registers.rs:57:11 | LL | asm!("li x16, 0"); | ^^^^^^^^^ @@ -11,7 +11,7 @@ LL | li x16, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:46:11 + --> $DIR/riscv32e-registers.rs:61:11 | LL | asm!("li x17, 0"); | ^^^^^^^^^ @@ -23,7 +23,7 @@ LL | li x17, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:49:11 + --> $DIR/riscv32e-registers.rs:65:11 | LL | asm!("li x18, 0"); | ^^^^^^^^^ @@ -35,7 +35,7 @@ LL | li x18, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:52:11 + --> $DIR/riscv32e-registers.rs:69:11 | LL | asm!("li x19, 0"); | ^^^^^^^^^ @@ -47,7 +47,7 @@ LL | li x19, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:55:11 + --> $DIR/riscv32e-registers.rs:73:11 | LL | asm!("li x20, 0"); | ^^^^^^^^^ @@ -59,7 +59,7 @@ LL | li x20, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:58:11 + --> $DIR/riscv32e-registers.rs:77:11 | LL | asm!("li x21, 0"); | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | li x21, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:61:11 + --> $DIR/riscv32e-registers.rs:81:11 | LL | asm!("li x22, 0"); | ^^^^^^^^^ @@ -83,7 +83,7 @@ LL | li x22, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:64:11 + --> $DIR/riscv32e-registers.rs:85:11 | LL | asm!("li x23, 0"); | ^^^^^^^^^ @@ -95,7 +95,7 @@ LL | li x23, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:67:11 + --> $DIR/riscv32e-registers.rs:89:11 | LL | asm!("li x24, 0"); | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | li x24, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:70:11 + --> $DIR/riscv32e-registers.rs:93:11 | LL | asm!("li x25, 0"); | ^^^^^^^^^ @@ -119,7 +119,7 @@ LL | li x25, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:73:11 + --> $DIR/riscv32e-registers.rs:97:11 | LL | asm!("li x26, 0"); | ^^^^^^^^^ @@ -131,7 +131,7 @@ LL | li x26, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:76:11 + --> $DIR/riscv32e-registers.rs:101:11 | LL | asm!("li x27, 0"); | ^^^^^^^^^ @@ -143,7 +143,7 @@ LL | li x27, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:79:11 + --> $DIR/riscv32e-registers.rs:105:11 | LL | asm!("li x28, 0"); | ^^^^^^^^^ @@ -155,7 +155,7 @@ LL | li x28, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:82:11 + --> $DIR/riscv32e-registers.rs:109:11 | LL | asm!("li x29, 0"); | ^^^^^^^^^ @@ -167,7 +167,7 @@ LL | li x29, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:85:11 + --> $DIR/riscv32e-registers.rs:113:11 | LL | asm!("li x30, 0"); | ^^^^^^^^^ @@ -179,7 +179,7 @@ LL | li x30, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:88:11 + --> $DIR/riscv32e-registers.rs:117:11 | LL | asm!("li x31, 0"); | ^^^^^^^^^ diff --git a/tests/ui/asm/riscv/riscv32e-registers.riscv32em_llvm24.stderr b/tests/ui/asm/riscv/riscv32e-registers.riscv32em_llvm24.stderr new file mode 100644 index 0000000000000..94625fabf6750 --- /dev/null +++ b/tests/ui/asm/riscv/riscv32e-registers.riscv32em_llvm24.stderr @@ -0,0 +1,194 @@ +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:57:11 + | +LL | asm!("li x16, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x16, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:61:11 + | +LL | asm!("li x17, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x17, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:65:11 + | +LL | asm!("li x18, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x18, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:69:11 + | +LL | asm!("li x19, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x19, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:73:11 + | +LL | asm!("li x20, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x20, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:77:11 + | +LL | asm!("li x21, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x21, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:81:11 + | +LL | asm!("li x22, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x22, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:85:11 + | +LL | asm!("li x23, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x23, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:89:11 + | +LL | asm!("li x24, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x24, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:93:11 + | +LL | asm!("li x25, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x25, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:97:11 + | +LL | asm!("li x26, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x26, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:101:11 + | +LL | asm!("li x27, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x27, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:105:11 + | +LL | asm!("li x28, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x28, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:109:11 + | +LL | asm!("li x29, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x29, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:113:11 + | +LL | asm!("li x30, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x30, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:117:11 + | +LL | asm!("li x31, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x31, 0 + | ^ + +error: aborting due to 16 previous errors + diff --git a/tests/ui/asm/riscv/riscv32e-registers.riscv32em.stderr b/tests/ui/asm/riscv/riscv32e-registers.riscv32emc_llvm23.stderr similarity index 86% rename from tests/ui/asm/riscv/riscv32e-registers.riscv32em.stderr rename to tests/ui/asm/riscv/riscv32e-registers.riscv32emc_llvm23.stderr index 4ae29b78b54aa..7a6bf6e5176d0 100644 --- a/tests/ui/asm/riscv/riscv32e-registers.riscv32em.stderr +++ b/tests/ui/asm/riscv/riscv32e-registers.riscv32emc_llvm23.stderr @@ -1,5 +1,5 @@ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:43:11 + --> $DIR/riscv32e-registers.rs:57:11 | LL | asm!("li x16, 0"); | ^^^^^^^^^ @@ -11,7 +11,7 @@ LL | li x16, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:46:11 + --> $DIR/riscv32e-registers.rs:61:11 | LL | asm!("li x17, 0"); | ^^^^^^^^^ @@ -23,7 +23,7 @@ LL | li x17, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:49:11 + --> $DIR/riscv32e-registers.rs:65:11 | LL | asm!("li x18, 0"); | ^^^^^^^^^ @@ -35,7 +35,7 @@ LL | li x18, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:52:11 + --> $DIR/riscv32e-registers.rs:69:11 | LL | asm!("li x19, 0"); | ^^^^^^^^^ @@ -47,7 +47,7 @@ LL | li x19, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:55:11 + --> $DIR/riscv32e-registers.rs:73:11 | LL | asm!("li x20, 0"); | ^^^^^^^^^ @@ -59,7 +59,7 @@ LL | li x20, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:58:11 + --> $DIR/riscv32e-registers.rs:77:11 | LL | asm!("li x21, 0"); | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | li x21, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:61:11 + --> $DIR/riscv32e-registers.rs:81:11 | LL | asm!("li x22, 0"); | ^^^^^^^^^ @@ -83,7 +83,7 @@ LL | li x22, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:64:11 + --> $DIR/riscv32e-registers.rs:85:11 | LL | asm!("li x23, 0"); | ^^^^^^^^^ @@ -95,7 +95,7 @@ LL | li x23, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:67:11 + --> $DIR/riscv32e-registers.rs:89:11 | LL | asm!("li x24, 0"); | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | li x24, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:70:11 + --> $DIR/riscv32e-registers.rs:93:11 | LL | asm!("li x25, 0"); | ^^^^^^^^^ @@ -119,7 +119,7 @@ LL | li x25, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:73:11 + --> $DIR/riscv32e-registers.rs:97:11 | LL | asm!("li x26, 0"); | ^^^^^^^^^ @@ -131,7 +131,7 @@ LL | li x26, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:76:11 + --> $DIR/riscv32e-registers.rs:101:11 | LL | asm!("li x27, 0"); | ^^^^^^^^^ @@ -143,7 +143,7 @@ LL | li x27, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:79:11 + --> $DIR/riscv32e-registers.rs:105:11 | LL | asm!("li x28, 0"); | ^^^^^^^^^ @@ -155,7 +155,7 @@ LL | li x28, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:82:11 + --> $DIR/riscv32e-registers.rs:109:11 | LL | asm!("li x29, 0"); | ^^^^^^^^^ @@ -167,7 +167,7 @@ LL | li x29, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:85:11 + --> $DIR/riscv32e-registers.rs:113:11 | LL | asm!("li x30, 0"); | ^^^^^^^^^ @@ -179,7 +179,7 @@ LL | li x30, 0 | ^ error: invalid operand for instruction - --> $DIR/riscv32e-registers.rs:88:11 + --> $DIR/riscv32e-registers.rs:117:11 | LL | asm!("li x31, 0"); | ^^^^^^^^^ diff --git a/tests/ui/asm/riscv/riscv32e-registers.riscv32emc_llvm24.stderr b/tests/ui/asm/riscv/riscv32e-registers.riscv32emc_llvm24.stderr new file mode 100644 index 0000000000000..94625fabf6750 --- /dev/null +++ b/tests/ui/asm/riscv/riscv32e-registers.riscv32emc_llvm24.stderr @@ -0,0 +1,194 @@ +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:57:11 + | +LL | asm!("li x16, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x16, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:61:11 + | +LL | asm!("li x17, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x17, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:65:11 + | +LL | asm!("li x18, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x18, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:69:11 + | +LL | asm!("li x19, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x19, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:73:11 + | +LL | asm!("li x20, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x20, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:77:11 + | +LL | asm!("li x21, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x21, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:81:11 + | +LL | asm!("li x22, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x22, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:85:11 + | +LL | asm!("li x23, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x23, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:89:11 + | +LL | asm!("li x24, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x24, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:93:11 + | +LL | asm!("li x25, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x25, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:97:11 + | +LL | asm!("li x26, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x26, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:101:11 + | +LL | asm!("li x27, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x27, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:105:11 + | +LL | asm!("li x28, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x28, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:109:11 + | +LL | asm!("li x29, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x29, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:113:11 + | +LL | asm!("li x30, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x30, 0 + | ^ + +error: register must be a GPR + --> $DIR/riscv32e-registers.rs:117:11 + | +LL | asm!("li x31, 0"); + | ^^^^^^^^^ + | +note: instantiated into assembly here + --> :1:5 + | +LL | li x31, 0 + | ^ + +error: aborting due to 16 previous errors + diff --git a/tests/ui/asm/riscv/riscv32e-registers.rs b/tests/ui/asm/riscv/riscv32e-registers.rs index 70231edddbc62..a5f4151b2c80a 100644 --- a/tests/ui/asm/riscv/riscv32e-registers.rs +++ b/tests/ui/asm/riscv/riscv32e-registers.rs @@ -2,15 +2,29 @@ // //@ add-minicore //@ build-fail -//@ revisions: riscv32e riscv32em riscv32emc -// +//@ revisions: riscv32e_llvm23 riscv32em_llvm23 riscv32emc_llvm23 +//@ revisions: riscv32e_llvm24 riscv32em_llvm24 riscv32emc_llvm24 //@ compile-flags: --crate-type=rlib -//@ [riscv32e] needs-llvm-components: riscv -//@ [riscv32e] compile-flags: --target=riscv32e-unknown-none-elf -//@ [riscv32em] needs-llvm-components: riscv -//@ [riscv32em] compile-flags: --target=riscv32em-unknown-none-elf -//@ [riscv32emc] needs-llvm-components: riscv -//@ [riscv32emc] compile-flags: --target=riscv32emc-unknown-none-elf +//@ [riscv32e_llvm23] needs-llvm-components: riscv +//@ [riscv32e_llvm23] compile-flags: --target=riscv32e-unknown-none-elf +//@ [riscv32e_llvm23] max-llvm-major-version: 23 +//@ [riscv32e_llvm24] needs-llvm-components: riscv +//@ [riscv32e_llvm24] compile-flags: --target=riscv32e-unknown-none-elf +//@ [riscv32e_llvm24] min-llvm-version: 24 + +//@ [riscv32em_llvm23] needs-llvm-components: riscv +//@ [riscv32em_llvm23] compile-flags: --target=riscv32em-unknown-none-elf +//@ [riscv32em_llvm23] max-llvm-major-version: 23 +//@ [riscv32em_llvm24] needs-llvm-components: riscv +//@ [riscv32em_llvm24] compile-flags: --target=riscv32em-unknown-none-elf +//@ [riscv32em_llvm24] min-llvm-version: 24 + +//@ [riscv32emc_llvm23] needs-llvm-components: riscv +//@ [riscv32emc_llvm23] compile-flags: --target=riscv32emc-unknown-none-elf +//@ [riscv32emc_llvm23] max-llvm-major-version: 23 +//@ [riscv32emc_llvm24] needs-llvm-components: riscv +//@ [riscv32emc_llvm24] compile-flags: --target=riscv32emc-unknown-none-elf +//@ [riscv32emc_llvm24] min-llvm-version: 24 //@ ignore-backends: gcc // Unlike bad-reg.rs, this tests if the assembler can reject invalid registers @@ -41,51 +55,67 @@ pub unsafe fn registers() { asm!("li x14, 0"); asm!("li x15, 0"); asm!("li x16, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x17, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x18, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x19, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x20, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x21, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x22, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x23, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x24, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x25, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x26, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x27, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x28, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x29, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x30, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here asm!("li x31, 0"); - //~^ ERROR invalid operand for instruction + //[riscv32e_llvm23,riscv32em_llvm23,riscv32emc_llvm23]~^ ERROR invalid operand for instruction + //[riscv32e_llvm24,riscv32em_llvm24,riscv32emc_llvm24]~^^ ERROR register must be a GPR //~| NOTE instantiated into assembly here } diff --git a/tests/ui/c-variadic/copy.rs b/tests/ui/c-variadic/copy.rs index 5f3ec25581c9e..7befce36902c7 100644 --- a/tests/ui/c-variadic/copy.rs +++ b/tests/ui/c-variadic/copy.rs @@ -1,6 +1,5 @@ //@ run-pass //@ ignore-backends: gcc -#![feature(c_variadic)] // Test the behavior of `VaList::clone`. In C a `va_list` is duplicated using `va_copy`, but the // rust api just uses `Clone`. This should create a completely independent cursor into the diff --git a/tests/ui/c-variadic/inherent-method.rs b/tests/ui/c-variadic/inherent-method.rs index c71e57816c824..5f5cdc76d4a2e 100644 --- a/tests/ui/c-variadic/inherent-method.rs +++ b/tests/ui/c-variadic/inherent-method.rs @@ -1,7 +1,5 @@ //@ run-pass //@ ignore-backends: gcc -#![feature(c_variadic)] - #[repr(transparent)] struct S(i32); diff --git a/tests/ui/c-variadic/issue-86053-1.rs b/tests/ui/c-variadic/issue-86053-1.rs index e63d348dbb3bc..40efb5954f603 100644 --- a/tests/ui/c-variadic/issue-86053-1.rs +++ b/tests/ui/c-variadic/issue-86053-1.rs @@ -1,6 +1,5 @@ // Regression test for the ICE described in issue #86053. -#![feature(c_variadic)] #![crate_type="lib"] fn ordering4 < 'a , 'b > ( a : , self , self , self , diff --git a/tests/ui/c-variadic/issue-86053-1.stderr b/tests/ui/c-variadic/issue-86053-1.stderr index d9bce99cfdb4d..b18bf603dd36a 100644 --- a/tests/ui/c-variadic/issue-86053-1.stderr +++ b/tests/ui/c-variadic/issue-86053-1.stderr @@ -1,53 +1,53 @@ error: expected type, found `,` - --> $DIR/issue-86053-1.rs:6:47 + --> $DIR/issue-86053-1.rs:5:47 | LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ^ expected type error: unexpected `self` parameter in function - --> $DIR/issue-86053-1.rs:6:51 + --> $DIR/issue-86053-1.rs:5:51 | LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ^^^^ must be the first parameter of an associated function error: unexpected `self` parameter in function - --> $DIR/issue-86053-1.rs:6:58 + --> $DIR/issue-86053-1.rs:5:58 | LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ^^^^ must be the first parameter of an associated function error: unexpected `self` parameter in function - --> $DIR/issue-86053-1.rs:6:67 + --> $DIR/issue-86053-1.rs:5:67 | LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ^^^^ must be the first parameter of an associated function error: unexpected `self` parameter in function - --> $DIR/issue-86053-1.rs:11:5 + --> $DIR/issue-86053-1.rs:10:5 | LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^^^^ must be the first parameter of an associated function error: unexpected `self` parameter in function - --> $DIR/issue-86053-1.rs:11:23 + --> $DIR/issue-86053-1.rs:10:23 | LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^^^^ must be the first parameter of an associated function error: unexpected `self` parameter in function - --> $DIR/issue-86053-1.rs:11:32 + --> $DIR/issue-86053-1.rs:10:32 | LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^^^^ must be the first parameter of an associated function error: `...` must be the last argument of a C-variadic function - --> $DIR/issue-86053-1.rs:11:12 + --> $DIR/issue-86053-1.rs:10:12 | LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^^^^^^ error: `...` is not supported for non-extern functions - --> $DIR/issue-86053-1.rs:11:39 + --> $DIR/issue-86053-1.rs:10:39 | LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^^^^^^ @@ -55,7 +55,7 @@ LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error[E0425]: cannot find type `F` in this scope - --> $DIR/issue-86053-1.rs:11:54 + --> $DIR/issue-86053-1.rs:10:54 | LL | self , _: ... , self , self , _: ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^ diff --git a/tests/ui/c-variadic/issue-86053-2.rs b/tests/ui/c-variadic/issue-86053-2.rs index 0914676a35f4f..76333a44bf538 100644 --- a/tests/ui/c-variadic/issue-86053-2.rs +++ b/tests/ui/c-variadic/issue-86053-2.rs @@ -1,8 +1,6 @@ // Regression test for the ICE caused by the example in // https://github.com/rust-lang/rust/issues/86053#issuecomment-855672258 -#![feature(c_variadic)] - trait H {} unsafe extern "C" fn ordering4<'a, F: H<&'static &'a ()>>(_: (), _: ...) {} diff --git a/tests/ui/c-variadic/issue-86053-2.stderr b/tests/ui/c-variadic/issue-86053-2.stderr index 823dadff6f895..de7d743a2a242 100644 --- a/tests/ui/c-variadic/issue-86053-2.stderr +++ b/tests/ui/c-variadic/issue-86053-2.stderr @@ -1,12 +1,12 @@ error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references - --> $DIR/issue-86053-2.rs:8:39 + --> $DIR/issue-86053-2.rs:6:39 | LL | unsafe extern "C" fn ordering4<'a, F: H<&'static &'a ()>>(_: (), _: ...) {} | ^^^^^^^^^^^^^^^^^^ | = note: the pointer is valid for the static lifetime note: but the referenced data is only valid for the lifetime `'a` as defined here - --> $DIR/issue-86053-2.rs:8:32 + --> $DIR/issue-86053-2.rs:6:32 | LL | unsafe extern "C" fn ordering4<'a, F: H<&'static &'a ()>>(_: (), _: ...) {} | ^^ diff --git a/tests/ui/c-variadic/naked-invalid.rs b/tests/ui/c-variadic/naked-invalid.rs index 2cc4aaafbfcc0..2aeb400c9853e 100644 --- a/tests/ui/c-variadic/naked-invalid.rs +++ b/tests/ui/c-variadic/naked-invalid.rs @@ -4,7 +4,7 @@ //@ ignore-backends: gcc #![feature(no_core, lang_items, rustc_attrs)] -#![feature(c_variadic, c_variadic_naked_functions, abi_x86_interrupt, naked_functions_rustic_abi)] +#![feature(c_variadic_naked_functions, abi_x86_interrupt, naked_functions_rustic_abi)] #![crate_type = "rlib"] #![no_core] diff --git a/tests/ui/c-variadic/naked.rs b/tests/ui/c-variadic/naked.rs index 73664206d9ced..cda6a67d04681 100644 --- a/tests/ui/c-variadic/naked.rs +++ b/tests/ui/c-variadic/naked.rs @@ -1,7 +1,7 @@ //@ run-pass //@ only-x86_64 //@ only-linux -#![feature(c_variadic, c_variadic_naked_functions)] +#![feature(c_variadic_naked_functions)] #[repr(C)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/c-variadic/no-closure.rs b/tests/ui/c-variadic/no-closure.rs index 830ed962a8c4a..254f1e10b125e 100644 --- a/tests/ui/c-variadic/no-closure.rs +++ b/tests/ui/c-variadic/no-closure.rs @@ -1,4 +1,3 @@ -#![feature(c_variadic)] #![crate_type = "lib"] // Check that `...` in closures is rejected. diff --git a/tests/ui/c-variadic/no-closure.stderr b/tests/ui/c-variadic/no-closure.stderr index 0946c4632e6e4..088cc44d47ed0 100644 --- a/tests/ui/c-variadic/no-closure.stderr +++ b/tests/ui/c-variadic/no-closure.stderr @@ -1,5 +1,5 @@ error: unexpected `...` - --> $DIR/no-closure.rs:6:35 + --> $DIR/no-closure.rs:5:35 | LL | const F: extern "C" fn(...) = |_: ...| {}; | ^^^ @@ -7,7 +7,7 @@ LL | const F: extern "C" fn(...) = |_: ...| {}; = note: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: unexpected `...` - --> $DIR/no-closure.rs:11:14 + --> $DIR/no-closure.rs:10:14 | LL | let f = |...| {}; | ^^^ not a valid pattern @@ -15,7 +15,7 @@ LL | let f = |...| {}; = note: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: unexpected `...` - --> $DIR/no-closure.rs:16:17 + --> $DIR/no-closure.rs:15:17 | LL | let f = |_: ...| {}; | ^^^ diff --git a/tests/ui/c-variadic/not-async.rs b/tests/ui/c-variadic/not-async.rs index a4ad9c6bceb54..9387c984324ec 100644 --- a/tests/ui/c-variadic/not-async.rs +++ b/tests/ui/c-variadic/not-async.rs @@ -1,5 +1,4 @@ //@ edition: 2021 -#![feature(c_variadic)] #![crate_type = "lib"] async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {} diff --git a/tests/ui/c-variadic/not-async.stderr b/tests/ui/c-variadic/not-async.stderr index bb8cc64e15fa4..921210382236c 100644 --- a/tests/ui/c-variadic/not-async.stderr +++ b/tests/ui/c-variadic/not-async.stderr @@ -1,17 +1,17 @@ error: functions cannot be both `async` and C-variadic - --> $DIR/not-async.rs:5:1 + --> $DIR/not-async.rs:4:1 | LL | async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {} | ^^^^^ `async` because of this ^^^^^^ C-variadic because of this error: functions cannot be both `async` and C-variadic - --> $DIR/not-async.rs:12:5 + --> $DIR/not-async.rs:11:5 | LL | async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {} | ^^^^^ `async` because of this ^^^^^^ C-variadic because of this error[E0700]: hidden type for `impl Future` captures lifetime that does not appear in bounds - --> $DIR/not-async.rs:5:65 + --> $DIR/not-async.rs:4:65 | LL | async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {} | -^^ @@ -21,7 +21,7 @@ LL | async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {} = note: hidden type `{async fn body of fn_cannot_be_async()}` captures lifetime `'_` error[E0700]: hidden type for `impl Future` captures lifetime that does not appear in bounds - --> $DIR/not-async.rs:12:73 + --> $DIR/not-async.rs:11:73 | LL | async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {} | -^^ diff --git a/tests/ui/c-variadic/not-dyn-compatible.rs b/tests/ui/c-variadic/not-dyn-compatible.rs index 6676cc661c875..f8d5fd4a39288 100644 --- a/tests/ui/c-variadic/not-dyn-compatible.rs +++ b/tests/ui/c-variadic/not-dyn-compatible.rs @@ -3,7 +3,6 @@ // Creating a function pointer from a method on an `&dyn T` value creates a ReifyShim. // This shim cannot reliably forward C-variadic arguments. Thus the trait as a whole // is dyn-incompatible to prevent invalid shims from being created. -#![feature(c_variadic)] #[repr(transparent)] struct Struct(u64); diff --git a/tests/ui/c-variadic/not-dyn-compatible.stderr b/tests/ui/c-variadic/not-dyn-compatible.stderr index 76630600c511f..40274371a09b4 100644 --- a/tests/ui/c-variadic/not-dyn-compatible.stderr +++ b/tests/ui/c-variadic/not-dyn-compatible.stderr @@ -1,12 +1,12 @@ error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/not-dyn-compatible.rs:27:30 + --> $DIR/not-dyn-compatible.rs:26:30 | LL | let dyn_object: &dyn Trait = &Struct(64); | ^^^^^ `Trait` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit - --> $DIR/not-dyn-compatible.rs:14:26 + --> $DIR/not-dyn-compatible.rs:13:26 | LL | trait Trait { | ----- this trait is not dyn compatible... diff --git a/tests/ui/c-variadic/pass-by-value-abi.rs b/tests/ui/c-variadic/pass-by-value-abi.rs index 6f7cce467c354..bcca09e90438a 100644 --- a/tests/ui/c-variadic/pass-by-value-abi.rs +++ b/tests/ui/c-variadic/pass-by-value-abi.rs @@ -17,7 +17,7 @@ //@ [win] only-windows //@ [win] only-x86_64 -#![feature(rustc_attrs, c_variadic)] +#![feature(rustc_attrs)] #![crate_type = "lib"] // Can't use `minicore` here as this is testing the implementation in `core::ffi` specifically. diff --git a/tests/ui/c-variadic/roundtrip.rs b/tests/ui/c-variadic/roundtrip.rs index ab6d61a5b8250..59ab4099f7620 100644 --- a/tests/ui/c-variadic/roundtrip.rs +++ b/tests/ui/c-variadic/roundtrip.rs @@ -1,12 +1,6 @@ //@ run-pass //@ ignore-backends: gcc -#![feature( - c_variadic, - const_c_variadic, - c_variadic_int128, - const_destruct, - const_raw_ptr_comparison -)] +#![feature(const_c_variadic, c_variadic_int128, const_destruct, const_raw_ptr_comparison)] #![allow(unused_features)] // c_variadic_int128 is only used on 64-bit targets. use std::ffi::*; diff --git a/tests/ui/c-variadic/same-program-multiple-abis-arm.rs b/tests/ui/c-variadic/same-program-multiple-abis-arm.rs index 301485519b9b9..62a701c942d38 100644 --- a/tests/ui/c-variadic/same-program-multiple-abis-arm.rs +++ b/tests/ui/c-variadic/same-program-multiple-abis-arm.rs @@ -2,7 +2,7 @@ //@ only-arm //@ ignore-thumb (this test uses arm assembly) //@ only-eabihf (the assembly below requires float hardware support) -#![feature(c_variadic, c_variadic_naked_functions)] +#![feature(c_variadic_naked_functions)] // Check that multiple c-variadic calling conventions can be used in the same program. // @@ -21,8 +21,6 @@ fn main() { // following code compiled for the `armv7-unknown-linux-gnueabihf` target: // // ```rust -// #![feature(c_variadic)] -// // #[unsafe(no_mangle)] // unsafe extern "C" fn variadic(a: f64, mut args: ...) -> f64 { // let b = args.next_arg::(); diff --git a/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs b/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs index 1f6f676780050..78f574667bc0d 100644 --- a/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs +++ b/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs @@ -1,6 +1,6 @@ //@ run-pass //@ only-x86_64 -#![feature(c_variadic, c_variadic_naked_functions)] +#![feature(c_variadic_naked_functions)] // Check that multiple c-variadic calling conventions can be used in the same program. // @@ -20,8 +20,6 @@ fn main() { // targets, respectively: // // ```rust -// #![feature(c_variadic)] -// // #[unsafe(no_mangle)] // unsafe extern "C" fn variadic(a: u32, mut args: ...) -> u32 { // let b = args.next_arg::(); diff --git a/tests/ui/c-variadic/trait-method.rs b/tests/ui/c-variadic/trait-method.rs index 753c0fbe89f22..9a3ba87614214 100644 --- a/tests/ui/c-variadic/trait-method.rs +++ b/tests/ui/c-variadic/trait-method.rs @@ -1,6 +1,5 @@ //@ run-pass //@ ignore-backends: gcc -#![feature(c_variadic)] #[repr(transparent)] struct Struct(i32); diff --git a/tests/ui/c-variadic/unsupported-abi.rs b/tests/ui/c-variadic/unsupported-abi.rs index f055ea4819146..1b62003a9275b 100644 --- a/tests/ui/c-variadic/unsupported-abi.rs +++ b/tests/ui/c-variadic/unsupported-abi.rs @@ -3,7 +3,7 @@ //@ compile-flags: --target=i686-pc-windows-gnu --crate-type=rlib //@ ignore-backends: gcc #![no_core] -#![feature(no_core, lang_items, c_variadic)] +#![feature(no_core, lang_items)] // Test that ABIs for which C-variadics are not supported report an error. diff --git a/tests/ui/c-variadic/valid.rs b/tests/ui/c-variadic/valid.rs index 2ea50e668d3b2..9d937e611afe8 100644 --- a/tests/ui/c-variadic/valid.rs +++ b/tests/ui/c-variadic/valid.rs @@ -1,6 +1,5 @@ //@ run-pass //@ ignore-backends: gcc -#![feature(c_variadic)] // In rust (and C23 and above) `...` can be the only argument. unsafe extern "C" fn only_dot_dot_dot(mut ap: ...) -> i32 { diff --git a/tests/ui/c-variadic/variadic-ffi-4.rs b/tests/ui/c-variadic/variadic-ffi-4.rs index d9e2e617ce3a1..f89a9aec74691 100644 --- a/tests/ui/c-variadic/variadic-ffi-4.rs +++ b/tests/ui/c-variadic/variadic-ffi-4.rs @@ -1,6 +1,5 @@ #![crate_type = "lib"] #![no_std] -#![feature(c_variadic)] use core::ffi::VaList; diff --git a/tests/ui/c-variadic/variadic-ffi-4.stderr b/tests/ui/c-variadic/variadic-ffi-4.stderr index 01ace5c796800..d53f1f527748c 100644 --- a/tests/ui/c-variadic/variadic-ffi-4.stderr +++ b/tests/ui/c-variadic/variadic-ffi-4.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:8:5 + --> $DIR/variadic-ffi-4.rs:7:5 | LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaList<'f> { | -- -- has type `VaList<'1>` @@ -9,7 +9,7 @@ LL | ap | ^^ function was supposed to return data with lifetime `'f` but it is returning data with lifetime `'1` error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:13:5 + --> $DIR/variadic-ffi-4.rs:12:5 | LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> { | -- has type `VaList<'1>` @@ -17,7 +17,7 @@ LL | ap | ^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:17:5 + --> $DIR/variadic-ffi-4.rs:16:5 | LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) { | ------- ------- has type `VaList<'1>` @@ -27,7 +27,7 @@ LL | *ap0 = ap1; | ^^^^ assignment requires that `'1` must outlive `'2` error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:22:5 + --> $DIR/variadic-ffi-4.rs:21:5 | LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { | ------- ------- has type `VaList<'1>` @@ -41,7 +41,7 @@ LL | ap0 = &mut ap1; = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:22:5 + --> $DIR/variadic-ffi-4.rs:21:5 | LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { | ------- ------- has type `VaList<'1>` @@ -55,7 +55,7 @@ LL | ap0 = &mut ap1; = help: see for more information about variance error[E0597]: `ap1` does not live long enough - --> $DIR/variadic-ffi-4.rs:22:11 + --> $DIR/variadic-ffi-4.rs:21:11 | LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { | - ------- binding `ap1` declared here @@ -71,7 +71,7 @@ LL | } | - `ap1` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:29:5 + --> $DIR/variadic-ffi-4.rs:28:5 | LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaList, mut ap1: ...) { | ------- ------- has type `VaList<'1>` diff --git a/tests/ui/c-variadic/variadic-ffi-6.rs b/tests/ui/c-variadic/variadic-ffi-6.rs index 4dd8a2d452181..fd5a6db03b49c 100644 --- a/tests/ui/c-variadic/variadic-ffi-6.rs +++ b/tests/ui/c-variadic/variadic-ffi-6.rs @@ -1,13 +1,11 @@ -#![crate_type="lib"] -#![feature(c_variadic)] +#![crate_type = "lib"] -pub unsafe extern "C" fn use_vararg_lifetime( - x: usize, - y: ... -) -> &usize { //~ ERROR missing lifetime specifier +pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> &usize { + //~^ ERROR missing lifetime specifier &0 } -pub unsafe extern "C" fn use_normal_arg_lifetime(x: &usize, y: ...) -> &usize { // OK +pub unsafe extern "C" fn use_normal_arg_lifetime(x: &usize, y: ...) -> &usize { + // OK x } diff --git a/tests/ui/c-variadic/variadic-ffi-6.stderr b/tests/ui/c-variadic/variadic-ffi-6.stderr index 344bfed4b42a2..1b743070dc83e 100644 --- a/tests/ui/c-variadic/variadic-ffi-6.stderr +++ b/tests/ui/c-variadic/variadic-ffi-6.stderr @@ -1,22 +1,22 @@ error[E0106]: missing lifetime specifier - --> $DIR/variadic-ffi-6.rs:7:6 + --> $DIR/variadic-ffi-6.rs:3:67 | -LL | ) -> &usize { - | ^ expected named lifetime parameter +LL | pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> &usize { + | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | -LL | ) -> &'static usize { - | +++++++ +LL | pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> &'static usize { + | +++++++ help: instead, you are more likely to want to change one of the arguments to be borrowed... | -LL | x: &usize, - | + +LL | pub unsafe extern "C" fn use_vararg_lifetime(x: &usize, y: ...) -> &usize { + | + help: ...or alternatively, you might want to return an owned value | -LL - ) -> &usize { -LL + ) -> usize { +LL - pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> &usize { +LL + pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> usize { | error: aborting due to 1 previous error diff --git a/tests/ui/c-variadic/variadic-unreachable-arg-error.rs b/tests/ui/c-variadic/variadic-unreachable-arg-error.rs index e3fd24a088cfd..a9d8a13893ddf 100644 --- a/tests/ui/c-variadic/variadic-unreachable-arg-error.rs +++ b/tests/ui/c-variadic/variadic-unreachable-arg-error.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(c_variadic)] - extern "C" { fn foo(f: isize, x: u8, ...); } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs index 213b69b6fa201..40a0f152e3005 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs @@ -3,7 +3,7 @@ //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm //@ ignore-backends: gcc -#![feature(cmse_nonsecure_entry, c_variadic, no_core, lang_items)] +#![feature(cmse_nonsecure_entry, no_core, lang_items)] #![no_core] extern crate minicore; diff --git a/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.rs b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.rs new file mode 100644 index 0000000000000..9d114a1173929 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Znext-solver=globally + +#![feature(min_generic_const_args)] +#![feature(generic_const_args)] +#![feature(generic_const_exprs)] +//~^ ERROR `-Znext-solver=globally` and `generic_const_exprs` are incompatible +//@ normalize-stderr: "(--> ).*/tests/ui/const-generics/generic_const_exprs" -> "$1$$DIR" + +use std::mem::size_of; + +union AsBytes { + as_bytes: [u8; const { size_of::() }], +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.stderr b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.stderr new file mode 100644 index 0000000000000..9c2b303107185 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/next-solver-gce-incompatible-issue-158428.stderr @@ -0,0 +1,10 @@ +error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed + --> $DIR/next-solver-gce-incompatible-issue-158428.rs:5:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: remove one of these features + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/static-const-arg.rs b/tests/ui/const-generics/mgca/static-const-arg.rs new file mode 100644 index 0000000000000..9ad248de3cb0f --- /dev/null +++ b/tests/ui/const-generics/mgca/static-const-arg.rs @@ -0,0 +1,18 @@ +// Regression test for #132986. +// FIXME(min_generic_const_args): using statics as direct const arguments should error instead of +// ICEing until const eval can evaluate statics to valtrees for const generics. + +#![feature(min_generic_const_args)] +#![allow(incomplete_features)] + +static A: u32 = 0; + +struct Foo; + +const _: Foo<{ A }> = Foo; +//~^ ERROR static items cannot be used as const arguments + +const _: Foo = Foo; +//~^ ERROR static items cannot be used as const arguments + +fn main() {} diff --git a/tests/ui/const-generics/mgca/static-const-arg.stderr b/tests/ui/const-generics/mgca/static-const-arg.stderr new file mode 100644 index 0000000000000..9c5473f94d2cc --- /dev/null +++ b/tests/ui/const-generics/mgca/static-const-arg.stderr @@ -0,0 +1,14 @@ +error: static items cannot be used as const arguments + --> $DIR/static-const-arg.rs:12:16 + | +LL | const _: Foo<{ A }> = Foo; + | ^ + +error: static items cannot be used as const arguments + --> $DIR/static-const-arg.rs:15:14 + | +LL | const _: Foo = Foo; + | ^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr b/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr index 52ef108a84dbf..d0339d09cdc7a 100644 --- a/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr +++ b/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr @@ -4,7 +4,7 @@ error[E0284]: type annotations needed LL | type const X: usize = const { N }; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` | - = note: cannot satisfy `X::{constant#0}::{constant#0} == _` + = note: cannot satisfy `X::{constant#0} == _` error: the constant `"this isn't a usize"` is not of type `usize` --> $DIR/type-const-free-anon-const-mismatch.rs:8:1 diff --git a/tests/ui/consts/const-eval/c-variadic-fail.rs b/tests/ui/consts/const-eval/c-variadic-fail.rs index 410fa273f98f8..97236c6ec8f90 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.rs +++ b/tests/ui/consts/const-eval/c-variadic-fail.rs @@ -1,6 +1,5 @@ //@ build-fail -#![feature(c_variadic)] #![feature(const_c_variadic)] #![feature(const_trait_impl)] #![feature(const_destruct)] diff --git a/tests/ui/consts/const-eval/c-variadic-fail.stderr b/tests/ui/consts/const-eval/c-variadic-fail.stderr index e32edfb3ea453..ccf2936324a9c 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.stderr +++ b/tests/ui/consts/const-eval/c-variadic-fail.stderr @@ -1,11 +1,11 @@ error[E0080]: more C-variadic arguments read than were passed - --> $DIR/c-variadic-fail.rs:28:13 + --> $DIR/c-variadic-fail.rs:27:13 | LL | const { read_n::<1>() } | ^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#2}` failed inside this call | note: inside `read_n::<1>` - --> $DIR/c-variadic-fail.rs:16:17 + --> $DIR/c-variadic-fail.rs:15:17 | LL | let _ = ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:28:5 + --> $DIR/c-variadic-fail.rs:27:5 | LL | const { read_n::<1>() } | ^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:28:5 + --> $DIR/c-variadic-fail.rs:27:5 | LL | const { read_n::<1>() } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,13 +27,13 @@ LL | const { read_n::<1>() } = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: more C-variadic arguments read than were passed - --> $DIR/c-variadic-fail.rs:32:13 + --> $DIR/c-variadic-fail.rs:31:13 | LL | const { read_n::<2>(1) } | ^^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#3}` failed inside this call | note: inside `read_n::<2>` - --> $DIR/c-variadic-fail.rs:16:17 + --> $DIR/c-variadic-fail.rs:15:17 | LL | let _ = ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ @@ -41,13 +41,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:32:5 + --> $DIR/c-variadic-fail.rs:31:5 | LL | const { read_n::<2>(1) } | ^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:32:5 + --> $DIR/c-variadic-fail.rs:31:5 | LL | const { read_n::<2>(1) } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,13 +55,13 @@ LL | const { read_n::<2>(1) } = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg value mismatch: value `-1_i32` cannot be represented by type `u32` - --> $DIR/c-variadic-fail.rs:72:13 + --> $DIR/c-variadic-fail.rs:71:13 | LL | const { read_as::(-1i32) }; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#12}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:72:5 + --> $DIR/c-variadic-fail.rs:71:5 | LL | const { read_as::(-1i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:72:5 + --> $DIR/c-variadic-fail.rs:71:5 | LL | const { read_as::(-1i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,13 +83,13 @@ LL | const { read_as::(-1i32) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg value mismatch: value `-2147483648_i32` cannot be represented by type `u32` - --> $DIR/c-variadic-fail.rs:74:13 + --> $DIR/c-variadic-fail.rs:73:13 | LL | const { read_as::(i32::MIN) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#13}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -97,13 +97,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:74:5 + --> $DIR/c-variadic-fail.rs:73:5 | LL | const { read_as::(i32::MIN) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:74:5 + --> $DIR/c-variadic-fail.rs:73:5 | LL | const { read_as::(i32::MIN) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,13 +111,13 @@ LL | const { read_as::(i32::MIN) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg value mismatch: value `4294967295_u32` cannot be represented by type `i32` - --> $DIR/c-variadic-fail.rs:76:13 + --> $DIR/c-variadic-fail.rs:75:13 | LL | const { read_as::(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#14}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -125,13 +125,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:76:5 + --> $DIR/c-variadic-fail.rs:75:5 | LL | const { read_as::(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:76:5 + --> $DIR/c-variadic-fail.rs:75:5 | LL | const { read_as::(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | const { read_as::(u32::MAX) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg value mismatch: value `2147483648_u32` cannot be represented by type `i32` - --> $DIR/c-variadic-fail.rs:78:13 + --> $DIR/c-variadic-fail.rs:77:13 | LL | const { read_as::(i32::MAX as u32 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#15}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -153,13 +153,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:78:5 + --> $DIR/c-variadic-fail.rs:77:5 | LL | const { read_as::(i32::MAX as u32 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:78:5 + --> $DIR/c-variadic-fail.rs:77:5 | LL | const { read_as::(i32::MAX as u32 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,13 +167,13 @@ LL | const { read_as::(i32::MAX as u32 + 1) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg value mismatch: value `18446744073709551615_u64` cannot be represented by type `i64` - --> $DIR/c-variadic-fail.rs:80:13 + --> $DIR/c-variadic-fail.rs:79:13 | LL | const { read_as::(u64::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#16}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -181,13 +181,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:80:5 + --> $DIR/c-variadic-fail.rs:79:5 | LL | const { read_as::(u64::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:80:5 + --> $DIR/c-variadic-fail.rs:79:5 | LL | const { read_as::(u64::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -195,13 +195,13 @@ LL | const { read_as::(u64::MAX) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg value mismatch: value `9223372036854775808_u64` cannot be represented by type `i64` - --> $DIR/c-variadic-fail.rs:82:13 + --> $DIR/c-variadic-fail.rs:81:13 | LL | const { read_as::(i64::MAX as u64 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#17}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -209,13 +209,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:82:5 + --> $DIR/c-variadic-fail.rs:81:5 | LL | const { read_as::(i64::MAX as u64 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:82:5 + --> $DIR/c-variadic-fail.rs:81:5 | LL | const { read_as::(i64::MAX as u64 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -223,13 +223,13 @@ LL | const { read_as::(i64::MAX as u64 + 1) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `i32` is incompatible with next argument of type `u64` - --> $DIR/c-variadic-fail.rs:85:13 + --> $DIR/c-variadic-fail.rs:84:13 | LL | const { read_as::(1u64) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#18}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -237,13 +237,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:85:5 + --> $DIR/c-variadic-fail.rs:84:5 | LL | const { read_as::(1u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:85:5 + --> $DIR/c-variadic-fail.rs:84:5 | LL | const { read_as::(1u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -251,13 +251,13 @@ LL | const { read_as::(1u64) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `f64` is incompatible with next argument of type `i32` - --> $DIR/c-variadic-fail.rs:88:13 + --> $DIR/c-variadic-fail.rs:87:13 | LL | const { read_as::(1i32) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#19}` failed inside this call | note: inside `read_as::` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -265,13 +265,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:88:5 + --> $DIR/c-variadic-fail.rs:87:5 | LL | const { read_as::(1i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:88:5 + --> $DIR/c-variadic-fail.rs:87:5 | LL | const { read_as::(1i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -279,13 +279,13 @@ LL | const { read_as::(1i32) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `*const u16` is incompatible with next argument of type `*const c_void` - --> $DIR/c-variadic-fail.rs:111:13 + --> $DIR/c-variadic-fail.rs:110:13 | LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#12}` failed inside this call | note: inside `read_as::<*const u16>` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -293,13 +293,13 @@ note: inside `VaList::<'_>::next_arg::<*const u16>` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:111:5 + --> $DIR/c-variadic-fail.rs:110:5 | LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:111:5 + --> $DIR/c-variadic-fail.rs:110:5 | LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,13 +307,13 @@ LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `*const c_void` is incompatible with next argument of type `*const u16` - --> $DIR/c-variadic-fail.rs:113:13 + --> $DIR/c-variadic-fail.rs:112:13 | LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#13}` failed inside this call | note: inside `read_as::<*const c_void>` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -321,13 +321,13 @@ note: inside `VaList::<'_>::next_arg::<*const c_void>` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:113:5 + --> $DIR/c-variadic-fail.rs:112:5 | LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:113:5 + --> $DIR/c-variadic-fail.rs:112:5 | LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -335,13 +335,13 @@ LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `*const u16` is incompatible with next argument of type `*const i32` - --> $DIR/c-variadic-fail.rs:115:13 + --> $DIR/c-variadic-fail.rs:114:13 | LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#14}` failed inside this call | note: inside `read_as::<*const u16>` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -349,13 +349,13 @@ note: inside `VaList::<'_>::next_arg::<*const u16>` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:115:5 + --> $DIR/c-variadic-fail.rs:114:5 | LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:115:5 + --> $DIR/c-variadic-fail.rs:114:5 | LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -363,13 +363,13 @@ LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `*const u8` is incompatible with next argument of type `usize` - --> $DIR/c-variadic-fail.rs:118:13 + --> $DIR/c-variadic-fail.rs:117:13 | LL | const { read_as::<*const u8>(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#15}` failed inside this call | note: inside `read_as::<*const u8>` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -377,13 +377,13 @@ note: inside `VaList::<'_>::next_arg::<*const u8>` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:118:5 + --> $DIR/c-variadic-fail.rs:117:5 | LL | const { read_as::<*const u8>(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:118:5 + --> $DIR/c-variadic-fail.rs:117:5 | LL | const { read_as::<*const u8>(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -391,13 +391,13 @@ LL | const { read_as::<*const u8>(1usize) }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: va_arg type mismatch: requested `*const fn(&())` is incompatible with next argument of type `*const for<'a> fn(&'a ())` - --> $DIR/c-variadic-fail.rs:127:13 + --> $DIR/c-variadic-fail.rs:126:13 | LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: fn(&'a ())>()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_lifetime::{constant#1}` failed inside this call | note: inside `read_as::<*const fn(&())>` - --> $DIR/c-variadic-fail.rs:37:5 + --> $DIR/c-variadic-fail.rs:36:5 | LL | ap.next_arg::() | ^^^^^^^^^^^^^^^^^^ @@ -405,13 +405,13 @@ note: inside `VaList::<'_>::next_arg::<*const fn(&())>` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:127:5 + --> $DIR/c-variadic-fail.rs:126:5 | LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: fn(&'a ())>()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:127:5 + --> $DIR/c-variadic-fail.rs:126:5 | LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: fn(&'a ())>()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -419,7 +419,7 @@ LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling - --> $DIR/c-variadic-fail.rs:140:13 + --> $DIR/c-variadic-fail.rs:139:13 | LL | ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ evaluation of `use_after_free::{constant#0}` failed inside this call @@ -428,7 +428,7 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:136:5 + --> $DIR/c-variadic-fail.rs:135:5 | LL | / const { LL | | unsafe { @@ -439,7 +439,7 @@ LL | | }; | |_____^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:136:5 + --> $DIR/c-variadic-fail.rs:135:5 | LL | / const { LL | | unsafe { @@ -452,13 +452,13 @@ LL | | }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list - --> $DIR/c-variadic-fail.rs:162:22 + --> $DIR/c-variadic-fail.rs:161:22 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_drop::{constant#0}` failed inside this call | note: inside `manual_copy_drop::helper` - --> $DIR/c-variadic-fail.rs:159:9 + --> $DIR/c-variadic-fail.rs:158:9 | LL | drop(ap); | ^^^^^^^^ @@ -470,13 +470,13 @@ note: inside ` as Drop>::drop` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:162:5 + --> $DIR/c-variadic-fail.rs:161:5 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:162:5 + --> $DIR/c-variadic-fail.rs:161:5 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -484,13 +484,13 @@ LL | const { unsafe { helper(1, 2, 3) } }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list - --> $DIR/c-variadic-fail.rs:178:22 + --> $DIR/c-variadic-fail.rs:177:22 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_forget::{constant#0}` failed inside this call | note: inside `manual_copy_forget::helper` - --> $DIR/c-variadic-fail.rs:175:9 + --> $DIR/c-variadic-fail.rs:174:9 | LL | drop(ap); | ^^^^^^^^ @@ -502,13 +502,13 @@ note: inside ` as Drop>::drop` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:178:5 + --> $DIR/c-variadic-fail.rs:177:5 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:178:5 + --> $DIR/c-variadic-fail.rs:177:5 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -516,13 +516,13 @@ LL | const { unsafe { helper(1, 2, 3) } }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list - --> $DIR/c-variadic-fail.rs:191:22 + --> $DIR/c-variadic-fail.rs:190:22 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_read::{constant#0}` failed inside this call | note: inside `manual_copy_read::helper` - --> $DIR/c-variadic-fail.rs:188:17 + --> $DIR/c-variadic-fail.rs:187:17 | LL | let _ = ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ @@ -530,13 +530,13 @@ note: inside `VaList::<'_>::next_arg::` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:191:5 + --> $DIR/c-variadic-fail.rs:190:5 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:191:5 + --> $DIR/c-variadic-fail.rs:190:5 | LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -544,7 +544,7 @@ LL | const { unsafe { helper(1, 2, 3) } }; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got null pointer - --> $DIR/c-variadic-fail.rs:199:5 + --> $DIR/c-variadic-fail.rs:198:5 | LL | } | ^ evaluation of `drop_of_invalid::{constant#0}` failed inside this call @@ -555,7 +555,7 @@ note: inside ` as Drop>::drop` --> $SRC_DIR/core/src/ffi/va_list.rs:LL:COL note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:196:5 + --> $DIR/c-variadic-fail.rs:195:5 | LL | / const { LL | | let mut invalid: MaybeUninit = MaybeUninit::zeroed(); @@ -564,7 +564,7 @@ LL | | } | |_____^ note: erroneous constant encountered - --> $DIR/c-variadic-fail.rs:196:5 + --> $DIR/c-variadic-fail.rs:195:5 | LL | / const { LL | | let mut invalid: MaybeUninit = MaybeUninit::zeroed(); diff --git a/tests/ui/consts/const-eval/c-variadic-ignored-argument.rs b/tests/ui/consts/const-eval/c-variadic-ignored-argument.rs index fe700eea186e0..506d6ad5fee23 100644 --- a/tests/ui/consts/const-eval/c-variadic-ignored-argument.rs +++ b/tests/ui/consts/const-eval/c-variadic-ignored-argument.rs @@ -1,6 +1,5 @@ //@ build-pass //@ compile-flags: --emit=obj -#![feature(c_variadic)] #![feature(const_c_variadic)] #![feature(const_destruct)] #![crate_type = "lib"] diff --git a/tests/ui/consts/const-eval/c-variadic.rs b/tests/ui/consts/const-eval/c-variadic.rs index b8f02ea8a0848..6dba6e1af5997 100644 --- a/tests/ui/consts/const-eval/c-variadic.rs +++ b/tests/ui/consts/const-eval/c-variadic.rs @@ -2,7 +2,6 @@ //@ run-pass //@ ignore-backends: gcc -#![feature(c_variadic)] #![feature(const_c_variadic)] #![feature(const_destruct)] #![feature(const_cmp)] diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr index 2bb6d2b8fef7c..1c514f337817f 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -16,7 +16,7 @@ error: constant BAD_PATTERN cannot be used as pattern LL | BAD_PATTERN => {}, | ^^^^^^^^^^^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr index 1bd031f163483..42e2bfb4ce4a3 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -15,7 +15,7 @@ error: constant extern_::C cannot be used as pattern LL | C => {} | ^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns error: constant mutable::C cannot be used as pattern --> $DIR/const_refs_to_static_fail_invalid.rs:43:9 @@ -23,7 +23,7 @@ error: constant mutable::C cannot be used as pattern LL | C => {} | ^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns error: aborting due to 3 previous errors diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index bf7d6eecb7c3a..852b4518a920c 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -22,7 +22,7 @@ error: constant REF_INTERIOR_MUT cannot be used as pattern LL | REF_INTERIOR_MUT => {}, | ^^^^^^^^^^^^^^^^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index c2b730375f2c2..1ec49bff3e894 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -10,7 +10,7 @@ error: constant SLICE_MUT cannot be used as pattern LL | SLICE_MUT => true, | ^^^^^^^^^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns error: constant U8_MUT cannot be used as pattern --> $DIR/const_refers_to_static_cross_crate.rs:44:9 @@ -18,7 +18,7 @@ error: constant U8_MUT cannot be used as pattern LL | U8_MUT => true, | ^^^^^^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns error: constant U8_MUT2 cannot be used as pattern --> $DIR/const_refers_to_static_cross_crate.rs:53:9 @@ -26,7 +26,7 @@ error: constant U8_MUT2 cannot be used as pattern LL | U8_MUT2 => true, | ^^^^^^^ | - = note: constants that reference mutable or external memory cannot be used as patterns + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns error: aborting due to 4 previous errors diff --git a/tests/ui/delegation/auxiliary/fn-header-aux.rs b/tests/ui/delegation/auxiliary/fn-header-aux.rs index d26209a4f789f..82ac8ed9d65d4 100644 --- a/tests/ui/delegation/auxiliary/fn-header-aux.rs +++ b/tests/ui/delegation/auxiliary/fn-header-aux.rs @@ -1,7 +1,5 @@ //@ edition:2018 -#![feature(c_variadic)] - pub unsafe fn unsafe_fn_extern() {} pub extern "C" fn extern_fn_extern() {} pub unsafe extern "C" fn variadic_fn_extern(n: usize, mut args: ...) {} diff --git a/tests/ui/delegation/fn-header-variadic.rs b/tests/ui/delegation/fn-header-variadic.rs index b5056f48a9be4..051be3a51502d 100644 --- a/tests/ui/delegation/fn-header-variadic.rs +++ b/tests/ui/delegation/fn-header-variadic.rs @@ -1,7 +1,6 @@ //@ aux-crate:fn_header_aux=fn-header-aux.rs //@ ignore-backends: gcc -#![feature(c_variadic)] #![feature(fn_delegation)] mod to_reuse { diff --git a/tests/ui/delegation/fn-header-variadic.stderr b/tests/ui/delegation/fn-header-variadic.stderr index 688a965fb4d5c..a0b5a6313d080 100644 --- a/tests/ui/delegation/fn-header-variadic.stderr +++ b/tests/ui/delegation/fn-header-variadic.stderr @@ -1,5 +1,5 @@ error: delegation to C-variadic functions is not allowed - --> $DIR/fn-header-variadic.rs:11:17 + --> $DIR/fn-header-variadic.rs:10:17 | LL | pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {} | ------------------------------------------------------------- callee defined here @@ -8,12 +8,12 @@ LL | reuse to_reuse::variadic_fn; | ^^^^^^^^^^^ error: delegation to C-variadic functions is not allowed - --> $DIR/fn-header-variadic.rs:13:22 + --> $DIR/fn-header-variadic.rs:12:22 | LL | reuse fn_header_aux::variadic_fn_extern; | ^^^^^^^^^^^^^^^^^^ | - ::: $DIR/auxiliary/fn-header-aux.rs:7:1 + ::: $DIR/auxiliary/fn-header-aux.rs:5:1 | LL | pub unsafe extern "C" fn variadic_fn_extern(n: usize, mut args: ...) {} | -------------------------------------------------------------------- callee defined here diff --git a/tests/ui/delegation/fn-header.rs b/tests/ui/delegation/fn-header.rs index d3fb6fb88ed59..16e3c10136ce0 100644 --- a/tests/ui/delegation/fn-header.rs +++ b/tests/ui/delegation/fn-header.rs @@ -3,7 +3,6 @@ //@ aux-crate:fn_header_aux=fn-header-aux.rs //@ ignore-backends: gcc -#![feature(c_variadic)] #![feature(fn_delegation)] #![deny(unused_unsafe)] diff --git a/tests/ui/delegation/unsupported.current.stderr b/tests/ui/delegation/unsupported.current.stderr index 6cdd54e2e27fc..075dfbe7622fe 100644 --- a/tests/ui/delegation/unsupported.current.stderr +++ b/tests/ui/delegation/unsupported.current.stderr @@ -1,23 +1,23 @@ -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:30:25 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ | = note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle + = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition = note: for more information, see and -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:33:24 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ | = note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle + = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition = note: for more information, see and error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/unsupported.next.stderr b/tests/ui/delegation/unsupported.next.stderr index 6cdd54e2e27fc..075dfbe7622fe 100644 --- a/tests/ui/delegation/unsupported.next.stderr +++ b/tests/ui/delegation/unsupported.next.stderr @@ -1,23 +1,23 @@ -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:30:25 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ | = note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle + = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition = note: for more information, see and -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:33:24 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ | = note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle - = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle + = note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition = note: for more information, see and error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/unsupported.rs b/tests/ui/delegation/unsupported.rs index 3da1206b5b2df..7514d51f0f9ed 100644 --- a/tests/ui/delegation/unsupported.rs +++ b/tests/ui/delegation/unsupported.rs @@ -8,7 +8,6 @@ // If we end up in a query cycle, it should be okay as long as results are the same. #![feature(const_trait_impl)] -#![feature(c_variadic)] #![feature(fn_delegation)] mod opaque { diff --git a/tests/ui/explicit-tail-calls/c-variadic.rs b/tests/ui/explicit-tail-calls/c-variadic.rs index affe90c606526..c4bbf5956fc3d 100644 --- a/tests/ui/explicit-tail-calls/c-variadic.rs +++ b/tests/ui/explicit-tail-calls/c-variadic.rs @@ -1,5 +1,5 @@ #![expect(incomplete_features)] -#![feature(c_variadic, explicit_tail_calls)] +#![feature(explicit_tail_calls)] #![allow(unused)] unsafe extern "C" fn foo(mut ap: ...) -> u32 { diff --git a/tests/ui/explicit-tail-calls/signature-mismatch.rs b/tests/ui/explicit-tail-calls/signature-mismatch.rs index bed480f60f63b..a70c952faf76e 100644 --- a/tests/ui/explicit-tail-calls/signature-mismatch.rs +++ b/tests/ui/explicit-tail-calls/signature-mismatch.rs @@ -1,6 +1,5 @@ #![expect(incomplete_features)] #![feature(explicit_tail_calls, rust_tail_cc)] -#![feature(c_variadic)] fn _f0((): ()) { become _g0(); //~ error: mismatched signatures diff --git a/tests/ui/explicit-tail-calls/signature-mismatch.stderr b/tests/ui/explicit-tail-calls/signature-mismatch.stderr index 6e26f1c075539..63f15c06a09c0 100644 --- a/tests/ui/explicit-tail-calls/signature-mismatch.stderr +++ b/tests/ui/explicit-tail-calls/signature-mismatch.stderr @@ -1,5 +1,5 @@ error: mismatched signatures - --> $DIR/signature-mismatch.rs:6:5 + --> $DIR/signature-mismatch.rs:5:5 | LL | become _g0(); | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | become _g0(); = note: callee signature: `fn()` error: mismatched signatures - --> $DIR/signature-mismatch.rs:12:5 + --> $DIR/signature-mismatch.rs:11:5 | LL | become _g1(()); | ^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | become _g1(()); = note: callee signature: `fn(())` error: mismatched function ABIs - --> $DIR/signature-mismatch.rs:18:5 + --> $DIR/signature-mismatch.rs:17:5 | LL | become _g2(); | ^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | become _g2(); = note: caller ABI is `"C"`, while callee ABI is `"Rust"` error: mismatched function ABIs - --> $DIR/signature-mismatch.rs:24:5 + --> $DIR/signature-mismatch.rs:23:5 | LL | become _g3(); | ^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | become _g3(); = note: caller ABI is `"Rust"`, while callee ABI is `"C"` error: mismatched function ABIs - --> $DIR/signature-mismatch.rs:34:5 + --> $DIR/signature-mismatch.rs:33:5 | LL | become _tailcc(); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs b/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs index bf52c4d0cf526..1fc0ac4198937 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs +++ b/tests/ui/feature-gates/feature-gate-c_variadic-naked-functions.rs @@ -4,7 +4,7 @@ //@ ignore-backends: gcc #![feature(no_core, lang_items, rustc_attrs)] -#![feature(c_variadic, abi_x86_interrupt, naked_functions_rustic_abi)] +#![feature(abi_x86_interrupt, naked_functions_rustic_abi)] #![crate_type = "rlib"] #![no_core] diff --git a/tests/ui/feature-gates/feature-gate-c_variadic.rs b/tests/ui/feature-gates/feature-gate-c_variadic.rs deleted file mode 100644 index 649816b48d784..0000000000000 --- a/tests/ui/feature-gates/feature-gate-c_variadic.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_type = "lib"] - -pub unsafe extern "C" fn test(_: i32, ap: ...) {} -//~^ ERROR C-variadic functions are unstable - -trait Trait { - unsafe extern "C" fn trait_test(_: i32, ap: ...) {} - //~^ ERROR C-variadic functions are unstable -} diff --git a/tests/ui/feature-gates/feature-gate-c_variadic.stderr b/tests/ui/feature-gates/feature-gate-c_variadic.stderr deleted file mode 100644 index ae880093b980c..0000000000000 --- a/tests/ui/feature-gates/feature-gate-c_variadic.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: C-variadic functions are unstable - --> $DIR/feature-gate-c_variadic.rs:3:1 - | -LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #44930 for more information - = help: add `#![feature(c_variadic)]` 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[E0658]: C-variadic functions are unstable - --> $DIR/feature-gate-c_variadic.rs:7:5 - | -LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #44930 for more information - = help: add `#![feature(c_variadic)]` 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 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs index 98b5f063d5844..49c0bdf3a724b 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs @@ -17,7 +17,7 @@ // //@[msp430] compile-flags: --target msp430-none-elf -Ctarget-cpu=msp430 //@[msp430] needs-llvm-components: msp430 -#![feature(no_core, lang_items, rustc_attrs, c_variadic)] +#![feature(no_core, lang_items, rustc_attrs)] #![crate_type = "rlib"] #![no_core] diff --git a/tests/ui/feature-gates/feature-gate-const-c-variadic.rs b/tests/ui/feature-gates/feature-gate-const-c-variadic.rs index 4e8b3c54b1fd1..efb2e3d4b8ece 100644 --- a/tests/ui/feature-gates/feature-gate-const-c-variadic.rs +++ b/tests/ui/feature-gates/feature-gate-const-c-variadic.rs @@ -1,5 +1,3 @@ -#![feature(c_variadic)] - fn main() { const unsafe extern "C" fn foo(ap: ...) { //~^ ERROR c-variadic const function definitions are unstable diff --git a/tests/ui/feature-gates/feature-gate-const-c-variadic.stderr b/tests/ui/feature-gates/feature-gate-const-c-variadic.stderr index 8fd85be08fca4..43bdfbcb3e250 100644 --- a/tests/ui/feature-gates/feature-gate-const-c-variadic.stderr +++ b/tests/ui/feature-gates/feature-gate-const-c-variadic.stderr @@ -1,5 +1,5 @@ error[E0658]: c-variadic const function definitions are unstable - --> $DIR/feature-gate-const-c-variadic.rs:4:5 + --> $DIR/feature-gate-const-c-variadic.rs:2:5 | LL | const unsafe extern "C" fn foo(ap: ...) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const unsafe extern "C" fn foo(ap: ...) { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0015]: calling const c-variadic functions is unstable in constants - --> $DIR/feature-gate-const-c-variadic.rs:9:22 + --> $DIR/feature-gate-const-c-variadic.rs:7:22 | LL | const { unsafe { foo() } } | ^^^^^ diff --git a/tests/ui/force-inlining/early-deny.rs b/tests/ui/force-inlining/early-deny.rs index 99b03a4e0e2ce..ca45c2c4c0cc1 100644 --- a/tests/ui/force-inlining/early-deny.rs +++ b/tests/ui/force-inlining/early-deny.rs @@ -1,21 +1,17 @@ //@ check-fail //@ compile-flags: --crate-type=lib -#![feature(c_variadic)] #![feature(rustc_attrs)] #[rustc_no_mir_inline] #[rustc_force_inline] //~^ ERROR `rustc_attr` is incompatible with `#[rustc_force_inline]` -pub fn rustc_attr() { -} +pub fn rustc_attr() {} #[cold] #[rustc_force_inline] //~^ ERROR `cold` is incompatible with `#[rustc_force_inline]` -pub fn cold() { -} +pub fn cold() {} #[rustc_force_inline] //~^ ERROR `variadic` is incompatible with `#[rustc_force_inline]` -pub unsafe extern "C" fn variadic(args: ...) { -} +pub unsafe extern "C" fn variadic(args: ...) {} diff --git a/tests/ui/force-inlining/early-deny.stderr b/tests/ui/force-inlining/early-deny.stderr index abee66fd293c6..53d9e09d5e616 100644 --- a/tests/ui/force-inlining/early-deny.stderr +++ b/tests/ui/force-inlining/early-deny.stderr @@ -1,32 +1,32 @@ error: `rustc_attr` is incompatible with `#[rustc_force_inline]` - --> $DIR/early-deny.rs:7:1 + --> $DIR/early-deny.rs:6:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ LL | -LL | pub fn rustc_attr() { +LL | pub fn rustc_attr() {} | ------------------- `rustc_attr` defined here | = note: incompatible due to: #[rustc_no_mir_inline] error: `cold` is incompatible with `#[rustc_force_inline]` - --> $DIR/early-deny.rs:13:1 + --> $DIR/early-deny.rs:11:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ LL | -LL | pub fn cold() { +LL | pub fn cold() {} | ------------- `cold` defined here | = note: incompatible due to: cold error: `variadic` is incompatible with `#[rustc_force_inline]` - --> $DIR/early-deny.rs:18:1 + --> $DIR/early-deny.rs:15:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ LL | -LL | pub unsafe extern "C" fn variadic(args: ...) { +LL | pub unsafe extern "C" fn variadic(args: ...) {} | -------------------------------------------- `variadic` defined here | = note: incompatible due to: C variadic diff --git a/tests/ui/inference/note-and-explain-ReVar-124973.rs b/tests/ui/inference/note-and-explain-ReVar-124973.rs index 8c04648d57b2d..ff68c53c0f028 100644 --- a/tests/ui/inference/note-and-explain-ReVar-124973.rs +++ b/tests/ui/inference/note-and-explain-ReVar-124973.rs @@ -1,7 +1,5 @@ //@ edition:2018 -#![feature(c_variadic)] - async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) {} //~^ ERROR functions cannot be both `async` and C-variadic //~| ERROR hidden type for `impl Future` captures lifetime that does not appear in bounds diff --git a/tests/ui/inference/note-and-explain-ReVar-124973.stderr b/tests/ui/inference/note-and-explain-ReVar-124973.stderr index 2b5e79e9a1c64..3610fa82754b9 100644 --- a/tests/ui/inference/note-and-explain-ReVar-124973.stderr +++ b/tests/ui/inference/note-and-explain-ReVar-124973.stderr @@ -1,11 +1,11 @@ error: functions cannot be both `async` and C-variadic - --> $DIR/note-and-explain-ReVar-124973.rs:5:1 + --> $DIR/note-and-explain-ReVar-124973.rs:3:1 | LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) {} | ^^^^^ `async` because of this ^^^^^^ C-variadic because of this error[E0700]: hidden type for `impl Future` captures lifetime that does not appear in bounds - --> $DIR/note-and-explain-ReVar-124973.rs:5:76 + --> $DIR/note-and-explain-ReVar-124973.rs:3:76 | LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) {} | -^^ diff --git a/tests/ui/lint/function-item-references.rs b/tests/ui/lint/function-item-references.rs index 4f2fc4de8632e..5afd8341473f3 100644 --- a/tests/ui/lint/function-item-references.rs +++ b/tests/ui/lint/function-item-references.rs @@ -1,5 +1,6 @@ //@ check-pass -#![feature(c_variadic)] +#![feature(custom_inner_attributes)] // for top-level rustfmt::skip +#![rustfmt::skip] #![warn(function_item_references)] use std::fmt::Pointer; use std::fmt::Formatter; diff --git a/tests/ui/lint/function-item-references.stderr b/tests/ui/lint/function-item-references.stderr index a9d18bb6a4743..837a4b2087fdf 100644 --- a/tests/ui/lint/function-item-references.stderr +++ b/tests/ui/lint/function-item-references.stderr @@ -1,203 +1,203 @@ warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:44:18 + --> $DIR/function-item-references.rs:45:18 | LL | Pointer::fmt(&zst_ref, f) | ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` | note: the lint level is defined here - --> $DIR/function-item-references.rs:3:9 + --> $DIR/function-item-references.rs:4:9 | LL | #![warn(function_item_references)] | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:81:22 + --> $DIR/function-item-references.rs:82:22 | LL | println!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:83:20 + --> $DIR/function-item-references.rs:84:20 | LL | print!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:85:21 + --> $DIR/function-item-references.rs:86:21 | LL | format!("{:p}", &foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:88:22 + --> $DIR/function-item-references.rs:89:22 | LL | println!("{:p}", &foo as *const _); | ^^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:90:22 + --> $DIR/function-item-references.rs:91:22 | LL | println!("{:p}", zst_ref); | ^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:92:22 + --> $DIR/function-item-references.rs:93:22 | LL | println!("{:p}", cast_zst_ptr); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:94:22 + --> $DIR/function-item-references.rs:95:22 | LL | println!("{:p}", coerced_zst_ptr); | ^^^^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:97:22 + --> $DIR/function-item-references.rs:98:22 | LL | println!("{:p}", &fn_item); | ^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:99:22 + --> $DIR/function-item-references.rs:100:22 | LL | println!("{:p}", indirect_ref); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:102:22 + --> $DIR/function-item-references.rs:103:22 | LL | println!("{:p}", &nop); | ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:104:22 + --> $DIR/function-item-references.rs:105:22 | LL | println!("{:p}", &bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:106:22 + --> $DIR/function-item-references.rs:107:22 | LL | println!("{:p}", &baz); | ^^^^ help: cast `baz` to obtain a function pointer: `baz as fn(_, _) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:108:22 + --> $DIR/function-item-references.rs:109:22 | LL | println!("{:p}", &unsafe_fn); | ^^^^^^^^^^ help: cast `unsafe_fn` to obtain a function pointer: `unsafe_fn as unsafe fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:110:22 + --> $DIR/function-item-references.rs:111:22 | LL | println!("{:p}", &c_fn); | ^^^^^ help: cast `c_fn` to obtain a function pointer: `c_fn as extern "C" fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:112:22 + --> $DIR/function-item-references.rs:113:22 | LL | println!("{:p}", &unsafe_c_fn); | ^^^^^^^^^^^^ help: cast `unsafe_c_fn` to obtain a function pointer: `unsafe_c_fn as unsafe extern "C" fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:114:22 + --> $DIR/function-item-references.rs:115:22 | LL | println!("{:p}", &variadic); | ^^^^^^^^^ help: cast `variadic` to obtain a function pointer: `variadic as unsafe extern "C" fn(_, ...)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:116:22 + --> $DIR/function-item-references.rs:117:22 | LL | println!("{:p}", &take_generic_ref::); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_ref` to obtain a function pointer: `take_generic_ref:: as fn(_)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:118:22 + --> $DIR/function-item-references.rs:119:22 | LL | println!("{:p}", &take_generic_array::); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_array` to obtain a function pointer: `take_generic_array:: as fn(_)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:120:22 + --> $DIR/function-item-references.rs:121:22 | LL | println!("{:p}", &multiple_generic::); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `multiple_generic` to obtain a function pointer: `multiple_generic:: as fn(_, _)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:122:22 + --> $DIR/function-item-references.rs:123:22 | LL | println!("{:p}", &multiple_generic_arrays::); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `multiple_generic_arrays` to obtain a function pointer: `multiple_generic_arrays:: as fn(_, _)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:124:22 + --> $DIR/function-item-references.rs:125:22 | LL | println!("{:p}", &std::env::var::); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `var` to obtain a function pointer: `var:: as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:127:32 + --> $DIR/function-item-references.rs:128:32 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `nop` to obtain a function pointer: `nop as fn()` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:127:38 + --> $DIR/function-item-references.rs:128:38 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:127:44 + --> $DIR/function-item-references.rs:128:44 | LL | println!("{:p} {:p} {:p}", &nop, &foo, &bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:142:41 + --> $DIR/function-item-references.rs:143:41 | LL | std::mem::transmute::<_, usize>(&foo); | ^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:144:50 + --> $DIR/function-item-references.rs:145:50 | LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:144:50 + --> $DIR/function-item-references.rs:145:50 | LL | std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:147:41 + --> $DIR/function-item-references.rs:148:41 | LL | std::mem::transmute::<_, usize>(&take_generic_ref::); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: cast `take_generic_ref` to obtain a function pointer: `take_generic_ref:: as fn(_)` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:156:15 + --> $DIR/function-item-references.rs:157:15 | LL | print_ptr(&bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:158:24 + --> $DIR/function-item-references.rs:159:24 | LL | bound_by_ptr_trait(&bar); | ^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:160:30 + --> $DIR/function-item-references.rs:161:30 | LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `bar` to obtain a function pointer: `bar as fn(_) -> _` warning: taking a reference to a function item does not give a function pointer - --> $DIR/function-item-references.rs:160:30 + --> $DIR/function-item-references.rs:161:30 | LL | bound_by_ptr_trait_tuple((&foo, &bar)); | ^^^^^^^^^^^^ help: cast `foo` to obtain a function pointer: `foo as fn() -> _` diff --git a/tests/ui/lint/runtime-symbols-unix.rs b/tests/ui/lint/runtime-symbols-unix.rs index fcb7540be6a3b..6c42c706de0b9 100644 --- a/tests/ui/lint/runtime-symbols-unix.rs +++ b/tests/ui/lint/runtime-symbols-unix.rs @@ -5,7 +5,6 @@ //@ normalize-stderr: "\*const [iu]8" -> "*const U8" #![feature(linkage)] -#![feature(c_variadic)] #![allow(clashing_extern_declarations)] // we are voluntarily testing different definitions use core::ffi::{c_char, c_int, c_void}; diff --git a/tests/ui/lint/runtime-symbols-unix.stderr b/tests/ui/lint/runtime-symbols-unix.stderr index 11fed56a7e785..fbb1fbd2e8d4a 100644 --- a/tests/ui/lint/runtime-symbols-unix.stderr +++ b/tests/ui/lint/runtime-symbols-unix.stderr @@ -1,5 +1,5 @@ error: invalid definition of the runtime `open` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:15:5 + --> $DIR/runtime-symbols-unix.rs:14:5 | LL | pub fn open() {} | ^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | pub fn open() {} = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default error: invalid definition of the runtime `read` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:19:9 + --> $DIR/runtime-symbols-unix.rs:18:9 | LL | pub fn read(); | ^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | pub fn read(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "read")]`, or `#[link_name = "read"]` error: invalid definition of the runtime `write` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:22:9 + --> $DIR/runtime-symbols-unix.rs:21:9 | LL | pub fn write(); | ^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | pub fn write(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "write")]`, or `#[link_name = "write"]` error: invalid definition of the runtime `close` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:27:5 + --> $DIR/runtime-symbols-unix.rs:26:5 | LL | pub static close: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | pub static close: () = (); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]` error: invalid definition of the runtime `malloc` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:31:9 + --> $DIR/runtime-symbols-unix.rs:30:9 | LL | pub fn malloc(); | ^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | pub fn malloc(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]` error: invalid definition of the runtime `realloc` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:34:9 + --> $DIR/runtime-symbols-unix.rs:33:9 | LL | pub fn realloc(); | ^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | pub fn realloc(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "realloc")]`, or `#[link_name = "realloc"]` error: invalid definition of the runtime `free` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:37:9 + --> $DIR/runtime-symbols-unix.rs:36:9 | LL | pub fn free(); | ^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | pub fn free(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "free")]`, or `#[link_name = "free"]` error: invalid definition of the runtime `exit` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:40:9 + --> $DIR/runtime-symbols-unix.rs:39:9 | LL | pub fn exit(); | ^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | pub fn exit(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "exit")]`, or `#[link_name = "exit"]` warning: suspicious definition of the runtime `open` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:47:9 + --> $DIR/runtime-symbols-unix.rs:46:9 | LL | pub fn open(path: *const U8, oflag: usize, ...) -> c_int; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | pub fn open(path: *const U8, oflag: usize, ...) -> c_int; = note: `#[warn(suspicious_runtime_symbol_definitions)]` on by default warning: suspicious definition of the runtime `free` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:50:9 + --> $DIR/runtime-symbols-unix.rs:49:9 | LL | pub fn free(ptr: *const U8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | pub fn free(ptr: *const U8); = help: allow this lint if the signature is compatible warning: suspicious definition of the runtime `exit` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:53:9 + --> $DIR/runtime-symbols-unix.rs:52:9 | LL | pub fn exit(code: f32) -> !; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | pub fn exit(code: f32) -> !; = help: allow this lint if the signature is compatible warning: suspicious definition of the runtime `exit` symbol used by the standard library - --> $DIR/runtime-symbols-unix.rs:58:9 + --> $DIR/runtime-symbols-unix.rs:57:9 | LL | pub static exit2: Option !>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/runtime-symbols.rs b/tests/ui/lint/runtime-symbols.rs index 9f7ff98e73b03..e51b101572031 100644 --- a/tests/ui/lint/runtime-symbols.rs +++ b/tests/ui/lint/runtime-symbols.rs @@ -4,7 +4,6 @@ //@ normalize-stderr: "\*const [iu]8" -> "*const U8" #![feature(linkage)] -#![feature(c_variadic)] #![allow(clashing_extern_declarations)] // we are voluntarily testing different definitions use core::ffi::{c_char, c_int, c_void}; diff --git a/tests/ui/lint/runtime-symbols.stderr b/tests/ui/lint/runtime-symbols.stderr index 6adc96460c42e..dca6e85c282e3 100644 --- a/tests/ui/lint/runtime-symbols.stderr +++ b/tests/ui/lint/runtime-symbols.stderr @@ -1,5 +1,5 @@ error: invalid definition of the runtime `memmove` symbol used by the standard library - --> $DIR/runtime-symbols.rs:14:5 + --> $DIR/runtime-symbols.rs:13:5 | LL | pub fn memmove() {} | ^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | pub fn memmove() {} = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default error: invalid definition of the runtime `memset` symbol used by the standard library - --> $DIR/runtime-symbols.rs:18:9 + --> $DIR/runtime-symbols.rs:17:9 | LL | pub fn memset(); | ^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | pub fn memset(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "memset")]`, or `#[link_name = "memset"]` error: invalid definition of the runtime `memcmp` symbol used by the standard library - --> $DIR/runtime-symbols.rs:21:9 + --> $DIR/runtime-symbols.rs:20:9 | LL | pub fn memcmp(); | ^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | pub fn memcmp(); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "memcmp")]`, or `#[link_name = "memcmp"]` error: invalid definition of the runtime `strlen` symbol used by the standard library - --> $DIR/runtime-symbols.rs:26:5 + --> $DIR/runtime-symbols.rs:25:5 | LL | pub static strlen: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | pub static strlen: () = (); = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "strlen")]`, or `#[link_name = "strlen"]` error: invalid definition of the runtime `strlen` symbol used by the standard library - --> $DIR/runtime-symbols.rs:32:9 + --> $DIR/runtime-symbols.rs:31:9 | LL | static strlen2: Option; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | static strlen2: Option; = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "strlen")]`, or `#[link_name = "strlen"]` error: invalid definition of the runtime `memcpy` symbol used by the standard library - --> $DIR/runtime-symbols.rs:38:5 + --> $DIR/runtime-symbols.rs:37:5 | LL | pub fn memcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut c_void { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | pub fn memcpy(dest: *mut c_void, src: *const c_void, n: usize) -> *mut = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "memcpy")]`, or `#[link_name = "memcpy"]` error: invalid definition of the runtime `bcmp` symbol used by the standard library - --> $DIR/runtime-symbols.rs:45:5 + --> $DIR/runtime-symbols.rs:44:5 | LL | pub unsafe extern "C" fn bcmp(s1: *const c_void, s2: *const c_void, n: usize, _: ...) -> c_int { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | pub unsafe extern "C" fn bcmp(s1: *const c_void, s2: *const c_void, n: = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "bcmp")]`, or `#[link_name = "bcmp"]` error: invalid definition of the runtime `bcmp` symbol used by the standard library - --> $DIR/runtime-symbols.rs:52:5 + --> $DIR/runtime-symbols.rs:51:5 | LL | pub extern "C" fn bcmp_(s1: *const c_void, s2: *const c_void, n: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | pub extern "C" fn bcmp_(s1: *const c_void, s2: *const c_void, n: usize) = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "bcmp")]`, or `#[link_name = "bcmp"]` warning: suspicious definition of the runtime `memcpy` symbol used by the standard library - --> $DIR/runtime-symbols.rs:58:5 + --> $DIR/runtime-symbols.rs:57:5 | LL | pub extern "C" fn memcpy(dest: *mut c_void, src: *const c_void, n: i64) -> *mut c_void { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | pub extern "C" fn memcpy(dest: *mut c_void, src: *const c_void, n: i64) = note: `#[warn(suspicious_runtime_symbol_definitions)]` on by default warning: suspicious definition of the runtime `memmove` symbol used by the standard library - --> $DIR/runtime-symbols.rs:64:5 + --> $DIR/runtime-symbols.rs:63:5 | LL | pub extern "C" fn memmove(dest: *mut c_void, src: *const c_void, n: i64) -> *mut c_void { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | pub extern "C" fn memmove(dest: *mut c_void, src: *const c_void, n: i64 = help: allow this lint if the signature is compatible warning: suspicious definition of the runtime `memset` symbol used by the standard library - --> $DIR/runtime-symbols.rs:70:9 + --> $DIR/runtime-symbols.rs:69:9 | LL | fn memset(s: *mut c_void, c: c_int, n: usize) -> f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | fn memset(s: *mut c_void, c: c_int, n: usize) -> f64; = help: allow this lint if the signature is compatible warning: suspicious definition of the runtime `bcmp` symbol used by the standard library - --> $DIR/runtime-symbols.rs:75:5 + --> $DIR/runtime-symbols.rs:74:5 | LL | pub extern "C" fn bcmp_(s1: *const U8, s2: *const U8, n: usize) -> c_int { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -125,7 +125,7 @@ LL | pub extern "C" fn bcmp_(s1: *const U8, s2: *const U8, n: usize) -> c_in = help: allow this lint if the signature is compatible warning: suspicious definition of the runtime `strlen` symbol used by the standard library - --> $DIR/runtime-symbols.rs:81:5 + --> $DIR/runtime-symbols.rs:80:5 | LL | pub extern "C" fn strlen(s: *const u64) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mir/issue-83499-input-output-iteration-ice.rs b/tests/ui/mir/issue-83499-input-output-iteration-ice.rs index 4c547356716c2..7ff04b4573a3a 100644 --- a/tests/ui/mir/issue-83499-input-output-iteration-ice.rs +++ b/tests/ui/mir/issue-83499-input-output-iteration-ice.rs @@ -1,7 +1,5 @@ // Test that when in MIR the amount of local_decls and amount of normalized_input_tys don't match // that an out-of-bounds access does not occur. -#![feature(c_variadic)] - fn main() {} unsafe extern "C" fn foo(_: Bar, _: ...) -> impl {} diff --git a/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr b/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr index 2ce695ce79d93..c7a150763871e 100644 --- a/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr +++ b/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr @@ -1,11 +1,11 @@ error: at least one trait must be specified - --> $DIR/issue-83499-input-output-iteration-ice.rs:7:45 + --> $DIR/issue-83499-input-output-iteration-ice.rs:5:45 | LL | unsafe extern "C" fn foo(_: Bar, _: ...) -> impl {} | ^^^^ error[E0425]: cannot find type `Bar` in this scope - --> $DIR/issue-83499-input-output-iteration-ice.rs:7:29 + --> $DIR/issue-83499-input-output-iteration-ice.rs:5:29 | LL | unsafe extern "C" fn foo(_: Bar, _: ...) -> impl {} | ^^^ not found in this scope diff --git a/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.rs b/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.rs index 60a3b47010e29..a49a3ecd460e6 100644 --- a/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.rs +++ b/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.rs @@ -1,5 +1,3 @@ -#![feature(c_variadic)] - // Regression test that covers all 3 cases of https://github.com/rust-lang/rust/issues/130372 unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {} diff --git a/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr b/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr index b949b4ea298ad..0771bcda65b36 100644 --- a/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr +++ b/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr @@ -1,11 +1,11 @@ error[E0060]: this function takes at least 1 argument but 0 arguments were supplied - --> $DIR/mismatch-args-vargs-issue-130372.rs:9:9 + --> $DIR/mismatch-args-vargs-issue-130372.rs:7:9 | LL | test_va_copy(); | ^^^^^^^^^^^^-- argument #1 of type `u64` is missing | note: function defined here - --> $DIR/mismatch-args-vargs-issue-130372.rs:5:22 + --> $DIR/mismatch-args-vargs-issue-130372.rs:3:22 | LL | unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {} | ^^^^^^^^^^^^ ------ diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs index 4e038875d78f8..170bd7a86253f 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -1,4 +1,3 @@ -#![feature(c_variadic)] #![allow(anonymous_parameters)] fn main() {} diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr index ea9f9baa58ba2..0524423ccbd33 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -1,5 +1,5 @@ error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:6:19 + --> $DIR/variadic-ffi-semantic-restrictions.rs:5:19 | LL | fn f1_1(x: isize, _: ...) {} | ^^^^^^ @@ -7,7 +7,7 @@ LL | fn f1_1(x: isize, _: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:9:9 + --> $DIR/variadic-ffi-semantic-restrictions.rs:8:9 | LL | fn f1_2(_: ...) {} | ^^^^^^ @@ -15,7 +15,7 @@ LL | fn f1_2(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "Rust"` functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:12:30 + --> $DIR/variadic-ffi-semantic-restrictions.rs:11:30 | LL | unsafe extern "Rust" fn f1_3(_: ...) {} | ------------- ^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe extern "Rust" fn f1_3(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: functions with a C variable argument list must be unsafe - --> $DIR/variadic-ffi-semantic-restrictions.rs:15:30 + --> $DIR/variadic-ffi-semantic-restrictions.rs:14:30 | LL | extern "C" fn f2_1(x: isize, _: ...) {} | ^^^^^^ @@ -36,7 +36,7 @@ LL | unsafe extern "C" fn f2_1(x: isize, _: ...) {} | ++++++ error: functions with a C variable argument list must be unsafe - --> $DIR/variadic-ffi-semantic-restrictions.rs:18:20 + --> $DIR/variadic-ffi-semantic-restrictions.rs:17:20 | LL | extern "C" fn f2_2(_: ...) {} | ^^^^^^ @@ -47,13 +47,13 @@ LL | unsafe extern "C" fn f2_2(_: ...) {} | ++++++ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:21:20 + --> $DIR/variadic-ffi-semantic-restrictions.rs:20:20 | LL | extern "C" fn f2_3(_: ..., x: isize) {} | ^^^^^^ error: functions with a C variable argument list must be unsafe - --> $DIR/variadic-ffi-semantic-restrictions.rs:24:30 + --> $DIR/variadic-ffi-semantic-restrictions.rs:23:30 | LL | extern "C" fn f3_1(x: isize, _: ...) {} | ^^^^^^ @@ -64,7 +64,7 @@ LL | unsafe extern "C" fn f3_1(x: isize, _: ...) {} | ++++++ error: functions with a C variable argument list must be unsafe - --> $DIR/variadic-ffi-semantic-restrictions.rs:27:20 + --> $DIR/variadic-ffi-semantic-restrictions.rs:26:20 | LL | extern "C" fn f3_2(_: ...) {} | ^^^^^^ @@ -75,13 +75,13 @@ LL | unsafe extern "C" fn f3_2(_: ...) {} | ++++++ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:30:20 + --> $DIR/variadic-ffi-semantic-restrictions.rs:29:20 | LL | extern "C" fn f3_3(_: ..., x: isize) {} | ^^^^^^ error[E0658]: c-variadic const function definitions are unstable - --> $DIR/variadic-ffi-semantic-restrictions.rs:33:1 + --> $DIR/variadic-ffi-semantic-restrictions.rs:32:1 | LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: c-variadic const function definitions are unstable - --> $DIR/variadic-ffi-semantic-restrictions.rs:37:1 + --> $DIR/variadic-ffi-semantic-restrictions.rs:36:1 | LL | const extern "C" fn f4_2(x: isize, _: ...) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | const extern "C" fn f4_2(x: isize, _: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: functions with a C variable argument list must be unsafe - --> $DIR/variadic-ffi-semantic-restrictions.rs:37:36 + --> $DIR/variadic-ffi-semantic-restrictions.rs:36:36 | LL | const extern "C" fn f4_2(x: isize, _: ...) {} | ^^^^^^ @@ -112,13 +112,13 @@ LL | const unsafe extern "C" fn f4_2(x: isize, _: ...) {} | ++++++ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:42:26 + --> $DIR/variadic-ffi-semantic-restrictions.rs:41:26 | LL | const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} | ^^^^^^ error[E0658]: c-variadic const function definitions are unstable - --> $DIR/variadic-ffi-semantic-restrictions.rs:42:1 + --> $DIR/variadic-ffi-semantic-restrictions.rs:41:1 | LL | const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -128,7 +128,7 @@ LL | const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: functions with a C variable argument list must be unsafe - --> $DIR/variadic-ffi-semantic-restrictions.rs:42:44 + --> $DIR/variadic-ffi-semantic-restrictions.rs:41:44 | LL | const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} | ^^^^^^ @@ -139,13 +139,13 @@ LL | const unsafe extern "C" fn f4_3(_: ..., x: isize, _: ...) {} | ++++++ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:48:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:47:13 | LL | fn e_f2(..., x: isize); | ^^^ error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:55:23 + --> $DIR/variadic-ffi-semantic-restrictions.rs:54:23 | LL | fn i_f1(x: isize, _: ...) {} | ^^^^^^ @@ -153,7 +153,7 @@ LL | fn i_f1(x: isize, _: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:57:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:56:13 | LL | fn i_f2(_: ...) {} | ^^^^^^ @@ -161,13 +161,13 @@ LL | fn i_f2(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:59:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:58:13 | LL | fn i_f3(_: ..., x: isize, _: ...) {} | ^^^^^^ error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:59:31 + --> $DIR/variadic-ffi-semantic-restrictions.rs:58:31 | LL | fn i_f3(_: ..., x: isize, _: ...) {} | ^^^^^^ @@ -175,13 +175,13 @@ LL | fn i_f3(_: ..., x: isize, _: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:62:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:61:13 | LL | fn i_f4(_: ..., x: isize, _: ...) {} | ^^^^^^ error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:62:31 + --> $DIR/variadic-ffi-semantic-restrictions.rs:61:31 | LL | fn i_f4(_: ..., x: isize, _: ...) {} | ^^^^^^ @@ -189,7 +189,7 @@ LL | fn i_f4(_: ..., x: isize, _: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error[E0658]: c-variadic const function definitions are unstable - --> $DIR/variadic-ffi-semantic-restrictions.rs:65:5 + --> $DIR/variadic-ffi-semantic-restrictions.rs:64:5 | LL | const fn i_f5(x: isize, _: ...) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | const fn i_f5(x: isize, _: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:65:29 + --> $DIR/variadic-ffi-semantic-restrictions.rs:64:29 | LL | const fn i_f5(x: isize, _: ...) {} | ^^^^^^ @@ -207,7 +207,7 @@ LL | const fn i_f5(x: isize, _: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:72:23 + --> $DIR/variadic-ffi-semantic-restrictions.rs:71:23 | LL | fn t_f1(x: isize, _: ...) {} | ^^^^^^ @@ -215,7 +215,7 @@ LL | fn t_f1(x: isize, _: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:74:23 + --> $DIR/variadic-ffi-semantic-restrictions.rs:73:23 | LL | fn t_f2(x: isize, _: ...); | ^^^^^^ @@ -223,7 +223,7 @@ LL | fn t_f2(x: isize, _: ...); = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:76:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:75:13 | LL | fn t_f3(_: ...) {} | ^^^^^^ @@ -231,7 +231,7 @@ LL | fn t_f3(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/variadic-ffi-semantic-restrictions.rs:78:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:77:13 | LL | fn t_f4(_: ...); | ^^^^^^ @@ -239,19 +239,19 @@ LL | fn t_f4(_: ...); = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:80:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:79:13 | LL | fn t_f5(_: ..., x: isize) {} | ^^^^^^ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:82:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:81:13 | LL | fn t_f6(_: ..., x: isize); | ^^^^^^ error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time - --> $DIR/variadic-ffi-semantic-restrictions.rs:33:43 + --> $DIR/variadic-ffi-semantic-restrictions.rs:32:43 | LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} | ^ - value is dropped here @@ -263,7 +263,7 @@ LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time - --> $DIR/variadic-ffi-semantic-restrictions.rs:37:36 + --> $DIR/variadic-ffi-semantic-restrictions.rs:36:36 | LL | const extern "C" fn f4_2(x: isize, _: ...) {} | ^ - value is dropped here @@ -275,7 +275,7 @@ LL | const extern "C" fn f4_2(x: isize, _: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time - --> $DIR/variadic-ffi-semantic-restrictions.rs:65:29 + --> $DIR/variadic-ffi-semantic-restrictions.rs:64:29 | LL | const fn i_f5(x: isize, _: ...) {} | ^ - value is dropped here diff --git a/tests/ui/pattern/manually-drop-dangling-ref.rs b/tests/ui/pattern/manually-drop-dangling-ref.rs new file mode 100644 index 0000000000000..439e06e4a10bb --- /dev/null +++ b/tests/ui/pattern/manually-drop-dangling-ref.rs @@ -0,0 +1,6 @@ +use std::mem::{ManuallyDrop, transmute}; +const DATA: ManuallyDrop<&i32> = unsafe { transmute(4_usize) }; + +fn main() { + if let DATA = DATA {} //~ERROR: cannot be used as pattern +} diff --git a/tests/ui/pattern/manually-drop-dangling-ref.stderr b/tests/ui/pattern/manually-drop-dangling-ref.stderr new file mode 100644 index 0000000000000..667415959ceed --- /dev/null +++ b/tests/ui/pattern/manually-drop-dangling-ref.stderr @@ -0,0 +1,10 @@ +error: constant DATA cannot be used as pattern + --> $DIR/manually-drop-dangling-ref.rs:5:12 + | +LL | if let DATA = DATA {} + | ^^^^ + | + = note: constants that reference mutable or external memory or that contain dangling references cannot be used as patterns + +error: aborting due to 1 previous error + diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs index 358b50f7564bc..48b0a958fb3bb 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs @@ -3,7 +3,8 @@ //@ check-pass -#![feature(c_variadic)] +#![feature(custom_inner_attributes)] // for top-level rustfmt::skip +#![rustfmt::skip] extern crate param_attrs; diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs index d96bbee14ca19..b89440bf4271c 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs @@ -1,7 +1,8 @@ //@ edition:2015 //@ proc-macro: ident-mac.rs -#![feature(c_variadic)] +#![feature(custom_inner_attributes)] // for top-level rustfmt::skip +#![rustfmt::skip] #![allow(anonymous_parameters)] extern crate ident_mac; diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr index ba3c0e347b186..74ceb290708f2 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr +++ b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr @@ -1,176 +1,176 @@ error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:12:23 + --> $DIR/proc-macro-cannot-be-used.rs:63:56 | -LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } - | ^^ not a non-macro attribute +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:12:40 + --> $DIR/proc-macro-cannot-be-used.rs:63:40 | -LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:16:40 + --> $DIR/proc-macro-cannot-be-used.rs:59:60 | -LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} - | ^^ not a non-macro attribute +LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:19:30 + --> $DIR/proc-macro-cannot-be-used.rs:59:44 | -LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); - | ^^ not a non-macro attribute +LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:19:40 + --> $DIR/proc-macro-cannot-be-used.rs:59:21 | -LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); - | ^^ not a non-macro attribute +LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:23:11 + --> $DIR/proc-macro-cannot-be-used.rs:56:41 | -LL | fn free(#[id] arg1: u8) { - | ^^ not a non-macro attribute +LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:25:18 + --> $DIR/proc-macro-cannot-be-used.rs:56:21 | -LL | let lam = |#[id] W(x), #[id] y: usize| (); - | ^^ not a non-macro attribute +LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:25:30 + --> $DIR/proc-macro-cannot-be-used.rs:53:30 | -LL | let lam = |#[id] W(x), #[id] y: usize| (); +LL | fn trait2(#[id] &self, #[id] arg1: u8); | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:31:20 + --> $DIR/proc-macro-cannot-be-used.rs:53:17 | -LL | fn inherent1(#[id] self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn trait2(#[id] &self, #[id] arg1: u8); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:31:32 + --> $DIR/proc-macro-cannot-be-used.rs:50:29 | -LL | fn inherent1(#[id] self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn trait1(#[id] self, #[id] arg1: u8); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:34:20 + --> $DIR/proc-macro-cannot-be-used.rs:50:17 | -LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn trait1(#[id] self, #[id] arg1: u8); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:34:33 + --> $DIR/proc-macro-cannot-be-used.rs:44:56 | -LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:37:24 + --> $DIR/proc-macro-cannot-be-used.rs:44:40 | -LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:37:44 + --> $DIR/proc-macro-cannot-be-used.rs:41:47 | -LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:40:24 + --> $DIR/proc-macro-cannot-be-used.rs:41:24 | LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:40:47 + --> $DIR/proc-macro-cannot-be-used.rs:38:44 | -LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} - | ^^ not a non-macro attribute +LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:43:40 + --> $DIR/proc-macro-cannot-be-used.rs:38:24 | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} - | ^^ not a non-macro attribute +LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:43:56 + --> $DIR/proc-macro-cannot-be-used.rs:35:33 | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} - | ^^ not a non-macro attribute +LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:49:17 + --> $DIR/proc-macro-cannot-be-used.rs:35:20 | -LL | fn trait1(#[id] self, #[id] arg1: u8); - | ^^ not a non-macro attribute +LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:49:29 + --> $DIR/proc-macro-cannot-be-used.rs:32:32 | -LL | fn trait1(#[id] self, #[id] arg1: u8); - | ^^ not a non-macro attribute +LL | fn inherent1(#[id] self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:52:17 + --> $DIR/proc-macro-cannot-be-used.rs:32:20 | -LL | fn trait2(#[id] &self, #[id] arg1: u8); - | ^^ not a non-macro attribute +LL | fn inherent1(#[id] self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:52:30 + --> $DIR/proc-macro-cannot-be-used.rs:26:30 | -LL | fn trait2(#[id] &self, #[id] arg1: u8); +LL | let lam = |#[id] W(x), #[id] y: usize| (); | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:55:21 + --> $DIR/proc-macro-cannot-be-used.rs:26:18 | -LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); - | ^^ not a non-macro attribute +LL | let lam = |#[id] W(x), #[id] y: usize| (); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:55:41 + --> $DIR/proc-macro-cannot-be-used.rs:24:11 | -LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); - | ^^ not a non-macro attribute +LL | fn free(#[id] arg1: u8) { + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:58:21 + --> $DIR/proc-macro-cannot-be-used.rs:20:40 | -LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - | ^^ not a non-macro attribute +LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:58:44 + --> $DIR/proc-macro-cannot-be-used.rs:20:30 | -LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - | ^^ not a non-macro attribute +LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:58:60 + --> $DIR/proc-macro-cannot-be-used.rs:17:40 | -LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - | ^^ not a non-macro attribute +LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} + | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:62:40 + --> $DIR/proc-macro-cannot-be-used.rs:13:40 | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); +LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:62:56 + --> $DIR/proc-macro-cannot-be-used.rs:13:23 | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); - | ^^ not a non-macro attribute +LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } + | ^^ not a non-macro attribute error: aborting due to 29 previous errors diff --git a/tests/ui/sanitizer/kcfi-c-variadic.rs b/tests/ui/sanitizer/kcfi-c-variadic.rs index 651029ab7dfe6..2f88ccfb1269c 100644 --- a/tests/ui/sanitizer/kcfi-c-variadic.rs +++ b/tests/ui/sanitizer/kcfi-c-variadic.rs @@ -4,8 +4,6 @@ //@ ignore-backends: gcc //@ run-pass -#![feature(c_variadic)] - trait Trait { unsafe extern "C" fn foo(x: i32, y: i32, mut ap: ...) -> i32 { x + y + ap.next_arg::() + ap.next_arg::() diff --git a/tests/ui/splat/splat-invalid.rs b/tests/ui/splat/splat-invalid.rs index 1fe4d131fc584..b8dd5738c32bf 100644 --- a/tests/ui/splat/splat-invalid.rs +++ b/tests/ui/splat/splat-invalid.rs @@ -2,7 +2,6 @@ #![allow(incomplete_features)] #![feature(splat)] -#![feature(c_variadic)] fn multisplat_fn_bad(#[splat] (_a, _b): (u32, i8), #[splat] (_c, _d): (u32, i8)) {} //~^ ERROR multiple `#[splat]`s are not allowed in the same function argument list diff --git a/tests/ui/splat/splat-invalid.stderr b/tests/ui/splat/splat-invalid.stderr index 86b1dbbb7e44b..035393c65c9e5 100644 --- a/tests/ui/splat/splat-invalid.stderr +++ b/tests/ui/splat/splat-invalid.stderr @@ -1,5 +1,5 @@ error: multiple `#[splat]`s are not allowed in the same function argument list - --> $DIR/splat-invalid.rs:7:22 + --> $DIR/splat-invalid.rs:6:22 | LL | fn multisplat_fn_bad(#[splat] (_a, _b): (u32, i8), #[splat] (_c, _d): (u32, i8)) {} | ^^^^^^^^ ^^^^^^^^ @@ -7,7 +7,7 @@ LL | fn multisplat_fn_bad(#[splat] (_a, _b): (u32, i8), #[splat] (_c, _d): (u32, = help: remove `#[splat]` from all but one argument error: multiple `#[splat]`s are not allowed in the same function argument list - --> $DIR/splat-invalid.rs:19:5 + --> $DIR/splat-invalid.rs:18:5 | LL | #[splat] | ^^^^^^^^ @@ -21,7 +21,7 @@ LL | #[splat] (_c, _d): (u32, i8), = help: remove `#[splat]` from all but one argument error: `...` and `#[splat]` are not allowed in the same function argument list - --> $DIR/splat-invalid.rs:28:37 + --> $DIR/splat-invalid.rs:27:37 | LL | unsafe extern "C" fn splat_variadic(#[splat] (_a, _b): (u32, i8), varargs: ...) {} | ^^^^^^^^ ^^^^^^^^^^^^ @@ -29,13 +29,13 @@ LL | unsafe extern "C" fn splat_variadic(#[splat] (_a, _b): (u32, i8), varargs: = help: remove `#[splat]` or remove `...` error: `...` must be the last argument of a C-variadic function - --> $DIR/splat-invalid.rs:31:38 + --> $DIR/splat-invalid.rs:30:38 | LL | unsafe extern "C" fn splat_variadic2(varargs: ..., #[splat] (_a, _b): (u32, i8)) {} | ^^^^^^^^^^^^ error: `...` and `#[splat]` are not allowed in the same function argument list - --> $DIR/splat-invalid.rs:31:38 + --> $DIR/splat-invalid.rs:30:38 | LL | unsafe extern "C" fn splat_variadic2(varargs: ..., #[splat] (_a, _b): (u32, i8)) {} | ^^^^^^^^^^^^ ^^^^^^^^ @@ -43,7 +43,7 @@ LL | unsafe extern "C" fn splat_variadic2(varargs: ..., #[splat] (_a, _b): (u32, = help: remove `#[splat]` or remove `...` error: incorrect function inside `extern` block - --> $DIR/splat-invalid.rs:36:8 + --> $DIR/splat-invalid.rs:35:8 | LL | extern "C" { | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body @@ -54,7 +54,7 @@ LL | fn splat_variadic3(#[splat] (_a, _b): (u32, i8), ...) {} = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html error: `...` and `#[splat]` are not allowed in the same function argument list - --> $DIR/splat-invalid.rs:36:24 + --> $DIR/splat-invalid.rs:35:24 | LL | fn splat_variadic3(#[splat] (_a, _b): (u32, i8), ...) {} | ^^^^^^^^ ^^^ @@ -62,7 +62,7 @@ LL | fn splat_variadic3(#[splat] (_a, _b): (u32, i8), ...) {} = help: remove `#[splat]` or remove `...` error: incorrect function inside `extern` block - --> $DIR/splat-invalid.rs:40:8 + --> $DIR/splat-invalid.rs:39:8 | LL | extern "C" { | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body @@ -74,13 +74,13 @@ LL | fn splat_variadic4(..., #[splat] (_a, _b): (u32, i8)) {} = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html error: `...` must be the last argument of a C-variadic function - --> $DIR/splat-invalid.rs:40:24 + --> $DIR/splat-invalid.rs:39:24 | LL | fn splat_variadic4(..., #[splat] (_a, _b): (u32, i8)) {} | ^^^ error: `...` and `#[splat]` are not allowed in the same function argument list - --> $DIR/splat-invalid.rs:40:24 + --> $DIR/splat-invalid.rs:39:24 | LL | fn splat_variadic4(..., #[splat] (_a, _b): (u32, i8)) {} | ^^^ ^^^^^^^^ @@ -88,37 +88,37 @@ LL | fn splat_variadic4(..., #[splat] (_a, _b): (u32, i8)) {} = help: remove `#[splat]` or remove `...` error: multiple `splat` attributes - --> $DIR/splat-invalid.rs:12:5 + --> $DIR/splat-invalid.rs:11:5 | LL | #[splat] | ^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/splat-invalid.rs:11:5 + --> $DIR/splat-invalid.rs:10:5 | LL | #[splat] | ^^^^^^^^ error: multiple `splat` attributes - --> $DIR/splat-invalid.rs:21:5 + --> $DIR/splat-invalid.rs:20:5 | LL | #[splat] | ^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/splat-invalid.rs:19:5 + --> $DIR/splat-invalid.rs:18:5 | LL | #[splat] | ^^^^^^^^ error[E0053]: method `has_splat` has an incompatible type for trait - --> $DIR/splat-invalid.rs:60:5 + --> $DIR/splat-invalid.rs:59:5 | LL | fn has_splat(_: ()) {} | ^^^^^^^^^^^^^^^^^^^ expected fn with arg 0 splatted, found fn with no splatted arg | note: type in trait - --> $DIR/splat-invalid.rs:52:5 + --> $DIR/splat-invalid.rs:51:5 | LL | fn has_splat(#[splat] _: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,13 +126,13 @@ LL | fn has_splat(#[splat] _: ()); found signature `fn(())` error[E0053]: method `no_splat` has an incompatible type for trait - --> $DIR/splat-invalid.rs:62:5 + --> $DIR/splat-invalid.rs:61:5 | LL | fn no_splat(#[splat] _: (u32, f64)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn with no splatted arg, found fn with arg 0 splatted | note: type in trait - --> $DIR/splat-invalid.rs:54:5 + --> $DIR/splat-invalid.rs:53:5 | LL | fn no_splat(_: (u32, f64)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/thir-print/c-variadic.rs b/tests/ui/thir-print/c-variadic.rs index a418e17e84c35..b07c422ea3cd4 100644 --- a/tests/ui/thir-print/c-variadic.rs +++ b/tests/ui/thir-print/c-variadic.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Zunpretty=thir-tree --crate-type=lib //@ check-pass -#![feature(c_variadic)] #![expect(varargs_without_pattern)] // The `...` argument uses `PatKind::Missing`. diff --git a/tests/ui/thir-print/c-variadic.stderr b/tests/ui/thir-print/c-variadic.stderr index a4050695944d4..e05e50a93f57d 100644 --- a/tests/ui/thir-print/c-variadic.stderr +++ b/tests/ui/thir-print/c-variadic.stderr @@ -1,6 +1,6 @@ Future incompatibility report: Future breakage diagnostic: warning: missing pattern for `...` argument - --> $DIR/c-variadic.rs:7:34 + --> $DIR/c-variadic.rs:6:34 | LL | unsafe extern "C" fn foo(_: i32, ...) {} | ^^^ diff --git a/tests/ui/thir-print/c-variadic.stdout b/tests/ui/thir-print/c-variadic.stdout index a426902b2deb2..ad6dacb4753b3 100644 --- a/tests/ui/thir-print/c-variadic.stdout +++ b/tests/ui/thir-print/c-variadic.stdout @@ -2,13 +2,13 @@ DefId(0:3 ~ c_variadic[a5de]::foo): params: [ Param { ty: i32 - ty_span: Some($DIR/c-variadic.rs:7:29: 7:32 (#0)) + ty_span: Some($DIR/c-variadic.rs:6:29: 6:32 (#0)) self_kind: None hir_id: Some(HirId(DefId(0:3 ~ c_variadic[a5de]::foo).1)) param: Some( Pat { ty: i32 - span: $DIR/c-variadic.rs:7:26: 7:27 (#0) + span: $DIR/c-variadic.rs:6:26: 6:27 (#0) kind: PatKind { Wild } @@ -23,7 +23,7 @@ params: [ param: Some( Pat { ty: std::ffi::VaList<'{erased}> - span: $DIR/c-variadic.rs:7:34: 7:37 (#0) + span: $DIR/c-variadic.rs:6:34: 6:37 (#0) kind: PatKind { Missing } @@ -35,7 +35,7 @@ body: Expr { ty: () temp_scope_id: 6 - span: $DIR/c-variadic.rs:7:39: 7:41 (#0) + span: $DIR/c-variadic.rs:6:39: 6:41 (#0) kind: Scope { region_scope: Node(6) @@ -44,11 +44,11 @@ body: Expr { ty: () temp_scope_id: 6 - span: $DIR/c-variadic.rs:7:39: 7:41 (#0) + span: $DIR/c-variadic.rs:6:39: 6:41 (#0) kind: Block { targeted_by_break: false - span: $DIR/c-variadic.rs:7:39: 7:41 (#0) + span: $DIR/c-variadic.rs:6:39: 6:41 (#0) region_scope: Node(5) safety_mode: Safe stmts: [] diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs index 57641423643e8..a88009aa91d23 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs @@ -1,5 +1,6 @@ //@ known-bug: unknown -// Ensure that we print unsatisfied always-const trait bounds as `const Trait` in diagnostics. +// This used to ensure that the next solver prints unsatisfied always-const trait bounds as +// `const Trait`, but no longer does because GCE is incompatible with the next solver. //@ compile-flags: -Znext-solver #![feature(const_trait_impl, generic_const_exprs)] diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr index 147b248c33da8..912cdd1d42944 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr @@ -1,45 +1,10 @@ error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed - --> $DIR/unsatisfied-const-trait-bound.rs:5:30 + --> $DIR/unsatisfied-const-trait-bound.rs:6:30 | LL | #![feature(const_trait_impl, generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = help: remove one of these features -error[E0391]: cycle detected when evaluating type-level constant - --> $DIR/unsatisfied-const-trait-bound.rs:28:35 - | -LL | fn accept0(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ - | - = note: ...which requires const-evaluating + checking `accept0::{constant#0}`... - = note: ...which requires checking if `accept0::{constant#0}` is a trivial const... - = note: ...which requires building MIR for `accept0::{constant#0}`... - = note: ...which requires building an abstract representation for `accept0::{constant#0}`... - = note: ...which requires building THIR for `accept0::{constant#0}`... - = note: ...which requires type-checking `accept0::{constant#0}`... - = note: ...which requires computing normalized predicates of `accept0::{constant#0}`... - = note: ...which again requires evaluating type-level constant, completing the cycle - = note: cycle used when computing normalized predicates of `accept0` - = note: for more information, see and - -error[E0391]: cycle detected when checking if `accept1::{constant#0}` is a trivial const - --> $DIR/unsatisfied-const-trait-bound.rs:32:49 - | -LL | const fn accept1(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ - | - = note: ...which requires building MIR for `accept1::{constant#0}`... - = note: ...which requires building an abstract representation for `accept1::{constant#0}`... - = note: ...which requires building THIR for `accept1::{constant#0}`... - = note: ...which requires type-checking `accept1::{constant#0}`... - = note: ...which requires computing normalized predicates of `accept1::{constant#0}`... - = note: ...which requires evaluating type-level constant... - = note: ...which requires const-evaluating + checking `accept1::{constant#0}`... - = note: ...which again requires checking if `accept1::{constant#0}` is a trivial const, completing the cycle - = note: cycle used when const-evaluating + checking `accept1::{constant#0}` - = note: for more information, see and - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/traits/next-solver/float-fallback-hack-depth.rs b/tests/ui/traits/next-solver/float-fallback-hack-depth.rs new file mode 100644 index 0000000000000..34d8c73229636 --- /dev/null +++ b/tests/ui/traits/next-solver/float-fallback-hack-depth.rs @@ -0,0 +1,21 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// Regression test for github.com/rust-lang/trait-system-refactor-initiative#280 +// We force unresolved float infer vars to fallback to `f32` if there're stalled `f32: From` +// obligations. +// Previously the recursion limit is 3 which is not enough, causing some bevy crates to fail. + +trait Trait {} +impl> Trait for T {} + +struct W(T); +impl Trait for W {} + +fn impls_trait(_: T) {} + +fn main() { + impls_trait(W(1.0)) + //~^ WARN: falling back to `f32` as the trait bound `f32: From` is not satisfied [float_literal_f32_fallback] + //~| WARN: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/traits/next-solver/float-fallback-hack-depth.stderr b/tests/ui/traits/next-solver/float-fallback-hack-depth.stderr new file mode 100644 index 0000000000000..e7222e5cb2852 --- /dev/null +++ b/tests/ui/traits/next-solver/float-fallback-hack-depth.stderr @@ -0,0 +1,12 @@ +warning: falling back to `f32` as the trait bound `f32: From` is not satisfied + --> $DIR/float-fallback-hack-depth.rs:18:19 + | +LL | impls_trait(W(1.0)) + | ^^^ help: explicitly specify the type as `f32`: `1.0_f32` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #154024 + = note: `#[warn(float_literal_f32_fallback)]` (part of `#[warn(future_incompatible)]`) on by default + +warning: 1 warning emitted +