Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a243ad2

Browse files
committedJan 21, 2021
Auto merge of rust-lang#81240 - JohnTitor:rollup-ieaz82a, r=JohnTitor
Rollup of 11 pull requests Successful merges: - rust-lang#79655 (Add Vec visualization to understand capacity) - rust-lang#80172 (Use consistent punctuation for 'Prelude contents' docs) - rust-lang#80429 (Add regression test for mutual recursion in obligation forest) - rust-lang#80601 (Improve grammar in documentation of format strings) - rust-lang#81046 (Improve unknown external crate error) - rust-lang#81178 (Visit only terminators when removing landing pads) - rust-lang#81179 (Fix broken links with `--document-private-items` in the standard library) - rust-lang#81184 (Remove unnecessary `after_run` function) - rust-lang#81185 (Fix ICE in mir when evaluating SizeOf on unsized type) - rust-lang#81187 (Fix typo in counters.rs) - rust-lang#81219 (Document security implications of std::env::temp_dir) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 339e196 + d6c7a79 commit a243ad2

File tree

27 files changed

+256
-86
lines changed

27 files changed

+256
-86
lines changed
 

‎compiler/rustc_mir/src/interpret/step.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
264264
NullaryOp(mir::NullOp::SizeOf, ty) => {
265265
let ty = self.subst_from_current_frame_and_normalize_erasing_regions(ty);
266266
let layout = self.layout_of(ty)?;
267-
assert!(
268-
!layout.is_unsized(),
269-
"SizeOf nullary MIR operator called for unsized type"
270-
);
267+
if layout.is_unsized() {
268+
// FIXME: This should be a span_bug (#80742)
269+
self.tcx.sess.delay_span_bug(
270+
self.frame().current_span(),
271+
&format!("SizeOf nullary MIR operator called for unsized type {}", ty),
272+
);
273+
}
271274
self.write_scalar(Scalar::from_machine_usize(layout.size.bytes(), self), dest)?;
272275
}
273276

‎compiler/rustc_mir/src/shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
8181
MirPhase::Const,
8282
&[&[
8383
&add_moves_for_packed_drops::AddMovesForPackedDrops,
84-
&no_landing_pads::NoLandingPads::new(tcx),
84+
&no_landing_pads::NoLandingPads,
8585
&remove_noop_landing_pads::RemoveNoopLandingPads,
8686
&simplify::SimplifyCfg::new("make_shim"),
8787
&add_call_guards::CriticalCallEdges,

‎compiler/rustc_mir/src/transform/coverage/counters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl CoverageCounters {
3232
}
3333

3434
/// Activate the `DebugCounters` data structures, to provide additional debug formatting
35-
/// features when formating `CoverageKind` (counter) values.
35+
/// features when formatting `CoverageKind` (counter) values.
3636
pub fn enable_debug(&mut self) {
3737
self.debug_counters.enable();
3838
}

‎compiler/rustc_mir/src/transform/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,15 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
433433

434434
let post_borrowck_cleanup: &[&dyn MirPass<'tcx>] = &[
435435
// Remove all things only needed by analysis
436-
&no_landing_pads::NoLandingPads::new(tcx),
436+
&no_landing_pads::NoLandingPads,
437437
&simplify_branches::SimplifyBranches::new("initial"),
438438
&remove_noop_landing_pads::RemoveNoopLandingPads,
439439
&cleanup_post_borrowck::CleanupNonCodegenStatements,
440440
&simplify::SimplifyCfg::new("early-opt"),
441441
// These next passes must be executed together
442442
&add_call_guards::CriticalCallEdges,
443443
&elaborate_drops::ElaborateDrops,
444-
&no_landing_pads::NoLandingPads::new(tcx),
444+
&no_landing_pads::NoLandingPads,
445445
// AddMovesForPackedDrops needs to run after drop
446446
// elaboration.
447447
&add_moves_for_packed_drops::AddMovesForPackedDrops,

‎compiler/rustc_mir/src/transform/no_landing_pads.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,27 @@
22
//! specified.
33
44
use crate::transform::MirPass;
5-
use rustc_middle::mir::visit::MutVisitor;
65
use rustc_middle::mir::*;
76
use rustc_middle::ty::TyCtxt;
87
use rustc_target::spec::PanicStrategy;
98

10-
pub struct NoLandingPads<'tcx> {
11-
tcx: TyCtxt<'tcx>,
12-
}
13-
14-
impl<'tcx> NoLandingPads<'tcx> {
15-
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
16-
NoLandingPads { tcx }
17-
}
18-
}
9+
pub struct NoLandingPads;
1910

20-
impl<'tcx> MirPass<'tcx> for NoLandingPads<'tcx> {
11+
impl<'tcx> MirPass<'tcx> for NoLandingPads {
2112
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
2213
no_landing_pads(tcx, body)
2314
}
2415
}
2516

