Skip to content

supposedly unused unsafe blocks are really unsafe #6030

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
metajack opened this issue Apr 23, 2013 · 12 comments
Closed

supposedly unused unsafe blocks are really unsafe #6030

metajack opened this issue Apr 23, 2013 · 12 comments

Comments

@metajack
Copy link
Contributor

With #5797 many warnings were generated in Servo code. I attempted to remove these unused unsafe blocks, but I am very concerned that this lint mode is inaccurate. See metajack/servo@868c740#commitcomment-3066562 for a commit that has some comments from @jdm as well.

@metajack
Copy link
Contributor Author

ping @alexcrichton

@alexcrichton
Copy link
Member

Was that second reference to 5797 a typo? I don't see any comments by jdm there...

@metajack
Copy link
Contributor Author

Yes. I've updated the description.

@alexcrichton
Copy link
Member

Does servo not build with the unsafe blocks removed? If it builds then it's not a problem with the warning...

@metajack
Copy link
Contributor Author

It does build, yes. Perhaps the warning has just uncovered a compiler bug?

@alexcrichton
Copy link
Member

Well, this is either a compiler bug, or those functions legitimately don't need to be unsafe, I'd recommend double-checking that the definition of those functions in question are indeed marked as unsafe fn

@metajack
Copy link
Contributor Author

The first thing in that commit is calling an extern fn FT_Get_Sfnt_Table(face: FT_Face, tag: FT_Sfnt_Tag) -> *c_void;. Isn't this the definition of unsafe?

Farther down by one of @jdm's comments is a call to this extern:

pub fn JS_SetReservedSlot(++obj: JSRawObject, ++index: uint32_t, ++v: JSVal);

JSRawObject is an unsafe pointer here, but that shouldn't even matter since this is an FFI call.

@metajack
Copy link
Contributor Author

@brson @pcwalton comments?

@pcwalton
Copy link
Contributor

Yes, all C functions are unsafe (if that's what's being asked).

@brson
Copy link
Contributor

brson commented Apr 23, 2013

@metajack I think it's a bug. I also saw some suspiciously unsafe code in passing recently but didn't think much of it at the time.

@thestinger
Copy link
Contributor

A shot in the dark is that the pub use statements break this.

@alexcrichton
Copy link
Member

I believe this was fixed when @pcwalton introduced effect analysis awhile back in aeda178.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 24, 2020
…matthiaskrgr

fix some use of `snippet` in `types.rs`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants