Skip to content

Tweak region inference to ignore constraints like 'a <= 'static #13975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

nikomatsakis
Copy link
Contributor

Tweak region inference to ignore constraints like 'a <= 'static, since they
have no value. This also ensures that we can handle some obscure cases of fn
subtyping with bound regions that we didn't used to handle correctly.

Fixes #13974.

@nikomatsakis
Copy link
Contributor Author

r? @pnkfelix

@@ -299,6 +299,9 @@ impl<'a> RegionVarBindings<'a> {
sub.repr(self.tcx),
sup.repr(self.tcx)));
}
(_, ReStatic) => {
// all regions are subreigons of static, so we can ignore this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "subreigons"

@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2014

It might be good to put together a compile fail test for the other direction on 'static, just to make sure no one gets the direction of this relation backwards in the future. :)

@nikomatsakis
Copy link
Contributor Author

@pnkfelix good idea. In fact, this may have exposed a bug ;)

@nikomatsakis
Copy link
Contributor Author

@pnkfelix never mind, test was buggy

@nikomatsakis
Copy link
Contributor Author

actually, I remember now that my thought was that there are already tests covering the other direction. Still, doesn't hurt.

@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2014

@nikomatsakis (copied from IRC) : the earlier version of this PR had a run-pass test. It seems that in adding the compile-fail test, you removed the run-pass test from the PR. Do I misunderstand your intent here?

@nikomatsakis
Copy link
Contributor Author

@pnkfelix I moved it from run-pass to compile-fail since I added some calls that are expected to yield type errors

@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2014

@nikomatsakis i see; i usually try to factor such things into the run-pass part and the compile-fail part, just to try to make sure that a supposedly working test actually works, but I see your philosophy here.

@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2014

(also, that travis failure does look suspiciously related to this change...)

@nikomatsakis
Copy link
Contributor Author

Pushed new commit that should address travis failure.

@alexcrichton
Copy link
Member

Looks like there's still an error :(

…e they

have no value. This also ensures that we can handle some obscure cases of fn
subtyping with bound regions that we didn't used to handle correctly.

Fixes rust-lang#13974.
@nikomatsakis
Copy link
Contributor Author

OK, it oughta' work now gosh darn it.

@alexcrichton
Copy link
Member

ping @pnkfelix

@pnkfelix
Copy link
Member

oh does it work now? Thanks for the ping, will review tomorrow morning. :)

bors added a commit that referenced this pull request May 20, 2014
…-static, r=pnkfelix

Tweak region inference to ignore constraints like `'a <= 'static`, since they
have no value. This also ensures that we can handle some obscure cases of fn
subtyping with bound regions that we didn't used to handle correctly.

Fixes #13974.
@bors bors merged commit 7cdd02d into rust-lang:master May 21, 2014
@nikomatsakis nikomatsakis deleted the issue-13794-fn-subtyping-and-static branch March 30, 2016 16:13
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 13, 2023
…, r=DropDemBits

fix: Suppress extra indent after the end of field and function chains

(spurred on by <rust-lang/rust-analyzer#4182 (comment)>)

Caveat that this doesn't work for after tail expressions, although there shouldn't be anything after those anyways.

This also complicates when to reload the language configuration by nature of now always having a language configuration applicable.

Examples of indentation fixes:

```rs
fn main() {
    println!("Hello!"); // < enter here!
    // ... indents down here

    fs::read_to_string("soup") // < enter here!
    // ... still indents down here :(
        .map(|_| ())
        .map(|_| ()) // < enter here!
        // ... still indents down here :D
        .map_err(|_| ())
        .unwrap(); // < enter here!
    // ... indents down here :D

    // ... and subsequent enters stay at the same indent

    0.0f64
        .to_radians()
        .to_radians()
        .to_radians() // force semi on a new line
        ; // < enter here!
    // ... indents down here :D
}

fn tail_end() -> i32 {
    0i32.wrapping_abs()
        .wrapping_abs()
        .wrapping_abs()
        .wrapping_abs() // < enter here!
        // ... still indents here 🤷
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect fn subtyping with bound regions and 'static
4 participants