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.
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
The changed line makes it look like `unsafe` is allowed, but the
first statement of `parse_item_foreign_fn` is:
`self.expect_keyword(keywords::Fn)?;`
So we get the strange "expected one of `fn`, `pub`, `static`, or
`unsafe`, found `unsafe`".
Fixes: #27361
Current description of `std::mem::size_of` is ambiguous, and the
`std::intrinsics::size_of` description incorrectly defines size
as the number of bytes necessary to exactly overwrite a value,
not including the padding between elements necessary in a vector
or structure.
Current code leads to messages like "... use a \xHH escape: \u{e4}"
which is confusing.
The printed span already points to the offending character, which
should be enough to identify the non-ASCII problem.
Fixes: #29088
This is curiously missing from both the short message and this
long diagnostic.
Refs #31573 (not sure if it should be considered "fixed" as the
short message still only refers to extern crates).
In situations where the value of the last expression must be inferred,
rustc will not emit the "you might need to remove the semicolon" warning,
so at least note this in the extended description.
Fixes: #30497
resolve: improve diagnostics and lay groundwork for resolving before ast->hir
This PR improves diagnostics in `resolve` and lays some groundwork for resolving before ast->hir.
More specifically,
- It removes an API in `resolve` intended for external refactoring tools (see #27493) that appears not to be in active use. The API is incompatible with resolving before ast->hir, but could be rewritten in a more compatible and less intrusive way.
- It improves the diagnostics for pattern bindings that conflict with `const`s.
- It improves the diagnostics for modules used as expressions (fixes#33186).
- It refactors away some uses of the hir map, which is unavavailable before ast->hir lowering.
r? @eddyb
Remove the requirement that ast->hir lowering be reproducible
This PR changes the ast->hir lowerer to be non-reproducible, and it removes the lowering context's id cache.
If the `hir` of an `ast` node needs to be reproduced, we can use the hir map instead of the lowerer -- for example, `tcx.map.expect_expr(expr.id)` instead of `lower_expr(lcx, expr)`.
r? @nrc
* It is not clear what a "base function" is.
* The suggestion just adds parens, so suggests calling without args.
The second point could be fixed with e.g. `(...)` instead of `()`,
but the preceding "note: X is a function, perhaps you wish to call it"
should already be clear enough.
Fixes: #31341
Fix a race condition caused by concurrently executed codegen unit tests.
This hopefully fixes issue #33315.
This short-term solution just makes sure that every test uses its own directory so they can't get into conflict with each other.
As a more long-term solution, I'd probably prefer to make the partitioning scheme specifiable via `-Ccodegen-units` (e.g. like `-Ccodegen-units=per-module`) so that we don't have to rely on `-Zincremental` in these test cases.
r? @alexcrichton
On my system, when the processor is already loaded, and I try to
run the test suite, e.g. compile-fail/dep-graph-assoc-type-trans.rs
fails because of undecodable JSON.
Running the compiler manually, I can see that the dep graph thread
panics (and puts non-JSON on stderr) while `send`ing on `swap_out`,
presumably because the other end has already quit. I think that in
this case, we can just gracefully exit the thread.
Invalid expressions on the RHS were just swallowed without generating
an error. The new code more closely mirrors the code for parsing
`..x` in the `parse_prefix_range_expr` method, where no cancel is done
either.
Fixes#33262.
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.
* implement Display on Token instead of custom tok_str() fn
* use expression returns
* remove redundant parens in asserts
* remove "/* bad */" comments that appear to be related to early
changes in memory management
* and a few individual idiomatic changes
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
Make BTreeSet::Insert docs more consistent
Made the BTreeSet::Insert documentation consistent with the HashSet::Insert documentation by using the term 'value' instead of 'key'.
r? @steveklabnik
configure: Add a sanity check for tarballs without submodules
Because GitHub publishes broken tarballs on our behalf that we can't
disable, this adds a check that src/liblibc exists, and then
complains if not.
Tested.
When downloading a file in the bootstrap phase - get it to a temp
location first. Verify it there and only if downloaded properly move it
to the `cache` directory.
This should prevent `make` being stuck if the download was interrupted
or otherwise corrupted.
The temporary files are deleted in case of an exception.