2617
pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
27-
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
28-
NoLandingPads::new(tcx).visit_body(body);
29-
}
30-
}
31-
32-
impl<'tcx> MutVisitor<'tcx> for NoLandingPads<'tcx> {
33-
fn tcx(&self) -> TyCtxt<'tcx> {
34-
self.tcx
18+
if tcx.sess.panic_strategy() != PanicStrategy::Abort {
19+
return;
3520
}
3621

37-
fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Location) {
22+
for block in body.basic_blocks_mut() {
23+
let terminator = block.terminator_mut();
3824
if let Some(unwind) = terminator.kind.unwind_mut() {
3925
unwind.take();
4026
}
41-
self.super_terminator(terminator, location);
4227
}
4328
}

‎compiler/rustc_resolve/src/late.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ impl<'a> PathSource<'a> {
243243
// "function" here means "anything callable" rather than `DefKind::Fn`,
244244
// this is not precise but usually more helpful than just "value".
245245
Some(ExprKind::Call(call_expr, _)) => match &call_expr.kind {
246+
// the case of `::some_crate()`
247+
ExprKind::Path(_, path)
248+
if path.segments.len() == 2
249+
&& path.segments[0].ident.name == kw::PathRoot =>
250+
{
251+
"external crate"
252+
}
246253
ExprKind::Path(_, path) => {
247254
let mut msg = "function";
248255
if let Some(segment) = path.segments.iter().last() {

‎compiler/rustc_resolve/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,20 +2485,26 @@ impl<'a> Resolver<'a> {
24852485
(format!("use of undeclared crate or module `{}`", ident), None)
24862486
}
24872487
} else {
2488-
let mut msg =
2489-
format!("could not find `{}` in `{}`", ident, path[i - 1].ident);
2488+
let parent = path[i - 1].ident.name;
2489+
let parent = if parent == kw::PathRoot {
2490+
"crate root".to_owned()
2491+
} else {
2492+
format!("`{}`", parent)
2493+
};
2494+
2495+
let mut msg = format!("could not find `{}` in {}", ident, parent);
24902496
if ns == TypeNS || ns == ValueNS {
24912497
let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
24922498
if let FindBindingResult::Binding(Ok(binding)) =
24932499
find_binding_in_ns(self, ns_to_try)
24942500
{
24952501
let mut found = |what| {
24962502
msg = format!(
2497-
"expected {}, found {} `{}` in `{}`",
2503+
"expected {}, found {} `{}` in {}",
24982504
ns.descr(),
24992505
what,
25002506
ident,
2501-
path[i - 1].ident
2507+
parent
25022508
)
25032509
};
25042510
if binding.module().is_some() {

‎library/alloc/src/fmt.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,22 @@
282282
//! `%`. The actual grammar for the formatting syntax is:
283283
//!
284284
//! ```text
285-
//! format_string := <text> [ maybe-format <text> ] *
286-
//! maybe-format := '{' '{' | '}' '}' | <format>
285+
//! format_string := text [ maybe_format text ] *
286+
//! maybe_format := '{' '{' | '}' '}' | format
287287
//! format := '{' [ argument ] [ ':' format_spec ] '}'
288288
//! argument := integer | identifier
289289
//!
290-
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
290+
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
291291
//! fill := character
292292
//! align := '<' | '^' | '>'
293293
//! sign := '+' | '-'
294294
//! width := count
295295
//! precision := count | '*'
296-
//! type := identifier | '?' | ''
296+
//! type := '' | '?' | 'x?' | 'X?' | identifier
297297
//! count := parameter | integer
298298
//! parameter := argument '$'
299299
//! ```
300+
//! In the above grammar, `text` may not contain any `'{'` or `'}'` characters.
300301
//!
301302
//! # Formatting traits
302303
//!

‎library/alloc/src/vec/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,27 @@ mod spec_extend;
285285
/// you would see if you coerced it to a slice), followed by [`capacity`]` -
286286
/// `[`len`] logically uninitialized, contiguous elements.
287287
///
288+
/// A vector containing the elements `'a'` and `'b'` with capacity 4 can be
289+
/// visualized as below. The top part is the `Vec` struct, it contains a
290+
/// pointer to the head of the allocation in the heap, length and capacity.
291+
/// The bottom part is the allocation on the heap, a contiguous memory block.
292+
///
293+
/// ```text
294+
/// ptr len capacity
295+
/// +--------+--------+--------+
296+
/// | 0x0123 | 2 | 4 |
297+
/// +--------+--------+--------+
298+
/// |
299+
/// v
300+
/// Heap +--------+--------+--------+--------+
301+
/// | 'a' | 'b' | uninit | uninit |
302+
/// +--------+--------+--------+--------+
303+
/// ```
304+
///
305+
/// - **uninit** represents memory that is not initialized, see [`MaybeUninit`].
306+
/// - Note: the ABI is not stable and `Vec` makes no guarantees about its memory
307+
/// layout (including the order of fields).
308+
///
288309
/// `Vec` will never perform a "small optimization" where elements are actually
289310
/// stored on the stack for two reasons:
290311
///
@@ -345,6 +366,7 @@ mod spec_extend;
345366
/// [`push`]: Vec::push
346367
/// [`insert`]: Vec::insert
347368
/// [`reserve`]: Vec::reserve
369+
/// [`MaybeUninit`]: core::mem::MaybeUninit
348370
/// [owned slice]: Box
349371
/// [slice]: ../../std/primitive.slice.html
350372
/// [`&`]: ../../std/primitive.reference.html

‎library/alloc/src/vec/spec_from_iter_nested.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::{SpecExtend, Vec};
55

66
/// Another specialization trait for Vec::from_iter
77
/// necessary to manually prioritize overlapping specializations
8-
/// see [`SpecFromIter`] for details.
8+
/// see [`SpecFromIter`](super::SpecFromIter) for details.
99
pub(super) trait SpecFromIterNested<T, I> {
1010
fn from_iter(iter: I) -> Self;
1111
}

‎library/std/src/env.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ pub fn home_dir() -> Option<PathBuf> {
561561

562562
/// Returns the path of a temporary directory.
563563
///
564+
/// The temporary directory may be shared among users, or between processes
565+
/// with different privileges; thus, the creation of any files or directories
566+
/// in the temporary directory must use a secure method to create a uniquely
567+
/// named file. Creating a file or directory with a fixed or predictable name
568+
/// may result in "insecure temporary file" security vulnerabilities. Consider
569+
/// using a crate that securely creates temporary files or directories.
570+
///
564571
/// # Unix
565572
///
566573
/// Returns the value of the `TMPDIR` environment variable if it is
@@ -580,14 +587,10 @@ pub fn home_dir() -> Option<PathBuf> {
580587
///
581588
/// ```no_run
582589
/// use std::env;
583-
/// use std::fs::File;
584590
///
585-
/// fn main() -> std::io::Result<()> {
591+
/// fn main() {
586592
/// let mut dir = env::temp_dir();
587-
/// dir.push("foo.txt");
588-
///
589-
/// let f = File::create(dir)?;
590-
/// Ok(())
593+
/// println!("Temporary directory: {}", dir.display());
591594
/// }
592595
/// ```
593596
#[stable(feature = "env", since = "1.0.0")]

‎library/std/src/io/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! The I/O Prelude
1+
//! The I/O Prelude.
22
//!
33
//! The purpose of this module is to alleviate imports of many common I/O traits
44
//! by adding a glob import to the top of I/O heavy modules:

‎library/std/src/prelude/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! The Rust Prelude.
1+
//! # The Rust Prelude
22
//!
33
//! Rust comes with a variety of things in its standard library. However, if
44
//! you had to manually import every single thing that you used, it would be
@@ -28,35 +28,35 @@
2828
//! The current version of the prelude (version 1) lives in
2929
//! [`std::prelude::v1`], and re-exports the following:
3030
//!
31-
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]},
31+
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]}:
3232
//! marker traits that indicate fundamental properties of types.
33-
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}, various
33+
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}: various
3434
//! operations for both destructors and overloading `()`.
35-
//! * [`std::mem`]::[`drop`][`mem::drop`], a convenience function for explicitly
35+
//! * [`std::mem`]::[`drop`][`mem::drop`]: a convenience function for explicitly
3636
//! dropping a value.
37-
//! * [`std::boxed`]::[`Box`], a way to allocate values on the heap.
38-
//! * [`std::borrow`]::[`ToOwned`], the conversion trait that defines
37+
//! * [`std::boxed`]::[`Box`]: a way to allocate values on the heap.
38+
//! * [`std::borrow`]::[`ToOwned`]: the conversion trait that defines
3939
//! [`to_owned`], the generic method for creating an owned type from a
4040
//! borrowed type.
41-
//! * [`std::clone`]::[`Clone`], the ubiquitous trait that defines
41+
//! * [`std::clone`]::[`Clone`]: the ubiquitous trait that defines
4242
//! [`clone`][`Clone::clone`], the method for producing a copy of a value.
43-
//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`] }, the
43+
//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]}: the
4444
//! comparison traits, which implement the comparison operators and are often
4545
//! seen in trait bounds.
46-
//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}, generic
46+
//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}: generic
4747
//! conversions, used by savvy API authors to create overloaded methods.
4848
//! * [`std::default`]::[`Default`], types that have default values.
49-
//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`]
50-
//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}, iterators of various
49+
//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`],
50+
//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}: iterators of various
5151
//! kinds.
5252
//! * [`std::option`]::[`Option`]::{[`self`][`Option`], [`Some`], [`None`]}, a
5353
//! type which expresses the presence or absence of a value. This type is so
5454
//! commonly used, its variants are also exported.
55-
//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}, a type
55+
//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}: a type
5656
//! for functions that may succeed or fail. Like [`Option`], its variants are
5757
//! exported as well.
58-
//! * [`std::string`]::{[`String`], [`ToString`]}, heap allocated strings.
59-
//! * [`std::vec`]::[`Vec`], a growable, heap-allocated vector.
58+
//! * [`std::string`]::{[`String`], [`ToString`]}: heap-allocated strings.
59+
//! * [`std::vec`]::[`Vec`]: a growable, heap-allocated vector.
6060
//!
6161
//! [`mem::drop`]: crate::mem::drop
6262
//! [`std::borrow`]: crate::borrow

‎src/librustdoc/formats/renderer.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ crate trait FormatRenderer<'tcx>: Clone {
3838
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
3939

4040
/// Post processing hook for cleanup and dumping output to files.
41-
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error>;
42-
43-
/// Called after everything else to write out errors.
44-
fn after_run(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error>;
41+
///
42+
/// A handler is available if the renderer wants to report errors.
43+
fn after_krate(
44+
&mut self,
45+
krate: &clean::Crate,
46+
cache: &Cache,
47+
diag: &rustc_errors::Handler,
48+
) -> Result<(), Error>;
4549
}
4650

4751
/// Main method for rendering a crate.
@@ -104,6 +108,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
104108
}
105109
}
106110

107-
format_renderer.after_krate(&krate, &cache)?;
108-
format_renderer.after_run(diag)
111+
format_renderer.after_krate(&krate, &cache, diag)
109112
}

