Skip to content

Commit 9fcc9cf

Browse files
committed
Auto merge of rust-lang#136954 - jhpratt:rollup-koefsot, r=jhpratt
Rollup of 12 pull requests Successful merges: - rust-lang#134090 (Stabilize target_feature_11) - rust-lang#135025 (Cast allocas to default address space) - rust-lang#135841 (Reject `?Trait` bounds in various places where we unconditionally warned since 1.0) - rust-lang#136217 (Mark condition/carry bit as clobbered in C-SKY inline assembly) - rust-lang#136699 (std: replace the `FromInner` implementation for addresses with private conversion functions) - rust-lang#136806 (Fix cycle when debug-printing opaque types from RPITIT) - rust-lang#136807 (compiler: internally merge `PtxKernel` into `GpuKernel`) - rust-lang#136818 (Implement `read*_exact` for `std:io::repeat`) - rust-lang#136927 (Correctly escape hashtags when running `invalid_rust_codeblocks` lint) - rust-lang#136937 (Update books) - rust-lang#136945 (Add diagnostic item for `std::io::BufRead`) - rust-lang#136947 (Reinstate nnethercote in the review rotation.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6dce9f8 + d16b067 commit 9fcc9cf

File tree

91 files changed

+463
-642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+463
-642
lines changed

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
6565
sess.dcx().fatal("C-cmse-nonsecure-entry call conv is not yet implemented");
6666
}
6767

68-
Conv::Msp430Intr
69-
| Conv::PtxKernel
70-
| Conv::GpuKernel
71-
| Conv::AvrInterrupt
72-
| Conv::AvrNonBlockingInterrupt => {
68+
Conv::Msp430Intr | Conv::GpuKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
7369
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
7470
}
7571
}

compiler/rustc_codegen_llvm/src/abi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ impl llvm::CallConv {
687687
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
688688
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
689689
Conv::Msp430Intr => llvm::Msp430Intr,
690-
Conv::PtxKernel => llvm::PtxKernel,
691690
Conv::X86Fastcall => llvm::X86FastcallCallConv,
692691
Conv::X86Intr => llvm::X86_Intr,
693692
Conv::X86Stdcall => llvm::X86StdcallCallConv,

compiler/rustc_codegen_llvm/src/asm.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
286286
InlineAsmArch::M68k => {
287287
constraints.push("~{ccr}".to_string());
288288
}
289-
InlineAsmArch::CSKY => {}
289+
InlineAsmArch::CSKY => {
290+
constraints.push("~{psr}".to_string());
291+
}
290292
}
291293
}
292294
if !options.contains(InlineAsmOptions::NOMEM) {

compiler/rustc_codegen_llvm/src/builder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
543543
unsafe {
544544
let alloca = llvm::LLVMBuildAlloca(bx.llbuilder, ty, UNNAMED);
545545
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
546-
alloca
546+
// Cast to default addrspace if necessary
547+
llvm::LLVMBuildPointerCast(bx.llbuilder, alloca, self.cx().type_ptr(), UNNAMED)
547548
}
548549
}
549550

