| author | bors <bors@rust-lang.org> 2025-06-18 21:19:39 UTC |
| committer | bors <bors@rust-lang.org> 2025-06-18 21:19:39 UTC |
| log | 044514eb26511d2d8aa999fdf27e85df6beb6576 |
| tree | fb5c0b63b1bbee2e9a2615a9c985d4dc62e2b8f0 |
| parent | c68340350c78eea402c4a85f8d9c1b7d3d607635 |
| parent | 663939dfb0d20a4de47d755b8f8fd1af44aac80f |
Rollup of 6 pull requests
Successful merges:
- rust-lang/rust#135656 (Add `-Z hint-mostly-unused` to tell rustc that most of a crate will go unused)
- rust-lang/rust#138237 (Get rid of `EscapeDebugInner`.)
- rust-lang/rust#141614 (lint direct use of rustc_type_ir )
- rust-lang/rust#142123 (Implement initial support for timing sections (`--json=timings`))
- rust-lang/rust#142377 (Try unremapping compiler sources)
- rust-lang/rust#142674 (remove duplicate crash test)
r? `@ghost`
`@rustbot` modify labels: rollup35 files changed, 772 insertions(+), 181 deletions(-)
compiler/rustc_errors/src/emitter.rs+11-1| ... | ... | @@ -34,6 +34,7 @@ use crate::snippet::{ |
| 34 | 34 | Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString, |
| 35 | 35 | }; |
| 36 | 36 | use crate::styled_buffer::StyledBuffer; |
| 37 | use crate::timings::TimingRecord; | |
| 37 | 38 | use crate::translation::{Translate, to_fluent_args}; |
| 38 | 39 | use crate::{ |
| 39 | 40 | CodeSuggestion, DiagInner, DiagMessage, ErrCode, FluentBundle, LazyFallbackBundle, Level, |
| ... | ... | @@ -164,11 +165,16 @@ impl Margin { |
| 164 | 165 | } |
| 165 | 166 | } |
| 166 | 167 | |
| 168 | pub enum TimingEvent { | |
| 169 | Start, | |
| 170 | End, | |
| 171 | } | |
| 172 | ||
| 167 | 173 | const ANONYMIZED_LINE_NUM: &str = "LL"; |
| 168 | 174 | |
| 169 | 175 | pub type DynEmitter = dyn Emitter + DynSend; |
| 170 | 176 | |
| 171 | /// Emitter trait for emitting errors. | |
| 177 | /// Emitter trait for emitting errors and other structured information. | |
| 172 | 178 | pub trait Emitter: Translate { |
| 173 | 179 | /// Emit a structured diagnostic. |
| 174 | 180 | fn emit_diagnostic(&mut self, diag: DiagInner, registry: &Registry); |
| ... | ... | @@ -177,6 +183,10 @@ pub trait Emitter: Translate { |
| 177 | 183 | /// Currently only supported for the JSON format. |
| 178 | 184 | fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {} |
| 179 | 185 | |
| 186 | /// Emit a timestamp with start/end of a timing section. | |
| 187 | /// Currently only supported for the JSON format. | |
| 188 | fn emit_timing_section(&mut self, _record: TimingRecord, _event: TimingEvent) {} | |
| 189 | ||
| 180 | 190 | /// Emit a report about future breakage. |
| 181 | 191 | /// Currently only supported for the JSON format. |
| 182 | 192 | fn emit_future_breakage_report(&mut self, _diags: Vec<DiagInner>, _registry: &Registry) {} |
compiler/rustc_errors/src/json.rs+28-1| ... | ... | @@ -28,9 +28,10 @@ use termcolor::{ColorSpec, WriteColor}; |
| 28 | 28 | use crate::diagnostic::IsLint; |
| 29 | 29 | use crate::emitter::{ |
| 30 | 30 | ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType, OutputTheme, |
| 31 | should_show_source_code, | |
| 31 | TimingEvent, should_show_source_code, | |
| 32 | 32 | }; |
| 33 | 33 | use crate::registry::Registry; |
| 34 | use crate::timings::{TimingRecord, TimingSection}; | |
| 34 | 35 | use crate::translation::{Translate, to_fluent_args}; |
| 35 | 36 | use crate::{ |
| 36 | 37 | CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, Subdiag, Suggestions, |
| ... | ... | @@ -104,6 +105,7 @@ impl JsonEmitter { |
| 104 | 105 | enum EmitTyped<'a> { |
| 105 | 106 | Diagnostic(Diagnostic), |
| 106 | 107 | Artifact(ArtifactNotification<'a>), |
| 108 | SectionTiming(SectionTimestamp<'a>), | |
| 107 | 109 | FutureIncompat(FutureIncompatReport<'a>), |
| 108 | 110 | UnusedExtern(UnusedExterns<'a>), |
| 109 | 111 | } |
| ... | ... | @@ -135,6 +137,21 @@ impl Emitter for JsonEmitter { |
| 135 | 137 | } |
| 136 | 138 | } |
| 137 | 139 | |
| 140 | fn emit_timing_section(&mut self, record: TimingRecord, event: TimingEvent) { | |
| 141 | let event = match event { | |
| 142 | TimingEvent::Start => "start", | |
| 143 | TimingEvent::End => "end", | |
| 144 | }; | |
| 145 | let name = match record.section { | |
| 146 | TimingSection::Linking => "link", | |
| 147 | }; | |
| 148 | let data = SectionTimestamp { name, event, timestamp: record.timestamp }; | |
| 149 | let result = self.emit(EmitTyped::SectionTiming(data)); | |
| 150 | if let Err(e) = result { | |
| 151 | panic!("failed to print timing section: {e:?}"); | |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 138 | 155 | fn emit_future_breakage_report(&mut self, diags: Vec<crate::DiagInner>, registry: &Registry) { |
| 139 | 156 | let data: Vec<FutureBreakageItem<'_>> = diags |
| 140 | 157 | .into_iter() |
| ... | ... | @@ -263,6 +280,16 @@ struct ArtifactNotification<'a> { |
| 263 | 280 | emit: &'a str, |
| 264 | 281 | } |
| 265 | 282 | |
| 283 | #[derive(Serialize)] | |
| 284 | struct SectionTimestamp<'a> { | |
| 285 | /// Name of the section | |
| 286 | name: &'a str, | |
| 287 | /// Start/end of the section | |
| 288 | event: &'a str, | |
| 289 | /// Opaque timestamp. | |
| 290 | timestamp: u128, | |
| 291 | } | |
| 292 | ||
| 266 | 293 | #[derive(Serialize)] |
| 267 | 294 | struct FutureBreakageItem<'a> { |
| 268 | 295 | // Always EmitTyped::Diagnostic, but we want to make sure it gets serialized |
compiler/rustc_errors/src/lib.rs+12| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | #![allow(internal_features)] |
| 8 | 8 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 9 | 9 | #![allow(rustc::untranslatable_diagnostic)] |
| 10 | #![cfg_attr(not(bootstrap), allow(rustc::direct_use_of_rustc_type_ir))] | |
| 10 | 11 | #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] |
| 11 | 12 | #![doc(rust_logo)] |
| 12 | 13 | #![feature(array_windows)] |
| ... | ... | @@ -74,7 +75,9 @@ pub use snippet::Style; |
| 74 | 75 | pub use termcolor::{Color, ColorSpec, WriteColor}; |
| 75 | 76 | use tracing::debug; |
| 76 | 77 | |
| 78 | use crate::emitter::TimingEvent; | |
| 77 | 79 | use crate::registry::Registry; |
| 80 | use crate::timings::TimingRecord; | |
| 78 | 81 | |
| 79 | 82 | pub mod annotate_snippet_emitter_writer; |
| 80 | 83 | pub mod codes; |
| ... | ... | @@ -90,6 +93,7 @@ mod snippet; |
| 90 | 93 | mod styled_buffer; |
| 91 | 94 | #[cfg(test)] |
| 92 | 95 | mod tests; |
| 96 | pub mod timings; | |
| 93 | 97 | pub mod translation; |
| 94 | 98 | |
| 95 | 99 | pub type PResult<'a, T> = Result<T, Diag<'a>>; |
| ... | ... | @@ -1156,6 +1160,14 @@ impl<'a> DiagCtxtHandle<'a> { |
| 1156 | 1160 | self.inner.borrow_mut().emitter.emit_artifact_notification(path, artifact_type); |
| 1157 | 1161 | } |
| 1158 | 1162 | |
| 1163 | pub fn emit_timing_section_start(&self, record: TimingRecord) { | |
| 1164 | self.inner.borrow_mut().emitter.emit_timing_section(record, TimingEvent::Start); | |
| 1165 | } | |
| 1166 | ||
| 1167 | pub fn emit_timing_section_end(&self, record: TimingRecord) { | |
| 1168 | self.inner.borrow_mut().emitter.emit_timing_section(record, TimingEvent::End); | |
| 1169 | } | |
| 1170 | ||
| 1159 | 1171 | pub fn emit_future_breakage_report(&self) { |
| 1160 | 1172 | let inner = &mut *self.inner.borrow_mut(); |
| 1161 | 1173 | let diags = std::mem::take(&mut inner.future_breakage_diagnostics); |
compiler/rustc_errors/src/timings.rs created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | use std::time::Instant; | |
| 2 | ||
| 3 | use crate::DiagCtxtHandle; | |
| 4 | ||
| 5 | /// A high-level section of the compilation process. | |
| 6 | #[derive(Copy, Clone, Debug)] | |
| 7 | pub enum TimingSection { | |
| 8 | /// Time spent linking. | |
| 9 | Linking, | |
| 10 | } | |
| 11 | ||
| 12 | /// Section with attached timestamp | |
| 13 | #[derive(Copy, Clone, Debug)] | |
| 14 | pub struct TimingRecord { | |
| 15 | pub section: TimingSection, | |
| 16 | /// Microseconds elapsed since some predetermined point in time (~start of the rustc process). | |
| 17 | pub timestamp: u128, | |
| 18 | } | |
| 19 | ||
| 20 | impl TimingRecord { | |
| 21 | fn from_origin(origin: Instant, section: TimingSection) -> Self { | |
| 22 | Self { section, timestamp: Instant::now().duration_since(origin).as_micros() } | |
| 23 | } | |
| 24 | ||
| 25 | pub fn section(&self) -> TimingSection { | |
| 26 | self.section | |
| 27 | } | |
| 28 | ||
| 29 | pub fn timestamp(&self) -> u128 { | |
| 30 | self.timestamp | |
| 31 | } | |
| 32 | } | |
| 33 | ||
| 34 | /// Manages emission of start/end section timings, enabled through `--json=timings`. | |
| 35 | pub struct TimingSectionHandler { | |
| 36 | /// Time when the compilation session started. | |
| 37 | /// If `None`, timing is disabled. | |
| 38 | origin: Option<Instant>, | |
| 39 | } | |
| 40 | ||
| 41 | impl TimingSectionHandler { | |
| 42 | pub fn new(enabled: bool) -> Self { | |
| 43 | let origin = if enabled { Some(Instant::now()) } else { None }; | |
| 44 | Self { origin } | |
| 45 | } | |
| 46 | ||
| 47 | /// Returns a RAII guard that will immediately emit a start the provided section, and then emit | |
| 48 | /// its end when it is dropped. | |
| 49 | pub fn start_section<'a>( | |
| 50 | &self, | |
| 51 | diag_ctxt: DiagCtxtHandle<'a>, | |
| 52 | section: TimingSection, | |
| 53 | ) -> TimingSectionGuard<'a> { | |
| 54 | TimingSectionGuard::create(diag_ctxt, section, self.origin) | |
| 55 | } | |
| 56 | } | |
| 57 | ||
| 58 | /// RAII wrapper for starting and ending section timings. | |
| 59 | pub struct TimingSectionGuard<'a> { | |
| 60 | dcx: DiagCtxtHandle<'a>, | |
| 61 | section: TimingSection, | |
| 62 | origin: Option<Instant>, | |
| 63 | } | |
| 64 | ||
| 65 | impl<'a> TimingSectionGuard<'a> { | |
| 66 | fn create(dcx: DiagCtxtHandle<'a>, section: TimingSection, origin: Option<Instant>) -> Self { | |
| 67 | if let Some(origin) = origin { | |
| 68 | dcx.emit_timing_section_start(TimingRecord::from_origin(origin, section)); | |
| 69 | } | |
| 70 | Self { dcx, section, origin } | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 74 | impl<'a> Drop for TimingSectionGuard<'a> { | |
| 75 | fn drop(&mut self) { | |
| 76 | if let Some(origin) = self.origin { | |
| 77 | self.dcx.emit_timing_section_end(TimingRecord::from_origin(origin, self.section)); | |
| 78 | } | |
| 79 | } | |
| 80 | } |
compiler/rustc_infer/src/lib.rs+1| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | #![allow(internal_features)] |
| 17 | 17 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 18 | 18 | #![allow(rustc::untranslatable_diagnostic)] |
| 19 | #![cfg_attr(not(bootstrap), allow(rustc::direct_use_of_rustc_type_ir))] | |
| 19 | 20 | #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] |
| 20 | 21 | #![doc(rust_logo)] |
| 21 | 22 | #![feature(assert_matches)] |
compiler/rustc_interface/src/queries.rs+2| ... | ... | @@ -4,6 +4,7 @@ use std::sync::Arc; |
| 4 | 4 | use rustc_codegen_ssa::CodegenResults; |
| 5 | 5 | use rustc_codegen_ssa::traits::CodegenBackend; |
| 6 | 6 | use rustc_data_structures::svh::Svh; |
| 7 | use rustc_errors::timings::TimingSection; | |
| 7 | 8 | use rustc_hir::def_id::LOCAL_CRATE; |
| 8 | 9 | use rustc_metadata::EncodedMetadata; |
| 9 | 10 | use rustc_middle::dep_graph::DepGraph; |
| ... | ... | @@ -88,6 +89,7 @@ impl Linker { |
| 88 | 89 | } |
| 89 | 90 | |
| 90 | 91 | let _timer = sess.prof.verbose_generic_activity("link_crate"); |
| 92 | let _timing = sess.timings.start_section(sess.dcx(), TimingSection::Linking); | |
| 91 | 93 | codegen_backend.link(sess, codegen_results, self.metadata, &self.output_filenames) |
| 92 | 94 | } |
| 93 | 95 | } |
compiler/rustc_interface/src/tests.rs+1| ... | ... | @@ -802,6 +802,7 @@ fn test_unstable_options_tracking_hash() { |
| 802 | 802 | tracked!(force_unstable_if_unmarked, true); |
| 803 | 803 | tracked!(function_return, FunctionReturn::ThunkExtern); |
| 804 | 804 | tracked!(function_sections, Some(false)); |
| 805 | tracked!(hint_mostly_unused, true); | |
| 805 | 806 | tracked!(human_readable_cgu_names, true); |
| 806 | 807 | tracked!(incremental_ignore_spans, true); |
| 807 | 808 | tracked!(inline_mir, Some(true)); |
compiler/rustc_lint/messages.ftl+3| ... | ... | @@ -812,6 +812,9 @@ lint_tykind = usage of `ty::TyKind` |
| 812 | 812 | lint_tykind_kind = usage of `ty::TyKind::<kind>` |
| 813 | 813 | .suggestion = try using `ty::<kind>` directly |
| 814 | 814 | |
| 815 | lint_type_ir_direct_use = do not use `rustc_type_ir` unless you are implementing type system internals | |
| 816 | .note = use `rustc_middle::ty` instead | |
| 817 | ||
| 815 | 818 | lint_type_ir_inherent_usage = do not use `rustc_type_ir::inherent` unless you're inside of the trait solver |
| 816 | 819 | .note = the method or struct you're looking for is likely defined somewhere else downstream in the compiler |
| 817 | 820 |
compiler/rustc_lint/src/internal.rs+28-3| ... | ... | @@ -14,8 +14,8 @@ use {rustc_ast as ast, rustc_hir as hir}; |
| 14 | 14 | use crate::lints::{ |
| 15 | 15 | BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, |
| 16 | 16 | NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag, |
| 17 | SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrInherentUsage, | |
| 18 | TypeIrTraitUsage, UntranslatableDiag, | |
| 17 | SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrDirectUse, | |
| 18 | TypeIrInherentUsage, TypeIrTraitUsage, UntranslatableDiag, | |
| 19 | 19 | }; |
| 20 | 20 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; |
| 21 | 21 | |
| ... | ... | @@ -301,8 +301,18 @@ declare_tool_lint! { |
| 301 | 301 | "usage `rustc_type_ir`-specific abstraction traits outside of trait system", |
| 302 | 302 | report_in_external_macro: true |
| 303 | 303 | } |
| 304 | declare_tool_lint! { | |
| 305 | /// The `direct_use_of_rustc_type_ir` lint detects usage of `rustc_type_ir`. | |
| 306 | /// | |
| 307 | /// This module should only be used within the trait solver and some desirable | |
| 308 | /// crates like rustc_middle. | |
| 309 | pub rustc::DIRECT_USE_OF_RUSTC_TYPE_IR, | |
| 310 | Allow, | |
| 311 | "usage `rustc_type_ir` abstraction outside of trait system", | |
| 312 | report_in_external_macro: true | |
| 313 | } | |
| 304 | 314 | |
| 305 | declare_lint_pass!(TypeIr => [NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT, USAGE_OF_TYPE_IR_INHERENT, USAGE_OF_TYPE_IR_TRAITS]); | |
| 315 | declare_lint_pass!(TypeIr => [DIRECT_USE_OF_RUSTC_TYPE_IR, NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT, USAGE_OF_TYPE_IR_INHERENT, USAGE_OF_TYPE_IR_TRAITS]); | |
| 306 | 316 | |
| 307 | 317 | impl<'tcx> LateLintPass<'tcx> for TypeIr { |
| 308 | 318 | fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { |
| ... | ... | @@ -372,6 +382,21 @@ impl<'tcx> LateLintPass<'tcx> for TypeIr { |
| 372 | 382 | NonGlobImportTypeIrInherent { suggestion: lo.eq_ctxt(hi).then(|| lo.to(hi)), snippet }, |
| 373 | 383 | ); |
| 374 | 384 | } |
| 385 | ||
| 386 | fn check_path( | |
| 387 | &mut self, | |
| 388 | cx: &LateContext<'tcx>, | |
| 389 | path: &rustc_hir::Path<'tcx>, | |
| 390 | _: rustc_hir::HirId, | |
| 391 | ) { | |
| 392 | if let Some(seg) = path.segments.iter().find(|seg| { | |
| 393 | seg.res | |
| 394 | .opt_def_id() | |
| 395 | .is_some_and(|def_id| cx.tcx.is_diagnostic_item(sym::type_ir, def_id)) | |
| 396 | }) { | |
| 397 | cx.emit_span_lint(DIRECT_USE_OF_RUSTC_TYPE_IR, seg.ident.span, TypeIrDirectUse); | |
| 398 | } | |
| 399 | } | |
| 375 | 400 | } |
| 376 | 401 | |
| 377 | 402 | declare_tool_lint! { |
compiler/rustc_lint/src/lib.rs+1| ... | ... | @@ -668,6 +668,7 @@ fn register_internals(store: &mut LintStore) { |
| 668 | 668 | LintId::of(USAGE_OF_TYPE_IR_TRAITS), |
| 669 | 669 | LintId::of(BAD_OPT_ACCESS), |
| 670 | 670 | LintId::of(SPAN_USE_EQ_CTXT), |
| 671 | LintId::of(DIRECT_USE_OF_RUSTC_TYPE_IR), | |
| 671 | 672 | ], |
| 672 | 673 | ); |
| 673 | 674 | } |
compiler/rustc_lint/src/lints.rs+5| ... | ... | @@ -969,6 +969,11 @@ pub(crate) struct TypeIrInherentUsage; |
| 969 | 969 | #[note] |
| 970 | 970 | pub(crate) struct TypeIrTraitUsage; |
| 971 | 971 | |
| 972 | #[derive(LintDiagnostic)] | |
| 973 | #[diag(lint_type_ir_direct_use)] | |
| 974 | #[note] | |
| 975 | pub(crate) struct TypeIrDirectUse; | |
| 976 | ||
| 972 | 977 | #[derive(LintDiagnostic)] |
| 973 | 978 | #[diag(lint_non_glob_import_type_ir_inherent)] |
| 974 | 979 | pub(crate) struct NonGlobImportTypeIrInherent { |
compiler/rustc_metadata/src/rmeta/decoder.rs+123-75| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | // Decoding metadata from a single crate's metadata |
| 2 | 2 | |
| 3 | 3 | use std::iter::TrustedLen; |
| 4 | use std::path::Path; | |
| 4 | use std::path::{Path, PathBuf}; | |
| 5 | 5 | use std::sync::{Arc, OnceLock}; |
| 6 | 6 | use std::{io, iter, mem}; |
| 7 | 7 | |
| ... | ... | @@ -1610,10 +1610,14 @@ impl<'a> CrateMetadataRef<'a> { |
| 1610 | 1610 | /// Proc macro crates don't currently export spans, so this function does not have |
| 1611 | 1611 | /// to work for them. |
| 1612 | 1612 | fn imported_source_file(self, source_file_index: u32, sess: &Session) -> ImportedSourceFile { |
| 1613 | fn filter<'a>(sess: &Session, path: Option<&'a Path>) -> Option<&'a Path> { | |
| 1613 | fn filter<'a>( | |
| 1614 | sess: &Session, | |
| 1615 | real_source_base_dir: &Option<PathBuf>, | |
| 1616 | path: Option<&'a Path>, | |
| 1617 | ) -> Option<&'a Path> { | |
| 1614 | 1618 | path.filter(|_| { |
| 1615 | 1619 | // Only spend time on further checks if we have what to translate *to*. |
| 1616 | sess.opts.real_rust_source_base_dir.is_some() | |
| 1620 | real_source_base_dir.is_some() | |
| 1617 | 1621 | // Some tests need the translation to be always skipped. |
| 1618 | 1622 | && sess.opts.unstable_opts.translate_remapped_path_to_local_path |
| 1619 | 1623 | }) |
| ... | ... | @@ -1625,57 +1629,92 @@ impl<'a> CrateMetadataRef<'a> { |
| 1625 | 1629 | }) |
| 1626 | 1630 | } |
| 1627 | 1631 | |
| 1628 | let try_to_translate_virtual_to_real = |name: &mut rustc_span::FileName| { | |
| 1629 | // Translate the virtual `/rustc/$hash` prefix back to a real directory | |
| 1630 | // that should hold actual sources, where possible. | |
| 1631 | // | |
| 1632 | // NOTE: if you update this, you might need to also update bootstrap's code for generating | |
| 1633 | // the `rust-src` component in `Src::run` in `src/bootstrap/dist.rs`. | |
| 1634 | let virtual_rust_source_base_dir = [ | |
| 1635 | filter(sess, option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(Path::new)), | |
| 1636 | filter(sess, sess.opts.unstable_opts.simulate_remapped_rust_src_base.as_deref()), | |
| 1637 | ]; | |
| 1632 | let try_to_translate_virtual_to_real = | |
| 1633 | |virtual_source_base_dir: Option<&str>, | |
| 1634 | real_source_base_dir: &Option<PathBuf>, | |
| 1635 | name: &mut rustc_span::FileName| { | |
| 1636 | let virtual_source_base_dir = [ | |
| 1637 | filter(sess, real_source_base_dir, virtual_source_base_dir.map(Path::new)), | |
| 1638 | filter( | |
| 1639 | sess, | |
| 1640 | real_source_base_dir, | |
| 1641 | sess.opts.unstable_opts.simulate_remapped_rust_src_base.as_deref(), | |
| 1642 | ), | |
| 1643 | ]; | |
| 1638 | 1644 | |
| 1639 | debug!( | |
| 1640 | "try_to_translate_virtual_to_real(name={:?}): \ | |
| 1641 | virtual_rust_source_base_dir={:?}, real_rust_source_base_dir={:?}", | |
| 1642 | name, virtual_rust_source_base_dir, sess.opts.real_rust_source_base_dir, | |
| 1643 | ); | |
| 1645 | debug!( | |
| 1646 | "try_to_translate_virtual_to_real(name={:?}): \ | |
| 1647 | virtual_source_base_dir={:?}, real_source_base_dir={:?}", | |
| 1648 | name, virtual_source_base_dir, real_source_base_dir, | |
| 1649 | ); | |
| 1644 | 1650 | |
| 1645 | for virtual_dir in virtual_rust_source_base_dir.iter().flatten() { | |
| 1646 | if let Some(real_dir) = &sess.opts.real_rust_source_base_dir | |
| 1651 | for virtual_dir in virtual_source_base_dir.iter().flatten() { | |
| 1652 | if let Some(real_dir) = &real_source_base_dir | |
| 1653 | && let rustc_span::FileName::Real(old_name) = name | |
| 1654 | && let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } = | |
| 1655 | old_name | |
| 1656 | && let Ok(rest) = virtual_name.strip_prefix(virtual_dir) | |
| 1657 | { | |
| 1658 | let new_path = real_dir.join(rest); | |
| 1659 | ||
| 1660 | debug!( | |
| 1661 | "try_to_translate_virtual_to_real: `{}` -> `{}`", | |
| 1662 | virtual_name.display(), | |
| 1663 | new_path.display(), | |
| 1664 | ); | |
| 1665 | ||
| 1666 | // Check if the translated real path is affected by any user-requested | |
| 1667 | // remaps via --remap-path-prefix. Apply them if so. | |
| 1668 | // Note that this is a special case for imported rust-src paths specified by | |
| 1669 | // https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths. | |
| 1670 | // Other imported paths are not currently remapped (see #66251). | |
| 1671 | let (user_remapped, applied) = | |
| 1672 | sess.source_map().path_mapping().map_prefix(&new_path); | |
| 1673 | let new_name = if applied { | |
| 1674 | rustc_span::RealFileName::Remapped { | |
| 1675 | local_path: Some(new_path.clone()), | |
| 1676 | virtual_name: user_remapped.to_path_buf(), | |
| 1677 | } | |
| 1678 | } else { | |
| 1679 | rustc_span::RealFileName::LocalPath(new_path) | |
| 1680 | }; | |
| 1681 | *old_name = new_name; | |
| 1682 | } | |
| 1683 | } | |
| 1684 | }; | |
| 1685 | ||
| 1686 | let try_to_translate_real_to_virtual = | |
| 1687 | |virtual_source_base_dir: Option<&str>, | |
| 1688 | real_source_base_dir: &Option<PathBuf>, | |
| 1689 | subdir: &str, | |
| 1690 | name: &mut rustc_span::FileName| { | |
| 1691 | if let Some(virtual_dir) = &sess.opts.unstable_opts.simulate_remapped_rust_src_base | |
| 1692 | && let Some(real_dir) = real_source_base_dir | |
| 1647 | 1693 | && let rustc_span::FileName::Real(old_name) = name |
| 1648 | && let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } = | |
| 1649 | old_name | |
| 1650 | && let Ok(rest) = virtual_name.strip_prefix(virtual_dir) | |
| 1651 | 1694 | { |
| 1652 | let new_path = real_dir.join(rest); | |
| 1653 | ||
| 1654 | debug!( | |
| 1655 | "try_to_translate_virtual_to_real: `{}` -> `{}`", | |
| 1656 | virtual_name.display(), | |
| 1657 | new_path.display(), | |
| 1658 | ); | |
| 1659 | ||
| 1660 | // Check if the translated real path is affected by any user-requested | |
| 1661 | // remaps via --remap-path-prefix. Apply them if so. | |
| 1662 | // Note that this is a special case for imported rust-src paths specified by | |
| 1663 | // https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths. | |
| 1664 | // Other imported paths are not currently remapped (see #66251). | |
| 1665 | let (user_remapped, applied) = | |
| 1666 | sess.source_map().path_mapping().map_prefix(&new_path); | |
| 1667 | let new_name = if applied { | |
| 1668 | rustc_span::RealFileName::Remapped { | |
| 1669 | local_path: Some(new_path.clone()), | |
| 1670 | virtual_name: user_remapped.to_path_buf(), | |
| 1695 | let relative_path = match old_name { | |
| 1696 | rustc_span::RealFileName::LocalPath(local) => { | |
| 1697 | local.strip_prefix(real_dir).ok() | |
| 1698 | } | |
| 1699 | rustc_span::RealFileName::Remapped { virtual_name, .. } => { | |
| 1700 | virtual_source_base_dir | |
| 1701 | .and_then(|virtual_dir| virtual_name.strip_prefix(virtual_dir).ok()) | |
| 1671 | 1702 | } |
| 1672 | } else { | |
| 1673 | rustc_span::RealFileName::LocalPath(new_path) | |
| 1674 | 1703 | }; |
| 1675 | *old_name = new_name; | |
| 1704 | debug!( | |
| 1705 | ?relative_path, | |
| 1706 | ?virtual_dir, | |
| 1707 | ?subdir, | |
| 1708 | "simulate_remapped_rust_src_base" | |
| 1709 | ); | |
| 1710 | if let Some(rest) = relative_path.and_then(|p| p.strip_prefix(subdir).ok()) { | |
| 1711 | *old_name = rustc_span::RealFileName::Remapped { | |
| 1712 | local_path: None, | |
| 1713 | virtual_name: virtual_dir.join(subdir).join(rest), | |
| 1714 | }; | |
| 1715 | } | |
| 1676 | 1716 | } |
| 1677 | } | |
| 1678 | }; | |
| 1717 | }; | |
| 1679 | 1718 | |
| 1680 | 1719 | let mut import_info = self.cdata.source_map_import_info.lock(); |
| 1681 | 1720 | for _ in import_info.len()..=(source_file_index as usize) { |
| ... | ... | @@ -1713,36 +1752,45 @@ impl<'a> CrateMetadataRef<'a> { |
| 1713 | 1752 | // This is useful for testing so that tests about the effects of |
| 1714 | 1753 | // `try_to_translate_virtual_to_real` don't have to worry about how the |
| 1715 | 1754 | // compiler is bootstrapped. |
| 1716 | if let Some(virtual_dir) = &sess.opts.unstable_opts.simulate_remapped_rust_src_base | |
| 1717 | && let Some(real_dir) = &sess.opts.real_rust_source_base_dir | |
| 1718 | && let rustc_span::FileName::Real(ref mut old_name) = name | |
| 1719 | { | |
| 1720 | let relative_path = match old_name { | |
| 1721 | rustc_span::RealFileName::LocalPath(local) => { | |
| 1722 | local.strip_prefix(real_dir).ok() | |
| 1723 | } | |
| 1724 | rustc_span::RealFileName::Remapped { virtual_name, .. } => { | |
| 1725 | option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR") | |
| 1726 | .and_then(|virtual_dir| virtual_name.strip_prefix(virtual_dir).ok()) | |
| 1727 | } | |
| 1728 | }; | |
| 1729 | debug!(?relative_path, ?virtual_dir, "simulate_remapped_rust_src_base"); | |
| 1730 | for subdir in ["library", "compiler"] { | |
| 1731 | if let Some(rest) = relative_path.and_then(|p| p.strip_prefix(subdir).ok()) | |
| 1732 | { | |
| 1733 | *old_name = rustc_span::RealFileName::Remapped { | |
| 1734 | local_path: None, // FIXME: maybe we should preserve this? | |
| 1735 | virtual_name: virtual_dir.join(subdir).join(rest), | |
| 1736 | }; | |
| 1737 | break; | |
| 1738 | } | |
| 1739 | } | |
| 1740 | } | |
| 1755 | try_to_translate_real_to_virtual( | |
| 1756 | option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR"), | |
| 1757 | &sess.opts.real_rust_source_base_dir, | |
| 1758 | "library", | |
| 1759 | &mut name, | |
| 1760 | ); | |
| 1761 | ||
| 1762 | // If this file is under $sysroot/lib/rustlib/rustc-src/ | |
| 1763 | // and the user wish to simulate remapping with -Z simulate-remapped-rust-src-base, | |
| 1764 | // then we change `name` to a similar state as if the rust was bootstrapped | |
| 1765 | // with `remap-debuginfo = true`. | |
| 1766 | try_to_translate_real_to_virtual( | |
| 1767 | option_env!("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR"), | |
| 1768 | &sess.opts.real_rustc_dev_source_base_dir, | |
| 1769 | "compiler", | |
| 1770 | &mut name, | |
| 1771 | ); | |
| 1741 | 1772 | |
| 1742 | 1773 | // If this file's path has been remapped to `/rustc/$hash`, |
| 1743 | // we might be able to reverse that (also see comments above, | |
| 1744 | // on `try_to_translate_virtual_to_real`). | |
| 1745 | try_to_translate_virtual_to_real(&mut name); | |
| 1774 | // we might be able to reverse that. | |
| 1775 | // | |
| 1776 | // NOTE: if you update this, you might need to also update bootstrap's code for generating | |
| 1777 | // the `rust-src` component in `Src::run` in `src/bootstrap/dist.rs`. | |
| 1778 | try_to_translate_virtual_to_real( | |
| 1779 | option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR"), | |
| 1780 | &sess.opts.real_rust_source_base_dir, | |
| 1781 | &mut name, | |
| 1782 | ); | |
| 1783 | ||
| 1784 | // If this file's path has been remapped to `/rustc-dev/$hash`, | |
| 1785 | // we might be able to reverse that. | |
| 1786 | // | |
| 1787 | // NOTE: if you update this, you might need to also update bootstrap's code for generating | |
| 1788 | // the `rustc-dev` component in `Src::run` in `src/bootstrap/dist.rs`. | |
| 1789 | try_to_translate_virtual_to_real( | |
| 1790 | option_env!("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR"), | |
| 1791 | &sess.opts.real_rustc_dev_source_base_dir, | |
| 1792 | &mut name, | |
| 1793 | ); | |
| 1746 | 1794 | |
| 1747 | 1795 | let local_version = sess.source_map().new_imported_source_file( |
| 1748 | 1796 | name, |
compiler/rustc_middle/src/lib.rs+1| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | #![allow(internal_features)] |
| 29 | 29 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 30 | 30 | #![allow(rustc::untranslatable_diagnostic)] |
| 31 | #![cfg_attr(not(bootstrap), allow(rustc::direct_use_of_rustc_type_ir))] | |
| 31 | 32 | #![cfg_attr(not(bootstrap), feature(sized_hierarchy))] |
| 32 | 33 | #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] |
| 33 | 34 | #![doc(rust_logo)] |
compiler/rustc_mir_transform/src/cross_crate_inline.rs+7| ... | ... | @@ -50,6 +50,13 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { |
| 50 | 50 | _ => {} |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | // If the crate is likely to be mostly unused, use cross-crate inlining to defer codegen until | |
| 54 | // the function is referenced, in order to skip codegen for unused functions. This is | |
| 55 | // intentionally after the check for `inline(never)`, so that `inline(never)` wins. | |
| 56 | if tcx.sess.opts.unstable_opts.hint_mostly_unused { | |
| 57 | return true; | |
| 58 | } | |
| 59 | ||
| 53 | 60 | let sig = tcx.fn_sig(def_id).instantiate_identity(); |
| 54 | 61 | for ty in sig.inputs().skip_binder().iter().chain(std::iter::once(&sig.output().skip_binder())) |
| 55 | 62 | { |
compiler/rustc_next_trait_solver/src/lib.rs+1| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | // tidy-alphabetical-start |
| 8 | 8 | #![allow(rustc::usage_of_type_ir_inherent)] |
| 9 | 9 | #![allow(rustc::usage_of_type_ir_traits)] |
| 10 | #![cfg_attr(not(bootstrap), allow(rustc::direct_use_of_rustc_type_ir))] | |
| 10 | 11 | // tidy-alphabetical-end |
| 11 | 12 | |
| 12 | 13 | pub mod canonicalizer; |
compiler/rustc_passes/src/diagnostic_items.rs+2-2| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | //! * Compiler internal types like `Ty` and `TyCtxt` |
| 11 | 11 | |
| 12 | 12 | use rustc_hir::diagnostic_items::DiagnosticItems; |
| 13 | use rustc_hir::{Attribute, OwnerId}; | |
| 13 | use rustc_hir::{Attribute, CRATE_OWNER_ID, OwnerId}; | |
| 14 | 14 | use rustc_middle::query::{LocalCrate, Providers}; |
| 15 | 15 | use rustc_middle::ty::TyCtxt; |
| 16 | 16 | use rustc_span::def_id::{DefId, LOCAL_CRATE}; |
| ... | ... | @@ -67,7 +67,7 @@ fn diagnostic_items(tcx: TyCtxt<'_>, _: LocalCrate) -> DiagnosticItems { |
| 67 | 67 | |
| 68 | 68 | // Collect diagnostic items in this crate. |
| 69 | 69 | let crate_items = tcx.hir_crate_items(()); |
| 70 | for id in crate_items.owners() { | |
| 70 | for id in crate_items.owners().chain(std::iter::once(CRATE_OWNER_ID)) { | |
| 71 | 71 | observe_item(tcx, &mut diagnostic_items, id); |
| 72 | 72 | } |
| 73 | 73 |
compiler/rustc_session/src/config.rs+26-4| ... | ... | @@ -1364,8 +1364,10 @@ impl Default for Options { |
| 1364 | 1364 | cli_forced_local_thinlto_off: false, |
| 1365 | 1365 | remap_path_prefix: Vec::new(), |
| 1366 | 1366 | real_rust_source_base_dir: None, |
| 1367 | real_rustc_dev_source_base_dir: None, | |
| 1367 | 1368 | edition: DEFAULT_EDITION, |
| 1368 | 1369 | json_artifact_notifications: false, |
| 1370 | json_timings: false, | |
| 1369 | 1371 | json_unused_externs: JsonUnusedExterns::No, |
| 1370 | 1372 | json_future_incompat: false, |
| 1371 | 1373 | pretty: None, |
| ... | ... | @@ -1880,6 +1882,9 @@ pub struct JsonConfig { |
| 1880 | 1882 | pub json_rendered: HumanReadableErrorType, |
| 1881 | 1883 | pub json_color: ColorConfig, |
| 1882 | 1884 | json_artifact_notifications: bool, |
| 1885 | /// Output start and end timestamps of several high-level compilation sections | |
| 1886 | /// (frontend, backend, linker). | |
| 1887 | json_timings: bool, | |
| 1883 | 1888 | pub json_unused_externs: JsonUnusedExterns, |
| 1884 | 1889 | json_future_incompat: bool, |
| 1885 | 1890 | } |
| ... | ... | @@ -1921,6 +1926,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json |
| 1921 | 1926 | let mut json_artifact_notifications = false; |
| 1922 | 1927 | let mut json_unused_externs = JsonUnusedExterns::No; |
| 1923 | 1928 | let mut json_future_incompat = false; |
| 1929 | let mut json_timings = false; | |
| 1924 | 1930 | for option in matches.opt_strs("json") { |
| 1925 | 1931 | // For now conservatively forbid `--color` with `--json` since `--json` |
| 1926 | 1932 | // won't actually be emitting any colors and anything colorized is |
| ... | ... | @@ -1937,6 +1943,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json |
| 1937 | 1943 | } |
| 1938 | 1944 | "diagnostic-rendered-ansi" => json_color = ColorConfig::Always, |
| 1939 | 1945 | "artifacts" => json_artifact_notifications = true, |
| 1946 | "timings" => json_timings = true, | |
| 1940 | 1947 | "unused-externs" => json_unused_externs = JsonUnusedExterns::Loud, |
| 1941 | 1948 | "unused-externs-silent" => json_unused_externs = JsonUnusedExterns::Silent, |
| 1942 | 1949 | "future-incompat" => json_future_incompat = true, |
| ... | ... | @@ -1949,6 +1956,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json |
| 1949 | 1956 | json_rendered, |
| 1950 | 1957 | json_color, |
| 1951 | 1958 | json_artifact_notifications, |
| 1959 | json_timings, | |
| 1952 | 1960 | json_unused_externs, |
| 1953 | 1961 | json_future_incompat, |
| 1954 | 1962 | } |
| ... | ... | @@ -2476,6 +2484,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2476 | 2484 | json_rendered, |
| 2477 | 2485 | json_color, |
| 2478 | 2486 | json_artifact_notifications, |
| 2487 | json_timings, | |
| 2479 | 2488 | json_unused_externs, |
| 2480 | 2489 | json_future_incompat, |
| 2481 | 2490 | } = parse_json(early_dcx, matches); |
| ... | ... | @@ -2497,6 +2506,10 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2497 | 2506 | let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut target_modifiers); |
| 2498 | 2507 | let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches); |
| 2499 | 2508 | |
| 2509 | if !unstable_opts.unstable_options && json_timings { | |
| 2510 | early_dcx.early_fatal("--json=timings is unstable and requires using `-Zunstable-options`"); | |
| 2511 | } | |
| 2512 | ||
| 2500 | 2513 | check_error_format_stability(early_dcx, &unstable_opts, error_format); |
| 2501 | 2514 | |
| 2502 | 2515 | let output_types = parse_output_types(early_dcx, &unstable_opts, matches); |
| ... | ... | @@ -2701,9 +2714,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2701 | 2714 | |
| 2702 | 2715 | let sysroot = filesearch::materialize_sysroot(sysroot_opt); |
| 2703 | 2716 | |
| 2704 | let real_rust_source_base_dir = { | |
| 2705 | // This is the location used by the `rust-src` `rustup` component. | |
| 2706 | let mut candidate = sysroot.join("lib/rustlib/src/rust"); | |
| 2717 | let real_source_base_dir = |suffix: &str, confirm: &str| { | |
| 2718 | let mut candidate = sysroot.join(suffix); | |
| 2707 | 2719 | if let Ok(metadata) = candidate.symlink_metadata() { |
| 2708 | 2720 | // Replace the symlink bootstrap creates, with its destination. |
| 2709 | 2721 | // We could try to use `fs::canonicalize` instead, but that might |
| ... | ... | @@ -2716,9 +2728,17 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2716 | 2728 | } |
| 2717 | 2729 | |
| 2718 | 2730 | // Only use this directory if it has a file we can expect to always find. |
| 2719 | candidate.join("library/std/src/lib.rs").is_file().then_some(candidate) | |
| 2731 | candidate.join(confirm).is_file().then_some(candidate) | |
| 2720 | 2732 | }; |
| 2721 | 2733 | |
| 2734 | let real_rust_source_base_dir = | |
| 2735 | // This is the location used by the `rust-src` `rustup` component. | |
| 2736 | real_source_base_dir("lib/rustlib/src/rust", "library/std/src/lib.rs"); | |
| 2737 | ||
| 2738 | let real_rustc_dev_source_base_dir = | |
| 2739 | // This is the location used by the `rustc-dev` `rustup` component. | |
| 2740 | real_source_base_dir("lib/rustlib/rustc-src/rust", "compiler/rustc/src/main.rs"); | |
| 2741 | ||
| 2722 | 2742 | let mut search_paths = vec![]; |
| 2723 | 2743 | for s in &matches.opt_strs("L") { |
| 2724 | 2744 | search_paths.push(SearchPath::from_cli_opt( |
| ... | ... | @@ -2772,8 +2792,10 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M |
| 2772 | 2792 | cli_forced_local_thinlto_off: disable_local_thinlto, |
| 2773 | 2793 | remap_path_prefix, |
| 2774 | 2794 | real_rust_source_base_dir, |
| 2795 | real_rustc_dev_source_base_dir, | |
| 2775 | 2796 | edition, |
| 2776 | 2797 | json_artifact_notifications, |
| 2798 | json_timings, | |
| 2777 | 2799 | json_unused_externs, |
| 2778 | 2800 | json_future_incompat, |
| 2779 | 2801 | pretty, |
compiler/rustc_session/src/options.rs+19-3| ... | ... | @@ -395,21 +395,35 @@ top_level_options!( |
| 395 | 395 | |
| 396 | 396 | /// Remap source path prefixes in all output (messages, object files, debug, etc.). |
| 397 | 397 | remap_path_prefix: Vec<(PathBuf, PathBuf)> [TRACKED_NO_CRATE_HASH], |
| 398 | /// Base directory containing the `src/` for the Rust standard library, and | |
| 399 | /// potentially `rustc` as well, if we can find it. Right now it's always | |
| 400 | /// `$sysroot/lib/rustlib/src/rust` (i.e. the `rustup` `rust-src` component). | |
| 398 | ||
| 399 | /// Base directory containing the `library/` directory for the Rust standard library. | |
| 400 | /// Right now it's always `$sysroot/lib/rustlib/src/rust` | |
| 401 | /// (i.e. the `rustup` `rust-src` component). | |
| 401 | 402 | /// |
| 402 | 403 | /// This directory is what the virtual `/rustc/$hash` is translated back to, |
| 403 | 404 | /// if Rust was built with path remapping to `/rustc/$hash` enabled |
| 404 | 405 | /// (the `rust.remap-debuginfo` option in `bootstrap.toml`). |
| 405 | 406 | real_rust_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH], |
| 406 | 407 | |
| 408 | /// Base directory containing the `compiler/` directory for the rustc sources. | |
| 409 | /// Right now it's always `$sysroot/lib/rustlib/rustc-src/rust` | |
| 410 | /// (i.e. the `rustup` `rustc-dev` component). | |
| 411 | /// | |
| 412 | /// This directory is what the virtual `/rustc-dev/$hash` is translated back to, | |
| 413 | /// if Rust was built with path remapping to `/rustc/$hash` enabled | |
| 414 | /// (the `rust.remap-debuginfo` option in `bootstrap.toml`). | |
| 415 | real_rustc_dev_source_base_dir: Option<PathBuf> [TRACKED_NO_CRATE_HASH], | |
| 416 | ||
| 407 | 417 | edition: Edition [TRACKED], |
| 408 | 418 | |
| 409 | 419 | /// `true` if we're emitting JSON blobs about each artifact produced |
| 410 | 420 | /// by the compiler. |
| 411 | 421 | json_artifact_notifications: bool [TRACKED], |
| 412 | 422 | |
| 423 | /// `true` if we're emitting JSON timings with the start and end of | |
| 424 | /// high-level compilation sections | |
| 425 | json_timings: bool [UNTRACKED], | |
| 426 | ||
| 413 | 427 | /// `true` if we're emitting a JSON blob containing the unused externs |
| 414 | 428 | json_unused_externs: JsonUnusedExterns [UNTRACKED], |
| 415 | 429 | |
| ... | ... | @@ -2235,6 +2249,8 @@ options! { |
| 2235 | 2249 | environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"), |
| 2236 | 2250 | has_thread_local: Option<bool> = (None, parse_opt_bool, [TRACKED], |
| 2237 | 2251 | "explicitly enable the `cfg(target_thread_local)` directive"), |
| 2252 | hint_mostly_unused: bool = (false, parse_bool, [TRACKED], | |
| 2253 | "hint that most of this crate will go unused, to minimize work for uncalled functions"), | |
| 2238 | 2254 | human_readable_cgu_names: bool = (false, parse_bool, [TRACKED], |
| 2239 | 2255 | "generate human-readable, predictable names for codegen units (default: no)"), |
| 2240 | 2256 | identify_regions: bool = (false, parse_bool, [UNTRACKED], |
compiler/rustc_session/src/session.rs+7| ... | ... | @@ -18,6 +18,7 @@ use rustc_errors::emitter::{ |
| 18 | 18 | DynEmitter, HumanEmitter, HumanReadableErrorType, OutputTheme, stderr_destination, |
| 19 | 19 | }; |
| 20 | 20 | use rustc_errors::json::JsonEmitter; |
| 21 | use rustc_errors::timings::TimingSectionHandler; | |
| 21 | 22 | use rustc_errors::{ |
| 22 | 23 | Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, FatalAbort, |
| 23 | 24 | FluentBundle, LazyFallbackBundle, TerminalUrl, fallback_fluent_bundle, |
| ... | ... | @@ -156,6 +157,9 @@ pub struct Session { |
| 156 | 157 | /// Used by `-Z self-profile`. |
| 157 | 158 | pub prof: SelfProfilerRef, |
| 158 | 159 | |
| 160 | /// Used to emit section timings events (enabled by `--json=timings`). | |
| 161 | pub timings: TimingSectionHandler, | |
| 162 | ||
| 159 | 163 | /// Data about code being compiled, gathered during compilation. |
| 160 | 164 | pub code_stats: CodeStats, |
| 161 | 165 | |
| ... | ... | @@ -1126,6 +1130,8 @@ pub fn build_session( |
| 1126 | 1130 | .as_ref() |
| 1127 | 1131 | .map(|_| rng().next_u32().to_base_fixed_len(CASE_INSENSITIVE).to_string()); |
| 1128 | 1132 | |
| 1133 | let timings = TimingSectionHandler::new(sopts.json_timings); | |
| 1134 | ||
| 1129 | 1135 | let sess = Session { |
| 1130 | 1136 | target, |
| 1131 | 1137 | host, |
| ... | ... | @@ -1136,6 +1142,7 @@ pub fn build_session( |
| 1136 | 1142 | io, |
| 1137 | 1143 | incr_comp_session: RwLock::new(IncrCompSession::NotInitialized), |
| 1138 | 1144 | prof, |
| 1145 | timings, | |
| 1139 | 1146 | code_stats: Default::default(), |
| 1140 | 1147 | lint_store: None, |
| 1141 | 1148 | driver_lint_caps, |
compiler/rustc_span/src/symbol.rs+1| ... | ... | @@ -2183,6 +2183,7 @@ symbols! { |
| 2183 | 2183 | type_changing_struct_update, |
| 2184 | 2184 | type_const, |
| 2185 | 2185 | type_id, |
| 2186 | type_ir, | |
| 2186 | 2187 | type_ir_infer_ctxt_like, |
| 2187 | 2188 | type_ir_inherent, |
| 2188 | 2189 | type_ir_interner, |
compiler/rustc_type_ir/src/lib.rs+2| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | #![cfg_attr(feature = "nightly", rustc_diagnostic_item = "type_ir")] | |
| 1 | 2 | // tidy-alphabetical-start |
| 2 | 3 | #![allow(rustc::usage_of_ty_tykind)] |
| 3 | 4 | #![allow(rustc::usage_of_type_ir_inherent)] |
| ... | ... | @@ -7,6 +8,7 @@ |
| 7 | 8 | feature(associated_type_defaults, never_type, rustc_attrs, negative_impls) |
| 8 | 9 | )] |
| 9 | 10 | #![cfg_attr(feature = "nightly", allow(internal_features))] |
| 11 | #![cfg_attr(not(bootstrap), allow(rustc::direct_use_of_rustc_type_ir))] | |
| 10 | 12 | // tidy-alphabetical-end |
| 11 | 13 | |
| 12 | 14 | extern crate self as rustc_type_ir; |
library/core/src/ascii.rs+6-10| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | |
| 10 | 10 | #![stable(feature = "core_ascii", since = "1.26.0")] |
| 11 | 11 | |
| 12 | use crate::escape::{AlwaysEscaped, EscapeIterInner}; | |
| 13 | use crate::fmt; | |
| 12 | 14 | use crate::iter::FusedIterator; |
| 13 | 15 | use crate::num::NonZero; |
| 14 | use crate::{escape, fmt}; | |
| 15 | 16 | |
| 16 | 17 | mod ascii_char; |
| 17 | 18 | #[unstable(feature = "ascii_char", issue = "110998")] |
| ... | ... | @@ -24,7 +25,7 @@ pub use ascii_char::AsciiChar as Char; |
| 24 | 25 | #[must_use = "iterators are lazy and do nothing unless consumed"] |
| 25 | 26 | #[stable(feature = "rust1", since = "1.0.0")] |
| 26 | 27 | #[derive(Clone)] |
| 27 | pub struct EscapeDefault(escape::EscapeIterInner<4>); | |
| 28 | pub struct EscapeDefault(EscapeIterInner<4, AlwaysEscaped>); | |
| 28 | 29 | |
| 29 | 30 | /// Returns an iterator that produces an escaped version of a `u8`. |
| 30 | 31 | /// |
| ... | ... | @@ -96,17 +97,12 @@ pub fn escape_default(c: u8) -> EscapeDefault { |
| 96 | 97 | impl EscapeDefault { |
| 97 | 98 | #[inline] |
| 98 | 99 | pub(crate) const fn new(c: u8) -> Self { |
| 99 | Self(escape::EscapeIterInner::ascii(c)) | |
| 100 | Self(EscapeIterInner::ascii(c)) | |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | #[inline] |
| 103 | 104 | pub(crate) fn empty() -> Self { |
| 104 | Self(escape::EscapeIterInner::empty()) | |
| 105 | } | |
| 106 | ||
| 107 | #[inline] | |
| 108 | pub(crate) fn as_str(&self) -> &str { | |
| 109 | self.0.as_str() | |
| 105 | Self(EscapeIterInner::empty()) | |
| 110 | 106 | } |
| 111 | 107 | } |
| 112 | 108 | |
| ... | ... | @@ -168,7 +164,7 @@ impl FusedIterator for EscapeDefault {} |
| 168 | 164 | #[stable(feature = "ascii_escape_display", since = "1.39.0")] |
| 169 | 165 | impl fmt::Display for EscapeDefault { |
| 170 | 166 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 171 | f.write_str(self.0.as_str()) | |
| 167 | fmt::Display::fmt(&self.0, f) | |
| 172 | 168 | } |
| 173 | 169 | } |
| 174 | 170 |
library/core/src/char/mod.rs+19-43| ... | ... | @@ -44,7 +44,7 @@ pub use self::methods::{encode_utf8_raw, encode_utf8_raw_unchecked}; // perma-un |
| 44 | 44 | use crate::ascii; |
| 45 | 45 | pub(crate) use self::methods::EscapeDebugExtArgs; |
| 46 | 46 | use crate::error::Error; |
| 47 | use crate::escape; | |
| 47 | use crate::escape::{AlwaysEscaped, EscapeIterInner, MaybeEscaped}; | |
| 48 | 48 | use crate::fmt::{self, Write}; |
| 49 | 49 | use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; |
| 50 | 50 | use crate::num::NonZero; |
| ... | ... | @@ -161,12 +161,12 @@ pub const fn from_digit(num: u32, radix: u32) -> Option<char> { |
| 161 | 161 | /// [`escape_unicode`]: char::escape_unicode |
| 162 | 162 | #[derive(Clone, Debug)] |
| 163 | 163 | #[stable(feature = "rust1", since = "1.0.0")] |
| 164 | pub struct EscapeUnicode(escape::EscapeIterInner<10>); | |
| 164 | pub struct EscapeUnicode(EscapeIterInner<10, AlwaysEscaped>); | |
| 165 | 165 | |
| 166 | 166 | impl EscapeUnicode { |
| 167 | 167 | #[inline] |
| 168 | 168 | const fn new(c: char) -> Self { |
| 169 | Self(escape::EscapeIterInner::unicode(c)) | |
| 169 | Self(EscapeIterInner::unicode(c)) | |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| ... | ... | @@ -215,7 +215,7 @@ impl FusedIterator for EscapeUnicode {} |
| 215 | 215 | #[stable(feature = "char_struct_display", since = "1.16.0")] |
| 216 | 216 | impl fmt::Display for EscapeUnicode { |
| 217 | 217 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 218 | f.write_str(self.0.as_str()) | |
| 218 | fmt::Display::fmt(&self.0, f) | |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| ... | ... | @@ -227,22 +227,22 @@ impl fmt::Display for EscapeUnicode { |
| 227 | 227 | /// [`escape_default`]: char::escape_default |
| 228 | 228 | #[derive(Clone, Debug)] |
| 229 | 229 | #[stable(feature = "rust1", since = "1.0.0")] |
| 230 | pub struct EscapeDefault(escape::EscapeIterInner<10>); | |
| 230 | pub struct EscapeDefault(EscapeIterInner<10, AlwaysEscaped>); | |
| 231 | 231 | |
| 232 | 232 | impl EscapeDefault { |
| 233 | 233 | #[inline] |
| 234 | 234 | const fn printable(c: ascii::Char) -> Self { |
| 235 | Self(escape::EscapeIterInner::ascii(c.to_u8())) | |
| 235 | Self(EscapeIterInner::ascii(c.to_u8())) | |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | #[inline] |
| 239 | 239 | const fn backslash(c: ascii::Char) -> Self { |
| 240 | Self(escape::EscapeIterInner::backslash(c)) | |
| 240 | Self(EscapeIterInner::backslash(c)) | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | #[inline] |
| 244 | 244 | const fn unicode(c: char) -> Self { |
| 245 | Self(escape::EscapeIterInner::unicode(c)) | |
| 245 | Self(EscapeIterInner::unicode(c)) | |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| ... | ... | @@ -290,8 +290,9 @@ impl FusedIterator for EscapeDefault {} |
| 290 | 290 | |
| 291 | 291 | #[stable(feature = "char_struct_display", since = "1.16.0")] |
| 292 | 292 | impl fmt::Display for EscapeDefault { |
| 293 | #[inline] | |
| 293 | 294 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 294 | f.write_str(self.0.as_str()) | |
| 295 | fmt::Display::fmt(&self.0, f) | |
| 295 | 296 | } |
| 296 | 297 | } |
| 297 | 298 | |
| ... | ... | @@ -303,37 +304,22 @@ impl fmt::Display for EscapeDefault { |
| 303 | 304 | /// [`escape_debug`]: char::escape_debug |
| 304 | 305 | #[stable(feature = "char_escape_debug", since = "1.20.0")] |
| 305 | 306 | #[derive(Clone, Debug)] |
| 306 | pub struct EscapeDebug(EscapeDebugInner); | |
| 307 | ||
| 308 | #[derive(Clone, Debug)] | |
| 309 | // Note: It’s possible to manually encode the EscapeDebugInner inside of | |
| 310 | // EscapeIterInner (e.g. with alive=254..255 indicating that data[0..4] holds | |
| 311 | // a char) which would likely result in a more optimised code. For now we use | |
| 312 | // the option easier to implement. | |
| 313 | enum EscapeDebugInner { | |
| 314 | Bytes(escape::EscapeIterInner<10>), | |
| 315 | Char(char), | |
| 316 | } | |
| 307 | pub struct EscapeDebug(EscapeIterInner<10, MaybeEscaped>); | |
| 317 | 308 | |
| 318 | 309 | impl EscapeDebug { |
| 319 | 310 | #[inline] |
| 320 | 311 | const fn printable(chr: char) -> Self { |
| 321 | Self(EscapeDebugInner::Char(chr)) | |
| 312 | Self(EscapeIterInner::printable(chr)) | |
| 322 | 313 | } |
| 323 | 314 | |
| 324 | 315 | #[inline] |
| 325 | 316 | const fn backslash(c: ascii::Char) -> Self { |
| 326 | Self(EscapeDebugInner::Bytes(escape::EscapeIterInner::backslash(c))) | |
| 317 | Self(EscapeIterInner::backslash(c)) | |
| 327 | 318 | } |
| 328 | 319 | |
| 329 | 320 | #[inline] |
| 330 | 321 | const fn unicode(c: char) -> Self { |
| 331 | Self(EscapeDebugInner::Bytes(escape::EscapeIterInner::unicode(c))) | |
| 332 | } | |
| 333 | ||
| 334 | #[inline] | |
| 335 | fn clear(&mut self) { | |
| 336 | self.0 = EscapeDebugInner::Bytes(escape::EscapeIterInner::empty()); | |
| 322 | Self(EscapeIterInner::unicode(c)) | |
| 337 | 323 | } |
| 338 | 324 | } |
| 339 | 325 | |
| ... | ... | @@ -343,13 +329,7 @@ impl Iterator for EscapeDebug { |
| 343 | 329 | |
| 344 | 330 | #[inline] |
| 345 | 331 | fn next(&mut self) -> Option<char> { |
| 346 | match self.0 { | |
| 347 | EscapeDebugInner::Bytes(ref mut bytes) => bytes.next().map(char::from), | |
| 348 | EscapeDebugInner::Char(chr) => { | |
| 349 | self.clear(); | |
| 350 | Some(chr) | |
| 351 | } | |
| 352 | } | |
| 332 | self.0.next() | |
| 353 | 333 | } |
| 354 | 334 | |
| 355 | 335 | #[inline] |
| ... | ... | @@ -367,10 +347,7 @@ impl Iterator for EscapeDebug { |
| 367 | 347 | #[stable(feature = "char_escape_debug", since = "1.20.0")] |
| 368 | 348 | impl ExactSizeIterator for EscapeDebug { |
| 369 | 349 | fn len(&self) -> usize { |
| 370 | match &self.0 { | |
| 371 | EscapeDebugInner::Bytes(bytes) => bytes.len(), | |
| 372 | EscapeDebugInner::Char(_) => 1, | |
| 373 | } | |
| 350 | self.0.len() | |
| 374 | 351 | } |
| 375 | 352 | } |
| 376 | 353 | |
| ... | ... | @@ -379,11 +356,9 @@ impl FusedIterator for EscapeDebug {} |
| 379 | 356 | |
| 380 | 357 | #[stable(feature = "char_escape_debug", since = "1.20.0")] |
| 381 | 358 | impl fmt::Display for EscapeDebug { |
| 359 | #[inline] | |
| 382 | 360 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 383 | match &self.0 { | |
| 384 | EscapeDebugInner::Bytes(bytes) => f.write_str(bytes.as_str()), | |
| 385 | EscapeDebugInner::Char(chr) => f.write_char(*chr), | |
| 386 | } | |
| 361 | fmt::Display::fmt(&self.0, f) | |
| 387 | 362 | } |
| 388 | 363 | } |
| 389 | 364 | |
| ... | ... | @@ -480,6 +455,7 @@ macro_rules! casemappingiter_impls { |
| 480 | 455 | |
| 481 | 456 | #[stable(feature = "char_struct_display", since = "1.16.0")] |
| 482 | 457 | impl fmt::Display for $ITER_NAME { |
| 458 | #[inline] | |
| 483 | 459 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 484 | 460 | fmt::Display::fmt(&self.0, f) |
| 485 | 461 | } |
library/core/src/escape.rs+184-38| ... | ... | @@ -1,11 +1,16 @@ |
| 1 | 1 | //! Helper code for character escaping. |
| 2 | 2 | |
| 3 | 3 | use crate::ascii; |
| 4 | use crate::fmt::{self, Write}; | |
| 5 | use crate::marker::PhantomData; | |
| 4 | 6 | use crate::num::NonZero; |
| 5 | 7 | use crate::ops::Range; |
| 6 | 8 | |
| 7 | 9 | const HEX_DIGITS: [ascii::Char; 16] = *b"0123456789abcdef".as_ascii().unwrap(); |
| 8 | 10 | |
| 11 | /// Escapes a character with `\x` representation. | |
| 12 | /// | |
| 13 | /// Returns a buffer with the escaped representation and its corresponding range. | |
| 9 | 14 | #[inline] |
| 10 | 15 | const fn backslash<const N: usize>(a: ascii::Char) -> ([ascii::Char; N], Range<u8>) { |
| 11 | 16 | const { assert!(N >= 2) }; |
| ... | ... | @@ -18,6 +23,9 @@ const fn backslash<const N: usize>(a: ascii::Char) -> ([ascii::Char; N], Range<u |
| 18 | 23 | (output, 0..2) |
| 19 | 24 | } |
| 20 | 25 | |
| 26 | /// Escapes a character with `\xNN` representation. | |
| 27 | /// | |
| 28 | /// Returns a buffer with the escaped representation and its corresponding range. | |
| 21 | 29 | #[inline] |
| 22 | 30 | const fn hex_escape<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>) { |
| 23 | 31 | const { assert!(N >= 4) }; |
| ... | ... | @@ -35,6 +43,7 @@ const fn hex_escape<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>) { |
| 35 | 43 | (output, 0..4) |
| 36 | 44 | } |
| 37 | 45 | |
| 46 | /// Returns a buffer with the verbatim character and its corresponding range. | |
| 38 | 47 | #[inline] |
| 39 | 48 | const fn verbatim<const N: usize>(a: ascii::Char) -> ([ascii::Char; N], Range<u8>) { |
| 40 | 49 | const { assert!(N >= 1) }; |
| ... | ... | @@ -48,7 +57,7 @@ const fn verbatim<const N: usize>(a: ascii::Char) -> ([ascii::Char; N], Range<u8 |
| 48 | 57 | |
| 49 | 58 | /// Escapes an ASCII character. |
| 50 | 59 | /// |
| 51 | /// Returns a buffer and the length of the escaped representation. | |
| 60 | /// Returns a buffer with the escaped representation and its corresponding range. | |
| 52 | 61 | const fn escape_ascii<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>) { |
| 53 | 62 | const { assert!(N >= 4) }; |
| 54 | 63 | |
| ... | ... | @@ -122,9 +131,9 @@ const fn escape_ascii<const N: usize>(byte: u8) -> ([ascii::Char; N], Range<u8>) |
| 122 | 131 | } |
| 123 | 132 | } |
| 124 | 133 | |
| 125 | /// Escapes a character `\u{NNNN}` representation. | |
| 134 | /// Escapes a character with `\u{NNNN}` representation. | |
| 126 | 135 | /// |
| 127 | /// Returns a buffer and the length of the escaped representation. | |
| 136 | /// Returns a buffer with the escaped representation and its corresponding range. | |
| 128 | 137 | const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8>) { |
| 129 | 138 | const { assert!(N >= 10 && N < u8::MAX as usize) }; |
| 130 | 139 | |
| ... | ... | @@ -149,77 +158,214 @@ const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8> |
| 149 | 158 | (output, (start as u8)..(N as u8)) |
| 150 | 159 | } |
| 151 | 160 | |
| 152 | /// An iterator over an fixed-size array. | |
| 153 | /// | |
| 154 | /// This is essentially equivalent to array’s IntoIter except that indexes are | |
| 155 | /// limited to u8 to reduce size of the structure. | |
| 156 | #[derive(Clone, Debug)] | |
| 157 | pub(crate) struct EscapeIterInner<const N: usize> { | |
| 158 | // The element type ensures this is always ASCII, and thus also valid UTF-8. | |
| 159 | data: [ascii::Char; N], | |
| 160 | ||
| 161 | // Invariant: `alive.start <= alive.end <= N` | |
| 161 | #[derive(Clone, Copy)] | |
| 162 | union MaybeEscapedCharacter<const N: usize> { | |
| 163 | pub escape_seq: [ascii::Char; N], | |
| 164 | pub literal: char, | |
| 165 | } | |
| 166 | ||
| 167 | /// Marker type to indicate that the character is always escaped, | |
| 168 | /// used to optimize the iterator implementation. | |
| 169 | #[derive(Clone, Copy)] | |
| 170 | #[non_exhaustive] | |
| 171 | pub(crate) struct AlwaysEscaped; | |
| 172 | ||
| 173 | /// Marker type to indicate that the character may be escaped, | |
| 174 | /// used to optimize the iterator implementation. | |
| 175 | #[derive(Clone, Copy)] | |
| 176 | #[non_exhaustive] | |
| 177 | pub(crate) struct MaybeEscaped; | |
| 178 | ||
| 179 | /// An iterator over a possibly escaped character. | |
| 180 | #[derive(Clone)] | |
| 181 | pub(crate) struct EscapeIterInner<const N: usize, ESCAPING> { | |
| 182 | // Invariant: | |
| 183 | // | |
| 184 | // If `alive.end <= Self::LITERAL_ESCAPE_START`, `data` must contain | |
| 185 | // printable ASCII characters in the `alive` range of its `escape_seq` variant. | |
| 186 | // | |
| 187 | // If `alive.end > Self::LITERAL_ESCAPE_START`, `data` must contain a | |
| 188 | // `char` in its `literal` variant, and the `alive` range must have a | |
| 189 | // length of at most `1`. | |
| 190 | data: MaybeEscapedCharacter<N>, | |
| 162 | 191 | alive: Range<u8>, |
| 192 | escaping: PhantomData<ESCAPING>, | |
| 163 | 193 | } |
| 164 | 194 | |
| 165 | impl<const N: usize> EscapeIterInner<N> { | |
| 195 | impl<const N: usize, ESCAPING> EscapeIterInner<N, ESCAPING> { | |
| 196 | const LITERAL_ESCAPE_START: u8 = 128; | |
| 197 | ||
| 198 | /// # Safety | |
| 199 | /// | |
| 200 | /// `data.escape_seq` must contain an escape sequence in the range given by `alive`. | |
| 201 | #[inline] | |
| 202 | const unsafe fn new(data: MaybeEscapedCharacter<N>, alive: Range<u8>) -> Self { | |
| 203 | // Longer escape sequences are not useful given `alive.end` is at most | |
| 204 | // `Self::LITERAL_ESCAPE_START`. | |
| 205 | const { assert!(N < Self::LITERAL_ESCAPE_START as usize) }; | |
| 206 | ||
| 207 | // Check bounds, which implicitly also checks the invariant | |
| 208 | // `alive.end <= Self::LITERAL_ESCAPE_START`. | |
| 209 | debug_assert!(alive.end <= (N + 1) as u8); | |
| 210 | ||
| 211 | Self { data, alive, escaping: PhantomData } | |
| 212 | } | |
| 213 | ||
| 166 | 214 | pub(crate) const fn backslash(c: ascii::Char) -> Self { |
| 167 | let (data, range) = backslash(c); | |
| 168 | Self { data, alive: range } | |
| 215 | let (escape_seq, alive) = backslash(c); | |
| 216 | // SAFETY: `escape_seq` contains an escape sequence in the range given by `alive`. | |
| 217 | unsafe { Self::new(MaybeEscapedCharacter { escape_seq }, alive) } | |
| 169 | 218 | } |
| 170 | 219 | |
| 171 | 220 | pub(crate) const fn ascii(c: u8) -> Self { |
| 172 | let (data, range) = escape_ascii(c); | |
| 173 | Self { data, alive: range } | |
| 221 | let (escape_seq, alive) = escape_ascii(c); | |
| 222 | // SAFETY: `escape_seq` contains an escape sequence in the range given by `alive`. | |
| 223 | unsafe { Self::new(MaybeEscapedCharacter { escape_seq }, alive) } | |
| 174 | 224 | } |
| 175 | 225 | |
| 176 | 226 | pub(crate) const fn unicode(c: char) -> Self { |
| 177 | let (data, range) = escape_unicode(c); | |
| 178 | Self { data, alive: range } | |
| 227 | let (escape_seq, alive) = escape_unicode(c); | |
| 228 | // SAFETY: `escape_seq` contains an escape sequence in the range given by `alive`. | |
| 229 | unsafe { Self::new(MaybeEscapedCharacter { escape_seq }, alive) } | |
| 179 | 230 | } |
| 180 | 231 | |
| 181 | 232 | #[inline] |
| 182 | 233 | pub(crate) const fn empty() -> Self { |
| 183 | Self { data: [ascii::Char::Null; N], alive: 0..0 } | |
| 234 | // SAFETY: `0..0` ensures an empty escape sequence. | |
| 235 | unsafe { Self::new(MaybeEscapedCharacter { escape_seq: [ascii::Char::Null; N] }, 0..0) } | |
| 184 | 236 | } |
| 185 | 237 | |
| 186 | 238 | #[inline] |
| 187 | pub(crate) fn as_ascii(&self) -> &[ascii::Char] { | |
| 188 | // SAFETY: `self.alive` is guaranteed to be a valid range for indexing `self.data`. | |
| 189 | unsafe { | |
| 190 | self.data.get_unchecked(usize::from(self.alive.start)..usize::from(self.alive.end)) | |
| 191 | } | |
| 239 | pub(crate) fn len(&self) -> usize { | |
| 240 | usize::from(self.alive.end - self.alive.start) | |
| 192 | 241 | } |
| 193 | 242 | |
| 194 | 243 | #[inline] |
| 195 | pub(crate) fn as_str(&self) -> &str { | |
| 196 | self.as_ascii().as_str() | |
| 244 | pub(crate) fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> { | |
| 245 | self.alive.advance_by(n) | |
| 197 | 246 | } |
| 198 | 247 | |
| 199 | 248 | #[inline] |
| 200 | pub(crate) fn len(&self) -> usize { | |
| 201 | usize::from(self.alive.end - self.alive.start) | |
| 249 | pub(crate) fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> { | |
| 250 | self.alive.advance_back_by(n) | |
| 251 | } | |
| 252 | ||
| 253 | /// Returns a `char` if `self.data` contains one in its `literal` variant. | |
| 254 | #[inline] | |
| 255 | const fn to_char(&self) -> Option<char> { | |
| 256 | if self.alive.end > Self::LITERAL_ESCAPE_START { | |
| 257 | // SAFETY: We just checked that `self.data` contains a `char` in | |
| 258 | // its `literal` variant. | |
| 259 | return Some(unsafe { self.data.literal }); | |
| 260 | } | |
| 261 | ||
| 262 | None | |
| 202 | 263 | } |
| 203 | 264 | |
| 265 | /// Returns the printable ASCII characters in the `escape_seq` variant of `self.data` | |
| 266 | /// as a string. | |
| 267 | /// | |
| 268 | /// # Safety | |
| 269 | /// | |
| 270 | /// - `self.data` must contain printable ASCII characters in its `escape_seq` variant. | |
| 271 | /// - `self.alive` must be a valid range for `self.data.escape_seq`. | |
| 272 | #[inline] | |
| 273 | unsafe fn to_str_unchecked(&self) -> &str { | |
| 274 | debug_assert!(self.alive.end <= Self::LITERAL_ESCAPE_START); | |
| 275 | ||
| 276 | // SAFETY: The caller guarantees `self.data` contains printable ASCII | |
| 277 | // characters in its `escape_seq` variant, and `self.alive` is | |
| 278 | // a valid range for `self.data.escape_seq`. | |
| 279 | unsafe { | |
| 280 | self.data | |
| 281 | .escape_seq | |
| 282 | .get_unchecked(usize::from(self.alive.start)..usize::from(self.alive.end)) | |
| 283 | .as_str() | |
| 284 | } | |
| 285 | } | |
| 286 | } | |
| 287 | ||
| 288 | impl<const N: usize> EscapeIterInner<N, AlwaysEscaped> { | |
| 204 | 289 | pub(crate) fn next(&mut self) -> Option<u8> { |
| 205 | 290 | let i = self.alive.next()?; |
| 206 | 291 | |
| 207 | // SAFETY: `i` is guaranteed to be a valid index for `self.data`. | |
| 208 | unsafe { Some(self.data.get_unchecked(usize::from(i)).to_u8()) } | |
| 292 | // SAFETY: The `AlwaysEscaped` marker guarantees that `self.data` | |
| 293 | // contains printable ASCII characters in its `escape_seq` | |
| 294 | // variant, and `i` is guaranteed to be a valid index for | |
| 295 | // `self.data.escape_seq`. | |
| 296 | unsafe { Some(self.data.escape_seq.get_unchecked(usize::from(i)).to_u8()) } | |
| 209 | 297 | } |
| 210 | 298 | |
| 211 | 299 | pub(crate) fn next_back(&mut self) -> Option<u8> { |
| 212 | 300 | let i = self.alive.next_back()?; |
| 213 | 301 | |
| 214 | // SAFETY: `i` is guaranteed to be a valid index for `self.data`. | |
| 215 | unsafe { Some(self.data.get_unchecked(usize::from(i)).to_u8()) } | |
| 302 | // SAFETY: The `AlwaysEscaped` marker guarantees that `self.data` | |
| 303 | // contains printable ASCII characters in its `escape_seq` | |
| 304 | // variant, and `i` is guaranteed to be a valid index for | |
| 305 | // `self.data.escape_seq`. | |
| 306 | unsafe { Some(self.data.escape_seq.get_unchecked(usize::from(i)).to_u8()) } | |
| 216 | 307 | } |
| 308 | } | |
| 217 | 309 | |
| 218 | pub(crate) fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> { | |
| 219 | self.alive.advance_by(n) | |
| 310 | impl<const N: usize> EscapeIterInner<N, MaybeEscaped> { | |
| 311 | // This is the only way to create any `EscapeIterInner` containing a `char` in | |
| 312 | // the `literal` variant of its `self.data`, meaning the `AlwaysEscaped` marker | |
| 313 | // guarantees that `self.data` contains printable ASCII characters in its | |
| 314 | // `escape_seq` variant. | |
| 315 | pub(crate) const fn printable(c: char) -> Self { | |
| 316 | Self { | |
| 317 | data: MaybeEscapedCharacter { literal: c }, | |
| 318 | // Uphold the invariant `alive.end > Self::LITERAL_ESCAPE_START`, and ensure | |
| 319 | // `len` behaves correctly for iterating through one character literal. | |
| 320 | alive: Self::LITERAL_ESCAPE_START..(Self::LITERAL_ESCAPE_START + 1), | |
| 321 | escaping: PhantomData, | |
| 322 | } | |
| 220 | 323 | } |
| 221 | 324 | |
| 222 | pub(crate) fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> { | |
| 223 | self.alive.advance_back_by(n) | |
| 325 | pub(crate) fn next(&mut self) -> Option<char> { | |
| 326 | let i = self.alive.next()?; | |
| 327 | ||
| 328 | if let Some(c) = self.to_char() { | |
| 329 | return Some(c); | |
| 330 | } | |
| 331 | ||
| 332 | // SAFETY: At this point, `self.data` must contain printable ASCII | |
| 333 | // characters in its `escape_seq` variant, and `i` is | |
| 334 | // guaranteed to be a valid index for `self.data.escape_seq`. | |
| 335 | Some(char::from(unsafe { self.data.escape_seq.get_unchecked(usize::from(i)).to_u8() })) | |
| 336 | } | |
| 337 | } | |
| 338 | ||
| 339 | impl<const N: usize> fmt::Display for EscapeIterInner<N, AlwaysEscaped> { | |
| 340 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| 341 | // SAFETY: The `AlwaysEscaped` marker guarantees that `self.data` | |
| 342 | // contains printable ASCII chars, and `self.alive` is | |
| 343 | // guaranteed to be a valid range for `self.data`. | |
| 344 | f.write_str(unsafe { self.to_str_unchecked() }) | |
| 345 | } | |
| 346 | } | |
| 347 | ||
| 348 | impl<const N: usize> fmt::Display for EscapeIterInner<N, MaybeEscaped> { | |
| 349 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| 350 | if let Some(c) = self.to_char() { | |
| 351 | return f.write_char(c); | |
| 352 | } | |
| 353 | ||
| 354 | // SAFETY: At this point, `self.data` must contain printable ASCII | |
| 355 | // characters in its `escape_seq` variant, and `self.alive` | |
| 356 | // is guaranteed to be a valid range for `self.data`. | |
| 357 | f.write_str(unsafe { self.to_str_unchecked() }) | |
| 358 | } | |
| 359 | } | |
| 360 | ||
| 361 | impl<const N: usize> fmt::Debug for EscapeIterInner<N, AlwaysEscaped> { | |
| 362 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| 363 | f.debug_tuple("EscapeIterInner").field(&format_args!("'{}'", self)).finish() | |
| 364 | } | |
| 365 | } | |
| 366 | ||
| 367 | impl<const N: usize> fmt::Debug for EscapeIterInner<N, MaybeEscaped> { | |
| 368 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| 369 | f.debug_tuple("EscapeIterInner").field(&format_args!("'{}'", self)).finish() | |
| 224 | 370 | } |
| 225 | 371 | } |
library/core/src/slice/ascii.rs+1-1| ... | ... | @@ -308,7 +308,7 @@ impl<'a> fmt::Display for EscapeAscii<'a> { |
| 308 | 308 | |
| 309 | 309 | if let Some(&b) = bytes.first() { |
| 310 | 310 | // guaranteed to be non-empty, better to write it as a str |
| 311 | f.write_str(ascii::escape_default(b).as_str())?; | |
| 311 | fmt::Display::fmt(&ascii::escape_default(b), f)?; | |
| 312 | 312 | bytes = &bytes[1..]; |
| 313 | 313 | } |
| 314 | 314 | } |
src/doc/rustc-dev-guide/src/tests/ui.md+2| ... | ... | @@ -113,6 +113,8 @@ Compiletest makes the following replacements on the compiler output: |
| 113 | 113 | - The base directory where the test's output goes is replaced with |
| 114 | 114 | `$TEST_BUILD_DIR`. This only comes up in a few rare circumstances. Example: |
| 115 | 115 | `/path/to/rust/build/x86_64-unknown-linux-gnu/test/ui` |
| 116 | - The real directory to the standard library source is replaced with `$SRC_DIR_REAL`. | |
| 117 | - The real directory to the compiler source is replaced with `$COMPILER_DIR_REAL`. | |
| 116 | 118 | - Tabs are replaced with `\t`. |
| 117 | 119 | - Backslashes (`\`) are converted to forward slashes (`/`) within paths (using a |
| 118 | 120 | heuristic). This helps normalize differences with Windows-style paths. |
src/doc/rustc/src/command-line-arguments.md+3| ... | ... | @@ -471,6 +471,9 @@ to customize the output: |
| 471 | 471 | - `future-incompat` - includes a JSON message that contains a report if the |
| 472 | 472 | crate contains any code that may fail to compile in the future. |
| 473 | 473 | |
| 474 | - `timings` - output a JSON message when a certain compilation "section" | |
| 475 | (such as frontend analysis, code generation, linking) begins or ends. | |
| 476 | ||
| 474 | 477 | Note that it is invalid to combine the `--json` argument with the |
| 475 | 478 | [`--color`](#option-color) argument, and it is required to combine `--json` |
| 476 | 479 | with `--error-format=json`. |
src/doc/rustc/src/json.md+29| ... | ... | @@ -298,6 +298,35 @@ appropriately. (This is needed by Cargo which shares the same dependencies |
| 298 | 298 | across multiple build targets, so it should only report an unused dependency if |
| 299 | 299 | its not used by any of the targets.) |
| 300 | 300 | |
| 301 | ## Timings | |
| 302 | ||
| 303 | **This setting is currently unstable and requires usage of `-Zunstable-options`.** | |
| 304 | ||
| 305 | The `--timings` option will tell `rustc` to emit messages when a certain compilation | |
| 306 | section (such as code generation or linking) begins or ends. The messages currently have | |
| 307 | the following format: | |
| 308 | ||
| 309 | ```json | |
| 310 | { | |
| 311 | "$message_type": "section_timing", /* Type of this message */ | |
| 312 | "event": "start", /* Marks the "start" or "end" of the compilation section */ | |
| 313 | "name": "link", /* The name of the compilation section */ | |
| 314 | // Opaque timestamp when the message was emitted, in microseconds | |
| 315 | // The timestamp is currently relative to the beginning of the compilation session | |
| 316 | "time": 12345 | |
| 317 | } | |
| 318 | ``` | |
| 319 | ||
| 320 | Note that the JSON format of the `timings` messages is unstable and subject to change. | |
| 321 | ||
| 322 | Compilation sections can be nested; for example, if you encounter the start of "foo", | |
| 323 | then the start of "bar", then the end of "bar" and then the end of "bar", it means that the | |
| 324 | "bar" section happened as a part of the "foo" section. | |
| 325 | ||
| 326 | The timestamp should only be used for computing the duration of each section. | |
| 327 | ||
| 328 | We currently do not guarantee any specific section names to be emitted. | |
| 329 | ||
| 301 | 330 | [option-emit]: command-line-arguments.md#option-emit |
| 302 | 331 | [option-error-format]: command-line-arguments.md#option-error-format |
| 303 | 332 | [option-json]: command-line-arguments.md#option-json |
src/doc/unstable-book/src/compiler-flags/hint-mostly-unused.md created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | # `hint-mostly-unused` | |
| 2 | ||
| 3 | This flag hints to the compiler that most of the crate will probably go unused. | |
| 4 | The compiler can optimize its operation based on this assumption, in order to | |
| 5 | compile faster. This is a hint, and does not guarantee any particular behavior. | |
| 6 | ||
| 7 | This option can substantially speed up compilation if applied to a large | |
| 8 | dependency where the majority of the dependency does not get used. This flag | |
| 9 | may slow down compilation in other cases. | |
| 10 | ||
| 11 | Currently, this option makes the compiler defer as much code generation as | |
| 12 | possible from functions in the crate, until later crates invoke those | |
| 13 | functions. Functions that never get invoked will never have code generated for | |
| 14 | them. For instance, if a crate provides thousands of functions, but only a few | |
| 15 | of them will get called, this flag will result in the compiler only doing code | |
| 16 | generation for the called functions. (This uses the same mechanisms as | |
| 17 | cross-crate inlining of functions.) This does not affect `extern` functions, or | |
| 18 | functions marked as `#[inline(never)]`. | |
| 19 | ||
| 20 | To try applying this flag to one dependency out of a dependency tree, use the | |
| 21 | [`profile-rustflags`](https://doc.rust-lang.org/cargo/reference/unstable.html#profile-rustflags-option) | |
| 22 | feature of nightly cargo: | |
| 23 | ||
| 24 | ```toml | |
| 25 | cargo-features = ["profile-rustflags"] | |
| 26 | ||
| 27 | # ... | |
| 28 | [dependencies] | |
| 29 | mostly-unused-dependency = "1.2.3" | |
| 30 | ||
| 31 | [profile.release.package.mostly-unused-dependency] | |
| 32 | rustflags = ["-Zhint-mostly-unused"] | |
| 33 | ``` |
src/tools/compiletest/src/runtest.rs+6| ... | ... | @@ -2372,6 +2372,12 @@ impl<'test> TestCx<'test> { |
| 2372 | 2372 | rust_src_dir.read_link_utf8().unwrap_or_else(|_| rust_src_dir.to_path_buf()); |
| 2373 | 2373 | normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL"); |
| 2374 | 2374 | |
| 2375 | // Real paths into the compiler | |
| 2376 | let rustc_src_dir = &self.config.sysroot_base.join("lib/rustlib/rustc-src/rust"); | |
| 2377 | rustc_src_dir.try_exists().expect(&*format!("{} should exists", rustc_src_dir)); | |
| 2378 | let rustc_src_dir = rustc_src_dir.read_link_utf8().unwrap_or(rustc_src_dir.to_path_buf()); | |
| 2379 | normalize_path(&rustc_src_dir.join("compiler"), "$COMPILER_DIR_REAL"); | |
| 2380 | ||
| 2375 | 2381 | // eg. |
| 2376 | 2382 | // /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui/<test_dir>/$name.$revision.$mode/ |
| 2377 | 2383 | normalize_path(&self.output_base_dir(), "$TEST_BUILD_DIR"); |
tests/ui-fulldeps/internal-lints/direct-use-of-rustc-type-ir.rs created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //@ compile-flags: -Z unstable-options | |
| 2 | //@ ignore-stage1 | |
| 3 | ||
| 4 | #![feature(rustc_private)] | |
| 5 | #![deny(rustc::direct_use_of_rustc_type_ir)] | |
| 6 | ||
| 7 | extern crate rustc_middle; | |
| 8 | extern crate rustc_type_ir; | |
| 9 | ||
| 10 | use rustc_middle::ty::*; // OK, we have to accept rustc_middle::ty::* | |
| 11 | ||
| 12 | // We have to deny direct import of type_ir | |
| 13 | use rustc_type_ir::*; | |
| 14 | //~^ ERROR: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 15 | ||
| 16 | // We have to deny direct types usages which resolves to type_ir | |
| 17 | fn foo<I: rustc_type_ir::Interner>(cx: I, did: I::DefId) { | |
| 18 | //~^ ERROR: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 19 | } | |
| 20 | ||
| 21 | fn main() { | |
| 22 | let _ = rustc_type_ir::InferConst::Fresh(42); | |
| 23 | //~^ ERROR: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 24 | let _: rustc_type_ir::InferConst; | |
| 25 | //~^ ERROR: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 26 | } |
tests/ui-fulldeps/internal-lints/direct-use-of-rustc-type-ir.stderr created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | error: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 2 | --> $DIR/direct-use-of-rustc-type-ir.rs:13:5 | |
| 3 | | | |
| 4 | LL | use rustc_type_ir::*; | |
| 5 | | ^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | = note: use `rustc_middle::ty` instead | |
| 8 | note: the lint level is defined here | |
| 9 | --> $DIR/direct-use-of-rustc-type-ir.rs:5:9 | |
| 10 | | | |
| 11 | LL | #![deny(rustc::direct_use_of_rustc_type_ir)] | |
| 12 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 13 | ||
| 14 | error: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 15 | --> $DIR/direct-use-of-rustc-type-ir.rs:17:11 | |
| 16 | | | |
| 17 | LL | fn foo<I: rustc_type_ir::Interner>(cx: I, did: I::DefId) { | |
| 18 | | ^^^^^^^^^^^^^ | |
| 19 | | | |
| 20 | = note: use `rustc_middle::ty` instead | |
| 21 | ||
| 22 | error: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 23 | --> $DIR/direct-use-of-rustc-type-ir.rs:22:13 | |
| 24 | | | |
| 25 | LL | let _ = rustc_type_ir::InferConst::Fresh(42); | |
| 26 | | ^^^^^^^^^^^^^ | |
| 27 | | | |
| 28 | = note: use `rustc_middle::ty` instead | |
| 29 | ||
| 30 | error: do not use `rustc_type_ir` unless you are implementing type system internals | |
| 31 | --> $DIR/direct-use-of-rustc-type-ir.rs:24:12 | |
| 32 | | | |
| 33 | LL | let _: rustc_type_ir::InferConst; | |
| 34 | | ^^^^^^^^^^^^^ | |
| 35 | | | |
| 36 | = note: use `rustc_middle::ty` instead | |
| 37 | ||
| 38 | error: aborting due to 4 previous errors | |
| 39 |
tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | error[E0277]: the trait bound `NotAValidResultType: VisitorResult` is not satisfied | |
| 2 | --> $DIR/rustc-dev-remap.rs:LL:COL | |
| 3 | | | |
| 4 | LL | type Result = NotAValidResultType; | |
| 5 | | ^^^^^^^^^^^^^^^^^^^ the trait `VisitorResult` is not implemented for `NotAValidResultType` | |
| 6 | | | |
| 7 | = help: the following other types implement trait `VisitorResult`: | |
| 8 | () | |
| 9 | ControlFlow<T> | |
| 10 | note: required by a bound in `rustc_ast::visit::Visitor::Result` | |
| 11 | --> /rustc-dev/xyz/compiler/rustc_ast/src/visit.rs:LL:COL | |
| 12 | ||
| 13 | error: aborting due to 1 previous error | |
| 14 | ||
| 15 | For more information about this error, try `rustc --explain E0277`. |
tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | error[E0277]: the trait bound `NotAValidResultType: VisitorResult` is not satisfied | |
| 2 | --> $DIR/rustc-dev-remap.rs:LL:COL | |
| 3 | | | |
| 4 | LL | type Result = NotAValidResultType; | |
| 5 | | ^^^^^^^^^^^^^^^^^^^ the trait `VisitorResult` is not implemented for `NotAValidResultType` | |
| 6 | | | |
| 7 | = help: the following other types implement trait `VisitorResult`: | |
| 8 | () | |
| 9 | ControlFlow<T> | |
| 10 | note: required by a bound in `rustc_ast::visit::Visitor::Result` | |
| 11 | --> $COMPILER_DIR_REAL/rustc_ast/src/visit.rs:LL:COL | |
| 12 | | | |
| 13 | LL | type Result: VisitorResult = (); | |
| 14 | | ^^^^^^^^^^^^^ required by this bound in `Visitor::Result` | |
| 15 | ||
| 16 | error: aborting due to 1 previous error | |
| 17 | ||
| 18 | For more information about this error, try `rustc --explain E0277`. |
tests/ui-fulldeps/rustc-dev-remap.rs created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //@ check-fail | |
| 2 | // | |
| 3 | //@ ignore-stage1 | |
| 4 | //@ ignore-cross-compile | |
| 5 | //@ ignore-remote | |
| 6 | // | |
| 7 | //@ revisions: only-remap remap-unremap | |
| 8 | //@ compile-flags: -Z simulate-remapped-rust-src-base=/rustc-dev/xyz | |
| 9 | //@ [remap-unremap]compile-flags: -Ztranslate-remapped-path-to-local-path=yes | |
| 10 | ||
| 11 | // The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically | |
| 12 | // as the remapped revision will begin with $COMPILER_DIR_REAL, | |
| 13 | // so we have to do it ourselves. | |
| 14 | //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:COL" | |
| 15 | ||
| 16 | #![feature(rustc_private)] | |
| 17 | ||
| 18 | extern crate rustc_ast; | |
| 19 | ||
| 20 | use rustc_ast::visit::Visitor; | |
| 21 | ||
| 22 | struct MyStruct; | |
| 23 | struct NotAValidResultType; | |
| 24 | ||
| 25 | impl Visitor<'_> for MyStruct { | |
| 26 | type Result = NotAValidResultType; | |
| 27 | //~^ ERROR the trait bound `NotAValidResultType: VisitorResult` is not satisfied | |
| 28 | } | |
| 29 | ||
| 30 | fn main() {} |