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

Commit 3954398

Browse files
committed
Auto merge of rust-lang#128298 - matthiaskrgr:rollup-0wdu2wo, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#127853 (`#[naked]`: report incompatible attributes) - rust-lang#128276 (Add a README to rustbook to explain its purpose) - rust-lang#128279 (Stabilize `is_sorted`) - rust-lang#128282 (bitwise and bytewise methods on `NonZero`) - rust-lang#128285 (rustc book: document how the RUST_TARGET_PATH variable is used) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0bb6fec + b801fab commit 3954398

File tree

39 files changed

+874
-236
lines changed

39 files changed

+874
-236
lines changed

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ builtin_macros_multiple_defaults = multiple declared defaults
220220
.note = only one variant can be default
221221
.suggestion = make `{$ident}` default
222222
223+
builtin_macros_naked_functions_testing_attribute =
224+
cannot use `#[naked]` with testing attributes
225+
.label = function marked with testing attribute here
226+
.naked_attribute = `#[naked]` is incompatible with testing attributes
227+
223228
builtin_macros_no_default_variant = no default declared
224229
.help = make a unit variant default by placing `#[default]` above it
225230
.suggestion = make `{$ident}` default

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,3 +923,13 @@ pub(crate) struct ExpectedItem<'a> {
923923
pub span: Span,
924924
pub token: &'a str,
925925
}
926+
927+
#[derive(Diagnostic)]
928+
#[diag(builtin_macros_naked_functions_testing_attribute, code = E0736)]
929+
pub struct NakedFunctionTestingAttribute {
930+
#[primary_span]
931+
#[label(builtin_macros_naked_attribute)]
932+
pub naked_span: Span,
933+
#[label]
934+
pub testing_span: Span,
935+
}

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ pub(crate) fn expand_test_or_bench(
133133
};
134134
};
135135

136+
if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
137+
cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
138+
testing_span: attr_sp,
139+
naked_span: attr.span,
140+
});
141+
return vec![Annotatable::Item(item)];
142+
}
143+
136144
// check_*_signature will report any errors in the type so compilation
137145
// will fail. We shouldn't try to expand in this case because the errors
138146
// would be spurious.

compiler/rustc_codegen_cranelift/example/std_example.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
coroutines,
44
stmt_expr_attributes,
55
coroutine_trait,
6-
is_sorted,
76
repr_simd,
87
tuple_trait,
98
unboxed_closures

compiler/rustc_codegen_gcc/example/std_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(internal_features)]
2-
#![feature(core_intrinsics, coroutines, coroutine_trait, is_sorted, stmt_expr_attributes)]
2+
#![feature(core_intrinsics, coroutines, coroutine_trait, stmt_expr_attributes)]
33

44
#[cfg(feature="master")]
55
#[cfg(target_arch="x86_64")]
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
`#[track_caller]` and `#[naked]` cannot both be applied to the same function.
1+
Functions marked with the `#[naked]` attribute are restricted in what other
2+
attributes they may be marked with.
3+
4+
Notable attributes that are incompatible with `#[naked]` are:
5+
6+
* `#[inline]`
7+
* `#[track_caller]`
8+
* `#[test]`, `#[ignore]`, `#[should_panic]`
29

310
Erroneous code example:
411

512
```compile_fail,E0736
13+
#[inline]
614
#[naked]
7-
#[track_caller]
815
fn foo() {}
916
```
1017

11-
This is primarily due to ABI incompatibilities between the two attributes.
12-
See [RFC 2091] for details on this and other limitations.
13-
14-
[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
18+
These incompatibilities are due to the fact that naked functions deliberately
19+
impose strict restrictions regarding the code that the compiler is
20+
allowed to produce for this function.

compiler/rustc_error_codes/src/error_codes/E0739.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
`#[track_caller]` can not be applied on struct.
1+
`#[track_caller]` must be applied to a function
22

33
Erroneous code example:
44

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ This API is completely unstable and subject to change.
6464
#![doc(rust_logo)]
6565
#![feature(control_flow_enum)]
6666
#![feature(if_let_guard)]
67-
#![feature(is_sorted)]
6867
#![feature(iter_intersperse)]
6968
#![feature(let_chains)]
7069
#![feature(never_type)]

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,14 +1984,18 @@ declare_lint! {
19841984
///
19851985
/// ```rust
19861986
/// trait MyIterator : Iterator {
1987-
/// // is_sorted is an unstable method that already exists on the Iterator trait
1988-
/// fn is_sorted(self) -> bool where Self: Sized {true}
1987+
/// // is_partitioned is an unstable method that already exists on the Iterator trait
1988+
/// fn is_partitioned<P>(self, predicate: P) -> bool
1989+
/// where
1990+
/// Self: Sized,
1991+
/// P: FnMut(Self::Item) -> bool,
1992+
/// {true}
19891993
/// }
19901994
///
19911995
/// impl<T: ?Sized> MyIterator for T where T: Iterator { }
19921996
///
19931997
/// let x = vec![1, 2, 3];
1994-
/// let _ = x.iter().is_sorted();
1998+
/// let _ = x.iter().is_partitioned(|_| true);
19951999
/// ```
19962000
///
19972001
/// {{produces}}
@@ -2007,7 +2011,7 @@ declare_lint! {
20072011
/// is an early-warning to let you know that there may be a collision in
20082012
/// the future. This can be avoided by adding type annotations to
20092013
/// disambiguate which trait method you intend to call, such as
2010-
/// `MyIterator::is_sorted(my_iter)` or renaming or removing the method.
2014+
/// `MyIterator::is_partitioned(my_iter, my_predicate)` or renaming or removing the method.
20112015
///
20122016
/// [nightly channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
20132017
/// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(decl_macro)]
77
#![feature(if_let_guard)]
88
#![feature(impl_trait_in_assoc_type)]
9-
#![feature(is_sorted)]
109
#![feature(let_chains)]
1110
#![feature(map_try_insert)]
1211
#![feature(never_type)]

0 commit comments

Comments
 (0)