Skip to content

Commit d2db689

Browse files
committed
Auto merge of #3069 - rust-lang:rustup-2023-09-21, r=RalfJung
Automatic sync from rustc
2 parents 70f3d3e + ed8fbcb commit d2db689

File tree

262 files changed

+9392
-5627
lines changed

Some content is hidden

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

262 files changed

+9392
-5627
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
[submodule "src/llvm-project"]
3434
path = src/llvm-project
3535
url = https://github.com/rust-lang/llvm-project.git
36-
branch = rustc/17.0-2023-07-29
36+
branch = rustc/17.0-2023-09-19
3737
shallow = true
3838
[submodule "src/doc/embedded-book"]
3939
path = src/doc/embedded-book

Cargo.lock

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,13 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
627627

628628
[[package]]
629629
name = "colored"
630-
version = "2.0.0"
630+
version = "2.0.4"
631631
source = "registry+https://github.com/rust-lang/crates.io-index"
632-
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
632+
checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6"
633633
dependencies = [
634-
"atty",
634+
"is-terminal",
635635
"lazy_static",
636-
"winapi",
636+
"windows-sys 0.48.0",
637637
]
638638

639639
[[package]]
@@ -644,9 +644,9 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335"
644644

645645
[[package]]
646646
name = "compiler_builtins"
647-
version = "0.1.100"
647+
version = "0.1.101"
648648
source = "registry+https://github.com/rust-lang/crates.io-index"
649-
checksum = "d6c0f24437059853f0fa64afc51f338f93647a3de4cf3358ba1bb4171a199775"
649+
checksum = "01a6d58e9c3408138099a396a98fd0d0e6cfb25d723594d2ae48b5004513fd5b"
650650
dependencies = [
651651
"cc",
652652
"rustc-std-workspace-core",
@@ -1169,19 +1169,6 @@ dependencies = [
11691169
"termcolor",
11701170
]
11711171

1172-
[[package]]
1173-
name = "env_logger"
1174-
version = "0.9.3"
1175-
source = "registry+https://github.com/rust-lang/crates.io-index"
1176-
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
1177-
dependencies = [
1178-
"atty",
1179-
"humantime 2.1.0",
1180-
"log",
1181-
"regex",
1182-
"termcolor",
1183-
]
1184-
11851172
[[package]]
11861173
name = "env_logger"
11871174
version = "0.10.0"
@@ -2142,9 +2129,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
21422129

21432130
[[package]]
21442131
name = "libc"
2145-
version = "0.2.147"
2132+
version = "0.2.148"
21462133
source = "registry+https://github.com/rust-lang/crates.io-index"
2147-
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
2134+
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
21482135
dependencies = [
21492136
"rustc-std-workspace-core",
21502137
]
@@ -2454,7 +2441,7 @@ version = "0.1.0"
24542441
dependencies = [
24552442
"colored",
24562443
"ctrlc",
2457-
"env_logger 0.9.3",
2444+
"env_logger 0.10.0",
24582445
"getrandom",
24592446
"lazy_static",
24602447
"libc",
@@ -5591,11 +5578,11 @@ dependencies = [
55915578

55925579
[[package]]
55935580
name = "tracing-tree"
5594-
version = "0.2.3"
5581+
version = "0.2.4"
55955582
source = "registry+https://github.com/rust-lang/crates.io-index"
5596-
checksum = "4f9742d8df709837409dbb22aa25dd7769c260406f20ff48a2320b80a4a6aed0"
5583+
checksum = "92d6b63348fad3ae0439b8bebf8d38fb5bda0b115d7a8a7e6f165f12790c58c3"
55975584
dependencies = [
5598-
"atty",
5585+
"is-terminal",
55995586
"nu-ansi-term",
56005587
"tracing-core",
56015588
"tracing-log",

RELEASES.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.72.1 (2023-09-19)
2+
===========================
3+
4+
- [Adjust codegen change to improve LLVM codegen](https://github.com/rust-lang/rust/pull/115236)
5+
- [rustdoc: Fix self ty params in objects with lifetimes](https://github.com/rust-lang/rust/pull/115276)
6+
- [Fix regression in compile times](https://github.com/rust-lang/rust/pull/114948)
7+
- Resolve some ICE regressions in the compiler:
8+
- [#115215](https://github.com/rust-lang/rust/pull/115215)
9+
- [#115559](https://github.com/rust-lang/rust/pull/115559)
10+
111
Version 1.72.0 (2023-08-24)
212
==========================
313

@@ -103,6 +113,16 @@ Compatibility Notes
103113
to a registry.
104114
[#12291](https://github.com/rust-lang/cargo/pull/12291)
105115

116+
Version 1.71.1 (2023-08-03)
117+
===========================
118+
119+
- [Fix CVE-2023-38497: Cargo did not respect the umask when extracting dependencies](https://github.com/rust-lang/cargo/security/advisories/GHSA-j3xp-wfr4-hx87)
120+
- [Fix bash completion for users of Rustup](https://github.com/rust-lang/rust/pull/113579)
121+
- [Do not show `suspicious_double_ref_op` lint when calling `borrow()`](https://github.com/rust-lang/rust/pull/112517)
122+
- [Fix ICE: substitute types before checking inlining compatibility](https://github.com/rust-lang/rust/pull/113802)
123+
- [Fix ICE: don't use `can_eq` in `derive(..)` suggestion for missing method](https://github.com/rust-lang/rust/pull/111516)
124+
- [Fix building Rust 1.71.0 from the source tarball](https://github.com/rust-lang/rust/issues/113678)
125+
106126
Version 1.71.0 (2023-07-13)
107127
==========================
108128

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,12 +1431,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14311431
),
14321432
ImplTraitContext::Universal => {
14331433
let span = t.span;
1434-
self.create_def(
1435-
self.current_hir_id_owner.def_id,
1436-
*def_node_id,
1437-
DefPathData::ImplTrait,
1438-
span,
1439-
);
14401434

14411435
// HACK: pprust breaks strings with newlines when the type
14421436
// gets too long. We don't want these to show up in compiler
@@ -1447,6 +1441,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14471441
span,
14481442
);
14491443

1444+
self.create_def(
1445+
self.current_hir_id_owner.def_id,
1446+
*def_node_id,
1447+
DefPathData::TypeNs(ident.name),
1448+
span,
1449+
);
14501450
let (param, bounds, path) = self.lower_universal_param_and_bounds(
14511451
*def_node_id,
14521452
span,

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
44
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
5-
use rustc_middle::mir::interpret::{read_target_uint, AllocId, ConstValue, GlobalAlloc, Scalar};
5+
use rustc_middle::mir::interpret::{read_target_uint, AllocId, GlobalAlloc, Scalar};
6+
use rustc_middle::mir::ConstValue;
67

78
use cranelift_module::*;
89

@@ -183,15 +184,11 @@ pub(crate) fn codegen_const_value<'tcx>(
183184
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),
184185
layout,
185186
),
186-
ConstValue::Slice { data, start, end } => {
187+
ConstValue::Slice { data, meta } => {
187188
let alloc_id = fx.tcx.reserve_and_set_memory_alloc(data);
188-
let ptr = pointer_for_allocation(fx, alloc_id)
189-
.offset_i64(fx, i64::try_from(start).unwrap())
190-
.get_addr(fx);
191-
let len = fx
192-
.bcx
193-
.ins()
194-
.iconst(fx.pointer_type, i64::try_from(end.checked_sub(start).unwrap()).unwrap());
189+
let ptr = pointer_for_allocation(fx, alloc_id).get_addr(fx);
190+
// FIXME: the `try_from` here can actually fail, e.g. for very long ZST slices.
191+
let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(meta).unwrap());
195192
CValue::by_val_pair(ptr, len, layout)
196193
}
197194
}

compiler/rustc_codegen_ssa/src/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(non_camel_case_types)]
22

33
use rustc_hir::LangItem;
4-
use rustc_middle::mir::interpret::ConstValue;
4+
use rustc_middle::mir;
55
use rustc_middle::ty::{self, layout::TyAndLayout, Ty, TyCtxt};
66
use rustc_span::Span;
77

@@ -194,10 +194,10 @@ pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
194194
pub fn asm_const_to_str<'tcx>(
195195
tcx: TyCtxt<'tcx>,
196196
sp: Span,
197-
const_value: ConstValue<'tcx>,
197+
const_value: mir::ConstValue<'tcx>,
198198
ty_and_layout: TyAndLayout<'tcx>,
199199
) -> String {
200-
let ConstValue::Scalar(scalar) = const_value else {
200+
let mir::ConstValue::Scalar(scalar) = const_value else {
201201
span_bug!(sp, "expected Scalar for promoted asm const, but got {:#?}", const_value)
202202
};
203203
let value = scalar.assert_bits(ty_and_layout.size);

compiler/rustc_codegen_ssa/src/mir/constant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::errors;
22
use crate::mir::operand::OperandRef;
33
use crate::traits::*;
44
use rustc_middle::mir;
5-
use rustc_middle::mir::interpret::{ConstValue, ErrorHandled};
5+
use rustc_middle::mir::interpret::ErrorHandled;
66
use rustc_middle::ty::layout::HasTyCtxt;
77
use rustc_middle::ty::{self, Ty};
88
use rustc_target::abi::Abi;
@@ -20,7 +20,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
2020
OperandRef::from_const(bx, val, ty)
2121
}
2222

23-
pub fn eval_mir_constant(&self, constant: &mir::Constant<'tcx>) -> ConstValue<'tcx> {
23+
pub fn eval_mir_constant(&self, constant: &mir::Constant<'tcx>) -> mir::ConstValue<'tcx> {
2424
self.monomorphize(constant.literal)
2525
.eval(self.cx.tcx(), ty::ParamEnv::reveal_all(), Some(constant.span))
2626
.expect("erroneous constant not captured by required_consts")

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::glue;
66
use crate::traits::*;
77
use crate::MemFlags;
88

9-
use rustc_middle::mir;
10-
use rustc_middle::mir::interpret::{alloc_range, ConstValue, Pointer, Scalar};
9+
use rustc_middle::mir::interpret::{alloc_range, Pointer, Scalar};
10+
use rustc_middle::mir::{self, ConstValue};
1111
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1212
use rustc_middle::ty::Ty;
1313
use rustc_target::abi::{self, Abi, Align, Size};
@@ -86,7 +86,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
8686

8787
pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
8888
bx: &mut Bx,
89-
val: ConstValue<'tcx>,
89+
val: mir::ConstValue<'tcx>,
9090
ty: Ty<'tcx>,
9191
) -> Self {
9292
let layout = bx.layout_of(ty);
@@ -100,23 +100,20 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
100100
OperandValue::Immediate(llval)
101101
}
102102
ConstValue::ZeroSized => return OperandRef::zero_sized(layout),
103-
ConstValue::Slice { data, start, end } => {
103+
ConstValue::Slice { data, meta } => {
104104
let Abi::ScalarPair(a_scalar, _) = layout.abi else {
105105
bug!("from_const: invalid ScalarPair layout: {:#?}", layout);
106106
};
107107
let a = Scalar::from_pointer(
108-
Pointer::new(
109-
bx.tcx().reserve_and_set_memory_alloc(data),
110-
Size::from_bytes(start),
111-
),
108+
Pointer::new(bx.tcx().reserve_and_set_memory_alloc(data), Size::ZERO),
112109
&bx.tcx(),
113110
);
114111
let a_llval = bx.scalar_to_backend(
115112
a,
116113
a_scalar,
117114
bx.scalar_pair_element_backend_type(layout, 0, true),
118115
);
119-
let b_llval = bx.const_usize((end - start) as u64);
116+
let b_llval = bx.const_usize(meta);
120117
OperandValue::Pair(a_llval, b_llval)
121118
}
122119
ConstValue::Indirect { alloc_id, offset } => {

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use crate::errors::ConstEvalError;
44
use either::{Left, Right};
55

66
use rustc_hir::def::DefKind;
7-
use rustc_middle::mir;
87
use rustc_middle::mir::interpret::{ErrorHandled, InterpErrorInfo};
98
use rustc_middle::mir::pretty::write_allocation_bytes;
9+
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
1010
use rustc_middle::traits::Reveal;
1111
use rustc_middle::ty::layout::LayoutOf;
1212
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -18,9 +18,8 @@ use super::{CanAccessStatics, CompileTimeEvalContext, CompileTimeInterpreter};
1818
use crate::errors;
1919
use crate::interpret::eval_nullary_intrinsic;
2020
use crate::interpret::{
21-
intern_const_alloc_recursive, ConstAlloc, ConstValue, CtfeValidationMode, GlobalId, Immediate,
22-
InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking,
23-
StackPopCleanup,
21+
intern_const_alloc_recursive, CtfeValidationMode, GlobalId, Immediate, InternKind, InterpCx,
22+
InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, StackPopCleanup,
2423
};
2524

2625
// Returns a pointer to where the result lives
@@ -152,19 +151,26 @@ pub(super) fn op_to_const<'tcx>(
152151
Immediate::Scalar(x) => ConstValue::Scalar(x),
153152
Immediate::ScalarPair(a, b) => {
154153
debug!("ScalarPair(a: {:?}, b: {:?})", a, b);
155-
// FIXME: assert that this has an appropriate type.
156-
// Currently we actually get here for non-[u8] slices during valtree construction!
157-
let msg = "`op_to_const` on an immediate scalar pair must only be used on slice references to actually allocated memory";
154+
// This codepath solely exists for `valtree_to_const_value` to not need to generate
155+
// a `ConstValue::Indirect` for wide references, so it is tightly restricted to just
156+
// that case.
157+
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap().ty; // `false` = no raw ptrs
158+
debug_assert!(
159+
matches!(
160+
ecx.tcx.struct_tail_without_normalization(pointee_ty).kind(),
161+
ty::Str | ty::Slice(..),
162+
),
163+
"`ConstValue::Slice` is for slice-tailed types only, but got {}",
164+
imm.layout.ty,
165+
);
166+
let msg = "`op_to_const` on an immediate scalar pair must only be used on slice references to the beginning of an actual allocation";
158167
// We know `offset` is relative to the allocation, so we can use `into_parts`.
159-
// We use `ConstValue::Slice` so that we don't have to generate an allocation for
160-
// `ConstValue::Indirect` here.
161168
let (alloc_id, offset) = a.to_pointer(ecx).expect(msg).into_parts();
162169
let alloc_id = alloc_id.expect(msg);
163170
let data = ecx.tcx.global_alloc(alloc_id).unwrap_memory();
164-
let start = offset.bytes_usize();
165-
let len = b.to_target_usize(ecx).expect(msg);
166-
let len: usize = len.try_into().unwrap();
167-
ConstValue::Slice { data, start, end: start + len }
171+
assert!(offset == abi::Size::ZERO, "{}", msg);
172+
let meta = b.to_target_usize(ecx).expect(msg);
173+
ConstValue::Slice { data, meta }
168174
}
169175
Immediate::Uninit => bug!("`Uninit` is not a valid value for {}", op.layout.ty),
170176
},

compiler/rustc_const_eval/src/const_eval/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Not in interpret to make sure we do not use private implementation details
22

33
use crate::errors::MaxNumNodesInConstErr;
4-
use crate::interpret::{intern_const_alloc_recursive, ConstValue, InternKind, InterpCx, Scalar};
4+
use crate::interpret::{intern_const_alloc_recursive, InternKind, InterpCx, Scalar};
55
use rustc_middle::mir;
66
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
77
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -22,15 +22,15 @@ pub(crate) use valtrees::{const_to_valtree_inner, valtree_to_const_value};
2222
pub(crate) fn const_caller_location(
2323
tcx: TyCtxt<'_>,
2424
(file, line, col): (Symbol, u32, u32),
25-
) -> ConstValue<'_> {
25+
) -> mir::ConstValue<'_> {
2626
trace!("const_caller_location: {}:{}:{}", file, line, col);
2727
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), CanAccessStatics::No);
2828

2929
let loc_place = ecx.alloc_caller_location(file, line, col);
3030
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() {
3131
bug!("intern_const_alloc_recursive should not error in this case")
3232
}
33-
ConstValue::Scalar(Scalar::from_maybe_pointer(loc_place.ptr(), &tcx))
33+
mir::ConstValue::Scalar(Scalar::from_maybe_pointer(loc_place.ptr(), &tcx))
3434
}
3535

3636
// We forbid type-level constants that contain more than `VALTREE_MAX_NODES` nodes.
@@ -87,7 +87,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
8787
#[instrument(skip(tcx), level = "debug")]
8888
pub(crate) fn try_destructure_mir_constant_for_diagnostics<'tcx>(
8989
tcx: TyCtxt<'tcx>,
90-
val: ConstValue<'tcx>,
90+
val: mir::ConstValue<'tcx>,
9191
ty: Ty<'tcx>,
9292
) -> Option<mir::DestructuredConstant<'tcx>> {
9393
let param_env = ty::ParamEnv::reveal_all();

0 commit comments

Comments
 (0)