Skip to content

Commit

Permalink
Auto merge of #48399 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 12 pull requests

- Successful merges: #47379, #47833, #48106, #48198, #48314, #48325, #48335, #48352, #48354, #48360, #48382, #48397
- Failed merges:
  • Loading branch information
bors committed Feb 22, 2018
2 parents 27a046e + 24c17cb commit b1f8e6f
Show file tree
Hide file tree
Showing 55 changed files with 2,626 additions and 232 deletions.
6 changes: 3 additions & 3 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ Herman J. Radtke III <[email protected]> Herman J. Radtke III <hermanradtk
Ilyong Cho <[email protected]>
Ivan Ivaschenko <[email protected]>
J. J. Weber <[email protected]>
Jakub Bukaj <[email protected]>
Jakub Bukaj <jakub@jakub.cc> <[email protected]>
Jakub Bukaj <jakub@jakub.cc> Jakub Bukaj <[email protected]>
Jakub Adam Wieczorek <[email protected]> <[email protected]>
Jakub Adam Wieczorek <jakub[email protected]> <[email protected]>
Jakub Adam Wieczorek <jakub[email protected]> <[email protected]>
James Deng <[email protected]> <[email protected]>
James Miller <[email protected]> <[email protected]>
James Perry <[email protected]>
Expand Down
8 changes: 4 additions & 4 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl Ordering {
/// v.sort_by_key(|&num| (num > 3, Reverse(num)));
/// assert_eq!(v, vec![3, 2, 1, 6, 5, 4]);
/// ```
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
pub struct Reverse<T>(#[stable(feature = "reverse_cmp_key", since = "1.19.0")] pub T);

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub trait Iterator {
/// This function might panic if the iterator has more than [`usize::MAX`]
/// elements.
///
/// [`usize::MAX`]: ../../std/isize/constant.MAX.html
/// [`usize::MAX`]: ../../std/usize/constant.MAX.html
///
/// # Examples
///
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ Basic usage:
```
", $Feature, "let x: ", stringify!($SelfT), " = 2; // or any other integer type
assert_eq!(x.pow(4), 16);",
assert_eq!(x.pow(5), 32);",
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -2364,7 +2364,7 @@ assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(132), (0x1, true));", $E
Basic usage:
```
", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(4), 16);", $EndFeature, "
", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(5), 32);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ impl DefPathTable {
index
}

pub fn next_id(&self, address_space: DefIndexAddressSpace) -> DefIndex {
DefIndex::from_array_index(self.index_to_key[address_space.index()].len(), address_space)
}

#[inline(always)]
pub fn def_key(&self, index: DefIndex) -> DefKey {
self.index_to_key[index.address_space().index()]
Expand Down
13 changes: 11 additions & 2 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
// for each body-id in this map, which will process the
// obligations within. This is expected to be done 'late enough'
// that all type inference variables have been bound and so forth.
region_obligations: RefCell<Vec<(ast::NodeId, RegionObligation<'tcx>)>>,
pub region_obligations: RefCell<Vec<(ast::NodeId, RegionObligation<'tcx>)>>,
}

/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
Expand Down Expand Up @@ -1555,11 +1555,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
InferOk { value, obligations }
}

fn borrow_region_constraints(&self) -> RefMut<'_, RegionConstraintCollector<'tcx>> {
pub fn borrow_region_constraints(&self) -> RefMut<'_, RegionConstraintCollector<'tcx>> {
RefMut::map(
self.region_constraints.borrow_mut(),
|c| c.as_mut().expect("region constraints already solved"))
}

/// Clears the selection, evaluation, and projection cachesThis is useful when
/// repeatedly attemping to select an Obligation while changing only
/// its ParamEnv, since FulfillmentContext doesn't use 'probe'
pub fn clear_caches(&self) {
self.selection_cache.clear();
self.evaluation_cache.clear();
self.projection_cache.borrow_mut().clear();
}
}

impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {
Expand Down
10 changes: 7 additions & 3 deletions src/librustc/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub type VarOrigins = IndexVec<RegionVid, RegionVariableOrigin>;
/// Describes constraints between the region variables and other
/// regions, as well as other conditions that must be verified, or
/// assumptions that can be made.
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct RegionConstraintData<'tcx> {
/// Constraints of the form `A <= B`, where either `A` or `B` can
/// be a region variable (or neither, as it happens).
Expand Down Expand Up @@ -142,7 +142,7 @@ pub enum Constraint<'tcx> {
/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
/// `i`. Inference variables may be involved (but this verification
/// step doesn't influence inference).
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Verify<'tcx> {
pub kind: GenericKind<'tcx>,
pub origin: SubregionOrigin<'tcx>,
Expand All @@ -159,7 +159,7 @@ pub enum GenericKind<'tcx> {
/// When we introduce a verification step, we wish to test that a
/// particular region (let's call it `'min`) meets some bound.
/// The bound is described the by the following grammar:
#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum VerifyBound<'tcx> {
/// B = exists {R} --> some 'r in {R} must outlive 'min
///
Expand Down Expand Up @@ -288,6 +288,10 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
&self.var_origins
}

pub fn region_constraint_data(&self) -> &RegionConstraintData<'tcx> {
&self.data
}

/// Once all the constraints have been gathered, extract out the final data.
///
/// Not legal during a snapshot.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use syntax_pos::{Span, DUMMY_SP};
pub use self::coherence::{orphan_check, overlapping_impls, OrphanCheckErr, OverlapResult};
pub use self::fulfill::FulfillmentContext;
pub use self::project::MismatchedProjectionTypes;
pub use self::project::{normalize, normalize_projection_type, Normalized};
pub use self::project::{ProjectionCache, ProjectionCacheSnapshot, Reveal};
pub use self::project::{normalize, normalize_projection_type, poly_project_and_unify_type};
pub use self::project::{ProjectionCache, ProjectionCacheSnapshot, Reveal, Normalized};
pub use self::object_safety::ObjectSafetyViolation;
pub use self::object_safety::MethodViolationCode;
pub use self::on_unimplemented::{OnUnimplementedDirective, OnUnimplementedNote};
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,10 @@ impl<'tcx> ProjectionCache<'tcx> {
}
}

pub fn clear(&mut self) {
self.map.clear();
}

pub fn snapshot(&mut self) -> ProjectionCacheSnapshot {
ProjectionCacheSnapshot { snapshot: self.map.snapshot() }
}
Expand Down
31 changes: 30 additions & 1 deletion src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> {
inferred_obligations: SnapshotVec<InferredObligationsSnapshotVecDelegate<'tcx>>,

intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause>>,

/// Controls whether or not to filter out negative impls when selecting.
/// This is used in librustdoc to distinguish between the lack of an impl
/// and a negative impl
allow_negative_impls: bool
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -424,6 +429,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
intercrate: None,
inferred_obligations: SnapshotVec::new(),
intercrate_ambiguity_causes: None,
allow_negative_impls: false,
}
}

Expand All @@ -436,6 +442,20 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
intercrate: Some(mode),
inferred_obligations: SnapshotVec::new(),
intercrate_ambiguity_causes: None,
allow_negative_impls: false,
}
}

pub fn with_negative(infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>,
allow_negative_impls: bool) -> SelectionContext<'cx, 'gcx, 'tcx> {
debug!("with_negative({:?})", allow_negative_impls);
SelectionContext {
infcx,
freshener: infcx.freshener(),
intercrate: None,
inferred_obligations: SnapshotVec::new(),
intercrate_ambiguity_causes: None,
allow_negative_impls,
}
}

Expand Down Expand Up @@ -1086,7 +1106,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
fn filter_negative_impls(&self, candidate: SelectionCandidate<'tcx>)
-> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
if let ImplCandidate(def_id) = candidate {
if self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative {
if !self.allow_negative_impls &&
self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative {
return Err(Unimplemented)
}
}
Expand Down Expand Up @@ -3337,6 +3358,10 @@ impl<'tcx> SelectionCache<'tcx> {
hashmap: RefCell::new(FxHashMap())
}
}

pub fn clear(&self) {
*self.hashmap.borrow_mut() = FxHashMap()
}
}

impl<'tcx> EvaluationCache<'tcx> {
Expand All @@ -3345,6 +3370,10 @@ impl<'tcx> EvaluationCache<'tcx> {
hashmap: RefCell::new(FxHashMap())
}
}

pub fn clear(&self) {
*self.hashmap.borrow_mut() = FxHashMap()
}
}

impl<'o,'tcx> TraitObligationStack<'o,'tcx> {
Expand Down
5 changes: 5 additions & 0 deletions src/librustc_data_structures/snapshot_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ impl<K, V> SnapshotMap<K, V>
}
}

pub fn clear(&mut self) {
self.map.clear();
self.undo_log.clear();
}

pub fn insert(&mut self, key: K, value: V) -> bool {
match self.map.insert(key.clone(), value) {
None => {
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ Erroneous code example:
extern crate core;
struct core;
fn main() {}
```
There are two possible solutions:
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
scope_expr_id,
span,
&format!("the type of this value must be known in this context"));
&format!("type annotations needed"));
}
} else {
let t = self.structurally_resolved_type(span, final_ty);
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5052,9 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ty
} else {
if !self.is_tainted_by_errors() {
type_error_struct!(self.tcx.sess, sp, ty, E0619,
"the type of this value must be known in this context")
.emit();
self.need_type_info((**self).body_id, sp, ty);
}
self.demand_suptype(sp, self.tcx.types.err, ty);
self.tcx.types.err
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4368,12 +4368,13 @@ i_am_a_function();
"##,

E0619: r##"
#### Note: this error code is no longer emitted by the compiler.
The type-checker needed to know the type of an expression, but that type had not
yet been inferred.
Erroneous code example:
```compile_fail,E0619
```compile_fail
let mut x = vec![];
match x.pop() {
Some(v) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ path = "lib.rs"
doctest = false

[dependencies]
pulldown-cmark = { version = "0.1.0", default-features = false }
pulldown-cmark = { version = "0.1.2", default-features = false }
tempdir = "0.3"
Loading

0 comments on commit b1f8e6f

Please sign in to comment.