Skip to content

Commit 537ccdf

Browse files
committed
Auto merge of #70692 - Centril:rollup-d0t4ecx, r=Centril
Rollup of 8 pull requests Successful merges: - #70281 (Implement Hash for Infallible) - #70421 (parse: recover on `const fn()` / `async fn()`) - #70615 (Renamed `PerDefTables` to `Tables`) - #70631 (Update cargo) - #70634 (Remove some reexports in `rustc_middle`) - #70658 (add `STILL_FURTHER_SPECIALIZABLE` flag) - #70678 (Add missing markdown rust annotation) - #70681 (Handle unterminated raw strings with no #s properly) Failed merges: r? @ghost
2 parents 0f72ce1 + ec0da72 commit 537ccdf

File tree

151 files changed

+892
-669
lines changed

Some content is hidden

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

151 files changed

+892
-669
lines changed

src/doc/unstable-book/src/language-features/generators.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Feedback on the design and usage is always appreciated!
8787

8888
The `Generator` trait in `std::ops` currently looks like:
8989

90-
```
90+
```rust
9191
# #![feature(arbitrary_self_types, generator_trait)]
9292
# use std::ops::GeneratorState;
9393
# use std::pin::Pin;
@@ -107,7 +107,7 @@ point for executing the `Generator` itself.
107107

108108
The return value of `resume`, `GeneratorState`, looks like:
109109

110-
```
110+
```rust
111111
pub enum GeneratorState<Y, R> {
112112
Yielded(Y),
113113
Complete(R),

src/libcore/convert/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#![stable(feature = "rust1", since = "1.0.0")]
4242

4343
use crate::fmt;
44+
use crate::hash::{Hash, Hasher};
4445

4546
mod num;
4647

@@ -746,3 +747,10 @@ impl From<!> for Infallible {
746747
x
747748
}
748749
}
750+
751+
#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
752+
impl Hash for Infallible {
753+
fn hash<H: Hasher>(&self, _: &mut H) {
754+
match *self {}
755+
}
756+
}

src/librustc_codegen_llvm/abi.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
1010
use rustc_codegen_ssa::traits::*;
1111
use rustc_codegen_ssa::MemFlags;
1212
use rustc_middle::bug;
13-
use rustc_middle::ty::layout::{self};
13+
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
1414
use rustc_middle::ty::Ty;
1515
use rustc_target::abi::call::ArgAbi;
16-
use rustc_target::abi::{HasDataLayout, LayoutOf};
17-
18-
use libc::c_uint;
19-
20-
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
2116
pub use rustc_target::abi::call::*;
17+
use rustc_target::abi::{self, HasDataLayout, Int, LayoutOf};
2218
pub use rustc_target::spec::abi::Abi;
2319

