Skip to content

Commit 0bcc96d

Browse files
authored
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Some cleanup changes and commenting r? @nikomatsakis Cc @eddyb
2 parents 1ff91d6 + caf6c92 commit 0bcc96d

File tree

4 files changed

+13
-22
lines changed
  • compiler
    • rustc_middle/src/ty
    • rustc_trait_selection/src/traits/error_reporting
    • rustc_traits/src/chalk
  • src/librustdoc/clean

4 files changed

+13
-22
lines changed

compiler/rustc_middle/src/ty/sty.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,12 @@ impl<'tcx> TyS<'tcx> {
22802280
///
22812281
/// Returning true means the type is known to be sized. Returning
22822282
/// `false` means nothing -- could be sized, might not be.
2283+
///
2284+
/// Note that we could never rely on the fact that a type such as `[_]` is
2285+
/// trivially `!Sized` because we could be in a type environment with a
2286+
/// bound such as `[_]: Copy`. A function with such a bound obviously never
2287+
/// can be called, but that doesn't mean it shouldn't typecheck. This is why
2288+
/// this method doesn't return `Option<bool>`.
22832289
pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool {
22842290
match self.kind() {
22852291
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1512,12 +1512,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15121512
// avoid inundating the user with unnecessary errors, but we now
15131513
// check upstream for type errors and don't add the obligations to
15141514
// begin with in those cases.
1515-
if self
1516-
.tcx
1517-
.lang_items()
1518-
.sized_trait()
1519-
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
1520-
{
1515+
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
15211516
self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0282).emit();
15221517
return;
15231518
}

compiler/rustc_traits/src/chalk/db.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,15 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
110110
.map(|i| chalk_ir::AssocTypeId(i.def_id))
111111
.collect();
112112

113-
let well_known = if self
114-
.interner
115-
.tcx
116-
.lang_items()
117-
.sized_trait()
118-
.map(|t| def_id == t)
119-
.unwrap_or(false)
120-
{
113+
let well_known = if self.interner.tcx.lang_items().sized_trait() == Some(def_id) {
121114
Some(chalk_solve::rust_ir::WellKnownTrait::Sized)
122-
} else if self.interner.tcx.lang_items().copy_trait().map(|t| def_id == t).unwrap_or(false)
123-
{
115+
} else if self.interner.tcx.lang_items().copy_trait() == Some(def_id) {
124116
Some(chalk_solve::rust_ir::WellKnownTrait::Copy)
125-
} else if self.interner.tcx.lang_items().clone_trait().map(|t| def_id == t).unwrap_or(false)
126-
{
117+
} else if self.interner.tcx.lang_items().clone_trait() == Some(def_id) {
127118
Some(chalk_solve::rust_ir::WellKnownTrait::Clone)
128-
} else if self.interner.tcx.lang_items().drop_trait().map(|t| def_id == t).unwrap_or(false)
129-
{
119+
} else if self.interner.tcx.lang_items().drop_trait() == Some(def_id) {
130120
Some(chalk_solve::rust_ir::WellKnownTrait::Drop)
131-
} else if self.interner.tcx.lang_items().fn_trait().map(|t| def_id == t).unwrap_or(false) {
121+
} else if self.interner.tcx.lang_items().fn_trait() == Some(def_id) {
132122
Some(chalk_solve::rust_ir::WellKnownTrait::Fn)
133123
} else if self
134124
.interner

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
840840
let mut where_predicates =
841841
where_predicates.into_iter().flat_map(|p| p.clean(cx)).collect::<Vec<_>>();
842842

843-
// Type parameters and have a Sized bound by default unless removed with
843+
// Type parameters have a Sized bound by default unless removed with
844844
// ?Sized. Scan through the predicates and mark any type parameter with
845845
// a Sized bound, removing the bounds as we find them.
846846
//

0 commit comments

Comments
 (0)