Skip to content

Commit 11467b1

Browse files
committed
Auto merge of #114526 - matthiaskrgr:rollup-zz041wi, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #114486 (Avoid invalid NaN lint machine-applicable suggestion in const context) - #114503 (Remove invalid lint when there is a generic argument in prefix path) - #114509 (Migrate GUI colors test to original CSS color format) - #114524 (Also ICE when goals go from Ok to Err in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8236f63 + bf4b1d7 commit 11467b1

File tree

7 files changed

+36
-20
lines changed

7 files changed

+36
-20
lines changed

compiler/rustc_lint/src/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ pub enum InvalidNanComparisons {
14961496
#[diag(lint_invalid_nan_comparisons_eq_ne)]
14971497
EqNe {
14981498
#[subdiagnostic]
1499-
suggestion: InvalidNanComparisonsSuggestion,
1499+
suggestion: Option<InvalidNanComparisonsSuggestion>,
15001500
},
15011501
#[diag(lint_invalid_nan_comparisons_lt_le_gt_ge)]
15021502
LtLeGtGe,

compiler/rustc_lint/src/types.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -572,32 +572,36 @@ fn lint_nan<'tcx>(
572572
}
573573

574574
fn eq_ne(
575+
cx: &LateContext<'_>,
575576
e: &hir::Expr<'_>,
576577
l: &hir::Expr<'_>,
577578
r: &hir::Expr<'_>,
578579
f: impl FnOnce(Span, Span) -> InvalidNanComparisonsSuggestion,
579580
) -> InvalidNanComparisons {
580-
let suggestion =
581+
// FIXME(#72505): This suggestion can be restored if `f{32,64}::is_nan` is made const.
582+
let suggestion = (!cx.tcx.hir().is_inside_const_context(e.hir_id)).then(|| {
581583
if let Some(l_span) = l.span.find_ancestor_inside(e.span) &&
582-
let Some(r_span) = r.span.find_ancestor_inside(e.span) {
584+
let Some(r_span) = r.span.find_ancestor_inside(e.span)
585+
{
583586
f(l_span, r_span)
584587
} else {
585588
InvalidNanComparisonsSuggestion::Spanless
586-
};
589+
}
590+
});
587591

588592
InvalidNanComparisons::EqNe { suggestion }
589593
}
590594

591595
let lint = match binop.node {
592596
hir::BinOpKind::Eq | hir::BinOpKind::Ne if is_nan(cx, l) => {
593-
eq_ne(e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion::Spanful {
597+
eq_ne(cx, e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion::Spanful {
594598
nan_plus_binop: l_span.until(r_span),
595599
float: r_span.shrink_to_hi(),
596600
neg: (binop.node == hir::BinOpKind::Ne).then(|| r_span.shrink_to_lo()),
597601
})
598602
}
599603
hir::BinOpKind::Eq | hir::BinOpKind::Ne if is_nan(cx, r) => {
600-
eq_ne(e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion::Spanful {
604+
eq_ne(cx, e, l, r, |l_span, r_span| InvalidNanComparisonsSuggestion::Spanful {
601605
nan_plus_binop: l_span.shrink_to_hi().to(r_span),
602606
float: l_span.shrink_to_hi(),
603607
neg: (binop.node == hir::BinOpKind::Ne).then(|| l_span.shrink_to_lo()),

compiler/rustc_resolve/src/late.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3944,11 +3944,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
39443944

39453945
if path.len() > 1
39463946
&& let Some(res) = result.full_res()
3947+
&& let Some((&last_segment, prev_segs)) = path.split_last()
3948+
&& prev_segs.iter().all(|seg| !seg.has_generic_args)
39473949
&& res != Res::Err
39483950
&& path[0].ident.name != kw::PathRoot
39493951
&& path[0].ident.name != kw::DollarCrate
39503952
{
3951-
let last_segment = *path.last().unwrap();
39523953
let unqualified_result = {
39533954
match self.resolve_path(&[last_segment], Some(ns), None) {
39543955
PathResult::NonModule(path_res) => path_res.expect_full_res(),

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,19 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
391391
debug!("rerunning goal to check result is stable");
392392
self.search_graph.reset_encountered_overflow(encountered_overflow);
393393
let (_orig_values, canonical_goal) = self.canonicalize_goal(goal);
394-
let new_canonical_response = EvalCtxt::evaluate_canonical_goal(
394+
let Ok(new_canonical_response) = EvalCtxt::evaluate_canonical_goal(
395395
self.tcx(),
396396
self.search_graph,
397397
canonical_goal,
398398
// FIXME(-Ztrait-solver=next): we do not track what happens in `evaluate_canonical_goal`
399399
&mut ProofTreeBuilder::new_noop(),
400-
)?;
400+
) else {
401+
bug!(
402+
"goal went from {certainty:?} to error: re-canonicalized goal={canonical_goal:#?} \
403+
first_response={canonical_response:#?},
404+
second response was error"
405+
);
406+
};
401407
// We only check for modulo regions as we convert all regions in
402408
// the input to new existentials, even if they're expected to be
403409
// `'static` or a placeholder region.

tests/rustdoc-gui/scrape-examples-toggle.goml

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ define-function: (
2828

2929
call-function: ("check-color", {
3030
"theme": "ayu",
31-
"toggle_line_color": "rgb(153, 153, 153)",
32-
"toggle_line_hover_color": "rgb(197, 197, 197)",
31+
"toggle_line_color": "#999",
32+
"toggle_line_hover_color": "#c5c5c5",
3333
})
3434
call-function: ("check-color", {
3535
"theme": "dark",
36-
"toggle_line_color": "rgb(153, 153, 153)",
37-
"toggle_line_hover_color": "rgb(197, 197, 197)",
36+
"toggle_line_color": "#999",
37+
"toggle_line_hover_color": "#c5c5c5",
3838
})
3939
call-function: ("check-color", {
4040
"theme": "light",
41-
"toggle_line_color": "rgb(204, 204, 204)",
42-
"toggle_line_hover_color": "rgb(153, 153, 153)",
41+
"toggle_line_color": "#ccc",
42+
"toggle_line_hover_color": "#999",
4343
})
4444

4545
// Toggling all docs will close additional examples

tests/ui/lint/invalid-nan-comparison.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ LL | const TEST: bool = 5f32 == f32::NAN;
55
| ^^^^^^^^^^^^^^^^
66
|
77
= note: `#[warn(invalid_nan_comparisons)]` on by default
8-
help: use `f32::is_nan()` or `f64::is_nan()` instead
9-
|
10-
LL - const TEST: bool = 5f32 == f32::NAN;
11-
LL + const TEST: bool = 5f32.is_nan();
12-
|
138

149
warning: incorrect NaN comparison, NaN cannot be directly compared to itself
1510
--> $DIR/invalid-nan-comparison.rs:14:5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![deny(unused_qualifications)]
2+
// check-pass
3+
fn bar() {
4+
match Option::<Option<()>>::None {
5+
Some(v) => {}
6+
None => {}
7+
}
8+
}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)