Skip to content

Rollup of 9 pull requests #68330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
12f029b
Fix deref impl on type alias
GuillaumeGomez Jan 10, 2020
fd4a88f
Add test for typedef deref
GuillaumeGomez Jan 10, 2020
81a5b94
formatting
GuillaumeGomez Jan 10, 2020
6e79146
remove unneeded code from cache.rs
GuillaumeGomez Jan 15, 2020
e6ad49a
Include type alias implementations
GuillaumeGomez Jan 15, 2020
d755238
Simplify deref impls for type aliases
GuillaumeGomez Jan 15, 2020
8a9b951
Fix rendering on sidebar and update tests
GuillaumeGomez Jan 15, 2020
ea64a33
Update sanitizer tests
tmiasko Jan 16, 2020
25a8f94
Don't warn about snake case for field puns that don't introduce a new…
jumbatm Nov 23, 2019
3094c37
Improve code readability
GuillaumeGomez Jan 16, 2020
10a9ea4
Do not ICE on malformed suggestion spans
estebank Jan 15, 2020
03240e1
review comments
estebank Jan 17, 2020
cdc828e
Stop treating `FalseEdges` and `FalseUnwind` as having semantic value…
oli-obk Jan 17, 2020
a91f77c
Add regression test for integer literals in generic arguments in wher…
varkor Jan 17, 2020
9c6c2f1
Clean up E0198 explanation
GuillaumeGomez Jan 16, 2020
482dc77
formatting
GuillaumeGomez Jan 17, 2020
e8a4b93
Clean up E0199 explanation
GuillaumeGomez Jan 17, 2020
d461e6d
Use named fields for `ast::ItemKind::Impl`
ecstatic-morse Jan 14, 2020
4743995
Use named fields for `hir::ItemKind::Impl`
ecstatic-morse Jan 18, 2020
c854aec
Rollup merge of #66660 - jumbatm:dont_warn_about_snake_case_in_patter…
tmandry Jan 18, 2020
bafe089
Rollup merge of #68093 - GuillaumeGomez:fix-deref-impl-typedef, r=oli…
tmandry Jan 18, 2020
fca3264
Rollup merge of #68204 - ecstatic-morse:item-kind-impl, r=oli-obk
tmandry Jan 18, 2020
7f6fdef
Rollup merge of #68256 - estebank:bad-sugg-span, r=petrochenkov
tmandry Jan 18, 2020
2a1ab29
Rollup merge of #68279 - GuillaumeGomez:clean-up-e0198, r=Dylan-DPC
tmandry Jan 18, 2020
87293cd
Rollup merge of #68291 - tmiasko:sanitizer-tests, r=nikomatsakis
tmandry Jan 18, 2020
9d9c8c6
Rollup merge of #68312 - varkor:issue-67753-regression, r=Centril
tmandry Jan 18, 2020
dd6a838
Rollup merge of #68314 - oli-obk:true_unwind, r=eddyb
tmandry Jan 18, 2020
14d779c
Rollup merge of #68317 - GuillaumeGomez:clean-up-e0199, r=Dylan-DPC
tmandry Jan 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't warn about snake case for field puns that don't introduce a new…
… name.
  • Loading branch information
jumbatm committed Jan 16, 2020
commit 25a8f9473f29e732838b6d88394dd80fe645b7f6
15 changes: 14 additions & 1 deletion src/librustc_lint/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
}

fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat<'_>) {
if let &PatKind::Binding(_, _, ident, _) = &p.kind {
if let &PatKind::Binding(_, hid, ident, _) = &p.kind {
if let hir::Node::Pat(parent_pat) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid))
{
if let PatKind::Struct(_, field_pats, _) = &parent_pat.kind {
for field in field_pats.iter() {
if field.ident != ident {
// Only check if a new name has been introduced, to avoid warning
// on both the struct definition and this pattern.
self.check_snake_case(cx, "variable", &ident);
}
}
return;
}
}
self.check_snake_case(cx, "variable", &ident);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#![deny(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

enum Foo {
Bad {
lowerCamelCaseName: bool,
//~^ ERROR structure field `lowerCamelCaseName` should have a snake case name
},
Good {
snake_case_name: bool,
},
}

fn main() {
let b = Foo::Bad { lowerCamelCaseName: true };

match b {
Foo::Bad { lowerCamelCaseName } => {}
Foo::Good { snake_case_name: lowerCamelCaseBinding } => { }
//~^ ERROR variable `lowerCamelCaseBinding` should have a snake case name
}

if let Foo::Good { snake_case_name: anotherLowerCamelCaseBinding } = b { }
//~^ ERROR variable `anotherLowerCamelCaseBinding` should have a snake case name

if let Foo::Bad { lowerCamelCaseName: yetAnotherLowerCamelCaseBinding } = b { }
//~^ ERROR variable `yetAnotherLowerCamelCaseBinding` should have a snake case name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
error: structure field `lowerCamelCaseName` should have a snake case name
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:7:9
|
LL | lowerCamelCaseName: bool,
| ^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `lower_camel_case_name`
|
note: lint level defined here
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:1:9
|
LL | #![deny(non_snake_case)]
| ^^^^^^^^^^^^^^

error: variable `lowerCamelCaseBinding` should have a snake case name
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:20:38
|
LL | Foo::Good { snake_case_name: lowerCamelCaseBinding } => { }
| ^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `lower_camel_case_binding`

error: variable `anotherLowerCamelCaseBinding` should have a snake case name
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:24:41
|
LL | if let Foo::Good { snake_case_name: anotherLowerCamelCaseBinding } = b { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `another_lower_camel_case_binding`

error: variable `yetAnotherLowerCamelCaseBinding` should have a snake case name
--> $DIR/issue-66362-no-snake-case-warning-for-field-puns.rs:27:43
|
LL | if let Foo::Bad { lowerCamelCaseName: yetAnotherLowerCamelCaseBinding } = b { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `yet_another_lower_camel_case_binding`

error: aborting due to 4 previous errors