mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 14:52:56 +03:00
refactor 'Output = $ty' & reduce rustc dep
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
use crate::ty::fold::{TypeFoldable, TypeFolder};
|
||||
use crate::ty::subst::{InternalSubsts, Subst};
|
||||
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt};
|
||||
use crate::util::common::FN_OUTPUT_NAME;
|
||||
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
@@ -1364,7 +1363,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
|
||||
projection_ty: ty::ProjectionTy::from_ref_and_name(
|
||||
tcx,
|
||||
trait_ref,
|
||||
Ident::with_dummy_span(FN_OUTPUT_NAME),
|
||||
Ident::with_dummy_span(rustc_hir::FN_OUTPUT_NAME),
|
||||
),
|
||||
ty: ret_type,
|
||||
});
|
||||
|
||||
@@ -5,14 +5,9 @@
|
||||
use std::fmt::Debug;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
// The name of the associated type for `Fn` return types.
|
||||
pub const FN_OUTPUT_NAME: Symbol = sym::Output;
|
||||
|
||||
pub use errors::ErrorReported;
|
||||
|
||||
pub fn to_readable_str(mut val: usize) -> String {
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
use rustc::lint::builtin;
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
use rustc::util::captures::Captures;
|
||||
use rustc::util::common::FN_OUTPUT_NAME;
|
||||
use rustc::{bug, span_bug};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
@@ -1978,12 +1977,7 @@ fn lower_async_fn_output_type_to_future_bound(
|
||||
// "<Output = T>"
|
||||
let future_params = self.arena.alloc(hir::GenericArgs {
|
||||
args: &[],
|
||||
bindings: arena_vec![self; hir::TypeBinding {
|
||||
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
|
||||
kind: hir::TypeBindingKind::Equality { ty: output_ty },
|
||||
hir_id: self.next_id(),
|
||||
span,
|
||||
}],
|
||||
bindings: arena_vec![self; self.output_ty_binding(span, output_ty)],
|
||||
parenthesized: false,
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
use rustc::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
|
||||
use rustc::span_bug;
|
||||
use rustc::util::common::FN_OUTPUT_NAME;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_hir as hir;
|
||||
@@ -406,16 +405,22 @@ fn lower_parenthesized_parameter_data(
|
||||
FunctionRetTy::Default(_) => this.arena.alloc(this.ty_tup(span, &[])),
|
||||
};
|
||||
let args = smallvec![GenericArg::Type(this.ty_tup(span, inputs))];
|
||||
let binding = hir::TypeBinding {
|
||||
hir_id: this.next_id(),
|
||||
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
|
||||
span: output_ty.span,
|
||||
kind: hir::TypeBindingKind::Equality { ty: output_ty },
|
||||
};
|
||||
let binding = this.output_ty_binding(output_ty.span, output_ty);
|
||||
(
|
||||
GenericArgsCtor { args, bindings: arena_vec![this; binding], parenthesized: true },
|
||||
false,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// An associated type binding `Output = $ty`.
|
||||
crate fn output_ty_binding(
|
||||
&mut self,
|
||||
span: Span,
|
||||
ty: &'hir hir::Ty<'hir>,
|
||||
) -> hir::TypeBinding<'hir> {
|
||||
let ident = Ident::with_dummy_span(hir::FN_OUTPUT_NAME);
|
||||
let kind = hir::TypeBindingKind::Equality { ty };
|
||||
hir::TypeBinding { hir_id: self.next_id(), span, ident, kind }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1875,6 +1875,9 @@ pub enum ImplItemKind<'hir> {
|
||||
OpaqueTy(GenericBounds<'hir>),
|
||||
}
|
||||
|
||||
// The name of the associated type for `Fn` return types.
|
||||
pub const FN_OUTPUT_NAME: Symbol = sym::Output;
|
||||
|
||||
/// Bind a type to an associated type (i.e., `A = Foo`).
|
||||
///
|
||||
/// Bindings like `A: Debug` are represented as a special type `A =
|
||||
|
||||
Reference in New Issue
Block a user