Skip to content

Commit 24a70eb

Browse files
committed
Auto merge of #39694 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #39604, #39619, #39670, #39678, #39682, #39683 - Failed merges:
2 parents 4053276 + 55c17a5 commit 24a70eb

File tree

10 files changed

+127
-36
lines changed

10 files changed

+127
-36
lines changed

.mailmap

+2-4
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ Lindsey Kuper <[email protected]> <[email protected]>
132132
Luke Metz <[email protected]>
133133
134134
135-
136-
Makoto Nakashima <[email protected]> gifnksm <[email protected]>
137-
Makoto Nakashima <[email protected]> NAKASHIMA, Makoto <[email protected]>
135+
136+
138137
Marcell Pardavi <[email protected]>
139138
Margaret Meyerhofer <[email protected]> <mmeyerho@andrew>
140139
Mark Sinclair <[email protected]>
@@ -150,7 +149,6 @@ Michael Woerister <michaelwoerister@posteo> <michaelwoerister@gmail>
150149
Mickaël Raybaud-Roig <[email protected]> m-r-r <[email protected]>
151150
152151
Mukilan Thiagarajan <[email protected]>
153-
NAKASHIMA, Makoto <[email protected]>
154152
Nathan Wilson <[email protected]>
155153
Nathaniel Herman <[email protected]> Nathaniel Herman <[email protected]>
156154

src/librustc_metadata/index.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,17 @@ impl<'tcx> LazySeq<Index> {
9696
}
9797

9898
#[repr(packed)]
99-
#[derive(Copy, Clone)]
99+
#[derive(Copy)]
100100
struct Unaligned<T>(T);
101101

102+
// The derived Clone impl is unsafe for this packed struct since it needs to pass a reference to
103+
// the field to `T::clone`, but this reference may not be properly aligned.
104+
impl<T: Copy> Clone for Unaligned<T> {
105+
fn clone(&self) -> Self {
106+
*self
107+
}
108+
}
109+
102110
impl<T> Unaligned<T> {
103111
fn get(self) -> T { self.0 }
104112
}

src/librustc_trans/back/link.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ use syntax::attr;
4848
use syntax::symbol::Symbol;
4949
use syntax_pos::Span;
5050

51+
/// The LLVM module name containing crate-metadata. This includes a `.` on
52+
/// purpose, so it cannot clash with the name of a user-defined module.
53+
pub const METADATA_MODULE_NAME: &'static str = "crate.metadata";
54+
/// The name of the crate-metadata object file the compiler generates. Must
55+
/// match up with `METADATA_MODULE_NAME`.
56+
pub const METADATA_OBJ_NAME: &'static str = "crate.metadata.o";
57+
5158
// RLIB LLVM-BYTECODE OBJECT LAYOUT
5259
// Version 1
5360
// Bytes Data
@@ -213,7 +220,7 @@ pub fn link_binary(sess: &Session,
213220
remove(sess, &obj);
214221
}
215222
}
216-
remove(sess, &outputs.with_extension("metadata.o"));
223+
remove(sess, &outputs.with_extension(METADATA_OBJ_NAME));
217224
}
218225

