Skip to content

Commit cc71eef

Browse files
committed
Auto merge of #100213 - matthiaskrgr:rollup-mqe7t1n, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #100071 (deps: dedupe `annotate-snippets` crate versions) - #100127 (Remove Windows function preloading) - #100130 (Avoid pointing out `return` span if it has nothing to do with type error) - #100169 (Optimize `pointer::as_aligned_to`) - #100175 (ascii -> ASCII in code comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2befdef + ee0b755 commit cc71eef

24 files changed

+266
-219
lines changed

Diff for: Cargo.lock

+3-9
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ dependencies = [
8282
"url 2.2.2",
8383
]
8484

85-
[[package]]
86-
name = "annotate-snippets"
87-
version = "0.8.0"
88-
source = "registry+https://github.com/rust-lang/crates.io-index"
89-
checksum = "d78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5"
90-
9185
[[package]]
9286
name = "annotate-snippets"
9387
version = "0.9.1"
@@ -3862,7 +3856,7 @@ dependencies = [
38623856
name = "rustc_errors"
38633857
version = "0.0.0"
38643858
dependencies = [
3865-
"annotate-snippets 0.8.0",
3859+
"annotate-snippets",
38663860
"atty",
38673861
"rustc_data_structures",
38683862
"rustc_error_messages",
@@ -4114,7 +4108,7 @@ dependencies = [
41144108
name = "rustc_macros"
41154109
version = "0.1.0"
41164110
dependencies = [
4117-
"annotate-snippets 0.8.0",
4111+
"annotate-snippets",
41184112
"fluent-bundle",
41194113
"fluent-syntax",
41204114
"proc-macro2",
@@ -4729,7 +4723,7 @@ dependencies = [
47294723
name = "rustfmt-nightly"
47304724
version = "1.5.1"
47314725
dependencies = [
4732-
"annotate-snippets 0.9.1",
4726+
"annotate-snippets",
47334727
"anyhow",
47344728
"bytecount",
47354729
"cargo_metadata 0.14.0",

Diff for: compiler/rustc_errors/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rustc_lint_defs = { path = "../rustc_lint_defs" }
1818
unicode-width = "0.1.4"
1919
atty = "0.2"
2020
termcolor = "1.0"
21-
annotate-snippets = "0.8.0"
21+
annotate-snippets = "0.9"
2222
termize = "0.1.1"
2323
serde = { version = "1.0.125", features = ["derive"] }
2424
serde_json = "1.0.59"

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ impl AnnotateSnippetEmitterWriter {
183183
annotation_type: annotation_type_for_level(*level),
184184
}),
185185
footer: vec![],
186-
opt: FormatOptions { color: true, anonymized_line_numbers: self.ui_testing },
186+
opt: FormatOptions {
187+
color: true,
188+
anonymized_line_numbers: self.ui_testing,
189+
margin: None,
190+
},
187191
slices: annotated_files
188192
.iter()
189193
.map(|(source, line_index, annotations)| {

Diff for: compiler/rustc_macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
proc-macro = true
88

99
[dependencies]
10-
annotate-snippets = "0.8.0"
10+
annotate-snippets = "0.9"
1111
fluent-bundle = "0.15.2"
1212
fluent-syntax = "0.11"
1313
synstructure = "0.12.1"

Diff for: compiler/rustc_typeck/src/check/coercion.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14931493
// type)
14941494
(self.final_ty.unwrap_or(self.expected_ty), expression_ty)
14951495
};
1496+
let (expected, found) = fcx.resolve_vars_if_possible((expected, found));
14961497

14971498
let mut err;
14981499
let mut unsized_return = false;
@@ -1695,9 +1696,30 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
16951696
);
16961697
}
16971698

1698-
if let (Some(sp), Some(fn_output)) = (fcx.ret_coercion_span.get(), fn_output) {
1699+
let ret_coercion_span = fcx.ret_coercion_span.get();
1700+
1701+
if let Some(sp) = ret_coercion_span
1702+
// If the closure has an explicit return type annotation, or if
1703+
// the closure's return type has been inferred from outside
1704+
// requirements (such as an Fn* trait bound), then a type error
1705+
// may occur at the first return expression we see in the closure
1706+
// (if it conflicts with the declared return type). Skip adding a
1707+
// note in this case, since it would be incorrect.
1708+
&& !fcx.return_type_pre_known
1709+
{
1710+
err.span_note(
1711+
sp,
1712+
&format!(
1713+
"return type inferred to be `{}` here",
1714+
expected
1715+
),
1716+
);
1717+
}
1718+
1719+
if let (Some(sp), Some(fn_output)) = (ret_coercion_span, fn_output) {
16991720
self.add_impl_trait_explanation(&mut err, cause, fcx, expected, sp, fn_output);
17001721
}
1722+
17011723
err
17021724
}
17031725

Diff for: compiler/rustc_typeck/src/check/demand.rs

-22
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4545
self.note_type_is_not_clone(err, expected, expr_ty, expr);
4646
self.note_need_for_fn_pointer(err, expected, expr_ty);
4747
self.note_internal_mutation_in_method(err, expr, expected, expr_ty);
48-
self.report_closure_inferred_return_type(err, expected);
4948
}
5049

5150
// Requires that the two types unify, and prints an error message if
@@ -1418,25 +1417,4 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14181417
_ => false,
14191418
}
14201419
}
1421-
1422-
// Report the type inferred by the return statement.
1423-
fn report_closure_inferred_return_type(&self, err: &mut Diagnostic, expected: Ty<'tcx>) {
1424-
if let Some(sp) = self.ret_coercion_span.get()
1425-
// If the closure has an explicit return type annotation, or if
1426-
// the closure's return type has been inferred from outside
1427-
// requirements (such as an Fn* trait bound), then a type error
1428-
// may occur at the first return expression we see in the closure
1429-
// (if it conflicts with the declared return type). Skip adding a
1430-
// note in this case, since it would be incorrect.
1431-
&& !self.return_type_pre_known
1432-
{
1433-
err.span_note(
1434-
sp,
1435-
&format!(
1436-
"return type inferred to be `{}` here",
1437-
self.resolve_vars_if_possible(expected)
1438-
),
1439-
);
1440-
}
1441-
}
14421420
}

