<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144509>144509</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`modernize-use-trailing-return-type` might show incorrect/imprecise type in fix-it hint for lamdba with iterator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
enhancement,
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
#include <algorithm>
#include <vector>
void f()
{
auto it = [](const std::vector<int>& v) {
return v.cbegin();
};
auto it2 = [](const std::vector<int>& v) {
return std::find_if(v.cbegin(), v.cend(), [](int i) -> bool {
return i == 0;
});
};
}
```
```
<source>:6:15: warning: use a trailing return type for this lambda [modernize-use-trailing-return-type]
6 | auto it = [](const std::vector<int>& v) {
| ^
| -> const_iterator
<source>:10:16: warning: use a trailing return type for this lambda [modernize-use-trailing-return-type]
10 | auto it2 = [](const std::vector<int>& v) {
| ^
| -> __gnu_cxx::__normal_iterator<const int *, std::vector<int>>
```
It should be suggesting `std::vector<int>::const_iterator` in both cases.
The second case might also happen for other types.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE-P6jYQ_zTOZRTk2PkDhxzyYJF67x05zpBM5djIdtjdfvrKBJbubp9UqU-NUMBj_Ps3k6gQaLSILat-sOqQqSVOzrdn8viqrpj1bnhvWc3Xj75cGO-YkGS1WQYEJvfKjM5TnGYmX75tXlFH5-87vLs6GuDMxJaJXao0PxjvAADUEh1QBCYPsCphYqudDRFCHJjsmOweWHuyMSGKGq5M7OCJki6PcfEWrhvd40j2ziUff2HNYV18Jha_jvnj1JnscKLk9osYsU_y0A7P9Qcz2QiUsHMmX6B3znxh-RsTJdFJN3_6e3j88Pw03BzS_dHKNYJPS7kPbvEak0XZ1Ux2RcVkB6_KW7Jj-rkEBAXRKzJkx4eQ-H5BODsPcaIARs39oJKl2Q3oLf2J-RIwf5zK11N5OpVMr8JrYM0efuUsPPCeF6tePu3eMr4hnyiiVwnyWw4FT7f6_wqi4F-D-O-z-T2Jf47idBrtctJvbyv06WSdn5V5hiP3K3uaUia6NLk_FbI-85_H7bcIYXKLGaBHCMs4YogpPlbzn-Ok4pcm1RzIQu_iBFoFDJsV_vcJIaB2driVYaZxiqBMcDCpywXtrTcuTuhvrQqbbGjlsJM7lWFbNBUvql3Dy2xq67NEXWwLbGrRCLHDUkjeDzuFjSoFYkat4KLiddEUhdiKclPzEqut3jZDoYtCnlnJcVZkNsZc543zY0YhLNgWZVnxXWZUjybcXrtC9MvIhGBiz4RAOymrcUYbP2raKDvmkYb3VKoOmW8Tat4vY2AlNxRiePJEigbTS_tfjF3N7ymFyb0CWe28Rx2ZONJ88agp4DrVZOFMbzlFmFL3U5BGzUOv4JXiBI_WZIs37RTjJaTGiSMTx5HitPQb7WYmjknk_Su_ePfHnSslE5g43sO5tuKvAAAA__9xtfDj">