Skip to content

Commit 24f1e33

Browse files
committed
Auto merge of #134027 - workingjubilee:rollup-29t4fjz, r=workingjubilee
Rollup of 5 pull requests Successful merges: - #131669 (lint: change help for pointers to dyn types in FFI) - #133184 (wasi/fs: Improve stopping condition for <ReadDir as Iterator>::next) - #133265 (Add a range argument to vec.extract_if) - #133456 (Add licenses + Run `cargo update`) - #133767 (Add more info on type/trait mismatches for different crate versions) Failed merges: - #133522 (Don't suggest restricting bound with unstable traits on stable and mention it's unstable on nightly) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 728f2da + 152b5e9 commit 24f1e33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1667
-756
lines changed

Diff for: Cargo.lock

+337-243
Large diffs are not rendered by default.

Diff for: compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tempfile = "3.2"
4242
thin-vec = "0.2.12"
4343
thorin-dwp = "0.8"
4444
tracing = "0.1"
45-
wasm-encoder = "0.216.0"
45+
wasm-encoder = "0.219"
4646
# tidy-alphabetical-end
4747

4848
[target.'cfg(unix)'.dependencies]

Diff for: compiler/rustc_errors/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1558,18 +1558,18 @@ impl DiagCtxtInner {
15581558
debug!(?diagnostic);
15591559
debug!(?self.emitted_diagnostics);
15601560

1561-
let already_emitted_sub = |sub: &mut Subdiag| {
1561+
let not_yet_emitted = |sub: &mut Subdiag| {
15621562
debug!(?sub);
15631563
if sub.level != OnceNote && sub.level != OnceHelp {
1564-
return false;
1564+
return true;
15651565
}
15661566
let mut hasher = StableHasher::new();
15671567
sub.hash(&mut hasher);
15681568
let diagnostic_hash = hasher.finish();
15691569
debug!(?diagnostic_hash);
1570-
!self.emitted_diagnostics.insert(diagnostic_hash)
1570+
self.emitted_diagnostics.insert(diagnostic_hash)
15711571
};
1572-
diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
1572+
diagnostic.children.retain_mut(not_yet_emitted);
15731573
if already_emitted {
15741574
let msg = "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`";
15751575
diagnostic.sub(Note, msg, MultiSpan::new());

Diff for: compiler/rustc_lint/messages.ftl

+11-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ lint_improper_ctypes_128bit = 128-bit integers don't currently have a known stab
359359
lint_improper_ctypes_array_help = consider passing a pointer to the array
360360
361361
lint_improper_ctypes_array_reason = passing raw arrays by value is not FFI-safe
362-
lint_improper_ctypes_box = box cannot be represented as a single pointer
363362
364363
lint_improper_ctypes_char_help = consider using `u32` or `libc::wchar_t` instead
365364
@@ -377,7 +376,9 @@ lint_improper_ctypes_enum_repr_help =
377376
lint_improper_ctypes_enum_repr_reason = enum has no representation hint
378377
lint_improper_ctypes_fnptr_help = consider using an `extern fn(...) -> ...` function pointer instead
379378
379+
lint_improper_ctypes_fnptr_indirect_reason = the function pointer to `{$ty}` is FFI-unsafe due to `{$inner_ty}`
380380
lint_improper_ctypes_fnptr_reason = this function pointer has Rust-specific calling convention
381+
381382
lint_improper_ctypes_non_exhaustive = this enum is non-exhaustive
382383
lint_improper_ctypes_non_exhaustive_variant = this enum has non-exhaustive variants
383384
@@ -388,7 +389,11 @@ lint_improper_ctypes_opaque = opaque types have no C equivalent
388389
lint_improper_ctypes_pat_help = consider using the base type instead
389390
390391
lint_improper_ctypes_pat_reason = pattern types have no C equivalent
391-
lint_improper_ctypes_slice_help = consider using a raw pointer instead
392+
393+
lint_improper_ctypes_sized_ptr_to_unsafe_type =
394+
this reference (`{$ty}`) is ABI-compatible with a C pointer, but `{$inner_ty}` itself does not have a C layout
395+
396+
lint_improper_ctypes_slice_help = consider using a raw pointer to the slice's first element (and a length) instead
392397
393398
lint_improper_ctypes_slice_reason = slices have no C equivalent
394399
lint_improper_ctypes_str_help = consider using `*const u8` and a length instead
@@ -414,6 +419,10 @@ lint_improper_ctypes_union_layout_help = consider adding a `#[repr(C)]` or `#[re
414419
lint_improper_ctypes_union_layout_reason = this union has unspecified layout
415420
lint_improper_ctypes_union_non_exhaustive = this union is non-exhaustive
416421
422+
lint_improper_ctypes_unsized_box = this box for an unsized type contains metadata, which makes it incompatible with a C pointer
423+
lint_improper_ctypes_unsized_ptr = this pointer to an unsized type contains metadata, which makes it incompatible with a C pointer
424+
lint_improper_ctypes_unsized_ref = this reference to an unsized type contains metadata, which makes it incompatible with a C pointer
425+
417426
lint_incomplete_include =
418427
include macro expected single expression in source
419428

Diff for: compiler/rustc_lint/src/lints.rs

+36-9
Original file line numberDiff line numberDiff line change
@@ -1851,13 +1851,44 @@ pub(crate) struct UnpredictableFunctionPointerComparisonsSuggestion<'a> {
18511851
pub right: Span,
18521852
}
18531853

1854+
pub(crate) struct ImproperCTypesLayer<'a> {
1855+
pub ty: Ty<'a>,
1856+
pub inner_ty: Option<Ty<'a>>,
1857+
pub note: DiagMessage,
1858+
pub span_note: Option<Span>,
1859+
pub help: Option<DiagMessage>,
1860+
}
1861+
1862+
impl<'a> Subdiagnostic for ImproperCTypesLayer<'a> {
1863+
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
1864+
self,
1865+
diag: &mut Diag<'_, G>,
1866+
f: &F,
1867+
) {
1868+
diag.arg("ty", self.ty);
1869+
if let Some(ty) = self.inner_ty {
1870+
diag.arg("inner_ty", ty);
1871+
}
1872+
1873+
if let Some(help) = self.help {
1874+
let msg = f(diag, help.into());
1875+
diag.help(msg);
1876+
}
1877+
1878+
let msg = f(diag, self.note.into());
1879+
diag.note(msg);
1880+
if let Some(note) = self.span_note {
1881+
let msg = f(diag, fluent::lint_note.into());
1882+
diag.span_note(note, msg);
1883+
};
1884+
}
1885+
}
1886+
18541887
pub(crate) struct ImproperCTypes<'a> {
18551888
pub ty: Ty<'a>,
18561889
pub desc: &'a str,
18571890
pub label: Span,
1858-
pub help: Option<DiagMessage>,
1859-
pub note: DiagMessage,
1860-
pub span_note: Option<Span>,
1891+
pub reasons: Vec<ImproperCTypesLayer<'a>>,
18611892
}
18621893

18631894
// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
@@ -1867,12 +1898,8 @@ impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> {
18671898
diag.arg("ty", self.ty);
18681899
diag.arg("desc", self.desc);
18691900
diag.span_label(self.label, fluent::lint_label);
1870-
if let Some(help) = self.help {
1871-
diag.help(help);
1872-
}
1873-
diag.note(self.note);
1874-
if let Some(note) = self.span_note {
1875-
diag.span_note(note, fluent::lint_note);
1901+
for reason in self.reasons.into_iter() {
1902+
diag.subdiagnostic(reason);
18761903
}
18771904
}
18781905
}

Diff for: compiler/rustc_lint/src/non_ascii_idents.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl EarlyLintPass for NonAsciiIdents {
205205
(IdentifierType::Not_NFKC, "Not_NFKC"),
206206
] {
207207
let codepoints: Vec<_> =
208-
chars.extract_if(|(_, ty)| *ty == Some(id_ty)).collect();
208+
chars.extract_if(.., |(_, ty)| *ty == Some(id_ty)).collect();
209209
if codepoints.is_empty() {
210210
continue;
211211
}
@@ -217,7 +217,7 @@ impl EarlyLintPass for NonAsciiIdents {
217217
}
218218

219219
let remaining = chars
220-
.extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
220+
.extract_if(.., |(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
221221
.collect::<Vec<_>>();
222222
if !remaining.is_empty() {
223223
cx.emit_span_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints {

0 commit comments

Comments
 (0)