about summary refs log tree commit diff
path: root/src/librustc_span/lib.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-1872/+0
2020-08-14Rework `rustc_serialize`Matthew Jasper-29/+27
- Move the type parameter from `encode` and `decode` methods to the trait. - Remove `UseSpecialized(En|De)codable` traits. - Remove blanket impls for references. - Add `RefDecodable` trait to allow deserializing to arena-allocated references safely. - Remove ability to (de)serialize HIR. - Create proc-macros `(Ty)?(En|De)codable` to help implement these new traits.
2020-08-09Auto merge of #75134 - Aaron1011:feature/expn-data-parent-hash, r=petrochenkovbors-30/+34
Hash parent ExpnData cc https://github.com/rust-lang/rust/pull/72121#discussion_r460528326
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-0/+9
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-04Hash parent ExpnDataAaron Hill-30/+34
2020-07-26Share serialization optimization between incr and metadataAaron Hill-0/+1
2020-07-26Hygiene serialization implementationAaron Hill-14/+47
2020-07-16apply bootstrap cfgsMark Rousskov-1/+0
2020-07-09Eliminate confusing "globals" terminology.Nicholas Nethercote-11/+15
There are some structures that are called "globals", but are they global to a compilation session, and not truly global. I have always found this highly confusing, so this commit renames them as "session globals" and adds a comment explaining things. Also, the commit fixes an unnecessary nesting of `set()` calls `src/librustc_errors/json/tests.rs`
2020-07-02Rollup merge of #73853 - pierwill:pierwill-multispan-doc, r=jonas-schievinkManish Goregaokar-1/+3
Add newline to rustc MultiSpan docs Also adds back-ticks when referring to the contents of this collection.
2020-06-28Add newline to rustc MultiSpan docspierwill-1/+3
Also adds back-ticks when referring to the contents of this collection.
2020-06-28Remove `const_if_match` feature gate from librariesDylan MacKenzie-1/+1
2020-06-26Explain move errors that occur due to method calls involving `self`Aaron Hill-1/+2
This is a re-attempt of #72389 (which was reverted in #73594) Instead of using `ExpnKind::Desugaring` to represent operators, this PR checks the lang item directly.
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-3/+1
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-15Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakisRalf Jung-1/+3
Explain move errors that occur due to method calls involving `self` When calling a method that takes `self` (e.g. `vec.into_iter()`), the method receiver is moved out of. If the method receiver is used again, a move error will be emitted:: ```rust fn main() { let a = vec![true]; a.into_iter(); a; } ``` emits ``` error[E0382]: use of moved value: `a` --> src/main.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | - value moved here 4 | a; | ^ value used here after move ``` However, the error message doesn't make it clear that the move is caused by the call to `into_iter`. This PR adds additional messages to move errors when the move is caused by using a value as the receiver of a `self` method:: ``` error[E0382]: use of moved value: `a` --> vec.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | ------------- value moved due to this method call 4 | a; | ^ value used here after move | note: this function takes `self`, which moves the receiver --> /home/aaron/repos/rust/src/libcore/iter/traits/collect.rs:239:5 | 239 | fn into_iter(self) -> Self::IntoIter; ``` TODO: - [x] Add special handling for `FnOnce/FnMut/Fn` - we probably don't want to point at the unstable trait methods - [x] Consider adding additional context for operations (e.g. `Shr::shr`) when the call was generated using the operator syntax (e.g. `a >> b`) - [x] Consider pointing to the method parent (impl or trait block) in addition to the method itself.
2020-06-12Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnayDylan DPC-1/+1
Migrate to numeric associated consts The deprecation PR is #72885 cc #68490 cc rust-lang/rfcs#2700
2020-06-11Explain move errors that occur due to method calls involving `self`Aaron Hill-1/+3
2020-06-10Migrate to numeric associated constsLzu Tao-1/+1
2020-06-08Show `SyntaxContext` in formatted `Span` debug outputAaron Hill-1/+9
This is only really useful in debug messages, so I've switched to calling `span_to_string` in any place that causes a `Span` to end up in user-visible output.
2020-06-04Auto merge of #72618 - Aaron1011:feature/early-sourcemap, r=petrochenkovbors-5/+40
Make `SourceMap` available for early debug-printing of `Span`s Normally, we debug-print `Spans` using the `SourceMap` retrieved from the global `TyCtxt`. However, we fall back to printing out the `Span`'s raw fields (instead of a file and line number) when we try to print a `Span` before a `TyCtxt` is available. This makes debugging early phases of the compile, such as parsing, much more difficult. This commit stores a `SourceMap` in `rustc_span::GlOBALS` as a fallback. When a `TyCtxt` is not available, we try to retrieve one from `GLOBALS` - only if this is not available do we fall back to the raw field output. I'm not sure how to write a test for this - however, this can be verified locally by setting `RUSTC_LOG="rustc_parse=debug"`, and verifying that the output contains filenames and line numbers.
2020-05-31Make `SourceMap` available for early debug-printing of `Span`sAaron Hill-5/+40
Normally, we debug-print `Spans` using the `SourceMap` retrieved from the global `TyCtxt`. However, we fall back to printing out the `Span`'s raw fields (instead of a file and line number) when we try to print a `Span` before a `TyCtxt` is available. This makes debugging early phases of the compile, such as parsing, much more difficult. This commit stores a `SourceMap` in `rustc_span::GlOBALS` as a fallback. When a `TyCtxt` is not available, we try to retrieve one from `GLOBALS` - only if this is not available do we fall back to the raw field output. I'm not sure how to write a test for this - however, this can be verified locally by setting `RUSTC_LOG="rustc_parse=debug"`, and verifying that the output contains filenames and line numbers.
2020-05-31Auto merge of #72767 - pnkfelix:track-devirtualized-filenames-issue-70924, ↵bors-4/+60
r=eddyb Track devirtualized filenames Split payload of FileName::Real to track both real and virtualized paths. (Such splits arise from metadata refs into libstd; the virtualized paths look like `/rustc/1.45.0/src/libstd/io/cursor.rs` rather than `/Users/felixklock/Dev/Mozilla/rust.git/src/libstd/io/cursor.rs`) This way, we can emit the virtual name into things like the like the StableSourceFileId (as was done back before PR #70642) that ends up in incremental build artifacts, while still using the devirtualized file path when we want to access the file. Fix #70924
2020-05-30add fixme suggested by eddybFelix S Klock II-1/+4
2020-05-29Use the virtual name for libstd files in StableSourceFileId and also in theFelix S. Klock II-0/+13
encoded build artifacts. Fix #70924.
2020-05-29Split payload of FileName::Real to track both real and virutalized paths.Felix S. Klock II-4/+44
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-05-29Improve inline asm error diagnosticsAmanieu d'Antras-1/+11
2020-05-10use min_specialization for some rustc crates where it requires no changesRalf Jung-1/+1
2020-05-08FIXME commentCameron Taggart-1/+1
2020-05-07#[allow(unused)]Cameron Taggart-0/+1
2020-05-07allow wasm target for rustc-ap-rustc_spanCameron Taggart-0/+3
2020-04-25Auto merge of #71439 - Mark-Simulacrum:stage0-next, r=jonas-schievinkbors-1/+1
Bump bootstrap compiler This bumps the bootstrap compiler and the rustfmt that x.py fmt uses.
2020-04-25Bump bootstrap compilerMark Rousskov-1/+1
2020-04-22Sort `MultiSpan`s on creationEsteban Küber-1/+2
2020-04-11Normalize source when loading external foreign source into SourceMapArlo Siemsen-1/+3
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-02Add hash of source files in debug infoArlo Siemsen-12/+77
* 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-26pacify the merciless x.py fmtNiko Matsakis-35/+7
2020-03-26introduce `negative_impls` feature gate and documentNiko Matsakis-7/+36
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-23Split long derive lists into two derive attributes.Ana-Maria Mihalache-12/+2
2020-03-20parse/lexer: support `StringReader::retokenize` called on external files.Eduard-Mihai Burtescu-3/+3
2020-03-18Properly handle Spans that reference imported SourceFilesAaron Hill-21/+40
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-17Add requisite feature gates for const assertDylan MacKenzie-0/+3
2020-03-16hygiene: `modern` -> `normalize_to_macros_2_0`Vadim Petrochenkov-6/+6
`modern_and_legacy` -> `normalize_to_macro_rules`
2020-03-14Rollup merge of #69802 - matthiaskrgr:cl1ppy, r=Dylan-DPCYuki Okushi-5/+1
fix more clippy findings * reduce references on match patterns (clippy::match_ref_pats) * Use writeln!(fmt, "word") instead of write!(fmt, "word\n") (clippy::write_with_newline) * libtest: remove redundant argument to writeln!() (clippy::writeln_empty_string) * remove unneeded mutable references (cippy::unnecessary_mut_passed) * libtest: declare variables as floats instead of casting them (clippy::unnecessary_cast) * rustdoc: remove redundant static lifetimes (clippy::redundant_static_lifetimes) * call .as_deref() instead of .as_ref().map(Deref::deref) (clippy::option_as_ref_deref) * iterate over a maps values directly. (clippy::for_kv_map) * rustdoc: simplify boolean condition (clippy::nonminimal_bool) * Use ?-operator in more places (clippy::question_mark, had some false negatives fixed recently) * rustdoc: Use .any(p) instead of find(p).is_some(). (clippy::search_is_some) * rustdoc: don't call into_iter() on iterator. (clippy::identity_conversion)
2020-03-10Store `TokenStream` in `rmeta::MacroDef`.Mazdak Farrokhzad-21/+1
This removes a hack from `load_macro_untracked` in which parsing is used.
2020-03-07Use ?-operator in more places (clippy::question_mark, had some false ↵Matthias Krüger-5/+1
negatives fixed recently)
2020-02-29Make it build againVadim Petrochenkov-1/+1
2020-02-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-1/+1
2020-02-18Fix race condition when allocating source files in SourceMapJohn Kåre Alsaker-6/+4
2020-02-11Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPCDylan DPC-2/+0
Remove unused feature gates I think many of the remaining unstable things can be easily be replaced with stable things. I have kept the `#![feature(nll)]` even though it is only necessary in `libstd`, to make regressions of it harder.