Skip to content

Commit 9081929

Browse files
committed
Auto merge of #66879 - RalfJung:rollup-nprxpzi, r=RalfJung
Rollup of 11 pull requests Successful merges: - #66379 (Rephrase docs in for ptr) - #66589 (Draw vertical lines correctly in compiler error messages) - #66613 (Allow customising ty::TraitRef's printing behavior) - #66766 (Panic machinery comments and tweaks) - #66791 (Handle GlobalCtxt directly from librustc_interface query system) - #66793 (Record temporary static references in generator witnesses) - #66808 (Cleanup error code) - #66826 (Clarifies how to tag users for assigning PRs) - #66837 (Clarify `{f32,f64}::EPSILON` docs) - #66844 (Miri: do not consider memory allocated by caller_location leaked) - #66872 (Minor documentation fix) Failed merges: r? @ghost
2 parents 25d8a94 + 0b1b36c commit 9081929

File tree

50 files changed

+622
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+622
-379
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ All pull requests are reviewed by another person. We have a bot,
150150
request.
151151

152152
If you want to request that a specific person reviews your pull request,
153-
you can add an `r?` to the message. For example, [Steve][steveklabnik] usually reviews
153+
you can add an `r?` to the pull request description. For example, [Steve][steveklabnik] usually reviews
154154
documentation changes. So if you were to make a documentation change, add
155155

156156
r? @steveklabnik
157157

158-
to the end of the message, and @rust-highfive will assign [@steveklabnik][steveklabnik] instead
159-
of a random person. This is entirely optional.
158+
to the end of the pull request description, and [@rust-highfive][rust-highfive] will assign
159+
[@steveklabnik][steveklabnik] instead of a random person. This is entirely optional.
160160

161161
After someone has reviewed your pull request, they will leave an annotation
162162
on the pull request with an `r+`. It will look something like this:

src/libcore/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use crate::intrinsics;
6868
// Any trait
6969
///////////////////////////////////////////////////////////////////////////////
7070

71-
/// A type to emulate dynamic typing.
71+
/// A trait to emulate dynamic typing.
7272
///
7373
/// Most types implement `Any`. However, any type which contains a non-`'static` reference does not.
7474
/// See the [module-level documentation][mod] for more details.

src/libcore/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub const DIGITS: u32 = 6;
2626

2727
/// [Machine epsilon] value for `f32`.
2828
///
29-
/// This is the difference between `1.0` and the next largest representable number.
29+
/// This is the difference between `1.0` and the next larger representable number.
3030
///
3131
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
3232
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub const DIGITS: u32 = 15;
2626

2727
/// [Machine epsilon] value for `f64`.
2828
///
29-
/// This is the difference between `1.0` and the next largest representable number.
29+
/// This is the difference between `1.0` and the next larger representable number.
3030
///
3131
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
3232
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/panic.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ impl fmt::Display for Location<'_> {
266266
#[unstable(feature = "std_internals", issue = "0")]
267267
#[doc(hidden)]
268268
pub unsafe trait BoxMeUp {
269-
fn box_me_up(&mut self) -> *mut (dyn Any + Send);
269+
/// Take full ownership of the contents.
270+
/// The return type is actually `Box<dyn Any + Send>`, but we cannot use `Box` in libcore.
271+
///
272+
/// After this method got called, only some dummy default value is left in `self`.
273+
/// Calling this method twice, or calling `get` after calling this method, is an error.
274+
///
275+
/// The argument is borrowed because the panic runtime (`__rust_start_panic`) only
276+
/// gets a borrowed `dyn BoxMeUp`.
277+
fn take_box(&mut self) -> *mut (dyn Any + Send);
278+
279+
/// Just borrow the contents.
270280
fn get(&mut self) -> &(dyn Any + Send);
271281
}

src/libcore/panicking.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
//! ```
1212
//!
1313
//! This definition allows for panicking with any general message, but it does not
14-
//! allow for failing with a `Box<Any>` value. The reason for this is that libcore
15-
//! is not allowed to allocate.
14+
//! allow for failing with a `Box<Any>` value. (`PanicInfo` just contains a `&(dyn Any + Send)`,
15+
//! for which we fill in a dummy value in `PanicInfo::internal_constructor`.)
16+
//! The reason for this is that libcore is not allowed to allocate.
1617
//!
1718
//! This module contains a few other panicking functions, but these are just the
1819
//! necessary lang items for the compiler. All panics are funneled through this
19-
//! one function. Currently, the actual symbol is declared in the standard
20-
//! library, but the location of this may change over time.
20+
//! one function. The actual symbol is declared through the `#[panic_handler]` attribute.
2121
2222
// ignore-tidy-undocumented-unsafe
2323

@@ -72,6 +72,7 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, location: &Location<'_>) -> ! {
7272
}
7373

