Auto merge of #122117 - matthiaskrgr:rollup-3yrv3j6, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #122015 (Add better explanation for `rustc_index::IndexVec`)
 - #122061 (Clarify FatalErrorHandler)
 - #122062 (Explicitly assign constructed C++ classes)
 - #122072 (Refer to "slice" instead of "vector" in Ord and PartialOrd trait impl of slices)
 - #122088 (Remove unnecessary fixme on new thread stack size)
 - #122094 (Remove outdated footnote "missing-stack-probe" in platform-support)
 - #122107 (Temporarily make allow-by-default the `non_local_definitions` lint)
 - #122109 (compiletest: Add a `//@ needs-threads` directive)

Failed merges:

 - #122104 (Rust is a proper name: rust → Rust)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-03-07 00:04:02 +00:00
commit d03b986db1
93 changed files with 279 additions and 200 deletions

View File

@ -12,7 +12,24 @@ use std::vec;
use crate::{Idx, IndexSlice};
/// An owned contiguous collection of `T`s, indexed by `I` rather than by `usize`.
/// Its purpose is to avoid mixing indexes.
///
/// ## Why use this instead of a `Vec`?
///
/// An `IndexVec` allows element access only via a specific associated index type, meaning that
/// trying to use the wrong index type (possibly accessing an invalid element) will fail at
/// compile time.
///
/// It also documents what the index is indexing: in a `HashMap<usize, Something>` it's not
/// immediately clear what the `usize` means, while a `HashMap<FieldIdx, Something>` makes it obvious.
///
/// ```compile_fail
/// use rustc_index::{Idx, IndexVec};
///
/// fn f<I1: Idx, I2: Idx>(vec1: IndexVec<I1, u8>, idx1: I1, idx2: I2) {
/// &vec1[idx1]; // Ok
/// &vec1[idx2]; // Compile error!
/// }
/// ```
///
/// While it's possible to use `u32` or `usize` directly for `I`,
/// you almost certainly want to use a [`newtype_index!`]-generated type instead.

View File

@ -14,6 +14,7 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// #![warn(non_local_definitions)]
/// trait MyTrait {}
/// struct MyStruct;
///
@ -36,7 +37,7 @@ declare_lint! {
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
pub NON_LOCAL_DEFINITIONS,
Warn,
Allow,
"checks for non-local definitions",
report_in_external_macro
}

View File

@ -120,7 +120,7 @@ extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
}
auto FilenamesWriter =
coverage::CoverageFilenamesSectionWriter(ArrayRef<std::string>(FilenameRefs));
RawRustStringOstream OS(BufferOut);
auto OS = RawRustStringOstream(BufferOut);
FilenamesWriter.write(OS);
}
@ -160,7 +160,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
ArrayRef<unsigned>(VirtualFileMappingIDs, NumVirtualFileMappingIDs),
Expressions,
MappingRegions);
RawRustStringOstream OS(BufferOut);
auto OS = RawRustStringOstream(BufferOut);
CoverageMappingWriter.write(OS);
}
@ -168,23 +168,23 @@ extern "C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar(
LLVMValueRef F,
const char *FuncName,
size_t FuncNameLen) {
StringRef FuncNameRef(FuncName, FuncNameLen);
auto FuncNameRef = StringRef(FuncName, FuncNameLen);
return wrap(createPGOFuncNameVar(*cast<Function>(unwrap(F)), FuncNameRef));
}
extern "C" uint64_t LLVMRustCoverageHashByteArray(
const char *Bytes,
size_t NumBytes) {
StringRef StrRef(Bytes, NumBytes);
auto StrRef = StringRef(Bytes, NumBytes);
return IndexedInstrProf::ComputeHash(StrRef);
}
static void WriteSectionNameToString(LLVMModuleRef M,
InstrProfSectKind SK,
RustStringRef Str) {
Triple TargetTriple(unwrap(M)->getTargetTriple());
auto TargetTriple = Triple(unwrap(M)->getTargetTriple());
auto name = getInstrProfSectionName(SK, TargetTriple.getObjectFormat());
RawRustStringOstream OS(Str);
auto OS = RawRustStringOstream(Str);
OS << name;
}
@ -200,7 +200,7 @@ extern "C" void LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
extern "C" void LLVMRustCoverageWriteMappingVarNameToString(RustStringRef Str) {
auto name = getCoverageMappingVarName();
RawRustStringOstream OS(Str);
auto OS = RawRustStringOstream(Str);
OS << name;
}

View File

