Skip to content

Commit dd5e502

Browse files
committed
Auto merge of rust-lang#123327 - BoxyUwU:param_env_docs_rewrite, r=compiler-errors
Update `ParamEnv` docs There is now a wealth of information in the dev guide about `ParamEnv` so we should explicitly link to it from the doc comments. I also added a caution against using `ParamEnv` and removed the comment about it being "suitable for type checking" as you should practically never use `ParamEnv::empty` for type checking r? `@compiler-errors`
2 parents 1684a75 + 03dd329 commit dd5e502

File tree

1 file changed

+10
-5
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+10
-5
lines changed

compiler/rustc_middle/src/ty/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,11 @@ impl PlaceholderLike for PlaceholderConst {
10341034
}
10351035
}
10361036

1037-
/// When type checking, we use the `ParamEnv` to track
1038-
/// details about the set of where-clauses that are in scope at this
1039-
/// particular point.
1037+
/// When interacting with the type system we must provide information about the
1038+
/// environment. `ParamEnv` is the type that represents this information. See the
1039+
/// [dev guide chapter][param_env_guide] for more information.
1040+
///
1041+
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/param_env/param_env_summary.html
10401042
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
10411043
pub struct ParamEnv<'tcx> {
10421044
/// This packs both caller bounds and the reveal enum into one pointer.
@@ -1103,8 +1105,11 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ParamEnv<'tcx> {
11031105
impl<'tcx> ParamEnv<'tcx> {
11041106
/// Construct a trait environment suitable for contexts where
11051107
/// there are no where-clauses in scope. Hidden types (like `impl
1106-
/// Trait`) are left hidden, so this is suitable for ordinary
1107-
/// type-checking.
1108+
/// Trait`) are left hidden. In majority of cases it is incorrect
1109+
/// to use an empty environment. See the [dev guide section][param_env_guide]
1110+
/// for information on what a `ParamEnv` is and how to acquire one.
1111+
///
1112+
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/param_env/param_env_summary.html
11081113
#[inline]
11091114
pub fn empty() -> Self {
11101115
Self::new(List::empty(), Reveal::UserFacing)

0 commit comments

Comments
 (0)