Skip to content

Commit 41f807b

Browse files
committed
---
yaml --- r: 155326 b: refs/heads/try2 c: eb58ac1 h: refs/heads/master v: v3
1 parent a6e883e commit 41f807b

File tree

8 files changed

+59
-69
lines changed

8 files changed

+59
-69
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 4b5f4563bff67e2727befdb235314726849331a7
8+
refs/heads/try2: eb58ac126e638287998959a20aa91ffa730b95c2
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/lint/builtin.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,8 +1490,27 @@ impl LintPass for Stability {
14901490
}
14911491

14921492
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1493-
// if the expression was produced by a macro expansion,
1494-
if e.span.expn_id != NO_EXPANSION { return }
1493+
// skip if `e` is not from macro arguments
1494+
let skip = cx.tcx.sess.codemap().with_expn_info(e.span.expn_id, |expninfo| {
1495+
match expninfo {
1496+
Some(ref info) => {
1497+
if info.call_site.expn_id != NO_EXPANSION ||
1498+
!( e.span.lo > info.call_site.lo && e.span.hi < info.call_site.hi ) {
1499+
// This code is not from the arguments,
1500+
// or this macro call was generated by an other macro
1501+
// We can't handle it.
1502+
true
1503+
} else if info.callee.span.is_none() {
1504+
// We don't want to mess with compiler builtins.
1505+
true
1506+
} else {
1507+
false
1508+
}
1509+
},
1510+
_ => { false }
1511+
}
1512+
});
1513+
if skip { return; }
14951514

14961515
let id = match e.node {
14971516
ast::ExprPath(..) | ast::ExprStruct(..) => {

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,10 +2154,6 @@ pub fn autoderef<T>(fcx: &FnCtxt, sp: Span, base_ty: ty::t,
21542154
for autoderefs in range(0, fcx.tcx().sess.recursion_limit.get()) {
21552155
let resolved_t = structurally_resolved_type(fcx, sp, t);
21562156

2157-
if ty::type_is_bot(resolved_t) {
2158-
return (resolved_t, autoderefs, None);
2159-
}
2160-
21612157
match should_stop(resolved_t, autoderefs) {
21622158
Some(x) => return (resolved_t, autoderefs, Some(x)),
21632159
None => {}
@@ -3955,18 +3951,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
39553951
check_expr_with_expectation_and_lvalue_pref(
39563952
fcx, &**oprnd, expected_inner, lvalue_pref);
39573953
let mut oprnd_t = fcx.expr_ty(&**oprnd);
3958-
3959-
if !ty::type_is_error(oprnd_t) {
3954+
if !ty::type_is_error(oprnd_t) && !ty::type_is_bot(oprnd_t) {
39603955
match unop {
39613956
ast::UnBox => {
3962-
if !ty::type_is_bot(oprnd_t) {
3963-
oprnd_t = ty::mk_box(tcx, oprnd_t)
3964-
}
3957+
oprnd_t = ty::mk_box(tcx, oprnd_t)
39653958
}
39663959
ast::UnUniq => {
3967-
if !ty::type_is_bot(oprnd_t) {
3968-
oprnd_t = ty::mk_uniq(tcx, oprnd_t);
3969-
}
3960+
oprnd_t = ty::mk_uniq(tcx, oprnd_t);
39703961
}
39713962
ast::UnDeref => {
39723963
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
@@ -4003,27 +3994,23 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
40033994
};
40043995
}
40053996
ast::UnNot => {
4006-
if !ty::type_is_bot(oprnd_t) {
4007-
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
4008-
oprnd_t);
4009-
if !(ty::type_is_integral(oprnd_t) ||
4010-
ty::get(oprnd_t).sty == ty::ty_bool) {
4011-
oprnd_t = check_user_unop(fcx, "!", "not",
4012-
tcx.lang_items.not_trait(),
4013-
expr, &**oprnd, oprnd_t);
4014-
}
3997+
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
3998+
oprnd_t);
3999+
if !(ty::type_is_integral(oprnd_t) ||
4000+
ty::get(oprnd_t).sty == ty::ty_bool) {
4001+
oprnd_t = check_user_unop(fcx, "!", "not",
4002+
tcx.lang_items.not_trait(),
4003+
expr, &**oprnd, oprnd_t);
40154004
}
40164005
}
40174006
ast::UnNeg => {
4018-
if !ty::type_is_bot(oprnd_t) {
4019-
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
4020-
oprnd_t);
4021-
if !(ty::type_is_integral(oprnd_t) ||
4022-
ty::type_is_fp(oprnd_t)) {
4023-
oprnd_t = check_user_unop(fcx, "-", "neg",
4024-
tcx.lang_items.neg_trait(),
4025-
expr, &**oprnd, oprnd_t);
4026-
}
4007+
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
4008+
oprnd_t);
4009+
if !(ty::type_is_integral(oprnd_t) ||
4010+
ty::type_is_fp(oprnd_t)) {
4011+
oprnd_t = check_user_unop(fcx, "-", "neg",
4012+
tcx.lang_items.neg_trait(),
4013+
expr, &**oprnd, oprnd_t);
40274014
}
40284015
}
40294016
}
@@ -4481,21 +4468,21 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
44814468
check_expr(fcx, &**idx);
44824469
let raw_base_t = fcx.expr_ty(&**base);
44834470
let idx_t = fcx.expr_ty(&**idx);
4484-
if ty::type_is_error(raw_base_t) {
4471+
if ty::type_is_error(raw_base_t) || ty::type_is_bot(raw_base_t) {
44854472
fcx.write_ty(id, raw_base_t);
4486-
} else if ty::type_is_error(idx_t) {
4473+
} else if ty::type_is_error(idx_t) || ty::type_is_bot(idx_t) {
44874474
fcx.write_ty(id, idx_t);
44884475
} else {
44894476
let (_, autoderefs, field_ty) =
44904477
autoderef(fcx, expr.span, raw_base_t, Some(base.id),
44914478
lvalue_pref, |base_t, _| ty::index(base_t));
44924479
match field_ty {
4493-
Some(ty) if !ty::type_is_bot(ty) => {
4480+
Some(ty) => {
44944481
check_expr_has_type(fcx, &**idx, ty::mk_uint());
44954482
fcx.write_ty(id, ty);
44964483
fcx.write_autoderef_adjustment(base.id, base.span, autoderefs);
44974484
}
4498-
_ => {
4485+
None => {
44994486
// This is an overloaded method.
45004487
let base_t = structurally_resolved_type(fcx,
45014488
expr.span,

branches/try2/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
//
1111
// ignore-stage1
12-
// force-host
13-
1412
#![feature(plugin_registrar, managed_boxes, quote)]
1513
#![crate_type = "dylib"]
1614

branches/try2/src/test/auxiliary/lint_stability.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,13 @@ pub struct LockedTupleStruct(pub int);
181181
macro_rules! macro_test(
182182
() => (deprecated());
183183
)
184+
185+
#[macro_export]
186+
macro_rules! macro_test_arg(
187+
($func:expr) => ($func);
188+
)
189+
190+
#[macro_export]
191+
macro_rules! macro_test_arg_nested(
192+
($func:ident) => (macro_test_arg!($func()));
193+
)

branches/try2/src/test/compile-fail/index-bot.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

branches/try2/src/test/compile-fail/issue-17373.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

branches/try2/src/test/compile-fail/lint-stability.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ mod cross_crate {
109109
let _ = FrozenTupleStruct (1);
110110
let _ = LockedTupleStruct (1);
111111

112-
// At the moment, the following just checks that the stability
113-
// level of expanded code does not trigger the
114-
// lint. Eventually, we will want to lint the contents of the
112+
// At the moment, the lint checker only checks stability in
113+
// in the arguments of macros.
114+
// Eventually, we will want to lint the contents of the
115115
// macro in the module *defining* it. Also, stability levels
116116
// on macros themselves are not yet linted.
117117
macro_test!();
118+
macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text
119+
macro_test_arg_nested!(deprecated_text);
118120
}
119121

120122
fn test_method_param<F: Trait>(foo: F) {

0 commit comments

Comments
 (0)