summary refs log tree commit diff
path: root/src/librustc_span
AgeCommit message (Collapse)AuthorLines
2020-06-01add fixme suggested by eddybFelix S Klock II-1/+4
2020-06-01Use the virtual name for libstd files in StableSourceFileId and also in theFelix S. Klock II-1/+23
encoded build artifacts. Fix #70924.
2020-06-01Split payload of FileName::Real to track both real and virutalized paths.Felix S. Klock II-12/+61
Such splits arise from metadata refs into libstd. This way, we can (in a follow on commit) continue to emit the virtual name into things like the like the StableSourceFileId that ends up in incremetnal build artifacts, while still using the devirtualized file path when we want to access the file. Note that this commit is intended to be a refactoring; the actual fix to the bug in question is in a follow-on commit.
2020-06-01`StableSourceFileId::new_from_pieces` does not need to be public.Felix S. Klock II-1/+1
(and I want to discourage further use of it if possible.)
2020-04-16Auto merge of #70831 - sfackler:shrink-future-stack, r=matthewjasperbors-1/+2
Remove a stack frame from .await calls The stack frames when `.await`ing one async fn from another currently look like this: ``` 12: foo::b::{{closure}} at src/main.rs:2 13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:66 14: core::future::poll_with_context at /home/sfackler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:84 15: foo::a::{{closure}} at src/main.rs:6 ``` Since the move away from using TLS to pass the Context around, it's now easy to remove frame 14 by removing poll_with_context in favor of calling Future::poll directly. This still leaves the `GenFuture` frame, but that seems significantly harder to deal with. It also improves diagnostics a bit since they no longer talk about the private poll_with_context function.
2020-04-13Fix symbol sortingSteven Fackler-1/+1
2020-04-12Rollup merge of #71053 - phansch:update_kw_sym_docs, r=Dylan-DPCDylan DPC-0/+8
Add some basic docs to `sym` and `kw` modules I was looking into improving some Clippy documentation but was missing a place that explains the `kw` and `sym` modules from rustc. This adds some very basic usage documentation to these modules.
2020-04-12Rollup merge of #71048 - arlosi:normalize_ext_src, r=eddybDylan DPC-1/+59
Normalize source when loading external foreign source into SourceMap The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources. This leads to the external source matching according to the `src_hash`, but differing internally because it was not normalized. Fixes #70874.
2020-04-12Add some basic docs to `sym` and `kw` modulesPhilipp Hansch-0/+8
I was looking into improving some Clippy documentation but was missing a place that explains the `kw` and `sym` modules from rustc.
2020-04-11Normalize source when loading external foreign source into SourceMapArlo Siemsen-1/+59
The compiler normalizes source when reading files initially (removes BOMs, etc), but not when loading external sources. Fixes #70874 by normalizing when loading external sources too. Adds a test to verify normalization.
2020-04-10Auto merge of #70986 - marmeladema:issue70853/librustc_middle-local-def-id, ↵bors-0/+5
r=eddyb rustc_middle: return `LocalDefId` where possible in hir::map module This changes the return type of the following functions to return a `LocalDefId` instead of a `DefId`: * opt_local_def_id_from_node_id * opt_local_def_id * body_owner_def_id * local_def_id_from_node_id * get_parent_id This is another step in the right direction for #70853 This pull request will be followed by another (substantial one) which changes the return type of `local_def_id` function but this change being more invasive, we might want to wait for #70956 or #70961 (or some other form it) to land first.
2020-04-10librustc_middle: return LocalDefId instead of DefId in get_parent_didmarmeladema-0/+5
2020-04-08Replace "rc"/"arc" lang items with Rc/Arc diagnostic items.Eduard-Mihai Burtescu-0/+2
2020-04-05Remove a stack frame from .await callsSteven Fackler-1/+2
2020-04-05Stop importing int/float modules in librustc_*Linus Färnstrand-1/+0
2020-04-02Add hash of source files in debug infoArlo Siemsen-19/+91
* Adds either an MD5 or SHA1 hash to the debug info. * Adds new unstable option `-Z src-hash-algorithm` to control the hashing algorithm.
2020-03-30rustc -> rustc_middle part 1Mazdak Farrokhzad-1/+1
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-0/+1
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-26pacify the merciless x.py fmtNiko Matsakis-35/+7
2020-03-26introduce `negative_impls` feature gate and documentNiko Matsakis-7/+37
They used to be covered by `optin_builtin_traits` but negative impls are now applicable to all traits, not just auto traits. This also adds docs in the unstable book for the current state of auto traits.
2020-03-25Rename `def_span` to `guess_head_span`Esteban Küber-1/+8
2020-03-23Rollup merge of #70318 - anyska:multiple-derives, r=Dylan-DPCMazdak Farrokhzad-60/+10
Split long derive lists into two derive attributes.
2020-03-23Rollup merge of #70199 - ↵Mazdak Farrokhzad-0/+7
pnkfelix:issue-68808-dont-turn-dummy-spans-into-invalid-lines, r=estebank Revised span-to-lines conversion to produce an empty vec on DUMMY_SP. This required revising some of the client code to stop relying on the returned set of lines being non-empty. Fix #68808
2020-03-23Update src/librustc_span/source_map.rsFelix S Klock II-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-03-23Split long derive lists into two derive attributes.Ana-Maria Mihalache-60/+10
2020-03-22Rollup merge of #70229 - matthiaskrgr:cl3ppy, r=Mark-SimulacrumDylan DPC-4/+4
more clippy fixes * remove unused unit values (clippy::unused_unit) * make some let-if-bindings more idiomatic (clippy::useless_let_if_seq) * clarify when we pass () to functions (clippy::unit_arg) * don't redundantly repeat field names (clippy::redundant_field_names) * remove redundant returns (clippy::needless_return) * use let instead of match for matches with single bindings (clippy::match_single_binding) * don't convert results to options just for matching (clippy::if_let_some_result)
2020-03-22Rollup merge of #70172 - eddyb:retokenize-external-src, r=petrochenkovDylan DPC-3/+3
parse/lexer: support `StringReader::retokenize` called on external files. This ~~should theoretically~~ fixes #69933, ~~but I'm not sure what the best way to test it is~~. **EDIT**: see https://github.com/rust-lang/rust/issues/69933#issuecomment-602019598. r? @petrochenkov cc @Xanewok @staktrace
2020-03-21remove redundant returns (clippy::needless_return)Matthias Krüger-4/+4
2020-03-21Rollup merge of #69901 - RalfJung:rustc_layout, r=eddybDylan DPC-0/+1
add #[rustc_layout(debug)] @eddyb recently told me about the `#[rustc_layout]` attribute, and I think it would be very useful if it could be used to print all the layout information Rust has about a type. When working with layouts (e.g. in Miri), it is often not clear how certain surface language features get represented internally. I have some awful hacks locally to be able to dump this debug information; with this attribute I could get it on the playground which is so much better. :)
2020-03-21Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-SimulacrumMazdak Farrokhzad-14/+8
more clippy fixes * remove redundant returns (clippy::needless_return) * remove redundant import (clippy::single_component_path_imports) * remove redundant format!() call (clippy::useless_format) * don't use ok() before calling expect() (clippy::ok_expect)
2020-03-21Rollup merge of #69033 - jonas-schievink:resume-with-context, r=tmandryMazdak Farrokhzad-1/+2
Use generator resume arguments in the async/await lowering This removes the TLS requirement from async/await and enables it in `#![no_std]` crates. Closes https://github.com/rust-lang/rust/issues/56974 I'm not confident the HIR lowering is completely correct, there seem to be quite a few undocumented invariants in there. The `async-std` and tokio test suites are passing with these changes though.
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-14/+8
2020-03-20Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.Felix S. Klock II-0/+7
This required revising some of the client code to stop relying on the returned set of lines being non-empty.
2020-03-20add debug option to #[rustc_layout]Ralf Jung-0/+1
2020-03-20parse/lexer: support `StringReader::retokenize` called on external files.Eduard-Mihai Burtescu-3/+3
2020-03-19rustc: use LocalDefId instead of DefIndex in HirId.Eduard-Mihai Burtescu-1/+12
2020-03-19rustc: introduce DefId::as_local(self) -> Option<LocalDefId> and use it.Eduard-Mihai Burtescu-2/+6
2020-03-19rustc: rename DefId::to_local to expect_local and use it instead of ↵Eduard-Mihai Burtescu-8/+3
LocalDefId::from_def_id.
2020-03-19rustc: make LocalDefId's index field public like DefId's is.Eduard-Mihai Burtescu-3/+5
2020-03-18Properly handle Spans that reference imported SourceFilesAaron Hill-24/+49
Previously, metadata encoding used DUMMY_SP to represent any spans that referenced an 'imported' SourceFile - e.g. a SourceFile from an upstream dependency. These leads to sub-optimal error messages in certain cases (see the included test). This PR changes how we encode and decode spans in crate metadata. We encode spans in one of two ways: * 'Local' spans, which reference non-imported SourceFiles, are encoded exactly as before. * 'Foreign' spans, which reference imported SourceFiles, are encoded with the CrateNum of their 'originating' crate. Additionally, their 'lo' and 'high' values are rebased on top of the 'originating' crate, which allows them to be used with the SourceMap data encoded for that crate. The `ExternalSource` enum is renamed to `ExternalSourceKind`. There is now a struct called `ExternalSource`, which holds an `ExternalSourceKind` along with the original line number information for the file. This is used during `Span` serialization to rebase spans onto their 'owning' crate.
2020-03-18Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obkMazdak Farrokhzad-2/+5
Make methods declared by `newtype_index` macro `const` Crates that use the macro to define an `Idx` type need to enable `#![feature(const_if_match, const_panic)]`.
2020-03-17Make async/await lowering use resume argumentsJonas Schievink-1/+2
2020-03-17Add requisite feature gates for const assertDylan MacKenzie-0/+3
2020-03-17Rename `from_u32_const` -> `from_u32`Dylan MacKenzie-2/+2
2020-03-17Rollup merge of #68746 - matthewjasper:metahygiene, r=petrochenkovMazdak Farrokhzad-0/+25
Make macro metavars respect (non-)hygiene This makes them more consistent with other name resolution while not breaking any code on crater.
2020-03-17Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasperMazdak Farrokhzad-0/+1
expand: Implement something similar to `#[cfg(accessible(path))]` cc https://github.com/rust-lang/rust/issues/64797 The feature is implemented as a `#[cfg_accessible(path)]` attribute macro rather than as `#[cfg(accessible(path))]` because it needs to wait until `path` becomes resolvable, and `cfg` cannot wait, but macros can wait. Later we can think about desugaring or not desugaring `#[cfg(accessible(path))]` into `#[cfg_accessible(path)]`. This implementation is also incomplete in the sense that it never returns "false" from `cfg_accessible(path)`, it requires some tweaks to resolve, which is not quite ready to answer queries like this during early resolution. However, the most important part of this PR is not `cfg_accessible` itself, but expansion infrastructure for retrying expansions. Before this PR we could say "we cannot resolve this macro path, let's try it later", with this PR we can say "we cannot expand this macro, let's try it later" as well. This is a pre-requisite for - turning `#[derive(...)]` into a regular attribute macro, - properly supporting eager expansion for macros that cannot yet be resolved like ``` fn main() { println!(not_available_yet!()); } macro_rules! make_available { () => { #[macro_export] macro_rules! not_available_yet { () => { "Hello world!" } }} } make_available!(); ```
2020-03-16Auto merge of #68970 - matthewjasper:min-spec, r=nikomatsakisbors-0/+3
Implement a feature for a sound specialization subset This implements a new feature (`min_specialization`) that restricts specialization to a subset that is reasonable for the standard library to use. The plan is to then: * Update `libcore` and `liballoc` to compile with `min_specialization`. * Add a lint to forbid use of `feature(specialization)` (and other unsound, type system extending features) in the standard library. * Fix the soundness issues around `specialization`. * Remove `min_specialization` The rest of this is an overview from a comment in this PR ## Basic approach To enforce this requirement on specializations we take the following approach: 1. Match up the substs for `impl2` so that the implemented trait and self-type match those for `impl1`. 2. Check for any direct use of `'static` in the substs of `impl2`. 3. Check that all of the generic parameters of `impl1` occur at most once in the *unconstrained* substs for `impl2`. A parameter is constrained if its value is completely determined by an associated type projection predicate. 4. Check that all predicates on `impl1` also exist on `impl2` (after matching substs). ## Example Suppose we have the following always applicable impl: ```rust impl<T> SpecExtend<T> for std::vec::IntoIter<T> { /* specialized impl */ } impl<T, I: Iterator<Item=T>> SpecExtend<T> for I { /* default impl */ } ``` We get that the subst for `impl2` are `[T, std::vec::IntoIter<T>]`. `T` is constrained to be `<I as Iterator>::Item`, so we check only `std::vec::IntoIter<T>` for repeated parameters, which it doesn't have. The predicates of `impl1` are only `T: Sized`, which is also a predicate of impl2`. So this specialization is sound. ## Extensions Unfortunately not all specializations in the standard library are allowed by this. So there are two extensions to these rules that allow specializing on some traits. ### rustc_specialization_trait If a trait is always applicable, then it's sound to specialize on it. We check trait is always applicable in the same way as impls, except that step 4 is now "all predicates on `impl1` are always applicable". We require that `specialization` or `min_specialization` is enabled to implement these traits. ### rustc_specialization_marker There are also some specialization on traits with no methods, including the `FusedIterator` trait which is advertised as allowing optimizations. We allow marking marker traits with an unstable attribute that means we ignore them in point 3 of the checks above. This is unsound but we allow it in the short term because it can't cause use after frees with purely safe code in the same way as specializing on traits methods can. r? @nikomatsakis cc #31844 #67194
2020-03-16Make macro metavars respect (non-)hygieneMatthew Jasper-0/+25
2020-03-16Rollup merge of #69989 - petrochenkov:nolegacy, r=eddyb,matthewjasperDylan DPC-28/+28
resolve/hygiene: `macro_rules` are not "legacy" The "modern" vs "legacy" naming was introduced by jseyfried during initial implementation of macros 2.0. At this point it's clear that `macro_rules` are not going anywhere and won't be deprecated in the near future. So this PR changes the naming "legacy" (when it implies "macro_rules") to "macro_rules". This should also help people reading this code because it's wasn't obvious that "legacy" actually meant "macro_rules" in these contexts. The most contentious renaming here is probably ``` fn modern -> fn normalize_to_macros_2_0 fn modern_and_legacy -> fn normalize_to_macro_rules ``` Other alternatives that I could think of are `normalize_to_opaque`/`normalize_to_semitransparent`, or `strip_non_opaque`/`strip_transparent`, but they seemed less intuitive. The documentation to these functions can be found in `symbol.rs`. r? @matthewjasper
2020-03-16hygiene: `modern` -> `normalize_to_macros_2_0`Vadim Petrochenkov-28/+28
`modern_and_legacy` -> `normalize_to_macro_rules`