7474
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
75+
// that gets resolved to the `#[panic_handler]` function.
7576
extern "Rust" {
7677
#[lang = "panic_impl"]
7778
fn panic_impl(pi: &PanicInfo<'_>) -> !;

src/libcore/ptr/mod.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,17 +1074,22 @@ impl<T: ?Sized> *const T {
10741074
/// operation because the returned value could be pointing to invalid
10751075
/// memory.
10761076
///
1077-
/// When calling this method, you have to ensure that if the pointer is
1078-
/// non-NULL, then it is properly aligned, dereferencable (for the whole
1079-
/// size of `T`) and points to an initialized instance of `T`. This applies
1080-
/// even if the result of this method is unused!
1077+
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
1078+
/// all of the following is true:
1079+
/// - it is properly aligned
1080+
/// - it must point to an initialized instance of T; in particular, the pointer must be
1081+
/// "dereferencable" in the sense defined [here].
1082+
///
1083+
/// This applies even if the result of this method is unused!
10811084
/// (The part about being initialized is not yet fully decided, but until
10821085
/// it is, the only safe approach is to ensure that they are indeed initialized.)
10831086
///
10841087
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
1085-
/// not necessarily reflect the actual lifetime of the data. It is up to the
1086-
/// caller to ensure that for the duration of this lifetime, the memory this
1087-
/// pointer points to does not get written to outside of `UnsafeCell<U>`.
1088+
/// not necessarily reflect the actual lifetime of the data. *You* must enforce
1089+
/// Rust's aliasing rules. In particular, for the duration of this lifetime,
1090+
/// the memory the pointer points to must not get mutated (except inside `UnsafeCell`).
1091+
///
1092+
/// [here]: crate::ptr#safety
10881093
///
10891094
/// # Examples
10901095
///
@@ -1929,18 +1934,23 @@ impl<T: ?Sized> *mut T {
19291934
/// of the returned pointer, nor can it ensure that the lifetime `'a`
19301935
/// returned is indeed a valid lifetime for the contained data.
19311936
///
1932-
/// When calling this method, you have to ensure that if the pointer is
1933-
/// non-NULL, then it is properly aligned, dereferencable (for the whole
1934-
/// size of `T`) and points to an initialized instance of `T`. This applies
1935-
/// even if the result of this method is unused!
1937+
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
1938+
/// all of the following is true:
1939+
/// - it is properly aligned
1940+
/// - it must point to an initialized instance of T; in particular, the pointer must be
1941+
/// "dereferencable" in the sense defined [here].
1942+
///
1943+
/// This applies even if the result of this method is unused!
19361944
/// (The part about being initialized is not yet fully decided, but until
19371945
/// it is the only safe approach is to ensure that they are indeed initialized.)
19381946
///
19391947
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
1940-
/// not necessarily reflect the actual lifetime of the data. It is up to the
1941-
/// caller to ensure that for the duration of this lifetime, the memory this
1942-
/// pointer points to does not get accessed through any other pointer.
1948+
/// not necessarily reflect the actual lifetime of the data. *You* must enforce
1949+
/// Rust's aliasing rules. In particular, for the duration of this lifetime,
1950+
/// the memory this pointer points to must not get accessed (read or written)
1951+
/// through any other pointer.
19431952
///
1953+
/// [here]: crate::ptr#safety
19441954
/// [`as_ref`]: #method.as_ref
19451955
///
19461956
/// # Examples

src/libpanic_unwind/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ pub unsafe extern "C" fn __rust_maybe_catch_panic(f: fn(*mut u8),
9494
#[unwind(allowed)]
9595
pub unsafe extern "C" fn __rust_start_panic(payload: usize) -> u32 {
9696
let payload = payload as *mut &mut dyn BoxMeUp;
97-
imp::panic(Box::from_raw((*payload).box_me_up()))
97+
imp::panic(Box::from_raw((*payload).take_box()))
9898
}

src/librustc/arena.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ macro_rules! arena_types {
9393
rustc::hir::def_id::CrateNum
9494
>
9595
>,
96+
[few] hir_forest: rustc::hir::map::Forest,
9697
[few] diagnostic_items: rustc_data_structures::fx::FxHashMap<
9798
syntax::symbol::Symbol,
9899
rustc::hir::def_id::DefId,

src/librustc/hir/map/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub struct Map<'hir> {
200200

201201
map: HirEntryMap<'hir>,
202202

203-
definitions: &'hir Definitions,
203+
definitions: Definitions,
204204

205205
/// The reverse mapping of `node_to_hir_id`.
206206
hir_to_node_id: FxHashMap<HirId, NodeId>,
@@ -267,8 +267,8 @@ impl<'hir> Map<'hir> {
267267
}
268268

269269
#[inline]
270-
pub fn definitions(&self) -> &'hir Definitions {
271-
self.definitions
270+
pub fn definitions(&self) -> &Definitions {
271+
&self.definitions
272272
}
273273

274274
pub fn def_key(&self, def_id: DefId) -> DefKey {
@@ -1251,7 +1251,7 @@ impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } }
12511251
pub fn map_crate<'hir>(sess: &crate::session::Session,
12521252
cstore: &CrateStoreDyn,
12531253
forest: &'hir Forest,
1254-
definitions: &'hir Definitions)
1254+
definitions: Definitions)
12551255
-> Map<'hir> {
12561256
let _prof_timer = sess.prof.generic_activity("build_hir_map");
12571257

@@ -1260,7 +1260,7 @@ pub fn map_crate<'hir>(sess: &crate::session::Session,
12601260
.map(|(node_id, &hir_id)| (hir_id, node_id)).collect();
12611261

12621262
let (map, crate_hash) = {
1263-
let hcx = crate::ich::StableHashingContext::new(sess, &forest.krate, definitions, cstore);
1263+
let hcx = crate::ich::StableHashingContext::new(sess, &forest.krate, &definitions, cstore);
12641264

12651265
let mut collector = NodeCollector::root(sess,
12661266
&forest.krate,

0 commit comments

Comments
 (0)