Add CodeGen options to optimize for size.
Add CodeGen options to annotate functions with the attributes OptimizeSize and/or MinSize used by LLVM to reduce .text size.
Closes#32296
The compiler created a directory as part of `-Z incremental` but that may be
hierarchically used concurrently so we need to protect ourselves against that.
Fix alloc_jemalloc on windows gnu targets
jemalloc prefixes the symbols by default on Windows so we need to account
for that to avoid link errors such as: `undefined reference to 'mallocx'`
when using alloc_jemalloc.
There is now a CoreEmitter that everything desugars to, but without
losing any information. Also remove RenderSpan::FileLine. This lets the
rustc_driver tests build.
The extra filename and line was mainly there to keep the indentation
relative to the main snippet; now that this doesn't include
filename/line-number as a prefix, it is distracted.
This API pulls the "expected type foo, found type bar" out after the
main snippet. There are some other places where it makes sense, but this
is a start.
Major changes:
- Remove old snippet rendering code and use the new stuff.
- Introduce `span_label` method to add a label
- Remove EndSpan mode and replace with a fn to get the last
character of a span.
- Stop using `Option<MultiSpan>` and just use an empty `MultiSpan`
- and probably a bunch of other stuff :)
MultiSpan model is now:
- set of primary spans
- set of span+label pairs
Primary spans render with `^^^`, secondary spans with `---`.
Labels are placed next to the `^^^` or `---` marker as appropriate.
This should fix#31754 and follow-up #25343. Before the latter, the
closure was visited twice in the context of the enclosing fn, which
made even a single closure with a loop label emit a warning.
With this change, the closure is still visited within the context
of the main fn (which is intended, since it is not a separate item)
but resets the found loop labels while being visited.
Fixes: #31754
There was no span available in the cast function, but we need to infer the `x` in `x as char` to `u8`.
The spans are now removed from all functions using `infer` and instead added in `eval_const_expr_partial`
[MIR] Handle coercion casts properly when building the MIR
Coercion casts (`expr as T` where the type of `expr` can be coerced to
`T`) are essentially no-ops, as the actual work is done by a coercion.
Previously a check for type equality was used to avoid emitting the
redundant cast in the MIR, but this failed for coercion casts of
function items that had lifetime parameters. The MIR trans code doesn't
handle `FnPtr -> FnPtr` casts and produced an error.
Also fixes a bug with type ascription expressions not having any
adjustments applied.
Fixes#33295
/cc @eddyb