about summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2024-04-16Construct `SourceMap` at the same time as `SessionGlobals`.Nicholas Nethercote-35/+18
Currently `SourceMap` is constructed slightly later than `SessionGlobals`, and inserted. This commit changes things so they are done at the same time. Benefits: - `SessionGlobals::source_map` changes from `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still optional, but mutability isn't required because it's initialized at construction. - `set_source_map` is removed, simplifying `run_compiler`, which is good because that's a critical function and it's nice to make it simpler. This requires moving things around a bit, so the necessary inputs are available when `SessionGlobals` is created, in particular the `loader` and `hash_kind`, which are no longer computed by `build_session`. These inputs are captured by the new `SourceMapInputs` type, which is threaded through various places.
2024-04-10typeck: fix `?` operator suggestion span许杰友 Jieyou Xu (Joe)-0/+39
2024-03-28Replace Session should_remap_filepaths with filename_display_preferenceUrgau-0/+12
2024-03-27Helper function for resolve_pathKornel-0/+11
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-14/+59
2024-02-11Rollup merge of #120272 - ↵Matthias Krüger-0/+7
long-long-float:suppress-suggestions-in-derive-macro, r=oli-obk Suppress suggestions in derive macro close #118809 I suppress warnings inside derive macros. For example, the compiler emits following error by a program described in https://github.com/rust-lang/rust/issues/118809#issuecomment-1852256687 with a suggestion that indicates invalid syntax. ``` error[E0308]: `?` operator has incompatible types --> src/main.rs:3:17 | 3 | #[derive(Debug, Deserialize)] | ^^^^^^^^^^^ expected `u32`, found `u64` | = note: `?` operator cannot convert from `u64` to `u32` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit | 3 | #[derive(Debug, Deserialize.try_into().unwrap())] | ++++++++++++++++++++ For more information about this error, try `rustc --explain E0308`. error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors ``` In this PR, suggestions to cast are suppressed. ``` error[E0308]: `?` operator has incompatible types --> src/main.rs:3:17 | 3 | #[derive(Debug, Deserialize)] | ^^^^^^^^^^^ expected `u32`, found `u64` | = note: `?` operator cannot convert from `u64` to `u32` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0308`. error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors ```
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-09Check with overlaps_or_adjacentlong-long-float-0/+7
2024-02-07Rename `unchecked_claim_error_was_emitted` as `unchecked_error_guaranteed`.Nicholas Nethercote-1/+1
It's more to-the-point.
2024-02-07Tighten up `ErrorGuaranteed` handling.Nicholas Nethercote-3/+2
- In `emit_producing_error_guaranteed`, only allow `Level::Error`. - In `emit_diagnostic`, only produce `ErrorGuaranteed` for `Level` and `DelayedBug`. (Not `Bug` or `Fatal`. They don't need it, because the relevant `emit` methods abort.) - Add/update various comments.
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-01-28normalize_newlines(): fix incorrect commentMatthew Woodcraft-1/+1
2024-01-09Remove more needless leb128 coding for enum variantsMark Rousskov-11/+12
This removes emit_enum_variant and the emit_usize calls that resulted in. In libcore this eliminates 17% of leb128, taking us from 8964488 to 7383842 leb128's serialized.
2024-01-09Rollup merge of #118903 - azhogin:azhogin/skip_second_stmt_debuginfo.rs, ↵Matthias Krüger-7/+0
r=petrochenkov Improved support of collapse_debuginfo attribute for macros. Added walk_chain_collapsed function to consider collapse_debuginfo attribute in parent macros in call chain. Fixed collapse_debuginfo attribute processing for cranelift (there was if/else branches error swap). cc https://github.com/rust-lang/rust/issues/100758
2024-01-08Improved support of collapse_debuginfo attribute for macros.Andrew Zhogin-7/+0
2024-01-06Auto merge of #119662 - matthiaskrgr:rollup-ehofh5n, r=matthiaskrgrbors-49/+47
Rollup of 9 pull requests Successful merges: - #118194 (rustdoc: search for tuples and unit by type with `()`) - #118781 (merge core_panic feature into panic_internals) - #119486 (pass allow-{dirty,staged} to clippy) - #119591 (rustc_mir_transform: Make DestinationPropagation stable for queries) - #119595 (Fixed ambiguity in hint.rs) - #119624 (rustc_span: More consistent span combination operations) - #119653 (compiler: update Fuchsia sanitizer support.) - #119655 (Remove ignore-stage1 that was added when changing error count msg) - #119661 (Strip lld-wrapper binaries) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-06Rollup merge of #119624 - petrochenkov:dialoc4, r=compiler-errorsMatthias Krüger-49/+47
rustc_span: More consistent span combination operations Also add more tests for using `tt` in addition to `ident`, and some other minor tweaks, see individual commits. This is a part of https://github.com/rust-lang/rust/pull/119412 that doesn't yet add side tables for metavariable spans.
2024-01-06Auto merge of #119531 - petrochenkov:cmpctxt, r=cjgillotbors-20/+16
rustc_span: Optimize syntax context comparisons Including comparisons with root context. - `eq_ctxt` doesn't require retrieving full `SpanData`, or taking the span interner lock twice. - Checking `SyntaxContext` for "rootness" is cheaper than extracting a full outer `ExpnData` for it and checking *it* for rootness. The internal lint for `eq_ctxt` is also tweaked to detect `a.ctxt() != b.ctxt()` in addition to `a.ctxt() == b.ctxt()`.
2024-01-06rustc_span: Optimize syntax context comparisonsVadim Petrochenkov-20/+16
Including comparisons with root context
2024-01-05rustc_span: More consistent span combination operationsVadim Petrochenkov-49/+47
2024-01-01Add comments sugested by reviewerbjorn3-0/+5
2023-12-31Avoid specialization for AttrId deserializationbjorn3-0/+22
2023-12-31Remove almost all uses of specialization from the metadata encoding codebjorn3-1/+136
2023-12-31Avoid specialization for the Span Encodable and Decodable implsbjorn3-11/+35
2023-12-19Unify SourceFile::name_hash and StableSourceFileIdMichael Woerister-14/+72
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-23remove unused pub fnklensy-7/+0
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-11-09Move `BorrowedBuf` and `BorrowedCursor` from `std:io` to `core::io`John Millikin-0/+1
Assigned new feature name `core_io_borrowed_buf` to distinguish from the `Read::read_buf` functionality in `std::io`.
2023-11-02Deinline all session global functions.Nicholas Nethercote-6/+0
These are all called very rarely, so there is no need for them to be inline.
2023-11-02Formatting tweaks.Nicholas Nethercote-9/+12
2023-11-02Minimize `pub` usage in `hygiene.rs`.Nicholas Nethercote-1/+1
And remove dead functions revealed by this.
2023-11-02Explain the `()` argument to `ErrorGuaranteed`.Nicholas Nethercote-0/+3
2023-10-23Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillotbors-1/+18
Avoid a `track_errors` by bubbling up most errors from `check_well_formed` I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them. This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`) cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-21Rollup merge of #116312 - c410-f3r:try, r=Mark-SimulacrumMatthias Krüger-9/+12
Initiate the inner usage of `cfg_match` (Compiler) cc #115585 Dogfood to test the implementation and remove dependencies.
2023-10-20Ensure we never accidentally serialize an `ErrorGuaranteed`Oli Scherer-1/+18
2023-10-19Initiate the inner usage of `cfg_match`Caio-9/+12
2023-10-17[RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopesUrgau-1/+1
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+2
2023-10-06Rollup merge of #116474 - nnethercote:rustc_assorted, r=spastorinoMatthias Krüger-6/+1
Assorted small cleanups r? `@spastorino`
2023-10-06Remove unused `FileName::CfgSpec`.Nicholas Nethercote-6/+1
2023-10-05Allow file names to end with '>'Martin Nordholts-1/+0
The `rustc_span::FileName` enum already differentiates between real files and "fake" files such as `<anon>`. We do not need to artificially forbid real file names from ending in `>`.
2023-09-27fix clippy::{redundant_guards, useless_format}Matthias Krüger-2/+2
2023-09-25Rename `cold_path` to `outline`John Kåre Alsaker-2/+2
2023-09-09Auto merge of #115594 - nnethercote:span-tweaks, r=cjgillotbors-11/+1
Span tweaks Some minor improvements to code clarity. r? `@cjgillot`
2023-09-08Add Freeze::cloneJohn Kåre Alsaker-8/+2
2023-09-08Optimize `Span::is_dummy`.Nicholas Nethercote-11/+1
It's quite hot, and worth having a version that works directly at the `Span` level, rather than first converting to the `SpanData` level.
2023-09-07Use `Freeze` for `SourceFile.lines`John Kåre Alsaker-123/+140
2023-09-07Use `Freeze` for `SourceFile.external_src`John Kåre Alsaker-30/+34
2023-09-04Remove always-zero field.Camille GILLOT-21/+4