Auto merge of #123991 - fmease:rollup-96xcgnm, r=fmease

Rollup of 7 pull requests

Successful merges:

 - #123016 (Remove `TypeVariableOriginKind` and `ConstVariableOriginKind`)
 - #123462 (Cleanup: Rename `ModSep` to `PathSep`)
 - #123603 (Don't even parse an intrinsic unless the feature gate is enabled)
 - #123926 (Fix pretty HIR for anon consts in diagnostics)
 - #123973 (crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues.)
 - #123984 (sanitizers: Add rustc_sanitizers to triagebot.toml)
 - #123989 (Just use `type_dependent_def_id` to figure out what the method is for an expr)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-04-16 00:03:54 +00:00
commit 63f70b3d10
83 changed files with 401 additions and 628 deletions

View file

@ -4278,6 +4278,7 @@ dependencies = [
"rustc_fluent_macro",
"rustc_graphviz",
"rustc_hir",
"rustc_hir_pretty",
"rustc_index",
"rustc_macros",
"rustc_query_system",

View file

@ -308,11 +308,11 @@ fn from_tokens<'a, I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItem>
// FIXME: Share code with `parse_path`.
let path = match tokens.next().map(|tt| TokenTree::uninterpolate(tt)).as_deref() {
Some(&TokenTree::Token(
Token { kind: ref kind @ (token::Ident(..) | token::ModSep), span },
Token { kind: ref kind @ (token::Ident(..) | token::PathSep), span },
_,
)) => 'arm: {
let mut segments = if let &token::Ident(name, _) = kind {
if let Some(TokenTree::Token(Token { kind: token::ModSep, .. }, _)) =
if let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) =
tokens.peek()
{
tokens.next();
@ -331,7 +331,7 @@ fn from_tokens<'a, I>(tokens: &mut iter::Peekable<I>) -> Option<MetaItem>
} else {
return None;
}
if let Some(TokenTree::Token(Token { kind: token::ModSep, .. }, _)) =
if let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) =
tokens.peek()
{
tokens.next();

View file

@ -290,7 +290,7 @@ pub enum TokenKind {
/// `:`
Colon,
/// `::`
ModSep,
PathSep,
/// `->`
RArrow,
/// `<-`
@ -393,7 +393,7 @@ pub fn break_two_token_op(&self) -> Option<(TokenKind, TokenKind)> {
BinOpEq(Shr) => (Gt, Ge),
DotDot => (Dot, Dot),
DotDotDot => (Dot, DotDot),
ModSep => (Colon, Colon),
PathSep => (Colon, Colon),
RArrow => (BinOp(Minus), Gt),
LArrow => (Lt, BinOp(Minus)),
FatArrow => (Eq, Gt),
@ -454,7 +454,9 @@ pub fn is_punct(&self) -> bool {
match self.kind {
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
| BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon
| ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true,
| PathSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => {
true
}
OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..)
| Lifetime(..) | Interpolated(..) | Eof => false,
@ -481,7 +483,7 @@ pub fn can_begin_expr(&self) -> bool {
// DotDotDot is no longer supported, but we need some way to display the error
DotDot | DotDotDot | DotDotEq | // range notation
Lt | BinOp(Shl) | // associated path
ModSep | // global path
PathSep | // global path
Lifetime(..) | // labeled loop
Pound => true, // expression attributes
Interpolated(ref nt) => matches!(&nt.0, NtLiteral(..) |
@ -507,7 +509,7 @@ pub fn can_begin_pattern(&self) -> bool {
// DotDotDot is no longer supported
| DotDot | DotDotDot | DotDotEq // ranges
| Lt | BinOp(Shl) // associated path
| ModSep => true, // global path
| PathSep => true, // global path
Interpolated(ref nt) => matches!(&nt.0, NtLiteral(..) |
NtPat(..) |
NtBlock(..) |
@ -530,7 +532,7 @@ pub fn can_begin_type(&self) -> bool {
Question | // maybe bound in trait object
Lifetime(..) | // lifetime bound in trait object
Lt | BinOp(Shl) | // associated path
ModSep => true, // global path
PathSep => true, // global path
Interpolated(ref nt) => matches!(&nt.0, NtTy(..) | NtPath(..)),
// For anonymous structs or unions, which only appear in specific positions
// (type of struct fields or union fields), we don't consider them as regular types
@ -708,7 +710,7 @@ pub fn is_qpath_start(&self) -> bool {
}
pub fn is_path_start(&self) -> bool {
self == &ModSep
self == &PathSep
|| self.is_qpath_start()
|| self.is_whole_path()
|| self.is_path_segment_keyword()
@ -821,7 +823,7 @@ pub fn glue(&self, joint: &Token) -> Option<Token> {
_ => return None,
},
Colon => match joint.kind {
Colon => ModSep,
Colon => PathSep,
_ => return None,
},
SingleQuote => match joint.kind {
@ -830,7 +832,7 @@ pub fn glue(&self, joint: &Token) -> Option<Token> {
},
Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot
| DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar
| DotDotEq | Comma | Semi | PathSep | RArrow | LArrow | FatArrow | Pound | Dollar
| Question | OpenDelim(..) | CloseDelim(..) | Literal(..) | Ident(..)
| Lifetime(..) | Interpolated(..) | DocComment(..) | Eof => return None,
};

View file

@ -893,7 +893,7 @@ fn token_kind_to_string_ext(
token::Comma => ",".into(),
token::Semi => ";".into(),
token::Colon => ":".into(),
token::ModSep => "::".into(),
token::PathSep => "::".into(),
token::RArrow => "->".into(),
token::LArrow => "<-".into(),
token::FatArrow => "=>".into(),

View file

@ -1752,32 +1752,31 @@ fn suggest_copy_for_type_in_cloned_ref(&self, err: &mut Diag<'tcx>, place: Place
let tcx = self.infcx.tcx;
let hir = tcx.hir();
let Some(body_id) = tcx.hir_node(self.mir_hir_id()).body_id() else { return };
struct FindUselessClone<'hir> {
tcx: TyCtxt<'hir>,
def_id: DefId,
pub clones: Vec<&'hir hir::Expr<'hir>>,
struct FindUselessClone<'tcx> {
tcx: TyCtxt<'tcx>,
typeck_results: &'tcx ty::TypeckResults<'tcx>,
pub clones: Vec<&'tcx hir::Expr<'tcx>>,
}
impl<'hir> FindUselessClone<'hir> {
pub fn new(tcx: TyCtxt<'hir>, def_id: DefId) -> Self {
Self { tcx, def_id, clones: vec![] }
impl<'tcx> FindUselessClone<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
Self { tcx, typeck_results: tcx.typeck(def_id), clones: vec![] }
}
}
impl<'v> Visitor<'v> for FindUselessClone<'v> {
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
if let hir::ExprKind::MethodCall(segment, _rcvr, args, _span) = ex.kind
&& segment.ident.name == sym::clone
&& args.len() == 0
&& let Some(def_id) = self.def_id.as_local()
&& let Some(method) = self.tcx.lookup_method_for_diagnostic((def_id, ex.hir_id))
&& Some(self.tcx.parent(method)) == self.tcx.lang_items().clone_trait()
impl<'tcx> Visitor<'tcx> for FindUselessClone<'tcx> {
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
if let hir::ExprKind::MethodCall(..) = ex.kind
&& let Some(method_def_id) =
self.typeck_results.type_dependent_def_id(ex.hir_id)
&& self.tcx.lang_items().clone_trait() == Some(self.tcx.parent(method_def_id))
{
self.clones.push(ex);
}
hir::intravisit::walk_expr(self, ex);
}
}
let mut expr_finder = FindUselessClone::new(tcx, self.mir_def_id().into());
let mut expr_finder = FindUselessClone::new(tcx, self.mir_def_id());
let body = hir.body(body_id).value;
expr_finder.visit_expr(body);

View file

@ -26,7 +26,7 @@
use rustc_middle::ty::{Region, TyCtxt};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use rustc_trait_selection::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_trait_selection::infer::type_variable::TypeVariableOrigin;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
@ -1104,10 +1104,9 @@ fn suggest_deref_closure_value(&self, diag: &mut Diag<'_>) {
);
let closure_kind = args.as_closure().kind();
let closure_kind_ty = Ty::from_closure_kind(tcx, closure_kind);
let tupled_upvars_ty = self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: closure_expr.span,
});
let tupled_upvars_ty = self
.infcx
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: closure_expr.span });
let closure_args = ty::ClosureArgs::new(
tcx,
ty::ClosureArgsParts {
@ -1131,17 +1130,12 @@ fn suggest_deref_closure_value(&self, diag: &mut Diag<'_>) {
};
// The found `Self` type of the method call.
let Some(possible_rcvr_ty) = tables.node_type_opt(rcvr.hir_id) else { return };
// The `MethodCall` expression is `Res::Err`, so we search for the method on the `rcvr_ty`.
let Some(method) = tcx.lookup_method_for_diagnostic((self.mir_def_id(), expr.hir_id))
else {
return;
};
let Some(method_def_id) = tables.type_dependent_def_id(expr.hir_id) else { return };
// Get the type for the parameter corresponding to the argument the closure with the
// lifetime error we had.
let Some(input) = tcx
.fn_sig(method)
.fn_sig(method_def_id)
.instantiate_identity()
.inputs()
.skip_binder()
@ -1156,7 +1150,7 @@ fn suggest_deref_closure_value(&self, diag: &mut Diag<'_>) {
let ty::Param(closure_param) = input.kind() else { return };
// Get the arguments for the found method, only specifying that `Self` is the receiver type.
let args = GenericArgs::for_item(tcx, method, |param, _| {
let args = GenericArgs::for_item(tcx, method_def_id, |param, _| {
if param.index == 0 {
possible_rcvr_ty.into()
} else if param.index == closure_param.index {
@ -1166,7 +1160,7 @@ fn suggest_deref_closure_value(&self, diag: &mut Diag<'_>) {
}
});
let preds = tcx.predicates_of(method).instantiate(tcx, args);
let preds = tcx.predicates_of(method_def_id).instantiate(tcx, args);
let ocx = ObligationCtxt::new(&self.infcx);
ocx.register_obligations(preds.iter().map(|(pred, span)| {

View file

@ -11,7 +11,7 @@
use itertools::Itertools;
use rustc_hir as hir;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{BoundRegionConversionTime, RegionVariableOrigin};
use rustc_middle::mir::*;
use rustc_middle::ty::{self, Ty};
@ -75,10 +75,7 @@ pub(super) fn check_signature_annotation(&mut self, body: &Body<'tcx>) {
);
let next_ty_var = || {
self.infcx.next_ty_var(TypeVariableOrigin {
span: body.span,
kind: TypeVariableOriginKind::MiscVariable,
})
self.infcx.next_ty_var(TypeVariableOrigin { span: body.span, param_def_id: None })
};
let output_ty = Ty::new_coroutine(
self.tcx(),

View file

@ -16,7 +16,7 @@
use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::region_constraints::RegionConstraintData;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
};
@ -2425,7 +2425,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
ty::RawPtr(_, _) | ty::FnPtr(_) => {
let ty_right = right.ty(body, tcx);
let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
param_def_id: None,
span: body.source_info(location).span,
});
self.sub_types(

View file

@ -1,6 +1,6 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_infer::infer::{ObligationEmittingRelation, StructurallyRelateAliases};
use rustc_infer::traits::{Obligation, PredicateObligations};
@ -129,10 +129,7 @@ fn relate_opaques(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>
// the opaque.
let mut enable_subtyping = |ty, opaque_is_expected| {
let ty_vid = infcx.next_ty_var_id_in_universe(
TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: self.span(),
},
TypeVariableOrigin { param_def_id: None, span: self.span() },
ty::UniverseIndex::ROOT,
);

View file

@ -24,20 +24,6 @@
impl pprust_ast::PpAnn for AstNoAnn {}
struct HirNoAnn<'tcx> {
tcx: TyCtxt<'tcx>,
}
impl<'tcx> pprust_hir::PpAnn for HirNoAnn<'tcx> {
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
pprust_hir::PpAnn::nested(
&(&self.tcx.hir() as &dyn hir::intravisit::Map<'_>),
state,
nested,
)
}
}
struct AstIdentifiedAnn;
impl pprust_ast::PpAnn for AstIdentifiedAnn {
@ -300,10 +286,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
)
};
match s {
PpHirMode::Normal => {
let annotation = HirNoAnn { tcx };
f(&annotation)
}
PpHirMode::Normal => f(&tcx),
PpHirMode::Identified => {
let annotation = HirIdentifiedAnn { tcx };
f(&annotation)

View file

@ -208,7 +208,7 @@ fn from_internal((stream, rustc): (TokenStream, &mut Rustc<'_, '_>)) -> Self {
Comma => op(","),
Semi => op(";"),
Colon => op(":"),
ModSep => op("::"),
PathSep => op("::"),
RArrow => op("->"),
LArrow => op("<-"),
FatArrow => op("=>"),

View file

@ -9,7 +9,7 @@
use rustc_hir::intravisit;
use rustc_hir::{GenericParamKind, ImplItemKind};
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::{util, FulfillmentError};
use rustc_middle::ty::error::{ExpectedFound, TypeError};
@ -800,10 +800,10 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
bug!("FIXME(RPITIT): error here");
}
// Replace with infer var
let infer_ty = self.ocx.infcx.next_ty_var(TypeVariableOrigin {
span: self.span,
kind: TypeVariableOriginKind::MiscVariable,
});
let infer_ty = self
.ocx
.infcx
.next_ty_var(TypeVariableOrigin { span: self.span, param_def_id: None });
self.types.insert(proj.def_id, (infer_ty, proj.args));
// Recurse into bounds
for (pred, pred_span) in self

View file

@ -12,7 +12,7 @@ pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
let hir_id = expr.hir_id;
if let hir::ExprKind::AddrOf(borrow_kind, m, expr) = expr.kind
&& matches!(borrow_kind, hir::BorrowKind::Ref)
&& let Some(var) = is_path_static_mut(*expr)
&& let Some(var) = path_if_static_mut(tcx, expr)
{
handle_static_mut_ref(tcx, span, var, span.edition().at_least_rust_2024(), m, hir_id);
}
@ -24,7 +24,7 @@ pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
&& let hir::PatKind::Binding(ba, _, _, _) = loc.pat.kind
&& let hir::ByRef::Yes(rmutbl) = ba.0
&& let Some(init) = loc.init
&& let Some(var) = is_path_static_mut(*init)
&& let Some(var) = path_if_static_mut(tcx, init)
{
handle_static_mut_ref(
tcx,
@ -37,13 +37,13 @@ pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
}
}
fn is_path_static_mut(expr: hir::Expr<'_>) -> Option<String> {
fn path_if_static_mut(tcx: TyCtxt<'_>, expr: &hir::Expr<'_>) -> Option<String> {
if let hir::ExprKind::Path(qpath) = expr.kind
&& let hir::QPath::Resolved(_, path) = qpath
&& let hir::def::Res::Def(def_kind, _) = path.res
&& let hir::def::DefKind::Static { mutability: Mutability::Mut, nested: false } = def_kind
{
return Some(qpath_to_string(&qpath));
return Some(qpath_to_string(&tcx, &qpath));
}
None
}

View file

@ -49,10 +49,6 @@ fn pre(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
}
pub struct NoAnn;
impl PpAnn for NoAnn {}
impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> {
fn nested(&self, state: &mut State<'_>, nested: Nested) {
match nested {
@ -190,16 +186,16 @@ fn to_string<F>(ann: &dyn PpAnn, f: F) -> String
printer.s.eof()
}
pub fn ty_to_string(ty: &hir::Ty<'_>) -> String {
to_string(&NoAnn, |s| s.print_type(ty))
pub fn ty_to_string(ann: &dyn PpAnn, ty: &hir::Ty<'_>) -> String {
to_string(ann, |s| s.print_type(ty))
}
pub fn qpath_to_string(segment: &hir::QPath<'_>) -> String {
to_string(&NoAnn, |s| s.print_qpath(segment, false))
pub fn qpath_to_string(ann: &dyn PpAnn, segment: &hir::QPath<'_>) -> String {
to_string(ann, |s| s.print_qpath(segment, false))
}
pub fn pat_to_string(pat: &hir::Pat<'_>) -> String {
to_string(&NoAnn, |s| s.print_pat(pat))
pub fn pat_to_string(ann: &dyn PpAnn, pat: &hir::Pat<'_>) -> String {
to_string(ann, |s| s.print_pat(pat))
}
impl<'a> State<'a> {

View file

@ -5,7 +5,7 @@
use rustc_hir::def_id::LocalDefId;
use rustc_hir::{self as hir, ExprKind, PatKind};
use rustc_hir_pretty::ty_to_string;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
use rustc_trait_selection::traits::{
@ -67,10 +67,7 @@ pub fn check_match(
// arm for inconsistent arms or to the whole match when a `()` type
// is required).
Expectation::ExpectHasType(ety) if ety != Ty::new_unit(self.tcx) => ety,
_ => self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: expr.span,
}),
_ => self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span }),
};
CoerceMany::with_coercion_sites(coerce_first, arms)
};
@ -395,7 +392,7 @@ pub fn maybe_get_coercion_reason(
return self.get_fn_decl(hir_id).map(|(_, fn_decl, _)| {
let (ty, span) = match fn_decl.output {
hir::FnRetTy::DefaultReturn(span) => ("()".to_string(), span),
hir::FnRetTy::Return(ty) => (ty_to_string(ty), ty.span),
hir::FnRetTy::Return(ty) => (ty_to_string(&self.tcx, ty), ty.span),
};
(span, format!("expected `{ty}` because of this return type"))
});
@ -578,10 +575,8 @@ pub(super) fn demand_scrutinee_type(
// ...but otherwise we want to use any supertype of the
// scrutinee. This is sort of a workaround, see note (*) in
// `check_pat` for some details.
let scrut_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: scrut.span,
});
let scrut_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: scrut.span });
self.check_expr_has_type_or_error(scrut, scrut_ty, |_| {});
scrut_ty
}

View file

@ -13,10 +13,7 @@
infer,
traits::{self, Obligation},
};
use rustc_infer::{
infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
traits::ObligationCause,
};
use rustc_infer::{infer::type_variable::TypeVariableOrigin, traits::ObligationCause};
use rustc_middle::ty::adjustment::{
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
};
@ -180,18 +177,14 @@ fn try_overloaded_call_step(
infer::FnCall,
closure_args.coroutine_closure_sig(),
);
let tupled_upvars_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: callee_expr.span,
});
let tupled_upvars_ty = self
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: callee_expr.span });
// We may actually receive a coroutine back whose kind is different
// from the closure that this dispatched from. This is because when
// we have no captures, we automatically implement `FnOnce`. This
// impl forces the closure kind to `FnOnce` i.e. `u8`.
let kind_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: callee_expr.span,
});
let kind_ty = self
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: callee_expr.span });
let call_sig = self.tcx.mk_fn_sig(
[coroutine_closure_sig.tupled_inputs_ty],
coroutine_closure_sig.to_coroutine(
@ -305,10 +298,7 @@ fn try_overloaded_call_traits(
Ty::new_tup_from_iter(
self.tcx,
arg_exprs.iter().map(|e| {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: e.span,
})
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: e.span })
}),
)
});
@ -724,7 +714,8 @@ fn report_invalid_callee(
def::CtorOf::Variant => "enum variant",
};
let removal_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
unit_variant = Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(qpath)));
unit_variant =
Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(&self.tcx, qpath)));
}
let callee_ty = self.resolve_vars_if_possible(callee_ty);

View file

@ -8,7 +8,7 @@
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
use rustc_hir_analysis::check::{check_function_signature, forbid_intrinsic_abi};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::RegionVariableOrigin;
use rustc_middle::ty::{self, Binder, Ty, TyCtxt};
use rustc_span::def_id::LocalDefId;
@ -123,8 +123,7 @@ pub(super) fn check_fn<'a, 'tcx>(
// We have special-cased the case where the function is declared
// `-> dyn Foo` and we don't actually relate it to the
// `fcx.ret_coercion`, so just instantiate a type variable.
actual_return_ty =
fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::DynReturnFn, span });
actual_return_ty = fcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
debug!("actual_return_ty replaced with {:?}", actual_return_ty);
}

View file

@ -6,7 +6,7 @@
use rustc_hir as hir;
use rustc_hir::lang_items::LangItem;
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
use rustc_infer::infer::{InferOk, InferResult};
use rustc_macros::{TypeFoldable, TypeVisitable};
@ -72,10 +72,8 @@ pub fn check_expr_closure(
let parent_args =
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id(expr_def_id.to_def_id()));
let tupled_upvars_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
});
let tupled_upvars_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
// FIXME: We could probably actually just unify this further --
// instead of having a `FnSig` and a `Option<CoroutineTypes>`,
@ -102,11 +100,9 @@ pub fn check_expr_closure(
// Create a type variable (for now) to represent the closure kind.
// It will be unified during the upvar inference phase (`upvar.rs`)
None => self.next_ty_var(TypeVariableOrigin {
// FIXME(eddyb) distinguish closure kind inference variables from the rest.
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
}),
None => {
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
}
};
let closure_args = ty::ClosureArgs::new(
@ -126,7 +122,7 @@ pub fn check_expr_closure(
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)
| hir::CoroutineKind::Coroutine(_) => {
let yield_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
param_def_id: None,
span: expr_span,
});
self.require_type_is_sized(yield_ty, expr_span, traits::SizedYieldType);
@ -138,7 +134,7 @@ pub fn check_expr_closure(
// not a problem.
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _) => {
let yield_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
param_def_id: None,
span: expr_span,
});
self.require_type_is_sized(yield_ty, expr_span, traits::SizedYieldType);
@ -166,10 +162,8 @@ pub fn check_expr_closure(
// Resume type defaults to `()` if the coroutine has no argument.
let resume_ty = liberated_sig.inputs().get(0).copied().unwrap_or(tcx.types.unit);
let interior = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
});
let interior =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
self.deferred_coroutine_interiors.borrow_mut().push((
expr_def_id,
body.id(),
@ -181,11 +175,9 @@ pub fn check_expr_closure(
// later during upvar analysis. Regular coroutines always have the kind
// ty of `().`
let kind_ty = match kind {
hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure) => self
.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
}),
hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure) => {
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
}
_ => tcx.types.unit,
};
@ -219,30 +211,23 @@ pub fn check_expr_closure(
}
};
// Compute all of the variables that will be used to populate the coroutine.
let resume_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
});
let interior = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
});
let resume_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
let interior =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
let closure_kind_ty = match expected_kind {
Some(kind) => Ty::from_closure_kind(tcx, kind),
// Create a type variable (for now) to represent the closure kind.
// It will be unified during the upvar inference phase (`upvar.rs`)
None => self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
}),
None => {
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
}
};
let coroutine_captures_by_ref_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
});
let coroutine_captures_by_ref_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
let closure_args = ty::CoroutineClosureArgs::new(
tcx,
ty::CoroutineClosureArgsParts {
@ -274,16 +259,13 @@ pub fn check_expr_closure(
// Create a type variable (for now) to represent the closure kind.
// It will be unified during the upvar inference phase (`upvar.rs`)
None => self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
}),
None => {
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span })
}
};
let coroutine_upvars_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::ClosureSynthetic,
span: expr_span,
});
let coroutine_upvars_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr_span });
// We need to turn the liberated signature that we got from HIR, which
// looks something like `|Args...| -> T`, into a signature that is suitable

