Skip to content

Commit

Permalink
Auto merge of #115952 - matthiaskrgr:rollup-qzk8t4e, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #115869 (Avoid blessing cargo deps's source code in ui tests)
 - #115873 (Make `TyKind::Adt`'s `Debug` impl be more pretty)
 - #115879 (Migrate diagnostics in `hir_typeck/src/cast.rs`)
 - #115930 (coverage: Fix an unstable-sort inconsistency in coverage spans)
 - #115931 (Move mobile topbar title creation entirely into JS)
 - #115941 (Add myself to .mailmap)
 - #115943 (compiletest: Don't swallow some error messages.)
 - #115949 (Update browser-ui-test version)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 19, 2023
2 parents 65ea825 + aa55d7d commit f3984ce
Show file tree
Hide file tree
Showing 40 changed files with 825 additions and 374 deletions.
3 changes: 2 additions & 1 deletion .mailmap
Expand Up @@ -328,7 +328,8 @@ Kyle J Strand <batmanaod@gmail.com> <BatmanAoD@users.noreply.github.com>
Kyle J Strand <batmanaod@gmail.com> <kyle.j.strand@gmail.com>
Kyle J Strand <batmanaod@gmail.com> <kyle.strand@pieinsurance.com>
Kyle J Strand <batmanaod@gmail.com> <kyle.strand@rms.com>
Laurențiu Nicola <lnicola@dend.ro>
Laurențiu Nicola <lnicola@dend.ro> Laurentiu Nicola <lnicola@dend.ro>
Laurențiu Nicola <lnicola@dend.ro> <lnicola@users.noreply.github.com>
lcnr <rust@lcnr.de> <bastian_kauschke@hotmail.de>
Lee Jeffery <leejeffery@gmail.com> Lee Jeffery <lee@leejeffery.co.uk>
Lee Wondong <wdlee91@gmail.com>
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock
Expand Up @@ -662,6 +662,7 @@ dependencies = [
"diff",
"getopts",
"glob",
"home",
"lazycell",
"libc",
"miow",
Expand Down Expand Up @@ -1663,6 +1664,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"

[[package]]
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys 0.48.0",
]

