Auto merge of #39694 - frewsxcv:rollup, r=frewsxcv

Rollup of 6 pull requests

- Successful merges: #39604, #39619, #39670, #39678, #39682, #39683
- Failed merges:
This commit is contained in:
bors 2017-02-09 21:58:10 +00:00
commit 24a70eb598
10 changed files with 127 additions and 36 deletions

View File

@ -132,9 +132,8 @@ Lindsey Kuper <lindsey@composition.al> <lkuper@mozilla.com>
Luke Metz <luke.metz@students.olin.edu>
Luqman Aden <me@luqman.ca> <laden@csclub.uwaterloo.ca>
Luqman Aden <me@luqman.ca> <laden@mozilla.com>
Makoto Nakashima <makoto.nksm+github@gmail.com> <makoto.nksm@gmail.com>
Makoto Nakashima <makoto.nksm+github@gmail.com> gifnksm <makoto.nksm+github@gmail.com>
Makoto Nakashima <makoto.nksm+github@gmail.com> NAKASHIMA, Makoto <makoto.nksm+github@gmail.com>
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> <makoto.nksm@gmail.com>
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> <makoto.nksm+github@gmail.com>
Marcell Pardavi <marcell.pardavi@gmail.com>
Margaret Meyerhofer <mmeyerho@andrew.cmu.edu> <mmeyerho@andrew>
Mark Sinclair <mark.edward.x@gmail.com>
@ -150,7 +149,6 @@ Michael Woerister <michaelwoerister@posteo> <michaelwoerister@gmail>
Mickaël Raybaud-Roig <raybaudroigm@gmail.com> m-r-r <raybaudroigm@gmail.com>
Ms2ger <ms2ger@gmail.com> <Ms2ger@gmail.com>
Mukilan Thiagarajan <mukilanthiagarajan@gmail.com>
NAKASHIMA, Makoto <makoto.nksm+github@gmail.com>
Nathan Wilson <wilnathan@gmail.com>
Nathaniel Herman <nherman@post.harvard.edu> Nathaniel Herman <nherman@college.harvard.edu>
Neil Pankey <npankey@gmail.com> <neil@wire.im>

View File

@ -96,9 +96,17 @@ impl<'tcx> LazySeq<Index> {
}
#[repr(packed)]
#[derive(Copy, Clone)]
#[derive(Copy)]
struct Unaligned<T>(T);
// The derived Clone impl is unsafe for this packed struct since it needs to pass a reference to
// the field to `T::clone`, but this reference may not be properly aligned.
impl<T: Copy> Clone for Unaligned<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Unaligned<T> {
fn get(self) -> T { self.0 }
}

View File

@ -48,6 +48,13 @@ use syntax::attr;
use syntax::symbol::Symbol;
use syntax_pos::Span;
/// The LLVM module name containing crate-metadata. This includes a `.` on
/// purpose, so it cannot clash with the name of a user-defined module.
pub const METADATA_MODULE_NAME: &'static str = "crate.metadata";
/// The name of the crate-metadata object file the compiler generates. Must
/// match up with `METADATA_MODULE_NAME`.
pub const METADATA_OBJ_NAME: &'static str = "crate.metadata.o";
// RLIB LLVM-BYTECODE OBJECT LAYOUT
// Version 1
// Bytes Data
@ -213,7 +220,7 @@ pub fn link_binary(sess: &Session,
remove(sess, &obj);
}
}
remove(sess, &outputs.with_extension("metadata.o"));
remove(sess, &outputs.with_extension(METADATA_OBJ_NAME));
}
out_filenames
@ -832,7 +839,7 @@ fn link_args(cmd: &mut Linker,
// object file, so we link that in here.
if crate_type == config::CrateTypeDylib ||
crate_type == config::CrateTypeProcMacro {
cmd.add_object(&outputs.with_extension("metadata.o"));
cmd.add_object(&outputs.with_extension(METADATA_OBJ_NAME));
}
// Try to strip as much out of the generated object by removing unused

View File

@ -886,12 +886,12 @@ pub fn run_passes(sess: &Session,
// Clean up unwanted temporary files.
// We create the following files by default:
// - crate.#module-name#.bc
// - crate.#module-name#.o
// - crate.metadata.bc
// - crate.metadata.o
// - crate.o (linked from crate.##.o)
// - crate.bc (copied from crate.##.bc)
// - #crate#.#module-name#.bc
// - #crate#.#module-name#.o
// - #crate#.crate.metadata.bc
// - #crate#.crate.metadata.o
// - #crate#.o (linked from crate.##.o)
// - #crate#.bc (copied from crate.##.bc)
// We may create additional files if requested by the user (through
// `-C save-temps` or `--emit=` flags).
@ -939,9 +939,9 @@ pub fn run_passes(sess: &Session,
}
// We leave the following files around by default:
// - crate.o
// - crate.metadata.o
// - crate.bc
// - #crate#.o
// - #crate#.crate.metadata.o
// - #crate#.bc
// These are used in linking steps and will be cleaned up afterward.
// FIXME: time_llvm_passes support - does this use a global context or

View File

@ -1151,7 +1151,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
});
let metadata_module = ModuleTranslation {
name: "metadata".to_string(),
name: link::METADATA_MODULE_NAME.to_string(),
symbol_name_hash: 0, // we always rebuild metadata, at least for now
source: ModuleSource::Translated(ModuleLlvm {
llcx: shared_ccx.metadata_llcx(),

View File

@ -138,13 +138,20 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
while span.expn_id != NO_EXPANSION && span.expn_id != COMMAND_LINE_EXPN {
if let Some(callsite_span) = cm.with_expn_info(span.expn_id,
|ei| ei.map(|ei| ei.call_site.clone())) {
// When the current function itself is a result of macro expansion,
// we stop at the function body level because no line stepping can occurr
// at the level above that.
if self.mir.span.expn_id != NO_EXPANSION &&
span.expn_id == self.mir.span.expn_id {
break;
}
span = callsite_span;
} else {
break;
}
}
let scope = self.scope_metadata_for_loc(source_info.scope, span.lo);
// Use span of the outermost call site, while keeping the original lexical scope
// Use span of the outermost expansion site, while keeping the original lexical scope.
(scope, span)
}
}

View File

@ -0,0 +1,17 @@
// Copyright 2013-2017 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn included() {
foo!(); // #inc-loc1
foo2!(); // #inc-loc2
zzz(); // #inc-loc3
}