View file

@ -43,7 +43,7 @@
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::Expr;
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult};
use rustc_infer::traits::TraitEngineExt as _;
use rustc_infer::traits::{IfExpressionCause, MatchExpressionArmCause, TraitEngine};
@ -280,10 +280,7 @@ fn coerce_from_inference_variable(
if b.is_ty_var() {
// Two unresolved type variables: create a `Coerce` predicate.
let target_ty = if self.use_lub {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::LatticeVariable,
span: self.cause.span,
})
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.cause.span })
} else {
b
};
@ -582,10 +579,7 @@ fn coerce_unsized(&self, mut source: Ty<'tcx>, mut target: Ty<'tcx>) -> CoerceRe
// the `CoerceUnsized` target type and the expected type.
// We only have the latter, so we use an inference variable
// for the former and let type inference do the rest.
let origin = TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: self.cause.span,
};
let origin = TypeVariableOrigin { param_def_id: None, span: self.cause.span };
let coerce_target = self.next_ty_var(origin);
let mut coercion = self.unify_and(coerce_target, target, |target| {
let unsize = Adjustment { kind: Adjust::Pointer(PointerCoercion::Unsize), target };

View file

@ -337,10 +337,8 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
ty_op: |ty| {
if let ty::Infer(infer) = ty.kind() {
match infer {
ty::TyVar(_) => self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
}),
ty::TyVar(_) => self
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP }),
ty::IntVar(_) => self.next_int_var(),
ty::FloatVar(_) => self.next_float_var(),
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
@ -356,10 +354,7 @@ fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
if let ty::ConstKind::Infer(_) = ct.kind() {
self.next_const_var(
ct.ty(),
ConstVariableOrigin {
kind: ConstVariableOriginKind::MiscVariable,
span: DUMMY_SP,
},
ConstVariableOrigin { param_def_id: None, span: DUMMY_SP },
)
} else {
ct

View file

@ -1,4 +1,4 @@
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
@ -110,8 +110,7 @@ pub(super) fn only_has_type(self, fcx: &FnCtxt<'a, 'tcx>) -> Option<Ty<'tcx>> {
/// Like `only_has_type`, but instead of returning `None` if no
/// hard constraint exists, creates a fresh type variable.
pub(super) fn coercion_target_type(self, fcx: &FnCtxt<'a, 'tcx>, span: Span) -> Ty<'tcx> {
self.only_has_type(fcx).unwrap_or_else(|| {
fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span })
})
self.only_has_type(fcx)
.unwrap_or_else(|| fcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span }))
}
}

View file

@ -37,7 +37,7 @@
use rustc_hir::{ExprKind, HirId, QPath};
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _;
use rustc_infer::infer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::DefineOpaqueTypes;
use rustc_infer::infer::InferOk;
use rustc_infer::traits::query::NoSolution;
@ -54,7 +54,6 @@
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
use rustc_target::spec::abi::Abi::RustIntrinsic;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt as _;
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
@ -81,10 +80,8 @@ pub fn check_expr_has_type_or_error(
return Ty::new_error(self.tcx(), reported);
}
let adj_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::AdjustmentType,
span: expr.span,
});
let adj_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span });
self.apply_adjustments(
expr,
vec![Adjustment { kind: Adjust::NeverToAny, target: adj_ty }],
@ -541,16 +538,12 @@ pub(crate) fn check_expr_path(
if let ty::FnDef(did, _) = *ty.kind() {
let fn_sig = ty.fn_sig(tcx);
if tcx.fn_sig(did).skip_binder().abi() == RustIntrinsic
&& tcx.item_name(did) == sym::transmute
{
if tcx.is_intrinsic(did, sym::transmute) {
let Some(from) = fn_sig.inputs().skip_binder().get(0) else {
let e = self.dcx().span_delayed_bug(
span_bug!(
tcx.def_span(did),
"intrinsic fn `transmute` defined with no parameters",
"intrinsic fn `transmute` defined with no parameters"
);
self.set_tainted_by_errors(e);
return Ty::new_error(tcx, e);
};
let to = fn_sig.output().skip_binder();
// We defer the transmute to the end of typeck, once all inference vars have
@ -1420,10 +1413,7 @@ fn check_expr_array(
_ => None,
})
.unwrap_or_else(|| {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: expr.span,
})
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span })
});
let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
assert_eq!(self.diverges.get(), Diverges::Maybe);
@ -1434,10 +1424,7 @@ fn check_expr_array(
}
coerce.complete(self)
} else {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: expr.span,
})
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span })
};
let array_len = args.len() as u64;
self.suggest_array_len(expr, array_len);
@ -1520,10 +1507,8 @@ fn check_expr_repeat(
(uty, uty)
}
None => {
let ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: element.span,
});
let ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: element.span });
let element_ty = self.check_expr_has_type_or_error(element, ty, |_| {});
(element_ty, ty)
}

View file

@ -2,7 +2,7 @@
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_infer::{infer::type_variable::TypeVariableOriginKind, traits::ObligationCauseCode};
use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
use rustc_span::{symbol::kw, Span};
use rustc_trait_selection::traits;
@ -340,7 +340,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for FindAmbiguousParameter<'_, 'tcx> {
type Result = ControlFlow<ty::GenericArg<'tcx>>;
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
if let Some(origin) = self.0.type_var_origin(ty)
&& let TypeVariableOriginKind::TypeParameterDefinition(_, def_id) = origin.kind
&& let Some(def_id) = origin.param_def_id
&& let generics = self.0.tcx.generics_of(self.1)
&& let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id)
&& let Some(arg) =

View file

@ -31,7 +31,7 @@
use rustc_hir_analysis::structured_errors::StructuredDiag;
use rustc_index::IndexVec;
use rustc_infer::infer::error_reporting::{FailureCode, ObligationCauseExt};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::TypeTrace;
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
use rustc_middle::traits::ObligationCauseCode::ExprBindingObligation;
@ -2184,7 +2184,7 @@ fn label_fn_like(
[
callee_ty,
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
param_def_id: None,
span: rustc_span::DUMMY_SP,
}),
],

View file

@ -16,8 +16,8 @@
use rustc_infer::infer;
use rustc_infer::infer::error_reporting::sub_relations::SubRelations;
use rustc_infer::infer::error_reporting::TypeErrCtxt;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::infer::unify_key::ConstVariableOrigin;
use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitableExt};
use rustc_session::Session;
use rustc_span::symbol::Ident;
@ -236,10 +236,7 @@ fn re_infer(&self, def: Option<&ty::GenericParamDef>, span: Span) -> Option<ty::
fn ty_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
match param {
Some(param) => self.var_for_def(span, param).as_type().unwrap(),
None => self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span,
}),
None => self.next_ty_var(TypeVariableOrigin { param_def_id: None, span }),
}
}
@ -258,10 +255,7 @@ fn ct_infer(
},
) => self.var_for_effect(param).as_const().unwrap(),
Some(param) => self.var_for_def(span, param).as_const().unwrap(),
None => self.next_const_var(
ty,
ConstVariableOrigin { kind: ConstVariableOriginKind::ConstInference, span },
),
None => self.next_const_var(ty, ConstVariableOrigin { span, param_def_id: None }),
}
}

View file

@ -2,7 +2,7 @@
use rustc_hir as hir;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::PatKind;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::ty::Ty;
use rustc_middle::ty::UserType;
use rustc_span::def_id::LocalDefId;
@ -72,10 +72,7 @@ fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<Ty<'tcx>>) -> T
match ty_opt {
None => {
// Infer the variable's type.
let var_ty = self.fcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span,
});
let var_ty = self.fcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
self.fcx.locals.borrow_mut().insert(nid, var_ty);
var_ty
}

View file

@ -56,11 +56,11 @@
use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{Map, Visitor};
use rustc_hir::intravisit::Visitor;
use rustc_hir::{HirIdMap, Node};
use rustc_hir_analysis::check::check_abi;
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::traits::{ObligationCauseCode, ObligationInspector, WellFormedLoc};
use rustc_middle::query::Providers;
use rustc_middle::traits;
@ -261,10 +261,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
tcx.impl_trait_ref(item.container_id(tcx)).unwrap().instantiate_identity().args;
Some(tcx.type_of(trait_item).instantiate(tcx, args))
} else {
Some(fcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span,
}))
Some(fcx.next_ty_var(TypeVariableOrigin { span, param_def_id: None }))
}
} else if let Node::AnonConst(_) = node {
let id = tcx.local_def_id_to_hir_id(def_id);
@ -272,10 +269,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
Node::Ty(&hir::Ty { kind: hir::TyKind::Typeof(ref anon_const), span, .. })
if anon_const.hir_id == id =>
{
Some(fcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span,
}))
Some(fcx.next_ty_var(TypeVariableOrigin { span, param_def_id: None }))
}
Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), span, .. })
| Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), span, .. }) => {
@ -285,10 +279,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
Some(fcx.next_int_var())
}
hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == id => {
Some(fcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span,
}))
Some(fcx.next_ty_var(TypeVariableOrigin { span, param_def_id: None }))
}
_ => None,
})
@ -374,7 +365,7 @@ fn report_unexpected_variant_res(
Res::Def(DefKind::Variant, _) => "struct variant",
_ => res.descr(),
};
let path_str = rustc_hir_pretty::qpath_to_string(qpath);
let path_str = rustc_hir_pretty::qpath_to_string(&tcx, qpath);
let err = tcx
.dcx()
.struct_span_err(span, format!("expected {expected}, found {res_descr} `{path_str}`"))
@ -436,28 +427,6 @@ fn fatally_break_rust(tcx: TyCtxt<'_>, span: Span) -> ! {
diag.emit()
}
pub fn lookup_method_for_diagnostic<'tcx>(
tcx: TyCtxt<'tcx>,
(def_id, hir_id): (LocalDefId, hir::HirId),
) -> Option<DefId> {
let root_ctxt = TypeckRootCtxt::new(tcx, def_id);
let param_env = tcx.param_env(def_id);
let fn_ctxt = FnCtxt::new(&root_ctxt, param_env, def_id);
let hir::Node::Expr(expr) = tcx.hir().hir_node(hir_id) else {
return None;
};
let hir::ExprKind::MethodCall(segment, rcvr, _, _) = expr.kind else {
return None;
};
let tables = tcx.typeck(def_id);
// The found `Self` type of the method call.
let possible_rcvr_ty = tables.node_type_opt(rcvr.hir_id)?;
fn_ctxt
.lookup_method_for_diagnostic(possible_rcvr_ty, segment, expr.span, expr, rcvr)
.ok()
.map(|method| method.def_id)
}
pub fn provide(providers: &mut Providers) {
method::provide(providers);
*providers = Providers {
@ -465,7 +434,6 @@ pub fn provide(providers: &mut Providers) {
diagnostic_only_typeck,
has_typeck_results,
used_trait_imports,
lookup_method_for_diagnostic: lookup_method_for_diagnostic,
..*providers
};
}

View file

@ -7,7 +7,7 @@
use hir::ItemKind;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::ty::{Adt, Array, Ref, Ty};
use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
use rustc_span::symbol::kw::{Empty, Underscore};
@ -218,10 +218,8 @@ pub(super) fn lint_fully_qualified_call_from_2018(
// If we know it does not, we don't need to warn.
if method_name.name == sym::from_iter {
if let Some(trait_def_id) = self.tcx.get_diagnostic_item(sym::FromIterator) {
let any_type = self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span,
});
let any_type =
self.infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
if !self
.infcx
.type_implements_trait(trait_def_id, [self_ty, any_type], self.param_env)

View file

@ -22,12 +22,8 @@
use rustc_hir::PatKind::Binding;
use rustc_hir::PathSegment;
use rustc_hir::{ExprKind, Node, QPath};
use rustc_infer::infer::{
self,
type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
RegionVariableOrigin,
};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_infer::infer::{self, type_variable::TypeVariableOrigin, RegionVariableOrigin};
use rustc_middle::infer::unify_key::ConstVariableOrigin;
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
use rustc_middle::ty::print::{with_crate_prefix, with_forced_trimmed_paths};
@ -82,13 +78,7 @@ fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool {
let trait_ref = ty::TraitRef::new(
tcx,
fn_once,
[
ty,
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span,
}),
],
[ty, self.next_ty_var(TypeVariableOrigin { param_def_id: None, span })],
);
let poly_trait_ref = ty::Binder::dummy(trait_ref);
let obligation = Obligation::misc(
@ -1271,7 +1261,7 @@ pub fn report_no_match_method_error(
.map(|expr| {
self.node_ty_opt(expr.hir_id).unwrap_or_else(|| {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
param_def_id: None,
span: expr.span,
})
})
@ -1861,7 +1851,7 @@ fn suggest_associated_call_syntax(
GenericArgKind::Type(_) => self
.next_ty_var(TypeVariableOrigin {
span: rustc_span::DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
param_def_id: None,
})
.into(),
GenericArgKind::Const(arg) => self
@ -1869,7 +1859,7 @@ fn suggest_associated_call_syntax(
arg.ty(),
ConstVariableOrigin {
span: rustc_span::DUMMY_SP,
kind: ConstVariableOriginKind::MiscVariable,
param_def_id: None,
},
)
.into(),

View file

@ -7,7 +7,7 @@
use rustc_data_structures::packed::Pu128;
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag};
use rustc_hir as hir;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::ty::adjustment::{
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
@ -219,10 +219,8 @@ fn check_overloaded_binop(
// e.g., adding `&'a T` and `&'b T`, given `&'x T: Add<&'x T>`, will result
// in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`.
let lhs_ty = self.check_expr(lhs_expr);
let fresh_var = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: lhs_expr.span,
});
let fresh_var = self
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: lhs_expr.span });
self.demand_coerce(lhs_expr, lhs_ty, fresh_var, Some(rhs_expr), AllowTwoPhase::No)
}
IsAssign::Yes => {
@ -241,10 +239,8 @@ fn check_overloaded_binop(
// using this variable as the expected type, which sometimes lets
// us do better coercions than we would be able to do otherwise,
// particularly for things like `String + &String`.
let rhs_ty_var = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: rhs_expr.span,
});
let rhs_ty_var =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: rhs_expr.span });
let result = self.lookup_op_method(
(lhs_expr, lhs_ty),

View file

@ -9,7 +9,7 @@
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind};
use rustc_infer::infer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::{self, Adt, Ty, TypeVisitableExt};
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
@ -1365,13 +1365,8 @@ fn check_pat_tuple(
}
let max_len = cmp::max(expected_len, elements.len());
let element_tys_iter = (0..max_len).map(|_| {
self.next_ty_var(
// FIXME: `MiscVariable` for now -- obtaining the span and name information
// from all tuple elements isn't trivial.
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span },
)
});
let element_tys_iter =
(0..max_len).map(|_| self.next_ty_var(TypeVariableOrigin { param_def_id: None, span }));
let element_tys = tcx.mk_type_list_from_iter(element_tys_iter);
let pat_ty = Ty::new_tup(tcx, element_tys);
if let Some(err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, pat_info.top_info) {
@ -1561,7 +1556,7 @@ fn error_tuple_variant_index_shorthand(
{
let has_shorthand_field_name = field_patterns.iter().any(|field| field.is_shorthand);
if has_shorthand_field_name {
let path = rustc_hir_pretty::qpath_to_string(qpath);
let path = rustc_hir_pretty::qpath_to_string(&self.tcx, qpath);
let mut err = struct_span_code_err!(
self.dcx(),
pat.span,
@ -1743,7 +1738,7 @@ fn error_tuple_variant_as_struct_pat(
return None;
}
let path = rustc_hir_pretty::qpath_to_string(qpath);
let path = rustc_hir_pretty::qpath_to_string(&self.tcx, qpath);
let mut err = struct_span_code_err!(
self.dcx(),
pat.span,
@ -1793,7 +1788,7 @@ fn get_suggested_tuple_struct_pattern(
f
}
}
Err(_) => rustc_hir_pretty::pat_to_string(field.pat),
Err(_) => rustc_hir_pretty::pat_to_string(&self.tcx, field.pat),
}
})
.collect::<Vec<String>>()
@ -1997,10 +1992,8 @@ fn check_pat_box(
Ok(()) => {
// Here, `demand::subtype` is good enough, but I don't
// think any errors can be introduced by using `demand::eqtype`.
let inner_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: inner.span,
});
let inner_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: inner.span });
let box_ty = Ty::new_box(tcx, inner_ty);
self.demand_eqtype_pat(span, expected, box_ty, pat_info.top_info);
(box_ty, inner_ty)
@ -2088,7 +2081,7 @@ fn check_pat_ref(
(expected, expected)
} else {
let inner_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
param_def_id: None,
span: inner.span,
});
let ref_ty = self.new_ref_ty(pat.span, mutbl, inner_ty);
@ -2138,8 +2131,7 @@ fn try_resolve_slice_ty_to_array_ty(
let tcx = self.tcx;
let len = before.len();
let ty_var_origin =
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span };
let ty_var_origin = TypeVariableOrigin { param_def_id: None, span };
let inner_ty = self.next_ty_var(ty_var_origin);
Some(Ty::new_array(tcx, inner_ty, len.try_into().unwrap()))

View file

@ -4,7 +4,7 @@
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir_analysis::autoderef::Autoderef;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::InferOk;
use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref, PointerCoercion};
use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
@ -147,10 +147,8 @@ fn try_index_step(
// If some lookup succeeds, write callee into table and extract index/element
// type from the method signature.
// If some lookup succeeded, install method in table
let input_ty = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::AutoDeref,
span: base_expr.span,
});
let input_ty =
self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: base_expr.span });
let method =
self.try_overloaded_place_op(expr.span, self_ty, &[input_ty], PlaceOp::Index);

View file

@ -21,8 +21,8 @@
//!
//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::ConstVariableOrigin;
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin};
use rustc_index::IndexVec;
use rustc_middle::infer::unify_key::EffectVarValue;
use rustc_middle::ty::fold::TypeFoldable;
@ -115,7 +115,7 @@ pub fn instantiate_canonical_var(
CanonicalVarKind::Ty(ty_kind) => {
let ty = match ty_kind {
CanonicalTyVarKind::General(ui) => self.next_ty_var_in_universe(
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span },
TypeVariableOrigin { param_def_id: None, span },
universe_map(ui),
),
@ -148,7 +148,7 @@ pub fn instantiate_canonical_var(
CanonicalVarKind::Const(ui, ty) => self
.next_const_var_in_universe(
ty,
ConstVariableOrigin { kind: ConstVariableOriginKind::MiscVariable, span },
ConstVariableOrigin { param_def_id: None, span },
universe_map(ui),
)
.into(),

View file

@ -3,7 +3,7 @@
SourceKindMultiSuggestion, SourceKindSubdiag,
};
use crate::infer::error_reporting::TypeErrCtxt;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::InferCtxt;
use rustc_errors::{codes::*, Diag, IntoDiagArg};
use rustc_hir as hir;
@ -13,16 +13,14 @@
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, LetStmt, LocalSource};
use rustc_middle::hir::nested_filter;
use rustc_middle::infer::unify_key::{
ConstVariableOrigin, ConstVariableOriginKind, ConstVariableValue,
};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableValue};
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Print, Printer};
use rustc_middle::ty::{
self, GenericArg, GenericArgKind, GenericArgsRef, InferConst, IsSuggestable, Ty, TyCtxt,
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeckResults,
};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{sym, Ident};
use rustc_span::{BytePos, Span, DUMMY_SP};
use std::borrow::Cow;
use std::iter;
@ -188,8 +186,11 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
let mut infcx_inner = infcx.inner.borrow_mut();
let ty_vars = infcx_inner.type_variables();
let var_origin = ty_vars.var_origin(ty_vid);
if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) = var_origin.kind
&& name != kw::SelfUpper
if let Some(def_id) = var_origin.param_def_id
// The `Self` param of a trait has the def-id of the trait,
// since it's a synthetic parameter.
&& infcx.tcx.def_kind(def_id) == DefKind::TyParam
&& let name = infcx.tcx.item_name(def_id)
&& !var_origin.span.from_expansion()
{
let generics = infcx.tcx.generics_of(infcx.tcx.parent(def_id));
@ -216,8 +217,8 @@ fn fmt_printer<'a, 'tcx>(infcx: &'a InferCtxt<'tcx>, ns: Namespace) -> FmtPrinte
None
}
ConstVariableValue::Unknown { origin, universe: _ } => {
if let ConstVariableOriginKind::ConstParameterDefinition(name, _) = origin.kind {
return Some(name);
if let Some(def_id) = origin.param_def_id {
Some(infcx.tcx.item_name(def_id))
} else {
None
}
@ -302,21 +303,18 @@ pub fn extract_inference_diagnostics_data(
let mut inner = self.inner.borrow_mut();
let ty_vars = &inner.type_variables();
let var_origin = ty_vars.var_origin(ty_vid);
if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) =
var_origin.kind
if let Some(def_id) = var_origin.param_def_id
// The `Self` param of a trait has the def-id of the trait,
// since it's a synthetic parameter.
&& self.tcx.def_kind(def_id) == DefKind::TyParam
&& !var_origin.span.from_expansion()
{
if name != kw::SelfUpper && !var_origin.span.from_expansion() {
return InferenceDiagnosticsData {
name: name.to_string(),
span: Some(var_origin.span),
kind: UnderspecifiedArgKind::Type {
prefix: "type parameter".into(),
},
parent: InferenceDiagnosticsParentData::for_def_id(
self.tcx, def_id,
),
};
}
return InferenceDiagnosticsData {
name: self.tcx.item_name(def_id).to_string(),
span: Some(var_origin.span),
kind: UnderspecifiedArgKind::Type { prefix: "type parameter".into() },
parent: InferenceDiagnosticsParentData::for_def_id(self.tcx, def_id),
};
}
}
@ -341,11 +339,9 @@ pub fn extract_inference_diagnostics_data(
}
ConstVariableValue::Unknown { origin, universe: _ } => origin,
};
if let ConstVariableOriginKind::ConstParameterDefinition(name, def_id) =
origin.kind
{
if let Some(def_id) = origin.param_def_id {
return InferenceDiagnosticsData {
name: name.to_string(),
name: self.tcx.item_name(def_id).to_string(),
span: Some(origin.span),
kind: UnderspecifiedArgKind::Const { is_parameter: true },
parent: InferenceDiagnosticsParentData::for_def_id(self.tcx, def_id),
@ -549,16 +545,13 @@ pub fn emit_inference_failure_err(
GenericArgKind::Type(_) => self
.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
param_def_id: None,
})
.into(),
GenericArgKind::Const(arg) => self
.next_const_var(
arg.ty(),
ConstVariableOrigin {
span: DUMMY_SP,
kind: ConstVariableOriginKind::MiscVariable,
},
ConstVariableOrigin { span: DUMMY_SP, param_def_id: None },
)
.into(),
}
@ -576,10 +569,9 @@ pub fn emit_inference_failure_err(
}
}
InferSourceKind::FullyQualifiedMethodCall { receiver, successor, args, def_id } => {
let placeholder = Some(self.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
}));
let placeholder = Some(
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
);
if let Some(args) = args.make_suggestable(self.infcx.tcx, true, placeholder) {
let mut printer = fmt_printer(self, Namespace::ValueNS);
printer.print_def_path(def_id, args).unwrap();
@ -613,10 +605,9 @@ pub fn emit_inference_failure_err(
}
}
InferSourceKind::ClosureReturn { ty, data, should_wrap_expr } => {
let placeholder = Some(self.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
}));
let placeholder = Some(
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
);
if let Some(ty) = ty.make_suggestable(self.infcx.tcx, true, placeholder) {
let ty_info = ty_to_string(self, ty, None);
multi_suggestions.push(SourceKindMultiSuggestion::new_closure_return(

View file

@ -30,7 +30,7 @@
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::ConstVariableValue;
use rustc_middle::infer::unify_key::EffectVarValue;
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ToType};
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
use rustc_middle::mir::ConstraintCategory;
@ -48,7 +48,7 @@
use snapshot::undo_log::InferCtxtUndoLogs;
use std::cell::{Cell, RefCell};
use std::fmt;
use type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use type_variable::TypeVariableOrigin;
pub mod at;
pub mod canonical;
@ -1111,13 +1111,7 @@ pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> GenericArg
// as the generic parameters for the default, `(T, U)`.
let ty_var_id = self.inner.borrow_mut().type_variables().new_var(
self.universe(),
TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeParameterDefinition(
param.name,
param.def_id,
),
span,
},
TypeVariableOrigin { param_def_id: Some(param.def_id), span },
);
Ty::new_var(self.tcx, ty_var_id).into()
@ -1126,13 +1120,7 @@ pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> GenericArg
if is_host_effect {
return self.var_for_effect(param);
}
let origin = ConstVariableOrigin {
kind: ConstVariableOriginKind::ConstParameterDefinition(
param.name,
param.def_id,
),
span,
};
let origin = ConstVariableOrigin { param_def_id: Some(param.def_id), span };
let const_var_id = self
.inner
.borrow_mut()
@ -1411,10 +1399,7 @@ fn replace_ty(&mut self, bt: ty::BoundTy) -> Ty<'tcx> {
.entry(bt.var)
.or_insert_with(|| {
self.infcx
.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: self.span,
})
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.span })
.into()
})
.expect_ty()
@ -1426,10 +1411,7 @@ fn replace_const(&mut self, bv: ty::BoundVar, ty: Ty<'tcx>) -> ty::Const<'tcx> {
self.infcx
.next_const_var(
ty,
ConstVariableOrigin {
kind: ConstVariableOriginKind::MiscVariable,
span: self.span,
},
ConstVariableOrigin { param_def_id: None, span: self.span },
)
.into()
})

