Skip to content

Commit 0b63055

Browse files
committed
Auto merge of rust-lang#134026 - workingjubilee:rollup-4r2ihhs, r=<try>
[TEST] Rollup of 5 pull requests Successful merges: - rust-lang#133987 (Define acronym for thread local storage) - rust-lang#133992 (Actually walk into lifetimes and attrs in `EarlyContextAndPass`) - rust-lang#133993 (Fix: typo in E0751 error explanation) - rust-lang#133996 (Move most tests for `-l` and `#[link(..)]` into `tests/ui/link-native-libs`) - rust-lang#134020 (Remove unnecessary `int_type_width_signed` function) try-job: i686-mingw r? `@ghost` `@rustbot` modify labels: rollup
2 parents 728f2da + efc28f2 commit 0b63055

File tree

64 files changed

+178
-104
lines changed

Some content is hidden

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

64 files changed

+178
-104
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

+75-91
Original file line numberDiff line numberDiff line change
@@ -352,84 +352,84 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
352352
| sym::saturating_add
353353
| sym::saturating_sub => {
354354
let ty = arg_tys[0];
355-
match int_type_width_signed(ty, self) {
356-
Some((width, signed)) => match name {
357-
sym::ctlz | sym::cttz => {
358-
let y = self.const_bool(false);
359-
let ret = self.call_intrinsic(&format!("llvm.{name}.i{width}"), &[
360-
args[0].immediate(),
361-
y,
362-
]);
363-
364-
self.intcast(ret, llret_ty, false)
365-
}
366-
sym::ctlz_nonzero => {
367-
let y = self.const_bool(true);
368-
let llvm_name = &format!("llvm.ctlz.i{width}");
369-
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
370-
self.intcast(ret, llret_ty, false)
371-
}
372-
sym::cttz_nonzero => {
373-
let y = self.const_bool(true);
374-
let llvm_name = &format!("llvm.cttz.i{width}");
375-
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
376-
self.intcast(ret, llret_ty, false)
377-
}
378-
sym::ctpop => {
379-
let ret = self.call_intrinsic(&format!("llvm.ctpop.i{width}"), &[args
380-
[0]
381-
.immediate()]);
382-
self.intcast(ret, llret_ty, false)
383-
}
384-
sym::bswap => {
385-
if width == 8 {
386-
args[0].immediate() // byte swap a u8/i8 is just a no-op
387-
} else {
388-
self.call_intrinsic(&format!("llvm.bswap.i{width}"), &[
389-
args[0].immediate()
390-
])
391-
}
392-
}
393-
sym::bitreverse => self
394-
.call_intrinsic(&format!("llvm.bitreverse.i{width}"), &[
355+
if !ty.is_integral() {
356+
tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
357+
span,
358+
name,
359+
ty,
360+
});
361+
return Ok(());
362+
}
363+
let (size, signed) = ty.int_size_and_signed(self.tcx);
364+
let width = size.bits();
365+
match name {
366+
sym::ctlz | sym::cttz => {
367+
let y = self.const_bool(false);
368+
let ret = self.call_intrinsic(&format!("llvm.{name}.i{width}"), &[
369+
args[0].immediate(),
370+
y,
371+
]);
372+
373+
self.intcast(ret, llret_ty, false)
374+
}
375+
sym::ctlz_nonzero => {
376+
let y = self.const_bool(true);
377+
let llvm_name = &format!("llvm.ctlz.i{width}");
378+
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
379+
self.intcast(ret, llret_ty, false)
380+
}
381+
sym::cttz_nonzero => {
382+
let y = self.const_bool(true);
383+
let llvm_name = &format!("llvm.cttz.i{width}");
384+
let ret = self.call_intrinsic(llvm_name, &[args[0].immediate(), y]);
385+
self.intcast(ret, llret_ty, false)
386+
}
387+
sym::ctpop => {
388+
let ret = self.call_intrinsic(&format!("llvm.ctpop.i{width}"), &[
389+
args[0].immediate()
390+
]);
391+
self.intcast(ret, llret_ty, false)
392+
}
393+
sym::bswap => {
394+
if width == 8 {
395+
args[0].immediate() // byte swap a u8/i8 is just a no-op
396+
} else {
397+
self.call_intrinsic(&format!("llvm.bswap.i{width}"), &[
395398
args[0].immediate()
396-
]),
397-
sym::rotate_left | sym::rotate_right => {
398-
let is_left = name == sym::rotate_left;
399-
let val = args[0].immediate();
400-
let raw_shift = args[1].immediate();
401-
// rotate = funnel shift with first two args the same
402-
let llvm_name =
403-
&format!("llvm.fsh{}.i{}", if is_left { 'l' } else { 'r' }, width);
404-
405-
// llvm expects shift to be the same type as the values, but rust
406-
// always uses `u32`.
407-
let raw_shift = self.intcast(raw_shift, self.val_ty(val), false);
408-
409-
self.call_intrinsic(llvm_name, &[val, val, raw_shift])
399+
])
410400
}
411-
sym::saturating_add | sym::saturating_sub => {
412-
let is_add = name == sym::saturating_add;
413-
let lhs = args[0].immediate();
414-
let rhs = args[1].immediate();
415-
let llvm_name = &format!(
416-
"llvm.{}{}.sat.i{}",
417-
if signed { 's' } else { 'u' },
418-
if is_add { "add" } else { "sub" },
419-
width
420-
);
421-
self.call_intrinsic(llvm_name, &[lhs, rhs])
422-
}
423-
_ => bug!(),
424-
},
425-
None => {
426-
tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
427-
span,
428-
name,
429-
ty,
430-
});
431-
return Ok(());
432401
}
402+
sym::bitreverse => self
403+
.call_intrinsic(&format!("llvm.bitreverse.i{width}"), &[
404+
args[0].immediate()
405+
]),
406+
sym::rotate_left | sym::rotate_right => {
407+
let is_left = name == sym::rotate_left;
408+
let val = args[0].immediate();
409+
let raw_shift = args[1].immediate();
410+
// rotate = funnel shift with first two args the same
411+
let llvm_name =
412+
&format!("llvm.fsh{}.i{}", if is_left { 'l' } else { 'r' }, width);
413+
414+
// llvm expects shift to be the same type as the values, but rust
415+
// always uses `u32`.
416+
let raw_shift = self.intcast(raw_shift, self.val_ty(val), false);
417+
418+
self.call_intrinsic(llvm_name, &[val, val, raw_shift])
419+
}
420+
sym::saturating_add | sym::saturating_sub => {
421+
let is_add = name == sym::saturating_add;
422+
let lhs = args[0].immediate();
423+
let rhs = args[1].immediate();
424+
let llvm_name = &format!(
425+
"llvm.{}{}.sat.i{}",
426+
if signed { 's' } else { 'u' },
427+
if is_add { "add" } else { "sub" },
428+
width
429+
);
430+
self.call_intrinsic(llvm_name, &[lhs, rhs])
431+
}
432+
_ => bug!(),
433433
}
434434
}
435435

