Skip to content

Commit ef3e386

Browse files
committed
Auto merge of rust-lang#78212 - JohnTitor:rollup-j5r6xuy, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#77420 (Unify const-checking structured errors for `&mut` and `&raw mut`) - rust-lang#77554 (Support signed integers and `char` in v0 mangling) - rust-lang#77976 (Mark inout asm! operands as used in liveness pass) - rust-lang#78009 (Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling) - rust-lang#78084 (Greatly improve display for small mobile devices screens) - rust-lang#78155 (Fix two small issues in compiler/rustc_lint/src/types.rs) - rust-lang#78156 (Fixed build failure of `rustfmt`) - rust-lang#78172 (Add test case for rust-lang#77062) - rust-lang#78188 (Add tracking issue number for pin_static_ref) - rust-lang#78200 (Add `ControlFlow::is_{break,continue}` methods) Failed merges: r? `@ghost`
2 parents c4fe25d + 69e0658 commit ef3e386

File tree

25 files changed

+411
-93
lines changed

25 files changed

+411
-93
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -3276,9 +3276,9 @@ dependencies = [
32763276

32773277
[[package]]
32783278
name = "rustc-demangle"
3279-
version = "0.1.16"
3279+
version = "0.1.18"
32803280
source = "registry+https://github.com/rust-lang/crates.io-index"
3281-
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
3281+
checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
32823282
dependencies = [
32833283
"compiler_builtins",
32843284
"rustc-std-workspace-core",

compiler/rustc_codegen_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ measureme = "0.7.1"
1515
snap = "1"
1616
tracing = "0.1"
1717
rustc_middle = { path = "../rustc_middle" }
18-
rustc-demangle = "0.1"
18+
rustc-demangle = "0.1.18"
1919
rustc_attr = { path = "../rustc_attr" }
2020
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
2121
rustc_data_structures = { path = "../rustc_data_structures" }

compiler/rustc_lint/src/types.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
145145
// We need to preserve the literal's suffix,
146146
// as it may determine typing information.
147147
let suffix = match lit.node {
148-
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str().to_string(),
149-
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str().to_string(),
150-
LitKind::Int(_, LitIntType::Unsuffixed) => "".to_string(),
148+
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str(),
149+
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str(),
150+
LitKind::Int(_, LitIntType::Unsuffixed) => "",
151151
_ => bug!(),
152152
};
153153
let suggestion = format!("{}..={}{}", start, lit_val - 1, suffix);
@@ -170,24 +170,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
170170
// warnings are consistent between 32- and 64-bit platforms.
171171
fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
172172
match int_ty {
173-
ast::IntTy::Isize => (i64::MIN as i128, i64::MAX as i128),
174-
ast::IntTy::I8 => (i8::MIN as i64 as i128, i8::MAX as i128),
175-
ast::IntTy::I16 => (i16::MIN as i64 as i128, i16::MAX as i128),
176-
ast::IntTy::I32 => (i32::MIN as i64 as i128, i32::MAX as i128),
177-
ast::IntTy::I64 => (i64::MIN as i128, i64::MAX as i128),
178-
ast::IntTy::I128 => (i128::MIN as i128, i128::MAX),
173+
ast::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()),
174+
ast::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()),
175+
ast::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()),
176+
ast::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()),
177+
ast::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()),
178+
ast::IntTy::I128 => (i128::MIN, i128::MAX),
179179
}
180180
}
181181

