Rollup merge of #146987 - hkBst:sort-params-1, r=nnethercote

impl Ord for params and use unstable sort

AFAICT we are only sorting to find duplicates, so unstable sort should work fine, and maybe is a tiny bit faster?
This commit is contained in:
Stuart Cook 2025-09-29 21:06:45 +10:00 committed by GitHub
commit acd91e2fe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -4,7 +4,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeV
use rustc_span::Span;
use tracing::debug;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub(crate) struct Parameter(pub u32);
impl From<ty::ParamTy> for Parameter {

View file

@ -275,7 +275,7 @@ fn check_duplicate_params<'tcx>(
span: Span,
) -> Result<(), ErrorGuaranteed> {
let mut base_params = cgp::parameters_for(tcx, parent_args, true);
base_params.sort_by_key(|param| param.0);
base_params.sort_unstable();
if let (_, [duplicate, ..]) = base_params.partition_dedup() {
let param = impl1_args[duplicate.0 as usize];
return Err(tcx