Skip to content

Commit 3d86494

Browse files
committed
Auto merge of rust-lang#141518 - GuillaumeGomez:rollup-ivjep2j, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#140066 (Stabilize `<[T; N]>::as_mut_slice` as `const`) - rust-lang#141105 (additional edge cases tests for `path.rs` 🧪 ) - rust-lang#141487 (Update askama to `0.14.0`) - rust-lang#141498 (Use C-string literals to reduce boilerplate) - rust-lang#141505 (rename internal panicking::try to catch_unwind) - rust-lang#141511 (Cleanup CodegenFnAttrFlags) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5e16c66 + 7cd749d commit 3d86494

File tree

26 files changed

+155
-112
lines changed

26 files changed

+155
-112
lines changed

Cargo.lock

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,20 @@ version = "0.13.1"
183183
source = "registry+https://github.com/rust-lang/crates.io-index"
184184
checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7"
185185
dependencies = [
186-
"askama_derive",
186+
"askama_derive 0.13.1",
187+
"itoa",
188+
"percent-encoding",
189+
"serde",
190+
"serde_json",
191+
]
192+
193+
[[package]]
194+
name = "askama"
195+
version = "0.14.0"
196+
source = "registry+https://github.com/rust-lang/crates.io-index"
197+
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
198+
dependencies = [
199+
"askama_derive 0.14.0",
187200
"itoa",
188201
"percent-encoding",
189202
"serde",
@@ -196,7 +209,24 @@ version = "0.13.1"
196209
source = "registry+https://github.com/rust-lang/crates.io-index"
197210
checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac"
198211
dependencies = [
199-
"askama_parser",
212+
"askama_parser 0.13.0",
213+
"basic-toml",
214+
"memchr",
215+
"proc-macro2",
216+
"quote",
217+
"rustc-hash 2.1.1",
218+
"serde",
219+
"serde_derive",
220+
"syn 2.0.101",
221+
]
222+
223+
[[package]]
224+
name = "askama_derive"
225+
version = "0.14.0"
226+
source = "registry+https://github.com/rust-lang/crates.io-index"
227+
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
228+
dependencies = [
229+
"askama_parser 0.14.0",
200230
"basic-toml",
201231
"memchr",
202232
"proc-macro2",
@@ -219,6 +249,18 @@ dependencies = [
219249
"winnow 0.7.10",
220250
]
221251

252+
[[package]]
253+
name = "askama_parser"
254+
version = "0.14.0"
255+
source = "registry+https://github.com/rust-lang/crates.io-index"
256+
checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
257+
dependencies = [
258+
"memchr",
259+
"serde",
260+
"serde_derive",
261+
"winnow 0.7.10",
262+
]
263+
222264
[[package]]
223265
name = "autocfg"
224266
version = "1.4.0"
@@ -540,7 +582,7 @@ name = "clippy"
540582
version = "0.1.89"
541583
dependencies = [
542584
"anstream",
543-
"askama",
585+
"askama 0.13.1",
544586
"cargo_metadata 0.18.1",
545587
"clippy_config",
546588
"clippy_lints",
@@ -1389,7 +1431,7 @@ name = "generate-copyright"
13891431
version = "0.1.0"
13901432
dependencies = [
13911433
"anyhow",
1392-
"askama",
1434+
"askama 0.14.0",
13931435
"cargo_metadata 0.18.1",
13941436
"serde",
13951437
"serde_json",
@@ -4622,7 +4664,7 @@ name = "rustdoc"
46224664
version = "0.0.0"
46234665
dependencies = [
46244666
"arrayvec",
4625-
"askama",
4667+
"askama 0.14.0",
46264668
"base64",
46274669
"expect-test",
46284670
"indexmap",

compiler/rustc_codegen_gcc/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
154154
// TODO(antoyo): set link section.
155155
}
156156

157-
if attrs.flags.contains(CodegenFnAttrFlags::USED)
157+
if attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
158158
|| attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
159159
{
160160
self.add_used_global(global.to_rvalue());

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl<'ll> CodegenCx<'ll, '_> {
527527

528528
base::set_variable_sanitizer_attrs(g, attrs);
529529

530-
if attrs.flags.contains(CodegenFnAttrFlags::USED) {
530+
if attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) {
531531
// `USED` and `USED_LINKER` can't be used together.
532532
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER));
533533

@@ -551,7 +551,7 @@ impl<'ll> CodegenCx<'ll, '_> {
551551
}
552552
if attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) {
553553
// `USED` and `USED_LINKER` can't be used together.
554-
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED));
554+
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER));
555555

