Skip to content

Bare raw pointers have been disallowed forever #32915

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

Merged
merged 2 commits into from
Apr 15, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1532,9 +1532,8 @@ impl<'a> Parser<'a> {
} else {
let span = self.last_span;
self.span_err(span,
"bare raw pointers are no longer allowed, you should \
likely use `*mut T`, but otherwise `*T` is now \
known as `*const T`");
"bare raw pointers are not allowed, use `*mut T` or \
`*const T` as appropriate");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great sentiment. Can we change the wording even more? It doesn't make sense to say "bare raw pointer" when that doesn't exist as a concept (?). Technically, it's just "expected mut or const in raw pointer type (use *mut T or *const T as appropriate)", something like that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your wording. I have updated the message.

Mutability::Immutable
};
let t = self.parse_ty()?;
Expand Down
15 changes: 15 additions & 0 deletions src/test/parse-fail/bare-raw-pointer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z parse-only

fn foo(_: *()) {
//~^ bare raw pointers are not allowed, use `*mut T` or `*const T` as appropriate
}