Auto merge of #42902 - petrochenkov:keydcrate, r=jseyfried
Make `$crate` a keyword Fixes https://github.com/rust-lang/rust/issues/42898 r? @jseyfried or @nrc
This commit is contained in:
commit
5eef7c7966
16 changed files with 184 additions and 121 deletions
23
src/test/compile-fail/dollar-crate-is-keyword-2.rs
Normal file
23
src/test/compile-fail/dollar-crate-is-keyword-2.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
mod a {}
|
||||
|
||||
macro_rules! m {
|
||||
() => {
|
||||
use a::$crate; //~ ERROR unresolved import `a::$crate`
|
||||
use a::$crate::b; //~ ERROR unresolved import `a::$crate::b`
|
||||
type A = a::$crate; //~ ERROR cannot find type `$crate` in module `a`
|
||||
}
|
||||
}
|
||||
|
||||
m!();
|
||||
|
||||
fn main() {}
|
||||
24
src/test/compile-fail/dollar-crate-is-keyword.rs
Normal file
24
src/test/compile-fail/dollar-crate-is-keyword.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
macro_rules! m {
|
||||
() => {
|
||||
struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate`
|
||||
|
||||
use $crate; // OK
|
||||
//~^ WARN `$crate` may not be imported
|
||||
use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate`
|
||||
//~^ WARN `$crate` may not be imported
|
||||
}
|
||||
}
|
||||
|
||||
m!();
|
||||
|
||||
fn main() {}
|
||||
21
src/test/compile-fail/use-self-type.rs
Normal file
21
src/test/compile-fail/use-self-type.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
fn f() {}
|
||||
fn g() {
|
||||
use Self::f; //~ ERROR unresolved import
|
||||
pub(in Self::f) struct Z; //~ ERROR Use of undeclared type or module `Self`
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
fn macro() { //~ ERROR `macro` is a reserved keyword
|
||||
fn macro() { //~ ERROR expected identifier, found reserved keyword `macro`
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue