-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #44857 - toidiu:ak-44493-empty-predicate, r=nikomatsakis
#44493 add structure for inferred_outlives_of #44493 - add placeholder for the final implementation of inferred_outlives_of - add some placeholder tests
- Loading branch information
Showing
9 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2013 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. | ||
|
||
use rustc::hir::def_id::DefId; | ||
use rustc::ty::{self, TyCtxt}; | ||
use rustc::ty::maps::Providers; | ||
|
||
/// Code to write unit test for outlives. | ||
pub mod test; | ||
|
||
pub fn provide(providers: &mut Providers) { | ||
*providers = Providers { | ||
inferred_outlives_of, | ||
..*providers | ||
}; | ||
} | ||
|
||
//todo | ||
fn inferred_outlives_of<'a, 'tcx>(_tcx: TyCtxt<'a, 'tcx, 'tcx>, _def_id: DefId) | ||
-> Vec<ty::Predicate<'tcx>> { | ||
Vec::new() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2013 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. | ||
|
||
use rustc::hir; | ||
use rustc::hir::itemlikevisit::ItemLikeVisitor; | ||
use rustc::ty::TyCtxt; | ||
|
||
pub fn test_inferred_outlives<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { | ||
tcx.hir.krate().visit_all_item_likes(&mut OutlivesTest { tcx }); | ||
} | ||
|
||
struct OutlivesTest<'a, 'tcx: 'a> { | ||
tcx: TyCtxt<'a, 'tcx, 'tcx> | ||
} | ||
|
||
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> { | ||
fn visit_item(&mut self, item: &'tcx hir::Item) { | ||
let item_def_id = self.tcx.hir.local_def_id(item.id); | ||
|
||
// For unit testing: check for a special "rustc_outlives" | ||
// attribute and report an error with various results if found. | ||
if self.tcx.has_attr(item_def_id, "rustc_outlives") { | ||
let inferred_outlives_of = self.tcx.inferred_outlives_of(item_def_id); | ||
span_err!(self.tcx.sess, | ||
item.span, | ||
E0640, | ||
"{:?}", | ||
inferred_outlives_of); | ||
} | ||
} | ||
|
||
fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) { } | ||
fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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> { //~ ERROR 19:1: 21:2: [] [E0640] | ||
field: &'a T | ||
} | ||
|
||
fn main() { } |