Skip to content

Commit 7ced01a

Browse files
committed
Auto merge of rust-lang#71717 - Dylan-DPC:rollup-av5vjor, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#70950 (extend NLL checker to understand `'empty` combined with universes) - rust-lang#71433 (Add help message for missing right operand in condition) - rust-lang#71449 (Move `{Free,}RegionRelations` and `FreeRegionMap` to `rustc_infer`) - rust-lang#71559 (Detect git version before attempting to use --progress) - rust-lang#71597 (Rename Unique::empty() -> Unique::dangling()) Failed merges: r? @ghost
2 parents be8589f + 97a8870 commit 7ced01a

File tree

37 files changed

+485
-296
lines changed

37 files changed

+485
-296
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3852,6 +3852,7 @@ dependencies = [
38523852
"rustc_session",
38533853
"rustc_span",
38543854
"rustc_target",
3855+
"serialize",
38553856
"smallvec 1.0.0",
38563857
]
38573858

src/bootstrap/bootstrap.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import argparse
33
import contextlib
44
import datetime
5+
import distutils.version
56
import hashlib
67
import os
78
import re
@@ -331,6 +332,7 @@ def __init__(self):
331332
self.use_locked_deps = ''
332333
self.use_vendored_sources = ''
333334
self.verbose = False
335+
self.git_version = None
334336

