Skip to content

Commit 6b9676b

Browse files
committed
Auto merge of rust-lang#131612 - tgross35:rollup-zy3yg4p, r=tgross35
Rollup of 7 pull requests Successful merges: - rust-lang#130870 (Add suggestion for removing invalid path sep `::` in fn def) - rust-lang#130954 (Stabilize const `ptr::write*` and `mem::replace`) - rust-lang#131233 (std: fix stdout-before-main) - rust-lang#131590 (yeet some clones) - rust-lang#131596 (mark InterpResult as must_use) - rust-lang#131597 (Take a display name for `tool_check_step!`) - rust-lang#131605 (`LLVMConstInt` only allows integer types) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e200c7f + 1b98ae0 commit 6b9676b

File tree

26 files changed

+175
-58
lines changed

26 files changed

+175
-58
lines changed

compiler/rustc_borrowck/src/nll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
165165
universe_causes,
166166
type_tests,
167167
liveness_constraints,
168-
elements.clone(),
168+
elements,
169169
);
170170

171171
// If requested: dump NLL facts, and run legacy polonius analysis.

compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub(crate) fn expand_deriving_smart_ptr(
312312
impl_generics.params.insert(pointee_param_idx + 1, extra_param);
313313

314314
// Add the impl blocks for `DispatchFromDyn` and `CoerceUnsized`.
315-
let gen_args = vec![GenericArg::Type(alt_self_type.clone())];
315+
let gen_args = vec![GenericArg::Type(alt_self_type)];
316316
add_impl_block(impl_generics.clone(), sym::DispatchFromDyn, gen_args.clone());
317317
add_impl_block(impl_generics.clone(), sym::CoerceUnsized, gen_args);
318318
}

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_abi as abi;
55
use rustc_abi::Primitive::Pointer;
66
use rustc_abi::{AddressSpace, HasDataLayout};
77
use rustc_ast::Mutability;
8+
use rustc_codegen_ssa::common::TypeKind;
89
use rustc_codegen_ssa::traits::*;
910
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
1011
use rustc_hir::def_id::DefId;
@@ -146,6 +147,10 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
146147
}
147148

148149
fn const_int(&self, t: &'ll Type, i: i64) -> &'ll Value {
150+
debug_assert!(
151+
self.type_kind(t) == TypeKind::Integer,
152+
"only allows integer types in const_int"
153+
);
149154
unsafe { llvm::LLVMConstInt(t, i as u64, True) }
150155
}
151156

@@ -176,10 +181,18 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
176181
}
177182

178183
fn const_uint(&self, t: &'ll Type, i: u64) -> &'ll Value {
184+
debug_assert!(
185+
self.type_kind(t) == TypeKind::Integer,
186+
"only allows integer types in const_uint"
187+
);
179188
unsafe { llvm::LLVMConstInt(t, i, False) }
180189
}
181190

182191
fn const_uint_big(&self, t: &'ll Type, u: u128) -> &'ll Value {
192+
debug_assert!(
193+
self.type_kind(t) == TypeKind::Integer,
194+
"only allows integer types in const_uint_big"
195+
);
183196
unsafe {
184197
let words = [u as u64, (u >> 64) as u64];
185198
llvm::LLVMConstIntOfArbitraryPrecision(t, 2, words.as_ptr())

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ impl Drop for Guard {
754754
///
755755
/// We also make things panic if this type is ever implicitly dropped.
756756
#[derive(Debug)]
757+
#[must_use]
757758
pub struct InterpResult_<'tcx, T> {
758759
res: Result<T, InterpErrorInfo<'tcx>>,
759760
guard: Guard,

compiler/rustc_parse/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ parse_invalid_meta_item = expected unsuffixed literal, found `{$token}`
422422
423423
parse_invalid_offset_of = offset_of expects dot-separated field and variant names
424424
425+
parse_invalid_path_sep_in_fn_definition = invalid path separator in function definition
426+
.suggestion = remove invalid path separator
427+
425428
parse_invalid_unicode_escape = invalid unicode character escape
426429
.label = invalid escape
427430
.help = unicode escape must {$surrogate ->

compiler/rustc_parse/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,14 @@ pub(crate) struct MissingFnParams {
17551755
pub span: Span,
17561756
}
17571757

1758+
#[derive(Diagnostic)]
1759+
#[diag(parse_invalid_path_sep_in_fn_definition)]
1760+
pub(crate) struct InvalidPathSepInFnDefinition {
1761+
#[primary_span]
1762+
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
1763+
pub span: Span,
1764+
}
1765+
17581766
#[derive(Diagnostic)]
17591767
#[diag(parse_missing_trait_in_trait_impl)]
17601768
pub(crate) struct MissingTraitInTraitImpl {

compiler/rustc_parse/src/parser/generics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ impl<'a> Parser<'a> {
269269
/// | ( < lifetimes , typaramseq ( , )? > )
270270
/// where typaramseq = ( typaram ) | ( typaram , typaramseq )
271271
pub(super) fn parse_generics(&mut self) -> PResult<'a, ast::Generics> {
272+
// invalid path separator `::` in function definition
273+
// for example `fn invalid_path_separator::<T>() {}`
274+
if self.eat_noexpect(&token::PathSep) {
275+
self.dcx()
276+
.emit_err(errors::InvalidPathSepInFnDefinition { span: self.prev_token.span });
277+
}
278+
272279
let span_lo = self.token.span;
273280
let (params, span) = if self.eat_lt() {
274281
let params = self.parse_generic_params()?;

library/alloc/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173
#![feature(allow_internal_unstable)]
174174
#![feature(cfg_sanitize)]
175175
#![feature(const_precise_live_drops)]
176-
#![feature(const_ptr_write)]
177176
#![feature(const_try)]
178177
#![feature(decl_macro)]
179178
#![feature(dropck_eyepatch)]

library/alloc/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#![feature(const_cow_is_borrowed)]
88
#![feature(const_heap)]
99
#![cfg_attr(bootstrap, feature(const_mut_refs))]
10-
#![feature(const_ptr_write)]
1110
#![feature(const_try)]
1211
#![feature(core_intrinsics)]
1312
#![feature(extract_if)]

library/core/src/intrinsics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ extern "rust-intrinsic" {
10841084
/// it does not require an `unsafe` block.
10851085
/// Therefore, implementations must not require the user to uphold
10861086
/// any safety invariants.
1087-
#[rustc_const_unstable(feature = "const_intrinsic_forget", issue = "none")]
1087+
#[rustc_const_stable(feature = "const_intrinsic_forget", since = "CURRENT_RUSTC_VERSION")]
10881088
#[rustc_safe_intrinsic]
10891089
#[rustc_nounwind]
10901090
pub fn forget<T: ?Sized>(_: T);
@@ -2688,7 +2688,7 @@ extern "rust-intrinsic" {
26882688
/// This intrinsic can *only* be called where the pointer is a local without
26892689
/// projections (`write_via_move(ptr, x)`, not `write_via_move(*ptr, x)`) so
26902690
/// that it trivially obeys runtime-MIR rules about derefs in operands.
2691-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
2691+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
26922692
#[rustc_nounwind]
26932693
pub fn write_via_move<T>(ptr: *mut T, value: T);
26942694

@@ -3525,13 +3525,13 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
35253525
#[doc(alias = "memset")]
35263526
#[stable(feature = "rust1", since = "1.0.0")]
35273527
#[rustc_allowed_through_unstable_modules]
3528-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
3528+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
35293529
#[inline(always)]
35303530
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
35313531
#[rustc_diagnostic_item = "ptr_write_bytes"]
35323532
pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
35333533
extern "rust-intrinsic" {
3534-
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
3534+
#[rustc_const_stable(feature = "const_ptr_write", since = "CURRENT_RUSTC_VERSION")]
35353535
#[rustc_nounwind]
35363536
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
35373537
}

0 commit comments

Comments
 (0)