‎src/librustdoc/html/render/mod.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -523,17 +523,12 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
523523
Ok((cx, krate))
524524
}
525525

526-
fn after_run(&mut self, diag: &rustc_errors::Handler) -> Result<(), Error> {
527-
Arc::get_mut(&mut self.shared).unwrap().fs.close();
528-
let nb_errors = self.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
529-
if nb_errors > 0 {
530-
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
531-
} else {
532-
Ok(())
533-
}
534-
}
535-
536-
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
526+
fn after_krate(
527+
&mut self,
528+
krate: &clean::Crate,
529+
cache: &Cache,
530+
diag: &rustc_errors::Handler,
531+
) -> Result<(), Error> {
537532
let final_file = self.dst.join(&*krate.name.as_str()).join("all.html");
538533
let settings_file = self.dst.join("settings.html");
539534
let crate_name = krate.name;
@@ -596,7 +591,15 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
596591
&style_files,
597592
);
598593
self.shared.fs.write(&settings_file, v.as_bytes())?;
599-
Ok(())
594+
595+
// Flush pending errors.
596+
Arc::get_mut(&mut self.shared).unwrap().fs.close();
597+
let nb_errors = self.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
598+
if nb_errors > 0 {
599+
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
600+
} else {
601+
Ok(())
602+
}
600603
}
601604

