         end
       end
 
-    failure_message_hit =
-      failure_message ||
-        quote do
-          """
-          Found message matching #{unquote(binary)} after #{timeout}ms.
-
-          This means the message was delivered too close to the timeout value, you may want to either:
-
-            1. Give an increased timeout to `assert_receive/2`
-            2. Increase the default timeout to all `assert_receive` in your
-               test_helper.exs by setting ExUnit.configure(assert_receive_timeout: ...)
-          """
-        end
-
-    failure_message_miss =
-      failure_message ||
-        quote do
-          "No message matching #{unquote(binary)} after #{timeout}ms."
-        end
-
     timeout =
       if is_integer(timeout) do
         timeout
       else
+        quote do: ExUnit.Assertions.__timeout__(unquote(timeout))
+      end
+
+    failure_message =
+      failure_message ||
         quote do
-          case unquote(timeout) do
-            timeout when is_integer(timeout) and timeout >= 0 ->
-              timeout
-
-            timeout ->
-              raise ArgumentError,
-                    "timeout must be a non-negative integer, got: #{inspect(timeout)}"
-          end
+          ExUnit.Assertions.__timeout__(
+            unquote(binary),
+            unquote(pins),
+            unquote(pattern_finder),
+            timeout
+          )
         end
-      end
 
     quote do
       timeout = unquote(timeout)
 
       {received, unquote(vars)} =
         receive do
-          unquote(pattern) ->
-            {received, unquote(vars)}
+          unquote(pattern) -> {received, unquote(vars)}
         after
-          timeout ->
-            {:messages, messages} = Process.info(self(), :messages)
-
-            if Enum.any?(messages, unquote(pattern_finder)) do
-              flunk(unquote(failure_message_hit))
-            else
-              flunk(
-                unquote(failure_message_miss) <>
-                  ExUnit.Assertions.__pins__(unquote(pins)) <>
-                  ExUnit.Assertions.__mailbox__(messages)
-              )
-            end
+          timeout -> flunk(unquote(failure_message))
         end
 
       received

  @max_mailbox_length 10

  @doc false
  def __mailbox__(messages) do
    length = length(messages)

    mailbox =
      messages
      |> Enum.take(@max_mailbox_length)
      |> Enum.map_join(@indent, &inspect/1)

    mailbox_message(length, @indent <> mailbox)
  end

  @doc false

        "expected:\n  #{inspect(message)}\n" <>
        "actual:\n" <> "  #{inspect(Exception.message(error))}"

    unless match?, do: flunk(message)

    error
  end
