Skip to content

Commit 0e949ea

Browse files
committed
rust-timer simulated merge of cd0c54a
Original message: Rollup merge of rust-lang#81178 - tmiasko:no-landing-pads, r=oli-obk Visit only terminators when removing landing pads No functional changes intended
1 parent 01e137c commit 0e949ea

18 files changed

+133
-51
lines changed

compiler/rustc_mir/src/shim.rs

+1-1
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/mod.rs

+2-2
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

+6-21
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

+7
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

+10-4
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

+5-4
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

+22
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/std/src/io/prelude.rs

+1-1
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

+14-14
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/test/ui/editions/edition-imports-virtual-2015-gated.stderr

+1-1
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

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+
}
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`.
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+
}
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

+1-1
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

+2-2
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

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() {}
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)