mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Fixup some issues with minicore
This commit is contained in:
parent
563bb6bd6c
commit
5df690e13f
4 changed files with 73 additions and 48 deletions
|
@ -913,6 +913,7 @@ pub mod fmt {
|
|||
}
|
||||
|
||||
mod rt {
|
||||
use super::*;
|
||||
|
||||
extern "C" {
|
||||
type Opaque;
|
||||
|
@ -930,8 +931,8 @@ pub mod fmt {
|
|||
unsafe { Argument { formatter: transmute(f), value: transmute(x) } }
|
||||
}
|
||||
|
||||
pub fn new_display<'b, T: Display>(x: &'b T) -> Argument<'_> {
|
||||
Self::new(x, Display::fmt)
|
||||
pub fn new_display<'b, T: crate::fmt::Display>(x: &'b T) -> Argument<'_> {
|
||||
Self::new(x, crate::fmt::Display::fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -968,7 +969,9 @@ pub mod fmt {
|
|||
flags: u32,
|
||||
precision: Count,
|
||||
width: Count,
|
||||
) -> Self;
|
||||
) -> Self {
|
||||
Placeholder { position, fill, align, flags, precision, width }
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "format_unsafe_arg"]
|
||||
|
@ -1007,6 +1010,14 @@ pub mod fmt {
|
|||
) -> Arguments<'a> {
|
||||
Arguments { pieces, fmt: Some(fmt), args }
|
||||
}
|
||||
|
||||
pub const fn as_str(&self) -> Option<&'static str> {
|
||||
match (self.pieces, self.args) {
|
||||
([], []) => Some(""),
|
||||
([s], []) => Some(s),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// region:derive
|
||||
|
@ -1156,8 +1167,8 @@ pub mod pin {
|
|||
pointer: P,
|
||||
}
|
||||
impl<P> Pin<P> {
|
||||
pub fn new(_pointer: P) -> Pin<P> {
|
||||
loop {}
|
||||
pub fn new(pointer: P) -> Pin<P> {
|
||||
Pin { pointer }
|
||||
}
|
||||
}
|
||||
// region:deref
|
||||
|
@ -1382,12 +1393,23 @@ mod panic {
|
|||
|
||||
mod panicking {
|
||||
#[rustc_const_panic_str] // enforce a &&str argument in const-check and hook this by const-eval
|
||||
pub const fn panic_display<T: fmt::Display>(x: &T) -> ! {
|
||||
panic_fmt(format_args!("{}", *x));
|
||||
pub const fn panic_display<T: crate::fmt::Display>(x: &T) -> ! {
|
||||
panic_fmt(crate::format_args!("{}", *x));
|
||||
}
|
||||
|
||||
// This function is used instead of panic_fmt in const eval.
|
||||
#[lang = "const_panic_fmt"]
|
||||
pub const fn const_panic_fmt(fmt: crate::fmt::Arguments<'_>) -> ! {
|
||||
if let Some(msg) = fmt.as_str() {
|
||||
// The panic_display function is hooked by const eval.
|
||||
panic_display(&msg);
|
||||
} else {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "panic_fmt"] // needed for const-evaluated panics
|
||||
pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
|
||||
pub const fn panic_fmt(fmt: crate::fmt::Arguments<'_>) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue