Make transmuting from fn item types to pointer-sized types a hard error.
Closes#19925 by removing the future compatibility lint and the associated workarounds.
This is a `[breaking-change]` if you `transmute` from a function item without casting first.
For more information on how to fix your code, see https://github.com/rust-lang/rust/issues/19925.
Simplify `TokenTree` and fix `macro_rules!` bugs
This PR
- fixes#39390, fixes#39403, and fixes#39404 (each is a [breaking-change], see issues for examples),
- fixes#39889,
- simplifies and optimizes macro invocation parsing,
- cleans up `ext::tt::transcribe`,
- removes `tokenstream::TokenTree::Sequence` and `Token::MatchNt`,
- instead, adds a new type `ext::tt::quoted::TokenTree` for use by `macro_rules!` (`ext::tt`)
- removes `parser.quote_depth` and `parser.parsing_token_tree`, and
- removes `quote_matcher!`.
- Instead, use `quote_tokens!` and `ext::tt::quoted::parse` the result with `expect_matchers=true`.
- I found no outside uses of `quote_matcher!` when searching Rust code on Github.
r? @nrc
Move two large error_reporting fn's to a separate file
Hello!
I tried to make `librustc/infer/error_reporting,rs` more readable by modularizing it and moving its two largest functions to a separate file.
If you have any suggestions, please send it right away! 🚀
Thanks goes to @nikomatsakis for supporting.
added Error and Display impl for std::ffi::FromBytesWithNulError
Fixes#39925.
This is my first PR, so I wasn't quite sure about the stability annotation.
impl RangeArgument for RangeInclusive and add appropriate tests
Now that `RangeArgument` returns a `Bound`, the impl for `RangeInclusive` is natural to implement and all that's required are tests around it.
Simplify `TokenTree` and fix `macro_rules!` bugs
This PR
- fixes#39390, fixes#39403, and fixes#39404 (each is a [breaking-change], see issues for examples),
- fixes#39889,
- simplifies and optimizes macro invocation parsing,
- cleans up `ext::tt::transcribe`,
- removes `tokenstream::TokenTree::Sequence` and `Token::MatchNt`,
- instead, adds a new type `ext::tt::quoted::TokenTree` for use by `macro_rules!` (`ext::tt`)
- removes `parser.quote_depth` and `parser.parsing_token_tree`, and
- removes `quote_matcher!`.
- Instead, use `quote_tokens!` and `ext::tt::quoted::parse` the result with `expect_matchers=true`.
- I found no outside uses of `quote_matcher!` when searching Rust code on Github.
r? @nrc
sort unstable book alphabetically
I made these the same order as they were in the compiler, but for no good reason. Much easier to find out what you need when they're sorted alphabetically
r? @frewsxcv
Structs doc: Change "pointers" to "references"
Let's call them "references" instead of "pointers". That's how they're called in chapter 4.9 "References and Borrowing".
r? @steveklabnik
I made these the same order as they were in the compiler, but for no good reason. Much easier to find out what you need when they're sorted alphabetically
Make lifetime elision docs clearer
Previously it said
"It's forbidden to allow reasoning about types based on the item signature alone."
I think that sentence is wrong. Rust **uses** the item signatures to perform type inference within the body. I think what's meant is the other way around: It does not infer types for item signatures.
r? @steveklabnik
Example for how to provide stdin using std::process::Command
Spawning a child process and writing to its stdin is a bit tricky due to
`as_mut` and having to use a limited borrow. An example for this might
help newer users.
r? @steveklabnik
Replace ./configure with config.toml in README.md and CONTRIBUTING.md
Replace ./configure with config.toml in README.md and CONTRIBUTING.md, so that new users aren't confused about which build system to use, and how to configure the build process.
librustc error_reporting.rs cleanup.
Read some code in librustc, mainly in error_reporting.rs, and cleaned up some things along the way. I recommend looking at each commit individually or looking at the [whitespace insensitive diff](https://github.com/rust-lang/rust/pull/39977/files?w=1).
travis: Split Android into dist/test images
PRs can't land againt beta right now because the android bot is filling up on
disk space. I don't really know what's going on but the android bot is the
longest one to run anyway so it'll benefit from being split up regardless.
[12/12] On-demand type-checking, const-evaluation, MIR building & const-qualification.
_This is the last of a series ([prev](https://github.com/rust-lang/rust/pull/38813)) 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>
As this contains all of the changes that didn't fit neatly into other PRs, I'll be elaborating a bit:
### User-facing changes
* when determining whether an `impl Trait` type implements an auto-trait (e.g. `Send` or `Sync`), the function the `impl Trait` came from has to be inferred and type-checking, disallowing cycles
* this results from not having an obvious place to put the "deferred obligation" in on-demand atm
* while we could model side-effects like that and "post-processing passes" better, it's still more limiting than being able to know the result in the original function (e.g. specialization) *and* there are serious problems around region-checking (if a `Send` impl required `'static`, it wasn't enforced)
* early const-eval requires type-checking and const-qualification to be performed first, which means:
* you get the intended errors before (if any) constant evaluation error that is simply fallout
* associated consts should always work now, and `const fn` type parameters are properly tracked
* don't get too excited, array lengths still can't depend on type parameters
* #38864 works as intended now, with `Self` being allowed in `impl` bounds
* #32205 is largely improved, with associated types being limited to "exact match" `impl`s (as opposed to traversing the specialization graph to resolve unspecified type parameters to their defaults in another `impl` or in the `trait`) *while* checking for overlaps building the specialization graph for that trait - once all the trait impls' have been checked for coherence (including ahead-of-time/on-demand), it's uniform
* [crater report](https://gist.github.com/eddyb/bbb869072468c7e08d6d808e75938051) looks clean (aside from `clippy` which broke due to `rustc` internal changes)
### Compiler-internal changes
* `ty::Generics`
* no longer contains the actual type parameter defaults, instead they're associated with the type parameter's `DefId`, like associated types in a trait definition
* this allows computing `ty::Generics` as a leaf (reading only its own HIR)
* holds a mapping from `DefIndex` of type parameters to their indices
* `ty::AdtDef`
* only tracks `#[repr(simd)]` in its `ReprOptions` `repr` field
* doesn't contain `enum` discriminant values, but instead each variant either refers to either an explicit value for its discriminant, or the distance from the last explicit discriminant, if any
* the `.discriminants(tcx)` method produces an iterator of `ConstInt` values, looking up explicit discriminants in a separate map, if necessary
* this allows computing `ty::AdtDef` as a leaf (reading only its own HIR)
* Small note: the two above (`Generics`, `AdtDef`), `TraitDef` and `AssociatedItem` should probably end up as part of the HIR, eventually, as they're trivially constructed from it
* `ty::FnSig`
* now also holds ABI and unsafety, alongside argument types, return type and C variadicity
* `&ty::BareFnTy` and `ty::ClosureTy` have been replaced with `PolyFnSig = Binder<FnSig>`
* `BareFnTy` was interned and `ClosureTy` was treated as non-trivial to `Clone` because they had a `PolyFnSig` and so used to contain a `Vec<Ty>` (now `&[Ty]`)
* `ty::maps`
* all the `DepTrackingMap`s have been grouped in a structure available at `tcx.maps`
* when creating the `tcx`, a set of `Providers` (one `fn` pointer per map) is required for the local crate, and one for all other crates (i.e. metadata loading), `librustc_driver` plugging the various crates (e.g. `librustc_metadata`, `librustc_typeck`, `librustc_mir`) into it
* when a map is queried and the value is missing, the appropriate `fn` pointer from the `Providers` of that crate is called with the `TyCtxt` and the key being queried, to produce the value on-demand
* `rustc_const_eval`
* demands both `typeck_tables` and `mir_const_qualif` (in preparation for miri)
* tracks `Substs` in `ConstVal::Function` for `const fn` calls
* returns `TypeckError` if type-checking has failed (or cases that can only be reached if it had)
* this error kind is never reported, resulting in less noisy/redundant diagnostics
* fixes#39548 (testcase by @larsluthman, taken from #39812, which this supersedes)
* on-demand has so far been hooked up to:
* `rustc_metadata::cstore_impl`: `ty`, `generics`, `predicates`, `super_predicates`, `trait_def`, `adt_def`, `variances`, `associated_item_def_ids`, `associated_item`, `impl_trait_ref`, `custom_coerce_unsized_kind`, `mir`, `mir_const_qualif`, `typeck_tables`, `closure_kind`, `closure_type`
* `rustc_typeck::collect`: `ty`, `generics`, `predicates`, `super_predicates`, `type_param_predicates`, `trait_def`, `adt_def`, `impl_trait_ref`
* `rustc_typeck::coherence`: `coherent_trait`, `coherent_inherent_impls`
* `rustc_typeck::check`: `typeck_tables`, `closure_type`, `closure_kind`
* `rustc_mir::mir_map`: `mir`
* `rustc_mir::transform::qualify_consts`: `mir_const_qualif`
PRs can't land againt beta right now because the android bot is filling up on
disk space. I don't really know what's going on but the android bot is the
longest one to run anyway so it'll benefit from being split up regardless.
appveyor: Use sccache on pc-windows-gnu for caching
Now that mozilla/sccache#43 is fixed the caching works for MinGW on Windows. We
still can't use it for MSVC just yet, but I'll try to revive that branch at some
point.