Skip to content

Commit

Permalink
Fix future rustc lint rule on named lifetime elision (#13197) (#13199)
Browse files Browse the repository at this point in the history
This commit fixes a future lint rule that will appear in future version
of the rust compiler. The new rule will raise a warning at compile time
if the code used an elided lifetime resolves to a named lifetime. While
this typically would only cause an issue in unsafe rust, it can cause a
confusing error message in cases when using functions like this in a
safe context. This fixes the code violating this future rule to get
ahead of any potential errors when compiling with a release of Rust from
the near future.

This rule is documented here:

https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/builtin/static.ELIDED_NAMED_LIFETIMES.html
(cherry picked from commit 12ecea7)

Co-authored-by: Matthew Treinish <[email protected]>
  • Loading branch information
mergify[bot] and mtreinish authored Sep 20, 2024
1 parent bec0155 commit b15f8ca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/qasm3/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait PyRegister {
// or at a minimum
// fn iter<'a>(&'a self, py: Python<'a>) -> ::pyo3::types::iter::PyListIterator<'a>;
// but we can't use the former before Rust 1.75 and the latter before PyO3 0.21.
fn bit_list<'a>(&'a self, py: Python<'a>) -> &Bound<'a, PyList>;
fn bit_list<'a>(&'a self, py: Python<'a>) -> &'a Bound<'a, PyList>;
}

macro_rules! register_type {
Expand All @@ -38,7 +38,7 @@ macro_rules! register_type {
}

impl PyRegister for $name {
fn bit_list<'a>(&'a self, py: Python<'a>) -> &Bound<'a, PyList> {
fn bit_list<'a>(&'a self, py: Python<'a>) -> &'a Bound<'a, PyList> {
self.items.bind(py)
}
}
Expand Down Expand Up @@ -286,7 +286,7 @@ pub struct PyCircuit(Py<PyAny>);

impl PyCircuit {
/// Untyped access to the inner Python object.
pub fn inner<'a>(&'a self, py: Python<'a>) -> &Bound<'a, PyAny> {
pub fn inner<'a>(&'a self, py: Python<'a>) -> &'a Bound<'a, PyAny> {
self.0.bind(py)
}

Expand Down

0 comments on commit b15f8ca

Please sign in to comment.