Bug 497866

Summary: Add a detach warning when a Qt container is converted to a QSpan / std::span
Product: [Developer tools] clazy Reporter: Giuseppe D'Angelo <dangelog>
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: REPORTED ---    
Severity: normal CC: smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Giuseppe D'Angelo 2024-12-24 14:58:49 UTC
The ranged constructors for QSpan and std::span will call .data() on the input. Even if the element type of the span is const, this will result in a detach if a Qt container is passed, e.g.

```
void f(std::span<const int> s); // will only read, never mutate

QList<int> list = ~~~;
f(list); // unnecessary detach here
```

Clazy should extend its "detach" family of warnings to cover this case, since span is vocabulary types, making the above error-prone.