From 9b686552c79542315ecf9cdd275441a9c3804a53 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 24 Aug 2018 02:21:52 +0300 Subject: [PATCH 1/4] Revert "hygiene: Make sure expansion info is set at most once for a given `Mark`" This reverts commit b15785b67133b5017f141d1fda1dd3dcf331b4b4. --- src/libsyntax_pos/hygiene.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 1531f030127e3..57c3e1e25d15e 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -108,14 +108,7 @@ impl Mark { #[inline] pub fn set_expn_info(self, info: ExpnInfo) { - HygieneData::with(|data| { - let old_info = &mut data.marks[self.0 as usize].expn_info; - if let Some(old_info) = old_info { - panic!("expansion info is reset for the mark {}\nold: {:#?}\nnew: {:#?}", - self.0, old_info, info); - } - *old_info = Some(info); - }) + HygieneData::with(|data| data.marks[self.0 as usize].expn_info = Some(info)) } #[inline] From 3a35445847d3fe68ba0aae0a642d0cd46af7f830 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 24 Aug 2018 02:26:50 +0300 Subject: [PATCH 2/4] Add a test for reset expansion info --- src/test/ui/hygiene/expansion-info-reset.rs | 17 +++++++++++++++++ src/test/ui/hygiene/expansion-info-reset.stderr | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/test/ui/hygiene/expansion-info-reset.rs create mode 100644 src/test/ui/hygiene/expansion-info-reset.stderr diff --git a/src/test/ui/hygiene/expansion-info-reset.rs b/src/test/ui/hygiene/expansion-info-reset.rs new file mode 100644 index 0000000000000..d80c1129b2948 --- /dev/null +++ b/src/test/ui/hygiene/expansion-info-reset.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// FIXME: Investigate why expansion info for a single expansion id is reset from +// `MacroBang(format_args)` to `MacroAttribute(derive(Clone))` (issue #52363). + +fn main() { + format_args!({ #[derive(Clone)] struct S; }); + //~^ ERROR format argument must be a string literal +} diff --git a/src/test/ui/hygiene/expansion-info-reset.stderr b/src/test/ui/hygiene/expansion-info-reset.stderr new file mode 100644 index 0000000000000..02a7b0d1b0261 --- /dev/null +++ b/src/test/ui/hygiene/expansion-info-reset.stderr @@ -0,0 +1,12 @@ +error: format argument must be a string literal + --> $DIR/expansion-info-reset.rs:15:18 + | +LL | format_args!({ #[derive(Clone)] struct S; }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: you might be missing a string literal to format with + | +LL | format_args!("{}", { #[derive(Clone)] struct S; }); + | ^^^^^ + +error: aborting due to previous error + From 98bedcbfd0e1419df749e859937d994ccaa72c91 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 14 Aug 2018 21:08:42 -0700 Subject: [PATCH 3/4] std: Use target_pointer_width for BACKTRACE_ELF_SIZE The former code used `target.contains("64")` to detect Elf64 targets, but this is inaccurate in a few cases: - `s390x-unknown-linux-gnu` is 64-bit - `sparcv9-sun-solaris` is 64-bit - `x86_64-unknown-linux-gnux32` is 32-bit Instead the `std` build script can use `CARGO_CFG_TARGET_POINTER_WIDTH` to reliably detect 64-bit targets for libbacktrace. Also update to backtrace-sys 0.1.24 for alexcrichton/backtrace-rs#122. --- src/libstd/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 26d93f97e69f3..016e7adb4c914 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -104,7 +104,8 @@ fn build_libbacktrace(target: &str) -> Result<(), ()> { } else { build.file("../libbacktrace/elf.c"); - if target.contains("64") { + let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap(); + if pointer_width == "64" { build.define("BACKTRACE_ELF_SIZE", "64"); } else { build.define("BACKTRACE_ELF_SIZE", "32"); From 1aa4bbbe39c4ec9588a7bc8d4dc4b56d1967c432 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Thu, 2 Aug 2018 08:49:36 +0200 Subject: [PATCH 4/4] rustbuild: fix local_rebuild If we detect a local rebuild (e.g. bootstrap compiler is the same version as target compiler), we set stage to 1. When trying to build e.g. UnstableBook, we use Mode::ToolBootstrap and stage is 1. Just allow Mode::ToolBootstrap and stagge != 0 if we are in a local_rebuild Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 724d3b741903f..dc0b0aaf0bb3c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -777,7 +777,7 @@ impl<'a> Builder<'a> { // compiler, but for tools we just use the precompiled libraries that // we've downloaded let use_snapshot = mode == Mode::ToolBootstrap; - assert!(!use_snapshot || stage == 0); + assert!(!use_snapshot || stage == 0 || self.local_rebuild); let maybe_sysroot = self.sysroot(compiler); let sysroot = if use_snapshot {