182182
fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
183-
match uint_ty {
184-
ast::UintTy::Usize => (u64::MIN as u128, u64::MAX as u128),
185-
ast::UintTy::U8 => (u8::MIN as u128, u8::MAX as u128),
186-
ast::UintTy::U16 => (u16::MIN as u128, u16::MAX as u128),
187-
ast::UintTy::U32 => (u32::MIN as u128, u32::MAX as u128),
188-
ast::UintTy::U64 => (u64::MIN as u128, u64::MAX as u128),
189-
ast::UintTy::U128 => (u128::MIN, u128::MAX),
190-
}
183+
let max = match uint_ty {
184+
ast::UintTy::Usize => u64::MAX.into(),
185+
ast::UintTy::U8 => u8::MAX.into(),
186+
ast::UintTy::U16 => u16::MAX.into(),
187+
ast::UintTy::U32 => u32::MAX.into(),
188+
ast::UintTy::U64 => u64::MAX.into(),
189+
ast::UintTy::U128 => u128::MAX,
190+
};
191+
(0, max)
191192
}
192193

193194
fn get_bin_hex_repr(cx: &LateContext<'_>, lit: &hir::Lit) -> Option<String> {

compiler/rustc_mir/src/transform/check_consts/ops.rs

+11-27
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ impl NonConstOp for CellBorrow {
224224
}
225225

226226
#[derive(Debug)]
227-
pub struct MutBorrow;
227+
pub struct MutBorrow(pub hir::BorrowKind);
228+
228229
impl NonConstOp for MutBorrow {
229230
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
230231
// Forbid everywhere except in const fn with a feature gate
@@ -236,22 +237,28 @@ impl NonConstOp for MutBorrow {
236237
}
237238

238239
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
240+
let raw = match self.0 {
241+
hir::BorrowKind::Raw => "raw ",
242+
hir::BorrowKind::Ref => "",
243+
};
244+
239245
let mut err = if ccx.const_kind() == hir::ConstContext::ConstFn {
240246
feature_err(
241247
&ccx.tcx.sess.parse_sess,
242248
sym::const_mut_refs,
243249
span,
244-
&format!("mutable references are not allowed in {}s", ccx.const_kind()),
250+
&format!("{}mutable references are not allowed in {}s", raw, ccx.const_kind()),
245251
)
246252
} else {
247253
let mut err = struct_span_err!(
248254
ccx.tcx.sess,
249255
span,
250256
E0764,
251-
"mutable references are not allowed in {}s",
257+
"{}mutable references are not allowed in {}s",
258+
raw,
252259
ccx.const_kind(),
253260
);
254-
err.span_label(span, format!("`&mut` is only allowed in `const fn`"));
261+
err.span_label(span, format!("`&{}mut` is only allowed in `const fn`", raw));
255262
err
256263
};
257264
if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
@@ -270,29 +277,6 @@ impl NonConstOp for MutBorrow {
270277
}
271278
}
272279

273-
// FIXME(ecstaticmorse): Unify this with `MutBorrow`. It has basically the same issues.
274-
#[derive(Debug)]
275-
pub struct MutAddressOf;
276-
impl NonConstOp for MutAddressOf {
277-
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
278-
// Forbid everywhere except in const fn with a feature gate
279-
if ccx.const_kind() == hir::ConstContext::ConstFn {
280-
Status::Unstable(sym::const_mut_refs)
281-
} else {
282-
Status::Forbidden
283-
}
284-
}
285-
286-
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
287-
feature_err(
288-
&ccx.tcx.sess.parse_sess,
289-
sym::const_mut_refs,
290-
span,
291-
&format!("`&raw mut` is not allowed in {}s", ccx.const_kind()),
292-
)
293-
}
294-
}
295-
296280
#[derive(Debug)]
297281
pub struct MutDeref;
298282
impl NonConstOp for MutDeref {

compiler/rustc_mir/src/transform/check_consts/validation.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
525525

526526
if !is_allowed {
527527
if let BorrowKind::Mut { .. } = kind {
528-
self.check_op(ops::MutBorrow);
528+
self.check_op(ops::MutBorrow(hir::BorrowKind::Ref));
529529
} else {
530530
self.check_op(ops::CellBorrow);
531531
}
532532
}
533533
}
534534

