Skip to content

Invalid help suggestion #56714

Closed
Closed
@bjorn3

Description

@bjorn3
Member
error[E0609]: no field `opts` on type `*mut rustc::session::Session`
   --> src/lib.rs:143:54
    |
143 |             (sess as *const Session as *mut Session).opts.cli_forced_codegen_units = Some(1);
    |                                                      ^^^^
help: `sess as *const Session as *mut Session` is a native pointer; try dereferencing it
    |
143 |             (sess as *const Session as *mut Session).(*sess as *const Session as *mut Session).opts.cli_forced_codegen_units = Some(1);
    | 

Activity

oli-obk

oli-obk commented on Dec 11, 2018

@oli-obk
Contributor

Can you provide a minimal repro as a regression test?

jonas-schievink

jonas-schievink commented on Dec 11, 2018

@jonas-schievink
Contributor

(they should also be called raw pointers, not native, unless that terminology has changed recently)

bjorn3

bjorn3 commented on Dec 11, 2018

@bjorn3
MemberAuthor
struct Session {
    opts: u8
}

fn main() {
    let sess: &Session = &Session { opts: 0 };
    (sess as *const Session as *mut Session).opts = 42;
}

Edit: smaller repro

added 4 commits that reference this issue on Dec 23, 2018

Rollup merge of rust-lang#56966 - varkor:raw-pointer-deref-parens, r=…

ae6164c

Rollup merge of rust-lang#56966 - varkor:raw-pointer-deref-parens, r=…

d875fcd

Rollup merge of rust-lang#56966 - varkor:raw-pointer-deref-parens, r=…

eb24b33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @oli-obk@jonas-schievink@bjorn3

        Issue actions

          Invalid help suggestion · Issue #56714 · rust-lang/rust