View file

@ -1,4 +1,4 @@
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use super::type_variable::TypeVariableOrigin;
use super::{DefineOpaqueTypes, InferResult};
use crate::errors::OpaqueHiddenTypeDiag;
use crate::infer::{InferCtxt, InferOk};
@ -65,13 +65,7 @@ pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<TyCtxt<'tcx>>>(
let span = if span.contains(def_span) { def_span } else { span };
let code = traits::ObligationCauseCode::OpaqueReturnType(None);
let cause = ObligationCause::new(span, body_id, code);
// FIXME(compiler-errors): We probably should add a new TypeVariableOriginKind
// for opaque types, and then use that kind to fix the spans for type errors
// that we see later on.
let ty_var = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span,
});
let ty_var = self.next_ty_var(TypeVariableOrigin { param_def_id: None, span });
obligations.extend(
self.handle_opaque_type(ty, ty_var, &cause, param_env).unwrap().obligations,
);

View file

@ -3,7 +3,7 @@
use crate::traits::{Obligation, PredicateObligation};
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use super::type_variable::TypeVariableOrigin;
use super::InferCtxt;
impl<'tcx> InferCtxt<'tcx> {
@ -24,7 +24,7 @@ pub fn infer_projection(
debug_assert!(!self.next_trait_solver());
let def_id = projection_ty.def_id;
let ty_var = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
param_def_id: None,
span: self.tcx.def_span(def_id),
});
let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Projection(

View file

@ -1,7 +1,7 @@
use std::mem;
use super::StructurallyRelateAliases;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind, TypeVariableValue};
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableValue};
use crate::infer::{InferCtxt, ObligationEmittingRelation, RegionVariableOrigin};
use rustc_data_structures::sso::SsoHashMap;
use rustc_data_structures::stack::ensure_sufficient_stack;
@ -352,7 +352,7 @@ fn generalize_alias_ty(
) -> Result<Ty<'tcx>, TypeError<'tcx>> {
if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() {
return Ok(self.infcx.next_ty_var_in_universe(
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span: self.span },
TypeVariableOrigin { param_def_id: None, span: self.span },
self.for_universe,
));
}
@ -375,10 +375,7 @@ fn generalize_alias_ty(
debug!("generalization failure in alias");
Ok(self.infcx.next_ty_var_in_universe(
TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: self.span,
},
TypeVariableOrigin { param_def_id: None, span: self.span },
self.for_universe,
))
}

View file

@ -18,7 +18,7 @@
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
use super::combine::ObligationEmittingRelation;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::{DefineOpaqueTypes, InferCtxt};
use crate::traits::ObligationCause;
@ -88,18 +88,14 @@ pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
// iterate on the subtype obligations that are returned, but I
// think this suffices. -nmatsakis
(&ty::Infer(TyVar(..)), _) => {
let v = infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::LatticeVariable,
span: this.cause().span,
});
let v = infcx
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: this.cause().span });
this.relate_bound(v, b, a)?;
Ok(v)
}
(_, &ty::Infer(TyVar(..))) => {
let v = infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::LatticeVariable,
span: this.cause().span,
});
let v = infcx
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: this.cause().span });
this.relate_bound(v, a, b)?;
Ok(v)
}

View file

@ -1,4 +1,4 @@
use rustc_middle::infer::unify_key::{ConstVariableOriginKind, ConstVariableValue, ConstVidKey};
use rustc_middle::infer::unify_key::{ConstVariableValue, ConstVidKey};
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid};
@ -33,10 +33,9 @@ fn const_vars_since_snapshot<'tcx>(
range.start.vid..range.end.vid,
(range.start.index()..range.end.index())
.map(|index| match table.probe_value(ConstVid::from_u32(index)) {
ConstVariableValue::Known { value: _ } => ConstVariableOrigin {
kind: ConstVariableOriginKind::MiscVariable,
span: rustc_span::DUMMY_SP,
},
ConstVariableValue::Known { value: _ } => {
ConstVariableOrigin { param_def_id: None, span: rustc_span::DUMMY_SP }
}
ConstVariableValue::Unknown { origin, universe: _ } => origin,
})
.collect(),

View file

@ -2,7 +2,6 @@
use rustc_hir::def_id::DefId;
use rustc_index::IndexVec;
use rustc_middle::ty::{self, Ty, TyVid};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use crate::infer::InferCtxtUndoLogs;
@ -37,30 +36,11 @@ pub struct TypeVariableTable<'a, 'tcx> {
#[derive(Copy, Clone, Debug)]
pub struct TypeVariableOrigin {
pub kind: TypeVariableOriginKind,
pub span: Span,
}
/// Reasons to create a type inference variable
#[derive(Copy, Clone, Debug)]
pub enum TypeVariableOriginKind {
MiscVariable,
NormalizeProjectionType,
TypeInference,
TypeParameterDefinition(Symbol, DefId),
/// One of the upvars or closure kind parameters in a `ClosureArgs`
/// (before it has been determined).
// FIXME(eddyb) distinguish upvar inference variables from the rest.
ClosureSynthetic,
AutoDeref,
AdjustmentType,
/// In type check, when we are type checking a function that
/// returns `-> dyn Foo`, we instantiate a type variable with the
/// return type for diagnostic purposes.
DynReturnFn,
LatticeVariable,
/// `DefId` of the type parameter this was instantiated for, if any.
///
/// This should only be used for diagnostics.
pub param_def_id: Option<DefId>,
}
#[derive(Clone)]

View file

@ -1,9 +1,8 @@
use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, TyKind};
use rustc_hir::{Path, QPath};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::InferCtxt;
use rustc_infer::traits::{Obligation, ObligationCause};
use rustc_middle::query::Key;
use rustc_middle::ty::{self, Binder, Ty, TyCtxt, TypeFoldable, TypeFolder};
use rustc_middle::ty::{EarlyBinder, TraitRef, TypeSuperFoldable};
use rustc_span::def_id::{DefId, LOCAL_CRATE};
@ -313,13 +312,10 @@ fn interner(&self) -> TyCtxt<'tcx> {
}
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
if let Some(ty_did) = t.ty_def_id()
&& (self.did_has_local_parent)(ty_did)
if let Some(def) = t.ty_adt_def()
&& (self.did_has_local_parent)(def.did())
{
self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: self.infer_span,
})
self.infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.infer_span })
} else {
t.super_fold_with(self)
}

View file

@ -25,6 +25,7 @@ rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hir = { path = "../rustc_hir" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_query_system = { path = "../rustc_query_system" }

View file

@ -13,6 +13,7 @@
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
use rustc_hir::intravisit::Visitor;
use rustc_hir::*;
use rustc_hir_pretty as pprust_hir;
use rustc_middle::hir::nested_filter;
use rustc_span::def_id::StableCrateId;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@ -999,6 +1000,12 @@ fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
}
}
impl<'tcx> pprust_hir::PpAnn for TyCtxt<'tcx> {
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
pprust_hir::PpAnn::nested(&(&self.hir() as &dyn intravisit::Map<'_>), state, nested)
}
}
pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
let krate = tcx.hir_crate(());
let hir_body_hash = krate.opt_hir_hash.expect("HIR hash missing while computing crate hash");

View file

@ -1,7 +1,6 @@
use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::unify::{NoError, UnifyKey, UnifyValue};
use rustc_span::def_id::DefId;
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use std::cmp;
use std::marker::PhantomData;
@ -106,16 +105,11 @@ fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
#[derive(Copy, Clone, Debug)]
pub struct ConstVariableOrigin {
pub kind: ConstVariableOriginKind,
pub span: Span,
}
/// Reasons to create a const inference variable
#[derive(Copy, Clone, Debug)]
pub enum ConstVariableOriginKind {
MiscVariable,
ConstInference,
ConstParameterDefinition(Symbol, DefId),
/// `DefId` of the const parameter this was instantiated for, if any.
///
/// This should only be used for diagnostics.
pub param_def_id: Option<DefId>,
}
#[derive(Copy, Clone, Debug)]

View file

@ -983,9 +983,6 @@
query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
}
query lookup_method_for_diagnostic((def_id, hir_id): (LocalDefId, hir::HirId)) -> Option<DefId> {
desc { |tcx| "lookup_method_for_diagnostics `{}`", tcx.def_path_str(def_id) }
}
query used_trait_imports(key: LocalDefId) -> &'tcx UnordSet<LocalDefId> {
desc { |tcx| "finding used_trait_imports `{}`", tcx.def_path_str(key) }

