forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#100644 - TaKO8Ki:rollup-n0o6a1t, r=TaKO8Ki
Rollup of 4 pull requests Successful merges: - rust-lang#100243 (Remove opt_remap_env_constness from rustc_query_impl) - rust-lang#100625 (Add `IpDisplayBuffer` helper struct.) - rust-lang#100629 (Use `merged_ty` method instead of rewriting it every time) - rust-lang#100630 (rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
7 changed files
with
78 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::fmt; | ||
use crate::mem::MaybeUninit; | ||
use crate::str; | ||
|
||
/// Used for slow path in `Display` implementations when alignment is required. | ||
pub struct IpDisplayBuffer<const SIZE: usize> { | ||
buf: [MaybeUninit<u8>; SIZE], | ||
len: usize, | ||
} | ||
|
||
impl<const SIZE: usize> IpDisplayBuffer<SIZE> { | ||
#[inline] | ||
pub const fn new() -> Self { | ||
Self { buf: MaybeUninit::uninit_array(), len: 0 } | ||
} | ||
|
||
#[inline] | ||
pub fn as_str(&self) -> &str { | ||
// SAFETY: `buf` is only written to by the `fmt::Write::write_str` implementation | ||
// which writes a valid UTF-8 string to `buf` and correctly sets `len`. | ||
unsafe { | ||
let s = MaybeUninit::slice_assume_init_ref(&self.buf[..self.len]); | ||
str::from_utf8_unchecked(s) | ||
} | ||
} | ||
} | ||
|
||
impl<const SIZE: usize> fmt::Write for IpDisplayBuffer<SIZE> { | ||
fn write_str(&mut self, s: &str) -> fmt::Result { | ||
let bytes = s.as_bytes(); | ||
|
||
if let Some(buf) = self.buf.get_mut(self.len..(self.len + bytes.len())) { | ||
MaybeUninit::write_slice(buf, bytes); | ||
self.len += bytes.len(); | ||
Ok(()) | ||
} else { | ||
Err(fmt::Error) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/test/rustdoc-json/reexport/export_extern_crate_as_self.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! Regression test for <https://github.com/rust-lang/rust/issues/100531> | ||
#![feature(no_core)] | ||
#![no_core] | ||
|
||
#![crate_name = "export_extern_crate_as_self"] | ||
|
||
// ignore-tidy-linelength | ||
|
||
// @is export_extern_crate_as_self.json "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\" | ||
pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has |