diff options
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/lib.rs | 10 | ||||
| -rw-r--r-- | src/librustc_typeck/outlives/test.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/outlives-associated-types.rs | 24 |
4 files changed, 31 insertions, 7 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 5f741029731..8f91d07b53f 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4676,8 +4676,8 @@ register_diagnostics! { E0588, // packed struct cannot transitively contain a `[repr(align)]` struct E0592, // duplicate definitions with name `{}` // E0613, // Removed (merged with E0609) + E0640, // infer outlives E0627, // yield statement outside of generator literal E0632, // cannot provide explicit type parameters when `impl Trait` is used in // argument position. - E0628, // infer outlives } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index ea4ce64e487..49ba0499f78 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -306,6 +306,11 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) })?; tcx.sess.track_errors(|| { + time(time_passes, "outlives testing", || + outlives::test::test_inferred_outlives(tcx)); + })?; + + tcx.sess.track_errors(|| { time(time_passes, "impl wf inference", || impl_wf_check::impl_wf_check(tcx)); })?; @@ -320,11 +325,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) variance::test::test_variance(tcx)); })?; - tcx.sess.track_errors(|| { - time(time_passes, "outlives testing", || - outlives::test::test_inferred_outlives(tcx)); - })?; - time(time_passes, "wf checking", || check::check_wf_new(tcx))?; time(time_passes, "item-types checking", || check::check_item_types(tcx))?; diff --git a/src/librustc_typeck/outlives/test.rs b/src/librustc_typeck/outlives/test.rs index 665b3d57d91..196e6605494 100644 --- a/src/librustc_typeck/outlives/test.rs +++ b/src/librustc_typeck/outlives/test.rs @@ -30,7 +30,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> { let inferred_outlives_of = self.tcx.inferred_outlives_of(item_def_id); span_err!(self.tcx.sess, item.span, - E0628, + E0640, "{:?}", inferred_outlives_of); } diff --git a/src/test/compile-fail/outlives-associated-types.rs b/src/test/compile-fail/outlives-associated-types.rs new file mode 100644 index 00000000000..f742ca81bcc --- /dev/null +++ b/src/test/compile-fail/outlives-associated-types.rs @@ -0,0 +1,24 @@ +// Copyright 2015 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. + +// Test that the outlives computation runs for now... + +#![feature(rustc_attrs)] + +//todo add all the test cases +// https://github.com/rust-lang/rfcs/blob/master/text/2093-infer-outlives.md#example-1-a-reference + +#[rustc_outlives] +struct Direct<'a, T> { + // inferred: `T: 'a` + field: &'a T //~ ERROR generic reference may outlive the data it points to +} + +fn main() { } |