219226
out_filenames
@@ -832,7 +839,7 @@ fn link_args(cmd: &mut Linker,
832839
// object file, so we link that in here.
833840
if crate_type == config::CrateTypeDylib ||
834841
crate_type == config::CrateTypeProcMacro {
835-
cmd.add_object(&outputs.with_extension("metadata.o"));
842+
cmd.add_object(&outputs.with_extension(METADATA_OBJ_NAME));
836843
}
837844

838845
// Try to strip as much out of the generated object by removing unused

src/librustc_trans/back/write.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -886,12 +886,12 @@ pub fn run_passes(sess: &Session,
886886
// Clean up unwanted temporary files.
887887

888888
// We create the following files by default:
889-
// - crate.#module-name#.bc
890-
// - crate.#module-name#.o
891-
// - crate.metadata.bc
892-
// - crate.metadata.o
893-
// - crate.o (linked from crate.##.o)
894-
// - crate.bc (copied from crate.##.bc)
889+
// - #crate#.#module-name#.bc
890+
// - #crate#.#module-name#.o
891+
// - #crate#.crate.metadata.bc
892+
// - #crate#.crate.metadata.o
893+
// - #crate#.o (linked from crate.##.o)
894+
// - #crate#.bc (copied from crate.##.bc)
895895
// We may create additional files if requested by the user (through
896896
// `-C save-temps` or `--emit=` flags).
897897

@@ -939,9 +939,9 @@ pub fn run_passes(sess: &Session,
939939
}
940940

941941
// We leave the following files around by default:
942-
// - crate.o
943-
// - crate.metadata.o
944-
// - crate.bc
942+
// - #crate#.o
943+
// - #crate#.crate.metadata.o
944+
// - #crate#.bc
945945
// These are used in linking steps and will be cleaned up afterward.
946946

947947
// FIXME: time_llvm_passes support - does this use a global context or

src/librustc_trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11511151
});
11521152