View File

@ -44,6 +44,17 @@ extern crate macro_stepping; // exports new_scope!()
// gdb-command:frame
// gdb-check:[...]#loc6[...]
// gdb-command:continue
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#inc-loc1[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#inc-loc2[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#inc-loc3[...]
// === LLDB TESTS ==================================================================================
// lldb-command:set set stop-line-count-before 0
@ -68,6 +79,17 @@ extern crate macro_stepping; // exports new_scope!()
// lldb-command:frame select
// lldb-check:[...]#loc5[...]
// lldb-command:continue
// lldb-command:step
// lldb-command:frame select
// lldb-check:[...]#inc-loc1[...]
// lldb-command:next
// lldb-command:frame select
// lldb-check:[...]#inc-loc2[...]
// lldb-command:next
// lldb-command:frame select
// lldb-check:[...]#inc-loc3[...]
macro_rules! foo {
() => {
let a = 1;
@ -99,6 +121,10 @@ fn main() {
"world");
zzz(); // #loc6
included(); // #break
}
fn zzz() {()}
include!("macro-stepping.inc");

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt;
#[repr(C)]
enum CEnum {
Hello = 30,
@ -15,16 +17,15 @@ enum CEnum {
}
fn test1(c: CEnum) -> i32 {
let c2 = CEnum::Hello;
match (c, c2) {
(CEnum::Hello, CEnum::Hello) => 42,
(CEnum::World, CEnum::Hello) => 0,
_ => 1
}
let c2 = CEnum::Hello;
match (c, c2) {
(CEnum::Hello, CEnum::Hello) => 42,
(CEnum::World, CEnum::Hello) => 0,
_ => 1
}
}
#[repr(packed)]
#[derive(PartialEq, Debug)]
struct Pakd {
a: u64,
b: u32,
@ -33,6 +34,36 @@ struct Pakd {
e: ()
}
// It is unsafe to use #[derive(Debug)] on a packed struct because the code generated by the derive
// macro takes references to the fields instead of accessing them directly.
impl fmt::Debug for Pakd {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// It's important that we load the fields into locals by-value here. This will do safe
// unaligned loads into the locals, then pass references to the properly-aligned locals to
// the formatting code.
let Pakd { a, b, c, d, e } = *self;
f.debug_struct("Pakd")
.field("a", &a)
.field("b", &b)
.field("c", &c)
.field("d", &d)
.field("e", &e)
.finish()
}
}
// It is unsafe to use #[derive(PartialEq)] on a packed struct because the code generated by the
// derive macro takes references to the fields instead of accessing them directly.
impl PartialEq for Pakd {
fn eq(&self, other: &Pakd) -> bool {
self.a == other.a &&
self.b == other.b &&
self.c == other.c &&
self.d == other.d &&
self.e == other.e
}
}
impl Drop for Pakd {
fn drop(&mut self) {}
}
@ -59,12 +90,12 @@ fn test5(x: fn(u32) -> Option<u32>) -> (Option<u32>, Option<u32>) {
}
fn main() {
assert_eq!(test1(CEnum::Hello), 42);
assert_eq!(test1(CEnum::World), 0);
assert_eq!(test2(), Pakd { a: 42, b: 42, c: 42, d: 42, e: () });
assert_eq!(test3(), TupleLike(42, 42));
let t4 = test4(TupleLike);
assert_eq!(t4.0, t4.1);
let t5 = test5(Some);
assert_eq!(t5.0, t5.1);
assert_eq!(test1(CEnum::Hello), 42);
assert_eq!(test1(CEnum::World), 0);
assert_eq!(test2(), Pakd { a: 42, b: 42, c: 42, d: 42, e: () });
assert_eq!(test3(), TupleLike(42, 42));
let t4 = test4(TupleLike);
assert_eq!(t4.0, t4.1);
let t5 = test5(Some);
assert_eq!(t5.0, t5.1);
}

View File

@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-stage0
// ignore-stage1
// ignore-emscripten
#![feature(i128_type, test)]