@ -77,9 +77,9 @@ extern "C" void LLVMRustTimeTraceProfilerFinishThread() {
}
extern "C" void LLVMRustTimeTraceProfilerFinish(const char* FileName) {
StringRef FN(FileName);
auto FN = StringRef(FileName);
std::error_code EC;
raw_fd_ostream OS(FN, EC, sys::fs::CD_CreateAlways);
auto OS = raw_fd_ostream(FN, EC, sys::fs::CD_CreateAlways);
timeTraceProfilerWrite(OS);
timeTraceProfilerCleanup();
@ -424,7 +424,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
auto CM = fromRust(RustCM);
std::string Error;
Triple Trip(Triple::normalize(TripleStr));
auto Trip = Triple(Triple::normalize(TripleStr));
const llvm::Target *TheTarget =
TargetRegistry::lookupTarget(Trip.getTriple(), Error);
if (TheTarget == nullptr) {
@ -537,8 +537,8 @@ extern "C" void LLVMRustDisposeTargetMachine(LLVMTargetMachineRef TM) {
// TargetLibraryInfo pass, so we use this method to do so.
extern "C" void LLVMRustAddLibraryInfo(LLVMPassManagerRef PMR, LLVMModuleRef M,
bool DisableSimplifyLibCalls) {
Triple TargetTriple(unwrap(M)->getTargetTriple());
TargetLibraryInfoImpl TLII(TargetTriple);
auto TargetTriple = Triple(unwrap(M)->getTargetTriple());
auto TLII = TargetLibraryInfoImpl(TargetTriple);
if (DisableSimplifyLibCalls)
TLII.disableAllFunctions();
unwrap(PMR)->add(new TargetLibraryInfoWrapperPass(TLII));
@ -589,7 +589,7 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
std::string ErrorInfo;
std::error_code EC;
raw_fd_ostream OS(Path, EC, sys::fs::OF_None);
auto OS = raw_fd_ostream(Path, EC, sys::fs::OF_None);
if (EC)
ErrorInfo = EC.message();
if (ErrorInfo != "") {
@ -597,9 +597,9 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
return LLVMRustResult::Failure;
}
buffer_ostream BOS(OS);
auto BOS = buffer_ostream(OS);
if (DwoPath) {
raw_fd_ostream DOS(DwoPath, EC, sys::fs::OF_None);
auto DOS = raw_fd_ostream(DwoPath, EC, sys::fs::OF_None);
EC.clear();
if (EC)
ErrorInfo = EC.message();
@ -607,7 +607,7 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
LLVMRustSetLastError(ErrorInfo.c_str());
return LLVMRustResult::Failure;
}
buffer_ostream DBOS(DOS);
auto DBOS = buffer_ostream(DOS);
unwrap(Target)->addPassesToEmitFile(*PM, BOS, &DBOS, FileType, false);
PM->run(*unwrap(M));
} else {
@ -796,7 +796,7 @@ LLVMRustOptimize(
DebugInfoForProfiling);
}
PassBuilder PB(TM, PTO, PGOOpt, &PIC);
auto PB = PassBuilder(TM, PTO, PGOOpt, &PIC);
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
@ -1112,7 +1112,7 @@ extern "C" LLVMRustResult
LLVMRustPrintModule(LLVMModuleRef M, const char *Path, DemangleFn Demangle) {
std::string ErrorInfo;
std::error_code EC;
raw_fd_ostream OS(Path, EC, sys::fs::OF_None);
auto OS = raw_fd_ostream(Path, EC, sys::fs::OF_None);
if (EC)
ErrorInfo = EC.message();
if (ErrorInfo != "") {
@ -1120,8 +1120,8 @@ LLVMRustPrintModule(LLVMModuleRef M, const char *Path, DemangleFn Demangle) {
return LLVMRustResult::Failure;
}
RustAssemblyAnnotationWriter AAW(Demangle);
formatted_raw_ostream FOS(OS);
auto AAW = RustAssemblyAnnotationWriter(Demangle);
auto FOS = formatted_raw_ostream(OS);
unwrap(M)->print(FOS, &AAW);
return LLVMRustResult::Success;
@ -1281,8 +1281,8 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
// Load each module's summary and merge it into one combined index
for (int i = 0; i < num_modules; i++) {
auto module = &modules[i];
StringRef buffer(module->data, module->len);
MemoryBufferRef mem_buffer(buffer, module->identifier);
auto buffer = StringRef(module->data, module->len);
auto mem_buffer = MemoryBufferRef(buffer, module->identifier);
Ret->ModuleMap[module->identifier] = mem_buffer;
@ -1485,7 +1485,7 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M,
return MOrErr;
};
bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
FunctionImporter Importer(Data->Index, Loader, ClearDSOLocal);
auto Importer = FunctionImporter(Data->Index, Loader, ClearDSOLocal);
Expected<bool> Result = Importer.importFunctions(Mod, ImportList);
if (!Result) {
LLVMRustSetLastError(toString(Result.takeError()).c_str());
@ -1510,7 +1510,7 @@ extern "C" LLVMRustThinLTOBuffer*
LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin) {
auto Ret = std::make_unique<LLVMRustThinLTOBuffer>();
{
raw_string_ostream OS(Ret->data);
auto OS = raw_string_ostream(Ret->data);
{
if (is_thin) {
PassBuilder PB;
@ -1557,8 +1557,8 @@ LLVMRustParseBitcodeForLTO(LLVMContextRef Context,
const char *data,
size_t len,
const char *identifier) {
StringRef Data(data, len);
MemoryBufferRef Buffer(Data, identifier);
auto Data = StringRef(data, len);
auto Buffer = MemoryBufferRef(Data, identifier);
unwrap(Context)->enableDebugTypeODRUniquing();
Expected<std::unique_ptr<Module>> SrcOrError =
parseBitcodeFile(Buffer, *unwrap(Context));
@ -1576,8 +1576,8 @@ extern "C" const char *LLVMRustGetSliceFromObjectDataByName(const char *data,
const char *name,
size_t *out_len) {
*out_len = 0;
StringRef Data(data, len);
MemoryBufferRef Buffer(Data, ""); // The id is unused.
auto Data = StringRef(data, len);
auto Buffer = MemoryBufferRef(Data, ""); // The id is unused.
file_magic Type = identify_magic(Buffer.getBuffer());
Expected<std::unique_ptr<object::ObjectFile>> ObjFileOrError =
object::ObjectFile::createObjectFile(Buffer, Type);

View File

@ -66,12 +66,22 @@ static LLVM_THREAD_LOCAL char *LastError;
static void FatalErrorHandler(void *UserData,
const char* Reason,
bool GenCrashDiag) {
// Do the same thing that the default error handler does.
std::cerr << "LLVM ERROR: " << Reason << std::endl;
// Once upon a time we emitted "LLVM ERROR:" specifically to mimic LLVM. Then,
// we developed crater and other tools which only expose logs, not error codes.
// Use a more greppable prefix that will still match the "LLVM ERROR:" prefix.
std::cerr << "rustc-LLVM ERROR: " << Reason << std::endl;
// Since this error handler exits the process, we have to run any cleanup that
// LLVM would run after handling the error. This might change with an LLVM
// upgrade.
//
// In practice, this will do nothing, because the only cleanup LLVM does is
// to remove all files that were registered with it via a frontend calling
// one of the `createOutputFile` family of functions in LLVM and passing true
// to RemoveFileOnSignal, something that rustc does not do. However, it would
// be... inadvisable to suddenly stop running these handlers, if LLVM gets
// "interesting" ideas in the future about what cleanup should be done.
// We might even find it useful for generating less artifacts.
sys::RunInterruptHandlers();
exit(101);
@ -109,7 +119,7 @@ extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M,
extern "C" const char *LLVMRustPrintPassTimings(size_t *Len) {
std::string buf;
raw_string_ostream SS(buf);
auto SS = raw_string_ostream(buf);
TimerGroup::printAll(SS);
SS.flush();
*Len = buf.length();
@ -120,7 +130,7 @@ extern "C" const char *LLVMRustPrintPassTimings(size_t *Len) {
extern "C" const char *LLVMRustPrintStatistics(size_t *Len) {
std::string buf;
raw_string_ostream SS(buf);
auto SS = raw_string_ostream(buf);
llvm::PrintStatistics(SS);
SS.flush();
*Len = buf.length();
@ -174,7 +184,7 @@ extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M,
extern "C" LLVMValueRef
LLVMRustGetOrInsertGlobal(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef Ty) {
Module *Mod = unwrap(M);
StringRef NameRef(Name, NameLen);
auto NameRef = StringRef(Name, NameLen);
// We don't use Module::getOrInsertGlobal because that returns a Constant*,
// which may either be the real GlobalVariable*, or a constant bitcast of it
@ -285,7 +295,7 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
template<typename T> static inline void AddAttributes(T *t, unsigned Index,
LLVMAttributeRef *Attrs, size_t AttrsLen) {
AttributeList PAL = t->getAttributes();
AttrBuilder B(t->getContext());
auto B = AttrBuilder(t->getContext());
for (LLVMAttributeRef Attr : ArrayRef<LLVMAttributeRef>(Attrs, AttrsLen))
B.addAttribute(unwrap(Attr));
AttributeList PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
@ -1195,13 +1205,13 @@ extern "C" int64_t LLVMRustDIBuilderCreateOpLLVMFragment() {
}
extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Ty, RustStringRef Str) {
RawRustStringOstream OS(Str);
auto OS = RawRustStringOstream(Str);
unwrap<llvm::Type>(Ty)->print(OS);
}
extern "C" void LLVMRustWriteValueToString(LLVMValueRef V,
RustStringRef Str) {
RawRustStringOstream OS(Str);
auto OS = RawRustStringOstream(Str);
if (!V) {
OS << "(null)";
} else {
@ -1224,7 +1234,7 @@ extern "C" LLVMTypeRef LLVMRustArrayType(LLVMTypeRef ElementTy,
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Twine, LLVMTwineRef)
extern "C" void LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef Str) {
RawRustStringOstream OS(Str);
auto OS = RawRustStringOstream(Str);
unwrap(T)->print(OS);
}
@ -1236,11 +1246,11 @@ extern "C" void LLVMRustUnpackOptimizationDiagnostic(
llvm::DiagnosticInfoOptimizationBase *Opt =
static_cast<llvm::DiagnosticInfoOptimizationBase *>(unwrap(DI));
RawRustStringOstream PassNameOS(PassNameOut);
auto PassNameOS = RawRustStringOstream(PassNameOut);
PassNameOS << Opt->getPassName();
*FunctionOut = wrap(&Opt->getFunction());
RawRustStringOstream FilenameOS(FilenameOut);
auto FilenameOS = RawRustStringOstream(FilenameOut);
DiagnosticLocation loc = Opt->getLocation();
if (loc.isValid()) {
*Line = loc.getLine();
@ -1248,7 +1258,7 @@ extern "C" void LLVMRustUnpackOptimizationDiagnostic(
FilenameOS << loc.getAbsolutePath();
}
RawRustStringOstream MessageOS(MessageOut);
auto MessageOS = RawRustStringOstream(MessageOut);
MessageOS << Opt->getMsg();
}
@ -1291,8 +1301,8 @@ LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI,
extern "C" void LLVMRustWriteDiagnosticInfoToString(LLVMDiagnosticInfoRef DI,
RustStringRef Str) {
RawRustStringOstream OS(Str);
DiagnosticPrinterRawOStream DP(OS);
auto OS = RawRustStringOstream(Str);
auto DP = DiagnosticPrinterRawOStream(OS);
unwrap(DI)->print(DP);
}
@ -1406,7 +1416,7 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
default:
{
std::string error;
llvm::raw_string_ostream stream(error);
auto stream = llvm::raw_string_ostream(error);
stream << "Rust does not support the TypeID: " << unwrap(Ty)->getTypeID()
<< " for the type: " << *unwrap(Ty);
stream.flush();
@ -1432,7 +1442,7 @@ extern "C" bool LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef,
unsigned* RangesOut,
size_t* NumRanges) {
SMDiagnostic& D = *unwrap(DRef);
RawRustStringOstream MessageOS(MessageOut);
auto MessageOS = RawRustStringOstream(MessageOut);
MessageOS << D.getMessage();
switch (D.getKind()) {
@ -1547,7 +1557,7 @@ extern "C" void LLVMRustPositionBuilderAtStart(LLVMBuilderRef B,
extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V,
const char *Name, size_t NameLen) {
Triple TargetTriple(unwrap(M)->getTargetTriple());
Triple TargetTriple = Triple(unwrap(M)->getTargetTriple());
GlobalObject *GV = unwrap<GlobalObject>(V);
if (TargetTriple.supportsCOMDAT()) {
StringRef NameRef(Name, NameLen);
@ -1711,7 +1721,7 @@ extern "C" LLVMRustModuleBuffer*
LLVMRustModuleBufferCreate(LLVMModuleRef M) {
auto Ret = std::make_unique<LLVMRustModuleBuffer>();
{
raw_string_ostream OS(Ret->data);
auto OS = raw_string_ostream(Ret->data);
WriteBitcodeToFile(*unwrap(M), OS);
}
return Ret.release();
@ -1741,8 +1751,8 @@ LLVMRustModuleCost(LLVMModuleRef M) {
extern "C" void
LLVMRustModuleInstructionStats(LLVMModuleRef M, RustStringRef Str)
{
RawRustStringOstream OS(Str);
llvm::json::OStream JOS(OS);
auto OS = RawRustStringOstream(Str);
auto JOS = llvm::json::OStream(OS);
auto Module = unwrap(M);
JOS.object([&] {
@ -1857,7 +1867,7 @@ extern "C" LLVMRustResult LLVMRustWriteImportLibrary(
MinGW);
if (Error) {
std::string errorString;
llvm::raw_string_ostream stream(errorString);
auto stream = llvm::raw_string_ostream(errorString);
stream << Error;
stream.flush();
LLVMRustSetLastError(errorString.c_str());
@ -2041,7 +2051,7 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
}
extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) {
RawRustStringOstream OS(Str);
auto OS = RawRustStringOstream(Str);
GlobalValue *GV = unwrap<GlobalValue>(V);
Mangler().getNameWithPrefix(OS, GV, true);
}

View File

@ -11,6 +11,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Object/ObjectFile.h"
#include <llvm/Support/raw_ostream.h>
using namespace llvm;
using namespace llvm::sys;
@ -42,7 +43,7 @@ extern "C" void *LLVMRustGetSymbols(
MemoryBuffer::getMemBuffer(StringRef(BufPtr, BufLen), StringRef("LLVMRustGetSymbolsObject"),
false);
SmallString<0> SymNameBuf;
raw_svector_ostream SymName(SymNameBuf);
auto SymName = raw_svector_ostream(SymNameBuf);
// In the scenario when LLVMContext is populated SymbolicFile will contain a
// reference to it, thus SymbolicFile should be destroyed first.
@ -60,7 +61,7 @@ extern "C" void *LLVMRustGetSymbols(
if (!ObjOrErr) {
Error E = ObjOrErr.takeError();
SmallString<0> ErrorBuf;
raw_svector_ostream Error(ErrorBuf);
auto Error = raw_svector_ostream(ErrorBuf);
Error << E << '\0';
return ErrorCallback(Error.str().data());
}
@ -70,7 +71,7 @@ extern "C" void *LLVMRustGetSymbols(
if (!ObjOrErr) {
Error E = ObjOrErr.takeError();
SmallString<0> ErrorBuf;
raw_svector_ostream Error(ErrorBuf);
auto Error = raw_svector_ostream(ErrorBuf);
Error << E << '\0';
return ErrorCallback(Error.str().data());
}
@ -83,7 +84,7 @@ extern "C" void *LLVMRustGetSymbols(
continue;
if (Error E = S.printName(SymName)) {
SmallString<0> ErrorBuf;
raw_svector_ostream Error(ErrorBuf);
auto Error = raw_svector_ostream(ErrorBuf);
Error << E << '\0';
return ErrorCallback(Error.str().data());
}

View File

@ -24,7 +24,7 @@ where
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq> Eq for [T] {}
/// Implements comparison of vectors [lexicographically](Ord#lexicographical-comparison).
/// Implements comparison of slices [lexicographically](Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Ord for [T] {
fn cmp(&self, other: &[T]) -> Ordering {
@ -32,7 +32,7 @@ impl<T: Ord> Ord for [T] {
}
}
/// Implements comparison of vectors [lexicographically](Ord#lexicographical-comparison).
/// Implements comparison of slices [lexicographically](Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd> PartialOrd for [T] {
fn partial_cmp(&self, other: &[T]) -> Option<Ordering> {

View File

@ -26,11 +26,8 @@ impl Thread {
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
let p = Box::into_raw(Box::new(p));
// FIXME On UNIX, we guard against stack sizes that are too small but
// that's because pthreads enforces that stacks are at least
// PTHREAD_STACK_MIN bytes big. Windows has no such lower limit, it's
// just that below a certain threshold you can't do anything useful.
// That threshold is application and architecture-specific, however.
// CreateThread rounds up values for the stack size to the nearest page size (at least 4kb).
// If a value of zero is given then the default stack size is used instead.
let ret = c::CreateThread(
ptr::null_mut(),
stack,

View File

@ -423,3 +423,16 @@ fn scope_join_race() {
});
}
}
// Test that the smallest value for stack_size works on Windows.
#[cfg(windows)]
#[test]
fn test_minimal_thread_stack() {
use crate::sync::atomic::AtomicU8;
static COUNT: AtomicU8 = AtomicU8::new(0);
let builder = thread::Builder::new().stack_size(1);
let before = builder.spawn(|| COUNT.fetch_add(1, Ordering::Relaxed)).unwrap().join().unwrap();
assert_eq!(before, 0);
assert_eq!(COUNT.load(Ordering::Relaxed), 1);
}

View File

@ -32,7 +32,7 @@ All tier 1 targets with host tools support the full standard library.
target | notes
-------|-------
`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.1, glibc 2.17+) [^missing-stack-probes]
`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.1, glibc 2.17+)
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 7+) [^windows-support] [^x86_32-floats-return-ABI]
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 7+) [^windows-support] [^x86_32-floats-return-ABI]
`i686-unknown-linux-gnu` | 32-bit Linux (kernel 3.2+, glibc 2.17+) [^x86_32-floats-return-ABI]
@ -41,10 +41,6 @@ target | notes
`x86_64-pc-windows-msvc` | 64-bit MSVC (Windows 7+) [^windows-support]
`x86_64-unknown-linux-gnu` | 64-bit Linux (kernel 3.2+, glibc 2.17+)
[^missing-stack-probes]: Stack probes support is missing on
`aarch64-unknown-linux-gnu`, but it's planned to be implemented in the near
future. The implementation is tracked on [issue #77071][77071].
[^windows-support]: Only Windows 10 currently undergoes automated testing. Earlier versions of Windows rely on testing and support from the community.
[^x86_32-floats-return-ABI]: Due to limitations of the C ABI, floating-point support on `i686` targets is non-compliant: floating-point return values are passed via an x87 register, so NaN payload bits can be lost. See [issue #114479][x86-32-float-issue].

View File

@ -451,6 +451,15 @@ impl Config {
self.target_cfg().panic == PanicStrategy::Unwind
}
pub fn has_threads(&self) -> bool {
// Wasm targets don't have threads unless `-threads` is in the target
// name, such as `wasm32-wasip1-threads`.
if self.target.starts_with("wasm") {
return self.target.contains("threads");
}
true
}
pub fn has_asm_support(&self) -> bool {
static ASM_SUPPORTED_ARCHS: &[&str] = &[
"x86", "x86_64", "arm", "aarch64", "riscv32",

View File

@ -787,6 +787,7 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
"needs-sanitizer-shadow-call-stack",
"needs-sanitizer-support",
"needs-sanitizer-thread",
"needs-threads",
"needs-unwind",
"needs-xray",
"no-prefer-dynamic",

View File

@ -84,6 +84,11 @@ pub(super) fn handle_needs(
condition: config.run_enabled(),
ignore_reason: "ignored when running the resulting test binaries is disabled",
},
Need {
name: "needs-threads",
condition: config.has_threads(),
ignore_reason: "ignored on targets without threading support",
},
Need {
name: "needs-unwind",
condition: config.can_unwind(),

View File

@ -592,3 +592,23 @@ fn ignore_mode() {
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
}
}
#[test]
fn threads_support() {
let threads = [
("x86_64-unknown-linux-gnu", true),
("aarch64-apple-darwin", true),
("wasm32-unknown-unknown", false),
("wasm64-unknown-unknown", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1-threads", true),
("wasm32-wasi-preview1-threads", true),
];
for (target, has_threads) in threads {
let config = cfg().target(target).build();
assert_eq!(config.has_threads(), has_threads);
assert_eq!(check_ignore(&config, "//@ needs-threads"), !has_threads)
}
}

View File

@ -1,4 +1,4 @@
//@ ignore-wasm32-bare compiled with panic=abort by default
//@ needs-unwind
//@ compile-flags: -C no-prepopulate-passes -Copt-level=0
//

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(rustc_private)]
extern crate libc;

View File

@ -4,7 +4,7 @@
// make sure the stack pointers are maintained properly in both
// directions
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(rustc_private)]
extern crate libc;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(rustc_private)]

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View File

@ -7,8 +7,7 @@
// optimisation.
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(intrinsics)]
use std::{mem, thread};

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads
//@ needs-threads
//@ compile-flags: -O
// Tests that the `vec!` macro does not overflow the stack when it is

View File

@ -3,7 +3,7 @@
//@ revisions: default nomiropt
//@[nomiropt]compile-flags: -Z mir-opt-level=0
//@ ignore-emscripten no threads support
//@ needs-threads
//@ compile-flags: --test
#![feature(coroutines, coroutine_trait)]

View File

@ -5,7 +5,7 @@
// that use capture clauses.
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
extern crate cci_capture_clause;

View File

@ -4,7 +4,7 @@
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(unused_mut)]
//@ ignore-emscripten No support for threads
//@ needs-threads
/**
A somewhat reduced test case to expose some Valgrind issues.

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_variables)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::mem;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
// Regression test for unwrapping the result of `join`, issue #21291

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
pub fn main() {
let f = || || 0;

View File

@ -1,6 +1,6 @@
//@ edition:2018
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::time::Duration;

View File

@ -1,3 +1,3 @@
'common' global must have a zero initializer!
ptr @TEST
LLVM ERROR: Broken module found, compilation aborted!
rustc-LLVM ERROR: Broken module found, compilation aborted!

View File

@ -4,6 +4,7 @@
//@ rustc-env:CARGO=/usr/bin/cargo
#![feature(inline_const)]
#![warn(non_local_definitions)]
extern crate non_local_macro;

View File

@ -1,5 +1,5 @@
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:36:5
--> $DIR/non_local_definitions.rs:37:5
|
LL | const Z: () = {
| - help: use a const-anon item to suppress this lint: `_`
@ -11,10 +11,14 @@ LL | impl Uto for &Test {}
= note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/non_local_definitions.rs:7:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:46:5
--> $DIR/non_local_definitions.rs:47:5
|
LL | impl Uto for *mut Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -25,7 +29,7 @@ LL | impl Uto for *mut Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:54:9
--> $DIR/non_local_definitions.rs:55:9
|
LL | impl Uto for Test {}
| ^^^^^^^^^^^^^^^^^^^^
@ -36,7 +40,7 @@ LL | impl Uto for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:63:5
--> $DIR/non_local_definitions.rs:64:5
|
LL | impl Uto2 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -47,7 +51,7 @@ LL | impl Uto2 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:71:5
--> $DIR/non_local_definitions.rs:72:5
|
LL | impl Uto3 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -58,7 +62,7 @@ LL | impl Uto3 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:75:5
--> $DIR/non_local_definitions.rs:76:5
|
LL | macro_rules! m0 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -69,7 +73,7 @@ LL | macro_rules! m0 { () => { } };
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:87:5
--> $DIR/non_local_definitions.rs:88:5
|
LL | macro_rules! m { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -80,7 +84,7 @@ LL | macro_rules! m { () => { } };
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:90:5
--> $DIR/non_local_definitions.rs:91:5
|
LL | / impl Test {
LL | |
@ -94,7 +98,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:96:9
--> $DIR/non_local_definitions.rs:97:9
|
LL | / impl Test {
LL | |
@ -108,7 +112,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:105:9
--> $DIR/non_local_definitions.rs:106:9
|
LL | / impl Test {
LL | |
@ -122,7 +126,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:114:9
--> $DIR/non_local_definitions.rs:115:9
|
LL | / impl Test {
LL | |
@ -136,7 +140,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:122:5
--> $DIR/non_local_definitions.rs:123:5
|
LL | / impl Display for Test {
LL | |
@ -152,7 +156,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:129:5
--> $DIR/non_local_definitions.rs:130:5
|
LL | impl dyn Uto5 {}
| ^^^^^^^^^^^^^^^^
@ -163,7 +167,7 @@ LL | impl dyn Uto5 {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:132:5
--> $DIR/non_local_definitions.rs:133:5
|
LL | impl<T: Uto5> Uto5 for Vec<T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -174,7 +178,7 @@ LL | impl<T: Uto5> Uto5 for Vec<T> { }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:135:5
--> $DIR/non_local_definitions.rs:136:5
|
LL | impl Uto5 for &dyn Uto5 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -185,7 +189,7 @@ LL | impl Uto5 for &dyn Uto5 {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:138:5
--> $DIR/non_local_definitions.rs:139:5
|
LL | impl Uto5 for *mut Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -196,7 +200,7 @@ LL | impl Uto5 for *mut Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:141:5
--> $DIR/non_local_definitions.rs:142:5
|
LL | impl Uto5 for *mut [Test] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -207,7 +211,7 @@ LL | impl Uto5 for *mut [Test] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:144:5
--> $DIR/non_local_definitions.rs:145:5
|
LL | impl Uto5 for [Test; 8] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -218,7 +222,7 @@ LL | impl Uto5 for [Test; 8] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:147:5
--> $DIR/non_local_definitions.rs:148:5
|
LL | impl Uto5 for (Test,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
@ -229,7 +233,7 @@ LL | impl Uto5 for (Test,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:150:5
--> $DIR/non_local_definitions.rs:151:5
|
LL | impl Uto5 for fn(Test) -> () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -240,7 +244,7 @@ LL | impl Uto5 for fn(Test) -> () {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:153:5
--> $DIR/non_local_definitions.rs:154:5
|
LL | impl Uto5 for fn() -> Test {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -251,7 +255,7 @@ LL | impl Uto5 for fn() -> Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:157:9
--> $DIR/non_local_definitions.rs:158:9
|
LL | impl Uto5 for Test {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -262,7 +266,7 @@ LL | impl Uto5 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:164:9
--> $DIR/non_local_definitions.rs:165:9
|
LL | impl Uto5 for &Test {}
| ^^^^^^^^^^^^^^^^^^^^^^
@ -273,7 +277,7 @@ LL | impl Uto5 for &Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:171:9
--> $DIR/non_local_definitions.rs:172:9
|
LL | impl Uto5 for &(Test,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -284,7 +288,7 @@ LL | impl Uto5 for &(Test,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:178:9
--> $DIR/non_local_definitions.rs:179:9
|
LL | impl Uto5 for &(Test,Test) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -295,7 +299,7 @@ LL | impl Uto5 for &(Test,Test) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:186:5
--> $DIR/non_local_definitions.rs:187:5
|
LL | impl Uto5 for *mut InsideMain {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -306,7 +310,7 @@ LL | impl Uto5 for *mut InsideMain {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:188:5
--> $DIR/non_local_definitions.rs:189:5
|
LL | impl Uto5 for *mut [InsideMain] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -317,7 +321,7 @@ LL | impl Uto5 for *mut [InsideMain] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:190:5
--> $DIR/non_local_definitions.rs:191:5
|
LL | impl Uto5 for [InsideMain; 8] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -328,7 +332,7 @@ LL | impl Uto5 for [InsideMain; 8] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:192:5
--> $DIR/non_local_definitions.rs:193:5
|
LL | impl Uto5 for (InsideMain,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -339,7 +343,7 @@ LL | impl Uto5 for (InsideMain,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:194:5
--> $DIR/non_local_definitions.rs:195:5
|
LL | impl Uto5 for fn(InsideMain) -> () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -350,7 +354,7 @@ LL | impl Uto5 for fn(InsideMain) -> () {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:196:5
--> $DIR/non_local_definitions.rs:197:5
|
LL | impl Uto5 for fn() -> InsideMain {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -361,7 +365,7 @@ LL | impl Uto5 for fn() -> InsideMain {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:210:9
--> $DIR/non_local_definitions.rs:211:9
|
LL | / impl Display for InsideMain {
LL | |
@ -377,7 +381,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:217:9
--> $DIR/non_local_definitions.rs:218:9
|
LL | / impl InsideMain {
LL | |
@ -394,7 +398,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:221:17
--> $DIR/non_local_definitions.rs:222:17
|
LL | macro_rules! m2 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -405,7 +409,7 @@ LL | macro_rules! m2 { () => { } };
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:231:5
--> $DIR/non_local_definitions.rs:232:5
|
LL | impl<T: Uto6> Uto3 for Vec<T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -416,7 +420,7 @@ LL | impl<T: Uto6> Uto3 for Vec<T> { }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:240:5
--> $DIR/non_local_definitions.rs:241:5
|
LL | impl Uto7 for Test where Local: std::any::Any {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -427,7 +431,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:243:5
--> $DIR/non_local_definitions.rs:244:5
|
LL | impl<T> Uto8 for T {}
| ^^^^^^^^^^^^^^^^^^^^^
@ -438,7 +442,7 @@ LL | impl<T> Uto8 for T {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:252:5
--> $DIR/non_local_definitions.rs:253:5
|
LL | / impl Default for UwU<OwO> {
LL | |
@ -454,7 +458,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:263:5
--> $DIR/non_local_definitions.rs:264:5
|
LL | / impl From<Cat> for () {
LL | |
@ -470,7 +474,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:272:5
--> $DIR/non_local_definitions.rs:273:5
|
LL | / impl AsRef<Cat> for () {
LL | |
@ -484,7 +488,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:283:5
--> $DIR/non_local_definitions.rs:284:5
|
LL | / impl PartialEq<B> for G {
LL | |
@ -500,7 +504,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:300:5
--> $DIR/non_local_definitions.rs:301:5
|
LL | / impl PartialEq<Dog> for &Dog {
LL | |
@ -516,7 +520,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:307:5
--> $DIR/non_local_definitions.rs:308:5
|
LL | / impl PartialEq<()> for Dog {
LL | |
@ -532,7 +536,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:314:5
--> $DIR/non_local_definitions.rs:315:5
|
LL | / impl PartialEq<()> for &Dog {
LL | |
@ -548,7 +552,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:321:5
--> $DIR/non_local_definitions.rs:322:5
|
LL | / impl PartialEq<Dog> for () {
LL | |
@ -564,7 +568,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:343:5
--> $DIR/non_local_definitions.rs:344:5
|
LL | / impl From<Wrap<Wrap<Lion>>> for () {
LL | |
@ -580,7 +584,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:350:5
--> $DIR/non_local_definitions.rs:351:5
|
LL | / impl From<()> for Wrap<Lion> {
LL | |
@ -596,7 +600,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:363:13
--> $DIR/non_local_definitions.rs:364:13
|
LL | impl MacroTrait for OutsideStruct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -611,7 +615,7 @@ LL | m!();
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: non-local `impl` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:373:1
--> $DIR/non_local_definitions.rs:374:1
|
LL | non_local_macro::non_local_impl!(CargoUpdate);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -624,7 +628,7 @@ LL | non_local_macro::non_local_impl!(CargoUpdate);
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: non-local `macro_rules!` definition, they should be avoided as they go against expectation
--> $DIR/non_local_definitions.rs:376:1
--> $DIR/non_local_definitions.rs:377:1
|
LL | non_local_macro::non_local_macro_rules!(my_macro);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,6 +1,6 @@
//@ run-pass
//@ ignore-windows
//@ ignore-emscripten no threads support
//@ needs-threads
use std::cell::Cell;
use std::fmt;

View File

@ -1,7 +1,7 @@
//@ run-pass
//@ compile-flags: -C lto
//@ no-prefer-dynamic
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,9 +1,8 @@
//@ run-pass
//@ needs-unwind
//@ needs-threads
#![allow(stable_features)]
//@ ignore-emscripten no threads support
#![feature(std_panic)]
use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -1,7 +1,7 @@
//@ run-fail
//@ error-pattern:thread '<unnamed>' panicked
//@ error-pattern:test
//@ ignore-emscripten Needs threads
//@ needs-threads
use std::thread;

View File

@ -1,7 +1,7 @@
//@ run-fail
//@ error-pattern:thread 'owned name' panicked
//@ error-pattern:test
//@ ignore-emscripten Needs threads.
//@ needs-threads
use std::thread::Builder;

View File

@ -5,6 +5,8 @@
//@ edition:2018
#![no_std] // Don't load unnecessary hygiene information from std
#![warn(non_local_definitions)]
extern crate std;
extern crate nested_macro_rules;

View File

@ -12,7 +12,7 @@ LL | | }
LL | | }
| |_________^
|
::: $DIR/nested-macro-rules.rs:21:5
::: $DIR/nested-macro-rules.rs:23:5
|
LL | nested_macro_rules::outer_macro!(SecondStruct, SecondAttrStruct);
| ---------------------------------------------------------------- in this macro invocation
@ -21,7 +21,11 @@ LL | nested_macro_rules::outer_macro!(SecondStruct, SecondAttrStruct);
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/nested-macro-rules.rs:8:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View File

@ -25,7 +25,7 @@ PRINT-BANG INPUT (DISPLAY): SecondStruct
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "SecondStruct",
span: $DIR/nested-macro-rules.rs:21:38: 21:50 (#15),
span: $DIR/nested-macro-rules.rs:23:38: 23:50 (#15),
},
]
PRINT-ATTR INPUT (DISPLAY): struct SecondAttrStruct {}
@ -36,7 +36,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
},
Ident {
ident: "SecondAttrStruct",
span: $DIR/nested-macro-rules.rs:21:52: 21:68 (#15),
span: $DIR/nested-macro-rules.rs:23:52: 23:68 (#15),
},
Group {
delimiter: Brace,

View File

@ -2,7 +2,7 @@
// https://github.com/fortanix/rust-sgx/issues/109
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::{net::TcpListener, sync::mpsc, thread};

View File

@ -1,7 +1,7 @@
// program should terminate when std::process::exit is called from any thread
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::{process, thread};

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View File

@ -3,7 +3,7 @@
//@ run-flags: --test-threads=1 test1 test2
//@ check-run-results
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
//@ ignore-emscripten no threads support
//@ needs-threads
#[test]
fn test1() {}

View File

@ -2,7 +2,7 @@
//@ run-flags: --test-threads=1
//@ check-run-results
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
//@ ignore-emscripten no threads support
//@ needs-threads
//@ run-pass
#[test]

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
//@ compile-flags: -O
//@ ignore-nto Doesn't work without emulated TLS enabled (in LLVM)

View File

@ -2,7 +2,7 @@
// Reported as issue #126, child leaks the string.
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,13 +1,13 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};
pub fn main() {
let (tx, rx) = channel();
let t = thread::spawn(move|| { child(&tx) });
let t = thread::spawn(move || { child(&tx) });
let y = rx.recv().unwrap();
println!("received");
println!("{}", y);

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no processes
//@ needs-threads
//@ ignore-sgx no processes
use std::cell::RefCell;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads
//@ needs-threads
//@ ignore-sgx no processes
use std::thread;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,4 +1,4 @@
//@ ignore-wasm32
//@ needs-threads
//@ dont-check-compiler-stderr
#![feature(cfg_target_thread_local, thread_local_internals)]

View File

@ -1,4 +1,4 @@
//@ ignore-wasm32
//@ needs-threads
#![feature(thread_local)]
#![feature(cfg_target_thread_local, thread_local_internals)]

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::channel;
use std::thread;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::channel;
use std::thread;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Receiver};

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(deprecated)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{TryRecvError, channel};
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
//@ compile-flags:--test
//@ ignore-emscripten
//@ needs-threads
use std::sync::mpsc::channel;
use std::sync::mpsc::TryRecvError;

View File

@ -4,7 +4,7 @@
#![allow(non_camel_case_types)]
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::channel;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(non_camel_case_types)]
//@ ignore-emscripten no threads support
//@ needs-threads
/*
Make sure we can spawn tasks that take different types of

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -3,7 +3,7 @@
#![allow(unused_mut)]
//@ ignore-windows
//@ exec-env:RUST_LOG=debug
//@ ignore-emscripten no threads support
//@ needs-threads
// regression test for issue #10405, make sure we don't call println! too soon.

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_variables)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_parens)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
//@ pretty-expanded FIXME #23616
use std::sync::mpsc::{channel, Sender};

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
//@ pretty-expanded FIXME #23616
// Issue #922

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(unused_assignments)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
//@ pretty-expanded FIXME #23616
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-fail
//@ error-pattern:Ensure that the child thread runs by panicking
//@ ignore-emscripten Needs threads.
//@ needs-threads
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::channel;

View File

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
//@ needs-unwind
#![feature(internal_output_capture)]

View File

@ -1,6 +1,6 @@
//@ run-pass
//@ ignore-android needs extra network permissions
//@ ignore-emscripten no threads or sockets support
//@ needs-threads
//@ ignore-netbsd system ulimit (Too many open files)
//@ ignore-openbsd system ulimit (Too many open files)

View File

@ -5,7 +5,7 @@
//@ error-pattern:should be a positive integer
//@ compile-flags: --test
//@ exec-env:RUST_TEST_THREADS=foo
//@ ignore-emscripten
//@ needs-threads
#[test]
fn do_nothing() {}

View File

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -1,6 +1,6 @@
//@ run-pass
//@ no-prefer-dynamic
//@ ignore-emscripten no threads support
//@ needs-threads
static mut HIT: bool = false;

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(stable_features)]
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(thread_local_try_with)]

View File

@ -1,7 +1,7 @@
//@ run-pass
#![allow(stable_features)]
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(thread_local_try_with)]

View File

@ -2,7 +2,7 @@
//@ needs-unwind
#![allow(non_camel_case_types)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View File

@ -2,7 +2,7 @@
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -2,7 +2,7 @@
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View File

@ -3,7 +3,7 @@
// Tests that a heterogeneous list of existential `dyn` types can be put inside an Arc
// and shared between threads as long as all types fulfill Send.
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::Arc;
use std::sync::mpsc::channel;