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 10 pull requests #54051

Merged
merged 32 commits into from
Sep 8, 2018
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
faf80ad
remove base_place
matthewjasper Sep 3, 2018
fb307e5
Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.
nnethercote Sep 4, 2018
28745a6
Implement initializer() for FileDesc
fbernier Sep 6, 2018
c34dd37
rustc_resolve: don't record uniform_paths canaries as reexports.
eddyb Sep 6, 2018
9b764c3
crates that provide a `panic_handler` are exempt from `unused_extern_…
japaric Sep 6, 2018
6c4f3f5
update UI test
japaric Sep 6, 2018
8aae6ca
Have rust-lldb look for the rust-enabled lldb
tromey Sep 5, 2018
ef44068
rustbuild: allow configuring llvm version suffix
Keruspe Sep 6, 2018
1242639
change syntax of `newtype_index` to look like a struct decl
nikomatsakis Jul 25, 2018
c46f185
add a comment
nikomatsakis Jul 25, 2018
5aee959
make field always private, add `From` impls
nikomatsakis Jul 25, 2018
6ccf9b8
change from tuple struct to brace struct
nikomatsakis Aug 28, 2018
24ab375
remove all references to `private` from outside the macro
nikomatsakis Aug 28, 2018
c67d518
add various `#[inline]` directives
nikomatsakis Aug 30, 2018
f702bd6
rewrite constants to use NewType::MAX instead of u32::MAX
nikomatsakis Aug 23, 2018
3b6361d
switch to using `NonZeroU32` to represent indices
nikomatsakis Aug 30, 2018
3805ebe
remove use of `from_u32_unchecked`
nikomatsakis Aug 30, 2018
ec0ad09
use a `BTreeSet` for a more stable error message order
nikomatsakis Aug 31, 2018
e5e72f6
switch back to using a plain `u32`, not `NonZeroU32`
nikomatsakis Sep 6, 2018
ab43c1e
add `const_fn` feature
nikomatsakis Sep 6, 2018
de6a611
update books for next release
steveklabnik Sep 6, 2018
b31eaa4
Update `petgraph` dependency to 0.4.13
GabrielMajeri Sep 8, 2018
7569d92
Rollup merge of #53932 - matthewjasper:remove-base-path, r=nikomatsakis
kennytm Sep 8, 2018
dbc9ec9
Rollup merge of #53942 - nnethercote:faster-precompute, r=nikomatsakis
kennytm Sep 8, 2018
5cc51ad
Rollup merge of #53973 - tromey:prefer-rust-enabled-lldb, r=alexcrichton
kennytm Sep 8, 2018
14c21a1
Rollup merge of #53981 - fbernier:patch-1, r=sfackler
kennytm Sep 8, 2018
e2e3608
Rollup merge of #53987 - Keruspe:llvm-suffix, r=alexcrichton
kennytm Sep 8, 2018
407da0a
Rollup merge of #53993 - eddyb:issue-53691, r=petrochenkov
kennytm Sep 8, 2018
1a86a93
Rollup merge of #54007 - japaric:gh53964, r=cramertj
kennytm Sep 8, 2018
0b58d2d
Rollup merge of #54040 - steveklabnik:update-books, r=Mark-Simulacrum
kennytm Sep 8, 2018
b1ef2b8
Rollup merge of #54050 - GabrielMajeri:fix-build-with-nightly, r=alex…
kennytm Sep 8, 2018
51c3879
Rollup merge of #53315 - nikomatsakis:newtype-index, r=Mark-Simulacrum
kennytm Sep 8, 2018
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
Prev Previous commit
Next Next commit
change syntax of newtype_index to look like a struct decl
nikomatsakis committed Sep 7, 2018

Verified

This commit was signed with the committer’s verified signature.
nagy Daniel Nagy
commit 1242639b88b0dee9ebb0f103efe017826c5b334e
4 changes: 3 additions & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,9 @@ pub struct DepGraph {
fingerprints: Lrc<Lock<IndexVec<DepNodeIndex, Fingerprint>>>
}

newtype_index!(DepNodeIndex);
newtype_index! {
pub struct DepNodeIndex { .. }
}

impl DepNodeIndex {
const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX);
4 changes: 3 additions & 1 deletion src/librustc/dep_graph/serialized.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,9 @@ use dep_graph::DepNode;
use ich::Fingerprint;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};

newtype_index!(SerializedDepNodeIndex);
newtype_index! {
pub struct SerializedDepNodeIndex { .. }
}

/// Data for use when recompiling the **current crate**.
#[derive(Debug, RustcEncodable, RustcDecodable)]
7 changes: 4 additions & 3 deletions src/librustc/hir/def_id.rs
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ use serialize;
use std::fmt;
use std::u32;

newtype_index!(CrateNum
{
newtype_index! {
pub struct CrateNum {
ENCODABLE = custom
DEBUG_FORMAT = "crate{}",

@@ -35,7 +35,8 @@ newtype_index!(CrateNum
/// A special CrateNum that we use for the tcx.rcache when decoding from
/// the incr. comp. cache.
const RESERVED_FOR_INCR_COMP_CACHE = u32::MAX - 2,
});
}
}

impl CrateNum {
pub fn new(x: usize) -> CrateNum {
7 changes: 4 additions & 3 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
@@ -159,11 +159,12 @@ pub struct BlockRemainder {
pub first_statement_index: FirstStatementIndex,
}

newtype_index!(FirstStatementIndex
{
newtype_index! {
pub struct FirstStatementIndex {
pub idx
MAX = SCOPE_DATA_REMAINDER_MAX
});
}
}

impl From<ScopeData> for Scope {
#[inline]
32 changes: 23 additions & 9 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
@@ -523,11 +523,12 @@ impl BorrowKind {
///////////////////////////////////////////////////////////////////////////
// Variables and temps

newtype_index!(Local
{
newtype_index! {
pub struct Local {
DEBUG_FORMAT = "_{}",
const RETURN_PLACE = 0,
});
}
}

/// Classifies locals into categories. See `Mir::local_kind`.
#[derive(PartialEq, Eq, Debug)]
@@ -852,7 +853,11 @@ pub struct UpvarDecl {
///////////////////////////////////////////////////////////////////////////
// BasicBlock

newtype_index!(BasicBlock { DEBUG_FORMAT = "bb{}" });
newtype_index! {
pub struct BasicBlock {
DEBUG_FORMAT = "bb{}"
}
}

impl BasicBlock {
pub fn start_location(self) -> Location {
@@ -1822,7 +1827,11 @@ pub type PlaceProjection<'tcx> = Projection<'tcx, Place<'tcx>, Local, Ty<'tcx>>;
/// and the index is a local.
pub type PlaceElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>;

newtype_index!(Field { DEBUG_FORMAT = "field[{}]" });
newtype_index! {
pub struct Field {
DEBUG_FORMAT = "field[{}]"
}
}

impl<'tcx> Place<'tcx> {
pub fn field(self, f: Field, ty: Ty<'tcx>) -> Place<'tcx> {
@@ -1895,11 +1904,12 @@ impl<'tcx> Debug for Place<'tcx> {
///////////////////////////////////////////////////////////////////////////
// Scopes

newtype_index!(SourceScope
{
newtype_index! {
pub struct SourceScope {
DEBUG_FORMAT = "scope[{}]",
const OUTERMOST_SOURCE_SCOPE = 0,
});
}
}

#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct SourceScopeData {
@@ -2271,7 +2281,11 @@ pub struct Constant<'tcx> {
pub literal: &'tcx ty::Const<'tcx>,
}

newtype_index!(Promoted { DEBUG_FORMAT = "promoted[{}]" });
newtype_index! {
pub struct Promoted {
DEBUG_FORMAT = "promoted[{}]"
}
}

impl<'tcx> Debug for Constant<'tcx> {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
18 changes: 11 additions & 7 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
@@ -1034,11 +1034,12 @@ impl<'a, 'gcx, 'tcx> ParamTy {
/// is the outer fn.
///
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
newtype_index!(DebruijnIndex
{
newtype_index! {
pub struct DebruijnIndex {
DEBUG_FORMAT = "DebruijnIndex({})",
const INNERMOST = 0,
});
}
}

pub type Region<'tcx> = &'tcx RegionKind;

@@ -1176,11 +1177,12 @@ pub struct FloatVid {
pub index: u32,
}

newtype_index!(RegionVid
{
newtype_index! {
pub struct RegionVid {
pub idx
DEBUG_FORMAT = custom,
});
}
}

impl Atom for RegionVid {
fn index(self) -> usize {
@@ -1217,7 +1219,9 @@ pub enum InferTy {
CanonicalTy(CanonicalVar),
}

newtype_index!(CanonicalVar);
newtype_index! {
pub struct CanonicalVar { .. }
}

/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
33 changes: 30 additions & 3 deletions src/librustc_data_structures/indexed_vec.rs
Original file line number Diff line number Diff line change
@@ -53,20 +53,22 @@ macro_rules! newtype_index {
// ---- public rules ----

// Use default constants
($name:ident) => (
($v:vis struct $name:ident { .. }) => (
newtype_index!(
// Leave out derives marker so we can use its absence to ensure it comes first
@type [$name]
@max [::std::u32::MAX]
@vis [$v]
@debug_format ["{}"]);
);

// Define any constants
($name:ident { $($tokens:tt)+ }) => (
($v:vis struct $name:ident { $($tokens:tt)+ }) => (
newtype_index!(
// Leave out derives marker so we can use its absence to ensure it comes first
@type [$name]
@max [::std::u32::MAX]
@vis [$v]
@debug_format ["{}"]
$($tokens)+);
);
@@ -78,9 +80,10 @@ macro_rules! newtype_index {
@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]) => (
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, $($derives),*)]
pub struct $type($($pub)* u32);
$v struct $type($($pub)* u32);

impl Idx for $type {
#[inline]
@@ -170,26 +173,30 @@ macro_rules! newtype_index {
// Handle the case where someone wants to make the internal field public
(@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
pub idx
$($tokens:tt)*) => (
newtype_index!(
@pub [pub]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);

// The default case is that the internal field is private
(@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
$($tokens:tt)*) => (
newtype_index!(
@pub []
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -198,13 +205,15 @@ macro_rules! newtype_index {
(@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
derive [$($derives:ident),*]
$($tokens:tt)*) => (
newtype_index!(
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
derive [$($derives,)*]
$($tokens)*);
@@ -215,6 +224,7 @@ macro_rules! newtype_index {
(@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
derive [$($derives:ident,)+]
ENCODABLE = custom
@@ -224,6 +234,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -233,6 +244,7 @@ macro_rules! newtype_index {
(@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
derive [$($derives:ident,)+]
$($tokens:tt)*) => (
@@ -241,6 +253,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -250,6 +263,7 @@ macro_rules! newtype_index {
(@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
ENCODABLE = custom
$($tokens:tt)*) => (
@@ -258,6 +272,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -266,13 +281,15 @@ macro_rules! newtype_index {
(@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
$($tokens:tt)*) => (
newtype_index!(
@derives [RustcDecodable, RustcEncodable,]
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -282,13 +299,15 @@ macro_rules! newtype_index {
@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
$name:ident = $constant:expr) => (
newtype_index!(
@derives [$($derives,)*]
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$name = $constant,);
);
@@ -298,6 +317,7 @@ macro_rules! newtype_index {
@pub [$($pub:tt)*]
@type [$type:ident]
@max [$_max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
$(#[doc = $doc:expr])*
const $name:ident = $constant:expr) => (
@@ -306,6 +326,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$(#[doc = $doc])* const $name = $constant,);
);
@@ -315,6 +336,7 @@ macro_rules! newtype_index {
@pub [$($pub:tt)*]
@type [$type:ident]
@max [$_max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
MAX = $max:expr,
$($tokens:tt)*) => (
@@ -323,6 +345,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -332,6 +355,7 @@ macro_rules! newtype_index {
@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$_debug_format:tt]
DEBUG_FORMAT = $debug_format:tt,
$($tokens:tt)*) => (
@@ -340,6 +364,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
@@ -349,6 +374,7 @@ macro_rules! newtype_index {
@pub [$($pub:tt)*]
@type [$type:ident]
@max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
$(#[doc = $doc:expr])*
const $name:ident = $constant:expr,
@@ -360,6 +386,7 @@ macro_rules! newtype_index {
@pub [$($pub)*]
@type [$type]
@max [$max]
@vis [$v]
@debug_format [$debug_format]
$($tokens)*);
);
6 changes: 5 additions & 1 deletion src/librustc_mir/borrow_check/location.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,11 @@ crate struct LocationTable {
statements_before_block: IndexVec<BasicBlock, usize>,
}

newtype_index!(LocationIndex { DEBUG_FORMAT = "LocationIndex({})" });
newtype_index! {
pub struct LocationIndex {
DEBUG_FORMAT = "LocationIndex({})"
}
}

#[derive(Copy, Clone, Debug)]
crate enum RichLocation {
12 changes: 10 additions & 2 deletions src/librustc_mir/borrow_check/nll/constraints/mod.rs
Original file line number Diff line number Diff line change
@@ -98,6 +98,14 @@ impl fmt::Debug for OutlivesConstraint {
}
}

newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });
newtype_index! {
pub struct ConstraintIndex {
DEBUG_FORMAT = "ConstraintIndex({})"
}
}

newtype_index!(ConstraintSccIndex { DEBUG_FORMAT = "ConstraintSccIndex({})" });
newtype_index! {
pub struct ConstraintSccIndex {
DEBUG_FORMAT = "ConstraintSccIndex({})"
}
}
8 changes: 6 additions & 2 deletions src/librustc_mir/borrow_check/nll/region_infer/values.rs
Original file line number Diff line number Diff line change
@@ -123,13 +123,17 @@ impl RegionValueElements {

/// A single integer representing a `Location` in the MIR control-flow
/// graph. Constructed efficiently from `RegionValueElements`.
newtype_index!(PointIndex { DEBUG_FORMAT = "PointIndex({})" });
newtype_index! {
pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
}

/// A single integer representing a (non-zero) `UniverseIndex`.
/// Computed just by subtracting one from `UniverseIndex`; this is
/// because the `0` value for `UniverseIndex` represents the root
/// universe, and we don't need/want a bit for that one.
newtype_index!(PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" });
newtype_index! {
pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
}

/// An individual element in a region value -- the value of a
/// particular region variable consists of a set of these elements.
Original file line number Diff line number Diff line change
@@ -97,6 +97,6 @@ impl NllLivenessMap {
/// compute liveness information. For many locals, we are able to
/// skip liveness information: for example, those variables whose
/// types contain no regions.
newtype_index!(
LiveVar
);
newtype_index! {
pub struct LiveVar { .. }
}
Original file line number Diff line number Diff line change
@@ -48,7 +48,9 @@ struct Appearance {
next: Option<AppearanceIndex>,
}

newtype_index!(AppearanceIndex);
newtype_index! {
pub struct AppearanceIndex { .. }
}

impl vll::LinkElem for Appearance {
type LinkIndex = AppearanceIndex;
4 changes: 3 additions & 1 deletion src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
@@ -402,7 +402,9 @@ struct CFG<'tcx> {
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
}

newtype_index!(ScopeId);
newtype_index! {
pub struct ScopeId { .. }
}

///////////////////////////////////////////////////////////////////////////
/// The `BlockAnd` "monad" packages up the new basic block along with a