Skip to content

Commit c021e53

Browse files
author
toidiu
committed
add a test case
dont duplicate error codes choose unlikely error code specify error pattern in test
1 parent ba1efa3 commit c021e53

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4676,8 +4676,8 @@ register_diagnostics! {
46764676
E0588, // packed struct cannot transitively contain a `[repr(align)]` struct
46774677
E0592, // duplicate definitions with name `{}`
46784678
// E0613, // Removed (merged with E0609)
4679+
E0640, // infer outlives
46794680
E0627, // yield statement outside of generator literal
46804681
E0632, // cannot provide explicit type parameters when `impl Trait` is used in
46814682
// argument position.
4682-
E0628, // infer outlives
46834683
}

src/librustc_typeck/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
305305

306306
})?;
307307

308+
tcx.sess.track_errors(|| {
309+
time(time_passes, "outlives testing", ||
310+
outlives::test::test_inferred_outlives(tcx));
311+
})?;
312+
308313
tcx.sess.track_errors(|| {
309314
time(time_passes, "impl wf inference", ||
310315
impl_wf_check::impl_wf_check(tcx));
@@ -320,11 +325,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
320325
variance::test::test_variance(tcx));
321326
})?;
322327

323-
tcx.sess.track_errors(|| {
324-
time(time_passes, "outlives testing", ||
325-
outlives::test::test_inferred_outlives(tcx));
326-
})?;
327-
328328
time(time_passes, "wf checking", || check::check_wf_new(tcx))?;
329329

330330
time(time_passes, "item-types checking", || check::check_item_types(tcx))?;

src/librustc_typeck/outlives/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> {
3030
let inferred_outlives_of = self.tcx.inferred_outlives_of(item_def_id);
3131
span_err!(self.tcx.sess,
3232
item.span,
33-
E0628,
33+
E0640,
3434
"{:?}",
3535
inferred_outlives_of);
3636
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2015 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+
// Test that the outlives computation runs for now...
12+
13+
#![feature(rustc_attrs)]
14+
15+
//todo add all the test cases
16+
// https://github.com/rust-lang/rfcs/blob/master/text/2093-infer-outlives.md#example-1-a-reference
17+
18+
#[rustc_outlives]
19+
struct Direct<'a, T> {
20+
// inferred: `T: 'a`
21+
field: &'a T //~ ERROR generic reference may outlive the data it points to
22+
}
23+
24+
fn main() { }

0 commit comments

Comments
 (0)