Skip to content

Commit b1f8e6f

Browse files
committed
Auto merge of #48399 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 12 pull requests - Successful merges: #47379, #47833, #48106, #48198, #48314, #48325, #48335, #48352, #48354, #48360, #48382, #48397 - Failed merges:
2 parents 27a046e + 24c17cb commit b1f8e6f

Some content is hidden

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

55 files changed

+2626
-232
lines changed

.mailmap

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ Herman J. Radtke III <herman@hermanradtke.com> Herman J. Radtke III <hermanradtk
9595
Ilyong Cho <ilyoan@gmail.com>
9696
Ivan Ivaschenko <defuz.net@gmail.com>
9797
J. J. Weber <jjweber@gmail.com>
98-
Jakub Bukaj <jakub@jakub.cc>
99-
Jakub Bukaj <jakub@jakub.cc> <jakubw@jakubw.net>
100-
Jakub Bukaj <jakub@jakub.cc> Jakub Bukaj <jakub.bukaj@yahoo.com>
98+
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakub@jakub.cc>
99+
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakubw@jakubw.net>
100+
Jakub Adam Wieczorek <jakub.adam.wieczorek@gmail.com> <jakub.bukaj@yahoo.com>
101101
James Deng <cnjamesdeng@gmail.com> <cnJamesDeng@gmail.com>
102102
James Miller <bladeon@gmail.com> <james@aatch.net>
103103
James Perry <james.austin.perry@gmail.com>