556556
self.add_used_global(g);
557557
}

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
128128
} else {
129129
SymbolExportKind::Text
130130
},
131-
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED)
131+
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
132132
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
133133
|| used,
134134
};

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
189189
)
190190
.emit();
191191
}
192-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED;
192+
codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED_COMPILER;
193193
}
194194
Some(_) => {
195195
tcx.dcx().emit_err(errors::ExpectedUsedSymbol { span: attr.span() });
@@ -220,7 +220,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
220220
|| tcx.sess.target.is_like_windows
221221
|| tcx.sess.target.is_like_wasm);
222222
codegen_fn_attrs.flags |= if is_like_elf {
223-
CodegenFnAttrFlags::USED
223+
CodegenFnAttrFlags::USED_COMPILER
224224
} else {
225225
CodegenFnAttrFlags::USED_LINKER
226226
};

compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,49 +96,46 @@ bitflags::bitflags! {
9696
/// `#[cold]`: a hint to LLVM that this function, when called, is never on
9797
/// the hot path.
9898
const COLD = 1 << 0;
99-
/// `#[rustc_allocator]`: a hint to LLVM that the pointer returned from this
100-
/// function is never null and the function has no side effects other than allocating.
101-
const ALLOCATOR = 1 << 1;
102-
/// An indicator that function will never unwind. Will become obsolete
103-
/// once C-unwind is fully stabilized.
104-
const NEVER_UNWIND = 1 << 3;
99+
/// `#[rustc_nounwind]`: An indicator that function will never unwind.
100+
const NEVER_UNWIND = 1 << 1;
105101
/// `#[naked]`: an indicator to LLVM that no function prologue/epilogue
106102
/// should be generated.
107-
const NAKED = 1 << 4;
103+
const NAKED = 1 << 2;
108104
/// `#[no_mangle]`: an indicator that the function's name should be the same
109105
/// as its symbol.
110-
const NO_MANGLE = 1 << 5;
106+
const NO_MANGLE = 1 << 3;
111107
/// `#[rustc_std_internal_symbol]`: an indicator that this symbol is a
112108
/// "weird symbol" for the standard library in that it has slightly
113109
/// different linkage, visibility, and reachability rules.
114-
const RUSTC_STD_INTERNAL_SYMBOL = 1 << 6;
110+
const RUSTC_STD_INTERNAL_SYMBOL = 1 << 4;
115111
/// `#[thread_local]`: indicates a static is actually a thread local
116112
/// piece of memory
117-
const THREAD_LOCAL = 1 << 8;
118-
/// `#[used]`: indicates that LLVM can't eliminate this function (but the
113+
const THREAD_LOCAL = 1 << 5;
114+
/// `#[used(compiler)]`: indicates that LLVM can't eliminate this function (but the
119115
/// linker can!).
120-
const USED = 1 << 9;
116+
const USED_COMPILER = 1 << 6;
117+
/// `#[used(linker)]`:
118+
/// indicates that neither LLVM nor the linker will eliminate this function.
119+
const USED_LINKER = 1 << 7;
121120
/// `#[track_caller]`: allow access to the caller location
122-
const TRACK_CALLER = 1 << 10;
121+
const TRACK_CALLER = 1 << 8;
123122
/// #[ffi_pure]: applies clang's `pure` attribute to a foreign function
124123
/// declaration.
125-
const FFI_PURE = 1 << 11;
124+
const FFI_PURE = 1 << 9;
126125
/// #[ffi_const]: applies clang's `const` attribute to a foreign function
127126
/// declaration.
128-
const FFI_CONST = 1 << 12;
129-
// (Bit 13 was used for `#[cmse_nonsecure_entry]`, but is now unused.)
130-
// (Bit 14 was used for `#[coverage(off)]`, but is now unused.)
131-
/// `#[used(linker)]`:
132-
/// indicates that neither LLVM nor the linker will eliminate this function.
133-
const USED_LINKER = 1 << 15;
127+
const FFI_CONST = 1 << 10;
128+
/// `#[rustc_allocator]`: a hint to LLVM that the pointer returned from this
129+
/// function is never null and the function has no side effects other than allocating.
130+
const ALLOCATOR = 1 << 11;
134131
/// `#[rustc_deallocator]`: a hint to LLVM that the function only deallocates memory.
135-
const DEALLOCATOR = 1 << 16;
132+
const DEALLOCATOR = 1 << 12;
136133
/// `#[rustc_reallocator]`: a hint to LLVM that the function only reallocates memory.
137-
const REALLOCATOR = 1 << 17;
134+
const REALLOCATOR = 1 << 13;
138135
/// `#[rustc_allocator_zeroed]`: a hint to LLVM that the function only allocates zeroed memory.
139-
const ALLOCATOR_ZEROED = 1 << 18;
136+
const ALLOCATOR_ZEROED = 1 << 14;
140137
/// `#[no_builtins]`: indicates that disable implicit builtin knowledge of functions for the function.
141-
const NO_BUILTINS = 1 << 19;
138+
const NO_BUILTINS = 1 << 15;
142139
}
143140
}
144141
rustc_data_structures::external_bitflags_debug! { CodegenFnAttrFlags }

