-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
librustc: Don't pass around Session with @ and make building_library just bool instead of @mut bool. #9551
Conversation
@@ -864,12 +867,10 @@ pub fn Resolver(session: Session, | |||
|
|||
/// The main resolver class. | |||
pub struct Resolver { | |||
session: @Session, | |||
session: Cell<Session>, |
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.
It seems weird to have Cell
inside of a structure, it's normally only ever used for transferring ownership between closures. What's the use-case here?
My concern over the cell should get alleviated once #9556 lands |
#9556 has landed, and this needs a rebase. |
…just bool instead of @mut bool.
I'm a little uneasy about the |
// since we know the session will outlive it, we just cheat | ||
// and tell it the session has a static lifetime | ||
let s: &'static session::Session = unsafe { | ||
cast::transmute(s) |
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.
I think that this transmute in particular is not a safe assumption. Someone using the compiler libraries could fairly easily construct a situation in which the tcx outlives the session (unintentionally), only to get befuddled once segfaults start cropping up.
Closing this for now. |
…r=xFrednet [`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop` fix rust-lang#9427 changelog: [`unnecessary_lazy_evaluations`] Do not suggest switching to early evaluation when type has custom `Drop`
Having to dereference
sess.building_library
is really annoying so this fixes that! Also, Session is no longer passed around with @.2 caveats, due to pervasive use of @ in rustc there are 2 points where I just transmute to a
&'static Session
to put intoResolver
andty::ctxt
which is probably fine given that the session will outlive them.