Skip to content

Commit 7c329d6

Browse files
committed
Auto merge of #160414 - jhpratt:rollup-bSKtJ4G, r=jhpratt
Rollup of 3 pull requests Successful merges: - #160306 (Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins)) - #160254 (Rerun the goal with doubled recursion limit even if the goal has ty vars) - #160380 (Improve the test for patterns in fn pointers)
2 parents 65dd30f + 9e756da commit 7c329d6

6 files changed

Lines changed: 317 additions & 77 deletions

File tree

‎compiler/rustc_codegen_ssa/src/back/symbol_export.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc_middle::ty::{
1717
};
1818
use rustc_middle::util::Providers;
1919
use rustc_session::config::CrateType;
20+
use rustc_session::cstore::CrateDepKind;
2021
use rustc_span::Span;
2122
use rustc_symbol_mangling::mangle_internal_symbol;
2223
use rustc_target::spec::{Arch, Os, TlsModel};
@@ -434,6 +435,14 @@ fn upstream_monomorphizations_provider(
434435
let async_drop_in_place_fn_def_id = tcx.lang_items().async_drop_in_place_fn();
435436

436437
for &cnum in cnums.iter() {
438+
// It should be possible to compile to build a crate against a conditional dependency then
439+
// later link that crate without the conditional dependency, so we cannot use exported
440+
// generics from conditional dependencies.
441+
// https://github.com/rust-lang/rust/issues/159682
442+
if tcx.crate_dep_kind(cnum) == CrateDepKind::Conditional {
443+
continue;
444+
}
445+
437446
for (exported_symbol, _) in tcx.exported_generic_symbols(cnum).iter() {
438447
let (def_id, args) = match *exported_symbol {
439448
ExportedSymbol::Generic(def_id, args) => (def_id, args),

‎compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,6 @@ fn maybe_evaluate_root_goal_with_higher_recursion_limit<D, I>(
338338
Ok(goal_evaluation) => goal_evaluation.goal.predicate,
339339
};
340340

341-
// Some goals no longer overflow after the stalled infers are resolved.
342-
// Thus we don't have to rerun eagerly here.
343-
let has_stalled_infers = match predicate.kind().skip_binder() {
344-
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) => {
345-
projection.projection_term.has_non_region_infer()
346-
}
347-
_ => predicate.has_non_region_infer(),
348-
};
349-
if has_stalled_infers {
350-
return;
351-
}
352-
353341
let rerun_result = delegate.commit_if_ok(|| {
354342
let rerun_result =
355343
EvalCtxt::enter_root(delegate, delegate.cx().recursion_limit() * 2, span, |ecx| {
@@ -397,19 +385,6 @@ fn maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit<D, I>(
397385
Ok(_) => {}
398386
}
399387

400-
// Some goals no longer overflow after the stalled infers are resolved.
401-
// Thus we don't have to rerun eagerly here.
402-
let predicate: I::Predicate = goal_evaluation.uncanonicalized_goal.predicate;
403-
let has_stalled_infers = match predicate.kind().skip_binder() {
404-
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) => {
405-
projection.projection_term.has_non_region_infer()
406-
}
407-
_ => predicate.has_non_region_infer(),
408-
};
409-
if has_stalled_infers {
410-
return;
411-
}
412-
413388
let rerun_result = delegate.commit_if_ok(|| {
414389
let (new_result, new_goal_evaluation) = evaluate_root_goal_for_proof_tree(
415390
delegate,
@@ -426,6 +401,7 @@ fn maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit<D, I>(
426401
}
427402
});
428403
if let Ok(rerun_result) = rerun_result {
404+
let predicate: I::Predicate = goal_evaluation.uncanonicalized_goal.predicate;
429405
delegate.cx().emit_next_solver_overflow_fcw(predicate, span);
430406
*initial_result = rerun_result;
431407
}

‎tests/ui/fn/fn-ptr-pattern.rs‎

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,77 @@
1-
fn patterns<F>(
2-
pat1: fn(true: bool),
1+
fn allowed<F>(
2+
data: &str,
3+
f1: fn(msg: String),
4+
f2: fn(_: String),
5+
f3: fn(String, msg: String),
6+
f4: fn(msg: String, String),
7+
f5: fn(duplicate_name: bool, duplicate_name: bool),
8+
) { }
9+
10+
11+
// Patterns are semantically rejected
12+
fn semantics<F>(
13+
pat1: fn(1..3: bool),
314
//~^ ERROR patterns aren't allowed in function pointer types
4-
pat2: fn(1..3: bool),
15+
pat2: fn((x, y): (bool, bool)),
516
//~^ ERROR patterns aren't allowed in function pointer types
6-
pat3: fn((x, y): (bool, bool)),
17+
pat3: fn(Thing { a, b }: Thing),
18+
//~^ ERROR patterns aren't allowed in function pointer types
19+
pat4: fn(NoThing { a, b }: NoThing),
20+
//~^ ERROR patterns aren't allowed in function pointer types
21+
//~| ERROR cannot find type `NoThing` in this scope
22+
pat5: fn((((((x))))): bool),
723
//~^ ERROR patterns aren't allowed in function pointer types
8-
pat4: fn(self),
24+
25+
self1: fn(self),
926
//~^ ERROR `self` parameter is only allowed in associated functions
10-
pat5: fn(self, self),
27+
self2: fn(self, self),
1128
//~^ ERROR `self` parameter is only allowed in associated functions
1229
//~| ERROR unexpected `self` parameter in function
13-
pat6: fn(bool, self),
30+
self3: fn(bool, self),
1431
//~^ ERROR unexpected `self` parameter in function
15-
pat7: fn(Thing { a, b }: Thing),
32+
33+
restricted_pat1: fn(mut x: ()),
1634
//~^ ERROR patterns aren't allowed in function pointer types
17-
pat8: fn(NoThing { a, b }: NoThing),
35+
restricted_pat2: fn(&x: ()),
1836
//~^ ERROR patterns aren't allowed in function pointer types
19-
//~| ERROR cannot find type `NoThing` in this scope
20-
pat9: fn((((((x))))): bool),
37+
restricted_pat3: fn(&&x: ()),
38+
//~^ ERROR patterns aren't allowed in function pointer types
39+
restricted_pat4: fn(false: ()),
40+
//~^ ERROR patterns aren't allowed in function pointer types
41+
restricted_pat5: fn(&_: ()),
42+
//~^ ERROR patterns aren't allowed in function pointer types
43+
restricted_pat6: fn(&true: ()),
2144
//~^ ERROR patterns aren't allowed in function pointer types
2245
) { }
2346

47+
// Patterns are also syntactically rejected, but restricted patterns are not
48+
#[cfg(false)]
49+
fn syntax<F>(
50+
pat1: fn(1..3: bool),
51+
//~^ ERROR patterns aren't allowed in function pointer types
52+
pat2: fn((x, y): (bool, bool)),
53+
//~^ ERROR patterns aren't allowed in function pointer types
54+
pat3: fn(Thing { a, b }: Thing),
55+
//~^ ERROR patterns aren't allowed in function pointer types
56+
pat4: fn(NoThing { a, b }: NoThing),
57+
//~^ ERROR patterns aren't allowed in function pointer types
58+
pat5: fn((((((x))))): bool),
59+
//~^ ERROR patterns aren't allowed in function pointer types
60+
61+
self1: fn(self),
62+
self2: fn(self, self),
63+
//~^ ERROR unexpected `self` parameter in function
64+
self3: fn(bool, self),
65+
//~^ ERROR unexpected `self` parameter in function
66+
67+
restricted_pat1: fn(mut x: ()),
68+
restricted_pat2: fn(&x: ()),
69+
restricted_pat3: fn(&&x: ()),
70+
restricted_pat4: fn(false: ()),
71+
restricted_pat5: fn(&_: ()),
72+
restricted_pat6: fn(&true: ()),
73+
) { }
74+
2475
struct Thing { a: bool, b: bool }
2576

2677
fn main() {

0 commit comments

Comments
 (0)