Skip to content

Commit 0036c93

Browse files
authored
Merge pull request #145 from pacak/rc-0.2.14
Release 0.2.14
2 parents ac53542 + 3951a89 commit 0036c93

File tree

9 files changed

+43
-14
lines changed

9 files changed

+43
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-show-asm"
3-
version = "0.2.13"
3+
version = "0.2.14"
44
edition = "2021"
55
description = "A cargo subcommand that displays the generated assembly of Rust source code."
66
categories = ["development-tools::cargo-plugins", "development-tools::debugging" ]

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [0.2.14] - 2023-02-22
4+
- Allow to pass -C flags directly to rustc
5+
- --llvm-input to show llvm-ir before any LLVM passes
6+
- Only generate debug info for LLVM resulting in cleaner
7+
Thanks to @jonasmalacofilho
8+
39
## [0.2.13] - 2023-02-03
410
- support cdylib crates
511
- bump deps

src/asm.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ pub fn parse_file(input: &str) -> anyhow::Result<Vec<Statement>> {
2525
if leftovers.len() < 1000 {
2626
anyhow::bail!("Didn't consume everything, leftovers: {leftovers:?}")
2727
} else {
28-
let head = &leftovers[..leftovers.char_indices().nth(200).unwrap().0];
28+
let head = &leftovers[..leftovers
29+
.char_indices()
30+
.nth(200)
31+
.expect("Shouldn't have that much unicode here...")
32+
.0];
2933
anyhow::bail!("Didn't consume everything, leftovers prefix: {head:?}");
3034
}
3135
}

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ pub fn get_dump_range(
7878
items: BTreeMap<Item, Range<usize>>,
7979
) -> Option<Range<usize>> {
8080
if items.len() == 1 {
81-
return Some(items.into_iter().next().unwrap().1);
81+
return Some(
82+
items
83+
.into_iter()
84+
.next()
85+
.expect("We just checked there's one item present")
86+
.1,
87+
);
8288
}
8389
match goal {
8490
// to dump everything just return an empty range

src/llvm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ fn find_items(lines: &CachedLines) -> BTreeMap<Item, Range<usize>> {
5757
}
5858
} else if line == "}" {
5959
if let Some(mut cur) = current_item.take() {
60+
// go home clippy, you're drunk
61+
#[allow(clippy::range_plus_one)]
6062
let range = cur.len..ix + 1;
6163
cur.len = range.len();
6264
res.insert(cur, range);

src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ fn spawn_cargo(
106106
.args(syntax.format().iter().flat_map(|s| ["-C", s]))
107107
.args(target_cpu.iter().map(|cpu| format!("-Ctarget-cpu={cpu}")));
108108

109-
// Debug info is needed to detect function boundaries in asm (Windows/Mac), and to map asm/wasm
110-
// output to rust source.
111-
if matches!(
112-
syntax,
113-
opts::Syntax::Intel | opts::Syntax::Att | opts::Syntax::Wasm
114-
) {
115-
cmd.arg("-Cdebuginfo=2");
109+
{
110+
#[allow(clippy::enum_glob_use)]
111+
use opts::Syntax::*;
112+
// Debug info is needed to detect function boundaries in asm (Windows/Mac), and to map asm/wasm
113+
// output to rust source.
114+
if matches!(syntax, Intel | Att | Wasm | McaAtt | McaIntel) {
115+
cmd.arg("-Cdebuginfo=2");
116+
}
116117
}
117118

118119
cmd.stdin(Stdio::null())

src/mca.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ use crate::{
99
opts::{Format, ToDump},
1010
};
1111

12+
/// dump mca analysis
13+
///
14+
/// # Errors
15+
/// Clippy, why do you care?
1216
pub fn dump_function(
1317
goal: ToDump,
1418
path: &Path,
@@ -55,9 +59,9 @@ pub fn dump_function(
5559
}
5660
};
5761

58-
let mut i = mca.stdin.take().unwrap();
59-
let o = mca.stdout.take().unwrap();
60-
let e = mca.stderr.take().unwrap();
62+
let mut i = mca.stdin.take().expect("Stdin should be piped");
63+
let o = mca.stdout.take().expect("Stdout should be piped");
64+
let e = mca.stderr.take().expect("Stderr should be piped");
6165

6266
if mca_intel {
6367
writeln!(i, ".intel_syntax")?;

src/mir.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ fn find_items(lines: &CachedLines) -> BTreeMap<Item, Range<usize>> {
1919
}
2020
} else if line == "}" {
2121
if let Some(mut cur) = current_item.take() {
22+
// go home clippy, you're drunk
23+
#[allow(clippy::range_plus_one)]
2224
let range = cur.len..ix + 1;
2325
cur.len = range.len();
2426
res.insert(cur, range);
@@ -57,6 +59,10 @@ fn dump_range(_fmt: &Format, strings: &[&str]) {
5759
}
5860
}
5961

62+
/// dump mir code
63+
///
64+
/// # Errors
65+
/// Reports file IO errors
6066
pub fn dump_function(goal: ToDump, path: &Path, fmt: &Format) -> anyhow::Result<()> {
6167
let lines = CachedLines::without_ending(std::fs::read_to_string(path)?);
6268
let items = find_items(&lines);

0 commit comments

Comments
 (0)