From d8f7b831e72a421ffb60c60cb318342d4c409b62 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 15 Dec 2021 18:41:41 +0100 Subject: [PATCH] add regression test --- rust-version | 2 +- src/shims/foreign_items.rs | 2 +- tests/run-pass/issue-91636.rs | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/run-pass/issue-91636.rs diff --git a/rust-version b/rust-version index 3f00e3abe91..b517ff5b95c 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -404c8471aba60c2d837fa728e7c729a0f52d5830 +c5ecc157043ba413568b09292001a4a74b541a4e diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 4ec422cf1f8..42d7958b260 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -176,7 +176,7 @@ fn lookup_exported_symbol( if let Some((original_instance, original_cnum)) = instance_and_crate { // Make sure we are consistent wrt what is 'first' and 'second'. let original_span = tcx.def_span(original_instance.def_id()).data(); - let span = tcx.def_span(def_id).data(); + let span = tcx.def_span(def_id).data(); if original_span < span { throw_machine_stop!(TerminationInfo::MultipleSymbolDefinitions { link_name, diff --git a/tests/run-pass/issue-91636.rs b/tests/run-pass/issue-91636.rs new file mode 100644 index 00000000000..21000bb68d2 --- /dev/null +++ b/tests/run-pass/issue-91636.rs @@ -0,0 +1,20 @@ +type BuiltIn = for<'a> fn(&str); + +struct Function { + inner: BuiltIn, +} + +impl Function { + fn new(subr: BuiltIn) -> Self { + Self { inner: subr } + } +} + +fn dummy(_: &str) {} + +fn main() { + let func1 = Function::new(dummy); + let func2 = Function::new(dummy); + let inner: fn(&'static _) -> _ = func1.inner; + assert!(inner == func2.inner); +}