Skip to content

Commit 394e1b4

Browse files
committed
Auto merge of #73779 - Manishearth:rollup-lwqd9jm, r=Manishearth
Rollup of 12 pull requests Successful merges: - #72771 (Warn if linking to a private item) - #72937 (Fortanix SGX target libunwind build process changes) - #73485 (Perform obligation deduplication to avoid buggy `ExistentialMismatch`) - #73529 (Add liballoc impl SpecFromElem for i8) - #73579 (add missing doc links) - #73627 (Shortcuts for min/max on double-ended BTreeMap/BTreeSet iterators) - #73691 (Bootstrap: detect Windows based on sys.platform) - #73694 (Document the Self keyword) - #73718 (Document the super keyword) - #73728 (Document some invariants correctly/more) - #73738 (Remove irrelevant comment) - #73765 (Remove blank line) Failed merges: r? @ghost
2 parents dda8a7f + 50026ae commit 394e1b4

29 files changed

+445
-116
lines changed

src/bootstrap/bootstrap.py

+6
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def default_build_triple():
184184
ostype = require(["uname", "-s"], exit=required)
185185
cputype = require(['uname', '-m'], exit=required)
186186

187+
# If we do not have `uname`, assume Windows.
187188
if ostype is None or cputype is None:
188189
return 'x86_64-pc-windows-msvc'
189190

@@ -236,6 +237,11 @@ def default_build_triple():
236237
if ostype.endswith('WOW64'):
237238
cputype = 'x86_64'
238239
ostype = 'pc-windows-gnu'
240+
elif sys.platform == 'win32':
241+
# Some Windows platforms might have a `uname` command that returns a
242+
# non-standard string (e.g. gnuwin32 tools returns `windows32`). In
243+
# these cases, fall back to using sys.platform.
244+
return 'x86_64-pc-windows-msvc'
239245
else:
240246
err = "unknown OS type: {}".format(ostype)
241247
sys.exit(err)

