rustc_typeck: correctly compute Substs for Res::SelfCtor.#61896
rustc_typeck: correctly compute Substs for Res::SelfCtor.#61896bors merged 1 commit intorust-lang:masterfrom
Substs for Res::SelfCtor.#61896Conversation
src/test/ui/issues/issue-61882.rs
Outdated
There was a problem hiding this comment.
Would be good to add the const B: Self = Self(0); case also for some redundancy?
I don't know what an interesting test for A<&'static T> would be... I have:
impl A<&'static u8> {
fn f() -> Self {
let x = 0;
Self(&x)
}
}it fails with "cannot return value referencing local variable x".
There was a problem hiding this comment.
You can't return it. Try Self(&x); - that should still error, even if you're not returning it.
There was a problem hiding this comment.
Ah good call; it doesn't error:
struct A<T>(T);
impl A<&'static u8> {
fn f() {
let x = 0;
Self(&x);
}
}so you can add that to the test file.
There was a problem hiding this comment.
Decided to check your branch out to help speed things up... but Self(&x); for impl A<&'static u8> { still does not error.
There was a problem hiding this comment.
It does error, but it needs to be in a separate test because it doesn't borrow-check A::f if A::B doesn't type-check (we should probably remove this limitation and keep going? cc @estebank)
|
r=me with tests requested by Centril |
|
@bors r=petrochenkov |
|
📌 Commit dedf2ed has been approved by |
…nkov rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`. Fixes rust-lang#61882. r? @petrochenkov cc @varkor
…nkov rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`. Fixes rust-lang#61882. r? @petrochenkov cc @varkor
Rollup of 11 pull requests Successful merges: - #61505 (Only show methods that appear in `impl` blocks in the Implementors sections of trait doc pages) - #61701 (move stray run-pass const tests into const/ folder) - #61748 (Tweak transparent enums and unions diagnostic spans) - #61802 (Make MaybeUninit #[repr(transparent)]) - #61839 (ci: Add a script for generating CPU usage graphs) - #61842 (Remove unnecessary lift calls) - #61843 (Turn down the myriad-closures test) - #61896 (rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`.) - #61898 (syntax: Factor out common fields from `SyntaxExtension` variants) - #61938 (create an issue for miri even in status test-fail) - #61941 (Preserve generator and yield source for error messages) Failed merges: r? @ghost
Rollup of 11 pull requests Successful merges: - #61505 (Only show methods that appear in `impl` blocks in the Implementors sections of trait doc pages) - #61701 (move stray run-pass const tests into const/ folder) - #61748 (Tweak transparent enums and unions diagnostic spans) - #61802 (Make MaybeUninit #[repr(transparent)]) - #61839 (ci: Add a script for generating CPU usage graphs) - #61842 (Remove unnecessary lift calls) - #61843 (Turn down the myriad-closures test) - #61896 (rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`.) - #61898 (syntax: Factor out common fields from `SyntaxExtension` variants) - #61938 (create an issue for miri even in status test-fail) - #61941 (Preserve generator and yield source for error messages) Failed merges: r? @ghost
Rollup of 11 pull requests Successful merges: - #61505 (Only show methods that appear in `impl` blocks in the Implementors sections of trait doc pages) - #61701 (move stray run-pass const tests into const/ folder) - #61748 (Tweak transparent enums and unions diagnostic spans) - #61802 (Make MaybeUninit #[repr(transparent)]) - #61839 (ci: Add a script for generating CPU usage graphs) - #61842 (Remove unnecessary lift calls) - #61843 (Turn down the myriad-closures test) - #61896 (rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`.) - #61898 (syntax: Factor out common fields from `SyntaxExtension` variants) - #61938 (create an issue for miri even in status test-fail) - #61941 (Preserve generator and yield source for error messages) Failed merges: r? @ghost
|
discussed at T-compiler meeting. accepting for beta-backport. |
|
@eddyb there are conflicts applying this to the beta branch. Is this partial diff for @@ -5255,12 +5209,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let tcx = self.tcx;
- let res = match self.rewrite_self_ctor(res, span) {
- Ok(res) => res,
- Err(ErrorReported) => return (tcx.types.err, res),
- };
let path_segs = match res {
- Res::Local(_) | Res::Upvar(..) => Vec::new(),
+ Res::Local(_) | Res::Upvar(..) | Res::SelfCtor(_) => vec![],
Res::Def(kind, def_id) =>
AstConv::def_ids_for_value_path_segments(self, segments, self_ty, kind, def_id),
_ => bug!("instantiate_value_path on {:?}", res),
|
|
@pietroalbini Yes, that seems correct. I could take a look at a backported PR, or open a backport PR myself if you prefer that. |
[beta] Rollup backports Rolled up: * [beta] Comment out dev key #61700 Cherry picked: * Dont ICE on an attempt to use GAT without feature gate #61118 * Fix cfg(test) build for x86_64-fortanix-unknown-sgx #61503 * Handle index out of bound errors during const eval without panic #61598 * Hygienize macros in the standard library #61629 * Fix ICE involving mut references #61947 * rustc_typeck: correctly compute `Substs` for `Res::SelfCtor`. #61896 * Revert "Set test flag when rustdoc is running with --test option" #61199 * create a "provisional cache" to restore performance in the case of cycles #61754 r? @ghost
Fixes #61882.
r? @petrochenkov cc @varkor