Skip to content

Code snippet is machine dependent #45149

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

Closed
gaurikholkar-zz opened this issue Oct 9, 2017 · 1 comment
Closed

Code snippet is machine dependent #45149

gaurikholkar-zz opened this issue Oct 9, 2017 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gaurikholkar-zz
Copy link

fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32
where F: FnOnce(&'a i32, &i32) -> &'a i32
{
    let y = 22;
    f(x, &y)
}

fn foo<'a>(x: &'a i32) {
    invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
}

This UI test was moved to compile-fail as the finer details of the error seemed to vary on different machines.

Following are the Logs

[01:35:31] failures:
[01:35:31] 
[01:35:31] ---- [ui] ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.rs stdout ----
[01:35:31] 	ui: /checkout/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.rs
[01:35:31] normalized stderr:
[01:35:31] error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |     ^^^^^^
[01:35:31]    |
[01:35:31] note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 19:16...
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:16
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:35:31] note: ...so that reference does not outlive borrowed content
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:45
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |                                             ^
[01:35:31] note: but, the lifetime must be valid for the call at 19:5...
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:35:31] note: ...so that argument is valid for the call
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:12
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |            ^^
[01:35:31] 
[01:35:31] error: aborting due to previous error(s)
[01:35:31] 
[01:35:31] 
[01:35:31] 
[01:35:31] expected stderr:
[01:35:31] error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |     ^^^^^^
[01:35:31]    |
[01:35:31] note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 19:16...
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:16
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:35:31] note: ...so that reference does not outlive borrowed content
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:45
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |                                             ^
[01:35:31] note: but, the lifetime must be valid for the expression at 19:5...
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |     ^^^^^^
[01:35:31] note: ...so that a type/lifetime parameter is in scope here
[01:35:31]   --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]    |
[01:35:31] 19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]    |     ^^^^^^
[01:35:31] 
[01:35:31] error: aborting due to previous error(s)
[01:35:31] 
[01:35:31] 
[01:35:31] 
[01:35:31] diff of stderr:
[01:35:31] 
[01:35:31]  error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
[01:35:31]    --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]     |
[01:35:31]  19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]     |     ^^^^^^
[01:35:31]     |
[01:35:31]  note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 19:16...
[01:35:31]    --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:16
[01:35:31]     |
[01:35:31]  19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:35:31]  note: ...so that reference does not outlive borrowed content
[01:35:31]    --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:45
[01:35:31]     |
[01:35:31]  19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31]     |                                             ^
[01:35:31] -note: but, the lifetime must be valid for the expression at 19:5...
[01:35:31] +note: but, the lifetime must be valid for the call at 19:5...
[01:35:31]    --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31]     |
[01:35:31]  19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31] -   |     ^^^^^^
[01:35:31] -note: ...so that a type/lifetime parameter is in scope here
[01:35:31] -  --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5
[01:35:31] +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:35:31] +note: ...so that argument is valid for the call
[01:35:31] +  --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:12
[01:35:31]     |
[01:35:31]  19 |     invoke(&x, |a, b| if a > b { a } else { b });
[01:35:31] -   |     ^^^^^^
[01:35:31] +   |            ^^
[01:35:31]  
[01:35:31]  error: aborting due to previous error(s)

Check here for more details

cc @nikomatsakis

@XAMPPRocky XAMPPRocky added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jan 22, 2018
@Mark-Simulacrum
Copy link
Member

This is a UI test today afaict so closing (https://github.com/rust-lang/rust/blob/master/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs and a few others were checked manually).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants