Skip to content

Move TypeckResults to separate module #105758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions compiler/rustc_middle/src/ty/parameterized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::{DefId, DefIndex};
use rustc_index::vec::{Idx, IndexVec};

use crate::middle::exported_symbols::ExportedSymbol;
use crate::mir::Body;
use crate::ty::{
self, Clause, Const, FnSig, GeneratorDiagnosticData, GenericPredicates, Predicate, TraitRef, Ty,
};
use crate::ty;

pub trait ParameterizedOverTcx: 'static {
#[allow(unused_lifetimes)]
type Value<'tcx>;
}

Expand Down Expand Up @@ -100,29 +95,28 @@ trivially_parameterized_over_tcx! {
rustc_type_ir::Variance,
}

// HACK(compiler-errors): This macro rule can only take an ident,
// not a path, due to parsing ambiguity reasons. That means we gotta
// import all of these types above.
// HACK(compiler-errors): This macro rule can only take a fake path,
// not a real, due to parsing ambiguity reasons.
#[macro_export]
macro_rules! parameterized_over_tcx {
($($ident:ident),+ $(,)?) => {
($($($fake_path:ident)::+),+ $(,)?) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i thought i tried this and it didn't work

$(
impl $crate::ty::ParameterizedOverTcx for $ident<'static> {
type Value<'tcx> = $ident<'tcx>;
impl $crate::ty::ParameterizedOverTcx for $($fake_path)::+<'static> {
type Value<'tcx> = $($fake_path)::+<'tcx>;
}
)*
}
}

parameterized_over_tcx! {
Ty,
FnSig,
GenericPredicates,
TraitRef,
Const,
Predicate,
Clause,
GeneratorDiagnosticData,
Body,
ExportedSymbol,
crate::middle::exported_symbols::ExportedSymbol,
crate::mir::Body,
ty::Ty,
ty::FnSig,
ty::GenericPredicates,
ty::TraitRef,
ty::Const,
ty::Predicate,
ty::Clause,
ty::GeneratorDiagnosticData,
}