The reference is pointing to the static memory, it's not dangling.
"static"? Did you mean the stack? In this case there is a String created from the static constant.
The String is on the stack and the address refers to the stack location. Rust allows this without creating a separate local variable for the String, as a convenience I assume.
The feature that would make a value like &0 be a reference pointing to static memory is called “constant static promotion” (exact naming can vary) and (among other conditions) it only applies to const-evaluable values, which String::from isn't.
The second context is when a reference is bound to a temporary. The temporary to which the reference is
bound or the temporary that is the complete object to a subobject of which the temporary is bound persists
for the lifetime of the reference except as specified below...
The "except as specified" and references bound to things which look like temporaries are both major sources of bugs.
Yes, this is a special case that someone thought was a good idea to add. Under the normal lifetime rules, it definitely shouldn't work. (And I think it was a bad idea to allow it in the first place, and IMO you shouldn't rely on it, because it's weirdness for no benefit.)
How could it possibly be "turned into a string literal"? String literals have type &str, not String. String is an opaque UDT that doesn't have special semantics to the compiler, unlike string literals. The compiler isn't allowed to just turn arbitrary types into other types.