Auto merge of #136954 - jhpratt:rollup-koefsot, r=jhpratt

Rollup of 12 pull requests

Successful merges:

 - #134090 (Stabilize target_feature_11)
 - #135025 (Cast allocas to default address space)
 - #135841 (Reject `?Trait` bounds in various places where we unconditionally warned since 1.0)
 - #136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly)
 - #136699 (std: replace the `FromInner` implementation for addresses with private conversion functions)
 - #136806 (Fix cycle when debug-printing opaque types from RPITIT)
 - #136807 (compiler: internally merge `PtxKernel` into `GpuKernel`)
 - #136818 (Implement `read*_exact` for `std:io::repeat`)
 - #136927 (Correctly escape hashtags when running `invalid_rust_codeblocks` lint)
 - #136937 (Update books)
 - #136945 (Add diagnostic item for `std::io::BufRead`)
 - #136947 (Reinstate nnethercote in the review rotation.)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-02-13 02:13:24 +00:00
commit 9fcc9cf4a2
91 changed files with 473 additions and 652 deletions

View file

@ -65,11 +65,7 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
sess.dcx().fatal("C-cmse-nonsecure-entry call conv is not yet implemented");
}
Conv::Msp430Intr
| Conv::PtxKernel
| Conv::GpuKernel
| Conv::AvrInterrupt
| Conv::AvrNonBlockingInterrupt => {
Conv::Msp430Intr | Conv::GpuKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
}
}

View file

@ -687,7 +687,6 @@ impl llvm::CallConv {
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
Conv::Msp430Intr => llvm::Msp430Intr,
Conv::PtxKernel => llvm::PtxKernel,
Conv::X86Fastcall => llvm::X86FastcallCallConv,
Conv::X86Intr => llvm::X86_Intr,
Conv::X86Stdcall => llvm::X86StdcallCallConv,

View file

@ -286,7 +286,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
InlineAsmArch::M68k => {
constraints.push("~{ccr}".to_string());
}
InlineAsmArch::CSKY => {}
InlineAsmArch::CSKY => {
constraints.push("~{psr}".to_string());
}
}
}
if !options.contains(InlineAsmOptions::NOMEM) {

View file

@ -543,7 +543,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
unsafe {
let alloca = llvm::LLVMBuildAlloca(bx.llbuilder, ty, UNNAMED);
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
alloca
// Cast to default addrspace if necessary
llvm::LLVMBuildPointerCast(bx.llbuilder, alloca, self.cx().type_ptr(), UNNAMED)
}
}
@ -552,7 +553,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
let alloca =
llvm::LLVMBuildArrayAlloca(self.llbuilder, self.cx().type_i8(), size, UNNAMED);
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
alloca
// Cast to default addrspace if necessary
llvm::LLVMBuildPointerCast(self.llbuilder, alloca, self.cx().type_ptr(), UNNAMED)
}
}

View file

@ -272,10 +272,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
if safe_target_features {
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
// The `#[target_feature]` attribute is allowed on
// WebAssembly targets on all functions, including safe
// ones. Other targets require that `#[target_feature]` is
// only applied to unsafe functions (pending the
// `target_feature_11` feature) because on most targets
// WebAssembly targets on all functions. Prior to stabilizing
// the `target_feature_11` feature, `#[target_feature]` was
// only permitted on unsafe functions because on most targets
// execution of instructions that are not supported is
// considered undefined behavior. For WebAssembly which is a
// 100% safe target at execution time it's not possible to
@ -289,17 +288,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
// if a target is documenting some wasm-specific code then
// it's not spuriously denied.
//
// This exception needs to be kept in sync with allowing
// `#[target_feature]` on `main` and `start`.
} else if !tcx.features().target_feature_11() {
feature_err(
&tcx.sess,
sym::target_feature_11,
attr.span,
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
)
.with_span_label(tcx.def_span(did), "not an `unsafe` function")
.emit();
// Now that `#[target_feature]` is permitted on safe functions,
// this exception must still exist for allowing the attribute on
// `main`, `start`, and other functions that are not usually
// allowed.
} else {
check_target_feature_trait_unsafe(tcx, did, attr.span);
}
@ -628,10 +620,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
// its parent function, which effectively inherits the features anyway. Boxing this closure
// would result in this closure being compiled without the inherited target features, but this
// is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
if tcx.features().target_feature_11()
&& tcx.is_closure_like(did.to_def_id())
&& !codegen_fn_attrs.inline.always()
{
if tcx.is_closure_like(did.to_def_id()) && codegen_fn_attrs.inline != InlineAttr::Always {
let owner_id = tcx.parent(did.to_def_id());
if tcx.def_kind(owner_id).has_codegen_attrs() {
codegen_fn_attrs

View file

@ -386,6 +386,8 @@ declare_features! (
(accepted, struct_variant, "1.0.0", None),
/// Allows `#[target_feature(...)]`.
(accepted, target_feature, "1.27.0", None),
/// Allows the use of `#[target_feature]` on safe functions.
(accepted, target_feature_11, "CURRENT_RUSTC_VERSION", Some(69098)),
/// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
(accepted, termination_trait, "1.26.0", Some(43301)),
/// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).

View file

@ -633,8 +633,6 @@ declare_features! (
(unstable, strict_provenance_lints, "1.61.0", Some(130351)),
/// Allows string patterns to dereference values to match them.
(unstable, string_deref_patterns, "1.67.0", Some(87121)),
/// Allows the use of `#[target_feature]` on safe functions.
(unstable, target_feature_11, "1.45.0", Some(69098)),
/// Allows using `#[thread_local]` on `static` items.
(unstable, thread_local, "1.0.0", Some(29594)),
/// Allows defining `trait X = A + B;` alias items.

View file

@ -30,53 +30,55 @@ fn associated_type_bounds<'tcx>(
span: Span,
filter: PredicateFilter,
) -> &'tcx [(ty::Clause<'tcx>, Span)] {
let item_ty = Ty::new_projection_from_args(
tcx,
assoc_item_def_id.to_def_id(),
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
);
ty::print::with_reduced_queries!({
let item_ty = Ty::new_projection_from_args(
tcx,
assoc_item_def_id.to_def_id(),
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
);
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
let mut bounds = Bounds::default();
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
// Associated types are implicitly sized unless a `?Sized` bound is found
match filter {
PredicateFilter::All
| PredicateFilter::SelfOnly
| PredicateFilter::SelfTraitThatDefines(_)
| PredicateFilter::SelfAndAssociatedTypeBounds => {
icx.lowerer().add_sized_bound(&mut bounds, item_ty, hir_bounds, None, span);
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
let mut bounds = Bounds::default();
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
// Associated types are implicitly sized unless a `?Sized` bound is found
match filter {
PredicateFilter::All
| PredicateFilter::SelfOnly
| PredicateFilter::SelfTraitThatDefines(_)
| PredicateFilter::SelfAndAssociatedTypeBounds => {
icx.lowerer().add_sized_bound(&mut bounds, item_ty, hir_bounds, None, span);
}
// `ConstIfConst` is only interested in `~const` bounds.
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
}
// `ConstIfConst` is only interested in `~const` bounds.
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
}
let trait_def_id = tcx.local_parent(assoc_item_def_id);
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
let trait_def_id = tcx.local_parent(assoc_item_def_id);
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id()));
let bounds_from_parent =
trait_predicates.predicates.iter().copied().filter_map(|(clause, span)| {
remap_gat_vars_and_recurse_into_nested_projections(
tcx,
filter,
item_trait_ref,
assoc_item_def_id,
span,
clause,
)
});
let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id()));
let bounds_from_parent =
trait_predicates.predicates.iter().copied().filter_map(|(clause, span)| {
remap_gat_vars_and_recurse_into_nested_projections(
tcx,
filter,
item_trait_ref,
assoc_item_def_id,
span,
clause,
)
});
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
debug!(
"associated_type_bounds({}) = {:?}",
tcx.def_path_str(assoc_item_def_id.to_def_id()),
all_bounds
);
assert_only_contains_predicates_from(filter, all_bounds, item_ty);
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
debug!(
"associated_type_bounds({}) = {:?}",
tcx.def_path_str(assoc_item_def_id.to_def_id()),
all_bounds
);
assert_only_contains_predicates_from(filter, all_bounds, item_ty);
all_bounds
})
}
/// The code below is quite involved, so let me explain.

View file

