Skip to content

Commit

Permalink
Deploying to gh-pages from @ 9fda4b4 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinleroy committed Aug 30, 2024
1 parent 4c852ff commit efefc11
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 189 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><a href="index.html">Introduction</a></li><li class="chapter-item expanded "><a href="trait-debugging-101.html"><strong aria-hidden="true">1.</strong> Trait Debugging 101</a></li><li class="chapter-item expanded "><a href="typestate.html"><strong aria-hidden="true">2.</strong> Trait Methods and Typestate</a></li></ol>
<ol class="chapter"><li class="chapter-item expanded "><a href="trait-debugging-101.html"><strong aria-hidden="true">1.</strong> Trait Debugging 101</a></li><li class="chapter-item expanded "><a href="typestate.html"><strong aria-hidden="true">2.</strong> Trait Methods and Typestate</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
Expand Down
Binary file modified assets/axum-hello-server/async-fix-response.mp4
Binary file not shown.
Binary file modified assets/axum-hello-server/axum-type-checks.mp4
Binary file not shown.
Binary file modified assets/axum-hello-server/bottom-up-start.mp4
Binary file not shown.
Binary file added assets/diesel-bad-select/failing-bounds.mp4
Binary file not shown.
Binary file modified assets/diesel-bad-select/find-bug.mp4
Binary file not shown.
Binary file added assets/diesel-bad-select/open-argus.mp4
Binary file not shown.
189 changes: 184 additions & 5 deletions index.html

Large diffs are not rendered by default.

132 changes: 44 additions & 88 deletions print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

103 changes: 28 additions & 75 deletions trait-debugging-101.html

Large diffs are not rendered by default.

