Skip to content
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

clippy broken on nightly #3506

Closed
oli-obk opened this issue Dec 7, 2018 · 7 comments
Closed

clippy broken on nightly #3506

oli-obk opened this issue Dec 7, 2018 · 7 comments
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Dec 7, 2018

rust-lang/rust#56066 (comment) broke clippy. Not sure how yet.

@matthiaskrgr
Copy link
Member

relevant log output

[01:04:10] failures:
[01:04:10]
[01:04:10] ---- [ui] ui/cast_alignment.rs stdout ----
[01:04:10] normalized stderr:
[01:04:10] error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
[01:04:10]   --> $DIR/cast_alignment.rs:25:5
[01:04:10]    |
[01:04:10] 25 |     (&1u8 as *const u8) as *const u16;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]    |
[01:04:10]    = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
[01:04:10]
[01:04:10] error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
[01:04:10]   --> $DIR/cast_alignment.rs:26:5
[01:04:10]    |
[01:04:10] 26 |     (&mut 1u8 as *mut u8) as *mut u16;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]
[01:04:10] error: casting from `*const libc::c_void` to a more-strictly-aligned pointer (`*const u32`)
[01:04:10]   --> $DIR/cast_alignment.rs:37:5
[01:04:10]    |
[01:04:10] 37 |     (&1u32 as *const u32 as *const libc::c_void) as *const u32;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]
[01:04:10] error: aborting due to 3 previous errors
[01:04:10]
[01:04:10]
[01:04:10]
[01:04:10] expected stderr:
[01:04:10] error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
[01:04:10]   --> $DIR/cast_alignment.rs:25:5
[01:04:10]    |
[01:04:10] 25 |     (&1u8 as *const u8) as *const u16;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]    |
[01:04:10]    = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
[01:04:10]
[01:04:10] error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
[01:04:10]   --> $DIR/cast_alignment.rs:26:5
[01:04:10]    |
[01:04:10] 26 |     (&mut 1u8 as *mut u8) as *mut u16;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]
[01:04:10] error: aborting due to 2 previous errors
[01:04:10]
[01:04:10]
[01:04:10]
[01:04:10] diff of stderr:
[01:04:10]
[01:04:10]  error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
[01:04:10]    --> $DIR/cast_alignment.rs:25:5
[01:04:10]     |
[01:04:10]  25 |     (&1u8 as *const u8) as *const u16;
[01:04:10]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]     |
[01:04:10]     = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
[01:04:10]
[01:04:10]  error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
[01:04:10]    --> $DIR/cast_alignment.rs:26:5
[01:04:10]     |
[01:04:10]  26 |     (&mut 1u8 as *mut u8) as *mut u16;
[01:04:10]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]
[01:04:10] -error: aborting due to 2 previous errors
[01:04:10] +error: casting from `*const libc::c_void` to a more-strictly-aligned pointer (`*const u32`)
[01:04:10] +  --> $DIR/cast_alignment.rs:37:5
[01:04:10] +   |
[01:04:10] +37 |     (&1u32 as *const u32 as *const libc::c_void) as *const u32;
[01:04:10] +   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10] +
[01:04:10] +error: aborting due to 3 previous errors
[01:04:10]
[01:04:10]
[01:04:10]
[01:04:10] The actual stderr differed from the expected stderr.
[01:04:10] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-b15fab67c6160a74/out/test_build_base/cast_alignment.stderr
[01:04:10] To update references, run this command from build directory:
[01:04:10] tests/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-b15fab67c6160a74/out/test_build_base' 'cast_alignment.rs'
[01:04:10]
[01:04:10] error: 1 errors occurred comparing output.
[01:04:10] status: exit code: 1
[01:04:10] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/clippy-driver" "tests/ui/cast_alignment.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-b15fab67c6160a74/out/test_build_base" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-b15fab67c6160a74/out/test_build_base/cast_alignment.stage-id" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "-Dwarnings" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-b15fab67c6160a74/out/test_build_base/cast_alignment.stage-id.aux" "-A" "unused"
[01:04:10] stdout:
[01:04:10] ------------------------------------------
[01:04:10]
[01:04:10] ------------------------------------------
[01:04:10] stderr:
[01:04:10] ------------------------------------------
[01:04:10] error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
[01:04:10]   --> tests/ui/cast_alignment.rs:25:5
[01:04:10]    |
[01:04:10] 25 |     (&1u8 as *const u8) as *const u16;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]    |
[01:04:10]    = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
[01:04:10]
[01:04:10] error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
[01:04:10]   --> tests/ui/cast_alignment.rs:26:5
[01:04:10]    |
[01:04:10] 26 |     (&mut 1u8 as *mut u8) as *mut u16;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]
[01:04:10] error: casting from `*const libc::c_void` to a more-strictly-aligned pointer (`*const u32`)
[01:04:10]   --> tests/ui/cast_alignment.rs:37:5
[01:04:10]    |
[01:04:10] 37 |     (&1u32 as *const u32 as *const libc::c_void) as *const u32;
[01:04:10]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:04:10]
[01:04:10] error: aborting due to 3 previous errors
[01:04:10]
[01:04:10]
[01:04:10] ------------------------------------------
[01:04:10]
[01:04:10] thread '[ui] ui/cast_alignment.rs' panicked at 'explicit panic', /cargo/registry/src/github.com-1ecc6299db9ec823/compiletest_rs-0.3.17/src/runtest.rs:2553:9
[01:04:10] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:04:10]
[01:04:10]
[01:04:10] failures:
[01:04:10]     [ui] ui/cast_alignment.rs
[01:04:10]
[01:04:10] test result: FAILED. 226 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out
[01:04:10]
[01:04:10] test compile_test ... FAILED
[01:04:10]
[01:04:10] failures:
[01:04:10]
[01:04:10] ---- compile_test stdout ----
[01:04:10] thread 'compile_test' panicked at 'Some tests failed', /cargo/registry/src/github.com-1ecc6299db9ec823/compiletest_rs-0.3.17/src/lib.rs:89:22
[01:04:10]
[01:04:10]
[01:04:10] failures:
[01:04:10]     compile_test
[01:04:10]
[01:04:10] test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:04:10]
[01:04:10] error: test failed, to rerun pass '--test compile-test'
[01:04:10]
[01:04:10]
[01:04:10] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/tools/clippy/Cargo.toml" "--features" "rustc-workspace-hack/all-static"
[01:04:10] expected success, got: exit code: 101
[01:04:10]
[01:04:10]

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Dec 7, 2018

