rust/tests
bors 6e41e61977 Auto merge of #145314 - estebank:issue-135589-all, r=Nadrieril
Tweak output of missing lifetime on associated type

Follow up to https://github.com/rust-lang/rust/pull/135602.

Previously we only showed the trait's assoc item if the trait was local, because we were looking for a small span only for the generics, which we don't have for foreign traits. We now use `def_span` for the item, so we at least provide some context, even if its span is too wide.

```
error[E0195]: lifetime parameters or bounds on type `IntoIter` do not match the trait declaration
   --> tests/ui/lifetimes/missing-lifetime-in-assoc-type-4.rs:7:18
    |
7   |     type IntoIter<'a> = std::collections::btree_map::Values<'a, i32, T>;
    |                  ^^^^ lifetimes do not match type in trait
    |
   ::: /home/gh-estebank/rust/library/core/src/iter/traits/collect.rs:292:5
    |
292 |     type IntoIter: Iterator<Item = Self::Item>;
    |     ------------------------------------------ lifetimes in impl do not match this type in trait
```

Given an associated item that needs a named lifetime, look at the enclosing `impl` item for one. If there is none, look at the self type and the implemented trait to see if either of those has an anonimous lifetime. If so, suggest adding a named lifetime.

```
error: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
  --> $DIR/missing-lifetime-in-assoc-type-2.rs:5:17
   |
LL |     type Item = &T;
   |                 ^ this lifetime must come from the implemented type
   |
help: add a lifetime to the impl block and use it in the self type and associated type
   |
LL ~ impl<'a> IntoIterator for &'a S {
LL ~     type Item = &'a T;
   |
```

Move the previous long message to a note and use a shorter primary message:

```
error: missing lifetime in associated type
  --> $DIR/missing-lifetime-in-assoc-type-1.rs:9:17
   |
LL | impl<'a> IntoIterator for &S {
   |     ---- there is a named lifetime specified on the impl block you could use
...
LL |     type Item = &T;
   |                 ^ this lifetime must come from the implemented type
   |
note: in the trait the associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type
  --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: consider using the lifetime from the impl block
   |
LL |     type Item = &'a T;
   |                  ++
```

r? `@Nadrieril`
2025-11-04 21:37:44 +00:00
..
assembly-llvm Stabilize -Zjump-tables=<bool> into -Cjump-table=<bool> 2025-11-03 08:12:16 -06:00
auxiliary FCW for repr(C) enums whose discriminant values do not fit into a c_int 2025-11-04 11:44:55 +01:00
codegen-llvm Rollup merge of #145974 - pmur:murp/stabilize-zno-jump-tables, r=wesleywiser 2025-11-04 13:44:48 +11:00
codegen-units pub async fn implementation coroutine (func::{closure#0}) is monomorphized, when func itself is monomorphized 2025-09-01 13:45:00 +07:00
coverage Add coverage scope for controlling paths in code coverage 2025-10-27 12:54:24 +01:00
coverage-run-rustdoc
crashes Rollup merge of #147642 - camelid:misc-const-fixes, r=BoxyUwU 2025-11-02 15:56:48 +01:00
debuginfo Auto merge of #147728 - Enselic:gdbt-check-typo, r=Zalathar 2025-11-03 10:10:34 +00:00
incremental Add a fast path for lowering trivial consts 2025-10-25 16:59:53 -04:00
mir-opt Rollup merge of #135099 - Shunpoco:116971-mir-opt-copy-prop, r=davidtwco 2025-11-03 17:20:31 +01:00
pretty Remove QPath::LangItem from ranges 2025-10-27 21:19:38 -05:00
run-make Rollup merge of #148268 - notriddle:emit-scraped-examples, r=GuillaumeGomez 2025-11-03 17:20:37 +01:00
run-make-cargo Skip the panic-immediate-abort-works test when cross-compiling 2025-09-22 21:13:38 -04:00
rustdoc Move rustdoc tests to appropriate subdirectories 2025-10-26 19:16:41 -07:00
rustdoc-gui rustdoc-search: add test case for throbber 2025-10-07 12:59:58 -07:00
rustdoc-js Add regression test for including extern crates in import filtering 2025-11-01 00:13:19 +01:00
rustdoc-js-std Add regression test for including derive macros in macro filtering 2025-10-27 16:00:32 +01:00
rustdoc-json Add tests for doc(attribute = "...") attribute 2025-08-28 15:56:30 +02:00
rustdoc-ui Rollup merge of #148290 - oli-obk:push-qwxvxyopypry, r=nnethercote 2025-11-02 09:10:38 +01:00
ui Auto merge of #145314 - estebank:issue-135589-all, r=Nadrieril 2025-11-04 21:37:44 +00:00
ui-fulldeps When more than a single impl and less than 4 could apply, point at them 2025-10-31 20:44:01 +00:00
COMPILER_TESTS.md