Auto merge of #120309 - fmease:rollup-kr7wqy6, r=fmease

Rollup of 9 pull requests

Successful merges:

 - #114764 ([style edition 2024] Combine all delimited exprs as last argument)
 - #118326 (Add `NonZero*::count_ones`)
 - #119460 (coverage: Never emit improperly-ordered coverage regions)
 - #119616 (Add a new `wasm32-wasi-preview2` target)
 - #120185 (coverage: Don't instrument `#[automatically_derived]` functions)
 - #120265 (Remove no-system-llvm)
 - #120284 (privacy: Refactor top-level visiting in `TypePrivacyVisitor`)
 - #120285 (Remove extra # from url in suggestion)
 - #120299 (Add mw to review rotation and add some owner assignments)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-01-24 20:34:41 +00:00
commit 7ffc697ce1
64 changed files with 614 additions and 408 deletions

View File

@ -329,7 +329,7 @@ fn make_code_region(
start_line = source_map.doctest_offset_line(&file.name, start_line);
end_line = source_map.doctest_offset_line(&file.name, end_line);
Some(CodeRegion {
check_code_region(CodeRegion {
file_name,
start_line: start_line as u32,
start_col: start_col as u32,
@ -338,6 +338,39 @@ fn make_code_region(
})
}
/// If `llvm-cov` sees a code region that is improperly ordered (end < start),
/// it will immediately exit with a fatal error. To prevent that from happening,
/// discard regions that are improperly ordered, or might be interpreted in a
/// way that makes them improperly ordered.
fn check_code_region(code_region: CodeRegion) -> Option<CodeRegion> {
let CodeRegion { file_name: _, start_line, start_col, end_line, end_col } = code_region;
// Line/column coordinates are supposed to be 1-based. If we ever emit
// coordinates of 0, `llvm-cov` might misinterpret them.
let all_nonzero = [start_line, start_col, end_line, end_col].into_iter().all(|x| x != 0);
// Coverage mappings use the high bit of `end_col` to indicate that a
// region is actually a "gap" region, so make sure it's unset.
let end_col_has_high_bit_unset = (end_col & (1 << 31)) == 0;
// If a region is improperly ordered (end < start), `llvm-cov` will exit
// with a fatal error, which is inconvenient for users and hard to debug.
let is_ordered = (start_line, start_col) <= (end_line, end_col);
if all_nonzero && end_col_has_high_bit_unset && is_ordered {
Some(code_region)
} else {
debug!(
?code_region,
?all_nonzero,
?end_col_has_high_bit_unset,
?is_ordered,
"Skipping code region that would be misinterpreted or rejected by LLVM"
);
// If this happens in a debug build, ICE to make it easier to notice.
debug_assert!(false, "Improper code region: {code_region:?}");
None
}
}
fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
// Only instrument functions, methods, and closures (not constants since they are evaluated
// at compile time by Miri).
@ -351,7 +384,18 @@ fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
return false;
}
// Don't instrument functions with `#[automatically_derived]` on their
// enclosing impl block, on the assumption that most users won't care about
// coverage for derived impls.
if let Some(impl_of) = tcx.impl_of_method(def_id.to_def_id())
&& tcx.is_automatically_derived(impl_of)
{
trace!("InstrumentCoverage skipped for {def_id:?} (automatically derived)");
return false;
}
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::NO_COVERAGE) {
trace!("InstrumentCoverage skipped for {def_id:?} (`#[coverage(off)]`)");
return false;
}

View File

@ -24,13 +24,13 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, CRATE_DEF_ID};
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{AssocItemKind, ForeignItemKind, ItemId, PatKind};
use rustc_middle::bug;
use rustc_middle::hir::nested_filter;
use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level};
use rustc_middle::query::Providers;
use rustc_middle::ty::GenericArgs;
use rustc_middle::ty::{self, Const, GenericParamDefKind};
use rustc_middle::ty::{TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
use rustc_middle::{bug, span_bug};
use rustc_session::lint;
use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{kw, sym, Ident};
@ -1064,29 +1064,22 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
struct TypePrivacyVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
module_def_id: LocalModDefId,
maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>,
current_item: LocalDefId,
span: Span,
}
impl<'tcx> TypePrivacyVisitor<'tcx> {
/// Gets the type-checking results for the current body.
/// As this will ICE if called outside bodies, only call when working with
/// `Expr` or `Pat` nodes (they are guaranteed to be found only in bodies).
#[track_caller]
fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> {
self.maybe_typeck_results
.expect("`TypePrivacyVisitor::typeck_results` called outside of body")
}
fn item_is_accessible(&self, did: DefId) -> bool {
self.tcx.visibility(did).is_accessible_from(self.current_item, self.tcx)
self.tcx.visibility(did).is_accessible_from(self.module_def_id, self.tcx)
}
// Take node-id of an expression or pattern and check its type for privacy.
fn check_expr_pat_type(&mut self, id: hir::HirId, span: Span) -> bool {
self.span = span;
let typeck_results = self.typeck_results();
let typeck_results = self
.maybe_typeck_results
.unwrap_or_else(|| span_bug!(span, "`hir::Expr` or `hir::Pat` outside of a body"));
let result: ControlFlow<()> = try {
self.visit(typeck_results.node_type(id))?;
self.visit(typeck_results.node_args(id))?;
@ -1107,35 +1100,13 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
}
impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
type NestedFilter = nested_filter::All;
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
fn nested_visit_map(&mut self) -> Self::Map {
self.tcx.hir()
}
fn visit_mod(&mut self, _m: &'tcx hir::Mod<'tcx>, _s: Span, _n: hir::HirId) {
// Don't visit nested modules, since we run a separate visitor walk
// for each module in `effective_visibilities`
}
fn visit_nested_body(&mut self, body: hir::BodyId) {
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
let old_maybe_typeck_results =
self.maybe_typeck_results.replace(self.tcx.typeck_body(body));
let body = self.tcx.hir().body(body);
self.visit_body(body);
self.maybe_typeck_results.replace(self.tcx.typeck_body(body_id));
self.visit_body(self.tcx.hir().body(body_id));
self.maybe_typeck_results = old_maybe_typeck_results;
}
fn visit_generic_arg(&mut self, generic_arg: &'tcx hir::GenericArg<'tcx>) {
match generic_arg {
hir::GenericArg::Type(t) => self.visit_ty(t),
hir::GenericArg::Infer(inf) => self.visit_infer(inf),
hir::GenericArg::Lifetime(_) | hir::GenericArg::Const(_) => {}
}
}
fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) {
self.span = hir_ty.span;
if let Some(typeck_results) = self.maybe_typeck_results {
@ -1163,19 +1134,19 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
return;
}
} else {
// We don't do anything for const infers here.
// FIXME: check types of const infers here.
}
} else {
bug!("visit_infer without typeck_results");
span_bug!(self.span, "`hir::InferArg` outside of a body");
}
intravisit::walk_inf(self, inf);
}
fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef<'tcx>) {
self.span = trait_ref.path.span;
if self.maybe_typeck_results.is_none() {
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
// The traits' privacy in bodies is already checked as a part of trait object types.
if self.maybe_typeck_results.is_some() {
// Privacy of traits in bodies is checked as a part of trait object types.
} else {
let bounds = rustc_hir_analysis::hir_trait_to_predicates(
self.tcx,
trait_ref,
@ -1223,7 +1194,10 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
hir::ExprKind::MethodCall(segment, ..) => {
// Method calls have to be checked specially.
self.span = segment.ident.span;
if let Some(def_id) = self.typeck_results().type_dependent_def_id(expr.hir_id) {
let typeck_results = self
.maybe_typeck_results
.unwrap_or_else(|| span_bug!(self.span, "`hir::Expr` outside of a body"));
if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) {
if self.visit(self.tcx.type_of(def_id).instantiate_identity()).is_break() {
return;
}
@ -1251,9 +1225,13 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
Res::Def(kind, def_id) => Some((kind, def_id)),
_ => None,
},
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
.maybe_typeck_results
.and_then(|typeck_results| typeck_results.type_dependent_def(id)),
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
match self.maybe_typeck_results {
Some(typeck_results) => typeck_results.type_dependent_def(id),
// FIXME: Check type-relative associated types in signatures.
None => None,
}
}
};
let def = def.filter(|(kind, _)| {
matches!(
@ -1307,15 +1285,6 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
intravisit::walk_local(self, local);
}
// Check types in item interfaces.
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
let orig_current_item = mem::replace(&mut self.current_item, item.owner_id.def_id);
let old_maybe_typeck_results = self.maybe_typeck_results.take();
intravisit::walk_item(self, item);
self.maybe_typeck_results = old_maybe_typeck_results;
self.current_item = orig_current_item;
}
}
impl<'tcx> DefIdVisitor<'tcx> for TypePrivacyVisitor<'tcx> {
@ -1785,13 +1754,8 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
// Check privacy of explicitly written types and traits as well as
// inferred types of expressions and patterns.
let mut visitor = TypePrivacyVisitor {
tcx,
maybe_typeck_results: None,
current_item: module_def_id.to_local_def_id(),
span,
};
intravisit::walk_mod(&mut visitor, module, hir_id);
let mut visitor = TypePrivacyVisitor { tcx, module_def_id, maybe_typeck_results: None, span };
tcx.hir().visit_item_likes_in_module(module_def_id, &mut visitor);
}
fn effective_visibilities(tcx: TyCtxt<'_>, (): ()) -> &EffectiveVisibilities {

View File

@ -1793,6 +1793,7 @@ symbols! {
warn,
wasm_abi,
wasm_import_module,
wasm_preview2,
wasm_target_feature,
while_let,
windows,

View File

@ -1574,6 +1574,7 @@ supported_targets! {
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
("wasm32-unknown-unknown", wasm32_unknown_unknown),
("wasm32-wasi", wasm32_wasi),
("wasm32-wasi-preview2", wasm32_wasi_preview2),
("wasm32-wasi-preview1-threads", wasm32_wasi_preview1_threads),
("wasm64-unknown-unknown", wasm64_unknown_unknown),

View File

@ -72,11 +72,12 @@
//! best we can with this target. Don't start relying on too much here unless
//! you know what you're getting in to!
use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
use crate::spec::{base, crt_objects, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
pub fn target() -> Target {
let mut options = base::wasm::options();
options.families = cvs!["wasm", "wasi"];
options.os = "wasi".into();
options.add_pre_link_args(

View File

@ -0,0 +1,64 @@
//! The `wasm32-wasi-preview2` target is the next evolution of the
//! wasm32-wasi target. While the wasi specification is still under
//! active development, the {review 2 iteration is considered an "island
//! of stability" that should allow users to rely on it indefinitely.
//!
//! The `wasi` target is a proposal to define a standardized set of WebAssembly
//! component imports that allow it to interoperate with the host system in a
//! standardized way. This set of imports is intended to empower WebAssembly
//! binaries with host capabilities such as filesystem access, network access, etc.
//!
//! Wasi Preview 2 relies on the WebAssembly component model which is an extension of
//! the core WebAssembly specification which allows interoperability between WebAssembly
//! modules (known as "components") through high-level, shared-nothing APIs instead of the
//! low-level, shared-everything linear memory model of the core WebAssembly specification.
//!
//! You can see more about wasi at <https://wasi.dev> and the component model at
//! <https://github.com/WebAssembly/component-model>.
use crate::spec::crt_objects;
use crate::spec::LinkSelfContainedDefault;
use crate::spec::{base, Target};
pub fn target() -> Target {
let mut options = base::wasm::options();
options.os = "wasi".into();
options.env = "preview2".into();
options.linker = Some("wasm-component-ld".into());
options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained();
options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained();
// FIXME: Figure out cases in which WASM needs to link with a native toolchain.
options.link_self_contained = LinkSelfContainedDefault::True;
// Right now this is a bit of a workaround but we're currently saying that
// the target by default has a static crt which we're taking as a signal
// for "use the bundled crt". If that's turned off then the system's crt
// will be used, but this means that default usage of this target doesn't
// need an external compiler but it's still interoperable with an external
// compiler if configured correctly.
options.crt_static_default = true;
options.crt_static_respected = true;
// Allow `+crt-static` to create a "cdylib" output which is just a wasm file
// without a main function.
options.crt_static_allows_dylibs = true;
// WASI's `sys::args::init` function ignores its arguments; instead,
// `args::args()` makes the WASI API calls itself.
options.main_needs_argc_argv = false;
// And, WASI mangles the name of "main" to distinguish between different
// signatures.
options.entry_name = "__main_void".into();
Target {
llvm_target: "wasm32-unknown-unknown".into(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(),
arch: "wasm32".into(),
options,
}
}

View File

@ -3155,7 +3155,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} else {
// FIXME: we may suggest array::repeat instead
err.help("consider using `core::array::from_fn` to initialize the array");
err.help("see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information");
err.help("see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information");
}
if self.tcx.sess.is_nightly_build()

View File

@ -288,6 +288,43 @@ macro_rules! nonzero_integer {
unsafe { intrinsics::cttz_nonzero(self.get() as $UnsignedPrimitive) as u32 }
}
/// Returns the number of ones in the binary representation of `self`.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(non_zero_count_ones)]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
#[doc = concat!("# use std::num::{self, ", stringify!($Ty), "};")]
///
/// let one = num::NonZeroU32::new(1)?;
/// let three = num::NonZeroU32::new(3)?;
#[doc = concat!("let a = ", stringify!($Ty), "::new(0b100_0000)?;")]
#[doc = concat!("let b = ", stringify!($Ty), "::new(0b100_0011)?;")]
///
/// assert_eq!(a.count_ones(), one);
/// assert_eq!(b.count_ones(), three);
/// # Some(())
/// # }
/// ```
///
#[unstable(feature = "non_zero_count_ones", issue = "120287")]
#[rustc_const_unstable(feature = "non_zero_count_ones", issue = "120287")]
#[doc(alias = "popcount")]
#[doc(alias = "popcnt")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline(always)]
pub const fn count_ones(self) -> NonZeroU32 {
// SAFETY:
// `self` is non-zero, which means it has at least one bit set, which means
// that the result of `count_ones` is non-zero.
unsafe { NonZeroU32::new_unchecked(self.get().count_ones()) }
}
nonzero_integer_signedness_dependent_methods! {
Self = $Ty,
Primitive = $signedness $Int,

View File

@ -85,6 +85,9 @@ pub mod linux;
#[cfg(any(target_os = "wasi", doc))]
pub mod wasi;
#[cfg(any(all(target_os = "wasi", target_env = "preview2"), doc))]
pub mod wasi_preview2;
// windows
#[cfg(not(all(
doc,

View File

@ -28,7 +28,8 @@
//! [`OsStr`]: crate::ffi::OsStr
//! [`OsString`]: crate::ffi::OsString
#![stable(feature = "rust1", since = "1.0.0")]
#![cfg_attr(not(target_env = "preview2"), stable(feature = "rust1", since = "1.0.0"))]
#![cfg_attr(target_env = "preview2", unstable(feature = "wasm_preview2", issue = "none"))]
#![deny(unsafe_op_in_unsafe_fn)]
#![doc(cfg(target_os = "wasi"))]

View File

@ -0,0 +1,5 @@
//! Platform-specific extensions to `std` for Preview 2 of the WebAssembly System Interface (WASI).
//!
//! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized.
#![stable(feature = "raw_ext", since = "1.1.0")]

View File

@ -40,6 +40,9 @@ cfg_if::cfg_if! {
} else if #[cfg(target_os = "wasi")] {
mod wasi;
pub use self::wasi::*;
} else if #[cfg(all(target_os = "wasi", target_env = "preview2"))] {
mod wasi_preview2;
pub use self::wasi_preview2::*;
} else if #[cfg(target_family = "wasm")] {
mod wasm;
pub use self::wasm::*;

View File

@ -0,0 +1,123 @@
use crate::io as std_io;
use crate::mem;
#[inline]
pub fn is_interrupted(errno: i32) -> bool {
errno == wasi::ERRNO_INTR.raw().into()
}
pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
use std_io::ErrorKind;
let Ok(errno) = u16::try_from(errno) else {
return ErrorKind::Uncategorized;
};
macro_rules! match_errno {
($($($errno:ident)|+ => $errkind:ident),*, _ => $wildcard:ident $(,)?) => {
match errno {
$(e if $(e == ::wasi::$errno.raw())||+ => ErrorKind::$errkind),*,
_ => ErrorKind::$wildcard,
}
};
}
match_errno! {
ERRNO_2BIG => ArgumentListTooLong,
ERRNO_ACCES => PermissionDenied,
ERRNO_ADDRINUSE => AddrInUse,
ERRNO_ADDRNOTAVAIL => AddrNotAvailable,
ERRNO_AFNOSUPPORT => Unsupported,
ERRNO_AGAIN => WouldBlock,
// ALREADY => "connection already in progress",
// BADF => "bad file descriptor",
// BADMSG => "bad message",
ERRNO_BUSY => ResourceBusy,
// CANCELED => "operation canceled",
// CHILD => "no child processes",
ERRNO_CONNABORTED => ConnectionAborted,
ERRNO_CONNREFUSED => ConnectionRefused,
ERRNO_CONNRESET => ConnectionReset,
ERRNO_DEADLK => Deadlock,
// DESTADDRREQ => "destination address required",
ERRNO_DOM => InvalidInput,
// DQUOT => /* reserved */,
ERRNO_EXIST => AlreadyExists,
// FAULT => "bad address",
ERRNO_FBIG => FileTooLarge,
ERRNO_HOSTUNREACH => HostUnreachable,
// IDRM => "identifier removed",
// ILSEQ => "illegal byte sequence",
// INPROGRESS => "operation in progress",
ERRNO_INTR => Interrupted,
ERRNO_INVAL => InvalidInput,
ERRNO_IO => Uncategorized,
// ISCONN => "socket is connected",
ERRNO_ISDIR => IsADirectory,
ERRNO_LOOP => FilesystemLoop,
// MFILE => "file descriptor value too large",
ERRNO_MLINK => TooManyLinks,
// MSGSIZE => "message too large",
// MULTIHOP => /* reserved */,
ERRNO_NAMETOOLONG => InvalidFilename,
ERRNO_NETDOWN => NetworkDown,
// NETRESET => "connection aborted by network",
ERRNO_NETUNREACH => NetworkUnreachable,
// NFILE => "too many files open in system",
// NOBUFS => "no buffer space available",
ERRNO_NODEV => NotFound,
ERRNO_NOENT => NotFound,
// NOEXEC => "executable file format error",
// NOLCK => "no locks available",
// NOLINK => /* reserved */,
ERRNO_NOMEM => OutOfMemory,
// NOMSG => "no message of the desired type",
// NOPROTOOPT => "protocol not available",
ERRNO_NOSPC => StorageFull,
ERRNO_NOSYS => Unsupported,
ERRNO_NOTCONN => NotConnected,
ERRNO_NOTDIR => NotADirectory,
ERRNO_NOTEMPTY => DirectoryNotEmpty,
// NOTRECOVERABLE => "state not recoverable",
// NOTSOCK => "not a socket",
ERRNO_NOTSUP => Unsupported,
// NOTTY => "inappropriate I/O control operation",
ERRNO_NXIO => NotFound,
// OVERFLOW => "value too large to be stored in data type",
// OWNERDEAD => "previous owner died",
ERRNO_PERM => PermissionDenied,
ERRNO_PIPE => BrokenPipe,
// PROTO => "protocol error",
ERRNO_PROTONOSUPPORT => Unsupported,
// PROTOTYPE => "protocol wrong type for socket",
// RANGE => "result too large",
ERRNO_ROFS => ReadOnlyFilesystem,
ERRNO_SPIPE => NotSeekable,
ERRNO_SRCH => NotFound,
// STALE => /* reserved */,
ERRNO_TIMEDOUT => TimedOut,
ERRNO_TXTBSY => ResourceBusy,
ERRNO_XDEV => CrossesDevices,
ERRNO_NOTCAPABLE => PermissionDenied,
_ => Uncategorized,
}
}
pub fn abort_internal() -> ! {
unsafe { libc::abort() }
}
pub fn hashmap_random_keys() -> (u64, u64) {
let mut ret = (0u64, 0u64);
unsafe {
let base = &mut ret as *mut (u64, u64) as *mut u8;
let len = mem::size_of_val(&ret);
wasi::random_get(base, len).expect("random_get failure");
}
return ret;
}
#[inline]
pub(crate) fn err2io(err: wasi::Errno) -> std_io::Error {
std_io::Error::from_raw_os_error(err.raw().into())
}

View File

@ -14,9 +14,6 @@
//! compiling for wasm. That way it's a compile time error for something that's
//! guaranteed to be a runtime error!
use crate::io as std_io;
use crate::mem;
#[path = "../unix/alloc.rs"]
pub mod alloc;
pub mod args;
@ -72,123 +69,12 @@ cfg_if::cfg_if! {
mod common;
pub use common::*;
#[inline]
pub fn is_interrupted(errno: i32) -> bool {
errno == wasi::ERRNO_INTR.raw().into()
}
pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
use std_io::ErrorKind;
let Ok(errno) = u16::try_from(errno) else {
return ErrorKind::Uncategorized;
};
macro_rules! match_errno {
($($($errno:ident)|+ => $errkind:ident),*, _ => $wildcard:ident $(,)?) => {
match errno {
$(e if $(e == ::wasi::$errno.raw())||+ => ErrorKind::$errkind),*,
_ => ErrorKind::$wildcard,
}
};
}
match_errno! {
ERRNO_2BIG => ArgumentListTooLong,
ERRNO_ACCES => PermissionDenied,
ERRNO_ADDRINUSE => AddrInUse,
ERRNO_ADDRNOTAVAIL => AddrNotAvailable,
ERRNO_AFNOSUPPORT => Unsupported,
ERRNO_AGAIN => WouldBlock,
// ALREADY => "connection already in progress",
// BADF => "bad file descriptor",
// BADMSG => "bad message",
ERRNO_BUSY => ResourceBusy,
// CANCELED => "operation canceled",
// CHILD => "no child processes",
ERRNO_CONNABORTED => ConnectionAborted,
ERRNO_CONNREFUSED => ConnectionRefused,
ERRNO_CONNRESET => ConnectionReset,
ERRNO_DEADLK => Deadlock,
// DESTADDRREQ => "destination address required",
ERRNO_DOM => InvalidInput,
// DQUOT => /* reserved */,
ERRNO_EXIST => AlreadyExists,
// FAULT => "bad address",
ERRNO_FBIG => FileTooLarge,
ERRNO_HOSTUNREACH => HostUnreachable,
// IDRM => "identifier removed",
// ILSEQ => "illegal byte sequence",
// INPROGRESS => "operation in progress",
ERRNO_INTR => Interrupted,
ERRNO_INVAL => InvalidInput,
ERRNO_IO => Uncategorized,
// ISCONN => "socket is connected",
ERRNO_ISDIR => IsADirectory,
ERRNO_LOOP => FilesystemLoop,
// MFILE => "file descriptor value too large",
ERRNO_MLINK => TooManyLinks,
// MSGSIZE => "message too large",
// MULTIHOP => /* reserved */,
ERRNO_NAMETOOLONG => InvalidFilename,
ERRNO_NETDOWN => NetworkDown,
// NETRESET => "connection aborted by network",
ERRNO_NETUNREACH => NetworkUnreachable,
// NFILE => "too many files open in system",
// NOBUFS => "no buffer space available",
ERRNO_NODEV => NotFound,
ERRNO_NOENT => NotFound,
// NOEXEC => "executable file format error",
// NOLCK => "no locks available",
// NOLINK => /* reserved */,
ERRNO_NOMEM => OutOfMemory,
// NOMSG => "no message of the desired type",
// NOPROTOOPT => "protocol not available",
ERRNO_NOSPC => StorageFull,
ERRNO_NOSYS => Unsupported,
ERRNO_NOTCONN => NotConnected,
ERRNO_NOTDIR => NotADirectory,
ERRNO_NOTEMPTY => DirectoryNotEmpty,
// NOTRECOVERABLE => "state not recoverable",
// NOTSOCK => "not a socket",
ERRNO_NOTSUP => Unsupported,
// NOTTY => "inappropriate I/O control operation",
ERRNO_NXIO => NotFound,
// OVERFLOW => "value too large to be stored in data type",
// OWNERDEAD => "previous owner died",
ERRNO_PERM => PermissionDenied,
ERRNO_PIPE => BrokenPipe,
// PROTO => "protocol error",
ERRNO_PROTONOSUPPORT => Unsupported,
// PROTOTYPE => "protocol wrong type for socket",
// RANGE => "result too large",
ERRNO_ROFS => ReadOnlyFilesystem,
ERRNO_SPIPE => NotSeekable,
ERRNO_SRCH => NotFound,
// STALE => /* reserved */,
ERRNO_TIMEDOUT => TimedOut,
ERRNO_TXTBSY => ResourceBusy,
ERRNO_XDEV => CrossesDevices,
ERRNO_NOTCAPABLE => PermissionDenied,
_ => Uncategorized,
}
}
pub fn abort_internal() -> ! {
unsafe { libc::abort() }
}
pub fn hashmap_random_keys() -> (u64, u64) {
let mut ret = (0u64, 0u64);
unsafe {
let base = &mut ret as *mut (u64, u64) as *mut u8;
let len = mem::size_of_val(&ret);
wasi::random_get(base, len).expect("random_get failure");
}
return ret;
}
#[inline]
fn err2io(err: wasi::Errno) -> std_io::Error {
std_io::Error::from_raw_os_error(err.raw().into())
}
mod helpers;
// These exports are listed individually to work around Rust's glob import
// conflict rules. If we glob export `helpers` and `common` together, then
// the compiler complains about conflicts.
pub use helpers::abort_internal;
pub use helpers::decode_error_kind;
use helpers::err2io;
pub use helpers::hashmap_random_keys;
pub use helpers::is_interrupted;

View File

@ -0,0 +1,78 @@
//! System bindings for the wasi preview 2 target.
//!
//! This is the next evolution of the original wasi target, and is intended to
//! replace that target over time.
//!
//! To begin with, this target mirrors the wasi target 1 to 1, but over
//! time this will change significantly.
#[path = "../unix/alloc.rs"]
pub mod alloc;
#[path = "../wasi/args.rs"]
pub mod args;
#[path = "../unix/cmath.rs"]
pub mod cmath;
#[path = "../wasi/env.rs"]
pub mod env;
#[path = "../wasi/fd.rs"]
pub mod fd;
#[path = "../wasi/fs.rs"]
pub mod fs;
#[allow(unused)]
#[path = "../wasm/atomics/futex.rs"]
pub mod futex;
#[path = "../wasi/io.rs"]
pub mod io;
#[path = "../wasi/net.rs"]
pub mod net;
#[path = "../wasi/os.rs"]
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]
pub mod process;
#[path = "../wasi/stdio.rs"]
pub mod stdio;
#[path = "../wasi/thread.rs"]
pub mod thread;
#[path = "../unsupported/thread_local_dtor.rs"]
pub mod thread_local_dtor;
#[path = "../unsupported/thread_local_key.rs"]
pub mod thread_local_key;
#[path = "../wasi/time.rs"]
pub mod time;
cfg_if::cfg_if! {
if #[cfg(target_feature = "atomics")] {
compile_error!("The wasm32-wasi-preview2 target does not support atomics");
} else {
#[path = "../unsupported/locks/mod.rs"]
pub mod locks;
#[path = "../unsupported/once.rs"]
pub mod once;
#[path = "../unsupported/thread_parking.rs"]
pub mod thread_parking;
}
}
#[path = "../unsupported/common.rs"]
#[deny(unsafe_op_in_unsafe_fn)]
#[allow(unused)]
mod common;
pub use common::*;
#[path = "../wasi/helpers.rs"]
mod helpers;
// These exports are listed individually to work around Rust's glob import
// conflict rules. If we glob export `helpers` and `common` together, then
// the compiler complains about conflicts.
pub use helpers::abort_internal;
pub use helpers::decode_error_kind;
use helpers::err2io;
pub use helpers::hashmap_random_keys;
pub use helpers::is_interrupted;

View File

@ -367,10 +367,13 @@ fn copy_self_contained_objects(
let srcdir = builder
.wasi_root(target)
.unwrap_or_else(|| {
panic!("Target {:?} does not have a \"wasi-root\" key", target.triple)
panic!(
"Target {:?} does not have a \"wasi-root\" key in Config.toml",
target.triple
)
})
.join("lib")
.join(target.to_string().replace("-preview1", ""));
.join(target.to_string().replace("-preview1", "").replace("-preview2", ""));
for &obj in &["libc.a", "crt1-command.o", "crt1-reactor.o"] {
copy_and_stamp(
builder,

View File

@ -88,7 +88,7 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
(Some(Mode::Std), "no_sync", None),
(Some(Mode::Std), "backtrace_in_libstd", None),
/* Extra values not defined in the built-in targets yet, but used in std */
(Some(Mode::Std), "target_env", Some(&["libnx"])),
(Some(Mode::Std), "target_env", Some(&["libnx", "preview2"])),
// (Some(Mode::Std), "target_os", Some(&[])),
// #[cfg(bootstrap)] zkvm
(Some(Mode::Std), "target_os", Some(&["zkvm"])),

View File

@ -59,6 +59,7 @@
- [*-unknown-openbsd](platform-support/openbsd.md)
- [\*-unknown-uefi](platform-support/unknown-uefi.md)
- [wasm32-wasi-preview1-threads](platform-support/wasm32-wasi-preview1-threads.md)
- [wasm32-wasi-preview2](platform-support/wasm32-wasi-preview2.md)
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)
- [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md)
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)

View File

@ -360,6 +360,7 @@ target | std | host | notes
`thumbv7a-pc-windows-msvc` | ? | |
`thumbv7a-uwp-windows-msvc` | ✓ | |
`thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode ARMv7-A Linux with NEON, MUSL
[`wasm32-wasi-preview2`](platform-support/wasm32-wasi-preview2.md) | ✓ | | WebAssembly
[`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly
`x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64
[`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ? | | x86 64-bit tvOS

View File

@ -0,0 +1,30 @@
# `wasm32-wasi-preview2`
**Tier: 3**
The `wasm32-wasi-preview2` target is a new and still (as of January 2024) an
experimental target. This target is an extension to `wasm32-wasi-preview1` target,
originally known as `wasm32-wasi`. It is the next evolution in the development of
wasi (the [WebAssembly System Interface](https://wasi.dev)) that uses the WebAssembly
[component model] to allow for a standardized set of syscalls that are intended to empower
WebAssembly binaries with native host capabilities.
[component model]: https://github.com/WebAssembly/component-model
## Target maintainers
- Alex Crichton, https://github.com/alexcrichton
- Ryan Levick, https://github.com/rylev
## Requirements
This target is cross-compiled. The target supports `std` fully.
## Platform requirements
The WebAssembly runtime should support the wasi preview 2 API set.
This target is not a stable target. This means that there are only a few engines
which implement wasi preview 2, for example:
* Wasmtime - `-W component-model`

View File

@ -36,6 +36,10 @@ For a full history of changes in the Rust 2024 style edition, see the git
history of the style guide. Notable changes in the Rust 2024 style edition
include:
- [#114764](https://github.com/rust-lang/rust/pull/114764) As the last member
of a delimited expression, delimited expressions are generally combinable,
regardless of the number of members. Previously only applied with exactly
one member (except for closures with explicit blocks).
- Miscellaneous `rustfmt` bugfixes.
- Use version-sort (sort `x8`, `x16`, `x32`, `x64`, `x128` in that order).
- Change "ASCIIbetical" sort to Unicode-aware "non-lowercase before lowercase".

View File

@ -818,11 +818,11 @@ E.g., `&&Some(foo)` matches, `Foo(4, Bar)` does not.
## Combinable expressions
Where a function call has a single argument, and that argument is formatted
across multiple-lines, format the outer call as if it were a single-line call,
When the last argument in a function call is formatted across
multiple-lines, format the outer call as if it were a single-line call,
if the result fits. Apply the same combining behaviour to any similar
expressions which have multi-line, block-indented lists of sub-expressions
delimited by parentheses (e.g., macros or tuple struct literals). E.g.,
delimited by parentheses, brackets, or braces. E.g.,
```rust
foo(bar(
@ -848,20 +848,61 @@ let arr = [combinable(
an_expr,
another_expr,
)];
let x = Thing(an_expr, another_expr, match cond {
A => 1,
B => 2,
});
let x = format!("Stuff: {}", [
an_expr,
another_expr,
]);
let x = func(an_expr, another_expr, SomeStruct {
field: this_is_long,
another_field: 123,
});
```
Apply this behavior recursively.
For a function with multiple arguments, if the last argument is a multi-line
closure with an explicit block, there are no other closure arguments, and all
the arguments and the first line of the closure fit on the first line, use the
same combining behavior:
If the last argument is a multi-line closure with an explicit block,
only apply the combining behavior if there are no other closure arguments.
```rust
// Combinable
foo(first_arg, x, |param| {
action();
foo(param)
})
// Not combinable, because the closure is not the last argument
foo(
first_arg,
|param| {
action();
foo(param)
},
whatever,
)
// Not combinable, because the first line of the closure does not fit
foo(
first_arg,
x,
move |very_long_param_causing_line_to_overflow| -> Bar {
action();
foo(param)
},
)
// Not combinable, because there is more than one closure argument
foo(
first_arg,
|x| x.bar(),
|param| {
action();
foo(param)
},
)
```
## Ranges

View File

@ -1109,9 +1109,6 @@ fn ignore_lldb(config: &Config, line: &str) -> IgnoreDecision {
}
fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
if config.system_llvm && line.starts_with("no-system-llvm") {
return IgnoreDecision::Ignore { reason: "ignored when the system LLVM is used".into() };
}
if let Some(needed_components) =
config.parse_name_value_directive(line, "needs-llvm-components")
{

View File

@ -242,15 +242,6 @@ fn aux_build() {
);
}
#[test]
fn no_system_llvm() {
let config: Config = cfg().system_llvm(false).build();
assert!(!check_ignore(&config, "// no-system-llvm"));
let config: Config = cfg().system_llvm(true).build();
assert!(check_ignore(&config, "// no-system-llvm"));
}
#[test]
fn llvm_version() {
let config: Config = cfg().llvm_version("8.1.2").build();
@ -266,6 +257,18 @@ fn llvm_version() {
assert!(!check_ignore(&config, "// min-llvm-version: 9.0"));
}
#[test]
fn system_llvm_version() {
let config: Config = cfg().system_llvm(true).llvm_version("17.0.0").build();
assert!(check_ignore(&config, "// min-system-llvm-version: 18.0"));
let config: Config = cfg().system_llvm(true).llvm_version("18.0.0").build();
assert!(!check_ignore(&config, "// min-system-llvm-version: 18.0"));
let config: Config = cfg().llvm_version("17.0.0").build();
assert!(!check_ignore(&config, "// min-system-llvm-version: 18.0"));
}
#[test]
fn ignore_target() {
let config: Config = cfg().target("x86_64-unknown-linux-gnu").build();

View File

@ -534,6 +534,9 @@
// revisions: wasm64_unknown_unknown
// [wasm64_unknown_unknown] compile-flags: --target wasm64-unknown-unknown
// [wasm64_unknown_unknown] needs-llvm-components: webassembly
// revisions: wasm32_wasi_preview2
// [wasm32_wasi_preview2] compile-flags: --target wasm32-wasi-preview2
// [wasm32_wasi_preview2] needs-llvm-components: webassembly
// revisions: x86_64_apple_darwin
// [x86_64_apple_darwin] compile-flags: --target x86_64-apple-darwin
// [x86_64_apple_darwin] needs-llvm-components: x86

View File

@ -1,5 +1,3 @@
//
// no-system-llvm
// compile-flags: -O
#![crate_type = "lib"]

View File

@ -1,5 +1,4 @@
// compile-flags: -C opt-level=3 -C target-cpu=x86-64-v3
// no-system-llvm
// only-x86_64
// ignore-debug (the extra assertions get in the way)
@ -10,7 +9,7 @@
pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] {
// CHECK: load <8 x i32>
// CHECK: shl <8 x i32>
// CHECK: or <8 x i32>
// CHECK: or{{( disjoint)?}} <8 x i32>
// CHECK: store <8 x i32>
x.map(|x| 2 * x + 1)
}

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O
#![crate_type="lib"]

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -Coverflow-checks=no -O
// revisions: YES NO
// [YES]compile-flags: -Zfewer-names=yes

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O -C overflow-checks=on
#![crate_type = "lib"]

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O
// ignore-debug: the debug assertions get in the way
#![crate_type = "lib"]

View File

@ -1,6 +1,5 @@
//
// only-macos
// no-system-llvm
// compile-flags: -O
#![crate_type = "rlib"]

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O
// ignore-debug: the debug assertions get in the way
#![crate_type = "lib"]

View File

@ -1,5 +1,4 @@
//
// no-system-llvm
// compile-flags: -O
#![crate_type="lib"]

View File

@ -1,5 +1,4 @@
// compile-flags: -O -Z merge-functions=disabled
// no-system-llvm
// ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"]

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O
// only-64bit (because the LLVM type of i64 for usize shows up)
// ignore-debug: the debug assertions get in the way

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O
// ignore-debug: the debug assertions add extra comparisons
#![crate_type = "lib"]

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O
// ignore-debug (these add extra checks that make it hard to verify)
#![crate_type = "lib"]

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -O -C panic=abort
#![crate_type = "lib"]

View File

@ -1,5 +1,4 @@
// ignore-debug: the debug assertions get in the way
// no-system-llvm
// compile-flags: -O
#![crate_type="lib"]

View File

@ -1,5 +1,4 @@
// ignore-debug: the debug assertions get in the way
// no-system-llvm
// compile-flags: -O
#![crate_type = "lib"]

View File

@ -34,8 +34,7 @@ $DIR/doctest.rs:
LL| |//!
LL| |//! doctest returning a result:
LL| 1|//! ```
LL| 2|//! #[derive(Debug, PartialEq)]
^1
LL| 1|//! #[derive(Debug, PartialEq)]
LL| 1|//! struct SomeError {
LL| 1|//! msg: String,
LL| 1|//! }
@ -63,7 +62,7 @@ $DIR/doctest.rs:
LL| 1|//! println!("called some_func()");
LL| 1|//! }
LL| |//!
LL| 0|//! #[derive(Debug)]
LL| |//! #[derive(Debug)]
LL| |//! struct SomeError;
LL| |//!
LL| |//! extern crate doctest_crate;

View File

@ -1,19 +1,3 @@
Function name: <bad_counter_ids::Foo as core::cmp::PartialEq>::eq
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 11, 00, 1a]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 12, 17) to (start + 0, 26)
Function name: <bad_counter_ids::Foo as core::fmt::Debug>::fmt
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 0a, 00, 0f]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 12, 10) to (start + 0, 15)
Function name: bad_counter_ids::eq_bad
Raw bytes (14): 0x[01, 01, 00, 02, 01, 23, 01, 02, 1f, 00, 03, 01, 00, 02]
Number of files: 1

View File

@ -9,7 +9,7 @@
LL| |// a too-large counter ID and silently discard the entire function from its
LL| |// coverage reports.
LL| |
LL| 8|#[derive(Debug, PartialEq, Eq)]
LL| |#[derive(Debug, PartialEq, Eq)]
LL| |struct Foo(u32);
LL| |
LL| 1|fn eq_good() {

View File

@ -1,19 +1,3 @@
Function name: <issue_83601::Foo as core::cmp::PartialEq>::eq
Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 11, 00, 1a]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 3, 17) to (start + 0, 26)
Function name: <issue_83601::Foo as core::fmt::Debug>::fmt
Raw bytes (9): 0x[01, 01, 00, 01, 01, 03, 0a, 00, 0f]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 3, 10) to (start + 0, 15)
Function name: issue_83601::main
Raw bytes (21): 0x[01, 01, 01, 05, 09, 03, 01, 06, 01, 02, 1c, 05, 03, 09, 01, 1c, 02, 02, 05, 03, 02]
Number of files: 1

View File

@ -1,7 +1,6 @@
LL| |// Shows that rust-lang/rust/83601 is resolved
LL| |
LL| 3|#[derive(Debug, PartialEq, Eq)]
^2
LL| |#[derive(Debug, PartialEq, Eq)]
LL| |struct Foo(u32);
LL| |
LL| 1|fn main() {

View File

@ -1,11 +1,3 @@
Function name: <issue_84561::Foo as core::cmp::PartialEq>::eq
Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 0a, 00, 13]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 4, 10) to (start + 0, 19)
Function name: <issue_84561::Foo as core::fmt::Debug>::fmt
Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 8a, 01, 05, 01, 25, 05, 01, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06]
Number of files: 1

