Auto merge of #81240 - JohnTitor:rollup-ieaz82a, r=JohnTitor
Rollup of 11 pull requests Successful merges: - #79655 (Add Vec visualization to understand capacity) - #80172 (Use consistent punctuation for 'Prelude contents' docs) - #80429 (Add regression test for mutual recursion in obligation forest) - #80601 (Improve grammar in documentation of format strings) - #81046 (Improve unknown external crate error) - #81178 (Visit only terminators when removing landing pads) - #81179 (Fix broken links with `--document-private-items` in the standard library) - #81184 (Remove unnecessary `after_run` function) - #81185 (Fix ICE in mir when evaluating SizeOf on unsized type) - #81187 (Fix typo in counters.rs) - #81219 (Document security implications of std::env::temp_dir) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
a243ad280a
|
@ -264,10 +264,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
NullaryOp(mir::NullOp::SizeOf, ty) => {
|
NullaryOp(mir::NullOp::SizeOf, ty) => {
|
||||||
let ty = self.subst_from_current_frame_and_normalize_erasing_regions(ty);
|
let ty = self.subst_from_current_frame_and_normalize_erasing_regions(ty);
|
||||||
let layout = self.layout_of(ty)?;
|
let layout = self.layout_of(ty)?;
|
||||||
assert!(
|
if layout.is_unsized() {
|
||||||
!layout.is_unsized(),
|
// FIXME: This should be a span_bug (#80742)
|
||||||
"SizeOf nullary MIR operator called for unsized type"
|
self.tcx.sess.delay_span_bug(
|
||||||
);
|
self.frame().current_span(),
|
||||||
|
&format!("SizeOf nullary MIR operator called for unsized type {}", ty),
|
||||||
|
);
|
||||||
|
}
|
||||||
self.write_scalar(Scalar::from_machine_usize(layout.size.bytes(), self), dest)?;
|
self.write_scalar(Scalar::from_machine_usize(layout.size.bytes(), self), dest)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
||||||
MirPhase::Const,
|
MirPhase::Const,
|
||||||
&[&[
|
&[&[
|
||||||
&add_moves_for_packed_drops::AddMovesForPackedDrops,
|
&add_moves_for_packed_drops::AddMovesForPackedDrops,
|
||||||
&no_landing_pads::NoLandingPads::new(tcx),
|
&no_landing_pads::NoLandingPads,
|
||||||
&remove_noop_landing_pads::RemoveNoopLandingPads,
|
&remove_noop_landing_pads::RemoveNoopLandingPads,
|
||||||
&simplify::SimplifyCfg::new("make_shim"),
|
&simplify::SimplifyCfg::new("make_shim"),
|
||||||
&add_call_guards::CriticalCallEdges,
|
&add_call_guards::CriticalCallEdges,
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl CoverageCounters {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Activate the `DebugCounters` data structures, to provide additional debug formatting
|
/// Activate the `DebugCounters` data structures, to provide additional debug formatting
|
||||||
/// features when formating `CoverageKind` (counter) values.
|
/// features when formatting `CoverageKind` (counter) values.
|
||||||
pub fn enable_debug(&mut self) {
|
pub fn enable_debug(&mut self) {
|
||||||
self.debug_counters.enable();
|
self.debug_counters.enable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
|
||||||
|
|
||||||
let post_borrowck_cleanup: &[&dyn MirPass<'tcx>] = &[
|
let post_borrowck_cleanup: &[&dyn MirPass<'tcx>] = &[
|
||||||
// Remove all things only needed by analysis
|
// Remove all things only needed by analysis
|
||||||
&no_landing_pads::NoLandingPads::new(tcx),
|
&no_landing_pads::NoLandingPads,
|
||||||
&simplify_branches::SimplifyBranches::new("initial"),
|
&simplify_branches::SimplifyBranches::new("initial"),
|
||||||
&remove_noop_landing_pads::RemoveNoopLandingPads,
|
&remove_noop_landing_pads::RemoveNoopLandingPads,
|
||||||
&cleanup_post_borrowck::CleanupNonCodegenStatements,
|
&cleanup_post_borrowck::CleanupNonCodegenStatements,
|
||||||
|
@ -441,7 +441,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
|
||||||
// These next passes must be executed together
|
// These next passes must be executed together
|
||||||
&add_call_guards::CriticalCallEdges,
|
&add_call_guards::CriticalCallEdges,
|
||||||
&elaborate_drops::ElaborateDrops,
|
&elaborate_drops::ElaborateDrops,
|
||||||
&no_landing_pads::NoLandingPads::new(tcx),
|
&no_landing_pads::NoLandingPads,
|
||||||
// AddMovesForPackedDrops needs to run after drop
|
// AddMovesForPackedDrops needs to run after drop
|
||||||
// elaboration.
|
// elaboration.
|
||||||
&add_moves_for_packed_drops::AddMovesForPackedDrops,
|
&add_moves_for_packed_drops::AddMovesForPackedDrops,
|
||||||
|
|
|
@ -2,42 +2,27 @@
|
||||||
//! specified.
|
//! specified.
|
||||||
|
|
||||||
use crate::transform::MirPass;
|
use crate::transform::MirPass;
|
||||||
use rustc_middle::mir::visit::MutVisitor;
|
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_target::spec::PanicStrategy;
|
use rustc_target::spec::PanicStrategy;
|
||||||
|
|
||||||
pub struct NoLandingPads<'tcx> {
|
pub struct NoLandingPads;
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> NoLandingPads<'tcx> {
|
impl<'tcx> MirPass<'tcx> for NoLandingPads {
|
||||||
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
|
|
||||||
NoLandingPads { tcx }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> MirPass<'tcx> for NoLandingPads<'tcx> {
|
|
||||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
no_landing_pads(tcx, body)
|
no_landing_pads(tcx, body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
|
if tcx.sess.panic_strategy() != PanicStrategy::Abort {
|
||||||
NoLandingPads::new(tcx).visit_body(body);
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> MutVisitor<'tcx> for NoLandingPads<'tcx> {
|
|
||||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
|
||||||
self.tcx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
|
for block in body.basic_blocks_mut() {
|
||||||
|
let terminator = block.terminator_mut();
|
||||||
if let Some(unwind) = terminator.kind.unwind_mut() {
|
if let Some(unwind) = terminator.kind.unwind_mut() {
|
||||||
unwind.take();
|
unwind.take();
|
||||||
}
|
}
|
||||||
self.super_terminator(terminator, location);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,13 @@ impl<'a> PathSource<'a> {
|
||||||
// "function" here means "anything callable" rather than `DefKind::Fn`,
|
// "function" here means "anything callable" rather than `DefKind::Fn`,
|
||||||
// this is not precise but usually more helpful than just "value".
|
// this is not precise but usually more helpful than just "value".
|
||||||
Some(ExprKind::Call(call_expr, _)) => match &call_expr.kind {
|
Some(ExprKind::Call(call_expr, _)) => match &call_expr.kind {
|
||||||
|
// the case of `::some_crate()`
|
||||||
|
ExprKind::Path(_, path)
|
||||||
|
if path.segments.len() == 2
|
||||||
|
&& path.segments[0].ident.name == kw::PathRoot =>
|
||||||
|
{
|
||||||
|
"external crate"
|
||||||
|
}
|
||||||
ExprKind::Path(_, path) => {
|
ExprKind::Path(_, path) => {
|
||||||
let mut msg = "function";
|
let mut msg = "function";
|
||||||
if let Some(segment) = path.segments.iter().last() {
|
if let Some(segment) = path.segments.iter().last() {
|
||||||
|
|
|
@ -2485,8 +2485,14 @@ impl<'a> Resolver<'a> {
|
||||||
(format!("use of undeclared crate or module `{}`", ident), None)
|
(format!("use of undeclared crate or module `{}`", ident), None)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut msg =
|
let parent = path[i - 1].ident.name;
|
||||||
format!("could not find `{}` in `{}`", ident, path[i - 1].ident);
|
let parent = if parent == kw::PathRoot {
|
||||||
|
"crate root".to_owned()
|
||||||
|
} else {
|
||||||
|
format!("`{}`", parent)
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut msg = format!("could not find `{}` in {}", ident, parent);
|
||||||
if ns == TypeNS || ns == ValueNS {
|
if ns == TypeNS || ns == ValueNS {
|
||||||
let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
|
let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
|
||||||
if let FindBindingResult::Binding(Ok(binding)) =
|
if let FindBindingResult::Binding(Ok(binding)) =
|
||||||
|
@ -2494,11 +2500,11 @@ impl<'a> Resolver<'a> {
|
||||||
{
|
{
|
||||||
let mut found = |what| {
|
let mut found = |what| {
|
||||||
msg = format!(
|
msg = format!(
|
||||||
"expected {}, found {} `{}` in `{}`",
|
"expected {}, found {} `{}` in {}",
|
||||||
ns.descr(),
|
ns.descr(),
|
||||||
what,
|
what,
|
||||||
ident,
|
ident,
|
||||||
path[i - 1].ident
|
parent
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
if binding.module().is_some() {
|
if binding.module().is_some() {
|
||||||
|
|
|
@ -282,21 +282,22 @@
|
||||||
//! `%`. The actual grammar for the formatting syntax is:
|
//! `%`. The actual grammar for the formatting syntax is:
|
||||||
//!
|
//!
|
||||||
//! ```text
|
//! ```text
|
||||||
//! format_string := <text> [ maybe-format <text> ] *
|
//! format_string := text [ maybe_format text ] *
|
||||||
//! maybe-format := '{' '{' | '}' '}' | <format>
|
//! maybe_format := '{' '{' | '}' '}' | format
|
||||||
//! format := '{' [ argument ] [ ':' format_spec ] '}'
|
//! format := '{' [ argument ] [ ':' format_spec ] '}'
|
||||||
//! argument := integer | identifier
|
//! argument := integer | identifier
|
||||||
//!
|
//!
|
||||||
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
|
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
|
||||||
//! fill := character
|
//! fill := character
|
||||||
//! align := '<' | '^' | '>'
|
//! align := '<' | '^' | '>'
|
||||||
//! sign := '+' | '-'
|
//! sign := '+' | '-'
|
||||||
//! width := count
|
//! width := count
|
||||||
//! precision := count | '*'
|
//! precision := count | '*'
|
||||||
//! type := identifier | '?' | ''
|
//! type := '' | '?' | 'x?' | 'X?' | identifier
|
||||||
//! count := parameter | integer
|
//! count := parameter | integer
|
||||||
//! parameter := argument '$'
|
//! parameter := argument '$'
|
||||||
//! ```
|
//! ```
|
||||||
|
//! In the above grammar, `text` may not contain any `'{'` or `'}'` characters.
|
||||||
//!
|
//!
|
||||||
//! # Formatting traits
|
//! # Formatting traits
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -285,6 +285,27 @@ mod spec_extend;
|
||||||
/// you would see if you coerced it to a slice), followed by [`capacity`]` -
|
/// you would see if you coerced it to a slice), followed by [`capacity`]` -
|
||||||
/// `[`len`] logically uninitialized, contiguous elements.
|
/// `[`len`] logically uninitialized, contiguous elements.
|
||||||
///
|
///
|
||||||
|
/// A vector containing the elements `'a'` and `'b'` with capacity 4 can be
|
||||||
|
/// visualized as below. The top part is the `Vec` struct, it contains a
|
||||||
|
/// pointer to the head of the allocation in the heap, length and capacity.
|
||||||
|
/// The bottom part is the allocation on the heap, a contiguous memory block.
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
|
/// ptr len capacity
|
||||||
|
/// +--------+--------+--------+
|
||||||
|
/// | 0x0123 | 2 | 4 |
|
||||||
|
/// +--------+--------+--------+
|
||||||
|
/// |
|
||||||
|
/// v
|
||||||
|
/// Heap +--------+--------+--------+--------+
|
||||||
|
/// | 'a' | 'b' | uninit | uninit |
|
||||||
|
/// +--------+--------+--------+--------+
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// - **uninit** represents memory that is not initialized, see [`MaybeUninit`].
|
||||||
|
/// - Note: the ABI is not stable and `Vec` makes no guarantees about its memory
|
||||||
|
/// layout (including the order of fields).
|
||||||
|
///
|
||||||
/// `Vec` will never perform a "small optimization" where elements are actually
|
/// `Vec` will never perform a "small optimization" where elements are actually
|
||||||
/// stored on the stack for two reasons:
|
/// stored on the stack for two reasons:
|
||||||
///
|
///
|
||||||
|
@ -345,6 +366,7 @@ mod spec_extend;
|
||||||
/// [`push`]: Vec::push
|
/// [`push`]: Vec::push
|
||||||
/// [`insert`]: Vec::insert
|
/// [`insert`]: Vec::insert
|
||||||
/// [`reserve`]: Vec::reserve
|
/// [`reserve`]: Vec::reserve
|
||||||
|
/// [`MaybeUninit`]: core::mem::MaybeUninit
|
||||||
/// [owned slice]: Box
|
/// [owned slice]: Box
|
||||||
/// [slice]: ../../std/primitive.slice.html
|
/// [slice]: ../../std/primitive.slice.html
|
||||||
/// [`&`]: ../../std/primitive.reference.html
|
/// [`&`]: ../../std/primitive.reference.html
|
||||||
|
|
|
@ -5,7 +5,7 @@ use super::{SpecExtend, Vec};
|
||||||
|
|
||||||
/// Another specialization trait for Vec::from_iter
|
/// Another specialization trait for Vec::from_iter
|
||||||
/// necessary to manually prioritize overlapping specializations
|
/// necessary to manually prioritize overlapping specializations
|
||||||
/// see [`SpecFromIter`] for details.
|
/// see [`SpecFromIter`](super::SpecFromIter) for details.
|
||||||
pub(super) trait SpecFromIterNested<T, I> {
|
pub(super) trait SpecFromIterNested<T, I> {
|
||||||
fn from_iter(iter: I) -> Self;
|
fn from_iter(iter: I) -> Self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,6 +561,13 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||||
|
|
||||||
/// Returns the path of a temporary directory.
|
/// Returns the path of a temporary directory.
|
||||||
///
|
///
|
||||||
|
/// The temporary directory may be shared among users, or between processes
|
||||||
|
/// with different privileges; thus, the creation of any files or directories
|
||||||
|
/// in the temporary directory must use a secure method to create a uniquely
|
||||||
|
/// named file. Creating a file or directory with a fixed or predictable name
|
||||||
|
/// may result in "insecure temporary file" security vulnerabilities. Consider
|
||||||
|
/// using a crate that securely creates temporary files or directories.
|
||||||
|
///
|
||||||
/// # Unix
|
/// # Unix
|
||||||
///
|
///
|
||||||
/// Returns the value of the `TMPDIR` environment variable if it is
|
/// Returns the value of the `TMPDIR` environment variable if it is
|
||||||
|
@ -580,14 +587,10 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use std::env;
|
/// use std::env;
|
||||||
/// use std::fs::File;
|
|
||||||
///
|
///
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() {
|
||||||
/// let mut dir = env::temp_dir();
|
/// let mut dir = env::temp_dir();
|
||||||
/// dir.push("foo.txt");
|
/// println!("Temporary directory: {}", dir.display());
|
||||||
///
|
|
||||||
/// let f = File::create(dir)?;
|
|
||||||
/// Ok(())
|
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "env", since = "1.0.0")]
|
#[stable(feature = "env", since = "1.0.0")]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! The I/O Prelude
|
//! The I/O Prelude.
|
||||||
//!
|
//!
|
||||||
//! The purpose of this module is to alleviate imports of many common I/O traits
|
//! The purpose of this module is to alleviate imports of many common I/O traits
|
||||||
//! by adding a glob import to the top of I/O heavy modules:
|
//! by adding a glob import to the top of I/O heavy modules:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! The Rust Prelude.
|
//! # The Rust Prelude
|
||||||
//!
|
//!
|
||||||
//! Rust comes with a variety of things in its standard library. However, if
|
//! Rust comes with a variety of things in its standard library. However, if
|
||||||
//! you had to manually import every single thing that you used, it would be
|
//! you had to manually import every single thing that you used, it would be
|
||||||
|
@ -28,35 +28,35 @@
|
||||||
//! The current version of the prelude (version 1) lives in
|
//! The current version of the prelude (version 1) lives in
|
||||||
//! [`std::prelude::v1`], and re-exports the following:
|
//! [`std::prelude::v1`], and re-exports the following:
|
||||||
//!
|
//!
|
||||||
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]},
|
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]}:
|
||||||
//! marker traits that indicate fundamental properties of types.
|
//! marker traits that indicate fundamental properties of types.
|
||||||
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}, various
|
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}: various
|
||||||
//! operations for both destructors and overloading `()`.
|
//! operations for both destructors and overloading `()`.
|
||||||
//! * [`std::mem`]::[`drop`][`mem::drop`], a convenience function for explicitly
|
//! * [`std::mem`]::[`drop`][`mem::drop`]: a convenience function for explicitly
|
||||||
//! dropping a value.
|
//! dropping a value.
|
||||||
//! * [`std::boxed`]::[`Box`], a way to allocate values on the heap.
|
//! * [`std::boxed`]::[`Box`]: a way to allocate values on the heap.
|
||||||
//! * [`std::borrow`]::[`ToOwned`], the conversion trait that defines
|
//! * [`std::borrow`]::[`ToOwned`]: the conversion trait that defines
|
||||||
//! [`to_owned`], the generic method for creating an owned type from a
|
//! [`to_owned`], the generic method for creating an owned type from a
|
||||||
//! borrowed type.
|
//! borrowed type.
|
||||||
//! * [`std::clone`]::[`Clone`], the ubiquitous trait that defines
|
//! * [`std::clone`]::[`Clone`]: the ubiquitous trait that defines
|
||||||
//! [`clone`][`Clone::clone`], the method for producing a copy of a value.
|
//! [`clone`][`Clone::clone`], the method for producing a copy of a value.
|
||||||
//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`] }, the
|
//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]}: the
|
||||||
//! comparison traits, which implement the comparison operators and are often
|
//! comparison traits, which implement the comparison operators and are often
|
||||||
//! seen in trait bounds.
|
//! seen in trait bounds.
|
||||||
//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}, generic
|
//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}: generic
|
||||||
//! conversions, used by savvy API authors to create overloaded methods.
|
//! conversions, used by savvy API authors to create overloaded methods.
|
||||||
//! * [`std::default`]::[`Default`], types that have default values.
|
//! * [`std::default`]::[`Default`], types that have default values.
|
||||||
//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`]
|
//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`],
|
||||||
//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}, iterators of various
|
//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}: iterators of various
|
||||||
//! kinds.
|
//! kinds.
|
||||||
//! * [`std::option`]::[`Option`]::{[`self`][`Option`], [`Some`], [`None`]}, a
|
//! * [`std::option`]::[`Option`]::{[`self`][`Option`], [`Some`], [`None`]}, a
|
||||||
//! type which expresses the presence or absence of a value. This type is so
|
//! type which expresses the presence or absence of a value. This type is so
|
||||||
//! commonly used, its variants are also exported.
|
//! commonly used, its variants are also exported.
|
||||||
//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}, a type
|
//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}: a type
|
||||||
//! for functions that may succeed or fail. Like [`Option`], its variants are
|
//! for functions that may succeed or fail. Like [`Option`], its variants are
|
||||||
//! exported as well.
|
//! exported as well.
|
||||||
//! * [`std::string`]::{[`String`], [`ToString`]}, heap allocated strings.
|
//! * [`std::string`]::{[`String`], [`ToString`]}: heap-allocated strings.
|
||||||
//! * [`std::vec`]::[`Vec`], a growable, heap-allocated vector.
|
//! * [`std::vec`]::[`Vec`]: a growable, heap-allocated vector.
|
||||||
//!
|
//!
|
||||||
//! [`mem::drop`]: crate::mem::drop
|
//! [`mem::drop`]: crate::mem::drop
|
||||||
//! [`std::borrow`]: crate::borrow
|
//! [`std::borrow`]: crate::borrow
|
||||||
|
|
|
@ -38,10 +38,14 @@ crate trait FormatRenderer<'tcx>: Clone {
|
||||||
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
|
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
|
||||||
|
|
||||||
/// Post processing hook for cleanup and dumping output to files.
|
/// Post processing hook for cleanup and dumping output to files.
|
||||||
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error>;
|
///
|
||||||
|
/// A handler is available if the renderer wants to report errors.
|
||||||
/// Called after everything else to write out errors.
|
fn after_krate(
|
||||||
fn after_run(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>;
|
&mut self,
|
||||||
|
krate: &clean::Crate,
|
||||||
|
cache: &Cache,
|
||||||
|
diag: &rustc_errors::Handler,
|
||||||
|
) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Main method for rendering a crate.
|
/// Main method for rendering a crate.
|
||||||
|
@ -104,6 +108,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format_renderer.after_krate(&krate, &cache)?;
|
format_renderer.after_krate(&krate, &cache, diag)
|
||||||
format_renderer.after_run(diag)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,17 +523,12 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||||
Ok((cx, krate))
|
Ok((cx, krate))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_run(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error> {
|
fn after_krate(
|
||||||
Arc::get_mut(&mut self.shared).unwrap().fs.close();
|
&mut self,
|
||||||
let nb_errors = self.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
|
krate: &clean::Crate,
|
||||||
if nb_errors > 0 {
|
cache: &Cache,
|
||||||
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
diag: &rustc_errors::Handler,
|
||||||
} else {
|
) -> Result<(), Error> {
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
|
|
||||||
let final_file = self.dst.join(&*krate.name.as_str()).join("all.html");
|
let final_file = self.dst.join(&*krate.name.as_str()).join("all.html");
|
||||||
let settings_file = self.dst.join("settings.html");
|
let settings_file = self.dst.join("settings.html");
|
||||||
let crate_name = krate.name;
|
let crate_name = krate.name;
|
||||||
|
@ -596,7 +591,15 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||||
&style_files,
|
&style_files,
|
||||||
);
|
);
|
||||||
self.shared.fs.write(&settings_file, v.as_bytes())?;
|
self.shared.fs.write(&settings_file, v.as_bytes())?;
|
||||||
Ok(())
|
|
||||||
|
// Flush pending errors.
|
||||||
|
Arc::get_mut(&mut self.shared).unwrap().fs.close();
|
||||||
|
let nb_errors = self.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
|
||||||
|
if nb_errors > 0 {
|
||||||
|
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mod_item_in(
|
fn mod_item_in(
|
||||||
|
|
|
@ -199,7 +199,12 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
|
fn after_krate(
|
||||||
|
&mut self,
|
||||||
|
krate: &clean::Crate,
|
||||||
|
cache: &Cache,
|
||||||
|
_diag: &rustc_errors::Handler,
|
||||||
|
) -> Result<(), Error> {
|
||||||
debug!("Done with crate");
|
debug!("Done with crate");
|
||||||
let mut index = (*self.index).clone().into_inner();
|
let mut index = (*self.index).clone().into_inner();
|
||||||
index.extend(self.get_trait_items(cache));
|
index.extend(self.get_trait_items(cache));
|
||||||
|
@ -245,8 +250,4 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
serde_json::ser::to_writer(&file, &output).unwrap();
|
serde_json::ser::to_writer(&file, &output).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_run(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ error[E0432]: unresolved import `E`
|
||||||
--> $DIR/edition-imports-virtual-2015-gated.rs:8:5
|
--> $DIR/edition-imports-virtual-2015-gated.rs:8:5
|
||||||
|
|
|
|
||||||
LL | gen_gated!();
|
LL | gen_gated!();
|
||||||
| ^^^^^^^^^^^^^ could not find `E` in `{{root}}`
|
| ^^^^^^^^^^^^^ could not find `E` in crate root
|
||||||
|
|
|
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
// check-fail
|
||||||
|
|
||||||
|
// This test used to cause an ICE in rustc_mir::interpret::step::eval_rvalue_into_place
|
||||||
|
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
#![feature(const_evaluatable_checked)]
|
||||||
|
#![feature(const_generics)]
|
||||||
|
|
||||||
|
use std::fmt::Debug;
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
use std::mem::size_of;
|
||||||
|
|
||||||
|
struct Inline<T>
|
||||||
|
where
|
||||||
|
[u8; size_of::<T>() + 1]: ,
|
||||||
|
{
|
||||||
|
_phantom: PhantomData<T>,
|
||||||
|
buf: [u8; size_of::<T>() + 1],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Inline<T>
|
||||||
|
where
|
||||||
|
[u8; size_of::<T>() + 1]: ,
|
||||||
|
{
|
||||||
|
pub fn new(val: T) -> Inline<T> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let dst = Inline::<dyn Debug>::new(0); //~ ERROR
|
||||||
|
//~^ ERROR
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
error[E0599]: no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope
|
||||||
|
--> $DIR/issue-80742.rs:31:36
|
||||||
|
|
|
||||||
|
LL | / struct Inline<T>
|
||||||
|
LL | | where
|
||||||
|
LL | | [u8; size_of::<T>() + 1]: ,
|
||||||
|
LL | | {
|
||||||
|
LL | | _phantom: PhantomData<T>,
|
||||||
|
LL | | buf: [u8; size_of::<T>() + 1],
|
||||||
|
LL | | }
|
||||||
|
| |_- function or associated item `new` not found for this
|
||||||
|
...
|
||||||
|
LL | let dst = Inline::<dyn Debug>::new(0);
|
||||||
|
| ^^^ function or associated item not found in `Inline<dyn Debug>`
|
||||||
|
|
|
||||||
|
::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
||||||
|
|
|
||||||
|
LL | pub trait Debug {
|
||||||
|
| --------------- doesn't satisfy `dyn Debug: Sized`
|
||||||
|
|
|
||||||
|
= note: the method `new` exists but the following trait bounds were not satisfied:
|
||||||
|
`dyn Debug: Sized`
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
|
||||||
|
--> $DIR/issue-80742.rs:31:15
|
||||||
|
|
|
||||||
|
LL | struct Inline<T>
|
||||||
|
| - required by this bound in `Inline`
|
||||||
|
...
|
||||||
|
LL | let dst = Inline::<dyn Debug>::new(0);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: the trait `Sized` is not implemented for `dyn Debug`
|
||||||
|
help: consider relaxing the implicit `Sized` restriction
|
||||||
|
|
|
||||||
|
LL | struct Inline<T: ?Sized>
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0277, E0599.
|
||||||
|
For more information about an error, try `rustc --explain E0277`.
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
::foo() //~ cannot find external crate `foo` in the crate root
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0425]: cannot find external crate `foo` in the crate root
|
||||||
|
--> $DIR/crate-called-as-function.rs:2:7
|
||||||
|
|
|
||||||
|
LL | ::foo()
|
||||||
|
| ^^^ not found in the crate root
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0425`.
|
|
@ -0,0 +1,4 @@
|
||||||
|
fn main() {
|
||||||
|
let _map = std::hahmap::HashMap::new();
|
||||||
|
//~^ ERROR failed to resolve: could not find `hahmap` in `std
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
error[E0433]: failed to resolve: could not find `hahmap` in `std`
|
||||||
|
--> $DIR/missing-in-namespace.rs:2:29
|
||||||
|
|
|
||||||
|
LL | let _map = std::hahmap::HashMap::new();
|
||||||
|
| ^^^^^^^ not found in `std::hahmap`
|
||||||
|
|
|
||||||
|
help: consider importing this struct
|
||||||
|
|
|
||||||
|
LL | use std::collections::HashMap;
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0433`.
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let s = ::xcrate::S;
|
let s = ::xcrate::S;
|
||||||
//~^ ERROR failed to resolve: could not find `xcrate` in `{{root}}`
|
//~^ ERROR failed to resolve: could not find `xcrate` in crate root
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0433]: failed to resolve: could not find `xcrate` in `{{root}}`
|
error[E0433]: failed to resolve: could not find `xcrate` in crate root
|
||||||
--> $DIR/non-existent-2.rs:4:15
|
--> $DIR/non-existent-2.rs:4:15
|
||||||
|
|
|
|
||||||
LL | let s = ::xcrate::S;
|
LL | let s = ::xcrate::S;
|
||||||
| ^^^^^^ could not find `xcrate` in `{{root}}`
|
| ^^^^^^ could not find `xcrate` in crate root
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
pub fn iso<A, B, F1, F2>(a: F1, b: F2) -> (Box<dyn Fn(A) -> B>, Box<dyn Fn(B) -> A>)
|
||||||
|
where
|
||||||
|
F1: (Fn(A) -> B) + 'static,
|
||||||
|
F2: (Fn(B) -> A) + 'static,
|
||||||
|
{
|
||||||
|
(Box::new(a), Box::new(b))
|
||||||
|
}
|
||||||
|
pub fn iso_un_option<A, B>() -> (Box<dyn Fn(A) -> B>, Box<dyn Fn(B) -> A>) {
|
||||||
|
let left = |o_a: Option<_>| o_a.unwrap();
|
||||||
|
let right = |o_b: Option<_>| o_b.unwrap();
|
||||||
|
iso(left, right)
|
||||||
|
//~^ ERROR overflow
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,16 @@
|
||||||
|
error[E0275]: overflow evaluating the requirement `Option<_>: Sized`
|
||||||
|
--> $DIR/mutual-recursion-issue-75860.rs:11:5
|
||||||
|
|
|
||||||
|
LL | iso(left, right)
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
::: $SRC_DIR/core/src/option.rs:LL:COL
|
||||||
|
|
|
||||||
|
LL | pub enum Option<T> {
|
||||||
|
| - required by this bound in `Option`
|
||||||
|
|
|
||||||
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`mutual_recursion_issue_75860`)
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0275`.
|
Loading…
Reference in New Issue