Account for Weak alias kinds when adding more targetted obligation

This commit is contained in:
Esteban Küber 2023-08-26 19:53:11 +00:00
parent ef11db803c
commit 7411e25abe
4 changed files with 19 additions and 14 deletions

View File

@ -318,8 +318,10 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
fn record_ty(&self, hir_id: hir::HirId, ty: Ty<'tcx>, span: Span) {
// FIXME: normalization and escaping regions
let ty = if !ty.has_escaping_bound_vars() {
if let ty::Alias(ty::AliasKind::Projection, ty::AliasTy { args, def_id, .. }) =
ty.kind()
if let ty::Alias(
ty::AliasKind::Projection | ty::AliasKind::Weak,
ty::AliasTy { args, def_id, .. },
) = ty.kind()
{
self.add_required_obligations_for_hir(span, *def_id, args, hir_id);
}

View File

@ -1,14 +1,14 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24
|
LL | let _: lazy::Alias<String>;
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound on the type alias `Alias`
note: required by a bound in `lazy::Alias`
--> $DIR/auxiliary/lazy.rs:4:19
|
LL | pub type Alias<T: Copy> = Option<T>;
| ^^^^ required by this bound
| ^^^^ required by this bound in `Alias`
error: aborting due to previous error

View File

@ -1,14 +1,14 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24
|
LL | let _: lazy::Alias<String>;
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound on the type alias `Alias`
note: required by a bound in `lazy::Alias`
--> $DIR/auxiliary/lazy.rs:4:19
|
LL | pub type Alias<T: Copy> = Option<T>;
| ^^^^ required by this bound
| ^^^^ required by this bound in `Alias`
error: aborting due to previous error

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `String: From<()>` is not satisfied
--> $DIR/trailing-where-clause.rs:12:12
--> $DIR/trailing-where-clause.rs:12:18
|
LL | let _: Alias<()>;
| ^^^^^^^^^ the trait `From<()>` is not implemented for `String`
| ^^ the trait `From<()>` is not implemented for `String`
|
= help: the following other types implement trait `From<T>`:
<String as From<char>>
@ -11,11 +11,14 @@ LL | let _: Alias<()>;
<String as From<&str>>
<String as From<&mut str>>
<String as From<&String>>
note: required by a bound on the type alias `Alias`
note: required by a bound in `Alias`
--> $DIR/trailing-where-clause.rs:8:13
|
LL | type Alias<T> = T
| ----- required by a bound in this type alias
LL | where
LL | String: From<T>;
| ^^^^^^^ required by this bound
| ^^^^^^^ required by this bound in `Alias`
error: aborting due to previous error