Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6f5d855

Browse files
committed
Handle inherent associated types fallout
1 parent 263a0de commit 6f5d855

15 files changed

+117
-72
lines changed

tests/rustdoc-json/type/inherent_associated_type_bound.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
// @set Carrier = '$.index[*][?(@.name=="Carrier")].id'
66
pub struct Carrier<'a>(&'a ());
77

8-
// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.generic_params[*].name' \""'b"\"
9-
// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier
10-
// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\"
11-
// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"'
12-
// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.trait' null
13-
// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"'
14-
15-
pub type User = for<'b> fn(Carrier<'b>::Focus<i32>);
8+
// @count "$.index[*][?(@.name=='user')].inner.function.decl.inputs[*]" 1
9+
// @is "$.index[*][?(@.name=='user')].inner.function.decl.inputs[0][0]" '"_"'
10+
// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.generic_params[*].name' \""'b"\"
11+
// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier
12+
// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\"
13+
// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"'
14+
// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.trait' null
15+
// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"'
16+
pub fn user(_: for<'b> fn(Carrier<'b>::Focus<i32>)) {}
1617

1718
impl<'a> Carrier<'a> {
1819
pub type Focus<T> = &'a mut T;

tests/rustdoc-json/type/inherent_associated_type_projections.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
// @set Parametrized = '$.index[*][?(@.name=="Parametrized")].id'
66
pub struct Parametrized<T>(T);
77

8-
// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.id' $Parametrized
9-
// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\"
10-
// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.name' '"Proj"'
11-
// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.trait' null
12-
pub type Test = Parametrized<i32>::Proj;
8+
// @count "$.index[*][?(@.name=='test')].inner.function.decl.inputs[*]" 1
9+
// @is "$.index[*][?(@.name=='test')].inner.function.decl.inputs[0][0]" '"_"'
10+
// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Parametrized
11+
// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\"
12+
// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.name' '"Proj"'
13+
// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.trait' null
14+
pub fn test(_: Parametrized<i32>::Proj) {}
1315

1416
/// param_bool
1517
impl Parametrized<bool> {

tests/rustdoc/inherent-projections.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ impl Owner {
1313
}
1414

1515
// Make sure we handle bound vars correctly.
16-
// @has 'inherent_projections/type.User.html' '//pre[@class="rust item-decl"]' "for<'a> fn(_: Carrier<'a>::Focus)"
17-
pub type User = for<'a> fn(Carrier<'a>::Focus);
16+
// @has 'inherent_projections/fn.user.html' '//pre[@class="rust item-decl"]' "user(_: for<'a> fn(_: Carrier<'a>::Focus))"
17+
pub fn user(_: for<'a> fn(Carrier<'a>::Focus)) {}
1818

1919
pub struct Carrier<'a>(&'a ());
2020

@@ -27,11 +27,11 @@ impl<'a> Carrier<'a> {
2727
// FIXME(inherent_associated_types): Below we link to `Proj` but we should link to `Proj-1`.
2828
// The current test checks for the buggy behavior for demonstration purposes.
2929

30-
// @has 'inherent_projections/type.Test.html'
31-
// @has - '//pre[@class="rust item-decl"]' "Parametrized<i32>"
30+
// @has 'inherent_projections/fn.test.html'
31+
// @has - '//pre[@class="rust item-decl"]' "test(_: Parametrized<i32>::Proj)"
3232
// @has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj'
3333
// @!has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj-1'
34-
pub type Test = Parametrized<i32>::Proj;
34+
pub fn test(_: Parametrized<i32>::Proj) {}
3535

3636
pub struct Parametrized<T>(T);
3737

tests/ui/associated-inherent-types/issue-111879-0.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
pub struct Carrier<'a>(&'a ());
77

8-
pub type User = for<'b> fn(Carrier<'b>::Focus<i32>);
9-
108
impl<'a> Carrier<'a> {
11-
pub type Focus<T> = &'a mut User; //~ ERROR overflow evaluating associated type
9+
pub type Focus<T> = &'a mut for<'b> fn(Carrier<'b>::Focus<i32>); //~ ERROR overflow evaluating associated type
1210
}
1311

1412
fn main() {}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: overflow evaluating associated type `Carrier<'b>::Focus<i32>`
2-
--> $DIR/issue-111879-0.rs:11:25
2+
--> $DIR/issue-111879-0.rs:9:25
33
|
4-
LL | pub type Focus<T> = &'a mut User;
5-
| ^^^^^^^^^^^^
4+
LL | pub type Focus<T> = &'a mut for<'b> fn(Carrier<'b>::Focus<i32>);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: aborting due to previous error
88

tests/ui/associated-inherent-types/late-bound-regions.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// Test if we correctly normalize `S<'a>::P` with respect to late-bound regions.
55

6-
type Function = for<'a> fn(&'a i32) -> S<'a>::P;
7-
86
struct S<'a>(&'a ());
97

108
trait Inter {
@@ -16,7 +14,7 @@ impl<'a> S<'a> {
1614
}
1715

1816
fn ret_ref_local<'e>() -> &'e i32 {
19-
let f: Function = |x| x;
17+
let f: for<'a> fn(&'a i32) -> S<'a>::P = |x| x;
2018

2119
let local = 0;
2220
f(&local) //~ ERROR cannot return value referencing local variable `local`

tests/ui/associated-inherent-types/late-bound-regions.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0515]: cannot return value referencing local variable `local`
2-
--> $DIR/late-bound-regions.rs:22:5
2+
--> $DIR/late-bound-regions.rs:20:5
33
|
44
LL | f(&local)
55
| ^^------^

tests/ui/associated-inherent-types/not-found-self-type-differs.alias.stderr

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/ui/associated-inherent-types/not-found-self-type-differs.local.stderr

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// revisions: local alias
2-
31
#![feature(inherent_associated_types)]
42
#![allow(incomplete_features)]
53

@@ -13,10 +11,7 @@ impl<T> Family<Result<T, ()>> {
1311
type Proj = Self;
1412
}
1513

16-
#[cfg(alias)]
17-
type Alias = Family<Option<()>>::Proj; //[alias]~ ERROR associated type `Proj` not found for `Family<Option<()>>`
18-
1914
fn main() {
20-
#[cfg(local)]
21-
let _: Family<std::path::PathBuf>::Proj = (); //[local]~ ERROR associated type `Proj` not found for `Family<PathBuf>`
15+
let _: Family<Option<()>>::Proj; //~ ERROR associated type `Proj` not found for `Family<Option<()>>`
16+
let _: Family<std::path::PathBuf>::Proj = (); //~ ERROR associated type `Proj` not found for `Family<PathBuf>`
2217
}

0 commit comments

Comments
 (0)