src/bootstrap/compile.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -131,26 +131,13 @@ fn copy_third_party_objects(
131131
compiler: &Compiler,
132132
target: Interned<String>,
133133
) -> Vec<(PathBuf, DependencyType)> {
134-
let libdir = builder.sysroot_libdir(*compiler, target);
135134
let mut target_deps = vec![];
136135

137-
// Copies libunwind.a compiled to be linked with x86_64-fortanix-unknown-sgx.
138-
//
139-
// This target needs to be linked to Fortanix's port of llvm's libunwind.
140-
// libunwind requires support for rwlock and printing to stderr,
141-
// which is provided by std for this target.
136+
// FIXME: remove this in 2021
142137
if target == "x86_64-fortanix-unknown-sgx" {
143-
let src_path_env = "X86_FORTANIX_SGX_LIBS";
144-
let src =
145-
env::var(src_path_env).unwrap_or_else(|_| panic!("{} not found in env", src_path_env));
146-
copy_and_stamp(
147-
builder,
148-
&*libdir,
149-
Path::new(&src),
150-
"libunwind.a",
151-
&mut target_deps,
152-
DependencyType::Target,
153-
);
138+
if env::var_os("X86_FORTANIX_SGX_LIBS").is_some() {
139+
builder.info("Warning: X86_FORTANIX_SGX_LIBS environment variable is ignored, libunwind is now compiled as part of rustbuild");
140+
}
154141
}
155142

156143
if builder.config.sanitizers && compiler.stage != 0 {

src/ci/docker/dist-various-2/Dockerfile

+1-5
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc
7171
COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
7272
COPY dist-various-2/x86_64-fortanix-unknown-sgx-clang-wrap.sh /usr/bin/x86_64-fortanix-unknown-sgx-clang-11
7373
RUN ln -s /usr/bin/x86_64-fortanix-unknown-sgx-clang-11 /usr/bin/x86_64-fortanix-unknown-sgx-clang++-11
74-
# We pass the commit id of the port of LLVM's libunwind to the build script.
75-
# Any update to the commit id here, should cause the container image to be re-built from this point on.
76-
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "800f95131fe6acd20b96b6f4723ca3c820f3d379"
74+
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh
7775

7876
COPY dist-various-2/build-wasi-toolchain.sh /tmp/
7977
RUN /tmp/build-wasi-toolchain.sh
@@ -105,8 +103,6 @@ ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda
105103
ENV TARGETS=$TARGETS,armv7-unknown-linux-gnueabi
106104
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabi
107105

108-
ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/"
109-
110106
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
111107
# we need asm in the search path for gcc-7 (for gnux32) but not in the search path of the
112108
# cross compilers.

src/ci/docker/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh

-42
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33
set -eu
44
source shared.sh
55

6-
if [ -z "$1" ]; then
7-
echo "Usage: ${0} <commit_id>"
8-
exit -1
9-
fi
10-
116
target="x86_64-fortanix-unknown-sgx"
12-
url="https://github.com/fortanix/llvm-project/archive/${1}.tar.gz"
13-
repo_name="llvm-project"
147

158
install_prereq() {
169
curl https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add -
@@ -24,39 +17,4 @@ install_prereq() {
2417
clang-11
2518
}
2619

27-
build_unwind() {
28-
set -x
29-
dir_name="${target}_temp"
30-
rm -rf ${dir_name}
31-
mkdir -p ${dir_name}
32-
pushd ${dir_name}
33-
34-
# Clone Fortanix's fork of llvm-project which has a port of libunwind
35-
fetch_github_commit_archive "$repo_name" "$url"
36-
cd "${repo_name}/libunwind"
37-
38-
# Build libunwind
39-
mkdir -p build
40-
cd build
41-
target_CC="CC_${target//-/_}"
42-
target_CXX="CXX_${target//-/_}"
43-
target_CFLAGS="CFLAGS_${target//-/_}"
44-
target_CXXFLAGS="CXXFLAGS_${target//-/_}"
45-
cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" \
46-
-DCMAKE_C_COMPILER="${!target_CC}" -DCMAKE_CXX_COMPILER="${!target_CXX}" \
47-
-DCMAKE_C_FLAGS="${!target_CFLAGS}" -DCMAKE_CXX_FLAGS="${!target_CXXFLAGS}" \
48-
-DCMAKE_C_COMPILER_TARGET=$target -DCMAKE_CXX_COMPILER_TARGET=$target \
49-
-DLLVM_ENABLE_WARNINGS=1 -DLIBUNWIND_ENABLE_WERROR=1 -DLIBUNWIND_ENABLE_PEDANTIC=0 \
50-
-DLLVM_PATH=../../llvm/ ../
51-
make unwind_static
52-
install -D "lib/libunwind.a" "/${target}/lib/libunwind.a"
53-
54-
popd
55-
rm -rf ${dir_name}
56-
57-
{ set +x; } 2>/dev/null
58-
}
59-
60-
set -x
6120
hide_output install_prereq
62-
build_unwind

src/liballoc/collections/btree/map.rs

+40
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,14 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
13961396
fn last(mut self) -> Option<(&'a K, &'a V)> {
13971397
self.next_back()
13981398
}
1399+
1400+
fn min(mut self) -> Option<(&'a K, &'a V)> {
1401+
self.next()
1402+
}
1403+
1404+
fn max(mut self) -> Option<(&'a K, &'a V)> {
1405+
self.next_back()
1406+
}
13991407
}
14001408

14011409
#[stable(feature = "fused", since = "1.26.0")]
@@ -1458,6 +1466,14 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
14581466
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
14591467
self.next_back()
14601468
}
1469+
1470+
fn min(mut self) -> Option<(&'a K, &'a mut V)> {
1471+
self.next()
1472+
}
1473+
1474+
fn max(mut self) -> Option<(&'a K, &'a mut V)> {
1475+
self.next_back()
1476+
}
14611477
}
14621478

14631479
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1595,6 +1611,14 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
15951611
fn last(mut self) -> Option<&'a K> {
15961612
self.next_back()
15971613
}
1614+
1615+
fn min(mut self) -> Option<&'a K> {
1616+
self.next()
1617+
}
1618+
1619+
fn max(mut self) -> Option<&'a K> {
1620+
self.next_back()
1621+
}
15981622
}
15991623

16001624
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1768,6 +1792,14 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
17681792
fn last(mut self) -> Option<(&'a K, &'a V)> {
17691793
self.next_back()
17701794
}
1795+
1796+
fn min(mut self) -> Option<(&'a K, &'a V)> {
1797+
self.next()
1798+
}
1799+
1800+
fn max(mut self) -> Option<(&'a K, &'a V)> {
1801+
self.next_back()
1802+
}
17711803
}
17721804

