未验证 提交 d711c5cd 编写于 作者: K kennytm 提交者: GitHub

Rollup merge of #52293 - ljedrz:dyn_librustc_typeck, r=estebank

Deny bare trait objects in librustc_typeck

Enforce `#![deny(bare_trait_objects)]` in `src/librustc_typeck`.
......@@ -98,7 +98,7 @@ struct ParamRange {
/// This type must not appear anywhere in other converted types.
const TRAIT_OBJECT_DUMMY_SELF: ty::TypeVariants<'static> = ty::TyInfer(ty::FreshTy(0));
impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
pub fn ast_region_to_region(&self,
lifetime: &hir::Lifetime,
def: Option<&ty::GenericParamDef>)
......
......@@ -604,7 +604,7 @@ fn check_supplied_sig_against_expectation(
/// If there is no expected signature, then we will convert the
/// types that the user gave into a signature.
fn supplied_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
let astconv: &AstConv = self;
let astconv: &dyn AstConv = self;
// First, convert the types that the user supplied (if any).
let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a));
......@@ -630,7 +630,7 @@ fn supplied_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
/// so should yield an error, but returns back a signature where
/// all parameters are of type `TyErr`.
fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
let astconv: &AstConv = self;
let astconv: &dyn AstConv = self;
let supplied_arguments = decl.inputs.iter().map(|a| {
// Convert the types that the user supplied (if any), but ignore them.
......
......@@ -1071,7 +1071,7 @@ pub fn coerce<'a>(&mut self,
pub fn coerce_forced_unit<'a>(&mut self,
fcx: &FnCtxt<'a, 'gcx, 'tcx>,
cause: &ObligationCause<'tcx>,
augment_error: &mut FnMut(&mut DiagnosticBuilder),
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder),
label_unit_as_expected: bool)
{
self.coerce_inner(fcx,
......@@ -1090,7 +1090,7 @@ fn coerce_inner<'a>(&mut self,
cause: &ObligationCause<'tcx>,
expression: Option<&'gcx hir::Expr>,
mut expression_ty: Ty<'tcx>,
augment_error: Option<&mut FnMut(&mut DiagnosticBuilder)>,
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder)>,
label_expression_as_expected: bool)
{
// Incorporate whatever type inference information we have
......
......@@ -526,7 +526,7 @@ fn visit_fru_field_types(&mut self) {
}
}
fn resolve<T>(&self, x: &T, span: &Locatable) -> T::Lifted
fn resolve<T>(&self, x: &T, span: &dyn Locatable) -> T::Lifted
where
T: TypeFoldable<'tcx> + ty::Lift<'gcx>,
{
......@@ -580,14 +580,14 @@ fn to_span(&self, tcx: &TyCtxt) -> Span {
struct Resolver<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> {
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>,
span: &'cx Locatable,
span: &'cx dyn Locatable,
body: &'gcx hir::Body,
}
impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> {
fn new(
fcx: &'cx FnCtxt<'cx, 'gcx, 'tcx>,
span: &'cx Locatable,
span: &'cx dyn Locatable,
body: &'gcx hir::Body,
) -> Resolver<'cx, 'gcx, 'tcx> {
Resolver {
......
......@@ -212,7 +212,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>,
let cause = ObligationCause::misc(span, impl_node_id);
let check_mutbl = |mt_a: ty::TypeAndMut<'gcx>,
mt_b: ty::TypeAndMut<'gcx>,
mk_ptr: &Fn(Ty<'gcx>) -> Ty<'gcx>| {
mk_ptr: &dyn Fn(Ty<'gcx>) -> Ty<'gcx>| {
if (mt_a.mutbl, mt_b.mutbl) == (hir::MutImmutable, hir::MutMutable) {
infcx.report_mismatched_types(&cause,
mk_ptr(mt_b.ty),
......
......@@ -1244,7 +1244,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
// Is it marked with ?Sized
fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &dyn AstConv<'gcx, 'tcx>,
ast_bounds: &[hir::GenericBound],
span: Span) -> bool
{
......@@ -1598,7 +1598,7 @@ pub enum SizedByDefault { Yes, No, }
/// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or
/// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the
/// built-in trait (formerly known as kind): Send.
pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &dyn AstConv<'gcx, 'tcx>,
param_ty: Ty<'tcx>,
ast_bounds: &[hir::GenericBound],
sized_by_default: SizedByDefault,
......@@ -1646,7 +1646,7 @@ pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>,
/// because this can be anywhere from 0 predicates (`T:?Sized` adds no
/// predicates) to 1 (`T:Foo`) to many (`T:Bar<X=i32>` adds `T:Bar`
/// and `<T as Bar>::X == i32`).
fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
fn predicates_from_bound<'tcx>(astconv: &dyn AstConv<'tcx, 'tcx>,
param_ty: Ty<'tcx>,
bound: &hir::GenericBound)
-> Vec<ty::Predicate<'tcx>>
......
......@@ -2338,7 +2338,7 @@ fn main() {
```compile_fail,E0225
fn main() {
let _: Box<std::io::Read + std::io::Write>;
let _: Box<dyn std::io::Read + std::io::Write>;
}
```
......@@ -2348,7 +2348,7 @@ fn main() {
```
fn main() {
let _: Box<std::io::Read + Send + Sync>;
let _: Box<dyn std::io::Read + Send + Sync>;
}
```
"##,
......
......@@ -70,6 +70,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![allow(non_camel_case_types)]
#![deny(bare_trait_objects)]
#![feature(box_patterns)]
#![feature(box_syntax)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册