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 12 pull requests #73779

Merged
merged 30 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7f2396
Perform obligation deduplication to avoid buggy `ExistentialMismatch`
estebank Jun 18, 2020
f66bcc5
Add liballoc impl SpecFromElem for i8
pickfire Jun 20, 2020
7cac209
add missing doc links
RalfJung Jun 21, 2020
55d207a
tweak wording
RalfJung Jun 21, 2020
cb8c94c
improve grammar
RalfJung Jun 21, 2020
f3b1582
Update libunwind build process for x86_64-fortanix-unknown-sgx target
AdrianCX Jun 23, 2020
f44b8b9
Document the Self keyword
poliorcetics Jun 24, 2020
5232e20
Document the super keyword
poliorcetics Jun 25, 2020
343a921
Fix comments
AdrianCX Jun 25, 2020
db6fa2f
Remove deprecated comments
AdrianCX Jun 25, 2020
8b368db
Bootstrap: fallback detection of Windows
ajpaverd Jun 25, 2020
1a355a2
Document some invariants correctly/more
oli-obk Jun 25, 2020
f9af59d
Remove irrelevant comment
nbdd0121 Jun 25, 2020
42062a5
Shortcuts for min/max on ordinary BTreeMap/BTreeSet iterators
ssomers Jun 22, 2020
6f8bec9
Warn if linking to a private item
jyn514 May 13, 2020
20552c8
Generate docs for links to private items when passed --document-private
jyn514 May 30, 2020
6742382
Fix debug messages
jyn514 Jun 26, 2020
cb152ea
Remove blank line
kraai Jun 26, 2020
8adc781
Rollup merge of #72771 - jyn514:rustdoc, r=Manishearth
Manishearth Jun 26, 2020
38cbf15
Rollup merge of #72937 - AdrianCX:master, r=nikomatsakis
Manishearth Jun 26, 2020
f13d09a
Rollup merge of #73485 - estebank:dedup-preds, r=nikomatsakis
Manishearth Jun 26, 2020
23b0776
Rollup merge of #73529 - pickfire:liballoc-specfromelem-i8, r=cuviper
Manishearth Jun 26, 2020
92af945
Rollup merge of #73579 - RalfJung:doc-missing-links, r=shepmaster
Manishearth Jun 26, 2020
dfbba65
Rollup merge of #73627 - ssomers:btree_iter_min_max, r=Mark-Simulacrum
Manishearth Jun 26, 2020
c18e919
Rollup merge of #73691 - ajpaverd:bootstrap-windows-73689, r=Mark-Sim…
Manishearth Jun 26, 2020
8d9c00d
Rollup merge of #73694 - poliorcetics:self-upper-keyword, r=Mark-Simu…
Manishearth Jun 26, 2020
bc10bb0
Rollup merge of #73718 - poliorcetics:super-keyword, r=shepmaster
Manishearth Jun 26, 2020
83f6d0a
Rollup merge of #73728 - oli-obk:const_prop_cleanup, r=wesleywiser
Manishearth Jun 26, 2020
7926c64
Rollup merge of #73738 - nbdd0121:comment, r=nikomatsakis
Manishearth Jun 26, 2020
50026ae
Rollup merge of #73765 - kraai:remove-blank-line, r=jonas-schievink
Manishearth Jun 26, 2020
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
6 changes: 6 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def default_build_triple():
ostype = require(["uname", "-s"], exit=required)
cputype = require(['uname', '-m'], exit=required)

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

