-
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.
Slightly refactor the dumping of HIR analysis data
- Loading branch information
Showing
13 changed files
with
92 additions
and
104 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use rustc_hir::def::DefKind; | ||
use rustc_hir::def_id::CRATE_DEF_ID; | ||
use rustc_middle::ty::TyCtxt; | ||
use rustc_span::sym; | ||
|
||
pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) { | ||
if !tcx.has_attr(CRATE_DEF_ID, sym::rustc_hidden_type_of_opaques) { | ||
return; | ||
} | ||
|
||
for id in tcx.hir().items() { | ||
let DefKind::OpaqueTy = tcx.def_kind(id.owner_id) else { continue }; | ||
|
||
let ty = tcx.type_of(id.owner_id).instantiate_identity(); | ||
|
||
tcx.dcx().emit_err(crate::errors::TypeOf { span: tcx.def_span(id.owner_id), ty }); | ||
} | ||
} |
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 @@ | ||
use rustc_middle::bug; | ||
use rustc_middle::ty::{self, TyCtxt}; | ||
use rustc_span::sym; | ||
|
||
pub(crate) fn inferred_outlives(tcx: TyCtxt<'_>) { | ||
for id in tcx.hir().items() { | ||
if !tcx.has_attr(id.owner_id, sym::rustc_outlives) { | ||
continue; | ||
} | ||
|
||
let preds = tcx.inferred_outlives_of(id.owner_id); | ||
let mut preds: Vec<_> = preds | ||
.iter() | ||
.map(|(pred, _)| match pred.kind().skip_binder() { | ||
ty::ClauseKind::RegionOutlives(p) => p.to_string(), | ||
ty::ClauseKind::TypeOutlives(p) => p.to_string(), | ||
err => bug!("unexpected clause {:?}", err), | ||
}) | ||
.collect(); | ||
preds.sort(); | ||
|
||
let span = tcx.def_span(id.owner_id); | ||
let mut err = tcx.dcx().struct_span_err(span, sym::rustc_outlives.as_str()); | ||
for pred in preds { | ||
err.note(pred); | ||
} | ||
err.emit(); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
use rustc_hir::def::DefKind; | ||
use rustc_hir::def_id::CRATE_DEF_ID; | ||
use rustc_middle::ty::TyCtxt; | ||
use rustc_span::symbol::sym; | ||
|
||
pub(crate) fn variances(tcx: TyCtxt<'_>) { | ||
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_variance_of_opaques) { | ||
for id in tcx.hir().items() { | ||
let DefKind::OpaqueTy = tcx.def_kind(id.owner_id) else { continue }; | ||
|
||
let variances = tcx.variances_of(id.owner_id); | ||
|
||
tcx.dcx().emit_err(crate::errors::VariancesOf { | ||
span: tcx.def_span(id.owner_id), | ||
variances: format!("{variances:?}"), | ||
}); | ||
} | ||
} | ||
|
||
for id in tcx.hir().items() { | ||
if !tcx.has_attr(id.owner_id, sym::rustc_variance) { | ||
continue; | ||
} | ||
|
||
let variances = tcx.variances_of(id.owner_id); | ||
|
||
tcx.dcx().emit_err(crate::errors::VariancesOf { | ||
span: tcx.def_span(id.owner_id), | ||
variances: format!("{variances:?}"), | ||
}); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.