602605
fn mod_item_in(

‎src/librustdoc/json/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
199199
Ok(())
200200
}
201201

202-
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
202+
fn after_krate(
203+
&mut self,
204+
krate: &clean::Crate,
205+
cache: &Cache,
206+
_diag: &rustc_errors::Handler,
207+
) -> Result<(), Error> {
203208
debug!("Done with crate");
204209
let mut index = (*self.index).clone().into_inner();
205210
index.extend(self.get_trait_items(cache));
@@ -245,8 +250,4 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
245250
serde_json::ser::to_writer(&file, &output).unwrap();
246251
Ok(())
247252
}
248-
249-
fn after_run(&mut self, _diag: &rustc_errors::Handler) -> Result<(), Error> {
250-
Ok(())
251-
}
252253
}

‎src/test/ui/editions/edition-imports-virtual-2015-gated.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `E`
22
--> $DIR/edition-imports-virtual-2015-gated.rs:8:5
33
|
44
LL | gen_gated!();
5-
| ^^^^^^^^^^^^^ could not find `E` in `{{root}}`
5+
| ^^^^^^^^^^^^^ could not find `E` in crate root
66
|
77
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
88

‎src/test/ui/mir/issue-80742.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// check-fail
2+
3+
// This test used to cause an ICE in rustc_mir::interpret::step::eval_rvalue_into_place
4+
5+
#![allow(incomplete_features)]
6+
#![feature(const_evaluatable_checked)]
7+
#![feature(const_generics)]
8+
9+
use std::fmt::Debug;
10+
use std::marker::PhantomData;
11+
use std::mem::size_of;
12+
13+
struct Inline<T>
14+
where
15+
[u8; size_of::<T>() + 1]: ,
16+
{
17+
_phantom: PhantomData<T>,
18+
buf: [u8; size_of::<T>() + 1],
19+
}
20+
21+
impl<T> Inline<T>
22+
where
23+
[u8; size_of::<T>() + 1]: ,
24+
{
25+
pub fn new(val: T) -> Inline<T> {
26+
todo!()
27+
}
28+
}
29+
30+
fn main() {
31+
let dst = Inline::<dyn Debug>::new(0); //~ ERROR
32+
//~^ ERROR
33+
}

