Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #66875

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
266ede1
Isolate compiler queries inside the Queries type.
cjgillot Nov 24, 2019
5098ba6
Move linking ouside the interface queries.
cjgillot Nov 24, 2019
27513a2
Tidy.
cjgillot Nov 24, 2019
becfe5c
Fix test.
cjgillot Nov 24, 2019
cd5d0c7
Rename continue_panic_fmt to panic_handler, and make it the #[panic_h…
RalfJung Nov 25, 2019
08f779c
better comment and rename BoxMeUp::box_me_up to take_box
RalfJung Nov 25, 2019
18bb912
Remove wrong comment.
cjgillot Nov 25, 2019
ea1b803
Pass Queries by reference.
cjgillot Nov 25, 2019
7d01b6c
Simplify early exits.
cjgillot Nov 25, 2019
8ffc944
Don't move stuff out of Compiler::enter.
cjgillot Nov 25, 2019
9d5f721
Superfluous lifetime.
cjgillot Nov 25, 2019
3c48579
more panicking comments
RalfJung Nov 25, 2019
3a8e1b6
panic_handler -> begin_panic_handler (and more comments)
RalfJung Nov 26, 2019
3e96ca2
abort on BoxMeUp misuse
RalfJung Nov 26, 2019
61486f4
expand comment
RalfJung Nov 26, 2019
4a19ef9
explain why __rust_start_panic does not take a Box
RalfJung Nov 26, 2019
babe9fc
rename update_count_then_panic -> rust_panic_without_hook
RalfJung Nov 26, 2019
68b1ac9
Reduce righward drift.
cjgillot Nov 26, 2019
144d1c2
Review nits.
cjgillot Nov 26, 2019
58a9c73
Make the HIR map own the Definitions.
cjgillot Nov 26, 2019
b99513b
Have Queries own the GlobalCtxt.
cjgillot Nov 26, 2019
7b71e9a
Formatting.
cjgillot Nov 26, 2019
7e72b36
Move local Arena to Queries.
cjgillot Nov 26, 2019
1f850f6
Record temporary static references in generator witnesses
matthewjasper Nov 26, 2019
79e2324
Rename lifetimes.
cjgillot Nov 27, 2019
e5ed101
Rename BoxedGlobalCtxt.
cjgillot Nov 27, 2019
77a4c85
Simplify handling of AllArenas.
cjgillot Nov 27, 2019
e321ba9
Misc renames.
cjgillot Nov 27, 2019
1e12f39
Allocate HIR Forest on arena.
cjgillot Nov 27, 2019
38f9cd4
Clean up E0080 long explanation
GuillaumeGomez Nov 27, 2019
ce69610
Clean up E0081 long explanation
GuillaumeGomez Nov 27, 2019
7edaeba
Clean up E0091 long explanation
GuillaumeGomez Nov 27, 2019
d411dd2
Elaborate on std::ptr::{as_ref,as_mod} and clarify docs
CreepySkeleton Nov 13, 2019
f11dd32
Use intra-doc links
CreepySkeleton Nov 27, 2019
df625bd
Add async fn test for #66695
matthewjasper Nov 27, 2019
9b78191
Clarifies how to tag users for assigning PRs
Nov 27, 2019
2a7dc5e
Update CONTRIBUTING.md
Dylan-DPC Nov 28, 2019
77f2ac4
Update CONTRIBUTING.md
Dylan-DPC Nov 28, 2019
85a468b
Clarify `{f32,f64}::EPSILON` docs
ohadravid Nov 28, 2019
fd40d0c
rustc: move MIR source_scope_local_data's ClearCrossCrate to be aroun…
eddyb Nov 26, 2019
314f8d5
rustc_mir: fix inliner to also copy over source_scope_local_data.
eddyb Nov 26, 2019
3aead85
rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.
eddyb Nov 26, 2019
3048d7e
do not consider memory allocated by caller_location leaked
RalfJung Nov 28, 2019
f07bd06
allow customising ty::TraitRef's printing behavior
basil-cow Nov 21, 2019
26e5fd4
Minor documentation fix
Mikotochan Nov 29, 2019
54a3aa8
Rollup merge of #66379 - CreepySkeleton:patch-1, r=RalfJung
RalfJung Nov 29, 2019
9933b80
Rollup merge of #66613 - Areredify:trait-ref-print, r=eddyb
RalfJung Nov 29, 2019
535a09a
Rollup merge of #66766 - RalfJung:panic-comments, r=SimonSapin
RalfJung Nov 29, 2019
b3d835f
Rollup merge of #66789 - eddyb:mir-source-scope-local-data, r=oli-obk
RalfJung Nov 29, 2019
9a32226
Rollup merge of #66791 - cjgillot:arena, r=Mark-Simulacrum
RalfJung Nov 29, 2019
d54acc1
Rollup merge of #66793 - matthewjasper:record-static-refs, r=cramertj
RalfJung Nov 29, 2019
45eacba
Rollup merge of #66808 - GuillaumeGomez:cleanup-err-code-3, r=Dylan-DPC
RalfJung Nov 29, 2019
182a2ee
Rollup merge of #66826 - mlodato517:mlodato517-clarify-pr-message-ass…
RalfJung Nov 29, 2019
5ca191c
Rollup merge of #66837 - ohadravid:epsilon-doc, r=dtolnay
RalfJung Nov 29, 2019
d2aed25
Rollup merge of #66844 - RalfJung:caller-location-leak, r=oli-obk
RalfJung Nov 29, 2019
7d0b1ab
Rollup merge of #66872 - Mikotochan:patch-1, r=jonas-schievink
RalfJung Nov 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ All pull requests are reviewed by another person. We have a bot,
request.

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

