Skip to content

Commit c82f132

Browse files
committed
Auto merge of #40911 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #40780, #40814, #40816, #40832, #40901, #40907 - Failed merges:
2 parents e1cec5d + fb6ced4 commit c82f132

File tree

20 files changed

+371
-45
lines changed

20 files changed

+371
-45
lines changed

.travis.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@ before_script:
133133
script:
134134
- >
135135
if [ "$ALLOW_PR" = "" ] && [ "$TRAVIS_BRANCH" != "auto" ]; then
136-
echo skipping, not a full build;
137-
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
138-
travis_retry stamp sh -c 'git submodule deinit -f . && git submodule update --init' &&
139-
stamp src/ci/run.sh;
136+
echo skipping, not a full build
140137
else
141-
travis_retry stamp sh -c 'git submodule deinit -f . && git submodule update --init' &&
142-
stamp src/ci/docker/run.sh $IMAGE;
138+
stamp src/ci/init_repo.sh . "$HOME/rustsrc" &&
139+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
140+
stamp src/ci/run.sh;
141+
else
142+
stamp src/ci/docker/run.sh $IMAGE;
143+
fi
143144
fi
144145
145146
after_success:
@@ -169,20 +170,29 @@ after_failure:
169170
- dmesg | grep -i kill
170171

171172
# Save tagged docker images we created and load them if they're available
173+
# Travis saves caches whether the build failed or not, nuke rustsrc if
174+
# the failure was while updating it (as it may be in an bad state)
175+
# https://github.com/travis-ci/travis-ci/issues/4472
172176
before_cache:
173177
- docker history -q rust-ci |
174178
grep -v missing |
175179
xargs docker save |
176180
gzip > $HOME/docker/rust-ci.tar.gz
181+
- if [ ! -f $HOME/rustsrc/cache_valid1 ]; then
182+
echo "WARNING rustsrc cache was invalid when saving";
183+
rm -rf $HOME/rustsrc && mkdir $HOME/rustsrc;
184+
fi
177185
before_install:
178186
- zcat $HOME/docker/rust-ci.tar.gz | docker load || true
187+
- mkdir -p $HOME/rustsrc
179188

180189
notifications:
181190
email: false
182191

183192
cache:
184193
directories:
185194
- $HOME/docker
195+
- $HOME/rustsrc
186196

187197
before_deploy:
188198
- mkdir -p deploy/$TRAVIS_COMMIT

appveyor.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ install:
141141
- set SCCACHE_ERROR_LOG=%CD%/sccache.log
142142

143143
test_script:
144-
- appveyor-retry sh -c 'git submodule deinit -f . && git submodule update --init'
144+
- mkdir C:\cache\rustsrc
145+
- sh src/ci/init_repo.sh . /c/cache/rustsrc
145146
- set SRC=.
146147
- set NO_CCACHE=1
147148
- sh src/ci/run.sh
@@ -150,6 +151,7 @@ on_failure:
150151
- cat %CD%/sccache.log
151152

152153
cache:
154+
- C:\cache\rustsrc
153155
- "build/i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
154156
- "build/x86_64-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"
155157
- "i686-pc-windows-msvc/llvm -> src/rustllvm/llvm-rebuild-trigger"

src/ci/docker/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ exec docker \
5757
--env DEPLOY_ALT=$DEPLOY_ALT \
5858
--env LOCAL_USER_ID=`id -u` \
5959
--volume "$HOME/.cargo:/cargo" \
60+
--volume "$HOME/rustsrc:$HOME/rustsrc" \
6061
--privileged \
6162
--rm \
6263
rust-ci \