20+
use libc::c_uint;
21+
2422
macro_rules! for_each_kind {
2523
($flags: ident, $f: ident, $($kind: ident),+) => ({
2624
$(if $flags.contains(ArgAttribute::$kind) { $f(llvm::Attribute::$kind) })+
@@ -450,11 +448,11 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
450448
PassMode::Indirect(ref attrs, _) => apply(attrs, Some(self.ret.layout.llvm_type(bx))),
451449
_ => {}
452450
}
453-
if let layout::Abi::Scalar(ref scalar) = self.ret.layout.abi {
451+
if let abi::Abi::Scalar(ref scalar) = self.ret.layout.abi {
454452
// If the value is a boolean, the range is 0..2 and that ultimately
455453
// become 0..0 when the type becomes i1, which would be rejected
456454
// by the LLVM verifier.
457-
if let layout::Int(..) = scalar.value {
455+
if let Int(..) = scalar.value {
458456
if !scalar.is_bool() {
459457
let range = scalar.valid_range_exclusive(bx);
460458
if range.start != range.end {

src/librustc_codegen_llvm/builder.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ use rustc_codegen_ssa::MemFlags;
1616
use rustc_data_structures::const_cstr;
1717
use rustc_data_structures::small_c_str::SmallCStr;
1818
use rustc_hir::def_id::DefId;
19-
use rustc_middle::ty::layout::{self, Align, Size, TyAndLayout};
19+
use rustc_middle::ty::layout::TyAndLayout;
2020
use rustc_middle::ty::{self, Ty, TyCtxt};
2121
use rustc_session::config::{self, Sanitizer};
22+
use rustc_target::abi::{self, Align, Size};
2223
use rustc_target::spec::{HasTargetSpec, Target};
2324
use std::borrow::Cow;
2425
use std::ffi::CStr;
@@ -60,8 +61,8 @@ impl BackendTypes for Builder<'_, 'll, 'tcx> {
6061
type DIVariable = <CodegenCx<'ll, 'tcx> as BackendTypes>::DIVariable;
6162
}
6263

63-
impl ty::layout::HasDataLayout for Builder<'_, '_, '_> {
64-
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
64+
impl abi::HasDataLayout for Builder<'_, '_, '_> {
65+
fn data_layout(&self) -> &abi::TargetDataLayout {
6566
self.cx.data_layout()
6667
}
6768
}
@@ -84,7 +85,7 @@ impl HasTargetSpec for Builder<'_, '_, 'tcx> {
8485
}
8586
}
8687

87-
impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
88+
impl abi::LayoutOf for Builder<'_, '_, 'tcx> {
8889
type Ty = Ty<'tcx>;
8990
type TyAndLayout = TyAndLayout<'tcx>;
9091

@@ -435,17 +436,17 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
435436
fn scalar_load_metadata<'a, 'll, 'tcx>(
436437
bx: &mut Builder<'a, 'll, 'tcx>,
437438
load: &'ll Value,
438-
scalar: &layout::Scalar,
439+
scalar: &abi::Scalar,
439440
) {
440441
let vr = scalar.valid_range.clone();
441442
match scalar.value {
442-
layout::Int(..) => {
443+
abi::Int(..) => {
443444
let range = scalar.valid_range_exclusive(bx);
444445
if range.start != range.end {
445446
bx.range_metadata(load, range);
446447
}
447448
}
448-
layout::Pointer if vr.start() < vr.end() && !vr.contains(&0) => {
449+
abi::Pointer if vr.start() < vr.end() && !vr.contains(&0) => {
449450
bx.nonnull_metadata(load);
450451
}
451452
_ => {}
@@ -465,16 +466,16 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
465466
}
466467
let llval = const_llval.unwrap_or_else(|| {
467468
let load = self.load(place.llval, place.align);
468-
if let layout::Abi::Scalar(ref scalar) = place.layout.abi {
469+
if let abi::Abi::Scalar(ref scalar) = place.layout.abi {
469470
scalar_load_metadata(self, load, scalar);
470471
}
471472
load
472473
});
473474
OperandValue::Immediate(to_immediate(self, llval, place.layout))
474-
} else if let layout::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
475+
} else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
475476
let b_offset = a.value.size(self).align_to(b.value.align(self).abi);
476477

477-
let mut load = |i, scalar: &layout::Scalar, align| {
478+
let mut load = |i, scalar: &abi::Scalar, align| {
478479
let llptr = self.struct_gep(place.llval, i as u64);
479480
let load = self.load(llptr, align);
480481
scalar_load_metadata(self, load, scalar);

src/librustc_codegen_llvm/common.rs

+12-19
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22

33
//! Code that is useful in various codegen modules.
44
5-
use crate::consts;
5+
use crate::consts::{self, const_alloc_to_llvm};
6+
pub use crate::context::CodegenCx;
67
use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
78
use crate::type_::Type;
89
use crate::type_of::LayoutLlvmExt;
910
use crate::value::Value;
10-
use log::debug;
11-
use rustc_codegen_ssa::traits::*;
12-
use rustc_middle::bug;
1311

14-
use crate::consts::const_alloc_to_llvm;
12+
use rustc_ast::ast::Mutability;
1513
use rustc_codegen_ssa::mir::place::PlaceRef;
14+
use rustc_codegen_ssa::traits::*;
15+
use rustc_middle::bug;
1616
use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar};
17-
use rustc_middle::ty::layout::{self, HasDataLayout, LayoutOf, Size, TyAndLayout};
18-
19-
use libc::{c_char, c_uint};
20-
21-
use rustc_ast::ast::Mutability;
17+
use rustc_middle::ty::layout::TyAndLayout;
2218
use rustc_span::symbol::Symbol;
19+
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Pointer, Size};
2320

24-
pub use crate::context::CodegenCx;
21+
use libc::{c_char, c_uint};
22+
use log::debug;
2523

2624
/*
2725
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
@@ -229,12 +227,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
229227
})
230228
}
231229

232-
fn scalar_to_backend(
233-
&self,
234-
cv: Scalar,
235-
layout: &layout::Scalar,
236-
llty: &'ll Type,
237-
) -> &'ll Value {
230+
fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: &'ll Type) -> &'ll Value {
238231
let bitsize = if layout.is_bool() { 1 } else { layout.value.size(self).bits() };
239232
match cv {
240233
Scalar::Raw { size: 0, .. } => {
@@ -244,7 +237,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
244237
Scalar::Raw { data, size } => {
245238
assert_eq!(size as u64, layout.value.size(self).bytes());
246239
let llval = self.const_uint_big(self.type_ix(bitsize), data);
247-
if layout.value == layout::Pointer {
240+
if layout.value == Pointer {
248241
unsafe { llvm::LLVMConstIntToPtr(llval, llty) }
249242
} else {
250243
self.const_bitcast(llval, llty)
@@ -278,7 +271,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
278271
1,
279272
)
280273
};
281-
if layout.value != layout::Pointer {
274+
if layout.value != Pointer {
282275
unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
283276
} else {
284277
self.const_bitcast(llval, llty)

src/librustc_codegen_llvm/consts.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ use rustc_middle::mir::interpret::{
1616
read_target_uint, Allocation, ConstValue, ErrorHandled, Pointer,
1717
};
1818
use rustc_middle::mir::mono::MonoItem;
19-
use rustc_middle::ty::layout::{self, Align, LayoutOf, Size};
2019
use rustc_middle::ty::{self, Instance, Ty};
2120
use rustc_middle::{bug, span_bug};
2221
use rustc_span::symbol::{sym, Symbol};
2322
use rustc_span::Span;
24-
use rustc_target::abi::HasDataLayout;
23+
use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size};
2524

2625
use std::ffi::CStr;
2726

@@ -56,7 +55,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
5655
as u64;
5756
llvals.push(cx.scalar_to_backend(
5857
Pointer::new(alloc_id, Size::from_bytes(ptr_offset)).into(),
59-
&layout::Scalar { value: layout::Primitive::Pointer, valid_range: 0..=!0 },
58+
&Scalar { value: Primitive::Pointer, valid_range: 0..=!0 },
6059
cx.type_i8p(),
6160
));
6261
next_offset = offset + pointer_size;

src/librustc_codegen_llvm/context.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ use rustc_data_structures::fx::FxHashMap;
1414
use rustc_data_structures::small_c_str::SmallCStr;
1515
use rustc_middle::bug;
1616
use rustc_middle::mir::mono::CodegenUnit;
17-
use rustc_middle::ty::layout::{
18-
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyAndLayout, VariantIdx,
19-
};
17+
use rustc_middle::ty::layout::{HasParamEnv, LayoutError, TyAndLayout};
2018
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2119
use rustc_session::config::{self, CFGuard, DebugInfo};
2220
use rustc_session::Session;
2321
use rustc_span::source_map::{Span, DUMMY_SP};
2422
use rustc_span::symbol::Symbol;
23+
use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx};
2524
use rustc_target::spec::{HasTargetSpec, Target};
2625

2726
use std::cell::{Cell, RefCell};
@@ -817,8 +816,8 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
817816
}
818817
}
819818

820-
impl ty::layout::HasDataLayout for CodegenCx<'ll, 'tcx> {
821-
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
819+
impl HasDataLayout for CodegenCx<'ll, 'tcx> {
820+
fn data_layout(&self) -> &TargetDataLayout {
822821
&self.tcx.data_layout
823822
}
824823
}

0 commit comments

Comments
 (0)