]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #57232 - Zoxc:par-collector-misc, r=michaelwoerister
authorMazdak Farrokhzad <twingoow@gmail.com>
Mon, 14 Jan 2019 10:31:49 +0000 (11:31 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Jan 2019 10:31:49 +0000 (11:31 +0100)
Parallelize and optimize parts of HIR map creation

r? @michaelwoerister

66 files changed:
Cargo.lock
src/ci/docker/dist-various-1/Dockerfile
src/librustc/hir/intravisit.rs
src/librustc/hir/map/blocks.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/traits/error_reporting.rs
src/librustc/traits/mod.rs
src/librustc/traits/structural_impls.rs
src/librustc_lint/nonstandard_style.rs
src/librustc_typeck/check/mod.rs
src/libsyntax/diagnostics/plugin.rs
src/libsyntax_ext/test.rs
src/test/run-pass/binding/match-static-const-rename.rs [deleted file]
src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs [deleted file]
src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs [deleted file]
src/test/run-pass/snake-case-no-lowercase-equivalent.rs [deleted file]
src/test/run-pass/test-allow-non-camel-case-variant.rs [deleted file]
src/test/ui/associated-const/associated-const-upper-case-lint.rs [deleted file]
src/test/ui/associated-const/associated-const-upper-case-lint.stderr [deleted file]
src/test/ui/enable-unstable-lib-feature.stderr
src/test/ui/expr_attr_paren_order.stderr
src/test/ui/if-else-type-mismatch.rs [new file with mode: 0644]
src/test/ui/if-else-type-mismatch.stderr [new file with mode: 0644]
src/test/ui/if/if-branch-types.stderr
src/test/ui/issues/issue-17718-const-naming.rs
src/test/ui/issues/issue-17718-const-naming.stderr
src/test/ui/lint/command-line-lint-group-deny.stderr
src/test/ui/lint/command-line-lint-group-forbid.stderr
src/test/ui/lint/command-line-lint-group-warn.stderr
src/test/ui/lint/lint-group-nonstandard-style.stderr
src/test/ui/lint/lint-lowercase-static-const-pattern-rename.rs [new file with mode: 0644]
src/test/ui/lint/lint-lowercase-static-const-pattern.rs [new file with mode: 0644]
src/test/ui/lint/lint-lowercase-static-const-pattern.stderr [new file with mode: 0644]
src/test/ui/lint/lint-non-camel-case-types.rs
src/test/ui/lint/lint-non-camel-case-types.stderr
src/test/ui/lint/lint-non-camel-case-variant.rs [new file with mode: 0644]
src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs [new file with mode: 0644]
src/test/ui/lint/lint-non-snake-case-crate-2.rs
src/test/ui/lint/lint-non-snake-case-crate-2.stderr
src/test/ui/lint/lint-non-snake-case-crate.rs
src/test/ui/lint/lint-non-snake-case-crate.stderr
src/test/ui/lint/lint-non-snake-case-functions.rs
src/test/ui/lint/lint-non-snake-case-functions.stderr
src/test/ui/lint/lint-non-snake-case-lifetimes.rs
src/test/ui/lint/lint-non-snake-case-lifetimes.stderr
src/test/ui/lint/lint-non-snake-case-modules.rs
src/test/ui/lint/lint-non-snake-case-modules.stderr
src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs [new file with mode: 0644]
src/test/ui/lint/lint-non-uppercase-associated-const.rs [new file with mode: 0644]
src/test/ui/lint/lint-non-uppercase-associated-const.stderr [new file with mode: 0644]
src/test/ui/lint/lint-non-uppercase-statics.rs
src/test/ui/lint/lint-non-uppercase-statics.stderr
src/test/ui/lint/lint-nonstandard-style-unicode.rs [new file with mode: 0644]
src/test/ui/lint/lint-uppercase-variables.rs
src/test/ui/lint/lint-uppercase-variables.stderr
src/test/ui/lint/reasons.stderr
src/test/ui/match/match-static-const-lc.rs [deleted file]
src/test/ui/match/match-static-const-lc.stderr [deleted file]
src/test/ui/regions/region-invariant-static-error-reporting.stderr
src/test/ui/regions/regions-fn-subtyping-return-static.rs
src/test/ui/regions/regions-fn-subtyping-return-static.stderr [deleted file]
src/test/ui/span/issue-24690.stderr
src/test/ui/str/str-array-assignment.stderr
src/test/ui/utf8_idents.rs
src/test/ui/utf8_idents.stderr
src/tools/build-manifest/src/main.rs

index 1fde5ac8cb15a25e813549b416b275ba528255c4..d3c6054f4da373b12c1d54c4e590fbfacf2aacb6 100644 (file)
@@ -97,7 +97,7 @@ name = "backtrace-sys"
 version = "0.1.27"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "compiler_builtins 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-std-workspace-core 1.0.0",
@@ -131,7 +131,7 @@ name = "bootstrap"
 version = "0.0.0"
 dependencies = [
  "build_helper 0.1.0",
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -264,7 +264,7 @@ version = "0.1.0"
 
 [[package]]
 name = "cc"
-version = "1.0.25"
+version = "1.0.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -382,7 +382,7 @@ name = "cmake"
 version = "0.1.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -414,7 +414,7 @@ name = "compiler_builtins"
 version = "0.1.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-std-workspace-core 1.0.0",
 ]
 
@@ -608,7 +608,7 @@ name = "curl-sys"
 version = "0.4.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "libnghttp2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1077,7 +1077,7 @@ name = "jemalloc-sys"
 version = "0.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -1161,7 +1161,7 @@ name = "libgit2-sys"
 version = "0.7.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1175,7 +1175,7 @@ name = "libnghttp2-sys"
 version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1184,7 +1184,7 @@ name = "libssh2-sys"
 version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1197,7 +1197,7 @@ name = "libz-sys"
 version = "1.0.25"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1237,7 +1237,7 @@ name = "lzma-sys"
 version = "0.1.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1343,7 +1343,7 @@ name = "miniz-sys"
 version = "0.1.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1360,7 +1360,7 @@ name = "miniz_oxide_c_api"
 version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1474,7 +1474,7 @@ name = "openssl-src"
 version = "111.1.0+1.1.1a"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -1482,7 +1482,7 @@ name = "openssl-sys"
 version = "0.9.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-src 111.1.0+1.1.1a (registry+https://github.com/rust-lang/crates.io-index)",
  "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1681,7 +1681,7 @@ version = "0.0.0"
 name = "profiler_builtins"
 version = "0.0.0"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "compiler_builtins 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core 0.0.0",
 ]
@@ -2323,7 +2323,7 @@ dependencies = [
 name = "rustc_codegen_llvm"
 version = "0.0.0"
 dependencies = [
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2335,7 +2335,7 @@ name = "rustc_codegen_ssa"
 version = "0.0.0"
 dependencies = [
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "jobserver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2485,7 +2485,7 @@ name = "rustc_llvm"
 version = "0.0.0"
 dependencies = [
  "build_helper 0.1.0",
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2900,7 +2900,7 @@ version = "0.0.0"
 dependencies = [
  "alloc 0.0.0",
  "backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
- "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "compiler_builtins 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "core 0.0.0",
  "dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3411,7 +3411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
 "checksum bytesize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "716960a18f978640f25101b5cbf1c6f6b0d3192fab36a2d98ca96f0ecbe41010"
 "checksum cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d8dfe3adeb30f7938e6c1dd5327f29235d8ada3e898aeb08c343005ec2915a2"
-"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
+"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
 "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
 "checksum chalk-engine 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17ec698a6f053a23bfbe646d9f2fde4b02abc19125595270a99e6f44ae0bdd1a"
 "checksum chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "295635afd6853aa9f20baeb7f0204862440c0fe994c5a253d5f479dac41d047e"
index 4f8a3c0240e1a19b50938da2acf7b5f5e2740b97..76cdd367987b2c1cb1419abe4b2bb6c1ae419591 100644 (file)
@@ -21,12 +21,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
   patch \
   libssl-dev \
   pkg-config \
-  gcc-arm-none-eabi \
   libnewlib-arm-none-eabi \
-  qemu-system-arm
+  qemu-system-arm \
+# software-properties-common for the add-apt-repository command
+  software-properties-common
 
 WORKDIR /build
 
+# Use the team-gcc-arm-embedded PPA for a newer version of Arm GCC
+RUN add-apt-repository ppa:team-gcc-arm-embedded/ppa && \
+    apt-get update && \
+    apt-get install -y --no-install-recommends gcc-arm-embedded
+
 COPY dist-various-1/build-rumprun.sh /build
 RUN ./build-rumprun.sh
 
@@ -103,6 +109,7 @@ ENV TARGETS=$TARGETS,thumbv6m-none-eabi
 ENV TARGETS=$TARGETS,thumbv7m-none-eabi
 ENV TARGETS=$TARGETS,thumbv7em-none-eabi
 ENV TARGETS=$TARGETS,thumbv7em-none-eabihf
+ENV TARGETS=$TARGETS,thumbv8m.main-none-eabi
 ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
 ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
 ENV TARGETS=$TARGETS,armebv7r-none-eabi
index d4f891c874a40cc4eb31f235e76a56e016134f85..f633703be56d409106b73e1c8b9913acdd64935b 100644 (file)
 
 #[derive(Copy, Clone)]
 pub enum FnKind<'a> {
-    /// #[xxx] pub async/const/extern "Abi" fn foo()
-    ItemFn(Name, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
+    /// `#[xxx] pub async/const/extern "Abi" fn foo()`
+    ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
 
-    /// fn foo(&self)
+    /// `fn foo(&self)`
     Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
 
-    /// |x, y| {}
+    /// `|x, y| {}`
     Closure(&'a [Attribute]),
 }
 
@@ -472,7 +472,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
             visitor.visit_nested_body(body);
         }
         ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
-            visitor.visit_fn(FnKind::ItemFn(item.ident.name,
+            visitor.visit_fn(FnKind::ItemFn(item.ident,
                                             generics,
                                             header,
                                             &item.vis,
index 837a20ac0f2f02590b8cab93b62580817d7206d7..f61b8551927bbd659b680bb6ce1deee18868b914 100644 (file)
@@ -15,7 +15,7 @@
 use hir::map;
 use hir::{Expr, FnDecl, Node};
 use hir::intravisit::FnKind;
-use syntax::ast::{Attribute, Ident, Name, NodeId};
+use syntax::ast::{Attribute, Ident, NodeId};
 use syntax_pos::Span;
 
 /// An FnLikeNode is a Node that is like a fn, in that it has a decl
@@ -98,7 +98,7 @@ pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
 /// These are all the components one can extract from a fn item for
 /// use when implementing FnLikeNode operations.
 struct ItemFnParts<'a> {
-    name:     Name,
+    ident:    Ident,
     decl:     &'a ast::FnDecl,
     header:   ast::FnHeader,
     vis:      &'a ast::Visibility,
@@ -200,7 +200,7 @@ pub fn unsafety(self) -> ast::Unsafety {
 
     pub fn kind(self) -> FnKind<'a> {
         let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
-            FnKind::ItemFn(p.name, p.generics, p.header, p.vis, p.attrs)
+            FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs)
         };
         let closure = |c: ClosureParts<'a>| {
             FnKind::Closure(c.attrs)
@@ -228,7 +228,7 @@ fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
                 ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
                     item_fn(ItemFnParts {
                         id: i.id,
-                        name: i.ident.name,
+                        ident: i.ident,
                         decl: &decl,
                         body: block,
                         vis: &i.vis,
index f71cce8273c46db336fee0eb92e96708457bf842..2995b25308d4c9f455565cf6278f92fa3e3fd988 100644 (file)
@@ -511,6 +511,18 @@ fn note_error_origin(&self, err: &mut DiagnosticBuilder<'tcx>, cause: &Obligatio
                     }
                 }
             },
+            ObligationCauseCode::IfExpression { then, outer, semicolon } => {
+                err.span_label(then, "expected because of this");
+                outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
+                if let Some(sp) = semicolon {
+                    err.span_suggestion_short_with_applicability(
+                        sp,
+                        "consider removing this semicolon",
+                        String::new(),
+                        Applicability::MachineApplicable,
+                    );
+                }
+            }
             _ => (),
         }
     }
@@ -1460,7 +1472,7 @@ fn as_failure_code(&self, terr: &TypeError<'tcx>) -> FailureCode {
                 }
                 _ => "match arms have incompatible types",
             }),
-            IfExpression => Error0308("if and else have incompatible types"),
+            IfExpression { .. } => Error0308("if and else have incompatible types"),
             IfExpressionWithNoElse => Error0317("if may be missing an else clause"),
             MainFunctionType => Error0580("main function has wrong type"),
             StartFunctionType => Error0308("start function has wrong type"),
@@ -1488,7 +1500,7 @@ fn as_requirement_str(&self) -> &'static str {
                 hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
                 _ => "match arms have compatible types",
             },
-            IfExpression => "if and else have compatible types",
+            IfExpression { .. } => "if and else have compatible types",
             IfExpressionWithNoElse => "if missing an else returns ()",
             MainFunctionType => "`main` function has the correct type",
             StartFunctionType => "`start` function has the correct type",
index 7d9e80fd60f5c345020a1e72739539d3703f62a4..367a7eacdfcaf50dd4e61a592f163f65a79e82ad 100644 (file)
@@ -1445,7 +1445,7 @@ fn note_obligation_cause_code<T>(&self,
             ObligationCauseCode::ExprAssignable |
             ObligationCauseCode::MatchExpressionArm { .. } |
             ObligationCauseCode::MatchExpressionArmPattern { .. } |
-            ObligationCauseCode::IfExpression |
+            ObligationCauseCode::IfExpression { .. } |
             ObligationCauseCode::IfExpressionWithNoElse |
             ObligationCauseCode::MainFunctionType |
             ObligationCauseCode::StartFunctionType |
index 14c25b77a1b8213f855f2dfde4dc3129c2a7e3c2..68383bef37a6a90d4f40cc93c43182ea7b40df94 100644 (file)
@@ -229,7 +229,11 @@ pub enum ObligationCauseCode<'tcx> {
     MatchExpressionArmPattern { span: Span, ty: Ty<'tcx> },
 
     /// Computing common supertype in an if expression
-    IfExpression,
+    IfExpression {
+        then: Span,
+        outer: Option<Span>,
+        semicolon: Option<Span>,
+    },
 
     /// Computing common supertype of an if expression with no else counter-part
     IfExpressionWithNoElse,
index 277e2ed0e87d26980ba2f021a23a891847c7a3c5..2f5df022218fe3fd4e71c6d0ec0f230f2785b5d5 100644 (file)
@@ -520,7 +520,11 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
             super::MatchExpressionArmPattern { span, ty } => {
                 tcx.lift(&ty).map(|ty| super::MatchExpressionArmPattern { span, ty })
             }
-            super::IfExpression => Some(super::IfExpression),
+            super::IfExpression { then, outer, semicolon } => Some(super::IfExpression {
+                then,
+                outer,
+                semicolon,
+            }),
             super::IfExpressionWithNoElse => Some(super::IfExpressionWithNoElse),
             super::MainFunctionType => Some(super::MainFunctionType),
             super::StartFunctionType => Some(super::StartFunctionType),
index 2694a04b94ce4c3106bdd2f81486325e6b0026da..a4a3fa552e9881627a9342126b7eb57452784379 100644 (file)
@@ -7,7 +7,8 @@
 use lint::{EarlyLintPass, LintPass, LateLintPass};
 use syntax::ast;
 use syntax::attr;
-use syntax_pos::Span;
+use syntax::errors::Applicability;
+use syntax_pos::{BytePos, symbol::Ident, Span};
 
 #[derive(PartialEq)]
 pub enum MethodLateContext {
@@ -40,13 +41,12 @@ pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext {
 pub struct NonCamelCaseTypes;
 
 impl NonCamelCaseTypes {
-    fn check_case(&self, cx: &EarlyContext, sort: &str, name: ast::Name, span: Span) {
+    fn check_case(&self, cx: &EarlyContext, sort: &str, ident: &Ident) {
         fn char_has_case(c: char) -> bool {
             c.is_lowercase() || c.is_uppercase()
         }
 
-        fn is_camel_case(name: ast::Name) -> bool {
-            let name = name.as_str();
+        fn is_camel_case(name: &str) -> bool {
             let name = name.trim_matches('_');
             if name.is_empty() {
                 return true;
@@ -86,14 +86,20 @@ fn to_camel_case(s: &str) -> String {
                 }).0
         }
 
+        let name = &ident.name.as_str();
+
         if !is_camel_case(name) {
-            let c = to_camel_case(&name.as_str());
-            let m = if c.is_empty() {
-                format!("{} `{}` should have a camel case name such as `CamelCase`", sort, name)
-            } else {
-                format!("{} `{}` should have a camel case name such as `{}`", sort, name, c)
-            };
-            cx.span_lint(NON_CAMEL_CASE_TYPES, span, &m);
+            let c = to_camel_case(name);
+
+            let msg = format!("{} `{}` should have a camel case name", sort, name);
+            cx.struct_span_lint(NON_CAMEL_CASE_TYPES, ident.span, &msg)
+                .span_suggestion_with_applicability(
+                    ident.span,
+                    "convert the identifier to camel case",
+                    c,
+                    Applicability::MaybeIncorrect,
+                )
+                .emit();
         }
     }
 }
@@ -122,19 +128,19 @@ fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
             ast::ItemKind::Ty(..) |
             ast::ItemKind::Enum(..) |
             ast::ItemKind::Struct(..) |
-            ast::ItemKind::Union(..) => self.check_case(cx, "type", it.ident.name, it.span),
-            ast::ItemKind::Trait(..) => self.check_case(cx, "trait", it.ident.name, it.span),
+            ast::ItemKind::Union(..) => self.check_case(cx, "type", &it.ident),
+            ast::ItemKind::Trait(..) => self.check_case(cx, "trait", &it.ident),
             _ => (),
         }
     }
 
     fn check_variant(&mut self, cx: &EarlyContext, v: &ast::Variant, _: &ast::Generics) {
-        self.check_case(cx, "variant", v.node.ident.name, v.span);
+        self.check_case(cx, "variant", &v.node.ident);
     }
 
     fn check_generic_param(&mut self, cx: &EarlyContext, param: &ast::GenericParam) {
         if let ast::GenericParamKind::Type { .. } = param.kind {
-            self.check_case(cx, "type parameter", param.ident.name, param.ident.span);
+            self.check_case(cx, "type parameter", &param.ident);
         }
     }
 }
@@ -179,7 +185,8 @@ fn to_snake_case(mut str: &str) -> String {
         words.join("_")
     }
 
-    fn check_snake_case(&self, cx: &LateContext, sort: &str, name: &str, span: Option<Span>) {
+    /// Checks if a given identifier is snake case, and reports a diagnostic if not.
+    fn check_snake_case(&self, cx: &LateContext, sort: &str, ident: &Ident) {
         fn is_snake_case(ident: &str) -> bool {
             if ident.is_empty() {
                 return true;
@@ -201,20 +208,28 @@ fn is_snake_case(ident: &str) -> bool {
             })
         }
 
+        let name = &ident.name.as_str();
+
         if !is_snake_case(name) {
             let sc = NonSnakeCase::to_snake_case(name);
-            let msg = if sc != name {
-                format!("{} `{}` should have a snake case name such as `{}`",
-                        sort,
-                        name,
-                        sc)
+
+            let msg = format!("{} `{}` should have a snake case name", sort, name);
+            let mut err = cx.struct_span_lint(NON_SNAKE_CASE, ident.span, &msg);
+
+            // We have a valid span in almost all cases, but we don't have one when linting a crate
+            // name provided via the command line.
+            if !ident.span.is_dummy() {
+                err.span_suggestion_with_applicability(
+                    ident.span,
+                    "convert the identifier to snake case",
+                    sc,
+                    Applicability::MaybeIncorrect,
+                );
             } else {
-                format!("{} `{}` should have a snake case name", sort, name)
-            };
-            match span {
-                Some(span) => cx.span_lint(NON_SNAKE_CASE, span, &msg),
-                None => cx.lint(NON_SNAKE_CASE, &msg),
+                err.help(&format!("convert the identifier to snake case: `{}`", sc));
             }
+
+            err.emit();
         }
     }
 }
@@ -227,50 +242,75 @@ fn get_lints(&self) -> LintArray {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
     fn check_crate(&mut self, cx: &LateContext, cr: &hir::Crate) {
-        let attr_crate_name = attr::find_by_name(&cr.attrs, "crate_name")
-            .and_then(|at| at.value_str().map(|s| (at, s)));
-        if let Some(ref name) = cx.tcx.sess.opts.crate_name {
-            self.check_snake_case(cx, "crate", name, None);
-        } else if let Some((attr, name)) = attr_crate_name {
-            self.check_snake_case(cx, "crate", &name.as_str(), Some(attr.span));
+        let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
+            Some(Ident::from_str(name))
+        } else {
+            attr::find_by_name(&cr.attrs, "crate_name")
+                .and_then(|attr| attr.meta())
+                .and_then(|meta| {
+                    meta.name_value_literal().and_then(|lit| {
+                        if let ast::LitKind::Str(name, ..) = lit.node {
+                            // Discard the double quotes surrounding the literal.
+                            let sp = cx.sess().source_map().span_to_snippet(lit.span)
+                                .ok()
+                                .and_then(|snippet| {
+                                    let left = snippet.find('"')?;
+                                    let right = snippet.rfind('"').map(|pos| snippet.len() - pos)?;
+
+                                    Some(
+                                        lit.span
+                                            .with_lo(lit.span.lo() + BytePos(left as u32 + 1))
+                                            .with_hi(lit.span.hi() - BytePos(right as u32)),
+                                    )
+                                })
+                                .unwrap_or_else(|| lit.span);
+
+                            Some(Ident::new(name, sp))
+                        } else {
+                            None
+                        }
+                    })
+                })
+        };
+
+        if let Some(ident) = &crate_ident {
+            self.check_snake_case(cx, "crate", ident);
         }
     }
 
     fn check_generic_param(&mut self, cx: &LateContext, param: &hir::GenericParam) {
-        match param.kind {
-            GenericParamKind::Lifetime { .. } => {
-                let name = param.name.ident().as_str();
-                self.check_snake_case(cx, "lifetime", &name, Some(param.span));
-            }
-            GenericParamKind::Type { .. } => {}
+        if let GenericParamKind::Lifetime { .. } = param.kind {
+            self.check_snake_case(cx, "lifetime", &param.name.ident());
         }
     }
 
-    fn check_fn(&mut self,
-                cx: &LateContext,
-                fk: FnKind,
-                _: &hir::FnDecl,
-                _: &hir::Body,
-                span: Span,
-                id: ast::NodeId) {
-        match fk {
-            FnKind::Method(name, ..) => {
+    fn check_fn(
+        &mut self,
+        cx: &LateContext,
+        fk: FnKind,
+        _: &hir::FnDecl,
+        _: &hir::Body,
+        _: Span,
+        id: ast::NodeId,
+    ) {
+        match &fk {
+            FnKind::Method(ident, ..) => {
                 match method_context(cx, id) {
                     MethodLateContext::PlainImpl => {
-                        self.check_snake_case(cx, "method", &name.as_str(), Some(span))
+                        self.check_snake_case(cx, "method", ident);
                     }
                     MethodLateContext::TraitAutoImpl => {
-                        self.check_snake_case(cx, "trait method", &name.as_str(), Some(span))
+                        self.check_snake_case(cx, "trait method", ident);
                     }
                     _ => (),
                 }
             }
-            FnKind::ItemFn(name, _, header, _, attrs) => {
+            FnKind::ItemFn(ident, _, header, _, attrs) => {
                 // Skip foreign-ABI #[no_mangle] functions (Issue #31924)
-                if header.abi != Abi::Rust && attr::find_by_name(attrs, "no_mangle").is_some() {
+                if header.abi != Abi::Rust && attr::contains_name(attrs, "no_mangle") {
                     return;
                 }
-                self.check_snake_case(cx, "function", &name.as_str(), Some(span))
+                self.check_snake_case(cx, "function", ident);
             }
             FnKind::Closure(_) => (),
         }
@@ -278,36 +318,35 @@ fn check_fn(&mut self,
 
     fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         if let hir::ItemKind::Mod(_) = it.node {
-            self.check_snake_case(cx, "module", &it.ident.as_str(), Some(it.span));
+            self.check_snake_case(cx, "module", &it.ident);
         }
     }
 
     fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) {
-        if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(ref pnames)) = item.node {
-            self.check_snake_case(cx,
-                                  "trait method",
-                                  &item.ident.as_str(),
-                                  Some(item.span));
+        if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node {
+            self.check_snake_case(cx, "trait method", &item.ident);
             for param_name in pnames {
-                self.check_snake_case(cx, "variable", &param_name.as_str(), Some(param_name.span));
+                self.check_snake_case(cx, "variable", param_name);
             }
         }
     }
 
     fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
-        if let &PatKind::Binding(_, _, ref ident, _) = &p.node {
-            self.check_snake_case(cx, "variable", &ident.as_str(), Some(p.span));
+        if let &PatKind::Binding(_, _, ident, _) = &p.node {
+            self.check_snake_case(cx, "variable", &ident);
         }
     }
 
-    fn check_struct_def(&mut self,
-                        cx: &LateContext,
-                        s: &hir::VariantData,
-                        _: ast::Name,
-                        _: &hir::Generics,
-                        _: ast::NodeId) {
+    fn check_struct_def(
+        &mut self,
+        cx: &LateContext,
+        s: &hir::VariantData,
+        _: ast::Name,
+        _: &hir::Generics,
+        _: ast::NodeId,
+    ) {
         for sf in s.fields() {
-            self.check_snake_case(cx, "structure field", &sf.ident.as_str(), Some(sf.span));
+            self.check_snake_case(cx, "structure field", &sf.ident);
         }
     }
 }
@@ -322,21 +361,21 @@ fn check_struct_def(&mut self,
 pub struct NonUpperCaseGlobals;
 
 impl NonUpperCaseGlobals {
-    fn check_upper_case(cx: &LateContext, sort: &str, name: ast::Name, span: Span) {
-        if name.as_str().chars().any(|c| c.is_lowercase()) {
-            let uc = NonSnakeCase::to_snake_case(&name.as_str()).to_uppercase();
-            if name != &*uc {
-                cx.span_lint(NON_UPPER_CASE_GLOBALS,
-                             span,
-                             &format!("{} `{}` should have an upper case name such as `{}`",
-                                      sort,
-                                      name,
-                                      uc));
-            } else {
-                cx.span_lint(NON_UPPER_CASE_GLOBALS,
-                             span,
-                             &format!("{} `{}` should have an upper case name", sort, name));
-            }
+    fn check_upper_case(cx: &LateContext, sort: &str, ident: &Ident) {
+        let name = &ident.name.as_str();
+
+        if name.chars().any(|c| c.is_lowercase()) {
+            let uc = NonSnakeCase::to_snake_case(&name).to_uppercase();
+
+            let msg = format!("{} `{}` should have an upper case name", sort, name);
+            cx.struct_span_lint(NON_UPPER_CASE_GLOBALS, ident.span, &msg)
+                .span_suggestion_with_applicability(
+                    ident.span,
+                    "convert the identifier to upper case",
+                    uc,
+                    Applicability::MaybeIncorrect,
+                )
+                .emit();
         }
     }
 }
@@ -350,38 +389,25 @@ fn get_lints(&self) -> LintArray {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
     fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         match it.node {
-            hir::ItemKind::Static(..) => {
-                if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
-                    return;
-                }
-                NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.ident.name,
-                                                      it.span);
+            hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, "no_mangle") => {
+                NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident);
             }
             hir::ItemKind::Const(..) => {
-                NonUpperCaseGlobals::check_upper_case(cx, "constant", it.ident.name,
-                                                      it.span);
+                NonUpperCaseGlobals::check_upper_case(cx, "constant", &it.ident);
             }
             _ => {}
         }
     }
 
     fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) {
-        match ti.node {
-            hir::TraitItemKind::Const(..) => {
-                NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
-                                                      ti.ident.name, ti.span);
-            }
-            _ => {}
+        if let hir::TraitItemKind::Const(..) = ti.node {
+            NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident);
         }
     }
 
     fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
-        match ii.node {
-            hir::ImplItemKind::Const(..) => {
-                NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
-                                                      ii.ident.name, ii.span);
-            }
-            _ => {}
+        if let hir::ImplItemKind::Const(..) = ii.node {
+            NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
         }
     }
 
@@ -390,10 +416,11 @@ fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
         if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node {
             if let Def::Const(..) = path.def {
                 if path.segments.len() == 1 {
-                    NonUpperCaseGlobals::check_upper_case(cx,
-                                                          "constant in pattern",
-                                                          path.segments[0].ident.name,
-                                                          path.span);
+                    NonUpperCaseGlobals::check_upper_case(
+                        cx,
+                        "constant in pattern",
+                        &path.segments[0].ident
+                    );
                 }
             }
         }
index dbbb7f42feb242bf98e71148c5c8c24049622413..1b07385d4d1f4e95da1d63627bddfddcda2e6f56 100644 (file)
@@ -3366,13 +3366,103 @@ fn check_then_else(&self,
         let coerce_to_ty = expected.coercion_target_type(self, sp);
         let mut coerce: DynamicCoerceMany = CoerceMany::new(coerce_to_ty);
 
-        let if_cause = self.cause(sp, ObligationCauseCode::IfExpression);
-        coerce.coerce(self, &if_cause, then_expr, then_ty);
+        coerce.coerce(self, &self.misc(sp), then_expr, then_ty);
 
         if let Some(else_expr) = opt_else_expr {
             let else_ty = self.check_expr_with_expectation(else_expr, expected);
             let else_diverges = self.diverges.get();
 
+            let mut outer_sp = if self.tcx.sess.source_map().is_multiline(sp) {
+                // The `if`/`else` isn't in one line in the output, include some context to make it
+                // clear it is an if/else expression:
+                // ```
+                // LL |      let x = if true {
+                //    | _____________-
+                // LL ||         10i32
+                //    ||         ----- expected because of this
+                // LL ||     } else {
+                // LL ||         10u32
+                //    ||         ^^^^^ expected i32, found u32
+                // LL ||     };
+                //    ||_____- if and else have incompatible types
+                // ```
+                Some(sp)
+            } else {
+                // The entire expression is in one line, only point at the arms
+                // ```
+                // LL |     let x = if true { 10i32 } else { 10u32 };
+                //    |                       -----          ^^^^^ expected i32, found u32
+                //    |                       |
+                //    |                       expected because of this
+                // ```
+                None
+            };
+            let mut remove_semicolon = None;
+            let error_sp = if let ExprKind::Block(block, _) = &else_expr.node {
+                if let Some(expr) = &block.expr {
+                    expr.span
+                } else if let Some(stmt) = block.stmts.last() {
+                    // possibly incorrect trailing `;` in the else arm
+                    remove_semicolon = self.could_remove_semicolon(block, then_ty);
+                    stmt.span
+                } else {  // empty block, point at its entirety
+                    // Avoid overlapping spans that aren't as readable:
+                    // ```
+                    // 2 |        let x = if true {
+                    //   |   _____________-
+                    // 3 |  |         3
+                    //   |  |         - expected because of this
+                    // 4 |  |     } else {
+                    //   |  |____________^
+                    // 5 | ||
+                    // 6 | ||     };
+                    //   | ||     ^
+                    //   | ||_____|
+                    //   | |______if and else have incompatible types
+                    //   |        expected integer, found ()
+                    // ```
+                    // by not pointing at the entire expression:
+                    // ```
+                    // 2 |       let x = if true {
+                    //   |               ------- if and else have incompatible types
+                    // 3 |           3
+                    //   |           - expected because of this
+                    // 4 |       } else {
+                    //   |  ____________^
+                    // 5 | |
+                    // 6 | |     };
+                    //   | |_____^ expected integer, found ()
+                    // ```
+                    if outer_sp.is_some() {
+                        outer_sp = Some(self.tcx.sess.source_map().def_span(sp));
+                    }
+                    else_expr.span
+                }
+            } else { // shouldn't happen unless the parser has done something weird
+                else_expr.span
+            };
+            let then_sp = if let ExprKind::Block(block, _) = &then_expr.node {
+                if let Some(expr) = &block.expr {
+                    expr.span
+                } else if let Some(stmt) = block.stmts.last() {
+                    // possibly incorrect trailing `;` in the else arm
+                    remove_semicolon = remove_semicolon.or(
+                        self.could_remove_semicolon(block, else_ty));
+                    stmt.span
+                } else {  // empty block, point at its entirety
+                    outer_sp = None;  // same as in `error_sp`, cleanup output
+                    then_expr.span
+                }
+            } else {  // shouldn't happen unless the parser has done something weird
+                then_expr.span
+            };
+
+            let if_cause = self.cause(error_sp, ObligationCauseCode::IfExpression {
+                then: then_sp,
+                outer: outer_sp,
+                semicolon: remove_semicolon,
+            });
+
             coerce.coerce(self, &if_cause, else_expr, else_ty);
 
             // We won't diverge unless both branches do (or the condition does).
@@ -5144,7 +5234,6 @@ fn suggest_missing_return_type(&self,
         }
     }
 
-
     /// A common error is to add an extra semicolon:
     ///
     /// ```
@@ -5156,31 +5245,43 @@ fn suggest_missing_return_type(&self,
     /// This routine checks if the final statement in a block is an
     /// expression with an explicit semicolon whose type is compatible
     /// with `expected_ty`. If so, it suggests removing the semicolon.
-    fn consider_hint_about_removing_semicolon(&self,
-                                              blk: &'gcx hir::Block,
-                                              expected_ty: Ty<'tcx>,
-                                              err: &mut DiagnosticBuilder) {
+    fn consider_hint_about_removing_semicolon(
+        &self,
+        blk: &'gcx hir::Block,
+        expected_ty: Ty<'tcx>,
+        err: &mut DiagnosticBuilder,
+    ) {
+        if let Some(span_semi) = self.could_remove_semicolon(blk, expected_ty) {
+            err.span_suggestion_with_applicability(
+                span_semi,
+                "consider removing this semicolon",
+                String::new(),
+                Applicability::MachineApplicable,
+            );
+        }
+    }
+
+    fn could_remove_semicolon(
+        &self,
+        blk: &'gcx hir::Block,
+        expected_ty: Ty<'tcx>,
+    ) -> Option<Span> {
         // Be helpful when the user wrote `{... expr;}` and
         // taking the `;` off is enough to fix the error.
         let last_stmt = match blk.stmts.last() {
             Some(s) => s,
-            None => return,
+            None => return None,
         };
         let last_expr = match last_stmt.node {
             hir::StmtKind::Semi(ref e, _) => e,
-            _ => return,
+            _ => return None,
         };
         let last_expr_ty = self.node_ty(last_expr.hir_id);
         if self.can_sub(self.param_env, last_expr_ty, expected_ty).is_err() {
-            return;
+            return None;
         }
         let original_span = original_sp(last_stmt.span, blk.span);
-        let span_semi = original_span.with_lo(original_span.hi() - BytePos(1));
-        err.span_suggestion_with_applicability(
-            span_semi,
-            "consider removing this semicolon",
-            String::new(),
-            Applicability::MachineApplicable);
+        Some(original_span.with_lo(original_span.hi() - BytePos(1)))
     }
 
     // Instantiates the given path, which must refer to an item with the given
index 71028ef9fc66a7ca488f49b80147982260c8fb77..fa6b825f2a2c21e8e4daa54aac69f5c3b7ae8167 100644 (file)
@@ -117,16 +117,18 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
             ));
         }
     });
-    let sym = Ident::with_empty_ctxt(Symbol::gensym(&format!(
-        "__register_diagnostic_{}", code
-    )));
+
+    let span = span.apply_mark(ecx.current_expansion.mark);
+
+    let sym = Ident::new(Symbol::gensym(&format!("__register_diagnostic_{}", code)), span);
+
     MacEager::items(smallvec![
         ecx.item_mod(
             span,
             span,
             sym,
-            Vec::new(),
-            Vec::new()
+            vec![],
+            vec![],
         )
     ])
 }
index cf842dddeb3d6cce4aeaeefbef83c00ce3386abf..a19d0458edd80309bc56365309c728046e4c4082 100644 (file)
@@ -124,14 +124,14 @@ pub fn expand_test_or_bench(
         ])
     };
 
-    let mut test_const = cx.item(sp, item.ident.gensym(),
+    let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name.gensymed(), sp),
         vec![
             // #[cfg(test)]
             cx.attribute(attr_sp, cx.meta_list(attr_sp, Symbol::intern("cfg"), vec![
                 cx.meta_list_item_word(attr_sp, Symbol::intern("test"))
             ])),
             // #[rustc_test_marker]
-            cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker")))
+            cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker"))),
         ],
         // const $ident: test::TestDescAndFn =
         ast::ItemKind::Const(cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
diff --git a/src/test/run-pass/binding/match-static-const-rename.rs b/src/test/run-pass/binding/match-static-const-rename.rs
deleted file mode 100644 (file)
index e78ae40..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// run-pass
-// Issue #7526: lowercase static constants in patterns look like bindings
-
-// This is similar to compile-fail/match-static-const-lc, except it
-// shows the expected usual workaround (choosing a different name for
-// the static definition) and also demonstrates that one can work
-// around this problem locally by renaming the constant in the `use`
-// form to an uppercase identifier that placates the lint.
-
-
-#![deny(non_upper_case_globals)]
-
-pub const A : isize = 97;
-
-fn f() {
-    let r = match (0,0) {
-        (0, A) => 0,
-        (x, y) => 1 + x + y,
-    };
-    assert_eq!(r, 1);
-    let r = match (0,97) {
-        (0, A) => 0,
-        (x, y) => 1 + x + y,
-    };
-    assert_eq!(r, 0);
-}
-
-mod m {
-    #[allow(non_upper_case_globals)]
-    pub const aha : isize = 7;
-}
-
-fn g() {
-    use self::m::aha as AHA;
-    let r = match (0,0) {
-        (0, AHA) => 0,
-        (x, y)   => 1 + x + y,
-    };
-    assert_eq!(r, 1);
-    let r = match (0,7) {
-        (0, AHA) => 0,
-        (x, y)   => 1 + x + y,
-    };
-    assert_eq!(r, 0);
-}
-
-fn h() {
-    let r = match (0,0) {
-        (0, self::m::aha) => 0,
-        (x, y)      => 1 + x + y,
-    };
-    assert_eq!(r, 1);
-    let r = match (0,7) {
-        (0, self::m::aha) => 0,
-        (x, y)      => 1 + x + y,
-    };
-    assert_eq!(r, 0);
-}
-
-pub fn main () {
-    f();
-    g();
-    h();
-}
diff --git a/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs b/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs
deleted file mode 100644 (file)
index a123abd..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-#![allow(dead_code)]
-
-
-#![forbid(non_camel_case_types)]
-#![forbid(non_upper_case_globals)]
-#![feature(non_ascii_idents)]
-
-// Some scripts (e.g., hiragana) don't have a concept of
-// upper/lowercase
-
-struct ヒ;
-
-static ラ: usize = 0;
-
-pub fn main() {}
diff --git a/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs b/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs
deleted file mode 100644 (file)
index 6c0ea83..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#![allow(dead_code)]
-// This is ok because we often use the trailing underscore to mean 'prime'
-
-// pretty-expanded FIXME #23616
-
-#[forbid(non_camel_case_types)]
-type Foo_ = isize;
-
-pub fn main() { }
diff --git a/src/test/run-pass/snake-case-no-lowercase-equivalent.rs b/src/test/run-pass/snake-case-no-lowercase-equivalent.rs
deleted file mode 100644 (file)
index cf7a163..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![allow(dead_code)]
-// pretty-expanded FIXME #23616
-
-#![feature(non_ascii_idents)]
-#![deny(non_snake_case)]
-
-// This name is neither upper nor lower case
-fn 你好() {}
-
-fn main() {}
diff --git a/src/test/run-pass/test-allow-non-camel-case-variant.rs b/src/test/run-pass/test-allow-non-camel-case-variant.rs
deleted file mode 100644 (file)
index da3ef7e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#![deny(non_camel_case_types)]
-
-pub enum Foo {
-    #[allow(non_camel_case_types)]
-    bar
-}
-
-fn main() {}
diff --git a/src/test/ui/associated-const/associated-const-upper-case-lint.rs b/src/test/ui/associated-const/associated-const-upper-case-lint.rs
deleted file mode 100644 (file)
index c851b27..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#![deny(non_upper_case_globals)]
-#![allow(dead_code)]
-
-struct Foo;
-
-impl Foo {
-    const not_upper: bool = true;
-}
-//~^^ ERROR associated constant `not_upper` should have an upper case name such as `NOT_UPPER`
-
-fn main() {}
diff --git a/src/test/ui/associated-const/associated-const-upper-case-lint.stderr b/src/test/ui/associated-const/associated-const-upper-case-lint.stderr
deleted file mode 100644 (file)
index 43feb03..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error: associated constant `not_upper` should have an upper case name such as `NOT_UPPER`
-  --> $DIR/associated-const-upper-case-lint.rs:7:5
-   |
-LL |     const not_upper: bool = true;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: lint level defined here
-  --> $DIR/associated-const-upper-case-lint.rs:1:9
-   |
-LL | #![deny(non_upper_case_globals)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
index d905ccc8ac070bccfc6a66d2e6d16f8ba7c12d78..51cfe7beade2dc467ffb4845a8e1f1f81585b68e 100644 (file)
@@ -1,8 +1,8 @@
-error: function `BOGUS` should have a snake case name such as `bogus`
-  --> $DIR/enable-unstable-lib-feature.rs:12:1
+error: function `BOGUS` should have a snake case name
+  --> $DIR/enable-unstable-lib-feature.rs:12:8
    |
 LL | pub fn BOGUS() { } //~ ERROR
-   | ^^^^^^^^^^^^^^^^^^
+   |        ^^^^^ help: convert the identifier to snake case: `bogus`
    |
 note: lint level defined here
   --> $DIR/enable-unstable-lib-feature.rs:6:9
index f3aa39f89cc3d1f5d698d9a8a4647e49ef42853c..8155514191ce35511f81bdae0a6f9a0f5602226f 100644 (file)
@@ -1,8 +1,8 @@
-error: variable `X` should have a snake case name such as `x`
+error: variable `X` should have a snake case name
   --> $DIR/expr_attr_paren_order.rs:19:17
    |
 LL |             let X = 0; //~ ERROR snake case name
-   |                 ^
+   |                 ^ help: convert the identifier to snake case: `x`
    |
 note: lint level defined here
   --> $DIR/expr_attr_paren_order.rs:17:17
diff --git a/src/test/ui/if-else-type-mismatch.rs b/src/test/ui/if-else-type-mismatch.rs
new file mode 100644 (file)
index 0000000..583c3d0
--- /dev/null
@@ -0,0 +1,46 @@
+fn main() {
+    let _ = if true {
+        1i32
+    } else {
+        2u32
+    };
+    //~^^ ERROR if and else have incompatible types
+    let _ = if true { 42i32 } else { 42u32 };
+    //~^ ERROR if and else have incompatible types
+    let _ = if true {
+        3u32;
+    } else {
+        4u32
+    };
+    //~^^ ERROR if and else have incompatible types
+    let _ = if true {
+        5u32
+    } else {
+        6u32;
+    };
+    //~^^ ERROR if and else have incompatible types
+    let _ = if true {
+        7i32;
+    } else {
+        8u32
+    };
+    //~^^ ERROR if and else have incompatible types
+    let _ = if true {
+        9i32
+    } else {
+        10u32;
+    };
+    //~^^ ERROR if and else have incompatible types
+    let _ = if true {
+
+    } else {
+        11u32
+    };
+    //~^^ ERROR if and else have incompatible types
+    let _ = if true {
+        12i32
+    } else {
+
+    };
+    //~^^^ ERROR if and else have incompatible types
+}
diff --git a/src/test/ui/if-else-type-mismatch.stderr b/src/test/ui/if-else-type-mismatch.stderr
new file mode 100644 (file)
index 0000000..b418c96
--- /dev/null
@@ -0,0 +1,130 @@
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:5:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         1i32
+   | |         ---- expected because of this
+LL | |     } else {
+LL | |         2u32
+   | |         ^^^^ expected i32, found u32
+LL | |     };
+   | |_____- if and else have incompatible types
+   |
+   = note: expected type `i32`
+              found type `u32`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:8:38
+   |
+LL |     let _ = if true { 42i32 } else { 42u32 };
+   |                       -----          ^^^^^ expected i32, found u32
+   |                       |
+   |                       expected because of this
+   |
+   = note: expected type `i32`
+              found type `u32`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:13:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         3u32;
+   | |         -----
+   | |         |   |
+   | |         |   help: consider removing this semicolon
+   | |         expected because of this
+LL | |     } else {
+LL | |         4u32
+   | |         ^^^^ expected (), found u32
+LL | |     };
+   | |_____- if and else have incompatible types
+   |
+   = note: expected type `()`
+              found type `u32`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:19:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         5u32
+   | |         ---- expected because of this
+LL | |     } else {
+LL | |         6u32;
+   | |         ^^^^-
+   | |         |   |
+   | |         |   help: consider removing this semicolon
+   | |         expected u32, found ()
+LL | |     };
+   | |_____- if and else have incompatible types
+   |
+   = note: expected type `u32`
+              found type `()`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:25:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         7i32;
+   | |         ----- expected because of this
+LL | |     } else {
+LL | |         8u32
+   | |         ^^^^ expected (), found u32
+LL | |     };
+   | |_____- if and else have incompatible types
+   |
+   = note: expected type `()`
+              found type `u32`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:31:9
+   |
+LL |       let _ = if true {
+   |  _____________-
+LL | |         9i32
+   | |         ---- expected because of this
+LL | |     } else {
+LL | |         10u32;
+   | |         ^^^^^^ expected i32, found ()
+LL | |     };
+   | |_____- if and else have incompatible types
+   |
+   = note: expected type `i32`
+              found type `()`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:37:9
+   |
+LL |       let _ = if true {
+   |  _____________________-
+LL | |
+LL | |     } else {
+   | |_____- expected because of this
+LL |           11u32
+   |           ^^^^^ expected (), found u32
+   |
+   = note: expected type `()`
+              found type `u32`
+
+error[E0308]: if and else have incompatible types
+  --> $DIR/if-else-type-mismatch.rs:42:12
+   |
+LL |       let _ = if true {
+   |               ------- if and else have incompatible types
+LL |           12i32
+   |           ----- expected because of this
+LL |       } else {
+   |  ____________^
+LL | |
+LL | |     };
+   | |_____^ expected i32, found ()
+   |
+   = note: expected type `i32`
+              found type `()`
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
index 44e172da783949d8c651691091a7bb9298895caa..74b925f72fff02248f7542a72a2beabce559e4cb 100644 (file)
@@ -1,8 +1,10 @@
 error[E0308]: if and else have incompatible types
-  --> $DIR/if-branch-types.rs:2:13
+  --> $DIR/if-branch-types.rs:2:38
    |
 LL |     let x = if true { 10i32 } else { 10u32 };
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
+   |                       -----          ^^^^^ expected i32, found u32
+   |                       |
+   |                       expected because of this
    |
    = note: expected type `i32`
               found type `u32`
index 9b3d84b3dd51c50cd35831179e73d619aabbce08..d30b95843f300a5c7b559f2158eb1795a53880d4 100644 (file)
@@ -1,8 +1,8 @@
 #![warn(unused)]
-#[deny(warnings)]
+#![deny(warnings)]
 
 const foo: isize = 3;
-//~^ ERROR: should have an upper case name such as
+//~^ ERROR: should have an upper case name
 //~^^ ERROR: constant item is never used
 
 fn main() {}
index 641e50a5fc9b7d68e944521cc80e0e40a63ba2e6..b92acecb83eca0ecb589d70ac252c73093509ed9 100644 (file)
@@ -5,23 +5,23 @@ LL | const foo: isize = 3;
    | ^^^^^^^^^^^^^^^^^^^^^
    |
 note: lint level defined here
-  --> $DIR/issue-17718-const-naming.rs:2:8
+  --> $DIR/issue-17718-const-naming.rs:2:9
    |
-LL | #[deny(warnings)]
-   |        ^^^^^^^^
+LL | #![deny(warnings)]
+   |         ^^^^^^^^
    = note: #[deny(dead_code)] implied by #[deny(warnings)]
 
-error: constant `foo` should have an upper case name such as `FOO`
-  --> $DIR/issue-17718-const-naming.rs:4:1
+error: constant `foo` should have an upper case name
+  --> $DIR/issue-17718-const-naming.rs:4:7
    |
 LL | const foo: isize = 3;
-   | ^^^^^^^^^^^^^^^^^^^^^
+   |       ^^^ help: convert the identifier to upper case: `FOO`
    |
 note: lint level defined here
-  --> $DIR/issue-17718-const-naming.rs:2:8
+  --> $DIR/issue-17718-const-naming.rs:2:9
    |
-LL | #[deny(warnings)]
-   |        ^^^^^^^^
+LL | #![deny(warnings)]
+   |         ^^^^^^^^
    = note: #[deny(non_upper_case_globals)] implied by #[deny(warnings)]
 
 error: aborting due to 2 previous errors
index c6a8f33829863953f943c216cf461c795c4a04cb..3250a41ee0ecdc940c459130a633181b6d3ab0f9 100644 (file)
@@ -1,8 +1,8 @@
-error: variable `_InappropriateCamelCasing` should have a snake case name such as `_inappropriate_camel_casing`
+error: variable `_InappropriateCamelCasing` should have a snake case name
   --> $DIR/command-line-lint-group-deny.rs:4:9
    |
 LL |     let _InappropriateCamelCasing = true; //~ ERROR should have a snake
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
    |
    = note: `-D non-snake-case` implied by `-D bad-style`
 
index 2c11cca96398b45784a184b680791f0f7e37ae3f..39f6da400c4935b1e7da45567182519327951486 100644 (file)
@@ -1,8 +1,8 @@
-error: variable `_InappropriateCamelCasing` should have a snake case name such as `_inappropriate_camel_casing`
+error: variable `_InappropriateCamelCasing` should have a snake case name
   --> $DIR/command-line-lint-group-forbid.rs:4:9
    |
 LL |     let _InappropriateCamelCasing = true; //~ ERROR should have a snake
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
    |
    = note: `-F non-snake-case` implied by `-F bad-style`
 
index 3939461ef57427d986aa907b2ff0d7daf9298824..42a198fe7e3e2bcfd41eb0383506f3a99235db83 100644 (file)
@@ -1,8 +1,8 @@
-warning: variable `_InappropriateCamelCasing` should have a snake case name such as `_inappropriate_camel_casing`
+warning: variable `_InappropriateCamelCasing` should have a snake case name
   --> $DIR/command-line-lint-group-warn.rs:5:9
    |
 LL |     let _InappropriateCamelCasing = true;
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
    |
    = note: `-W non-snake-case` implied by `-W bad-style`
 
index d85ca7811d01e97e066f6cf228bb7126e8ed3150..f3c7d70054b777a4da352a603adc8cff81f95bda 100644 (file)
@@ -1,8 +1,8 @@
-warning: type `snake_case` should have a camel case name such as `SnakeCase`
-  --> $DIR/lint-group-nonstandard-style.rs:22:9
+warning: type `snake_case` should have a camel case name
+  --> $DIR/lint-group-nonstandard-style.rs:22:16
    |
 LL |         struct snake_case; //~ WARN should have a camel
-   |         ^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^ help: convert the identifier to camel case: `SnakeCase`
    |
 note: lint level defined here
   --> $DIR/lint-group-nonstandard-style.rs:18:17
@@ -11,11 +11,11 @@ LL |         #![warn(nonstandard_style)]
    |                 ^^^^^^^^^^^^^^^^^
    = note: #[warn(non_camel_case_types)] implied by #[warn(nonstandard_style)]
 
-error: function `CamelCase` should have a snake case name such as `camel_case`
-  --> $DIR/lint-group-nonstandard-style.rs:4:1
+error: function `CamelCase` should have a snake case name
+  --> $DIR/lint-group-nonstandard-style.rs:4:4
    |
 LL | fn CamelCase() {} //~ ERROR should have a snake
-   | ^^^^^^^^^^^^^^^^^
+   |    ^^^^^^^^^ help: convert the identifier to snake case: `camel_case`
    |
 note: lint level defined here
   --> $DIR/lint-group-nonstandard-style.rs:1:9
@@ -24,11 +24,11 @@ LL | #![deny(nonstandard_style)]
    |         ^^^^^^^^^^^^^^^^^
    = note: #[deny(non_snake_case)] implied by #[deny(nonstandard_style)]
 
-error: function `CamelCase` should have a snake case name such as `camel_case`
-  --> $DIR/lint-group-nonstandard-style.rs:12:9
+error: function `CamelCase` should have a snake case name
+  --> $DIR/lint-group-nonstandard-style.rs:12:12
    |
 LL |         fn CamelCase() {} //~ ERROR should have a snake
-   |         ^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^ help: convert the identifier to snake case: `camel_case`
    |
 note: lint level defined here
   --> $DIR/lint-group-nonstandard-style.rs:10:14
@@ -37,11 +37,11 @@ LL |     #[forbid(nonstandard_style)]
    |              ^^^^^^^^^^^^^^^^^
    = note: #[forbid(non_snake_case)] implied by #[forbid(nonstandard_style)]
 
-error: static variable `bad` should have an upper case name such as `BAD`
-  --> $DIR/lint-group-nonstandard-style.rs:14:9
+error: static variable `bad` should have an upper case name
+  --> $DIR/lint-group-nonstandard-style.rs:14:16
    |
 LL |         static bad: isize = 1; //~ ERROR should have an upper
-   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^ help: convert the identifier to upper case: `BAD`
    |
 note: lint level defined here
   --> $DIR/lint-group-nonstandard-style.rs:10:14
@@ -50,11 +50,11 @@ LL |     #[forbid(nonstandard_style)]
    |              ^^^^^^^^^^^^^^^^^
    = note: #[forbid(non_upper_case_globals)] implied by #[forbid(nonstandard_style)]
 
-warning: function `CamelCase` should have a snake case name such as `camel_case`
-  --> $DIR/lint-group-nonstandard-style.rs:20:9
+warning: function `CamelCase` should have a snake case name
+  --> $DIR/lint-group-nonstandard-style.rs:20:12
    |
 LL |         fn CamelCase() {} //~ WARN should have a snake
-   |         ^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^ help: convert the identifier to snake case: `camel_case`
    |
 note: lint level defined here
   --> $DIR/lint-group-nonstandard-style.rs:18:17
diff --git a/src/test/ui/lint/lint-lowercase-static-const-pattern-rename.rs b/src/test/ui/lint/lint-lowercase-static-const-pattern-rename.rs
new file mode 100644 (file)
index 0000000..8ca5af2
--- /dev/null
@@ -0,0 +1,63 @@
+// compile-pass
+// Issue #7526: lowercase static constants in patterns look like bindings
+
+// This is similar to lint-lowercase-static-const-pattern.rs, except it
+// shows the expected usual workaround (choosing a different name for
+// the static definition) and also demonstrates that one can work
+// around this problem locally by renaming the constant in the `use`
+// form to an uppercase identifier that placates the lint.
+
+#![deny(non_upper_case_globals)]
+
+pub const A : isize = 97;
+
+fn f() {
+    let r = match (0,0) {
+        (0, A) => 0,
+        (x, y) => 1 + x + y,
+    };
+    assert_eq!(r, 1);
+    let r = match (0,97) {
+        (0, A) => 0,
+        (x, y) => 1 + x + y,
+    };
+    assert_eq!(r, 0);
+}
+
+mod m {
+    #[allow(non_upper_case_globals)]
+    pub const aha : isize = 7;
+}
+
+fn g() {
+    use self::m::aha as AHA;
+    let r = match (0,0) {
+        (0, AHA) => 0,
+        (x, y)   => 1 + x + y,
+    };
+    assert_eq!(r, 1);
+    let r = match (0,7) {
+        (0, AHA) => 0,
+        (x, y)   => 1 + x + y,
+    };
+    assert_eq!(r, 0);
+}
+
+fn h() {
+    let r = match (0,0) {
+        (0, self::m::aha) => 0,
+        (x, y)      => 1 + x + y,
+    };
+    assert_eq!(r, 1);
+    let r = match (0,7) {
+        (0, self::m::aha) => 0,
+        (x, y)      => 1 + x + y,
+    };
+    assert_eq!(r, 0);
+}
+
+pub fn main () {
+    f();
+    g();
+    h();
+}
diff --git a/src/test/ui/lint/lint-lowercase-static-const-pattern.rs b/src/test/ui/lint/lint-lowercase-static-const-pattern.rs
new file mode 100644 (file)
index 0000000..c2e159e
--- /dev/null
@@ -0,0 +1,51 @@
+// Issue #7526: lowercase static constants in patterns look like bindings
+
+#![allow(dead_code)]
+#![deny(non_upper_case_globals)]
+
+#[allow(non_upper_case_globals)]
+pub const a : isize = 97;
+
+fn f() {
+    let r = match (0,0) {
+        (0, a) => 0,
+        //~^ ERROR constant in pattern `a` should have an upper case name
+        (x, y) => 1 + x + y,
+    };
+    assert_eq!(r, 1);
+}
+
+mod m {
+    #[allow(non_upper_case_globals)]
+    pub const aha : isize = 7;
+}
+
+fn g() {
+    use self::m::aha;
+    let r = match (0,0) {
+        (0, aha) => 0,
+        //~^ ERROR constant in pattern `aha` should have an upper case name
+        (x, y)   => 1 + x + y,
+    };
+    assert_eq!(r, 1);
+}
+
+mod n {
+    pub const OKAY : isize = 8;
+}
+
+fn h() {
+    use self::n::OKAY as not_okay;
+    let r = match (0,0) {
+        (0, not_okay) => 0,
+//~^ ERROR constant in pattern `not_okay` should have an upper case name
+        (x, y)   => 1 + x + y,
+    };
+    assert_eq!(r, 1);
+}
+
+fn main () {
+    f();
+    g();
+    h();
+}
diff --git a/src/test/ui/lint/lint-lowercase-static-const-pattern.stderr b/src/test/ui/lint/lint-lowercase-static-const-pattern.stderr
new file mode 100644 (file)
index 0000000..d95510c
--- /dev/null
@@ -0,0 +1,26 @@
+error: constant in pattern `a` should have an upper case name
+  --> $DIR/lint-lowercase-static-const-pattern.rs:11:13
+   |
+LL |         (0, a) => 0,
+   |             ^ help: convert the identifier to upper case: `A`
+   |
+note: lint level defined here
+  --> $DIR/lint-lowercase-static-const-pattern.rs:4:9
+   |
+LL | #![deny(non_upper_case_globals)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+
+error: constant in pattern `aha` should have an upper case name
+  --> $DIR/lint-lowercase-static-const-pattern.rs:26:13
+   |
+LL |         (0, aha) => 0,
+   |             ^^^ help: convert the identifier to upper case: `AHA`
+
+error: constant in pattern `not_okay` should have an upper case name
+  --> $DIR/lint-lowercase-static-const-pattern.rs:40:13
+   |
+LL |         (0, not_okay) => 0,
+   |             ^^^^^^^^ help: convert the identifier to upper case: `NOT_OKAY`
+
+error: aborting due to 3 previous errors
+
index 436763b831687aff9998bb17c13d1d9f07d18fa4..bca1992605b77f655f62068e4504c1cf78bdc881 100644 (file)
@@ -2,31 +2,31 @@
 #![allow(dead_code)]
 
 struct ONE_TWO_THREE;
-//~^ ERROR type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree`
+//~^ ERROR type `ONE_TWO_THREE` should have a camel case name
 
-struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo`
+struct foo { //~ ERROR type `foo` should have a camel case name
     bar: isize,
 }
 
-enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2`
+enum foo2 { //~ ERROR type `foo2` should have a camel case name
     Bar
 }
 
-struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3`
+struct foo3 { //~ ERROR type `foo3` should have a camel case name
     bar: isize
 }
 
-type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4`
+type foo4 = isize; //~ ERROR type `foo4` should have a camel case name
 
 enum Foo5 {
-    bar //~ ERROR variant `bar` should have a camel case name such as `Bar`
+    bar //~ ERROR variant `bar` should have a camel case name
 }
 
-trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
+trait foo6 { //~ ERROR trait `foo6` should have a camel case name
     fn dummy(&self) { }
 }
 
-fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
+fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name
 
 #[repr(C)]
 struct foo7 {
@@ -35,10 +35,10 @@ struct foo7 {
 
 struct X86_64;
 
-struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
+struct X86__64; //~ ERROR type `X86__64` should have a camel case name
 
-struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
+struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name
 
-struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
+struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name
 
 fn main() { }
index 31a8555977116fffe7fa4a01d5d8eb5055066281..74f9a5993b8599a6280cf6a4309c573388596777 100644 (file)
@@ -1,8 +1,8 @@
-error: type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree`
-  --> $DIR/lint-non-camel-case-types.rs:4:1
+error: type `ONE_TWO_THREE` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:4:8
    |
 LL | struct ONE_TWO_THREE;
-   | ^^^^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^^^^^ help: convert the identifier to camel case: `OneTwoThree`
    |
 note: lint level defined here
   --> $DIR/lint-non-camel-case-types.rs:1:11
@@ -10,73 +10,65 @@ note: lint level defined here
 LL | #![forbid(non_camel_case_types)]
    |           ^^^^^^^^^^^^^^^^^^^^
 
-error: type `foo` should have a camel case name such as `Foo`
-  --> $DIR/lint-non-camel-case-types.rs:7:1
+error: type `foo` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:7:8
    |
-LL | / struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo`
-LL | |     bar: isize,
-LL | | }
-   | |_^
+LL | struct foo { //~ ERROR type `foo` should have a camel case name
+   |        ^^^ help: convert the identifier to camel case: `Foo`
 
-error: type `foo2` should have a camel case name such as `Foo2`
-  --> $DIR/lint-non-camel-case-types.rs:11:1
+error: type `foo2` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:11:6
    |
-LL | / enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2`
-LL | |     Bar
-LL | | }
-   | |_^
+LL | enum foo2 { //~ ERROR type `foo2` should have a camel case name
+   |      ^^^^ help: convert the identifier to camel case: `Foo2`
 
-error: type `foo3` should have a camel case name such as `Foo3`
-  --> $DIR/lint-non-camel-case-types.rs:15:1
+error: type `foo3` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:15:8
    |
-LL | / struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3`
-LL | |     bar: isize
-LL | | }
-   | |_^
+LL | struct foo3 { //~ ERROR type `foo3` should have a camel case name
+   |        ^^^^ help: convert the identifier to camel case: `Foo3`
 
-error: type `foo4` should have a camel case name such as `Foo4`
-  --> $DIR/lint-non-camel-case-types.rs:19:1
+error: type `foo4` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:19:6
    |
-LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4`
-   | ^^^^^^^^^^^^^^^^^^
+LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name
+   |      ^^^^ help: convert the identifier to camel case: `Foo4`
 
-error: variant `bar` should have a camel case name such as `Bar`
+error: variant `bar` should have a camel case name
   --> $DIR/lint-non-camel-case-types.rs:22:5
    |
-LL |     bar //~ ERROR variant `bar` should have a camel case name such as `Bar`
-   |     ^^^
+LL |     bar //~ ERROR variant `bar` should have a camel case name
+   |     ^^^ help: convert the identifier to camel case: `Bar`
 
-error: trait `foo6` should have a camel case name such as `Foo6`
-  --> $DIR/lint-non-camel-case-types.rs:25:1
+error: trait `foo6` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:25:7
    |
-LL | / trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
-LL | |     fn dummy(&self) { }
-LL | | }
-   | |_^
+LL | trait foo6 { //~ ERROR trait `foo6` should have a camel case name
+   |       ^^^^ help: convert the identifier to camel case: `Foo6`
 
-error: type parameter `ty` should have a camel case name such as `Ty`
+error: type parameter `ty` should have a camel case name
   --> $DIR/lint-non-camel-case-types.rs:29:6
    |
-LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
-   |      ^^
+LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name
+   |      ^^ help: convert the identifier to camel case: `Ty`
 
-error: type `X86__64` should have a camel case name such as `X86_64`
-  --> $DIR/lint-non-camel-case-types.rs:38:1
+error: type `X86__64` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:38:8
    |
-LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
-   | ^^^^^^^^^^^^^^^
+LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name
+   |        ^^^^^^^ help: convert the identifier to camel case: `X86_64`
 
-error: type `Abc_123` should have a camel case name such as `Abc123`
-  --> $DIR/lint-non-camel-case-types.rs:40:1
+error: type `Abc_123` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:40:8
    |
-LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
-   | ^^^^^^^^^^^^^^^
+LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name
+   |        ^^^^^^^ help: convert the identifier to camel case: `Abc123`
 
-error: type `A1_b2_c3` should have a camel case name such as `A1B2C3`
-  --> $DIR/lint-non-camel-case-types.rs:42:1
+error: type `A1_b2_c3` should have a camel case name
+  --> $DIR/lint-non-camel-case-types.rs:42:8
    |
-LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
-   | ^^^^^^^^^^^^^^^^
+LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name
+   |        ^^^^^^^^ help: convert the identifier to camel case: `A1B2C3`
 
 error: aborting due to 11 previous errors
 
diff --git a/src/test/ui/lint/lint-non-camel-case-variant.rs b/src/test/ui/lint/lint-non-camel-case-variant.rs
new file mode 100644 (file)
index 0000000..1f06b28
--- /dev/null
@@ -0,0 +1,10 @@
+// compile-pass
+
+#![deny(non_camel_case_types)]
+
+pub enum Foo {
+    #[allow(non_camel_case_types)]
+    bar
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs b/src/test/ui/lint/lint-non-camel-case-with-trailing-underscores.rs
new file mode 100644 (file)
index 0000000..c2fdfb4
--- /dev/null
@@ -0,0 +1,11 @@
+// compile-pass
+
+#![allow(dead_code)]
+// This is ok because we often use the trailing underscore to mean 'prime'
+
+// pretty-expanded FIXME #23616
+
+#[forbid(non_camel_case_types)]
+type Foo_ = isize;
+
+pub fn main() { }
index 56c35c256f2a2a6cc3b031c7cdaad7ec0ba8efe0..1b763a9d868d91f1d590c58ce89c7803b55e56cd 100644 (file)
@@ -1,5 +1,5 @@
 // compile-flags: --crate-name NonSnakeCase
-// error-pattern: crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
+// error-pattern: crate `NonSnakeCase` should have a snake case name
 
 #![deny(non_snake_case)]
 
index eef7f1c79ee5f7b33d0948e67cc9b709221ae58f..f3303191a06fe2ea85e22ae20bc33700dbfdc33c 100644 (file)
@@ -1,10 +1,11 @@
-error: crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
+error: crate `NonSnakeCase` should have a snake case name
    |
 note: lint level defined here
   --> $DIR/lint-non-snake-case-crate-2.rs:4:9
    |
 LL | #![deny(non_snake_case)]
    |         ^^^^^^^^^^^^^^
+   = help: convert the identifier to snake case: `non_snake_case`
 
 error: aborting due to previous error
 
index 221ce611db5d24aa3063e3ed84b7abfb12ec0c84..e4e84261a4ee9d062e01a148eb750a11a791459d 100644 (file)
@@ -1,5 +1,5 @@
 #![crate_name = "NonSnakeCase"]
-//~^ ERROR crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
+//~^ ERROR crate `NonSnakeCase` should have a snake case name
 #![deny(non_snake_case)]
 
 fn main() {}
index 6d8112091ece6eb88d05037df0a4887bb8a41d3a..5cfd60a76e437e09cba67449580cb5a0b28cd84e 100644 (file)
@@ -1,8 +1,8 @@
-error: crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
-  --> $DIR/lint-non-snake-case-crate.rs:1:1
+error: crate `NonSnakeCase` should have a snake case name
+  --> $DIR/lint-non-snake-case-crate.rs:1:18
    |
 LL | #![crate_name = "NonSnakeCase"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                  ^^^^^^^^^^^^ help: convert the identifier to snake case: `non_snake_case`
    |
 note: lint level defined here
   --> $DIR/lint-non-snake-case-crate.rs:3:9
index 5ad454a7a52d59ab6d5238bc92f4d57bdeb8f1bc..fa64a9f980e75b51a070e2ac11b41aac5edc96cb 100644 (file)
@@ -5,28 +5,28 @@
 
 impl Foo {
     fn Foo_Method() {}
-    //~^ ERROR method `Foo_Method` should have a snake case name such as `foo_method`
+    //~^ ERROR method `Foo_Method` should have a snake case name
 
     // Don't allow two underscores in a row
     fn foo__method(&self) {}
-    //~^ ERROR method `foo__method` should have a snake case name such as `foo_method`
+    //~^ ERROR method `foo__method` should have a snake case name
 
     pub fn xyZ(&mut self) {}
-    //~^ ERROR method `xyZ` should have a snake case name such as `xy_z`
+    //~^ ERROR method `xyZ` should have a snake case name
 
     fn render_HTML() {}
-    //~^ ERROR method `render_HTML` should have a snake case name such as `render_html`
+    //~^ ERROR method `render_HTML` should have a snake case name
 }
 
 trait X {
     fn ABC();
-    //~^ ERROR trait method `ABC` should have a snake case name such as `abc`
+    //~^ ERROR trait method `ABC` should have a snake case name
 
     fn a_b_C(&self) {}
-    //~^ ERROR trait method `a_b_C` should have a snake case name such as `a_b_c`
+    //~^ ERROR trait method `a_b_C` should have a snake case name
 
     fn something__else(&mut self);
-    //~^ ERROR trait method `something__else` should have a snake case name such as `something_else`
+    //~^ ERROR trait method `something__else` should have a snake case name
 }
 
 impl X for Foo {
@@ -36,9 +36,9 @@ fn something__else(&mut self) {}
 }
 
 fn Cookie() {}
-//~^ ERROR function `Cookie` should have a snake case name such as `cookie`
+//~^ ERROR function `Cookie` should have a snake case name
 
 pub fn bi_S_Cuit() {}
-//~^ ERROR function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit`
+//~^ ERROR function `bi_S_Cuit` should have a snake case name
 
 fn main() { }
index 508fb225437e4adda5b8cff7e58001a9a4bdab5a..49cbfa941261055d30a2509083bdd64801d606f1 100644 (file)
@@ -1,8 +1,8 @@
-error: method `Foo_Method` should have a snake case name such as `foo_method`
-  --> $DIR/lint-non-snake-case-functions.rs:7:5
+error: method `Foo_Method` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:7:8
    |
 LL |     fn Foo_Method() {}
-   |     ^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^^ help: convert the identifier to snake case: `foo_method`
    |
 note: lint level defined here
   --> $DIR/lint-non-snake-case-functions.rs:1:9
@@ -10,53 +10,53 @@ note: lint level defined here
 LL | #![deny(non_snake_case)]
    |         ^^^^^^^^^^^^^^
 
-error: method `foo__method` should have a snake case name such as `foo_method`
-  --> $DIR/lint-non-snake-case-functions.rs:11:5
+error: method `foo__method` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:11:8
    |
 LL |     fn foo__method(&self) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^^^ help: convert the identifier to snake case: `foo_method`
 
-error: method `xyZ` should have a snake case name such as `xy_z`
-  --> $DIR/lint-non-snake-case-functions.rs:14:5
+error: method `xyZ` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:14:12
    |
 LL |     pub fn xyZ(&mut self) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^ help: convert the identifier to snake case: `xy_z`
 
-error: method `render_HTML` should have a snake case name such as `render_html`
-  --> $DIR/lint-non-snake-case-functions.rs:17:5
+error: method `render_HTML` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:17:8
    |
 LL |     fn render_HTML() {}
-   |     ^^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^^^ help: convert the identifier to snake case: `render_html`
 
-error: trait method `ABC` should have a snake case name such as `abc`
-  --> $DIR/lint-non-snake-case-functions.rs:22:5
+error: trait method `ABC` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:22:8
    |
 LL |     fn ABC();
-   |     ^^^^^^^^^
+   |        ^^^ help: convert the identifier to snake case: `abc`
 
-error: trait method `a_b_C` should have a snake case name such as `a_b_c`
-  --> $DIR/lint-non-snake-case-functions.rs:25:5
+error: trait method `a_b_C` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:25:8
    |
 LL |     fn a_b_C(&self) {}
-   |     ^^^^^^^^^^^^^^^^^^
+   |        ^^^^^ help: convert the identifier to snake case: `a_b_c`
 
-error: trait method `something__else` should have a snake case name such as `something_else`
-  --> $DIR/lint-non-snake-case-functions.rs:28:5
+error: trait method `something__else` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:28:8
    |
 LL |     fn something__else(&mut self);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `something_else`
 
-error: function `Cookie` should have a snake case name such as `cookie`
-  --> $DIR/lint-non-snake-case-functions.rs:38:1
+error: function `Cookie` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:38:4
    |
 LL | fn Cookie() {}
-   | ^^^^^^^^^^^^^^
+   |    ^^^^^^ help: convert the identifier to snake case: `cookie`
 
-error: function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit`
-  --> $DIR/lint-non-snake-case-functions.rs:41:1
+error: function `bi_S_Cuit` should have a snake case name
+  --> $DIR/lint-non-snake-case-functions.rs:41:8
    |
 LL | pub fn bi_S_Cuit() {}
-   | ^^^^^^^^^^^^^^^^^^^^^
+   |        ^^^^^^^^^ help: convert the identifier to snake case: `bi_s_cuit`
 
 error: aborting due to 9 previous errors
 
index c7af431bafc3af0aa2d43ff0427247f24a96c1f9..de76d2dbef26adabe93cd941ac8719a79b49d3dc 100644 (file)
@@ -1,7 +1,7 @@
 #![deny(non_snake_case)]
 #![allow(dead_code)]
 
-fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar`
+fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name
     _: &'FooBar ()
 ) {}
 
index 694a5a2252565e318e93604af94f382ca81658ae..970666ebcfdc3cd9ce3f7744b5c638de2d47086d 100644 (file)
@@ -1,8 +1,8 @@
-error: lifetime `'FooBar` should have a snake case name such as `'foo_bar`
+error: lifetime `'FooBar` should have a snake case name
   --> $DIR/lint-non-snake-case-lifetimes.rs:4:6
    |
-LL | fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar`
-   |      ^^^^^^^
+LL | fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name
+   |      ^^^^^^^ help: convert the identifier to snake case: `'foo_bar`
    |
 note: lint level defined here
   --> $DIR/lint-non-snake-case-lifetimes.rs:1:9
index 90f45a4f413155ab3c66a9febcded32e0b4f58e2..73f1233217225980422207fe92cbb19fd3a9f556 100644 (file)
@@ -1,7 +1,7 @@
 #![deny(non_snake_case)]
 #![allow(dead_code)]
 
-mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar`
+mod FooBar { //~ ERROR module `FooBar` should have a snake case name
     pub struct S;
 }
 
index ec3accf2ae882fc3a8602a6e6b7c74d546c87fc6..651132e49d914c5dd0f55b996912729da1e8a7e8 100644 (file)
@@ -1,10 +1,8 @@
-error: module `FooBar` should have a snake case name such as `foo_bar`
-  --> $DIR/lint-non-snake-case-modules.rs:4:1
+error: module `FooBar` should have a snake case name
+  --> $DIR/lint-non-snake-case-modules.rs:4:5
    |
-LL | / mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar`
-LL | |     pub struct S;
-LL | | }
-   | |_^
+LL | mod FooBar { //~ ERROR module `FooBar` should have a snake case name
+   |     ^^^^^^ help: convert the identifier to snake case: `foo_bar`
    |
 note: lint level defined here
   --> $DIR/lint-non-snake-case-modules.rs:1:9
diff --git a/src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs b/src/test/ui/lint/lint-non-snake-case-no-lowercase-equivalent.rs
new file mode 100644 (file)
index 0000000..9a6487d
--- /dev/null
@@ -0,0 +1,12 @@
+// compile-pass
+
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+#![feature(non_ascii_idents)]
+#![deny(non_snake_case)]
+
+// This name is neither upper nor lower case
+fn 你好() {}
+
+fn main() {}
diff --git a/src/test/ui/lint/lint-non-uppercase-associated-const.rs b/src/test/ui/lint/lint-non-uppercase-associated-const.rs
new file mode 100644 (file)
index 0000000..7b0d939
--- /dev/null
@@ -0,0 +1,11 @@
+#![deny(non_upper_case_globals)]
+#![allow(dead_code)]
+
+struct Foo;
+
+impl Foo {
+    const not_upper: bool = true;
+}
+//~^^ ERROR associated constant `not_upper` should have an upper case name
+
+fn main() {}
diff --git a/src/test/ui/lint/lint-non-uppercase-associated-const.stderr b/src/test/ui/lint/lint-non-uppercase-associated-const.stderr
new file mode 100644 (file)
index 0000000..2185d5a
--- /dev/null
@@ -0,0 +1,14 @@
+error: associated constant `not_upper` should have an upper case name
+  --> $DIR/lint-non-uppercase-associated-const.rs:7:11
+   |
+LL |     const not_upper: bool = true;
+   |           ^^^^^^^^^ help: convert the identifier to upper case: `NOT_UPPER`
+   |
+note: lint level defined here
+  --> $DIR/lint-non-uppercase-associated-const.rs:1:9
+   |
+LL | #![deny(non_upper_case_globals)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
index 9424bef3dfbf2808e617f3d2e93ec02584bd4ece..5bd1430328b48e6c35e1640f8c5f22a87bddb564 100644 (file)
@@ -1,10 +1,9 @@
 #![forbid(non_upper_case_globals)]
 #![allow(dead_code)]
 
-static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO`
+static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name
 
-static mut bar: isize = 1;
-        //~^ ERROR static variable `bar` should have an upper case name such as `BAR`
+static mut bar: isize = 1; //~ ERROR static variable `bar` should have an upper case name
 
 #[no_mangle]
 pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning
index 9c3dbb2fdeae5c1669859f990bca8b9fdfacce53..f5bba5f145de4877fc5d00602bdbf2e59f9f65cc 100644 (file)
@@ -1,8 +1,8 @@
-error: static variable `foo` should have an upper case name such as `FOO`
-  --> $DIR/lint-non-uppercase-statics.rs:4:1
+error: static variable `foo` should have an upper case name
+  --> $DIR/lint-non-uppercase-statics.rs:4:8
    |
-LL | static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO`
-   | ^^^^^^^^^^^^^^^^^^^^^^
+LL | static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name
+   |        ^^^ help: convert the identifier to upper case: `FOO`
    |
 note: lint level defined here
   --> $DIR/lint-non-uppercase-statics.rs:1:11
@@ -10,11 +10,11 @@ note: lint level defined here
 LL | #![forbid(non_upper_case_globals)]
    |           ^^^^^^^^^^^^^^^^^^^^^^
 
-error: static variable `bar` should have an upper case name such as `BAR`
-  --> $DIR/lint-non-uppercase-statics.rs:6:1
+error: static variable `bar` should have an upper case name
+  --> $DIR/lint-non-uppercase-statics.rs:6:12
    |
-LL | static mut bar: isize = 1;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | static mut bar: isize = 1; //~ ERROR static variable `bar` should have an upper case name
+   |            ^^^ help: convert the identifier to upper case: `BAR`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/lint/lint-nonstandard-style-unicode.rs b/src/test/ui/lint/lint-nonstandard-style-unicode.rs
new file mode 100644 (file)
index 0000000..a0b4130
--- /dev/null
@@ -0,0 +1,16 @@
+// compile-pass
+
+#![allow(dead_code)]
+
+#![forbid(non_camel_case_types)]
+#![forbid(non_upper_case_globals)]
+#![feature(non_ascii_idents)]
+
+// Some scripts (e.g., hiragana) don't have a concept of
+// upper/lowercase
+
+struct ヒ;
+
+static ラ: usize = 0;
+
+pub fn main() {}
index 33c2968e610c9cc7fb4efd06de79029aa6ccd258..86a39502a81cc62c8debf8bb685cc930ba7e2156 100644 (file)
@@ -7,20 +7,20 @@ pub enum Foo { Foo }
 }
 
 struct Something {
-    X: usize //~ ERROR structure field `X` should have a snake case name such as `x`
+    X: usize //~ ERROR structure field `X` should have a snake case name
 }
 
-fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx`
+fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name
     println!("{}", Xx);
 }
 
 fn main() {
-    let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test`
+    let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name
     println!("{}", Test);
 
     match foo::Foo::Foo {
         Foo => {}
-//~^ ERROR variable `Foo` should have a snake case name such as `foo`
+//~^ ERROR variable `Foo` should have a snake case name
 //~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
 //~^^^ WARN unused variable: `Foo`
     }
index f8564668e920fe58d19967318c4a72317cfb4138..0741179c4a4ddf6170a48a1e6b534f41cd396a8b 100644 (file)
@@ -17,11 +17,11 @@ LL | #![warn(unused)]
    |         ^^^^^^
    = note: #[warn(unused_variables)] implied by #[warn(unused)]
 
-error: structure field `X` should have a snake case name such as `x`
+error: structure field `X` should have a snake case name
   --> $DIR/lint-uppercase-variables.rs:10:5
    |
-LL |     X: usize //~ ERROR structure field `X` should have a snake case name such as `x`
-   |     ^^^^^^^^
+LL |     X: usize //~ ERROR structure field `X` should have a snake case name
+   |     ^ help: convert the identifier to snake case: `x`
    |
 note: lint level defined here
   --> $DIR/lint-uppercase-variables.rs:3:9
@@ -29,23 +29,23 @@ note: lint level defined here
 LL | #![deny(non_snake_case)]
    |         ^^^^^^^^^^^^^^
 
-error: variable `Xx` should have a snake case name such as `xx`
+error: variable `Xx` should have a snake case name
   --> $DIR/lint-uppercase-variables.rs:13:9
    |
-LL | fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx`
-   |         ^^
+LL | fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name
+   |         ^^ help: convert the identifier to snake case: `xx`
 
-error: variable `Test` should have a snake case name such as `test`
+error: variable `Test` should have a snake case name
   --> $DIR/lint-uppercase-variables.rs:18:9
    |
-LL |     let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test`
-   |         ^^^^
+LL |     let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name
+   |         ^^^^ help: convert the identifier to snake case: `test`
 
-error: variable `Foo` should have a snake case name such as `foo`
+error: variable `Foo` should have a snake case name
   --> $DIR/lint-uppercase-variables.rs:22:9
    |
 LL |         Foo => {}
-   |         ^^^
+   |         ^^^ help: convert the identifier to snake case: `foo`
 
 error: aborting due to 4 previous errors
 
index df0f9cb9b61e89c7c87835cadc9a1c24cf4420fc..3bb1480a301095c12b3667c1d5e39e8ceffc0259 100644 (file)
@@ -11,11 +11,11 @@ note: lint level defined here
 LL | #![warn(elided_lifetimes_in_paths,
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^
 
-warning: variable `Social_exchange_psychology` should have a snake case name such as `social_exchange_psychology`
+warning: variable `Social_exchange_psychology` should have a snake case name
   --> $DIR/reasons.rs:30:9
    |
 LL |     let Social_exchange_psychology = CheaterDetectionMechanism {};
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `social_exchange_psychology`
    |
    = note: people shouldn't have to change their usual style habits
            to contribute to our project
diff --git a/src/test/ui/match/match-static-const-lc.rs b/src/test/ui/match/match-static-const-lc.rs
deleted file mode 100644 (file)
index c79da6e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// Issue #7526: lowercase static constants in patterns look like bindings
-
-#![allow(dead_code)]
-#![deny(non_upper_case_globals)]
-
-#[allow(non_upper_case_globals)]
-pub const a : isize = 97;
-
-fn f() {
-    let r = match (0,0) {
-        (0, a) => 0,
-        //~^ ERROR constant in pattern `a` should have an upper case name such as `A`
-        (x, y) => 1 + x + y,
-    };
-    assert_eq!(r, 1);
-}
-
-mod m {
-    #[allow(non_upper_case_globals)]
-    pub const aha : isize = 7;
-}
-
-fn g() {
-    use self::m::aha;
-    let r = match (0,0) {
-        (0, aha) => 0,
-        //~^ ERROR constant in pattern `aha` should have an upper case name such as `AHA`
-        (x, y)   => 1 + x + y,
-    };
-    assert_eq!(r, 1);
-}
-
-mod n {
-    pub const OKAY : isize = 8;
-}
-
-fn h() {
-    use self::n::OKAY as not_okay;
-    let r = match (0,0) {
-        (0, not_okay) => 0,
-//~^ ERROR constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY`
-        (x, y)   => 1 + x + y,
-    };
-    assert_eq!(r, 1);
-}
-
-fn main () {
-    f();
-    g();
-    h();
-}
diff --git a/src/test/ui/match/match-static-const-lc.stderr b/src/test/ui/match/match-static-const-lc.stderr
deleted file mode 100644 (file)
index 1ddb831..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-error: constant in pattern `a` should have an upper case name such as `A`
-  --> $DIR/match-static-const-lc.rs:11:13
-   |
-LL |         (0, a) => 0,
-   |             ^
-   |
-note: lint level defined here
-  --> $DIR/match-static-const-lc.rs:4:9
-   |
-LL | #![deny(non_upper_case_globals)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^
-
-error: constant in pattern `aha` should have an upper case name such as `AHA`
-  --> $DIR/match-static-const-lc.rs:26:13
-   |
-LL |         (0, aha) => 0,
-   |             ^^^
-
-error: constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY`
-  --> $DIR/match-static-const-lc.rs:40:13
-   |
-LL |         (0, not_okay) => 0,
-   |             ^^^^^^^^
-
-error: aborting due to 3 previous errors
-
index 40a3e7e96486bad644e64d0958001dfe47eaa5c4..60e70ddcd97019d20a1aa0c2cab400f6da47db52 100644 (file)
@@ -1,13 +1,15 @@
 error[E0308]: if and else have incompatible types
-  --> $DIR/region-invariant-static-error-reporting.rs:14:15
+  --> $DIR/region-invariant-static-error-reporting.rs:17:9
    |
 LL |       let bad = if x.is_some() {
-   |  _______________^
+   |  _______________-
 LL | |         x.unwrap()
+   | |         ---------- expected because of this
 LL | |     } else {
 LL | |         mk_static()
+   | |         ^^^^^^^^^^^ lifetime mismatch
 LL | |     };
-   | |_____^ lifetime mismatch
+   | |_____- if and else have incompatible types
    |
    = note: expected type `Invariant<'a>`
               found type `Invariant<'static>`
index 4d6d342f571a5c6b27fecbdd0ab0d5dc5acfa53f..9010770f1dc821dcf9877a315e3c1c2f3d8fbdd8 100644 (file)
@@ -10,6 +10,7 @@
 
 #![allow(dead_code)]
 #![allow(unused_variables)]
+#![allow(non_snake_case)]
 
 struct S;
 
diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static.stderr
deleted file mode 100644 (file)
index 61eaf9f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-warning: function `want_F` should have a snake case name such as `want_f`
-  --> $DIR/regions-fn-subtyping-return-static.rs:18:1
-   |
-LL | fn want_F(f: F) { }
-   | ^^^^^^^^^^^^^^^^^^^
-   |
-   = note: #[warn(non_snake_case)] on by default
-
-warning: function `want_G` should have a snake case name such as `want_g`
-  --> $DIR/regions-fn-subtyping-return-static.rs:22:1
-   |
-LL | fn want_G(f: G) { }
-   | ^^^^^^^^^^^^^^^^^^^
-
-warning: function `supply_F` should have a snake case name such as `supply_f`
-  --> $DIR/regions-fn-subtyping-return-static.rs:39:1
-   |
-LL | / fn supply_F() {
-LL | |     want_F(foo);
-LL | |
-LL | |     want_F(bar);
-LL | |
-LL | |     want_F(baz);
-LL | | }
-   | |_^
-
index 42b93334572fc15a8af4555bc992b522129a6625..f052f866c901b863b13948e30485cc693dc3f95c 100644 (file)
@@ -11,17 +11,17 @@ LL | #![warn(unused)]
    |         ^^^^^^
    = note: #[warn(unused_variables)] implied by #[warn(unused)]
 
-warning: variable `theTwo` should have a snake case name such as `the_two`
+warning: variable `theTwo` should have a snake case name
   --> $DIR/issue-24690.rs:12:9
    |
 LL |     let theTwo = 2; //~ WARN should have a snake case name
-   |         ^^^^^^
+   |         ^^^^^^ help: convert the identifier to snake case: `the_two`
    |
    = note: #[warn(non_snake_case)] on by default
 
-warning: variable `theOtherTwo` should have a snake case name such as `the_other_two`
+warning: variable `theOtherTwo` should have a snake case name
   --> $DIR/issue-24690.rs:13:9
    |
 LL |     let theOtherTwo = 2; //~ WARN should have a snake case name
-   |         ^^^^^^^^^^^
+   |         ^^^^^^^^^^^ help: convert the identifier to snake case: `the_other_two`
 
index 24d8db481b46833ef9e096a5c3fd5d387397199e..87809d212d79dd4e6b31b19c053b30ed43c80541 100644 (file)
@@ -1,8 +1,10 @@
 error[E0308]: if and else have incompatible types
-  --> $DIR/str-array-assignment.rs:3:11
+  --> $DIR/str-array-assignment.rs:3:37
    |
 LL |   let t = if true { s[..2] } else { s };
-   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found &str
+   |                     ------          ^ expected str, found &str
+   |                     |
+   |                     expected because of this
    |
    = note: expected type `str`
               found type `&str`
index bed0d9bb2be5498919c79606c549bed7215e996f..e601c6e455544516948d72d06c02b909e13b9fd7 100644 (file)
@@ -3,7 +3,7 @@
 fn foo<
     'β, //~ ERROR non-ascii idents are not fully supported
     γ  //~ ERROR non-ascii idents are not fully supported
-       //~^ WARN type parameter `γ` should have a camel case name such as `Γ`
+       //~^ WARN type parameter `γ` should have a camel case name
 >() {}
 
 struct X {
index 1ccf767491cdb3f7e72e33c12204e0694b88fca8..268dd99d06031ad10e7f74a51ec2f0ac40a33e4f 100644 (file)
@@ -30,11 +30,11 @@ LL |     let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported
    |
    = help: add #![feature(non_ascii_idents)] to the crate attributes to enable
 
-warning: type parameter `γ` should have a camel case name such as `Γ`
+warning: type parameter `γ` should have a camel case name
   --> $DIR/utf8_idents.rs:5:5
    |
 LL |     γ  //~ ERROR non-ascii idents are not fully supported
-   |     ^
+   |     ^ help: convert the identifier to camel case: `Γ`
    |
    = note: #[warn(non_camel_case_types)] on by default
 
index b00daa716777fd3a298c0f223995c5c3a5fee040..8c1baa55bcdcae2f6e57e480e57649791d87c151 100644 (file)
@@ -90,6 +90,7 @@
     "thumbv7em-none-eabi",
     "thumbv7em-none-eabihf",
     "thumbv7m-none-eabi",
+    "thumbv8m.main-none-eabi",
     "wasm32-unknown-emscripten",
     "wasm32-unknown-unknown",
     "x86_64-apple-darwin",