Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc_middle::ty::{
};
use rustc_middle::util::Providers;
use rustc_session::config::CrateType;
use rustc_session::cstore::CrateDepKind;
use rustc_span::Span;
use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::{Arch, Os, TlsModel};
Expand Down Expand Up @@ -434,6 +435,14 @@ fn upstream_monomorphizations_provider(
let async_drop_in_place_fn_def_id = tcx.lang_items().async_drop_in_place_fn();

for &cnum in cnums.iter() {
// It should be possible to compile to build a crate against a conditional dependency then
// later link that crate without the conditional dependency, so we cannot use exported
// generics from conditional dependencies.
// https://github.com/rust-lang/rust/issues/159682
if tcx.crate_dep_kind(cnum) == CrateDepKind::Conditional {
continue;
}

for (exported_symbol, _) in tcx.exported_generic_symbols(cnum).iter() {
let (def_id, args) = match *exported_symbol {
ExportedSymbol::Generic(def_id, args) => (def_id, args),
Expand Down
26 changes: 1 addition & 25 deletions compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,6 @@ fn maybe_evaluate_root_goal_with_higher_recursion_limit<D, I>(
Ok(goal_evaluation) => goal_evaluation.goal.predicate,
};

// Some goals no longer overflow after the stalled infers are resolved.
// Thus we don't have to rerun eagerly here.
let has_stalled_infers = match predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) => {
projection.projection_term.has_non_region_infer()
}
_ => predicate.has_non_region_infer(),
};
if has_stalled_infers {
return;
}

let rerun_result = delegate.commit_if_ok(|| {
let rerun_result =
EvalCtxt::enter_root(delegate, delegate.cx().recursion_limit() * 2, span, |ecx| {
Expand Down Expand Up @@ -397,19 +385,6 @@ fn maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit<D, I>(
Ok(_) => {}
}

// Some goals no longer overflow after the stalled infers are resolved.
// Thus we don't have to rerun eagerly here.
let predicate: I::Predicate = goal_evaluation.uncanonicalized_goal.predicate;
let has_stalled_infers = match predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) => {
projection.projection_term.has_non_region_infer()
}
_ => predicate.has_non_region_infer(),
};
if has_stalled_infers {
return;
}

let rerun_result = delegate.commit_if_ok(|| {
let (new_result, new_goal_evaluation) = evaluate_root_goal_for_proof_tree(
delegate,
Expand All @@ -426,6 +401,7 @@ fn maybe_evaluate_root_goal_for_proof_tree_with_higher_recursion_limit<D, I>(
}
});
if let Ok(rerun_result) = rerun_result {
let predicate: I::Predicate = goal_evaluation.uncanonicalized_goal.predicate;
delegate.cx().emit_next_solver_overflow_fcw(predicate, span);
*initial_result = rerun_result;
}
Expand Down
73 changes: 62 additions & 11 deletions tests/ui/fn/fn-ptr-pattern.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,77 @@
fn patterns<F>(
pat1: fn(true: bool),
fn allowed<F>(
data: &str,
f1: fn(msg: String),
f2: fn(_: String),
f3: fn(String, msg: String),
f4: fn(msg: String, String),
f5: fn(duplicate_name: bool, duplicate_name: bool),
) { }


// Patterns are semantically rejected
fn semantics<F>(
pat1: fn(1..3: bool),
//~^ ERROR patterns aren't allowed in function pointer types
pat2: fn(1..3: bool),
pat2: fn((x, y): (bool, bool)),
//~^ ERROR patterns aren't allowed in function pointer types
pat3: fn((x, y): (bool, bool)),
pat3: fn(Thing { a, b }: Thing),
//~^ ERROR patterns aren't allowed in function pointer types
pat4: fn(NoThing { a, b }: NoThing),
//~^ ERROR patterns aren't allowed in function pointer types
//~| ERROR cannot find type `NoThing` in this scope
pat5: fn((((((x))))): bool),
//~^ ERROR patterns aren't allowed in function pointer types
pat4: fn(self),

self1: fn(self),
//~^ ERROR `self` parameter is only allowed in associated functions
pat5: fn(self, self),
self2: fn(self, self),
//~^ ERROR `self` parameter is only allowed in associated functions
//~| ERROR unexpected `self` parameter in function
pat6: fn(bool, self),
self3: fn(bool, self),
//~^ ERROR unexpected `self` parameter in function
pat7: fn(Thing { a, b }: Thing),

restricted_pat1: fn(mut x: ()),
//~^ ERROR patterns aren't allowed in function pointer types
pat8: fn(NoThing { a, b }: NoThing),
restricted_pat2: fn(&x: ()),
//~^ ERROR patterns aren't allowed in function pointer types
//~| ERROR cannot find type `NoThing` in this scope
pat9: fn((((((x))))): bool),
restricted_pat3: fn(&&x: ()),
//~^ ERROR patterns aren't allowed in function pointer types
restricted_pat4: fn(false: ()),
//~^ ERROR patterns aren't allowed in function pointer types
restricted_pat5: fn(&_: ()),
//~^ ERROR patterns aren't allowed in function pointer types
restricted_pat6: fn(&true: ()),
//~^ ERROR patterns aren't allowed in function pointer types
) { }

// Patterns are also syntactically rejected, but restricted patterns are not
#[cfg(false)]
fn syntax<F>(
pat1: fn(1..3: bool),
//~^ ERROR patterns aren't allowed in function pointer types
pat2: fn((x, y): (bool, bool)),
//~^ ERROR patterns aren't allowed in function pointer types
pat3: fn(Thing { a, b }: Thing),
//~^ ERROR patterns aren't allowed in function pointer types
pat4: fn(NoThing { a, b }: NoThing),
//~^ ERROR patterns aren't allowed in function pointer types
pat5: fn((((((x))))): bool),
//~^ ERROR patterns aren't allowed in function pointer types

self1: fn(self),
self2: fn(self, self),
//~^ ERROR unexpected `self` parameter in function
self3: fn(bool, self),
//~^ ERROR unexpected `self` parameter in function

restricted_pat1: fn(mut x: ()),
restricted_pat2: fn(&x: ()),
restricted_pat3: fn(&&x: ()),
restricted_pat4: fn(false: ()),
restricted_pat5: fn(&_: ()),
restricted_pat6: fn(&true: ()),
) { }

struct Thing { a: bool, b: bool }

fn main() {
Expand Down
Loading
Loading