Repository: Qiskit/qiskit

Issue:
Fix bad references to deprecated `Bit` properties
Found in https://github.com/Qiskit/qiskit-terra/pull/9869.

```
test.python.visualization.test_circuit_latex.TestLatexSourceGenerator.test_teleport
-----------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/tmp/terra-tests/test/python/visualization/test_circuit_latex.py", line 144, in test_teleport
    circuit_drawer(circuit, filename=filename, output="latex_source")

      File "/home/vsts/work/1/s/qiskit/visualization/circuit/circuit_visualization.py", line 271, in circuit_drawer
    wire_order=wire_order,

      File "/home/vsts/work/1/s/qiskit/visualization/circuit/circuit_visualization.py", line 573, in _generate_latex_source
    latex = qcimg.latex()

      File "/home/vsts/work/1/s/qiskit/visualization/circuit/latex.py", line 214, in latex
    self._build_latex_array()

      File "/home/vsts/work/1/s/qiskit/visualization/circuit/latex.py", line 447, in _build_latex_array
    self._build_measure(node, column)

      File "/home/vsts/work/1/s/qiskit/visualization/circuit/latex.py", line 590, in _build_measure
    idx_str = str(node.cargs[0].index)

      File "/home/vsts/work/1/s/qiskit/utils/deprecation.py", line 91, in wrapper
    warnings.warn(msg, category=category, stacklevel=2)

    DeprecationWarning: The property ``qiskit.circuit.bit.Bit.index`` is deprecated as of qiskit-terra 0.17. It will be removed no earlier than 3 months after the release date. Instead, use the method ``QuantumCircuit.find_bit`` to find all the containing registers within a circuit and the index of the bit within the circuit.
```

```
test.python.visualization.timeline.test_layouts.TestBitArrange.test_qreg_creg_descending
----------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/tmp/terra-tests/test/python/visualization/timeline/test_layouts.py", line 48, in test_qreg_creg_descending
    sorted_regs = layouts.qreg_creg_descending(self.regs)

      File "/home/vsts/work/1/s/qiskit/visualization/timeline/layouts.py", line 114, in qreg_creg_descending
    qregs = sorted(qregs, key=lambda x: x.index, reverse=True)

      File "/home/vsts/work/1/s/qiskit/visualization/timeline/layouts.py", line 114, in <lambda>
    qregs = sorted(qregs, key=lambda x: x.index, reverse=True)

      File "/home/vsts/work/1/s/qiskit/utils/deprecation.py", line 91, in wrapper
    warnings.warn(msg, category=category, stacklevel=2)

    DeprecationWarning: The property ``qiskit.circuit.bit.Bit.index`` is deprecated as of qiskit-terra 0.17. It will be removed no earlier than 3 months after the release date. Instead, use the method ``QuantumCircuit.find_bit`` to find all the containing registers within a circuit and the index of the bit within the circuit.
```



Discussion:
Copied (in spirit) from internal Slack discussion:

I'd be surprised if this is the _only_ place using these deprecated properties still, but maybe we've cut more of them out than I thought.  There is an explicit filter to allow this particular warning in `QiskitTestCase` (a practice I disagree with, with regards to warnings raised by Terra!) - to find all the instances when running on `main`, one could comment out that filter then find and fix all the resulting test errors.

Resolving patch:
diff --git a/qiskit/visualization/circuit/latex.py b/qiskit/visualization/circuit/latex.py
--- a/qiskit/visualization/circuit/latex.py
+++ b/qiskit/visualization/circuit/latex.py
@@ -536,7 +536,7 @@ def _build_measure(self, node, col):
             register = get_bit_register(self._circuit, node.cargs[0])
             if register is not None:
                 wire2 = self._wire_map[register]
-                idx_str = str(node.cargs[0].index)
+                idx_str = str(self._circuit.find_bit(node.cargs[0]).registers[0][1])
             else:
                 wire2 = self._wire_map[node.cargs[0]]
 


Test patch: