1
Fork 0

Rollup merge of #137889 - mu001999-contrib:update-doc, r=wesleywiser

update outdated doc with new example

update the illegal definition example because we can compile `struct Ref<'a, T> { x: &'a T }` ([play](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=2eb2f8800d423c316b545c864623ae16))
This commit is contained in:
Matthias Krüger 2025-03-28 12:59:54 +01:00 committed by GitHub
commit 9597bf72dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -188,10 +188,10 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGua
/// definition itself. For example, this definition would be illegal:
///
/// ```rust
/// struct Ref<'a, T> { x: &'a T }
/// struct StaticRef<T> { x: &'static T }
/// ```
///
/// because the type did not declare that `T:'a`.
/// because the type did not declare that `T: 'static`.
///
/// We do this check as a pre-pass before checking fn bodies because if these constraints are
/// not included it frequently leads to confusing errors in fn bodies. So it's better to check