Add error note to illegal code snippet
Mark intentionally invalid code snippet in documentation as such with a comment. Similar comments used elsewhere in this file.
r? @steveklabnik
Make it clear that the reference isn't normative
Any time someone edits the reference, it has to be taken very seriously,
since it's the closest thing we have to a specification. This commit
adds language which indicates that this is not a normative document,
which makes it easier to make tweaks without worrying about forever
harming the future of Rust by painting ourselves in a corner.
r? @aturon
Add `{into,from}_raw` to Rc and Arc
These methods convert to and from a `*const T` for `Rc` and `Arc` similar to the way they work on `Box`. The only slight complication is that `from_raw` needs to offset the pointer back to find the beginning of the `RcBox`/`ArcInner`.
I felt this is a fairly small addition, filling in a gap (when compared to `Box`) so it wouldn't need an RFC. The motivation is primarily for FFI.
(I'll create an issue and update a PR with the issue number if reviewers agree with the change in principle **Edit: done #37197**)
~~Edit: This was initially `{into,from}_raw` but concerns were raised about the possible footgun if mixed with the methods of the same name of `Box`.~~
Edit: This was went from `{into,from}_raw` to `{into,from}_inner_raw` then back to `{into,from}_raw` during review.
A few changes are included here:
* The `winapi` and `url` dependencies were dropped. The source code for these
projects is pretty weighty, and we're about to vendor them, so let's not
commit to that intake just yet. If necessary we can vendor them later but for
now it shouldn't be necessary.
* The `--frozen` flag is now always passed to Cargo, obviating the need for
tidy's `cargo_lock` check.
* Tidy was updated to not check the vendor directory
Closes#34687
This commit vendors all dependencies when using rustbuild to ensure that we
don't hit the network during a build and can build as a self-contained unit.
`cargo new` now creates a `src/lib.rs` with a `tests` module by default. I've updated the earlier examples in this doc to reflect this. However, I don't know how we want to approach the "introduction" to idiomatic testing that follows in "the tests module" section. I _think_ it should be broken apart, with the module concept being introduced early on, and the `super` concept being addressed when we hit the `add_two` example. I'd like to get agreement on that being the right approach before I do it though.
I _also_ removed the `#fn main() {}` hidden at the beginning of each example, as these cause Rust Playground to not treat the file as a set of tests that it can run. Removing it _should_ cause Rust Playground to display a "Test >" button in the top left when a user runs the code, which will allow them to see the test runner output.
By using a second attribute `attributes(Bar)` on
proc_macro_derive, whitelist any attributes with
the name `Bar` in the deriving item. This allows
a proc_macro function to use custom attribtues
without a custom attribute error or unused attribute
lint.
Stabilize `..` in tuple (struct) patterns
I'd like to nominate `..` in tuple and tuple struct patterns for stabilization.
This feature is a relatively small extension to existing stable functionality and doesn't have known blockers.
The feature first appeared in Rust 1.10 6 months ago.
An example of use: https://github.com/rust-lang/rust/pull/36203
Closes https://github.com/rust-lang/rust/issues/33627
r? @nikomatsakis
KNOWN_ATTRIBUTES should really be named BUILT_ATTRIBUTES,
while KNOWN_ATTRIBUTES should be used to mark attributes
as known, similar to USED_ATTRIBUTES.
rustbuild: support MIPS host builds
There is a *little* code duplication, but primarily for sake of "match exhaustiveness". Let's blame Linux/MIPS for not exposing endianness explicitly in `uname -m` (that's user-space interface and as such is frozen).
Currently the build won't work as we have to wait for a new stage0 for the MIPS host compilers, but this paves the way to self-hosted Rust on MIPS. The cross-compiled MIPS binaries are confirmed to work on the Loongson 3A2000 (MIPS64r2-compatible) so we have plenty of confidence that they'll work on other MIPS platforms too, as Linux/MIPS user-space ABI is consistent across machines of the same bitness.
r? @alexcrichton
Remove mention of mipsel target_arch
This is the only remaining instance in rustc. All others were in the libc repo, removed with rust-lang/libc#445.
Actually there's more to clean in `libsyntax/abi.rs`, but let's save that for another commit...
Fix Arc::clone()'s MAX_REFCOUNT check (off-by-one)
Before, the strong count of an `Arc` could be set to
`MAX_REFCOUNT + 1`, because when this happened, `old_size` would
be exactly `MAX_REFCOUNT`. `Arc::clone()` would not abort.
This commit changes the check in `Arc::clone()` to also abort if
the old value is equal to `MAX_REFCOUNT`, because then the new
value will be equal to `MAX_REFCOUNT + 1`.
A test would require allocating memory for `isize::MAX` pointers.
This would probably crash any machine, so no test is submitted
with this commit.
There is a *little* code duplication, but primarily for sake of "match
exhaustiveness". Let's blame Linux/MIPS for not exposing endianness
explicitly in `uname -m` (that's user-space interface and as such is
frozen).
Currently the build won't work as we have to wait for a new stage0 for
the MIPS host compilers, but this paves the way to self-hosted Rust on
MIPS. The cross-compiled MIPS binaries are confirmed to work on the
Loongson 3A2000 (MIPS64r2-compatible) so we have plenty of confidence
that they'll work on other MIPS platforms too, as Linux/MIPS user-space
ABI is consistent across machines of the same bitness.
The `mipsel` `target_arch` was introduced with the initial MIPSel
support (rust-lang/rust@82ec1aef29),
but was subsequently removed with implementation of the Flexible Target
Specification (Rust RFC 0131,
rust-lang/rust@3a8f4ec32a).
This is the only remaining instance in rustc. All others are in the libc
repo, and are fixed in rust-lang/libc@b3676593f6.
macros: improve shadowing checks
This PR improves macro-expanded shadowing checks to work with out-of-(pre)order expansion.
Out-of-order expansion became possible in #37084, so this technically a [breaking-change] for nightly.
The regression test from this PR is an example of code that would break.
r? @nrc
Force static linking of LLVM
Run `llvm-config` with `--link-static` if available, to force static linking of LLVM.
This option was added in LLVM 3.8.
This is my first pull request, any feedback is welcome!
Fixes#36854
See also: #36996
The constant name `MAX_REFCOUNT` suggests that the value is a
_hard_ limit on the amount of references to an `Arc`. This is
a more soft limit however. This commit adds a comment to the
constant to annotate this.
See also: PR #37605
[4/n] rustc: harden against InferOk having obligations in more cases.
_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37402) | [next](https://github.com/rust-lang/rust/pull/37408)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._
<hr>
This adds more asserts that `InferOk` results have no obligations, pending completion of #32730.
Each of these could accidentally drop obligations on the floor if they start getting produced by unification, and a future change does just that, in order to produce a "shallow success" (hopefully leading to ambiguities during trait selection), _without_ the possibility of an eventual success - mostly guarded by ICEs for now.