Fix ICE in const pretty printing and resolve FIXME
Consts now have a `fmt::Display` impl, so we can just use that to pretty-print.
This resolves an ICE in https://github.com/rust-lang/rust/issues/61936, though it hits more ICEs afterwards. I couldn't find a test case that was resolved by this that didn't hit errors later on.
Handle multiple error fix suggestions carefuly
The existing code seems to assume that substitutions spans are disjoint,
which is not always the case.
In the example:
pub trait AAAA {}
pub trait B {}
pub trait C {}
pub type T<P: AAAA + B + C> = P;
, we get three substituions starting from ':' and ending respectively at
the end of each trait token.
With the former offset calculation, this would cause `underline_start` to
eventually become negative before being converted to `usize`...
The new version may report erroneous results for non perfectly overlapping
substitutions but I don't know if such examples exist. Alternatively, we
could detect these cases and trim out overlapping substitutions.
Fixes#67690
Add an unstable conversion from thread ID to u64
We see multiple cases inside rustc and ecosystem code where ThreadId is
transmuted to u64, exploiting the underlying detail. This is suboptimal
(can break unexpectedly if we change things in std).
It is unlikely that ThreadId will ever need to be larger than u64 --
creating even 2^32 threads over the course of a program is quite hard,
2^64 is even harder. As such, we do not choose to return a larger sized
type (e.g. u128). If we choose to shrink ThreadId in the future, or
otherwise change its internals, it is likely that a mapping to u64 will
still be applicable (though may become more complex).
I will file a tracking issue as soon as this is loosely approved.
Standard library support for riscv64gc-unknown-linux-gnu
Add std support for RISC-V 64-bit GNU/Linux and update libc for RISC-V support.
r? @alexcrichton
We see multiple cases inside rustc and ecosystem code where ThreadId is
transmuted to u64, exploiting the underlying detail. This is suboptimal
(can break unexpectedly if we change things in std).
It is unlikely that ThreadId will ever need to be larger than u64 --
creating even 2^32 threads over the course of a program is quite hard,
2^64 is even harder. As such, we do not choose to return a larger sized
type (e.g. u128). If we choose to shrink ThreadId in the future, or
otherwise change its internals, it is likely that a mapping to u64 will
still be applicable (though may become more complex).
Silence `TooGeneric` error
This error may be produced during intermediate failed attempts at evaluation of a generic const, which may nevertheless succeed later.
Fixes https://github.com/rust-lang/rust/issues/66962.
r? @eddyb
Fix ICE involving calling `Instance.ty` during const evaluation
Fixes#67639
`Instance.ty` assumes that we are in a fully monomorphic context (e.g.
codegen), and can therefore use an empty `ParamEnv` when performing
normalization. Howver, the MIR constant evaluator code ends up calling
`Instance.ty` as a result of us attemptign to 'speculatively'
const-evaluate generic functions during const propagation.
As a result,
we may end up with projections involving type parameters
(e.g. <T as MyTrait>::Bar>) in the type we are trying to normalize.
Normalization expects us to have proper predicates in the `ParamEnv` for
such projections, and will ICE if we don't.
This commit adds a new method `Instance.ty_env`, which takes a
`ParamEnv` for use during normalization. The MIR const-evaluator code is
changed to use this method, passing in the proper `ParamEnv` for the
context at hand.
buffer lexer errors in rustdoc syntax checking
The code isn't ideal (I really would like to display the errors inline), but this at least gets us to where we were before #63017.