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 #59433

Merged
merged 43 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7fb1c22
promoted is still left in 2 places
Mar 16, 2019
a837b8a
cleaner code as per review
Mar 17, 2019
23c87a1
fixed all compilation errors
Mar 18, 2019
776407e
tidy checks
Mar 19, 2019
8829dda
remove visit_static from librustc::mir
Mar 20, 2019
72f8d4e
Add no_hash to query macro and move some queries over
Zoxc Mar 20, 2019
b440041
Allow itertools
Zoxc Mar 20, 2019
d060e7d
Add no_force to query macro and move some queries over
Zoxc Mar 20, 2019
52374a6
Add anon to query macro and move a query over
Zoxc Mar 20, 2019
4d0a1e4
Add eval_always to query macro and move a query over
Zoxc Mar 20, 2019
75677c4
Fix whitespace
Zoxc Mar 20, 2019
71dfb01
Update build instructions in README.md
ewk Mar 21, 2019
cf2f1bb
review fixes
Mar 20, 2019
48af718
Expand `impl FromIterator for Option` doc to include example of early…
pnkfelix Mar 20, 2019
d5a61c0
Expand `impl FromIterator for Result` doc to include examples of `Err…
pnkfelix Mar 20, 2019
37cfeb2
Add/rename checked_duration_since tests
faern Mar 22, 2019
d56b1fd
Make duration_since use checked_duration_since
faern Mar 22, 2019
1ccad16
Update sys::time impls to have checked_sub_instant
faern Mar 22, 2019
8ba1a97
Expand suggestions for type ascription parse errors
estebank Mar 13, 2019
b1a6c32
Tweak labels
estebank Mar 13, 2019
72a3089
Only suggest let assignment for type ascription if we find an equals …
estebank Mar 13, 2019
81b876b
Hide "type ascription is experimental error" unless it's the only one
estebank Mar 13, 2019
44a086e
Review comment
estebank Mar 20, 2019
d72ef21
Reword type ascription note to reduce verbosity
estebank Mar 23, 2019
752544b
adding mir::StaticKind enum for static and promoted
Mar 23, 2019
fb93f10
code review fixes
Mar 24, 2019
8d7c2bb
replace redundant note in deprecation warning
euclio Mar 24, 2019
5390414
Provide suggestion when using field access instead of path
estebank Mar 18, 2019
4beea17
Deduplicate code for path suggestion
estebank Mar 20, 2019
6315221
Update src/libcore/option.rs
killercup Mar 25, 2019
0e83e96
add missing braces
pnkfelix Mar 25, 2019
0bb36a2
Clarify `{Ord,f32,f64}::clamp` docs a little
tbu- Mar 25, 2019
28c602a
Utilize `?` instead of `return None`.
frewsxcv Mar 25, 2019
b316514
Rollup merge of #59150 - estebank:type-ascription, r=varkor
Centril Mar 26, 2019
90c2d64
Rollup merge of #59232 - saleemjaffer:mir_place_refactor, r=oli-obk
Centril Mar 26, 2019
ba55822
Rollup merge of #59267 - estebank:assoc-const-as-field, r=davidtwco
Centril Mar 26, 2019
4fbe25c
Rollup merge of #59315 - Zoxc:move-query, r=oli-obk
Centril Mar 26, 2019
e132e43
Rollup merge of #59334 - ewk:readme, r=Mark-Simulacrum
Centril Mar 26, 2019
0616b73
Rollup merge of #59362 - pnkfelix:demo-from-iterator-short-circuiting…
Centril Mar 26, 2019
e298691
Rollup merge of #59374 - faern:simplify-checked-duration-since, r=she…
Centril Mar 26, 2019
95e7a50
Rollup merge of #59389 - euclio:deprecated-suggestion, r=varkor
Centril Mar 26, 2019
0677eb1
Rollup merge of #59410 - tbu-:pr_doc_clarifyclamp, r=joshtriplett
Centril Mar 26, 2019
822b4fc
Rollup merge of #59419 - frewsxcv:frewsxcv-qu, r=varkor
Centril Mar 26, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,7 @@ dependencies = [
name = "rustc_macros"
version = "0.1.0"
dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ of the rustc-guide instead._
$ ./x.py build && sudo ./x.py install
```

If after running `sudo ./x.py install` you see an error message like

```
error: failed to load source for a dependency on 'cc'
```

then run these two commands and then try `sudo ./x.py install` again:

```
$ cargo install cargo-vendor
```

```
$ cargo vendor
```

> ***Note:*** Install locations can be adjusted by copying the config file
> from `./config.toml.example` to `./config.toml`, and
> adjusting the `prefix` option under `[install]`. Various other options, such
Expand Down
13 changes: 9 additions & 4 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,14 @@ pub trait Ord: Eq + PartialOrd<Self> {
if self <= other { self } else { other }
}