src/ci/init_repo.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -o errexit
13+
set -o pipefail
14+
set -o nounset
15+
16+
set -o xtrace
17+
18+
ci_dir=$(cd $(dirname $0) && pwd)
19+
. "$ci_dir/shared.sh"
20+
21+
REPO_DIR="$1"
22+
CACHE_DIR="$2"
23+
24+
cache_src_dir="$CACHE_DIR/src"
25+
# If the layout of the cache directory changes, bump the number here
26+
# (and anywhere else this file is referenced) so the cache is wiped
27+
cache_valid_file="$CACHE_DIR/cache_valid1"
28+
29+
if [ ! -d "$REPO_DIR" -o ! -d "$REPO_DIR/.git" ]; then
30+
echo "Error: $REPO_DIR does not exist or is not a git repo"
31+
exit 1
32+
fi
33+
cd $REPO_DIR
34+
if [ ! -d "$CACHE_DIR" ]; then
35+
echo "Error: $CACHE_DIR does not exist or is not an absolute path"
36+
exit 1
37+
fi
38+
39+
# Wipe the cache if it's not valid, or mark it as invalid while we update it
40+
if [ ! -f "$cache_valid_file" ]; then
41+
rm -rf "$CACHE_DIR" && mkdir "$CACHE_DIR"
42+
else
43+
rm "$cache_valid_file"
44+
fi
45+
46+
# Update the cache (a pristine copy of the rust source master)
47+
if [ ! -d "$cache_src_dir/.git" ]; then
48+
retry sh -c "rm -rf $cache_src_dir && mkdir -p $cache_src_dir && \
49+
git clone https://github.com/rust-lang/rust.git $cache_src_dir"
50+
fi
51+
retry sh -c "cd $cache_src_dir && git reset --hard && git pull"
52+
retry sh -c "cd $cache_src_dir && \
53+
git submodule deinit -f . && git submodule sync && git submodule update --init"
54+
55+
# Cache was updated without errors, mark it as valid
56+
touch "$cache_valid_file"
57+
58+
# Update the submodules of the repo we're in, using the pristine repo as
59+
# a cache for any object files
60+
# No, `git submodule foreach` won't work:
61+
# http://stackoverflow.com/questions/12641469/list-submodules-in-a-git-repository
62+
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
63+
for module in $modules; do
64+
if [ ! -d "$cache_src_dir/$module" ]; then
65+
echo "WARNING: $module not found in pristine repo"
66+
retry sh -c "git submodule deinit -f $module && git submodule update --init $module"
67+
continue
68+
fi
69+
retry sh -c "git submodule deinit -f $module && \
70+
git submodule update --init --reference $cache_src_dir/$module $module"
71+
done

src/ci/shared.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/false
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -9,13 +9,16 @@
99
# option. This file may not be copied, modified, or distributed
1010
# except according to those terms.
1111

