about summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
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.)
2023-04-19fmt fixKevin Reid-1/+1
2023-04-19Make `impl Debug for Span` not panic on not having session globals.Kevin Reid-11/+20
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-11/+11
2023-04-17Auto merge of #110367 - saethlin:no-truncations, r=oli-obkbors-3/+1
Remove some suspicious cast truncations These truncations were added a long time ago, and as best I can tell without a perf justification. And with rust-lang/rust#110410 it has become perf-neutral to not truncate anymore. We worked hard for all these bits, let's use them.
2023-04-16Remove some unnecessary hash truncationsBen Kimock-3/+1
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-3/+4
2023-04-09Fix some clippy::complexityNilstrieb-5/+5
2023-04-09Box large enum variantsNilstrieb-2/+2
2023-04-04Remove a fishy Clone implOli Scherer-1/+19
2023-03-31Improve `with_source_map`.Nicholas Nethercote-10/+13
Rename `with_source_map` as `set_source_map`. Because `with` functions (e.g. `with_session_globals`, `scoped_tls::ScopedKey::with`) are for *getting* a value for the duration of a closure, and `set` functions (e.g. `set_session_globals_then` `scoped_tls::ScopedKey::with`) are for *setting* a value for the duration of a closure. Also fix up the comment, which is wrong: - The bit about `TyCtxt` is wrong. - `span_debug1` doesn't exist any more. - There's only one level of fallback, not two. (This is effectively a follow-up to the changes in #93936.) Also add a comment explaining that `SessionGlobals::source_map` should only be used when absolutely necessary.
2023-03-19refactor: improve "ident starts with number" errorEzra Shaw-0/+12
2023-02-25Add ErrorGuaranteed to HIR TyKind::ErrMichael Goulet-0/+14
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-1/+1
2023-02-19Use restricted Damerau-Levenshtein algorithmJacob Pratt-0/+1
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-2/+2
2023-01-31Use `Edition` methods a bit moreMaybe Waffle-4/+4
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-2/+2
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).
2022-12-25document that `Span::to` can go backwardsLukas Markeffsky-0/+3
2022-12-15Shorten trimmed display of closuresEsteban Küber-0/+7
When `with_forced_trimmed_paths` is used, only print filename and start of the closure's span, to reduce their verbosity.
2022-12-15more clippy::complexity fixesMatthias Krüger-1/+1
2022-12-09Introduce `Span::is_visible`Esteban Küber-0/+9
2022-12-01Remove useless borrows and derefsMaybe Waffle-1/+1
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-7/+7
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-3/+1
2022-10-28Auto merge of #103071 - wesleywiser:fix_inlined_line_numbers, r=davidtwcobors-1/+7
Fix line numbers for MIR inlined code `should_collapse_debuginfo` detects if the specified span is part of a macro expansion however it does this by checking if the span is anything other than a normal (non-expanded) kind, then the span sequence is walked backwards to the root span. This doesn't work when the MIR inliner inlines code as it creates spans with expansion information set to `ExprKind::Inlined` and results in the line number being attributed to the inline callsite rather than the normal line number of the inlined code. Fixes #103068
2022-10-24Auto merge of #102536 - scottmcm:lookup_line-tweak, r=jackh726bors-4/+1
Shorten the `lookup_line` code slightly The `match` looks like it's exactly the same as `checked_sub(1)`, so we might as well see if perf says we can just do that to save a couple lines.
2022-10-14Fix line numbers for MIR inlined codeWesley Wiser-1/+7
`should_collapse_debuginfo` detects if the specified span is part of a macro expansion however it does this by checking if the span is anything other than a normal (non-expanded) kind, then the span sequence is walked backwards to the root span. This doesn't work when the MIR inliner inlines code as it creates spans with expansion information set to `ExprKind::Inlined` and results in the line number being attributed to the inline callsite rather than the normal line number of the inlined code.
2022-10-09Add missing documentation for FileNameDisplayPreference variantsGuillaume Gomez-0/+4
2022-10-01Shorten the `lookup_line` code slightlyScott McMurray-4/+1
The `match` looks like it's exactly the same as `checked_sub(1)`, so we might as well see if perf says we can just do that to save a couple lines.
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-22Auto merge of #98840 - cjgillot:span-inline-ctxt, r=wesleywiserbors-3/+0
Inline SyntaxContext in both encoded span representation. The current interned representation for spans does not use the `ctxt_or_zero: u16` field. This PR proposes to use this field to store the `SyntaxContext` of the interned span instead. When `ctxt_or_zero` and the interned span's `ctxt` don't match, the inlined one takes precedence. This allows to implement `Span::ctxt` and `Span::with_ctxt` with much less probability to access the interner. Those functions are used a lot for hygiene, so this may be worth it.
2022-09-19use partition_point instead of binary_search when looking up source linesThe 8472-4/+3
In local benchmarks this results in 0.4% fewer cycles in a critical sequential section when compiling libcore.
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-07ssa: implement `#[collapse_debuginfo]`David Wood-0/+7
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-2/+0
by module
2022-08-21More docsMichael Goulet-0/+3
2022-08-21Comment a bit, use find_ancestor_in_same_ctxt to suppress some weird macro notesMichael Goulet-0/+7
2022-08-20Rollup merge of #100723 - 5225225:the-easy-ones, r=compiler-errorsMatthias Krüger-0/+2
Add the diagnostic translation lints to crates that don't emit them Some of these have a note saying that they should build on a stable compiler, does that mean they shouldn't get these lints? Or can we cfg them out on those?
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-08-17Keep ctxt in encoded span representation.Camille GILLOT-3/+0
2022-08-07Only encode position from start of file.Camille GILLOT-4/+0
2022-08-06Encode index of SourceFile along with span.Camille GILLOT-0/+2
2022-07-14Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPCbors-1/+0
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-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-2/+2
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-1/+0