335337
def download_stage0(self):
336338
"""Fetch the build system for Rust, written in Rust
@@ -743,15 +745,13 @@ def update_submodule(self, module, checked_out, recorded_submodules):
743745

744746
run(["git", "submodule", "-q", "sync", module],
745747
cwd=self.rust_root, verbose=self.verbose)
746-
try:
747-
run(["git", "submodule", "update",
748-
"--init", "--recursive", "--progress", module],
749-
cwd=self.rust_root, verbose=self.verbose, exception=True)
750-
except RuntimeError:
751-
# Some versions of git don't support --progress.
752-
run(["git", "submodule", "update",
753-
"--init", "--recursive", module],
754-
cwd=self.rust_root, verbose=self.verbose)
748+
749+
update_args = ["git", "submodule", "update", "--init", "--recursive"]
750+
if self.git_version >= distutils.version.LooseVersion("2.11.0"):
751+
update_args.append("--progress")
752+
update_args.append(module)
753+
run(update_args, cwd=self.rust_root, verbose=self.verbose, exception=True)
754+
755755
run(["git", "reset", "-q", "--hard"],
756756
cwd=module_path, verbose=self.verbose)
757757
run(["git", "clean", "-qdfx"],
@@ -763,9 +763,13 @@ def update_submodules(self):
763763
self.get_toml('submodules') == "false":
764764
return
765765

766-
# check the existence of 'git' command
766+
default_encoding = sys.getdefaultencoding()
767+
768+
# check the existence and version of 'git' command
767769
try:
768-
subprocess.check_output(['git', '--version'])
770+
git_version_output = subprocess.check_output(['git', '--version'])
771+
git_version_str = git_version_output.strip().split()[2].decode(default_encoding)
772+
self.git_version = distutils.version.LooseVersion(git_version_str)
769773
except (subprocess.CalledProcessError, OSError):
770774
print("error: `git` is not found, please make sure it's installed and in the path.")
771775
sys.exit(1)

src/liballoc/raw_vec.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ mod tests;
2525
/// involved. This type is excellent for building your own data structures like Vec and VecDeque.
2626
/// In particular:
2727
///
28-
/// * Produces `Unique::empty()` on zero-sized types.
29-
/// * Produces `Unique::empty()` on zero-length allocations.
30-
/// * Avoids freeing `Unique::empty()`.
28+
/// * Produces `Unique::dangling()` on zero-sized types.
29+
/// * Produces `Unique::dangling()` on zero-length allocations.
30+
/// * Avoids freeing `Unique::dangling()`.
3131
/// * Catches all overflows in capacity computations (promotes them to "capacity overflow" panics).
3232
/// * Guards against 32-bit systems allocating more than isize::MAX bytes.
3333
/// * Guards against overflowing your length.
@@ -125,7 +125,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
125125
/// the returned `RawVec`.
126126
pub const fn new_in(alloc: A) -> Self {
127127
// `cap: 0` means "unallocated". zero-sized types are ignored.
128-
Self { ptr: Unique::empty(), cap: 0, alloc }
128+
Self { ptr: Unique::dangling(), cap: 0, alloc }
129129
}
130130

131131
/// Like `with_capacity`, but parameterized over the choice of
@@ -172,7 +172,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
172172
}
173173

174174
/// Gets a raw pointer to the start of the allocation. Note that this is
175-
/// `Unique::empty()` if `capacity == 0` or `T` is zero-sized. In the former case, you must
175+
/// `Unique::dangling()` if `capacity == 0` or `T` is zero-sized. In the former case, you must
176176
/// be careful.
177177
pub fn ptr(&self) -> *mut T {
178178
self.ptr.as_ptr()

src/libcore/ptr/unique.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ impl<T: Sized> Unique<T> {
7070
/// a `T`, which means this must not be used as a "not yet initialized"
7171
/// sentinel value. Types that lazily allocate must track initialization by
7272
/// some other means.
73-
// FIXME: rename to dangling() to match NonNull?
7473
#[inline]
75-
pub const fn empty() -> Self {
74+
pub const fn dangling() -> Self {
7675
// SAFETY: mem::align_of() returns a valid, non-null pointer. The
7776
// conditions to call new_unchecked() are thus respected.
7877
unsafe { Unique::new_unchecked(mem::align_of::<T>() as *mut T) }

src/librustc_data_structures/graph/scc/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ impl<N: Idx, S: Idx> Sccs<N, S> {
4747
}
4848

4949
/// Returns an iterator over the SCCs in the graph.
50+
///
51+
/// The SCCs will be iterated in **dependency order** (or **post order**),
52+
/// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after.
53+
/// This is convenient when the edges represent dependencies: when you visit
54+
/// `S1`, the value for `S2` will already have been computed.
5055
pub fn all_sccs(&self) -> impl Iterator<Item = S> {
5156
(0..self.scc_data.len()).map(S::new)
5257
}

src/librustc_infer/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rustc_hir = { path = "../librustc_hir" }
1919
rustc_index = { path = "../librustc_index" }
2020
rustc_macros = { path = "../librustc_macros" }
2121
rustc_session = { path = "../librustc_session" }
22+
rustc_serialize = { path = "../libserialize", package = "serialize" }
2223
rustc_span = { path = "../librustc_span" }
2324
rustc_target = { path = "../librustc_target" }
2425
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

src/librustc_middle/ty/free_region_map.rs renamed to src/librustc_infer/infer/free_regions.rs

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
1-
use crate::ty::{self, Lift, Region, TyCtxt};
1+
//! This module handles the relationships between "free regions", i.e., lifetime parameters.
2+
//! Ordinarily, free regions are unrelated to one another, but they can be related via implied
3+
//! or explicit bounds. In that case, we track the bounds using the `TransitiveRelation` type,
4+
//! and use that to decide when one free region outlives another, and so forth.
5+
26
use rustc_data_structures::transitive_relation::TransitiveRelation;
7+
use rustc_hir::def_id::DefId;
8+
use rustc_middle::middle::region;
9+
use rustc_middle::ty::{self, Lift, Region, TyCtxt};
10+
11+
/// Combines a `region::ScopeTree` (which governs relationships between
12+
/// scopes) and a `FreeRegionMap` (which governs relationships between
13+
/// free regions) to yield a complete relation between concrete
14+
/// regions.
15+
///
16+
/// This stuff is a bit convoluted and should be refactored, but as we
17+
/// transition to NLL, it'll all go away anyhow.
18+
pub struct RegionRelations<'a, 'tcx> {
19+
pub tcx: TyCtxt<'tcx>,
20+
21+
/// The context used to fetch the region maps.
22+
pub context: DefId,
23+
24+
/// The region maps for the given context.
25+
pub region_scope_tree: &'a region::ScopeTree,
26+
27+
/// Free-region relationships.
28+
pub free_regions: &'a FreeRegionMap<'tcx>,
29+
}
30+
31+
impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
32+
pub fn new(
33+
tcx: TyCtxt<'tcx>,
34+
context: DefId,
35+
region_scope_tree: &'a region::ScopeTree,
36+
free_regions: &'a FreeRegionMap<'tcx>,
37+
) -> Self {
38+
Self { tcx, context, region_scope_tree, free_regions }
39+
}
40+
41+
pub fn lub_free_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
42+
self.free_regions.lub_free_regions(self.tcx, r_a, r_b)
43+
}
44+
}
345

446
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default, HashStable)]
547
pub struct FreeRegionMap<'tcx> {

src/librustc_infer/infer/lexical_region_resolve/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use graphviz as dot;
1010

1111
use super::Constraint;
1212
use crate::infer::region_constraints::RegionConstraintData;
13+
use crate::infer::RegionRelations;
1314
use crate::infer::SubregionOrigin;
1415
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1516
use rustc_hir::def_id::DefIndex;
16-
use rustc_middle::middle::free_region::RegionRelations;
1717
use rustc_middle::middle::region;
1818
use rustc_middle::ty;
1919

src/librustc_infer/infer/lexical_region_resolve/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::infer::region_constraints::MemberConstraint;
66
use crate::infer::region_constraints::RegionConstraintData;
77
use crate::infer::region_constraints::VarInfos;
88
use crate::infer::region_constraints::VerifyBound;
9+
use crate::infer::RegionRelations;
910
use crate::infer::RegionVariableOrigin;
1011
use crate::infer::RegionckMode;
1112
use crate::infer::SubregionOrigin;
@@ -14,7 +15,6 @@ use rustc_data_structures::graph::implementation::{
1415
Direction, Graph, NodeIndex, INCOMING, OUTGOING,
1516
};
1617
use rustc_index::vec::{Idx, IndexVec};
17-
use rustc_middle::middle::free_region::RegionRelations;
1818
use rustc_middle::ty::fold::TypeFoldable;
1919
use rustc_middle::ty::{self, Ty, TyCtxt};
2020
use rustc_middle::ty::{ReEarlyBound, ReEmpty, ReErased, ReFree, ReStatic};

src/librustc_infer/infer/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1818
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
1919
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
2020
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
21-
use rustc_middle::middle::free_region::RegionRelations;
2221
use rustc_middle::middle::region;
2322
use rustc_middle::mir;
2423
use rustc_middle::mir::interpret::ConstEvalResult;
@@ -39,6 +38,7 @@ use std::collections::BTreeMap;
3938
use std::fmt;
4039

4140
use self::combine::CombineFields;
41+
use self::free_regions::RegionRelations;
4242
use self::lexical_region_resolve::LexicalRegionResolutions;
4343
use self::outlives::env::OutlivesEnvironment;
4444
use self::region_constraints::{GenericKind, RegionConstraintData, VarInfos, VerifyBound};
@@ -50,6 +50,7 @@ pub mod canonical;
5050
mod combine;
5151
mod equate;
5252
pub mod error_reporting;
53+
pub mod free_regions;
5354
mod freshen;
5455
mod fudge;
5556
mod glb;
@@ -472,6 +473,9 @@ pub enum NLLRegionVariableOrigin {
472473
/// from a `for<'a> T` binder). Meant to represent "any region".
473474
Placeholder(ty::PlaceholderRegion),
474475

476+
/// The variable we create to represent `'empty(U0)`.
477+
RootEmptyRegion,
478+
475479
Existential {
476480
/// If this is true, then this variable was created to represent a lifetime
477481
/// bound in a `for` binder. For example, it might have been created to
@@ -493,6 +497,7 @@ impl NLLRegionVariableOrigin {
493497
NLLRegionVariableOrigin::FreeRegion => true,
494498
NLLRegionVariableOrigin::Placeholder(..) => true,
495499
NLLRegionVariableOrigin::Existential { .. } => false,
500+
NLLRegionVariableOrigin::RootEmptyRegion => false,
496501
}
497502
}
498503

src/librustc_infer/infer/outlives/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
use crate::infer::free_regions::FreeRegionMap;
12
use crate::infer::{GenericKind, InferCtxt};
23
use crate::traits::query::OutlivesBound;
34
use rustc_data_structures::fx::FxHashMap;
45
use rustc_hir as hir;
56
use rustc_middle::ty;
6-
use rustc_middle::ty::free_region_map::FreeRegionMap;
77

88
use super::explicit_outlives_bounds;
99

src/librustc_middle/middle/free_region.rs

-44
This file was deleted.

src/librustc_middle/middle/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pub mod codegen_fn_attrs;
22
pub mod cstore;
33
pub mod dependency_format;
44
pub mod exported_symbols;
5-
pub mod free_region;
65
pub mod lang_items;
76
pub mod lib_features {
87
use rustc_data_structures::fx::{FxHashMap, FxHashSet};

src/librustc_middle/ty/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub mod error;
9696
pub mod fast_reject;
9797
pub mod flags;
9898
pub mod fold;
99-
pub mod free_region_map;
10099
pub mod inhabitedness;
101100
pub mod layout;
102101
pub mod normalize_erasing_regions;

0 commit comments

Comments
 (0)