summary refs log tree commit diff
path: root/compiler/rustc_span/src/hygiene.rs
AgeCommit message (Collapse)AuthorLines
2022-12-01Remove useless borrows and derefsMaybe Waffle-1/+1
2022-11-25Prefer not accessing the private field of newtype_index typesOli Scherer-1/+1
2022-09-07ssa: implement `#[collapse_debuginfo]`David Wood-12/+16
Debuginfo line information for macro invocations are collapsed by default - line information are replaced by the line of the outermost expansion site. Using `-Zdebug-macros` disables this behaviour. When the `collapse_debuginfo` feature is enabled, the default behaviour is reversed so that debuginfo is not collapsed by default. In addition, the `#[collapse_debuginfo]` attribute is available and can be applied to macro definitions which will then have their line information collapsed. Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-07-14Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPCbors-0/+6
Rollup of 5 pull requests Successful merges: - #97720 (Always create elided lifetime parameters for functions) - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`) - #98705 (Implement `for<>` lifetime binder for closures) - #99126 (remove allow(rustc::potential_query_instability) in rustc_span) - #99139 (Give a better error when `x dist` fails for an optional tool) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-14Rollup merge of #99126 - NiklasJonsson:84447/rustc_span, r=petrochenkovDylan DPC-0/+6
remove allow(rustc::potential_query_instability) in rustc_span Also, avoid sorting before debug output as iteration order can now be relied upon. Related #84447
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13reduce scope of allow(rustc::potential_query_instability) in rustc_spanNiklas Jonsson-0/+6
2022-07-11lower let-else in MIR insteadDing Xiang Fei-2/+0
2022-07-10avoid some `&str` to `String` conversionsTakayuki Maeda-2/+1
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-26/+21
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-4/+4
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-3/+5
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-02fix most compiler/ doctestsElliot Roberts-3/+5
2022-04-30Add `do yeet` expressions to allow experimentation in nightlyScott McMurray-0/+2
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point. But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-13Remove last vestiges of skippng ident span hashingAaron Hill-10/+0
This removes a comment that no longer applies, and properly hashes the full ident for path segments.
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-04Remove ordering traits from `rustc_span::hygiene::LocalExpnId`pierwill-0/+7
2022-02-27Only create a single expansion for each inline integration.Camille GILLOT-13/+8
2022-02-15Inline LocalExpnId::from_raw and LocalExpnId::as_rawTomasz Miąsko-0/+2
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-14/+11
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-05Adjust assert_default_hashing_controlsAaron Hill-6/+12
2022-01-05Ensure that `Fingerprint` caching respects hashing configurationAaron Hill-0/+24
Fixes #92266 In some `HashStable` impls, we use a cache to avoid re-computing the same `Fingerprint` from the same structure (e.g. an `AdtDef`). However, the `StableHashingContext` used can be configured to perform hashing in different ways (e.g. skipping `Span`s). This configuration information is not included in the cache key, which will cause an incorrect `Fingerprint` to be used if we hash the same structure with different `StableHashingContext` settings. To fix this, the configuration settings of `StableHashingContext` are split out into a separate `HashingControls` struct. This struct is used as part of the cache key, ensuring that our caches always produce the correct result for the given settings. With this in place, we now turn off `Span` hashing during the entire process of computing the hash included in legacy symbols. This current has no effect, but will matter when a future PR starts hashing more `Span`s that we currently skip.
2021-11-28Add parent crate assert to register_expn_idCameron Steffen-0/+1
2021-11-28Add fast path to is_descendant_ofCameron Steffen-2/+19
2021-11-21Simplify for loop desugarCameron Steffen-9/+2
2021-10-21Don't suggest importing items with hygienic namesMatthew Jasper-1/+1
This will potentially hide a few correct suggestions, but importing these items from another module is not generally possible.
2021-10-02Add desugaring mark to while loopCameron Steffen-0/+2
2021-10-02rustc_span: Make hygiene debug printing reproducibleVadim Petrochenkov-1/+4
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-3/+1
2021-08-30Lower let-else to HIRCameron Steffen-0/+2
2021-07-19Auto merge of #87225 - estebank:cleanup, r=oli-obkbors-2/+2
Various diagnostics clean ups/tweaks * Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-2/+2
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-17Simplify Expn creation.Camille GILLOT-27/+25
2021-07-17Rename expn_info -> expn_data.Camille GILLOT-8/+8
2021-07-17Pass ExpnData by reference.Camille GILLOT-3/+3
2021-07-17Drop ExpnData::krate.Camille GILLOT-19/+10
2021-07-17Drop orig_id.Camille GILLOT-33/+9
2021-07-17Encode ExpnId using ExpnHash for incr. comp.Camille GILLOT-65/+56
2021-07-17Choose encoding format in caller code.Camille GILLOT-72/+26
2021-07-17Use LocalExpnId where possible.Camille GILLOT-14/+1
2021-07-17Make the CrateNum part of the ExpnId.Camille GILLOT-95/+250
2021-07-15Simplify metadata decoding.Camille GILLOT-30/+8
2021-07-15Separate encoding paths.Camille GILLOT-52/+87
The two paths will be modified independently in the next few commits.
2021-07-14Auto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkovbors-1/+1
Avoid cloning ExpnData to access Span edition ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost. r? `@ghost` -- opening for a perf run to start with
2021-07-13Cache expansion hash.Camille GILLOT-163/+120
2021-07-13Move HashStable implementations.Camille GILLOT-1/+59
2021-07-13Avoid cloning ExpnData to access Span editionMark Rousskov-1/+1
ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost.
2021-07-11rustc_span: Reorder some `ExpnData` fields in accordance with commentsVadim Petrochenkov-26/+25
A drive-by change.