View File

@ -1,7 +1,7 @@
LL| |// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
LL| |
LL| |// failure-status: 101
LL| 21|#[derive(PartialEq, Eq)]
LL| |#[derive(PartialEq, Eq)]
LL| |struct Foo(u32);
LL| |
LL| |#[rustfmt::skip]

View File

@ -1,51 +1,3 @@
Function name: <partial_eq::Version as core::clone::Clone>::clone (unused)
Raw bytes (9): 0x[01, 01, 00, 01, 00, 04, 0a, 00, 0f]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Zero) at (prev + 4, 10) to (start + 0, 15)
Function name: <partial_eq::Version as core::cmp::Ord>::cmp (unused)
Raw bytes (14): 0x[01, 01, 00, 02, 00, 04, 33, 00, 34, 00, 00, 35, 00, 36]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Zero) at (prev + 4, 51) to (start + 0, 52)
- Code(Zero) at (prev + 0, 53) to (start + 0, 54)
Function name: <partial_eq::Version as core::cmp::PartialEq>::eq (unused)
Raw bytes (14): 0x[01, 01, 00, 02, 00, 04, 18, 00, 19, 00, 00, 20, 00, 21]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Zero) at (prev + 4, 24) to (start + 0, 25)
- Code(Zero) at (prev + 0, 32) to (start + 0, 33)
Function name: <partial_eq::Version as core::cmp::PartialOrd>::partial_cmp
Raw bytes (22): 0x[01, 01, 04, 07, 0b, 00, 09, 0f, 15, 00, 11, 02, 01, 04, 27, 00, 28, 03, 00, 30, 00, 31]
Number of files: 1
- file 0 => global file 1
Number of expressions: 4
- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add)
- expression 1 operands: lhs = Zero, rhs = Counter(2)
- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(5)
- expression 3 operands: lhs = Zero, rhs = Counter(4)
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 4, 39) to (start + 0, 40)
- Code(Expression(0, Add)) at (prev + 0, 48) to (start + 0, 49)
= ((Zero + c2) + ((Zero + c4) + c5))
Function name: <partial_eq::Version as core::fmt::Debug>::fmt
Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 11, 00, 16]
Number of files: 1
- file 0 => global file 1
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 4, 17) to (start + 0, 22)
Function name: <partial_eq::Version>::new
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 05, 06, 06]
Number of files: 1

