about summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
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
2023-09-04Update doc.Camille GILLOT-8/+6
2023-09-03Register the file while computing its start position.Camille GILLOT-5/+9
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-66/+98
2023-08-27Load include_bytes! directly into an LrcBen Kimock-0/+2
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-16Auto merge of #112500 - lukas-code:span-ctxt, r=petrochenkovbors-4/+33
Fix argument removal suggestion around macros Fixes #112437. Fixes #113866. Helps with #114255. The issue was that `span.find_ancestor_inside(outer)` could previously return a span with a different expansion context from `outer`. This happens for example for the built-in macro `panic!`, which expands to another macro call of `panic_2021!` or `panic_2015!`. Because the call site of `panic_20xx!` has not associated source code, its span currently points to the call site of `panic!` instead. Something similar also happens items that get desugared in AST->HIR lowering. For example, `for` loops get two spans: One "inner" span that has the `.desugaring_kind()` kind set to `DesugaringKind::ForLoop` and one "outer" span that does not. Similar to the macro situation, both of these spans point to the same source code, but have different expansion contexts. This causes problems, because joining two spans with different expansion contexts will usually[^1] not actually join them together to avoid creating "spaghetti" spans that go from the macro definition to the macro call. For example, in the following snippet `full_span` might not actually contain the `adjusted_start` and `adjusted_end`. This caused the broken suggestion / debug ICE in the linked issues. ```rust let adjusted_start = start.find_ancestor_inside(shared_ancestor); let adjusted_end = end.find_ancestor_inside(shared_ancestor); let full_span = adjusted_start.to(adjusted_end) ``` To fix the issue, this PR introduces a new method, `find_ancestor_inside_same_ctxt`, which combines the functionality of `find_ancestor_inside` and `find_ancestor_in_same_ctxt`: It finds an ancestor span that is contained within the parent *and* has the same syntax context, and is therefore safe to extend. This new method should probably be used everywhere, where the returned span is extended, but for now it is just used for the argument removal suggestion. Additionally, this PR fixes a second issue where the function call itself is inside a macro but the arguments come from outside the macro. The test is added in the first commit to include stderr diff, so this is best reviewed commit by commit. [^1]: If one expansion context is the root context and the other is not.
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-08-01introduce `Span::find_ancestor_inside_same_ctxt`Lukas Markeffsky-4/+33
and use it for function argument diagnostics
2023-07-30Simplify `Span::can_be_used_for_suggestions` a little tiny bitMaybe Waffle-1/+1
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-6/+10
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-1/+2
2023-06-19Rollup merge of #112705 - WaffleLapkin:simplify_source_callee_impl, r=cjgillotMatthias Krüger-7/+10
Simplify `Span::source_callee` impl Imo the iterator impl is easier to grasp.
2023-06-16Add `SyntaxContext::is_root`Maybe Waffle-7/+7
2023-06-16Simplify `Span::source_callee` implMaybe Waffle-7/+10
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-6/+0
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-05-16Move DebuggerVisualizerFile types from rustc_span to rustc_middleMichael Woerister-33/+0
2023-05-16Fix dependency tracking for debugger visualizersMichael Woerister-2/+12
2023-05-14Simplify find_width_of_character_at_span.Mara Bos-0/+1
2023-05-06Rollup merge of #110985 - Amanieu:normalize_asm_spans, r=b-naberMatthias Krüger-0/+22
Fix spans in LLVM-generated inline asm errors Previously, incorrect spans were reported if inline assembly contained CRLF (Windows) line endings. Fixes #110885
2023-05-06Fix spans in LLVM-generated inline asm errorsAmanieu d'Antras-0/+22
Previously, incorrect spans were reported if inline assembly contained CRLF (Windows) line endings. Fixes #110885
2023-05-06Rollup merge of #111261 - ↵Yuki Okushi-0/+1
compiler-errors:error-guaranteed-should-be-scarier-to-construct, r=BoxyUwU Mark `ErrorGuaranteed` constructor as deprecated so people don't use it You should never ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever ever use this function unless you know what you're doing, so make it harder to accidentally use it! Alternatives are to change the name to sound scarier, make it `unsafe` (though it's not really a soundness thing), or work on deeper refactors to make it private. r? `@BoxyUwU`
2023-05-05Mark `ErrorGuaranteed` constructor as deprecated so people don't use itMichael Goulet-0/+1
2023-04-30Arc -> Lrcklensy-3/+2
2023-04-20Rollup merge of #110548 - kpreid:span, r=WaffleLapkinYuki Okushi-11/+20
Make `impl Debug for Span` not panic on not having session globals. I hit the panic that this patch avoids while messing with the early lints in `rustc_session::config::build_session_options()`. The rest of that project is not finished, but this seemed like a self-contained improvement. (Should changes like this add tests? I don't see similar unit tests.)