Skip to content
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

Nicer hunk headers for rust files #78882

Merged
merged 1 commit into from
Nov 9, 2020
Merged

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Nov 8, 2020

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 --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 --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 --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))
     }

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))
     }
```
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 8, 2020
@Mark-Simulacrum
Copy link
Member

Hm I guess this seems good, though I do wonder if the impl is really more useful sometimes. I wish we could see both, but doesn't seem like that's really possible.

@bors r+ rollup though

@bors
Copy link
Contributor

bors commented Nov 8, 2020

📌 Commit 3904617 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 8, 2020

When the function signature is visible, it will use the function
signature of the previous method as hunk header:

Could it show the impl if the current function is already present? I don't know why I'd want to know what the previous method was.

@jyn514 jyn514 added the A-meta Area: Issues about the rust-lang/rust repository. label Nov 8, 2020
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 8, 2020

I don't think that it is possible to show the impl when the current function is already present. According to https://www.git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header it is only possible to define a regex matching the line to use as hunk header. There doesn't seem to be any way to only match it in some cases or customize it. There is a way to specify a completely custom diff command though.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 8, 2020
…imulacrum

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))
     }
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 9, 2020
Rollup of 12 pull requests

Successful merges:

 - rust-lang#77640 (Refactor IntErrorKind to avoid "underflow" terminology)
 - rust-lang#78026 (Define `fs::hard_link` to not follow symlinks.)
 - rust-lang#78114 (Recognize `private_intra_doc_links` as a lint)
 - rust-lang#78228 (Promote aarch64-unknown-linux-gnu to Tier 1)
 - rust-lang#78345 (Fix handling of item names for HIR)
 - rust-lang#78437 (BTreeMap: stop mistaking node for an orderly place)
 - rust-lang#78476 (fix some incorrect aliasing in the BTree)
 - rust-lang#78674 (inliner: Use substs_for_mir_body)
 - rust-lang#78748 (Implement destructuring assignment for tuples)
 - rust-lang#78868 (Fix tab focus on restyled switches)
 - rust-lang#78878 (Avoid overlapping cfg attributes when both macOS and aarch64)
 - rust-lang#78882 (Nicer hunk headers for rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 92adac9 into rust-lang:master Nov 9, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 9, 2020
@bjorn3 bjorn3 deleted the nicer_hunk_headers branch November 9, 2020 08:12
ojeda added a commit to Rust-for-Linux/linux that referenced this pull request May 31, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
asahilina pushed a commit to AsahiLinux/linux that referenced this pull request Jul 14, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 19, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 20, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 23, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 23, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 25, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 27, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 28, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 30, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Jul 30, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 3, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 9, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 9, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 9, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 12, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 12, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 16, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 16, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 17, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 23, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Aug 31, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Sep 2, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Sep 7, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
herrnst pushed a commit to herrnst/linux-asahi that referenced this pull request Sep 14, 2023
Git supports a builtin Rust diff driver [1] since v2.23.0 (2019).

It improves the choice of hunk headers in some cases, such as
diffs within methods, since those are indented in Rust within
an `impl` block, and therefore the default diff driver would
pick the outer `impl` block instead (rather than the method
where the changed code is).

For instance, with the default diff driver:

    @@ -455,6 +455,8 @@ impl fmt::Write for RawFormatter {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

With the Rust diff driver:

    @@ -455,6 +455,8 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
             // Amount that we can copy. `saturating_sub` ensures we get 0 if `pos` goes past `end`.
             let len_to_copy = core::cmp::min(pos_new, self.end).saturating_sub(self.pos);

    +        test_diff_driver();
    +
             if len_to_copy > 0 {
                 // SAFETY: If `len_to_copy` is non-zero, then we know `pos` has not gone past `end`
                 // yet, so it is valid for write per the type invariants.

Thus set the `rust` diff driver for `*.rs` source files.

The Rust repository also does so since 2020 [2].

Link: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header [1]
Link: rust-lang/rust#78882 [2]
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230418233048.335281-1-ojeda@kernel.org
[ Added link to Rust repository ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues about the rust-lang/rust repository. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants