mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-11 11:36:49 +00:00
fix cycle error for "use constructor" suggestion
This commit is contained in:
parent
274674819c
commit
339fa311ad
@ -1755,11 +1755,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
|||||||
.filter_map(|item| {
|
.filter_map(|item| {
|
||||||
// Only assoc fns that return `Self`
|
// Only assoc fns that return `Self`
|
||||||
let fn_sig = self.r.tcx.fn_sig(item.def_id).skip_binder();
|
let fn_sig = self.r.tcx.fn_sig(item.def_id).skip_binder();
|
||||||
let ret_ty = fn_sig.output();
|
// Don't normalize the return type, because that can cause cycle errors.
|
||||||
let ret_ty = self
|
let ret_ty = fn_sig.output().skip_binder();
|
||||||
.r
|
|
||||||
.tcx
|
|
||||||
.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), ret_ty);
|
|
||||||
let ty::Adt(def, _args) = ret_ty.kind() else {
|
let ty::Adt(def, _args) = ret_ty.kind() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// aux-build:suggest-constructor-cycle-error.rs
|
// aux-build:suggest-constructor-cycle-error.rs
|
||||||
//~^ cycle detected when getting the resolver for lowering [E0391]
|
|
||||||
|
|
||||||
// Regression test for https://github.com/rust-lang/rust/issues/119625
|
// Regression test for https://github.com/rust-lang/rust/issues/119625
|
||||||
|
|
||||||
extern crate suggest_constructor_cycle_error as a;
|
extern crate suggest_constructor_cycle_error as a;
|
||||||
|
|
||||||
const CONST_NAME: a::Uuid = a::Uuid(());
|
const CONST_NAME: a::Uuid = a::Uuid(());
|
||||||
|
//~^ ERROR: cannot initialize a tuple struct which contains private fields [E0423]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
error[E0391]: cycle detected when getting the resolver for lowering
|
error[E0423]: cannot initialize a tuple struct which contains private fields
|
||||||
|
--> $DIR/suggest-constructor-cycle-error.rs:7:29
|
||||||
|
|
|
|
||||||
= note: ...which requires normalizing `[u8; suggest_constructor_cycle_error::::m::{impl#0}::encode_buffer::{constant#0}]`...
|
LL | const CONST_NAME: a::Uuid = a::Uuid(());
|
||||||
note: ...which requires resolving instance `suggest_constructor_cycle_error::m::Uuid::encode_buffer::{constant#0}`...
|
| ^^^^^^^
|
||||||
--> $DIR/auxiliary/suggest-constructor-cycle-error.rs:5:40
|
|
||||||
|
|
|
|
||||||
LL | pub fn encode_buffer() -> [u8; LENGTH] {
|
note: constructor is not visible here due to private fields
|
||||||
| ^^^^^^
|
--> $DIR/auxiliary/suggest-constructor-cycle-error.rs:2:21
|
||||||
= note: ...which requires calculating the lang items map...
|
|
|
||||||
= note: ...which again requires getting the resolver for lowering, completing the cycle
|
LL | pub struct Uuid(());
|
||||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
| ^^ private field
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0391`.
|
For more information about this error, try `rustc --explain E0423`.
|
||||||
|
Loading…
Reference in New Issue
Block a user