Expand Down Expand Up @@ -236,6 +237,11 @@ def default_build_triple():
if ostype.endswith('WOW64'):
cputype = 'x86_64'
ostype = 'pc-windows-gnu'
elif sys.platform == 'win32':
# Some Windows platforms might have a `uname` command that returns a
# non-standard string (e.g. gnuwin32 tools returns `windows32`). In
# these cases, fall back to using sys.platform.
return 'x86_64-pc-windows-msvc'
else:
err = "unknown OS type: {}".format(ostype)
sys.exit(err)
Expand Down
21 changes: 4 additions & 17 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,13 @@ fn copy_third_party_objects(
compiler: &Compiler,
target: Interned<String>,
) -> Vec<(PathBuf, DependencyType)> {
let libdir = builder.sysroot_libdir(*compiler, target);
let mut target_deps = vec![];

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

if builder.config.sanitizers && compiler.stage != 0 {
Expand Down
6 changes: 1 addition & 5 deletions src/ci/docker/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc
COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
COPY dist-various-2/x86_64-fortanix-unknown-sgx-clang-wrap.sh /usr/bin/x86_64-fortanix-unknown-sgx-clang-11
RUN ln -s /usr/bin/x86_64-fortanix-unknown-sgx-clang-11 /usr/bin/x86_64-fortanix-unknown-sgx-clang++-11
# We pass the commit id of the port of LLVM's libunwind to the build script.
# Any update to the commit id here, should cause the container image to be re-built from this point on.
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "800f95131fe6acd20b96b6f4723ca3c820f3d379"
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh

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

ENV X86_FORTANIX_SGX_LIBS="/x86_64-fortanix-unknown-sgx/lib/"

# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
# we need asm in the search path for gcc-7 (for gnux32) but not in the search path of the
# cross compilers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
set -eu
source shared.sh

if [ -z "$1" ]; then
echo "Usage: ${0} <commit_id>"
exit -1
fi

target="x86_64-fortanix-unknown-sgx"
url="https://github.com/fortanix/llvm-project/archive/${1}.tar.gz"
repo_name="llvm-project"

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

build_unwind() {
set -x
dir_name="${target}_temp"
rm -rf ${dir_name}
mkdir -p ${dir_name}
pushd ${dir_name}

# Clone Fortanix's fork of llvm-project which has a port of libunwind
fetch_github_commit_archive "$repo_name" "$url"
cd "${repo_name}/libunwind"

# Build libunwind
mkdir -p build
cd build
target_CC="CC_${target//-/_}"
target_CXX="CXX_${target//-/_}"
target_CFLAGS="CFLAGS_${target//-/_}"
target_CXXFLAGS="CXXFLAGS_${target//-/_}"
cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" \
-DCMAKE_C_COMPILER="${!target_CC}" -DCMAKE_CXX_COMPILER="${!target_CXX}" \
-DCMAKE_C_FLAGS="${!target_CFLAGS}" -DCMAKE_CXX_FLAGS="${!target_CXXFLAGS}" \
-DCMAKE_C_COMPILER_TARGET=$target -DCMAKE_CXX_COMPILER_TARGET=$target \
-DLLVM_ENABLE_WARNINGS=1 -DLIBUNWIND_ENABLE_WERROR=1 -DLIBUNWIND_ENABLE_PEDANTIC=0 \
-DLLVM_PATH=../../llvm/ ../
make unwind_static
install -D "lib/libunwind.a" "/${target}/lib/libunwind.a"

popd
rm -rf ${dir_name}

{ set +x; } 2>/dev/null
}

set -x
hide_output install_prereq
build_unwind
40 changes: 40 additions & 0 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,14 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
fn last(mut self) -> Option<(&'a K, &'a V)> {
self.next_back()
}

fn min(mut self) -> Option<(&'a K, &'a V)> {
self.next()
}

fn max(mut self) -> Option<(&'a K, &'a V)> {
self.next_back()
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand Down Expand Up @@ -1458,6 +1466,14 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
self.next_back()
}

fn min(mut self) -> Option<(&'a K, &'a mut V)> {
self.next()
}

fn max(mut self) -> Option<(&'a K, &'a mut V)> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1595,6 +1611,14 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
fn last(mut self) -> Option<&'a K> {
self.next_back()
}

fn min(mut self) -> Option<&'a K> {
self.next()
}

fn max(mut self) -> Option<&'a K> {
self.next_back()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1768,6 +1792,14 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
fn last(mut self) -> Option<(&'a K, &'a V)> {
self.next_back()
}

fn min(mut self) -> Option<(&'a K, &'a V)> {
self.next()
}

fn max(mut self) -> Option<(&'a K, &'a V)> {
self.next_back()
}
}

#[stable(feature = "map_values_mut", since = "1.10.0")]
Expand Down Expand Up @@ -1853,6 +1885,14 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
fn last(mut self) -> Option<(&'a K, &'a mut V)> {
self.next_back()
}

fn min(mut self) -> Option<(&'a K, &'a mut V)> {
self.next()
}

fn max(mut self) -> Option<(&'a K, &'a mut V)> {
self.next_back()
}
}

impl<'a, K, V> RangeMut<'a, K, V> {
Expand Down
35 changes: 35 additions & 0 deletions src/liballoc/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,12 +1291,22 @@ impl<'a, T> Iterator for Iter<'a, T> {
fn next(&mut self) -> Option<&'a T> {
self.iter.next()
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}

fn last(mut self) -> Option<&'a T> {
self.next_back()
}

fn min(mut self) -> Option<&'a T> {
self.next()
}

fn max(mut self) -> Option<&'a T> {
self.next_back()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
Expand All @@ -1321,6 +1331,7 @@ impl<T> Iterator for IntoIter<T> {
fn next(&mut self) -> Option<T> {
self.iter.next().map(|(k, _)| k)
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}
Expand Down Expand Up @@ -1359,6 +1370,14 @@ impl<'a, T> Iterator for Range<'a, T> {
fn last(mut self) -> Option<&'a T> {
self.next_back()
}

fn min(mut self) -> Option<&'a T> {
self.next()
}

fn max(mut self) -> Option<&'a T> {
self.next_back()
}
}

#[stable(feature = "btree_range", since = "1.17.0")]
Expand Down Expand Up @@ -1429,6 +1448,10 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
};
(self_len.saturating_sub(other_len), Some(self_len))
}