17731805
#[stable(feature = "map_values_mut", since = "1.10.0")]
@@ -1853,6 +1885,14 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
18531885
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
18541886
self.next_back()
18551887
}
1888+
1889+
fn min(mut self) -> Option<(&'a K, &'a mut V)> {
1890+
self.next()
1891+
}
1892+
1893+
fn max(mut self) -> Option<(&'a K, &'a mut V)> {
1894+
self.next_back()
1895+
}
18561896
}
18571897

18581898
impl<'a, K, V> RangeMut<'a, K, V> {

src/liballoc/collections/btree/set.rs

+35
Original file line numberDiff line numberDiff line change
@@ -1291,12 +1291,22 @@ impl<'a, T> Iterator for Iter<'a, T> {
12911291
fn next(&mut self) -> Option<&'a T> {
12921292
self.iter.next()
12931293
}
1294+
12941295
fn size_hint(&self) -> (usize, Option<usize>) {
12951296
self.iter.size_hint()
12961297
}
1298+
12971299
fn last(mut self) -> Option<&'a T> {
12981300
self.next_back()
12991301
}
1302+
1303+
fn min(mut self) -> Option<&'a T> {
1304+
self.next()
1305+
}
1306+
1307+
fn max(mut self) -> Option<&'a T> {
1308+
self.next_back()
1309+
}
13001310
}
13011311
#[stable(feature = "rust1", since = "1.0.0")]
13021312
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
@@ -1321,6 +1331,7 @@ impl<T> Iterator for IntoIter<T> {
13211331
fn next(&mut self) -> Option<T> {
13221332
self.iter.next().map(|(k, _)| k)
13231333
}
1334+
13241335
fn size_hint(&self) -> (usize, Option<usize>) {
13251336
self.iter.size_hint()
13261337
}
@@ -1359,6 +1370,14 @@ impl<'a, T> Iterator for Range<'a, T> {
13591370
fn last(mut self) -> Option<&'a T> {
13601371
self.next_back()
13611372
}
1373+
1374+
fn min(mut self) -> Option<&'a T> {
1375+
self.next()
1376+
}
1377+
1378+
fn max(mut self) -> Option<&'a T> {
1379+
self.next_back()
1380+
}
13621381
}
13631382

13641383
#[stable(feature = "btree_range", since = "1.17.0")]
@@ -1429,6 +1448,10 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
14291448
};
14301449
(self_len.saturating_sub(other_len), Some(self_len))
14311450
}
1451+
1452+
fn min(mut self) -> Option<&'a T> {
1453+
self.next()
1454+
}
14321455
}
14331456

14341457
#[stable(feature = "fused", since = "1.26.0")]
@@ -1460,6 +1483,10 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
14601483
// the number of elements to less than half the range of usize.
14611484
(0, Some(a_len + b_len))
14621485
}
1486+
1487+
fn min(mut self) -> Option<&'a T> {
1488+
self.next()
1489+
}
14631490
}
14641491

14651492
#[stable(feature = "fused", since = "1.26.0")]
@@ -1516,6 +1543,10 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
15161543
IntersectionInner::Answer(Some(_)) => (1, Some(1)),
15171544
}
15181545
}
1546+
1547+
fn min(mut self) -> Option<&'a T> {
1548+
self.next()
1549+
}
15191550
}
15201551

15211552
#[stable(feature = "fused", since = "1.26.0")]
@@ -1541,6 +1572,10 @@ impl<'a, T: Ord> Iterator for Union<'a, T> {
15411572
// No checked_add - see SymmetricDifference::size_hint.
15421573
(max(a_len, b_len), Some(a_len + b_len))
15431574
}
1575+
1576+
fn min(mut self) -> Option<&'a T> {
1577+
self.next()
1578+
}
15441579
}
15451580

15461581
#[stable(feature = "fused", since = "1.26.0")]

