Skip to content

Commit decffcb

Browse files
committed
Review comments
1 parent a1c267f commit decffcb

File tree

4 files changed

+130
-131
lines changed

4 files changed

+130
-131
lines changed

compiler/rustc_middle/src/traits/chalk.rs

+19-23
Original file line numberDiff line numberDiff line change
@@ -112,43 +112,39 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
112112
match application_ty.name {
113113
chalk_ir::TypeName::Ref(mutbl) => {
114114
let data = application_ty.substitution.interned();
115-
let lifetime = match &**data[0].interned() {
116-
chalk_ir::GenericArgData::Lifetime(t) => t,
115+
match (&**data[0].interned(), &**data[1].interned()) {
116+
(
117+
chalk_ir::GenericArgData::Lifetime(lifetime),
118+
chalk_ir::GenericArgData::Ty(ty),
119+
) => Some(match mutbl {
120+
chalk_ir::Mutability::Not => write!(fmt, "(&{:?} {:?})", lifetime, ty),
121+
chalk_ir::Mutability::Mut => write!(fmt, "(&{:?} mut {:?})", lifetime, ty),
122+
}),
117123
_ => unreachable!(),
118-
};
119-
let ty = match &**data[1].interned() {
120-
chalk_ir::GenericArgData::Ty(t) => t,
121-
_ => unreachable!(),
122-
};
123-
return Some(match mutbl {
124-
chalk_ir::Mutability::Not => write!(fmt, "(&{:?} {:?})", lifetime, ty),
125-
chalk_ir::Mutability::Mut => write!(fmt, "(&{:?} mut {:?})", lifetime, ty),
126-
});
124+
}
127125
}
128126
chalk_ir::TypeName::Array => {
129127
let data = application_ty.substitution.interned();
130-
let ty = match &**data[0].interned() {
131-
chalk_ir::GenericArgData::Ty(t) => t,
132-
_ => unreachable!(),
133-
};
134-
let len = match &**data[1].interned() {
135-
chalk_ir::GenericArgData::Const(t) => t,
128+
match (&**data[0].interned(), &**data[1].interned()) {
129+
(chalk_ir::GenericArgData::Ty(ty), chalk_ir::GenericArgData::Const(len)) => {
130+
Some(write!(fmt, "[{:?}; {:?}]", ty, len))
131+
}
136132
_ => unreachable!(),
137-
};
138-
return Some(write!(fmt, "[{:?}; {:?}]", ty, len));
133+
}
139134
}
140135
chalk_ir::TypeName::Slice => {
141136
let data = application_ty.substitution.interned();
142137
let ty = match &**data[0].interned() {
143138
chalk_ir::GenericArgData::Ty(t) => t,
144139
_ => unreachable!(),
145140
};
146-
return Some(write!(fmt, "[{:?}]", ty));
141+
Some(write!(fmt, "[{:?}]", ty))
142+
}
143+
_ => {
144+
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
145+
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
147146
}
148-
_ => {}
149147
}
150-
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
151-
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
152148
}
153149

154150
fn debug_substitution(

0 commit comments

Comments
 (0)