Skip to content

Commit f88e0eb

Browse files
committed
---
yaml --- r: 273181 b: refs/heads/beta c: a09a419 h: refs/heads/master i: 273179: 6b2bbf1
1 parent a4a0373 commit f88e0eb

File tree

2 files changed

+19
-12
lines changed
  • branches/beta/src/libsyntax_ext/deriving/generic

2 files changed

+19
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: c433b703ead56ec4dd05b5f3ad39301d27e19953
26+
refs/heads/beta: a09a41928ff9a9188453013d3c8efce19626e08d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,22 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec<P<ast
381381
visitor.types
382382
}
383383

384+
/// Replacement for expr_unreachable which generates intrinsics::unreachable()
385+
/// instead of unreachable!()
386+
fn expr_unreachable_intrinsic(cx: &ExtCtxt, sp: Span) -> P<Expr> {
387+
let path = cx.std_path(&["intrinsics", "unreachable"]);
388+
let call = cx.expr_call_global(
389+
sp, path, vec![]);
390+
let unreachable = cx.expr_block(P(ast::Block {
391+
stmts: vec![],
392+
expr: Some(call),
393+
id: ast::DUMMY_NODE_ID,
394+
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
395+
span: sp }));
396+
397+
unreachable
398+
}
399+
384400
impl<'a> TraitDef<'a> {
385401
pub fn expand(&self,
386402
cx: &mut ExtCtxt,
@@ -1297,16 +1313,7 @@ impl<'a> MethodDef<'a> {
12971313
//Since we know that all the arguments will match if we reach the match expression we
12981314
//add the unreachable intrinsics as the result of the catch all which should help llvm
12991315
//in optimizing it
1300-
let path = cx.std_path(&["intrinsics", "unreachable"]);
1301-
let call = cx.expr_call_global(
1302-
sp, path, vec![]);
1303-
let unreachable = cx.expr_block(P(ast::Block {
1304-
stmts: vec![],
1305-
expr: Some(call),
1306-
id: ast::DUMMY_NODE_ID,
1307-
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
1308-
span: sp }));
1309-
match_arms.push(cx.arm(sp, vec![cx.pat_wild(sp)], unreachable));
1316+
match_arms.push(cx.arm(sp, vec![cx.pat_wild(sp)], expr_unreachable_intrinsic(cx, sp)));
13101317

13111318
// Final wrinkle: the self_args are expressions that deref
13121319
// down to desired l-values, but we cannot actually deref
@@ -1382,7 +1389,7 @@ impl<'a> MethodDef<'a> {
13821389
// derive Debug on such a type could here generate code
13831390
// that needs the feature gate enabled.)
13841391

1385-
cx.expr_unreachable(sp)
1392+
expr_unreachable_intrinsic(cx, sp)
13861393
}
13871394
else {
13881395

0 commit comments

Comments
 (0)