-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Compiler assertion failure with -O, zero-size struct, and NonCopyable #10028
Comments
NonCopyable::new was removed in #10575. Can you provide a test case not depending on NonCopyable::new? |
Yup, I can still reproduce it. You need two files for it. The first is a library crate, which compiles fine--let's call it #[crate_type="lib"];
#[unsafe_no_drop_flag]
pub struct ZeroLengthThingWithDestructor;
impl Drop for ZeroLengthThingWithDestructor {
fn drop(&mut self) {}
}
impl ZeroLengthThingWithDestructor {
pub fn new() -> ZeroLengthThingWithDestructor {
ZeroLengthThingWithDestructor
}
} The library crate compiles fine. Now try to compile this file that uses it with extern mod issue10028;
use issue10028::ZeroLengthThingWithDestructor;
struct Foo {
zero_length_thing: ZeroLengthThingWithDestructor
}
fn make_foo() -> Foo {
Foo { zero_length_thing: ZeroLengthThingWithDestructor::new() }
}
fn main() {
let _f:Foo = make_foo();
} This is basically the same test case I had before--I just replaced If you combine them into the same crate (even |
This has been fixed, flagging as needstest |
…ers, r=flip1995 Add `extra_unused_type_parameters` lint Closes rust-lang#9240. ~~Keeping this as draft for now, because of a bug that I don't know how to fix.~~ It seems that opaque return types are not walked properly, for some unknown reason. As in, the following: ```rust fn used_ret_opaque<A>() -> impl Iterator<Item = A> { std::iter::empty() } ``` This triggers the lint even though it shouldn't. Discussion on Zulip didn't illuminate any possible reasons why, so PR-ing this now to increase visibility. --- changelog: new lint: [`extra_unused_type_parameters`] [rust-lang#10028](rust-lang/rust-clippy#10028) <!-- changelog_checked -->
This program:
will cause the compiler to crash and print this when compiled with
-O
:(
dag_dawg.rs
was the file name I tried to compile.) Without-O
it compiles fine. If you replaceNonCopyable::new()
with justNonCopyable
it compiles fine, suggesting thatNonCopyable::new()
itself is no longer even necessary.I created my own version of
NonCopyable
in another crate and linked to it. The crash reproduced only if, likestd::NonCopyable
, my struct had the attribute#[unsafe_no_drop_flag]
.Add a non-zero-length field to the struct and the crash goes away.
The text was updated successfully, but these errors were encountered: