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

[beta] Rollup backports #64097

Merged
merged 11 commits into from
Sep 3, 2019
Merged
2 changes: 1 addition & 1 deletion src/ci/docker/dist-various-1/install-mipsel-musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,13 @@ pub fn type_metadata(
}
ty::Closure(def_id, substs) => {
let upvar_tys : Vec<_> = substs.upvar_tys(def_id, cx.tcx).collect();
let containing_scope = get_namespace_for_item(cx, def_id);
prepare_tuple_metadata(cx,
t,
&upvar_tys,
unique_type_id,
usage_site_span).finalize(cx)
usage_site_span,
Some(containing_scope)).finalize(cx)
}
ty::Generator(def_id, substs, _) => {
let upvar_tys : Vec<_> = substs.prefix_tys(def_id, cx.tcx).map(|t| {
Expand Down Expand Up @@ -728,7 +730,8 @@ pub fn type_metadata(
t,
&tys,
unique_type_id,
usage_site_span).finalize(cx)
usage_site_span,
NO_SCOPE_METADATA).finalize(cx)
}
_ => {
bug!("debuginfo: unexpected type in type_metadata: {:?}", t)
Expand Down Expand Up @@ -1205,14 +1208,15 @@ fn prepare_tuple_metadata(
component_types: &[Ty<'tcx>],
unique_type_id: UniqueTypeId,
span: Span,
containing_scope: Option<&'ll DIScope>,
) -> RecursiveTypeDescription<'ll, 'tcx> {
let tuple_name = compute_debuginfo_type_name(cx.tcx, tuple_type, false);

let struct_stub = create_struct_stub(cx,
tuple_type,
&tuple_name[..],
unique_type_id,
NO_SCOPE_METADATA);
containing_scope);

create_and_register_recursive_type_forward_declaration(
cx,
Expand Down
14 changes: 10 additions & 4 deletions src/librustc_codegen_ssa/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,17 @@ pub fn push_debuginfo_type_name<'tcx>(
// processing
visited.remove(t);
},
ty::Closure(..) => {
output.push_str("closure");
ty::Closure(def_id, ..) => {
output.push_str(&format!(
"closure-{}",
tcx.def_key(def_id).disambiguated_data.disambiguator
));
}
ty::Generator(..) => {
output.push_str("generator");
ty::Generator(def_id, ..) => {
output.push_str(&format!(
"generator-{}",
tcx.def_key(def_id).disambiguated_data.disambiguator
));
}
ty::Error |
ty::Infer(_) |
Expand Down
16 changes: 9 additions & 7 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ impl<'a> base::Resolver for Resolver<'a> {

fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: ExpnId, force: bool)
-> Result<Option<Lrc<SyntaxExtension>>, Indeterminate> {
if !self.invocations.contains_key(&invoc.expansion_data.id) {
self.invocations.insert(invoc.expansion_data.id, self.invocations[&invoc_id]);
}
let invoc_id = invoc.expansion_data.id;
let (path, kind, derives_in_scope, after_derive) = match invoc.kind {
InvocationKind::Attr { ref attr, ref derives, after_derive, .. } =>
(&attr.path, MacroKind::Attr, derives.clone(), after_derive),
Expand All @@ -201,7 +205,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),
Expand All @@ -217,17 +221,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_info(ext.expn_info(span, fast_print_path(path)));
invoc_id.set_expn_info(ext.expn_info(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))
Expand Down
3 changes: 0 additions & 3 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,6 @@ pub fn expr_to_spanned_string<'a>(
mut expr: P<ast::Expr>,
err_msg: &str,
) -> Result<Spanned<(Symbol, ast::StrStyle)>, 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);

// we want to be able to handle e.g., `concat!("foo", "bar")`
cx.expander().visit_expr(&mut expr);
Err(match expr.node {
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,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 {
Expand Down
6 changes: 3 additions & 3 deletions src/stage0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
# `0.x.0` for Cargo where they were released on `date`.

date: 2019-08-13
date: 2019-08-15
rustc: 1.37.0
cargo: 0.38.0

Expand All @@ -25,7 +25,7 @@ cargo: 0.38.0
#
# This means that there's a small window of time (a few days) where artifacts
# are downloaded from dev-static.rust-lang.org instead of static.rust-lang.org.
# In order to ease this transition we have an extra key which is in the
# In order to ease this transition we have an extra key which is in the
# configuration file below. When uncommented this will instruct the bootstrap.py
# script to download from dev-static.rust-lang.org.
#
Expand All @@ -34,4 +34,4 @@ cargo: 0.38.0
# looking at a beta source tarball and it's uncommented we'll shortly comment it
# out.

dev: 1
#dev: 1
16 changes: 8 additions & 8 deletions src/test/debuginfo/generator-objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@

// gdb-command:run
// gdb-command:print b
// gdb-check:$1 = generator_objects::main::generator {__0: 0x[...], <<variant>>: {__state: 0, 0: generator_objects::main::generator::Unresumed, 1: generator_objects::main::generator::Returned, 2: generator_objects::main::generator::Panicked, 3: generator_objects::main::generator::Suspend0 {[...]}, 4: generator_objects::main::generator::Suspend1 {[...]}}}
// gdb-check:$1 = generator_objects::main::generator-0 {__0: 0x[...], <<variant>>: {__state: 0, 0: generator_objects::main::generator-0::Unresumed, 1: generator_objects::main::generator-0::Returned, 2: generator_objects::main::generator-0::Panicked, 3: generator_objects::main::generator-0::Suspend0 {[...]}, 4: generator_objects::main::generator-0::Suspend1 {[...]}}}
// gdb-command:continue
// gdb-command:print b
// gdb-check:$2 = generator_objects::main::generator {__0: 0x[...], <<variant>>: {__state: 3, 0: generator_objects::main::generator::Unresumed, 1: generator_objects::main::generator::Returned, 2: generator_objects::main::generator::Panicked, 3: generator_objects::main::generator::Suspend0 {c: 6, d: 7}, 4: generator_objects::main::generator::Suspend1 {[...]}}}
// gdb-check:$2 = generator_objects::main::generator-0 {__0: 0x[...], <<variant>>: {__state: 3, 0: generator_objects::main::generator-0::Unresumed, 1: generator_objects::main::generator-0::Returned, 2: generator_objects::main::generator-0::Panicked, 3: generator_objects::main::generator-0::Suspend0 {c: 6, d: 7}, 4: generator_objects::main::generator-0::Suspend1 {[...]}}}
// gdb-command:continue
// gdb-command:print b
// gdb-check:$3 = generator_objects::main::generator {__0: 0x[...], <<variant>>: {__state: 4, 0: generator_objects::main::generator::Unresumed, 1: generator_objects::main::generator::Returned, 2: generator_objects::main::generator::Panicked, 3: generator_objects::main::generator::Suspend0 {[...]}, 4: generator_objects::main::generator::Suspend1 {c: 7, d: 8}}}
// gdb-check:$3 = generator_objects::main::generator-0 {__0: 0x[...], <<variant>>: {__state: 4, 0: generator_objects::main::generator-0::Unresumed, 1: generator_objects::main::generator-0::Returned, 2: generator_objects::main::generator-0::Panicked, 3: generator_objects::main::generator-0::Suspend0 {[...]}, 4: generator_objects::main::generator-0::Suspend1 {c: 7, d: 8}}}
// gdb-command:continue
// gdb-command:print b
// gdb-check:$4 = generator_objects::main::generator {__0: 0x[...], <<variant>>: {__state: 1, 0: generator_objects::main::generator::Unresumed, 1: generator_objects::main::generator::Returned, 2: generator_objects::main::generator::Panicked, 3: generator_objects::main::generator::Suspend0 {[...]}, 4: generator_objects::main::generator::Suspend1 {[...]}}}
// gdb-check:$4 = generator_objects::main::generator-0 {__0: 0x[...], <<variant>>: {__state: 1, 0: generator_objects::main::generator-0::Unresumed, 1: generator_objects::main::generator-0::Returned, 2: generator_objects::main::generator-0::Panicked, 3: generator_objects::main::generator-0::Suspend0 {[...]}, 4: generator_objects::main::generator-0::Suspend1 {[...]}}}

// === LLDB TESTS ==================================================================================

// lldb-command:run
// lldb-command:print b
// lldbg-check:(generator_objects::main::generator) $0 = generator(&0x[...])
// lldbg-check:(generator_objects::main::generator-0) $0 = generator-0(&0x[...])
// lldb-command:continue
// lldb-command:print b
// lldbg-check:(generator_objects::main::generator) $1 = generator(&0x[...])
// lldbg-check:(generator_objects::main::generator-0) $1 = generator-0(&0x[...])
// lldb-command:continue
// lldb-command:print b
// lldbg-check:(generator_objects::main::generator) $2 = generator(&0x[...])
// lldbg-check:(generator_objects::main::generator-0) $2 = generator-0(&0x[...])
// lldb-command:continue
// lldb-command:print b
// lldbg-check:(generator_objects::main::generator) $3 = generator(&0x[...])
// lldbg-check:(generator_objects::main::generator-0) $3 = generator-0(&0x[...])

#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)]
#![omit_gdb_pretty_printer_section]
Expand Down
55 changes: 55 additions & 0 deletions src/test/debuginfo/issue-57822.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// This test makes sure that the LLDB pretty printer does not throw an exception
// for nested closures and generators.

// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
// min-system-llvm-version: 8.0
// min-gdb-version: 8.2
// ignore-tidy-linelength

// compile-flags:-g

// === GDB TESTS ===================================================================================

// gdb-command:run

// gdb-command:print g
// gdb-check:$1 = issue_57822::main::closure-1 (issue_57822::main::closure-0 (1))

// gdb-command:print b
// gdb-check:$2 = issue_57822::main::generator-3 {__0: issue_57822::main::generator-2 {__0: 2, <<variant>>: {[...]}}, <<variant>>: {[...]}}

// === LLDB TESTS ==================================================================================

// lldb-command:run

// lldb-command:print g
// lldbg-check:(issue_57822::main::closure-1) $0 = closure-1(closure-0(1))

// lldb-command:print b
// lldbg-check:(issue_57822::main::generator-3) $1 = generator-3(generator-2(2))

#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)]
#![omit_gdb_pretty_printer_section]

use std::ops::Generator;
use std::pin::Pin;

fn main() {
let mut x = 1;
let f = move || x;
let g = move || f();

let mut y = 2;
let mut a = move || {
y += 1;
yield;
};
let mut b = move || {
Pin::new(&mut a).resume();
yield;
};

zzz(); // #break
}

fn zzz() { () }
22 changes: 22 additions & 0 deletions src/test/ui/hygiene/eager-from-opaque-2.rs
Original file line number Diff line number Diff line change
@@ -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))
}
20 changes: 20 additions & 0 deletions src/test/ui/hygiene/eager-from-opaque.rs
Original file line number Diff line number Diff line change
@@ -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!());
}
3 changes: 3 additions & 0 deletions src/test/ui/macros/derive-in-eager-expansion-hang.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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!());
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy
2 changes: 1 addition & 1 deletion src/tools/rust-installer