Auto merge of #63790 - Centril:rollup-m4ax3r9, r=Centril

Rollup of 6 pull requests

Successful merges:

 - #61236 (take into account the system theme)
 - #63717 (Fix nested eager expansions in arguments of `format_args`)
 - #63747 (update Miri)
 - #63772 (ci: move libc mirrors to the rust-lang-ci-mirrors bucket)
 - #63780 (Improve diagnostics: break/continue in wrong context)
 - #63781 (Run Clippy without json-rendered flag)

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-08-21 17:09:25 +00:00
commit e44fdf9792
29 changed files with 194 additions and 102 deletions

View File

@ -875,8 +875,7 @@ impl<'a> Builder<'a> {
}
if cmd == "clippy" {
extra_args.push_str("-Zforce-unstable-if-unmarked -Zunstable-options \
--json-rendered=termcolor");
extra_args.push_str("-Zforce-unstable-if-unmarked");
}
if !extra_args.is_empty() {

View File

@ -5,7 +5,7 @@ mkdir /usr/local/mipsel-linux-musl
# Note that this originally came from:
# https://downloads.openwrt.org/snapshots/trunk/malta/generic/
# OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2
URL="https://rust-lang-ci2.s3.amazonaws.com/libc"
URL="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc"
FILE="OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2"
curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mipsel-linux-musl --strip-components=2

View File

@ -131,7 +131,7 @@ be taken. Erroneous code example:
```compile_fail,E0268
fn some_func() {
break; // error: `break` outside of loop
break; // error: `break` outside of a loop
}
```

View File

@ -16,8 +16,8 @@ use errors::Applicability;
enum Context {
Normal,
Loop(hir::LoopSource),
Closure,
AsyncClosure,
Closure(Span),
AsyncClosure(Span),
LabeledBlock,
AnonConst,
}
@ -58,11 +58,11 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
hir::ExprKind::Loop(ref b, _, source) => {
self.with_context(Loop(source), |v| v.visit_block(&b));
}
hir::ExprKind::Closure(_, ref function_decl, b, _, movability) => {
hir::ExprKind::Closure(_, ref function_decl, b, span, movability) => {
let cx = if let Some(GeneratorMovability::Static) = movability {
AsyncClosure
AsyncClosure(span)
} else {
Closure
Closure(span)
};
self.visit_fn_decl(&function_decl);
self.with_context(cx, |v| v.visit_nested_body(b));
@ -170,23 +170,22 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
}
fn require_break_cx(&self, name: &str, span: Span) {
let err_inside_of = |article, ty, closure_span| {
struct_span_err!(self.sess, span, E0267, "`{}` inside of {} {}", name, article, ty)
.span_label(span, format!("cannot `{}` inside of {} {}", name, article, ty))
.span_label(closure_span, &format!("enclosing {}", ty))
.emit();
};
match self.cx {
LabeledBlock | Loop(_) => {}
Closure => {
struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name)
.span_label(span, "cannot break inside of a closure")
.emit();
}
AsyncClosure => {
struct_span_err!(self.sess, span, E0267, "`{}` inside of an async block", name)
.span_label(span, "cannot break inside of an async block")
.emit();
}
LabeledBlock | Loop(_) => {},
Closure(closure_span) => err_inside_of("a", "closure", closure_span),
AsyncClosure(closure_span) => err_inside_of("an", "`async` block", closure_span),
Normal | AnonConst => {
struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name)
.span_label(span, "cannot break outside of a loop")
struct_span_err!(self.sess, span, E0268, "`{}` outside of a loop", name)
.span_label(span, format!("cannot `{}` outside of a loop", name))
.emit();
}
},
}
}

View File

@ -140,9 +140,23 @@ impl<'a> base::Resolver for Resolver<'a> {
ImportResolver { r: self }.resolve_imports()
}
fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: ExpnId, force: bool)
-> Result<Option<Lrc<SyntaxExtension>>, Indeterminate> {
let parent_scope = self.invocation_parent_scopes[&invoc_id];
fn resolve_macro_invocation(
&mut self, invoc: &Invocation, eager_expansion_root: ExpnId, force: bool
) -> Result<Option<Lrc<SyntaxExtension>>, Indeterminate> {
let invoc_id = invoc.expansion_data.id;
let parent_scope = match self.invocation_parent_scopes.get(&invoc_id) {
Some(parent_scope) => *parent_scope,
None => {
// If there's no entry in the table, then we are resolving an eagerly expanded
// macro, which should inherit its parent scope from its eager expansion root -
// the macro that requested this eager expansion.
let parent_scope = *self.invocation_parent_scopes.get(&eager_expansion_root)
.expect("non-eager expansion without a parent scope");
self.invocation_parent_scopes.insert(invoc_id, parent_scope);
parent_scope
}
};
let (path, kind, derives, after_derive) = match invoc.kind {
InvocationKind::Attr { ref attr, ref derives, after_derive, .. } =>
(&attr.path, MacroKind::Attr, self.arenas.alloc_ast_paths(derives), after_derive),
@ -161,7 +175,7 @@ impl<'a> base::Resolver for Resolver<'a> {
match self.resolve_macro_path(path, Some(MacroKind::Derive),
&parent_scope, true, force) {
Ok((Some(ref ext), _)) if ext.is_derive_copy => {
self.add_derives(invoc.expansion_data.id, SpecialDerives::COPY);
self.add_derives(invoc_id, SpecialDerives::COPY);
return Ok(None);
}
Err(Determinacy::Undetermined) => result = Err(Indeterminate),
@ -178,19 +192,15 @@ impl<'a> base::Resolver for Resolver<'a> {
let (ext, res) = self.smart_resolve_macro_path(path, kind, parent_scope, force)?;
let span = invoc.span();
invoc.expansion_data.id.set_expn_data(
ext.expn_data(parent_scope.expansion, span, fast_print_path(path))
);
invoc_id.set_expn_data(ext.expn_data(parent_scope.expansion, span, fast_print_path(path)));
if let Res::Def(_, def_id) = res {
if after_derive {
self.session.span_err(span, "macro attributes must be placed before `#[derive]`");
}
self.macro_defs.insert(invoc.expansion_data.id, def_id);
let normal_module_def_id =
self.macro_def_scope(invoc.expansion_data.id).normal_ancestor_id;
self.definitions.add_parent_module_of_macro_def(invoc.expansion_data.id,
normal_module_def_id);
self.macro_defs.insert(invoc_id, def_id);
let normal_module_def_id = self.macro_def_scope(invoc_id).normal_ancestor_id;
self.definitions.add_parent_module_of_macro_def(invoc_id, normal_module_def_id);
}
Ok(Some(ext))

View File

@ -914,7 +914,7 @@ themePicker.onblur = handleThemeButtonsBlur;
var but = document.createElement('button');
but.innerHTML = item;
but.onclick = function(el) {{
switchTheme(currentTheme, mainTheme, item);
switchTheme(currentTheme, mainTheme, item, true);
}};
but.onblur = handleThemeButtonsBlur;
themes.appendChild(but);

View File

@ -54,6 +54,21 @@
box-sizing: border-box;
}
/* This part handles the "default" theme being used depending on the system one. */
html {
content: "";
}
@media (prefers-color-scheme: light) {
html {
content: "light";
}
}
@media (prefers-color-scheme: dark) {
html {
content: "dark";
}
}
/* General structure and fonts */
body {

View File

@ -86,7 +86,7 @@ function getCurrentValue(name) {
return null;
}
function switchTheme(styleElem, mainStyleElem, newTheme) {
function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
var fullBasicCss = "rustdoc" + resourcesSuffix + ".css";
var fullNewTheme = newTheme + resourcesSuffix + ".css";
var newHref = mainStyleElem.href.replace(fullBasicCss, fullNewTheme);
@ -109,8 +109,18 @@ function switchTheme(styleElem, mainStyleElem, newTheme) {
});
if (found === true) {
styleElem.href = newHref;
updateLocalStorage("rustdoc-theme", newTheme);
// If this new value comes from a system setting or from the previously saved theme, no
// need to save it.
if (saveTheme === true) {
updateLocalStorage("rustdoc-theme", newTheme);
}
}
}
switchTheme(currentTheme, mainTheme, getCurrentValue("rustdoc-theme") || "light");
function getSystemValue() {
return getComputedStyle(document.documentElement).getPropertyValue('content');
}
switchTheme(currentTheme, mainTheme,
getCurrentValue("rustdoc-theme") || getSystemValue() || "light",
false);

View File

@ -682,8 +682,9 @@ pub trait Resolver {
fn resolve_imports(&mut self);
fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: ExpnId, force: bool)
-> Result<Option<Lrc<SyntaxExtension>>, Indeterminate>;
fn resolve_macro_invocation(
&mut self, invoc: &Invocation, eager_expansion_root: ExpnId, force: bool
) -> Result<Option<Lrc<SyntaxExtension>>, Indeterminate>;
fn check_unused_macros(&self);
@ -908,12 +909,9 @@ impl<'a> ExtCtxt<'a> {
/// compilation on error, merely emits a non-fatal error and returns `None`.
pub fn expr_to_spanned_string<'a>(
cx: &'a mut ExtCtxt<'_>,
mut expr: P<ast::Expr>,
expr: P<ast::Expr>,
err_msg: &str,
) -> Result<(Symbol, ast::StrStyle, Span), Option<DiagnosticBuilder<'a>>> {
// Update `expr.span`'s ctxt now in case expr is an `include!` macro invocation.
expr.span = expr.span.apply_mark(cx.current_expansion.id);
// Perform eager expansion on the expression.
// We want to be able to handle e.g., `concat!("foo", "bar")`.
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();

View File

@ -305,9 +305,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
continue
};
let scope =
let eager_expansion_root =
if self.monotonic { invoc.expansion_data.id } else { orig_expansion_data.id };
let ext = match self.cx.resolver.resolve_macro_invocation(&invoc, scope, force) {
let ext = match self.cx.resolver.resolve_macro_invocation(
&invoc, eager_expansion_root, force
) {
Ok(ext) => ext,
Err(Indeterminate) => {
undetermined_invocations.push(invoc);
@ -318,7 +320,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
progress = true;
let ExpansionData { depth, id: expn_id, .. } = invoc.expansion_data;
self.cx.current_expansion = invoc.expansion_data.clone();
self.cx.current_expansion.id = scope;
// FIXME(jseyfried): Refactor out the following logic
let (expanded_fragment, new_invocations) = if let Some(ext) = ext {

View File

@ -1,11 +1,11 @@
fn main() {
loop {
|_: [_; break]| {} //~ ERROR: `break` outside of loop
|_: [_; break]| {} //~ ERROR: `break` outside of a loop
//~^ ERROR mismatched types
}
loop {
|_: [_; continue]| {} //~ ERROR: `continue` outside of loop
|_: [_; continue]| {} //~ ERROR: `continue` outside of a loop
//~^ ERROR mismatched types
}
}

View File

@ -1,14 +1,14 @@
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/array-break-length.rs:3:17
|
LL | |_: [_; break]| {}
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error[E0268]: `continue` outside of loop
error[E0268]: `continue` outside of a loop
--> $DIR/array-break-length.rs:8:17
|
LL | |_: [_; continue]| {}
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `continue` outside of a loop
error[E0308]: mismatched types
--> $DIR/array-break-length.rs:3:9

View File

@ -30,14 +30,14 @@ async fn return_targets_async_block_not_async_fn() -> u8 {
fn no_break_in_async_block() {
async {
break 0u8; //~ ERROR `break` inside of an async block
break 0u8; //~ ERROR `break` inside of an `async` block
};
}
fn no_break_in_async_block_even_with_outer_loop() {
loop {
async {
break 0u8; //~ ERROR `break` inside of an async block
break 0u8; //~ ERROR `break` inside of an `async` block
};
}
}

View File

@ -1,14 +1,22 @@
error[E0267]: `break` inside of an async block
error[E0267]: `break` inside of an `async` block
--> $DIR/async-block-control-flow-static-semantics.rs:33:9
|
LL | break 0u8;
| ^^^^^^^^^ cannot break inside of an async block
LL | async {
| ___________-
LL | | break 0u8;
| | ^^^^^^^^^ cannot `break` inside of an `async` block
LL | | };
| |_____- enclosing `async` block
error[E0267]: `break` inside of an async block
error[E0267]: `break` inside of an `async` block
--> $DIR/async-block-control-flow-static-semantics.rs:40:13
|
LL | break 0u8;
| ^^^^^^^^^ cannot break inside of an async block
LL | async {
| _______________-
LL | | break 0u8;
| | ^^^^^^^^^ cannot `break` inside of an `async` block
LL | | };
| |_________- enclosing `async` block
error[E0308]: mismatched types
--> $DIR/async-block-control-flow-static-semantics.rs:13:43

View File

@ -7,8 +7,8 @@ fn cond() -> bool { true }
fn foo<F>(_: F) where F: FnOnce() {}
fn main() {
let pth = break; //~ ERROR: `break` outside of loop
if cond() { continue } //~ ERROR: `continue` outside of loop
let pth = break; //~ ERROR: `break` outside of a loop
if cond() { continue } //~ ERROR: `continue` outside of a loop
while cond() {
if cond() { break }
@ -21,5 +21,5 @@ fn main() {
let rs: Foo = Foo{t: pth};
let unconstrained = break; //~ ERROR: `break` outside of loop
let unconstrained = break; //~ ERROR: `break` outside of a loop
}

View File

@ -1,32 +1,37 @@
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/break-outside-loop.rs:10:15
|
LL | let pth = break;
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error[E0268]: `continue` outside of loop
error[E0268]: `continue` outside of a loop
--> $DIR/break-outside-loop.rs:11:17
|
LL | if cond() { continue }
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `continue` outside of a loop
error[E0267]: `break` inside of a closure
--> $DIR/break-outside-loop.rs:17:25
|
LL | foo(|| {
| -- enclosing closure
LL | if cond() { break }
| ^^^^^ cannot break inside of a closure
| ^^^^^ cannot `break` inside of a closure
error[E0267]: `continue` inside of a closure
--> $DIR/break-outside-loop.rs:18:25
|
LL | foo(|| {
| -- enclosing closure
LL | if cond() { break }
LL | if cond() { continue }
| ^^^^^^^^ cannot break inside of a closure
| ^^^^^^^^ cannot `continue` inside of a closure
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/break-outside-loop.rs:24:25
|
LL | let unconstrained = break;
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error: aborting due to 5 previous errors

View File

@ -1,9 +1,9 @@
fn main() {
|_: [_; continue]| {}; //~ ERROR: `continue` outside of loop
|_: [_; continue]| {}; //~ ERROR: `continue` outside of a loop
while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of loop
while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of a loop
//~^ ERROR mismatched types
while |_: [_; break]| {} {} //~ ERROR: `break` outside of loop
while |_: [_; break]| {} {} //~ ERROR: `break` outside of a loop
//~^ ERROR mismatched types
}

View File

@ -1,20 +1,20 @@
error[E0268]: `continue` outside of loop
error[E0268]: `continue` outside of a loop
--> $DIR/closure-array-break-length.rs:2:13
|
LL | |_: [_; continue]| {};
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `continue` outside of a loop
error[E0268]: `continue` outside of loop
error[E0268]: `continue` outside of a loop
--> $DIR/closure-array-break-length.rs:4:19
|
LL | while |_: [_; continue]| {} {}
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `continue` outside of a loop
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/closure-array-break-length.rs:7:19
|
LL | while |_: [_; break]| {} {}
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error[E0308]: mismatched types
--> $DIR/closure-array-break-length.rs:4:11

View File

@ -2,7 +2,9 @@ error[E0267]: `break` inside of a closure
--> $DIR/E0267.rs:2:18
|
LL | let w = || { break; };
| ^^^^^ cannot break inside of a closure
| -- ^^^^^ cannot `break` inside of a closure
| |
| enclosing closure
error: aborting due to previous error

View File

@ -1,8 +1,8 @@
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/E0268.rs:2:5
|
LL | break;
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error: aborting due to previous error

View File

@ -0,0 +1,22 @@
// Regression test for the issue #63460.
// check-pass
#[macro_export]
macro_rules! separator {
() => { "/" };
}
#[macro_export]
macro_rules! concat_separator {
( $e:literal, $($other:literal),+ ) => {
concat!($e, $crate::separator!(), $crate::concat_separator!($($other),+))
};
( $e:literal ) => {
$e
}
}
fn main() {
println!("{}", concat_separator!(2, 3, 4))
}

View File

@ -0,0 +1,20 @@
// Opaque macro can eagerly expand its input without breaking its resolution.
// Regression test for issue #63685.
// check-pass
macro_rules! foo {
() => {
"foo"
};
}
macro_rules! bar {
() => {
foo!()
};
}
fn main() {
format_args!(bar!());
}

View File

@ -1,8 +1,8 @@
// Make sure that a continue span actually contains the keyword.
fn main() {
continue //~ ERROR `continue` outside of loop
continue //~ ERROR `continue` outside of a loop
;
break //~ ERROR `break` outside of loop
break //~ ERROR `break` outside of a loop
;
}

View File

@ -1,14 +1,14 @@
error[E0268]: `continue` outside of loop
error[E0268]: `continue` outside of a loop
--> $DIR/issue-28105.rs:4:5
|
LL | continue
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `continue` outside of a loop
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/issue-28105.rs:6:5
|
LL | break
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error: aborting due to 2 previous errors

View File

@ -1,14 +1,14 @@
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/issue-43162.rs:3:5
|
LL | break true;
| ^^^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^^^ cannot `break` outside of a loop
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/issue-43162.rs:7:5
|
LL | break {};
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `break` outside of a loop
error[E0308]: mismatched types
--> $DIR/issue-43162.rs:1:13

View File

@ -4,17 +4,17 @@ error[E0426]: use of undeclared label `'L`
LL | |bool: [u8; break 'L]| 0;
| ^^ undeclared label `'L`
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/issue-50576.rs:2:17
|
LL | |bool: [u8; break 'L]| 0;
| ^^^^^^^^ cannot break outside of a loop
| ^^^^^^^^ cannot `break` outside of a loop
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/issue-50576.rs:5:16
|
LL | Vec::<[u8; break]>::new();
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error: aborting due to 3 previous errors

View File

@ -1,8 +1,8 @@
error[E0268]: `break` outside of loop
error[E0268]: `break` outside of a loop
--> $DIR/issue-50581.rs:2:14
|
LL | |_: [u8; break]| ();
| ^^^^^ cannot break outside of a loop
| ^^^^^ cannot `break` outside of a loop
error: aborting due to previous error

View File

@ -8,6 +8,9 @@ LL | |
LL | | ""
LL | | }
| |_____^
...
LL | format_args!(hang!());
| ------- in this macro invocation
help: you might be missing a string literal to format with
|
LL | format_args!("{}", hang!());

@ -1 +1 @@
Subproject commit 4f6f264c305ea30f1de90ad0c2f341e84d972b2e
Subproject commit d77fe6c63ca4c50b207a1161def90c9e57368d5b