compiler/rustc_passes/src/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ fn has_allow_dead_code_or_lang_attr(
707707
// #[used], #[no_mangle], #[export_name], etc also keeps the item alive
708708
// forcefully, e.g., for placing it in a specific section.
709709
cg_attrs.contains_extern_indicator()
710-
|| cg_attrs.flags.contains(CodegenFnAttrFlags::USED)
710+
|| cg_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
711711
|| cg_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
712712
}
713713
}

compiler/rustc_passes/src/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
427427
// FIXME(nbdd0121): `#[used]` are marked as reachable here so it's picked up by
428428
// `linked_symbols` in cg_ssa. They won't be exported in binary or cdylib due to their
429429
// `SymbolExportLevel::Rust` export level but may end up being exported in dylibs.
430-
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED)
430+
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
431431
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
432432
}
433433

library/core/src/array/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ impl<T, const N: usize> [T; N] {
588588
/// Returns a mutable slice containing the entire array. Equivalent to
589589
/// `&mut s[..]`.
590590
#[stable(feature = "array_as_slice", since = "1.57.0")]
591-
#[rustc_const_unstable(feature = "const_array_as_mut_slice", issue = "133333")]
591+
#[rustc_const_stable(feature = "const_array_as_mut_slice", since = "CURRENT_RUSTC_VERSION")]
592592
pub const fn as_mut_slice(&mut self) -> &mut [T] {
593593
self
594594
}

library/core/src/ffi/c_str.rs

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,8 @@ impl CStr {
511511
/// # Examples
512512
///
513513
/// ```
514-
/// use std::ffi::CStr;
515-
///
516-
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").unwrap();
517-
/// assert_eq!(cstr.count_bytes(), 3);
518-
///
519-
/// let cstr = CStr::from_bytes_with_nul(b"\0").unwrap();
520-
/// assert_eq!(cstr.count_bytes(), 0);
514+
/// assert_eq!(c"foo".count_bytes(), 3);
515+
/// assert_eq!(c"".count_bytes(), 0);
521516
/// ```
522517
#[inline]
523518
#[must_use]
@@ -533,19 +528,8 @@ impl CStr {
533528
/// # Examples
534529
///
535530
/// ```
536-
/// use std::ffi::CStr;
537-
/// # use std::ffi::FromBytesWithNulError;
538-
///
539-
/// # fn main() { test().unwrap(); }
540-
/// # fn test() -> Result<(), FromBytesWithNulError> {
541-
/// let cstr = CStr::from_bytes_with_nul(b"foo\0")?;
542-
/// assert!(!cstr.is_empty());
543-
///
544-
/// let empty_cstr = CStr::from_bytes_with_nul(b"\0")?;
545-
/// assert!(empty_cstr.is_empty());
531+
/// assert!(!c"foo".is_empty());
546532
/// assert!(c"".is_empty());
547-
/// # Ok(())
548-
/// # }
549533
/// ```
550534
#[inline]
551535
#[stable(feature = "cstr_is_empty", since = "1.71.0")]
@@ -569,10 +553,7 @@ impl CStr {
569553
/// # Examples
570554
///
571555
/// ```
572-
/// use std::ffi::CStr;
573-
///
574-
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
575-
/// assert_eq!(cstr.to_bytes(), b"foo");
556+
/// assert_eq!(c"foo".to_bytes(), b"foo");
576557
/// ```
577558
#[inline]
578559
#[must_use = "this returns the result of the operation, \
@@ -598,10 +579,7 @@ impl CStr {
598579
/// # Examples
599580
///
600581
/// ```
601-
/// use std::ffi::CStr;
602-
///
603-
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
604-
/// assert_eq!(cstr.to_bytes_with_nul(), b"foo\0");
582+
/// assert_eq!(c"foo".to_bytes_with_nul(), b"foo\0");
605583
/// ```
606584
#[inline]
607585
#[must_use = "this returns the result of the operation, \
@@ -623,10 +601,8 @@ impl CStr {
623601
///
624602
/// ```
625603
/// #![feature(cstr_bytes)]
626-
/// use std::ffi::CStr;
627604
///
628-
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
629-
/// assert!(cstr.bytes().eq(*b"foo"));
605+
/// assert!(c"foo".bytes().eq(*b"foo"));
630606
/// ```
631607
#[inline]
632608
#[unstable(feature = "cstr_bytes", issue = "112115")]
@@ -645,10 +621,7 @@ impl CStr {
645621
/// # Examples
646622
///
647623
/// ```
648-
/// use std::ffi::CStr;
649-
///
650-
/// let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
651-
/// assert_eq!(cstr.to_str(), Ok("foo"));
624+
/// assert_eq!(c"foo".to_str(), Ok("foo"));
652625
/// ```
653626
#[stable(feature = "cstr_to_str", since = "1.4.0")]
654627
#[rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0")]

library/std/src/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub use core::panic::abort_unwind;
356356
/// ```
357357
#[stable(feature = "catch_unwind", since = "1.9.0")]
358358
pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
359-
unsafe { panicking::r#try(f) }
359+
unsafe { panicking::catch_unwind(f) }
360360
}
361361

362362
/// Triggers a panic without invoking the panic hook.

library/std/src/panicking.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,13 @@ pub use realstd::rt::panic_count;
499499

500500
/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
501501
#[cfg(feature = "panic_immediate_abort")]
502-
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
502+
pub unsafe fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
503503
Ok(f())
504504
}
505505

506506
/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
507507
#[cfg(not(feature = "panic_immediate_abort"))]
508-
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
508+
pub unsafe fn catch_unwind<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
509509
union Data<F, R> {
510510
f: ManuallyDrop<F>,
511511
r: ManuallyDrop<R>,
@@ -541,7 +541,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
541541
let data_ptr = (&raw mut data) as *mut u8;
542542
// SAFETY:
543543
//
544-
// Access to the union's fields: this is `std` and we know that the `r#try`
544+
// Access to the union's fields: this is `std` and we know that the `catch_unwind`
545545
// intrinsic fills in the `r` or `p` union field based on its return value.
546546
//
547547
// The call to `intrinsics::catch_unwind` is made safe by:
@@ -602,7 +602,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
602602
// This function cannot be marked as `unsafe` because `intrinsics::catch_unwind`
603603
// expects normal function pointers.
604604
#[inline]
605-
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind
605+
#[rustc_nounwind] // `intrinsic::catch_unwind` requires catch fn to be nounwind
606606
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
607607
// SAFETY: this is the responsibility of the caller, see above.
608608
//

0 commit comments

Comments
 (0)