about summary refs log tree commit diff
path: root/compiler/rustc_span/src/hygiene.rs
AgeCommit message (Collapse)AuthorLines
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-1/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22Replace `custom_encodable` with `encodable`.Nicholas Nethercote-2/+0
By default, `newtype_index!` types get a default `Encodable`/`Decodable` impl. You can opt out of this with `custom_encodable`. Opting out is the opposite to how Rust normally works with autogenerated (derived) impls. This commit inverts the behaviour, replacing `custom_encodable` with `encodable` which opts into the default `Encodable`/`Decodable` impl. Only 23 of the 59 `newtype_index!` occurrences need `encodable`. Even better, there were eight crates with a dependency on `rustc_serialize` just from unused default `Encodable`/`Decodable` impls. This commit removes that dependency from those eight crates.
2023-11-10Remove `-Zkeep-hygiene-data`.Nicholas Nethercote-4/+0
It was added way back in #28585 under the name `-Zkeep-mtwt-tables`. The justification was: > This is so that the resolution results can be used after analysis, > potentially for tool support. There are no uses of significance in the code base, and various Google searches for both option names (and variants) found nothing of interest. @petrochenkov says removing this part (and it's only part) of the hygiene data is dubious. It doesn't seem that big, so let's just keep it around.
2023-11-02Minimize `pub` usage in `hygiene.rs`.Nicholas Nethercote-34/+15
And remove dead functions revealed by this.
2023-11-02Tweak `use` items.Nicholas Nethercote-6/+3
2023-08-25Rollup merge of #115081 - Zoxc:expn-id-decode, r=cjgillotMatthias Krüger-3/+3
Allow overwriting ExpnId for concurrent decoding These assertions only hold for the single threaded compiler. They were triggered in https://github.com/rust-lang/rust/pull/115003.
2023-08-23Extend comment on assertionJohn Kåre Alsaker-1/+5
2023-08-23Check that the old values matchJohn Kåre Alsaker-2/+2
2023-08-22Fix races conditions with `SyntaxContext` decodingJohn Kåre Alsaker-34/+80
2023-08-22Allow overwriting ExpnId for concurrent decodingJohn Kåre Alsaker-3/+3
2023-06-16Add `SyntaxContext::is_root`Maybe Waffle-4/+9
2023-05-30Lower the tracing level of some very verbose messagesOli Scherer-2/+2
2023-05-27Rollup merge of #111952 - cjgillot:drop-replace, r=WaffleLapkinGuillaume Gomez-2/+0
Remove DesugaringKind::Replace. A simple boolean flag is enough.
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-2/+0
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-4/+0
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-7/+7
2023-04-10Fix typos in compilerDaniPopes-1/+1
2023-04-01a couple clippy::complexity fixesMatthias Krüger-1/+1
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-18Ignore `Inlined` spans when computing caller location.Camille GILLOT-1/+1
2023-03-03Desugars drop and replace at MIR buildGiacomo Pasini-0/+2
This commit desugars the drop and replace deriving from an assignment at MIR build, avoiding the construction of the DropAndReplace terminator (which will be removed in a followign PR) In order to retain the same error messages for replaces a new DesugaringKind::Replace variant is introduced.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-10/+6
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2023-01-02Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkovbors-0/+4
Encode spans relative to the enclosing item -- enable on nightly Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default. This PR seeks to remove one of the main shortcomings of incremental: the handling of spans. Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed. Within one file: all the spans in HIR change, so typechecking had to be re-done. Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span). The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query. Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent. In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode: - the parent when the `SyntaxContext` is 0; - the `SyntaxContext` when the parent is `None`. Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans. The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required. Possible future directions: - validate that all spans are marked in HIR validation; - mark macro-expanded spans relative to the def-site and not the use-site.
2022-12-25Explain disabled span hashing.Camille GILLOT-0/+4
2022-12-25Give the correct track-caller location with MIR inlining.Camille GILLOT-0/+1
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-4/+2
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Make `#[debug_format]` an attribute in `newtype_index`Nilstrieb-1/+1
This removes the `custom` format functionality as its only user was trivially migrated to using a normal format. If a new use case for a custom formatting impl pops up, you can add it back.
2022-12-18Make `#[no_ord_impl]` an attribute in `newtype_index`Nilstrieb-1/+1
2022-12-18Make `#[custom_encodable]` an attribute for `newtype_index`Nilstrieb-2/+2
Makes the syntax a little more rusty.
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