diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9ab269702db1c..5926b2bc2a41c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1316,12 +1316,14 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item hir::ItemKind::Union(..) => { check_union(tcx, it.id, it.span); } - hir::ItemKind::Existential(..) | - hir::ItemKind::Ty(..) => { + hir::ItemKind::Existential(..) + // HACK(eddyb) This is done in `wfcheck` for type aliases, instead. + // | hir::ItemKind::Ty(..) + => { let def_id = tcx.hir.local_def_id(it.id); let pty_ty = tcx.type_of(def_id); let generics = tcx.generics_of(def_id); - check_bounds_are_used(tcx, &generics, pty_ty); + let _ = check_params_are_used(tcx, &generics, pty_ty); } hir::ItemKind::ForeignMod(ref m) => { check_abi(tcx, it.span, m.abi); @@ -5240,14 +5242,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } -pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - generics: &ty::Generics, - ty: Ty<'tcx>) { +fn check_params_are_used<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + generics: &ty::Generics, + ty: Ty<'tcx>, +) -> Result<(), ErrorReported> { let own_counts = generics.own_counts(); - debug!("check_bounds_are_used(n_tps={}, ty={:?})", own_counts.types, ty); + debug!("check_params_are_used(n_tps={}, ty={:?})", own_counts.types, ty); if own_counts.types == 0 { - return; + return Ok(()); } // Make a vector of booleans initially false, set to true when used. let mut types_used = vec![false; own_counts.types]; @@ -5260,7 +5264,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // If there is already another error, do not emit // an error for not using a type Parameter. assert!(tcx.sess.err_count() > 0); - return; + return Err(ErrorReported); } } @@ -5268,6 +5272,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::GenericParamDefKind::Type { .. } => true, _ => false, }); + let mut result = Ok(()); for (&used, param) in types_used.iter().zip(types) { if !used { let id = tcx.hir.as_local_node_id(param.def_id).unwrap(); @@ -5275,8 +5280,10 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, struct_span_err!(tcx.sess, span, E0091, "type parameter `{}` is unused", param.name) .span_label(span, "unused type parameter") .emit(); + result = Err(ErrorReported); } } + result } fn fatally_break_rust(sess: &Session) { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 9e09f2cd1851e..fef0a35f11d72 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -118,11 +118,64 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def hir::ItemKind::Fn(..) => { check_item_fn(tcx, item); } - hir::ItemKind::Static(..) => { - check_item_type(tcx, item); - } + hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => { - check_item_type(tcx, item); + for_item(tcx, item).with_fcx(|fcx, _this| { + let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item.id)); + let item_ty = fcx.normalize_associated_types_in(item.span, &ty); + + fcx.register_wf_obligation(item_ty, item.span, ObligationCauseCode::MiscObligation); + + vec![] // no implied bounds in a static/const + }); + } + hir::ItemKind::Ty(..) => { + let def_id = tcx.hir.local_def_id(item.id); + let item_ty = tcx.type_of(def_id); + let generics = tcx.generics_of(def_id); + let used_params = super::check_params_are_used(tcx, &generics, item_ty); + for_item(tcx, item).with_fcx(|fcx, _this| { + // HACK(eddyb) Commented out to not require trait bounds for projections. + // let item_ty = fcx.normalize_associated_types_in(item.span, &item_ty); + + // Check the user-declared bounds, assuming the type is WF. + // This ensures that by checking the WF of the aliased type, where + // the alias is used, we don't ignore bounds written on the alias. + // NB: this check only happens if *all* type parameters are used, + // otherwise every unused type parameter can cause errors here. + if let Ok(()) = used_params { + let user_predicates = fcx.param_env.caller_bounds; + let wf_predicates = ty::wf::obligations( + &fcx.infcx, + fcx.param_env, + fcx.body_id, + item_ty, + item.span, + ).into_iter().flatten().map(|o| o.predicate).collect(); + let wf_predicates = traits::elaborate_predicates(fcx.tcx, wf_predicates); + let wf_param_env = ty::ParamEnv { + caller_bounds: fcx.tcx.mk_predicates(wf_predicates), + reveal: fcx.param_env.reveal, + }; + fcx.register_predicates(user_predicates.iter().filter_map(|&predicate| { + // HACK(eddyb) Ignore `Sized` bounds on type parameters. + if let ty::Predicate::Trait(trait_ref) = predicate { + if Some(trait_ref.def_id()) == tcx.lang_items().sized_trait() { + if let ty::Param(_) = trait_ref.skip_binder().self_ty().sty { + return None; + } + } + } + + let code = ObligationCauseCode::MiscObligation; + let cause = traits::ObligationCause::new(item.span, fcx.body_id, code); + Some(traits::Obligation::new(cause, wf_param_env, predicate)) + })); + } + + // HACK(eddyb) Commented out to not require trait bounds for projections. + vec![/*item_ty*/] + }); } hir::ItemKind::Struct(ref struct_def, ref ast_generics) => { check_type_defn(tcx, item, false, |fcx| { @@ -322,21 +375,6 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) { }) } -fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - item: &hir::Item) -{ - debug!("check_item_type: {:?}", item); - - for_item(tcx, item).with_fcx(|fcx, _this| { - let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item.id)); - let item_ty = fcx.normalize_associated_types_in(item.span, &ty); - - fcx.register_wf_obligation(item_ty, item.span, ObligationCauseCode::MiscObligation); - - vec![] // no implied bounds in a const etc - }); -} - fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item, ast_self_ty: &hir::Ty, diff --git a/src/test/incremental/hashes/type_defs.rs b/src/test/incremental/hashes/type_defs.rs index 4dffaa424256a..dc5d3d91a0995 100644 --- a/src/test/incremental/hashes/type_defs.rs +++ b/src/test/incremental/hashes/type_defs.rs @@ -132,12 +132,12 @@ type ChangeNestedTupleField = (i32, (i64, i8)); // Add type param -------------------------------------------------------------- #[cfg(cfail1)] -type AddTypeParam = (T1, T1); +type AddTypeParam = (T1, Option); #[cfg(not(cfail1))] #[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] -type AddTypeParam = (T1, T2); +type AddTypeParam = (T1, Option); @@ -148,18 +148,18 @@ type AddTypeParamBound = (T1, u32); #[cfg(not(cfail1))] #[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] -type AddTypeParamBound = (T1, u32); +type AddTypeParamBound = (T1, u32); // Add type param bound in where clause ---------------------------------------- #[cfg(cfail1)] -type AddTypeParamBoundWhereClause where T1: Clone = (T1, u32); +type AddTypeParamBoundWhereClause where T1: Sized = (T1, u32); #[cfg(not(cfail1))] #[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] -type AddTypeParamBoundWhereClause where T1: Clone+Copy = (T1, u32); +type AddTypeParamBoundWhereClause where T1: Sized+std::any::Any = (T1, u32); @@ -203,7 +203,9 @@ where 'b: 'a, // Change Trait Bound Indirectly ----------------------------------------------- trait ReferencedTrait1 {} +impl ReferencedTrait1 for T {} trait ReferencedTrait2 {} +impl ReferencedTrait2 for T {} mod change_trait_bound_indirectly { #[cfg(cfail1)] diff --git a/src/test/run-pass/attr-on-generic-formals.rs b/src/test/run-pass/attr-on-generic-formals.rs index e87b9e3d82a24..7d16b0a2f41e0 100644 --- a/src/test/run-pass/attr-on-generic-formals.rs +++ b/src/test/run-pass/attr-on-generic-formals.rs @@ -30,7 +30,7 @@ trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); } type TyLt<#[rustc_lt_type] 'd> = &'d u32; -type TyTy<#[rustc_ty_type] L> = (L, ); +type TyTy<#[rustc_ty_type] L> = Option; impl<#[rustc_lt_inherent] 'e> StLt<'e> { } impl<#[rustc_ty_inherent] M> StTy { } diff --git a/src/test/run-pass/type-param.rs b/src/test/run-pass/type-param.rs index c59e40934fb4b..d677364b39944 100644 --- a/src/test/run-pass/type-param.rs +++ b/src/test/run-pass/type-param.rs @@ -12,6 +12,6 @@ // pretty-expanded FIXME #23616 -type lteq = extern fn(T) -> bool; +type lteq = extern fn(T) -> bool; pub fn main() { } diff --git a/src/test/ui/dst/dst-bad-assign-3.rs b/src/test/ui/dst/dst-bad-assign-3.rs index 339cfb5443de3..9417f128cd3d1 100644 --- a/src/test/ui/dst/dst-bad-assign-3.rs +++ b/src/test/ui/dst/dst-bad-assign-3.rs @@ -12,7 +12,7 @@ #![feature(unsized_tuple_coercion)] -type Fat = (isize, &'static str, T); +type Fat = (isize, &'static str, T); #[derive(PartialEq,Eq)] struct Bar; diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs index dba66e0b69bfc..c7e9155fc9fca 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -25,7 +25,7 @@ trait T where i32: Foo {} //~ ERROR union U where i32: Foo { f: i32 } //~ ERROR -type Y where i32: Foo = (); // OK - bound is ignored +type Y where i32: Foo = (); //~ ERROR impl Foo for () where i32: Foo { //~ ERROR fn test(&self) { diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index f20c1ebb37aa9..9d43b6cc79d57 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -34,6 +34,15 @@ LL | union U where i32: Foo { f: i32 } //~ ERROR = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:28:1 + | +LL | type Y where i32: Foo = (); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: see issue #48214 + = help: add #![feature(trivial_bounds)] to the crate attributes to enable + error[E0277]: the trait bound `i32: Foo` is not satisfied --> $DIR/feature-gate-trivial_bounds.rs:30:1 | @@ -125,6 +134,6 @@ LL | | } = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable -error: aborting due to 11 previous errors +error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generic/generic-param-attrs.rs b/src/test/ui/generic/generic-param-attrs.rs index 81113d949e173..1fee5ea58f027 100644 --- a/src/test/ui/generic/generic-param-attrs.rs +++ b/src/test/ui/generic/generic-param-attrs.rs @@ -28,7 +28,7 @@ enum EnTy<#[rustc_ty_enum] J> { A(J), B } trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); } type TyLt<#[rustc_lt_type] 'd> = &'d u32; -type TyTy<#[rustc_ty_type] L> = (L, ); +type TyTy<#[rustc_ty_type] L> = Option; impl<#[rustc_lt_inherent] 'e> StLt<'e> { } impl<#[rustc_ty_inherent] M> StTy { } diff --git a/src/test/ui/issues/issue-47715.rs b/src/test/ui/issues/issue-47715.rs index b6b720f088aee..c2ddd55486ef6 100644 --- a/src/test/ui/issues/issue-47715.rs +++ b/src/test/ui/issues/issue-47715.rs @@ -31,7 +31,7 @@ union Union + Copy> { x: T, } -type Type> = T; +type Type> = Container; //~^ ERROR `impl Trait` not allowed fn main() { diff --git a/src/test/ui/issues/issue-47715.stderr b/src/test/ui/issues/issue-47715.stderr index 29b6afe7d0729..1b271d96afbf2 100644 --- a/src/test/ui/issues/issue-47715.stderr +++ b/src/test/ui/issues/issue-47715.stderr @@ -19,7 +19,7 @@ LL | union Union + Copy> { error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/issue-47715.rs:34:30 | -LL | type Type> = T; +LL | type Type> = Container; | ^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-6936.rs b/src/test/ui/issues/issue-6936.rs index 8eb16edcbd3d3..9abd4fb77a26f 100644 --- a/src/test/ui/issues/issue-6936.rs +++ b/src/test/ui/issues/issue-6936.rs @@ -31,7 +31,7 @@ mod t4 { } mod t5 { - type Bar = T; + type Bar = T; mod Bar {} //~ ERROR the name `Bar` is defined multiple times } diff --git a/src/test/ui/issues/issue-6936.stderr b/src/test/ui/issues/issue-6936.stderr index 48fcbf40622a2..8766ed20dc1cc 100644 --- a/src/test/ui/issues/issue-6936.stderr +++ b/src/test/ui/issues/issue-6936.stderr @@ -31,8 +31,8 @@ LL | enum Foo {} //~ ERROR the name `Foo` is defined multiple times error[E0428]: the name `Bar` is defined multiple times --> $DIR/issue-6936.rs:35:5 | -LL | type Bar = T; - | ---------------- previous definition of the type `Bar` here +LL | type Bar = T; + | ------------------------ previous definition of the type `Bar` here LL | mod Bar {} //~ ERROR the name `Bar` is defined multiple times | ^^^^^^^ `Bar` redefined here | diff --git a/src/test/ui/privacy/private-in-public-warn.rs b/src/test/ui/privacy/private-in-public-warn.rs index 6eeb14638e759..aed0575e358b3 100644 --- a/src/test/ui/privacy/private-in-public-warn.rs +++ b/src/test/ui/privacy/private-in-public-warn.rs @@ -57,8 +57,11 @@ mod traits { pub struct Pub(T); pub trait PubTr {} - pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - //~| WARNING hard error + pub struct Struct(T); + //~^ ERROR private trait `traits::PrivTr` in public interface + pub type Alias = Struct; + //~^ ERROR private trait `traits::PrivTr` in public interface + //~| WARNING hard error pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in public interface @@ -81,7 +84,9 @@ mod traits_where { pub struct Pub(T); pub trait PubTr {} - pub type Alias where T: PrivTr = T; + pub struct Struct(T) where T: PrivTr; + //~^ ERROR private trait `traits_where::PrivTr` in public interface + pub type Alias where T: PrivTr = Struct; //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error pub trait Tr2 where T: PrivTr {} @@ -273,7 +278,7 @@ mod aliases_priv { mod aliases_params { struct Priv; - type PrivAliasGeneric = T; + type PrivAliasGeneric = Option; type Result = ::std::result::Result; pub fn f1(arg: PrivAliasGeneric) {} // OK, not an error diff --git a/src/test/ui/privacy/private-in-public-warn.stderr b/src/test/ui/privacy/private-in-public-warn.stderr index 04e743a5b0ebf..2998d326ed9a6 100644 --- a/src/test/ui/privacy/private-in-public-warn.stderr +++ b/src/test/ui/privacy/private-in-public-warn.stderr @@ -102,17 +102,23 @@ LL | struct Priv; LL | type Alias = Priv; //~ ERROR private type `types::Priv` in public interface | ^^^^^^^^^^^^^^^^^^ can't leak private type -error: private trait `traits::PrivTr` in public interface (error E0445) +error[E0445]: private trait `traits::PrivTr` in public interface --> $DIR/private-in-public-warn.rs:60:5 | -LL | pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub struct Struct(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:62:5 + | +LL | pub type Alias = Struct; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:62:5 + --> $DIR/private-in-public-warn.rs:65:5 | LL | pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +127,7 @@ LL | pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in pu = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:64:5 + --> $DIR/private-in-public-warn.rs:67:5 | LL | pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +136,7 @@ LL | pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:66:5 + --> $DIR/private-in-public-warn.rs:69:5 | LL | / pub trait Tr3 { LL | | //~^ ERROR private trait `traits::PrivTr` in public interface @@ -145,7 +151,7 @@ LL | | } = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:70:9 + --> $DIR/private-in-public-warn.rs:73:9 | LL | fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +160,7 @@ LL | fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:73:5 + --> $DIR/private-in-public-warn.rs:76:5 | LL | impl Pub {} //~ ERROR private trait `traits::PrivTr` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +169,7 @@ LL | impl Pub {} //~ ERROR private trait `traits::PrivTr` in p = note: for more information, see issue #34537 error: private trait `traits::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:75:5 + --> $DIR/private-in-public-warn.rs:78:5 | LL | impl PubTr for Pub {} //~ ERROR private trait `traits::PrivTr` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -171,17 +177,23 @@ LL | impl PubTr for Pub {} //~ ERROR private trait `traits::Pr = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 +error[E0445]: private trait `traits_where::PrivTr` in public interface + --> $DIR/private-in-public-warn.rs:87:5 + | +LL | pub struct Struct(T) where T: PrivTr; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + error: private trait `traits_where::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:84:5 + --> $DIR/private-in-public-warn.rs:89:5 | -LL | pub type Alias where T: PrivTr = T; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub type Alias where T: PrivTr = Struct; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 error: private trait `traits_where::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:87:5 + --> $DIR/private-in-public-warn.rs:92:5 | LL | pub trait Tr2 where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +202,7 @@ LL | pub trait Tr2 where T: PrivTr {} = note: for more information, see issue #34537 error: private trait `traits_where::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:91:9 + --> $DIR/private-in-public-warn.rs:96:9 | LL | fn f(arg: T) where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +211,7 @@ LL | fn f(arg: T) where T: PrivTr {} = note: for more information, see issue #34537 error: private trait `traits_where::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:95:5 + --> $DIR/private-in-public-warn.rs:100:5 | LL | impl Pub where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -208,7 +220,7 @@ LL | impl Pub where T: PrivTr {} = note: for more information, see issue #34537 error: private trait `traits_where::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:98:5 + --> $DIR/private-in-public-warn.rs:103:5 | LL | impl PubTr for Pub where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +229,7 @@ LL | impl PubTr for Pub where T: PrivTr {} = note: for more information, see issue #34537 error: private trait `generics::PrivTr` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:109:5 + --> $DIR/private-in-public-warn.rs:114:5 | LL | pub trait Tr1: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -226,7 +238,7 @@ LL | pub trait Tr1: PrivTr {} = note: for more information, see issue #34537 error: private type `generics::Priv` in public interface (error E0446) - --> $DIR/private-in-public-warn.rs:112:5 + --> $DIR/private-in-public-warn.rs:117:5 | LL | pub trait Tr2: PubTr {} //~ ERROR private type `generics::Priv` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -235,7 +247,7 @@ LL | pub trait Tr2: PubTr {} //~ ERROR private type `generics::Priv` i = note: for more information, see issue #34537 error: private type `generics::Priv` in public interface (error E0446) - --> $DIR/private-in-public-warn.rs:114:5 + --> $DIR/private-in-public-warn.rs:119:5 | LL | pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -244,7 +256,7 @@ LL | pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Pr = note: for more information, see issue #34537 error: private type `generics::Priv` in public interface (error E0446) - --> $DIR/private-in-public-warn.rs:116:5 + --> $DIR/private-in-public-warn.rs:121:5 | LL | pub trait Tr4: PubTr> {} //~ ERROR private type `generics::Priv` in public interface | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +265,7 @@ LL | pub trait Tr4: PubTr> {} //~ ERROR private type `generics::Pr = note: for more information, see issue #34537 error[E0446]: private type `impls::Priv` in public interface - --> $DIR/private-in-public-warn.rs:143:9 + --> $DIR/private-in-public-warn.rs:148:9 | LL | struct Priv; | - `impls::Priv` declared as private @@ -262,7 +274,7 @@ LL | type Alias = Priv; //~ ERROR private type `impls::Priv` in public i | ^^^^^^^^^^^^^^^^^^ can't leak private type error: private type `aliases_pub::Priv` in public interface (error E0446) - --> $DIR/private-in-public-warn.rs:214:9 + --> $DIR/private-in-public-warn.rs:219:9 | LL | pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface | ^^^^^^^^^^^^^^^^^^^^^^ @@ -271,7 +283,7 @@ LL | pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` i = note: for more information, see issue #34537 error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:218:9 + --> $DIR/private-in-public-warn.rs:223:9 | LL | struct Priv; | - `aliases_pub::Priv` declared as private @@ -280,7 +292,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu | ^^^^^^^^^^^^^^^^^^ can't leak private type error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:221:9 + --> $DIR/private-in-public-warn.rs:226:9 | LL | struct Priv; | - `aliases_pub::Priv` declared as private @@ -289,7 +301,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu | ^^^^^^^^^^^^^^^^^^ can't leak private type error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:224:9 + --> $DIR/private-in-public-warn.rs:229:9 | LL | struct Priv; | - `aliases_pub::Priv` declared as private @@ -298,7 +310,7 @@ LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in pu | ^^^^^^^^^^^^^^^^^^ can't leak private type error: private trait `aliases_priv::PrivTr1` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:248:5 + --> $DIR/private-in-public-warn.rs:253:5 | LL | pub trait Tr1: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +319,7 @@ LL | pub trait Tr1: PrivUseAliasTr {} = note: for more information, see issue #34537 error: private type `aliases_priv::Priv2` in public interface (error E0446) - --> $DIR/private-in-public-warn.rs:251:5 + --> $DIR/private-in-public-warn.rs:256:5 | LL | pub trait Tr2: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -316,7 +328,7 @@ LL | pub trait Tr2: PrivUseAliasTr {} = note: for more information, see issue #34537 error: private trait `aliases_priv::PrivTr1` in public interface (error E0445) - --> $DIR/private-in-public-warn.rs:251:5 + --> $DIR/private-in-public-warn.rs:256:5 | LL | pub trait Tr2: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -324,6 +336,7 @@ LL | pub trait Tr2: PrivUseAliasTr {} = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #34537 -error: aborting due to 35 previous errors +error: aborting due to 37 previous errors -For more information about this error, try `rustc --explain E0446`. +Some errors occurred: E0445, E0446. +For more information about an error, try `rustc --explain E0445`. diff --git a/src/test/ui/privacy/private-in-public.rs b/src/test/ui/privacy/private-in-public.rs index b865e391d29c1..ccda46ec4fab2 100644 --- a/src/test/ui/privacy/private-in-public.rs +++ b/src/test/ui/privacy/private-in-public.rs @@ -147,7 +147,7 @@ mod aliases_priv { mod aliases_params { struct Priv; - type PrivAliasGeneric = T; + type PrivAliasGeneric = Option; type Result = ::std::result::Result; pub fn f2(arg: PrivAliasGeneric) {} diff --git a/src/test/ui/regions/regions-outlives-projection-hrtype.rs b/src/test/ui/regions/regions-outlives-projection-hrtype.rs index 2d271b7be73e0..254176df22d39 100644 --- a/src/test/ui/regions/regions-outlives-projection-hrtype.rs +++ b/src/test/ui/regions/regions-outlives-projection-hrtype.rs @@ -24,7 +24,8 @@ trait TheTrait { fn wf() { } -type FnType = for<'r> fn(&'r T); +#[allow(type_alias_bounds)] +type FnType = for<'r> fn(&'r T); fn foo<'a,'b,T>() where FnType: TheTrait diff --git a/src/test/ui/regions/regions-outlives-projection-hrtype.stderr b/src/test/ui/regions/regions-outlives-projection-hrtype.stderr index ba4e318957e60..a0b6d44c12061 100644 --- a/src/test/ui/regions/regions-outlives-projection-hrtype.stderr +++ b/src/test/ui/regions/regions-outlives-projection-hrtype.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/regions-outlives-projection-hrtype.rs:36:1 + --> $DIR/regions-outlives-projection-hrtype.rs:37:1 | LL | fn main() { } //~ ERROR compilation successful | ^^^^^^^^^^^^^ diff --git a/src/test/ui/run-pass/binding/expr-match-generic.rs b/src/test/ui/run-pass/binding/expr-match-generic.rs index 11c907b9b2da1..c83f533e17db6 100644 --- a/src/test/ui/run-pass/binding/expr-match-generic.rs +++ b/src/test/ui/run-pass/binding/expr-match-generic.rs @@ -11,7 +11,8 @@ // run-pass #![allow(non_camel_case_types)] -type compare = extern "Rust" fn(T, T) -> bool; +#[allow(type_alias_bounds)] +type compare = extern "Rust" fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected.clone() }, _ => panic!("wat") }; diff --git a/src/test/ui/run-pass/issues/issue-14933.rs b/src/test/ui/run-pass/issues/issue-14933.rs index 30365bb3e4f41..487907f1ae226 100644 --- a/src/test/ui/run-pass/issues/issue-14933.rs +++ b/src/test/ui/run-pass/issues/issue-14933.rs @@ -11,6 +11,7 @@ // run-pass // pretty-expanded FIXME #23616 -pub type BigRat = T; +#[allow(type_alias_bounds)] +pub type BigRat = T; fn main() {} diff --git a/src/test/ui/run-pass/issues/issue-19404.rs b/src/test/ui/run-pass/issues/issue-19404.rs index 3a5ce65aef8eb..b4cfc830e9734 100644 --- a/src/test/ui/run-pass/issues/issue-19404.rs +++ b/src/test/ui/run-pass/issues/issue-19404.rs @@ -12,7 +12,8 @@ use std::any::TypeId; use std::rc::Rc; -type Fp = Rc; +#[allow(type_alias_bounds)] +type Fp = Rc; struct Engine; diff --git a/src/test/ui/run-pass/issues/issue-20616.rs b/src/test/ui/run-pass/issues/issue-20616.rs index c28d212366927..ecc8aac2b3ede 100644 --- a/src/test/ui/run-pass/issues/issue-20616.rs +++ b/src/test/ui/run-pass/issues/issue-20616.rs @@ -9,7 +9,7 @@ // except according to those terms. // run-pass -type MyType<'a, T> = &'a T; +type MyType<'a, T> = &'a Option; // combine lifetime bounds and type arguments in usual way type TypeA<'a> = MyType<'a, ()>; @@ -28,18 +28,18 @@ type TypeD = TypeA<'static>; type TypeE = TypeA<'static,>; // normal type argument -type TypeF = Box; +type TypeF = Option; // type argument with trailing comma -type TypeG = Box; +type TypeG = Option; // trailing comma on lifetime defs type TypeH<'a,> = &'a (); // trailing comma on type argument -type TypeI = T; +type TypeI = Option; -static STATIC: () = (); +static STATIC: Option<()> = Some(()); fn main() { diff --git a/src/test/ui/run-pass/issues/issue-22356.rs b/src/test/ui/run-pass/issues/issue-22356.rs index 6e62ae069829e..7d1ea45f37205 100644 --- a/src/test/ui/run-pass/issues/issue-22356.rs +++ b/src/test/ui/run-pass/issues/issue-22356.rs @@ -35,7 +35,8 @@ impl BufferHandle { } } -pub type RawBufferHandle = Handle<::Buffer, String>; +#[allow(type_alias_bounds)] +pub type RawBufferHandle = Handle<::Buffer, String>; pub trait Device { type Buffer; diff --git a/src/test/ui/run-pass/issues/issue-22471.rs b/src/test/ui/run-pass/issues/issue-22471.rs index 87b4bc1734b5e..0fd548ca0d3fc 100644 --- a/src/test/ui/run-pass/issues/issue-22471.rs +++ b/src/test/ui/run-pass/issues/issue-22471.rs @@ -9,8 +9,10 @@ // except according to those terms. // run-pass -#![allow(type_alias_bounds)] -type Foo where T: Copy = Box; +struct NeedsCopy(T); + +#[allow(type_alias_bounds)] +type Foo where T: Copy = NeedsCopy; fn main(){} diff --git a/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs b/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs index 41c01db076efd..ab2e2a1b426d2 100644 --- a/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs +++ b/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs @@ -17,7 +17,8 @@ use std::mem; const SZ: usize = 100; struct P([u8; SZ], T); -type Ack = P>; +#[allow(type_alias_bounds)] +type Ack = P>; fn main() { let size_of_sized; let size_of_unsized; diff --git a/src/test/ui/run-pass/specialization/specialization-projection-alias.rs b/src/test/ui/run-pass/specialization/specialization-projection-alias.rs index f2f107653445a..570b3fa53466e 100644 --- a/src/test/ui/run-pass/specialization/specialization-projection-alias.rs +++ b/src/test/ui/run-pass/specialization/specialization-projection-alias.rs @@ -19,7 +19,8 @@ trait Id_ { type Out; } -type Id = ::Out; +#[allow(type_alias_bounds)] +type Id = ::Out; impl Id_ for T { default type Out = T; diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs index 2c8b873b8c946..4e39e319fcb5a 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs @@ -29,7 +29,7 @@ trait T where i32: Foo {} union U where i32: Foo { f: i32 } -type Y where i32: Foo = (); +type Y where i32: Foo = S; impl Foo for () where i32: Foo { fn test(&self) { diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr index 85b16b17042f6..683be61267729 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr @@ -27,7 +27,7 @@ LL | union U where i32: Foo { f: i32 } warning: where clauses are not enforced in type aliases --> $DIR/trivial-bounds-inconsistent.rs:32:14 | -LL | type Y where i32: Foo = (); +LL | type Y where i32: Foo = S; | ^^^^^^^^ | = note: #[warn(type_alias_bounds)] on by default @@ -36,8 +36,8 @@ LL | type Y where i32: Foo = (); warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent.rs:32:1 | -LL | type Y where i32: Foo = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Y where i32: Foo = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent.rs:34:1 diff --git a/src/test/ui/type/type-alias-bounds-err.rs b/src/test/ui/type/type-alias-bounds-err.rs new file mode 100644 index 0000000000000..8e071b360fb25 --- /dev/null +++ b/src/test/ui/type/type-alias-bounds-err.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// This test contains examples originally in `type-alias-bounds.rs`, +// that now produce errors instead of being silently accepted. + +type SVec = Vec; +//~^ ERROR `T` cannot be sent between threads safely +type S2Vec where T: Send = Vec; +//~^ ERROR `T` cannot be sent between threads safely + +trait Bound { type Assoc; } + +type T6 = ::std::vec::Vec; +//~^ ERROR the trait bound `U: Bound` is not satisfied + +fn main() {} diff --git a/src/test/ui/type/type-alias-bounds-err.stderr b/src/test/ui/type/type-alias-bounds-err.stderr new file mode 100644 index 0000000000000..edf11b3f57906 --- /dev/null +++ b/src/test/ui/type/type-alias-bounds-err.stderr @@ -0,0 +1,29 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/type-alias-bounds-err.rs:16:1 + | +LL | type SVec = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/type-alias-bounds-err.rs:18:1 + | +LL | type S2Vec where T: Send = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + +error[E0277]: the trait bound `U: Bound` is not satisfied + --> $DIR/type-alias-bounds-err.rs:23:1 + | +LL | type T6 = ::std::vec::Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bound` is not implemented for `U` + | + = help: consider adding a `where U: Bound` bound + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type/type-alias-bounds.rs b/src/test/ui/type/type-alias-bounds.rs index a17bb9e952d3c..958c113b4f835 100644 --- a/src/test/ui/type/type-alias-bounds.rs +++ b/src/test/ui/type/type-alias-bounds.rs @@ -15,9 +15,8 @@ use std::rc::Rc; -type SVec = Vec; -//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] -type S2Vec where T: Send = Vec; +type SVec = Vec; // NOTE(eddyb) moved to `type-alias-bounds-err.rs` +type S2Vec where T: /*Send*/ = Vec; // NOTE(eddyb) moved to `type-alias-bounds-err.rs` //~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); //~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] @@ -54,8 +53,8 @@ type MySendable = Sendable; // no error here! // However, bounds *are* taken into account when accessing associated types trait Bound { type Assoc; } -type T1 = U::Assoc; //~ WARN not enforced in type aliases -type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases +type T1 = U::Assoc; //~ WARN not enforced in type aliases +type T2 where U: Bound + ?Sized = U::Assoc; //~ WARN not enforced in type aliases // This errors // type T3 = U::Assoc; @@ -63,7 +62,7 @@ type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases type T4 = ::Assoc; // Make sure the help about associatd types is not shown incorrectly -type T5 = ::Assoc; //~ WARN not enforced in type aliases -type T6 = ::std::vec::Vec; //~ WARN not enforced in type aliases +type T5 = ::Assoc; //~ WARN not enforced in type aliases +// type T6 = ::std::vec::Vec; // NOTE(eddyb) moved to `type-alias-bounds-err.rs` fn main() {} diff --git a/src/test/ui/type/type-alias-bounds.stderr b/src/test/ui/type/type-alias-bounds.stderr index 2a2b0b0f26e34..9266f6290c73a 100644 --- a/src/test/ui/type/type-alias-bounds.stderr +++ b/src/test/ui/type/type-alias-bounds.stderr @@ -1,22 +1,14 @@ -warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:18:14 - | -LL | type SVec = Vec; - | ^^^^ ^^^^ - | - = note: #[warn(type_alias_bounds)] on by default - = help: the bound will not be checked when the type alias is used, and should be removed - warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:20:21 + --> $DIR/type-alias-bounds.rs:19:21 | -LL | type S2Vec where T: Send = Vec; - | ^^^^^^^ +LL | type S2Vec where T: /*Send*/ = Vec; // NOTE(eddyb) moved to `type-alias-bounds-err.rs` + | ^^ | + = note: #[warn(type_alias_bounds)] on by default = help: the clause will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:22:19 + --> $DIR/type-alias-bounds.rs:21:19 | LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); | ^^ ^^ @@ -24,7 +16,7 @@ LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); = help: the bound will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:24:18 + --> $DIR/type-alias-bounds.rs:23:18 | LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); | ^^ ^^ @@ -32,7 +24,7 @@ LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); = help: the bound will not be checked when the type alias is used, and should be removed warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:26:25 + --> $DIR/type-alias-bounds.rs:25:25 | LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); | ^^^^^ ^^^^^ @@ -40,44 +32,44 @@ LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); = help: the clause will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:57:12 + --> $DIR/type-alias-bounds.rs:56:12 | -LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases - | ^^^^^ +LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^ ^^^^^^ | = help: the bound will not be checked when the type alias is used, and should be removed help: use fully disambiguated paths (i.e., `::Assoc`) to refer to associated types in type aliases - --> $DIR/type-alias-bounds.rs:57:21 + --> $DIR/type-alias-bounds.rs:56:30 | -LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases - | ^^^^^^^^ +LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^^^^ warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:58:18 + --> $DIR/type-alias-bounds.rs:57:18 | -LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases - | ^^^^^^^^ +LL | type T2 where U: Bound + ?Sized = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^^^^^^^^^^^^^ | = help: the clause will not be checked when the type alias is used, and should be removed help: use fully disambiguated paths (i.e., `::Assoc`) to refer to associated types in type aliases - --> $DIR/type-alias-bounds.rs:58:29 + --> $DIR/type-alias-bounds.rs:57:38 | -LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases - | ^^^^^^^^ +LL | type T2 where U: Bound + ?Sized = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^^^^ warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:66:12 + --> $DIR/type-alias-bounds.rs:57:29 | -LL | type T5 = ::Assoc; //~ WARN not enforced in type aliases - | ^^^^^ +LL | type T2 where U: Bound + ?Sized = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^^ | = help: the bound will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:67:12 + --> $DIR/type-alias-bounds.rs:65:12 | -LL | type T6 = ::std::vec::Vec; //~ WARN not enforced in type aliases - | ^^^^^ +LL | type T5 = ::Assoc; //~ WARN not enforced in type aliases + | ^^^^^ ^^^^^^ | = help: the bound will not be checked when the type alias is used, and should be removed