fn min(mut self) -> Option<&'a T> {
self.next()
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand Down Expand Up @@ -1460,6 +1483,10 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
// the number of elements to less than half the range of usize.
(0, Some(a_len + b_len))
}

fn min(mut self) -> Option<&'a T> {
self.next()
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand Down Expand Up @@ -1516,6 +1543,10 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
IntersectionInner::Answer(Some(_)) => (1, Some(1)),
}
}

fn min(mut self) -> Option<&'a T> {
self.next()
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand All @@ -1541,6 +1572,10 @@ impl<'a, T: Ord> Iterator for Union<'a, T> {
// No checked_add - see SymmetricDifference::size_hint.
(max(a_len, b_len), Some(a_len + b_len))
}

fn min(mut self) -> Option<&'a T> {
self.next()
}
}

#[stable(feature = "fused", since = "1.26.0")]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/raw_vec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fn allocator_param() {
//
// Instead, this just checks that the `RawVec` methods do at
// least go through the Allocator API when it reserves

// storage.

// A dumb allocator that consumes a fixed amount of fuel
Expand Down
35 changes: 35 additions & 0 deletions src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,41 @@ fn test_iter_mixed() {
test(size, map.into_iter());
}

#[test]
fn test_iter_min_max() {
let mut a = BTreeMap::new();
assert_eq!(a.iter().min(), None);
assert_eq!(a.iter().max(), None);
assert_eq!(a.iter_mut().min(), None);
assert_eq!(a.iter_mut().max(), None);
assert_eq!(a.range(..).min(), None);
assert_eq!(a.range(..).max(), None);
assert_eq!(a.range_mut(..).min(), None);
assert_eq!(a.range_mut(..).max(), None);
assert_eq!(a.keys().min(), None);
assert_eq!(a.keys().max(), None);
assert_eq!(a.values().min(), None);
assert_eq!(a.values().max(), None);
assert_eq!(a.values_mut().min(), None);
assert_eq!(a.values_mut().max(), None);
a.insert(1, 42);
a.insert(2, 24);
assert_eq!(a.iter().min(), Some((&1, &42)));
assert_eq!(a.iter().max(), Some((&2, &24)));
assert_eq!(a.iter_mut().min(), Some((&1, &mut 42)));
assert_eq!(a.iter_mut().max(), Some((&2, &mut 24)));
assert_eq!(a.range(..).min(), Some((&1, &42)));
assert_eq!(a.range(..).max(), Some((&2, &24)));
assert_eq!(a.range_mut(..).min(), Some((&1, &mut 42)));
assert_eq!(a.range_mut(..).max(), Some((&2, &mut 24)));
assert_eq!(a.keys().min(), Some(&1));
assert_eq!(a.keys().max(), Some(&2));
assert_eq!(a.values().min(), Some(&24));
assert_eq!(a.values().max(), Some(&42));
assert_eq!(a.values_mut().min(), Some(&mut 24));
assert_eq!(a.values_mut().max(), Some(&mut 42));
}

fn range_keys(map: &BTreeMap<i32, i32>, range: impl RangeBounds<i32>) -> Vec<i32> {
map.range(range)
.map(|(&k, &v)| {
Expand Down
31 changes: 31 additions & 0 deletions src/liballoc/tests/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ fn test_hash() {
assert_eq!(hash(&x), hash(&y));
}

#[test]
fn test_iter_min_max() {
let mut a = BTreeSet::new();
assert_eq!(a.iter().min(), None);
assert_eq!(a.iter().max(), None);
assert_eq!(a.range(..).min(), None);
assert_eq!(a.range(..).max(), None);
assert_eq!(a.difference(&BTreeSet::new()).min(), None);
assert_eq!(a.difference(&BTreeSet::new()).max(), None);
assert_eq!(a.intersection(&a).min(), None);
assert_eq!(a.intersection(&a).max(), None);
assert_eq!(a.symmetric_difference(&BTreeSet::new()).min(), None);
assert_eq!(a.symmetric_difference(&BTreeSet::new()).max(), None);
assert_eq!(a.union(&a).min(), None);
assert_eq!(a.union(&a).max(), None);
a.insert(1);
a.insert(2);
assert_eq!(a.iter().min(), Some(&1));
assert_eq!(a.iter().max(), Some(&2));
assert_eq!(a.range(..).min(), Some(&1));
assert_eq!(a.range(..).max(), Some(&2));
assert_eq!(a.difference(&BTreeSet::new()).min(), Some(&1));
assert_eq!(a.difference(&BTreeSet::new()).max(), Some(&2));
assert_eq!(a.intersection(&a).min(), Some(&1));
assert_eq!(a.intersection(&a).max(), Some(&2));
assert_eq!(a.symmetric_difference(&BTreeSet::new()).min(), Some(&1));
assert_eq!(a.symmetric_difference(&BTreeSet::new()).max(), Some(&2));
assert_eq!(a.union(&a).min(), Some(&1));
assert_eq!(a.union(&a).max(), Some(&2));
}

fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
where
F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool,
Expand Down
Loading