rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.21k stars 12.81k forks source link

TyCtxt::variances_of is misdocumented as applying to a generic parameter #133494

Open btj opened 1 week ago

btj commented 1 week ago

Location

https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.variances_of

Summary

This method returns the variances of the generic parameters of the struct with the given def_id. Contrary to what the documentation suggests, when given the def_id of a generic parameter of a struct, it returns an empty slice.

fmease commented 1 week ago

Good catch, feel free to submit a patch!

Small correction: ... of the *item given by the DefId [where item refers to ADTs, lazy type aliases, free and associated functions].