Change:
The following code example () produces the output <details</detailsThe second example also unexpectedly compiles in full NLL mode.
I renamed the title to focus on the part I would most like to investigate, which is why this function works but only with feature-nll: That seems like a blocker to disabling migration mode.
cc
marking P-medium to reflect that this is solely about , not migration mode (). When the latter becomes higher priority, this will likewise be raised up.
Update: this is only an issue now with
blocks
Diagnostics triage: this is not a diagnostics issue
This is now a compiler error with :
Yes, but it should be two compiler errors, one in makef and one on makeg.
Looking at this further - why don't we want to compile? It looks perfectly correct to me.
Running this example with my branch from yields, among some other errors: This error seems correct. If I had to guess the problem with NLL, though, I would guess that this is working because of the rule -- in other words, we are inferring to be implemented for and we are (not incorrectly) deducing that . My branch rejects this because I specifically tried to disallow that. I am not entirely convinced that we should disallow this -- it's just that doesn't have a very natural analog in polonius (though you can make it make sense). In fact, the idea of is kind of useful, or could be, so it may be that we want to accept it. If we want to disallow this example, I think we'll have to extend NLL to have a similarly "graded" notion of . I imagine the way to do this would be to extend the set of elements to include "empty" elements in each universe we create, and then permit these empty elements get to all the "free regions" in the root universe.
On the latest nightly, passing causes and to produce . I think this is now purely a diagnostic issue, rather than a soundness issue.

Discussion:
<ins> // Regression test for issue #57642 // Tests that we reject a bad higher-ranked subtype // with `#![feature(nll)]` #![feature(nll)] trait X { type G; fn make_g() -> Self::G; } impl<'a> X for fn(&'a ()) { type G = &'a (); fn make_g() -> Self::G { &() } } trait Y { type F; fn make_f() -> Self::F; } impl<T> Y for fn(T) { type F = fn(T); fn make_f() -> Self::F { |_| {} } } fn higher_ranked_region_has_lost_its_binder() { let x = <fn (&())>::make_g(); //~ ERROR no function } fn magical() { let x = <fn (&())>::make_f(); //~ ERROR no function } fn main() {} </ins>

<ins> error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'r> fn(&'r ())` in the current scope --> $DIR/issue-57642-higher-ranked-subtype.rs:34:25 | LL |     let x = <fn (&())>::make_g(); |                         ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` | = note: the method `make_g` exists but the following trait bounds were not satisfied: `for<'r> fn(&'r ()): X` = help: items from traits can only be used if the trait is implemented and in scope note: `X` defines an item `make_g`, perhaps you need to implement it --> $DIR/issue-57642-higher-ranked-subtype.rs:7:1 | LL | trait X { | ^^^^^^^ error[E0599]: no function or associated item named `make_f` found for fn pointer `for<'r> fn(&'r ())` in the current scope --> $DIR/issue-57642-higher-ranked-subtype.rs:38:25 | LL |     let x = <fn (&())>::make_f(); |                         ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` | = help: items from traits can only be used if the trait is implemented and in scope note: `Y` defines an item `make_f`, perhaps you need to implement it --> $DIR/issue-57642-higher-ranked-subtype.rs:20:1 | LL | trait Y { | ^^^^^^^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0599`. </ins>