-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #64250 - Xanewok:save-analysis-assoc-nested, r=varkor
save-analysis: Nest typeck tables when processing functions/methods Fixes an issue where we did not nest tables correctly when resolving associated types in formal argument/return type positions. This was the minimized reproduction case that I tested the fix on: ```rust pub trait Trait { type Assoc; } pub struct A; pub fn func() { fn _inner1<U: Trait>(_: U::Assoc) {} fn _inner2<U: Trait>() -> U::Assoc { unimplemented!() } impl A { fn _inner1<U: Trait>(self, _: U::Assoc) {} fn _inner2<U: Trait>(self) -> U::Assoc { unimplemented!() } } } ``` using `debug_assertions`-enabled rustc and by additionally passing `-Zsave-analysis`. Unfortunately the original assertion fired is a *debug* one and from what I can tell we don't run the tests with these on, so I'm not adding a test here. If I missed it and there is a way to run tests with these on, I'd love to add a test case for this. Closes #63663 Closes #50328 Closes #43982
- Loading branch information
Showing
3 changed files
with
79 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// check-pass | ||
// compile-flags: -Zsave-analysis | ||
|
||
// Check that this doesn't ICE when processing associated const in formal | ||
// argument and return type of functions defined inside function/method scope. | ||
|
||
pub trait Trait { | ||
type Assoc; | ||
} | ||
|
||
pub struct A; | ||
|
||
pub fn func() { | ||
fn _inner1<U: Trait>(_: U::Assoc) {} | ||
fn _inner2<U: Trait>() -> U::Assoc { unimplemented!() } | ||
|
||
impl A { | ||
fn _inner1<U: Trait>(self, _: U::Assoc) {} | ||
fn _inner2<U: Trait>(self) -> U::Assoc { unimplemented!() } | ||
} | ||
} | ||
|
||
fn main() {} |