535-
Rvalue::AddressOf(Mutability::Mut, _) => self.check_op(ops::MutAddressOf),
535+
Rvalue::AddressOf(Mutability::Mut, _) => {
536+
self.check_op(ops::MutBorrow(hir::BorrowKind::Raw))
537+
}
536538

537539
Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Shallow, ref place)
538540
| Rvalue::AddressOf(Mutability::Not, ref place) => {

compiler/rustc_mir_build/src/lints.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> {
7171

7272
let func_ty = func.ty(body, tcx);
7373
if let ty::FnDef(callee, substs) = *func_ty.kind() {
74-
let (callee, call_substs) =
75-
if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, substs) {
76-
(instance.def_id(), instance.substs)
77-
} else {
78-
(callee, substs)
79-
};
74+
let normalized_substs = tcx.normalize_erasing_regions(param_env, substs);
75+
let (callee, call_substs) = if let Ok(Some(instance)) =
76+
Instance::resolve(tcx, param_env, callee, normalized_substs)
77+
{
78+
(instance.def_id(), instance.substs)
79+
} else {
80+
(callee, normalized_substs)
81+
};
8082

8183
// FIXME(#57965): Make this work across function boundaries
8284

compiler/rustc_passes/src/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11741174
}
11751175
}
11761176
hir::InlineAsmOperand::InOut { expr, .. } => {
1177-
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE);
1177+
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE);
11781178
}
11791179
hir::InlineAsmOperand::SplitInOut { out_expr, .. } => {
11801180
if let Some(expr) = out_expr {

compiler/rustc_symbol_mangling/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ doctest = false
1010
[dependencies]
1111
tracing = "0.1"
1212
punycode = "0.4.0"
13-
rustc-demangle = "0.1.16"
13+
rustc-demangle = "0.1.18"
1414

1515
rustc_ast = { path = "../rustc_ast" }
1616
rustc_span = { path = "../rustc_span" }

compiler/rustc_symbol_mangling/src/v0.rs

+22-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
44
use rustc_hir as hir;
55
use rustc_hir::def_id::{CrateNum, DefId};
66
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
7+
use rustc_middle::mir::interpret::sign_extend;
78
use rustc_middle::ty::print::{Print, Printer};
89
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
910
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
@@ -527,17 +528,31 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
527528
}
528529
let start = self.out.len();
529530

530-
match ct.ty.kind() {
531-
ty::Uint(_) => {}
532-
ty::Bool => {}
531+
let mut neg = false;
532+
let val = match ct.ty.kind() {
533+
ty::Uint(_) | ty::Bool | ty::Char => {
534+
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty)
535+
}
536+
ty::Int(_) => {
537+
let param_env = ty::ParamEnv::reveal_all();
538+
ct.try_eval_bits(self.tcx, param_env, ct.ty).and_then(|b| {
539+
let sz = self.tcx.layout_of(param_env.and(ct.ty)).ok()?.size;
540+
let val = sign_extend(b, sz) as i128;
541+
if val < 0 {
542+
neg = true;
543+
}
544+
Some(val.wrapping_abs() as u128)
545+
})
546+
}
533547
_ => {
534548
bug!("symbol_names: unsupported constant of type `{}` ({:?})", ct.ty, ct);
535549
}
536-
}
537-
self = ct.ty.print(self)?;
550+
};
538551

539-
if let Some(bits) = ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty) {
540-
let _ = write!(self.out, "{:x}_", bits);
552+
if let Some(bits) = val {
553+
// We only print the type if the const can be evaluated.
554+
self = ct.ty.print(self)?;
555+
let _ = write!(self.out, "{}{:x}_", if neg { "n" } else { "" }, bits);
541556
} else {
542557
// NOTE(eddyb) despite having the path, we need to
543558
// encode a placeholder, as the path could refer

library/core/src/ops/control_flow.rs

+14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ impl<C, B> Try for ControlFlow<C, B> {
3232
}
3333

3434
impl<C, B> ControlFlow<C, B> {
35+
/// Returns `true` if this is a `Break` variant.
36+
#[inline]
37+
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
38+
pub fn is_break(&self) -> bool {
39+
matches!(*self, ControlFlow::Break(_))
40+
}
41+
42+
/// Returns `true` if this is a `Continue` variant.
43+
#[inline]
44+
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
45+
pub fn is_continue(&self) -> bool {
46+
matches!(*self, ControlFlow::Continue(_))
47+
}
48+
3549
/// Converts the `ControlFlow` into an `Option` which is `Some` if the
3650
/// `ControlFlow` was `Break` and `None` otherwise.
3751
#[inline]

library/core/src/pin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ impl<T: ?Sized> Pin<&'static T> {
786786
///
787787
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
788788
/// never ends.
789-
#[unstable(feature = "pin_static_ref", issue = "none")]
789+
#[unstable(feature = "pin_static_ref", issue = "78186")]
790790
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
791791
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
792792
// SAFETY: The 'static borrow guarantees the data will not be
@@ -800,7 +800,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
800800
///
801801
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
802802
/// never ends.
803-
#[unstable(feature = "pin_static_ref", issue = "none")]
803+
#[unstable(feature = "pin_static_ref", issue = "78186")]
804804
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
805805
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
806806
// SAFETY: The 'static borrow guarantees the data will not be

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ hashbrown = { version = "0.9.0", default-features = false, features = ['rustc-de
2424

2525
# Dependencies of the `backtrace` crate
2626
addr2line = { version = "0.13.0", optional = true, default-features = false }
27-
rustc-demangle = { version = "0.1.4", features = ['rustc-dep-of-std'] }
27+
rustc-demangle = { version = "0.1.18", features = ['rustc-dep-of-std'] }
2828
miniz_oxide = { version = "0.4.0", optional = true, default-features = false }
2929
[dependencies.object]
3030
version = "0.20"

src/bootstrap/native.rs

+2
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ fn configure_cmake(
378378
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
379379
} else if target.contains("windows") {
380380
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
381+
} else if target.contains("haiku") {
382+
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
381383
}
382384
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
383385
// that case like CMake we cannot easily determine system version either.

src/librustdoc/html/static/rustdoc.css

+35
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,41 @@ h4 > .notable-traits {
15681568
#titles, #titles > div {
15691569
height: 73px;
15701570
}
1571+
1572+
#main > table:not(.table-display) td {
1573+
word-break: break-word;
1574+
min-width: 10%;
1575+
}
1576+
1577+
.search-container > div {
1578+
display: block;
1579+
width: calc(100% - 37px);
1580+
}
1581+
1582+
#crate-search {
1583+
width: 100%;
1584+
border-radius: 4px;
1585+
border: 0;
1586+
}
1587+
1588+
#crate-search + .search-input {
1589+
width: calc(100% + 71px);
1590+
margin-left: -36px;
1591+
}
1592+
1593+
#theme-picker, #settings-menu {
1594+
padding: 5px;
1595+
width: 31px;
1596+
height: 31px;
1597+
}
1598+
1599+
#theme-picker {
1600+
margin-top: -2px;
1601+
}
1602+
1603+
#settings-menu {
1604+
top: 7px;
1605+
}
15711606
}
15721607

15731608
h3.notable {
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#![feature(raw_ref_op)]
22

3-
const A: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
3+
const A: () = { let mut x = 2; &raw mut x; }; //~ mutable reference
44

5-
static B: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
5+
static B: () = { let mut x = 2; &raw mut x; }; //~ mutable reference
66

7-
static mut C: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
7+
static mut C: () = { let mut x = 2; &raw mut x; }; //~ mutable reference
88

99
const fn foo() {
1010
let mut x = 0;
11-
let y = &raw mut x; //~ ERROR `&raw mut` is not allowed
11+
let y = &raw mut x; //~ mutable reference
1212
}
1313

1414
fn main() {}

0 commit comments

Comments
 (0)