diff options
| author | Urgau <urgau@numericable.fr> | 2024-02-14 19:12:19 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2024-02-14 19:23:20 +0100 |
| commit | ddec8c5edc488e3eec27ed59a4d8e5dbaad4130f (patch) | |
| tree | 22724e0fd2ecc5b3ed7b38287847cc7ebfc2a54b /compiler/rustc_lint/src/reference_casting.rs | |
| parent | 502ce8287bc3c86dca07acc38c5ff9431a6097be (diff) | |
| download | rust-ddec8c5edc488e3eec27ed59a4d8e5dbaad4130f.tar.gz rust-ddec8c5edc488e3eec27ed59a4d8e5dbaad4130f.zip | |
Ignore unsized types when trying to determine the size of a type
Diffstat (limited to 'compiler/rustc_lint/src/reference_casting.rs')
| -rw-r--r-- | compiler/rustc_lint/src/reference_casting.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index 519ab8bd50f..f386db9d8db 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -207,6 +207,13 @@ fn is_cast_to_bigger_memory_layout<'tcx>( } let from_layout = cx.layout_of(*inner_start_ty).ok()?; + + // if the type isn't sized, we bail out, instead of potentially giving + // the user a meaningless warning. + if from_layout.is_unsized() { + return None; + } + let alloc_layout = cx.layout_of(alloc_ty).ok()?; let to_layout = cx.layout_of(*inner_end_ty).ok()?; |
