From 7411e25abe1bb6d32b5f9949950201bcfe6250e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 26 Aug 2023 19:53:11 +0000 Subject: [PATCH] Account for `Weak` alias kinds when adding more targetted obligation --- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 6 ++++-- ...n-crate-has-lazy-type-aliases.locally_eager.stderr | 8 ++++---- ...rn-crate-has-lazy-type-aliases.locally_lazy.stderr | 8 ++++---- tests/ui/lazy-type-alias/trailing-where-clause.stderr | 11 +++++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 823422fab14..7707cc6de54 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -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); } diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr index 9e0e2bfa872..3b216ac1581 100644 --- a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr @@ -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; - | ^^^^^^^^^^^^^^^^^^^ 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 = Option; - | ^^^^ required by this bound + | ^^^^ required by this bound in `Alias` error: aborting due to previous error diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr index 9e0e2bfa872..3b216ac1581 100644 --- a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr @@ -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; - | ^^^^^^^^^^^^^^^^^^^ 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 = Option; - | ^^^^ required by this bound + | ^^^^ required by this bound in `Alias` error: aborting due to previous error diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.stderr b/tests/ui/lazy-type-alias/trailing-where-clause.stderr index d7606ba6b2a..193f80b23d3 100644 --- a/tests/ui/lazy-type-alias/trailing-where-clause.stderr +++ b/tests/ui/lazy-type-alias/trailing-where-clause.stderr @@ -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`: > @@ -11,11 +11,14 @@ LL | let _: Alias<()>; > > > -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 + | ----- required by a bound in this type alias +LL | where LL | String: From; - | ^^^^^^^ required by this bound + | ^^^^^^^ required by this bound in `Alias` error: aborting due to previous error