Skip to content

Rollup of 8 pull requests #115952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Sep 19, 2023
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d695b95
implement -Z ignore-directory-in-diagnostics-source-blocks
pietroalbini Sep 15, 2023
c230637
avoid blessing cargo deps's source code in ui tests
pietroalbini Sep 15, 2023
4690f97
coverage: Fix an unstable-sort inconsistency in coverage spans
Zalathar Sep 18, 2023
a4cb31b
coverage: Regression test for inconsistent handling of closure spans
Zalathar Sep 18, 2023
01b67f4
coverage: Simplify sorting of coverage spans extracted from MIR
Zalathar Sep 17, 2023
354397f
Move mobile topbar title creation entirely into JS
GuillaumeGomez Sep 18, 2023
bf693d1
Migrate 'lossy ptr2int cast' diagnostic
clubby789 Sep 15, 2023
6496181
Migrate 'lossy int2ptr cast' diagnostic
clubby789 Sep 15, 2023
dcb3e70
Migrate 'is_empty' diagnostics
clubby789 Sep 15, 2023
c2841e2
Migrate 'cast to bool' diagnostic
clubby789 Sep 15, 2023
94920cc
Migrate 'int to fat pointer' cast diagnostic
clubby789 Sep 15, 2023
82471e9
Migrate 'casting unknown pointer' diagnostic
clubby789 Sep 15, 2023
80a9699
Migrate 'trivial cast' lint
clubby789 Sep 15, 2023
9c5de75
Migrate 'cast enum with drop to int' diagnostic
clubby789 Sep 15, 2023
b2bf4b6
make more pretty
BoxyUwU Sep 15, 2023
de6de23
Add myself to .mailmap
lnicola Sep 18, 2023
10a5b9a
compiletest: Don't swallow some error messages.
ehuss Sep 18, 2023
f27c06c
Update browser-ui-test version
GuillaumeGomez Sep 18, 2023
0eec5e3
Rollup merge of #115869 - ferrocene:pa-fix-tests-cargo-remap, r=compi…
matthiaskrgr Sep 18, 2023
48c6051
Rollup merge of #115873 - BoxyUwU:tykind_adt_debug, r=oli-obk
matthiaskrgr Sep 18, 2023
970ee09
Rollup merge of #115879 - clubby789:migrate-hir-typeck-cast, r=compil…
matthiaskrgr Sep 18, 2023
3cf5a6b
Rollup merge of #115930 - Zalathar:spans-bug, r=compiler-errors
matthiaskrgr Sep 18, 2023
575e091
Rollup merge of #115931 - GuillaumeGomez:remove-empty-h2, r=notriddle
matthiaskrgr Sep 18, 2023
3ddad37
Rollup merge of #115941 - lnicola:lnicola-mailmap, r=Mark-Simulacrum
matthiaskrgr Sep 18, 2023
8c5fc20
Rollup merge of #115943 - ehuss:compiletest-errors, r=compiler-errors
matthiaskrgr Sep 18, 2023
aa55d7d
Rollup merge of #115949 - GuillaumeGomez:update-browser-ui-test, r=no…
matthiaskrgr Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
@@ -328,7 +328,8 @@ Kyle J Strand <[email protected]> <[email protected]>
Kyle J Strand <[email protected]> <[email protected]>
Kyle J Strand <[email protected]> <[email protected]>
Kyle J Strand <[email protected]> <[email protected]>
Laurențiu Nicola <[email protected]>
Laurențiu Nicola <[email protected]> Laurentiu Nicola <[email protected]>
Laurențiu Nicola <[email protected]> <[email protected]>
lcnr <[email protected]> <[email protected]>
Lee Jeffery <[email protected]> Lee Jeffery <[email protected]>
Lee Wondong <[email protected]>
10 changes: 10 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -662,6 +662,7 @@ dependencies = [
"diff",
"getopts",
"glob",
"home",
"lazycell",
"libc",
"miow",
@@ -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"
6 changes: 3 additions & 3 deletions compiler/rustc_data_structures/src/graph/dominators/mod.rs
Original file line number Diff line number Diff line change
@@ -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'
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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)),
27 changes: 24 additions & 3 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
@@ -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,
@@ -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,
@@ -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,
@@ -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)
}
};

@@ -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() {
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
@@ -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,
@@ -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,
@@ -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,
@@ -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 {
@@ -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();
@@ -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![];
}

44 changes: 44 additions & 0 deletions compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
@@ -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

@@ -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
@@ -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`
@@ -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

@@ -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
Loading