The general issue, as mentioned by xzczd, is that Manipulate
only "notices" explicit visible parameters. This is because when you evaluate something like Manipulate[x, {x, 0, 1}]
and start waggling the slider, you are not changing the value of the global symbol x
, but instead a temporary symbol called something like x$$15
. You can see this like so:
Manipulate[{SymbolName @ Unevaluated @ x, x}, {x, 0, 1}]

So in order to make the magic happen, Manipulate
has to find occurrences of x
in the manipulated expression and replace them with the temporary symbol. It does this before evaluating the expression.
So if you try this...
a = 10 + x;
Manipulate[a, {x, 0, 1}]
...Manipulate
looks at the unevaluated expression a
and finds no occurrence of x
. So you get this output:

Here a
is evaluating to 10 + x
(that's the global symbol x
) but the slider is controlling some temporary symbol like x$$15
.
To get the desired behaviour you can use With
to replace the a
inside the Manipulate
with its evaluated form 10 + x
. That way Manipulate
will "notice" the x
and replace it with the temporary symbol tied to the slider:
With[{a = a}, Manipulate[a, {x, 0, 1}]]

So for the problem in the question, the plot can be obtained like this:
rule = {z -> x^2 + 2 x + y};
With[{rule = rule},
Manipulate[Plot[z /. rule, {x, 0, 10}], {{y, 2, "y"}, 1, 5}]]
Special behaviour with Out
The apparent mystery is why this works:
a = 10 + x;
Manipulate[%, {x, 0, 1}]

The answer is simply that Manipulate
has special handling for Out
. Any occurrence of Out
in the manipulated expression is evaluated before Manipulate
does its localization, similarly to what we did above with With
. So Manipulate
"notices" the x
and works as desired.
For those who like to know these things: the handling of Out
is implemented by Manipulate`Dump`resolveOut
using the Trott-Strzebonski trick.
Manipulate
: Manipulate only "notices" explicit visible parameters. You can check the document for more information: reference.wolfram.com/mathematica/ref/Manipulate.en.html $\endgroup$%
is evaluated. E.g., this works with%
in place ofrule
:rule = {z -> x^2 + 2 x + y}; Manipulate[Plot[z /. %, {x, 0, 10}], {{y, 2, "y"}, 1, 5}]
. I thoughtOut[1]
would be treated like the global variable but it's not. $\endgroup$Manipulate
has special handling ofOut
viaManipulate`Dump`resolveOut[]
$\endgroup$?Manipulate`Dump`resolveOut
Good find! Consider putting it in an answer. $\endgroup$