Skip to content

Commit 7411e25

Browse files
committed
Account for Weak alias kinds when adding more targetted obligation
1 parent ef11db8 commit 7411e25

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,10 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
318318
fn record_ty(&self, hir_id: hir::HirId, ty: Ty<'tcx>, span: Span) {
319319
// FIXME: normalization and escaping regions
320320
let ty = if !ty.has_escaping_bound_vars() {
321-
if let ty::Alias(ty::AliasKind::Projection, ty::AliasTy { args, def_id, .. }) =
322-
ty.kind()
321+
if let ty::Alias(
322+
ty::AliasKind::Projection | ty::AliasKind::Weak,
323+
ty::AliasTy { args, def_id, .. },
324+
) = ty.kind()
323325
{
324326
self.add_required_obligations_for_hir(span, *def_id, args, hir_id);
325327
}

tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0277]: the trait bound `String: Copy` is not satisfied
2-
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
2+
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24
33
|
44
LL | let _: lazy::Alias<String>;
5-
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
5+
| ^^^^^^ the trait `Copy` is not implemented for `String`
66
|
7-
note: required by a bound on the type alias `Alias`
7+
note: required by a bound in `lazy::Alias`
88
--> $DIR/auxiliary/lazy.rs:4:19
99
|
1010
LL | pub type Alias<T: Copy> = Option<T>;
11-
| ^^^^ required by this bound
11+
| ^^^^ required by this bound in `Alias`
1212

1313
error: aborting due to previous error
1414

tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0277]: the trait bound `String: Copy` is not satisfied
2-
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
2+
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24
33
|
44
LL | let _: lazy::Alias<String>;
5-
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
5+
| ^^^^^^ the trait `Copy` is not implemented for `String`
66
|
7-
note: required by a bound on the type alias `Alias`
7+
note: required by a bound in `lazy::Alias`
88
--> $DIR/auxiliary/lazy.rs:4:19
99
|
1010
LL | pub type Alias<T: Copy> = Option<T>;
11-
| ^^^^ required by this bound
11+
| ^^^^ required by this bound in `Alias`
1212

1313
error: aborting due to previous error
1414

tests/ui/lazy-type-alias/trailing-where-clause.stderr

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `String: From<()>` is not satisfied
2-
--> $DIR/trailing-where-clause.rs:12:12
2+
--> $DIR/trailing-where-clause.rs:12:18
33
|
44
LL | let _: Alias<()>;
5-
| ^^^^^^^^^ the trait `From<()>` is not implemented for `String`
5+
| ^^ the trait `From<()>` is not implemented for `String`
66
|
77
= help: the following other types implement trait `From<T>`:
88
<String as From<char>>
@@ -11,11 +11,14 @@ LL | let _: Alias<()>;
1111
<String as From<&str>>
1212
<String as From<&mut str>>
1313
<String as From<&String>>
14-
note: required by a bound on the type alias `Alias`
14+
note: required by a bound in `Alias`
1515
--> $DIR/trailing-where-clause.rs:8:13
1616
|
17+
LL | type Alias<T> = T
18+
| ----- required by a bound in this type alias
19+
LL | where
1720
LL | String: From<T>;
18-
| ^^^^^^^ required by this bound
21+
| ^^^^^^^ required by this bound in `Alias`
1922

2023
error: aborting due to previous error
2124

0 commit comments

Comments
 (0)