r? @steveklabnik

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

After someone has reviewed your pull request, they will leave an annotation
on the pull request with an `r+`. It will look something like this:
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use crate::intrinsics;
// Any trait
///////////////////////////////////////////////////////////////////////////////

/// A type to emulate dynamic typing.
/// A trait to emulate dynamic typing.
///
/// Most types implement `Any`. However, any type which contains a non-`'static` reference does not.
/// See the [module-level documentation][mod] for more details.
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub const DIGITS: u32 = 6;

/// [Machine epsilon] value for `f32`.
///
/// This is the difference between `1.0` and the next largest representable number.
/// This is the difference between `1.0` and the next larger representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub const DIGITS: u32 = 15;

/// [Machine epsilon] value for `f64`.
///
/// This is the difference between `1.0` and the next largest representable number.
/// This is the difference between `1.0` and the next larger representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
12 changes: 11 additions & 1 deletion src/libcore/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ impl fmt::Display for Location<'_> {
#[unstable(feature = "std_internals", issue = "0")]
#[doc(hidden)]
pub unsafe trait BoxMeUp {
fn box_me_up(&mut self) -> *mut (dyn Any + Send);
/// Take full ownership of the contents.
/// The return type is actually `Box<dyn Any + Send>`, but we cannot use `Box` in libcore.
///
/// After this method got called, only some dummy default value is left in `self`.
/// Calling this method twice, or calling `get` after calling this method, is an error.
///
/// The argument is borrowed because the panic runtime (`__rust_start_panic`) only
/// gets a borrowed `dyn BoxMeUp`.
fn take_box(&mut self) -> *mut (dyn Any + Send);

/// Just borrow the contents.
fn get(&mut self) -> &(dyn Any + Send);
}
9 changes: 5 additions & 4 deletions src/libcore/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
//! ```
//!
//! This definition allows for panicking with any general message, but it does not
//! allow for failing with a `Box<Any>` value. The reason for this is that libcore
//! is not allowed to allocate.
//! allow for failing with a `Box<Any>` value. (`PanicInfo` just contains a `&(dyn Any + Send)`,
//! for which we fill in a dummy value in `PanicInfo::internal_constructor`.)
//! The reason for this is that libcore is not allowed to allocate.
//!
//! This module contains a few other panicking functions, but these are just the
//! necessary lang items for the compiler. All panics are funneled through this
//! one function. Currently, the actual symbol is declared in the standard
//! library, but the location of this may change over time.
//! one function. The actual symbol is declared through the `#[panic_handler]` attribute.

// ignore-tidy-undocumented-unsafe

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

// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
// that gets resolved to the `#[panic_handler]` function.
extern "Rust" {
#[lang = "panic_impl"]
fn panic_impl(pi: &PanicInfo<'_>) -> !;
Expand Down
38 changes: 24 additions & 14 deletions src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,17 +1074,22 @@ impl<T: ?Sized> *const T {
/// operation because the returned value could be pointing to invalid
/// memory.
///
/// When calling this method, you have to ensure that if the pointer is
/// non-NULL, then it is properly aligned, dereferencable (for the whole
/// size of `T`) and points to an initialized instance of `T`. This applies
/// even if the result of this method is unused!
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
/// all of the following is true:
/// - it is properly aligned
/// - it must point to an initialized instance of T; in particular, the pointer must be
/// "dereferencable" in the sense defined [here].
///
/// This applies even if the result of this method is unused!
/// (The part about being initialized is not yet fully decided, but until
/// it is, the only safe approach is to ensure that they are indeed initialized.)
///
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
/// not necessarily reflect the actual lifetime of the data. It is up to the
/// caller to ensure that for the duration of this lifetime, the memory this
/// pointer points to does not get written to outside of `UnsafeCell<U>`.
/// not necessarily reflect the actual lifetime of the data. *You* must enforce
/// Rust's aliasing rules. In particular, for the duration of this lifetime,
/// the memory the pointer points to must not get mutated (except inside `UnsafeCell`).
///
/// [here]: crate::ptr#safety
///
/// # Examples
///
Expand Down Expand Up @@ -1929,18 +1934,23 @@ impl<T: ?Sized> *mut T {
/// of the returned pointer, nor can it ensure that the lifetime `'a`
/// returned is indeed a valid lifetime for the contained data.
///
/// When calling this method, you have to ensure that if the pointer is
/// non-NULL, then it is properly aligned, dereferencable (for the whole
/// size of `T`) and points to an initialized instance of `T`. This applies
/// even if the result of this method is unused!
/// When calling this method, you have to ensure that *either* the pointer is NULL *or*
/// all of the following is true:
/// - it is properly aligned
/// - it must point to an initialized instance of T; in particular, the pointer must be
/// "dereferencable" in the sense defined [here].
///
/// This applies even if the result of this method is unused!
/// (The part about being initialized is not yet fully decided, but until
/// it is the only safe approach is to ensure that they are indeed initialized.)
///
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
/// not necessarily reflect the actual lifetime of the data. It is up to the
/// caller to ensure that for the duration of this lifetime, the memory this
/// pointer points to does not get accessed through any other pointer.
/// not necessarily reflect the actual lifetime of the data. *You* must enforce
/// Rust's aliasing rules. In particular, for the duration of this lifetime,
/// the memory this pointer points to must not get accessed (read or written)
/// through any other pointer.
///
/// [here]: crate::ptr#safety
/// [`as_ref`]: #method.as_ref
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion src/libpanic_unwind/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ pub unsafe extern "C" fn __rust_maybe_catch_panic(f: fn(*mut u8),
#[unwind(allowed)]
pub unsafe extern "C" fn __rust_start_panic(payload: usize) -> u32 {
let payload = payload as *mut &mut dyn BoxMeUp;
imp::panic(Box::from_raw((*payload).box_me_up()))
imp::panic(Box::from_raw((*payload).take_box()))
}
1 change: 1 addition & 0 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ macro_rules! arena_types {
rustc::hir::def_id::CrateNum
>
>,
[few] hir_forest: rustc::hir::map::Forest,
[few] diagnostic_items: rustc_data_structures::fx::FxHashMap<
syntax::symbol::Symbol,
rustc::hir::def_id::DefId,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub struct Map<'hir> {

map: HirEntryMap<'hir>,

definitions: &'hir Definitions,
definitions: Definitions,

/// The reverse mapping of `node_to_hir_id`.
hir_to_node_id: FxHashMap<HirId, NodeId>,
Expand Down Expand Up @@ -267,8 +267,8 @@ impl<'hir> Map<'hir> {
}

#[inline]
pub fn definitions(&self) -> &'hir Definitions {
self.definitions
pub fn definitions(&self) -> &Definitions {
&self.definitions
}

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

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

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

let mut collector = NodeCollector::root(sess,
&forest.krate,
Expand Down
16 changes: 14 additions & 2 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
infer::Types(ref exp_found) => self.expected_found_str_ty(exp_found),
infer::Regions(ref exp_found) => self.expected_found_str(exp_found),
infer::Consts(ref exp_found) => self.expected_found_str(exp_found),
infer::TraitRefs(ref exp_found) => self.expected_found_str(exp_found),
infer::PolyTraitRefs(ref exp_found) => self.expected_found_str(exp_found),
infer::TraitRefs(ref exp_found) => {
let pretty_exp_found = ty::error::ExpectedFound {
expected: exp_found.expected.print_only_trait_path(),
found: exp_found.found.print_only_trait_path()
};
self.expected_found_str(&pretty_exp_found)
},
infer::PolyTraitRefs(ref exp_found) => {
let pretty_exp_found = ty::error::ExpectedFound {
expected: exp_found.expected.print_only_trait_path(),
found: exp_found.found.print_only_trait_path()
};
self.expected_found_str(&pretty_exp_found)
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,15 @@ impl NiceRegionError<'me, 'tcx> {
format!(
"{}`{}` would have to be implemented for the type `{}`",
if leading_ellipsis { "..." } else { "" },
expected_trait_ref,
expected_trait_ref.map(|tr| tr.print_only_trait_path()),
expected_trait_ref.map(|tr| tr.self_ty()),
)
} else {
format!(
"{}`{}` must implement `{}`",
if leading_ellipsis { "..." } else { "" },
expected_trait_ref.map(|tr| tr.self_ty()),
expected_trait_ref,
expected_trait_ref.map(|tr| tr.print_only_trait_path()),
)
};

Expand Down Expand Up @@ -449,14 +449,14 @@ impl NiceRegionError<'me, 'tcx> {
let mut note = if passive_voice {
format!(
"...but `{}` is actually implemented for the type `{}`",
actual_trait_ref,
actual_trait_ref.map(|tr| tr.print_only_trait_path()),
actual_trait_ref.map(|tr| tr.self_ty()),
)
} else {
format!(
"...but `{}` actually implements `{}`",
actual_trait_ref.map(|tr| tr.self_ty()),
actual_trait_ref,
actual_trait_ref.map(|tr| tr.print_only_trait_path()),
)
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}

pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String {
self.resolve_vars_if_possible(t).to_string()
self.resolve_vars_if_possible(t).print_only_trait_path().to_string()
}

/// If `TyVar(vid)` resolves to a type, return that type. Else, return the
Expand Down
9 changes: 7 additions & 2 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,13 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
// This shouldn't ever be needed, but just in case:
path.push(match trait_ref {
Some(trait_ref) => {
Symbol::intern(&format!("<impl {} for {}>", trait_ref,
self_ty))
Symbol::intern(
&format!(
"<impl {} for {}>",
trait_ref.print_only_trait_path(),
self_ty
)
)
},
None => Symbol::intern(&format!("<impl {}>", self_ty)),
});
Expand Down
17 changes: 11 additions & 6 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ pub struct Body<'tcx> {
/// and used for debuginfo. Indexed by a `SourceScope`.
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,

/// Crate-local information for each source scope, that can't (and
/// needn't) be tracked across crates.
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,

/// The yield type of the function, if it is a generator.
pub yield_ty: Option<Ty<'tcx>>,

Expand Down Expand Up @@ -163,7 +159,6 @@ impl<'tcx> Body<'tcx> {
pub fn new(
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
source_scopes: IndexVec<SourceScope, SourceScopeData>,
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
local_decls: LocalDecls<'tcx>,
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
arg_count: usize,
Expand All @@ -183,7 +178,6 @@ impl<'tcx> Body<'tcx> {
phase: MirPhase::Build,
basic_blocks,
source_scopes,
source_scope_local_data,
yield_ty: None,
generator_drop: None,
generator_layout: None,
Expand Down Expand Up @@ -429,6 +423,13 @@ pub enum ClearCrossCrate<T> {
}

impl<T> ClearCrossCrate<T> {
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> {
match self {
ClearCrossCrate::Clear => ClearCrossCrate::Clear,
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
}
}

pub fn assert_crate_local(self) -> T {
match self {
ClearCrossCrate::Clear => bug!("unwrapping cross-crate data"),
Expand Down Expand Up @@ -2021,6 +2022,10 @@ rustc_index::newtype_index! {
pub struct SourceScopeData {
pub span: Span,
pub parent_scope: Option<SourceScope>,

/// Crate-local information for this source scope, that can't (and
/// needn't) be tracked across crates.
pub local_data: ClearCrossCrate<SourceScopeLocalData>,
}

#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ macro_rules! make_mir_visitor {
let SourceScopeData {
span,
parent_scope,
local_data: _,
} = scope_data;

self.visit_span(span);
Expand Down
Loading