View file

@ -1684,10 +1684,15 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
.any(|items| items.iter().any(|item| item.has_name(sym::notable_trait)))
}
/// Determines whether an item is an intrinsic (which may be via Abi or via the `rustc_intrinsic` attribute)
/// Determines whether an item is an intrinsic (which may be via Abi or via the `rustc_intrinsic` attribute).
///
/// We double check the feature gate here because whether a function may be defined as an intrinsic causes
/// the compiler to make some assumptions about its shape; if the user doesn't use a feature gate, they may
/// cause an ICE that we otherwise may want to prevent.
pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
|| tcx.has_attr(def_id, sym::rustc_intrinsic)
if (matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
&& tcx.features().intrinsics)
|| (tcx.has_attr(def_id, sym::rustc_intrinsic) && tcx.features().rustc_attrs)
{
Some(ty::IntrinsicDef {
name: tcx.item_name(def_id.into()),

View file

@ -2,7 +2,7 @@
use crate::build::matches::{Binding, Candidate, FlatPat, MatchPair, TestCase};
use crate::build::Builder;
use rustc_data_structures::fx::FxIndexSet;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_middle::mir::*;
use rustc_middle::thir::{self, *};
use rustc_middle::ty;
@ -178,10 +178,9 @@ pub(in crate::build) fn new(
cx.tcx,
ty::InlineConstArgsParts {
parent_args: ty::GenericArgs::identity_for_item(cx.tcx, parent_id),
ty: cx.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span,
}),
ty: cx
.infcx
.next_ty_var(TypeVariableOrigin { param_def_id: None, span }),
},
)
.args;

View file

@ -279,7 +279,7 @@ pub(super) fn expected_ident_found(
TokenKind::Colon,
TokenKind::Comma,
TokenKind::Semi,
TokenKind::ModSep,
TokenKind::PathSep,
TokenKind::OpenDelim(Delimiter::Brace),
TokenKind::OpenDelim(Delimiter::Parenthesis),
TokenKind::CloseDelim(Delimiter::Brace),
@ -1169,7 +1169,7 @@ pub(super) fn check_turbofish_missing_angle_brackets(&mut self, segment: &mut Pa
return;
}
if token::ModSep == self.token.kind && segment.args.is_none() {
if token::PathSep == self.token.kind && segment.args.is_none() {
let snapshot = self.create_snapshot_for_diagnostic();
self.bump();
let lo = self.token.span;
@ -1420,7 +1420,7 @@ pub(super) fn check_no_chained_comparison(
[(token::Lt, 1), (token::Gt, -1), (token::BinOp(token::Shr), -2)];
self.consume_tts(1, &modifiers);
if !&[token::OpenDelim(Delimiter::Parenthesis), token::ModSep]
if !&[token::OpenDelim(Delimiter::Parenthesis), token::PathSep]
.contains(&self.token.kind)
{
// We don't have `foo< bar >(` or `foo< bar >::`, so we rewind the
@ -1428,7 +1428,7 @@ pub(super) fn check_no_chained_comparison(
self.restore_snapshot(snapshot);
}
}
return if token::ModSep == self.token.kind {
return if token::PathSep == self.token.kind {
// We have some certainty that this was a bad turbofish at this point.
// `foo< bar >::`
if let ExprKind::Binary(o, ..) = inner_op.kind
@ -1784,7 +1784,7 @@ pub(super) fn maybe_recover_from_bad_qpath<T: RecoverQPath>(
}
// Do not add `::` to expected tokens.
if self.token == token::ModSep {
if self.token == token::PathSep {
if let Some(ty) = base.to_ty() {
return self.maybe_recover_from_bad_qpath_stage_2(ty.span, ty);
}
@ -1799,7 +1799,7 @@ pub(super) fn maybe_recover_from_bad_qpath_stage_2<T: RecoverQPath>(
ty_span: Span,
ty: P<Ty>,
) -> PResult<'a, P<T>> {
self.expect(&token::ModSep)?;
self.expect(&token::PathSep)?;
let mut path = ast::Path { segments: ThinVec::new(), span: DUMMY_SP, tokens: None };
self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None)?;

View file

@ -358,12 +358,12 @@ pub(super) fn is_path_start_item(&mut self) -> bool {
fn is_reuse_path_item(&mut self) -> bool {
// no: `reuse ::path` for compatibility reasons with macro invocations
self.token.is_keyword(kw::Reuse)
&& self.look_ahead(1, |t| t.is_path_start() && t.kind != token::ModSep)
&& self.look_ahead(1, |t| t.is_path_start() && t.kind != token::PathSep)
}
/// Are we sure this could not possibly be a macro invocation?
fn isnt_macro_invocation(&mut self) -> bool {
self.check_ident() && self.look_ahead(1, |t| *t != token::Not && *t != token::ModSep)
self.check_ident() && self.look_ahead(1, |t| *t != token::Not && *t != token::PathSep)
}
/// Recover on encountering a struct or method definition where the user
@ -1020,7 +1020,7 @@ fn parse_use_tree(&mut self) -> PResult<'a, UseTree> {
{
// `use *;` or `use ::*;` or `use {...};` or `use ::{...};`
let mod_sep_ctxt = self.token.span.ctxt();
if self.eat(&token::ModSep) {
if self.eat(&token::PathSep) {
prefix
.segments
.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)));
@ -1031,7 +1031,7 @@ fn parse_use_tree(&mut self) -> PResult<'a, UseTree> {
// `use path::*;` or `use path::{...};` or `use path;` or `use path as bar;`
prefix = self.parse_path(PathStyle::Mod)?;
if self.eat(&token::ModSep) {
if self.eat(&token::PathSep) {
self.parse_use_tree_glob_or_nested()?
} else {
// Recover from using a colon as path separator.
@ -2752,7 +2752,7 @@ fn parse_self_param(&mut self) -> PResult<'a, Option<Param>> {
// Is `self` `n` tokens ahead?
let is_isolated_self = |this: &Self, n| {
this.is_keyword_ahead(n, &[kw::SelfLower])
&& this.look_ahead(n + 1, |t| t != &token::ModSep)
&& this.look_ahead(n + 1, |t| t != &token::PathSep)
};
// Is `mut self` `n` tokens ahead?
let is_isolated_mut_self =

View file

@ -109,7 +109,7 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
($self: expr, $allow_qpath_recovery: expr) => {
if $allow_qpath_recovery
&& $self.may_recover()
&& $self.look_ahead(1, |t| t == &token::ModSep)
&& $self.look_ahead(1, |t| t == &token::PathSep)
&& let token::Interpolated(nt) = &$self.token.kind
&& let token::NtTy(ty) = &nt.0
{
@ -1532,7 +1532,7 @@ pub fn collect_tokens_no_attrs<R: HasAttrs + HasTokens>(
/// `::{` or `::*`
fn is_import_coupler(&mut self) -> bool {
self.check(&token::ModSep)
self.check(&token::PathSep)
&& self.look_ahead(1, |t| {
*t == token::OpenDelim(Delimiter::Brace) || *t == token::BinOp(token::Star)
})

View file

@ -62,7 +62,7 @@ fn may_be_ident(nt: &token::Nonterminal) -> bool {
_ => false,
},
NonterminalKind::Path | NonterminalKind::Meta => match &token.kind {
token::ModSep | token::Ident(..) => true,
token::PathSep | token::Ident(..) => true,
token::Interpolated(nt) => may_be_ident(&nt.0),
_ => false,
},
@ -76,7 +76,7 @@ fn may_be_ident(nt: &token::Nonterminal) -> bool {
token::Literal(_) | // literal
token::DotDot | // range pattern (future compat)
token::DotDotDot | // range pattern (future compat)
token::ModSep | // path
token::PathSep | // path
token::Lt | // path (UFCS constant)
token::BinOp(token::Shl) => true, // path (double UFCS)
// leading vert `|` or-pattern

View file

@ -1016,7 +1016,7 @@ fn can_be_ident_pat(&mut self) -> bool {
&& self.look_ahead(1, |t| !matches!(t.kind, token::OpenDelim(Delimiter::Parenthesis) // A tuple struct pattern.
| token::OpenDelim(Delimiter::Brace) // A struct pattern.
| token::DotDotDot | token::DotDotEq | token::DotDot // A range pattern.
| token::ModSep // A tuple / struct variant pattern.
| token::PathSep // A tuple / struct variant pattern.
| token::Not)) // A macro expanding to a pattern.
}

View file

@ -96,7 +96,7 @@ pub(super) fn parse_qpath(&mut self, style: PathStyle) -> PResult<'a, (P<QSelf>,
}
if !self.recover_colon_before_qpath_proj() {
self.expect(&token::ModSep)?;
self.expect(&token::PathSep)?;
}
let qself = P(QSelf { ty, path_span, position: path.segments.len() });
@ -200,7 +200,7 @@ pub(super) fn parse_path_inner(
let lo = self.token.span;
let mut segments = ThinVec::new();
let mod_sep_ctxt = self.token.span.ctxt();
if self.eat(&token::ModSep) {
if self.eat(&token::PathSep) {
segments.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)));
}
self.parse_path_segments(&mut segments, style, ty_generics)?;
@ -232,11 +232,11 @@ pub(super) fn parse_path_segments(
// `PathStyle::Expr` is only provided at the root invocation and never in
// `parse_path_segment` to recurse and therefore can be checked to maintain
// this invariant.
self.check_trailing_angle_brackets(&segment, &[&token::ModSep]);
self.check_trailing_angle_brackets(&segment, &[&token::PathSep]);
}
segments.push(segment);
if self.is_import_coupler() || !self.eat(&token::ModSep) {
if self.is_import_coupler() || !self.eat(&token::PathSep) {
if style == PathStyle::Expr
&& self.may_recover()
&& self.token == token::Colon
@ -291,7 +291,7 @@ pub(super) fn parse_path_segment(
Ok(
if style == PathStyle::Type && check_args_start(self)
|| style != PathStyle::Mod
&& self.check(&token::ModSep)
&& self.check(&token::PathSep)
&& self.look_ahead(1, |t| is_args_start(t))
{
// We use `style == PathStyle::Expr` to check if this is in a recursion or not. If
@ -303,7 +303,7 @@ pub(super) fn parse_path_segment(
}
// Generic arguments are found - `<`, `(`, `::<` or `::(`.
self.eat(&token::ModSep);
self.eat(&token::PathSep);
let lo = self.token.span;
let args = if self.eat_lt() {
// `<'a, T, A = U>`
@ -379,7 +379,7 @@ pub(super) fn parse_path_segment(
let token_before_parsing = self.token.clone();
let mut snapshot = None;
if self.may_recover()
&& prev_token_before_parsing.kind == token::ModSep
&& prev_token_before_parsing.kind == token::PathSep
&& (style == PathStyle::Expr && self.token.can_begin_expr()
|| style == PathStyle::Pat && self.token.can_begin_pattern())
{
@ -388,7 +388,7 @@ pub(super) fn parse_path_segment(
let (inputs, _) = match self.parse_paren_comma_seq(|p| p.parse_ty()) {
Ok(output) => output,
Err(mut error) if prev_token_before_parsing.kind == token::ModSep => {
Err(mut error) if prev_token_before_parsing.kind == token::PathSep => {
error.span_label(
prev_token_before_parsing.span.to(token_before_parsing.span),
"while parsing this parenthesized list of type arguments starting here",
@ -470,7 +470,7 @@ fn recover_fn_call_leading_path_sep(
}
}
if let token::ModSep | token::RArrow = self.token.kind {
if let token::PathSep | token::RArrow = self.token.kind {
return;
}

View file

@ -82,7 +82,7 @@ enum AllowCVariadic {
/// Types can also be of the form `IDENT(u8, u8) -> u8`, however this assumes
/// that `IDENT` is not the ident of a fn trait.
fn can_continue_type_after_non_fn_ident(t: &Token) -> bool {
t == &token::ModSep || t == &token::Lt || t == &token::BinOp(token::Shl)
t == &token::PathSep || t == &token::Lt || t == &token::BinOp(token::Shl)
}
fn can_begin_dyn_bound_in_edition_2015(t: &Token) -> bool {

View file

@ -2,7 +2,7 @@
use rustc_hir::def_id::DefId;
use rustc_infer::infer::at::ToTrace;
use rustc_infer::infer::canonical::CanonicalVarValues;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{
BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk, TyCtxtInferExt,
};
@ -10,7 +10,7 @@
use rustc_infer::traits::solve::{MaybeCause, NestedNormalizationGoals};
use rustc_infer::traits::ObligationCause;
use rustc_middle::infer::canonical::CanonicalVarInfos;
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_middle::infer::unify_key::ConstVariableOrigin;
use rustc_middle::traits::solve::inspect;
use rustc_middle::traits::solve::{
CanonicalInput, CanonicalResponse, Certainty, PredefinedOpaques, PredefinedOpaquesData,
@ -587,17 +587,11 @@ pub(super) fn tcx(&self) -> TyCtxt<'tcx> {
}
pub(super) fn next_ty_infer(&self) -> Ty<'tcx> {
self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
})
self.infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP })
}
pub(super) fn next_const_infer(&self, ty: Ty<'tcx>) -> ty::Const<'tcx> {
self.infcx.next_const_var(
ty,
ConstVariableOrigin { kind: ConstVariableOriginKind::MiscVariable, span: DUMMY_SP },
)
self.infcx.next_const_var(ty, ConstVariableOrigin { param_def_id: None, span: DUMMY_SP })
}
/// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`.

View file

@ -3,11 +3,11 @@
use crate::traits::{BoundVarReplacer, PlaceholderReplacer};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_infer::infer::at::At;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::InferCtxt;
use rustc_infer::traits::TraitEngineExt;
use rustc_infer::traits::{FulfillmentError, Obligation, TraitEngine};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_middle::infer::unify_key::ConstVariableOrigin;
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::{self, AliasTy, Ty, TyCtxt, UniverseIndex};
use rustc_middle::ty::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable};
@ -74,10 +74,8 @@ fn normalize_alias_ty(
self.depth += 1;
let new_infer_ty = infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
span: self.at.cause.span,
});
let new_infer_ty =
infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.at.cause.span });
let obligation = Obligation::new(
tcx,
self.at.cause.clone(),
@ -124,10 +122,7 @@ fn normalize_unevaluated_const(
let new_infer_ct = infcx.next_const_var(
ty,
ConstVariableOrigin {
kind: ConstVariableOriginKind::MiscVariable,
span: self.at.cause.span,
},
ConstVariableOrigin { param_def_id: None, span: self.at.cause.span },
);
let obligation = Obligation::new(
tcx,

View file

@ -1,4 +1,4 @@
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::InferCtxt;
use crate::traits::{Obligation, ObligationCause, ObligationCtxt};
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, Diag};
@ -217,10 +217,8 @@ fn type_implements_fn_trait(
let Some(trait_def_id) = trait_def_id else { continue };
// Make a fresh inference variable so we can determine what the generic parameters
// of the trait are.
let var = self.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
});
let var =
self.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None });
// FIXME(effects)
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, [ty.skip_binder(), var]);
let obligation = Obligation::new(

View file

@ -24,7 +24,7 @@
use rustc_hir::lang_items::LangItem;
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node};
use rustc_infer::infer::error_reporting::TypeErrCtxt;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
use rustc_middle::hir::map;
use rustc_middle::traits::IsConstable;
@ -1894,10 +1894,8 @@ pub(crate) fn build_fn_sig_ty<'tcx>(
ty::Tuple(inputs) if infcx.tcx.is_fn_trait(trait_ref.def_id) => {
infcx.tcx.mk_fn_sig(
*inputs,
infcx.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
}),
infcx
.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
false,
hir::Unsafety::Normal,
abi::Abi::Rust,
@ -1905,10 +1903,7 @@ pub(crate) fn build_fn_sig_ty<'tcx>(
}
_ => infcx.tcx.mk_fn_sig(
[inputs],
infcx.next_ty_var(TypeVariableOrigin {
span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable,
}),
infcx.next_ty_var(TypeVariableOrigin { span: DUMMY_SP, param_def_id: None }),
false,
hir::Unsafety::Normal,
abi::Abi::Rust,
@ -4269,7 +4264,7 @@ fn probe_assoc_types_at_expr(
continue;
};
let origin = TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span };
let origin = TypeVariableOrigin { param_def_id: None, span };
// Make `Self` be equivalent to the type of the call chain
// expression we're looking at now, so that we can tell what
// for example `Iterator::Item` is at this point in the chain.

View file

@ -6,7 +6,7 @@
AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
};
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::InferCtxtExt as _;
use crate::infer::{self, InferCtxt};
use crate::traits::error_reporting::infer_ctxt_ext::InferCtxtExt;
@ -2820,10 +2820,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Param(_) = *ty.kind() {
let infcx = self.infcx;
*self.var_map.entry(ty).or_insert_with(|| {
infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
})
infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: DUMMY_SP })
})
} else {
ty.super_fold_with(self)

View file

@ -18,7 +18,7 @@
use rustc_middle::traits::ImplSourceUserDefinedData;
use crate::errors::InherentProjectionNormalizationOverflow;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::type_variable::TypeVariableOrigin;
use crate::infer::{BoundRegionConversionTime, InferOk};
use crate::traits::normalize::normalize_with_depth;
use crate::traits::normalize::normalize_with_depth_to;
@ -522,7 +522,7 @@ fn normalize_to_error<'a, 'tcx>(
};
let tcx = selcx.infcx.tcx;
let new_value = selcx.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
param_def_id: None,
span: tcx.def_span(projection_ty.def_id),
});
Normalized { value: new_value, obligations: vec![trait_obligation] }

View file

@ -1,5 +1,5 @@
use rustc_infer::infer::at::At;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_infer::traits::{FulfillmentError, TraitEngine};
use rustc_middle::ty::{self, Ty};
@ -19,10 +19,9 @@ fn structurally_normalize(
return Ok(ty);
};
let new_infer_ty = self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::NormalizeProjectionType,
span: self.cause.span,
});
let new_infer_ty = self
.infcx
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.cause.span });
// We simply emit an `alias-eq` goal here, since that will take care of
// normalizing the LHS of the projection until it is a rigid projection

View file

@ -77,7 +77,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Msrv) {
let (help, final_suggestion) = if let Some(method) = omit_cast.corresponding_item() {
// don't force absolute path
let method = qpath_to_string(method);
let method = qpath_to_string(&cx.tcx, method);
("try call directly", format!("{method}{turbofish}()"))
} else {
let cast_expr_sugg = Sugg::hir_with_applicability(cx, cast_expr, "_", &mut app);

View file

@ -88,7 +88,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
if !prev_is_dollar
&& let Some(span) = is_crate_keyword(curr)
&& let Some(next) = cursor.look_ahead(0)
&& is_token(next, &TokenKind::ModSep)
&& is_token(next, &TokenKind::PathSep)
{
return Some(span);
}

View file

@ -19,7 +19,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm<'
if is_type_diagnostic_item(cx, ex_ty, sym::Result) {
for arm in arms {
if let PatKind::TupleStruct(ref path, inner, _) = arm.pat.kind {
let path_str = rustc_hir_pretty::qpath_to_string(path);
let path_str = rustc_hir_pretty::qpath_to_string(&cx.tcx, path);
if path_str == "Err" {
let mut matching_wild = inner.iter().any(is_wild);
let mut ident_bind_name = kw::Underscore;

View file

@ -49,7 +49,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
cx,
arguments.iter().collect(),
cx.typeck_results().expr_ty(fn_expr),
&rustc_hir_pretty::qpath_to_string(path),
&rustc_hir_pretty::qpath_to_string(&cx.tcx, path),
"function",
);
}

View file

@ -10,7 +10,7 @@
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, FnDecl, LangItem, TyKind, Unsafety};
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_infer::infer::type_variable::{TypeVariableOrigin};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::LateContext;
use rustc_middle::mir::interpret::Scalar;
@ -276,8 +276,8 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
.map(|arg| {
arg.into().unwrap_or_else(|| {
let orig = TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
param_def_id: None,
};
infcx.next_ty_var(orig).into()
})

View file

@ -1091,7 +1091,7 @@ fn next_space(tok: &TokenKind) -> SpaceState {
| TokenKind::DotDotEq
| TokenKind::Question => SpaceState::Punctuation,
TokenKind::ModSep
TokenKind::PathSep
| TokenKind::Pound
| TokenKind::Dollar
| TokenKind::OpenDelim(_)

View file

@ -14,3 +14,10 @@ If you happen to fix one of the crashes, please move it to a fitting
subdirectory in `tests/ui` and give it a meaningful name.
Also please add a doc comment at the top of the file explaining why
this test exists. :)
Adding
Fixes #NNNNN
Fixes #MMMMM
to the description of your pull request will ensure the
corresponding tickets will be closed automatically upon merge.
The ticket ids can be found in the file name or the `known-bug` annotation
inside the testfile.

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/value-suggestion-ice-123906.rs:3:9
|
LL | fn as_chunks<const N: usize>() -> [u8; N] {
| ------- expected `[u8; ]` because of this return type
| ------- expected `[u8; N]` because of this return type
LL | loop {
| ---- this loop is expected to be of type `[u8; N]`
LL | break;

View file

@ -0,0 +1,8 @@
enum Struct<const N: usize> { Variant { x: [(); N] } }
fn test() {
let x = Struct::<0>::Variant;
//~^ ERROR expected value, found struct variant `Struct<0>::Variant`
}
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0533]: expected value, found struct variant `Struct<0>::Variant`
--> $DIR/error-variant-with-turbofishes.rs:4:13
|
LL | let x = Struct::<0>::Variant;
| ^^^^^^^^^^^^^^^^^^^^ not a value
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0533`.

View file

@ -13,10 +13,8 @@ trait Tuple { }
// Functions
extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change
//~^ ERROR intrinsic must be in
//~| ERROR unrecognized intrinsic function: `f1`
extern "rust-intrinsic" fn f2() {} //~ ERROR intrinsics are subject to change
//~^ ERROR intrinsic must be in
//~| ERROR unrecognized intrinsic function: `f2`
extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change
// Methods in trait definition

View file

@ -8,7 +8,7 @@ LL | extern "rust-intrinsic" fn f1() {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:17:8
--> $DIR/feature-gate-abi.rs:16:8
|
LL | extern "rust-intrinsic" fn f2() {}
| ^^^^^^^^^^^^^^^^
@ -17,7 +17,7 @@ LL | extern "rust-intrinsic" fn f2() {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:20:8
--> $DIR/feature-gate-abi.rs:18:8
|
LL | extern "rust-call" fn f4(_: ()) {}
| ^^^^^^^^^^^
@ -27,7 +27,7 @@ LL | extern "rust-call" fn f4(_: ()) {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:24:12
--> $DIR/feature-gate-abi.rs:22:12
|
LL | extern "rust-intrinsic" fn m1();
| ^^^^^^^^^^^^^^^^
@ -36,7 +36,7 @@ LL | extern "rust-intrinsic" fn m1();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:26:12
--> $DIR/feature-gate-abi.rs:24:12
|
LL | extern "rust-intrinsic" fn m2();
| ^^^^^^^^^^^^^^^^
@ -45,7 +45,7 @@ LL | extern "rust-intrinsic" fn m2();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:28:12
--> $DIR/feature-gate-abi.rs:26:12
|
LL | extern "rust-call" fn m4(_: ());
| ^^^^^^^^^^^
@ -55,7 +55,7 @@ LL | extern "rust-call" fn m4(_: ());
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:30:12
--> $DIR/feature-gate-abi.rs:28:12
|
LL | extern "rust-call" fn dm4(_: ()) {}
| ^^^^^^^^^^^
@ -65,7 +65,7 @@ LL | extern "rust-call" fn dm4(_: ()) {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:37:12
--> $DIR/feature-gate-abi.rs:35:12
|
LL | extern "rust-intrinsic" fn m1() {}
| ^^^^^^^^^^^^^^^^
@ -74,7 +74,7 @@ LL | extern "rust-intrinsic" fn m1() {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:39:12
--> $DIR/feature-gate-abi.rs:37:12
|
LL | extern "rust-intrinsic" fn m2() {}
| ^^^^^^^^^^^^^^^^
@ -83,7 +83,7 @@ LL | extern "rust-intrinsic" fn m2() {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:41:12
--> $DIR/feature-gate-abi.rs:39:12
|
LL | extern "rust-call" fn m4(_: ()) {}
| ^^^^^^^^^^^
@ -93,7 +93,7 @@ LL | extern "rust-call" fn m4(_: ()) {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:46:12
--> $DIR/feature-gate-abi.rs:44:12
|
LL | extern "rust-intrinsic" fn im1() {}
| ^^^^^^^^^^^^^^^^
@ -102,7 +102,7 @@ LL | extern "rust-intrinsic" fn im1() {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:48:12
--> $DIR/feature-gate-abi.rs:46:12
|
LL | extern "rust-intrinsic" fn im2() {}
| ^^^^^^^^^^^^^^^^
@ -111,7 +111,7 @@ LL | extern "rust-intrinsic" fn im2() {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:50:12
--> $DIR/feature-gate-abi.rs:48:12
|
LL | extern "rust-call" fn im4(_: ()) {}
| ^^^^^^^^^^^
@ -121,7 +121,7 @@ LL | extern "rust-call" fn im4(_: ()) {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:54:18
--> $DIR/feature-gate-abi.rs:52:18
|
LL | type A1 = extern "rust-intrinsic" fn();
| ^^^^^^^^^^^^^^^^
@ -130,7 +130,7 @@ LL | type A1 = extern "rust-intrinsic" fn();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:55:18
--> $DIR/feature-gate-abi.rs:53:18
|
LL | type A2 = extern "rust-intrinsic" fn();
| ^^^^^^^^^^^^^^^^
@ -139,7 +139,7 @@ LL | type A2 = extern "rust-intrinsic" fn();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:56:18
--> $DIR/feature-gate-abi.rs:54:18
|
LL | type A4 = extern "rust-call" fn(_: ());
| ^^^^^^^^^^^
@ -149,7 +149,7 @@ LL | type A4 = extern "rust-call" fn(_: ());
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:59:8
--> $DIR/feature-gate-abi.rs:57:8
|
LL | extern "rust-intrinsic" {}
| ^^^^^^^^^^^^^^^^
@ -158,7 +158,7 @@ LL | extern "rust-intrinsic" {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: intrinsics are subject to change
--> $DIR/feature-gate-abi.rs:60:8
--> $DIR/feature-gate-abi.rs:58:8
|
LL | extern "rust-intrinsic" {}
| ^^^^^^^^^^^^^^^^
@ -167,7 +167,7 @@ LL | extern "rust-intrinsic" {}
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: rust-call ABI is subject to change
--> $DIR/feature-gate-abi.rs:61:8
--> $DIR/feature-gate-abi.rs:59:8
|
LL | extern "rust-call" {}
| ^^^^^^^^^^^
@ -176,30 +176,14 @@ LL | extern "rust-call" {}
= help: add `#![feature(unboxed_closures)]` 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[E0093]: unrecognized intrinsic function: `f1`
--> $DIR/feature-gate-abi.rs:14:28
|
LL | extern "rust-intrinsic" fn f1() {}
| ^^ unrecognized intrinsic
|
= help: if you're adding an intrinsic, be sure to update `check_intrinsic_type`
error[E0093]: unrecognized intrinsic function: `f2`
--> $DIR/feature-gate-abi.rs:17:28
|
LL | extern "rust-intrinsic" fn f2() {}
| ^^ unrecognized intrinsic
|
= help: if you're adding an intrinsic, be sure to update `check_intrinsic_type`
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:24:32
--> $DIR/feature-gate-abi.rs:22:32
|
LL | extern "rust-intrinsic" fn m1();
| ^^
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:26:32
--> $DIR/feature-gate-abi.rs:24:32
|
LL | extern "rust-intrinsic" fn m2();
| ^^
@ -211,36 +195,35 @@ LL | extern "rust-intrinsic" fn f1() {}
| ^^
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:17:33
--> $DIR/feature-gate-abi.rs:16:33
|
LL | extern "rust-intrinsic" fn f2() {}
| ^^
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:37:37
--> $DIR/feature-gate-abi.rs:35:37
|
LL | extern "rust-intrinsic" fn m1() {}
| ^^
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:39:37
--> $DIR/feature-gate-abi.rs:37:37
|
LL | extern "rust-intrinsic" fn m2() {}
| ^^
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:46:38
--> $DIR/feature-gate-abi.rs:44:38
|
LL | extern "rust-intrinsic" fn im1() {}
| ^^
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-abi.rs:48:38
--> $DIR/feature-gate-abi.rs:46:38
|
LL | extern "rust-intrinsic" fn im2() {}
| ^^
error: aborting due to 29 previous errors
error: aborting due to 27 previous errors
Some errors have detailed explanations: E0093, E0658.
For more information about an error, try `rustc --explain E0093`.
For more information about this error, try `rustc --explain E0658`.

View file

@ -4,6 +4,5 @@
extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change
//~^ ERROR intrinsic must be in
//~| ERROR unrecognized intrinsic function: `baz`
fn main() {}

View file

@ -24,21 +24,13 @@ LL | fn bar();
|
= help: if you're adding an intrinsic, be sure to update `check_intrinsic_type`
error[E0093]: unrecognized intrinsic function: `baz`
--> $DIR/feature-gate-intrinsics.rs:5:28
|
LL | extern "rust-intrinsic" fn baz() {}
| ^^^ unrecognized intrinsic
|
= help: if you're adding an intrinsic, be sure to update `check_intrinsic_type`
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/feature-gate-intrinsics.rs:5:34
|
LL | extern "rust-intrinsic" fn baz() {}
| ^^
error: aborting due to 5 previous errors
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0093, E0658.
For more information about an error, try `rustc --explain E0093`.

View file

@ -0,0 +1,7 @@
fn main() {
read_via_copy();
}
extern "rust-intrinsic" fn read_via_copy() {}
//~^ ERROR intrinsics are subject to change
//~| ERROR intrinsic must be in `extern "rust-intrinsic" { ... }` block

View file

@ -0,0 +1,18 @@
error[E0658]: intrinsics are subject to change
--> $DIR/incorrect-read_via_copy-defn.rs:5:8
|
LL | extern "rust-intrinsic" fn read_via_copy() {}
| ^^^^^^^^^^^^^^^^
|
= help: add `#![feature(intrinsics)]` 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: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/incorrect-read_via_copy-defn.rs:5:44
|
LL | extern "rust-intrinsic" fn read_via_copy() {}
| ^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -3,6 +3,5 @@ fn main() {
}
extern "rust-intrinsic" fn transmute() {}
//~^ ERROR intrinsic has wrong number of type parameters: found 0, expected 2
//~| ERROR intrinsics are subject to change
//~^ ERROR intrinsics are subject to change
//~| ERROR intrinsic must be in `extern "rust-intrinsic" { ... }` block

View file

@ -7,19 +7,12 @@ LL | extern "rust-intrinsic" fn transmute() {}
= help: add `#![feature(intrinsics)]` 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[E0094]: intrinsic has wrong number of type parameters: found 0, expected 2
--> $DIR/incorrect-transmute.rs:5:37
|
LL | extern "rust-intrinsic" fn transmute() {}
| ^ expected 2 type parameters
error: intrinsic must be in `extern "rust-intrinsic" { ... }` block
--> $DIR/incorrect-transmute.rs:5:40
|
LL | extern "rust-intrinsic" fn transmute() {}
| ^^
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0094, E0658.
For more information about an error, try `rustc --explain E0094`.
For more information about this error, try `rustc --explain E0658`.

View file

@ -3,5 +3,5 @@ fn main() {
//~^ ERROR expected a pattern, found an expression
//~| ERROR cannot find type `T` in this scope
//~| ERROR const and type arguments are not allowed on builtin type `str`
//~| ERROR expected unit struct, unit variant or constant, found associated function `str<, T>::as_bytes`
//~| ERROR expected unit struct, unit variant or constant, found associated function `str<
}

View file

@ -24,7 +24,9 @@ LL - let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
LL + let str::as_bytes;
|
error[E0533]: expected unit struct, unit variant or constant, found associated function `str<, T>::as_bytes`
error[E0533]: expected unit struct, unit variant or constant, found associated function `str<{
fn str() { let (/*ERROR*/); }
}, T>::as_bytes`
--> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:9
|
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;

View file

@ -384,7 +384,7 @@ trigger_files = [
[autolabel."PG-exploit-mitigations"]
trigger_files = [
"compiler/rustc_symbol_mangling/src/typeid",
"compiler/rustc_sanitizers",
"src/doc/rustc/src/exploit-mitigations.md",
"src/doc/unstable-book/src/compiler-flags/branch-protection.md",
"src/doc/unstable-book/src/compiler-flags/cf-protection.md",
@ -701,7 +701,7 @@ cc = ["@nnethercote"]
message = "Changes to the size of AST and/or HIR nodes."
cc = ["@nnethercote"]
[mentions."compiler/rustc_symbol_mangling/src/typeid"]
[mentions."compiler/rustc_sanitizers"]
cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"]
[mentions."src/doc/rustc/src/exploit-mitigations.md"]