-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[WIP] Tracking the unsolved variables that was assigned !
type
#78051
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||
---|---|---|---|---|---|---|
|
@@ -2555,6 +2555,13 @@ declare_lint! { | |||||
@feature_gate = sym::unsafe_block_in_unsafe_fn; | ||||||
} | ||||||
|
||||||
declare_lint! { | ||||||
//FIXME: Add explanation. | ||||||
pub FALL_BACK_TO_NEVER_TYPE, | ||||||
Deny, | ||||||
"Unresolved variable might fall back to never_type `!`" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: the style for user visible messages is not to have leading upper-case titling.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot @estebank I will make the change. |
||||||
} | ||||||
|
||||||
declare_lint! { | ||||||
/// The `cenum_impl_drop_cast` lint detects an `as` cast of a field-less | ||||||
/// `enum` that implements [`Drop`]. | ||||||
|
@@ -2770,6 +2777,7 @@ declare_lint_pass! { | |||||
MISSING_DOC_CODE_EXAMPLES, | ||||||
INVALID_HTML_TAGS, | ||||||
PRIVATE_DOC_TESTS, | ||||||
FALL_BACK_TO_NEVER_TYPE, | ||||||
WHERE_CLAUSES_OBJECT_SAFETY, | ||||||
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, | ||||||
MACRO_USE_EXTERN_CRATE, | ||||||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/issue-75777.rs:13:5 | ||
| | ||
LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | ||
| -- lifetime `'a` defined here | ||
LL | let fut: BoxFuture<'a, A> = Box::pin(future::ready(v)); | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` | ||
| | ||
= help: consider replacing `'a` with `'static` | ||
|
||
error: aborting due to previous error | ||
|
This file contains hidden or 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,17 @@ | ||
// Regression test for #75777. | ||
// Checks that a boxed future can be properly constructed. | ||
|
||
#![feature(future_readiness_fns)] | ||
|
||
use std::future::{self, Future}; | ||
use std::pin::Pin; | ||
|
||
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a + Send>>; | ||
|
||
fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | ||
let fut: BoxFuture<'a, A> = Box::pin(future::ready(v)); | ||
Box::new(move |_| fut) | ||
//~^ ERROR: cannot infer an appropriate lifetime | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,30 @@ | ||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements | ||
--> $DIR/issue-75777.rs:13:14 | ||
| | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^ | ||
| | ||
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 11:11... | ||
--> $DIR/issue-75777.rs:11:11 | ||
| | ||
LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | ||
| ^^ | ||
note: ...so that the types are compatible | ||
--> $DIR/issue-75777.rs:13:14 | ||
| | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^ | ||
= note: expected `(Pin<Box<dyn Future<Output = A> + Send>>,)` | ||
found `(Pin<Box<(dyn Future<Output = A> + Send + 'a)>>,)` | ||
= note: but, the lifetime must be valid for the static lifetime... | ||
note: ...so that the expression is assignable | ||
--> $DIR/issue-75777.rs:13:5 | ||
| | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: expected `Box<(dyn FnOnce(&'a Env) -> Pin<Box<(dyn Future<Output = A> + Send + 'a)>> + 'static)>` | ||
found `Box<dyn FnOnce(&'a Env) -> Pin<Box<(dyn Future<Output = A> + Send + 'a)>>>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0495`. |
11 changes: 11 additions & 0 deletions
11
src/test/ui/never_type/never_type_false_warning_unreachable.rs
This file contains hidden or 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,11 @@ | ||
#![deny(fall_back_to_never_type)] | ||
|
||
macro_rules! unreachable1 { | ||
() => {{ panic!("internal error: entered unreachable code") }}; | ||
} | ||
|
||
fn get_unchecked() { | ||
unreachable1!(); | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,15 @@ | ||
#![feature(never_type_fallback)] | ||
|
||
fn make_unit() {} | ||
|
||
fn unconstrained_return<T>() -> T { | ||
unsafe { | ||
let make_unit_fn: fn() = make_unit; | ||
let ffi: fn() -> T = std::mem::transmute(make_unit_fn); | ||
ffi() | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = if true { unconstrained_return() } else { panic!() }; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.