Skip to content

Commit 1a6bffc

Browse files
committed
Auto merge of rust-lang#85486 - RalfJung:rollup-4ibcxuu, r=RalfJung
Rollup of 8 pull requests Successful merges: - rust-lang#84717 (impl FromStr for proc_macro::Literal) - rust-lang#85169 (Add method-toggle to <details> for methods) - rust-lang#85287 (Expose `Concurrent` (private type in public i'face)) - rust-lang#85315 (adding time complexity for partition_in_place iter method) - rust-lang#85439 (Add diagnostic item to `CStr`) - rust-lang#85464 (Fix UB in documented example for `ptr::swap`) - rust-lang#85470 (Fix invalid CSS rules for a:hover) - rust-lang#85472 (CTFE Machine: do not expose Allocation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 25830f4 + 3f2784e commit 1a6bffc

File tree

7 files changed

+55
-24
lines changed

7 files changed

+55
-24
lines changed

core/src/iter/traits/iterator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,12 @@ pub trait Iterator {
18491849
///
18501850
/// The relative order of partitioned items is not maintained.
18511851
///
1852+
/// # Current implementation
1853+
/// Current algorithms tries finding the first element for which the predicate evaluates
1854+
/// to false, and the last element for which it evaluates to true and repeatedly swaps them.
1855+
///
1856+
/// Time Complexity: *O*(*N*)
1857+
///
18521858
/// See also [`is_partitioned()`] and [`partition()`].
18531859
///
18541860
/// [`is_partitioned()`]: Iterator::is_partitioned

core/src/ptr/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,12 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
342342
/// ```
343343
/// use std::ptr;
344344
///
345-
/// let mut array = [0, 1, 2, 3];
345+
/// let mut array: [i32; 4] = [0, 1, 2, 3];
346+
///
347+
/// let array_ptr: *mut i32 = array.as_mut_ptr();
346348
///
347-
/// let x = array[0..].as_mut_ptr() as *mut [u32; 3]; // this is `array[0..3]`
348-
/// let y = array[1..].as_mut_ptr() as *mut [u32; 3]; // this is `array[1..4]`
349+
/// let x = array_ptr as *mut [i32; 3]; // this is `array[0..3]`
350+
/// let y = unsafe { array_ptr.add(1) } as *mut [i32; 3]; // this is `array[1..4]`
349351
///
350352
/// unsafe {
351353
/// ptr::swap(x, y);

proc_macro/src/bridge/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ macro_rules! with_api {
107107
Literal {
108108
fn drop($self: $S::Literal);
109109
fn clone($self: &$S::Literal) -> $S::Literal;
110+
fn from_str(s: &str) -> Result<$S::Literal, ()>;
110111
fn debug_kind($self: &$S::Literal) -> String;
111112
fn symbol($self: &$S::Literal) -> String;
112113
fn suffix($self: &$S::Literal) -> Option<String>;
@@ -315,6 +316,19 @@ impl<T: Unmark> Unmark for Option<T> {
315316
}
316317
}
317318

319+
impl<T: Mark, E: Mark> Mark for Result<T, E> {
320+
type Unmarked = Result<T::Unmarked, E::Unmarked>;
321+
fn mark(unmarked: Self::Unmarked) -> Self {
322+
unmarked.map(T::mark).map_err(E::mark)
323+
}
324+
}
325+
impl<T: Unmark, E: Unmark> Unmark for Result<T, E> {
326+
type Unmarked = Result<T::Unmarked, E::Unmarked>;
327+
fn unmark(self) -> Self::Unmarked {
328+
self.map(T::unmark).map_err(E::unmark)
329+
}
330+
}
331+
318332
macro_rules! mark_noop {
319333
($($ty:ty),* $(,)?) => {
320334
$(

proc_macro/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ pub struct LexError {
9191
_inner: (),
9292
}
9393

94+
impl LexError {
95+
fn new() -> Self {
96+
LexError { _inner: () }
97+
}
98+
}
99+
94100
#[stable(feature = "proc_macro_lexerror_impls", since = "1.44.0")]
95101
impl fmt::Display for LexError {
96102
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -1171,6 +1177,28 @@ impl Literal {
11711177
}
11721178
}
11731179

1180+
/// Parse a single literal from its stringified representation.
1181+
///
1182+
/// In order to parse successfully, the input string must not contain anything
1183+
/// but the literal token. Specifically, it must not contain whitespace or
1184+
/// comments in addition to the literal.
1185+
///
1186+
/// The resulting literal token will have a `Span::call_site()` span.
1187+
///
1188+
/// NOTE: some errors may cause panics instead of returning `LexError`. We
1189+
/// reserve the right to change these errors into `LexError`s later.
1190+
#[stable(feature = "proc_macro_literal_parse", since = "1.54.0")]
1191+
impl FromStr for Literal {
1192+
type Err = LexError;
1193+
1194+
fn from_str(src: &str) -> Result<Self, LexError> {
1195+
match bridge::client::Literal::from_str(src) {
1196+
Ok(literal) => Ok(Literal(literal)),
1197+
Err(()) => Err(LexError::new()),
1198+
}
1199+
}
1200+
}
1201+
11741202
// N.B., the bridge only provides `to_string`, implement `fmt::Display`
11751203
// based on it (the reverse of the usual relationship between the two).
11761204
#[stable(feature = "proc_macro_lib", since = "1.15.0")]

proc_macro/tests/test.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

std/src/ffi/c_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub struct CString {
185185
///
186186
/// [`&str`]: prim@str
187187
#[derive(Hash)]
188+
#[cfg_attr(not(test), rustc_diagnostic_item = "CStr")]
188189
#[stable(feature = "rust1", since = "1.0.0")]
189190
// FIXME:
190191
// `fn from` in `impl From<&CStr> for Box<CStr>` current implementation relies

test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub mod test {
4949
cli::{parse_opts, TestOpts},
5050
filter_tests,
5151
helpers::metrics::{Metric, MetricMap},
52-
options::{Options, RunIgnored, RunStrategy, ShouldPanic},
52+
options::{Concurrent, Options, RunIgnored, RunStrategy, ShouldPanic},
5353
run_test, test_main, test_main_static,
5454
test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk},
5555
time::{TestExecTime, TestTimeOptions},

0 commit comments

Comments
 (0)