34 changes: 16 additions & 18 deletions typestate.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><a href="index.html">Introduction</a></li><li class="chapter-item expanded "><a href="trait-debugging-101.html"><strong aria-hidden="true">1.</strong> Trait Debugging 101</a></li><li class="chapter-item expanded "><a href="typestate.html" class="active"><strong aria-hidden="true">2.</strong> Trait Methods and Typestate</a></li></ol>
<ol class="chapter"><li class="chapter-item expanded "><a href="trait-debugging-101.html"><strong aria-hidden="true">1.</strong> Trait Debugging 101</a></li><li class="chapter-item expanded "><a href="typestate.html" class="active"><strong aria-hidden="true">2.</strong> Trait Methods and Typestate</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
Expand Down Expand Up @@ -238,20 +238,11 @@ <h1 id="trait-methods-and-typestate"><a class="header" href="#trait-methods-and-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::load`
= note: the full name for the type has been written to 'bad_select-fa50bb6fe8eee519.long-type-16986433487391717729.txt'
</code></pre>
<p>As we did in the previous section, we shall demo a short workflow using Argus to gather the same information.</p>
<p>As we did in the previous section, we shall demo a short workflow using Argus to gather the same information. Opening the Argus panel works a little differently, as you shall see in the following video. When there isn’t a link to the obligation in the error tooltip, you can always open Argus from the Command Palette or the bottom toolbar.</p>
<video controls>
<source alt="Diesel finding bug" src="assets/diesel-bad-select/find-bug.mp4" type="video/mp4" />
<source alt="Opening the Argus panel" src="assets/diesel-bad-select/open-argus.mp4" type="video/mp4" />
</video>
<p>We want to call attention to a some aspects of the above video that are easy to glance over.</p>
<ol>
<li>
<p>When opening the Argus debugger the hover tooltip said “Expression contains unsatisfied trait bounds,” but there wasn’t a link to jump to the error. This is an unfortunate circumstance, but one that does occur. In these cases you can open the Argus panel by clicking the Argus status in the bottom information bar, or run the command ‘Argus: Inspect current file’ in the command palette.</p>
</li>
<li>
<p>In the Argus panel there are two errors we chose <em>not</em> to explore further</p>
<pre><code class="language-rust ignore">id: Iterator
table: Iterator</code></pre>
<p>We chose not to explore them for two reasons. (1) they are in expressions that don’t contain errors as shown by Rust Analyzer, the method calls <code>.eq(...)</code> and <code>.filter(...)</code>. (2) the trait bound for <code>Iterator</code> seems strange as it isn’t related to the error diagnostic at all; we’re looking for something Diesel related but these errors are talking about <code>Iterator</code>. For these two reasons I chose to ignore the two <code>Iterator</code> bound “errors” and explore the other first.</p>
<p>Below we see that Argus presents <em>more</em> failing bounds than the compiler did. To debug effectively with Argus you should consider all failing founds in the context of your problem and start with the one that is most relevant. You can also compare the failing bound with information provided in the Rust error diagnostic to get you on the right track.</p>
<div id="admonition-important" class="admonition admonish-tip" role="note" aria-labelledby="admonition-important-title">
<div class="admonition-title">
<div id="admonition-important-title">
Expand All @@ -263,6 +254,17 @@ <h1 id="trait-methods-and-typestate"><a class="header" href="#trait-methods-and-
<p><strong>Argus may present more errors than the Rust compiler,</strong> it is research software after all. Use your judgement to decide which errors are first worth exploring, if there are multiple, look at all of them before diving down into one specific search tree. We’re working hard to reduce noise produced by Argus as much as possible.</p>
</div>
</div>
<video controls>
<source alt="Failing bounds in Argus" src="assets/diesel-bad-select/failing-bounds.mp4" type="video/mp4" />
</video>
<p>Now let’s dive into the trait error.</p>
<video controls>
<source alt="Diesel finding bug" src="assets/diesel-bad-select/find-bug.mp4" type="video/mp4" />
</video>
<p>Here are some key points from above that we’d like to highlight</p>
<ol>
<li>
<p>When opening the Argus debugger the hover tooltip said “Expression contains unsatisfied trait bounds,” but there wasn’t a link to jump to the error. This is an unfortunate circumstance, but one that does occur. In these cases you can open the Argus panel by clicking the Argus status in the bottom information bar, or run the command ‘Argus: Inspect current file’ in the command palette.</p>
</li>
<li>
<p>The printed types in Rust can get painfully verbose, the Rust diagnostic even <em>wrote types to a file</em> because they were too long. Argus shortens and condenses type information to keep the panel as readable as possible. One example of this is that fully-qualified identifiers, like <code>users::columns::id</code> prints shortened as <code>id</code>. On hover, the full path is shown at the bottom of the Argus panel in our mini-buffer. Extra information or notes Argus has for you are printed in the mini-buffer, so keep an eye on that if you feel Argus isn’t giving you enough information.</p>
Expand All @@ -271,11 +273,7 @@ <h1 id="trait-methods-and-typestate"><a class="header" href="#trait-methods-and-
<p>Clicking the tree icon next to a node in the Bottom-Up view jumps to that same node in the Top-Down view. This operation is useful if you want to gather contextual information around a node, but don’t want to search the Top-Down tree for it. You can get there in one click.</p>
</li>
</ol>
<p>In the video we expanded the Bottom-Up view to see where the bound <code>Count == Once</code> came from. The origin stems from the <code>T: AppearsOnTable&lt;Qs&gt;</code> constraint in the where clause of the <code>Eq&lt;T, U&gt;</code> impl block. In English we can summarize this as “an equality constraint is valid if both expressions appear in the selected table.” Looking through the search tree I see that the bound</p>
<pre><code class="language-rust ignore">users::columns::id: AppearsOnTable&lt;users::table&gt;</code></pre>
<p>holds true, while the bound</p>
<pre><code class="language-rust ignore">posts::columns::id: AppearsOnTable&lt;users::table&gt;</code></pre>
<p>is unsatisfied. Argh, we forgot to join the <code>users</code> and <code>posts</code> tables! At this point we understand and have identified the error, now it’s time to fix the program. Unfortunately Argus provides no aide to <em>fix</em> typestate errors. We’re in the wrong state, <code>posts::id</code> doesn’t appear in the table we’re selecting from, we need to get it on the selected-from table. This is a great time to reach for the Diesel documentation for <a href="https://docs.rs/diesel/latest/diesel/prelude/trait.QueryDsl.html"><code>QueryDsl</code></a>.</p>
<p>Turns out we forgot to join the <code>users</code> and <code>posts</code> tables! At this point we understand and have identified the error, now it’s time to fix the program. Unfortunately Argus provides no aide to <em>fix</em> typestate errors. We’re in the wrong state, <code>posts::id</code> doesn’t appear in the table we’re selecting from, we need to get it on the selected-from table. This is a great time to reach for the Diesel documentation for <a href="https://docs.rs/diesel/latest/diesel/prelude/trait.QueryDsl.html"><code>QueryDsl</code></a>.</p>
<video controls>
<source alt="Diesel fixing typestate error" src="assets/diesel-bad-select/fixed-error.mp4" type="video/mp4" />
</video>
Expand Down

0 comments on commit efefc11

Please sign in to comment.