‎src/test/ui/mir/issue-80742.stderr

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error[E0599]: no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope
2+
--> $DIR/issue-80742.rs:31:36
3+
|
4+
LL | / struct Inline<T>
5+
LL | | where
6+
LL | | [u8; size_of::<T>() + 1]: ,
7+
LL | | {
8+
LL | | _phantom: PhantomData<T>,
9+
LL | | buf: [u8; size_of::<T>() + 1],
10+
LL | | }
11+
| |_- function or associated item `new` not found for this
12+
...
13+
LL | let dst = Inline::<dyn Debug>::new(0);
14+
| ^^^ function or associated item not found in `Inline<dyn Debug>`
15+
|
16+
::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
17+
|
18+
LL | pub trait Debug {
19+
| --------------- doesn't satisfy `dyn Debug: Sized`
20+
|
21+
= note: the method `new` exists but the following trait bounds were not satisfied:
22+
`dyn Debug: Sized`
23+
24+
error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
25+
--> $DIR/issue-80742.rs:31:15
26+
|
27+
LL | struct Inline<T>
28+
| - required by this bound in `Inline`
29+
...
30+
LL | let dst = Inline::<dyn Debug>::new(0);
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
32+
|
33+
= help: the trait `Sized` is not implemented for `dyn Debug`
34+
help: consider relaxing the implicit `Sized` restriction
35+
|
36+
LL | struct Inline<T: ?Sized>
37+
| ^^^^^^^^
38+
39+
error: aborting due to 2 previous errors
40+
41+
Some errors have detailed explanations: E0277, E0599.
42+
For more information about an error, try `rustc --explain E0277`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
::foo() //~ cannot find external crate `foo` in the crate root
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find external crate `foo` in the crate root
2+
--> $DIR/crate-called-as-function.rs:2:7
3+
|
4+
LL | ::foo()
5+
| ^^^ not found in the crate root
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let _map = std::hahmap::HashMap::new();
3+
//~^ ERROR failed to resolve: could not find `hahmap` in `std
4+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0433]: failed to resolve: could not find `hahmap` in `std`
2+
--> $DIR/missing-in-namespace.rs:2:29
3+
|
4+
LL | let _map = std::hahmap::HashMap::new();
5+
| ^^^^^^^ not found in `std::hahmap`
6+
|
7+
help: consider importing this struct
8+
|
9+
LL | use std::collections::HashMap;
10+
|
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0433`.

‎src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
fn main() {
44
let s = ::xcrate::S;
5-
//~^ ERROR failed to resolve: could not find `xcrate` in `{{root}}`
5+
//~^ ERROR failed to resolve: could not find `xcrate` in crate root
66
}

‎src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0433]: failed to resolve: could not find `xcrate` in `{{root}}`
1+
error[E0433]: failed to resolve: could not find `xcrate` in crate root
22
--> $DIR/non-existent-2.rs:4:15
33
|
44
LL | let s = ::xcrate::S;
5-
| ^^^^^^ could not find `xcrate` in `{{root}}`
5+
| ^^^^^^ could not find `xcrate` in crate root
66

77
error: aborting due to previous error
88

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pub fn iso<A, B, F1, F2>(a: F1, b: F2) -> (Box<dyn Fn(A) -> B>, Box<dyn Fn(B) -> A>)
2+
where
3+
F1: (Fn(A) -> B) + 'static,
4+
F2: (Fn(B) -> A) + 'static,
5+
{
6+
(Box::new(a), Box::new(b))
7+
}
8+
pub fn iso_un_option<A, B>() -> (Box<dyn Fn(A) -> B>, Box<dyn Fn(B) -> A>) {
9+
let left = |o_a: Option<_>| o_a.unwrap();
10+
let right = |o_b: Option<_>| o_b.unwrap();
11+
iso(left, right)
12+
//~^ ERROR overflow
13+
}
14+
15+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0275]: overflow evaluating the requirement `Option<_>: Sized`
2+
--> $DIR/mutual-recursion-issue-75860.rs:11:5
3+
|
4+
LL | iso(left, right)
5+
| ^^^
6+
|
7+
::: $SRC_DIR/core/src/option.rs:LL:COL
8+
|
9+
LL | pub enum Option<T> {
10+
| - required by this bound in `Option`
11+
|
12+
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`mutual_recursion_issue_75860`)
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0275`.

0 commit comments

Comments
 (0)
This repository has been archived.