Skip to content

Commit e2d99c1

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

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
@@ -1507,12 +1507,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15071507
// avoid inundating the user with unnecessary errors, but we now
15081508
// check upstream for type errors and don't add the obligations to
15091509
// begin with in those cases.
1510-
if self
1511-
.tcx
1512-
.lang_items()
1513-
.sized_trait()
1514-
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
1515-
{
1510+
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
15161511
self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0282).emit();
15171512
return;
15181513
}

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
@@ -839,7 +839,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
839839
let mut where_predicates =
840840
where_predicates.into_iter().flat_map(|p| p.clean(cx)).collect::<Vec<_>>();
841841

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

0 commit comments

Comments
 (0)