@ -102,8 +102,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
seen_sized_unbound = true;
continue;
}
// There was a `?Trait` bound, but it was not `?Sized`; warn.
self.dcx().span_warn(
// There was a `?Trait` bound, but it was not `?Sized`
self.dcx().span_err(
unbound.span,
"relaxing a default bound only does something for `?Sized`; \
all other traits are not bound by default",

View file

@ -105,7 +105,6 @@ impl<'tcx> Stable<'tcx> for callconv::Conv {
Conv::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall,
Conv::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry,
Conv::Msp430Intr => CallConvention::Msp430Intr,
Conv::PtxKernel => CallConvention::PtxKernel,
Conv::X86Fastcall => CallConvention::X86Fastcall,
Conv::X86Intr => CallConvention::X86Intr,
Conv::X86Stdcall => CallConvention::X86Stdcall,

View file

@ -250,6 +250,7 @@ symbols! {
Into,
IntoFuture,
IntoIterator,
IoBufRead,
IoLines,
IoRead,
IoSeek,

View file

@ -542,8 +542,6 @@ pub enum Conv {
Msp430Intr,
PtxKernel,
GpuKernel,
X86Fastcall,
@ -689,7 +687,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
"sparc" => sparc::compute_abi_info(cx, self),
"sparc64" => sparc64::compute_abi_info(cx, self),
"nvptx64" => {
if cx.target_spec().adjust_abi(abi, self.c_variadic) == ExternAbi::PtxKernel {
let abi = cx.target_spec().adjust_abi(abi, self.c_variadic);
if abi == ExternAbi::PtxKernel || abi == ExternAbi::GpuKernel {
nvptx64::compute_ptx_kernel_abi_info(cx, self)
} else {
nvptx64::compute_abi_info(self)
@ -841,7 +840,6 @@ impl FromStr for Conv {
"CCmseNonSecureCall" => Ok(Conv::CCmseNonSecureCall),
"CCmseNonSecureEntry" => Ok(Conv::CCmseNonSecureEntry),
"Msp430Intr" => Ok(Conv::Msp430Intr),
"PtxKernel" => Ok(Conv::PtxKernel),
"X86Fastcall" => Ok(Conv::X86Fastcall),
"X86Intr" => Ok(Conv::X86Intr),
"X86Stdcall" => Ok(Conv::X86Stdcall),

View file

@ -105,7 +105,6 @@ impl ToJson for crate::callconv::Conv {
Self::CCmseNonSecureCall => "CCmseNonSecureCall",
Self::CCmseNonSecureEntry => "CCmseNonSecureEntry",
Self::Msp430Intr => "Msp430Intr",
Self::PtxKernel => "PtxKernel",
Self::X86Fastcall => "X86Fastcall",
Self::X86Intr => "X86Intr",
Self::X86Stdcall => "X86Stdcall",

View file

@ -290,7 +290,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv
Aapcs { .. } => Conv::ArmAapcs,
CCmseNonSecureCall => Conv::CCmseNonSecureCall,
CCmseNonSecureEntry => Conv::CCmseNonSecureEntry,
PtxKernel => Conv::PtxKernel,
PtxKernel => Conv::GpuKernel,
Msp430Interrupt => Conv::Msp430Intr,
X86Interrupt => Conv::X86Intr,
GpuKernel => Conv::GpuKernel,

View file

@ -192,7 +192,6 @@
#![feature(staged_api)]
#![feature(stmt_expr_attributes)]
#![feature(strict_provenance_lints)]
#![feature(target_feature_11)]
#![feature(trait_alias)]
#![feature(transparent_unions)]
#![feature(try_blocks)]

View file

@ -2249,6 +2249,7 @@ fn skip_until<R: BufRead + ?Sized>(r: &mut R, delim: u8) -> Result<usize> {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "IoBufRead")]
pub trait BufRead: Read {
/// Returns the contents of the internal buffer, filling it with more data
/// from the inner reader if it is empty.

View file

@ -188,6 +188,13 @@ impl Read for Repeat {
Ok(buf.len())
}
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
for slot in &mut *buf {
*slot = self.byte;
}
Ok(())
}
fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> {
// SAFETY: No uninit bytes are being written
for slot in unsafe { buf.as_mut() } {
@ -204,6 +211,10 @@ impl Read for Repeat {
Ok(())
}
fn read_buf_exact(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
self.read_buf(buf)
}
/// This function is not supported by `io::Repeat`, because there's no end of its data
fn read_to_end(&mut self, _: &mut Vec<u8>) -> io::Result<usize> {
Err(io::Error::from(io::ErrorKind::OutOfMemory))

View file

@ -8,32 +8,3 @@ pub use core::net::IpAddr;
pub use core::net::Ipv6MulticastScope;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::net::{Ipv4Addr, Ipv6Addr};
use crate::sys::net::netc as c;
use crate::sys_common::{FromInner, IntoInner};
impl IntoInner<c::in_addr> for Ipv4Addr {
#[inline]
fn into_inner(self) -> c::in_addr {
// `s_addr` is stored as BE on all machines and the array is in BE order.
// So the native endian conversion method is used so that it's never swapped.
c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) }
}
}
impl FromInner<c::in_addr> for Ipv4Addr {
fn from_inner(addr: c::in_addr) -> Ipv4Addr {
Ipv4Addr::from(addr.s_addr.to_ne_bytes())
}
}
impl IntoInner<c::in6_addr> for Ipv6Addr {
fn into_inner(self) -> c::in6_addr {
c::in6_addr { s6_addr: self.octets() }
}
}
impl FromInner<c::in6_addr> for Ipv6Addr {
#[inline]
fn from_inner(addr: c::in6_addr) -> Ipv6Addr {
Ipv6Addr::from(addr.s6_addr)
}
}

View file

@ -6,50 +6,8 @@ mod tests;
pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use crate::sys::net::{LookupHost, netc as c};
use crate::sys_common::{FromInner, IntoInner};
use crate::{io, iter, mem, option, slice, vec};
impl FromInner<c::sockaddr_in> for SocketAddrV4 {
fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 {
SocketAddrV4::new(Ipv4Addr::from_inner(addr.sin_addr), u16::from_be(addr.sin_port))
}
}
impl FromInner<c::sockaddr_in6> for SocketAddrV6 {
fn from_inner(addr: c::sockaddr_in6) -> SocketAddrV6 {
SocketAddrV6::new(
Ipv6Addr::from_inner(addr.sin6_addr),
u16::from_be(addr.sin6_port),
addr.sin6_flowinfo,
addr.sin6_scope_id,
)
}
}
impl IntoInner<c::sockaddr_in> for SocketAddrV4 {
fn into_inner(self) -> c::sockaddr_in {
c::sockaddr_in {
sin_family: c::AF_INET as c::sa_family_t,
sin_port: self.port().to_be(),
sin_addr: self.ip().into_inner(),
..unsafe { mem::zeroed() }
}
}
}
impl IntoInner<c::sockaddr_in6> for SocketAddrV6 {
fn into_inner(self) -> c::sockaddr_in6 {
c::sockaddr_in6 {
sin6_family: c::AF_INET6 as c::sa_family_t,
sin6_port: self.port().to_be(),
sin6_addr: self.ip().into_inner(),
sin6_flowinfo: self.flowinfo(),
sin6_scope_id: self.scope_id(),
..unsafe { mem::zeroed() }
}
}
}
use crate::sys::net::LookupHost;
use crate::{io, iter, option, slice, vec};
/// A trait for objects which can be converted or resolved to one or more
/// [`SocketAddr`] values.

View file

@ -122,7 +122,7 @@ impl BorrowedFd<'_> {
/// Creates a new `OwnedFd` instance that shares the same underlying file
/// description as the existing `BorrowedFd` instance.
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?;
let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?;
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
}
}
@ -168,7 +168,7 @@ impl FromRawFd for OwnedFd {
impl Drop for OwnedFd {
#[inline]
fn drop(&mut self) {
unsafe { sys::net::netc::close(self.fd.as_inner()) };
unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) };
}
}

View file

@ -499,38 +499,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
LookupHost::new(format!("{host}:{port}"))
}
}
#[allow(bad_style)]
pub mod netc {
pub const AF_INET: u8 = 0;
pub const AF_INET6: u8 = 1;
pub type sa_family_t = u8;
#[derive(Copy, Clone)]
pub struct in_addr {
pub s_addr: u32,
}
#[derive(Copy, Clone)]
pub struct sockaddr_in {
#[allow(dead_code)]
pub sin_family: sa_family_t,
pub sin_port: u16,
pub sin_addr: in_addr,
}
#[derive(Copy, Clone)]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
#[derive(Copy, Clone)]
pub struct sockaddr_in6 {
#[allow(dead_code)]
pub sin6_family: sa_family_t,
pub sin6_port: u16,
pub sin6_addr: in6_addr,
pub sin6_flowinfo: u32,
pub sin6_scope_id: u32,
}
}

View file

@ -3,9 +3,9 @@ mod tests;
use crate::ffi::{c_int, c_void};
use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAddrV6};
use crate::sys::common::small_c_string::run_with_cstr;
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::sys_common::{AsInner, FromInner};
use crate::time::Duration;
use crate::{cmp, fmt, mem, ptr};
@ -79,6 +79,111 @@ cfg_if::cfg_if! {
}
}
////////////////////////////////////////////////////////////////////////////////
// address conversions
////////////////////////////////////////////////////////////////////////////////
fn ip_v4_addr_to_c(addr: &Ipv4Addr) -> c::in_addr {
// `s_addr` is stored as BE on all machines and the array is in BE order.
// So the native endian conversion method is used so that it's never swapped.
c::in_addr { s_addr: u32::from_ne_bytes(addr.octets()) }
}
fn ip_v6_addr_to_c(addr: &Ipv6Addr) -> c::in6_addr {
c::in6_addr { s6_addr: addr.octets() }
}
fn ip_v4_addr_from_c(addr: c::in_addr) -> Ipv4Addr {
Ipv4Addr::from(addr.s_addr.to_ne_bytes())
}
fn ip_v6_addr_from_c(addr: c::in6_addr) -> Ipv6Addr {
Ipv6Addr::from(addr.s6_addr)
}
fn socket_addr_v4_to_c(addr: &SocketAddrV4) -> c::sockaddr_in {
c::sockaddr_in {
sin_family: c::AF_INET as c::sa_family_t,
sin_port: addr.port().to_be(),
sin_addr: ip_v4_addr_to_c(addr.ip()),
..unsafe { mem::zeroed() }
}
}
fn socket_addr_v6_to_c(addr: &SocketAddrV6) -> c::sockaddr_in6 {
c::sockaddr_in6 {
sin6_family: c::AF_INET6 as c::sa_family_t,
sin6_port: addr.port().to_be(),
sin6_addr: ip_v6_addr_to_c(addr.ip()),
sin6_flowinfo: addr.flowinfo(),
sin6_scope_id: addr.scope_id(),
..unsafe { mem::zeroed() }
}
}
fn socket_addr_v4_from_c(addr: c::sockaddr_in) -> SocketAddrV4 {
SocketAddrV4::new(ip_v4_addr_from_c(addr.sin_addr), u16::from_be(addr.sin_port))
}
fn socket_addr_v6_from_c(addr: c::sockaddr_in6) -> SocketAddrV6 {
SocketAddrV6::new(
ip_v6_addr_from_c(addr.sin6_addr),
u16::from_be(addr.sin6_port),
addr.sin6_flowinfo,
addr.sin6_scope_id,
)
}
/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level
/// SocketAddr* types into their system representation. The benefit of this specific
/// type over using `c::sockaddr_storage` is that this type is exactly as large as it
/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust.
#[repr(C)]
union SocketAddrCRepr {
v4: c::sockaddr_in,
v6: c::sockaddr_in6,
}
impl SocketAddrCRepr {
fn as_ptr(&self) -> *const c::sockaddr {
self as *const _ as *const c::sockaddr
}
}
fn socket_addr_to_c(addr: &SocketAddr) -> (SocketAddrCRepr, c::socklen_t) {
match addr {
SocketAddr::V4(a) => {
let sockaddr = SocketAddrCRepr { v4: socket_addr_v4_to_c(a) };
(sockaddr, mem::size_of::<c::sockaddr_in>() as c::socklen_t)
}
SocketAddr::V6(a) => {
let sockaddr = SocketAddrCRepr { v6: socket_addr_v6_to_c(a) };
(sockaddr, mem::size_of::<c::sockaddr_in6>() as c::socklen_t)
}
}
}
unsafe fn socket_addr_from_c(
storage: *const c::sockaddr_storage,
len: usize,
) -> io::Result<SocketAddr> {
match (*storage).ss_family as c_int {
c::AF_INET => {
assert!(len >= mem::size_of::<c::sockaddr_in>());
Ok(SocketAddr::V4(socket_addr_v4_from_c(unsafe {
*(storage as *const _ as *const c::sockaddr_in)
})))
}
c::AF_INET6 => {
assert!(len >= mem::size_of::<c::sockaddr_in6>());
Ok(SocketAddr::V6(socket_addr_v6_from_c(unsafe {
*(storage as *const _ as *const c::sockaddr_in6)
})))
}
_ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")),
}
}
////////////////////////////////////////////////////////////////////////////////
// sockaddr and misc bindings
////////////////////////////////////////////////////////////////////////////////
@ -124,25 +229,7 @@ where
let mut storage: c::sockaddr_storage = mem::zeroed();
let mut len = mem::size_of_val(&storage) as c::socklen_t;
cvt(f((&raw mut storage) as *mut _, &mut len))?;
sockaddr_to_addr(&storage, len as usize)
}
}
pub fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result<SocketAddr> {
match storage.ss_family as c_int {
c::AF_INET => {
assert!(len >= mem::size_of::<c::sockaddr_in>());
Ok(SocketAddr::V4(FromInner::from_inner(unsafe {
*(storage as *const _ as *const c::sockaddr_in)
})))
}
c::AF_INET6 => {
assert!(len >= mem::size_of::<c::sockaddr_in6>());
Ok(SocketAddr::V6(FromInner::from_inner(unsafe {
*(storage as *const _ as *const c::sockaddr_in6)
})))
}
_ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")),
socket_addr_from_c(&storage, len as usize)
}
}
@ -179,7 +266,7 @@ impl Iterator for LookupHost {
unsafe {
let cur = self.cur.as_ref()?;
self.cur = cur.ai_next;
match sockaddr_to_addr(mem::transmute(cur.ai_addr), cur.ai_addrlen as usize) {
match socket_addr_from_c(cur.ai_addr.cast(), cur.ai_addrlen as usize) {
Ok(addr) => return Some(addr),
Err(_) => continue,
}
@ -432,7 +519,7 @@ impl TcpListener {
setsockopt(&sock, c::SOL_SOCKET, c::SO_REUSEADDR, 1 as c_int)?;
// Bind our new socket
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?;
cfg_if::cfg_if! {
@ -473,7 +560,7 @@ impl TcpListener {
let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() };
let mut len = mem::size_of_val(&storage) as c::socklen_t;
let sock = self.inner.accept((&raw mut storage) as *mut _, &mut len)?;
let addr = sockaddr_to_addr(&storage, len as usize)?;
let addr = unsafe { socket_addr_from_c(&storage, len as usize)? };
Ok((TcpStream { inner: sock }, addr))
}
@ -542,7 +629,7 @@ impl UdpSocket {
init();
let sock = Socket::new(addr, c::SOCK_DGRAM)?;
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?;
Ok(UdpSocket { inner: sock })
}
@ -574,7 +661,7 @@ impl UdpSocket {
pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result<usize> {
let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
let (dst, dstlen) = dst.into_inner();
let (dst, dstlen) = socket_addr_to_c(dst);
let ret = cvt(unsafe {
c::sendto(
self.inner.as_raw(),
@ -656,15 +743,15 @@ impl UdpSocket {
pub fn join_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
let mreq = c::ip_mreq {
imr_multiaddr: multiaddr.into_inner(),
imr_interface: interface.into_inner(),
imr_multiaddr: ip_v4_addr_to_c(multiaddr),
imr_interface: ip_v4_addr_to_c(interface),
};
setsockopt(&self.inner, c::IPPROTO_IP, c::IP_ADD_MEMBERSHIP, mreq)
}
pub fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> {
let mreq = c::ipv6_mreq {
ipv6mr_multiaddr: multiaddr.into_inner(),
ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr),
ipv6mr_interface: to_ipv6mr_interface(interface),
};
setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq)
@ -672,15 +759,15 @@ impl UdpSocket {
pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
let mreq = c::ip_mreq {
imr_multiaddr: multiaddr.into_inner(),
imr_interface: interface.into_inner(),
imr_multiaddr: ip_v4_addr_to_c(multiaddr),
imr_interface: ip_v4_addr_to_c(interface),
};
setsockopt(&self.inner, c::IPPROTO_IP, c::IP_DROP_MEMBERSHIP, mreq)
}
pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> {
let mreq = c::ipv6_mreq {
ipv6mr_multiaddr: multiaddr.into_inner(),
ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr),
ipv6mr_interface: to_ipv6mr_interface(interface),
};
setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, mreq)
@ -720,7 +807,7 @@ impl UdpSocket {
}
pub fn connect(&self, addr: io::Result<&SocketAddr>) -> io::Result<()> {
let (addr, len) = addr?.into_inner();
let (addr, len) = socket_addr_to_c(addr?);
cvt_r(|| unsafe { c::connect(self.inner.as_raw(), addr.as_ptr(), len) }).map(drop)
}
}
@ -743,38 +830,3 @@ impl fmt::Debug for UdpSocket {
res.field(name, &self.inner.as_raw()).finish()
}
}
////////////////////////////////////////////////////////////////////////////////
// Converting SocketAddr to libc representation
////////////////////////////////////////////////////////////////////////////////
/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level
/// SocketAddr* types into their system representation. The benefit of this specific
/// type over using `c::sockaddr_storage` is that this type is exactly as large as it
/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust.
#[repr(C)]
pub(crate) union SocketAddrCRepr {
v4: c::sockaddr_in,
v6: c::sockaddr_in6,
}
impl SocketAddrCRepr {
pub fn as_ptr(&self) -> *const c::sockaddr {
self as *const _ as *const c::sockaddr
}
}
impl<'a> IntoInner<(SocketAddrCRepr, c::socklen_t)> for &'a SocketAddr {
fn into_inner(self) -> (SocketAddrCRepr, c::socklen_t) {
match *self {
SocketAddr::V4(ref a) => {
let sockaddr = SocketAddrCRepr { v4: a.into_inner() };
(sockaddr, mem::size_of::<c::sockaddr_in>() as c::socklen_t)
}
SocketAddr::V6(ref a) => {
let sockaddr = SocketAddrCRepr { v6: a.into_inner() };
(sockaddr, mem::size_of::<c::sockaddr_in6>() as c::socklen_t)
}
}
}
}

View file

@ -2,13 +2,13 @@
use core::ffi::c_int;
pub(crate) use hermit_abi as netc;
pub(super) use hermit_abi as netc;
use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c};
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
use crate::net::{Shutdown, SocketAddr};
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};
use crate::sys::fd::FileDesc;
use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr};
use crate::sys::time::Instant;
pub use crate::sys::{cvt, cvt_r};
use crate::sys_common::{AsInner, FromInner, IntoInner};
@ -55,7 +55,7 @@ impl Socket {
}
pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?;
Ok(())
}
@ -63,7 +63,7 @@ impl Socket {
pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> {
self.set_nonblocking(true)?;
let r = unsafe {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt(netc::connect(self.as_raw_fd(), addr.as_ptr(), len))
};
self.set_nonblocking(false)?;
@ -195,7 +195,7 @@ impl Socket {
&mut addrlen,
)
})?;
Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?))
Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? }))
}
pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {

View file

@ -1,17 +1,17 @@
use libc::{c_int, c_void, size_t};
use self::netc::{MSG_PEEK, sockaddr, socklen_t};
use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c};
use crate::ffi::CStr;
use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut};
use crate::net::{Shutdown, SocketAddr};
use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd};
use crate::sys::abi;
use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr};
use crate::sys_common::{FromInner, IntoInner};
use crate::time::Duration;
use crate::{cmp, mem, ptr, str};
pub mod netc {
pub(super) mod netc {
pub use crate::sys::abi::sockets::*;
}
@ -131,7 +131,7 @@ impl Socket {
}
pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt(unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?;
Ok(())
}
@ -256,7 +256,7 @@ impl Socket {
&mut addrlen,
)
})?;
Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?))
Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? }))
}
pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {

View file

@ -5,7 +5,7 @@ use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
use crate::net::{Shutdown, SocketAddr};
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
use crate::sys::fd::FileDesc;
use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr};
use crate::sys::net::{getsockopt, setsockopt};
use crate::sys::pal::IsMinusOne;
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::time::{Duration, Instant};
@ -19,8 +19,9 @@ cfg_if::cfg_if! {
}
}
pub(crate) use libc as netc;
pub(super) use libc as netc;
use super::{socket_addr_from_c, socket_addr_to_c};
pub use crate::sys::{cvt, cvt_r};
#[expect(non_camel_case_types)]
@ -150,7 +151,7 @@ impl Socket {
}
pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
loop {
let result = unsafe { libc::connect(self.as_raw_fd(), addr.as_ptr(), len) };
if result.is_minus_one() {
@ -168,7 +169,7 @@ impl Socket {
pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> {
self.set_nonblocking(true)?;
let r = unsafe {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt(libc::connect(self.as_raw_fd(), addr.as_ptr(), len))
};
self.set_nonblocking(false)?;
@ -334,7 +335,7 @@ impl Socket {
&mut addrlen,
)
})?;
Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?))
Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? }))
}
pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {

View file

@ -1,19 +1,18 @@
#![deny(unsafe_op_in_unsafe_fn)]
pub(super) use libc as netc;
use libc::{c_int, c_void, size_t};
use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c};
use crate::ffi::CStr;
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
use crate::net::{Shutdown, SocketAddr};
use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr};
use crate::sys::unsupported;
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::time::{Duration, Instant};
use crate::{cmp, mem, str};
pub extern crate libc as netc;
#[allow(non_camel_case_types)]
pub type wrlen_t = size_t;
@ -89,7 +88,7 @@ impl Socket {
}
pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?;
Ok(())
}
@ -224,7 +223,7 @@ impl Socket {
&mut addrlen,
)
})?;
Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?))
Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? }))
}
pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {

View file

@ -2,6 +2,7 @@
use core::ffi::{c_int, c_long, c_ulong, c_ushort};
use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c};
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read};
use crate::net::{Shutdown, SocketAddr};
use crate::os::windows::io::{
@ -16,7 +17,7 @@ use crate::{cmp, mem, ptr, sys};
#[allow(non_camel_case_types)]
pub type wrlen_t = i32;
pub mod netc {
pub(super) mod netc {
//! BSD socket compatibility shim
//!
//! Some Windows API types are not quite what's expected by our cross-platform
@ -225,7 +226,7 @@ impl Socket {
}
pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> {
let (addr, len) = addr.into_inner();
let (addr, len) = socket_addr_to_c(addr);
let result = unsafe { c::connect(self.as_raw(), addr.as_ptr(), len) };
cvt(result).map(drop)
}
@ -401,12 +402,12 @@ impl Socket {
let error = unsafe { c::WSAGetLastError() };
if error == c::WSAESHUTDOWN {
Ok((0, super::sockaddr_to_addr(&storage, addrlen as usize)?))
Ok((0, unsafe { socket_addr_from_c(&storage, addrlen as usize)? }))
} else {
Err(io::Error::from_raw_os_error(error))
}
}
_ => Ok((result as usize, super::sockaddr_to_addr(&storage, addrlen as usize)?)),
_ => Ok((result as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })),
}
}
@ -451,11 +452,11 @@ impl Socket {
}
None => 0,
};
super::setsockopt(self, c::SOL_SOCKET, kind, timeout)
setsockopt(self, c::SOL_SOCKET, kind, timeout)
}
pub fn timeout(&self, kind: c_int) -> io::Result<Option<Duration>> {
let raw: u32 = super::getsockopt(self, c::SOL_SOCKET, kind)?;
let raw: u32 = getsockopt(self, c::SOL_SOCKET, kind)?;
if raw == 0 {
Ok(None)
} else {
@ -488,26 +489,26 @@ impl Socket {
l_linger: linger.unwrap_or_default().as_secs() as c_ushort,
};
super::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger)
setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger)
}
pub fn linger(&self) -> io::Result<Option<Duration>> {
let val: c::LINGER = super::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
let val: c::LINGER = getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64)))
}
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
super::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL)
setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL)
}
pub fn nodelay(&self) -> io::Result<bool> {
let raw: c::BOOL = super::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?;
let raw: c::BOOL = getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?;
Ok(raw != 0)
}
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
let raw: c_int = super::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?;
let raw: c_int = getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?;
if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) }
}