-error: aborting due to 2 previous errors
+error: casting from `*const libc::c_void` to a more-strictly-aligned pointer (`*const u32`)
+  --> $DIR/cast_alignment.rs:37:5
+   |
+37 |     (&1u32 as *const u32 as *const libc::c_void) as *const u32;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors

the PR changed the libc module, so I guess libc::c_void changed under the hood causing clippy to additionally issue this warning.

If this is a TP, a simple test stderr update should suffice.

(I'm not that familiar with libc myself though)

@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 7, 2018

We should not report a lint on this situation. We have an exception for *c_void -> *T casts, so what is probably missing is an update of the path to c_void in

pub const C_VOID_LIBC: [&str; 2] = ["libc", "c_void"];

@phansch phansch added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 7, 2018
@phansch
Copy link
Member

phansch commented Dec 8, 2018

More specifically this seems to have been caused by this libc update: rust-lang/libc@c75ca64...5b40375 which was included in the SGX PR.

@phansch
Copy link
Member

phansch commented Dec 8, 2018

Pretty sure it was caused by this commit: rust-lang/libc@5c1a6b8. Now I will just have to figure out the new path of libc::cvoid.

@phansch
Copy link
Member

phansch commented Dec 8, 2018

This is weird. I think I found a bug in util::match_def_path()?

The ty path of the void type correctly reports libc::c_void but the DefId looks like DefId(5/0:3504 ~ libc[eac6]::unix[0]::c_void[0].

This is a problem because match_def_path compares the given path to the path of the given DefId and they are different in this case:

def_id: DefId(5/0:3504 ~ libc[eac6]::unix[0]::c_void[0])
path: ["libc", "c_void"]

Because they are different, the lint is triggered.

I'm not sure what the best fix would be here. @oli-obk

  1. We could add the paths for the different platforms to utils/paths.rs but that would require us to keep track of new platforms in libc.
  2. We could add a special case for libc that removes the platform specific path from the DefId, if that's possible.
  3. We could make the c_void check less strict, not checking the full path and instead just checking if it contains c_void.
  4. Is this perhaps a bug in rustc?

@phansch
Copy link
Member

phansch commented Dec 8, 2018

I need another coffee. The path and def_id are different because that's what we pass into match_def_id..

That rules out 4 and doesn't make it a bug with the function itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants