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",
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)",
[[package]]
name = "cc"
-version = "1.0.25"
+version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
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]]
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",
]
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)",
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)",
]
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)",
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)",
]
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)",
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)",
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)",
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)",
]
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)",
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]]
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)",
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",
]
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)",
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)",
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]]
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)",
"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"
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
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
#[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]),
}
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,
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
/// 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,
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)
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,
}
}
},
+ 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,
+ );
+ }
+ }
_ => (),
}
}
}
_ => "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"),
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",
ObligationCauseCode::ExprAssignable |
ObligationCauseCode::MatchExpressionArm { .. } |
ObligationCauseCode::MatchExpressionArmPattern { .. } |
- ObligationCauseCode::IfExpression |
+ ObligationCauseCode::IfExpression { .. } |
ObligationCauseCode::IfExpressionWithNoElse |
ObligationCauseCode::MainFunctionType |
ObligationCauseCode::StartFunctionType |
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,
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),
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 {
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;
}).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();
}
}
}
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", ¶m.ident);
}
}
}
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;
})
}
+ 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();
}
}
}
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", ¶m.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(_) => (),
}
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", ¶m_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);
}
}
}
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();
}
}
}
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);
}
}
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
+ );
}
}
}
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).
}
}
-
/// A common error is to add an extra semicolon:
///
/// ```
/// 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
));
}
});
- 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![],
)
])
}
])
};
- 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"))),
+++ /dev/null
-// 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();
-}
+++ /dev/null
-//
-#![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() {}
+++ /dev/null
-#![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() { }
+++ /dev/null
-#![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() {}
+++ /dev/null
-#![deny(non_camel_case_types)]
-
-pub enum Foo {
- #[allow(non_camel_case_types)]
- bar
-}
-
-fn main() {}
+++ /dev/null
-#![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() {}
+++ /dev/null
-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
-
-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
-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
--- /dev/null
+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
+}
--- /dev/null
+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`.
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`
#![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() {}
| ^^^^^^^^^^^^^^^^^^^^^
|
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
-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`
-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`
-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`
-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
| ^^^^^^^^^^^^^^^^^
= 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
| ^^^^^^^^^^^^^^^^^
= 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
| ^^^^^^^^^^^^^^^^^
= 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
| ^^^^^^^^^^^^^^^^^
= 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
--- /dev/null
+// 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();
+}
--- /dev/null
+// 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();
+}
--- /dev/null
+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
+
#![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 {
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() { }
-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
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
--- /dev/null
+// compile-pass
+
+#![deny(non_camel_case_types)]
+
+pub enum Foo {
+ #[allow(non_camel_case_types)]
+ bar
+}
+
+fn main() {}
--- /dev/null
+// 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() { }
// 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)]
-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
#![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() {}
-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
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 {
}
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() { }
-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
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
#![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 ()
) {}
-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
#![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;
}
-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
--- /dev/null
+// 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() {}
--- /dev/null
+#![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() {}
--- /dev/null
+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
+
#![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
-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
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
--- /dev/null
+// 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() {}
}
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`
}
| ^^^^^^
= 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
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
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
+++ /dev/null
-// 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();
-}
+++ /dev/null
-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
-
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>`
#![allow(dead_code)]
#![allow(unused_variables)]
+#![allow(non_snake_case)]
struct S;
+++ /dev/null
-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 | | }
- | |_^
-
| ^^^^^^
= 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`
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`
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 {
|
= 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
"thumbv7em-none-eabi",
"thumbv7em-none-eabihf",
"thumbv7m-none-eabi",
+ "thumbv8m.main-none-eabi",
"wasm32-unknown-emscripten",
"wasm32-unknown-unknown",
"x86_64-apple-darwin",