Skip to content

Commit 994b58f

Browse files
Okay actually check only alias TYPES
1 parent 5065123 commit 994b58f

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

compiler/rustc_trait_selection/src/traits/wf.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
435435
}
436436
}
437437

438-
/// Pushes the obligations required for an alias (except inherent) to be WF
439-
/// into `self.out`.
440-
fn compute_alias_ty(&mut self, data: ty::AliasTy<'tcx>) {
441-
self.compute_alias_term(data.into());
442-
}
443-
444438
/// Pushes the obligations required for an alias (except inherent) to be WF
445439
/// into `self.out`.
446440
fn compute_alias_term(&mut self, data: ty::AliasTerm<'tcx>) {
@@ -498,7 +492,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
498492
self.out.extend(obligations);
499493
}
500494

501-
self.compute_projection_args(data.args);
495+
data.args.visit_with(self);
502496
}
503497

504498
fn compute_projection_args(&mut self, args: GenericArgsRef<'tcx>) {
@@ -702,8 +696,8 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
702696
}
703697

704698
ty::Alias(ty::Projection | ty::Opaque | ty::Weak, data) => {
705-
self.compute_alias_ty(data);
706-
return; // Subtree handled by compute_projection.
699+
let obligations = self.nominal_obligations(data.def_id, data.args);
700+
self.out.extend(obligations);
707701
}
708702
ty::Alias(ty::Inherent, data) => {
709703
self.compute_inherent_projection(data);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait Trait {
2+
type Gat<U: ?Sized>;
3+
}
4+
5+
fn test<T>(f: for<'a> fn(<&'a T as Trait>::Gat<&'a [str]>)) where for<'a> &'a T: Trait {}
6+
//~^ ERROR the size for values of type `str` cannot be known at compilation time
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0277]: the size for values of type `str` cannot be known at compilation time
2+
--> $DIR/well-formed-aliases.rs:5:52
3+
|
4+
LL | fn test<T>(f: for<'a> fn(<&'a T as Trait>::Gat<&'a [str]>)) where for<'a> &'a T: Trait {}
5+
| ^^^^^ doesn't have a size known at compile-time
6+
|
7+
= help: the trait `Sized` is not implemented for `str`
8+
= note: slice and array elements must have `Sized` type
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)