@@ -552,7 +553,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
552553
let alloca =
553554
llvm::LLVMBuildArrayAlloca(self.llbuilder, self.cx().type_i8(), size, UNNAMED);
554555
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
555-
alloca
556+
// Cast to default addrspace if necessary
557+
llvm::LLVMBuildPointerCast(self.llbuilder, alloca, self.cx().type_ptr(), UNNAMED)
556558
}
557559
}
558560

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+8-19
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
272272
if safe_target_features {
273273
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
274274
// The `#[target_feature]` attribute is allowed on
275-
// WebAssembly targets on all functions, including safe
276-
// ones. Other targets require that `#[target_feature]` is
277-
// only applied to unsafe functions (pending the
278-
// `target_feature_11` feature) because on most targets
275+
// WebAssembly targets on all functions. Prior to stabilizing
276+
// the `target_feature_11` feature, `#[target_feature]` was
277+
// only permitted on unsafe functions because on most targets
279278
// execution of instructions that are not supported is
280279
// considered undefined behavior. For WebAssembly which is a
281280
// 100% safe target at execution time it's not possible to
@@ -289,17 +288,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
289288
// if a target is documenting some wasm-specific code then
290289
// it's not spuriously denied.
291290
//
292-
// This exception needs to be kept in sync with allowing
293-
// `#[target_feature]` on `main` and `start`.
294-
} else if !tcx.features().target_feature_11() {
295-
feature_err(
296-
&tcx.sess,
297-
sym::target_feature_11,
298-
attr.span,
299-
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
300-
)
301-
.with_span_label(tcx.def_span(did), "not an `unsafe` function")
302-
.emit();
291+
// Now that `#[target_feature]` is permitted on safe functions,
292+
// this exception must still exist for allowing the attribute on
293+
// `main`, `start`, and other functions that are not usually
294+
// allowed.
303295
} else {
304296
check_target_feature_trait_unsafe(tcx, did, attr.span);
305297
}
@@ -628,10 +620,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
628620
// its parent function, which effectively inherits the features anyway. Boxing this closure
629621
// would result in this closure being compiled without the inherited target features, but this
630622
// is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
631-
if tcx.features().target_feature_11()
632-
&& tcx.is_closure_like(did.to_def_id())
633-
&& !codegen_fn_attrs.inline.always()
634-
{
623+
if tcx.is_closure_like(did.to_def_id()) && codegen_fn_attrs.inline != InlineAttr::Always {
635624
let owner_id = tcx.parent(did.to_def_id());
636625
if tcx.def_kind(owner_id).has_codegen_attrs() {
637626
codegen_fn_attrs

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ declare_features! (
386386
(accepted, struct_variant, "1.0.0", None),
387387
/// Allows `#[target_feature(...)]`.
388388
(accepted, target_feature, "1.27.0", None),
389+
/// Allows the use of `#[target_feature]` on safe functions.
390+
(accepted, target_feature_11, "CURRENT_RUSTC_VERSION", Some(69098)),
389391
/// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
390392
(accepted, termination_trait, "1.26.0", Some(43301)),
391393
/// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).

compiler/rustc_feature/src/unstable.rs

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

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+45-43
Original file line numberDiff line numberDiff line change
@@ -30,53 +30,55 @@ fn associated_type_bounds<'tcx>(
3030
span: Span,
3131
filter: PredicateFilter,
3232
) -> &'tcx [(ty::Clause<'tcx>, Span)] {
33-
let item_ty = Ty::new_projection_from_args(
34-
tcx,
35-
assoc_item_def_id.to_def_id(),
36-
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
37-
);
38-
39-
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
40-
let mut bounds = Bounds::default();
41-
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
42-
// Associated types are implicitly sized unless a `?Sized` bound is found
43-
match filter {
44-
PredicateFilter::All
45-
| PredicateFilter::SelfOnly
46-
| PredicateFilter::SelfTraitThatDefines(_)
47-
| PredicateFilter::SelfAndAssociatedTypeBounds => {
48-
icx.lowerer().add_sized_bound(&mut bounds, item_ty, hir_bounds, None, span);
33+
ty::print::with_reduced_queries!({
34+
let item_ty = Ty::new_projection_from_args(
35+
tcx,
36+
assoc_item_def_id.to_def_id(),
37+
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
38+
);
39+
40+
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
41+
let mut bounds = Bounds::default();
42+
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
43+
// Associated types are implicitly sized unless a `?Sized` bound is found
44+
match filter {
45+
PredicateFilter::All
46+
| PredicateFilter::SelfOnly
47+
| PredicateFilter::SelfTraitThatDefines(_)
48+
| PredicateFilter::SelfAndAssociatedTypeBounds => {
49+
icx.lowerer().add_sized_bound(&mut bounds, item_ty, hir_bounds, None, span);
50+
}
51+
// `ConstIfConst` is only interested in `~const` bounds.
52+
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
4953
}
50-
// `ConstIfConst` is only interested in `~const` bounds.
51-
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
52-
}
5354

54-
let trait_def_id = tcx.local_parent(assoc_item_def_id);
55-
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
56-
57-
let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id()));
58-
let bounds_from_parent =
59-
trait_predicates.predicates.iter().copied().filter_map(|(clause, span)| {
60-
remap_gat_vars_and_recurse_into_nested_projections(
61-
tcx,
62-
filter,
63-
item_trait_ref,
64-
assoc_item_def_id,
65-
span,
66-
clause,
67-
)
68-
});
69-
70-
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
71-
debug!(
72-
"associated_type_bounds({}) = {:?}",
73-
tcx.def_path_str(assoc_item_def_id.to_def_id()),
74-
all_bounds
75-
);
55+
let trait_def_id = tcx.local_parent(assoc_item_def_id);
56+
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
57+
58+
let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id()));
59+
let bounds_from_parent =
60+
trait_predicates.predicates.iter().copied().filter_map(|(clause, span)| {
61+
remap_gat_vars_and_recurse_into_nested_projections(
62+
tcx,
63+
filter,
64+
item_trait_ref,
65+
assoc_item_def_id,
66+
span,
67+
clause,
68+
)
69+
});
70+
71+
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
72+
debug!(
73+
"associated_type_bounds({}) = {:?}",
74+
tcx.def_path_str(assoc_item_def_id.to_def_id()),
75+
all_bounds
76+
);
7677

77-
assert_only_contains_predicates_from(filter, all_bounds, item_ty);
78+
assert_only_contains_predicates_from(filter, all_bounds, item_ty);
7879

79-
all_bounds
80+
all_bounds
81+
})
8082
}
8183