11531153
let metadata_module = ModuleTranslation {
1154-
name: "metadata".to_string(),
1154+
name: link::METADATA_MODULE_NAME.to_string(),
11551155
symbol_name_hash: 0, // we always rebuild metadata, at least for now
11561156
source: ModuleSource::Translated(ModuleLlvm {
11571157
llcx: shared_ccx.metadata_llcx(),

src/librustc_trans/mir/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,20 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
138138
while span.expn_id != NO_EXPANSION && span.expn_id != COMMAND_LINE_EXPN {
139139
if let Some(callsite_span) = cm.with_expn_info(span.expn_id,
140140
|ei| ei.map(|ei| ei.call_site.clone())) {
141+
// When the current function itself is a result of macro expansion,
142+
// we stop at the function body level because no line stepping can occurr
143+
// at the level above that.
144+
if self.mir.span.expn_id != NO_EXPANSION &&
145+
span.expn_id == self.mir.span.expn_id {
146+
break;
147+
}
141148
span = callsite_span;
142149
} else {
143150
break;
144151
}
145152
}
146153
let scope = self.scope_metadata_for_loc(source_info.scope, span.lo);
147-
// Use span of the outermost call site, while keeping the original lexical scope
154+
// Use span of the outermost expansion site, while keeping the original lexical scope.
148155
(scope, span)
149156
}
150157
}

src/test/debuginfo/macro-stepping.inc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013-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+
fn included() {
12+
foo!(); // #inc-loc1
13+
14+
foo2!(); // #inc-loc2
15+
16+
zzz(); // #inc-loc3
17+
}

src/test/debuginfo/macro-stepping.rs

+26
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ extern crate macro_stepping; // exports new_scope!()
4444
// gdb-command:frame
4545
// gdb-check:[...]#loc6[...]
4646

47+
// gdb-command:continue
48+
// gdb-command:step
49+
// gdb-command:frame
50+
// gdb-check:[...]#inc-loc1[...]
51+
// gdb-command:next
52+
// gdb-command:frame
53+
// gdb-check:[...]#inc-loc2[...]
54+
// gdb-command:next
55+
// gdb-command:frame
56+
// gdb-check:[...]#inc-loc3[...]
57+
4758
// === LLDB TESTS ==================================================================================
4859

4960
// lldb-command:set set stop-line-count-before 0
@@ -68,6 +79,17 @@ extern crate macro_stepping; // exports new_scope!()
6879
// lldb-command:frame select
6980
// lldb-check:[...]#loc5[...]
7081

82+
// lldb-command:continue
83+
// lldb-command:step
84+
// lldb-command:frame select
85+
// lldb-check:[...]#inc-loc1[...]
86+
// lldb-command:next
87+
// lldb-command:frame select
88+
// lldb-check:[...]#inc-loc2[...]
89+
// lldb-command:next
90+
// lldb-command:frame select
91+
// lldb-check:[...]#inc-loc3[...]
92+
7193
macro_rules! foo {
7294
() => {
7395
let a = 1;
@@ -99,6 +121,10 @@ fn main() {
99121
"world");
100122

101123
zzz(); // #loc6
124+
125+
included(); // #break
102126
}
103127

104128
fn zzz() {()}
129+
130+
include!("macro-stepping.inc");

src/test/run-pass/mir_adt_construction.rs

+46-15
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::fmt;
12+
1113
#[repr(C)]
1214
enum CEnum {
1315
Hello = 30,
1416
World = 60
1517
}
1618

1719
fn test1(c: CEnum) -> i32 {
18-
let c2 = CEnum::Hello;
19-
match (c, c2) {
20-
(CEnum::Hello, CEnum::Hello) => 42,
21-
(CEnum::World, CEnum::Hello) => 0,
22-
_ => 1
23-
}
20+
let c2 = CEnum::Hello;
21+
match (c, c2) {
22+
(CEnum::Hello, CEnum::Hello) => 42,
23+
(CEnum::World, CEnum::Hello) => 0,
24+
_ => 1
25+
}
2426
}
2527

2628
#[repr(packed)]
27-
#[derive(PartialEq, Debug)]
2829
struct Pakd {
2930
a: u64,
3031
b: u32,
@@ -33,6 +34,36 @@ struct Pakd {
3334
e: ()
3435
}
3536

37+
// It is unsafe to use #[derive(Debug)] on a packed struct because the code generated by the derive
38+
// macro takes references to the fields instead of accessing them directly.
39+
impl fmt::Debug for Pakd {
40+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41+
// It's important that we load the fields into locals by-value here. This will do safe
42+
// unaligned loads into the locals, then pass references to the properly-aligned locals to
43+
// the formatting code.
44+
let Pakd { a, b, c, d, e } = *self;
45+
f.debug_struct("Pakd")
46+
.field("a", &a)
47+
.field("b", &b)
48+
.field("c", &c)
49+
.field("d", &d)
50+
.field("e", &e)
51+
.finish()
52+
}
53+
}
54+
55+
// It is unsafe to use #[derive(PartialEq)] on a packed struct because the code generated by the
56+
// derive macro takes references to the fields instead of accessing them directly.
57+
impl PartialEq for Pakd {
58+
fn eq(&self, other: &Pakd) -> bool {
59+
self.a == other.a &&
60+
self.b == other.b &&
61+
self.c == other.c &&
62+
self.d == other.d &&
63+
self.e == other.e
64+
}
65+
}
66+
3667
impl Drop for Pakd {
3768
fn drop(&mut self) {}
3869
}
@@ -59,12 +90,12 @@ fn test5(x: fn(u32) -> Option<u32>) -> (Option<u32>, Option<u32>) {
5990
}
6091

6192
fn main() {
62-
assert_eq!(test1(CEnum::Hello), 42);
63-
assert_eq!(test1(CEnum::World), 0);
64-
assert_eq!(test2(), Pakd { a: 42, b: 42, c: 42, d: 42, e: () });
65-
assert_eq!(test3(), TupleLike(42, 42));
66-
let t4 = test4(TupleLike);
67-
assert_eq!(t4.0, t4.1);
68-
let t5 = test5(Some);
69-
assert_eq!(t5.0, t5.1);
93+
assert_eq!(test1(CEnum::Hello), 42);
94+
assert_eq!(test1(CEnum::World), 0);
95+
assert_eq!(test2(), Pakd { a: 42, b: 42, c: 42, d: 42, e: () });
96+
assert_eq!(test3(), TupleLike(42, 42));
97+
let t4 = test4(TupleLike);
98+
assert_eq!(t4.0, t4.1);
99+
let t5 = test5(Some);
100+
assert_eq!(t5.0, t5.1);
70101
}

src/test/run-pass/u128.rs

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-stage0
12-
// ignore-stage1
13-
1411
// ignore-emscripten
1512

1613
#![feature(i128_type, test)]

0 commit comments

Comments
 (0)