Skip to content

Commit 0f0cdf6

Browse files
committed
Auto merge of #69030 - Dylan-DPC:rollup-t9uk7vc, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #68897 (clean up E0275 explanation) - #68908 (Add long error code explanation message for E0637 ) - #68932 (self-profile: Support arguments for generic_activities.) - #68986 (Make ASCII ctype functions unstably const ) - #69007 (Clean up E0283 explanation) - #69014 (change an instance of span_bug() to struct_span_err() to avoid ICE) Failed merges: r? @ghost
2 parents e6ec0d1 + 119bc97 commit 0f0cdf6

34 files changed

+354
-150
lines changed

src/libcore/char/methods.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,9 @@ impl char {
10721072
/// assert!(!esc.is_ascii_alphabetic());
10731073
/// ```
10741074
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1075+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
10751076
#[inline]
1076-
pub fn is_ascii_alphabetic(&self) -> bool {
1077+
pub const fn is_ascii_alphabetic(&self) -> bool {
10771078
self.is_ascii() && (*self as u8).is_ascii_alphabetic()
10781079
}
10791080

@@ -1104,8 +1105,9 @@ impl char {
11041105
/// assert!(!esc.is_ascii_uppercase());
11051106
/// ```
11061107
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1108+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
11071109
#[inline]
1108-
pub fn is_ascii_uppercase(&self) -> bool {
1110+
pub const fn is_ascii_uppercase(&self) -> bool {
11091111
self.is_ascii() && (*self as u8).is_ascii_uppercase()
11101112
}
11111113

@@ -1136,8 +1138,9 @@ impl char {
11361138
/// assert!(!esc.is_ascii_lowercase());
11371139
/// ```
11381140
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1141+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
11391142
#[inline]
1140-
pub fn is_ascii_lowercase(&self) -> bool {
1143+
pub const fn is_ascii_lowercase(&self) -> bool {
11411144
self.is_ascii() && (*self as u8).is_ascii_lowercase()
11421145
}
11431146

@@ -1171,8 +1174,9 @@ impl char {
11711174
/// assert!(!esc.is_ascii_alphanumeric());
11721175
/// ```
11731176
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1177+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
11741178
#[inline]
1175-
pub fn is_ascii_alphanumeric(&self) -> bool {
1179+
pub const fn is_ascii_alphanumeric(&self) -> bool {
11761180
self.is_ascii() && (*self as u8).is_ascii_alphanumeric()
11771181
}
11781182

@@ -1203,8 +1207,9 @@ impl char {
12031207
/// assert!(!esc.is_ascii_digit());
12041208
/// ```
12051209
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1210+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
12061211
#[inline]
1207-
pub fn is_ascii_digit(&self) -> bool {
1212+
pub const fn is_ascii_digit(&self) -> bool {
12081213
self.is_ascii() && (*self as u8).is_ascii_digit()
12091214
}
12101215

@@ -1238,8 +1243,9 @@ impl char {
12381243
/// assert!(!esc.is_ascii_hexdigit());
12391244
/// ```
12401245
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1246+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
12411247
#[inline]
1242-
pub fn is_ascii_hexdigit(&self) -> bool {
1248+
pub const fn is_ascii_hexdigit(&self) -> bool {
12431249
self.is_ascii() && (*self as u8).is_ascii_hexdigit()
12441250
}
12451251

@@ -1274,8 +1280,9 @@ impl char {
12741280
/// assert!(!esc.is_ascii_punctuation());
12751281
/// ```
12761282
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1283+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
12771284
#[inline]
1278-
pub fn is_ascii_punctuation(&self) -> bool {
1285+
pub const fn is_ascii_punctuation(&self) -> bool {
12791286
self.is_ascii() && (*self as u8).is_ascii_punctuation()
12801287
}
12811288

@@ -1306,8 +1313,9 @@ impl char {
13061313
/// assert!(!esc.is_ascii_graphic());
13071314
/// ```
13081315
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1316+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
13091317
#[inline]
1310-
pub fn is_ascii_graphic(&self) -> bool {
1318+
pub const fn is_ascii_graphic(&self) -> bool {
13111319
self.is_ascii() && (*self as u8).is_ascii_graphic()
13121320
}
13131321

@@ -1355,8 +1363,9 @@ impl char {
13551363
/// assert!(!esc.is_ascii_whitespace());
13561364
/// ```
13571365
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1366+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
13581367
#[inline]
1359-
pub fn is_ascii_whitespace(&self) -> bool {
1368+
pub const fn is_ascii_whitespace(&self) -> bool {
13601369
self.is_ascii() && (*self as u8).is_ascii_whitespace()
13611370
}
13621371

@@ -1389,8 +1398,9 @@ impl char {
13891398
/// assert!(esc.is_ascii_control());
13901399
/// ```
13911400
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
1401+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
13921402
#[inline]
1393-
pub fn is_ascii_control(&self) -> bool {
1403+
pub const fn is_ascii_control(&self) -> bool {
13941404
self.is_ascii() && (*self as u8).is_ascii_control()
13951405
}
13961406
}

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#![feature(bound_cloned)]
7171
#![feature(cfg_target_has_atomic)]
7272
#![feature(concat_idents)]
73+
#![feature(const_ascii_ctype_on_intrinsics)]
7374
#![feature(const_alloc_layout)]
7475
#![feature(const_if_match)]
7576
#![feature(const_checked_int_methods)]

src/libcore/num/mod.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -4449,8 +4449,9 @@ impl u8 {
44494449
/// assert!(!esc.is_ascii_alphabetic());
44504450
/// ```
44514451
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4452+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
44524453
#[inline]
4453-
pub fn is_ascii_alphabetic(&self) -> bool {
4454+
pub const fn is_ascii_alphabetic(&self) -> bool {
44544455
matches!(*self, b'A'..=b'Z' | b'a'..=b'z')
44554456
}
44564457

@@ -4481,8 +4482,9 @@ impl u8 {
44814482
/// assert!(!esc.is_ascii_uppercase());
44824483
/// ```
44834484
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4485+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
44844486
#[inline]
4485-
pub fn is_ascii_uppercase(&self) -> bool {
4487+
pub const fn is_ascii_uppercase(&self) -> bool {
44864488
matches!(*self, b'A'..=b'Z')
44874489
}
44884490

@@ -4513,8 +4515,9 @@ impl u8 {
45134515
/// assert!(!esc.is_ascii_lowercase());
45144516
/// ```
45154517
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4518+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
45164519
#[inline]
4517-
pub fn is_ascii_lowercase(&self) -> bool {
4520+
pub const fn is_ascii_lowercase(&self) -> bool {
45184521
matches!(*self, b'a'..=b'z')
45194522
}
45204523

@@ -4548,8 +4551,9 @@ impl u8 {
45484551
/// assert!(!esc.is_ascii_alphanumeric());
45494552
/// ```
45504553
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4554+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
45514555
#[inline]
4552-
pub fn is_ascii_alphanumeric(&self) -> bool {
4556+
pub const fn is_ascii_alphanumeric(&self) -> bool {
45534557
matches!(*self, b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z')
45544558
}
45554559

@@ -4580,8 +4584,9 @@ impl u8 {
45804584
/// assert!(!esc.is_ascii_digit());
45814585
/// ```
45824586
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4587+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
45834588
#[inline]
4584-
pub fn is_ascii_digit(&self) -> bool {
4589+
pub const fn is_ascii_digit(&self) -> bool {
45854590
matches!(*self, b'0'..=b'9')
45864591
}
45874592

@@ -4615,8 +4620,9 @@ impl u8 {
46154620
/// assert!(!esc.is_ascii_hexdigit());
46164621
/// ```
46174622
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4623+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
46184624
#[inline]
4619-
pub fn is_ascii_hexdigit(&self) -> bool {
4625+
pub const fn is_ascii_hexdigit(&self) -> bool {
46204626
matches!(*self, b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f')
46214627
}
46224628

@@ -4651,8 +4657,9 @@ impl u8 {
46514657
/// assert!(!esc.is_ascii_punctuation());
46524658
/// ```
46534659
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4660+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
46544661
#[inline]
4655-
pub fn is_ascii_punctuation(&self) -> bool {
4662+
pub const fn is_ascii_punctuation(&self) -> bool {
46564663
matches!(*self, b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~')
46574664
}
46584665

@@ -4683,8 +4690,9 @@ impl u8 {
46834690
/// assert!(!esc.is_ascii_graphic());
46844691
/// ```
46854692
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4693+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
46864694
#[inline]
4687-
pub fn is_ascii_graphic(&self) -> bool {
4695+
pub const fn is_ascii_graphic(&self) -> bool {
46884696
matches!(*self, b'!'..=b'~')
46894697
}
46904698

@@ -4732,8 +4740,9 @@ impl u8 {
47324740
/// assert!(!esc.is_ascii_whitespace());
47334741
/// ```
47344742
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4743+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
47354744
#[inline]
4736-
pub fn is_ascii_whitespace(&self) -> bool {
4745+
pub const fn is_ascii_whitespace(&self) -> bool {
47374746
matches!(*self, b'\t' | b'\n' | b'\x0C' | b'\r' | b' ')
47384747
}
47394748

@@ -4766,8 +4775,9 @@ impl u8 {
47664775
/// assert!(esc.is_ascii_control());
47674776
/// ```
47684777
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
4778+
#[rustc_const_unstable(feature = "const_ascii_ctype_on_intrinsics", issue = "68983")]
47694779
#[inline]
4770-
pub fn is_ascii_control(&self) -> bool {
4780+
pub const fn is_ascii_control(&self) -> bool {
47714781
matches!(*self, b'\0'..=b'\x1F' | b'\x7F')
47724782
}
47734783
}

src/librustc/ty/query/on_disk_cache.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,10 @@ where
10531053
Q: super::config::QueryDescription<'tcx, Value: Encodable>,
10541054
E: 'a + TyEncoder,
10551055
{
1056-
let desc = &format!("encode_query_results_for_{}", ::std::any::type_name::<Q>());
1057-
let _timer = tcx.sess.prof.extra_verbose_generic_activity(desc);
1056+
let _timer = tcx
1057+
.sess
1058+
.prof
1059+
.extra_verbose_generic_activity("encode_query_results_for", ::std::any::type_name::<Q>());
10581060

10591061
let shards = Q::query_cache(tcx).lock_shards();
10601062
assert!(shards.iter().all(|shard| shard.active.is_empty()));

src/librustc_codegen_llvm/back/lto.rs

+32-25
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,21 @@ fn prepare_lto(
110110
symbol_white_list.extend(exported_symbols[&cnum].iter().filter_map(symbol_filter));
111111
}
112112

113-
let _timer = cgcx.prof.generic_activity("LLVM_lto_load_upstream_bitcode");
114113
let archive = ArchiveRO::open(&path).expect("wanted an rlib");
115114
let bytecodes = archive
116115
.iter()
117116
.filter_map(|child| child.ok().and_then(|c| c.name().map(|name| (name, c))))
118117
.filter(|&(name, _)| name.ends_with(RLIB_BYTECODE_EXTENSION));
119118
for (name, data) in bytecodes {
119+
let _timer =
120+
cgcx.prof.generic_activity_with_arg("LLVM_lto_load_upstream_bitcode", name);
120121
info!("adding bytecode {}", name);
121122
let bc_encoded = data.data();
122123

123-
let (bc, id) = cgcx
124-
.prof
125-
.extra_verbose_generic_activity(&format!("decode {}", name))
126-
.run(|| match DecodedBytecode::new(bc_encoded) {
127-
Ok(b) => Ok((b.bytecode(), b.identifier().to_string())),
128-
Err(e) => Err(diag_handler.fatal(&e)),
129-
})?;
124+
let (bc, id) = match DecodedBytecode::new(bc_encoded) {
125+
Ok(b) => Ok((b.bytecode(), b.identifier().to_string())),
126+
Err(e) => Err(diag_handler.fatal(&e)),
127+
}?;
130128
let bc = SerializedModule::FromRlib(bc);
131129
upstream_modules.push((bc, CString::new(id).unwrap()));
132130
}
@@ -281,14 +279,14 @@ fn fat_lto(
281279
// save and persist everything with the original module.
282280
let mut linker = Linker::new(llmod);
283281
for (bc_decoded, name) in serialized_modules {
284-
let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_link_module");
282+
let _timer = cgcx
283+
.prof
284+
.generic_activity_with_arg("LLVM_fat_lto_link_module", format!("{:?}", name));
285285
info!("linking {:?}", name);
286-
cgcx.prof.extra_verbose_generic_activity(&format!("ll link {:?}", name)).run(|| {
287-
let data = bc_decoded.data();
288-
linker.add(&data).map_err(|()| {
289-
let msg = format!("failed to load bc of {:?}", name);
290-
write::llvm_err(&diag_handler, &msg)
291-
})
286+
let data = bc_decoded.data();
287+
linker.add(&data).map_err(|()| {
288+
let msg = format!("failed to load bc of {:?}", name);
289+
write::llvm_err(&diag_handler, &msg)
292290
})?;
293291
serialized_bitcode.push(bc_decoded);
294292
}
@@ -577,6 +575,8 @@ pub(crate) fn run_pass_manager(
577575
config: &ModuleConfig,
578576
thin: bool,
579577
) {
578+
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &module.name[..]);
579+
580580
// Now we have one massive module inside of llmod. Time to run the
581581
// LTO-specific optimization passes that LLVM provides.
582582
//
@@ -634,9 +634,7 @@ pub(crate) fn run_pass_manager(
634634
llvm::LLVMRustAddPass(pm, pass.unwrap());
635635
}
636636

637-
cgcx.prof
638-
.extra_verbose_generic_activity("LTO_passes")
639-
.run(|| llvm::LLVMRunPassManager(pm, module.module_llvm.llmod()));
637+
llvm::LLVMRunPassManager(pm, module.module_llvm.llmod());
640638

641639
llvm::LLVMDisposePassManager(pm);
642640
}
@@ -760,7 +758,9 @@ pub unsafe fn optimize_thin_module(
760758
// Like with "fat" LTO, get some better optimizations if landing pads
761759
// are disabled by removing all landing pads.
762760
if cgcx.no_landing_pads {
763-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_remove_landing_pads");
761+
let _timer = cgcx
762+
.prof
763+
.generic_activity_with_arg("LLVM_thin_lto_remove_landing_pads", thin_module.name());
764764
llvm::LLVMRustMarkAllFunctionsNounwind(llmod);
765765
save_temp_bitcode(&cgcx, &module, "thin-lto-after-nounwind");
766766
}
@@ -774,7 +774,8 @@ pub unsafe fn optimize_thin_module(
774774
// You can find some more comments about these functions in the LLVM
775775
// bindings we've got (currently `PassWrapper.cpp`)
776776
{
777-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_rename");
777+
let _timer =
778+
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
778779
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod) {
779780
let msg = "failed to prepare thin LTO module";
780781
return Err(write::llvm_err(&diag_handler, msg));
@@ -783,7 +784,9 @@ pub unsafe fn optimize_thin_module(
783784
}
784785

785786
{
786-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_resolve_weak");
787+
let _timer = cgcx
788+
.prof
789+
.generic_activity_with_arg("LLVM_thin_lto_resolve_weak", thin_module.name());
787790
if !llvm::LLVMRustPrepareThinLTOResolveWeak(thin_module.shared.data.0, llmod) {
788791
let msg = "failed to prepare thin LTO module";
789792
return Err(write::llvm_err(&diag_handler, msg));
@@ -792,7 +795,9 @@ pub unsafe fn optimize_thin_module(
792795
}
793796

794797
{
795-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_internalize");
798+
let _timer = cgcx
799+
.prof
800+
.generic_activity_with_arg("LLVM_thin_lto_internalize", thin_module.name());
796801
if !llvm::LLVMRustPrepareThinLTOInternalize(thin_module.shared.data.0, llmod) {
797802
let msg = "failed to prepare thin LTO module";
798803
return Err(write::llvm_err(&diag_handler, msg));
@@ -801,7 +806,8 @@ pub unsafe fn optimize_thin_module(
801806
}
802807

803808
{
804-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_import");
809+
let _timer =
810+
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_import", thin_module.name());
805811
if !llvm::LLVMRustPrepareThinLTOImport(thin_module.shared.data.0, llmod) {
806812
let msg = "failed to prepare thin LTO module";
807813
return Err(write::llvm_err(&diag_handler, msg));
@@ -839,7 +845,9 @@ pub unsafe fn optimize_thin_module(
839845
// so it appears). Hopefully we can remove this once upstream bugs are
840846
// fixed in LLVM.
841847
{
842-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_patch_debuginfo");
848+
let _timer = cgcx
849+
.prof
850+
.generic_activity_with_arg("LLVM_thin_lto_patch_debuginfo", thin_module.name());
843851
llvm::LLVMRustThinLTOPatchDICompileUnit(llmod, cu1);
844852
save_temp_bitcode(cgcx, &module, "thin-lto-after-patch");
845853
}
@@ -850,7 +858,6 @@ pub unsafe fn optimize_thin_module(
850858
// populate a thin-specific pass manager, which presumably LLVM treats a
851859
// little differently.
852860
{
853-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_optimize");
854861
info!("running thin lto passes over {}", module.name);
855862
let config = cgcx.config(module.kind);
856863
run_pass_manager(cgcx, &module, config, true);

0 commit comments

Comments
 (0)