Auto merge of #112212 - matthiaskrgr:rollup-e5ilgf0, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #111647 (use c literals in compiler and library) - #112165 (Rename `impl_defaultness` to `defaultness`) - #112182 (CFI: Fix cfi with repr(transparent): transform_ty: unexpected Alias(Proj) - #112189 (Debug-assert that closures and generators are made with the right number of substitutions) - #112205 (Add rustdoc test for double-hyphen to dash doc comment conversion) - #112206 (Fix typo in `std::cell` module docs) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
794249d768
11
Cargo.lock
11
Cargo.lock
@ -871,16 +871,6 @@ dependencies = [
|
|||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cstr"
|
|
||||||
version = "0.2.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c11a39d776a3b35896711da8a04dc1835169dcd36f710878187637314e47941b"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctrlc"
|
name = "ctrlc"
|
||||||
version = "3.3.1"
|
version = "3.3.1"
|
||||||
@ -3179,7 +3169,6 @@ name = "rustc_codegen_llvm"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cstr",
|
|
||||||
"libc",
|
"libc",
|
||||||
"measureme",
|
"measureme",
|
||||||
"object 0.31.1",
|
"object 0.31.1",
|
||||||
|
@ -8,7 +8,6 @@ test = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
cstr = "0.2"
|
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
measureme = "10.0.0"
|
measureme = "10.0.0"
|
||||||
object = { version = "0.31.1", default-features = false, features = [
|
object = { version = "0.31.1", default-features = false, features = [
|
||||||
|
@ -77,7 +77,7 @@ pub(crate) unsafe fn codegen(
|
|||||||
llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr().cast(), callee.len(), ty);
|
llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr().cast(), callee.len(), ty);
|
||||||
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
|
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);
|
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
|
||||||
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
|
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
|
||||||
@ -129,7 +129,7 @@ pub(crate) unsafe fn codegen(
|
|||||||
attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]);
|
attributes::apply_to_llfn(callee, llvm::AttributePlace::Function, &[no_return]);
|
||||||
llvm::LLVMRustSetVisibility(callee, llvm::Visibility::Hidden);
|
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);
|
let llbuilder = llvm::LLVMCreateBuilderInContext(llcx);
|
||||||
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
|
llvm::LLVMPositionBuilderAtEnd(llbuilder, llbb);
|
||||||
|
@ -595,7 +595,7 @@ pub(crate) fn run_pass_manager(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
module.module_llvm.llmod(),
|
module.module_llvm.llmod(),
|
||||||
llvm::LLVMModFlagBehavior::Error,
|
llvm::LLVMModFlagBehavior::Error,
|
||||||
"LTOPostLink\0".as_ptr().cast(),
|
c"LTOPostLink".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -891,11 +891,11 @@ unsafe fn embed_bitcode(
|
|||||||
let llglobal = llvm::LLVMAddGlobal(
|
let llglobal = llvm::LLVMAddGlobal(
|
||||||
llmod,
|
llmod,
|
||||||
common::val_ty(llconst),
|
common::val_ty(llconst),
|
||||||
"rustc.embedded.module\0".as_ptr().cast(),
|
c"rustc.embedded.module".as_ptr().cast(),
|
||||||
);
|
);
|
||||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
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::LLVMSetSection(llglobal, section.as_ptr().cast());
|
||||||
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
|
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
|
||||||
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
|
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
|
||||||
@ -904,10 +904,10 @@ unsafe fn embed_bitcode(
|
|||||||
let llglobal = llvm::LLVMAddGlobal(
|
let llglobal = llvm::LLVMAddGlobal(
|
||||||
llmod,
|
llmod,
|
||||||
common::val_ty(llconst),
|
common::val_ty(llconst),
|
||||||
"rustc.embedded.cmdline\0".as_ptr().cast(),
|
c"rustc.embedded.cmdline".as_ptr().cast(),
|
||||||
);
|
);
|
||||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
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::LLVMSetSection(llglobal, section.as_ptr().cast());
|
||||||
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
|
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
use crate::llvm;
|
use crate::llvm;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
|
||||||
use cstr::cstr;
|
|
||||||
|
|
||||||
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
|
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
|
||||||
use rustc_codegen_ssa::mono_item::MonoItemExt;
|
use rustc_codegen_ssa::mono_item::MonoItemExt;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
@ -110,11 +108,11 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: Symbol) -> ModuleCodegen<ModuleLlvm
|
|||||||
|
|
||||||
// Create the llvm.used and llvm.compiler.used variables.
|
// Create the llvm.used and llvm.compiler.used variables.
|
||||||
if !cx.used_statics.borrow().is_empty() {
|
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() {
|
if !cx.compiler_used_statics.borrow().is_empty() {
|
||||||
cx.create_used_variable_impl(
|
cx.create_used_variable_impl(
|
||||||
cstr!("llvm.compiler.used"),
|
c"llvm.compiler.used",
|
||||||
&*cx.compiler_used_statics.borrow(),
|
&*cx.compiler_used_statics.borrow(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::type_of::LayoutLlvmExt;
|
use crate::type_of::LayoutLlvmExt;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use cstr::cstr;
|
|
||||||
use libc::{c_char, c_uint};
|
use libc::{c_char, c_uint};
|
||||||
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
|
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
|
||||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
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::abi::{self, call::FnAbi, Align, Size, WrappingRange};
|
||||||
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
|
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::ffi::CStr;
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
@ -45,13 +43,10 @@ fn drop(&mut self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
/// 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).
|
/// 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.
|
// 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> {
|
impl<'ll, 'tcx> BackendTypes for Builder<'_, 'll, 'tcx> {
|
||||||
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
|
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
|
||||||
@ -1010,14 +1005,13 @@ fn resume(&mut self, exn0: &'ll Value, exn1: &'ll Value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
|
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
|
||||||
let name = cstr!("cleanuppad");
|
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
llvm::LLVMBuildCleanupPad(
|
llvm::LLVMBuildCleanupPad(
|
||||||
self.llbuilder,
|
self.llbuilder,
|
||||||
parent,
|
parent,
|
||||||
args.as_ptr(),
|
args.as_ptr(),
|
||||||
args.len() as c_uint,
|
args.len() as c_uint,
|
||||||
name.as_ptr(),
|
c"cleanuppad".as_ptr(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Funclet::new(ret.expect("LLVM does not have support for cleanuppad"))
|
Funclet::new(ret.expect("LLVM does not have support for cleanuppad"))
|
||||||
@ -1031,14 +1025,13 @@ fn cleanup_ret(&mut self, funclet: &Funclet<'ll>, unwind: Option<&'ll BasicBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
|
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
|
||||||
let name = cstr!("catchpad");
|
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
llvm::LLVMBuildCatchPad(
|
llvm::LLVMBuildCatchPad(
|
||||||
self.llbuilder,
|
self.llbuilder,
|
||||||
parent,
|
parent,
|
||||||
args.as_ptr(),
|
args.as_ptr(),
|
||||||
args.len() as c_uint,
|
args.len() as c_uint,
|
||||||
name.as_ptr(),
|
c"catchpad".as_ptr(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Funclet::new(ret.expect("LLVM does not have support for catchpad"))
|
Funclet::new(ret.expect("LLVM does not have support for catchpad"))
|
||||||
@ -1050,14 +1043,13 @@ fn catch_switch(
|
|||||||
unwind: Option<&'ll BasicBlock>,
|
unwind: Option<&'ll BasicBlock>,
|
||||||
handlers: &[&'ll BasicBlock],
|
handlers: &[&'ll BasicBlock],
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
let name = cstr!("catchswitch");
|
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
llvm::LLVMBuildCatchSwitch(
|
llvm::LLVMBuildCatchSwitch(
|
||||||
self.llbuilder,
|
self.llbuilder,
|
||||||
parent,
|
parent,
|
||||||
unwind,
|
unwind,
|
||||||
handlers.len() as c_uint,
|
handlers.len() as c_uint,
|
||||||
name.as_ptr(),
|
c"catchswitch".as_ptr(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let ret = ret.expect("LLVM does not have support for catchswitch");
|
let ret = ret.expect("LLVM does not have support for catchswitch");
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::type_of::LayoutLlvmExt;
|
use crate::type_of::LayoutLlvmExt;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use cstr::cstr;
|
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
|
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||||
@ -482,9 +481,9 @@ fn codegen_static(&self, def_id: DefId, is_mutable: bool) {
|
|||||||
.all(|&byte| byte == 0);
|
.all(|&byte| byte == 0);
|
||||||
|
|
||||||
let sect_name = if all_bytes_are_zero {
|
let sect_name = if all_bytes_are_zero {
|
||||||
cstr!("__DATA,__thread_bss")
|
c"__DATA,__thread_bss"
|
||||||
} else {
|
} else {
|
||||||
cstr!("__DATA,__thread_data")
|
c"__DATA,__thread_data"
|
||||||
};
|
};
|
||||||
llvm::LLVMSetSection(g, sect_name.as_ptr());
|
llvm::LLVMSetSection(g, sect_name.as_ptr());
|
||||||
}
|
}
|
||||||
@ -513,7 +512,7 @@ fn codegen_static(&self, def_id: DefId, is_mutable: bool) {
|
|||||||
let val = llvm::LLVMMetadataAsValue(self.llcx, meta);
|
let val = llvm::LLVMMetadataAsValue(self.llcx, meta);
|
||||||
llvm::LLVMAddNamedMetadataOperand(
|
llvm::LLVMAddNamedMetadataOperand(
|
||||||
self.llmod,
|
self.llmod,
|
||||||
"wasm.custom_sections\0".as_ptr().cast(),
|
c"wasm.custom_sections".as_ptr().cast(),
|
||||||
val,
|
val,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
|
||||||
use cstr::cstr;
|
|
||||||
use rustc_codegen_ssa::base::wants_msvc_seh;
|
use rustc_codegen_ssa::base::wants_msvc_seh;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_data_structures::base_n;
|
use rustc_data_structures::base_n;
|
||||||
@ -224,36 +223,42 @@ pub unsafe fn create_module<'ll>(
|
|||||||
// If skipping the PLT is enabled, we need to add some module metadata
|
// If skipping the PLT is enabled, we need to add some module metadata
|
||||||
// to ensure intrinsic calls don't use it.
|
// to ensure intrinsic calls don't use it.
|
||||||
if !sess.needs_plt() {
|
if !sess.needs_plt() {
|
||||||
let avoid_plt = "RtLibUseGOT\0".as_ptr().cast();
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llvm::LLVMRustAddModuleFlag(llmod, llvm::LLVMModFlagBehavior::Warning, avoid_plt, 1);
|
llmod,
|
||||||
|
llvm::LLVMModFlagBehavior::Warning,
|
||||||
|
c"RtLibUseGOT".as_ptr().cast(),
|
||||||
|
1,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable canonical jump tables if CFI is enabled. (See https://reviews.llvm.org/D65629.)
|
// 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() {
|
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(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Override,
|
llvm::LLVMModFlagBehavior::Override,
|
||||||
canonical_jump_tables,
|
c"CFI Canonical Jump Tables".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
|
// 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() {
|
if sess.is_split_lto_unit_enabled() || sess.is_sanitizer_cfi_enabled() {
|
||||||
let enable_split_lto_unit = "EnableSplitLTOUnit\0".as_ptr().cast();
|
|
||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Override,
|
llvm::LLVMModFlagBehavior::Override,
|
||||||
enable_split_lto_unit,
|
c"EnableSplitLTOUnit".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
|
// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
|
||||||
if sess.is_sanitizer_kcfi_enabled() {
|
if sess.is_sanitizer_kcfi_enabled() {
|
||||||
let kcfi = "kcfi\0".as_ptr().cast();
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llvm::LLVMRustAddModuleFlag(llmod, llvm::LLVMModFlagBehavior::Override, kcfi, 1);
|
llmod,
|
||||||
|
llvm::LLVMModFlagBehavior::Override,
|
||||||
|
c"kcfi".as_ptr().cast(),
|
||||||
|
1,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
|
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
|
||||||
@ -265,7 +270,7 @@ pub unsafe fn create_module<'ll>(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Warning,
|
llvm::LLVMModFlagBehavior::Warning,
|
||||||
"cfguard\0".as_ptr() as *const _,
|
c"cfguard".as_ptr() as *const _,
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -274,7 +279,7 @@ pub unsafe fn create_module<'ll>(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Warning,
|
llvm::LLVMModFlagBehavior::Warning,
|
||||||
"cfguard\0".as_ptr() as *const _,
|
c"cfguard".as_ptr() as *const _,
|
||||||
2,
|
2,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -292,26 +297,26 @@ pub unsafe fn create_module<'ll>(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
behavior,
|
behavior,
|
||||||
"branch-target-enforcement\0".as_ptr().cast(),
|
c"branch-target-enforcement".as_ptr().cast(),
|
||||||
bti.into(),
|
bti.into(),
|
||||||
);
|
);
|
||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
behavior,
|
behavior,
|
||||||
"sign-return-address\0".as_ptr().cast(),
|
c"sign-return-address".as_ptr().cast(),
|
||||||
pac_ret.is_some().into(),
|
pac_ret.is_some().into(),
|
||||||
);
|
);
|
||||||
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
|
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
|
||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
behavior,
|
behavior,
|
||||||
"sign-return-address-all\0".as_ptr().cast(),
|
c"sign-return-address-all".as_ptr().cast(),
|
||||||
pac_opts.leaf.into(),
|
pac_opts.leaf.into(),
|
||||||
);
|
);
|
||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
behavior,
|
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),
|
u32::from(pac_opts.key == PAuthKey::B),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -327,7 +332,7 @@ pub unsafe fn create_module<'ll>(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Override,
|
llvm::LLVMModFlagBehavior::Override,
|
||||||
"cf-protection-branch\0".as_ptr().cast(),
|
c"cf-protection-branch".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -335,7 +340,7 @@ pub unsafe fn create_module<'ll>(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Override,
|
llvm::LLVMModFlagBehavior::Override,
|
||||||
"cf-protection-return\0".as_ptr().cast(),
|
c"cf-protection-return".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -344,7 +349,7 @@ pub unsafe fn create_module<'ll>(
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
llmod,
|
llmod,
|
||||||
llvm::LLVMModFlagBehavior::Error,
|
llvm::LLVMModFlagBehavior::Error,
|
||||||
"Virtual Function Elim\0".as_ptr().cast(),
|
c"Virtual Function Elim".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -476,14 +481,13 @@ pub fn coverage_context(&self) -> Option<&coverageinfo::CrateCoverageContext<'ll
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn create_used_variable_impl(&self, name: &'static CStr, values: &[&'ll Value]) {
|
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);
|
let array = self.const_array(self.type_ptr_to(self.type_i8()), values);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let g = llvm::LLVMAddGlobal(self.llmod, self.val_ty(array), name.as_ptr());
|
let g = llvm::LLVMAddGlobal(self.llmod, self.val_ty(array), name.as_ptr());
|
||||||
llvm::LLVMSetInitializer(g, array);
|
llvm::LLVMSetInitializer(g, array);
|
||||||
llvm::LLVMRustSetLinkage(g, llvm::Linkage::AppendingLinkage);
|
llvm::LLVMRustSetLinkage(g, llvm::Linkage::AppendingLinkage);
|
||||||
llvm::LLVMSetSection(g, section.as_ptr());
|
llvm::LLVMSetSection(g, c"llvm.metadata".as_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
|
|||||||
unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr().cast()) };
|
unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr().cast()) };
|
||||||
|
|
||||||
section_var.unwrap_or_else(|| {
|
section_var.unwrap_or_else(|| {
|
||||||
let section_name = b".debug_gdb_scripts\0";
|
|
||||||
let mut section_contents = Vec::new();
|
let mut section_contents = Vec::new();
|
||||||
|
|
||||||
// Add the pretty printers for the standard library first.
|
// Add the pretty printers for the standard library first.
|
||||||
@ -71,7 +70,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
|
|||||||
let section_var = cx
|
let section_var = cx
|
||||||
.define_global(section_var_name, llvm_type)
|
.define_global(section_var_name, llvm_type)
|
||||||
.unwrap_or_else(|| bug!("symbol `{}` is already defined", section_var_name));
|
.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::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
|
||||||
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
|
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
|
||||||
llvm::LLVMSetUnnamedAddress(section_var, llvm::UnnamedAddr::Global);
|
llvm::LLVMSetUnnamedAddress(section_var, llvm::UnnamedAddr::Global);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
};
|
};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
|
||||||
use cstr::cstr;
|
|
||||||
use rustc_codegen_ssa::debuginfo::type_names::cpp_like_debuginfo;
|
use rustc_codegen_ssa::debuginfo::type_names::cpp_like_debuginfo;
|
||||||
use rustc_codegen_ssa::debuginfo::type_names::VTableNameKind;
|
use rustc_codegen_ssa::debuginfo::type_names::VTableNameKind;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
@ -812,7 +811,6 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
|
|||||||
|
|
||||||
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
|
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
|
||||||
let work_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped);
|
let work_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped);
|
||||||
let flags = "\0";
|
|
||||||
let output_filenames = tcx.output_filenames(());
|
let output_filenames = tcx.output_filenames(());
|
||||||
let split_name = if tcx.sess.target_can_use_split_dwarf() {
|
let split_name = if tcx.sess.target_can_use_split_dwarf() {
|
||||||
output_filenames
|
output_filenames
|
||||||
@ -849,7 +847,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
|
|||||||
producer.as_ptr().cast(),
|
producer.as_ptr().cast(),
|
||||||
producer.len(),
|
producer.len(),
|
||||||
tcx.sess.opts.optimize != config::OptLevel::No,
|
tcx.sess.opts.optimize != config::OptLevel::No,
|
||||||
flags.as_ptr().cast(),
|
c"".as_ptr().cast(),
|
||||||
0,
|
0,
|
||||||
// NB: this doesn't actually have any perceptible effect, it seems. LLVM will instead
|
// 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
|
// put the path supplied to `MCSplitDwarfFile` into the debug info of the final
|
||||||
@ -878,8 +876,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
|
|||||||
);
|
);
|
||||||
let val = llvm::LLVMMetadataAsValue(debug_context.llcontext, gcov_metadata);
|
let val = llvm::LLVMMetadataAsValue(debug_context.llcontext, gcov_metadata);
|
||||||
|
|
||||||
let llvm_gcov_ident = cstr!("llvm.gcov");
|
llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, c"llvm.gcov".as_ptr(), val);
|
||||||
llvm::LLVMAddNamedMetadataOperand(debug_context.llmod, llvm_gcov_ident.as_ptr(), val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert `llvm.ident` metadata on the wasm targets since that will
|
// Insert `llvm.ident` metadata on the wasm targets since that will
|
||||||
@ -892,7 +889,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
|
|||||||
);
|
);
|
||||||
llvm::LLVMAddNamedMetadataOperand(
|
llvm::LLVMAddNamedMetadataOperand(
|
||||||
debug_context.llmod,
|
debug_context.llmod,
|
||||||
cstr!("llvm.ident").as_ptr(),
|
c"llvm.ident".as_ptr(),
|
||||||
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
|
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ pub fn finalize(&self, sess: &Session) {
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
self.llmod,
|
self.llmod,
|
||||||
llvm::LLVMModFlagBehavior::Warning,
|
llvm::LLVMModFlagBehavior::Warning,
|
||||||
"Dwarf Version\0".as_ptr().cast(),
|
c"Dwarf Version".as_ptr().cast(),
|
||||||
dwarf_version,
|
dwarf_version,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -121,17 +121,16 @@ pub fn finalize(&self, sess: &Session) {
|
|||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
self.llmod,
|
self.llmod,
|
||||||
llvm::LLVMModFlagBehavior::Warning,
|
llvm::LLVMModFlagBehavior::Warning,
|
||||||
"CodeView\0".as_ptr().cast(),
|
c"CodeView".as_ptr().cast(),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent bitcode readers from deleting the debug info.
|
// Prevent bitcode readers from deleting the debug info.
|
||||||
let ptr = "Debug Info Version\0".as_ptr();
|
|
||||||
llvm::LLVMRustAddModuleFlag(
|
llvm::LLVMRustAddModuleFlag(
|
||||||
self.llmod,
|
self.llmod,
|
||||||
llvm::LLVMModFlagBehavior::Warning,
|
llvm::LLVMModFlagBehavior::Warning,
|
||||||
ptr.cast(),
|
c"Debug Info Version".as_ptr().cast(),
|
||||||
llvm::LLVMRustDebugMetadataVersion(),
|
llvm::LLVMRustDebugMetadataVersion(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(impl_trait_in_assoc_type)]
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
|
#![feature(c_str_literals)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
#![deny(rustc::untranslatable_diagnostic)]
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
@ -704,7 +704,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
|||||||
// grandparent. In that case, if parent is a `default impl`, inherited items use the
|
// grandparent. In that case, if parent is a `default impl`, inherited items use the
|
||||||
// "defaultness" from the grandparent, else they are final.
|
// "defaultness" from the grandparent, else they are final.
|
||||||
None => {
|
None => {
|
||||||
if tcx.impl_defaultness(parent_impl.def_id()).is_default() {
|
if tcx.defaultness(parent_impl.def_id()).is_default() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Err(parent_impl.def_id()))
|
Some(Err(parent_impl.def_id()))
|
||||||
@ -803,7 +803,7 @@ fn check_impl_items_against_trait<'tcx>(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|node_item| node_item.item.defaultness(tcx).has_value());
|
.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));
|
missing_items.push(tcx.associated_item(trait_item_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||||||
|
|
||||||
match item {
|
match item {
|
||||||
Some(item) if matches!(item.kind, hir::AssocItemKind::Fn { .. }) => {
|
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 {
|
tcx.sess.emit_err(errors::FunctionNotHaveDefaultImplementation {
|
||||||
span: item.span,
|
span: item.span,
|
||||||
note_span: attr_span,
|
note_span: attr_span,
|
||||||
|
@ -435,7 +435,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||||||
in_trait,
|
in_trait,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if in_trait && !tcx.impl_defaultness(owner).has_value() {
|
if in_trait && !tcx.defaultness(owner).has_value() {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
"tried to get type of this RPITIT with no definition"
|
"tried to get type of this RPITIT with no definition"
|
||||||
|
@ -586,7 +586,7 @@ fn point_at_associated_type(
|
|||||||
// FIXME: account for returning some type in a trait fn impl that has
|
// FIXME: account for returning some type in a trait fn impl that has
|
||||||
// an assoc type as a return type (#72076).
|
// an assoc type as a return type (#72076).
|
||||||
if let hir::Defaultness::Default { has_value: true } =
|
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();
|
let assoc_ty = tcx.type_of(item.id.owner_id).subst_identity();
|
||||||
if self.infcx.can_eq(param_env, assoc_ty, found) {
|
if self.infcx.can_eq(param_env, assoc_ty, found) {
|
||||||
|
@ -231,7 +231,7 @@ fn into_args(self) -> (DefId, SimplifiedType) {
|
|||||||
opt_def_kind => { table_direct }
|
opt_def_kind => { table_direct }
|
||||||
impl_parent => { table }
|
impl_parent => { table }
|
||||||
impl_polarity => { table_direct }
|
impl_polarity => { table_direct }
|
||||||
impl_defaultness => { table_direct }
|
defaultness => { table_direct }
|
||||||
constness => { table_direct }
|
constness => { table_direct }
|
||||||
coerce_unsized_info => { table }
|
coerce_unsized_info => { table }
|
||||||
mir_const_qualif => { table }
|
mir_const_qualif => { table }
|
||||||
|
@ -1437,8 +1437,8 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) {
|
|||||||
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
|
debug!("EncodeContext::encode_info_for_trait_item({:?})", def_id);
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
let impl_defaultness = tcx.impl_defaultness(def_id.expect_local());
|
let defaultness = tcx.defaultness(def_id.expect_local());
|
||||||
self.tables.impl_defaultness.set_some(def_id.index, impl_defaultness);
|
self.tables.defaultness.set_some(def_id.index, defaultness);
|
||||||
let trait_item = tcx.associated_item(def_id);
|
let trait_item = tcx.associated_item(def_id);
|
||||||
self.tables.assoc_container.set_some(def_id.index, trait_item.container);
|
self.tables.assoc_container.set_some(def_id.index, trait_item.container);
|
||||||
|
|
||||||
@ -1466,8 +1466,8 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) {
|
|||||||
debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id);
|
debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id);
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
let defaultness = self.tcx.impl_defaultness(def_id.expect_local());
|
let defaultness = self.tcx.defaultness(def_id.expect_local());
|
||||||
self.tables.impl_defaultness.set_some(def_id.index, defaultness);
|
self.tables.defaultness.set_some(def_id.index, defaultness);
|
||||||
let impl_item = self.tcx.associated_item(def_id);
|
let impl_item = self.tcx.associated_item(def_id);
|
||||||
self.tables.assoc_container.set_some(def_id.index, impl_item.container);
|
self.tables.assoc_container.set_some(def_id.index, impl_item.container);
|
||||||
|
|
||||||
@ -1653,7 +1653,7 @@ fn encode_info_for_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
|
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.constness.set_some(def_id.index, *constness);
|
||||||
self.tables.impl_polarity.set_some(def_id.index, self.tcx.impl_polarity(def_id));
|
self.tables.impl_polarity.set_some(def_id.index, self.tcx.impl_polarity(def_id));
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
|
|||||||
impl_parent: Table<DefIndex, RawDefId>,
|
impl_parent: Table<DefIndex, RawDefId>,
|
||||||
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
|
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
|
||||||
constness: Table<DefIndex, hir::Constness>,
|
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?
|
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
|
||||||
coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
|
coerce_unsized_info: Table<DefIndex, LazyValue<ty::adjustment::CoerceUnsizedInfo>>,
|
||||||
mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
|
mir_const_qualif: Table<DefIndex, LazyValue<mir::ConstQualifs>>,
|
||||||
|
@ -1475,8 +1475,9 @@
|
|||||||
desc { "getting traits in scope at a block" }
|
desc { "getting traits in scope at a block" }
|
||||||
}
|
}
|
||||||
|
|
||||||
query impl_defaultness(def_id: DefId) -> hir::Defaultness {
|
/// Returns whether the impl or associated function has the `default` keyword.
|
||||||
desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
|
query defaultness(def_id: DefId) -> hir::Defaultness {
|
||||||
|
desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) }
|
||||||
separate_provide_extern
|
separate_provide_extern
|
||||||
feedable
|
feedable
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ pub fn leaf_def(mut self, tcx: TyCtxt<'tcx>, trait_item_def_id: DefId) -> Option
|
|||||||
if let Some(item) = node.item(tcx, trait_item_def_id) {
|
if let Some(item) = node.item(tcx, trait_item_def_id) {
|
||||||
if finalizing_node.is_none() {
|
if finalizing_node.is_none() {
|
||||||
let is_specializable = item.defaultness(tcx).is_default()
|
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 {
|
if !is_specializable {
|
||||||
finalizing_node = Some(node);
|
finalizing_node = Some(node);
|
||||||
|
@ -48,7 +48,7 @@ pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
|
|||||||
///
|
///
|
||||||
/// [`type_of`]: crate::ty::TyCtxt::type_of
|
/// [`type_of`]: crate::ty::TyCtxt::type_of
|
||||||
pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness {
|
pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness {
|
||||||
tcx.impl_defaultness(self.def_id)
|
tcx.defaultness(self.def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1884,18 +1884,28 @@ pub fn mk_projection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_closure(self, closure_id: DefId, closure_substs: SubstsRef<'tcx>) -> Ty<'tcx> {
|
pub fn mk_closure(self, def_id: DefId, closure_substs: SubstsRef<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty_from_kind(Closure(closure_id, closure_substs))
|
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]
|
#[inline]
|
||||||
pub fn mk_generator(
|
pub fn mk_generator(
|
||||||
self,
|
self,
|
||||||
id: DefId,
|
def_id: DefId,
|
||||||
generator_substs: SubstsRef<'tcx>,
|
generator_substs: SubstsRef<'tcx>,
|
||||||
movability: hir::Movability,
|
movability: hir::Movability,
|
||||||
) -> Ty<'tcx> {
|
) -> 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]
|
#[inline]
|
||||||
|
@ -751,7 +751,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
|||||||
reach.generics().predicates();
|
reach.generics().predicates();
|
||||||
|
|
||||||
if trait_item_ref.kind == AssocItemKind::Type
|
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.
|
// No type to visit.
|
||||||
} else {
|
} else {
|
||||||
@ -1927,7 +1927,7 @@ fn check_assoc_item(
|
|||||||
|
|
||||||
let (check_ty, is_assoc_ty) = match assoc_item_kind {
|
let (check_ty, is_assoc_ty) = match assoc_item_kind {
|
||||||
AssocItemKind::Const | AssocItemKind::Fn { .. } => (true, false),
|
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.in_assoc_ty = is_assoc_ty;
|
||||||
check.generics().predicates();
|
check.generics().predicates();
|
||||||
|
@ -697,12 +697,12 @@ fn encode_ty<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unexpected types
|
// Unexpected types
|
||||||
ty::Bound(..)
|
ty::Alias(..)
|
||||||
|
| ty::Bound(..)
|
||||||
| ty::Error(..)
|
| ty::Error(..)
|
||||||
| ty::GeneratorWitness(..)
|
| ty::GeneratorWitness(..)
|
||||||
| ty::GeneratorWitnessMIR(..)
|
| ty::GeneratorWitnessMIR(..)
|
||||||
| ty::Infer(..)
|
| ty::Infer(..)
|
||||||
| ty::Alias(..)
|
|
||||||
| ty::Placeholder(..) => {
|
| ty::Placeholder(..) => {
|
||||||
bug!("encode_ty: unexpected `{:?}`", ty.kind());
|
bug!("encode_ty: unexpected `{:?}`", ty.kind());
|
||||||
}
|
}
|
||||||
@ -946,11 +946,18 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::Alias(..) => {
|
||||||
|
ty = transform_ty(
|
||||||
|
tcx,
|
||||||
|
tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty),
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ty::Bound(..)
|
ty::Bound(..)
|
||||||
| ty::Error(..)
|
| ty::Error(..)
|
||||||
| ty::GeneratorWitnessMIR(..)
|
| ty::GeneratorWitnessMIR(..)
|
||||||
| ty::Infer(..)
|
| ty::Infer(..)
|
||||||
| ty::Alias(..)
|
|
||||||
| ty::Param(..)
|
| ty::Param(..)
|
||||||
| ty::Placeholder(..) => {
|
| ty::Placeholder(..) => {
|
||||||
bug!("transform_ty: unexpected `{:?}`", ty.kind());
|
bug!("transform_ty: unexpected `{:?}`", ty.kind());
|
||||||
|
@ -295,7 +295,7 @@ pub fn future_trait_ref_and_outputs<'tcx>(
|
|||||||
|
|
||||||
pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
|
pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
|
||||||
assoc_item.defaultness(tcx).is_final()
|
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 {
|
pub enum TupleArgumentsFlag {
|
||||||
|
@ -297,8 +297,8 @@ fn associated_type_for_impl_trait_in_trait(
|
|||||||
// Copy visility of the containing function.
|
// Copy visility of the containing function.
|
||||||
trait_assoc_ty.visibility(tcx.visibility(fn_def_id));
|
trait_assoc_ty.visibility(tcx.visibility(fn_def_id));
|
||||||
|
|
||||||
// Copy impl_defaultness of the containing function.
|
// Copy defaultness of the containing function.
|
||||||
trait_assoc_ty.impl_defaultness(tcx.impl_defaultness(fn_def_id));
|
trait_assoc_ty.defaultness(tcx.defaultness(fn_def_id));
|
||||||
|
|
||||||
// Copy type_of of the opaque.
|
// Copy type_of of the opaque.
|
||||||
trait_assoc_ty.type_of(ty::EarlyBinder::bind(tcx.mk_opaque(
|
trait_assoc_ty.type_of(ty::EarlyBinder::bind(tcx.mk_opaque(
|
||||||
@ -393,8 +393,8 @@ fn associated_type_for_impl_trait_in_impl(
|
|||||||
// Copy visility of the containing function.
|
// Copy visility of the containing function.
|
||||||
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
|
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
|
||||||
|
|
||||||
// Copy impl_defaultness of the containing function.
|
// Copy defaultness of the containing function.
|
||||||
impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
|
impl_assoc_ty.defaultness(tcx.defaultness(impl_fn_def_id));
|
||||||
|
|
||||||
// Copy generics_of the trait's associated item but the impl as the parent.
|
// 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
|
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) resolves to the trait instead of the impl
|
||||||
|
@ -204,7 +204,7 @@ fn resolve_associated_item<'tcx>(
|
|||||||
} else {
|
} else {
|
||||||
// All other methods are default methods of the `Future` trait.
|
// All other methods are default methods of the `Future` trait.
|
||||||
// (this assumes that `ImplSource::Future` is only used for methods on `Future`)
|
// (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))
|
Some(Instance::new(trait_item_id, rcvr_substs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,13 +75,13 @@ fn sized_constraint_for_ty<'tcx>(
|
|||||||
result
|
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) {
|
match tcx.hir().get_by_def_id(def_id) {
|
||||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.defaultness,
|
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.defaultness,
|
||||||
hir::Node::ImplItem(hir::ImplItem { defaultness, .. })
|
hir::Node::ImplItem(hir::ImplItem { defaultness, .. })
|
||||||
| hir::Node::TraitItem(hir::TraitItem { defaultness, .. }) => *defaultness,
|
| hir::Node::TraitItem(hir::TraitItem { defaultness, .. }) => *defaultness,
|
||||||
node => {
|
node => {
|
||||||
bug!("`impl_defaultness` called on {:?}", node);
|
bug!("`defaultness` called on {:?}", node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -574,7 +574,7 @@ pub fn provide(providers: &mut Providers) {
|
|||||||
param_env_reveal_all_normalized,
|
param_env_reveal_all_normalized,
|
||||||
instance_def_size_estimate,
|
instance_def_size_estimate,
|
||||||
issue33140_self_ty,
|
issue33140_self_ty,
|
||||||
impl_defaultness,
|
defaultness,
|
||||||
unsizing_params_for_adt,
|
unsizing_params_for_adt,
|
||||||
..*providers
|
..*providers
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
//! [`borrow`](`RefCell::borrow`), and a mutable borrow (`&mut T`) can be obtained with
|
//! [`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
|
//! [`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
|
//! 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.
|
//! these rules, the thread will panic.
|
||||||
//!
|
//!
|
||||||
//! The corresponding [`Sync`] version of `RefCell<T>` is [`RwLock<T>`].
|
//! The corresponding [`Sync`] version of `RefCell<T>` is [`RwLock<T>`].
|
||||||
|
@ -240,6 +240,7 @@
|
|||||||
#![feature(allocator_internals)]
|
#![feature(allocator_internals)]
|
||||||
#![feature(allow_internal_unsafe)]
|
#![feature(allow_internal_unsafe)]
|
||||||
#![feature(allow_internal_unstable)]
|
#![feature(allow_internal_unstable)]
|
||||||
|
#![feature(c_str_literals)]
|
||||||
#![feature(c_unwind)]
|
#![feature(c_unwind)]
|
||||||
#![feature(cfg_target_thread_local)]
|
#![feature(cfg_target_thread_local)]
|
||||||
#![feature(concat_idents)]
|
#![feature(concat_idents)]
|
||||||
|
@ -242,13 +242,15 @@ pub fn args() -> Args {
|
|||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let process_info_sel = sel_registerName("processInfo\0".as_ptr());
|
let process_info_sel =
|
||||||
let arguments_sel = sel_registerName("arguments\0".as_ptr());
|
sel_registerName(c"processInfo".as_ptr() as *const libc::c_uchar);
|
||||||
let utf8_sel = sel_registerName("UTF8String\0".as_ptr());
|
let arguments_sel = sel_registerName(c"arguments".as_ptr() as *const libc::c_uchar);
|
||||||
let count_sel = sel_registerName("count\0".as_ptr());
|
let utf8_sel = sel_registerName(c"UTF8String".as_ptr() as *const libc::c_uchar);
|
||||||
let object_at_sel = sel_registerName("objectAtIndex:\0".as_ptr());
|
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 info = objc_msgSend(klass, process_info_sel);
|
||||||
let args = objc_msgSend(info, arguments_sel);
|
let args = objc_msgSend(info, arguments_sel);
|
||||||
|
|
||||||
|
@ -1063,7 +1063,7 @@ pub fn file_attr(&self) -> io::Result<FileAttr> {
|
|||||||
cfg_has_statx! {
|
cfg_has_statx! {
|
||||||
if let Some(ret) = unsafe { try_statx(
|
if let Some(ret) = unsafe { try_statx(
|
||||||
fd,
|
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::AT_EMPTY_PATH | libc::AT_STATX_SYNC_AS_STAT,
|
||||||
libc::STATX_ALL,
|
libc::STATX_ALL,
|
||||||
) } {
|
) } {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#![allow(missing_docs, nonstandard_style)]
|
#![allow(missing_docs, nonstandard_style)]
|
||||||
|
|
||||||
use crate::ffi::CStr;
|
|
||||||
use crate::io::ErrorKind;
|
use crate::io::ErrorKind;
|
||||||
|
|
||||||
pub use self::rand::hashmap_random_keys;
|
pub use self::rand::hashmap_random_keys;
|
||||||
@ -75,7 +74,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
|
|||||||
// thread-id for the main thread and so renaming the main thread will rename the
|
// 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.
|
// process and we only want to enable this on platforms we've tested.
|
||||||
if cfg!(target_os = "macos") {
|
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() {
|
unsafe fn sanitize_standard_fds() {
|
||||||
@ -121,7 +120,7 @@ unsafe fn sanitize_standard_fds() {
|
|||||||
if pfd.revents & libc::POLLNVAL == 0 {
|
if pfd.revents & libc::POLLNVAL == 0 {
|
||||||
continue;
|
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
|
// If the stream is closed but we failed to reopen it, abort the
|
||||||
// process. Otherwise we wouldn't preserve the safety of
|
// process. Otherwise we wouldn't preserve the safety of
|
||||||
// operations on the corresponding Rust object Stdin, Stdout, or
|
// operations on the corresponding Rust object Stdin, Stdout, or
|
||||||
@ -151,7 +150,7 @@ unsafe fn sanitize_standard_fds() {
|
|||||||
use libc::open64;
|
use libc::open64;
|
||||||
for fd in 0..3 {
|
for fd in 0..3 {
|
||||||
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
|
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
|
// If the stream is closed but we failed to reopen it, abort the
|
||||||
// process. Otherwise we wouldn't preserve the safety of
|
// process. Otherwise we wouldn't preserve the safety of
|
||||||
// operations on the corresponding Rust object Stdin, Stdout, or
|
// operations on the corresponding Rust object Stdin, Stdout, or
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
if #[cfg(target_os = "fuchsia")] {
|
if #[cfg(target_os = "fuchsia")] {
|
||||||
// fuchsia doesn't have /dev/null
|
// fuchsia doesn't have /dev/null
|
||||||
} else if #[cfg(target_os = "redox")] {
|
} else if #[cfg(target_os = "redox")] {
|
||||||
const DEV_NULL: &str = "null:\0";
|
const DEV_NULL: &CStr = c"null:";
|
||||||
} else if #[cfg(target_os = "vxworks")] {
|
} else if #[cfg(target_os = "vxworks")] {
|
||||||
const DEV_NULL: &str = "/null\0";
|
const DEV_NULL: &CStr = c"/null";
|
||||||
} else {
|
} else {
|
||||||
const DEV_NULL: &str = "/dev/null\0";
|
const DEV_NULL: &CStr = c"/dev/null";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,8 +474,7 @@ pub fn to_child_stdio(&self, readable: bool) -> io::Result<(ChildStdio, Option<A
|
|||||||
let mut opts = OpenOptions::new();
|
let mut opts = OpenOptions::new();
|
||||||
opts.read(readable);
|
opts.read(readable);
|
||||||
opts.write(!readable);
|
opts.write(!readable);
|
||||||
let path = unsafe { CStr::from_ptr(DEV_NULL.as_ptr() as *const _) };
|
let fd = File::open_c(DEV_NULL, &opts)?;
|
||||||
let fd = File::open_c(&path, &opts)?;
|
|
||||||
Ok((ChildStdio::Owned(fd.into_inner()), None))
|
Ok((ChildStdio::Owned(fd.into_inner()), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,10 +163,9 @@ pub fn set_name(name: &CStr) {
|
|||||||
#[cfg(target_os = "netbsd")]
|
#[cfg(target_os = "netbsd")]
|
||||||
pub fn set_name(name: &CStr) {
|
pub fn set_name(name: &CStr) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let cname = CStr::from_bytes_with_nul_unchecked(b"%s\0".as_slice());
|
|
||||||
let res = libc::pthread_setname_np(
|
let res = libc::pthread_setname_np(
|
||||||
libc::pthread_self(),
|
libc::pthread_self(),
|
||||||
cname.as_ptr(),
|
c"%s".as_ptr(),
|
||||||
name.as_ptr() as *mut libc::c_void,
|
name.as_ptr() as *mut libc::c_void,
|
||||||
);
|
);
|
||||||
debug_assert_eq!(res, 0);
|
debug_assert_eq!(res, 0);
|
||||||
|
@ -317,7 +317,7 @@ pub unsafe fn NtWriteFile(
|
|||||||
// Functions that aren't available on every version of Windows that we support,
|
// 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.
|
// but we still use them and just provide some form of a fallback implementation.
|
||||||
compat_fn_with_fallback! {
|
compat_fn_with_fallback! {
|
||||||
pub static KERNEL32: &CStr = ansi_str!("kernel32");
|
pub static KERNEL32: &CStr = c"kernel32";
|
||||||
|
|
||||||
// >= Win10 1607
|
// >= Win10 1607
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
|
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
|
||||||
@ -350,7 +350,7 @@ pub fn WaitOnAddress(
|
|||||||
}
|
}
|
||||||
|
|
||||||
compat_fn_with_fallback! {
|
compat_fn_with_fallback! {
|
||||||
pub static NTDLL: &CStr = ansi_str!("ntdll");
|
pub static NTDLL: &CStr = c"ntdll";
|
||||||
|
|
||||||
pub fn NtCreateKeyedEvent(
|
pub fn NtCreateKeyedEvent(
|
||||||
KeyedEventHandle: LPHANDLE,
|
KeyedEventHandle: LPHANDLE,
|
||||||
|
@ -228,9 +228,9 @@ pub fn option() -> Option<F> {
|
|||||||
/// Load all needed functions from "api-ms-win-core-synch-l1-2-0".
|
/// Load all needed functions from "api-ms-win-core-synch-l1-2-0".
|
||||||
pub(super) fn load_synch_functions() {
|
pub(super) fn load_synch_functions() {
|
||||||
fn try_load() -> Option<()> {
|
fn try_load() -> Option<()> {
|
||||||
const MODULE_NAME: &CStr = ansi_str!("api-ms-win-core-synch-l1-2-0");
|
const MODULE_NAME: &CStr = c"api-ms-win-core-synch-l1-2-0";
|
||||||
const WAIT_ON_ADDRESS: &CStr = ansi_str!("WaitOnAddress");
|
const WAIT_ON_ADDRESS: &CStr = c"WaitOnAddress";
|
||||||
const WAKE_BY_ADDRESS_SINGLE: &CStr = ansi_str!("WakeByAddressSingle");
|
const WAKE_BY_ADDRESS_SINGLE: &CStr = c"WakeByAddressSingle";
|
||||||
|
|
||||||
// Try loading the library and all the required functions.
|
// Try loading the library and all the required functions.
|
||||||
// If any step fails, then they all fail.
|
// If any step fails, then they all fail.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![allow(missing_docs, nonstandard_style)]
|
#![allow(missing_docs, nonstandard_style)]
|
||||||
|
|
||||||
use crate::ffi::{CStr, OsStr, OsString};
|
use crate::ffi::{OsStr, OsString};
|
||||||
use crate::io::ErrorKind;
|
use crate::io::ErrorKind;
|
||||||
use crate::mem::MaybeUninit;
|
use crate::mem::MaybeUninit;
|
||||||
use crate::os::windows::ffi::{OsStrExt, OsStringExt};
|
use crate::os::windows::ffi::{OsStrExt, OsStringExt};
|
||||||
@ -51,7 +51,7 @@ pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {
|
|||||||
|
|
||||||
// Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
|
// Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
|
||||||
// exists, we have to call it ourselves.
|
// 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.
|
// SAFETY: must be called only once during runtime cleanup.
|
||||||
|
@ -1224,7 +1224,7 @@ pub(crate) fn clean_impl_item<'tcx>(
|
|||||||
}
|
}
|
||||||
hir::ImplItemKind::Fn(ref sig, body) => {
|
hir::ImplItemKind::Fn(ref sig, body) => {
|
||||||
let m = clean_function(cx, sig, impl_.generics, FunctionArgs::Body(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))
|
MethodItem(m, Some(defaultness))
|
||||||
}
|
}
|
||||||
hir::ImplItemKind::Type(hir_ty) => {
|
hir::ImplItemKind::Type(hir_ty) => {
|
||||||
@ -1258,7 +1258,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
|
|||||||
|
|
||||||
let provided = match assoc_item.container {
|
let provided = match assoc_item.container {
|
||||||
ty::ImplContainer => true,
|
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 {
|
if provided {
|
||||||
AssocConstItem(ty, ConstantKind::Extern { def_id: assoc_item.def_id })
|
AssocConstItem(ty, ConstantKind::Extern { def_id: assoc_item.def_id })
|
||||||
@ -1440,7 +1440,7 @@ fn param_eq_arg(param: &GenericParamDef, arg: &GenericArg) -> bool {
|
|||||||
}
|
}
|
||||||
generics.where_predicates = where_predicates;
|
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(
|
AssocTypeItem(
|
||||||
Box::new(Typedef {
|
Box::new(Typedef {
|
||||||
type_: clean_middle_ty(
|
type_: clean_middle_ty(
|
||||||
|
@ -205,7 +205,7 @@ pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) {
|
|||||||
&UrlFragment::Item(def_id) => {
|
&UrlFragment::Item(def_id) => {
|
||||||
let kind = match tcx.def_kind(def_id) {
|
let kind = match tcx.def_kind(def_id) {
|
||||||
DefKind::AssocFn => {
|
DefKind::AssocFn => {
|
||||||
if tcx.impl_defaultness(def_id).has_value() {
|
if tcx.defaultness(def_id).has_value() {
|
||||||
"method."
|
"method."
|
||||||
} else {
|
} else {
|
||||||
"tymethod."
|
"tymethod."
|
||||||
|
@ -105,7 +105,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
|
|||||||
match tit_.kind {
|
match tit_.kind {
|
||||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
|
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
|
||||||
hir::TraitItemKind::Fn(..) => {
|
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
|
// trait method with default body needs inline in case
|
||||||
// an impl is not provided
|
// an impl is not provided
|
||||||
let desc = "a default trait method";
|
let desc = "a default trait method";
|
||||||
|
@ -132,7 +132,6 @@
|
|||||||
"crossbeam-epoch",
|
"crossbeam-epoch",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
"cstr",
|
|
||||||
"datafrog",
|
"datafrog",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"digest",
|
"digest",
|
||||||
|
@ -587,6 +587,6 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { }
|
|||||||
// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"}
|
// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"}
|
||||||
// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"}
|
// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"}
|
||||||
// CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_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: ![[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: ![[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: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"}
|
||||||
|
9
tests/rustdoc/double-hyphen-to-dash.rs
Normal file
9
tests/rustdoc/double-hyphen-to-dash.rs
Normal file
@ -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;
|
Loading…
Reference in New Issue
Block a user