[[package]]
name = "html-checker"
version = "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_data_structures/src/graph/dominators/mod.rs
Expand Up @@ -51,7 +51,7 @@ pub fn dominators<G: ControlFlowGraph>(graph: &G) -> Dominators<G::Node> {
// Traverse the graph, collecting a number of things:
//
// * Preorder mapping (to it, and back to the actual ordering)
// * Postorder mapping (used exclusively for rank_partial_cmp on the final product)
// * Postorder mapping (used exclusively for `cmp_in_dominator_order` on the final product)
// * Parents for each vertex in the preorder tree
//
// These are all done here rather than through one of the 'standard'
Expand Down Expand Up @@ -342,8 +342,8 @@ impl<Node: Idx> Dominators<Node> {
/// relationship, the dominator will always precede the dominated. (The relative ordering
/// of two unrelated nodes will also be consistent, but otherwise the order has no
/// meaning.) This method cannot be used to determine if either Node dominates the other.
pub fn rank_partial_cmp(&self, lhs: Node, rhs: Node) -> Option<Ordering> {
self.post_order_rank[rhs].partial_cmp(&self.post_order_rank[lhs])
pub fn cmp_in_dominator_order(&self, lhs: Node, rhs: Node) -> Ordering {
self.post_order_rank[rhs].cmp(&self.post_order_rank[lhs])
}

/// Returns true if `a` dominates `b`.
Expand Down
Expand Up @@ -169,6 +169,7 @@ impl AnnotateSnippetEmitterWriter {
.map(|line| {
// Ensure the source file is present before we try
// to load a string from it.
// FIXME(#115869): support -Z ignore-directory-in-diagnostics-source-blocks
source_map.ensure_source_file_source_present(&file);
(
format!("{}", source_map.filename_for_diagnostics(&file.name)),
Expand Down
27 changes: 24 additions & 3 deletions compiler/rustc_errors/src/emitter.rs
Expand Up @@ -8,7 +8,7 @@
//! The output types are defined in `rustc_session::config::ErrorOutputType`.

use rustc_span::source_map::SourceMap;
use rustc_span::{FileLines, SourceFile, Span};
use rustc_span::{FileLines, FileName, SourceFile, Span};

use crate::snippet::{
Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString,
Expand Down Expand Up @@ -635,6 +635,7 @@ pub struct EmitterWriter {
short_message: bool,
teach: bool,
ui_testing: bool,
ignored_directories_in_source_blocks: Vec<String>,
diagnostic_width: Option<usize>,

macro_backtrace: bool,
Expand Down Expand Up @@ -664,6 +665,7 @@ impl EmitterWriter {
short_message: false,
teach: false,
ui_testing: false,
ignored_directories_in_source_blocks: Vec::new(),
diagnostic_width: None,
macro_backtrace: false,
track_diagnostics: false,
Expand Down Expand Up @@ -1193,7 +1195,7 @@ impl EmitterWriter {
let will_be_emitted = |span: Span| {
!span.is_dummy() && {
let file = sm.lookup_source_file(span.hi());
sm.ensure_source_file_source_present(&file)
should_show_source_code(&self.ignored_directories_in_source_blocks, sm, &file)
}
};

Expand Down Expand Up @@ -1388,7 +1390,11 @@ impl EmitterWriter {
// Print out the annotate source lines that correspond with the error
for annotated_file in annotated_files {
// we can't annotate anything if the source is unavailable.
if !sm.ensure_source_file_source_present(&annotated_file.file) {
if !should_show_source_code(
&self.ignored_directories_in_source_blocks,
sm,
&annotated_file.file,
) {
if !self.short_message {
// We'll just print an unannotated message.
for (annotation_id, line) in annotated_file.lines.iter().enumerate() {
Expand Down Expand Up @@ -2737,3 +2743,18 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
// bug, but be defensive against that here.
&& found != suggested
}

pub(crate) fn should_show_source_code(
ignored_directories: &[String],
sm: &SourceMap,
file: &SourceFile,
) -> bool {
if !sm.ensure_source_file_source_present(file) {
return false;
}

let FileName::Real(name) = &file.name else { return true };
name.local_path()
.map(|path| ignored_directories.iter().all(|dir| !path.starts_with(dir)))
.unwrap_or(true)
}
16 changes: 14 additions & 2 deletions compiler/rustc_errors/src/json.rs
Expand Up @@ -12,7 +12,7 @@
use rustc_span::source_map::{FilePathMapping, SourceMap};
use termcolor::{ColorSpec, WriteColor};

use crate::emitter::{Emitter, HumanReadableErrorType};
use crate::emitter::{should_show_source_code, Emitter, HumanReadableErrorType};
use crate::registry::Registry;
use crate::translation::{to_fluent_args, Translate};
use crate::DiagnosticId;
Expand Down Expand Up @@ -45,6 +45,7 @@ pub struct JsonEmitter {
fallback_bundle: LazyFallbackBundle,
pretty: bool,
ui_testing: bool,
ignored_directories_in_source_blocks: Vec<String>,
json_rendered: HumanReadableErrorType,
diagnostic_width: Option<usize>,
macro_backtrace: bool,
Expand Down Expand Up @@ -73,6 +74,7 @@ impl JsonEmitter {
fallback_bundle,
pretty,
ui_testing: false,
ignored_directories_in_source_blocks: Vec::new(),
json_rendered,
diagnostic_width,
macro_backtrace,
Expand Down Expand Up @@ -127,6 +129,7 @@ impl JsonEmitter {
fallback_bundle,
pretty,
ui_testing: false,
ignored_directories_in_source_blocks: Vec::new(),
json_rendered,
diagnostic_width,
macro_backtrace,
Expand All @@ -138,6 +141,10 @@ impl JsonEmitter {
pub fn ui_testing(self, ui_testing: bool) -> Self {
Self { ui_testing, ..self }
}

pub fn ignored_directories_in_source_blocks(self, value: Vec<String>) -> Self {
Self { ignored_directories_in_source_blocks: value, ..self }
}
}

impl Translate for JsonEmitter {
Expand Down Expand Up @@ -381,6 +388,7 @@ impl Diagnostic {
.track_diagnostics(je.track_diagnostics)
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(je.ignored_directories_in_source_blocks.clone())
.emit_diagnostic(diag);
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
let output = String::from_utf8(output).unwrap();
Expand Down Expand Up @@ -558,7 +566,11 @@ impl DiagnosticSpanLine {
.span_to_lines(span)
.map(|lines| {
// We can't get any lines if the source is unavailable.
if !je.sm.ensure_source_file_source_present(&lines.file) {
if !should_show_source_code(
&je.ignored_directories_in_source_blocks,
&je.sm,
&lines.file,
) {
return vec![];
}

Expand Down
44 changes: 44 additions & 0 deletions compiler/rustc_hir_typeck/messages.ftl
Expand Up @@ -16,6 +16,21 @@ hir_typeck_candidate_trait_note = `{$trait_name}` defines an item `{$item_name}`
*[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it
}
hir_typeck_cannot_cast_to_bool = cannot cast `{$expr_ty}` as `bool`
.suggestion = compare with zero instead
.help = compare with zero instead
.label = unsupported cast
hir_typeck_cast_enum_drop = cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`
hir_typeck_cast_unknown_pointer = cannot cast {$to ->
[true] to
*[false] from
} a pointer of an unknown kind
.label_to = needs more type information
.note = the type information given here is insufficient to check whether the pointer cast is valid
.label_from = the type information given here is insufficient to check whether the pointer cast is valid
hir_typeck_const_select_must_be_const = this argument must be a `const fn`
.help = consult the documentation on `const_eval_select` for more information
Expand All @@ -29,6 +44,8 @@ hir_typeck_convert_using_method = try using `{$sugg}` to convert `{$found}` to `
hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private
hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`
hir_typeck_expected_default_return_type = expected `()` because of default return type
hir_typeck_expected_return_type = expected `{$expected}` because of return type
Expand Down Expand Up @@ -57,6 +74,13 @@ hir_typeck_functional_record_update_on_non_struct =
hir_typeck_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
hir_typeck_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
hir_typeck_int_to_fat = cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
[true] is
*[false] may be
} wide
hir_typeck_int_to_fat_label = creating a `{$cast_ty}` requires both an address and {$metadata}
hir_typeck_int_to_fat_label_nightly = consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
hir_typeck_invalid_callee = expected function, found {$ty}
hir_typeck_lang_start_expected_sig_note = the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
Expand All @@ -69,6 +93,16 @@ hir_typeck_lang_start_incorrect_param = parameter {$param_num} of the `start` la
hir_typeck_lang_start_incorrect_ret_ty = the return type of the `start` lang item is incorrect
.suggestion = change the type from `{$found_ty}` to `{$expected_ty}`
hir_typeck_lossy_provenance_int2ptr =
strict provenance disallows casting integer `{$expr_ty}` to pointer `{$cast_ty}`
.suggestion = use `.with_addr()` to adjust a valid pointer in the same allocation, to this address
.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
hir_typeck_lossy_provenance_ptr2int =
under strict provenance it is considered bad style to cast pointer `{$expr_ty}` to integer `{$cast_ty}`
.suggestion = use `.addr()` to obtain the address of a pointer
.help = if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_addr()` instead
hir_typeck_method_call_on_unknown_raw_pointee =
cannot call a method on a raw pointer with an unknown pointee type
Expand Down Expand Up @@ -113,8 +147,18 @@ hir_typeck_suggest_boxing_when_appropriate = store this in the heap by calling `
hir_typeck_suggest_ptr_null_mut = consider using `core::ptr::null_mut` instead
hir_typeck_trivial_cast = trivial {$numeric ->
[true] numeric cast
*[false] cast
}: `{$expr_ty}` as `{$cast_ty}`
.help = cast can be replaced by coercion; this might require a temporary variable
hir_typeck_union_pat_dotdot = `..` cannot be used in union patterns
hir_typeck_union_pat_multiple_fields = union patterns should have exactly one field
hir_typeck_use_is_empty =
consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything
hir_typeck_yield_expr_outside_of_generator =
yield expression outside of generator literal

0 comments on commit f3984ce

Please sign in to comment.