Skip to content

Commit f3984ce

Browse files
committed
Auto merge of rust-lang#115952 - matthiaskrgr:rollup-qzk8t4e, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#115869 (Avoid blessing cargo deps's source code in ui tests) - rust-lang#115873 (Make `TyKind::Adt`'s `Debug` impl be more pretty) - rust-lang#115879 (Migrate diagnostics in `hir_typeck/src/cast.rs`) - rust-lang#115930 (coverage: Fix an unstable-sort inconsistency in coverage spans) - rust-lang#115931 (Move mobile topbar title creation entirely into JS) - rust-lang#115941 (Add myself to .mailmap) - rust-lang#115943 (compiletest: Don't swallow some error messages.) - rust-lang#115949 (Update browser-ui-test version) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 65ea825 + aa55d7d commit f3984ce

40 files changed

+825
-374
lines changed

.mailmap

+2-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ Kyle J Strand <[email protected]> <[email protected]>
328328
329329
330330
331-
Laurențiu Nicola <[email protected]>
331+
Laurențiu Nicola <[email protected]> Laurentiu Nicola <[email protected]>
332+
332333
333334
Lee Jeffery <[email protected]> Lee Jeffery <[email protected]>
334335
Lee Wondong <[email protected]>

Cargo.lock

+10
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ dependencies = [
662662
"diff",
663663
"getopts",
664664
"glob",
665+
"home",
665666
"lazycell",
666667
"libc",
667668
"miow",
@@ -1663,6 +1664,15 @@ version = "0.4.3"
16631664
source = "registry+https://github.com/rust-lang/crates.io-index"
16641665
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
16651666

1667+
[[package]]
1668+
name = "home"
1669+
version = "0.5.5"
1670+
source = "registry+https://github.com/rust-lang/crates.io-index"
1671+
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
1672+
dependencies = [
1673+
"windows-sys 0.48.0",
1674+
]
1675+
16661676
[[package]]
16671677
name = "html-checker"
16681678
version = "0.1.0"

compiler/rustc_data_structures/src/graph/dominators/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn dominators<G: ControlFlowGraph>(graph: &G) -> Dominators<G::Node> {
5151
// Traverse the graph, collecting a number of things:
5252
//
5353
// * Preorder mapping (to it, and back to the actual ordering)
54-
// * Postorder mapping (used exclusively for rank_partial_cmp on the final product)
54+
// * Postorder mapping (used exclusively for `cmp_in_dominator_order` on the final product)
5555
// * Parents for each vertex in the preorder tree
5656
//
5757
// These are all done here rather than through one of the 'standard'
@@ -342,8 +342,8 @@ impl<Node: Idx> Dominators<Node> {
342342
/// relationship, the dominator will always precede the dominated. (The relative ordering
343343
/// of two unrelated nodes will also be consistent, but otherwise the order has no
344344
/// meaning.) This method cannot be used to determine if either Node dominates the other.
345-
pub fn rank_partial_cmp(&self, lhs: Node, rhs: Node) -> Option<Ordering> {
346-
self.post_order_rank[rhs].partial_cmp(&self.post_order_rank[lhs])
345+
pub fn cmp_in_dominator_order(&self, lhs: Node, rhs: Node) -> Ordering {
346+
self.post_order_rank[rhs].cmp(&self.post_order_rank[lhs])
347347
}
348348

349349
/// Returns true if `a` dominates `b`.

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ impl AnnotateSnippetEmitterWriter {
169169
.map(|line| {
170170
// Ensure the source file is present before we try
171171
// to load a string from it.
172+
// FIXME(#115869): support -Z ignore-directory-in-diagnostics-source-blocks
172173
source_map.ensure_source_file_source_present(&file);
173174
(
174175
format!("{}", source_map.filename_for_diagnostics(&file.name)),

compiler/rustc_errors/src/emitter.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! The output types are defined in `rustc_session::config::ErrorOutputType`.
99
1010
use rustc_span::source_map::SourceMap;
11-
use rustc_span::{FileLines, SourceFile, Span};
11+
use rustc_span::{FileLines, FileName, SourceFile, Span};
1212

1313
use crate::snippet::{
1414
Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString,
@@ -635,6 +635,7 @@ pub struct EmitterWriter {
635635
short_message: bool,
636636
teach: bool,
637637
ui_testing: bool,
638+
ignored_directories_in_source_blocks: Vec<String>,
638639
diagnostic_width: Option<usize>,
639640

640641
macro_backtrace: bool,
@@ -664,6 +665,7 @@ impl EmitterWriter {
664665
short_message: false,
665666
teach: false,
666667
ui_testing: false,
668+
ignored_directories_in_source_blocks: Vec::new(),
667669
diagnostic_width: None,
668670
macro_backtrace: false,
669671
track_diagnostics: false,
@@ -1193,7 +1195,7 @@ impl EmitterWriter {
11931195
let will_be_emitted = |span: Span| {
11941196
!span.is_dummy() && {
11951197
let file = sm.lookup_source_file(span.hi());
1196-
sm.ensure_source_file_source_present(&file)
1198+
should_show_source_code(&self.ignored_directories_in_source_blocks, sm, &file)
11971199
}
11981200
};
11991201

@@ -1388,7 +1390,11 @@ impl EmitterWriter {
13881390
// Print out the annotate source lines that correspond with the error
13891391
for annotated_file in annotated_files {
13901392
// we can't annotate anything if the source is unavailable.
1391-
if !sm.ensure_source_file_source_present(&annotated_file.file) {
1393+
if !should_show_source_code(
1394+
&self.ignored_directories_in_source_blocks,
1395+
sm,
1396+
&annotated_file.file,
1397+
) {
13921398
if !self.short_message {
13931399
// We'll just print an unannotated message.
13941400
for (annotation_id, line) in annotated_file.lines.iter().enumerate() {
@@ -2737,3 +2743,18 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
27372743
// bug, but be defensive against that here.
27382744
&& found != suggested
27392745
}
2746+
2747+
pub(crate) fn should_show_source_code(
2748+
ignored_directories: &[String],
2749+
sm: &SourceMap,
2750+
file: &SourceFile,
2751+
) -> bool {
2752+
if !sm.ensure_source_file_source_present(file) {
2753+
return false;
2754+
}
2755+
2756+
let FileName::Real(name) = &file.name else { return true };
2757+
name.local_path()
2758+
.map(|path| ignored_directories.iter().all(|dir| !path.starts_with(dir)))
2759+
.unwrap_or(true)
2760+
}

compiler/rustc_errors/src/json.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use rustc_span::source_map::{FilePathMapping, SourceMap};
1313
use termcolor::{ColorSpec, WriteColor};
1414

15-
use crate::emitter::{Emitter, HumanReadableErrorType};
15+
use crate::emitter::{should_show_source_code, Emitter, HumanReadableErrorType};
1616
use crate::registry::Registry;
1717
use crate::translation::{to_fluent_args, Translate};
1818
use crate::DiagnosticId;
@@ -45,6 +45,7 @@ pub struct JsonEmitter {
4545
fallback_bundle: LazyFallbackBundle,
4646
pretty: bool,
4747
ui_testing: bool,
48+
ignored_directories_in_source_blocks: Vec<String>,
4849
json_rendered: HumanReadableErrorType,
4950
diagnostic_width: Option<usize>,
5051
macro_backtrace: bool,
@@ -73,6 +74,7 @@ impl JsonEmitter {
7374
fallback_bundle,
7475
pretty,
7576
ui_testing: false,
77+
ignored_directories_in_source_blocks: Vec::new(),
7678
json_rendered,
7779
diagnostic_width,
7880
macro_backtrace,
@@ -127,6 +129,7 @@ impl JsonEmitter {
127129
fallback_bundle,
128130
pretty,
129131
ui_testing: false,
132+
ignored_directories_in_source_blocks: Vec::new(),
130133
json_rendered,
131134
diagnostic_width,
132135
macro_backtrace,
@@ -138,6 +141,10 @@ impl JsonEmitter {
138141
pub fn ui_testing(self, ui_testing: bool) -> Self {
139142
Self { ui_testing, ..self }
140143
}
144+
145+
pub fn ignored_directories_in_source_blocks(self, value: Vec<String>) -> Self {
146+
Self { ignored_directories_in_source_blocks: value, ..self }
147+
}
141148
}
142149

143150
impl Translate for JsonEmitter {
@@ -381,6 +388,7 @@ impl Diagnostic {
381388
.track_diagnostics(je.track_diagnostics)
382389
.terminal_url(je.terminal_url)
383390
.ui_testing(je.ui_testing)
391+
.ignored_directories_in_source_blocks(je.ignored_directories_in_source_blocks.clone())
384392
.emit_diagnostic(diag);
385393
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
386394
let output = String::from_utf8(output).unwrap();
@@ -558,7 +566,11 @@ impl DiagnosticSpanLine {
558566
.span_to_lines(span)
559567
.map(|lines| {
560568
// We can't get any lines if the source is unavailable.
561-
if !je.sm.ensure_source_file_source_present(&lines.file) {
569+
if !should_show_source_code(
570+
&je.ignored_directories_in_source_blocks,
571+
&je.sm,
572+
&lines.file,
573+
) {
562574
return vec![];
563575
}
564576

compiler/rustc_hir_typeck/messages.ftl

+44
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ hir_typeck_candidate_trait_note = `{$trait_name}` defines an item `{$item_name}`
1616
*[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it
1717
}
1818
19+
hir_typeck_cannot_cast_to_bool = cannot cast `{$expr_ty}` as `bool`
20+
.suggestion = compare with zero instead
21+
.help = compare with zero instead
22+
.label = unsupported cast
23+
24+
hir_typeck_cast_enum_drop = cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`
25+
26+
hir_typeck_cast_unknown_pointer = cannot cast {$to ->
27+
[true] to
28+
*[false] from
29+
} a pointer of an unknown kind
30+
.label_to = needs more type information
31+
.note = the type information given here is insufficient to check whether the pointer cast is valid
32+
.label_from = the type information given here is insufficient to check whether the pointer cast is valid
33+
1934
hir_typeck_const_select_must_be_const = this argument must be a `const fn`
2035
.help = consult the documentation on `const_eval_select` for more information
2136
@@ -29,6 +44,8 @@ hir_typeck_convert_using_method = try using `{$sugg}` to convert `{$found}` to `
2944
3045
hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private
3146
47+
hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`
48+
3249
hir_typeck_expected_default_return_type = expected `()` because of default return type
3350
3451
hir_typeck_expected_return_type = expected `{$expected}` because of return type
@@ -57,6 +74,13 @@ hir_typeck_functional_record_update_on_non_struct =
5774
hir_typeck_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
5875
hir_typeck_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
5976
77+
hir_typeck_int_to_fat = cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
78+
[true] is
79+
*[false] may be
80+
} wide
81+
hir_typeck_int_to_fat_label = creating a `{$cast_ty}` requires both an address and {$metadata}
82+
hir_typeck_int_to_fat_label_nightly = consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
83+
6084
hir_typeck_invalid_callee = expected function, found {$ty}
6185
6286
hir_typeck_lang_start_expected_sig_note = the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
@@ -69,6 +93,16 @@ hir_typeck_lang_start_incorrect_param = parameter {$param_num} of the `start` la
6993
hir_typeck_lang_start_incorrect_ret_ty = the return type of the `start` lang item is incorrect
7094
.suggestion = change the type from `{$found_ty}` to `{$expected_ty}`
7195
96+
hir_typeck_lossy_provenance_int2ptr =
97+
strict provenance disallows casting integer `{$expr_ty}` to pointer `{$cast_ty}`
98+
.suggestion = use `.with_addr()` to adjust a valid pointer in the same allocation, to this address
99+
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::from_exposed_addr()` instead
100+
101+
hir_typeck_lossy_provenance_ptr2int =
102+
under strict provenance it is considered bad style to cast pointer `{$expr_ty}` to integer `{$cast_ty}`
103+
.suggestion = use `.addr()` to obtain the address of a pointer
104+
.help = if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
105+
72106
hir_typeck_method_call_on_unknown_raw_pointee =
73107
cannot call a method on a raw pointer with an unknown pointee type
74108
@@ -113,8 +147,18 @@ hir_typeck_suggest_boxing_when_appropriate = store this in the heap by calling `
113147
114148
hir_typeck_suggest_ptr_null_mut = consider using `core::ptr::null_mut` instead
115149
150+
hir_typeck_trivial_cast = trivial {$numeric ->
151+
[true] numeric cast
152+
*[false] cast
153+
}: `{$expr_ty}` as `{$cast_ty}`
154+
.help = cast can be replaced by coercion; this might require a temporary variable
155+
116156
hir_typeck_union_pat_dotdot = `..` cannot be used in union patterns
117157
118158
hir_typeck_union_pat_multiple_fields = union patterns should have exactly one field
159+
160+
hir_typeck_use_is_empty =
161+
consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything
162+
119163
hir_typeck_yield_expr_outside_of_generator =
120164
yield expression outside of generator literal

0 commit comments

Comments
 (0)