View File

@ -1,8 +1,7 @@
LL| |// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the
LL| |// structure of this test.
LL| |
LL| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
^0 ^0 ^0 ^1 ^1 ^0^0
LL| |#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
LL| |pub struct Version {
LL| | major: usize,
LL| | minor: usize,

View File

@ -1,7 +1,6 @@
// only-x86_64
// compile-flags:--test
// should-fail
// no-system-llvm
// #49723: rustdoc didn't add target features when extracting or running doctests

View File

@ -6,7 +6,7 @@ LL | let headers = [Header{value: &[]}; 128];
|
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Header<'_>` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]
@ -21,7 +21,7 @@ LL | let headers = [Header{value: &[0]}; 128];
|
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Header<'_>` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]

View File

@ -125,7 +125,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_env = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_env` are: ``, `eabihf`, `gnu`, `gnueabihf`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `psx`, `relibc`, `sgx`, `uclibc`
= note: expected values for `target_env` are: ``, `eabihf`, `gnu`, `gnueabihf`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `preview2`, `psx`, `relibc`, `sgx`, `uclibc`
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
@ -134,7 +134,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_family = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expected values for `target_family` are: `unix`, `wasm`, `windows`
= note: expected values for `target_family` are: `unix`, `wasi`, `wasm`, `windows`
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`

View File

@ -6,7 +6,7 @@ LL | [x; { N }]
|
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider restricting type parameter `T`
|
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {

View File

@ -6,7 +6,7 @@ LL | [x; N]
|
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider restricting type parameter `T`
|
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {

View File

@ -7,7 +7,7 @@ LL | let arr: [Option<Bar>; 2] = [x; 2];
= note: required for `Option<Bar>` to implement `Copy`
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Bar` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]
@ -23,7 +23,7 @@ LL | let arr: [Option<Bar>; 2] = [x; 2];
= note: required for `Option<Bar>` to implement `Copy`
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Bar` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]

View File

@ -7,7 +7,7 @@ LL | let arr: [Option<Bar>; 2] = [x; 2];
= note: required for `Option<Bar>` to implement `Copy`
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Bar` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]
@ -23,7 +23,7 @@ LL | let arr: [Option<Bar>; 2] = [x; 2];
= note: required for `Option<Bar>` to implement `Copy`
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Bar` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]

View File

@ -2,7 +2,6 @@
// LLVM bug which needed a fix to be backported.
// run-pass
// no-system-llvm
fn main() {
let buffer = [49u8, 10];

View File

@ -1,4 +1,3 @@
// no-system-llvm
// compile-flags: -C opt-level=3
// aux-build: issue-76387.rs
// run-pass

View File

@ -26,6 +26,7 @@ type A = <m::Alias as m::Trait>::X; //~ ERROR type `Priv` is private
trait Tr2<T> {}
impl<T> Tr2<T> for u8 {}
fn g() -> impl Tr2<m::Alias> { 0 } //~ ERROR type `Priv` is private
//~| ERROR type `Priv` is private
fn g_ext() -> impl Tr2<ext::Alias> { 0 } //~ ERROR type `ext::Priv` is private
//~| ERROR type `ext::Priv` is private
fn main() {}

View File

@ -46,11 +46,23 @@ error: type `Priv` is private
LL | fn g() -> impl Tr2<m::Alias> { 0 }
| ^^^^^^^^^^^^^^^^^^ private type
error: type `Priv` is private
--> $DIR/private-type-in-interface.rs:28:16
|
LL | fn g() -> impl Tr2<m::Alias> { 0 }
| ^^^^^^^^^^^^^ private type
error: type `ext::Priv` is private
--> $DIR/private-type-in-interface.rs:29:15
--> $DIR/private-type-in-interface.rs:30:15
|
LL | fn g_ext() -> impl Tr2<ext::Alias> { 0 }
| ^^^^^^^^^^^^^^^^^^^^ private type
error: aborting due to 9 previous errors
error: type `ext::Priv` is private
--> $DIR/private-type-in-interface.rs:30:20
|
LL | fn g_ext() -> impl Tr2<ext::Alias> { 0 }
| ^^^^^^^^^^^^^^^ private type
error: aborting due to 11 previous errors

View File

@ -6,7 +6,7 @@ LL | let _ = [ a; 5 ];
|
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
help: consider annotating `Foo` with `#[derive(Copy)]`
|
LL + #[derive(Copy)]

View File

@ -6,7 +6,7 @@ LL | let string_arr = [foo(); 64];
|
= note: the `Copy` trait is required because this value will be copied for each element of the array
= help: consider using `core::array::from_fn` to initialize the array
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html# for more information
= help: see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information
error: aborting due to 1 previous error

View File

@ -646,6 +646,7 @@ compiler-team = [
"@estebank",
"@oli-obk",
"@wesleywiser",
"@michaelwoerister",
]
compiler-team-contributors = [
"@TaKO8Ki",
@ -738,6 +739,10 @@ ast_lowering = [
"@estebank",
"@spastorino",
]
debuginfo = [
"@michaelwoerister",
"@davidtwco"
]
fallback = [
"@Mark-Simulacrum"
]
@ -761,66 +766,71 @@ project-stable-mir = [
]
[assign.owners]
"/.github/workflows" = ["infra-ci"]
"/Cargo.lock" = ["@Mark-Simulacrum"]
"/Cargo.toml" = ["@Mark-Simulacrum"]
"/compiler" = ["compiler"]
"/compiler/rustc_arena" = ["compiler", "arena"]
"/compiler/rustc_ast" = ["compiler", "parser"]
"/compiler/rustc_ast_lowering" = ["compiler", "ast_lowering"]
"/compiler/rustc_hir_analysis" = ["compiler", "types"]
"/compiler/rustc_lexer" = ["compiler", "lexer"]
"/compiler/rustc_llvm" = ["@cuviper"]
"/compiler/rustc_middle/src/mir" = ["compiler", "mir"]
"/compiler/rustc_middle/src/traits" = ["compiler", "types"]
"/compiler/rustc_middle/src/ty" = ["compiler", "types"]
"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"]
"/compiler/rustc_const_eval/src/transform" = ["compiler", "mir-opt"]
"/compiler/rustc_mir_build/src/build" = ["compiler", "mir"]
"/compiler/rustc_smir" = ["project-stable-mir"]
"/compiler/rustc_parse" = ["compiler", "parser"]
"/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"]
"/compiler/rustc_query_impl" = ["compiler", "query-system"]
"/compiler/rustc_query_system" = ["compiler", "query-system"]
"/compiler/rustc_trait_selection" = ["compiler", "types"]
"/compiler/rustc_traits" = ["compiler", "types"]
"/compiler/rustc_type_ir" = ["compiler", "types"]
"/compiler/stable_mir" = ["project-stable-mir"]
"/library/alloc" = ["libs"]
"/library/core" = ["libs"]
"/library/panic_abort" = ["libs"]
"/library/panic_unwind" = ["libs"]
"/library/proc_macro" = ["@petrochenkov"]
"/library/std" = ["libs"]
"/library/std/src/sys/pal/windows" = ["@ChrisDenton", "@thomcc"]
"/library/stdarch" = ["libs"]
"/library/test" = ["libs"]
"/src/bootstrap" = ["bootstrap"]
"/src/ci" = ["infra-ci"]
"/src/doc" = ["docs"]
"/src/doc/book" = ["@ehuss"]
"/src/doc/edition-guide" = ["@ehuss"]
"/src/doc/embedded-book" = ["@ehuss"]
"/src/doc/nomicon" = ["@ehuss"]
"/src/doc/reference" = ["@ehuss"]
"/src/doc/rust-by-example" = ["@ehuss"]
"/src/doc/rustc-dev-guide" = ["@ehuss"]
"/src/doc/rustdoc" = ["rustdoc"]
"/src/doc/style-guide" = ["style-team"]
"/src/etc" = ["@Mark-Simulacrum"]
"/src/librustdoc" = ["rustdoc"]
"/src/llvm-project" = ["@cuviper"]
"/src/rustdoc-json-types" = ["rustdoc"]
"/src/stage0.json" = ["bootstrap"]
"/tests/ui" = ["compiler"]
"/src/tools/cargo" = ["@ehuss", "@joshtriplett"]
"/src/tools/compiletest" = ["bootstrap", "@wesleywiser", "@oli-obk", "@compiler-errors"]
"/src/tools/linkchecker" = ["@ehuss"]
"/src/tools/rust-installer" = ["bootstrap"]
"/src/tools/rustbook" = ["@ehuss"]
"/src/tools/rustdoc" = ["rustdoc"]
"/src/tools/rustdoc-js" = ["rustdoc"]
"/src/tools/rustdoc-themes" = ["rustdoc"]
"/src/tools/tidy" = ["bootstrap"]
"/src/tools/x" = ["bootstrap"]
"/src/tools/rustdoc-gui-test" = ["bootstrap", "@onur-ozkan"]
"/.github/workflows" = ["infra-ci"]
"/Cargo.lock" = ["@Mark-Simulacrum"]
"/Cargo.toml" = ["@Mark-Simulacrum"]
"/compiler" = ["compiler"]
"/compiler/rustc_arena" = ["compiler", "arena"]
"/compiler/rustc_ast" = ["compiler", "parser"]
"/compiler/rustc_ast_lowering" = ["compiler", "ast_lowering"]
"/compiler/rustc_data_structures/src/stable_hasher.rs" = ["compiler", "incremental"]
"/compiler/rustc_hir_analysis" = ["compiler", "types"]
"/compiler/rustc_incremental" = ["compiler", "incremental"]
"/compiler/rustc_lexer" = ["compiler", "lexer"]
"/compiler/rustc_llvm" = ["@cuviper"]
"/compiler/rustc_codegen_llvm/src/debuginfo" = ["compiler", "debuginfo"]
"/compiler/rustc_middle/src/mir" = ["compiler", "mir"]
"/compiler/rustc_middle/src/traits" = ["compiler", "types"]
"/compiler/rustc_middle/src/ty" = ["compiler", "types"]
"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"]
"/compiler/rustc_const_eval/src/transform" = ["compiler", "mir-opt"]
"/compiler/rustc_mir_build/src/build" = ["compiler", "mir"]
"/compiler/rustc_smir" = ["project-stable-mir"]
"/compiler/rustc_parse" = ["compiler", "parser"]
"/compiler/rustc_parse/src/lexer" = ["compiler", "lexer"]
"/compiler/rustc_query_impl" = ["compiler", "query-system"]
"/compiler/rustc_query_system" = ["compiler", "query-system"]
"/compiler/rustc_query_system/src/dep_graph" = ["compiler", "incremental", "query-system"]
"/compiler/rustc_query_system/src/ich" = ["compiler", "incremental", "query-system"]
"/compiler/rustc_trait_selection" = ["compiler", "types"]
"/compiler/rustc_traits" = ["compiler", "types"]
"/compiler/rustc_type_ir" = ["compiler", "types"]
"/compiler/stable_mir" = ["project-stable-mir"]
"/library/alloc" = ["libs"]
"/library/core" = ["libs"]
"/library/panic_abort" = ["libs"]
"/library/panic_unwind" = ["libs"]
"/library/proc_macro" = ["@petrochenkov"]
"/library/std" = ["libs"]
"/library/std/src/sys/pal/windows" = ["@ChrisDenton", "@thomcc"]
"/library/stdarch" = ["libs"]
"/library/test" = ["libs"]
"/src/bootstrap" = ["bootstrap"]
"/src/ci" = ["infra-ci"]
"/src/doc" = ["docs"]
"/src/doc/book" = ["@ehuss"]
"/src/doc/edition-guide" = ["@ehuss"]
"/src/doc/embedded-book" = ["@ehuss"]
"/src/doc/nomicon" = ["@ehuss"]
"/src/doc/reference" = ["@ehuss"]
"/src/doc/rust-by-example" = ["@ehuss"]
"/src/doc/rustc-dev-guide" = ["@ehuss"]
"/src/doc/rustdoc" = ["rustdoc"]
"/src/doc/style-guide" = ["style-team"]
"/src/etc" = ["@Mark-Simulacrum"]
"/src/librustdoc" = ["rustdoc"]
"/src/llvm-project" = ["@cuviper"]
"/src/rustdoc-json-types" = ["rustdoc"]
"/src/stage0.json" = ["bootstrap"]
"/tests/ui" = ["compiler"]
"/src/tools/cargo" = ["@ehuss", "@joshtriplett"]
"/src/tools/compiletest" = ["bootstrap", "@wesleywiser", "@oli-obk", "@compiler-errors"]
"/src/tools/linkchecker" = ["@ehuss"]
"/src/tools/rust-installer" = ["bootstrap"]
"/src/tools/rustbook" = ["@ehuss"]
"/src/tools/rustdoc" = ["rustdoc"]
"/src/tools/rustdoc-js" = ["rustdoc"]
"/src/tools/rustdoc-themes" = ["rustdoc"]
"/src/tools/tidy" = ["bootstrap"]
"/src/tools/x" = ["bootstrap"]
"/src/tools/rustdoc-gui-test" = ["bootstrap", "@onur-ozkan"]