rust/compiler
Jacob Pratt 2c374e3e21
Rollup merge of #137757 - estebank:trim-spans, r=davidtwco
On long spans, trim the middle of them to make them fit in the terminal width

When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well.

```
error[E0308]: mismatched types
  --> $DIR/long-span.rs:6:15
   |
LL | ... = [0, 0, 0, 0, ..., 0, 0];
   |       ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]`
```

Address part of https://github.com/rust-lang/rust/issues/137680 (missing handling of the long suggestion). Fix https://github.com/rust-lang/rust/issues/125581.

---

Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars.

Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic.

---

`-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
2025-03-08 01:27:22 -05:00
..
rustc Fix overcapturing, unsafe extern blocks, and new unsafe ops 2025-02-22 00:01:48 +00:00
rustc_abi Rollup merge of #137805 - RalfJung:layout-debug-print, r=Noratrieb 2025-03-06 12:22:19 -05:00
rustc_arena Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_ast Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_ast_ir Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_ast_lowering Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino 2025-03-07 19:15:34 +01:00
rustc_ast_passes Change feature flag error to be ergonomic clones are experimental 2025-03-06 17:58:34 -03:00
rustc_ast_pretty Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_attr_data_structures Spruce up AttributeKind docs 2025-02-26 22:21:36 +00:00
rustc_attr_parsing Rollup merge of #137758 - jdonszelmann:fix-137662, r=nnethercote 2025-03-06 12:22:15 -05:00
rustc_baked_icu_data Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_borrowck Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_builtin_macros Rollup merge of #138187 - matthiaskrgr:rmclone, r=cjgillot 2025-03-07 21:57:54 -05:00
rustc_codegen_cranelift Fully test the alloc crate through alloctests 2025-03-07 19:11:13 +00:00
rustc_codegen_gcc Rollup merge of #137549 - oli-obk:llvm-ffi, r=davidtwco 2025-03-07 19:15:34 +01:00
rustc_codegen_llvm Rollup merge of #137549 - oli-obk:llvm-ffi, r=davidtwco 2025-03-07 19:15:34 +01:00
rustc_codegen_ssa Rollup merge of #137685 - lqd:nostart-stop-gc, r=petrochenkov 2025-03-08 01:27:22 -05:00
rustc_const_eval Pass Option<Symbol> to def_path_data/create_def methods. 2025-03-07 20:53:00 +11:00
rustc_data_structures Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, r=lcnr 2025-03-06 12:22:16 -05:00
rustc_driver Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_driver_impl Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_error_codes Rollup merge of #136764 - traviscross:TC/make-ptr_cast_add_auto_to_object-hard-error, r=oli-obk 2025-03-05 21:46:34 +08:00
rustc_error_messages Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_errors Make trimming logic work on more than one span at a time 2025-03-07 17:55:08 +00:00
rustc_expand Auto merge of #137959 - matthiaskrgr:rollup-62vjvwr, r=matthiaskrgr 2025-03-04 02:27:56 +00:00
rustc_feature Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_fluent_macro rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME 2025-02-28 21:14:06 -06:00
rustc_fs_util Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_graphviz Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_hashes Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_hir Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obk 2025-03-07 19:15:36 +01:00
rustc_hir_analysis Rollup merge of #138173 - compiler-errors:incoherent-negative-impl, r=oli-obk 2025-03-07 21:57:53 -05:00
rustc_hir_pretty Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_hir_typeck Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_incremental Change span field accesses to method calls 2025-02-24 14:22:31 +01:00
rustc_index Rollup merge of #136610 - Jarcho:range_idx, r=Noratrieb 2025-02-24 02:11:32 -05:00
rustc_index_macros Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_infer Use Binder<Vec<T>> instead of Vec<Binder<T>> in new solver 2025-02-26 17:32:26 +00:00
rustc_interface Remove some unnecessary aliases from rustc_data_structures::sync 2025-03-03 20:20:24 +11:00
rustc_lexer Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
rustc_lint Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obk 2025-03-07 19:15:36 +01:00
rustc_lint_defs Rollup merge of #136764 - traviscross:TC/make-ptr_cast_add_auto_to_object-hard-error, r=oli-obk 2025-03-05 21:46:34 +08:00
rustc_llvm Rollup merge of #138137 - ZequanWu:fix-triple, r=cuviper 2025-03-07 21:57:52 -05:00
rustc_log Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_macros pretty print hir attributes 2025-02-24 14:31:19 +01:00
rustc_metadata Auto merge of #135695 - Noratrieb:elf-raw-dylib, r=bjorn3 2025-03-04 15:39:44 +00:00
rustc_middle Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obk 2025-03-07 19:15:36 +01:00
rustc_mir_build Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_mir_dataflow Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
rustc_mir_transform Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino 2025-03-07 19:15:34 +01:00
rustc_monomorphize compiler: use is_rustic_abi in abi_check 2025-03-04 18:23:51 -08:00
rustc_next_trait_solver Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk 2025-03-05 21:46:44 +08:00
rustc_parse Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_parse_format Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
rustc_passes Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obk 2025-03-07 19:15:36 +01:00
rustc_pattern_analysis Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
rustc_privacy Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
rustc_query_impl Introduce new parsing infrastructure and types for parsed attributes 2025-02-24 14:26:06 +01:00
rustc_query_system Rollup merge of #137731 - SparrowLii:waiter, r=nnethercote 2025-03-05 21:46:45 +08:00
rustc_resolve Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino 2025-03-07 19:15:34 +01:00
rustc_sanitizers Introduce new-style attribute parsers for several attributes 2025-02-24 14:31:17 +01:00
rustc_serialize rename sub_ptr 😅 2025-02-23 23:11:00 +07:00
rustc_session Remove highlighting of spans on -Zteach 2025-03-07 17:55:08 +00:00
rustc_smir Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
rustc_span Rollup merge of #137606 - davidtwco:next-edition, r=traviscross,ehuss 2025-03-07 21:57:49 -05:00
rustc_symbol_mangling Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
rustc_target Rollup merge of #137957 - Noratrieb:no, r=wesleywiser 2025-03-07 21:57:50 -05:00
rustc_trait_selection Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakis 2025-03-07 19:15:33 +01:00
rustc_traits Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack 2025-03-04 18:18:48 +00:00
rustc_transmute Remove allow(dead_code) attributes. 2025-02-28 17:31:31 +11:00
rustc_ty_utils Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino 2025-03-07 19:15:34 +01:00
rustc_type_ir Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk 2025-03-05 21:46:44 +08:00
rustc_type_ir_macros Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
stable_mir Make CrateItem::body() function return an option 2025-03-04 17:46:40 -08:00