-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use subtyping for UnsafeFnPointer
coercion, too
#129288
Conversation
I don't feel comfortable to review this. |
ty_fn_ptr_from, | ||
*ty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you flip the args and check whether there's an existing test which goes from fail to pass to make sure we check for that potential unsoundness?
r=me after that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, tests/ui/nll/mir_check_cast_unsafe_fn.rs
checks this, which was added 7 years ago:
#![allow(dead_code)]
fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
// Here the NLL checker must relate the types in `f` to the types
// in `g`. These are related via the `UnsafeFnPointer` cast.
let g: unsafe fn(_) -> _ = f;
unsafe { g(input) }
//~^ ERROR lifetime may not live long enough
}
fn main() {}
@bors r=lcnr rollup |
…, r=lcnr Use subtyping for `UnsafeFnPointer` coercion, too I overlooked this in rust-lang#129059, which changed MIR typechecking to use subtyping for other fn pointer coercions. Fixes rust-lang#129285
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#129207 (Lint that warns when an elided lifetime ends up being a named lifetime) - rust-lang#129288 (Use subtyping for `UnsafeFnPointer` coercion, too) - rust-lang#129405 (Fixing span manipulation and indentation of the suggestion introduced by rust-lang#126187) - rust-lang#129518 (gitignore: ignore ICE reports regardless of directory) - rust-lang#129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR) - rust-lang#129544 (Removes dead code from the compiler) - rust-lang#129553 (add back test for stable-const-can-only-call-stable-const) - rust-lang#129590 (Avoid taking reference of &TyKind) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#129288 (Use subtyping for `UnsafeFnPointer` coercion, too) - rust-lang#129405 (Fixing span manipulation and indentation of the suggestion introduced by rust-lang#126187) - rust-lang#129518 (gitignore: ignore ICE reports regardless of directory) - rust-lang#129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR) - rust-lang#129525 (rustdoc: clean up tuple <-> primitive conversion docs) - rust-lang#129526 (Use `FxHasher` on new solver unconditionally) - rust-lang#129544 (Removes dead code from the compiler) - rust-lang#129553 (add back test for stable-const-can-only-call-stable-const) - rust-lang#129590 (Avoid taking reference of &TyKind) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#129288 (Use subtyping for `UnsafeFnPointer` coercion, too) - rust-lang#129405 (Fixing span manipulation and indentation of the suggestion introduced by rust-lang#126187) - rust-lang#129518 (gitignore: ignore ICE reports regardless of directory) - rust-lang#129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR) - rust-lang#129525 (rustdoc: clean up tuple <-> primitive conversion docs) - rust-lang#129526 (Use `FxHasher` on new solver unconditionally) - rust-lang#129544 (Removes dead code from the compiler) - rust-lang#129553 (add back test for stable-const-can-only-call-stable-const) - rust-lang#129590 (Avoid taking reference of &TyKind) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129288 - compiler-errors:unsafe-fn-coercion, r=lcnr Use subtyping for `UnsafeFnPointer` coercion, too I overlooked this in rust-lang#129059, which changed MIR typechecking to use subtyping for other fn pointer coercions. Fixes rust-lang#129285
I overlooked this in #129059, which changed MIR typechecking to use subtyping for other fn pointer coercions.
Fixes #129285