rustdoc: fix doctests with non-feature crate attrs
Fixes#38129.
The book says that any top-level crate attributes at the beginning of a doctest are moved outside the generated `fn main`, but it was only checking for `#![feature`, not `#![`.
These attributes previously caused warnings but were then ignored, so in theory this could change the behavior of doctests in the wild.
Remove attr-variant-data.rs since it relies on quirks
in legacy custom derive resolution (undefined derives
only print a warning).
Add a new test which uses a defined proc macro derive,
and tests pretty printing of proc macro derive
attributes.
Implement kind="static-nobundle" (RFC 1717)
This implements the "static-nobundle" library kind (last item from #37403).
Rustc handles "static-nobundle" libs very similarly to dylibs, except that on Windows, uses of their symbols do not get marked with "dllimport". Which is the whole point of this feature.
These methods enable socket reads without side-effects. That is,
repeated calls to peek() return identical data. This is accomplished
by providing the POSIX flag MSG_PEEK to the underlying socket read
operations.
This also moves the current implementation of recv_from out of the
platform-independent sys_common and into respective sys/windows and
sys/unix implementations. This allows for more platform-dependent
implementations.
Previously, the note/message for the source of a lint being the command
line unconditionally named the individual lint, even if the actual
command specified a lint group (e.g., `-D warnings`); here, we take note
of the actual command options so we can be more specific.
This remains in the matter of #36846.
Warning or error messages set via a lint group attribute
(e.g. `#[deny(warnings)]`) should still make it clear which individual
lint (by name) was triggered, similarly to how we include "on by
default" language for default lints. This—and, while we're here, the
existing "on by default" language—can be tucked into a note rather than
cluttering the main error message. This occasions the slightest of
refactorings (we now have to get the diagnostic-builder with the main
message first, before matching on the lint source).
This is in the matter of #36846.
rewrite the predecessors code to create a reduced graph
The old code created a flat listing of "HIR -> WorkProduct" edges.
While perfectly general, this could lead to a lot of repetition if the
same HIR nodes affect many work-products. This is set to be a problem
when we start to skip typeck, since we will be adding a lot more
"work-product"-like nodes.
The newer code uses an alternative strategy: it "reduces" the graph
instead. Basically we walk the dep-graph and convert it to a DAG, where
we only keep intermediate nodes if they are used by multiple
work-products.
This DAG does not contain the same set of nodes as the original graph,
but it is guaranteed that (a) every output node is included in the graph
and (b) the set of input nodes that can reach each output node is
unchanged.
(Input nodes are basically HIR nodes and foreign metadata; output nodes
are nodes that have assocaited state which we will persist to disk in
some way. These are assumed to be disjoint sets.)
r? @michaelwoerister
Fixes#39494
Before, the `count` would be copied into the closure and could
potentially be optimized way. This change ensures it's borrowed by
closure and finally consumed by `test::black_box`.
Miscellaneous refactors around how lints and typeck interact
This is preparation for making incr. comp. skip typeck. The main gist of is trying to rationalize the outputs from typeck that are not part of tables:
- one bit of output is the `used_trait_imports` set, which becomes something we track for dependencies
- the other big of output are various lints; we used to store these into a table on sess, but this work stores them into the`TypeckTables`, and then makes the lint pass consult that
- I think it probably makes sense to handle errors similarly, eventually, but that's not necessary now
r? @eddyb
Fixes#39495
Instead of directly creating a 'DIGlobalVariable', we now have to create
a 'DIGlobalVariableExpression' which itself contains a reference to a
'DIGlobalVariable'.
This is a straightforward change.
In the future, we should rename 'DIGlobalVariable' in the FFI
bindings, assuming we will only refer to 'DIGlobalVariableExpression'
and not 'DIGlobalVariable'.
std: Add ToString trait specialization for Cow<'a, str> and String
There is a specialized version of ToString for str type in std. I think there are other types can also benefit from specialization. `Cow` and `String` are the most obvious one.
r? @bluss
We introduced the unadjusted ABI to work around wrong
(buggy) ABI expectations by LLVM on Windows [1].
Therefore, it should be solely used on Windows and not
on other platforms, like right now is the case.
[1]: see this comment for details https://github.com/rust-lang/rust/pull/38482#issuecomment-269074031
Bump version, upgrade bootstrap
This commit updates the version number to 1.17.0 as we're not on that version of
the nightly compiler, and at the same time this updates src/stage0.txt to
bootstrap from freshly minted beta compiler and beta Cargo.
This commit updates the version number to 1.17.0 as we're not on that version of
the nightly compiler, and at the same time this updates src/stage0.txt to
bootstrap from freshly minted beta compiler and beta Cargo.
Use `String::with_capacity` in `format!`
Add an `Arguments::estimated_capacity` to estimate the length of formatted text and use it in `std::fmt::format` as the initial capacity of the buffer.
The capacity is calculated based on the literal parts of format string, see the details in the implementation.
Some benches:
```rust
empty: format!("{}", black_box(""))
literal: format!("Literal")
long: format!("Hello Hello Hello Hello, {}!", black_box("world"))
long_rev: format!("{}, hello hello hello hello!", black_box("world"))
long_rev_2: format!("{}{}, hello hello hello hello!", 1, black_box("world"))
short: format!("Hello, {}!", black_box("world"))
short_rev: format!("{}, hello!", black_box("world"))
short_rev_2: format!("{}{}, hello!", 1, black_box("world"))
surround: format!("aaaaa{}ccccc{}eeeee", black_box("bbbbb"), black_box("eeeee"))
two_spaced: format!("{} {}", black_box("bbbbb"), black_box("eeeee"))
worst_case: format!("{} a long piece...", black_box("and even longer argument. not sure why it has to be so long"))
```
```
empty 25 28 3 12.00%
literal 35 29 -6 -17.14%
long 80 46 -34 -42.50%
long_rev 79 45 -34 -43.04%
long_rev_2 111 66 -45 -40.54%
short 73 46 -27 -36.99%
short_rev 74 76 2 2.70%
short_rev_2 107 108 1 0.93%
surround 142 65 -77 -54.23%
two_spaced 111 115 4 3.60%
worst_case 89 101 12 13.48%
```