Skip to content
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

Try disallowing keywords as identifiers #2275

Closed
brson opened this issue Apr 24, 2012 · 9 comments
Closed

Try disallowing keywords as identifiers #2275

brson opened this issue Apr 24, 2012 · 9 comments
Labels
A-grammar Area: The grammar of Rust A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@brson
Copy link
Contributor

brson commented Apr 24, 2012

The distinction between bad words and contextual keywords is difficult to keep track of. Built-in types are no longer keywords, which allows us to create things like mod int. It may be fairly easy now to disallow keywords as identifiers.

@ghost ghost assigned brson Apr 24, 2012
@graydon
Copy link
Contributor

graydon commented Apr 25, 2012

I agree, though this is RFC-level to the extent that others probably ought to comment.

@catamorphism
Copy link
Contributor

I agree. Simplify!

@pcwalton
Copy link
Contributor

pcwalton commented Jun 5, 2012

Agreed.

@bstrie
Copy link
Contributor

bstrie commented Jul 17, 2012

Is this done? I note that this program doesn't compile:

fn main() {
    let pure: ~str = ~"asdf";
    io::println(pure);
}

Same if you replace pure with for or fn.

@bblum
Copy link
Contributor

bblum commented Jul 25, 2012

Not done; the program works with with or move as the identifier name.

I'm in favour of this change. Makes syntax hilighting easier.

@metajack
Copy link
Contributor

This appears to be necessary to make the grammar LL(1). See https://mail.mozilla.org/pipermail/rust-dev/2013-April/003780.html

@bstrie
Copy link
Contributor

bstrie commented Apr 25, 2013

Regardless of the grammar situation, this is still a good change to make. Let's not bother enabling IF IF THEN THEN ELSE ELSE.

@emberian
Copy link
Member

I think this is fixed, but it needs a testcase for every keyword... simple way would be to write a script that sucks in the list of keywords and spits out a file for each of them, generated from a simple template. Needs to do this to ensure that they each don't compile.

bors added a commit that referenced this issue Aug 27, 2013
This is a pull request for #2275

I've created a small python script to generate test files for a list of keywords (as break do else enum extern false fn for if impl let loop match mod mut priv pub ref return self static struct super true trait type unsafe use while), but I'm not really sure where to put it. I've added the created files as well.

I did not use 

     fn main() {
        let $KW = "foo"; //~ error
        println($KW); //~ error
    } 

as template, because for return, self, ref, loop, mut and break this does not raise an error in the ```println``` line, only in the ```let``` line.
@pnkfelix
Copy link
Member

Closed by PR #8739

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
…, r=RalfJung

Enable permissive provenance by default

This completes the plan laid out in rust-lang/miri#2133:
- We use permissive provenance with wildcard pointers by default.
- We print a warning on int2ptr casts. `-Zmiri-permissive-provenance` suppresses the warning; `-Zmiri-strict-provenance` turns it into a hard error.
- Raw pointer tagging is now always enabled, so we remove the `-Zmiri-tag-raw-pointers` flag and the code for untagged pointers. (Passing the flag still works, for compatibility -- but we just ignore it, with a warning.)

We also fix an intptrcast issue:
- Only live allocations are considered when computing the AllocId from an address.

So, finally, Miri has a good story for ptr2int2ptr roundtrips *and* no weird false negatives when doing raw pointer stuff with Stacked Borrows. :-) 🎉   Thanks a lot to everyone who helped with this, in particular `@carbotaniuman` who convinced me this is even possible.

Fixes rust-lang/miri#2133
Fixes rust-lang/miri#1866
Fixes rust-lang/miri#1993
jieyouxu pushed a commit to jieyouxu/rust that referenced this issue Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

9 participants