/// Returns max if self is greater than max, and min if self is less than min.
/// Otherwise this will return self. Panics if min > max.
/// Restrict a value to a certain interval.
///
/// Returns `max` if `self` is greater than `max`, and `min` if `self` is
/// less than `min`. Otherwise this returns `self`.
///
/// # Panics
///
/// Panics if `min > max`.
///
/// # Examples
///
Expand All @@ -586,8 +592,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
assert!(min <= max);
if self < min {
min
}
else if self > max {
} else if self > max {
max
} else {
self
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,8 @@ impl<'a> Formatted<'a> {

let mut written = self.sign.len();
for part in self.parts {
match part.write(&mut out[written..]) {
Some(len) => { written += len; }
None => { return None; }
}
let len = part.write(&mut out[written..])?;
written += len;
}
Some(written)
}
Expand Down
20 changes: 20 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,26 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
/// Since the last element is zero, it would underflow. Thus, the resulting
/// value is `None`.
///
/// Here is a variation on the previous example, showing that no
/// further elements are taken from `iter` after the first `None`.
///
/// ```
/// let items = vec![3_u16, 2, 1, 10];
///
/// let mut shared = 0;
///
/// let res: Option<Vec<u16>> = items
/// .iter()
/// .map(|x| { shared += x; x.checked_sub(2) })
/// .collect();
///
/// assert_eq!(res, None);
/// assert_eq!(shared, 6);
/// ```
///
/// Since the third element caused an underflow, no further elements were taken,
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
///
/// [`Iterator`]: ../iter/trait.Iterator.html
#[inline]
fn from_iter<I: IntoIterator<Item=Option<A>>>(iter: I) -> Option<V> {
Expand Down
28 changes: 28 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,34 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
/// ).collect();
/// assert_eq!(res, Ok(vec![2, 3]));
/// ```
///
/// Here is another example that tries to subtract one from another list
/// of integers, this time checking for underflow:
///
/// ```
/// let v = vec![1, 2, 0];
/// let res: Result<Vec<u32>, &'static str> = v.iter().map(|x: &u32|
/// x.checked_sub(1).ok_or("Underflow!")
/// ).collect();
/// assert_eq!(res, Err("Underflow!"));
/// ```
///
/// Here is a variation on the previous example, showing that no
/// further elements are taken from `iter` after the first `Err`.
///
/// ```
/// let v = vec![3, 2, 1, 10];
/// let mut shared = 0;
/// let res: Result<Vec<u32>, &'static str> = v.iter().map(|x: &u32| {
/// shared += x;
/// x.checked_sub(2).ok_or("Underflow!")
/// }).collect();
/// assert_eq!(res, Err("Underflow!"));
/// assert_eq!(shared, 6);
/// ```
///
/// Since the third element caused an underflow, no further elements were taken,
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
#[inline]
fn from_iter<I: IntoIterator<Item=Result<A, E>>>(iter: I) -> Result<V, E> {
// FIXME(#11084): This could be replaced with Iterator::scan when this
Expand Down
19 changes: 0 additions & 19 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>

// Represents the MIR for a fn; also used as the task node for
// things read/modify that MIR.
[] MirConstQualif(DefId),
[] MirBuilt(DefId),
[] MirConst(DefId),
[] MirValidated(DefId),
[] MirOptimized(DefId),
[] MirShim { instance_def: InstanceDef<'tcx> },

[] BorrowCheckKrate,
Expand All @@ -485,7 +480,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] CollectModItemTypes(DefId),

[] Reachability,
[] MirKeys,
[eval_always] CrateVariances,

// Nodes representing bits of computed IR in the tcx. Each shared
Expand Down Expand Up @@ -544,7 +538,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[anon] TraitSelect,

[] ParamEnv(DefId),
[] Environment(DefId),
[] DescribeDef(DefId),

// FIXME(mw): DefSpans are not really inputs since they are derived from
Expand All @@ -571,7 +564,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[] HasGlobalAllocator(CrateNum),
[] HasPanicHandler(CrateNum),
[input] ExternCrate(DefId),
[eval_always] LintLevels,
[] Specializes { impl1: DefId, impl2: DefId },
[input] InScopeTraits(DefIndex),
[input] ModuleExports(DefId),
Expand Down Expand Up @@ -621,14 +613,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
[input] UsedCrateSource(CrateNum),
[input] PostorderCnums,

// These queries are not expected to have inputs -- as a result, they
// are not good candidates for "replay" because they are essentially
// pure functions of their input (and hence the expectation is that
// no caller would be green **apart** from just these
// queries). Making them anonymous avoids hashing the result, which
// may save a bit of time.
[anon] EraseRegionsTy { ty: Ty<'tcx> },

[input] Freevars(DefId),
[input] MaybeUnusedTraitImport(DefId),
[input] MaybeUnusedExternCrates,
Expand Down Expand Up @@ -667,9 +651,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>

[input] Features,

[] ProgramClausesFor(DefId),
[] ProgramClausesForEnv(traits::Environment<'tcx>),
[] WasmImportModuleMap(CrateNum),
[] ForeignModules(CrateNum),

[] UpstreamMonomorphizations(CrateNum),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
diag.span_suggestion(
span,
&msg,
"replace the use of the deprecated item",
suggestion.to_string(),
Applicability::MachineApplicable,
);
Expand Down
50 changes: 29 additions & 21 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1913,22 +1913,24 @@ pub enum PlaceBase<'tcx> {

/// static or static mut variable
Static(Box<Static<'tcx>>),

/// Constant code promoted to an injected static
Promoted(Box<(Promoted, Ty<'tcx>)>),
}

/// The `DefId` of a static, along with its normalized type (which is
/// stored to avoid requiring normalization when reading MIR).
/// We store the normalized type to avoid requiring normalization when reading MIR
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
pub struct Static<'tcx> {
pub def_id: DefId,
pub ty: Ty<'tcx>,
pub kind: StaticKind,
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, RustcEncodable, RustcDecodable)]
pub enum StaticKind {
Promoted(Promoted),
Static(DefId),
}

impl_stable_hash_for!(struct Static<'tcx> {
def_id,
ty
ty,
kind
});

/// The `Projection` data structure defines things of the form `B.x`
Expand Down Expand Up @@ -2048,7 +2050,7 @@ impl<'tcx> Place<'tcx> {
match self {
Place::Base(PlaceBase::Local(local)) => Some(*local),
Place::Projection(box Projection { base, elem: _ }) => base.base_local(),
Place::Base(PlaceBase::Promoted(..)) | Place::Base(PlaceBase::Static(..)) => None,
Place::Base(PlaceBase::Static(..)) => None,
}
}
}
Expand All @@ -2059,18 +2061,24 @@ impl<'tcx> Debug for Place<'tcx> {

match *self {
Base(PlaceBase::Local(id)) => write!(fmt, "{:?}", id),
Base(PlaceBase::Static(box self::Static { def_id, ty })) => write!(
fmt,
"({}: {:?})",
ty::tls::with(|tcx| tcx.def_path_str(def_id)),
ty
),
Base(PlaceBase::Promoted(ref promoted)) => write!(
fmt,
"({:?}: {:?})",
promoted.0,
promoted.1
),
Base(PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) })) => {
write!(
fmt,
"({}: {:?})",
ty::tls::with(|tcx| tcx.def_path_str(def_id)),
ty
)
},
Base(PlaceBase::Static(
box self::Static { ty, kind: StaticKind::Promoted(promoted) })
) => {
write!(
fmt,
"({:?}: {:?})",
promoted,
ty
)
},
Projection(ref data) => match data.elem {
ProjectionElem::Downcast(ref adt_def, index) => {
write!(fmt, "({:?} as {})", data.base, adt_def.variants[index].ident)
Expand Down
1 change: 0 additions & 1 deletion src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ impl<'tcx> Place<'tcx> {
match *self {
Place::Base(PlaceBase::Local(index)) =>
PlaceTy::Ty { ty: local_decls.local_decls()[index].ty },
Place::Base(PlaceBase::Promoted(ref data)) => PlaceTy::Ty { ty: data.1 },
Place::Base(PlaceBase::Static(ref data)) =>
PlaceTy::Ty { ty: data.ty },
Place::Projection(ref proj) =>
Expand Down
26 changes: 5 additions & 21 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ macro_rules! make_mir_visitor {
self.super_place(place, context, location);
}

fn visit_static(&mut self,
static_: & $($mutability)? Static<'tcx>,
context: PlaceContext<'tcx>,
location: Location) {
self.super_static(static_, context, location);
}

fn visit_projection(&mut self,
place: & $($mutability)? PlaceProjection<'tcx>,
context: PlaceContext<'tcx>,
Expand Down Expand Up @@ -736,27 +729,18 @@ macro_rules! make_mir_visitor {
Place::Base(PlaceBase::Local(local)) => {
self.visit_local(local, context, location);
}
Place::Base(PlaceBase::Static(static_)) => {
self.visit_static(static_, context, location);
Place::Base(PlaceBase::Static(box Static { kind, ty })) => {
if let StaticKind::Static(def_id) = kind {
self.visit_def_id(& $($mutability)? *def_id, location)
}
self.visit_ty(& $($mutability)? *ty, TyContext::Location(location));
}
Place::Base(PlaceBase::Promoted(promoted)) => {
self.visit_ty(& $($mutability)? promoted.1, TyContext::Location(location));
},
Place::Projection(proj) => {
self.visit_projection(proj, context, location);
}
}
}

fn super_static(&mut self,
static_: & $($mutability)? Static<'tcx>,
_context: PlaceContext<'tcx>,
location: Location) {
let Static { def_id, ty } = static_;
self.visit_def_id(def_id, location);
self.visit_ty(ty, TyContext::Location(location));
}

fn super_projection(&mut self,
proj: & $($mutability)? PlaceProjection<'tcx>,
context: PlaceContext<'tcx>,
Expand Down
Loading