From b2fb0848b47fc487426d6d37f770ca419e2666cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasper=20Clemens=20Gr=C3=A4flich?= <jasper.graeflich@ptb.de> Date: Thu, 18 Aug 2022 12:18:14 +0200 Subject: [PATCH] Fix lstinline and lstlistoflistings --- thesis/1-1-6-loans-and-regions.tex | 6 +++--- thesis/thesis.pdf | 4 ++-- thesis/thesis.tex | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/thesis/1-1-6-loans-and-regions.tex b/thesis/1-1-6-loans-and-regions.tex index 67b0f13..9f02bb5 100644 --- a/thesis/1-1-6-loans-and-regions.tex +++ b/thesis/1-1-6-loans-and-regions.tex @@ -92,7 +92,7 @@ A \emph{region}\footnote{Polonius calls regions \emph{origins}, which is a more Now, a loan $L$ is live at some node $N$, if there is some variable which is live at $N$ and contains $L$ in its region. This difference means that different paths through the \ac{CFG} are independent from each other, because a node in one path can’t see a node in the other one by walking back the \ac{CFG}. -Let’s look at the example from \autoref{lst:nll-reject-correct} with all regions made explicit. \lstinline~x'{L1, L2}~ denotes that expression \inline{x} has a region consisting of the two loans \inline{L1} and \inline{L2}. +Let’s look at the example from \autoref{lst:nll-reject-correct} with all regions made explicit. \inline{x'{L1, L2}} denotes that expression \inline{x} has a region consisting of the two loans \inline{L1} and \inline{L2}. \begin{listing}[H] \begin{minted}{rust} @@ -110,9 +110,9 @@ Let’s look at the example from \autoref{lst:nll-reject-correct} with all regio \label{lst:regions} \end{listing} -In \autoref{lst:regions} we can see that there are four relevant loans: \inline{L0} is the loan of the reference we got passed in. All references depend on it. \inline{first} creates a reference with loan \inline{L1} that is returned in the \inline{Some} branch, \inline{push} implicitly reborrows to push a value onto \inline{*v}. The final reference is created by the index operation and it may also be returned. Therefore, the return value has a region \lstinline~'{L0, L1, L2}~, because those three loans are what it may depend on. +In \autoref{lst:regions} we can see that there are four relevant loans: \inline{L0} is the loan of the reference we got passed in. All references depend on it. \inline{first} creates a reference with loan \inline{L1} that is returned in the \inline{Some} branch, \inline{push} implicitly reborrows to push a value onto \inline{*v}. The final reference is created by the index operation and it may also be returned. Therefore, the return value has a region \inline{'{L0, L1, L2}}, because those three loans are what it may depend on. -Under \ac{NLL}, the \inline{push} was not possible because \inline{x} being live and depending on \inline{fst} meant that \inline{fst} was live. With Polonius, we must check if there is any live variable that has a nonempty intersection with \lstinline~'{L0, L2}~. \inline{fst} and \inline{x} are not live, so they don’t pose a problem, even if the regions overlap. \inline{v} is live and there is a region overlap, but since the compiler inserts a reborrow, it is not a problem. There could still be an error if the borrow stack were invalidated at a later point, but since Polonius is only looking backwards, this is not something we have to consider here. There are no more live variables, so the node passes the borrow check. +Under \ac{NLL}, the \inline{push} was not possible because \inline{x} being live and depending on \inline{fst} meant that \inline{fst} was live. With Polonius, we must check if there is any live variable that has a nonempty intersection with \inline~{'{L0, L2}}. \inline{fst} and \inline{x} are not live, so they don’t pose a problem, even if the regions overlap. \inline{v} is live and there is a region overlap, but since the compiler inserts a reborrow, it is not a problem. There could still be an error if the borrow stack were invalidated at a later point, but since Polonius is only looking backwards, this is not something we have to consider here. There are no more live variables, so the node passes the borrow check. \subsubsection{Self-referential Structs} diff --git a/thesis/thesis.pdf b/thesis/thesis.pdf index 6b7b1ea..7aab73b 100644 --- a/thesis/thesis.pdf +++ b/thesis/thesis.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a28168ad5751b468c4a7f47b678d3729290f472766c33abdd7c07a38d1af964 -size 178188 +oid sha256:8779b69f89079e0b06e13608da8f868ba7d76c7dcd53aa16595fd30996f400df +size 172233 diff --git a/thesis/thesis.tex b/thesis/thesis.tex index c2bb4d0..e225df1 100644 --- a/thesis/thesis.tex +++ b/thesis/thesis.tex @@ -23,7 +23,7 @@ % It seems like the LOL is confused if the caption contains % an `\lstlisting[language=Rust]'. It is fine without the % optional keyword. -\lstlistoflistings +\listoflistings % \listoffigures -- GitLab