View file

@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
unsupported()
}
}
#[allow(nonstandard_style)]
pub mod netc {
pub const AF_INET: u8 = 0;
pub const AF_INET6: u8 = 1;
pub type sa_family_t = u8;
#[derive(Copy, Clone)]
pub struct in_addr {
pub s_addr: u32,
}
#[derive(Copy, Clone)]
pub struct sockaddr_in {
#[allow(dead_code)]
pub sin_family: sa_family_t,
pub sin_port: u16,
pub sin_addr: in_addr,
}
#[derive(Copy, Clone)]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
#[derive(Copy, Clone)]
pub struct sockaddr_in6 {
#[allow(dead_code)]
pub sin6_family: sa_family_t,
pub sin6_port: u16,
pub sin6_addr: in6_addr,
pub sin6_flowinfo: u32,
pub sin6_scope_id: u32,
}
}

View file

@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
unsupported()
}
}
#[allow(nonstandard_style)]
pub mod netc {
pub const AF_INET: u8 = 0;
pub const AF_INET6: u8 = 1;
pub type sa_family_t = u8;
#[derive(Copy, Clone)]
pub struct in_addr {
pub s_addr: u32,
}
#[derive(Copy, Clone)]
pub struct sockaddr_in {
#[allow(dead_code)]
pub sin_family: sa_family_t,
pub sin_port: u16,
pub sin_addr: in_addr,
}
#[derive(Copy, Clone)]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
#[derive(Copy, Clone)]
pub struct sockaddr_in6 {
#[allow(dead_code)]
pub sin6_family: sa_family_t,
pub sin6_port: u16,
pub sin6_addr: in6_addr,
pub sin6_flowinfo: u32,
pub sin6_scope_id: u32,
}
}

View file

@ -505,38 +505,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
unsupported()
}
}
#[allow(nonstandard_style)]
pub mod netc {
pub const AF_INET: u8 = 0;
pub const AF_INET6: u8 = 1;
pub type sa_family_t = u8;
#[derive(Copy, Clone)]
pub struct in_addr {
pub s_addr: u32,
}
#[derive(Copy, Clone)]
pub struct sockaddr_in {
#[allow(dead_code)]
pub sin_family: sa_family_t,
pub sin_port: u16,
pub sin_addr: in_addr,
}
#[derive(Copy, Clone)]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
#[derive(Copy, Clone)]
pub struct sockaddr_in6 {
#[allow(dead_code)]
pub sin6_family: sa_family_t,
pub sin6_port: u16,
pub sin6_addr: in6_addr,
pub sin6_flowinfo: u32,
pub sin6_scope_id: u32,
}
}

View file

@ -46,38 +46,3 @@ pub struct GetAddress {
}
pub use dns::LookupHost;
#[allow(nonstandard_style)]
pub mod netc {
pub const AF_INET: u8 = 0;
pub const AF_INET6: u8 = 1;
pub type sa_family_t = u8;
#[derive(Copy, Clone)]
pub struct in_addr {
pub s_addr: u32,
}
#[derive(Copy, Clone)]
pub struct sockaddr_in {
#[allow(dead_code)]
pub sin_family: sa_family_t,
pub sin_port: u16,
pub sin_addr: in_addr,
}
#[derive(Copy, Clone)]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
#[derive(Copy, Clone)]
pub struct sockaddr_in6 {
#[allow(dead_code)]
pub sin6_family: sa_family_t,
pub sin6_port: u16,
pub sin6_addr: in6_addr,
pub sin6_flowinfo: u32,
pub sin6_scope_id: u32,
}
}

@ -1 +1 @@
Subproject commit e2fa4316c5a7c0d2499c5d6b799adcfad6ef7a45
Subproject commit d4d2c18cbd20876b2130a546e790446a8444cb32

@ -1 +1 @@
Subproject commit de2d5289e45506b11dd652bef4f99de64be70e1c
Subproject commit 6195dbd70fc6f0980c314b4d23875ac570d8253a

View file

@ -199,3 +199,5 @@ These flags registers must be restored upon exiting the asm block if the `preser
- SPARC
- Integer condition codes (`icc` and `xcc`)
- Floating-point condition codes (`fcc[0-3]`)
- CSKY
- Condition/carry bit (C) in `PSR`.

View file

@ -786,6 +786,7 @@ impl IndividualTestOptions {
/// [`clean`]: crate::clean
/// [`run_merged_tests`]: crate::doctest::runner::DocTestRunner::run_merged_tests
/// [`generate_unique_doctest`]: crate::doctest::make::DocTestBuilder::generate_unique_doctest
#[derive(Debug)]
pub(crate) struct ScrapedDocTest {
filename: FileName,
line: usize,

View file

@ -139,7 +139,7 @@ impl ErrorCodes {
/// Controls whether a line will be hidden or shown in HTML output.
///
/// All lines are used in documentation tests.
enum Line<'a> {
pub(crate) enum Line<'a> {
Hidden(&'a str),
Shown(Cow<'a, str>),
}
@ -152,7 +152,7 @@ impl<'a> Line<'a> {
}
}
fn for_code(self) -> Cow<'a, str> {
pub(crate) fn for_code(self) -> Cow<'a, str> {
match self {
Line::Shown(l) => l,
Line::Hidden(l) => Cow::Borrowed(l),
@ -160,12 +160,14 @@ impl<'a> Line<'a> {
}
}
/// This function is used to handle the "hidden lines" (ie starting with `#`) in
/// doctests. It also transforms `##` back into `#`.
// FIXME: There is a minor inconsistency here. For lines that start with ##, we
// have no easy way of removing a potential single space after the hashes, which
// is done in the single # case. This inconsistency seems okay, if non-ideal. In
// order to fix it we'd have to iterate to find the first non-# character, and
// then reallocate to remove it; which would make us return a String.
fn map_line(s: &str) -> Line<'_> {
pub(crate) fn map_line(s: &str) -> Line<'_> {
let trimmed = s.trim();
if trimmed.starts_with("##") {
Line::Shown(Cow::Owned(s.replacen("##", "#", 1)))

View file

@ -1,5 +1,6 @@
//! Validates syntax inside Rust code blocks (\`\`\`rust).
use std::borrow::Cow;
use std::sync::Arc;
use rustc_data_structures::sync::Lock;
@ -43,7 +44,11 @@ fn check_rust_syntax(
let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
let source = dox[code_block.code].to_owned();
let source = dox[code_block.code]
.lines()
.map(|line| crate::html::markdown::map_line(line).for_code())
.intersperse(Cow::Borrowed("\n"))
.collect::<String>();
let psess = ParseSess::with_dcx(dcx, sm);
let edition = code_block.lang_string.edition.unwrap_or_else(|| cx.tcx.sess.edition());

View file

@ -4,7 +4,6 @@
// make sure the feature is not enabled at compile-time
//@ compile-flags: -C opt-level=3 -C target-feature=-sse4.1 -C llvm-args=-x86-asm-syntax=intel
#![feature(target_feature_11)]
#![crate_type = "rlib"]
use std::arch::x86_64::{__m128, _mm_blend_ps};

View file

@ -0,0 +1,18 @@
// Check that pointers are casted to addrspace(0) before they are used
//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900
//@ needs-llvm-components: amdgpu
//@ add-core-stubs
#![feature(no_core)]
#![no_core]
extern crate minicore;
// CHECK-LABEL: @ref_of_local
// CHECK: [[alloca:%[0-9]]] = alloca
// CHECK: %i = addrspacecast ptr addrspace(5) [[alloca]] to ptr
#[no_mangle]
pub fn ref_of_local(f: fn(&i32)) {
let i = 0;
f(&i);
}

View file

@ -0,0 +1,24 @@
//@ add-core-stubs
//@ compile-flags: --target csky-unknown-linux-gnuabiv2
//@ needs-llvm-components: csky
#![crate_type = "rlib"]
#![feature(no_core, asm_experimental_arch)]
#![no_core]
extern crate minicore;
use minicore::*;
// CHECK-LABEL: @flags_clobber
// CHECK: call void asm sideeffect "", "~{psr}"()
#[no_mangle]
pub unsafe fn flags_clobber() {
asm!("", options(nostack, nomem));
}
// CHECK-LABEL: @no_clobber
// CHECK: call void asm sideeffect "", ""()
#[no_mangle]
pub unsafe fn no_clobber() {
asm!("", options(nostack, nomem, preserves_flags));
}

View file

@ -3,7 +3,6 @@
//@ compile-flags: -Copt-level=3 -Ctarget-cpu=x86-64
#![crate_type = "lib"]
#![feature(target_feature_11)]
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;

View file

@ -4,7 +4,6 @@
#![crate_type = "lib"]
#![feature(no_sanitize)]
#![feature(target_feature_11)]
#![feature(c_variadic)]
#[inline]

View file

@ -0,0 +1,17 @@
// This test ensures that `##` are not emitting a warning when generating
// docs with the 2024 edition (or any edition).
// Regression test for <https://github.com/rust-lang/rust/issues/136899>.
//@ check-pass
//@revisions: edition2021 edition2024
//@[edition2021] edition:2021
//@[edition2024] edition:2024
#![deny(warnings)]
//! Test
//!
//! ```
//! ##[allow(dead_code)]
//! println!("hello world");
//! ```

View file

@ -2,8 +2,6 @@
//@ needs-asm-support
//@ only-x86_64
#![feature(target_feature_11)]
use std::arch::asm;
#[target_feature(enable = "avx")]

View file

@ -1,14 +1,13 @@
//@ edition: 2021
//@ only-x86_64
#![feature(target_feature_11)]
// `target_feature_11` just to test safe functions w/ target features.
use std::pin::Pin;
use std::future::Future;
use std::pin::Pin;
#[target_feature(enable = "sse2")]
fn target_feature() -> Pin<Box<dyn Future<Output = ()> + 'static>> { todo!() }
fn target_feature() -> Pin<Box<dyn Future<Output = ()> + 'static>> {
todo!()
}
fn test(f: impl AsyncFn()) {}

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `#[target_features] fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}: AsyncFn()` is not satisfied
--> $DIR/fn-exception-target-features.rs:16:10
--> $DIR/fn-exception-target-features.rs:15:10
|
LL | test(target_feature);
| ---- ^^^^^^^^^^^^^^ unsatisfied trait bound
@ -8,7 +8,7 @@ LL | test(target_feature);
|
= help: the trait `AsyncFn()` is not implemented for fn item `#[target_features] fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}`
note: required by a bound in `test`
--> $DIR/fn-exception-target-features.rs:13:17
--> $DIR/fn-exception-target-features.rs:12:17
|
LL | fn test(f: impl AsyncFn()) {}
| ^^^^^^^^^ required by this bound in `test`

View file

@ -1,8 +1,7 @@
// ignore-tidy-linelength
//! Check that `-A warnings` cli flag applies to non-lint warnings as well.
//!
//! This test tries to exercise that by checking that the "relaxing a default bound only does
//! something for `?Sized`; all other traits are not bound by default" non-lint warning (normally
//! This test tries to exercise that by checking that a non-lint warning (normally
//! warn-by-default) is suppressed if the `-A warnings` cli flag is passed.
//!
//! Take special note that `warnings` is a special pseudo lint group in relationship to non-lint
@ -14,7 +13,7 @@
//! - Original impl PR: <https://github.com/rust-lang/rust/pull/21248>.
//! - RFC 507 "Release channels":
//! <https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md>.
#![crate_type = "lib"]
#![feature(rustc_attrs)]
//@ revisions: without_flag with_flag
@ -22,6 +21,6 @@
//@ check-pass
pub trait Trait {}
pub fn f<T: ?Trait>() {}
//[without_flag]~^ WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
#[rustc_error(warn)]
fn main() {}
//[without_flag]~^ WARN unexpected annotation used with `#[rustc_error(...)]`!

View file

@ -1,8 +1,8 @@
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/allow-non-lint-warnings.rs:26:13
warning: unexpected annotation used with `#[rustc_error(...)]`!
--> $DIR/allow-non-lint-warnings.rs:25:1
|
LL | pub fn f<T: ?Trait>() {}
| ^^^^^^
LL | fn main() {}
| ^^^^^^^^^
warning: 1 warning emitted

View file

@ -11,14 +11,14 @@ fn foo(_: Box<dyn Trait1 + ?Trait2>) {}
//~^ ERROR `?Trait` is not permitted in trait object types
fn bar<T: ?Trait1 + ?Trait2>(_: T) {}
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
trait Trait {}
// Do not suggest `#![feature(more_maybe_bounds)]` for repetitions
fn baz<T: ?Trait + ?Trait>(_ : T) {}
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
fn main() {}

View file

@ -35,13 +35,13 @@ LL | fn bar<T: ?Trait1 + ?Trait2>(_: T) {}
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/feature-gate-more-maybe-bounds.rs:12:11
|
LL | fn bar<T: ?Trait1 + ?Trait2>(_: T) {}
| ^^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/feature-gate-more-maybe-bounds.rs:12:21
|
LL | fn bar<T: ?Trait1 + ?Trait2>(_: T) {}
@ -53,19 +53,19 @@ error[E0203]: type parameter has more than one relaxed default bound, only one i
LL | fn baz<T: ?Trait + ?Trait>(_ : T) {}
| ^^^^^^ ^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/feature-gate-more-maybe-bounds.rs:19:11
|
LL | fn baz<T: ?Trait + ?Trait>(_ : T) {}
| ^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/feature-gate-more-maybe-bounds.rs:19:20
|
LL | fn baz<T: ?Trait + ?Trait>(_ : T) {}
| ^^^^^^
error: aborting due to 5 previous errors; 4 warnings emitted
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0203, E0658.
For more information about an error, try `rustc --explain E0203`.

View file

@ -0,0 +1,11 @@
//! Regression test for ICE https://github.com/rust-lang/rust/issues/135730
//! This used
use std::future::Future;
fn foo() -> impl ?Future<Output = impl Send> {
//~^ ERROR: relaxing a default bound only does something for `?Sized`
//~| ERROR: relaxing a default bound only does something for `?Sized`
()
}
pub fn main() {}

View file

@ -0,0 +1,16 @@
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/opt-out-bound-not-satisfied.rs:5:18
|
LL | fn foo() -> impl ?Future<Output = impl Send> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/opt-out-bound-not-satisfied.rs:5:18
|
LL | fn foo() -> impl ?Future<Output = impl Send> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors

View file

@ -1,5 +1,5 @@
struct Foo<T: ?Hash> {}
//~^ ERROR expected trait, found derive macro `Hash`
//~| WARN relaxing a default bound only does something for `?Sized`
//~| ERROR relaxing a default bound only does something for `?Sized`
fn main() {}

View file

@ -9,12 +9,12 @@ help: consider importing this trait instead
LL + use std::hash::Hash;
|
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/issue-37534.rs:1:15
|
LL | struct Foo<T: ?Hash> {}
| ^^^^^
error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0404`.

View file

@ -6,12 +6,12 @@
// Check that these function definitions only emit warnings, not errors
fn arg<T: ?Send>(_: T) {}
//~^ warning: relaxing a default bound only does something for `?Sized`
//~^ ERROR: relaxing a default bound only does something for `?Sized`
fn ref_arg<T: ?Send>(_: &T) {}
//~^ warning: relaxing a default bound only does something for `?Sized`
//~^ ERROR: relaxing a default bound only does something for `?Sized`
fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
//~^ warning: relaxing a default bound only does something for `?Sized`
//~| warning: relaxing a default bound only does something for `?Sized`
//~^ ERROR: relaxing a default bound only does something for `?Sized`
//~| ERROR: relaxing a default bound only does something for `?Sized`
// Check that there's no `?Sized` relaxation!
fn main() {

View file

@ -1,22 +1,22 @@
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/issue-87199.rs:8:11
|
LL | fn arg<T: ?Send>(_: T) {}
| ^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/issue-87199.rs:10:15
|
LL | fn ref_arg<T: ?Send>(_: &T) {}
| ^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/issue-87199.rs:12:40
|
LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
| ^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/issue-87199.rs:12:40
|
LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
@ -41,6 +41,6 @@ help: consider relaxing the implicit `Sized` restriction
LL | fn ref_arg<T: ?Send + ?Sized>(_: &T) {}
| ++++++++
error: aborting due to 1 previous error; 4 warnings emitted
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,7 +1,7 @@
//@ only-x86_64
//@ check-fail
#![feature(lang_items, no_core, target_feature_11)]
#![feature(lang_items, no_core)]
#![no_core]
#[lang = "copy"]

View file

@ -1,7 +1,6 @@
//@ compile-flags:-C panic=abort
//@ only-x86_64
#![feature(target_feature_11)]
#![no_std]
#![no_main]

View file

@ -1,5 +1,5 @@
error: `#[panic_handler]` function is not allowed to have `#[target_feature]`
--> $DIR/panic-handler-with-target-feature.rs:11:1
--> $DIR/panic-handler-with-target-feature.rs:10:1
|
LL | #[target_feature(enable = "avx2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -9,8 +9,6 @@
//@ check-pass
//@ only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable = "sse2")]
const fn sse2() {}

View file

@ -3,8 +3,6 @@
//@ check-pass
//@ only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable = "avx")]
fn also_use_avx() {
println!("Hello from AVX")

View file

@ -1,6 +0,0 @@
//@ only-x86_64
#[target_feature(enable = "sse2")] //~ ERROR can only be applied to `unsafe` functions
fn foo() {}
fn main() {}

View file

@ -1,15 +0,0 @@
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
--> $DIR/feature-gate-target_feature_11.rs:3:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn foo() {}
| -------- not an `unsafe` function
|
= note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,7 +1,5 @@
//@ only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable = "avx")]
fn foo_avx() {}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/fn-ptr.rs:14:21
--> $DIR/fn-ptr.rs:12:21
|
LL | #[target_feature(enable = "avx")]
| --------------------------------- `#[target_feature]` added here
@ -14,7 +14,7 @@ LL | let foo: fn() = foo_avx;
= note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers
error[E0308]: mismatched types
--> $DIR/fn-ptr.rs:23:21
--> $DIR/fn-ptr.rs:21:21
|
LL | #[target_feature(enable = "sse2")]
| ---------------------------------- `#[target_feature]` added here

View file

@ -1,7 +1,5 @@
//@ only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable = "avx")]
fn foo() {}

View file

@ -1,5 +1,5 @@
error[E0277]: expected a `Fn()` closure, found `#[target_features] fn() {foo}`
--> $DIR/fn-traits.rs:31:10
--> $DIR/fn-traits.rs:29:10
|
LL | call(foo);
| ---- ^^^ expected an `Fn()` closure, found `#[target_features] fn() {foo}`
@ -11,13 +11,13 @@ LL | call(foo);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call`
--> $DIR/fn-traits.rs:14:17
--> $DIR/fn-traits.rs:12:17
|
LL | fn call(f: impl Fn()) {
| ^^^^ required by this bound in `call`
error[E0277]: expected a `FnMut()` closure, found `#[target_features] fn() {foo}`
--> $DIR/fn-traits.rs:32:14
--> $DIR/fn-traits.rs:30:14
|
LL | call_mut(foo);
| -------- ^^^ expected an `FnMut()` closure, found `#[target_features] fn() {foo}`
@ -29,13 +29,13 @@ LL | call_mut(foo);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call_mut`
--> $DIR/fn-traits.rs:18:25
--> $DIR/fn-traits.rs:16:25
|
LL | fn call_mut(mut f: impl FnMut()) {
| ^^^^^^^ required by this bound in `call_mut`
error[E0277]: expected a `FnOnce()` closure, found `#[target_features] fn() {foo}`
--> $DIR/fn-traits.rs:33:15
--> $DIR/fn-traits.rs:31:15
|
LL | call_once(foo);
| --------- ^^^ expected an `FnOnce()` closure, found `#[target_features] fn() {foo}`
@ -47,13 +47,13 @@ LL | call_once(foo);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call_once`
--> $DIR/fn-traits.rs:22:22
--> $DIR/fn-traits.rs:20:22
|
LL | fn call_once(f: impl FnOnce()) {
| ^^^^^^^^ required by this bound in `call_once`
error[E0277]: expected a `FnOnce(i32)` closure, found `#[target_features] fn(i32) {bar}`
--> $DIR/fn-traits.rs:34:19
--> $DIR/fn-traits.rs:32:19
|
LL | call_once_i32(bar);
| ------------- ^^^ expected an `FnOnce(i32)` closure, found `#[target_features] fn(i32) {bar}`
@ -64,13 +64,13 @@ LL | call_once_i32(bar);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call_once_i32`
--> $DIR/fn-traits.rs:26:26
--> $DIR/fn-traits.rs:24:26
|
LL | fn call_once_i32(f: impl FnOnce(i32)) {
| ^^^^^^^^^^^ required by this bound in `call_once_i32`
error[E0277]: expected a `Fn()` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:36:10
--> $DIR/fn-traits.rs:34:10
|
LL | call(foo_unsafe);
| ---- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
@ -83,13 +83,13 @@ LL | call(foo_unsafe);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call`
--> $DIR/fn-traits.rs:14:17
--> $DIR/fn-traits.rs:12:17
|
LL | fn call(f: impl Fn()) {
| ^^^^ required by this bound in `call`
error[E0277]: expected a `FnMut()` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:38:14
--> $DIR/fn-traits.rs:36:14
|
LL | call_mut(foo_unsafe);
| -------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
@ -102,13 +102,13 @@ LL | call_mut(foo_unsafe);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call_mut`
--> $DIR/fn-traits.rs:18:25
--> $DIR/fn-traits.rs:16:25
|
LL | fn call_mut(mut f: impl FnMut()) {
| ^^^^^^^ required by this bound in `call_mut`
error[E0277]: expected a `FnOnce()` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:40:15
--> $DIR/fn-traits.rs:38:15
|
LL | call_once(foo_unsafe);
| --------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
@ -121,7 +121,7 @@ LL | call_once(foo_unsafe);
= note: `#[target_feature]` functions do not implement the `Fn` traits
= note: try casting the function to a `fn` pointer or wrapping it in a closure
note: required by a bound in `call_once`
--> $DIR/fn-traits.rs:22:22
--> $DIR/fn-traits.rs:20:22
|
LL | fn call_once(f: impl FnOnce()) {
| ^^^^^^^^ required by this bound in `call_once`

View file

@ -1,7 +1,5 @@
//@ only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable = "avx2")]
fn main() {}
//~^ ERROR `main` function is not allowed to have `#[target_feature]`

View file

@ -1,5 +1,5 @@
error: `main` function is not allowed to have `#[target_feature]`
--> $DIR/issue-108645-target-feature-on-main.rs:6:1
--> $DIR/issue-108645-target-feature-on-main.rs:4:1
|
LL | fn main() {}
| ^^^^^^^^^ `main` function is not allowed to have `#[target_feature]`

View file

@ -3,8 +3,6 @@
//@ check-pass
//@ only-x86_64
#![feature(target_feature_11)]
#[target_feature(enable = "avx")]
pub unsafe fn test() {
({

View file

@ -1,7 +1,5 @@
//@ check-pass
#![feature(target_feature_11)]
struct S<T>(T)
where
[T; (|| {}, 1).1]: Copy;

View file

@ -1,8 +1,6 @@
//@ only-x86_64
//@ run-pass
#![feature(target_feature_11)]
#[target_feature(enable = "sse2")]
fn foo() -> bool {
true

View file

@ -2,8 +2,6 @@
// Set the base cpu explicitly, in case the default has been changed.
//@ compile-flags: -C target-cpu=x86-64
#![feature(target_feature_11)]
#[target_feature(enable = "sse2")]
const fn sse2() {}

View file

@ -1,5 +1,5 @@
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:27:5
--> $DIR/safe-calls.rs:25:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
@ -8,39 +8,39 @@ LL | sse2();
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:27:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:29:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:31:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:36:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:38:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:40:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
|
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:47:5
--> $DIR/safe-calls.rs:45:5
|
LL | avx_bmi2();
| ^^^^^^^^^^ call to function with `#[target_feature]`
@ -48,7 +48,7 @@ LL | avx_bmi2();
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:49:5
--> $DIR/safe-calls.rs:47:5
|
LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
@ -56,7 +56,7 @@ LL | Quux.avx_bmi2();
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:61:15
--> $DIR/safe-calls.rs:59:15
|
LL | const _: () = sse2();
| ^^^^^^ call to function with `#[target_feature]`
@ -65,7 +65,7 @@ LL | const _: () = sse2();
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
error[E0133]: call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe and requires unsafe function or block
--> $DIR/safe-calls.rs:64:15
--> $DIR/safe-calls.rs:62:15
|
LL | const _: () = sse2_and_fxsr();
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
@ -74,7 +74,7 @@ LL | const _: () = sse2_and_fxsr();
= note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block
--> $DIR/safe-calls.rs:69:5
--> $DIR/safe-calls.rs:67:5
|
LL | sse2();
| ^^^^^^ call to function with `#[target_feature]`
@ -83,12 +83,12 @@ LL | sse2();
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
note: an unsafe function restricts its caller, but its body is safe by default
--> $DIR/safe-calls.rs:68:1
--> $DIR/safe-calls.rs:66:1
|
LL | unsafe fn needs_unsafe_block() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/safe-calls.rs:67:8
--> $DIR/safe-calls.rs:65:8
|
LL | #[deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,7 +1,5 @@
//@ only-x86_64
#![feature(target_feature_11)]
trait Foo {
fn foo(&self);
unsafe fn unsf_foo(&self);

View file

@ -1,5 +1,5 @@
error: `#[target_feature(..)]` cannot be applied to safe trait method
--> $DIR/trait-impl.rs:13:5
--> $DIR/trait-impl.rs:11:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method
@ -8,13 +8,13 @@ LL | fn foo(&self) {}
| ------------- not an `unsafe` function
error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/trait-impl.rs:15:5
--> $DIR/trait-impl.rs:13:5
|
LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ expected safe fn, found unsafe fn
|
note: type in trait
--> $DIR/trait-impl.rs:6:5
--> $DIR/trait-impl.rs:4:5
|
LL | fn foo(&self);
| ^^^^^^^^^^^^^^
@ -22,7 +22,7 @@ LL | fn foo(&self);
found signature `#[target_features] fn(&Bar)`
error: `#[target_feature(..)]` cannot be applied to safe trait method
--> $DIR/trait-impl.rs:23:5
--> $DIR/trait-impl.rs:21:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method

View file

@ -4,7 +4,7 @@
#![feature(avx512_target_feature)]
#![feature(portable_simd)]
#![feature(target_feature_11, simd_ffi)]
#![feature(simd_ffi)]
#![allow(improper_ctypes_definitions)]
use std::arch::x86_64::*;

View file

@ -1,6 +1,5 @@
//@ only-x86_64
//@ build-pass
#![feature(target_feature_11)]
#![allow(dead_code)]
#[target_feature(enable = "ssse3")]

View file

@ -28,13 +28,6 @@ extern "Rust" {}
//~^ ERROR malformed `target_feature` attribute
unsafe fn foo() {}
#[target_feature(enable = "sse2")]
//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
//~| NOTE see issue #69098
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
fn bar() {}
//~^ NOTE not an `unsafe` function
#[target_feature(enable = "sse2")]
//~^ ERROR attribute should be applied to a function
mod another {}
@ -58,7 +51,7 @@ enum Bar {}
#[target_feature(enable = "sse2")]
//~^ ERROR attribute should be applied to a function
union Qux {
//~^ NOTE not a function
//~^ NOTE not a function
f1: u16,
f2: u16,
}
@ -102,9 +95,8 @@ trait Quux {
impl Quux for Foo {
#[target_feature(enable = "sse2")]
//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
//~| NOTE see issue #69098
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
//~^ ERROR `#[target_feature(..)]` cannot be applied to safe trait method
//~| NOTE cannot be applied to safe trait method
fn foo() {}
//~^ NOTE not an `unsafe` function
//~| ERROR: incompatible type for trait
@ -117,9 +109,8 @@ fn main() {
//~^ ERROR attribute should be applied to a function
unsafe {
foo();
bar();
}
//~^^^^ NOTE not a function
//~^^^ NOTE not a function
#[target_feature(enable = "sse2")]
//~^ ERROR attribute should be applied to a function

View file

@ -32,7 +32,7 @@ LL | extern "Rust" {}
| ---------------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:38:1
--> $DIR/invalid-attribute.rs:31:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -41,7 +41,7 @@ LL | mod another {}
| -------------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:43:1
--> $DIR/invalid-attribute.rs:36:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,7 +50,7 @@ LL | const FOO: usize = 7;
| --------------------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:48:1
--> $DIR/invalid-attribute.rs:41:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -59,7 +59,7 @@ LL | struct Foo;
| ----------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:53:1
--> $DIR/invalid-attribute.rs:46:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -68,7 +68,7 @@ LL | enum Bar {}
| ----------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:58:1
--> $DIR/invalid-attribute.rs:51:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -81,7 +81,7 @@ LL | | }
| |_- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:66:1
--> $DIR/invalid-attribute.rs:59:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -90,7 +90,7 @@ LL | type Uwu = ();
| -------------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:71:1
--> $DIR/invalid-attribute.rs:64:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -99,7 +99,7 @@ LL | trait Baz {}
| ------------ not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:81:1
--> $DIR/invalid-attribute.rs:74:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -108,7 +108,7 @@ LL | static A: () = ();
| ------------------ not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:86:1
--> $DIR/invalid-attribute.rs:79:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -117,7 +117,7 @@ LL | impl Quux for u8 {}
| ------------------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:93:1
--> $DIR/invalid-attribute.rs:86:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -126,19 +126,18 @@ LL | impl Foo {}
| ----------- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:116:5
--> $DIR/invalid-attribute.rs:108:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | / unsafe {
LL | | foo();
LL | | bar();
LL | | }
| |_____- not a function definition
error: attribute should be applied to a function definition
--> $DIR/invalid-attribute.rs:124:5
--> $DIR/invalid-attribute.rs:115:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -164,27 +163,14 @@ error: malformed `target_feature` attribute input
LL | #[target_feature(disable = "baz")]
| ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."`
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
--> $DIR/invalid-attribute.rs:31:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | fn bar() {}
| -------- not an `unsafe` function
|
= note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: cannot use `#[inline(always)]` with `#[target_feature]`
--> $DIR/invalid-attribute.rs:76:1
--> $DIR/invalid-attribute.rs:69:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
error[E0046]: not all trait items implemented, missing: `foo`
--> $DIR/invalid-attribute.rs:88:1
--> $DIR/invalid-attribute.rs:81:1
|
LL | impl Quux for u8 {}
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation
@ -192,34 +178,30 @@ LL | impl Quux for u8 {}
LL | fn foo();
| --------- `foo` from trait
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
--> $DIR/invalid-attribute.rs:104:5
error: `#[target_feature(..)]` cannot be applied to safe trait method
--> $DIR/invalid-attribute.rs:97:5
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method
...
LL | fn foo() {}
| -------- not an `unsafe` function
|
= note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/invalid-attribute.rs:108:5
--> $DIR/invalid-attribute.rs:100:5
|
LL | fn foo() {}
| ^^^^^^^^ expected safe fn, found unsafe fn
|
note: type in trait
--> $DIR/invalid-attribute.rs:99:5
--> $DIR/invalid-attribute.rs:92:5
|
LL | fn foo();
| ^^^^^^^^^
= note: expected signature `fn()`
found signature `#[target_features] fn()`
error: aborting due to 24 previous errors
error: aborting due to 23 previous errors
Some errors have detailed explanations: E0046, E0053, E0658.
Some errors have detailed explanations: E0046, E0053.
For more information about an error, try `rustc --explain E0046`.

View file

@ -2,6 +2,6 @@ trait Trait {}
fn test<T: ?self::<i32>::Trait>() {}
//~^ ERROR type arguments are not allowed on module `maybe_bound_has_path_args`
//~| WARN relaxing a default bound only does something for `?Sized`
//~| ERROR relaxing a default bound only does something for `?Sized`
fn main() {}

View file

@ -1,4 +1,4 @@
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-bound-has-path-args.rs:3:12
|
LL | fn test<T: ?self::<i32>::Trait>() {}
@ -12,6 +12,6 @@ LL | fn test<T: ?self::<i32>::Trait>() {}
| |
| not allowed on module `maybe_bound_has_path_args`
error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0109`.

View file

@ -2,11 +2,11 @@ trait HasAssoc {
type Assoc;
}
fn hasassoc<T: ?HasAssoc<Assoc = ()>>() {}
//~^ WARN relaxing a default bound
//~^ ERROR relaxing a default bound
trait NoAssoc {}
fn noassoc<T: ?NoAssoc<Missing = ()>>() {}
//~^ WARN relaxing a default bound
//~^ ERROR relaxing a default bound
//~| ERROR associated type `Missing` not found for `NoAssoc`
fn main() {}

View file

@ -1,10 +1,10 @@
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-bound-with-assoc.rs:4:16
|
LL | fn hasassoc<T: ?HasAssoc<Assoc = ()>>() {}
| ^^^^^^^^^^^^^^^^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-bound-with-assoc.rs:8:15
|
LL | fn noassoc<T: ?NoAssoc<Missing = ()>>() {}
@ -16,6 +16,6 @@ error[E0220]: associated type `Missing` not found for `NoAssoc`
LL | fn noassoc<T: ?NoAssoc<Missing = ()>>() {}
| ^^^^^^^ associated type `Missing` not found
error: aborting due to 1 previous error; 2 warnings emitted
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0220`.

View file

@ -1,5 +1,3 @@
//@ check-pass
#![feature(auto_traits)]
#![feature(more_maybe_bounds)]
#![feature(negative_impls)]
@ -12,9 +10,9 @@ trait Trait4 where Self: Trait1 {}
fn foo(_: Box<(dyn Trait3 + ?Trait2)>) {}
fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {}
//~^ WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~^ ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
struct S;
impl !Trait2 for S {}

View file

@ -1,20 +1,20 @@
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-pass.rs:14:20
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-pass.rs:12:20
|
LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {}
| ^^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-pass.rs:14:30
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-pass.rs:12:30
|
LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {}
| ^^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-pass.rs:14:40
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-pass.rs:12:40
|
LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {}
| ^^^^^^^
warning: 3 warnings emitted
error: aborting due to 3 previous errors

View file

@ -3,7 +3,7 @@
trait Trait {}
fn foo<T: ?Trait + ?Trait>(_: T) {}
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
//~| ERROR relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
fn main() {}

View file

@ -4,18 +4,18 @@ error[E0203]: type parameter has more than one relaxed default bound, only one i
LL | fn foo<T: ?Trait + ?Trait>(_: T) {}
| ^^^^^^ ^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-repeated.rs:4:11
|
LL | fn foo<T: ?Trait + ?Trait>(_: T) {}
| ^^^^^^
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-polarity-repeated.rs:4:20
|
LL | fn foo<T: ?Trait + ?Trait>(_: T) {}
| ^^^^^^
error: aborting due to 1 previous error; 2 warnings emitted
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0203`.

View file

@ -11,11 +11,11 @@ trait Trait<'a> {}
struct S4<T>(T) where for<'a> T: ?Trait<'a>;
//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
//~| WARN relaxing a default bound only does something for `?Sized`
//~| ERROR relaxing a default bound only does something for `?Sized`
struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
//~^ ERROR type parameter has more than one relaxed default bound
//~| WARN relaxing a default bound only does something for `?Sized`
//~| ERROR relaxing a default bound only does something for `?Sized`
impl<T> S1<T> {
fn f() where T: ?Sized {}

View file

@ -43,7 +43,7 @@ LL | fn f() where T: ?Sized {}
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-bounds-where.rs:12:34
|
LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>;
@ -58,13 +58,13 @@ LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/maybe-bounds-where.rs:16:33
|
LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
| ^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors; 2 warnings emitted
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0203, E0658.
For more information about an error, try `rustc --explain E0203`.

View file

@ -1041,7 +1041,6 @@ warn_non_default_branch.enable = true
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
users_on_vacation = [
"jyn514",
"nnethercote",
"workingjubilee",
]