8284
/// The code below is quite involved, so let me explain.

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

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

compiler/rustc_smir/src/rustc_smir/convert/abi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl<'tcx> Stable<'tcx> for callconv::Conv {
105105
Conv::CCmseNonSecureCall => CallConvention::CCmseNonSecureCall,
106106
Conv::CCmseNonSecureEntry => CallConvention::CCmseNonSecureEntry,
107107
Conv::Msp430Intr => CallConvention::Msp430Intr,
108-
Conv::PtxKernel => CallConvention::PtxKernel,
109108
Conv::X86Fastcall => CallConvention::X86Fastcall,
110109
Conv::X86Intr => CallConvention::X86Intr,
111110
Conv::X86Stdcall => CallConvention::X86Stdcall,

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ symbols! {
250250
Into,
251251
IntoFuture,
252252
IntoIterator,
253+
IoBufRead,
253254
IoLines,
254255
IoRead,
255256
IoSeek,

compiler/rustc_target/src/callconv/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ pub enum Conv {
542542

543543
Msp430Intr,
544544

545-
PtxKernel,
546-
547545
GpuKernel,
548546

549547
X86Fastcall,
@@ -689,7 +687,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
689687
"sparc" => sparc::compute_abi_info(cx, self),
690688
"sparc64" => sparc64::compute_abi_info(cx, self),
691689
"nvptx64" => {
692-
if cx.target_spec().adjust_abi(abi, self.c_variadic) == ExternAbi::PtxKernel {
690+
let abi = cx.target_spec().adjust_abi(abi, self.c_variadic);
691+
if abi == ExternAbi::PtxKernel || abi == ExternAbi::GpuKernel {
693692
nvptx64::compute_ptx_kernel_abi_info(cx, self)
694693
} else {
695694
nvptx64::compute_abi_info(self)
@@ -841,7 +840,6 @@ impl FromStr for Conv {
841840
"CCmseNonSecureCall" => Ok(Conv::CCmseNonSecureCall),
842841
"CCmseNonSecureEntry" => Ok(Conv::CCmseNonSecureEntry),
843842
"Msp430Intr" => Ok(Conv::Msp430Intr),
844-
"PtxKernel" => Ok(Conv::PtxKernel),
845843
"X86Fastcall" => Ok(Conv::X86Fastcall),
846844
"X86Intr" => Ok(Conv::X86Intr),
847845
"X86Stdcall" => Ok(Conv::X86Stdcall),

compiler/rustc_target/src/json.rs

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl ToJson for crate::callconv::Conv {
105105
Self::CCmseNonSecureCall => "CCmseNonSecureCall",
106106
Self::CCmseNonSecureEntry => "CCmseNonSecureEntry",
107107
Self::Msp430Intr => "Msp430Intr",
108-
Self::PtxKernel => "PtxKernel",
109108
Self::X86Fastcall => "X86Fastcall",
110109
Self::X86Intr => "X86Intr",
111110
Self::X86Stdcall => "X86Stdcall",

compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv
290290
Aapcs { .. } => Conv::ArmAapcs,
291291
CCmseNonSecureCall => Conv::CCmseNonSecureCall,
292292
CCmseNonSecureEntry => Conv::CCmseNonSecureEntry,
293-
PtxKernel => Conv::PtxKernel,
293+
PtxKernel => Conv::GpuKernel,
294294
Msp430Interrupt => Conv::Msp430Intr,
295295
X86Interrupt => Conv::X86Intr,
296296
GpuKernel => Conv::GpuKernel,

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@
192192
#![feature(staged_api)]
193193
#![feature(stmt_expr_attributes)]
194194
#![feature(strict_provenance_lints)]
195-
#![feature(target_feature_11)]
196195
#![feature(trait_alias)]
197196
#![feature(transparent_unions)]
198197
#![feature(try_blocks)]

library/std/src/io/mod.rs

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

library/std/src/io/util.rs

+11
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ impl Read for Repeat {
188188
Ok(buf.len())
189189
}
190190

191+
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
192+
for slot in &mut *buf {
193+
*slot = self.byte;
194+
}
195+
Ok(())
196+
}
197+
191198
fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> {
192199
// SAFETY: No uninit bytes are being written
193200
for slot in unsafe { buf.as_mut() } {
@@ -204,6 +211,10 @@ impl Read for Repeat {
204211
Ok(())
205212
}
206213

214+
fn read_buf_exact(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
215+
self.read_buf(buf)
216+
}
217+
207218
/// This function is not supported by `io::Repeat`, because there's no end of its data
208219
fn read_to_end(&mut self, _: &mut Vec<u8>) -> io::Result<usize> {
209220
Err(io::Error::from(io::ErrorKind::OutOfMemory))

library/std/src/net/ip_addr.rs

-29
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,3 @@ pub use core::net::IpAddr;
88
pub use core::net::Ipv6MulticastScope;
99
#[stable(feature = "rust1", since = "1.0.0")]
1010
pub use core::net::{Ipv4Addr, Ipv6Addr};
11-
12-
use crate::sys::net::netc as c;
13-
use crate::sys_common::{FromInner, IntoInner};
14-
15-
impl IntoInner<c::in_addr> for Ipv4Addr {
16-
#[inline]
17-
fn into_inner(self) -> c::in_addr {
18-
// `s_addr` is stored as BE on all machines and the array is in BE order.
19-
// So the native endian conversion method is used so that it's never swapped.
20-
c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) }
21-
}
22-
}
23-
impl FromInner<c::in_addr> for Ipv4Addr {
24-
fn from_inner(addr: c::in_addr) -> Ipv4Addr {
25-
Ipv4Addr::from(addr.s_addr.to_ne_bytes())
26-
}
27-
}
28-
29-
impl IntoInner<c::in6_addr> for Ipv6Addr {
30-
fn into_inner(self) -> c::in6_addr {
31-
c::in6_addr { s6_addr: self.octets() }
32-
}
33-
}
34-
impl FromInner<c::in6_addr> for Ipv6Addr {
35-
#[inline]
36-
fn from_inner(addr: c::in6_addr) -> Ipv6Addr {
37-
Ipv6Addr::from(addr.s6_addr)
38-
}
39-
}

0 commit comments

Comments
 (0)