mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Auto merge of #154637 - JonathanBrouwer:rollup-fGsU36o, r=JonathanBrouwer
Rollup of 12 pull requests Successful merges: - rust-lang/rust#154419 (Take first task group for further execution) - rust-lang/rust#154569 (Fix type alias where clause suggestion spacing issue) - rust-lang/rust#154617 (Update flate2 users to use zlib-rs) - rust-lang/rust#154618 (Fix AtomicPtr::update's cfg gate) - rust-lang/rust#154620 (stabilize new Range type and iterator) - rust-lang/rust#151932 (refactor: remove `Adjust::ReborrowPin`) - rust-lang/rust#153980 (refactor: move doc(rust_logo) check to parser) - rust-lang/rust#154134 (fix: guard paren-sugar pretty-printing on short trait args) - rust-lang/rust#154270 (Create `Ty` type alias in `rustc_type_ir`) - rust-lang/rust#154580 (Split AttributeParserError Diagnostic implementation into subfunctions) - rust-lang/rust#154606 (misc test cleanups) - rust-lang/rust#154612 (Add a test for a now fixed ICE with `offset_of!()`)
This commit is contained in:
+9
-2
@@ -1422,12 +1422,13 @@ checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.5"
|
||||
version = "1.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb"
|
||||
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
"zlib-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6973,3 +6974,9 @@ dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.110",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zlib-rs"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513"
|
||||
|
||||
@@ -173,17 +173,19 @@ fn check_type_alias_where_clause_location(
|
||||
{
|
||||
let mut state = State::new();
|
||||
|
||||
let mut needs_comma = !ty_alias.after_where_clause.predicates.is_empty();
|
||||
if !ty_alias.after_where_clause.has_where_token {
|
||||
state.space();
|
||||
state.word_space("where");
|
||||
} else if !needs_comma {
|
||||
state.space();
|
||||
}
|
||||
|
||||
let mut first = ty_alias.after_where_clause.predicates.is_empty();
|
||||
for p in &ty_alias.generics.where_clause.predicates {
|
||||
if !first {
|
||||
if needs_comma {
|
||||
state.word_space(",");
|
||||
}
|
||||
first = false;
|
||||
needs_comma = true;
|
||||
state.print_where_predicate(p);
|
||||
}
|
||||
|
||||
@@ -1832,7 +1834,11 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
|
||||
Some((right, snippet))
|
||||
}
|
||||
};
|
||||
let left_sp = err.span;
|
||||
let left_sp = self
|
||||
.sess
|
||||
.source_map()
|
||||
.span_extend_prev_while(err.span, char::is_whitespace)
|
||||
.unwrap_or(err.span);
|
||||
self.lint_buffer.dyn_buffer_lint(
|
||||
DEPRECATED_WHERE_CLAUSE_LOCATION,
|
||||
item.id,
|
||||
@@ -1846,9 +1852,9 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
|
||||
sugg,
|
||||
}
|
||||
}
|
||||
None => {
|
||||
errors::DeprecatedWhereClauseLocationSugg::RemoveWhere { span: left_sp }
|
||||
}
|
||||
None => errors::DeprecatedWhereClauseLocationSugg::RemoveWhere {
|
||||
span: err.span,
|
||||
},
|
||||
};
|
||||
errors::DeprecatedWhereClauseLocation { suggestion }.into_diag(dcx, level)
|
||||
},
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use rustc_ast::ast::{AttrStyle, LitKind, MetaItemLit};
|
||||
use rustc_errors::msg;
|
||||
use rustc_feature::template;
|
||||
use rustc_hir::Target;
|
||||
use rustc_hir::attrs::{
|
||||
AttributeKind, CfgEntry, CfgHideShow, CfgInfo, DocAttribute, DocInline, HideOrShow,
|
||||
};
|
||||
use rustc_hir::lints::AttributeLintKind;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::{Span, Symbol, edition, sym};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
@@ -481,15 +483,19 @@ macro_rules! no_args_and_not_crate_level {
|
||||
}
|
||||
macro_rules! no_args_and_crate_level {
|
||||
($ident: ident) => {{
|
||||
no_args_and_crate_level!($ident, |span| {});
|
||||
}};
|
||||
($ident: ident, |$span:ident| $extra_validation:block) => {{
|
||||
if let Err(span) = args.no_args() {
|
||||
expected_no_args(cx, span);
|
||||
return;
|
||||
}
|
||||
let span = path.span();
|
||||
if !check_attr_crate_level(cx, span) {
|
||||
let $span = path.span();
|
||||
if !check_attr_crate_level(cx, $span) {
|
||||
return;
|
||||
}
|
||||
self.attribute.$ident = Some(span);
|
||||
$extra_validation
|
||||
self.attribute.$ident = Some($span);
|
||||
}};
|
||||
}
|
||||
macro_rules! string_arg_and_crate_level {
|
||||
@@ -553,7 +559,17 @@ macro_rules! string_arg_and_crate_level {
|
||||
),
|
||||
Some(sym::fake_variadic) => no_args_and_not_crate_level!(fake_variadic),
|
||||
Some(sym::search_unbox) => no_args_and_not_crate_level!(search_unbox),
|
||||
Some(sym::rust_logo) => no_args_and_crate_level!(rust_logo),
|
||||
Some(sym::rust_logo) => no_args_and_crate_level!(rust_logo, |span| {
|
||||
if !cx.features().rustdoc_internals() {
|
||||
feature_err(
|
||||
cx.sess(),
|
||||
sym::rustdoc_internals,
|
||||
span,
|
||||
msg!("the `#[doc(rust_logo)]` attribute is used for Rust branding"),
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}),
|
||||
Some(sym::auto_cfg) => self.parse_auto_cfg(cx, path, args),
|
||||
Some(sym::test) => {
|
||||
let Some(list) = args.list() else {
|
||||
|
||||
@@ -594,29 +594,108 @@ pub(crate) struct AttributeParseError<'a> {
|
||||
pub(crate) suggestions: Vec<String>,
|
||||
}
|
||||
|
||||
impl<'a> AttributeParseError<'a> {
|
||||
fn render_expected_specific_argument<G>(
|
||||
&self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
possibilities: &[Symbol],
|
||||
strings: bool,
|
||||
) where
|
||||
G: EmissionGuarantee,
|
||||
{
|
||||
let quote = if strings { '"' } else { '`' };
|
||||
match possibilities {
|
||||
&[] => {}
|
||||
&[x] => {
|
||||
diag.span_label(
|
||||
self.span,
|
||||
format!("the only valid argument here is {quote}{x}{quote}"),
|
||||
);
|
||||
}
|
||||
[first, second] => {
|
||||
diag.span_label(
|
||||
self.span,
|
||||
format!("valid arguments are {quote}{first}{quote} or {quote}{second}{quote}"),
|
||||
);
|
||||
}
|
||||
[first @ .., second_to_last, last] => {
|
||||
let mut res = String::new();
|
||||
for i in first {
|
||||
res.push_str(&format!("{quote}{i}{quote}, "));
|
||||
}
|
||||
res.push_str(&format!("{quote}{second_to_last}{quote} or {quote}{last}{quote}"));
|
||||
|
||||
diag.span_label(self.span, format!("valid arguments are {res}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_expected_specific_argument_list<G>(
|
||||
&self,
|
||||
diag: &mut Diag<'_, G>,
|
||||
possibilities: &[Symbol],
|
||||
strings: bool,
|
||||
) where
|
||||
G: EmissionGuarantee,
|
||||
{
|
||||
let description = self.description();
|
||||
|
||||
let quote = if strings { '"' } else { '`' };
|
||||
match possibilities {
|
||||
&[] => {}
|
||||
&[x] => {
|
||||
diag.span_label(
|
||||
self.span,
|
||||
format!(
|
||||
"this {description} is only valid with {quote}{x}{quote} as an argument"
|
||||
),
|
||||
);
|
||||
}
|
||||
[first, second] => {
|
||||
diag.span_label(self.span, format!("this {description} is only valid with either {quote}{first}{quote} or {quote}{second}{quote} as an argument"));
|
||||
}
|
||||
[first @ .., second_to_last, last] => {
|
||||
let mut res = String::new();
|
||||
for i in first {
|
||||
res.push_str(&format!("{quote}{i}{quote}, "));
|
||||
}
|
||||
res.push_str(&format!("{quote}{second_to_last}{quote} or {quote}{last}{quote}"));
|
||||
|
||||
diag.span_label(self.span, format!("this {description} is only valid with one of the following arguments: {res}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn description(&self) -> &'static str {
|
||||
match self.description {
|
||||
ParsedDescription::Attribute => "attribute",
|
||||
ParsedDescription::Macro => "macro",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
||||
let name = self.path.to_string();
|
||||
|
||||
let description = match self.description {
|
||||
ParsedDescription::Attribute => "attribute",
|
||||
ParsedDescription::Macro => "macro",
|
||||
};
|
||||
let description = self.description();
|
||||
|
||||
let mut diag = Diag::new(dcx, level, format!("malformed `{name}` {description} input"));
|
||||
diag.span(self.attr_span);
|
||||
diag.code(E0539);
|
||||
match self.reason {
|
||||
match &self.reason {
|
||||
AttributeParseErrorReason::ExpectedStringLiteral { byte_string } => {
|
||||
if let Some(start_point_span) = byte_string {
|
||||
diag.span_suggestion(
|
||||
start_point_span,
|
||||
*start_point_span,
|
||||
"consider removing the prefix",
|
||||
"",
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
diag.note("expected a normal string literal, not a byte string literal");
|
||||
|
||||
// Avoid emitting an "attribute must be of the form" suggestion, as the
|
||||
// attribute is likely to be well-formed already.
|
||||
return diag;
|
||||
} else {
|
||||
diag.span_label(self.span, "expected a string literal here");
|
||||
@@ -693,62 +772,14 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
||||
strings,
|
||||
list: false,
|
||||
} => {
|
||||
let quote = if strings { '"' } else { '`' };
|
||||
match possibilities {
|
||||
&[] => {}
|
||||
&[x] => {
|
||||
diag.span_label(
|
||||
self.span,
|
||||
format!("the only valid argument here is {quote}{x}{quote}"),
|
||||
);
|
||||
}
|
||||
[first, second] => {
|
||||
diag.span_label(self.span, format!("valid arguments are {quote}{first}{quote} or {quote}{second}{quote}"));
|
||||
}
|
||||
[first @ .., second_to_last, last] => {
|
||||
let mut res = String::new();
|
||||
for i in first {
|
||||
res.push_str(&format!("{quote}{i}{quote}, "));
|
||||
}
|
||||
res.push_str(&format!(
|
||||
"{quote}{second_to_last}{quote} or {quote}{last}{quote}"
|
||||
));
|
||||
|
||||
diag.span_label(self.span, format!("valid arguments are {res}"));
|
||||
}
|
||||
}
|
||||
self.render_expected_specific_argument(&mut diag, *possibilities, *strings);
|
||||
}
|
||||
AttributeParseErrorReason::ExpectedSpecificArgument {
|
||||
possibilities,
|
||||
strings,
|
||||
list: true,
|
||||
} => {
|
||||
let quote = if strings { '"' } else { '`' };
|
||||
match possibilities {
|
||||
&[] => {}
|
||||
&[x] => {
|
||||
diag.span_label(
|
||||
self.span,
|
||||
format!(
|
||||
"this {description} is only valid with {quote}{x}{quote} as an argument"
|
||||
),
|
||||
);
|
||||
}
|
||||
[first, second] => {
|
||||
diag.span_label(self.span, format!("this {description} is only valid with either {quote}{first}{quote} or {quote}{second}{quote} as an argument"));
|
||||
}
|
||||
[first @ .., second_to_last, last] => {
|
||||
let mut res = String::new();
|
||||
for i in first {
|
||||
res.push_str(&format!("{quote}{i}{quote}, "));
|
||||
}
|
||||
res.push_str(&format!(
|
||||
"{quote}{second_to_last}{quote} or {quote}{last}{quote}"
|
||||
));
|
||||
|
||||
diag.span_label(self.span, format!("this {description} is only valid with one of the following arguments: {res}"));
|
||||
}
|
||||
}
|
||||
self.render_expected_specific_argument_list(&mut diag, *possibilities, *strings);
|
||||
}
|
||||
AttributeParseErrorReason::ExpectedIdentifier => {
|
||||
diag.span_label(self.span, "expected a valid identifier here");
|
||||
|
||||
@@ -145,7 +145,9 @@ fn par_slice<I: DynSend>(
|
||||
|
||||
const MAX_GROUP_COUNT: usize = 128;
|
||||
let group_size = items.len().div_ceil(MAX_GROUP_COUNT);
|
||||
let groups = items.chunks_mut(group_size);
|
||||
let mut groups = items.chunks_mut(group_size);
|
||||
|
||||
let Some(first_group) = groups.next() else { return };
|
||||
|
||||
// Reverse the order of the later functions since Rayon executes them in reverse
|
||||
// order when using a single thread. This ensures the execution order matches
|
||||
@@ -159,6 +161,11 @@ fn par_slice<I: DynSend>(
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Run the first function without spawning to avoid overwhelming stealing.
|
||||
for i in first_group.iter_mut() {
|
||||
guard.run(|| for_each(i));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -751,16 +751,6 @@ fn walk_adjustment(&self, expr: &hir::Expr<'_>) -> Result<(), Cx::Error> {
|
||||
adjustment::Adjust::Borrow(ref autoref) => {
|
||||
self.walk_autoref(expr, &place_with_id, autoref);
|
||||
}
|
||||
|
||||
adjustment::Adjust::ReborrowPin(mutbl) => {
|
||||
// Reborrowing a Pin is like a combinations of a deref and a borrow, so we do
|
||||
// both.
|
||||
let bk = match mutbl {
|
||||
ty::Mutability::Not => ty::BorrowKind::Immutable,
|
||||
ty::Mutability::Mut => ty::BorrowKind::Mutable,
|
||||
};
|
||||
self.delegate.borrow_mut().borrow(&place_with_id, place_with_id.hir_id, bk);
|
||||
}
|
||||
}
|
||||
place_with_id = self.cat_expr_adjusted(expr, place_with_id, adjustment)?;
|
||||
}
|
||||
@@ -1292,8 +1282,7 @@ fn cat_expr_adjusted_with<F>(
|
||||
|
||||
adjustment::Adjust::NeverToAny
|
||||
| adjustment::Adjust::Pointer(_)
|
||||
| adjustment::Adjust::Borrow(_)
|
||||
| adjustment::Adjust::ReborrowPin(..) => {
|
||||
| adjustment::Adjust::Borrow(_) => {
|
||||
// Result is an rvalue.
|
||||
Ok(self.cat_rvalue(expr.hir_id, target))
|
||||
}
|
||||
|
||||
@@ -337,10 +337,6 @@ pub(crate) fn apply_adjustments(&self, expr: &hir::Expr<'_>, adj: Vec<Adjustment
|
||||
Adjust::Pointer(_pointer_coercion) => {
|
||||
// FIXME(const_trait_impl): We should probably enforce these.
|
||||
}
|
||||
Adjust::ReborrowPin(_mutability) => {
|
||||
// FIXME(const_trait_impl): We could enforce these; they correspond to
|
||||
// `&mut T: DerefMut` tho, so it's kinda moot.
|
||||
}
|
||||
Adjust::Borrow(_) => {
|
||||
// No effects to enforce here.
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
};
|
||||
use rustc_middle::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::adjustment::{
|
||||
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion,
|
||||
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, DerefAdjustKind,
|
||||
PointerCoercion,
|
||||
};
|
||||
use rustc_middle::ty::{
|
||||
self, AssocContainer, GenericArgs, GenericArgsRef, GenericParamDefKind, Ty, TyCtxt,
|
||||
@@ -243,12 +244,16 @@ fn adjust_self_ty(
|
||||
ty::Ref(_, ty, _) => *ty,
|
||||
_ => bug!("Expected a reference type for argument to Pin"),
|
||||
};
|
||||
adjustments.push(Adjustment {
|
||||
kind: Adjust::Deref(DerefAdjustKind::Pin),
|
||||
target: inner_ty,
|
||||
});
|
||||
Ty::new_pinned_ref(self.tcx, region, inner_ty, mutbl)
|
||||
}
|
||||
_ => bug!("Cannot adjust receiver type for reborrowing pin of {target:?}"),
|
||||
};
|
||||
|
||||
adjustments.push(Adjustment { kind: Adjust::ReborrowPin(mutbl), target });
|
||||
adjustments
|
||||
.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Pin(mutbl)), target });
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
|
||||
#![cfg_attr(all(feature = "nightly", test), feature(test))]
|
||||
#![cfg_attr(feature = "nightly", feature(extend_one, step_trait))]
|
||||
#![cfg_attr(feature = "nightly", feature(new_range_api))]
|
||||
// tidy-alphabetical-end
|
||||
|
||||
// FIXME(#125687): new_range_api recently stabilized
|
||||
// Remove this when it hits stable. cfg(bootstrap)
|
||||
#![allow(stable_features)]
|
||||
#![cfg_attr(feature = "nightly", feature(new_range_api))]
|
||||
|
||||
pub mod bit_set;
|
||||
#[cfg(feature = "nightly")]
|
||||
pub mod interval;
|
||||
|
||||
@@ -172,7 +172,6 @@ fn has_implicit_borrow(Adjustment { kind, .. }: &Adjustment<'_>) -> Option<(Muta
|
||||
&Adjust::Borrow(AutoBorrow::Ref(mutbl)) => Some((mutbl.into(), false)),
|
||||
Adjust::NeverToAny
|
||||
| Adjust::Pointer(..)
|
||||
| Adjust::ReborrowPin(..)
|
||||
| Adjust::Deref(DerefAdjustKind::Builtin | DerefAdjustKind::Pin)
|
||||
| Adjust::Borrow(AutoBorrow::RawPtr(..) | AutoBorrow::Pin(..)) => None,
|
||||
}
|
||||
|
||||
@@ -103,10 +103,6 @@ pub enum Adjust {
|
||||
Borrow(AutoBorrow),
|
||||
|
||||
Pointer(PointerCoercion),
|
||||
|
||||
/// Take a pinned reference and reborrow as a `Pin<&mut T>` or `Pin<&T>`.
|
||||
// FIXME(pin_ergonomics): This can be replaced with a `Deref(Pin)` followed by a `Borrow(Pin)`
|
||||
ReborrowPin(hir::Mutability),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
|
||||
|
||||
@@ -3327,7 +3327,8 @@ macro_rules! define_print_and_forward_display {
|
||||
TraitRefPrintSugared<'tcx> {
|
||||
if !with_reduced_queries()
|
||||
&& p.tcx().trait_def(self.0.def_id).paren_sugar
|
||||
&& let ty::Tuple(args) = self.0.args.type_at(1).kind()
|
||||
&& let Some(args_ty) = self.0.args.get(1).and_then(|arg| arg.as_type())
|
||||
&& let ty::Tuple(args) = args_ty.kind()
|
||||
{
|
||||
write!(p, "{}(", p.tcx().item_name(self.0.def_id))?;
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
|
||||
@@ -218,68 +218,6 @@ fn apply_adjustment(
|
||||
base: AdtExprBase::None,
|
||||
}));
|
||||
|
||||
debug!(?kind);
|
||||
kind
|
||||
}
|
||||
Adjust::ReborrowPin(mutbl) => {
|
||||
debug!("apply ReborrowPin adjustment");
|
||||
// Rewrite `$expr` as `Pin { __pointer: &(mut)? *($expr).__pointer }`
|
||||
|
||||
// We'll need these types later on
|
||||
let pin_ty_args = match expr.ty.kind() {
|
||||
ty::Adt(_, args) => args,
|
||||
_ => bug!("ReborrowPin with non-Pin type"),
|
||||
};
|
||||
let pin_ty = pin_ty_args.iter().next().unwrap().expect_ty();
|
||||
let ptr_target_ty = match pin_ty.kind() {
|
||||
ty::Ref(_, ty, _) => *ty,
|
||||
_ => bug!("ReborrowPin with non-Ref type"),
|
||||
};
|
||||
|
||||
// pointer = ($expr).__pointer
|
||||
let pointer_target = ExprKind::Field {
|
||||
lhs: self.thir.exprs.push(expr),
|
||||
variant_index: FIRST_VARIANT,
|
||||
name: FieldIdx::ZERO,
|
||||
};
|
||||
let arg = Expr { temp_scope_id, ty: pin_ty, span, kind: pointer_target };
|
||||
let arg = self.thir.exprs.push(arg);
|
||||
|
||||
// arg = *pointer
|
||||
let expr = ExprKind::Deref { arg };
|
||||
let arg = self.thir.exprs.push(Expr {
|
||||
temp_scope_id,
|
||||
ty: ptr_target_ty,
|
||||
span,
|
||||
kind: expr,
|
||||
});
|
||||
|
||||
// expr = &mut target
|
||||
let borrow_kind = match mutbl {
|
||||
hir::Mutability::Mut => BorrowKind::Mut { kind: mir::MutBorrowKind::Default },
|
||||
hir::Mutability::Not => BorrowKind::Shared,
|
||||
};
|
||||
let new_pin_target =
|
||||
Ty::new_ref(self.tcx, self.tcx.lifetimes.re_erased, ptr_target_ty, mutbl);
|
||||
let expr = self.thir.exprs.push(Expr {
|
||||
temp_scope_id,
|
||||
ty: new_pin_target,
|
||||
span,
|
||||
kind: ExprKind::Borrow { borrow_kind, arg },
|
||||
});
|
||||
|
||||
// kind = Pin { __pointer: pointer }
|
||||
let pin_did = self.tcx.require_lang_item(rustc_hir::LangItem::Pin, span);
|
||||
let args = self.tcx.mk_args(&[new_pin_target.into()]);
|
||||
let kind = ExprKind::Adt(Box::new(AdtExpr {
|
||||
adt_def: self.tcx.adt_def(pin_did),
|
||||
variant_index: FIRST_VARIANT,
|
||||
args,
|
||||
fields: Box::new([FieldExpr { name: FieldIdx::ZERO, expr }]),
|
||||
user_ty: None,
|
||||
base: AdtExprBase::None,
|
||||
}));
|
||||
|
||||
debug!(?kind);
|
||||
kind
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ pub(super) struct Canonicalizer<'a, D: SolverDelegate<Interner = I>, I: Interner
|
||||
|
||||
/// We can simply cache based on the ty itself, because we use
|
||||
/// `ty::BoundVarIndexKind::Canonical`.
|
||||
cache: HashMap<I::Ty, I::Ty>,
|
||||
cache: HashMap<ty::Ty<I>, ty::Ty<I>>,
|
||||
}
|
||||
|
||||
impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
|
||||
@@ -316,7 +316,7 @@ fn finalize(self) -> (ty::UniverseIndex, Vec<I::GenericArg>, I::CanonicalVarKind
|
||||
(max_universe, self.variables, var_kinds)
|
||||
}
|
||||
|
||||
fn inner_fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn inner_fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
|
||||
let kind = match t.kind() {
|
||||
ty::Infer(i) => match i {
|
||||
ty::TyVar(vid) => {
|
||||
@@ -475,7 +475,7 @@ fn fold_region(&mut self, r: I::Region) -> I::Region {
|
||||
Region::new_canonical_bound(self.cx(), var)
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
|
||||
if !t.flags().intersects(NEEDS_CANONICAL) {
|
||||
t
|
||||
} else if let Some(&ty) = self.cache.get(&t) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use rustc_type_ir::inherent::*;
|
||||
use rustc_type_ir::relate::solver_relating::RelateExt;
|
||||
use rustc_type_ir::{
|
||||
self as ty, Canonical, CanonicalVarKind, CanonicalVarValues, InferCtxtLike, Interner,
|
||||
self as ty, Canonical, CanonicalVarKind, CanonicalVarValues, InferCtxtLike, Interner, Ty,
|
||||
TypeFoldable,
|
||||
};
|
||||
use tracing::instrument;
|
||||
@@ -53,7 +53,7 @@ fn var_values(&self) -> CanonicalVarValues<I> {
|
||||
pub(super) fn canonicalize_goal<D, I>(
|
||||
delegate: &D,
|
||||
goal: Goal<I, I::Predicate>,
|
||||
opaque_types: &[(ty::OpaqueTypeKey<I>, I::Ty)],
|
||||
opaque_types: &[(ty::OpaqueTypeKey<I>, Ty<I>)],
|
||||
) -> (Vec<I::GenericArg>, CanonicalInput<I, I::Predicate>)
|
||||
where
|
||||
D: SolverDelegate<Interner = I>,
|
||||
@@ -264,7 +264,7 @@ fn register_region_constraints<D, I>(
|
||||
|
||||
fn register_new_opaque_types<D, I>(
|
||||
delegate: &D,
|
||||
opaque_types: &[(ty::OpaqueTypeKey<I>, I::Ty)],
|
||||
opaque_types: &[(ty::OpaqueTypeKey<I>, Ty<I>)],
|
||||
span: I::Span,
|
||||
) where
|
||||
D: SolverDelegate<Interner = I>,
|
||||
|
||||
@@ -47,7 +47,7 @@ pub enum Conflict {
|
||||
pub fn trait_ref_is_knowable<Infcx, I, E>(
|
||||
infcx: &Infcx,
|
||||
trait_ref: ty::TraitRef<I>,
|
||||
mut lazily_normalize_ty: impl FnMut(I::Ty) -> Result<I::Ty, E>,
|
||||
mut lazily_normalize_ty: impl FnMut(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
|
||||
) -> Result<Result<(), Conflict>, E>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
@@ -115,14 +115,14 @@ fn from(b: bool) -> IsFirstInputType {
|
||||
|
||||
#[derive_where(Debug; I: Interner, T: Debug)]
|
||||
pub enum OrphanCheckErr<I: Interner, T> {
|
||||
NonLocalInputType(Vec<(I::Ty, IsFirstInputType)>),
|
||||
NonLocalInputType(Vec<(ty::Ty<I>, IsFirstInputType)>),
|
||||
UncoveredTyParams(UncoveredTyParams<I, T>),
|
||||
}
|
||||
|
||||
#[derive_where(Debug; I: Interner, T: Debug)]
|
||||
pub struct UncoveredTyParams<I: Interner, T> {
|
||||
pub uncovered: T,
|
||||
pub local_ty: Option<I::Ty>,
|
||||
pub local_ty: Option<ty::Ty<I>>,
|
||||
}
|
||||
|
||||
/// Checks whether a trait-ref is potentially implementable by a crate.
|
||||
@@ -222,8 +222,8 @@ pub fn orphan_check_trait_ref<Infcx, I, E: Debug>(
|
||||
infcx: &Infcx,
|
||||
trait_ref: ty::TraitRef<I>,
|
||||
in_crate: InCrate,
|
||||
lazily_normalize_ty: impl FnMut(I::Ty) -> Result<I::Ty, E>,
|
||||
) -> Result<Result<(), OrphanCheckErr<I, I::Ty>>, E>
|
||||
lazily_normalize_ty: impl FnMut(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
|
||||
) -> Result<Result<(), OrphanCheckErr<I, ty::Ty<I>>>, E>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
I: Interner,
|
||||
@@ -262,14 +262,14 @@ struct OrphanChecker<'a, Infcx, I: Interner, F> {
|
||||
lazily_normalize_ty: F,
|
||||
/// Ignore orphan check failures and exclusively search for the first local type.
|
||||
search_first_local_ty: bool,
|
||||
non_local_tys: Vec<(I::Ty, IsFirstInputType)>,
|
||||
non_local_tys: Vec<(ty::Ty<I>, IsFirstInputType)>,
|
||||
}
|
||||
|
||||
impl<'a, Infcx, I, F, E> OrphanChecker<'a, Infcx, I, F>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
I: Interner,
|
||||
F: FnOnce(I::Ty) -> Result<I::Ty, E>,
|
||||
F: FnOnce(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
|
||||
{
|
||||
fn new(infcx: &'a Infcx, in_crate: InCrate, lazily_normalize_ty: F) -> Self {
|
||||
OrphanChecker {
|
||||
@@ -282,12 +282,15 @@ fn new(infcx: &'a Infcx, in_crate: InCrate, lazily_normalize_ty: F) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
fn found_non_local_ty(&mut self, t: I::Ty) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
|
||||
fn found_non_local_ty(&mut self, t: ty::Ty<I>) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
|
||||
self.non_local_tys.push((t, self.in_self_ty.into()));
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn found_uncovered_ty_param(&mut self, ty: I::Ty) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
|
||||
fn found_uncovered_ty_param(
|
||||
&mut self,
|
||||
ty: ty::Ty<I>,
|
||||
) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
|
||||
if self.search_first_local_ty {
|
||||
return ControlFlow::Continue(());
|
||||
}
|
||||
@@ -305,15 +308,15 @@ fn def_id_is_local(&mut self, def_id: impl DefId<I>) -> bool {
|
||||
|
||||
enum OrphanCheckEarlyExit<I: Interner, E> {
|
||||
NormalizationFailure(E),
|
||||
UncoveredTyParam(I::Ty),
|
||||
LocalTy(I::Ty),
|
||||
UncoveredTyParam(ty::Ty<I>),
|
||||
LocalTy(ty::Ty<I>),
|
||||
}
|
||||
|
||||
impl<'a, Infcx, I, F, E> TypeVisitor<I> for OrphanChecker<'a, Infcx, I, F>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
I: Interner,
|
||||
F: FnMut(I::Ty) -> Result<I::Ty, E>,
|
||||
F: FnMut(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
|
||||
{
|
||||
type Result = ControlFlow<OrphanCheckEarlyExit<I, E>>;
|
||||
|
||||
@@ -321,7 +324,7 @@ fn visit_region(&mut self, _r: I::Region) -> Self::Result {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, ty: ty::Ty<I>) -> Self::Result {
|
||||
let ty = self.infcx.shallow_resolve(ty);
|
||||
let ty = match (self.lazily_normalize_ty)(ty) {
|
||||
Ok(norm_ty) if norm_ty.is_ty_var() => ty,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use rustc_type_ir::solve::{Certainty, Goal, NoSolution};
|
||||
use rustc_type_ir::{self as ty, InferCtxtLike, Interner, TypeFoldable};
|
||||
use rustc_type_ir::{self as ty, InferCtxtLike, Interner, Ty, TypeFoldable};
|
||||
|
||||
pub trait SolverDelegate: Deref<Target = Self::Infcx> + Sized {
|
||||
type Infcx: InferCtxtLike<Interner = Self::Interner>;
|
||||
@@ -70,7 +70,7 @@ fn add_item_bounds_for_hidden_type(
|
||||
def_id: <Self::Interner as Interner>::DefId,
|
||||
args: <Self::Interner as Interner>::GenericArgs,
|
||||
param_env: <Self::Interner as Interner>::ParamEnv,
|
||||
hidden_ty: <Self::Interner as Interner>::Ty,
|
||||
hidden_ty: Ty<Self::Interner>,
|
||||
goals: &mut Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>,
|
||||
);
|
||||
|
||||
@@ -86,8 +86,8 @@ fn fetch_eligible_assoc_item(
|
||||
|
||||
fn is_transmutable(
|
||||
&self,
|
||||
src: <Self::Interner as Interner>::Ty,
|
||||
dst: <Self::Interner as Interner>::Ty,
|
||||
src: Ty<Self::Interner>,
|
||||
dst: Ty<Self::Interner>,
|
||||
assume: <Self::Interner as Interner>::Const,
|
||||
) -> Result<Certainty, NoSolution>;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ fn fold_region(&mut self, r: I::Region) -> I::Region {
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
|
||||
match t.kind() {
|
||||
ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), _)
|
||||
if debruijn.as_usize() + 1
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use rustc_type_ir::data_structures::DelayedMap;
|
||||
use rustc_type_ir::inherent::*;
|
||||
use rustc_type_ir::{
|
||||
self as ty, InferCtxtLike, Interner, TypeFoldable, TypeFolder, TypeSuperFoldable,
|
||||
self as ty, InferCtxtLike, Interner, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable,
|
||||
TypeVisitableExt,
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ struct EagerResolver<'a, D, I = <D as SolverDelegate>::Interner>
|
||||
delegate: &'a D,
|
||||
/// We're able to use a cache here as the folder does not have any
|
||||
/// mutable state.
|
||||
cache: DelayedMap<I::Ty, I::Ty>,
|
||||
cache: DelayedMap<Ty<I>, Ty<I>>,
|
||||
}
|
||||
|
||||
pub fn eager_resolve_vars<D: SolverDelegate, T: TypeFoldable<D::Interner>>(
|
||||
@@ -45,7 +45,7 @@ fn cx(&self) -> I {
|
||||
self.delegate.cx()
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: Ty<I>) -> Ty<I> {
|
||||
match t.kind() {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
let resolved = self.delegate.opportunistic_resolve_ty_var(vid);
|
||||
|
||||
@@ -46,11 +46,11 @@ pub(super) trait GoalKind<D, I = <D as SolverDelegate>::Interner>:
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
{
|
||||
fn self_ty(self) -> I::Ty;
|
||||
fn self_ty(self) -> ty::Ty<I>;
|
||||
|
||||
fn trait_ref(self, cx: I) -> ty::TraitRef<I>;
|
||||
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: I::Ty) -> Self;
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: ty::Ty<I>) -> Self;
|
||||
|
||||
fn trait_def_id(self, cx: I) -> I::TraitId;
|
||||
|
||||
@@ -683,7 +683,7 @@ fn assemble_alias_bound_candidates<G: GoalKind<D>>(
|
||||
// hitting another overflow error something. Add a depth parameter needed later.
|
||||
fn assemble_alias_bound_candidates_recur<G: GoalKind<D>>(
|
||||
&mut self,
|
||||
self_ty: I::Ty,
|
||||
self_ty: ty::Ty<I>,
|
||||
goal: Goal<I, G>,
|
||||
candidates: &mut Vec<Candidate<I>>,
|
||||
consider_self_bounds: AliasBoundKind,
|
||||
@@ -1017,13 +1017,13 @@ fn try_assemble_bounds_via_registered_opaques<G: GoalKind<D>>(
|
||||
struct ReplaceOpaque<I: Interner> {
|
||||
cx: I,
|
||||
alias_ty: ty::AliasTy<I>,
|
||||
self_ty: I::Ty,
|
||||
self_ty: ty::Ty<I>,
|
||||
}
|
||||
impl<I: Interner> TypeFolder<I> for ReplaceOpaque<I> {
|
||||
fn cx(&self) -> I {
|
||||
self.cx
|
||||
}
|
||||
fn fold_ty(&mut self, ty: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, ty: ty::Ty<I>) -> ty::Ty<I> {
|
||||
if let ty::Alias(ty::Opaque, alias_ty) = ty.kind() {
|
||||
if alias_ty == self.alias_ty {
|
||||
return self.self_ty;
|
||||
@@ -1280,7 +1280,7 @@ fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::R
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, ty: ty::Ty<I>) -> Self::Result {
|
||||
let ty = self.ecx.replace_bound_vars(ty, &mut self.universes);
|
||||
let Ok(ty) = self.ecx.structurally_normalize_ty(self.param_env, ty) else {
|
||||
return ControlFlow::Break(Err(NoSolution));
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#[instrument(level = "trace", skip(ecx), ret)]
|
||||
pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<D, I>(
|
||||
ecx: &EvalCtxt<'_, D>,
|
||||
ty: I::Ty,
|
||||
) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution>
|
||||
ty: ty::Ty<I>,
|
||||
) -> Result<ty::Binder<I, Vec<ty::Ty<I>>>, NoSolution>
|
||||
where
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
@@ -108,8 +108,8 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<D, I>(
|
||||
pub(in crate::solve) fn instantiate_constituent_tys_for_sizedness_trait<D, I>(
|
||||
ecx: &EvalCtxt<'_, D>,
|
||||
sizedness: SizedTraitKind,
|
||||
ty: I::Ty,
|
||||
) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution>
|
||||
ty: ty::Ty<I>,
|
||||
) -> Result<ty::Binder<I, Vec<ty::Ty<I>>>, NoSolution>
|
||||
where
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
@@ -186,8 +186,8 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sizedness_trait<D, I>(
|
||||
#[instrument(level = "trace", skip(ecx), ret)]
|
||||
pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<D, I>(
|
||||
ecx: &EvalCtxt<'_, D>,
|
||||
ty: I::Ty,
|
||||
) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution>
|
||||
ty: ty::Ty<I>,
|
||||
) -> Result<ty::Binder<I, Vec<ty::Ty<I>>>, NoSolution>
|
||||
where
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
@@ -268,9 +268,9 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<D, I>(
|
||||
// Returns a binder of the tupled inputs types and output type from a builtin callable type.
|
||||
pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Interner>(
|
||||
cx: I,
|
||||
self_ty: I::Ty,
|
||||
self_ty: ty::Ty<I>,
|
||||
goal_kind: ty::ClosureKind,
|
||||
) -> Result<Option<ty::Binder<I, (I::Ty, I::Ty)>>, NoSolution> {
|
||||
) -> Result<Option<ty::Binder<I, (ty::Ty<I>, ty::Ty<I>)>>, NoSolution> {
|
||||
match self_ty.kind() {
|
||||
// keep this in sync with assemble_fn_pointer_candidates until the old solver is removed.
|
||||
ty::FnDef(def_id, args) => {
|
||||
@@ -408,13 +408,13 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
|
||||
#[derive_where(Clone, Copy, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
|
||||
pub(in crate::solve) struct AsyncCallableRelevantTypes<I: Interner> {
|
||||
pub tupled_inputs_ty: I::Ty,
|
||||
pub tupled_inputs_ty: ty::Ty<I>,
|
||||
/// Type returned by calling the closure
|
||||
/// i.e. `f()`.
|
||||
pub output_coroutine_ty: I::Ty,
|
||||
pub output_coroutine_ty: ty::Ty<I>,
|
||||
/// Type returned by `await`ing the output
|
||||
/// i.e. `f().await`.
|
||||
pub coroutine_return_ty: I::Ty,
|
||||
pub coroutine_return_ty: ty::Ty<I>,
|
||||
}
|
||||
|
||||
// Returns a binder of the tupled inputs types, output type, and coroutine type
|
||||
@@ -424,7 +424,7 @@ pub(in crate::solve) struct AsyncCallableRelevantTypes<I: Interner> {
|
||||
// know the kind already, we can short-circuit this check.
|
||||
pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I: Interner>(
|
||||
cx: I,
|
||||
self_ty: I::Ty,
|
||||
self_ty: ty::Ty<I>,
|
||||
goal_kind: ty::ClosureKind,
|
||||
env_region: I::Region,
|
||||
) -> Result<(ty::Binder<I, AsyncCallableRelevantTypes<I>>, Vec<I::Predicate>), NoSolution> {
|
||||
@@ -608,7 +608,7 @@ fn coroutine_closure_to_certain_coroutine<I: Interner>(
|
||||
def_id: I::CoroutineClosureId,
|
||||
args: ty::CoroutineClosureArgs<I>,
|
||||
sig: ty::CoroutineClosureSignature<I>,
|
||||
) -> I::Ty {
|
||||
) -> ty::Ty<I> {
|
||||
sig.to_coroutine_given_kind_and_upvars(
|
||||
cx,
|
||||
args.parent_args(),
|
||||
@@ -632,7 +632,7 @@ fn coroutine_closure_to_ambiguous_coroutine<I: Interner>(
|
||||
def_id: I::CoroutineClosureId,
|
||||
args: ty::CoroutineClosureArgs<I>,
|
||||
sig: ty::CoroutineClosureSignature<I>,
|
||||
) -> I::Ty {
|
||||
) -> ty::Ty<I> {
|
||||
let upvars_projection_def_id = cx.require_lang_item(SolverLangItem::AsyncFnKindUpvars);
|
||||
let tupled_upvars_ty = Ty::new_projection(
|
||||
cx,
|
||||
@@ -664,8 +664,8 @@ fn coroutine_closure_to_ambiguous_coroutine<I: Interner>(
|
||||
#[instrument(level = "trace", skip(cx), ret)]
|
||||
pub(in crate::solve) fn extract_fn_def_from_const_callable<I: Interner>(
|
||||
cx: I,
|
||||
self_ty: I::Ty,
|
||||
) -> Result<(ty::Binder<I, (I::Ty, I::Ty)>, I::DefId, I::GenericArgs), NoSolution> {
|
||||
self_ty: ty::Ty<I>,
|
||||
) -> Result<(ty::Binder<I, (ty::Ty<I>, ty::Ty<I>)>, I::DefId, I::GenericArgs), NoSolution> {
|
||||
match self_ty.kind() {
|
||||
ty::FnDef(def_id, args) => {
|
||||
let sig = cx.fn_sig(def_id);
|
||||
@@ -742,7 +742,7 @@ pub(in crate::solve) fn extract_fn_def_from_const_callable<I: Interner>(
|
||||
// the old solver, for as long as that exists.
|
||||
pub(in crate::solve) fn const_conditions_for_destruct<I: Interner>(
|
||||
cx: I,
|
||||
self_ty: I::Ty,
|
||||
self_ty: ty::Ty<I>,
|
||||
) -> Result<Vec<ty::TraitRef<I>>, NoSolution> {
|
||||
let destruct_def_id = cx.require_trait_lang_item(SolverTraitLangItem::Destruct);
|
||||
|
||||
@@ -927,7 +927,7 @@ pub(in crate::solve) fn predicates_for_object_candidate<D, I>(
|
||||
struct ReplaceProjectionWith<'a, 'b, I: Interner, D: SolverDelegate<Interner = I>> {
|
||||
ecx: &'a mut EvalCtxt<'b, D>,
|
||||
param_env: I::ParamEnv,
|
||||
self_ty: I::Ty,
|
||||
self_ty: ty::Ty<I>,
|
||||
mapping: &'a HashMap<I::DefId, Vec<ty::Binder<I, ty::ProjectionPredicate<I>>>>,
|
||||
nested: Vec<Goal<I, I::Predicate>>,
|
||||
}
|
||||
@@ -1013,7 +1013,7 @@ fn cx(&self) -> I {
|
||||
self.ecx.cx()
|
||||
}
|
||||
|
||||
fn try_fold_ty(&mut self, ty: I::Ty) -> Result<I::Ty, Ambiguous> {
|
||||
fn try_fold_ty(&mut self, ty: ty::Ty<I>) -> Result<ty::Ty<I>, Ambiguous> {
|
||||
if let ty::Alias(ty::Projection, alias_ty) = ty.kind()
|
||||
&& let Some(term) = self.try_eagerly_replace_alias(alias_ty.into())?
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
use crate::delegate::SolverDelegate;
|
||||
use crate::solve::{
|
||||
BuiltinImplSource, CandidateSource, Certainty, EvalCtxt, Goal, GoalSource, NoSolution,
|
||||
QueryResult, assembly,
|
||||
QueryResult, Ty, assembly,
|
||||
};
|
||||
|
||||
impl<D, I> assembly::GoalKind<D> for ty::HostEffectPredicate<I>
|
||||
@@ -21,7 +21,7 @@ impl<D, I> assembly::GoalKind<D> for ty::HostEffectPredicate<I>
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
{
|
||||
fn self_ty(self) -> I::Ty {
|
||||
fn self_ty(self) -> Ty<I> {
|
||||
self.self_ty()
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ fn trait_ref(self, _: I) -> ty::TraitRef<I> {
|
||||
self.trait_ref
|
||||
}
|
||||
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: I::Ty) -> Self {
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: Ty<I>) -> Self {
|
||||
self.with_replaced_self_ty(cx, self_ty)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use rustc_type_ir::search_graph::{CandidateHeadUsages, PathKind};
|
||||
use rustc_type_ir::solve::OpaqueTypesJank;
|
||||
use rustc_type_ir::{
|
||||
self as ty, CanonicalVarValues, InferCtxtLike, Interner, TypeFoldable, TypeFolder,
|
||||
self as ty, CanonicalVarValues, InferCtxtLike, Interner, Ty, TypeFoldable, TypeFolder,
|
||||
TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
|
||||
TypingMode,
|
||||
};
|
||||
@@ -781,7 +781,7 @@ pub(super) fn next_region_var(&mut self) -> I::Region {
|
||||
region
|
||||
}
|
||||
|
||||
pub(super) fn next_ty_infer(&mut self) -> I::Ty {
|
||||
pub(super) fn next_ty_infer(&mut self) -> Ty<I> {
|
||||
let ty = self.delegate.next_ty_infer();
|
||||
self.inspect.add_var_value(ty);
|
||||
ty
|
||||
@@ -829,7 +829,7 @@ struct ContainsTermOrNotNameable<'a, D: SolverDelegate<Interner = I>, I: Interne
|
||||
term: I::Term,
|
||||
universe_of_term: ty::UniverseIndex,
|
||||
delegate: &'a D,
|
||||
cache: HashSet<I::Ty>,
|
||||
cache: HashSet<Ty<I>>,
|
||||
}
|
||||
|
||||
impl<D: SolverDelegate<Interner = I>, I: Interner> ContainsTermOrNotNameable<'_, D, I> {
|
||||
@@ -846,7 +846,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> TypeVisitor<I>
|
||||
for ContainsTermOrNotNameable<'_, D, I>
|
||||
{
|
||||
type Result = ControlFlow<()>;
|
||||
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, t: Ty<I>) -> Self::Result {
|
||||
if self.cache.contains(&t) {
|
||||
return ControlFlow::Continue(());
|
||||
}
|
||||
@@ -1072,7 +1072,7 @@ pub(super) fn resolve_vars_if_possible<T>(&self, value: T) -> T
|
||||
self.delegate.resolve_vars_if_possible(value)
|
||||
}
|
||||
|
||||
pub(super) fn shallow_resolve(&self, ty: I::Ty) -> I::Ty {
|
||||
pub(super) fn shallow_resolve(&self, ty: Ty<I>) -> Ty<I> {
|
||||
self.delegate.shallow_resolve(ty)
|
||||
}
|
||||
|
||||
@@ -1092,7 +1092,7 @@ pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs
|
||||
args
|
||||
}
|
||||
|
||||
pub(super) fn register_ty_outlives(&self, ty: I::Ty, lt: I::Region) {
|
||||
pub(super) fn register_ty_outlives(&self, ty: Ty<I>, lt: I::Region) {
|
||||
self.delegate.register_ty_outlives(ty, lt, self.origin_span);
|
||||
}
|
||||
|
||||
@@ -1134,8 +1134,8 @@ pub(super) fn fetch_eligible_assoc_item(
|
||||
pub(super) fn register_hidden_type_in_storage(
|
||||
&mut self,
|
||||
opaque_type_key: ty::OpaqueTypeKey<I>,
|
||||
hidden_ty: I::Ty,
|
||||
) -> Option<I::Ty> {
|
||||
hidden_ty: Ty<I>,
|
||||
) -> Option<Ty<I>> {
|
||||
self.delegate.register_hidden_type_in_storage(opaque_type_key, hidden_ty, self.origin_span)
|
||||
}
|
||||
|
||||
@@ -1144,7 +1144,7 @@ pub(super) fn add_item_bounds_for_hidden_type(
|
||||
opaque_def_id: I::DefId,
|
||||
opaque_args: I::GenericArgs,
|
||||
param_env: I::ParamEnv,
|
||||
hidden_ty: I::Ty,
|
||||
hidden_ty: Ty<I>,
|
||||
) {
|
||||
let mut goals = Vec::new();
|
||||
self.delegate.add_item_bounds_for_hidden_type(
|
||||
@@ -1170,8 +1170,8 @@ pub(super) fn evaluate_const(
|
||||
|
||||
pub(super) fn is_transmutable(
|
||||
&mut self,
|
||||
src: I::Ty,
|
||||
dst: I::Ty,
|
||||
src: Ty<I>,
|
||||
dst: Ty<I>,
|
||||
assume: I::Const,
|
||||
) -> Result<Certainty, NoSolution> {
|
||||
self.delegate.is_transmutable(dst, src, assume)
|
||||
@@ -1195,7 +1195,7 @@ pub(super) fn may_use_unstable_feature(
|
||||
|
||||
pub(crate) fn opaques_with_sub_unified_hidden_type(
|
||||
&self,
|
||||
self_ty: I::Ty,
|
||||
self_ty: Ty<I>,
|
||||
) -> Vec<ty::AliasTy<I>> {
|
||||
if let ty::Infer(ty::TyVar(vid)) = self_ty.kind() {
|
||||
self.delegate.opaques_with_sub_unified_hidden_type(vid)
|
||||
@@ -1389,7 +1389,7 @@ struct ReplaceAliasWithInfer<'me, 'a, D, I>
|
||||
ecx: &'me mut EvalCtxt<'a, D>,
|
||||
param_env: I::ParamEnv,
|
||||
normalization_goal_source: GoalSource,
|
||||
cache: HashMap<I::Ty, I::Ty>,
|
||||
cache: HashMap<Ty<I>, Ty<I>>,
|
||||
}
|
||||
|
||||
impl<'me, 'a, D, I> ReplaceAliasWithInfer<'me, 'a, D, I>
|
||||
@@ -1421,7 +1421,7 @@ fn cx(&self) -> I {
|
||||
self.ecx.cx()
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, ty: Ty<I>) -> Ty<I> {
|
||||
match ty.kind() {
|
||||
ty::Alias(..) if !ty.has_escaping_bound_vars() => {
|
||||
let infer_ty = self.ecx.next_ty_infer();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
use derive_where::derive_where;
|
||||
use rustc_type_ir::inherent::*;
|
||||
pub use rustc_type_ir::solve::*;
|
||||
use rustc_type_ir::{self as ty, Interner, TyVid, TypingMode};
|
||||
use rustc_type_ir::{self as ty, Interner, Ty, TyVid, TypingMode};
|
||||
use tracing::instrument;
|
||||
|
||||
pub use self::eval_ctxt::{
|
||||
@@ -88,7 +88,7 @@ impl<'a, D, I> EvalCtxt<'a, D>
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
fn compute_type_outlives_goal(
|
||||
&mut self,
|
||||
goal: Goal<I, ty::OutlivesPredicate<I, I::Ty>>,
|
||||
goal: Goal<I, ty::OutlivesPredicate<I, Ty<I>>>,
|
||||
) -> QueryResult<I> {
|
||||
let ty::OutlivesPredicate(ty, lt) = goal.predicate;
|
||||
self.register_ty_outlives(ty, lt);
|
||||
@@ -205,7 +205,7 @@ fn compute_const_evaluatable_goal(
|
||||
#[instrument(level = "trace", skip(self), ret)]
|
||||
fn compute_const_arg_has_type_goal(
|
||||
&mut self,
|
||||
goal: Goal<I, (I::Const, I::Ty)>,
|
||||
goal: Goal<I, (I::Const, Ty<I>)>,
|
||||
) -> QueryResult<I> {
|
||||
let (ct, ty) = goal.predicate;
|
||||
let ct = self.structurally_normalize_const(goal.param_env, ct)?;
|
||||
@@ -315,8 +315,8 @@ fn flounder(&mut self, candidates: &[Candidate<I>]) -> QueryResult<I> {
|
||||
fn structurally_normalize_ty(
|
||||
&mut self,
|
||||
param_env: I::ParamEnv,
|
||||
ty: I::Ty,
|
||||
) -> Result<I::Ty, NoSolution> {
|
||||
ty: Ty<I>,
|
||||
) -> Result<Ty<I>, NoSolution> {
|
||||
self.structurally_normalize_term(param_env, ty.into()).map(|term| term.expect_ty())
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ impl<D, I> assembly::GoalKind<D> for NormalizesTo<I>
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
{
|
||||
fn self_ty(self) -> I::Ty {
|
||||
fn self_ty(self) -> ty::Ty<I> {
|
||||
self.self_ty()
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ fn trait_ref(self, cx: I) -> ty::TraitRef<I> {
|
||||
self.alias.trait_ref(cx)
|
||||
}
|
||||
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: I::Ty) -> Self {
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: ty::Ty<I>) -> Self {
|
||||
self.with_replaced_self_ty(cx, self_ty)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ impl<D, I> assembly::GoalKind<D> for TraitPredicate<I>
|
||||
D: SolverDelegate<Interner = I>,
|
||||
I: Interner,
|
||||
{
|
||||
fn self_ty(self) -> I::Ty {
|
||||
fn self_ty(self) -> ty::Ty<I> {
|
||||
self.self_ty()
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ fn trait_ref(self, _: I) -> ty::TraitRef<I> {
|
||||
self.trait_ref
|
||||
}
|
||||
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: I::Ty) -> Self {
|
||||
fn with_replaced_self_ty(self, cx: I, self_ty: ty::Ty<I>) -> Self {
|
||||
self.with_replaced_self_ty(cx, self_ty)
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@ impl<D, I> EvalCtxt<'_, D>
|
||||
/// ```
|
||||
fn consider_builtin_dyn_upcast_candidates(
|
||||
&mut self,
|
||||
goal: Goal<I, (I::Ty, I::Ty)>,
|
||||
goal: Goal<I, (ty::Ty<I>, ty::Ty<I>)>,
|
||||
a_data: I::BoundExistentialPredicates,
|
||||
a_region: I::Region,
|
||||
b_data: I::BoundExistentialPredicates,
|
||||
@@ -977,7 +977,7 @@ fn consider_builtin_dyn_upcast_candidates(
|
||||
|
||||
fn consider_builtin_unsize_to_dyn_candidate(
|
||||
&mut self,
|
||||
goal: Goal<I, (I::Ty, I::Ty)>,
|
||||
goal: Goal<I, (ty::Ty<I>, ty::Ty<I>)>,
|
||||
b_data: I::BoundExistentialPredicates,
|
||||
b_region: I::Region,
|
||||
) -> Result<Candidate<I>, NoSolution> {
|
||||
@@ -1018,7 +1018,7 @@ fn consider_builtin_unsize_to_dyn_candidate(
|
||||
|
||||
fn consider_builtin_upcast_to_principal(
|
||||
&mut self,
|
||||
goal: Goal<I, (I::Ty, I::Ty)>,
|
||||
goal: Goal<I, (ty::Ty<I>, ty::Ty<I>)>,
|
||||
source: CandidateSource<I>,
|
||||
a_data: I::BoundExistentialPredicates,
|
||||
a_region: I::Region,
|
||||
@@ -1132,9 +1132,9 @@ fn consider_builtin_upcast_to_principal(
|
||||
/// `#[rustc_deny_explicit_impl]` in this case.
|
||||
fn consider_builtin_array_unsize(
|
||||
&mut self,
|
||||
goal: Goal<I, (I::Ty, I::Ty)>,
|
||||
a_elem_ty: I::Ty,
|
||||
b_elem_ty: I::Ty,
|
||||
goal: Goal<I, (ty::Ty<I>, ty::Ty<I>)>,
|
||||
a_elem_ty: ty::Ty<I>,
|
||||
b_elem_ty: ty::Ty<I>,
|
||||
) -> Result<Candidate<I>, NoSolution> {
|
||||
self.eq(goal.param_env, a_elem_ty, b_elem_ty)?;
|
||||
self.probe_builtin_trait_candidate(BuiltinImplSource::Misc)
|
||||
@@ -1156,7 +1156,7 @@ fn consider_builtin_array_unsize(
|
||||
/// ```
|
||||
fn consider_builtin_struct_unsize(
|
||||
&mut self,
|
||||
goal: Goal<I, (I::Ty, I::Ty)>,
|
||||
goal: Goal<I, (ty::Ty<I>, ty::Ty<I>)>,
|
||||
def: I::AdtDef,
|
||||
a_args: I::GenericArgs,
|
||||
b_args: I::GenericArgs,
|
||||
@@ -1319,8 +1319,8 @@ fn probe_and_evaluate_goal_for_constituent_tys(
|
||||
goal: Goal<I, TraitPredicate<I>>,
|
||||
constituent_tys: impl Fn(
|
||||
&EvalCtxt<'_, D>,
|
||||
I::Ty,
|
||||
) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution>,
|
||||
ty::Ty<I>,
|
||||
) -> Result<ty::Binder<I, Vec<ty::Ty<I>>>, NoSolution>,
|
||||
) -> Result<Candidate<I>, NoSolution> {
|
||||
self.probe_trait_candidate(source).enter(|ecx| {
|
||||
let goals =
|
||||
@@ -1542,7 +1542,10 @@ pub(super) fn compute_trait_goal(
|
||||
self.merge_trait_candidates(candidate_preference_mode, candidates, failed_candidate_info)
|
||||
}
|
||||
|
||||
fn try_stall_coroutine(&mut self, self_ty: I::Ty) -> Option<Result<Candidate<I>, NoSolution>> {
|
||||
fn try_stall_coroutine(
|
||||
&mut self,
|
||||
self_ty: ty::Ty<I>,
|
||||
) -> Option<Result<Candidate<I>, NoSolution>> {
|
||||
if let ty::Coroutine(def_id, _) = self_ty.kind() {
|
||||
match self.typing_mode() {
|
||||
TypingMode::Analysis {
|
||||
|
||||
@@ -1188,7 +1188,8 @@ fn check_doc_attrs(&self, attr: &DocAttribute, hir_id: HirId, target: Target) {
|
||||
html_no_source: _,
|
||||
// already checked in attr_parsing
|
||||
issue_tracker_base_url: _,
|
||||
rust_logo,
|
||||
// already checked in attr_parsing
|
||||
rust_logo: _,
|
||||
// allowed anywhere
|
||||
test_attrs: _,
|
||||
// already checked in attr_parsing
|
||||
@@ -1217,18 +1218,6 @@ fn check_doc_attrs(&self, attr: &DocAttribute, hir_id: HirId, target: Target) {
|
||||
|
||||
self.check_doc_inline(hir_id, target, inline);
|
||||
|
||||
if let Some(span) = rust_logo
|
||||
&& !self.tcx.features().rustdoc_internals()
|
||||
{
|
||||
feature_err(
|
||||
&self.tcx.sess,
|
||||
sym::rustdoc_internals,
|
||||
*span,
|
||||
msg!("the `#[doc(rust_logo)]` attribute is used for Rust branding"),
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
||||
if let Some(span) = masked {
|
||||
self.check_doc_masked(*span, hir_id, target);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use crate::inherent::*;
|
||||
use crate::lift::Lift;
|
||||
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
|
||||
use crate::{self as ty, DebruijnIndex, Interner, UniverseIndex};
|
||||
use crate::{self as ty, DebruijnIndex, Interner, Ty, UniverseIndex};
|
||||
|
||||
/// `Binder` is a binder for higher-ranked lifetimes or types. It is part of the
|
||||
/// compiler's representation for things like `for<'a> Fn(&'a isize)`
|
||||
@@ -274,7 +274,7 @@ pub struct ValidateBoundVars<I: Interner> {
|
||||
// We only cache types because any complex const will have to step through
|
||||
// a type at some point anyways. We may encounter the same variable at
|
||||
// different levels of binding, so this can't just be `Ty`.
|
||||
visited: SsoHashSet<(ty::DebruijnIndex, I::Ty)>,
|
||||
visited: SsoHashSet<(ty::DebruijnIndex, Ty<I>)>,
|
||||
}
|
||||
|
||||
impl<I: Interner> ValidateBoundVars<I> {
|
||||
@@ -297,7 +297,7 @@ fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &Binder<I, T>) -> Self::Resul
|
||||
result
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, t: Ty<I>) -> Self::Result {
|
||||
if t.outer_exclusive_binder() < self.binder_index
|
||||
|| !self.visited.insert((self.binder_index, t))
|
||||
{
|
||||
@@ -724,7 +724,7 @@ fn fold_region(&mut self, r: I::Region) -> I::Region {
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: Ty<I>) -> Ty<I> {
|
||||
if !t.has_param() {
|
||||
return t;
|
||||
}
|
||||
@@ -753,7 +753,7 @@ fn fold_clauses(&mut self, c: I::Clauses) -> I::Clauses {
|
||||
}
|
||||
|
||||
impl<'a, I: Interner> ArgFolder<'a, I> {
|
||||
fn ty_for_param(&self, p: I::ParamTy, source_ty: I::Ty) -> I::Ty {
|
||||
fn ty_for_param(&self, p: I::ParamTy, source_ty: Ty<I>) -> Ty<I> {
|
||||
// Look up the type in the args. It really should be in there.
|
||||
let opt_ty = self.args.get(p.index() as usize).map(|arg| arg.kind());
|
||||
let ty = match opt_ty {
|
||||
@@ -767,7 +767,7 @@ fn ty_for_param(&self, p: I::ParamTy, source_ty: I::Ty) -> I::Ty {
|
||||
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
fn type_param_expected(&self, p: I::ParamTy, ty: I::Ty, kind: ty::GenericArgKind<I>) -> ! {
|
||||
fn type_param_expected(&self, p: I::ParamTy, ty: Ty<I>, kind: ty::GenericArgKind<I>) -> ! {
|
||||
panic!(
|
||||
"expected type for `{:?}` ({:?}/{}) but found {:?} when instantiating, args={:?}",
|
||||
p,
|
||||
@@ -780,7 +780,7 @@ fn type_param_expected(&self, p: I::ParamTy, ty: I::Ty, kind: ty::GenericArgKind
|
||||
|
||||
#[cold]
|
||||
#[inline(never)]
|
||||
fn type_param_out_of_range(&self, p: I::ParamTy, ty: I::Ty) -> ! {
|
||||
fn type_param_out_of_range(&self, p: I::ParamTy, ty: Ty<I>) -> ! {
|
||||
panic!(
|
||||
"type parameter `{:?}` ({:?}/{}) out of range when instantiating, args={:?}",
|
||||
p,
|
||||
@@ -1277,7 +1277,7 @@ pub fn new_anon(ui: UniverseIndex, var: ty::BoundVar) -> Self {
|
||||
Self { universe: ui, bound, _tcx: PhantomData }
|
||||
}
|
||||
|
||||
pub fn find_const_ty_from_env(self, env: I::ParamEnv) -> I::Ty {
|
||||
pub fn find_const_ty_from_env(self, env: I::ParamEnv) -> Ty<I> {
|
||||
let mut candidates = env.caller_bounds().iter().filter_map(|clause| {
|
||||
// `ConstArgHasType` are never desugared to be higher ranked.
|
||||
match clause.kind().skip_binder() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use rustc_type_ir_macros::{GenericTypeVisitable, TypeFoldable_Generic, TypeVisitable_Generic};
|
||||
|
||||
use crate::solve::NoSolution;
|
||||
use crate::{self as ty, Interner};
|
||||
use crate::{self as ty, Interner, Ty};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(TypeFoldable_Generic, TypeVisitable_Generic, GenericTypeVisitable)]
|
||||
@@ -36,15 +36,15 @@ pub enum TypeError<I: Interner> {
|
||||
RegionsInsufficientlyPolymorphic(ty::BoundRegion<I>, I::Region),
|
||||
RegionsPlaceholderMismatch,
|
||||
|
||||
Sorts(ExpectedFound<I::Ty>),
|
||||
ArgumentSorts(ExpectedFound<I::Ty>, usize),
|
||||
Sorts(ExpectedFound<Ty<I>>),
|
||||
ArgumentSorts(ExpectedFound<Ty<I>>, usize),
|
||||
Traits(ExpectedFound<I::TraitId>),
|
||||
VariadicMismatch(ExpectedFound<bool>),
|
||||
|
||||
/// Instantiating a type variable with the given type would have
|
||||
/// created a cycle (because it appears somewhere within that
|
||||
/// type).
|
||||
CyclicTy(I::Ty),
|
||||
CyclicTy(Ty<I>),
|
||||
CyclicConst(I::Const),
|
||||
ProjectionMismatched(ExpectedFound<I::DefId>),
|
||||
ExistentialMismatch(ExpectedFound<I::BoundExistentialPredicates>),
|
||||
|
||||
@@ -113,7 +113,7 @@ pub enum TreatParams {
|
||||
/// ¹ meaning that if the outermost layers are different, then the whole types are also different.
|
||||
pub fn simplify_type<I: Interner>(
|
||||
cx: I,
|
||||
ty: I::Ty,
|
||||
ty: ty::Ty<I>,
|
||||
treat_params: TreatParams,
|
||||
) -> Option<SimplifiedType<I::DefId>> {
|
||||
match ty.kind() {
|
||||
@@ -236,11 +236,16 @@ pub fn args_may_unify(
|
||||
self.args_may_unify_inner(obligation_args, impl_args, Self::STARTING_DEPTH)
|
||||
}
|
||||
|
||||
pub fn types_may_unify(self, lhs: I::Ty, rhs: I::Ty) -> bool {
|
||||
pub fn types_may_unify(self, lhs: ty::Ty<I>, rhs: ty::Ty<I>) -> bool {
|
||||
self.types_may_unify_inner(lhs, rhs, Self::STARTING_DEPTH)
|
||||
}
|
||||
|
||||
pub fn types_may_unify_with_depth(self, lhs: I::Ty, rhs: I::Ty, depth_limit: usize) -> bool {
|
||||
pub fn types_may_unify_with_depth(
|
||||
self,
|
||||
lhs: ty::Ty<I>,
|
||||
rhs: ty::Ty<I>,
|
||||
depth_limit: usize,
|
||||
) -> bool {
|
||||
self.types_may_unify_inner(lhs, rhs, depth_limit)
|
||||
}
|
||||
|
||||
@@ -268,7 +273,7 @@ fn args_may_unify_inner(
|
||||
})
|
||||
}
|
||||
|
||||
fn types_may_unify_inner(self, lhs: I::Ty, rhs: I::Ty, depth: usize) -> bool {
|
||||
fn types_may_unify_inner(self, lhs: ty::Ty<I>, rhs: ty::Ty<I>, depth: usize) -> bool {
|
||||
if lhs == rhs {
|
||||
return true;
|
||||
}
|
||||
@@ -527,7 +532,7 @@ fn consts_may_unify_inner(self, lhs: I::Const, rhs: I::Const) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn var_and_ty_may_unify(self, var: ty::InferTy, ty: I::Ty) -> bool {
|
||||
fn var_and_ty_may_unify(self, var: ty::InferTy, ty: ty::Ty<I>) -> bool {
|
||||
if !ty.is_known_rigid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::inherent::*;
|
||||
use crate::visit::Flags;
|
||||
use crate::{self as ty, Interner};
|
||||
use crate::{self as ty, Interner, Ty};
|
||||
|
||||
bitflags::bitflags! {
|
||||
/// Flags that we track on types. These flags are propagated upwards
|
||||
@@ -430,7 +430,7 @@ fn add_predicate_atom(&mut self, atom: ty::PredicateKind<I>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn add_ty(&mut self, ty: I::Ty) {
|
||||
fn add_ty(&mut self, ty: Ty<I>) {
|
||||
self.add_flags(ty.flags());
|
||||
self.add_exclusive_binder(ty.outer_exclusive_binder());
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ fn fold_binder<T>(&mut self, t: ty::Binder<I, T>) -> ty::Binder<I, T>
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ fn try_fold_binder<T>(&mut self, t: ty::Binder<I, T>) -> Result<ty::Binder<I, T>
|
||||
t.try_super_fold_with(self)
|
||||
}
|
||||
|
||||
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Self::Error> {
|
||||
fn try_fold_ty(&mut self, t: ty::Ty<I>) -> Result<ty::Ty<I>, Self::Error> {
|
||||
t.try_super_fold_with(self)
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ fn fold_region(&mut self, r: I::Region) -> I::Region {
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, ty: ty::Ty<I>) -> ty::Ty<I> {
|
||||
match ty.kind() {
|
||||
ty::Bound(BoundVarIndexKind::Bound(debruijn), bound_ty)
|
||||
if debruijn >= self.current_index =>
|
||||
@@ -538,7 +538,7 @@ fn fold_region(&mut self, r: I::Region) -> I::Region {
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
|
||||
if t.has_type_flags(
|
||||
TypeFlags::HAS_FREE_REGIONS | TypeFlags::HAS_RE_BOUND | TypeFlags::HAS_RE_ERASED,
|
||||
) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
|
||||
use rustc_type_ir_macros::GenericTypeVisitable;
|
||||
|
||||
use crate::Interner;
|
||||
use crate::{Interner, Ty};
|
||||
|
||||
#[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)]
|
||||
#[derive(GenericTypeVisitable)]
|
||||
@@ -13,7 +13,7 @@
|
||||
)]
|
||||
pub enum GenericArgKind<I: Interner> {
|
||||
Lifetime(I::Region),
|
||||
Type(I::Ty),
|
||||
Type(Ty<I>),
|
||||
Const(I::Const),
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ impl<I: Interner> Eq for GenericArgKind<I> {}
|
||||
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
|
||||
)]
|
||||
pub enum TermKind<I: Interner> {
|
||||
Ty(I::Ty),
|
||||
Ty(Ty<I>),
|
||||
Const(I::Const),
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use crate::inherent::*;
|
||||
use crate::relate::RelateResult;
|
||||
use crate::relate::combine::PredicateEmittingRelation;
|
||||
use crate::{self as ty, Interner, TyVid};
|
||||
use crate::{self as ty, Interner, Ty, TyVid};
|
||||
|
||||
/// The current typing mode of an inference context. We unfortunately have some
|
||||
/// slightly different typing rules depending on the current context. See the
|
||||
@@ -161,12 +161,9 @@ fn next_trait_solver(&self) -> bool {
|
||||
fn sub_unification_table_root_var(&self, var: ty::TyVid) -> ty::TyVid;
|
||||
fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid;
|
||||
|
||||
fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> <Self::Interner as Interner>::Ty;
|
||||
fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> <Self::Interner as Interner>::Ty;
|
||||
fn opportunistic_resolve_float_var(
|
||||
&self,
|
||||
vid: ty::FloatVid,
|
||||
) -> <Self::Interner as Interner>::Ty;
|
||||
fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> Ty<Self::Interner>;
|
||||
fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> Ty<Self::Interner>;
|
||||
fn opportunistic_resolve_float_var(&self, vid: ty::FloatVid) -> Ty<Self::Interner>;
|
||||
fn opportunistic_resolve_ct_var(
|
||||
&self,
|
||||
vid: ty::ConstVid,
|
||||
@@ -179,7 +176,7 @@ fn opportunistic_resolve_lt_var(
|
||||
fn is_changed_arg(&self, arg: <Self::Interner as Interner>::GenericArg) -> bool;
|
||||
|
||||
fn next_region_infer(&self) -> <Self::Interner as Interner>::Region;
|
||||
fn next_ty_infer(&self) -> <Self::Interner as Interner>::Ty;
|
||||
fn next_ty_infer(&self) -> Ty<Self::Interner>;
|
||||
fn next_const_infer(&self) -> <Self::Interner as Interner>::Const;
|
||||
fn fresh_args_for_item(
|
||||
&self,
|
||||
@@ -209,7 +206,7 @@ fn instantiate_ty_var_raw<R: PredicateEmittingRelation<Self>>(
|
||||
target_is_expected: bool,
|
||||
target_vid: ty::TyVid,
|
||||
instantiation_variance: ty::Variance,
|
||||
source_ty: <Self::Interner as Interner>::Ty,
|
||||
source_ty: Ty<Self::Interner>,
|
||||
) -> RelateResult<Self::Interner, ()>;
|
||||
fn instantiate_int_var_raw(&self, vid: ty::IntVid, value: ty::IntVarValue);
|
||||
fn instantiate_float_var_raw(&self, vid: ty::FloatVid, value: ty::FloatVarValue);
|
||||
@@ -223,10 +220,7 @@ fn instantiate_const_var_raw<R: PredicateEmittingRelation<Self>>(
|
||||
|
||||
fn set_tainted_by_errors(&self, e: <Self::Interner as Interner>::ErrorGuaranteed);
|
||||
|
||||
fn shallow_resolve(
|
||||
&self,
|
||||
ty: <Self::Interner as Interner>::Ty,
|
||||
) -> <Self::Interner as Interner>::Ty;
|
||||
fn shallow_resolve(&self, ty: Ty<Self::Interner>) -> Ty<Self::Interner>;
|
||||
fn shallow_resolve_const(
|
||||
&self,
|
||||
ty: <Self::Interner as Interner>::Const,
|
||||
@@ -254,7 +248,7 @@ fn equate_regions(
|
||||
|
||||
fn register_ty_outlives(
|
||||
&self,
|
||||
ty: <Self::Interner as Interner>::Ty,
|
||||
ty: Ty<Self::Interner>,
|
||||
r: <Self::Interner as Interner>::Region,
|
||||
span: <Self::Interner as Interner>::Span,
|
||||
);
|
||||
@@ -263,26 +257,26 @@ fn register_ty_outlives(
|
||||
fn opaque_types_storage_num_entries(&self) -> Self::OpaqueTypeStorageEntries;
|
||||
fn clone_opaque_types_lookup_table(
|
||||
&self,
|
||||
) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, <Self::Interner as Interner>::Ty)>;
|
||||
) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, Ty<Self::Interner>)>;
|
||||
fn clone_duplicate_opaque_types(
|
||||
&self,
|
||||
) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, <Self::Interner as Interner>::Ty)>;
|
||||
) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, Ty<Self::Interner>)>;
|
||||
fn clone_opaque_types_added_since(
|
||||
&self,
|
||||
prev_entries: Self::OpaqueTypeStorageEntries,
|
||||
) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, <Self::Interner as Interner>::Ty)>;
|
||||
) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, Ty<Self::Interner>)>;
|
||||
fn opaques_with_sub_unified_hidden_type(&self, ty: TyVid) -> Vec<ty::AliasTy<Self::Interner>>;
|
||||
|
||||
fn register_hidden_type_in_storage(
|
||||
&self,
|
||||
opaque_type_key: ty::OpaqueTypeKey<Self::Interner>,
|
||||
hidden_ty: <Self::Interner as Interner>::Ty,
|
||||
hidden_ty: Ty<Self::Interner>,
|
||||
span: <Self::Interner as Interner>::Span,
|
||||
) -> Option<<Self::Interner as Interner>::Ty>;
|
||||
) -> Option<Ty<Self::Interner>>;
|
||||
fn add_duplicate_opaque_type(
|
||||
&self,
|
||||
opaque_type_key: ty::OpaqueTypeKey<Self::Interner>,
|
||||
hidden_ty: <Self::Interner as Interner>::Ty,
|
||||
hidden_ty: Ty<Self::Interner>,
|
||||
span: <Self::Interner as Interner>::Span,
|
||||
);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ pub trait Ty<I: Interner<Ty = Self>>:
|
||||
fn new_alias(interner: I, kind: ty::AliasTyKind, alias_ty: ty::AliasTy<I>) -> Self;
|
||||
|
||||
fn new_projection_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self {
|
||||
Ty::new_alias(
|
||||
Self::new_alias(
|
||||
interner,
|
||||
ty::AliasTyKind::Projection,
|
||||
ty::AliasTy::new_from_args(interner, def_id, args),
|
||||
@@ -67,7 +67,7 @@ fn new_projection(
|
||||
def_id: I::DefId,
|
||||
args: impl IntoIterator<Item: Into<I::GenericArg>>,
|
||||
) -> Self {
|
||||
Ty::new_alias(
|
||||
Self::new_alias(
|
||||
interner,
|
||||
ty::AliasTyKind::Projection,
|
||||
ty::AliasTy::new(interner, def_id, args),
|
||||
@@ -108,7 +108,7 @@ fn new_coroutine_witness_for_coroutine(
|
||||
|
||||
fn new_slice(interner: I, ty: Self) -> Self;
|
||||
|
||||
fn new_tup(interner: I, tys: &[I::Ty]) -> Self;
|
||||
fn new_tup(interner: I, tys: &[ty::Ty<I>]) -> Self;
|
||||
|
||||
fn new_tup_from_iter<It, T>(interner: I, iter: It) -> T::Output
|
||||
where
|
||||
@@ -121,7 +121,7 @@ fn new_tup_from_iter<It, T>(interner: I, iter: It) -> T::Output
|
||||
|
||||
fn new_pat(interner: I, ty: Self, pat: I::Pat) -> Self;
|
||||
|
||||
fn new_unsafe_binder(interner: I, ty: ty::Binder<I, I::Ty>) -> Self;
|
||||
fn new_unsafe_binder(interner: I, ty: ty::Binder<I, ty::Ty<I>>) -> Self;
|
||||
|
||||
fn tuple_fields(self) -> I::Tys;
|
||||
|
||||
@@ -158,7 +158,7 @@ fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
|
||||
self.kind().fn_sig(interner)
|
||||
}
|
||||
|
||||
fn discriminant_ty(self, interner: I) -> I::Ty;
|
||||
fn discriminant_ty(self, interner: I) -> ty::Ty<I>;
|
||||
|
||||
fn is_known_rigid(self) -> bool {
|
||||
self.kind().is_known_rigid()
|
||||
@@ -198,11 +198,11 @@ fn is_guaranteed_unsized_raw(self) -> bool {
|
||||
}
|
||||
|
||||
pub trait Tys<I: Interner<Tys = Self>>:
|
||||
Copy + Debug + Hash + Eq + SliceLike<Item = I::Ty> + TypeFoldable<I> + Default
|
||||
Copy + Debug + Hash + Eq + SliceLike<Item = ty::Ty<I>> + TypeFoldable<I> + Default
|
||||
{
|
||||
fn inputs(self) -> I::FnInputTys;
|
||||
|
||||
fn output(self) -> I::Ty;
|
||||
fn output(self) -> ty::Ty<I>;
|
||||
}
|
||||
|
||||
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq {
|
||||
@@ -290,7 +290,7 @@ fn is_ct_error(self) -> bool {
|
||||
}
|
||||
|
||||
pub trait ValueConst<I: Interner<ValueConst = Self>>: Copy + Debug + Hash + Eq {
|
||||
fn ty(self) -> I::Ty;
|
||||
fn ty(self) -> ty::Ty<I>;
|
||||
fn valtree(self) -> I::ValTree;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ pub trait GenericArg<I: Interner<GenericArg = Self>>:
|
||||
+ IntoKind<Kind = ty::GenericArgKind<I>>
|
||||
+ TypeVisitable<I>
|
||||
+ Relate<I>
|
||||
+ From<I::Ty>
|
||||
+ From<ty::Ty<I>>
|
||||
+ From<I::Region>
|
||||
+ From<I::Const>
|
||||
+ From<I::Term>
|
||||
@@ -323,11 +323,11 @@ fn as_term(&self) -> Option<I::Term> {
|
||||
}
|
||||
}
|
||||
|
||||
fn as_type(&self) -> Option<I::Ty> {
|
||||
fn as_type(&self) -> Option<ty::Ty<I>> {
|
||||
if let ty::GenericArgKind::Type(ty) = self.kind() { Some(ty) } else { None }
|
||||
}
|
||||
|
||||
fn expect_ty(&self) -> I::Ty {
|
||||
fn expect_ty(&self) -> ty::Ty<I> {
|
||||
self.as_type().expect("expected a type")
|
||||
}
|
||||
|
||||
@@ -359,11 +359,11 @@ fn is_non_region_infer(self) -> bool {
|
||||
pub trait Term<I: Interner<Term = Self>>:
|
||||
Copy + Debug + Hash + Eq + IntoKind<Kind = ty::TermKind<I>> + TypeFoldable<I> + Relate<I>
|
||||
{
|
||||
fn as_type(&self) -> Option<I::Ty> {
|
||||
fn as_type(&self) -> Option<ty::Ty<I>> {
|
||||
if let ty::TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
|
||||
}
|
||||
|
||||
fn expect_ty(&self) -> I::Ty {
|
||||
fn expect_ty(&self) -> ty::Ty<I> {
|
||||
self.as_type().expect("expected a type, but found a const")
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ fn rebase_onto(
|
||||
target: I::GenericArgs,
|
||||
) -> I::GenericArgs;
|
||||
|
||||
fn type_at(self, i: usize) -> I::Ty;
|
||||
fn type_at(self, i: usize) -> ty::Ty<I>;
|
||||
|
||||
fn region_at(self, i: usize) -> I::Region;
|
||||
|
||||
@@ -459,7 +459,7 @@ pub trait Predicate<I: Interner<Predicate = Self>>:
|
||||
+ UpcastFrom<I, ty::TraitRef<I>>
|
||||
+ UpcastFrom<I, ty::Binder<I, ty::TraitRef<I>>>
|
||||
+ UpcastFrom<I, ty::TraitPredicate<I>>
|
||||
+ UpcastFrom<I, ty::OutlivesPredicate<I, I::Ty>>
|
||||
+ UpcastFrom<I, ty::OutlivesPredicate<I, ty::Ty<I>>>
|
||||
+ UpcastFrom<I, ty::OutlivesPredicate<I, I::Region>>
|
||||
+ IntoKind<Kind = ty::Binder<I, ty::PredicateKind<I>>>
|
||||
+ Elaboratable<I>
|
||||
@@ -578,7 +578,7 @@ pub trait AdtDef<I: Interner>: Copy + Debug + Hash + Eq {
|
||||
/// Returns the type of the struct tail.
|
||||
///
|
||||
/// Expects the `AdtDef` to be a struct. If it is not, then this will panic.
|
||||
fn struct_tail_ty(self, interner: I) -> Option<ty::EarlyBinder<I, I::Ty>>;
|
||||
fn struct_tail_ty(self, interner: I) -> Option<ty::EarlyBinder<I, ty::Ty<I>>>;
|
||||
|
||||
fn is_phantom_data(self) -> bool;
|
||||
|
||||
@@ -591,13 +591,13 @@ fn field_representing_type_info(
|
||||
) -> Option<FieldInfo<I>>;
|
||||
|
||||
// FIXME: perhaps use `all_fields` and expose `FieldDef`.
|
||||
fn all_field_tys(self, interner: I) -> ty::EarlyBinder<I, impl IntoIterator<Item = I::Ty>>;
|
||||
fn all_field_tys(self, interner: I) -> ty::EarlyBinder<I, impl IntoIterator<Item = ty::Ty<I>>>;
|
||||
|
||||
fn sizedness_constraint(
|
||||
self,
|
||||
interner: I,
|
||||
sizedness: SizedTraitKind,
|
||||
) -> Option<ty::EarlyBinder<I, I::Ty>>;
|
||||
) -> Option<ty::EarlyBinder<I, ty::Ty<I>>>;
|
||||
|
||||
fn is_fundamental(self) -> bool;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
pub mod relate;
|
||||
pub mod search_graph;
|
||||
pub mod solve;
|
||||
pub mod sty;
|
||||
pub mod walk;
|
||||
|
||||
// These modules are not `pub` since they are glob-imported.
|
||||
@@ -78,6 +79,7 @@
|
||||
pub use region_kind::*;
|
||||
pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy};
|
||||
use rustc_type_ir_macros::GenericTypeVisitable;
|
||||
pub use sty::*;
|
||||
pub use ty_info::*;
|
||||
pub use ty_kind::*;
|
||||
pub use upcast::*;
|
||||
@@ -443,8 +445,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
|
||||
pub struct FieldInfo<I: Interner> {
|
||||
pub base: I::Ty,
|
||||
pub ty: I::Ty,
|
||||
pub base: Ty<I>,
|
||||
pub ty: Ty<I>,
|
||||
pub variant: Option<I::Symbol>,
|
||||
pub variant_idx: VariantIdx,
|
||||
pub name: I::Symbol,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use crate::data_structures::SsoHashSet;
|
||||
use crate::inherent::*;
|
||||
use crate::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt as _, TypeVisitor};
|
||||
use crate::{self as ty, Interner};
|
||||
use crate::{self as ty, Interner, Ty};
|
||||
|
||||
#[derive_where(Debug; I: Interner)]
|
||||
pub enum Component<I: Interner> {
|
||||
@@ -55,7 +55,7 @@ pub enum Component<I: Interner> {
|
||||
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
|
||||
pub fn push_outlives_components<I: Interner>(
|
||||
cx: I,
|
||||
ty: I::Ty,
|
||||
ty: Ty<I>,
|
||||
out: &mut SmallVec<[Component<I>; 4]>,
|
||||
) {
|
||||
ty.visit_with(&mut OutlivesCollector { cx, out, visited: Default::default() });
|
||||
@@ -64,14 +64,14 @@ pub fn push_outlives_components<I: Interner>(
|
||||
struct OutlivesCollector<'a, I: Interner> {
|
||||
cx: I,
|
||||
out: &'a mut SmallVec<[Component<I>; 4]>,
|
||||
visited: SsoHashSet<I::Ty>,
|
||||
visited: SsoHashSet<Ty<I>>,
|
||||
}
|
||||
|
||||
impl<I: Interner> TypeVisitor<I> for OutlivesCollector<'_, I> {
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
type Result = ();
|
||||
|
||||
fn visit_ty(&mut self, ty: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, ty: Ty<I>) -> Self::Result {
|
||||
if !self.visited.insert(ty) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ pub fn identity(interner: I, def_id: I::TraitId) -> TraitRef<I> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> Self {
|
||||
TraitRef::new(
|
||||
interner,
|
||||
self.def_id,
|
||||
@@ -110,13 +110,13 @@ pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn self_ty(&self) -> I::Ty {
|
||||
pub fn self_ty(&self) -> ty::Ty<I> {
|
||||
self.args.type_at(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Interner> ty::Binder<I, TraitRef<I>> {
|
||||
pub fn self_ty(&self) -> ty::Binder<I, I::Ty> {
|
||||
pub fn self_ty(&self) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound_ref(|tr| tr.self_ty())
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ pub struct TraitPredicate<I: Interner> {
|
||||
impl<I: Interner> Eq for TraitPredicate<I> {}
|
||||
|
||||
impl<I: Interner> TraitPredicate<I> {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> Self {
|
||||
Self {
|
||||
trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty),
|
||||
polarity: self.polarity,
|
||||
@@ -163,7 +163,7 @@ pub fn def_id(self) -> I::TraitId {
|
||||
self.trait_ref.def_id
|
||||
}
|
||||
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
pub fn self_ty(self) -> ty::Ty<I> {
|
||||
self.trait_ref.self_ty()
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ pub fn def_id(self) -> I::TraitId {
|
||||
self.skip_binder().def_id()
|
||||
}
|
||||
|
||||
pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
|
||||
pub fn self_ty(self) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound(|trait_ref| trait_ref.self_ty())
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ pub fn def_id(&self) -> I::DefId {
|
||||
/// Given an existential predicate like `?Self: PartialEq<u32>` (e.g., derived from `dyn PartialEq<u32>`),
|
||||
/// and a concrete type `self_ty`, returns a full predicate where the existentially quantified variable `?Self`
|
||||
/// has been replaced with `self_ty` (e.g., `self_ty: PartialEq<u32>`, in our example).
|
||||
pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> I::Clause {
|
||||
pub fn with_self_ty(&self, cx: I, self_ty: ty::Ty<I>) -> I::Clause {
|
||||
match self.skip_binder() {
|
||||
ExistentialPredicate::Trait(tr) => self.rebind(tr).with_self_ty(cx, self_ty).upcast(cx),
|
||||
ExistentialPredicate::Projection(p) => {
|
||||
@@ -384,7 +384,7 @@ pub fn erase_self_ty(interner: I, trait_ref: TraitRef<I>) -> ExistentialTraitRef
|
||||
/// we convert the principal trait-ref into a normal trait-ref,
|
||||
/// you must give *some* self type. A common choice is `mk_err()`
|
||||
/// or some placeholder type.
|
||||
pub fn with_self_ty(self, interner: I, self_ty: I::Ty) -> TraitRef<I> {
|
||||
pub fn with_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> TraitRef<I> {
|
||||
// otherwise the escaping vars would be captured by the binder
|
||||
// debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||
|
||||
@@ -401,7 +401,7 @@ pub fn def_id(&self) -> I::TraitId {
|
||||
/// we convert the principal trait-ref into a normal trait-ref,
|
||||
/// you must give *some* self type. A common choice is `mk_err()`
|
||||
/// or some placeholder type.
|
||||
pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, TraitRef<I>> {
|
||||
pub fn with_self_ty(&self, cx: I, self_ty: ty::Ty<I>) -> ty::Binder<I, TraitRef<I>> {
|
||||
self.map_bound(|trait_ref| trait_ref.with_self_ty(cx, self_ty))
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ pub fn trait_ref(&self, interner: I) -> ExistentialTraitRef<I> {
|
||||
ExistentialTraitRef::new_from_args(interner, def_id.try_into().unwrap(), args)
|
||||
}
|
||||
|
||||
pub fn with_self_ty(&self, interner: I, self_ty: I::Ty) -> ProjectionPredicate<I> {
|
||||
pub fn with_self_ty(&self, interner: I, self_ty: ty::Ty<I>) -> ProjectionPredicate<I> {
|
||||
// otherwise the escaping regions would be captured by the binders
|
||||
debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||
|
||||
@@ -487,7 +487,7 @@ pub fn erase_self_ty(interner: I, projection_predicate: ProjectionPredicate<I>)
|
||||
}
|
||||
|
||||
impl<I: Interner> ty::Binder<I, ExistentialProjection<I>> {
|
||||
pub fn with_self_ty(&self, cx: I, self_ty: I::Ty) -> ty::Binder<I, ProjectionPredicate<I>> {
|
||||
pub fn with_self_ty(&self, cx: I, self_ty: ty::Ty<I>) -> ty::Binder<I, ProjectionPredicate<I>> {
|
||||
self.map_bound(|p| p.with_self_ty(cx, self_ty))
|
||||
}
|
||||
|
||||
@@ -683,11 +683,11 @@ pub fn to_term(self, interner: I) -> I::Term {
|
||||
|
||||
/// The following methods work only with (trait) associated term projections.
|
||||
impl<I: Interner> AliasTerm<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
pub fn self_ty(self) -> ty::Ty<I> {
|
||||
self.args.type_at(0)
|
||||
}
|
||||
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> Self {
|
||||
AliasTerm::new(
|
||||
interner,
|
||||
self.def_id,
|
||||
@@ -796,11 +796,11 @@ pub struct ProjectionPredicate<I: Interner> {
|
||||
impl<I: Interner> Eq for ProjectionPredicate<I> {}
|
||||
|
||||
impl<I: Interner> ProjectionPredicate<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
pub fn self_ty(self) -> ty::Ty<I> {
|
||||
self.projection_term.self_ty()
|
||||
}
|
||||
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> ProjectionPredicate<I> {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> ProjectionPredicate<I> {
|
||||
Self {
|
||||
projection_term: self.projection_term.with_replaced_self_ty(interner, self_ty),
|
||||
..self
|
||||
@@ -859,11 +859,11 @@ pub struct NormalizesTo<I: Interner> {
|
||||
impl<I: Interner> Eq for NormalizesTo<I> {}
|
||||
|
||||
impl<I: Interner> NormalizesTo<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
pub fn self_ty(self) -> ty::Ty<I> {
|
||||
self.alias.self_ty()
|
||||
}
|
||||
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> NormalizesTo<I> {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> NormalizesTo<I> {
|
||||
Self { alias: self.alias.with_replaced_self_ty(interner, self_ty), ..self }
|
||||
}
|
||||
|
||||
@@ -896,11 +896,11 @@ pub struct HostEffectPredicate<I: Interner> {
|
||||
impl<I: Interner> Eq for HostEffectPredicate<I> {}
|
||||
|
||||
impl<I: Interner> HostEffectPredicate<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
pub fn self_ty(self) -> ty::Ty<I> {
|
||||
self.trait_ref.self_ty()
|
||||
}
|
||||
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> Self {
|
||||
Self { trait_ref: self.trait_ref.with_replaced_self_ty(interner, self_ty), ..self }
|
||||
}
|
||||
|
||||
@@ -915,7 +915,7 @@ pub fn def_id(self) -> I::TraitId {
|
||||
self.skip_binder().def_id()
|
||||
}
|
||||
|
||||
pub fn self_ty(self) -> ty::Binder<I, I::Ty> {
|
||||
pub fn self_ty(self) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound(|trait_ref| trait_ref.self_ty())
|
||||
}
|
||||
|
||||
@@ -936,8 +936,8 @@ pub fn constness(self) -> BoundConstness {
|
||||
)]
|
||||
pub struct SubtypePredicate<I: Interner> {
|
||||
pub a_is_expected: bool,
|
||||
pub a: I::Ty,
|
||||
pub b: I::Ty,
|
||||
pub a: ty::Ty<I>,
|
||||
pub b: ty::Ty<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for SubtypePredicate<I> {}
|
||||
@@ -950,8 +950,8 @@ impl<I: Interner> Eq for SubtypePredicate<I> {}
|
||||
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
|
||||
)]
|
||||
pub struct CoercePredicate<I: Interner> {
|
||||
pub a: I::Ty,
|
||||
pub b: I::Ty,
|
||||
pub a: ty::Ty<I>,
|
||||
pub b: ty::Ty<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for CoercePredicate<I> {}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
|
||||
use rustc_type_ir_macros::{GenericTypeVisitable, TypeFoldable_Generic, TypeVisitable_Generic};
|
||||
|
||||
use crate::{self as ty, Interner};
|
||||
use crate::{self as ty, Interner, Ty};
|
||||
|
||||
/// A clause is something that can appear in where bounds or be inferred
|
||||
/// by implied bounds.
|
||||
@@ -25,7 +25,7 @@ pub enum ClauseKind<I: Interner> {
|
||||
RegionOutlives(ty::OutlivesPredicate<I, I::Region>),
|
||||
|
||||
/// `where T: 'r`
|
||||
TypeOutlives(ty::OutlivesPredicate<I, I::Ty>),
|
||||
TypeOutlives(ty::OutlivesPredicate<I, Ty<I>>),
|
||||
|
||||
/// `where <T as TraitRef>::Name == X`, approximately.
|
||||
/// See the `ProjectionPredicate` struct for details.
|
||||
@@ -33,7 +33,7 @@ pub enum ClauseKind<I: Interner> {
|
||||
|
||||
/// Ensures that a const generic argument to a parameter `const N: u8`
|
||||
/// is of type `u8`.
|
||||
ConstArgHasType(I::Const, I::Ty),
|
||||
ConstArgHasType(I::Const, Ty<I>),
|
||||
|
||||
/// No syntax: `T` well-formed.
|
||||
WellFormed(I::Term),
|
||||
|
||||
@@ -44,7 +44,7 @@ pub enum VarianceDiagInfo<I: Interner> {
|
||||
Invariant {
|
||||
/// The generic type containing the generic parameter
|
||||
/// that changes the variance (e.g. `*mut T`, `MyStruct<T>`)
|
||||
ty: I::Ty,
|
||||
ty: ty::Ty<I>,
|
||||
/// The index of the generic parameter being used
|
||||
/// (e.g. `0` for `*mut T`, `1` for `MyStruct<'CovariantParam, 'InvariantParam>`)
|
||||
param_index: u32,
|
||||
@@ -75,13 +75,13 @@ fn relate<T: Relate<I>>(&mut self, a: T, b: T) -> RelateResult<I, T> {
|
||||
|
||||
fn relate_ty_args(
|
||||
&mut self,
|
||||
a_ty: I::Ty,
|
||||
b_ty: I::Ty,
|
||||
a_ty: ty::Ty<I>,
|
||||
b_ty: ty::Ty<I>,
|
||||
ty_def_id: I::DefId,
|
||||
a_arg: I::GenericArgs,
|
||||
b_arg: I::GenericArgs,
|
||||
mk: impl FnOnce(I::GenericArgs) -> I::Ty,
|
||||
) -> RelateResult<I, I::Ty>;
|
||||
mk: impl FnOnce(I::GenericArgs) -> ty::Ty<I>,
|
||||
) -> RelateResult<I, ty::Ty<I>>;
|
||||
|
||||
/// Switch variance for the purpose of relating `a` and `b`.
|
||||
fn relate_with_variance<T: Relate<I>>(
|
||||
@@ -98,7 +98,7 @@ fn relate_with_variance<T: Relate<I>>(
|
||||
// additional hooks for other types in the future if needed
|
||||
// without making older code, which called `relate`, obsolete.
|
||||
|
||||
fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty>;
|
||||
fn tys(&mut self, a: ty::Ty<I>, b: ty::Ty<I>) -> RelateResult<I, ty::Ty<I>>;
|
||||
|
||||
fn regions(&mut self, a: I::Region, b: I::Region) -> RelateResult<I, I::Region>;
|
||||
|
||||
@@ -332,9 +332,9 @@ fn relate<R: TypeRelation<I>>(
|
||||
#[instrument(level = "trace", skip(relation), ret)]
|
||||
pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
|
||||
relation: &mut R,
|
||||
a: I::Ty,
|
||||
b: I::Ty,
|
||||
) -> RelateResult<I, I::Ty> {
|
||||
a: ty::Ty<I>,
|
||||
b: ty::Ty<I>,
|
||||
) -> RelateResult<I, ty::Ty<I>> {
|
||||
let cx = relation.cx();
|
||||
match (a.kind(), b.kind()) {
|
||||
(ty::Infer(_), _) | (_, ty::Infer(_)) => {
|
||||
|
||||
@@ -39,15 +39,15 @@ fn register_predicates(
|
||||
);
|
||||
|
||||
/// Register `AliasRelate` obligation(s) that both types must be related to each other.
|
||||
fn register_alias_relate_predicate(&mut self, a: I::Ty, b: I::Ty);
|
||||
fn register_alias_relate_predicate(&mut self, a: ty::Ty<I>, b: ty::Ty<I>);
|
||||
}
|
||||
|
||||
pub fn super_combine_tys<Infcx, I, R>(
|
||||
infcx: &Infcx,
|
||||
relation: &mut R,
|
||||
a: I::Ty,
|
||||
b: I::Ty,
|
||||
) -> RelateResult<I, I::Ty>
|
||||
a: ty::Ty<I>,
|
||||
b: ty::Ty<I>,
|
||||
) -> RelateResult<I, ty::Ty<I>>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
I: Interner,
|
||||
@@ -226,13 +226,13 @@ pub fn super_combine_consts<Infcx, I, R>(
|
||||
pub fn combine_ty_args<Infcx, I, R>(
|
||||
infcx: &Infcx,
|
||||
relation: &mut R,
|
||||
a_ty: I::Ty,
|
||||
b_ty: I::Ty,
|
||||
a_ty: ty::Ty<I>,
|
||||
b_ty: ty::Ty<I>,
|
||||
variances: I::VariancesOf,
|
||||
a_args: I::GenericArgs,
|
||||
b_args: I::GenericArgs,
|
||||
mk: impl FnOnce(I::GenericArgs) -> I::Ty,
|
||||
) -> RelateResult<I, I::Ty>
|
||||
mk: impl FnOnce(I::GenericArgs) -> ty::Ty<I>,
|
||||
) -> RelateResult<I, ty::Ty<I>>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
I: Interner,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use crate::relate::combine::combine_ty_args;
|
||||
pub use crate::relate::*;
|
||||
use crate::solve::Goal;
|
||||
use crate::{self as ty, InferCtxtLike, Interner};
|
||||
use crate::{self as ty, InferCtxtLike, Interner, Ty};
|
||||
|
||||
pub trait RelateExt: InferCtxtLike {
|
||||
fn relate<T: Relate<Self::Interner>>(
|
||||
@@ -104,7 +104,7 @@ pub struct SolverRelating<'infcx, Infcx, I: Interner> {
|
||||
/// constrain `?1` to `u32`. When using the cache entry from the
|
||||
/// first time we've related these types, this only happens when
|
||||
/// later proving the `Subtype(?0, ?1)` goal from the first relation.
|
||||
cache: DelayedSet<(ty::Variance, I::Ty, I::Ty)>,
|
||||
cache: DelayedSet<(ty::Variance, Ty<I>, Ty<I>)>,
|
||||
}
|
||||
|
||||
impl<'infcx, Infcx, I> SolverRelating<'infcx, Infcx, I>
|
||||
@@ -142,13 +142,13 @@ fn cx(&self) -> I {
|
||||
|
||||
fn relate_ty_args(
|
||||
&mut self,
|
||||
a_ty: I::Ty,
|
||||
b_ty: I::Ty,
|
||||
a_ty: Ty<I>,
|
||||
b_ty: Ty<I>,
|
||||
def_id: I::DefId,
|
||||
a_args: I::GenericArgs,
|
||||
b_args: I::GenericArgs,
|
||||
_: impl FnOnce(I::GenericArgs) -> I::Ty,
|
||||
) -> RelateResult<I, I::Ty> {
|
||||
_: impl FnOnce(I::GenericArgs) -> Ty<I>,
|
||||
) -> RelateResult<I, Ty<I>> {
|
||||
if self.ambient_variance == ty::Invariant {
|
||||
// Avoid fetching the variance if we are in an invariant
|
||||
// context; no need, and it can induce dependency cycles
|
||||
@@ -178,7 +178,7 @@ fn relate_with_variance<T: Relate<I>>(
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "trace")]
|
||||
fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty> {
|
||||
fn tys(&mut self, a: Ty<I>, b: Ty<I>) -> RelateResult<I, Ty<I>> {
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
}
|
||||
@@ -383,7 +383,7 @@ fn register_goals(&mut self, obligations: impl IntoIterator<Item = Goal<I, I::Pr
|
||||
self.goals.extend(obligations);
|
||||
}
|
||||
|
||||
fn register_alias_relate_predicate(&mut self, a: I::Ty, b: I::Ty) {
|
||||
fn register_alias_relate_predicate(&mut self, a: Ty<I>, b: Ty<I>) {
|
||||
self.register_predicates([ty::Binder::dummy(match self.ambient_variance {
|
||||
ty::Covariant => ty::PredicateKind::AliasRelate(
|
||||
a.into(),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
use crate::lang_items::SolverTraitLangItem;
|
||||
use crate::search_graph::PathKind;
|
||||
use crate::{self as ty, Canonical, CanonicalVarValues, Interner, Upcast};
|
||||
use crate::{self as ty, Canonical, CanonicalVarValues, Interner, Ty, Upcast};
|
||||
|
||||
pub type CanonicalInput<I, T = <I as Interner>::Predicate> =
|
||||
ty::CanonicalQueryInput<I, QueryInput<I, T>>;
|
||||
@@ -254,7 +254,7 @@ impl<I: Interner> Eq for Response<I> {}
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
pub struct ExternalConstraintsData<I: Interner> {
|
||||
pub region_constraints: Vec<ty::OutlivesPredicate<I, I::GenericArg>>,
|
||||
pub opaque_types: Vec<(ty::OpaqueTypeKey<I>, I::Ty)>,
|
||||
pub opaque_types: Vec<(ty::OpaqueTypeKey<I>, Ty<I>)>,
|
||||
pub normalization_nested_goals: NestedNormalizationGoals<I>,
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
/// This type is temporary and exists to cut down the bloat of further PR's
|
||||
/// moving `struct Ty` from `rustc_middle` to `rustc_type_ir`.
|
||||
pub type Ty<I> = <I as crate::interner::Interner>::Ty;
|
||||
@@ -100,7 +100,7 @@ pub enum TyKind<I: Interner> {
|
||||
Str,
|
||||
|
||||
/// An array with the given length. Written as `[T; N]`.
|
||||
Array(I::Ty, I::Const),
|
||||
Array(ty::Ty<I>, I::Const),
|
||||
|
||||
/// A pattern newtype.
|
||||
///
|
||||
@@ -109,17 +109,17 @@ pub enum TyKind<I: Interner> {
|
||||
/// Only `Copy` and `Clone` will automatically get implemented for pattern types.
|
||||
/// Auto-traits treat this as if it were an aggregate with a single nested type.
|
||||
/// Only supports integer range patterns for now.
|
||||
Pat(I::Ty, I::Pat),
|
||||
Pat(ty::Ty<I>, I::Pat),
|
||||
|
||||
/// The pointee of an array slice. Written as `[T]`.
|
||||
Slice(I::Ty),
|
||||
Slice(ty::Ty<I>),
|
||||
|
||||
/// A raw pointer. Written as `*mut T` or `*const T`
|
||||
RawPtr(I::Ty, Mutability),
|
||||
RawPtr(ty::Ty<I>, Mutability),
|
||||
|
||||
/// A reference; a pointer with an associated lifetime. Written as
|
||||
/// `&'a mut T` or `&'a T`.
|
||||
Ref(I::Region, I::Ty, Mutability),
|
||||
Ref(I::Region, ty::Ty<I>, Mutability),
|
||||
|
||||
/// The anonymous type of a function declaration/definition.
|
||||
///
|
||||
@@ -469,18 +469,18 @@ pub fn is_opaque(self, interner: I) -> bool {
|
||||
matches!(self.kind(interner), AliasTyKind::Opaque)
|
||||
}
|
||||
|
||||
pub fn to_ty(self, interner: I) -> I::Ty {
|
||||
pub fn to_ty(self, interner: I) -> ty::Ty<I> {
|
||||
Ty::new_alias(interner, self.kind(interner), self)
|
||||
}
|
||||
}
|
||||
|
||||
/// The following methods work only with (trait) associated type projections.
|
||||
impl<I: Interner> AliasTy<I> {
|
||||
pub fn self_ty(self) -> I::Ty {
|
||||
pub fn self_ty(self) -> ty::Ty<I> {
|
||||
self.args.type_at(0)
|
||||
}
|
||||
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: I::Ty) -> Self {
|
||||
pub fn with_replaced_self_ty(self, interner: I, self_ty: ty::Ty<I>) -> Self {
|
||||
AliasTy::new(
|
||||
interner,
|
||||
self.def_id,
|
||||
@@ -735,7 +735,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
)]
|
||||
#[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic)]
|
||||
pub struct TypeAndMut<I: Interner> {
|
||||
pub ty: I::Ty,
|
||||
pub ty: ty::Ty<I>,
|
||||
pub mutbl: Mutability,
|
||||
}
|
||||
|
||||
@@ -765,7 +765,7 @@ pub fn inputs(self) -> I::FnInputTys {
|
||||
self.inputs_and_output.inputs()
|
||||
}
|
||||
|
||||
pub fn output(self) -> I::Ty {
|
||||
pub fn output(self) -> ty::Ty<I> {
|
||||
self.inputs_and_output.output()
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
|
||||
pub fn input(self, index: usize) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound(|fn_sig| fn_sig.inputs().get(index).unwrap())
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(self) -> ty::Binder<I, I::Ty> {
|
||||
pub fn output(self) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound(|fn_sig| fn_sig.output())
|
||||
}
|
||||
|
||||
@@ -856,21 +856,21 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
|
||||
// FIXME: this is a distinct type because we need to define `Encode`/`Decode`
|
||||
// impls in this crate for `Binder<I, I::Ty>`.
|
||||
// impls in this crate for `Binder<I, ty::Ty<I>>`.
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash; I: Interner)]
|
||||
#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
|
||||
#[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic, Lift_Generic)]
|
||||
pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, I::Ty>);
|
||||
pub struct UnsafeBinderInner<I: Interner>(ty::Binder<I, ty::Ty<I>>);
|
||||
|
||||
impl<I: Interner> Eq for UnsafeBinderInner<I> {}
|
||||
|
||||
impl<I: Interner> From<ty::Binder<I, I::Ty>> for UnsafeBinderInner<I> {
|
||||
fn from(value: ty::Binder<I, I::Ty>) -> Self {
|
||||
impl<I: Interner> From<ty::Binder<I, ty::Ty<I>>> for UnsafeBinderInner<I> {
|
||||
fn from(value: ty::Binder<I, ty::Ty<I>>) -> Self {
|
||||
UnsafeBinderInner(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Interner> From<UnsafeBinderInner<I>> for ty::Binder<I, I::Ty> {
|
||||
impl<I: Interner> From<UnsafeBinderInner<I>> for ty::Binder<I, ty::Ty<I>> {
|
||||
fn from(value: UnsafeBinderInner<I>) -> Self {
|
||||
value.0
|
||||
}
|
||||
@@ -883,7 +883,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
|
||||
impl<I: Interner> Deref for UnsafeBinderInner<I> {
|
||||
type Target = ty::Binder<I, I::Ty>;
|
||||
type Target = ty::Binder<I, ty::Ty<I>>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
@@ -894,7 +894,7 @@ fn deref(&self) -> &Self::Target {
|
||||
impl<I: Interner, E: rustc_serialize::Encoder> rustc_serialize::Encodable<E>
|
||||
for UnsafeBinderInner<I>
|
||||
where
|
||||
I::Ty: rustc_serialize::Encodable<E>,
|
||||
ty::Ty<I>: rustc_serialize::Encodable<E>,
|
||||
I::BoundVarKinds: rustc_serialize::Encodable<E>,
|
||||
{
|
||||
fn encode(&self, e: &mut E) {
|
||||
@@ -907,7 +907,7 @@ fn encode(&self, e: &mut E) {
|
||||
impl<I: Interner, D: rustc_serialize::Decoder> rustc_serialize::Decodable<D>
|
||||
for UnsafeBinderInner<I>
|
||||
where
|
||||
I::Ty: TypeVisitable<I> + rustc_serialize::Decodable<D>,
|
||||
ty::Ty<I>: TypeVisitable<I> + rustc_serialize::Decodable<D>,
|
||||
I::BoundVarKinds: rustc_serialize::Decodable<D>,
|
||||
{
|
||||
fn decode(decoder: &mut D) -> Self {
|
||||
@@ -937,7 +937,7 @@ pub fn inputs(self) -> I::FnInputTys {
|
||||
self.inputs_and_output.inputs()
|
||||
}
|
||||
|
||||
pub fn output(self) -> I::Ty {
|
||||
pub fn output(self) -> ty::Ty<I> {
|
||||
self.inputs_and_output.output()
|
||||
}
|
||||
}
|
||||
@@ -960,7 +960,7 @@ pub fn inputs(self) -> ty::Binder<I, I::FnInputTys> {
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> {
|
||||
pub fn input(self, index: usize) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound(|sig_tys| sig_tys.inputs().get(index).unwrap())
|
||||
}
|
||||
|
||||
@@ -969,7 +969,7 @@ pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(self) -> ty::Binder<I, I::Ty> {
|
||||
pub fn output(self) -> ty::Binder<I, ty::Ty<I>> {
|
||||
self.map_bound(|sig_tys| sig_tys.output())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ pub struct ClosureArgsParts<I: Interner> {
|
||||
/// This is the args of the typeck root.
|
||||
pub parent_args: I::GenericArgsSlice,
|
||||
/// Represents the maximum calling capability of the closure.
|
||||
pub closure_kind_ty: I::Ty,
|
||||
pub closure_kind_ty: ty::Ty<I>,
|
||||
/// Captures the closure's signature. This closure signature is "tupled", and
|
||||
/// thus has a peculiar signature of `extern "rust-call" fn((Args, ...)) -> Ty`.
|
||||
pub closure_sig_as_fn_ptr_ty: I::Ty,
|
||||
pub closure_sig_as_fn_ptr_ty: ty::Ty<I>,
|
||||
/// The upvars captured by the closure. Remains an inference variable
|
||||
/// until the upvar analysis, which happens late in HIR typeck.
|
||||
pub tupled_upvars_ty: I::Ty,
|
||||
pub tupled_upvars_ty: ty::Ty<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> ClosureArgs<I> {
|
||||
@@ -169,14 +169,14 @@ pub fn upvar_tys(self) -> I::Tys {
|
||||
|
||||
/// Returns the tuple type representing the upvars for this closure.
|
||||
#[inline]
|
||||
pub fn tupled_upvars_ty(self) -> I::Ty {
|
||||
pub fn tupled_upvars_ty(self) -> ty::Ty<I> {
|
||||
self.split().tupled_upvars_ty
|
||||
}
|
||||
|
||||
/// Returns the closure kind for this closure; may return a type
|
||||
/// variable during inference. To get the closure kind during
|
||||
/// inference, use `infcx.closure_kind(args)`.
|
||||
pub fn kind_ty(self) -> I::Ty {
|
||||
pub fn kind_ty(self) -> ty::Ty<I> {
|
||||
self.split().closure_kind_ty
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ pub fn kind_ty(self) -> I::Ty {
|
||||
// FIXME(eddyb) this should be unnecessary, as the shallowly resolved
|
||||
// type is known at the time of the creation of `ClosureArgs`,
|
||||
// see `rustc_hir_analysis::check::closure`.
|
||||
pub fn sig_as_fn_ptr_ty(self) -> I::Ty {
|
||||
pub fn sig_as_fn_ptr_ty(self) -> ty::Ty<I> {
|
||||
self.split().closure_sig_as_fn_ptr_ty
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ pub struct CoroutineClosureArgsParts<I: Interner> {
|
||||
/// This is the args of the typeck root.
|
||||
pub parent_args: I::GenericArgsSlice,
|
||||
/// Represents the maximum calling capability of the closure.
|
||||
pub closure_kind_ty: I::Ty,
|
||||
pub closure_kind_ty: ty::Ty<I>,
|
||||
/// Represents all of the relevant parts of the coroutine returned by this
|
||||
/// coroutine-closure. This signature parts type will have the general
|
||||
/// shape of `fn(tupled_inputs, resume_ty) -> (return_ty, yield_ty)`, where
|
||||
@@ -232,10 +232,10 @@ pub struct CoroutineClosureArgsParts<I: Interner> {
|
||||
///
|
||||
/// Use `coroutine_closure_sig` to break up this type rather than using it
|
||||
/// yourself.
|
||||
pub signature_parts_ty: I::Ty,
|
||||
pub signature_parts_ty: ty::Ty<I>,
|
||||
/// The upvars captured by the closure. Remains an inference variable
|
||||
/// until the upvar analysis, which happens late in HIR typeck.
|
||||
pub tupled_upvars_ty: I::Ty,
|
||||
pub tupled_upvars_ty: ty::Ty<I>,
|
||||
/// a function pointer that has the shape `for<'env> fn() -> (&'env T, ...)`.
|
||||
/// This allows us to represent the binder of the self-captures of the closure.
|
||||
///
|
||||
@@ -243,7 +243,7 @@ pub struct CoroutineClosureArgsParts<I: Interner> {
|
||||
/// from the closure's upvars, this will be `for<'env> fn() -> (&'env String,)`,
|
||||
/// while the `tupled_upvars_ty`, representing the by-move version of the same
|
||||
/// captures, will be `(String,)`.
|
||||
pub coroutine_captures_by_ref_ty: I::Ty,
|
||||
pub coroutine_captures_by_ref_ty: ty::Ty<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> CoroutineClosureArgs<I> {
|
||||
@@ -277,11 +277,11 @@ pub fn upvar_tys(self) -> I::Tys {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn tupled_upvars_ty(self) -> I::Ty {
|
||||
pub fn tupled_upvars_ty(self) -> ty::Ty<I> {
|
||||
self.split().tupled_upvars_ty
|
||||
}
|
||||
|
||||
pub fn kind_ty(self) -> I::Ty {
|
||||
pub fn kind_ty(self) -> ty::Ty<I> {
|
||||
self.split().closure_kind_ty
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ pub fn kind(self) -> ty::ClosureKind {
|
||||
self.kind_ty().to_opt_closure_kind().unwrap()
|
||||
}
|
||||
|
||||
pub fn signature_parts_ty(self) -> I::Ty {
|
||||
pub fn signature_parts_ty(self) -> ty::Ty<I> {
|
||||
self.split().signature_parts_ty
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ pub fn coroutine_closure_sig(self) -> ty::Binder<I, CoroutineClosureSignature<I>
|
||||
})
|
||||
}
|
||||
|
||||
pub fn coroutine_captures_by_ref_ty(self) -> I::Ty {
|
||||
pub fn coroutine_captures_by_ref_ty(self) -> ty::Ty<I> {
|
||||
self.split().coroutine_captures_by_ref_ty
|
||||
}
|
||||
|
||||
@@ -358,10 +358,10 @@ fn visit_region(&mut self, r: I::Region) -> Self::Result {
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic)]
|
||||
pub struct CoroutineClosureSignature<I: Interner> {
|
||||
pub tupled_inputs_ty: I::Ty,
|
||||
pub resume_ty: I::Ty,
|
||||
pub yield_ty: I::Ty,
|
||||
pub return_ty: I::Ty,
|
||||
pub tupled_inputs_ty: ty::Ty<I>,
|
||||
pub resume_ty: ty::Ty<I>,
|
||||
pub yield_ty: ty::Ty<I>,
|
||||
pub return_ty: ty::Ty<I>,
|
||||
|
||||
// Like the `fn_sig_as_fn_ptr_ty` of a regular closure, these types
|
||||
// never actually differ. But we save them rather than recreating them
|
||||
@@ -393,10 +393,10 @@ pub fn to_coroutine(
|
||||
self,
|
||||
cx: I,
|
||||
parent_args: I::GenericArgsSlice,
|
||||
coroutine_kind_ty: I::Ty,
|
||||
coroutine_kind_ty: ty::Ty<I>,
|
||||
coroutine_def_id: I::CoroutineId,
|
||||
tupled_upvars_ty: I::Ty,
|
||||
) -> I::Ty {
|
||||
tupled_upvars_ty: ty::Ty<I>,
|
||||
) -> ty::Ty<I> {
|
||||
let coroutine_args = ty::CoroutineArgs::new(
|
||||
cx,
|
||||
ty::CoroutineArgsParts {
|
||||
@@ -424,9 +424,9 @@ pub fn to_coroutine_given_kind_and_upvars(
|
||||
coroutine_def_id: I::CoroutineId,
|
||||
goal_kind: ty::ClosureKind,
|
||||
env_region: I::Region,
|
||||
closure_tupled_upvars_ty: I::Ty,
|
||||
coroutine_captures_by_ref_ty: I::Ty,
|
||||
) -> I::Ty {
|
||||
closure_tupled_upvars_ty: ty::Ty<I>,
|
||||
coroutine_captures_by_ref_ty: ty::Ty<I>,
|
||||
) -> ty::Ty<I> {
|
||||
let tupled_upvars_ty = Self::tupled_upvars_by_closure_kind(
|
||||
cx,
|
||||
goal_kind,
|
||||
@@ -457,11 +457,11 @@ pub fn to_coroutine_given_kind_and_upvars(
|
||||
pub fn tupled_upvars_by_closure_kind(
|
||||
cx: I,
|
||||
kind: ty::ClosureKind,
|
||||
tupled_inputs_ty: I::Ty,
|
||||
closure_tupled_upvars_ty: I::Ty,
|
||||
coroutine_captures_by_ref_ty: I::Ty,
|
||||
tupled_inputs_ty: ty::Ty<I>,
|
||||
closure_tupled_upvars_ty: ty::Ty<I>,
|
||||
coroutine_captures_by_ref_ty: ty::Ty<I>,
|
||||
env_region: I::Region,
|
||||
) -> I::Ty {
|
||||
) -> ty::Ty<I> {
|
||||
match kind {
|
||||
ty::ClosureKind::Fn | ty::ClosureKind::FnMut => {
|
||||
let ty::FnPtr(sig_tys, _) = coroutine_captures_by_ref_ty.kind() else {
|
||||
@@ -503,7 +503,7 @@ struct FoldEscapingRegions<I: Interner> {
|
||||
|
||||
// Depends on `debruijn` because we may have types with regions of different
|
||||
// debruijn depths depending on the binders we've entered.
|
||||
cache: DelayedMap<(ty::DebruijnIndex, I::Ty), I::Ty>,
|
||||
cache: DelayedMap<(ty::DebruijnIndex, ty::Ty<I>), ty::Ty<I>>,
|
||||
}
|
||||
|
||||
impl<I: Interner> TypeFolder<I> for FoldEscapingRegions<I> {
|
||||
@@ -511,7 +511,7 @@ fn cx(&self) -> I {
|
||||
self.interner
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
|
||||
if !t.has_vars_bound_at_or_above(self.debruijn) {
|
||||
t
|
||||
} else if let Some(&t) = self.cache.get(&(self.debruijn, t)) {
|
||||
@@ -553,9 +553,9 @@ fn fold_region(&mut self, r: <I as Interner>::Region) -> <I as Interner>::Region
|
||||
#[derive_where(Clone, Copy, PartialEq, Hash, Debug; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic)]
|
||||
pub struct GenSig<I: Interner> {
|
||||
pub resume_ty: I::Ty,
|
||||
pub yield_ty: I::Ty,
|
||||
pub return_ty: I::Ty,
|
||||
pub resume_ty: ty::Ty<I>,
|
||||
pub yield_ty: ty::Ty<I>,
|
||||
pub return_ty: ty::Ty<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> Eq for GenSig<I> {}
|
||||
@@ -581,15 +581,15 @@ pub struct CoroutineArgsParts<I: Interner> {
|
||||
/// kind: `i8`/`i16`/`i32`.
|
||||
///
|
||||
/// For regular coroutines, this field will always just be `()`.
|
||||
pub kind_ty: I::Ty,
|
||||
pub kind_ty: ty::Ty<I>,
|
||||
|
||||
pub resume_ty: I::Ty,
|
||||
pub yield_ty: I::Ty,
|
||||
pub return_ty: I::Ty,
|
||||
pub resume_ty: ty::Ty<I>,
|
||||
pub yield_ty: ty::Ty<I>,
|
||||
pub return_ty: ty::Ty<I>,
|
||||
|
||||
/// The upvars captured by the closure. Remains an inference variable
|
||||
/// until the upvar analysis, which happens late in HIR typeck.
|
||||
pub tupled_upvars_ty: I::Ty,
|
||||
pub tupled_upvars_ty: ty::Ty<I>,
|
||||
}
|
||||
|
||||
impl<I: Interner> CoroutineArgs<I> {
|
||||
@@ -619,7 +619,7 @@ pub fn parent_args(self) -> I::GenericArgsSlice {
|
||||
}
|
||||
|
||||
// Returns the kind of the coroutine. See docs on the `kind_ty` field.
|
||||
pub fn kind_ty(self) -> I::Ty {
|
||||
pub fn kind_ty(self) -> ty::Ty<I> {
|
||||
self.split().kind_ty
|
||||
}
|
||||
|
||||
@@ -638,22 +638,22 @@ pub fn upvar_tys(self) -> I::Tys {
|
||||
|
||||
/// Returns the tuple type representing the upvars for this coroutine.
|
||||
#[inline]
|
||||
pub fn tupled_upvars_ty(self) -> I::Ty {
|
||||
pub fn tupled_upvars_ty(self) -> ty::Ty<I> {
|
||||
self.split().tupled_upvars_ty
|
||||
}
|
||||
|
||||
/// Returns the type representing the resume type of the coroutine.
|
||||
pub fn resume_ty(self) -> I::Ty {
|
||||
pub fn resume_ty(self) -> ty::Ty<I> {
|
||||
self.split().resume_ty
|
||||
}
|
||||
|
||||
/// Returns the type representing the yield type of the coroutine.
|
||||
pub fn yield_ty(self) -> I::Ty {
|
||||
pub fn yield_ty(self) -> ty::Ty<I> {
|
||||
self.split().yield_ty
|
||||
}
|
||||
|
||||
/// Returns the type representing the return type of the coroutine.
|
||||
pub fn return_ty(self) -> I::Ty {
|
||||
pub fn return_ty(self) -> ty::Ty<I> {
|
||||
self.split().return_ty
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
use crate::inherent::*;
|
||||
use crate::{self as ty, Interner, TypeFlags};
|
||||
use crate::{self as ty, Interner, Ty, TypeFlags};
|
||||
|
||||
/// This trait is implemented for every type that can be visited,
|
||||
/// providing the skeleton of the traversal.
|
||||
@@ -98,7 +98,7 @@ fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::R
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, t: Ty<I>) -> Self::Result {
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::R
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, t: Ty<I>) -> Self::Result {
|
||||
// Note: no `super_visit_with` call.
|
||||
let flags = t.flags();
|
||||
if flags.intersects(self.flags) {
|
||||
@@ -522,7 +522,7 @@ fn visit_binder<T: TypeVisitable<I>>(&mut self, t: &ty::Binder<I, T>) -> Self::R
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
|
||||
fn visit_ty(&mut self, t: Ty<I>) -> Self::Result {
|
||||
// If the outer-exclusive-binder is *strictly greater* than
|
||||
// `outer_index`, that means that `t` contains some content
|
||||
// bound at `outer_index` or above (because
|
||||
|
||||
+24
-32
@@ -1,19 +1,18 @@
|
||||
//! # Experimental replacement range types
|
||||
//! # Replacement range types
|
||||
//!
|
||||
//! The types within this module are meant to replace the existing
|
||||
//! `Range`, `RangeInclusive`, and `RangeFrom` types in a future edition.
|
||||
//! The types within this module are meant to replace the legacy `Range`,
|
||||
//! `RangeInclusive`, `RangeToInclusive` and `RangeFrom` types in a future edition.
|
||||
//!
|
||||
//! ```
|
||||
//! #![feature(new_range_api)]
|
||||
//! use core::range::{Range, RangeFrom, RangeInclusive};
|
||||
//! use core::range::{Range, RangeFrom, RangeInclusive, RangeToInclusive};
|
||||
//!
|
||||
//! let arr = [0, 1, 2, 3, 4];
|
||||
//! assert_eq!(arr[ .. ], [0, 1, 2, 3, 4]);
|
||||
//! assert_eq!(arr[ .. 3 ], [0, 1, 2 ]);
|
||||
//! assert_eq!(arr[ ..=3 ], [0, 1, 2, 3 ]);
|
||||
//! assert_eq!(arr[ RangeFrom::from(1.. )], [ 1, 2, 3, 4]);
|
||||
//! assert_eq!(arr[ Range::from(1..3 )], [ 1, 2 ]);
|
||||
//! assert_eq!(arr[RangeInclusive::from(1..=3)], [ 1, 2, 3 ]);
|
||||
//! assert_eq!(arr[ .. ], [0, 1, 2, 3, 4]);
|
||||
//! assert_eq!(arr[ .. 3 ], [0, 1, 2 ]);
|
||||
//! assert_eq!(arr[RangeToInclusive::from( ..=3)], [0, 1, 2, 3 ]);
|
||||
//! assert_eq!(arr[ RangeFrom::from(1.. )], [ 1, 2, 3, 4]);
|
||||
//! assert_eq!(arr[ Range::from(1..3 )], [ 1, 2 ]);
|
||||
//! assert_eq!(arr[ RangeInclusive::from(1..=3)], [ 1, 2, 3 ]);
|
||||
//! ```
|
||||
|
||||
use crate::fmt;
|
||||
@@ -21,7 +20,7 @@
|
||||
|
||||
mod iter;
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[unstable(feature = "new_range_api_legacy", issue = "125687")]
|
||||
pub mod legacy;
|
||||
|
||||
#[doc(inline)]
|
||||
@@ -31,7 +30,7 @@
|
||||
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
|
||||
pub use iter::RangeInclusiveIter;
|
||||
#[doc(inline)]
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub use iter::RangeIter;
|
||||
|
||||
// FIXME(#125687): re-exports temporarily removed
|
||||
@@ -57,7 +56,6 @@
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(new_range_api)]
|
||||
/// use core::range::Range;
|
||||
///
|
||||
/// assert_eq!(Range::from(3..5), Range { start: 3, end: 5 });
|
||||
@@ -66,17 +64,17 @@
|
||||
#[lang = "RangeCopy"]
|
||||
#[derive(Copy, Hash)]
|
||||
#[derive_const(Clone, Default, PartialEq, Eq)]
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub struct Range<Idx> {
|
||||
/// The lower bound of the range (inclusive).
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub start: Idx,
|
||||
/// The upper bound of the range (exclusive).
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub end: Idx,
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.start.fmt(fmt)?;
|
||||
@@ -94,7 +92,6 @@ impl<Idx: Step> Range<Idx> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(new_range_api)]
|
||||
/// use core::range::Range;
|
||||
///
|
||||
/// let mut i = Range::from(3..9).iter().map(|n| n*n);
|
||||
@@ -102,7 +99,7 @@ impl<Idx: Step> Range<Idx> {
|
||||
/// assert_eq!(i.next(), Some(16));
|
||||
/// assert_eq!(i.next(), Some(25));
|
||||
/// ```
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
pub fn iter(&self) -> RangeIter<Idx> {
|
||||
self.clone().into_iter()
|
||||
@@ -115,7 +112,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(new_range_api)]
|
||||
/// use core::range::Range;
|
||||
///
|
||||
/// assert!(!Range::from(3..5).contains(&2));
|
||||
@@ -132,7 +128,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
|
||||
/// assert!(!Range::from(f32::NAN..1.0).contains(&0.5));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
||||
pub const fn contains<U>(&self, item: &U) -> bool
|
||||
where
|
||||
@@ -147,7 +143,6 @@ pub const fn contains<U>(&self, item: &U) -> bool
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(new_range_api)]
|
||||
/// use core::range::Range;
|
||||
///
|
||||
/// assert!(!Range::from(3..5).is_empty());
|
||||
@@ -158,7 +153,6 @@ pub const fn contains<U>(&self, item: &U) -> bool
|
||||
/// The range is empty if either side is incomparable:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(new_range_api)]
|
||||
/// use core::range::Range;
|
||||
///
|
||||
/// assert!(!Range::from(3.0..5.0).is_empty());
|
||||
@@ -166,7 +160,7 @@ pub const fn contains<U>(&self, item: &U) -> bool
|
||||
/// assert!( Range::from(f32::NAN..5.0).is_empty());
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
||||
pub const fn is_empty(&self) -> bool
|
||||
where
|
||||
@@ -176,7 +170,7 @@ pub const fn is_empty(&self) -> bool
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
||||
impl<T> const RangeBounds<T> for Range<T> {
|
||||
fn start_bound(&self) -> Bound<&T> {
|
||||
@@ -193,7 +187,7 @@ fn end_bound(&self) -> Bound<&T> {
|
||||
/// If you need to use this implementation where `T` is unsized,
|
||||
/// consider using the `RangeBounds` impl for a 2-tuple of [`Bound<&T>`][Bound],
|
||||
/// i.e. replace `start..end` with `(Bound::Included(start), Bound::Excluded(end))`.
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
||||
impl<T> const RangeBounds<T> for Range<&T> {
|
||||
fn start_bound(&self) -> Bound<&T> {
|
||||
@@ -204,8 +198,7 @@ fn end_bound(&self) -> Bound<&T> {
|
||||
}
|
||||
}
|
||||
|
||||
// #[unstable(feature = "range_into_bounds", issue = "136903")]
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[unstable(feature = "range_into_bounds", issue = "136903")]
|
||||
#[rustc_const_unstable(feature = "const_range", issue = "none")]
|
||||
impl<T> const IntoBounds<T> for Range<T> {
|
||||
fn into_bounds(self) -> (Bound<T>, Bound<T>) {
|
||||
@@ -213,7 +206,7 @@ fn into_bounds(self) -> (Bound<T>, Bound<T>) {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
|
||||
impl<T> const From<Range<T>> for legacy::Range<T> {
|
||||
#[inline]
|
||||
@@ -221,8 +214,7 @@ fn from(value: Range<T>) -> Self {
|
||||
Self { start: value.start, end: value.end }
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
|
||||
impl<T> const From<legacy::Range<T>> for Range<T> {
|
||||
#[inline]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use crate::{intrinsics, mem};
|
||||
|
||||
/// By-value [`Range`] iterator.
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RangeIter<A>(legacy::Range<A>);
|
||||
|
||||
@@ -17,7 +17,6 @@ impl<A> RangeIter<A> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(new_range_api)]
|
||||
/// #![feature(new_range_remainder)]
|
||||
///
|
||||
/// let range = core::range::Range::from(3..11);
|
||||
@@ -65,7 +64,7 @@ unsafe impl TrustedRandomAccessNoCoerce for RangeIter<$t> {
|
||||
u64 i64
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<A: Step> Iterator for RangeIter<A> {
|
||||
type Item = A;
|
||||
|
||||
@@ -133,7 +132,7 @@ unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<A: Step> DoubleEndedIterator for RangeIter<A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<A> {
|
||||
@@ -154,10 +153,10 @@ fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
|
||||
#[unstable(feature = "trusted_len", issue = "37572")]
|
||||
unsafe impl<A: TrustedStep> TrustedLen for RangeIter<A> {}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<A: Step> FusedIterator for RangeIter<A> {}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl<A: Step> IntoIterator for Range<A> {
|
||||
type Item = A;
|
||||
type IntoIter = RangeIter<A>;
|
||||
@@ -300,7 +299,7 @@ fn into_iter(self) -> Self::IntoIter {
|
||||
// since e.g. `(0..=u64::MAX).len()` would be `u64::MAX + 1`.
|
||||
macro_rules! range_exact_iter_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl ExactSizeIterator for RangeIter<$t> { }
|
||||
)*)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ impl Sealed for ops::RangeToInclusive<usize> {}
|
||||
#[stable(feature = "slice_index_with_ops_bound_pair", since = "1.53.0")]
|
||||
impl Sealed for (ops::Bound<usize>, ops::Bound<usize>) {}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl Sealed for range::Range<usize> {}
|
||||
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
|
||||
impl Sealed for range::RangeInclusive<usize> {}
|
||||
@@ -458,7 +458,7 @@ fn index_mut(self, slice: &mut [T]) -> &mut [T] {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
|
||||
unsafe impl<T> const SliceIndex<[T]> for range::Range<usize> {
|
||||
type Output = [T];
|
||||
|
||||
@@ -258,7 +258,7 @@ fn index_mut(self, slice: &mut str) -> &mut Self::Output {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
|
||||
unsafe impl const SliceIndex<str> for range::Range<usize> {
|
||||
type Output = str;
|
||||
|
||||
@@ -2136,7 +2136,7 @@ pub fn try_update(
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "atomic_try_update", since = "1.95.0")]
|
||||
#[cfg(target_has_atomic = "8")]
|
||||
#[cfg(target_has_atomic = "ptr")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[rustc_should_not_be_called_on_const_items]
|
||||
pub fn update(
|
||||
|
||||
@@ -85,7 +85,6 @@
|
||||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(never_type)]
|
||||
#![feature(new_range_api)]
|
||||
#![feature(next_index)]
|
||||
#![feature(non_exhaustive_omitted_patterns_lint)]
|
||||
#![feature(nonzero_from_str_radix)]
|
||||
|
||||
@@ -537,7 +537,7 @@
|
||||
pub use core::pin;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::ptr;
|
||||
#[unstable(feature = "new_range_api", issue = "125687")]
|
||||
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub use core::range;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::result;
|
||||
|
||||
@@ -170,6 +170,7 @@ dependencies = [
|
||||
"clap",
|
||||
"csv",
|
||||
"diff",
|
||||
"flate2",
|
||||
"glob-match",
|
||||
"insta",
|
||||
"serde",
|
||||
@@ -344,12 +345,13 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.0"
|
||||
version = "1.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
|
||||
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
"zlib-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -630,6 +632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -812,6 +815,12 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
|
||||
|
||||
[[package]]
|
||||
name = "similar"
|
||||
version = "2.7.0"
|
||||
@@ -1187,3 +1196,9 @@ dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zlib-rs"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513"
|
||||
|
||||
@@ -9,6 +9,7 @@ askama = "0.15.4"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
csv = "1"
|
||||
diff = "0.1"
|
||||
flate2 = { version = "1.1.9", default-features = false, features = ["zlib-rs"] } # For feature flag only
|
||||
glob-match = "0.2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_yaml = "0.9"
|
||||
|
||||
@@ -8,7 +8,7 @@ toml = "0.7"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
anyhow = "1.0.32"
|
||||
flate2 = "1.0.26"
|
||||
flate2 = { version = "1.1.9", default-features = false, features = ["zlib-rs"] }
|
||||
xz2 = "0.1.7"
|
||||
tar = "0.4.45"
|
||||
sha2 = "0.10.1"
|
||||
|
||||
@@ -11,7 +11,7 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.19"
|
||||
flate2 = "1.0.1"
|
||||
flate2 = { version = "1.1.9", default-features = false, features = ["zlib-rs"] }
|
||||
rayon = "1.0"
|
||||
tar = "0.4.45"
|
||||
walkdir = "2"
|
||||
|
||||
@@ -504,6 +504,7 @@ pub(crate) struct WorkspaceInfo<'a> {
|
||||
"zerotrie",
|
||||
"zerovec",
|
||||
"zerovec-derive",
|
||||
"zlib-rs",
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@ ui/associated-types/issue-44153.rs
|
||||
ui/associated-types/issue-47139-1.rs
|
||||
ui/associated-types/issue-47139-2.rs
|
||||
ui/associated-types/issue-47385.rs
|
||||
ui/associated-types/issue-47814.rs
|
||||
ui/associated-types/issue-48010.rs
|
||||
ui/associated-types/issue-48551.rs
|
||||
ui/associated-types/issue-50301.rs
|
||||
@@ -406,7 +405,6 @@ ui/closures/2229_closure_analysis/match/issue-87097.rs
|
||||
ui/closures/2229_closure_analysis/match/issue-87426.rs
|
||||
ui/closures/2229_closure_analysis/match/issue-87988.rs
|
||||
ui/closures/2229_closure_analysis/match/issue-88331.rs
|
||||
ui/closures/2229_closure_analysis/migrations/issue-78720.rs
|
||||
ui/closures/2229_closure_analysis/migrations/issue-86753.rs
|
||||
ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs
|
||||
ui/closures/2229_closure_analysis/run_pass/issue-87378.rs
|
||||
@@ -1001,7 +999,6 @@ ui/fmt/issue-86085.rs
|
||||
ui/fmt/issue-89173.rs
|
||||
ui/fmt/issue-91556.rs
|
||||
ui/fn/issue-1451.rs
|
||||
ui/fn/issue-1900.rs
|
||||
ui/fn/issue-3044.rs
|
||||
ui/fn/issue-3099.rs
|
||||
ui/fn/issue-3904.rs
|
||||
|
||||
+22
-6
@@ -36,6 +36,8 @@ These tests exercise the [`annotate-snippets`]-based emitter implementation.
|
||||
|
||||
[`annotate-snippets`]: https://github.com/rust-lang/annotate-snippets-rs
|
||||
|
||||
**FIXME**: merge this with `error-emitter`
|
||||
|
||||
## `tests/ui/anon-params`
|
||||
|
||||
These tests deal with anonymous parameters (no name, only type), a deprecated feature that becomes a hard error in Edition 2018.
|
||||
@@ -141,6 +143,8 @@ However, only a single test was ever added to this category: <https://github.com
|
||||
|
||||
Tests for pattern binding in match expressions, let statements, and other binding contexts. E.g. binding modes and refutability. See [Patterns | Reference](https://doc.rust-lang.org/reference/patterns.html).
|
||||
|
||||
**FIXME**: quite some overlap with `tests/ui/pattern` and `tests/ui/match`.
|
||||
|
||||
## `tests/ui/binop/`: Binary operators
|
||||
|
||||
Tests for binary operators (such as `==`, `&&` or `^`). E.g. overloading, type checking, and diagnostics for invalid operations.
|
||||
@@ -272,7 +276,7 @@ This directory is actually for the standard library [`std::process::Command`](ht
|
||||
|
||||
Some traits' implementation must be compared with their definition, checking for problems such as the implementation having stricter requirements (such as needing to implement `Copy`).
|
||||
|
||||
This subdirectory is *not* intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`).
|
||||
This subdirectory is *not* intended for comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`).
|
||||
|
||||
## `tests/ui/compile-flags/`
|
||||
|
||||
@@ -448,6 +452,8 @@ Exercises diagnostics for when a code block attempts to gain ownership of a non-
|
||||
|
||||
Exercises diagnostics for disallowed struct destructuring.
|
||||
|
||||
**FIXME**: does this really need to be its own immediate subdirectory?
|
||||
|
||||
## `tests/ui/dist`
|
||||
|
||||
Tests that require distribution artifacts.
|
||||
@@ -508,7 +514,7 @@ These tests run in specific Rust editions, such as Rust 2015 or Rust 2018, and c
|
||||
|
||||
## `tests/ui/eii`: Externally Implementable Items
|
||||
|
||||
Exercises `eii` keyword.
|
||||
Exercises the `#[eii]` attribute and related features.
|
||||
|
||||
## `tests/ui/entry-point/`: `main` function
|
||||
|
||||
@@ -611,8 +617,6 @@ Tests for `#![feature(fn_traits)]`. See [`fn_traits` | The Unstable book](https:
|
||||
|
||||
Anything to do with loops and `for`, `loop` and `while` keywords to express them.
|
||||
|
||||
**FIXME**: After `ui/for` is merged into this, also carry over its SUMMARY text.
|
||||
|
||||
## `tests/ui/force-inlining/`: `#[rustc_force_inline]`
|
||||
|
||||
Tests for `#[rustc_force_inline]`, which will force a function to always be labelled as inline by the compiler (it will be inserted at the point of its call instead of being used as a normal function call.) If the compiler is unable to inline the function, an error will be reported. See <https://github.com/rust-lang/rust/pull/134082>.
|
||||
@@ -730,6 +734,8 @@ Tests on type inference.
|
||||
|
||||
Tests for diagnostics on infinitely recursive types without indirection.
|
||||
|
||||
**FIXME**: check for overlap with `structs-enums/enum-rec` and `structs-enums/struct-rec`
|
||||
|
||||
## `tests/ui/inline-const/`
|
||||
|
||||
These tests revolve around the inline `const` block that forces the compiler to const-eval its content.
|
||||
@@ -853,7 +859,9 @@ Tests exercising analysis for unused variables, unreachable statements, function
|
||||
|
||||
## `tests/ui/loop-match`
|
||||
|
||||
Tests for `loop` with `match` expressions.
|
||||
Tests for the `loop_match` feature to optimize `loop`s consisting of one big `match` expressions.
|
||||
|
||||
See [Tracking issue for way to express intraprocedural finite state machines #132306](https://github.com/rust-lang/rust/issues/132306).
|
||||
|
||||
## `tests/ui/loops/`
|
||||
|
||||
@@ -891,6 +899,8 @@ See [Tracking issue for allowing overlapping implementations for marker trait #2
|
||||
|
||||
Broad category of tests on `match` constructs.
|
||||
|
||||
**FIXME**: many tests overlap with `tests/ui/bindings`, try to reduce duplication.
|
||||
|
||||
## `tests/ui/methods/`
|
||||
|
||||
A broad category for anything related to methods and method resolution.
|
||||
@@ -899,6 +909,8 @@ A broad category for anything related to methods and method resolution.
|
||||
|
||||
Certain mir-opt regression tests.
|
||||
|
||||
**FIXME**: many tests in this directory are not about MIR or optimizations, relocate these.
|
||||
|
||||
## `tests/ui/mir-dataflow`
|
||||
|
||||
Tests for MIR dataflow analysis.
|
||||
@@ -977,6 +989,8 @@ Tests that exercises edge cases, such as specific floats, large or very small nu
|
||||
|
||||
Tests that checks numeric types and their interactions, such as casting among them with `as` or providing the wrong numeric suffix.
|
||||
|
||||
**FIXME**: these tests could get moved to other directories, in particular `cast/` or `parser/`.
|
||||
|
||||
## `tests/ui/object-lifetime/`
|
||||
|
||||
Tests on lifetimes on objects, such as a lifetime bound not being able to be deduced from context, or checking that lifetimes are inherited properly.
|
||||
@@ -1308,7 +1322,7 @@ Some standard library tests which are too inconvenient or annoying to implement
|
||||
|
||||
## `tests/ui/str/`
|
||||
|
||||
Exercise `str` keyword and string slices.
|
||||
Exercise `str` primitive and string slices.
|
||||
|
||||
## `tests/ui/structs/`
|
||||
|
||||
@@ -1464,6 +1478,8 @@ See [RFC 0132 Unified Function Call Syntax](https://github.com/rust-lang/rfcs/bl
|
||||
|
||||
`#![feature(unboxed_closures)]`, `Fn`, `FnMut` and `FnOnce` traits
|
||||
|
||||
**FIXME**: many tests have `unboxed-closure` in their name but only test normal closures, rename these.
|
||||
|
||||
See [Tracking issue for Fn traits (`unboxed_closures` & `fn_traits` feature)](https://github.com/rust-lang/rust/issues/29625).
|
||||
|
||||
## `tests/ui/underscore-lifetime/`: `'_` elided lifetime
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
struct ArpIPv4<'a> {
|
||||
s: &'a u8
|
||||
}
|
||||
|
||||
impl<'a> ArpIPv4<'a> {
|
||||
const LENGTH: usize = 20;
|
||||
|
||||
pub fn to_buffer() -> [u8; Self::LENGTH] { //~ ERROR generic `Self` types are currently not permitted in anonymous constants
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
@@ -1,14 +0,0 @@
|
||||
error: generic `Self` types are currently not permitted in anonymous constants
|
||||
--> $DIR/issue-47814.rs:8:32
|
||||
|
|
||||
LL | pub fn to_buffer() -> [u8; Self::LENGTH] {
|
||||
| ^^^^
|
||||
|
|
||||
note: not a concrete type
|
||||
--> $DIR/issue-47814.rs:5:10
|
||||
|
|
||||
LL | impl<'a> ArpIPv4<'a> {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// Regression test for https://github.com/rust-lang/rust/issues/83176.
|
||||
//@ run-pass
|
||||
|
||||
#![warn(rust_2021_incompatible_closure_captures)]
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
warning: irrefutable `if let` pattern
|
||||
--> $DIR/issue-78720.rs:7:8
|
||||
--> $DIR/nested-copy-drops-83176.rs:8:8
|
||||
|
|
||||
LL | if let a = "" {
|
||||
| ^^^^^^^^^^
|
||||
@@ -1,5 +1,3 @@
|
||||
#![feature(new_range_api)]
|
||||
|
||||
fn main() {
|
||||
let a: core::range::RangeFrom<u8> = 1..;
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/feature-gate-new_range.rs:4:41
|
||||
--> $DIR/feature-gate-new_range.rs:2:41
|
||||
|
|
||||
LL | let a: core::range::RangeFrom<u8> = 1..;
|
||||
| -------------------------- ^^^ expected `RangeFrom<u8>`, found `RangeFrom<{integer}>`
|
||||
@@ -14,7 +14,7 @@ LL | let a: core::range::RangeFrom<u8> = (1..).into();
|
||||
| + ++++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/feature-gate-new_range.rs:6:37
|
||||
--> $DIR/feature-gate-new_range.rs:4:37
|
||||
|
|
||||
LL | let b: core::range::Range<u8> = 2..3;
|
||||
| ---------------------- ^^^^ expected `Range<u8>`, found `Range<{integer}>`
|
||||
@@ -29,7 +29,7 @@ LL | let b: core::range::Range<u8> = (2..3).into();
|
||||
| + ++++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/feature-gate-new_range.rs:8:46
|
||||
--> $DIR/feature-gate-new_range.rs:6:46
|
||||
|
|
||||
LL | let c: core::range::RangeInclusive<u8> = 4..=5;
|
||||
| ------------------------------- ^^^^^ expected `RangeInclusive<u8>`, found `RangeInclusive<{integer}>`
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
fn main<T>() { }
|
||||
//~^ ERROR `main` function is not allowed to have generic parameters
|
||||
@@ -1,9 +0,0 @@
|
||||
error[E0131]: `main` function is not allowed to have generic parameters
|
||||
--> $DIR/issue-1900.rs:1:8
|
||||
|
|
||||
LL | fn main<T>() { }
|
||||
| ^^^ `main` cannot have generic parameters
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0131`.
|
||||
@@ -0,0 +1,6 @@
|
||||
//! Regression test for https://github.com/rust-lang/rust/issues/36379
|
||||
//@ check-pass
|
||||
|
||||
fn _test() -> impl Default { }
|
||||
|
||||
fn main() {}
|
||||
@@ -1,5 +0,0 @@
|
||||
//@ check-pass
|
||||
|
||||
fn _test() -> impl Default { }
|
||||
|
||||
fn main() {}
|
||||
@@ -1,6 +1,6 @@
|
||||
//@ check-pass
|
||||
|
||||
#![feature(new_range_api)]
|
||||
#![feature(new_range_api_legacy)]
|
||||
|
||||
fn main() {
|
||||
// Unchanged
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//@ check-pass
|
||||
|
||||
#![feature(new_range_api)]
|
||||
#![feature(new_range)]
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//@ edition:2021
|
||||
// Regression test for #125805.
|
||||
// ICE when using `offset_of!` on a field whose type is a bare trait object
|
||||
// with a missing lifetime parameter.
|
||||
|
||||
trait X<'a> {}
|
||||
|
||||
use std::mem::offset_of;
|
||||
|
||||
struct T {
|
||||
y: X,
|
||||
//~^ ERROR missing lifetime specifier [E0106]
|
||||
//~| ERROR expected a type, found a trait [E0782]
|
||||
}
|
||||
|
||||
fn other() {
|
||||
offset_of!(T, y);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,27 @@
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/offset-of-unsized-trait-object-missing-lifetime.rs:11:8
|
||||
|
|
||||
LL | y: X,
|
||||
| ^ expected named lifetime parameter
|
||||
|
|
||||
help: consider introducing a named lifetime parameter
|
||||
|
|
||||
LL ~ struct T<'a> {
|
||||
LL ~ y: X<'a>,
|
||||
|
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/offset-of-unsized-trait-object-missing-lifetime.rs:11:8
|
||||
|
|
||||
LL | y: X,
|
||||
| ^
|
||||
|
|
||||
help: you can add the `dyn` keyword if you want a trait object
|
||||
|
|
||||
LL | y: dyn X,
|
||||
| +++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0782.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
@@ -6,6 +6,7 @@
|
||||
RangeToInclusive,
|
||||
RangeFrom,
|
||||
RangeFromIter,
|
||||
Range,
|
||||
};
|
||||
|
||||
fn range_inclusive(mut r: RangeInclusive<usize>) {
|
||||
@@ -43,13 +44,24 @@ fn range_from(mut r: RangeFrom<usize>) {
|
||||
i.remainder(); //~ ERROR unstable
|
||||
}
|
||||
|
||||
fn range(mut r: Range<usize>) {
|
||||
&[1, 2, 3][r];
|
||||
|
||||
r.start;
|
||||
r.end;
|
||||
r.contains(&5);
|
||||
r.is_empty();
|
||||
r.iter();
|
||||
|
||||
let mut i = r.into_iter();
|
||||
i.next();
|
||||
|
||||
// Left unstable
|
||||
i.remainder(); //~ ERROR unstable
|
||||
}
|
||||
|
||||
// Unstable module
|
||||
|
||||
use std::range::legacy; //~ ERROR unstable
|
||||
|
||||
// Unstable types
|
||||
|
||||
use std::range::Range; //~ ERROR unstable
|
||||
use std::range::RangeIter; //~ ERROR unstable
|
||||
|
||||
fn main() {}
|
||||
|
||||
@@ -1,35 +1,15 @@
|
||||
error[E0658]: use of unstable library feature `new_range_api`
|
||||
--> $DIR/new_range_stability.rs:48:5
|
||||
error[E0658]: use of unstable library feature `new_range_api_legacy`
|
||||
--> $DIR/new_range_stability.rs:65:5
|
||||
|
|
||||
LL | use std::range::legacy;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
|
||||
= help: add `#![feature(new_range_api)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `new_range_api`
|
||||
--> $DIR/new_range_stability.rs:52:5
|
||||
|
|
||||
LL | use std::range::Range;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
|
||||
= help: add `#![feature(new_range_api)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `new_range_api`
|
||||
--> $DIR/new_range_stability.rs:53:5
|
||||
|
|
||||
LL | use std::range::RangeIter;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
|
||||
= help: add `#![feature(new_range_api)]` to the crate attributes to enable
|
||||
= help: add `#![feature(new_range_api_legacy)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `new_range_remainder`
|
||||
--> $DIR/new_range_stability.rs:22:7
|
||||
--> $DIR/new_range_stability.rs:23:7
|
||||
|
|
||||
LL | i.remainder();
|
||||
| ^^^^^^^^^
|
||||
@@ -39,7 +19,7 @@ LL | i.remainder();
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `new_range_remainder`
|
||||
--> $DIR/new_range_stability.rs:43:7
|
||||
--> $DIR/new_range_stability.rs:44:7
|
||||
|
|
||||
LL | i.remainder();
|
||||
| ^^^^^^^^^
|
||||
@@ -48,6 +28,16 @@ LL | i.remainder();
|
||||
= help: add `#![feature(new_range_remainder)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error[E0658]: use of unstable library feature `new_range_remainder`
|
||||
--> $DIR/new_range_stability.rs:60:7
|
||||
|
|
||||
LL | i.remainder();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #154458 <https://github.com/rust-lang/rust/issues/154458> for more information
|
||||
= help: add `#![feature(new_range_remainder)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Check that specialization must be ungated to use the `default` keyword
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
default impl<T> Foo for T { //~ ERROR specialization is unstable
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -1,15 +0,0 @@
|
||||
error[E0658]: specialization is unstable
|
||||
--> $DIR/specialization-feature-gate-default.rs:7:1
|
||||
|
|
||||
LL | / default impl<T> Foo for T {
|
||||
LL | | fn foo(&self) {}
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
|
||||
= help: add `#![feature(specialization)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(rustc_attrs, unboxed_closures)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
#[rustc_paren_sugar]
|
||||
trait Tr {
|
||||
fn method();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
<u8 as Tr>::method();
|
||||
//~^ ERROR the trait bound `u8: Tr` is not satisfied
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
error[E0277]: the trait bound `u8: Tr` is not satisfied
|
||||
--> $DIR/paren-sugar-non-fn-trait-issue-153855.rs:10:6
|
||||
|
|
||||
LL | <u8 as Tr>::method();
|
||||
| ^^ the trait `Tr` is not implemented for `u8`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/paren-sugar-non-fn-trait-issue-153855.rs:5:1
|
||||
|
|
||||
LL | trait Tr {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
@@ -0,0 +1,16 @@
|
||||
#![feature(rustc_attrs, unboxed_closures)]
|
||||
#![allow(internal_features)]
|
||||
|
||||
// Regression test for #153855: diagnostics should not ICE when a
|
||||
// `#[rustc_paren_sugar]` trait is used with parenthesized syntax but does not
|
||||
// have an `Fn`-family generic layout.
|
||||
#[rustc_paren_sugar]
|
||||
trait Tr<'a, 'b, T> {
|
||||
fn method() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
<u8 as Tr(&u8)>::method;
|
||||
//~^ ERROR associated item constraints are not allowed here
|
||||
//~| ERROR the trait bound `u8: Tr<'_, '_, (&u8,)>` is not satisfied
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
error[E0229]: associated item constraints are not allowed here
|
||||
--> $DIR/paren-sugar-non-fn-trait-ufcs-issue-153855.rs:13:12
|
||||
|
|
||||
LL | <u8 as Tr(&u8)>::method;
|
||||
| ^^^^^^^ associated item constraint not allowed here
|
||||
|
||||
error[E0277]: the trait bound `u8: Tr<'_, '_, (&u8,)>` is not satisfied
|
||||
--> $DIR/paren-sugar-non-fn-trait-ufcs-issue-153855.rs:13:6
|
||||
|
|
||||
LL | <u8 as Tr(&u8)>::method;
|
||||
| ^^ the trait `Tr<'_, '_, (&u8,)>` is not implemented for `u8`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/paren-sugar-non-fn-trait-ufcs-issue-153855.rs:8:1
|
||||
|
|
||||
LL | trait Tr<'a, 'b, T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0229, E0277.
|
||||
For more information about an error, try `rustc --explain E0229`.
|
||||
@@ -0,0 +1,17 @@
|
||||
//@ check-pass
|
||||
//@ run-rustfix
|
||||
//@ compile-flags: --force-warn deprecated_where_clause_location
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
trait Trait {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl Trait for i32 {
|
||||
type Assoc = () where i32: Copy;
|
||||
//~^ WARNING where clause not allowed here
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,17 @@
|
||||
//@ check-pass
|
||||
//@ run-rustfix
|
||||
//@ compile-flags: --force-warn deprecated_where_clause_location
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
trait Trait {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl Trait for i32 {
|
||||
type Assoc where i32: Copy = () where;
|
||||
//~^ WARNING where clause not allowed here
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,16 @@
|
||||
warning: where clause not allowed here
|
||||
--> $DIR/alias-type-where-suggest-issue-153567.rs:13:16
|
||||
|
|
||||
LL | type Assoc where i32: Copy = () where;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
|
||||
= note: requested on the command line with `--force-warn deprecated-where-clause-location`
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc where i32: Copy = () where;
|
||||
LL + type Assoc = () where i32: Copy;
|
||||
|
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
@@ -14,12 +14,12 @@ trait Trait {
|
||||
|
||||
impl Trait for u32 {
|
||||
// Not fine, suggests moving.
|
||||
type Assoc = () where u32: Copy;
|
||||
type Assoc = () where u32: Copy;
|
||||
//~^ WARNING where clause not allowed here
|
||||
// Not fine, suggests moving `u32: Copy`
|
||||
type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
//~^ WARNING where clause not allowed here
|
||||
type Assoc3 = () where;
|
||||
type Assoc3 = () where;
|
||||
//~^ WARNING where clause not allowed here
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl Trait for i32 {
|
||||
// Fine.
|
||||
type Assoc = () where u32: Copy;
|
||||
// Not fine, suggests moving both.
|
||||
type Assoc2 = () where u32: Copy, i32: Copy;
|
||||
type Assoc2 = () where u32: Copy, i32: Copy;
|
||||
//~^ WARNING where clause not allowed here
|
||||
type Assoc3 = () where;
|
||||
//~^ WARNING where clause not allowed here
|
||||
|
||||
@@ -9,7 +9,7 @@ LL | type Assoc where u32: Copy = ();
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc where u32: Copy = ();
|
||||
LL + type Assoc = () where u32: Copy;
|
||||
LL + type Assoc = () where u32: Copy;
|
||||
|
|
||||
|
||||
warning: where clause not allowed here
|
||||
@@ -22,7 +22,7 @@ LL | type Assoc2 where u32: Copy = () where i32: Copy;
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc2 where u32: Copy = () where i32: Copy;
|
||||
LL + type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
LL + type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
|
|
||||
|
||||
warning: where clause not allowed here
|
||||
@@ -35,7 +35,7 @@ LL | type Assoc3 where = ();
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc3 where = ();
|
||||
LL + type Assoc3 = () where;
|
||||
LL + type Assoc3 = () where;
|
||||
|
|
||||
|
||||
warning: where clause not allowed here
|
||||
@@ -48,7 +48,7 @@ LL | type Assoc2 where u32: Copy, i32: Copy = ();
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc2 where u32: Copy, i32: Copy = ();
|
||||
LL + type Assoc2 = () where u32: Copy, i32: Copy;
|
||||
LL + type Assoc2 = () where u32: Copy, i32: Copy;
|
||||
|
|
||||
|
||||
warning: where clause not allowed here
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
trait Trait {
|
||||
// Not fine, suggests moving.
|
||||
type Assoc = () where u32: Copy;
|
||||
type Assoc = () where u32: Copy;
|
||||
//~^ WARNING where clause not allowed here
|
||||
// Not fine, suggests moving `u32: Copy`
|
||||
type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
//~^ WARNING where clause not allowed here
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ LL | type Assoc where u32: Copy = ();
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc where u32: Copy = ();
|
||||
LL + type Assoc = () where u32: Copy;
|
||||
LL + type Assoc = () where u32: Copy;
|
||||
|
|
||||
|
||||
warning: where clause not allowed here
|
||||
@@ -22,7 +22,7 @@ LL | type Assoc2 where u32: Copy = () where i32: Copy;
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - type Assoc2 where u32: Copy = () where i32: Copy;
|
||||
LL + type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
LL + type Assoc2 = () where i32: Copy, u32: Copy;
|
||||
|
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
Reference in New Issue
Block a user