Skip to content

Commit 49103dc

Browse files
author
Lukas Markeffsky
committed
move rustc_outlives test code from query to dedicated function
1 parent c03d978 commit 49103dc

File tree

4 files changed

+20
-32
lines changed

4 files changed

+20
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
2+
#### Note: this error code is no longer emitted by the compiler.

compiler/rustc_hir_analysis/src/outlives/mod.rs

-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_hir::def_id::LocalDefId;
44
use rustc_middle::query::Providers;
55
use rustc_middle::ty::GenericArgKind;
66
use rustc_middle::ty::{self, CratePredicatesMap, ToPredicate, TyCtxt};
7-
use rustc_span::symbol::sym;
87
use rustc_span::Span;
98

109
mod explicit;
@@ -49,25 +48,6 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau
4948
let predicates =
5049
crate_map.predicates.get(&item_def_id.to_def_id()).copied().unwrap_or(&[]);
5150

52-
if tcx.has_attr(item_def_id, sym::rustc_outlives) {
53-
let mut pred: Vec<String> = predicates
54-
.iter()
55-
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
56-
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
57-
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
58-
err => bug!("unexpected clause {:?}", err),
59-
})
60-
.collect();
61-
pred.sort();
62-
63-
let span = tcx.def_span(item_def_id);
64-
let mut err = tcx.sess.struct_span_err(span, "rustc_outlives");
65-
for p in pred {
66-
err.note(p);
67-
}
68-
err.emit();
69-
}
70-
7151
debug!("inferred_outlives_of({:?}) = {:?}", item_def_id, predicates);
7252

7353
predicates
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
use rustc_errors::struct_span_err;
2-
use rustc_middle::ty::TyCtxt;
1+
use rustc_middle::ty::{self, TyCtxt};
32
use rustc_span::symbol::sym;
43

54
pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
65
for id in tcx.hir().items() {
76
// For unit testing: check for a special "rustc_outlives"
87
// attribute and report an error with various results if found.
98
if tcx.has_attr(id.owner_id, sym::rustc_outlives) {
10-
let inferred_outlives_of = tcx.inferred_outlives_of(id.owner_id);
11-
struct_span_err!(
12-
tcx.sess,
13-
tcx.def_span(id.owner_id),
14-
E0640,
15-
"{:?}",
16-
inferred_outlives_of
17-
)
18-
.emit();
9+
let predicates = tcx.inferred_outlives_of(id.owner_id);
10+
let mut pred: Vec<String> = predicates
11+
.iter()
12+
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
13+
ty::ClauseKind::RegionOutlives(p) => p.to_string(),
14+
ty::ClauseKind::TypeOutlives(p) => p.to_string(),
15+
err => bug!("unexpected clause {:?}", err),
16+
})
17+
.collect();
18+
pred.sort();
19+
20+
let span = tcx.def_span(id.owner_id);
21+
let mut err = tcx.sess.struct_span_err(span, "rustc_outlives");
22+
for p in pred {
23+
err.note(p);
24+
}
25+
err.emit();
1926
}
2027
}
2128
}

src/tools/tidy/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ERROR_DOCS_PATH: &str = "compiler/rustc_error_codes/src/error_codes/";
2727
const ERROR_TESTS_PATH: &str = "tests/ui/error-codes/";
2828

2929
// Error codes that (for some reason) can't have a doctest in their explanation. Error codes are still expected to provide a code example, even if untested.
30-
const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E0640", "E0717"];
30+
const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E0717"];
3131

3232
// Error codes that don't yet have a UI test. This list will eventually be removed.
3333
const IGNORE_UI_TEST_CHECK: &[&str] =

0 commit comments

Comments
 (0)