Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 9b735a7

Browse files
committed
Auto merge of rust-lang#104083 - JohnTitor:rollup-lo3wbzs, r=JohnTitor
Rollup of 9 pull requests Successful merges: - rust-lang#103885 (rustdoc: various cross-crate reexport fixes) - rust-lang#103914 (Make underscore_literal_suffix a hard error.) - rust-lang#104045 (Add type_array to BaseTypeMethods) - rust-lang#104056 (Vec: IntoIterator signature consistency) - rust-lang#104059 (Fix typo in `rustc_middle/lint.rs`) - rust-lang#104062 (rustdoc: remove unused CSS `#sidebar-filler`) - rust-lang#104065 (Migrate rust logo filter to CSS variables) - rust-lang#104066 (LLVM 16: Update RISCV data layout) - rust-lang#104074 (rustdoc: Add an example for round that is different from truncate) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7eef946 + 7ca833e commit 9b735a7

37 files changed

+242
-144
lines changed

compiler/rustc_codegen_gcc/src/type_.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,27 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
201201
fn val_ty(&self, value: RValue<'gcc>) -> Type<'gcc> {
202202
value.get_type()
203203
}
204+
205+
fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
206+
if let Some(struct_type) = ty.is_struct() {
207+
if struct_type.get_field_count() == 0 {
208+
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
209+
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
210+
// zero for ZSTs.
211+
// FIXME(antoyo): fix gccjit API.
212+
len = 0;
213+
}
214+
}
215+
216+
// NOTE: see note above. Some other test uses usize::MAX.
217+
if len == u64::MAX {
218+
len = 0;
219+
}
220+
221+
let len: i32 = len.try_into().expect("array len");
222+
223+
self.context.new_array_type(None, ty, len)
224+
}
204225
}
205226

206227
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
@@ -227,27 +248,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
227248
self.context.new_opaque_struct_type(None, name)
228249
}
229250

230-
pub fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
231-
if let Some(struct_type) = ty.is_struct() {
232-
if struct_type.get_field_count() == 0 {
233-
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
234-
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
235-
// zero for ZSTs.
236-
// FIXME(antoyo): fix gccjit API.
237-
len = 0;
238-
}
239-
}
240-
241-
// NOTE: see note above. Some other test uses usize::MAX.
242-
if len == u64::MAX {
243-
len = 0;
244-
}
245-
246-
let len: i32 = len.try_into().expect("array len");
247-
248-
self.context.new_array_type(None, ty, len)
249-
}
250-
251251
pub fn type_bool(&self) -> Type<'gcc> {
252252
self.context.new_type::<bool>()
253253
}

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ pub unsafe fn create_module<'ll>(
158158
if sess.target.arch == "s390x" {
159159
target_data_layout = target_data_layout.replace("-v128:64", "");
160160
}
161+
162+
if sess.target.arch == "riscv64" {
163+
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
164+
}
161165
}
162166

163167
// Ensure the data-layout values hardcoded remain the defaults.

compiler/rustc_codegen_llvm/src/type_.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ impl<'ll> CodegenCx<'ll, '_> {
127127
pub(crate) fn type_variadic_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
128128
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, True) }
129129
}
130-
131-
pub(crate) fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
132-
unsafe { llvm::LLVMRustArrayType(ty, len) }
133-
}
134130
}
135131

136132
impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
@@ -231,6 +227,10 @@ impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
231227
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
232228
common::val_ty(v)
233229
}
230+
231+
fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
232+
unsafe { llvm::LLVMRustArrayType(ty, len) }
233+
}
234234
}
235235

236236
impl Type {

compiler/rustc_codegen_ssa/src/traits/type_.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
2222
fn type_f32(&self) -> Self::Type;
2323
fn type_f64(&self) -> Self::Type;
2424

25+
fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
2526
fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
2627
fn type_struct(&self, els: &[Self::Type], packed: bool) -> Self::Type;
2728
fn type_kind(&self, ty: Self::Type) -> TypeKind;

compiler/rustc_lexer/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ pub enum TokenKind {
8888
/// tokens.
8989
UnknownPrefix,
9090

91-
/// Examples: `"12_u8"`, `"1.0e-40"`, `b"123`.
91+
/// Examples: `12u8`, `1.0e-40`, `b"123"`. Note that `_` is an invalid
92+
/// suffix, but may be present here on string and float literals. Users of
93+
/// this type will need to check for and reject that case.
9294
///
9395
/// See [LiteralKind] for more details.
9496
Literal { kind: LiteralKind, suffix_start: u32 },
@@ -840,12 +842,13 @@ impl Cursor<'_> {
840842
self.eat_decimal_digits()
841843
}
842844

843-
// Eats the suffix of the literal, e.g. "_u8".
845+
// Eats the suffix of the literal, e.g. "u8".
844846
fn eat_literal_suffix(&mut self) {
845847
self.eat_identifier();
846848
}
847849

848-
// Eats the identifier.
850+
// Eats the identifier. Note: succeeds on `_`, which isn't a valid
851+
// identifer.
849852
fn eat_identifier(&mut self) {
850853
if !is_id_start(self.first()) {
851854
return;

compiler/rustc_middle/src/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub fn explain_lint_level_source(
276276

277277
/// The innermost function for emitting lints.
278278
///
279-
/// If you are loocking to implement a lint, look for higher level functions,
279+
/// If you are looking to implement a lint, look for higher level functions,
280280
/// for example:
281281
/// - [`TyCtxt::emit_spanned_lint`]
282282
/// - [`TyCtxt::struct_span_lint_hir`]

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,10 @@ impl<'a> StringReader<'a> {
175175
if string == "_" {
176176
self.sess
177177
.span_diagnostic
178-
.struct_span_warn(
178+
.struct_span_err(
179179
self.mk_sp(suffix_start, self.pos),
180180
"underscore literal suffix is not allowed",
181181
)
182-
.warn(
183-
"this was previously accepted by the compiler but is \
184-
being phased out; it will become a hard error in \
185-
a future release!",
186-
)
187-
.note(
188-
"see issue #42326 \
189-
<https://github.com/rust-lang/rust/issues/42326> \
190-
for more information",
191-
)
192182
.emit();
193183
None
194184
} else {

compiler/rustc_target/src/spec/riscv64gc_unknown_freebsd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
44
Target {
55
llvm_target: "riscv64-unknown-freebsd".into(),
66
pointer_width: 64,
7-
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
7+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
88
arch: "riscv64".into(),
99
options: TargetOptions {
1010
code_model: Some(CodeModel::Medium),

compiler/rustc_target/src/spec/riscv64gc_unknown_linux_gnu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
44
Target {
55
llvm_target: "riscv64-unknown-linux-gnu".into(),
66
pointer_width: 64,
7-
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
7+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
88
arch: "riscv64".into(),
99
options: TargetOptions {
1010
code_model: Some(CodeModel::Medium),

compiler/rustc_target/src/spec/riscv64gc_unknown_linux_musl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub fn target() -> Target {
44
Target {
55
llvm_target: "riscv64-unknown-linux-musl".into(),
66
pointer_width: 64,
7-
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),
7+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
88
arch: "riscv64".into(),
99
options: TargetOptions {
1010
code_model: Some(CodeModel::Medium),

0 commit comments

Comments
 (0)