Skip to content

Rollup of 9 pull requests #82547

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

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c28f2a8
Stabilize str_split_once
jhpratt Feb 9, 2021
4c70372
Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to m…
GuillaumeGomez Feb 15, 2021
5ff1be1
replaced some unwrap_or with unwrap_or_else
klensy Feb 23, 2021
c75c4a5
replaced some map_or with map_or_else
klensy Feb 23, 2021
6d5c0c1
Consider inexpensive inlining criteria first
tmiasko Feb 24, 2021
08b1e80
fix review
klensy Feb 25, 2021
fb24a10
Properly account for non-shorthand pattern field in unused variable lint
estebank Feb 25, 2021
356beb3
clarifies error when finding mismatched returned types for async func…
nellshamrell Feb 15, 2021
e130e9c
Update measureme dependency to the latest version
wesleywiser Feb 25, 2021
9d3739d
Set codegen thread names
wesleywiser Feb 18, 2021
c47903f
Add optional woff2 versions of FiraSans.
jsha Feb 26, 2021
ad7ed13
Embed woff2 files in rustdoc binary.
jsha Feb 26, 2021
91c246b
Rollup merge of #80845 - GuillaumeGomez:item-kind-transition, r=jyn514
GuillaumeGomez Feb 26, 2021
dc34ead
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
GuillaumeGomez Feb 26, 2021
3ddc7d4
Rollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebank
GuillaumeGomez Feb 26, 2021
e11393a
Rollup merge of #82456 - klensy:or-else, r=estebank
GuillaumeGomez Feb 26, 2021
443c483
Rollup merge of #82491 - tmiasko:i, r=lcnr
GuillaumeGomez Feb 26, 2021
f6e77e8
Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnr
GuillaumeGomez Feb 26, 2021
5964b43
Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa
GuillaumeGomez Feb 26, 2021
812d78f
Rollup merge of #82537 - wesleywiser:update_measureme, r=oli-obk
GuillaumeGomez Feb 26, 2021
65f3751
Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomez
GuillaumeGomez Feb 26, 2021
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
Properly account for non-shorthand pattern field in unused variable lint
Fix #82488
  • Loading branch information
estebank committed Feb 25, 2021
commit fb24a10ad39e2ed1a312c015b926cdb52ad1cef9
15 changes: 10 additions & 5 deletions compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,17 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
}

fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
let is_shorthand = matches!(param.pat.kind, rustc_hir::PatKind::Struct(..));
param.pat.each_binding(|_bm, hir_id, _x, ident| {
let var = if is_shorthand {
Local(LocalInfo { id: hir_id, name: ident.name, is_shorthand: true })
} else {
Param(hir_id, ident.name)
let var = match param.pat.kind {
rustc_hir::PatKind::Struct(_, fields, _) => Local(LocalInfo {
id: hir_id,
name: ident.name,
is_shorthand: fields
.iter()
.find(|f| f.ident == ident)
.map_or(false, |f| f.is_shorthand),
}),
_ => Param(hir_id, ident.name),
};
self.add_variable(var);
});
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/lint/unused_variables-issue-82488.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// run-rustfix
#![deny(unused_variables)]

struct Point {
x: u32,
y: u32
}

fn process_point(Point { x, y: _renamed }: Point) {
//~^ ERROR unused variable: `renamed`
let _ = x;
}

fn main() {
process_point(Point { x: 0, y: 0 });
}
16 changes: 16 additions & 0 deletions src/test/ui/lint/unused_variables-issue-82488.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// run-rustfix
#![deny(unused_variables)]

struct Point {
x: u32,
y: u32
}

fn process_point(Point { x, y: renamed }: Point) {
//~^ ERROR unused variable: `renamed`
let _ = x;
}

fn main() {
process_point(Point { x: 0, y: 0 });
}
14 changes: 14 additions & 0 deletions src/test/ui/lint/unused_variables-issue-82488.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: unused variable: `renamed`
--> $DIR/unused_variables-issue-82488.rs:9:32
|
LL | fn process_point(Point { x, y: renamed }: Point) {
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_renamed`
|
note: the lint level is defined here
--> $DIR/unused_variables-issue-82488.rs:2:9
|
LL | #![deny(unused_variables)]
| ^^^^^^^^^^^^^^^^

error: aborting due to previous error