Auto merge of #112217 - arlosi:update-vuln-deps, r=Mark-Simulacrum
Update dependencies with reported vulnerabilities
Vulnerable dependencies:
* bumpalo 3.12.1 (yanked)
* updated to 3.13.0
* tokio 1.8.4 - https://rustsec.org/advisories/RUSTSEC-2023-0001
* updated to 1.28.2
* remove_dir_all 0.5.3 - https://rustsec.org/advisories/RUSTSEC-2023-0018
* removed by using the standard library function in `rust-installer` instead and updating to `tempfile@3.5.0` (which also removes the dependency).
The new dependencies come from `tempfile@3.5.0` which adds the dependency on `rustix`
diff --git a/Cargo.lock b/Cargo.lock
index be622bb..416a1ae 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -872,16 +872,6 @@
]
[[package]]
-name = "cstr"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c11a39d776a3b35896711da8a04dc1835169dcd36f710878187637314e47941b"
-dependencies = [
- "proc-macro2",
- "quote",
-]
-
-[[package]]
name = "ctrlc"
version = "3.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3178,7 +3168,6 @@
version = "0.0.0"
dependencies = [
"bitflags",
- "cstr",
"libc",
"measureme",
"object 0.31.1",
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 5e0ab80..f52797c 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -71,9 +71,13 @@
let kind = match &e.kind {
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
- ExprKind::ConstBlock(anon_const) => {
- let anon_const = self.lower_anon_const(anon_const);
- hir::ExprKind::ConstBlock(anon_const)
+ ExprKind::ConstBlock(c) => {
+ let c = self.with_new_scopes(|this| hir::ConstBlock {
+ def_id: this.local_def_id(c.id),
+ hir_id: this.lower_node_id(c.id),
+ body: this.lower_const_body(c.value.span, Some(&c.value)),
+ });
+ hir::ExprKind::ConstBlock(c)
}
ExprKind::Repeat(expr, count) => {
let expr = self.lower_expr(expr);
diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs
index 2e66c81..ce84790 100644
--- a/compiler/rustc_ast_lowering/src/index.rs
+++ b/compiler/rustc_ast_lowering/src/index.rs
@@ -223,6 +223,14 @@
});
}
+ fn visit_inline_const(&mut self, constant: &'hir ConstBlock) {
+ self.insert(DUMMY_SP, constant.hir_id, Node::ConstBlock(constant));
+
+ self.with_parent(constant.hir_id, |this| {
+ intravisit::walk_inline_const(this, constant);
+ });
+ }
+
fn visit_expr(&mut self, expr: &'hir Expr<'hir>) {
self.insert(expr.span, expr.hir_id, Node::Expr(expr));
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
index 0a513b0..1e83c30 100644
--- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
@@ -475,9 +475,7 @@
sym::unchecked_add
| sym::unchecked_sub
| sym::unchecked_mul
- | sym::unchecked_div
| sym::exact_div
- | sym::unchecked_rem
| sym::unchecked_shl
| sym::unchecked_shr => {
intrinsic_args!(fx, args => (x, y); intrinsic);
@@ -487,8 +485,7 @@
sym::unchecked_add => BinOp::Add,
sym::unchecked_sub => BinOp::Sub,
sym::unchecked_mul => BinOp::Mul,
- sym::unchecked_div | sym::exact_div => BinOp::Div,
- sym::unchecked_rem => BinOp::Rem,
+ sym::exact_div => BinOp::Div,
sym::unchecked_shl => BinOp::Shl,
sym::unchecked_shr => BinOp::Shr,
_ => unreachable!(),
diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml
index ad51f2d..39ff3a0 100644
--- a/compiler/rustc_codegen_llvm/Cargo.toml
+++ b/compiler/rustc_codegen_llvm/Cargo.toml
@@ -8,7 +8,6 @@
[dependencies]
bitflags = "1.0"
-cstr = "0.2"
libc = "0.2"
measureme = "10.0.0"
object = { version = "0.31.1", default-features = false, features = [
diff --git a/compiler/rustc_codegen_llvm/src/allocator.rs b/compiler/rustc_codegen_llvm/src/allocator.rs
index a575088..ad06368 100644
--- a/compiler/rustc_codegen_llvm/src/allocator.rs
+++ b/compiler/rustc_codegen_llvm/src/allocator.rs
@@ -77,7 +77,7 @@
llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr().cast(), callee.len(), ty);
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
- let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, "entry\0".as_ptr().cast());
+ let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, c"entry".as_ptr().cast());
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
@@ -129,7 +129,7 @@
attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]);
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
- let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, "entry\0".as_ptr().cast());
+ let llbb = llvm::LLVMAppendBasicBlockInContext(llcx, llfn, c"entry".as_ptr().cast());
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs
index 604f68e..8b05af7 100644
--- a/compiler/rustc_codegen_llvm/src/back/lto.rs
+++ b/compiler/rustc_codegen_llvm/src/back/lto.rs
@@ -595,7 +595,7 @@
llvm::LLVMRustAddModuleFlag(
module.module_llvm.llmod(),
llvm::LLVMModFlagBehavior::Error,
- "LTOPostLink\0".as_ptr().cast(),
+ c"LTOPostLink".as_ptr().cast(),
1,
);
}
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
index ca2eab2..53b4296 100644
--- a/compiler/rustc_codegen_llvm/src/back/write.rs
+++ b/compiler/rustc_codegen_llvm/src/back/write.rs
@@ -891,11 +891,11 @@
let llglobal = llvm::LLVMAddGlobal(
llmod,
common::val_ty(llconst),
- "rustc.embedded.module\0".as_ptr().cast(),
+ c"rustc.embedded.module".as_ptr().cast(),
);
llvm::LLVMSetInitializer(llglobal, llconst);
- let section = if is_apple { "__LLVM,__bitcode\0" } else { ".llvmbc\0" };
+ let section = if is_apple { c"__LLVM,__bitcode" } else { c".llvmbc" };
llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
@@ -904,10 +904,10 @@
let llglobal = llvm::LLVMAddGlobal(
llmod,
common::val_ty(llconst),
- "rustc.embedded.cmdline\0".as_ptr().cast(),
+ c"rustc.embedded.cmdline".as_ptr().cast(),
);
llvm::LLVMSetInitializer(llglobal, llconst);
- let section = if is_apple { "__LLVM,__cmdline\0" } else { ".llvmcmd\0" };
+ let section = if is_apple { c"__LLVM,__cmdline" } else { c".llvmcmd" };
llvm::LLVMSetSection(llglobal, section.as_ptr().cast());
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
} else {
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs
index 5b2bbdb..2f7eb08 100644
--- a/compiler/rustc_codegen_llvm/src/base.rs
+++ b/compiler/rustc_codegen_llvm/src/base.rs
@@ -19,8 +19,6 @@
use crate::llvm;
use crate::value::Value;
-use cstr::cstr;
-
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
use rustc_codegen_ssa::mono_item::MonoItemExt;
use rustc_codegen_ssa::traits::*;
@@ -110,11 +108,11 @@
// Create the llvm.used and llvm.compiler.used variables.
if !cx.used_statics.borrow().is_empty() {
- cx.create_used_variable_impl(cstr!("llvm.used"), &*cx.used_statics.borrow());
+ cx.create_used_variable_impl(c"llvm.used", &*cx.used_statics.borrow());
}
if !cx.compiler_used_statics.borrow().is_empty() {
cx.create_used_variable_impl(
- cstr!("llvm.compiler.used"),
+ c"llvm.compiler.used",
&*cx.compiler_used_statics.borrow(),
);
}
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 5968e70..b4aa001 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -6,7 +6,6 @@
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
-use cstr::cstr;
use libc::{c_char, c_uint};
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
@@ -25,7 +24,6 @@
use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
use std::borrow::Cow;
-use std::ffi::CStr;
use std::iter;
use std::ops::Deref;
use std::ptr;
@@ -45,13 +43,10 @@
}
}
-// FIXME(eddyb) use a checked constructor when they become `const fn`.
-const EMPTY_C_STR: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") };
-
/// Empty string, to be used where LLVM expects an instruction name, indicating
/// that the instruction is to be left unnamed (i.e. numbered, in textual IR).
// FIXME(eddyb) pass `&CStr` directly to FFI once it's a thin pointer.
-const UNNAMED: *const c_char = EMPTY_C_STR.as_ptr();
+const UNNAMED: *const c_char = c"".as_ptr();
impl<'ll, 'tcx> BackendTypes for Builder<'_, 'll, 'tcx> {
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
@@ -1010,14 +1005,13 @@
}
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
- let name = cstr!("cleanuppad");
let ret = unsafe {
llvm::LLVMBuildCleanupPad(
self.llbuilder,
parent,
args.as_ptr(),
args.len() as c_uint,
- name.as_ptr(),
+ c"cleanuppad".as_ptr(),
)
};
Funclet::new(ret.expect("LLVM does not have support for cleanuppad"))
@@ -1031,14 +1025,13 @@
}
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
- let name = cstr!("catchpad");
let ret = unsafe {
llvm::LLVMBuildCatchPad(
self.llbuilder,
parent,
args.as_ptr(),
args.len() as c_uint,
- name.as_ptr(),
+ c"catchpad".as_ptr(),
)
};
Funclet::new(ret.expect("LLVM does not have support for catchpad"))
@@ -1050,14 +1043,13 @@
unwind: Option<&'ll BasicBlock>,
handlers: &[&'ll BasicBlock],
) -> &'ll Value {
- let name = cstr!("catchswitch");
let ret = unsafe {
llvm::LLVMBuildCatchSwitch(
self.llbuilder,
parent,
unwind,
handlers.len() as c_uint,
- name.as_ptr(),
+ c"catchswitch".as_ptr(),
)
};
let ret = ret.expect("LLVM does not have support for catchswitch");
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index df52f50..2087754 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -8,7 +8,6 @@
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
-use cstr::cstr;
use rustc_codegen_ssa::traits::*;
use rustc_hir::def_id::DefId;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
@@ -482,9 +481,9 @@
.all(|&byte| byte == 0);
let sect_name = if all_bytes_are_zero {
- cstr!("__DATA,__thread_bss")
+ c"__DATA,__thread_bss"
} else {
- cstr!("__DATA,__thread_data")
+ c"__DATA,__thread_data"
};
llvm::LLVMSetSection(g, sect_name.as_ptr());
}
@@ -513,7 +512,7 @@
let val = llvm::LLVMMetadataAsValue(self.llcx, meta);
llvm::LLVMAddNamedMetadataOperand(
self.llmod,
- "wasm.custom_sections\0".as_ptr().cast(),
+ c"wasm.custom_sections".as_ptr().cast(),
val,
);
}
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index ca0f771..e8a7afc 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -8,7 +8,6 @@
use crate::type_::Type;
use crate::value::Value;
-use cstr::cstr;
use rustc_codegen_ssa::base::wants_msvc_seh;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::base_n;
@@ -224,36 +223,42 @@
// If skipping the PLT is enabled, we need to add some module metadata
// to ensure intrinsic calls don't use it.
if !sess.needs_plt() {
- let avoid_plt = "RtLibUseGOT\0".as_ptr().cast();
- llvm::LLVMRustAddModuleFlag(llmod, llvm::LLVMModFlagBehavior::Warning, avoid_plt, 1);
+ llvm::LLVMRustAddModuleFlag(
+ llmod,
+ llvm::LLVMModFlagBehavior::Warning,
+ c"RtLibUseGOT".as_ptr().cast(),
+ 1,
+ );
}
// Enable canonical jump tables if CFI is enabled. (See https://reviews.llvm.org/D65629.)
if sess.is_sanitizer_cfi_canonical_jump_tables_enabled() && sess.is_sanitizer_cfi_enabled() {
- let canonical_jump_tables = "CFI Canonical Jump Tables\0".as_ptr().cast();
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Override,
- canonical_jump_tables,
+ c"CFI Canonical Jump Tables".as_ptr().cast(),
1,
);
}
// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
if sess.is_split_lto_unit_enabled() || sess.is_sanitizer_cfi_enabled() {
- let enable_split_lto_unit = "EnableSplitLTOUnit\0".as_ptr().cast();
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Override,
- enable_split_lto_unit,
+ c"EnableSplitLTOUnit".as_ptr().cast(),
1,
);
}
// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
if sess.is_sanitizer_kcfi_enabled() {
- let kcfi = "kcfi\0".as_ptr().cast();
- llvm::LLVMRustAddModuleFlag(llmod, llvm::LLVMModFlagBehavior::Override, kcfi, 1);
+ llvm::LLVMRustAddModuleFlag(
+ llmod,
+ llvm::LLVMModFlagBehavior::Override,
+ c"kcfi".as_ptr().cast(),
+ 1,
+ );
}
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
@@ -265,7 +270,7 @@
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Warning,
- "cfguard\0".as_ptr() as *const _,
+ c"cfguard".as_ptr() as *const _,
1,
)
}
@@ -274,7 +279,7 @@
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Warning,
- "cfguard\0".as_ptr() as *const _,
+ c"cfguard".as_ptr() as *const _,
2,
)
}
@@ -292,26 +297,26 @@
llvm::LLVMRustAddModuleFlag(
llmod,
behavior,
- "branch-target-enforcement\0".as_ptr().cast(),
+ c"branch-target-enforcement".as_ptr().cast(),
bti.into(),
);
llvm::LLVMRustAddModuleFlag(
llmod,
behavior,
- "sign-return-address\0".as_ptr().cast(),
+ c"sign-return-address".as_ptr().cast(),
pac_ret.is_some().into(),
);
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
llvm::LLVMRustAddModuleFlag(
llmod,
behavior,
- "sign-return-address-all\0".as_ptr().cast(),
+ c"sign-return-address-all".as_ptr().cast(),
pac_opts.leaf.into(),
);
llvm::LLVMRustAddModuleFlag(
llmod,
behavior,
- "sign-return-address-with-bkey\0".as_ptr().cast(),
+ c"sign-return-address-with-bkey".as_ptr().cast(),
u32::from(pac_opts.key == PAuthKey::B),
);
} else {
@@ -327,7 +332,7 @@
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Override,
- "cf-protection-branch\0".as_ptr().cast(),
+ c"cf-protection-branch".as_ptr().cast(),
1,
)
}
@@ -335,7 +340,7 @@
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Override,
- "cf-protection-return\0".as_ptr().cast(),
+ c"cf-protection-return".as_ptr().cast(),
1,
)
}
@@ -344,7 +349,7 @@
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
- "Virtual Function Elim\0".as_ptr().cast(),
+ c"Virtual Function Elim".as_ptr().cast(),
1,
);
}
@@ -476,14 +481,13 @@
}
pub(crate) fn create_used_variable_impl(&self, name: &'static CStr, values: &[&'ll Value]) {
- let section = cstr!("llvm.metadata");
let array = self.const_array(self.type_ptr_to(self.type_i8()), values);
unsafe {
let g = llvm::LLVMAddGlobal(self.llmod, self.val_ty(array), name.as_ptr());
llvm::LLVMSetInitializer(g, array);
llvm::LLVMRustSetLinkage(g, llvm::Linkage::AppendingLinkage);
- llvm::LLVMSetSection(g, section.as_ptr());
+ llvm::LLVMSetSection(g, c"llvm.metadata".as_ptr());
}
}
}
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
index 37f3091..8be54b7 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
@@ -38,7 +38,6 @@
unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr().cast()) };
section_var.unwrap_or_else(|| {
- let section_name = b".debug_gdb_scripts\0";
let mut section_contents = Vec::new();
// Add the pretty printers for the standard library first.
@@ -71,7 +70,7 @@
let section_var = cx
.define_global(section_var_name, llvm_type)
.unwrap_or_else(|| bug!("symbol `{}` is already defined", section_var_name));
- llvm::LLVMSetSection(section_var, section_name.as_ptr().cast());
+ llvm::LLVMSetSection(section_var, c".debug_gdb_scripts".as_ptr().cast());
llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
llvm::LLVMSetUnnamedAddress(section_var, llvm::UnnamedAddr::Global);
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index bd2fba1..166454d 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -20,7 +20,6 @@
};
use crate::value::Value;
-use cstr::cstr;
use rustc_codegen_ssa::debuginfo::type_names::cpp_like_debuginfo;
use rustc_codegen_ssa::debuginfo::type_names::VTableNameKind;
use rustc_codegen_ssa::traits::*;
@@ -812,7 +811,6 @@
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
let work_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped);
- let flags = "\0";
let output_filenames = tcx.output_filenames(());
let split_name = if tcx.sess.target_can_use_split_dwarf() {
output_filenames
@@ -849,7 +847,7 @@
producer.as_ptr().cast(),
producer.len(),
tcx.sess.opts.optimize != config::OptLevel::No,
- flags.as_ptr().cast(),
+ c"".as_ptr().cast(),
0,
// NB: this doesn't actually have any perceptible effect, it seems. LLVM will instead
// put the path supplied to `MCSplitDwarfFile` into the debug info of the final
@@ -878,8 +876,7 @@
);
let val = llvm::LLVMMetadataAsValue(debug_context.llcontext, gcov_metadata);
- let llvm_gcov_ident = cstr!("llvm.gcov");
- llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, llvm_gcov_ident.as_ptr(), val);
+ llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, c"llvm.gcov".as_ptr(), val);
}
// Insert `llvm.ident` metadata on the wasm targets since that will
@@ -892,7 +889,7 @@
);
llvm::LLVMAddNamedMetadataOperand(
debug_context.llmod,
- cstr!("llvm.ident").as_ptr(),
+ c"llvm.ident".as_ptr(),
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
);
}
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
index c3f0a00..aa7ae93 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
@@ -113,7 +113,7 @@
llvm::LLVMRustAddModuleFlag(
self.llmod,
llvm::LLVMModFlagBehavior::Warning,
- "Dwarf Version\0".as_ptr().cast(),
+ c"Dwarf Version".as_ptr().cast(),
dwarf_version,
);
} else {
@@ -121,17 +121,16 @@
llvm::LLVMRustAddModuleFlag(
self.llmod,
llvm::LLVMModFlagBehavior::Warning,
- "CodeView\0".as_ptr().cast(),
+ c"CodeView".as_ptr().cast(),
1,
)
}
// Prevent bitcode readers from deleting the debug info.
- let ptr = "Debug Info Version\0".as_ptr();
llvm::LLVMRustAddModuleFlag(
self.llmod,
llvm::LLVMModFlagBehavior::Warning,
- ptr.cast(),
+ c"Debug Info Version".as_ptr().cast(),
llvm::LLVMRustDebugMetadataVersion(),
);
}
diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs
index 805843e..ff9909c 100644
--- a/compiler/rustc_codegen_llvm/src/lib.rs
+++ b/compiler/rustc_codegen_llvm/src/lib.rs
@@ -11,6 +11,7 @@
#![feature(let_chains)]
#![feature(never_type)]
#![feature(impl_trait_in_assoc_type)]
+#![feature(c_str_literals)]
#![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)]
#![deny(rustc::untranslatable_diagnostic)]
diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
index 1479242..9ac2424 100644
--- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
@@ -211,8 +211,6 @@
args[1].val.unaligned_volatile_store(bx, dst);
return;
}
- | sym::unchecked_div
- | sym::unchecked_rem
| sym::unchecked_shl
| sym::unchecked_shr
| sym::unchecked_add
@@ -229,20 +227,6 @@
bx.exactudiv(args[0].immediate(), args[1].immediate())
}
}
- sym::unchecked_div => {
- if signed {
- bx.sdiv(args[0].immediate(), args[1].immediate())
- } else {
- bx.udiv(args[0].immediate(), args[1].immediate())
- }
- }
- sym::unchecked_rem => {
- if signed {
- bx.srem(args[0].immediate(), args[1].immediate())
- } else {
- bx.urem(args[0].immediate(), args[1].immediate())
- }
- }
sym::unchecked_shl => bx.shl(args[0].immediate(), args[1].immediate()),
sym::unchecked_shr => {
if signed {
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
index fb24cf4..fffb9a7 100644
--- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs
+++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
@@ -238,9 +238,7 @@
| sym::unchecked_shr
| sym::unchecked_add
| sym::unchecked_sub
- | sym::unchecked_mul
- | sym::unchecked_div
- | sym::unchecked_rem => {
+ | sym::unchecked_mul => {
let l = self.read_immediate(&args[0])?;
let r = self.read_immediate(&args[1])?;
let bin_op = match intrinsic_name {
@@ -249,8 +247,6 @@
sym::unchecked_add => BinOp::Add,
sym::unchecked_sub => BinOp::Sub,
sym::unchecked_mul => BinOp::Mul,
- sym::unchecked_div => BinOp::Div,
- sym::unchecked_rem => BinOp::Rem,
_ => bug!(),
};
let (val, overflowed, _ty) = self.overflowing_binary_op(bin_op, &l, &r)?;
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index e844731..70fc669 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -1675,6 +1675,14 @@
pub body: BodyId,
}
+/// An inline constant expression `const { something }`.
+#[derive(Copy, Clone, Debug, HashStable_Generic)]
+pub struct ConstBlock {
+ pub hir_id: HirId,
+ pub def_id: LocalDefId,
+ pub body: BodyId,
+}
+
/// An expression.
#[derive(Debug, Clone, Copy, HashStable_Generic)]
pub struct Expr<'hir> {
@@ -1922,7 +1930,7 @@
#[derive(Debug, Clone, Copy, HashStable_Generic)]
pub enum ExprKind<'hir> {
/// Allow anonymous constants from an inline `const` block
- ConstBlock(AnonConst),
+ ConstBlock(ConstBlock),
/// An array (e.g., `[a, b, c, d]`).
Array(&'hir [Expr<'hir>]),
/// A function call.
@@ -3641,6 +3649,7 @@
Variant(&'hir Variant<'hir>),
Field(&'hir FieldDef<'hir>),
AnonConst(&'hir AnonConst),
+ ConstBlock(&'hir ConstBlock),
Expr(&'hir Expr<'hir>),
ExprField(&'hir ExprField<'hir>),
Stmt(&'hir Stmt<'hir>),
@@ -3695,6 +3704,7 @@
Node::TypeBinding(b) => Some(b.ident),
Node::Param(..)
| Node::AnonConst(..)
+ | Node::ConstBlock(..)
| Node::Expr(..)
| Node::Stmt(..)
| Node::Block(..)
@@ -3758,7 +3768,7 @@
})
| Node::Expr(Expr {
kind:
- ExprKind::ConstBlock(AnonConst { body, .. })
+ ExprKind::ConstBlock(ConstBlock { body, .. })
| ExprKind::Closure(Closure { body, .. })
| ExprKind::Repeat(_, ArrayLen::Body(AnonConst { body, .. })),
..
@@ -3878,6 +3888,13 @@
this
}
+ /// Expect a [`Node::ConstBlock`] or panic.
+ #[track_caller]
+ pub fn expect_inline_const(self) -> &'hir ConstBlock {
+ let Node::ConstBlock(this) = self else { self.expect_failed("an inline constant") };
+ this
+ }
+
/// Expect a [`Node::Expr`] or panic.
#[track_caller]
pub fn expect_expr(self) -> &'hir Expr<'hir> {
diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs
index df0047d..f84c814 100644
--- a/compiler/rustc_hir/src/intravisit.rs
+++ b/compiler/rustc_hir/src/intravisit.rs
@@ -335,6 +335,9 @@
fn visit_anon_const(&mut self, c: &'v AnonConst) {
walk_anon_const(self, c)
}
+ fn visit_inline_const(&mut self, c: &'v ConstBlock) {
+ walk_inline_const(self, c)
+ }
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
walk_expr(self, ex)
}
@@ -679,13 +682,18 @@
visitor.visit_nested_body(constant.body);
}
+pub fn walk_inline_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v ConstBlock) {
+ visitor.visit_id(constant.hir_id);
+ visitor.visit_nested_body(constant.body);
+}
+
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
visitor.visit_id(expression.hir_id);
match expression.kind {
ExprKind::Array(subexpressions) => {
walk_list!(visitor, visit_expr, subexpressions);
}
- ExprKind::ConstBlock(ref anon_const) => visitor.visit_anon_const(anon_const),
+ ExprKind::ConstBlock(ref const_block) => visitor.visit_inline_const(const_block),
ExprKind::Repeat(ref element, ref count) => {
visitor.visit_expr(element);
visitor.visit_array_length(count)
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs
index 89f9669..4a1f8ec 100644
--- a/compiler/rustc_hir_analysis/src/check/check.rs
+++ b/compiler/rustc_hir_analysis/src/check/check.rs
@@ -704,7 +704,7 @@
// grandparent. In that case, if parent is a `default impl`, inherited items use the
// "defaultness" from the grandparent, else they are final.
None => {
- if tcx.impl_defaultness(parent_impl.def_id()).is_default() {
+ if tcx.defaultness(parent_impl.def_id()).is_default() {
None
} else {
Some(Err(parent_impl.def_id()))
@@ -803,7 +803,7 @@
.as_ref()
.is_some_and(|node_item| node_item.item.defaultness(tcx).has_value());
- if !is_implemented && tcx.impl_defaultness(impl_id).is_final() {
+ if !is_implemented && tcx.defaultness(impl_id).is_final() {
missing_items.push(tcx.associated_item(trait_item_id));
}
diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs
index 6ab5556..5bd6fcb 100644
--- a/compiler/rustc_hir_analysis/src/check/region.rs
+++ b/compiler/rustc_hir_analysis/src/check/region.rs
@@ -392,7 +392,7 @@
// Manually recurse over closures and inline consts, because they are the only
// case of nested bodies that share the parent environment.
hir::ExprKind::Closure(&hir::Closure { body, .. })
- | hir::ExprKind::ConstBlock(hir::AnonConst { body, .. }) => {
+ | hir::ExprKind::ConstBlock(hir::ConstBlock { body, .. }) => {
let body = visitor.tcx.hir().body(body);
visitor.visit_body(body);
}
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs
index 2f7d465..c7b9fc9 100644
--- a/compiler/rustc_hir_analysis/src/collect.rs
+++ b/compiler/rustc_hir_analysis/src/collect.rs
@@ -941,7 +941,7 @@
match item {
Some(item) if matches!(item.kind, hir::AssocItemKind::Fn { .. }) => {
- if !tcx.impl_defaultness(item.id.owner_id).has_value() {
+ if !tcx.defaultness(item.id.owner_id).has_value() {
tcx.sess.emit_err(errors::FunctionNotHaveDefaultImplementation {
span: item.span,
note_span: attr_span,
diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs
index ed60998..e92a0dc 100644
--- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs
@@ -50,7 +50,7 @@
// We do not allow generic parameters in anon consts if we are inside
// of a const parameter type, e.g. `struct Foo<const N: usize, const M: [u8; N]>` is not allowed.
None
- } else if tcx.lazy_normalization() {
+ } else if tcx.features().generic_const_exprs {
let parent_node = tcx.hir().get_parent(hir_id);
if let Node::Variant(Variant { disr_expr: Some(constant), .. }) = parent_node
&& constant.hir_id == hir_id
@@ -123,9 +123,6 @@
{
Some(parent_def_id.to_def_id())
}
- Node::Expr(&Expr { kind: ExprKind::ConstBlock(_), .. }) => {
- Some(tcx.typeck_root_def_id(def_id.to_def_id()))
- }
// Exclude `GlobalAsm` here which cannot have generics.
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
if asm.operands.iter().any(|(op, _op_sp)| match op {
@@ -142,7 +139,8 @@
}
}
}
- Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => {
+ Node::ConstBlock(_)
+ | Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => {
Some(tcx.typeck_root_def_id(def_id.to_def_id()))
}
Node::Item(item) => match item.kind {
@@ -339,17 +337,14 @@
}
// provide junk type parameter defs for const blocks.
- if let Node::AnonConst(_) = node {
- let parent_node = tcx.hir().get_parent(hir_id);
- if let Node::Expr(&Expr { kind: ExprKind::ConstBlock(_), .. }) = parent_node {
- params.push(ty::GenericParamDef {
- index: next_index(),
- name: Symbol::intern("<const_ty>"),
- def_id: def_id.to_def_id(),
- pure_wrt_drop: false,
- kind: ty::GenericParamDefKind::Type { has_default: false, synthetic: false },
- });
- }
+ if let Node::ConstBlock(_) = node {
+ params.push(ty::GenericParamDef {
+ index: next_index(),
+ name: Symbol::intern("<const_ty>"),
+ def_id: def_id.to_def_id(),
+ pure_wrt_drop: false,
+ kind: ty::GenericParamDefKind::Type { has_default: false, synthetic: false },
+ });
}
let param_def_id_to_index = params.iter().map(|param| (param.def_id, param.index)).collect();
diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
index 70d950e..dcb5790 100644
--- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
@@ -463,7 +463,7 @@
}
}
} else {
- if matches!(def_kind, DefKind::AnonConst) && tcx.lazy_normalization() {
+ if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let parent_def_id = tcx.hir().get_parent_item(hir_id);
diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs
index 65ab00f..c2b837f 100644
--- a/compiler/rustc_hir_analysis/src/collect/type_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs
@@ -34,12 +34,6 @@
Node::Ty(&Ty { kind: TyKind::Typeof(ref e), .. }) if e.hir_id == hir_id => {
return tcx.typeck(def_id).node_type(e.hir_id)
}
- Node::Expr(&Expr { kind: ExprKind::ConstBlock(ref anon_const), .. })
- if anon_const.hir_id == hir_id =>
- {
- let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id());
- return substs.as_inline_const().ty()
- }
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
if asm.operands.iter().any(|(op, _op_sp)| match op {
@@ -435,7 +429,7 @@
in_trait,
..
}) => {
- if in_trait && !tcx.impl_defaultness(owner).has_value() {
+ if in_trait && !tcx.defaultness(owner).has_value() {
span_bug!(
tcx.def_span(def_id),
"tried to get type of this RPITIT with no definition"
@@ -487,6 +481,11 @@
Node::AnonConst(_) => anon_const_type_of(tcx, def_id),
+ Node::ConstBlock(_) => {
+ let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id());
+ substs.as_inline_const().ty()
+ }
+
Node::GenericParam(param) => match ¶m.kind {
GenericParamKind::Type { default: Some(ty), .. }
| GenericParamKind::Const { ty, .. } => icx.to_ty(ty),
diff --git a/compiler/rustc_hir_analysis/src/outlives/mod.rs b/compiler/rustc_hir_analysis/src/outlives/mod.rs
index 2106d6f..fdbb890 100644
--- a/compiler/rustc_hir_analysis/src/outlives/mod.rs
+++ b/compiler/rustc_hir_analysis/src/outlives/mod.rs
@@ -20,7 +20,8 @@
fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clause<'_>, Span)] {
let id = tcx.hir().local_def_id_to_hir_id(item_def_id);
- if matches!(tcx.def_kind(item_def_id), hir::def::DefKind::AnonConst) && tcx.lazy_normalization()
+ if matches!(tcx.def_kind(item_def_id), hir::def::DefKind::AnonConst)
+ && tcx.features().generic_const_exprs
{
if tcx.hir().opt_const_param_default_param_def_id(id).is_some() {
// In `generics_of` we set the generics' parent to be our parent's parent which means that
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs
index d93e8ef..ced46fe 100644
--- a/compiler/rustc_hir_pretty/src/lib.rs
+++ b/compiler/rustc_hir_pretty/src/lib.rs
@@ -84,6 +84,7 @@
Node::ImplItem(a) => self.print_impl_item(a),
Node::Variant(a) => self.print_variant(a),
Node::AnonConst(a) => self.print_anon_const(a),
+ Node::ConstBlock(a) => self.print_inline_const(a),
Node::Expr(a) => self.print_expr(a),
Node::ExprField(a) => self.print_expr_field(&a),
Node::Stmt(a) => self.print_stmt(a),
@@ -1095,10 +1096,10 @@
self.end()
}
- fn print_expr_anon_const(&mut self, anon_const: &hir::AnonConst) {
+ fn print_inline_const(&mut self, constant: &hir::ConstBlock) {
self.ibox(INDENT_UNIT);
self.word_space("const");
- self.print_anon_const(anon_const);
+ self.ann.nested(self, Nested::Body(constant.body));
self.end()
}
@@ -1370,7 +1371,7 @@
self.print_expr_vec(exprs);
}
hir::ExprKind::ConstBlock(ref anon_const) => {
- self.print_expr_anon_const(anon_const);
+ self.print_inline_const(anon_const);
}
hir::ExprKind::Repeat(element, ref count) => {
self.print_expr_repeat(element, count);
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index 5e10add..3c5feb1 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -348,9 +348,7 @@
}
ExprKind::DropTemps(e) => self.check_expr_with_expectation(e, expected),
ExprKind::Array(args) => self.check_expr_array(args, expected, expr),
- ExprKind::ConstBlock(ref anon_const) => {
- self.check_expr_const_block(anon_const, expected, expr)
- }
+ ExprKind::ConstBlock(ref block) => self.check_expr_const_block(block, expected, expr),
ExprKind::Repeat(element, ref count) => {
self.check_expr_repeat(element, count, expected, expr)
}
@@ -1368,20 +1366,20 @@
fn check_expr_const_block(
&self,
- anon_const: &'tcx hir::AnonConst,
+ block: &'tcx hir::ConstBlock,
expected: Expectation<'tcx>,
_expr: &'tcx hir::Expr<'tcx>,
) -> Ty<'tcx> {
- let body = self.tcx.hir().body(anon_const.body);
+ let body = self.tcx.hir().body(block.body);
// Create a new function context.
- let def_id = anon_const.def_id;
+ let def_id = block.def_id;
let fcx = FnCtxt::new(self, self.param_env.with_const(), def_id);
crate::GatherLocalsVisitor::new(&fcx).visit_body(body);
let ty = fcx.check_expr_with_expectation(&body.value, expected);
fcx.require_type_is_sized(ty, body.value.span, traits::ConstSized);
- fcx.write_ty(anon_const.hir_id, ty);
+ fcx.write_ty(block.hir_id, ty);
ty
}
diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs
index e4a62ec..786a8c2 100644
--- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs
+++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs
@@ -270,6 +270,7 @@
| hir::Node::Variant(..)
| hir::Node::Field(..)
| hir::Node::AnonConst(..)
+ | hir::Node::ConstBlock(..)
| hir::Node::Stmt(..)
| hir::Node::PathSegment(..)
| hir::Node::Ty(..)
diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs
index b6b935d..ed532aa 100644
--- a/compiler/rustc_infer/src/infer/combine.rs
+++ b/compiler/rustc_infer/src/infer/combine.rs
@@ -227,7 +227,7 @@
return self.unify_const_variable(vid, a, relation.param_env());
}
(ty::ConstKind::Unevaluated(..), _) | (_, ty::ConstKind::Unevaluated(..))
- if self.tcx.lazy_normalization() =>
+ if self.tcx.features().generic_const_exprs || self.tcx.trait_solver_next() =>
{
relation.register_const_equate_obligation(a, b);
return Ok(b);
diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
index d1f1104..9a8fac0 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
@@ -586,7 +586,7 @@
// FIXME: account for returning some type in a trait fn impl that has
// an assoc type as a return type (#72076).
if let hir::Defaultness::Default { has_value: true } =
- tcx.impl_defaultness(item.id.owner_id)
+ tcx.defaultness(item.id.owner_id)
{
let assoc_ty = tcx.type_of(item.id.owner_id).subst_identity();
if self.infcx.can_eq(param_env, assoc_ty, found) {
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
index a15307e..243e4f5 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
@@ -231,7 +231,7 @@
opt_def_kind => { table_direct }
impl_parent => { table }
impl_polarity => { table_direct }
- impl_defaultness => { table_direct }
+ defaultness => { table_direct }
constness => { table_direct }
coerce_unsized_info => { table }
mir_const_qualif => { table }
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 6ceb61e..cbc012c 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -1191,7 +1191,7 @@
fn should_encode_const(def_kind: DefKind) -> bool {
match def_kind {
- DefKind::Const | DefKind::AssocConst | DefKind::AnonConst => true,
+ DefKind::Const | DefKind::AssocConst | DefKind::AnonConst | DefKind::InlineConst => true,
DefKind::Struct
| DefKind::Union
@@ -1210,7 +1210,6 @@
| DefKind::Closure
| DefKind::Generator
| DefKind::ConstParam
- | DefKind::InlineConst
| DefKind::AssocTy
| DefKind::TyParam
| DefKind::Trait
@@ -1437,8 +1436,8 @@
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
let tcx = self.tcx;
- let impl_defaultness = tcx.impl_defaultness(def_id.expect_local());
- self.tables.impl_defaultness.set_some(def_id.index, impl_defaultness);
+ let defaultness = tcx.defaultness(def_id.expect_local());
+ self.tables.defaultness.set_some(def_id.index, defaultness);
let trait_item = tcx.associated_item(def_id);
self.tables.assoc_container.set_some(def_id.index, trait_item.container);
@@ -1466,8 +1465,8 @@
debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id);
let tcx = self.tcx;
- let defaultness = self.tcx.impl_defaultness(def_id.expect_local());
- self.tables.impl_defaultness.set_some(def_id.index, defaultness);
+ let defaultness = self.tcx.defaultness(def_id.expect_local());
+ self.tables.defaultness.set_some(def_id.index, defaultness);
let impl_item = self.tcx.associated_item(def_id);
self.tables.assoc_container.set_some(def_id.index, impl_item.container);
@@ -1653,7 +1652,7 @@
);
}
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
- self.tables.impl_defaultness.set_some(def_id.index, *defaultness);
+ self.tables.defaultness.set_some(def_id.index, *defaultness);
self.tables.constness.set_some(def_id.index, *constness);
self.tables.impl_polarity.set_some(def_id.index, self.tcx.impl_polarity(def_id));
diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs
index 2da888f..e9b67c7 100644
--- a/compiler/rustc_metadata/src/rmeta/mod.rs
+++ b/compiler/rustc_metadata/src/rmeta/mod.rs
@@ -420,7 +420,7 @@
impl_parent: Table<DefIndex, RawDefId>,
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
constness: Table<DefIndex, hir::Constness>,
- impl_defaultness: Table<DefIndex, hir::Defaultness>,
+ defaultness: Table<DefIndex, hir::Defaultness>,
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index d1ddc8f..5f2eb89 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -44,6 +44,7 @@
}
Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
+ Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
_ => None,
}
@@ -240,15 +241,8 @@
None => bug!("constructor node without a constructor"),
}
}
- Node::AnonConst(_) => {
- let inline = match self.find_parent(hir_id) {
- Some(Node::Expr(&Expr {
- kind: ExprKind::ConstBlock(ref anon_const), ..
- })) if anon_const.hir_id == hir_id => true,
- _ => false,
- };
- if inline { DefKind::InlineConst } else { DefKind::AnonConst }
- }
+ Node::AnonConst(_) => DefKind::AnonConst,
+ Node::ConstBlock(_) => DefKind::InlineConst,
Node::Field(_) => DefKind::Field,
Node::Expr(expr) => match expr.kind {
ExprKind::Closure(Closure { movability: None, .. }) => DefKind::Closure,
@@ -1060,6 +1054,7 @@
Node::Variant(variant) => variant.span,
Node::Field(field) => field.span,
Node::AnonConst(constant) => self.body(constant.body).value.span,
+ Node::ConstBlock(constant) => self.body(constant.body).value.span,
Node::Expr(expr) => expr.span,
Node::ExprField(field) => field.span,
Node::Stmt(stmt) => stmt.span,
@@ -1289,6 +1284,7 @@
format!("{id} (field `{}` in {})", field.ident, path_str(field.def_id))
}
Some(Node::AnonConst(_)) => node_str("const"),
+ Some(Node::ConstBlock(_)) => node_str("const"),
Some(Node::Expr(_)) => node_str("expr"),
Some(Node::ExprField(_)) => node_str("expr field"),
Some(Node::Stmt(_)) => node_str("stmt"),
@@ -1434,6 +1430,11 @@
intravisit::walk_anon_const(self, c)
}
+ fn visit_inline_const(&mut self, c: &'hir ConstBlock) {
+ self.body_owners.push(c.def_id);
+ intravisit::walk_inline_const(self, c)
+ }
+
fn visit_expr(&mut self, ex: &'hir Expr<'hir>) {
if let ExprKind::Closure(closure) = ex.kind {
self.body_owners.push(closure.def_id);
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs
index 83f8f00..1a65f74 100644
--- a/compiler/rustc_middle/src/mir/syntax.rs
+++ b/compiler/rustc_middle/src/mir/syntax.rs
@@ -1273,13 +1273,18 @@
Mul,
/// The `/` operator (division)
///
- /// Division by zero is UB, because the compiler should have inserted checks
- /// prior to this.
+ /// For integer types, division by zero is UB, as is `MIN / -1` for signed.
+ /// The compiler should have inserted checks prior to this.
+ ///
+ /// Floating-point division by zero is safe, and does not need guards.
Div,
/// The `%` operator (modulus)
///
- /// Using zero as the modulus (second operand) is UB, because the compiler
- /// should have inserted checks prior to this.
+ /// For integer types, using zero as the modulus (second operand) is UB,
+ /// as is `MIN % -1` for signed.
+ /// The compiler should have inserted checks prior to this.
+ ///
+ /// Floating-point remainder by zero is safe, and does not need guards.
Rem,
/// The `^` operator (bitwise xor)
BitXor,
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 0b31c9b..45e0b49 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -1475,8 +1475,9 @@
desc { "getting traits in scope at a block" }
}
- query impl_defaultness(def_id: DefId) -> hir::Defaultness {
- desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
+ /// Returns whether the impl or associated function has the `default` keyword.
+ query defaultness(def_id: DefId) -> hir::Defaultness {
+ desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) }
separate_provide_extern
feedable
}
diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs
index c016f72..dc2cd20 100644
--- a/compiler/rustc_middle/src/traits/specialization_graph.rs
+++ b/compiler/rustc_middle/src/traits/specialization_graph.rs
@@ -228,7 +228,7 @@
if let Some(item) = node.item(tcx, trait_item_def_id) {
if finalizing_node.is_none() {
let is_specializable = item.defaultness(tcx).is_default()
- || tcx.impl_defaultness(node.def_id()).is_default();
+ || tcx.defaultness(node.def_id()).is_default();
if !is_specializable {
finalizing_node = Some(node);
diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs
index 090b769..cce609c 100644
--- a/compiler/rustc_middle/src/ty/assoc.rs
+++ b/compiler/rustc_middle/src/ty/assoc.rs
@@ -48,7 +48,7 @@
///
/// [`type_of`]: crate::ty::TyCtxt::type_of
pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness {
- tcx.impl_defaultness(self.def_id)
+ tcx.defaultness(self.def_id)
}
#[inline]
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 673d09c..bf6f219 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -1015,15 +1015,6 @@
self.query_system.on_disk_cache.as_ref().map_or(Ok(0), |c| c.serialize(self, encoder))
}
- /// If `true`, we should use lazy normalization for constants, otherwise
- /// we still evaluate them eagerly.
- #[inline]
- pub fn lazy_normalization(self) -> bool {
- let features = self.features();
- // Note: We only use lazy normalization for generic const expressions.
- features.generic_const_exprs
- }
-
#[inline]
pub fn local_crate_exports_generics(self) -> bool {
debug_assert!(self.sess.opts.share_generics());
@@ -1884,18 +1875,28 @@
}
#[inline]
- pub fn mk_closure(self, closure_id: DefId, closure_substs: SubstsRef<'tcx>) -> Ty<'tcx> {
- self.mk_ty_from_kind(Closure(closure_id, closure_substs))
+ pub fn mk_closure(self, def_id: DefId, closure_substs: SubstsRef<'tcx>) -> Ty<'tcx> {
+ debug_assert_eq!(
+ closure_substs.len(),
+ self.generics_of(self.typeck_root_def_id(def_id)).count() + 3,
+ "closure constructed with incorrect substitutions"
+ );
+ self.mk_ty_from_kind(Closure(def_id, closure_substs))
}
#[inline]
pub fn mk_generator(
self,
- id: DefId,
+ def_id: DefId,
generator_substs: SubstsRef<'tcx>,
movability: hir::Movability,
) -> Ty<'tcx> {
- self.mk_ty_from_kind(Generator(id, generator_substs, movability))
+ debug_assert_eq!(
+ generator_substs.len(),
+ self.generics_of(self.typeck_root_def_id(def_id)).count() + 5,
+ "generator constructed with incorrect number of substitutions"
+ );
+ self.mk_ty_from_kind(Generator(def_id, generator_substs, movability))
}
#[inline]
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs
index 8f6a069..7f0c1d5 100644
--- a/compiler/rustc_mir_build/src/build/mod.rs
+++ b/compiler/rustc_mir_build/src/build/mod.rs
@@ -556,7 +556,7 @@
span,
..
}) => (*span, ty.span),
- Node::AnonConst(_) => {
+ Node::AnonConst(_) | Node::ConstBlock(_) => {
let span = tcx.def_span(def);
(span, span)
}
diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
index 1bbe7b4..8eeb055 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
@@ -582,22 +582,15 @@
/// Converts inline const patterns.
fn lower_inline_const(
&mut self,
- anon_const: &'tcx hir::AnonConst,
+ block: &'tcx hir::ConstBlock,
id: hir::HirId,
span: Span,
) -> PatKind<'tcx> {
let tcx = self.tcx;
- let def_id = anon_const.def_id;
- let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
- let body_id = match tcx.hir().get(hir_id) {
- hir::Node::AnonConst(ac) => ac.body,
- _ => span_bug!(
- tcx.def_span(def_id.to_def_id()),
- "from_inline_const can only process anonymous constants"
- ),
- };
+ let def_id = block.def_id;
+ let body_id = block.body;
let expr = &tcx.hir().body(body_id).value;
- let ty = tcx.typeck(def_id).node_type(hir_id);
+ let ty = tcx.typeck(def_id).node_type(block.hir_id);
// Special case inline consts that are just literals. This is solely
// a performance optimization, as we could also just go through the regular
diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs
index 069514d..2f851cd 100644
--- a/compiler/rustc_mir_transform/src/check_unsafety.rs
+++ b/compiler/rustc_mir_transform/src/check_unsafety.rs
@@ -421,10 +421,8 @@
intravisit::walk_block(self, block);
}
- fn visit_anon_const(&mut self, c: &'tcx hir::AnonConst) {
- if matches!(self.tcx.def_kind(c.def_id), DefKind::InlineConst) {
- self.visit_body(self.tcx.hir().body(c.body))
- }
+ fn visit_inline_const(&mut self, c: &'tcx hir::ConstBlock) {
+ self.visit_body(self.tcx.hir().body(c.body))
}
fn visit_fn(
diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs
index dae01e4..3a7d58f 100644
--- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs
+++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs
@@ -82,30 +82,35 @@
drop(args);
terminator.kind = TerminatorKind::Goto { target };
}
- sym::wrapping_add | sym::wrapping_sub | sym::wrapping_mul => {
- if let Some(target) = *target {
- let lhs;
- let rhs;
- {
- let mut args = args.drain(..);
- lhs = args.next().unwrap();
- rhs = args.next().unwrap();
- }
- let bin_op = match intrinsic_name {
- sym::wrapping_add => BinOp::Add,
- sym::wrapping_sub => BinOp::Sub,
- sym::wrapping_mul => BinOp::Mul,
- _ => bug!("unexpected intrinsic"),
- };
- block.statements.push(Statement {
- source_info: terminator.source_info,
- kind: StatementKind::Assign(Box::new((
- *destination,
- Rvalue::BinaryOp(bin_op, Box::new((lhs, rhs))),
- ))),
- });
- terminator.kind = TerminatorKind::Goto { target };
+ sym::wrapping_add
+ | sym::wrapping_sub
+ | sym::wrapping_mul
+ | sym::unchecked_div
+ | sym::unchecked_rem => {
+ let target = target.unwrap();
+ let lhs;
+ let rhs;
+ {
+ let mut args = args.drain(..);
+ lhs = args.next().unwrap();
+ rhs = args.next().unwrap();
}
+ let bin_op = match intrinsic_name {
+ sym::wrapping_add => BinOp::Add,
+ sym::wrapping_sub => BinOp::Sub,
+ sym::wrapping_mul => BinOp::Mul,
+ sym::unchecked_div => BinOp::Div,
+ sym::unchecked_rem => BinOp::Rem,
+ _ => bug!("unexpected intrinsic"),
+ };
+ block.statements.push(Statement {
+ source_info: terminator.source_info,
+ kind: StatementKind::Assign(Box::new((
+ *destination,
+ Rvalue::BinaryOp(bin_op, Box::new((lhs, rhs))),
+ ))),
+ });
+ terminator.kind = TerminatorKind::Goto { target };
}
sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {
if let Some(target) = *target {
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index 09025c1..f4ee7b7 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -35,15 +35,15 @@
//!
//! - A "mono item" is something that results in a function or global in
//! the LLVM IR of a codegen unit. Mono items do not stand on their
-//! own, they can reference other mono items. For example, if function
+//! own, they can use other mono items. For example, if function
//! `foo()` calls function `bar()` then the mono item for `foo()`
-//! references the mono item for function `bar()`. In general, the
-//! definition for mono item A referencing a mono item B is that
-//! the LLVM artifact produced for A references the LLVM artifact produced
+//! uses the mono item for function `bar()`. In general, the
+//! definition for mono item A using a mono item B is that
+//! the LLVM artifact produced for A uses the LLVM artifact produced
//! for B.
//!
-//! - Mono items and the references between them form a directed graph,
-//! where the mono items are the nodes and references form the edges.
+//! - Mono items and the uses between them form a directed graph,
+//! where the mono items are the nodes and uses form the edges.
//! Let's call this graph the "mono item graph".
//!
//! - The mono item graph for a program contains all mono items
@@ -53,12 +53,11 @@
//! mono item graph for the current crate. It runs in two phases:
//!
//! 1. Discover the roots of the graph by traversing the HIR of the crate.
-//! 2. Starting from the roots, find neighboring nodes by inspecting the MIR
+//! 2. Starting from the roots, find uses by inspecting the MIR
//! representation of the item corresponding to a given node, until no more
//! new nodes are found.
//!
//! ### Discovering roots
-//!
//! The roots of the mono item graph correspond to the public non-generic
//! syntactic items in the source code. We find them by walking the HIR of the
//! crate, and whenever we hit upon a public function, method, or static item,
@@ -69,25 +68,23 @@
//! specified. Functions marked `#[no_mangle]` and functions called by inlinable
//! functions also always act as roots.)
//!
-//! ### Finding neighbor nodes
-//! Given a mono item node, we can discover neighbors by inspecting its
-//! MIR. We walk the MIR and any time we hit upon something that signifies a
-//! reference to another mono item, we have found a neighbor. Since the
-//! mono item we are currently at is always monomorphic, we also know the
-//! concrete type arguments of its neighbors, and so all neighbors again will be
-//! monomorphic. The specific forms a reference to a neighboring node can take
-//! in MIR are quite diverse. Here is an overview:
+//! ### Finding uses
+//! Given a mono item node, we can discover uses by inspecting its MIR. We walk
+//! the MIR to find other mono items used by each mono item. Since the mono
+//! item we are currently at is always monomorphic, we also know the concrete
+//! type arguments of its used mono items. The specific forms a use can take in
+//! MIR are quite diverse. Here is an overview:
//!
//! #### Calling Functions/Methods
-//! The most obvious form of one mono item referencing another is a
+//! The most obvious way for one mono item to use another is a
//! function or method call (represented by a CALL terminator in MIR). But
-//! calls are not the only thing that might introduce a reference between two
+//! calls are not the only thing that might introduce a use between two
//! function mono items, and as we will see below, they are just a
//! specialization of the form described next, and consequently will not get any
//! special treatment in the algorithm.
//!
//! #### Taking a reference to a function or method
-//! A function does not need to actually be called in order to be a neighbor of
+//! A function does not need to actually be called in order to be used by
//! another function. It suffices to just take a reference in order to introduce
//! an edge. Consider the following example:
//!
@@ -109,18 +106,18 @@
//! The MIR of none of these functions will contain an explicit call to
//! `print_val::<i32>`. Nonetheless, in order to mono this program, we need
//! an instance of this function. Thus, whenever we encounter a function or
-//! method in operand position, we treat it as a neighbor of the current
+//! method in operand position, we treat it as a use of the current
//! mono item. Calls are just a special case of that.
//!
//! #### Drop glue
//! Drop glue mono items are introduced by MIR drop-statements. The
-//! generated mono item will again have drop-glue item neighbors if the
+//! generated mono item will have additional drop-glue item uses if the
//! type to be dropped contains nested values that also need to be dropped. It
-//! might also have a function item neighbor for the explicit `Drop::drop`
+//! might also have a function item use for the explicit `Drop::drop`
//! implementation of its type.
//!
//! #### Unsizing Casts
-//! A subtle way of introducing neighbor edges is by casting to a trait object.
+//! A subtle way of introducing use edges is by casting to a trait object.
//! Since the resulting fat-pointer contains a reference to a vtable, we need to
//! instantiate all object-safe methods of the trait, as we need to store
//! pointers to these functions even if they never get called anywhere. This can
@@ -151,7 +148,7 @@
//! Mono item collection can be performed in one of two modes:
//!
//! - Lazy mode means that items will only be instantiated when actually
-//! referenced. The goal is to produce the least amount of machine code
+//! used. The goal is to produce the least amount of machine code
//! possible.
//!
//! - Eager mode is meant to be used in conjunction with incremental compilation
@@ -198,7 +195,6 @@
use rustc_session::Limit;
use rustc_span::source_map::{dummy_spanned, respan, Span, Spanned, DUMMY_SP};
use rustc_target::abi::Size;
-use std::ops::Range;
use std::path::PathBuf;
use crate::errors::{
@@ -211,75 +207,60 @@
Lazy,
}
-/// Maps every mono item to all mono items it references in its
-/// body.
-pub struct InliningMap<'tcx> {
- // Maps a source mono item to the range of mono items
- // accessed by it.
- // The range selects elements within the `targets` vecs.
- index: FxHashMap<MonoItem<'tcx>, Range<usize>>,
- targets: Vec<MonoItem<'tcx>>,
+pub struct UsageMap<'tcx> {
+ // Maps every mono item to the mono items used by it.
+ used_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
+
+ // Maps every mono item to the mono items that use it.
+ user_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
}
type MonoItems<'tcx> = Vec<Spanned<MonoItem<'tcx>>>;
-impl<'tcx> InliningMap<'tcx> {
- fn new() -> InliningMap<'tcx> {
- InliningMap { index: FxHashMap::default(), targets: Vec::new() }
+impl<'tcx> UsageMap<'tcx> {
+ fn new() -> UsageMap<'tcx> {
+ UsageMap { used_map: FxHashMap::default(), user_map: FxHashMap::default() }
}
- fn record_accesses<'a>(
+ fn record_used<'a>(
&mut self,
- source: MonoItem<'tcx>,
- new_targets: &'a [Spanned<MonoItem<'tcx>>],
+ user_item: MonoItem<'tcx>,
+ used_items: &'a [Spanned<MonoItem<'tcx>>],
) where
'tcx: 'a,
{
- let start_index = self.targets.len();
- let new_items_count = new_targets.len();
-
- self.targets.reserve(new_items_count);
-
- for Spanned { node: mono_item, .. } in new_targets.into_iter() {
- self.targets.push(*mono_item);
+ let used_items: Vec<_> = used_items.iter().map(|item| item.node).collect();
+ for &used_item in used_items.iter() {
+ self.user_map.entry(used_item).or_default().push(user_item);
}
- let end_index = self.targets.len();
- assert!(self.index.insert(source, start_index..end_index).is_none());
+ assert!(self.used_map.insert(user_item, used_items).is_none());
}
- /// Internally iterate over all items referenced by `source` which will be
- /// made available for inlining.
- pub fn with_inlining_candidates<F>(&self, tcx: TyCtxt<'tcx>, source: MonoItem<'tcx>, mut f: F)
+ pub fn get_user_items(&self, item: MonoItem<'tcx>) -> Option<&[MonoItem<'tcx>]> {
+ self.user_map.get(&item).map(|items| items.as_slice())
+ }
+
+ /// Internally iterate over all inlined items used by `item`.
+ pub fn for_each_inlined_used_item<F>(&self, tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>, mut f: F)
where
F: FnMut(MonoItem<'tcx>),
{
- if let Some(range) = self.index.get(&source) {
- for candidate in self.targets[range.clone()].iter() {
- let is_inlined = candidate.instantiation_mode(tcx) == InstantiationMode::LocalCopy;
- if is_inlined {
- f(*candidate);
- }
+ let used_items = self.used_map.get(&item).unwrap();
+ for used_item in used_items.iter() {
+ let is_inlined = used_item.instantiation_mode(tcx) == InstantiationMode::LocalCopy;
+ if is_inlined {
+ f(*used_item);
}
}
}
-
- /// Internally iterate over all items and the things each accesses.
- pub fn iter_accesses<F>(&self, mut f: F)
- where
- F: FnMut(MonoItem<'tcx>, &[MonoItem<'tcx>]),
- {
- for (&accessor, range) in &self.index {
- f(accessor, &self.targets[range.clone()])
- }
- }
}
#[instrument(skip(tcx, mode), level = "debug")]
pub fn collect_crate_mono_items(
tcx: TyCtxt<'_>,
mode: MonoItemCollectionMode,
-) -> (FxHashSet<MonoItem<'_>>, InliningMap<'_>) {
+) -> (FxHashSet<MonoItem<'_>>, UsageMap<'_>) {
let _prof_timer = tcx.prof.generic_activity("monomorphization_collector");
let roots =
@@ -288,12 +269,12 @@
debug!("building mono item graph, beginning at roots");
let mut visited = MTLock::new(FxHashSet::default());
- let mut inlining_map = MTLock::new(InliningMap::new());
+ let mut usage_map = MTLock::new(UsageMap::new());
let recursion_limit = tcx.recursion_limit();
{
let visited: MTLockRef<'_, _> = &mut visited;
- let inlining_map: MTLockRef<'_, _> = &mut inlining_map;
+ let usage_map: MTLockRef<'_, _> = &mut usage_map;
tcx.sess.time("monomorphization_collector_graph_walk", || {
par_for_each_in(roots, |root| {
@@ -304,13 +285,13 @@
visited,
&mut recursion_depths,
recursion_limit,
- inlining_map,
+ usage_map,
);
});
});
}
- (visited.into_inner(), inlining_map.into_inner())
+ (visited.into_inner(), usage_map.into_inner())
}
// Find all non-generic items by walking the HIR. These items serve as roots to
@@ -353,24 +334,23 @@
/// Collect all monomorphized items reachable from `starting_point`, and emit a note diagnostic if a
/// post-monomorphization error is encountered during a collection step.
-#[instrument(skip(tcx, visited, recursion_depths, recursion_limit, inlining_map), level = "debug")]
+#[instrument(skip(tcx, visited, recursion_depths, recursion_limit, usage_map), level = "debug")]
fn collect_items_rec<'tcx>(
tcx: TyCtxt<'tcx>,
- starting_point: Spanned<MonoItem<'tcx>>,
+ starting_item: Spanned<MonoItem<'tcx>>,
visited: MTLockRef<'_, FxHashSet<MonoItem<'tcx>>>,
recursion_depths: &mut DefIdMap<usize>,
recursion_limit: Limit,
- inlining_map: MTLockRef<'_, InliningMap<'tcx>>,
+ usage_map: MTLockRef<'_, UsageMap<'tcx>>,
) {
- if !visited.lock_mut().insert(starting_point.node) {
+ if !visited.lock_mut().insert(starting_item.node) {
// We've been here already, no need to search again.
return;
}
- let mut neighbors = Vec::new();
+ let mut used_items = Vec::new();
let recursion_depth_reset;
- //
// Post-monomorphization errors MVP
//
// We can encounter errors while monomorphizing an item, but we don't have a good way of
@@ -396,7 +376,7 @@
// FIXME: don't rely on global state, instead bubble up errors. Note: this is very hard to do.
let error_count = tcx.sess.diagnostic().err_count();
- match starting_point.node {
+ match starting_item.node {
MonoItem::Static(def_id) => {
let instance = Instance::mono(tcx, def_id);
@@ -404,19 +384,19 @@
debug_assert!(should_codegen_locally(tcx, &instance));
let ty = instance.ty(tcx, ty::ParamEnv::reveal_all());
- visit_drop_use(tcx, ty, true, starting_point.span, &mut neighbors);
+ visit_drop_use(tcx, ty, true, starting_item.span, &mut used_items);
recursion_depth_reset = None;
if let Ok(alloc) = tcx.eval_static_initializer(def_id) {
for &id in alloc.inner().provenance().ptrs().values() {
- collect_miri(tcx, id, &mut neighbors);
+ collect_miri(tcx, id, &mut used_items);
}
}
if tcx.needs_thread_local_shim(def_id) {
- neighbors.push(respan(
- starting_point.span,
+ used_items.push(respan(
+ starting_item.span,
MonoItem::Fn(Instance {
def: InstanceDef::ThreadLocalShim(def_id),
substs: InternalSubsts::empty(),
@@ -432,14 +412,14 @@
recursion_depth_reset = Some(check_recursion_limit(
tcx,
instance,
- starting_point.span,
+ starting_item.span,
recursion_depths,
recursion_limit,
));
check_type_length_limit(tcx, instance);
rustc_data_structures::stack::ensure_sufficient_stack(|| {
- collect_neighbours(tcx, instance, &mut neighbors);
+ collect_used_items(tcx, instance, &mut used_items);
});
}
MonoItem::GlobalAsm(item_id) => {
@@ -457,13 +437,13 @@
hir::InlineAsmOperand::SymFn { anon_const } => {
let fn_ty =
tcx.typeck_body(anon_const.body).node_type(anon_const.hir_id);
- visit_fn_use(tcx, fn_ty, false, *op_sp, &mut neighbors);
+ visit_fn_use(tcx, fn_ty, false, *op_sp, &mut used_items);
}
hir::InlineAsmOperand::SymStatic { path: _, def_id } => {
let instance = Instance::mono(tcx, *def_id);
if should_codegen_locally(tcx, &instance) {
trace!("collecting static {:?}", def_id);
- neighbors.push(dummy_spanned(MonoItem::Static(*def_id)));
+ used_items.push(dummy_spanned(MonoItem::Static(*def_id)));
}
}
hir::InlineAsmOperand::In { .. }
@@ -483,19 +463,19 @@
// Check for PMEs and emit a diagnostic if one happened. To try to show relevant edges of the
// mono item graph.
if tcx.sess.diagnostic().err_count() > error_count
- && starting_point.node.is_generic_fn()
- && starting_point.node.is_user_defined()
+ && starting_item.node.is_generic_fn()
+ && starting_item.node.is_user_defined()
{
- let formatted_item = with_no_trimmed_paths!(starting_point.node.to_string());
+ let formatted_item = with_no_trimmed_paths!(starting_item.node.to_string());
tcx.sess.emit_note(EncounteredErrorWhileInstantiating {
- span: starting_point.span,
+ span: starting_item.span,
formatted_item,
});
}
- inlining_map.lock_mut().record_accesses(starting_point.node, &neighbors);
+ usage_map.lock_mut().record_used(starting_item.node, &used_items);
- for neighbour in neighbors {
- collect_items_rec(tcx, neighbour, visited, recursion_depths, recursion_limit, inlining_map);
+ for used_item in used_items {
+ collect_items_rec(tcx, used_item, visited, recursion_depths, recursion_limit, usage_map);
}
if let Some((def_id, depth)) = recursion_depth_reset {
@@ -611,14 +591,14 @@
}
}
-struct MirNeighborCollector<'a, 'tcx> {
+struct MirUsedCollector<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
body: &'a mir::Body<'tcx>,
output: &'a mut MonoItems<'tcx>,
instance: Instance<'tcx>,
}
-impl<'a, 'tcx> MirNeighborCollector<'a, 'tcx> {
+impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> {
pub fn monomorphize<T>(&self, value: T) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
@@ -632,7 +612,7 @@
}
}
-impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
+impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: Location) {
debug!("visiting rvalue {:?}", *rvalue);
@@ -1392,13 +1372,13 @@
/// Scans the MIR in order to find function calls, closures, and drop-glue.
#[instrument(skip(tcx, output), level = "debug")]
-fn collect_neighbours<'tcx>(
+fn collect_used_items<'tcx>(
tcx: TyCtxt<'tcx>,
instance: Instance<'tcx>,
output: &mut MonoItems<'tcx>,
) {
let body = tcx.instance_mir(instance.def);
- MirNeighborCollector { tcx, body: &body, output, instance }.visit_body(&body);
+ MirUsedCollector { tcx, body: &body, output, instance }.visit_body(&body);
}
#[instrument(skip(tcx, output), level = "debug")]
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs
index 015361f..79fcd62 100644
--- a/compiler/rustc_monomorphize/src/partitioning.rs
+++ b/compiler/rustc_monomorphize/src/partitioning.rs
@@ -115,14 +115,14 @@
use rustc_session::config::{DumpMonoStatsFormat, SwitchWithOptPath};
use rustc_span::symbol::Symbol;
-use crate::collector::InliningMap;
+use crate::collector::UsageMap;
use crate::collector::{self, MonoItemCollectionMode};
use crate::errors::{CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownCguCollectionMode};
struct PartitioningCx<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
target_cgu_count: usize,
- inlining_map: &'a InliningMap<'tcx>,
+ usage_map: &'a UsageMap<'tcx>,
}
struct PlacedRootMonoItems<'tcx> {
@@ -138,14 +138,14 @@
tcx: TyCtxt<'tcx>,
mono_items: &mut I,
max_cgu_count: usize,
- inlining_map: &InliningMap<'tcx>,
+ usage_map: &UsageMap<'tcx>,
) -> Vec<CodegenUnit<'tcx>>
where
I: Iterator<Item = MonoItem<'tcx>>,
{
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning");
- let cx = &PartitioningCx { tcx, target_cgu_count: max_cgu_count, inlining_map };
+ let cx = &PartitioningCx { tcx, target_cgu_count: max_cgu_count, usage_map };
// In the first step, we place all regular monomorphizations into their
// respective 'home' codegen unit. Regular monomorphizations are all
@@ -405,7 +405,7 @@
}
/// For symbol internalization, we need to know whether a symbol/mono-item is
-/// accessed from outside the codegen unit it is defined in. This type is used
+/// used from outside the codegen unit it is defined in. This type is used
/// to keep track of that.
#[derive(Clone, PartialEq, Eq, Debug)]
enum MonoItemPlacement {
@@ -422,33 +422,25 @@
let single_codegen_unit = codegen_units.len() == 1;
- for old_codegen_unit in codegen_units.iter_mut() {
+ for cgu in codegen_units.iter_mut() {
// Collect all items that need to be available in this codegen unit.
let mut reachable = FxHashSet::default();
- for root in old_codegen_unit.items().keys() {
- follow_inlining(cx.tcx, *root, cx.inlining_map, &mut reachable);
+ for root in cgu.items().keys() {
+ // Insert the root item itself, plus all inlined items that are
+ // reachable from it without going via another root item.
+ reachable.insert(*root);
+ get_reachable_inlined_items(cx.tcx, *root, cx.usage_map, &mut reachable);
}
- let mut new_codegen_unit = CodegenUnit::new(old_codegen_unit.name());
-
// Add all monomorphizations that are not already there.
for mono_item in reachable {
- if let Some(linkage) = old_codegen_unit.items().get(&mono_item) {
- // This is a root, just copy it over.
- new_codegen_unit.items_mut().insert(mono_item, *linkage);
- } else {
+ if !cgu.items().contains_key(&mono_item) {
if roots.contains(&mono_item) {
- bug!(
- "GloballyShared mono-item inlined into other CGU: \
- {:?}",
- mono_item
- );
+ bug!("GloballyShared mono-item inlined into other CGU: {:?}", mono_item);
}
// This is a CGU-private copy.
- new_codegen_unit
- .items_mut()
- .insert(mono_item, (Linkage::Internal, Visibility::Default));
+ cgu.items_mut().insert(mono_item, (Linkage::Internal, Visibility::Default));
}
if !single_codegen_unit {
@@ -458,39 +450,32 @@
Entry::Occupied(e) => {
let placement = e.into_mut();
debug_assert!(match *placement {
- MonoItemPlacement::SingleCgu { cgu_name } => {
- cgu_name != new_codegen_unit.name()
- }
+ MonoItemPlacement::SingleCgu { cgu_name } => cgu_name != cgu.name(),
MonoItemPlacement::MultipleCgus => true,
});
*placement = MonoItemPlacement::MultipleCgus;
}
Entry::Vacant(e) => {
- e.insert(MonoItemPlacement::SingleCgu {
- cgu_name: new_codegen_unit.name(),
- });
+ e.insert(MonoItemPlacement::SingleCgu { cgu_name: cgu.name() });
}
}
}
}
-
- *old_codegen_unit = new_codegen_unit;
}
return mono_item_placements;
- fn follow_inlining<'tcx>(
+ fn get_reachable_inlined_items<'tcx>(
tcx: TyCtxt<'tcx>,
- mono_item: MonoItem<'tcx>,
- inlining_map: &InliningMap<'tcx>,
+ item: MonoItem<'tcx>,
+ usage_map: &UsageMap<'tcx>,
visited: &mut FxHashSet<MonoItem<'tcx>>,
) {
- if !visited.insert(mono_item) {
- return;
- }
-
- inlining_map.with_inlining_candidates(tcx, mono_item, |target| {
- follow_inlining(tcx, target, inlining_map, visited);
+ usage_map.for_each_inlined_used_item(tcx, item, |inlined_item| {
+ let is_new = visited.insert(inlined_item);
+ if is_new {
+ get_reachable_inlined_items(tcx, inlined_item, usage_map, visited);
+ }
});
}
}
@@ -504,7 +489,7 @@
if codegen_units.len() == 1 {
// Fast path for when there is only one codegen unit. In this case we
// can internalize all candidates, since there is nowhere else they
- // could be accessed from.
+ // could be used from.
for cgu in codegen_units {
for candidate in &internalization_candidates {
cgu.items_mut().insert(*candidate, (Linkage::Internal, Visibility::Default));
@@ -514,45 +499,36 @@
return;
}
- // Build a map from every monomorphization to all the monomorphizations that
- // reference it.
- let mut accessor_map: FxHashMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>> = Default::default();
- cx.inlining_map.iter_accesses(|accessor, accessees| {
- for accessee in accessees {
- accessor_map.entry(*accessee).or_default().push(accessor);
- }
- });
-
// For each internalization candidates in each codegen unit, check if it is
- // accessed from outside its defining codegen unit.
+ // used from outside its defining codegen unit.
for cgu in codegen_units {
let home_cgu = MonoItemPlacement::SingleCgu { cgu_name: cgu.name() };
- for (accessee, linkage_and_visibility) in cgu.items_mut() {
- if !internalization_candidates.contains(accessee) {
+ for (item, linkage_and_visibility) in cgu.items_mut() {
+ if !internalization_candidates.contains(item) {
// This item is no candidate for internalizing, so skip it.
continue;
}
- debug_assert_eq!(mono_item_placements[accessee], home_cgu);
+ debug_assert_eq!(mono_item_placements[item], home_cgu);
- if let Some(accessors) = accessor_map.get(accessee) {
- if accessors
+ if let Some(user_items) = cx.usage_map.get_user_items(*item) {
+ if user_items
.iter()
- .filter_map(|accessor| {
- // Some accessors might not have been
+ .filter_map(|user_item| {
+ // Some user mono items might not have been
// instantiated. We can safely ignore those.
- mono_item_placements.get(accessor)
+ mono_item_placements.get(user_item)
})
.any(|placement| *placement != home_cgu)
{
- // Found an accessor from another CGU, so skip to the next
- // item without marking this one as internal.
+ // Found a user from another CGU, so skip to the next item
+ // without marking this one as internal.
continue;
}
}
- // If we got here, we did not find any accesses from other CGUs,
- // so it's fine to make this monomorphization internal.
+ // If we got here, we did not find any uses from other CGUs, so
+ // it's fine to make this monomorphization internal.
*linkage_and_visibility = (Linkage::Internal, Visibility::Default);
}
}
@@ -788,7 +764,7 @@
} else {
// If this isn't a generic function then we mark this a `Default` if
// this is a reachable item, meaning that it's a symbol other crates may
- // access when they link to us.
+ // use when they link to us.
if tcx.is_reachable_non_generic(def_id.to_def_id()) {
*can_be_internalized = false;
debug_assert!(!is_generic);
@@ -968,7 +944,7 @@
}
};
- let (items, inlining_map) = collector::collect_crate_mono_items(tcx, collection_mode);
+ let (items, usage_map) = collector::collect_crate_mono_items(tcx, collection_mode);
tcx.sess.abort_if_errors();
@@ -979,7 +955,7 @@
tcx,
&mut items.iter().copied(),
tcx.sess.codegen_units(),
- &inlining_map,
+ &usage_map,
);
codegen_units[0].make_primary();
&*tcx.arena.alloc_from_iter(codegen_units)
diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs
index 2357b0a..fc437c4 100644
--- a/compiler/rustc_passes/src/check_const.rs
+++ b/compiler/rustc_passes/src/check_const.rs
@@ -199,6 +199,11 @@
self.recurse_into(kind, None, |this| intravisit::walk_anon_const(this, anon));
}
+ fn visit_inline_const(&mut self, block: &'tcx hir::ConstBlock) {
+ let kind = Some(hir::ConstContext::Const);
+ self.recurse_into(kind, None, |this| intravisit::walk_inline_const(this, block));
+ }
+
fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
let owner = self.tcx.hir().body_owner_def_id(body.id());
let kind = self.tcx.hir().body_const_context(owner);
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index 7812dcd..d5ac1cd 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -500,6 +500,17 @@
self.in_pat = in_pat;
}
+
+ fn visit_inline_const(&mut self, c: &'tcx hir::ConstBlock) {
+ // When inline const blocks are used in pattern position, paths
+ // referenced by it should be considered as used.
+ let in_pat = mem::replace(&mut self.in_pat, false);
+
+ self.live_symbols.insert(c.def_id);
+ intravisit::walk_inline_const(self, c);
+
+ self.in_pat = in_pat;
+ }
}
fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs
index 73cfe68..7c64df6 100644
--- a/compiler/rustc_passes/src/loops.rs
+++ b/compiler/rustc_passes/src/loops.rs
@@ -24,7 +24,7 @@
Closure(Span),
AsyncClosure(Span),
LabeledBlock,
- AnonConst,
+ Constant,
}
#[derive(Copy, Clone)]
@@ -53,7 +53,11 @@
}
fn visit_anon_const(&mut self, c: &'hir hir::AnonConst) {
- self.with_context(AnonConst, |v| intravisit::walk_anon_const(v, c));
+ self.with_context(Constant, |v| intravisit::walk_anon_const(v, c));
+ }
+
+ fn visit_inline_const(&mut self, c: &'hir hir::ConstBlock) {
+ self.with_context(Constant, |v| intravisit::walk_inline_const(v, c));
}
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
@@ -192,7 +196,7 @@
AsyncClosure(closure_span) => {
self.sess.emit_err(BreakInsideAsyncBlock { span, closure_span, name });
}
- Normal | AnonConst => {
+ Normal | Constant => {
self.sess.emit_err(OutsideLoop { span, name, is_break: name == "break" });
}
}
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs
index 65dfdf3..0197b99 100644
--- a/compiler/rustc_privacy/src/lib.rs
+++ b/compiler/rustc_privacy/src/lib.rs
@@ -751,7 +751,7 @@
reach.generics().predicates();
if trait_item_ref.kind == AssocItemKind::Type
- && !tcx.impl_defaultness(trait_item_ref.id.owner_id).has_value()
+ && !tcx.defaultness(trait_item_ref.id.owner_id).has_value()
{
// No type to visit.
} else {
@@ -1927,7 +1927,7 @@
let (check_ty, is_assoc_ty) = match assoc_item_kind {
AssocItemKind::Const | AssocItemKind::Fn { .. } => (true, false),
- AssocItemKind::Type => (self.tcx.impl_defaultness(def_id).has_value(), true),
+ AssocItemKind::Type => (self.tcx.defaultness(def_id).has_value(), true),
};
check.in_assoc_ty = is_assoc_ty;
check.generics().predicates();
diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
index 81af071..8582551 100644
--- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
+++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
@@ -697,12 +697,12 @@
}
// Unexpected types
- ty::Bound(..)
+ ty::Alias(..)
+ | ty::Bound(..)
| ty::Error(..)
| ty::GeneratorWitness(..)
| ty::GeneratorWitnessMIR(..)
| ty::Infer(..)
- | ty::Alias(..)
| ty::Placeholder(..) => {
bug!("encode_ty: unexpected `{:?}`", ty.kind());
}
@@ -946,11 +946,18 @@
);
}
+ ty::Alias(..) => {
+ ty = transform_ty(
+ tcx,
+ tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty),
+ options,
+ );
+ }
+
ty::Bound(..)
| ty::Error(..)
| ty::GeneratorWitnessMIR(..)
| ty::Infer(..)
- | ty::Alias(..)
| ty::Param(..)
| ty::Placeholder(..) => {
bug!("transform_ty: unexpected `{:?}`", ty.kind());
diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
index f91c672..bc93b9e 100644
--- a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
+++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
@@ -322,10 +322,13 @@
ty::PredicateKind::Ambiguous => {
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
- // FIXME: implement these predicates :)
- ty::PredicateKind::ConstEvaluatable(_) | ty::PredicateKind::ConstEquate(_, _) => {
+ // FIXME: implement this predicate :)
+ ty::PredicateKind::ConstEvaluatable(_) => {
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
+ ty::PredicateKind::ConstEquate(_, _) => {
+ bug!("ConstEquate should not be emitted when `-Ztrait-solver=next` is active")
+ }
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
bug!("TypeWellFormedFromEnv is only used for Chalk")
}
@@ -772,4 +775,21 @@
}
values
}
+
+ // Try to evaluate a const, or return `None` if the const is too generic.
+ // This doesn't mean the const isn't evaluatable, though, and should be treated
+ // as an ambiguity rather than no-solution.
+ pub(super) fn try_const_eval_resolve(
+ &self,
+ param_env: ty::ParamEnv<'tcx>,
+ unevaluated: ty::UnevaluatedConst<'tcx>,
+ ty: Ty<'tcx>,
+ ) -> Option<ty::Const<'tcx>> {
+ use rustc_middle::mir::interpret::ErrorHandled;
+ match self.infcx.try_const_eval_resolve(param_env, unevaluated, ty, None) {
+ Ok(ct) => Some(ct),
+ Err(ErrorHandled::Reported(e)) => Some(self.tcx().const_error(ty, e.into())),
+ Err(ErrorHandled::TooGeneric) => None,
+ }
+ }
}
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs
index 4a40319..2123274 100644
--- a/compiler/rustc_trait_selection/src/solve/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs
@@ -118,16 +118,6 @@
TypeError::Sorts(expected_found),
)
}
- ty::PredicateKind::ConstEquate(a, b) => {
- let (a, b) = infcx.instantiate_binder_with_placeholders(
- goal.predicate.kind().rebind((a, b)),
- );
- let expected_found = ExpectedFound::new(true, a, b);
- FulfillmentErrorCode::CodeConstEquateError(
- expected_found,
- TypeError::ConstMismatch(expected_found),
- )
- }
ty::PredicateKind::Clause(_)
| ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::ObjectSafe(_)
@@ -138,7 +128,8 @@
SelectionError::Unimplemented,
)
}
- ty::PredicateKind::TypeWellFormedFromEnv(_) => {
+ ty::PredicateKind::ConstEquate(..)
+ | ty::PredicateKind::TypeWellFormedFromEnv(_) => {
bug!("unexpected goal: {goal:?}")
}
},
diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs
index 7d7dfa2..242f9ba 100644
--- a/compiler/rustc_trait_selection/src/solve/project_goals.rs
+++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs
@@ -22,25 +22,65 @@
&mut self,
goal: Goal<'tcx, ProjectionPredicate<'tcx>>,
) -> QueryResult<'tcx> {
- match goal.predicate.projection_ty.kind(self.tcx()) {
- ty::AliasKind::Projection => {
+ let def_id = goal.predicate.def_id();
+ match self.tcx().def_kind(def_id) {
+ DefKind::AssocTy | DefKind::AssocConst => {
// To only compute normalization once for each projection we only
- // normalize if the expected term is an unconstrained inference variable.
+ // assemble normalization candidates if the expected term is an
+ // unconstrained inference variable.
+ //
+ // Why: For better cache hits, since if we have an unconstrained RHS then
+ // there are only as many cache keys as there are (canonicalized) alias
+ // types in each normalizes-to goal. This also weakens inference in a
+ // forwards-compatible way so we don't use the value of the RHS term to
+ // affect candidate assembly for projections.
//
// E.g. for `<T as Trait>::Assoc == u32` we recursively compute the goal
// `exists<U> <T as Trait>::Assoc == U` and then take the resulting type for
// `U` and equate it with `u32`. This means that we don't need a separate
- // projection cache in the solver.
+ // projection cache in the solver, since we're piggybacking off of regular
+ // goal caching.
if self.term_is_fully_unconstrained(goal) {
- let candidates = self.assemble_and_evaluate_candidates(goal);
- self.merge_candidates(candidates)
+ match self.tcx().associated_item(def_id).container {
+ ty::AssocItemContainer::TraitContainer => {
+ let candidates = self.assemble_and_evaluate_candidates(goal);
+ self.merge_candidates(candidates)
+ }
+ ty::AssocItemContainer::ImplContainer => {
+ bug!("IATs not supported here yet")
+ }
+ }
} else {
self.set_normalizes_to_hack_goal(goal);
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}
- ty::AliasKind::Opaque => self.normalize_opaque_type(goal),
- ty::AliasKind::Inherent => bug!("IATs not supported here yet"),
+ DefKind::AnonConst => self.normalize_anon_const(goal),
+ DefKind::OpaqueTy => self.normalize_opaque_type(goal),
+ kind => bug!("unknown DefKind {} in projection goal: {goal:#?}", kind.descr(def_id)),
+ }
+ }
+
+ #[instrument(level = "debug", skip(self), ret)]
+ fn normalize_anon_const(
+ &mut self,
+ goal: Goal<'tcx, ty::ProjectionPredicate<'tcx>>,
+ ) -> QueryResult<'tcx> {
+ if let Some(normalized_const) = self.try_const_eval_resolve(
+ goal.param_env,
+ ty::UnevaluatedConst::new(
+ goal.predicate.projection_ty.def_id,
+ goal.predicate.projection_ty.substs,
+ ),
+ self.tcx()
+ .type_of(goal.predicate.projection_ty.def_id)
+ .no_bound_vars()
+ .expect("const ty should not rely on other generics"),
+ ) {
+ self.eq(goal.param_env, normalized_const, goal.predicate.term.ct().unwrap())?;
+ self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
+ } else {
+ self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
}
}
@@ -173,17 +213,10 @@
);
// Finally we construct the actual value of the associated type.
- let is_const = matches!(tcx.def_kind(assoc_def.item.def_id), DefKind::AssocConst);
- let ty = tcx.type_of(assoc_def.item.def_id);
- let term: ty::EarlyBinder<ty::Term<'tcx>> = if is_const {
- let identity_substs =
- ty::InternalSubsts::identity_for_item(tcx, assoc_def.item.def_id);
- let did = assoc_def.item.def_id;
- let kind =
- ty::ConstKind::Unevaluated(ty::UnevaluatedConst::new(did, identity_substs));
- ty.map_bound(|ty| tcx.mk_const(kind, ty).into())
- } else {
- ty.map_bound(|ty| ty.into())
+ let term = match assoc_def.item.kind {
+ ty::AssocKind::Type => tcx.type_of(assoc_def.item.def_id).map_bound(|ty| ty.into()),
+ ty::AssocKind::Const => bug!("associated const projection is not supported yet"),
+ ty::AssocKind::Fn => unreachable!("we should never project to a fn"),
};
ecx.eq(goal.param_env, goal.predicate.term, term.subst(tcx, substs))
@@ -193,10 +226,14 @@
}
fn consider_auto_trait_candidate(
- _ecx: &mut EvalCtxt<'_, 'tcx>,
+ ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx> {
- bug!("auto traits do not have associated types: {:?}", goal);
+ ecx.tcx().sess.delay_span_bug(
+ ecx.tcx().def_span(goal.predicate.def_id()),
+ "associated types not allowed on auto traits",
+ );
+ Err(NoSolution)
}
fn consider_trait_alias_candidate(
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 65af0bb..563cc25 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -672,7 +672,9 @@
#[instrument(skip(self), level = "debug")]
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
let tcx = self.selcx.tcx();
- if tcx.lazy_normalization() || !needs_normalization(&constant, self.param_env.reveal()) {
+ if tcx.features().generic_const_exprs
+ || !needs_normalization(&constant, self.param_env.reveal())
+ {
constant
} else {
let constant = constant.super_fold_with(self);
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs
index e2c9c62..537405b 100644
--- a/compiler/rustc_trait_selection/src/traits/util.rs
+++ b/compiler/rustc_trait_selection/src/traits/util.rs
@@ -295,7 +295,7 @@
pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
assoc_item.defaultness(tcx).is_final()
- && tcx.impl_defaultness(assoc_item.container_id(tcx)).is_final()
+ && tcx.defaultness(assoc_item.container_id(tcx)).is_final()
}
pub enum TupleArgumentsFlag {
diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs
index 57b4183..658ab03 100644
--- a/compiler/rustc_ty_utils/src/assoc.rs
+++ b/compiler/rustc_ty_utils/src/assoc.rs
@@ -297,8 +297,8 @@
// Copy visility of the containing function.
trait_assoc_ty.visibility(tcx.visibility(fn_def_id));
- // Copy impl_defaultness of the containing function.
- trait_assoc_ty.impl_defaultness(tcx.impl_defaultness(fn_def_id));
+ // Copy defaultness of the containing function.
+ trait_assoc_ty.defaultness(tcx.defaultness(fn_def_id));
// Copy type_of of the opaque.
trait_assoc_ty.type_of(ty::EarlyBinder::bind(tcx.mk_opaque(
@@ -393,8 +393,8 @@
// Copy visility of the containing function.
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
- // Copy impl_defaultness of the containing function.
- impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
+ // Copy defaultness of the containing function.
+ impl_assoc_ty.defaultness(tcx.defaultness(impl_fn_def_id));
// Copy generics_of the trait's associated item but the impl as the parent.
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) resolves to the trait instead of the impl
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 36a20c7..dd91123 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -204,7 +204,7 @@
} else {
// All other methods are default methods of the `Future` trait.
// (this assumes that `ImplSource::Future` is only used for methods on `Future`)
- debug_assert!(tcx.impl_defaultness(trait_item_id).has_value());
+ debug_assert!(tcx.defaultness(trait_item_id).has_value());
Some(Instance::new(trait_item_id, rcvr_substs))
}
}
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs
index 12ad8b0..fe2d1fb 100644
--- a/compiler/rustc_ty_utils/src/ty.rs
+++ b/compiler/rustc_ty_utils/src/ty.rs
@@ -75,13 +75,13 @@
result
}
-fn impl_defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness {
+fn defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness {
match tcx.hir().get_by_def_id(def_id) {
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.defaultness,
hir::Node::ImplItem(hir::ImplItem { defaultness, .. })
| hir::Node::TraitItem(hir::TraitItem { defaultness, .. }) => *defaultness,
node => {
- bug!("`impl_defaultness` called on {:?}", node);
+ bug!("`defaultness` called on {:?}", node);
}
}
}
@@ -186,6 +186,7 @@
kind: hir::TraitItemKind::Const(..), ..
})
| hir::Node::AnonConst(_)
+ | hir::Node::ConstBlock(_)
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. })
| hir::Node::ImplItem(hir::ImplItem {
kind:
@@ -574,7 +575,7 @@
param_env_reveal_all_normalized,
instance_def_size_estimate,
issue33140_self_ty,
- impl_defaultness,
+ defaultness,
unsizing_params_for_adt,
..*providers
};
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index 744767a..c1cc892 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -59,7 +59,7 @@
//! [`borrow`](`RefCell::borrow`), and a mutable borrow (`&mut T`) can be obtained with
//! [`borrow_mut`](`RefCell::borrow_mut`). When these functions are called, they first verify that
//! Rust's borrow rules will be satisfied: any number of immutable borrows are allowed or a
-//! single immutable borrow is allowed, but never both. If a borrow is attempted that would violate
+//! single mutable borrow is allowed, but never both. If a borrow is attempted that would violate
//! these rules, the thread will panic.
//!
//! The corresponding [`Sync`] version of `RefCell<T>` is [`RwLock<T>`].
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 318a46d..d53f1a2 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -240,6 +240,7 @@
#![feature(allocator_internals)]
#![feature(allow_internal_unsafe)]
#![feature(allow_internal_unstable)]
+#![feature(c_str_literals)]
#![feature(c_unwind)]
#![feature(cfg_target_thread_local)]
#![feature(concat_idents)]
diff --git a/library/std/src/sys/unix/args.rs b/library/std/src/sys/unix/args.rs
index 9ed4d9c..0efe257 100644
--- a/library/std/src/sys/unix/args.rs
+++ b/library/std/src/sys/unix/args.rs
@@ -242,13 +242,15 @@
let mut res = Vec::new();
unsafe {
- let process_info_sel = sel_registerName("processInfo\0".as_ptr());
- let arguments_sel = sel_registerName("arguments\0".as_ptr());
- let utf8_sel = sel_registerName("UTF8String\0".as_ptr());
- let count_sel = sel_registerName("count\0".as_ptr());
- let object_at_sel = sel_registerName("objectAtIndex:\0".as_ptr());
+ let process_info_sel =
+ sel_registerName(c"processInfo".as_ptr() as *const libc::c_uchar);
+ let arguments_sel = sel_registerName(c"arguments".as_ptr() as *const libc::c_uchar);
+ let utf8_sel = sel_registerName(c"UTF8String".as_ptr() as *const libc::c_uchar);
+ let count_sel = sel_registerName(c"count".as_ptr() as *const libc::c_uchar);
+ let object_at_sel =
+ sel_registerName(c"objectAtIndex:".as_ptr() as *const libc::c_uchar);
- let klass = objc_getClass("NSProcessInfo\0".as_ptr());
+ let klass = objc_getClass(c"NSProcessInfo".as_ptr() as *const libc::c_uchar);
let info = objc_msgSend(klass, process_info_sel);
let args = objc_msgSend(info, arguments_sel);
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index 09e9ae2..0e5691d 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -1063,7 +1063,7 @@
cfg_has_statx! {
if let Some(ret) = unsafe { try_statx(
fd,
- b"\0" as *const _ as *const c_char,
+ c"".as_ptr() as *const c_char,
libc::AT_EMPTY_PATH | libc::AT_STATX_SYNC_AS_STAT,
libc::STATX_ALL,
) } {
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs
index bb9e65e..54e2f20 100644
--- a/library/std/src/sys/unix/mod.rs
+++ b/library/std/src/sys/unix/mod.rs
@@ -1,6 +1,5 @@
#![allow(missing_docs, nonstandard_style)]
-use crate::ffi::CStr;
use crate::io::ErrorKind;
pub use self::rand::hashmap_random_keys;
@@ -75,7 +74,7 @@
// thread-id for the main thread and so renaming the main thread will rename the
// process and we only want to enable this on platforms we've tested.
if cfg!(target_os = "macos") {
- thread::Thread::set_name(&CStr::from_bytes_with_nul_unchecked(b"main\0"));
+ thread::Thread::set_name(&c"main");
}
unsafe fn sanitize_standard_fds() {
@@ -121,7 +120,7 @@
if pfd.revents & libc::POLLNVAL == 0 {
continue;
}
- if open64("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
+ if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
// If the stream is closed but we failed to reopen it, abort the
// process. Otherwise we wouldn't preserve the safety of
// operations on the corresponding Rust object Stdin, Stdout, or
@@ -151,7 +150,7 @@
use libc::open64;
for fd in 0..3 {
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
- if open64("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
+ if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
// If the stream is closed but we failed to reopen it, abort the
// process. Otherwise we wouldn't preserve the safety of
// operations on the corresponding Rust object Stdin, Stdout, or
diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs
index 640648e..5f316b1 100644
--- a/library/std/src/sys/unix/process/process_common.rs
+++ b/library/std/src/sys/unix/process/process_common.rs
@@ -24,11 +24,11 @@
if #[cfg(target_os = "fuchsia")] {
// fuchsia doesn't have /dev/null
} else if #[cfg(target_os = "redox")] {
- const DEV_NULL: &str = "null:\0";
+ const DEV_NULL: &CStr = c"null:";
} else if #[cfg(target_os = "vxworks")] {
- const DEV_NULL: &str = "/null\0";
+ const DEV_NULL: &CStr = c"/null";
} else {
- const DEV_NULL: &str = "/dev/null\0";
+ const DEV_NULL: &CStr = c"/dev/null";
}
}
@@ -474,8 +474,7 @@
let mut opts = OpenOptions::new();
opts.read(readable);
opts.write(!readable);
- let path = unsafe { CStr::from_ptr(DEV_NULL.as_ptr() as *const _) };
- let fd = File::open_c(&path, &opts)?;
+ let fd = File::open_c(DEV_NULL, &opts)?;
Ok((ChildStdio::Owned(fd.into_inner()), None))
}
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index 7307d9b..878af50 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -163,10 +163,9 @@
#[cfg(target_os = "netbsd")]
pub fn set_name(name: &CStr) {
unsafe {
- let cname = CStr::from_bytes_with_nul_unchecked(b"%s\0".as_slice());
let res = libc::pthread_setname_np(
libc::pthread_self(),
- cname.as_ptr(),
+ c"%s".as_ptr(),
name.as_ptr() as *mut libc::c_void,
);
debug_assert_eq!(res, 0);
diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs
index 2bc40c4..07b0610 100644
--- a/library/std/src/sys/windows/c.rs
+++ b/library/std/src/sys/windows/c.rs
@@ -317,7 +317,7 @@
// Functions that aren't available on every version of Windows that we support,
// but we still use them and just provide some form of a fallback implementation.
compat_fn_with_fallback! {
- pub static KERNEL32: &CStr = ansi_str!("kernel32");
+ pub static KERNEL32: &CStr = c"kernel32";
// >= Win10 1607
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
@@ -350,7 +350,7 @@
}
compat_fn_with_fallback! {
- pub static NTDLL: &CStr = ansi_str!("ntdll");
+ pub static NTDLL: &CStr = c"ntdll";
pub fn NtCreateKeyedEvent(
KeyedEventHandle: LPHANDLE,
diff --git a/library/std/src/sys/windows/compat.rs b/library/std/src/sys/windows/compat.rs
index 4fe95d4..649cc4b 100644
--- a/library/std/src/sys/windows/compat.rs
+++ b/library/std/src/sys/windows/compat.rs
@@ -228,9 +228,9 @@
/// Load all needed functions from "api-ms-win-core-synch-l1-2-0".
pub(super) fn load_synch_functions() {
fn try_load() -> Option<()> {
- const MODULE_NAME: &CStr = ansi_str!("api-ms-win-core-synch-l1-2-0");
- const WAIT_ON_ADDRESS: &CStr = ansi_str!("WaitOnAddress");
- const WAKE_BY_ADDRESS_SINGLE: &CStr = ansi_str!("WakeByAddressSingle");
+ const MODULE_NAME: &CStr = c"api-ms-win-core-synch-l1-2-0";
+ const WAIT_ON_ADDRESS: &CStr = c"WaitOnAddress";
+ const WAKE_BY_ADDRESS_SINGLE: &CStr = c"WakeByAddressSingle";
// Try loading the library and all the required functions.
// If any step fails, then they all fail.
diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs
index bcc172b..b11c896 100644
--- a/library/std/src/sys/windows/mod.rs
+++ b/library/std/src/sys/windows/mod.rs
@@ -1,6 +1,6 @@
#![allow(missing_docs, nonstandard_style)]
-use crate::ffi::{CStr, OsStr, OsString};
+use crate::ffi::{OsStr, OsString};
use crate::io::ErrorKind;
use crate::mem::MaybeUninit;
use crate::os::windows::ffi::{OsStrExt, OsStringExt};
@@ -51,7 +51,7 @@
// Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
// exists, we have to call it ourselves.
- thread::Thread::set_name(&CStr::from_bytes_with_nul_unchecked(b"main\0"));
+ thread::Thread::set_name(&c"main");
}
// SAFETY: must be called only once during runtime cleanup.
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 43c859b..3b9270f 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -571,7 +571,7 @@
}
}
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, ValueEnum)]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
pub enum Kind {
#[clap(alias = "b")]
Build,
@@ -642,7 +642,10 @@
Kind::Doc => "Documenting",
Kind::Run => "Running",
Kind::Suggest => "Suggesting",
- _ => return format!("{self:?}"),
+ _ => {
+ let title_letter = self.as_str()[0..1].to_ascii_uppercase();
+ return format!("{title_letter}{}ing", &self.as_str()[1..]);
+ }
}
.to_owned()
}
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index 3de85c9..d6210ed 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -680,7 +680,7 @@
let compiler = builder.compiler(stage, builder.config.build);
builder.ensure(compile::Std::new(compiler, builder.config.build));
- let _guard = builder.msg(
+ let _guard = builder.msg_sysroot_tool(
Kind::Doc,
stage,
&format!("compiler{}", crate_description(&self.crates)),
@@ -834,6 +834,7 @@
cargo.arg("-Zskip-rustdoc-fingerprint");
// Only include compiler crates, no dependencies of those, such as `libc`.
cargo.arg("--no-deps");
+ cargo.arg("--lib");
$(
cargo.arg("-p").arg($krate);
)+
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index a1aaee6..aa5d1bd 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1045,8 +1045,8 @@
what: impl Display,
target: TargetSelection,
) -> Option<gha::Group> {
- let action = action.into();
- let msg = format!("{action:?}ing {what} for {target}");
+ let action = action.into().description();
+ let msg = format!("{action} {what} for {target}");
self.group(&msg)
}
@@ -1058,8 +1058,8 @@
host: TargetSelection,
target: TargetSelection,
) -> Option<gha::Group> {
- let action = action.into();
- let msg = |fmt| format!("{action:?}ing {what} {fmt}");
+ let action = action.into().description();
+ let msg = |fmt| format!("{action} {what} {fmt}");
let msg = if host == target {
msg(format_args!("(stage{stage} -> stage{}, {target})", stage + 1))
} else {
diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs
index 40038df..9b26d3f 100644
--- a/src/bootstrap/setup.rs
+++ b/src/bootstrap/setup.rs
@@ -20,7 +20,7 @@
Codegen,
Library,
Tools,
- User,
+ Dist,
None,
}
@@ -42,7 +42,7 @@
pub fn all() -> impl Iterator<Item = Self> {
use Profile::*;
// N.B. these are ordered by how they are displayed, not alphabetically
- [Library, Compiler, Codegen, Tools, User, None].iter().copied()
+ [Library, Compiler, Codegen, Tools, Dist, None].iter().copied()
}
pub fn purpose(&self) -> String {
@@ -52,7 +52,7 @@
Compiler => "Contribute to the compiler itself",
Codegen => "Contribute to the compiler, and also modify LLVM or codegen",
Tools => "Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)",
- User => "Install Rust from source",
+ Dist => "Install Rust from source",
None => "Do not modify `config.toml`"
}
.to_string()
@@ -72,7 +72,7 @@
Profile::Codegen => "codegen",
Profile::Library => "library",
Profile::Tools => "tools",
- Profile::User => "user",
+ Profile::Dist => "dist",
Profile::None => "none",
}
}
@@ -86,7 +86,7 @@
"lib" | "library" => Ok(Profile::Library),
"compiler" => Ok(Profile::Compiler),
"llvm" | "codegen" => Ok(Profile::Codegen),
- "maintainer" | "user" => Ok(Profile::User),
+ "maintainer" | "dist" => Ok(Profile::Dist),
"tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" | "rls" => {
Ok(Profile::Tools)
}
@@ -159,7 +159,7 @@
"test src/tools/rustfmt",
],
Profile::Library => &["check", "build", "test library/std", "doc"],
- Profile::User => &["dist", "build"],
+ Profile::Dist => &["dist", "build"],
};
println!();
@@ -169,7 +169,7 @@
println!("- `x.py {}`", cmd);
}
- if profile != Profile::User {
+ if profile != Profile::Dist {
println!(
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
);
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 5fd8671..b84a9cf 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -1224,7 +1224,7 @@
}
hir::ImplItemKind::Fn(ref sig, body) => {
let m = clean_function(cx, sig, impl_.generics, FunctionArgs::Body(body));
- let defaultness = cx.tcx.impl_defaultness(impl_.owner_id);
+ let defaultness = cx.tcx.defaultness(impl_.owner_id);
MethodItem(m, Some(defaultness))
}
hir::ImplItemKind::Type(hir_ty) => {
@@ -1258,7 +1258,7 @@
let provided = match assoc_item.container {
ty::ImplContainer => true,
- ty::TraitContainer => tcx.impl_defaultness(assoc_item.def_id).has_value(),
+ ty::TraitContainer => tcx.defaultness(assoc_item.def_id).has_value(),
};
if provided {
AssocConstItem(ty, ConstantKind::Extern { def_id: assoc_item.def_id })
@@ -1440,7 +1440,7 @@
}
generics.where_predicates = where_predicates;
- if tcx.impl_defaultness(assoc_item.def_id).has_value() {
+ if tcx.defaultness(assoc_item.def_id).has_value() {
AssocTypeItem(
Box::new(Typedef {
type_: clean_middle_ty(
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index 2b0fef2..c31ba33 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -205,7 +205,7 @@
&UrlFragment::Item(def_id) => {
let kind = match tcx.def_kind(def_id) {
DefKind::AssocFn => {
- if tcx.impl_defaultness(def_id).has_value() {
+ if tcx.defaultness(def_id).has_value() {
"method."
} else {
"tymethod."
diff --git a/src/tools/clippy/clippy_lints/src/missing_inline.rs b/src/tools/clippy/clippy_lints/src/missing_inline.rs
index 5a45954..a41d5a9 100644
--- a/src/tools/clippy/clippy_lints/src/missing_inline.rs
+++ b/src/tools/clippy/clippy_lints/src/missing_inline.rs
@@ -105,7 +105,7 @@
match tit_.kind {
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
hir::TraitItemKind::Fn(..) => {
- if cx.tcx.impl_defaultness(tit.id.owner_id).has_value() {
+ if cx.tcx.defaultness(tit.id.owner_id).has_value() {
// trait method with default body needs inline in case
// an impl is not provided
let desc = "a default trait method";
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 3dbf288..9979dfb 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -132,7 +132,6 @@
"crossbeam-epoch",
"crossbeam-utils",
"crypto-common",
- "cstr",
"datafrog",
"derive_more",
"digest",
diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs
index ebb26cd..472d921 100644
--- a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs
+++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs
@@ -587,6 +587,6 @@
// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"}
// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"}
// CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"}
-// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE
-// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E
-// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E
+// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE"}
+// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E"}
+// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"}
diff --git a/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff
index dd742d8..3530f4a 100644
--- a/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff
@@ -7,7 +7,7 @@
bb0: {
- _0 = std::intrinsics::min_align_of::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:21:5: 21:40
+- // + span: $DIR/lower_intrinsics.rs:27:5: 27:40
- // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::min_align_of::<T>}, val: Value(<ZST>) }
+ _0 = AlignOf(T); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42
diff --git a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff
index e95c3f9..158ce62 100644
--- a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff
@@ -11,7 +11,7 @@
StorageLive(_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
- _1 = std::intrinsics::assume(const true) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:106:9: 106:32
+- // + span: $DIR/lower_intrinsics.rs:112:9: 112:32
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(bool) {std::intrinsics::assume}, val: Value(<ZST>) }
+ assume(const true); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
diff --git a/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff
index 1f03b7b..6fc9616 100644
--- a/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff
@@ -31,7 +31,7 @@
_3 = &(*_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44
- _2 = discriminant_value::<T>(move _3) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:82:5: 82:41
+- // + span: $DIR/lower_intrinsics.rs:88:5: 88:41
- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a T) -> <T as DiscriminantKind>::Discriminant {discriminant_value::<T>}, val: Value(<ZST>) }
+ _2 = discriminant((*_3)); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45
@@ -46,13 +46,13 @@
StorageLive(_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44
_19 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44
// mir::Constant
- // + span: $DIR/lower_intrinsics.rs:83:42: 83:44
+ // + span: $DIR/lower_intrinsics.rs:89:42: 89:44
// + literal: Const { ty: &i32, val: Unevaluated(discriminant, [T], Some(promoted[2])) }
_7 = &(*_19); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44
_6 = &(*_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44
- _5 = discriminant_value::<i32>(move _6) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:83:5: 83:41
+- // + span: $DIR/lower_intrinsics.rs:89:5: 89:41
- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a i32) -> <i32 as DiscriminantKind>::Discriminant {discriminant_value::<i32>}, val: Value(<ZST>) }
+ _5 = discriminant((*_6)); // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45
+ goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45
@@ -67,13 +67,13 @@
StorageLive(_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45
_18 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45
// mir::Constant
- // + span: $DIR/lower_intrinsics.rs:84:42: 84:45
+ // + span: $DIR/lower_intrinsics.rs:90:42: 90:45
// + literal: Const { ty: &(), val: Unevaluated(discriminant, [T], Some(promoted[1])) }
_11 = &(*_18); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45
_10 = &(*_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45
- _9 = discriminant_value::<()>(move _10) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:84:5: 84:41
+- // + span: $DIR/lower_intrinsics.rs:90:5: 90:41
- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a ()) -> <() as DiscriminantKind>::Discriminant {discriminant_value::<()>}, val: Value(<ZST>) }
+ _9 = discriminant((*_10)); // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46
+ goto -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46
@@ -88,13 +88,13 @@
StorageLive(_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47
_17 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47
// mir::Constant
- // + span: $DIR/lower_intrinsics.rs:85:42: 85:47
+ // + span: $DIR/lower_intrinsics.rs:91:42: 91:47
// + literal: Const { ty: &E, val: Unevaluated(discriminant, [T], Some(promoted[0])) }
_15 = &(*_17); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47
_14 = &(*_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47
- _13 = discriminant_value::<E>(move _14) -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:85:5: 85:41
+- // + span: $DIR/lower_intrinsics.rs:91:5: 91:41
- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a E) -> <E as DiscriminantKind>::Discriminant {discriminant_value::<E>}, val: Value(<ZST>) }
+ _13 = discriminant((*_14)); // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48
+ goto -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48
diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff
index a54e9a9..5b870cc 100644
--- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff
@@ -49,7 +49,7 @@
StorageDead(_9); // scope 3 at $DIR/lower_intrinsics.rs:+4:90: +4:91
- _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:99:9: 99:28
+- // + span: $DIR/lower_intrinsics.rs:105:9: 105:28
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, *mut i32, usize) {copy_nonoverlapping::<i32>}, val: Value(<ZST>) }
+ copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95
+ goto -> bb1; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95
diff --git a/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff
index bfb000c..582a79f 100644
--- a/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff
@@ -11,7 +11,7 @@
_2 = move _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31
- _0 = std::intrinsics::forget::<T>(move _2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:26:5: 26:29
+- // + span: $DIR/lower_intrinsics.rs:32:5: 32:29
- // + literal: Const { ty: extern "rust-intrinsic" fn(T) {std::intrinsics::forget::<T>}, val: Value(<ZST>) }
+ _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32
diff --git a/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff
index 64d8290..81ad970 100644
--- a/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+2:9: +2:18
_1 = std::intrinsics::size_of::<T>; // scope 0 at $DIR/lower_intrinsics.rs:+2:21: +2:51
// mir::Constant
- // + span: $DIR/lower_intrinsics.rs:37:21: 37:51
+ // + span: $DIR/lower_intrinsics.rs:43:21: 43:51
// + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(<ZST>) }
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:14
_2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:14
diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff
index b022e2b..edc66e2 100644
--- a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff
@@ -24,7 +24,7 @@
_4 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56
- _3 = option_payload_ptr::<usize>(move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:137:18: 137:54
+- // + span: $DIR/lower_intrinsics.rs:143:18: 143:54
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<usize>) -> *const usize {option_payload_ptr::<usize>}, val: Value(<ZST>) }
+ _3 = &raw const (((*_4) as Some).0: usize); // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57
@@ -37,7 +37,7 @@
_6 = &raw const (*_2); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56
- _5 = option_payload_ptr::<String>(move _6) -> [return: bb2, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:138:18: 138:54
+- // + span: $DIR/lower_intrinsics.rs:144:18: 144:54
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<String>) -> *const String {option_payload_ptr::<String>}, val: Value(<ZST>) }
+ _5 = &raw const (((*_6) as Some).0: std::string::String); // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57
+ goto -> bb2; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57
diff --git a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff
index 60a1dd0..1760efe 100644
--- a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff
@@ -15,7 +15,7 @@
_4 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34
- _0 = offset::<*const i32, isize>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:144:5: 144:29
+- // + span: $DIR/lower_intrinsics.rs:150:5: 150:29
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, isize) -> *const i32 {offset::<*const i32, isize>}, val: Value(<ZST>) }
+ _0 = Offset(move _3, move _4); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35
diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff
index 5805df4..8583766 100644
--- a/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
_2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47
- _0 = read_via_copy::<i32>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:119:14: 119:45
+- // + span: $DIR/lower_intrinsics.rs:125:14: 125:45
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32) -> i32 {read_via_copy::<i32>}, val: Value(<ZST>) }
+ _0 = (*_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff
index 95b2ec4..f64bc9d 100644
--- a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
_2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47
- _0 = read_via_copy::<Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:124:14: 124:45
+- // + span: $DIR/lower_intrinsics.rs:130:14: 130:45
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Never) -> Never {read_via_copy::<Never>}, val: Value(<ZST>) }
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
}
diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs
index 0ca88a4..30b5c78 100644
--- a/tests/mir-opt/lower_intrinsics.rs
+++ b/tests/mir-opt/lower_intrinsics.rs
@@ -11,6 +11,12 @@
let _z = core::intrinsics::wrapping_mul(a, b);
}
+// EMIT_MIR lower_intrinsics.unchecked.LowerIntrinsics.diff
+pub unsafe fn unchecked(a: i32, b: i32) {
+ let _x = core::intrinsics::unchecked_div(a, b);
+ let _y = core::intrinsics::unchecked_rem(a, b);
+}
+
// EMIT_MIR lower_intrinsics.size_of.LowerIntrinsics.diff
pub fn size_of<T>() -> usize {
core::intrinsics::size_of::<T>()
diff --git a/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff
index 27e8acc..a880df6 100644
--- a/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff
@@ -7,7 +7,7 @@
bb0: {
- _0 = std::intrinsics::size_of::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:16:5: 16:35
+- // + span: $DIR/lower_intrinsics.rs:22:5: 22:35
- // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(<ZST>) }
+ _0 = SizeOf(T); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37
diff --git a/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff
index 1b3b768..cde7c64 100644
--- a/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
_2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35
- _0 = transmute::<std::cmp::Ordering, i8>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:43:14: 43:33
+- // + span: $DIR/lower_intrinsics.rs:49:14: 49:33
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(std::cmp::Ordering) -> i8 {transmute::<std::cmp::Ordering, i8>}, val: Value(<ZST>) }
+ _0 = move _2 as i8 (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36
diff --git a/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff
index c6a7d22..6fc0f3d 100644
--- a/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
_2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35
- _0 = transmute::<&T, *const T>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:53:14: 53:33
+- // + span: $DIR/lower_intrinsics.rs:59:14: 59:33
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&T) -> *const T {transmute::<&T, *const T>}, val: Value(<ZST>) }
+ _0 = move _2 as *const T (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36
diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff
index aa5d961..e6887a3 100644
--- a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff
@@ -12,7 +12,7 @@
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10
- _1 = transmute::<usize, Box<Never>>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:70:25: 70:44
+- // + span: $DIR/lower_intrinsics.rs:76:25: 76:44
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> Box<Never> {transmute::<usize, Box<Never>>}, val: Value(<ZST>) }
+ _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff
index 5fafd45..b2a44b7 100644
--- a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff
@@ -12,7 +12,7 @@
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10
- _1 = transmute::<usize, &mut Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:64:25: 64:44
+- // + span: $DIR/lower_intrinsics.rs:70:25: 70:44
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &mut Never {transmute::<usize, &mut Never>}, val: Value(<ZST>) }
+ _1 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff
index 08dead1..c49d3ae 100644
--- a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff
@@ -12,7 +12,7 @@
StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10
- _1 = transmute::<usize, &Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:58:21: 58:40
+- // + span: $DIR/lower_intrinsics.rs:64:21: 64:40
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &Never {transmute::<usize, &Never>}, val: Value(<ZST>) }
+ _1 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48
diff --git a/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff
index f0b7612..06759d7 100644
--- a/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
_2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48
- _0 = transmute::<(), Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:48:14: 48:46
+- // + span: $DIR/lower_intrinsics.rs:54:14: 54:46
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(()) -> Never {transmute::<(), Never>}, val: Value(<ZST>) }
+ _0 = move _2 as Never (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49
diff --git a/tests/mir-opt/lower_intrinsics.unchecked.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unchecked.LowerIntrinsics.diff
new file mode 100644
index 0000000..9bb43d8
--- /dev/null
+++ b/tests/mir-opt/lower_intrinsics.unchecked.LowerIntrinsics.diff
@@ -0,0 +1,60 @@
+- // MIR for `unchecked` before LowerIntrinsics
++ // MIR for `unchecked` after LowerIntrinsics
+
+ fn unchecked(_1: i32, _2: i32) -> () {
+ debug a => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:25: +0:26
+ debug b => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:33: +0:34
+ let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:41: +0:41
+ let _3: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:11
+ let mut _4: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47
+ let mut _5: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:49: +1:50
+ let mut _7: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+2:46: +2:47
+ let mut _8: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+2:49: +2:50
+ scope 1 {
+ debug _x => _3; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:11
+ let _6: i32; // in scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:11
+ scope 2 {
+ debug _y => _6; // in scope 2 at $DIR/lower_intrinsics.rs:+2:9: +2:11
+ }
+ }
+
+ bb0: {
+ StorageLive(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:11
+ StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47
+ _4 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47
+ StorageLive(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:49: +1:50
+ _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:49: +1:50
+- _3 = unchecked_div::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:51
+- // mir::Constant
+- // + span: $DIR/lower_intrinsics.rs:16:14: 16:45
+- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i32, i32) -> i32 {unchecked_div::<i32>}, val: Value(<ZST>) }
++ _3 = Div(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:51
++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:51
+ }
+
+ bb1: {
+ StorageDead(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51
+ StorageDead(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51
+ StorageLive(_6); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:11
+ StorageLive(_7); // scope 1 at $DIR/lower_intrinsics.rs:+2:46: +2:47
+ _7 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+2:46: +2:47
+ StorageLive(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:49: +2:50
+ _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:49: +2:50
+- _6 = unchecked_rem::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:51
+- // mir::Constant
+- // + span: $DIR/lower_intrinsics.rs:17:14: 17:45
+- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i32, i32) -> i32 {unchecked_rem::<i32>}, val: Value(<ZST>) }
++ _6 = Rem(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:51
++ goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:51
+ }
+
+ bb2: {
+ StorageDead(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51
+ StorageDead(_7); // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51
+ _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:+0:41: +3:2
+ StorageDead(_6); // scope 1 at $DIR/lower_intrinsics.rs:+3:1: +3:2
+ StorageDead(_3); // scope 0 at $DIR/lower_intrinsics.rs:+3:1: +3:2
+ return; // scope 0 at $DIR/lower_intrinsics.rs:+3:2: +3:2
+ }
+ }
+
diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff
index 28e4590..83c9c50 100644
--- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff
@@ -13,7 +13,7 @@
StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45
- _2 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:31:14: 31:43
+- // + span: $DIR/lower_intrinsics.rs:37:14: 37:43
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value(<ZST>) }
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45
}
diff --git a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff
index 9cf4fbb..4ae4466 100644
--- a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff
@@ -32,7 +32,7 @@
_5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54
- _3 = add_with_overflow::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:112:14: 112:49
+- // + span: $DIR/lower_intrinsics.rs:118:14: 118:49
- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {add_with_overflow::<i32>}, val: Value(<ZST>) }
+ _3 = CheckedAdd(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55
@@ -48,7 +48,7 @@
_8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54
- _6 = sub_with_overflow::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:113:14: 113:49
+- // + span: $DIR/lower_intrinsics.rs:119:14: 119:49
- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {sub_with_overflow::<i32>}, val: Value(<ZST>) }
+ _6 = CheckedSub(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55
+ goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55
@@ -64,7 +64,7 @@
_11 = _2; // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54
- _9 = mul_with_overflow::<i32>(move _10, move _11) -> [return: bb3, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:114:14: 114:49
+- // + span: $DIR/lower_intrinsics.rs:120:14: 120:49
- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {mul_with_overflow::<i32>}, val: Value(<ZST>) }
+ _9 = CheckedMul(move _10, move _11); // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55
+ goto -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55
diff --git a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff
index 38d99f6..2eabd7f 100644
--- a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff
+++ b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff
@@ -17,7 +17,7 @@
_4 = move _2; // scope 1 at $DIR/lower_intrinsics.rs:+1:50: +1:51
- _0 = write_via_move::<String>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52
- // mir::Constant
-- // + span: $DIR/lower_intrinsics.rs:129:14: 129:46
+- // + span: $DIR/lower_intrinsics.rs:135:14: 135:46
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*mut String, String) {write_via_move::<String>}, val: Value(<ZST>) }
+ (*_3) = move _4; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52
diff --git a/tests/rustdoc/double-hyphen-to-dash.rs b/tests/rustdoc/double-hyphen-to-dash.rs
new file mode 100644
index 0000000..66905f9
--- /dev/null
+++ b/tests/rustdoc/double-hyphen-to-dash.rs
@@ -0,0 +1,9 @@
+// This test ensures that `--` (double-hyphen) is correctly converted into `–` (dash).
+
+#![crate_name = "foo"]
+
+// @has 'foo/index.html' '//*[@class="desc docblock-short"]' '–'
+// @has 'foo/struct.Bar.html' '//*[@class="docblock"]' '–'
+
+/// --
+pub struct Bar;
diff --git a/tests/ui/auto-traits/issue-23080-2.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr
similarity index 91%
rename from tests/ui/auto-traits/issue-23080-2.stderr
rename to tests/ui/auto-traits/issue-23080-2.current.stderr
index fed4856..a57c6d9 100644
--- a/tests/ui/auto-traits/issue-23080-2.stderr
+++ b/tests/ui/auto-traits/issue-23080-2.current.stderr
@@ -1,5 +1,5 @@
error[E0380]: auto traits cannot have associated items
- --> $DIR/issue-23080-2.rs:5:10
+ --> $DIR/issue-23080-2.rs:8:10
|
LL | unsafe auto trait Trait {
| ----- auto traits cannot have associated items
diff --git a/tests/ui/auto-traits/issue-23080-2.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr
similarity index 91%
copy from tests/ui/auto-traits/issue-23080-2.stderr
copy to tests/ui/auto-traits/issue-23080-2.next.stderr
index fed4856..a57c6d9 100644
--- a/tests/ui/auto-traits/issue-23080-2.stderr
+++ b/tests/ui/auto-traits/issue-23080-2.next.stderr
@@ -1,5 +1,5 @@
error[E0380]: auto traits cannot have associated items
- --> $DIR/issue-23080-2.rs:5:10
+ --> $DIR/issue-23080-2.rs:8:10
|
LL | unsafe auto trait Trait {
| ----- auto traits cannot have associated items
diff --git a/tests/ui/auto-traits/issue-23080-2.rs b/tests/ui/auto-traits/issue-23080-2.rs
index cb4cf6d..882b8f3 100644
--- a/tests/ui/auto-traits/issue-23080-2.rs
+++ b/tests/ui/auto-traits/issue-23080-2.rs
@@ -1,3 +1,6 @@
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
+
#![feature(auto_traits)]
#![feature(negative_impls)]
diff --git a/tests/ui/traits/new-solver/array-default.rs b/tests/ui/traits/new-solver/array-default.rs
new file mode 100644
index 0000000..5077137
--- /dev/null
+++ b/tests/ui/traits/new-solver/array-default.rs
@@ -0,0 +1,8 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+fn has_default<const N: usize>() where [(); N]: Default {}
+
+fn main() {
+ has_default::<1>();
+}
diff --git a/tests/ui/traits/new-solver/structural-resolve-field.rs b/tests/ui/traits/new-solver/structural-resolve-field.rs
index c492d92..01899c9 100644
--- a/tests/ui/traits/new-solver/structural-resolve-field.rs
+++ b/tests/ui/traits/new-solver/structural-resolve-field.rs
@@ -1,35 +1,13 @@
// compile-flags: -Ztrait-solver=next
// check-pass
+#[derive(Default)]
struct Foo {
x: i32,
}
-impl MyDefault for Foo {
- fn my_default() -> Self {
- Self {
- x: 0,
- }
- }
-}
-
-trait MyDefault {
- fn my_default() -> Self;
-}
-
-impl MyDefault for [Foo; 0] {
- fn my_default() -> Self {
- []
- }
-}
-impl MyDefault for [Foo; 1] {
- fn my_default() -> Self {
- [Foo::my_default(); 1]
- }
-}
-
fn main() {
- let mut xs = <[Foo; 1]>::my_default();
+ let mut xs = <[Foo; 1]>::default();
xs[0].x = 1;
(&mut xs[0]).x = 2;
}
diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr
new file mode 100644
index 0000000..072ac32
--- /dev/null
+++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr
@@ -0,0 +1,18 @@
+error[E0277]: the trait bound `(): Trait<1>` is not satisfied
+ --> $DIR/unevaluated-const-impl-trait-ref.rs:20:13
+ |
+LL | needs::<1>();
+ | ^ the trait `Trait<1>` is not implemented for `()`
+ |
+ = help: the following other types implement trait `Trait<N>`:
+ <() as Trait<0>>
+ <() as Trait<2>>
+note: required by a bound in `needs`
+ --> $DIR/unevaluated-const-impl-trait-ref.rs:10:38
+ |
+LL | fn needs<const N: usize>() where (): Trait<N> {}
+ | ^^^^^^^^ required by this bound in `needs`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs
new file mode 100644
index 0000000..26c595b
--- /dev/null
+++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs
@@ -0,0 +1,22 @@
+// compile-flags: -Ztrait-solver=next
+// revisions: works fails
+//[works] check-pass
+
+trait Trait<const N: usize> {}
+
+impl Trait<{ 1 - 1 }> for () {}
+impl Trait<{ 1 + 1 }> for () {}
+
+fn needs<const N: usize>() where (): Trait<N> {}
+
+#[cfg(works)]
+fn main() {
+ needs::<0>();
+ needs::<2>();
+}
+
+#[cfg(fails)]
+fn main() {
+ needs::<1>();
+ //[fails]~^ ERROR the trait bound `(): Trait<1>` is not satisfied
+}