diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2020-11-08 16:40:00 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2020-11-08 16:46:53 +0100 |
| commit | 39046172ab91805efb79a55870c2ced2d61cfc3a (patch) | |
| tree | 3bd991b0ef31ed3084b18327d59054d85a4b0293 /.gitattributes | |
| parent | 87a0997ef9c0bfad0ba362741afa601d8fb285b8 (diff) | |
| download | rust-39046172ab91805efb79a55870c2ced2d61cfc3a.tar.gz rust-39046172ab91805efb79a55870c2ced2d61cfc3a.zip | |
Nicer hunk headers for rust files
I found this trick at
<https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more>
Before the hunk headers for changes in methods would refer to the impl:
```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..fa4264d729b 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -678,7 +678,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
ref closure_captures,
ref generator_interior_types,
} = *self;
-
+ // foo
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
type_dependent_defs.hash_stable(hcx, hasher);
field_indices.hash_stable(hcx, hasher);
```
After the hunk headers refer to the actual function signature:
```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..fa4264d729b 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -678,7 +678,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
ref closure_captures,
ref generator_interior_types,
} = *self;
-
+ // foo
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
type_dependent_defs.hash_stable(hcx, hasher);
field_indices.hash_stable(hcx, hasher);
```
When the function signature is visible, it will use the function
signature of the previous method as hunk header:
```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..63058dfc837 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -992,6 +992,7 @@ pub fn typeck_opt_const_arg(
}
pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
+ // foo
self.arena.alloc(Steal::new(mir))
}
```
Diffstat (limited to '.gitattributes')
| -rw-r--r-- | .gitattributes | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/.gitattributes b/.gitattributes index a7de7ce8559..2c5c37007d5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,7 @@ * text=auto eol=lf *.cpp rust *.h rust -*.rs rust +*.rs rust diff=rust *.fixed linguist-language=Rust src/etc/installer/gfx/* binary *.woff binary |