Diff for: library/core/src/ptr/const_ptr.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1336,11 +1336,8 @@ impl<T: ?Sized> *const T {
13361336
panic!("is_aligned_to: align is not a power-of-two");
13371337
}
13381338

1339-
// SAFETY: `is_power_of_two()` will return `false` for zero.
1340-
unsafe { core::intrinsics::assume(align != 0) };
1341-
13421339
// Cast is needed for `T: !Sized`
1343-
self.cast::<u8>().addr() % align == 0
1340+
self.cast::<u8>().addr() & align - 1 == 0
13441341
}
13451342
}
13461343

Diff for: library/core/src/ptr/mut_ptr.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1614,11 +1614,8 @@ impl<T: ?Sized> *mut T {
16141614
panic!("is_aligned_to: align is not a power-of-two");
16151615
}
16161616

1617-
// SAFETY: `is_power_of_two()` will return `false` for zero.
1618-
unsafe { core::intrinsics::assume(align != 0) };
1619-
16201617
// Cast is needed for `T: !Sized`
1621-
self.cast::<u8>().addr() % align == 0
1618+
self.cast::<u8>().addr() & align - 1 == 0
16221619
}
16231620
}
16241621

Diff for: library/core/src/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,7 @@ impl str {
23532353
#[inline]
23542354
pub fn is_ascii(&self) -> bool {
23552355
// We can treat each byte as character here: all multibyte characters
2356-
// start with a byte that is not in the ascii range, so we will stop
2356+
// start with a byte that is not in the ASCII range, so we will stop
23572357
// there already.
23582358
self.as_bytes().is_ascii()
23592359
}

Diff for: library/std/src/sys/windows/c.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -1250,19 +1250,21 @@ compat_fn_with_fallback! {
12501250
}
12511251
}
12521252

1253-
compat_fn_optional! {
1253+
compat_fn_with_fallback! {
12541254
pub static SYNCH_API: &CStr = ansi_str!("api-ms-win-core-synch-l1-2-0");
1255-
1256-
// >= Windows 8 / Server 2012
1257-
// https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress
1258-
pub fn WaitOnAddress(
1259-
Address: LPVOID,
1260-
CompareAddress: LPVOID,
1261-
AddressSize: SIZE_T,
1262-
dwMilliseconds: DWORD
1263-
) -> BOOL;
1264-
pub fn WakeByAddressSingle(Address: LPVOID) -> ();
1255+
#[allow(unused)]
1256+
fn WakeByAddressSingle(Address: LPVOID) -> () {
1257+
// This fallback is currently tightly coupled to its use in Parker::unpark.
1258+
//
1259+
// FIXME: If `WakeByAddressSingle` needs to be used anywhere other than
1260+
// Parker::unpark then this fallback will be wrong and will need to be decoupled.
1261+
crate::sys::windows::thread_parker::unpark_keyed_event(Address)
1262+
}
12651263
}
1264+
pub use crate::sys::compat::WaitOnAddress;
1265+
// Change exported name of `WakeByAddressSingle` to make the strange fallback
1266+
// behaviour clear.
1267+
pub use WakeByAddressSingle::call as wake_by_address_single_or_unpark_keyed_event;
12661268

12671269
compat_fn_with_fallback! {
12681270
pub static NTDLL: &CStr = ansi_str!("ntdll");

0 commit comments

Comments
 (0)