Tweak some stabilizations in libstd
This commit tweaks a few stable APIs in the `beta` branch before they hit
stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were
deleted (added in #49381, issue at #49657). The `and_modify` APIs added
in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure.
Closes#49581Closes#49657
Note that this commit, since it is trying to be minimal in order to
ease backporting to the beta and release channels, does *not* include
the old future-proofing warnings that we used to have associated with
such fallback to `()`; see discussion at this comment:
https://github.com/rust-lang/rust/issues/49691#issuecomment-381266730
This commit is just covering the feature gate itself and the tests
that made direct use of `!` and thus need to opt back into the
feature.
A follow on commit brings back the other change that motivates the
revert: Namely, going back to the old rules for falling back to `()`.
Fix bad merge in #49991
When I rebased #49991 on `master`, I messed up the merge for this line. I'm reverting this back to the way it was in f15e5c1.
r? @michaelwoerister
Disable auto-detection of libxml2 when compiling llvm.
This broke cross-compiling rustc with internal llvm (with both the host and target being executable on the machine), because llvm's build system detected libxml2 on the host, therefore auto-enabled libxml2 support, but wouldn't compile as the target didn't have libxml2 installed.
wasm: Increase default stack size to 1MB
This commit increases the dfeault stack size allocated to the
wasm32-unknown-unknown target to 1MB by default. Currently the default stack
size is one wasm page, or 64 kilobytes. This default stack is quite small and
has caused a stack overflow or two in the wild by accident.
The current "best practice" for fixing this is to pass `-Clink-args='-z
stack-size=$bigger'` but that's not great nor always easy to do. A default of
1MB matches more closely with other platforms where it's "pretty big" by
default.
Note that it was tested and if the users uses `-C link-args` to pass a custom
stack size that's still resepected as lld seems to take the first argument, and
where rustc is passing it will always be last.
Add rustdoc to x.py check
Modifying rustc can often cause errors in rustdoc, so it's useful to include it in the steps that are checked.
One thing that I was unsure about was when to call `clear_if_dirty` (both in this step, and in other steps in relation to this one) — we want to be sure rustdoc will always be rechecked after modifying previous steps — but does this belong in rustdoc, or the other steps?
Fixes#49917.
r? @Mark-Simulacrum
`nearest_common_ancestor()` uses an algorithm that requires computing
the full scope chain for both scopes, which is expensive because each
element involves a hash table lookup, and then looking for a common
tail.
This patch changes `nearest_common_ancestor()` to use a different
algorithm, which starts at the given scopes and works outwards (i.e. up
the scope tree) until a common ancestor is found. This is much faster
because in most cases the common ancestor is found well before the end
of the scope chains. Also, the use of a SmallVec avoids the need for any
allocation most of the time.
proc_macro: Stay on the "use the cache" path more
Discovered in #50061 we're falling off the "happy path" of using a stringified
token stream more often than we should. This was due to the fact that a
user-written token like `0xf` is equality-different from the stringified token
of `15` (despite being semantically equivalent).
This patch updates the call to `eq_unspanned` with an even more awful solution,
`probably_equal_for_proc_macro`, which ignores the value of each token and
basically only compares the structure of the token stream, assuming that the AST
doesn't change just one token at a time.
While this is a step towards fixing #50061 there is still one regression
from #49154 which needs to be fixed.
This commit transitions the `target_feature` attribute from `Normal` to
`Whitelisted`. Discovered in #50095 the fact of whether this attribute is used
or not is dependent on typechecking running and executing `check_name`, but
incremental compilation doesn't currently account for this, meaning that the
attribute ends up being flagged as unused when it shouldn't be.
I was a little too ambitious it seems hoping that `Normal` could be used, so
instead this transitions to `Whitelisted` to be the same as other codegen
attributes like `#[inline]`
Closes#50095
When compiling crates we'll be calculating and parsing `#[target_feature]` for
upstream crates. We'll also be checking the stability of listed features, but we
only want to check the listed stability during the actual crate that wrote the
relevant code. This commit updates the `target_feature` process to ignore
foreign `DefId` instances and only check the feature whitelist for local
functions.
Closes#50094
A Box type with associated allocator would, on its own, be a backwards
incompatible change, because of the additional parameter, but if that
additional parameter has a default, then backwards compatibility with
the current definition of the type is preserved.
But the owned_box lang item currently doesn't allow such extra
parameters, so add support for this.
box_free currently takes a pointer. With the prospect of the Box type
definition changing in the future to include an allocator, box_free will
also need to be aware of this. In order to prepare for that future, we
allow box_free to take a form where its argument are the fields of the
Box.
e.g. if Box is defined as `Box(A, B, C)`, then box_free signature
becomes `box_free(a: A, b: B, c: C)`.
We however still allow the current form (taking a pointer), so that the
same compiler can handle both forms, which helps with bootstrap.
Because box_free is now passed a pointer instead of a Box, we can stop
relying on TypeChecked::check_box_free_inputs, because
TypeChecker::check_call_inputs should be enough, like for all other
function calls.
It seems it was not actually reached anyways in cases where it would
have made a difference. (issue #50071)
Currently, MIR just passes the raw Box to box_free(), which happens to
work because practically, it's the same thing. But that might not be
true in the future, with Box<T, A: Alloc>.
The MIR inline pass actually fixes up the argument while inlining
box_free, but this is not enabled by default and doesn't necessarily
happen (the inline threshold needs to be passed).
This change effectively moves what the MIR inline pass does to the
elaborate_drops pass, so that box_free() is passed the raw pointer
instead of the Box.
This commit tweaks a few stable APIs in the `beta` branch before they hit
stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were
deleted (added in #49381, issue at #49657). The `and_modify` APIs added
in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure.
Closes#49581Closes#49657
atomic: remove 'Atomic*' from Debug output
For the same reason that we don't show `Vec { data: [0, 1, 2, 3] }`, but just the array, the `AtomicUsize(1000)` is noisy, and seeing just `1000` is likely better.
This commit increases the dfeault stack size allocated to the
wasm32-unknown-unknown target to 1MB by default. Currently the default stack
size is one wasm page, or 64 kilobytes. This default stack is quite small and
has caused a stack overflow or two in the wild by accident.
The current "best practice" for fixing this is to pass `-Clink-args='-z
stack-size=$bigger'` but that's not great nor always easy to do. A default of
1MB matches more closely with other platforms where it's "pretty big" by
default.
Note that it was tested and if the users uses `-C link-args` to pass a custom
stack size that's still resepected as lld seems to take the first argument, and
where rustc is passing it will always be last.