src/Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libcore/cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl Ordering {
343343
/// v.sort_by_key(|&num| (num > 3, Reverse(num)));
344344
/// assert_eq!(v, vec![3, 2, 1, 6, 5, 4]);
345345
/// ```
346-
#[derive(PartialEq, Eq, Debug)]
346+
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
347347
#[stable(feature = "reverse_cmp_key", since = "1.19.0")]
348348
pub struct Reverse<T>(#[stable(feature = "reverse_cmp_key", since = "1.19.0")] pub T);
349349

src/libcore/iter/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub trait Iterator {
168168
/// This function might panic if the iterator has more than [`usize::MAX`]
169169
/// elements.
170170
///
171-
/// [`usize::MAX`]: ../../std/isize/constant.MAX.html
171+
/// [`usize::MAX`]: ../../std/usize/constant.MAX.html
172172
///
173173
/// # Examples
174174
///

src/libcore/num/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ Basic usage:
12091209
```
12101210
", $Feature, "let x: ", stringify!($SelfT), " = 2; // or any other integer type
12111211
1212-
assert_eq!(x.pow(4), 16);",
1212+
assert_eq!(x.pow(5), 32);",
12131213
$EndFeature, "
12141214
```"),
12151215
#[stable(feature = "rust1", since = "1.0.0")]
@@ -2364,7 +2364,7 @@ assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(132), (0x1, true));", $E
23642364
Basic usage:
23652365
23662366
```
2367-
", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(4), 16);", $EndFeature, "
2367+
", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(5), 32);", $EndFeature, "
23682368
```"),
23692369
#[stable(feature = "rust1", since = "1.0.0")]
23702370
#[inline]

src/librustc/hir/map/definitions.rs

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ impl DefPathTable {
7272
index
7373
}
7474

75+
pub fn next_id(&self, address_space: DefIndexAddressSpace) -> DefIndex {
76+
DefIndex::from_array_index(self.index_to_key[address_space.index()].len(), address_space)
77+
}
78+
7579
#[inline(always)]
7680
pub fn def_key(&self, index: DefIndex) -> DefKey {
7781
self.index_to_key[index.address_space().index()]

src/librustc/infer/mod.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
180180
// for each body-id in this map, which will process the
181181
// obligations within. This is expected to be done 'late enough'
182182
// that all type inference variables have been bound and so forth.
183-
region_obligations: RefCell<Vec<(ast::NodeId, RegionObligation<'tcx>)>>,
183+
pub region_obligations: RefCell<Vec<(ast::NodeId, RegionObligation<'tcx>)>>,
184184
}
185185

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

1558-
fn borrow_region_constraints(&self) -> RefMut<'_, RegionConstraintCollector<'tcx>> {
1558+
pub fn borrow_region_constraints(&self) -> RefMut<'_, RegionConstraintCollector<'tcx>> {
15591559
RefMut::map(
15601560
self.region_constraints.borrow_mut(),
15611561
|c| c.as_mut().expect("region constraints already solved"))
15621562
}
1563+
1564+
/// Clears the selection, evaluation, and projection cachesThis is useful when
1565+
/// repeatedly attemping to select an Obligation while changing only
1566+
/// its ParamEnv, since FulfillmentContext doesn't use 'probe'
1567+
pub fn clear_caches(&self) {
1568+
self.selection_cache.clear();
1569+
self.evaluation_cache.clear();
1570+
self.projection_cache.borrow_mut().clear();
1571+
}
15631572
}
15641573

15651574
impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {

src/librustc/infer/region_constraints/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub type VarOrigins = IndexVec<RegionVid, RegionVariableOrigin>;
8282
/// Describes constraints between the region variables and other
8383
/// regions, as well as other conditions that must be verified, or
8484
/// assumptions that can be made.
85-
#[derive(Debug, Default)]
85+
#[derive(Debug, Default, Clone)]
8686
pub struct RegionConstraintData<'tcx> {
8787
/// Constraints of the form `A <= B`, where either `A` or `B` can
8888
/// be a region variable (or neither, as it happens).
@@ -142,7 +142,7 @@ pub enum Constraint<'tcx> {
142142
/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
143143
/// `i`. Inference variables may be involved (but this verification
144144
/// step doesn't influence inference).
145-
#[derive(Debug)]
145+
#[derive(Debug, Clone)]
146146
pub struct Verify<'tcx> {
147147
pub kind: GenericKind<'tcx>,
148148
pub origin: SubregionOrigin<'tcx>,
@@ -159,7 +159,7 @@ pub enum GenericKind<'tcx> {
159159
/// When we introduce a verification step, we wish to test that a
160160
/// particular region (let's call it `'min`) meets some bound.
161161
/// The bound is described the by the following grammar:
162-
#[derive(Debug)]
162+
#[derive(Debug, Clone)]
163163
pub enum VerifyBound<'tcx> {
164164
/// B = exists {R} --> some 'r in {R} must outlive 'min
165165
///
@@ -288,6 +288,10 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
288288
&self.var_origins
289289
}
290290

291+
pub fn region_constraint_data(&self) -> &RegionConstraintData<'tcx> {
292+
&self.data
293+
}
294+
291295
/// Once all the constraints have been gathered, extract out the final data.
292296
///
293297
/// Not legal during a snapshot.

src/librustc/traits/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use syntax_pos::{Span, DUMMY_SP};
3232
pub use self::coherence::{orphan_check, overlapping_impls, OrphanCheckErr, OverlapResult};
3333
pub use self::fulfill::FulfillmentContext;
3434
pub use self::project::MismatchedProjectionTypes;
35-
pub use self::project::{normalize, normalize_projection_type, Normalized};
36-
pub use self::project::{ProjectionCache, ProjectionCacheSnapshot, Reveal};
35+
pub use self::project::{normalize, normalize_projection_type, poly_project_and_unify_type};
36+
pub use self::project::{ProjectionCache, ProjectionCacheSnapshot, Reveal, Normalized};
3737
pub use self::object_safety::ObjectSafetyViolation;
3838
pub use self::object_safety::MethodViolationCode;
3939
pub use self::on_unimplemented::{OnUnimplementedDirective, OnUnimplementedNote};

src/librustc/traits/project.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,10 @@ impl<'tcx> ProjectionCache<'tcx> {
15961596
}
15971597
}
15981598

1599+
pub fn clear(&mut self) {
1600+
self.map.clear();
1601+
}
1602+
15991603
pub fn snapshot(&mut self) -> ProjectionCacheSnapshot {
16001604
ProjectionCacheSnapshot { snapshot: self.map.snapshot() }
16011605
}

src/librustc/traits/select.rs

+30-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> {
9393
inferred_obligations: SnapshotVec<InferredObligationsSnapshotVecDelegate<'tcx>>,
9494

9595
intercrate_ambiguity_causes: Option<Vec<IntercrateAmbiguityCause>>,
96+
97+
/// Controls whether or not to filter out negative impls when selecting.
98+
/// This is used in librustdoc to distinguish between the lack of an impl
99+
/// and a negative impl
100+
allow_negative_impls: bool
96101
}
97102

98103
#[derive(Clone, Debug)]
@@ -424,6 +429,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
424429
intercrate: None,
425430
inferred_obligations: SnapshotVec::new(),
426431
intercrate_ambiguity_causes: None,
432+
allow_negative_impls: false,
427433
}
428434
}
429435

@@ -436,6 +442,20 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
436442
intercrate: Some(mode),
437443
inferred_obligations: SnapshotVec::new(),
438444
intercrate_ambiguity_causes: None,
445+
allow_negative_impls: false,
446+
}
447+
}
448+
449+
pub fn with_negative(infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>,
450+
allow_negative_impls: bool) -> SelectionContext<'cx, 'gcx, 'tcx> {
451+
debug!("with_negative({:?})", allow_negative_impls);
452+
SelectionContext {
453+
infcx,
454+
freshener: infcx.freshener(),
455+
intercrate: None,
456+
inferred_obligations: SnapshotVec::new(),
457+
intercrate_ambiguity_causes: None,
458+
allow_negative_impls,
439459
}
440460
}
441461

@@ -1086,7 +1106,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
10861106
fn filter_negative_impls(&self, candidate: SelectionCandidate<'tcx>)
10871107
-> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
10881108
if let ImplCandidate(def_id) = candidate {
1089-
if self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative {
1109+
if !self.allow_negative_impls &&
1110+
self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative {
10901111
return Err(Unimplemented)
10911112
}
10921113
}
@@ -3337,6 +3358,10 @@ impl<'tcx> SelectionCache<'tcx> {
33373358
hashmap: RefCell::new(FxHashMap())
33383359
}
33393360
}
3361+
3362+
pub fn clear(&self) {
3363+
*self.hashmap.borrow_mut() = FxHashMap()
3364+
}
33403365
}
33413366

33423367
impl<'tcx> EvaluationCache<'tcx> {
@@ -3345,6 +3370,10 @@ impl<'tcx> EvaluationCache<'tcx> {
33453370
hashmap: RefCell::new(FxHashMap())
33463371
}
33473372
}
3373+
3374+
pub fn clear(&self) {
3375+
*self.hashmap.borrow_mut() = FxHashMap()
3376+
}
33483377
}
33493378

33503379
impl<'o,'tcx> TraitObligationStack<'o,'tcx> {

src/librustc_data_structures/snapshot_map/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ impl<K, V> SnapshotMap<K, V>
4545
}
4646
}
4747

48+
pub fn clear(&mut self) {
49+
self.map.clear();
50+
self.undo_log.clear();
51+
}
52+
4853
pub fn insert(&mut self, key: K, value: V) -> bool {
4954
match self.map.insert(key.clone(), value) {
5055
None => {

src/librustc_resolve/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ Erroneous code example:
325325
extern crate core;
326326
327327
struct core;
328+
329+
fn main() {}
328330
```
329331
330332
There are two possible solutions:

src/librustc_typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
337337
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
338338
scope_expr_id,
339339
span,
340-
&format!("the type of this value must be known in this context"));
340+
&format!("type annotations needed"));
341341
}
342342
} else {
343343
let t = self.structurally_resolved_type(span, final_ty);

src/librustc_typeck/check/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -5052,9 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50525052
ty
50535053
} else {
50545054
if !self.is_tainted_by_errors() {
5055-
type_error_struct!(self.tcx.sess, sp, ty, E0619,
5056-
"the type of this value must be known in this context")
5057-
.emit();
5055+
self.need_type_info((**self).body_id, sp, ty);
50585056
}
50595057
self.demand_suptype(sp, self.tcx.types.err, ty);
50605058
self.tcx.types.err

src/librustc_typeck/diagnostics.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4368,12 +4368,13 @@ i_am_a_function();
43684368
"##,
43694369

43704370
E0619: r##"
4371+
#### Note: this error code is no longer emitted by the compiler.
43714372
The type-checker needed to know the type of an expression, but that type had not
43724373
yet been inferred.
43734374
43744375
Erroneous code example:
43754376
4376-
```compile_fail,E0619
4377+
```compile_fail
43774378
let mut x = vec![];
43784379
match x.pop() {
43794380
Some(v) => {

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ path = "lib.rs"
1010
doctest = false
1111

1212
[dependencies]
13-
pulldown-cmark = { version = "0.1.0", default-features = false }
13+
pulldown-cmark = { version = "0.1.2", default-features = false }
1414
tempdir = "0.3"

0 commit comments

Comments
 (0)