@@ -2531,19 +2531,3 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
25312531

25322532
span_bug!(span, "unknown SIMD intrinsic");
25332533
}
2534-
2535-
// Returns the width of an int Ty, and if it's signed or not
2536-
// Returns None if the type is not an integer
2537-
// FIXME: there’s multiple of this functions, investigate using some of the already existing
2538-
// stuffs.
2539-
fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, bool)> {
2540-
match ty.kind() {
2541-
ty::Int(t) => {
2542-
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.pointer_width)), true))
2543-
}
2544-
ty::Uint(t) => {
2545-
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.pointer_width)), false))
2546-
}
2547-
_ => None,
2548-
}
2549-
}

compiler/rustc_error_codes/src/error_codes/E0751.md

+1-1

compiler/rustc_lint/src/early.rs

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
245245

246246
fn visit_lifetime(&mut self, lt: &'a ast::Lifetime, _: ast_visit::LifetimeCtxt) {
247247
self.check_id(lt.id);
248+
ast_visit::walk_lifetime(self, lt);
248249
}
249250

250251
fn visit_path(&mut self, p: &'a ast::Path, id: ast::NodeId) {
@@ -259,6 +260,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
259260

260261
fn visit_attribute(&mut self, attr: &'a ast::Attribute) {
261262
lint_callback!(self, check_attribute, attr);
263+
ast_visit::walk_attribute(self, attr);
262264
}
263265

264266
fn visit_mac_def(&mut self, mac: &'a ast::MacroDef, id: ast::NodeId) {

compiler/rustc_lint/src/hidden_unicode_codepoints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::lints::{
99
use crate::{EarlyContext, EarlyLintPass, LintContext};
1010

1111
declare_lint! {
12+
#[allow(text_direction_codepoint_in_literal)]
1213
/// The `text_direction_codepoint_in_literal` lint detects Unicode codepoints that change the
1314
/// visual representation of text on screen in a way that does not correspond to their on
1415
/// memory representation.

compiler/rustc_lint_defs/src/builtin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3929,6 +3929,7 @@ declare_lint! {
39293929
}
39303930

39313931
declare_lint! {
3932+
#[allow(text_direction_codepoint_in_literal)]
39323933
/// The `text_direction_codepoint_in_comment` lint detects Unicode codepoints in comments that
39333934
/// change the visual representation of text on screen in a way that does not correspond to
39343935
/// their on memory representation.

library/std/src/thread/local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::cell::{Cell, RefCell};
1212
use crate::error::Error;
1313
use crate::fmt;
1414

15-
/// A thread local storage key which owns its contents.
15+
/// A thread local storage (TLS) key which owns its contents.
1616
///
1717
/// This key uses the fastest possible implementation available to it for the
1818
/// target platform. It is instantiated with the [`thread_local!`] macro and the

src/tools/tidy/src/issues.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -2295,8 +2295,6 @@ ui/issues/issue-43853.rs
22952295
ui/issues/issue-4387.rs
22962296
ui/issues/issue-43910.rs
22972297
ui/issues/issue-43923.rs
2298-
ui/issues/issue-43925.rs
2299-
ui/issues/issue-43926.rs
23002298
ui/issues/issue-43988.rs
23012299
ui/issues/issue-44023.rs
23022300
ui/issues/issue-44056.rs
@@ -2545,8 +2543,6 @@ ui/issues/issue-6936.rs
25452543
ui/issues/issue-69455.rs
25462544
ui/issues/issue-69602-type-err-during-codegen-ice.rs
25472545
ui/issues/issue-69683.rs
2548-
ui/issues/issue-70093/issue-70093-link-directives.rs
2549-
ui/issues/issue-70093/issue-70093.rs
25502546
ui/issues/issue-7012.rs
25512547
ui/issues/issue-70381.rs
25522548
ui/issues/issue-7044.rs
@@ -2711,11 +2707,15 @@ ui/limits/issue-17913.rs
27112707
ui/limits/issue-55878.rs
27122708
ui/limits/issue-69485-var-size-diffs-too-large.rs
27132709
ui/limits/issue-75158-64.rs
2710+
ui/link-native-libs/issue-109144.rs
2711+
ui/link-native-libs/issue-43925.rs
2712+
ui/link-native-libs/issue-43926.rs
2713+
ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
2714+
ui/link-native-libs/issue-70093/issue-70093.rs
27142715
ui/linkage-attr/auxiliary/issue-12133-dylib.rs
27152716
ui/linkage-attr/auxiliary/issue-12133-dylib2.rs
27162717
ui/linkage-attr/auxiliary/issue-12133-rlib.rs
27172718
ui/linkage-attr/issue-10755.rs
2718-
ui/linkage-attr/issue-109144.rs
27192719
ui/linkage-attr/issue-12133-1.rs
27202720
ui/linkage-attr/issue-12133-2.rs
27212721
ui/linkage-attr/issue-12133-3.rs

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ignore::Walk;
1717
const ENTRY_LIMIT: u32 = 901;
1818
// FIXME: The following limits should be reduced eventually.
1919

20-
const ISSUES_ENTRY_LIMIT: u32 = 1672;
20+
const ISSUES_ENTRY_LIMIT: u32 = 1667;
2121

2222
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2323
"rs", // test source files

tests/ui/rust-2024/gen-kw.e2015.stderr

+38-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,47 @@ LL | () => { mod test { fn gen() {} } }
3434
error: `gen` is a keyword in the 2024 edition
3535
--> $DIR/gen-kw.rs:25:9
3636
|
37-
LL | fn test<'gen>() {}
37+
LL | fn test<'gen>(_: &'gen i32) {}
3838
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
3939
|
4040
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
4141
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
4242

43-
error: aborting due to 4 previous errors
43+
error: `gen` is a keyword in the 2024 edition
44+
--> $DIR/gen-kw.rs:25:19
45+
|
46+
LL | fn test<'gen>(_: &'gen i32) {}
47+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
48+
|
49+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
50+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
51+
52+
error: `gen` is a keyword in the 2024 edition
53+
--> $DIR/gen-kw.rs:33:13
54+
|
55+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
56+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
57+
|
58+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
59+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
60+
61+
error: `gen` is a keyword in the 2024 edition
62+
--> $DIR/gen-kw.rs:33:28
63+
|
64+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
65+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
66+
|
67+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
68+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
69+
70+
error: `gen` is a keyword in the 2024 edition
71+
--> $DIR/gen-kw.rs:33:37
72+
|
73+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
74+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
75+
|
76+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
77+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
78+
79+
error: aborting due to 8 previous errors
4480

tests/ui/rust-2024/gen-kw.e2018.stderr

+38-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,47 @@ LL | () => { mod test { fn gen() {} } }
3434
error: `gen` is a keyword in the 2024 edition
3535
--> $DIR/gen-kw.rs:25:9
3636
|
37-
LL | fn test<'gen>() {}
37+
LL | fn test<'gen>(_: &'gen i32) {}
3838
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
3939
|
4040
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
4141
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
4242

43-
error: aborting due to 4 previous errors
43+
error: `gen` is a keyword in the 2024 edition
44+
--> $DIR/gen-kw.rs:25:19
45+
|
46+
LL | fn test<'gen>(_: &'gen i32) {}
47+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
48+
|
49+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
50+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
51+
52+
error: `gen` is a keyword in the 2024 edition
53+
--> $DIR/gen-kw.rs:33:13
54+
|
55+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
56+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
57+
|
58+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
59+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
60+
61+
error: `gen` is a keyword in the 2024 edition
62+
--> $DIR/gen-kw.rs:33:28
63+
|
64+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
65+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
66+
|
67+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
68+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
69+
70+
error: `gen` is a keyword in the 2024 edition
71+
--> $DIR/gen-kw.rs:33:37
72+
|
73+
LL | struct Test<'gen>(Box<Test<'gen>>, &'gen ());
74+
| ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
75+
|
76+
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
77+
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
78+
79+
error: aborting due to 8 previous errors
4480

tests/ui/rust-2024/gen-kw.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@ macro_rules! t {
2222
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
2323
}
2424

25-
fn test<'gen>() {}
25+
fn test<'gen>(_: &'gen i32) {}
2626
//~^ ERROR `gen` is a keyword in the 2024 edition
27+
//~| ERROR `gen` is a keyword in the 2024 edition
2728
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
29+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
30+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
31+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
32+
33+
struct Test<'gen>(Box<Test<'gen>>, &'gen ());
34+
//~^ ERROR `gen` is a keyword in the 2024 edition
35+
//~| ERROR `gen` is a keyword in the 2024 edition
36+
//~| ERROR `gen` is a keyword in the 2024 edition
37+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
38+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
39+
//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
40+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
41+
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
2842
//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
2943

3044
t!();

0 commit comments

Comments
 (0)