12+
# This file is intended to be sourced with `. shared.sh` or
13+
# `source shared.sh`, hence the invalid shebang and not being
14+
# marked as an executable file in git.
15+
1216
# See http://unix.stackexchange.com/questions/82598
1317
function retry {
18+
echo "Attempting with retry:" "$@"
1419
local n=1
1520
local max=5
16-
local delay=15
1721
while true; do
18-
echo "Attempting:" "$@"
1922
"$@" && break || {
2023
if [[ $n -lt $max ]]; then
2124
((n++))

src/doc/rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
% The Rust Reference Manual
22

3-
The manual has moved, and is now called [the reference](reference.html).
3+
The manual has moved, and is now called [the reference](reference/index.html).

src/libcore/slice/sort.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ fn break_patterns<T>(v: &mut [T]) {
527527
// we first take it modulo a power of two, and then decrease by `len` until it fits
528528
// into the range `[0, len - 1]`.
529529
let mut other = gen_usize() & (modulus - 1);
530-
while other >= len {
530+
531+
// `other` is guaranteed to be less than `2 * len`.
532+
if other >= len {
531533
other -= len;
532534
}
533535

src/libcore/str/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ unsafe fn from_raw_parts_mut<'a>(p: *mut u8, len: usize) -> &'a mut str {
327327
///
328328
/// This function is unsafe because it does not check that the bytes passed to
329329
/// it are valid UTF-8. If this constraint is violated, undefined behavior
330-
/// results, as the rest of Rust assumes that `&str`s are valid UTF-8.
330+
/// results, as the rest of Rust assumes that [`&str`]s are valid UTF-8.
331+
///
332+
/// [`&str`]: ../../std/primitive.str.html
331333
///
332334
/// # Examples
333335
///

src/librustc_typeck/check/method/suggest.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
197197
let field_ty = field.ty(tcx, substs);
198198

199199
if self.is_fn_ty(&field_ty, span) {
200-
err.span_note(span,
201-
&format!("use `({0}.{1})(...)` if you \
202-
meant to call the function \
203-
stored in the `{1}` field",
204-
expr_string,
205-
item_name));
200+
err.help(&format!("use `({0}.{1})(...)` if you \
201+
meant to call the function \
202+
stored in the `{1}` field",
203+
expr_string,
204+
item_name));
206205
} else {
207-
err.span_note(span,
208-
&format!("did you mean to write `{0}.{1}`?",
209-
expr_string,
210-
item_name));
206+
err.help(&format!("did you mean to write `{0}.{1}` \
207+
instead of `{0}.{1}(...)`?",
208+
expr_string,
209+
item_name));
211210
}
211+
err.span_label(span, &"field, not a method");
212212
break;
213213
}
214214
}

src/librustdoc/visit_ast.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use syntax_pos::Span;
2121

2222
use rustc::hir::map as hir_map;
2323
use rustc::hir::def::Def;
24-
use rustc::hir::def_id::LOCAL_CRATE;
24+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
2525
use rustc::middle::cstore::LoadedMacro;
2626
use rustc::middle::privacy::AccessLevel;
2727
use rustc::util::nodemap::FxHashSet;
@@ -48,6 +48,7 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> {
4848
inlining: bool,
4949
/// Is the current module and all of its parents public?
5050
inside_public_path: bool,
51+
reexported_macros: FxHashSet<DefId>,
5152
}
5253

5354
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
@@ -62,6 +63,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
6263
view_item_stack: stack,
6364
inlining: false,
6465
inside_public_path: true,
66+
reexported_macros: FxHashSet(),
6567
}
6668
}
6769

@@ -201,9 +203,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
201203
if let Some(exports) = self.cx.tcx.export_map.get(&id) {
202204
for export in exports {
203205
if let Def::Macro(def_id, ..) = export.def {
204-
if def_id.krate == LOCAL_CRATE {
206+
if def_id.krate == LOCAL_CRATE || self.reexported_macros.contains(&def_id) {
205207
continue // These are `krate.exported_macros`, handled in `self.visit()`.
206208
}
209+
207210
let imported_from = self.cx.sess().cstore.original_crate_name(def_id.krate);
208211
let def = match self.cx.sess().cstore.load_macro(def_id, self.cx.sess()) {
209212
LoadedMacro::MacroDef(macro_def) => macro_def,
@@ -217,6 +220,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
217220
} else {
218221
unreachable!()
219222
};
223+
220224
om.macros.push(Macro {
221225
def_id: def_id,
222226
attrs: def.attrs.clone().into(),
@@ -263,6 +267,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
263267
false
264268
}
265269

270+
debug!("maybe_inline_local def: {:?}", def);
271+
266272
let tcx = self.cx.tcx;
267273
if def == Def::Err {
268274
return false;
@@ -274,6 +280,17 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
274280
let is_no_inline = use_attrs.lists("doc").has_word("no_inline") ||
275281
use_attrs.lists("doc").has_word("hidden");
276282

283+
// Memoize the non-inlined `pub use`'d macros so we don't push an extra
284+
// declaration in `visit_mod_contents()`
285+
if !def_did.is_local() {
286+
if let Def::Macro(did, _) = def {
287+
if please_inline { return true }
288+
debug!("memoizing non-inlined macro export: {:?}", def);
289+
self.reexported_macros.insert(did);
290+
return false;
291+
}
292+
}
293+
277294
// For cross-crate impl inlining we need to know whether items are
278295
// reachable in documentation - a previously nonreachable item can be
279296
// made reachable by cross-crate inlining which we're checking here.
@@ -294,6 +311,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
294311
},
295312
_ => {},
296313
}
314+
297315
return false
298316
}
299317

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
#![crate_name="macros"]
11+
12+
#[macro_export]
13+
macro_rules! foo {
14+
() => {};
15+
}
16+
17+
#[macro_export]
18+
macro_rules! bar {
19+
() => {};
20+
}
21+
22+
#[macro_export]
23+
macro_rules! baz {
24+
() => {};
25+
}
26+
27+
#[macro_export]
28+
macro_rules! quux {
29+
() => {};
30+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:pub-use-extern-macros.rs
12+
13+
#![feature(use_extern_macros, macro_reexport)]
14+
15+
// @has pub_use_extern_macros/macro.foo.html
16+
// @!has pub_use_extern_macros/index.html 'pub use macros::foo;'
17+
#[macro_reexport(foo)] extern crate macros;
18+
19+
// @has pub_use_extern_macros/index.html 'pub use macros::bar;'
20+
// @!has pub_use_extern_macros/macro.bar.html
21+
pub use macros::bar;
22+
23+
// @has pub_use_extern_macros/macro.baz.html
24+
// @!has pub_use_extern_macros/index.html 'pub use macros::baz;'
25+
#[doc(inline)]
26+
pub use macros::baz;
27+
28+
// @!has pub_use_extern_macros/macro.quux.html
29+
// @!has pub_use_extern_macros/index.html 'pub use macros::quux;'
30+
#[doc(hidden)]
31+
pub use macros::quux;

src/test/compile-fail/issue-18343.rs renamed to src/test/ui/suggestions/confuse-field-and-method/issue-18343.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ struct Obj<F> where F: FnMut() -> u32 {
1414

1515
fn main() {
1616
let o = Obj { closure: || 42 };
17-
o.closure(); //~ ERROR no method named `closure` found
18-
//~^ NOTE use `(o.closure)(...)` if you meant to call the function stored in the `closure` field
17+
o.closure();
18+
//~^ ERROR no method named `closure` found
19+
//~| HELP use `(o.closure)(...)` if you meant to call the function stored in the `closure` field
20+
//~| NOTE field, not a method
1921
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: no method named `closure` found for type `Obj<[closure@$DIR/issue-18343.rs:16:28: 16:33]>` in the current scope
2+
--> $DIR/issue-18343.rs:17:7
3+
|
4+
17 | o.closure();
5+
| ^^^^^^^ field, not a method
6+
|
7+
= help: use `(o.closure)(...)` if you meant to call the function stored in the `closure` field
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)