src/liballoc/raw_vec/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn allocator_param() {
1212
//
1313
// Instead, this just checks that the `RawVec` methods do at
1414
// least go through the Allocator API when it reserves
15-
1615
// storage.
1716

1817
// A dumb allocator that consumes a fixed amount of fuel

src/liballoc/tests/btree/map.rs

+35
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,41 @@ fn test_iter_mixed() {
309309
test(size, map.into_iter());
310310
}
311311

312+
#[test]
313+
fn test_iter_min_max() {
314+
let mut a = BTreeMap::new();
315+
assert_eq!(a.iter().min(), None);
316+
assert_eq!(a.iter().max(), None);
317+
assert_eq!(a.iter_mut().min(), None);
318+
assert_eq!(a.iter_mut().max(), None);
319+
assert_eq!(a.range(..).min(), None);
320+
assert_eq!(a.range(..).max(), None);
321+
assert_eq!(a.range_mut(..).min(), None);
322+
assert_eq!(a.range_mut(..).max(), None);
323+
assert_eq!(a.keys().min(), None);
324+
assert_eq!(a.keys().max(), None);
325+
assert_eq!(a.values().min(), None);
326+
assert_eq!(a.values().max(), None);
327+
assert_eq!(a.values_mut().min(), None);
328+
assert_eq!(a.values_mut().max(), None);
329+
a.insert(1, 42);
330+
a.insert(2, 24);
331+
assert_eq!(a.iter().min(), Some((&1, &42)));
332+
assert_eq!(a.iter().max(), Some((&2, &24)));
333+
assert_eq!(a.iter_mut().min(), Some((&1, &mut 42)));
334+
assert_eq!(a.iter_mut().max(), Some((&2, &mut 24)));
335+
assert_eq!(a.range(..).min(), Some((&1, &42)));
336+
assert_eq!(a.range(..).max(), Some((&2, &24)));
337+
assert_eq!(a.range_mut(..).min(), Some((&1, &mut 42)));
338+
assert_eq!(a.range_mut(..).max(), Some((&2, &mut 24)));
339+
assert_eq!(a.keys().min(), Some(&1));
340+
assert_eq!(a.keys().max(), Some(&2));
341+
assert_eq!(a.values().min(), Some(&24));
342+
assert_eq!(a.values().max(), Some(&42));
343+
assert_eq!(a.values_mut().min(), Some(&mut 24));
344+
assert_eq!(a.values_mut().max(), Some(&mut 42));
345+
}
346+
312347
fn range_keys(map: &BTreeMap<i32, i32>, range: impl RangeBounds<i32>) -> Vec<i32> {
313348
map.range(range)
314349
.map(|(&k, &v)| {

src/liballoc/tests/btree/set.rs

+31
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,37 @@ fn test_hash() {
3333
assert_eq!(hash(&x), hash(&y));
3434
}
3535

36+
#[test]
37+
fn test_iter_min_max() {
38+
let mut a = BTreeSet::new();
39+
assert_eq!(a.iter().min(), None);
40+
assert_eq!(a.iter().max(), None);
41+
assert_eq!(a.range(..).min(), None);
42+
assert_eq!(a.range(..).max(), None);
43+
assert_eq!(a.difference(&BTreeSet::new()).min(), None);
44+
assert_eq!(a.difference(&BTreeSet::new()).max(), None);
45+
assert_eq!(a.intersection(&a).min(), None);
46+
assert_eq!(a.intersection(&a).max(), None);
47+
assert_eq!(a.symmetric_difference(&BTreeSet::new()).min(), None);
48+
assert_eq!(a.symmetric_difference(&BTreeSet::new()).max(), None);
49+
assert_eq!(a.union(&a).min(), None);
50+
assert_eq!(a.union(&a).max(), None);
51+
a.insert(1);
52+
a.insert(2);
53+
assert_eq!(a.iter().min(), Some(&1));
54+
assert_eq!(a.iter().max(), Some(&2));
55+
assert_eq!(a.range(..).min(), Some(&1));
56+
assert_eq!(a.range(..).max(), Some(&2));
57+
assert_eq!(a.difference(&BTreeSet::new()).min(), Some(&1));
58+
assert_eq!(a.difference(&BTreeSet::new()).max(), Some(&2));
59+
assert_eq!(a.intersection(&a).min(), Some(&1));
60+
assert_eq!(a.intersection(&a).max(), Some(&2));
61+
assert_eq!(a.symmetric_difference(&BTreeSet::new()).min(), Some(&1));
62+
assert_eq!(a.symmetric_difference(&BTreeSet::new()).max(), Some(&2));
63+
assert_eq!(a.union(&a).min(), Some(&1));
64+
assert_eq!(a.union(&a).max(), Some(&2));
65+
}
66+
3667
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
3768
where
3869
F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool,

0 commit comments

Comments
 (0)