Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c601585
rustdoc: move notable trait tests into their own directory
notriddle Mar 9, 2023
ee6b228
rustdoc: handle generics better when matching notable traits
notriddle Mar 9, 2023
86179c4
rustdoc: rename `Type::is_same` to `is_doc_subtype_of`
notriddle Mar 13, 2023
bfb66eb
rustdoc: fix comments in test
notriddle Mar 14, 2023
7f76084
Add clarifying comments
notriddle Mar 17, 2023
c9ddb73
refactor: refactor identifier parsing somewhat
Ezrashaw Mar 17, 2023
b4e17a5
refactor: improve "ident starts with number" error
Ezrashaw Mar 17, 2023
4da7970
Update stdarch
Noratrieb Mar 19, 2023
43008ce
Add `#![feature(generic_arg_infer)]` to core for stdarch
Noratrieb Mar 19, 2023
20dc532
Remove Ty::is_region_ptr
mu001999 Mar 20, 2023
05b5046
feat: implement error recovery in `expected_ident_found`
Ezrashaw Mar 17, 2023
460ecd2
Eagerly intern and check CrateNum/StableCrateId collisions
oli-obk Mar 16, 2023
47f24a8
new solver cleanup + coherence
lcnr Mar 21, 2023
938434a
enable `intercrate` in the solver `InferCtxt`
lcnr Mar 21, 2023
a7ec045
disable global caching during coherence
lcnr Mar 21, 2023
f86b035
woops
lcnr Mar 21, 2023
293f21c
iat selection: erase regions in self type
fmease Mar 21, 2023
67a2c5b
rustc: Remove unused `Session` argument from some attribute functions
petrochenkov Mar 19, 2023
1581b97
make link clickable
Mar 22, 2023
0392e29
Rollup merge of #108954 - notriddle:notriddle/notable-trait-generic, …
matthiaskrgr Mar 22, 2023
34fa6da
Rollup merge of #109203 - Ezrashaw:refactor-ident-parsing, r=Nilstrieb
matthiaskrgr Mar 22, 2023
950aa3e
Rollup merge of #109213 - oli-obk:cstore, r=cjgillot
matthiaskrgr Mar 22, 2023
577d85f
Rollup merge of #109358 - petrochenkov:nosess, r=cjgillot
matthiaskrgr Mar 22, 2023
29d04ff
Rollup merge of #109359 - Nilstrieb:bump-stdarch, r=Amanieu
matthiaskrgr Mar 22, 2023
2ee07a1
Rollup merge of #109378 - MU001999:master, r=scottmcm
matthiaskrgr Mar 22, 2023
b22db3f
Rollup merge of #109423 - fmease:iat-selection-erase-regions-in-self-…
matthiaskrgr Mar 22, 2023
28b9354
Rollup merge of #109447 - lcnr:coherence, r=compiler-errors
matthiaskrgr Mar 22, 2023
783f3a1
Rollup merge of #109501 - lukas-code:link, r=WaffleLapkin
matthiaskrgr Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 51 additions & 31 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::ObligationCause;
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
use rustc_middle::middle::stability::AllowUnstable;
use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef};
use rustc_middle::ty::DynKind;
use rustc_middle::ty::GenericParamDefKind;
Expand Down Expand Up @@ -2225,47 +2226,66 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {

let param_env = tcx.param_env(block.owner.to_def_id());
let cause = ObligationCause::misc(span, block.owner.def_id);

let mut fulfillment_errors = Vec::new();
let mut applicable_candidates: Vec<_> = candidates
.iter()
.filter_map(|&(impl_, (assoc_item, def_scope))| {
infcx.probe(|_| {
let ocx = ObligationCtxt::new_in_snapshot(&infcx);
let mut applicable_candidates: Vec<_> = infcx.probe(|_| {
let universe = infcx.create_next_universe();

// Regions are not considered during selection.
let self_ty = tcx.replace_escaping_bound_vars_uncached(
self_ty,
FnMutDelegate {
regions: &mut |_| tcx.lifetimes.re_erased,
types: &mut |bv| {
tcx.mk_placeholder(ty::PlaceholderType { universe, name: bv.kind })
},
consts: &mut |bv, ty| {
tcx.mk_const(ty::PlaceholderConst { universe, name: bv }, ty)
},
},
);

let impl_ty = tcx.type_of(impl_);
let impl_substs = infcx.fresh_item_substs(impl_);
let impl_ty = impl_ty.subst(tcx, impl_substs);
let impl_ty = ocx.normalize(&cause, param_env, impl_ty);
candidates
.iter()
.filter_map(|&(impl_, (assoc_item, def_scope))| {
infcx.probe(|_| {
let ocx = ObligationCtxt::new_in_snapshot(&infcx);

// Check that the Self-types can be related.
// FIXME(fmease): Should we use `eq` here?
ocx.sup(&ObligationCause::dummy(), param_env, impl_ty, self_ty).ok()?;
let impl_ty = tcx.type_of(impl_);
let impl_substs = infcx.fresh_item_substs(impl_);
let impl_ty = impl_ty.subst(tcx, impl_substs);
let impl_ty = ocx.normalize(&cause, param_env, impl_ty);

// Check whether the impl imposes obligations we have to worry about.
let impl_bounds = tcx.predicates_of(impl_);
let impl_bounds = impl_bounds.instantiate(tcx, impl_substs);
// Check that the Self-types can be related.
// FIXME(fmease): Should we use `eq` here?
ocx.sup(&ObligationCause::dummy(), param_env, impl_ty, self_ty).ok()?;

let impl_bounds = ocx.normalize(&cause, param_env, impl_bounds);
// Check whether the impl imposes obligations we have to worry about.
let impl_bounds = tcx.predicates_of(impl_);
let impl_bounds = impl_bounds.instantiate(tcx, impl_substs);

let impl_obligations = traits::predicates_for_generics(
|_, _| cause.clone(),
param_env,
impl_bounds,
);
let impl_bounds = ocx.normalize(&cause, param_env, impl_bounds);

ocx.register_obligations(impl_obligations);
let impl_obligations = traits::predicates_for_generics(
|_, _| cause.clone(),
param_env,
impl_bounds,
);

let mut errors = ocx.select_where_possible();
if !errors.is_empty() {
fulfillment_errors.append(&mut errors);
return None;
}
ocx.register_obligations(impl_obligations);

let mut errors = ocx.select_where_possible();
if !errors.is_empty() {
fulfillment_errors.append(&mut errors);
return None;
}

// FIXME(fmease): Unsolved vars can escape this InferCtxt snapshot.
Some((assoc_item, def_scope, infcx.resolve_vars_if_possible(impl_substs)))
// FIXME(fmease): Unsolved vars can escape this InferCtxt snapshot.
Some((assoc_item, def_scope, infcx.resolve_vars_if_possible(impl_substs)))
})
})
})
.collect();
.collect()
});

if applicable_candidates.len() > 1 {
return Err(self.complain_about_ambiguous_inherent_assoc_type(
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/associated-inherent-types/issue-109299-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(inherent_associated_types, non_lifetime_binders, type_alias_impl_trait)]
#![allow(incomplete_features)]

struct Lexer<T>(T);

impl Lexer<i32> {
type Cursor = ();
}

type X = impl for<T> Fn() -> Lexer<T>::Cursor; //~ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope

fn main() {}
15 changes: 15 additions & 0 deletions tests/ui/associated-inherent-types/issue-109299-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0220]: associated type `Cursor` not found for `Lexer<T>` in the current scope
--> $DIR/issue-109299-1.rs:10:40
|
LL | struct Lexer<T>(T);
| --------------- associated item `Cursor` not found for this struct
...
LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
| ^^^^^^ associated item not found in `Lexer<T>`
|
= note: the associated type was found for
- `Lexer<i32>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0220`.
12 changes: 12 additions & 0 deletions tests/ui/associated-inherent-types/issue-109299.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

struct Lexer<'d>(&'d ());

impl Lexer<'d> { //~ ERROR use of undeclared lifetime name `'d`
type Cursor = ();
}

fn test(_: Lexer::Cursor) {}

fn main() {}
11 changes: 11 additions & 0 deletions tests/ui/associated-inherent-types/issue-109299.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0261]: use of undeclared lifetime name `'d`
--> $DIR/issue-109299.rs:6:12
|
LL | impl Lexer<'d> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'d` here: `<'d>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0261`.