Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deref impl typedef #68093

Merged
merged 9 commits into from
Jan 18, 2020
Merged

Conversation

GuillaumeGomez
Copy link
Member

Fixes #35295.

r? @kinnison

@dns2utf8
Copy link
Contributor

I like that the unwraps have transitioned to expects.

@JohnTitor JohnTitor added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2020
@GuillaumeGomez
Copy link
Member Author

@dns2utf8 This is a side-effect of my debugging (and I hate unwrap).

Copy link
Member

@ollie27 ollie27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now only including impls for the inner item_type but we actually need the impls for the typedef itself as well. Take for example:

pub struct FooA;
pub type FooB = FooA;
pub type FooC = FooB;

impl FooA {
    pub fn foo_a(&self) {}
}

impl FooB {
    pub fn foo_b(&self) {}
}

impl FooC {
    pub fn foo_c(&self) {}
}

pub struct Bar;
impl std::ops::Deref for Bar {
    type Target = FooC;
    fn deref(&self) -> &Self::Target { unimplemented!() }
}

Currently the docs for Bar show only method foo_c but with this PR it shows only foo_a but what we really need is all of foo_a, foo_b and foo_c to be included.

I'm not sure of the best way to do that but maybe Typedef could contain a Vec<Type> or Vec<DefId> containing each inner type rather than just a single Option<Type>.

if item.name.is_none() {
// this is most likely from a typedef
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change for? I can't see anything in this PR that would require this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed anymore, indeed! It was part of my debugging.

crate_paths.push((short, fqp.last().expect("no fqp").clone()));
} else {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, what is this change for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@GuillaumeGomez
Copy link
Member Author

@ollie27 This is a great point: I didn't think about checking the type alias itself for implementations. I'll need to update the PR to extend it a bit.

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also appreciate the .unwrap() -> .expect("...") changes, and other than wondering about the same points as Ollie did in cache.rs I think this is looking quite OK.

I wonder if, in the process of removing that additional debugging code you might fold the formatting fixes into the requisite commits though, to keep the history a bit cleaner?

@kinnison kinnison added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 14, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-15T14:09:50.6790543Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-15T14:09:50.7142443Z ##[command]git config gc.auto 0
2020-01-15T14:09:50.7227410Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-15T14:09:50.7292201Z ##[command]git config --get-all http.proxy
2020-01-15T14:09:50.7444617Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68093/merge:refs/remotes/pull/68093/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GuillaumeGomez
Copy link
Member Author

With the last changes:

Screenshot from 2020-01-15 18-14-32

So we currently have foo_a and foo_c but foo_b is missing. More to come soon I guess. :)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-15T17:53:21.1555209Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-15T17:53:21.2445285Z ##[command]git config gc.auto 0
2020-01-15T17:53:21.2523198Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-15T17:53:21.2588118Z ##[command]git config --get-all http.proxy
2020-01-15T17:53:21.2732925Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68093/merge:refs/remotes/pull/68093/merge
---
2020-01-15T18:48:34.0970427Z .................................................................................................... 1600/9520
2020-01-15T18:48:39.2033897Z .................................................................................................... 1700/9520
2020-01-15T18:48:47.4705723Z .................................................................................................... 1800/9520
2020-01-15T18:48:56.4937146Z .........i.......................................................................................... 1900/9520
2020-01-15T18:49:03.2967864Z ...................................................................................................i 2000/9520
2020-01-15T18:49:19.2102210Z iiii................................................................................................ 2100/9520
2020-01-15T18:49:27.5036257Z .................................................................................................... 2300/9520
2020-01-15T18:49:29.9825043Z .................................................................................................... 2400/9520
2020-01-15T18:49:35.9378351Z .................................................................................................... 2500/9520
2020-01-15T18:49:56.0176820Z .................................................................................................... 2600/9520
---
2020-01-15T18:52:33.2918741Z ..........................................i...............i......................................... 4900/9520
2020-01-15T18:52:42.1634729Z .................................................................................................... 5000/9520
2020-01-15T18:52:48.6288233Z .....................................................................................i.............. 5100/9520
2020-01-15T18:52:53.9201246Z .................................................................................................... 5200/9520
2020-01-15T18:53:04.0905317Z ........................................................ii.ii...........i........................... 5300/9520
2020-01-15T18:53:13.0852361Z .................................................................................................... 5500/9520
2020-01-15T18:53:23.0556524Z .................................................................................................... 5600/9520
2020-01-15T18:53:29.3802791Z .........................................i.......................................................... 5700/9520
2020-01-15T18:53:35.9257371Z .................................................................................................... 5800/9520
2020-01-15T18:53:35.9257371Z .................................................................................................... 5800/9520
2020-01-15T18:53:46.3254840Z .................................................................................................... 5900/9520
2020-01-15T18:53:55.9902116Z ................................ii...i..ii...........i.............................................. 6000/9520
2020-01-15T18:54:13.9450343Z .................................................................................................... 6200/9520
2020-01-15T18:54:21.8211028Z .................................................................................................... 6300/9520
2020-01-15T18:54:21.8211028Z .................................................................................................... 6300/9520
2020-01-15T18:54:34.1893179Z ............................................................i..ii................................... 6400/9520
2020-01-15T18:55:02.5475062Z .................................................................................................... 6600/9520
2020-01-15T18:55:04.7360151Z ....................................i............................................................... 6700/9520
2020-01-15T18:55:06.9532882Z .................................................................................................... 6800/9520
2020-01-15T18:55:09.4591852Z ....................................i............................................................... 6900/9520
---
2020-01-15T18:56:47.0918747Z .................................................................................................... 7500/9520
2020-01-15T18:56:51.5447789Z .................................................................................................... 7600/9520
2020-01-15T18:56:57.6331184Z .................................................................................................... 7700/9520
2020-01-15T18:57:04.9167792Z .................................................................................................... 7800/9520
2020-01-15T18:57:14.8690676Z .....................................................................................iiii........... 7900/9520
2020-01-15T18:57:31.5200738Z ...................i......i......................................................................... 8100/9520
2020-01-15T18:57:36.7218612Z .................................................................................................... 8200/9520
2020-01-15T18:57:49.9478956Z .................................................................................................... 8300/9520
2020-01-15T18:57:59.9424802Z .................................................................................................... 8400/9520
---
2020-01-15T19:00:24.9783606Z  finished in 7.005
2020-01-15T19:00:24.9982900Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-15T19:00:25.1988413Z 
2020-01-15T19:00:25.1988657Z running 166 tests
2020-01-15T19:00:28.1448077Z iiii......i........ii..iiii...i....i...........i............i..i..................i....i............ 100/166
2020-01-15T19:00:30.3417509Z i.i.i...iii..iiiiiii.......................iii............ii......
2020-01-15T19:00:30.3418157Z 
2020-01-15T19:00:30.3419972Z  finished in 5.343
2020-01-15T19:00:30.3621599Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-15T19:00:30.5300572Z 
---
2020-01-15T19:00:32.5146333Z  finished in 2.152
2020-01-15T19:00:32.5338902Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-15T19:00:32.6995428Z 
2020-01-15T19:00:32.6996296Z running 9 tests
2020-01-15T19:00:32.6997362Z iiiiiiiii
2020-01-15T19:00:32.6997742Z 
2020-01-15T19:00:32.7002510Z  finished in 0.166
2020-01-15T19:00:32.7195190Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-15T19:00:32.9110107Z 
---
2020-01-15T19:00:52.3069143Z  finished in 19.587
2020-01-15T19:00:52.3333328Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-15T19:00:52.5178647Z 
2020-01-15T19:00:52.5179164Z running 116 tests
2020-01-15T19:01:17.3540878Z .iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii..........i.....i..i.......ii.i.ii 100/116
2020-01-15T19:01:20.7415196Z .....iiii.....ii
2020-01-15T19:01:20.7415679Z 
2020-01-15T19:01:20.7417316Z  finished in 28.409
2020-01-15T19:01:20.7424944Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-15T19:01:20.7425304Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-01-15T19:14:23.4272783Z 
2020-01-15T19:14:23.4273640Z    Doc-tests core
2020-01-15T19:14:27.9942496Z 
2020-01-15T19:14:27.9943505Z running 2442 tests
2020-01-15T19:14:37.1454222Z ......iiiii......................................................................................... 100/2442
2020-01-15T19:14:46.0202822Z ..................................................................................ii................ 200/2442
2020-01-15T19:15:06.8598827Z ................i................................................................................... 400/2442
2020-01-15T19:15:06.8598827Z ................i................................................................................... 400/2442
2020-01-15T19:15:16.4801520Z .................................................................i..i..................iiii......... 500/2442
2020-01-15T19:15:32.6937917Z .................................................................................................... 700/2442
2020-01-15T19:15:41.1117111Z .................................................................................................... 800/2442
2020-01-15T19:15:49.5468076Z .................................................................................................... 900/2442
2020-01-15T19:15:57.9040057Z .................................................................................................... 1000/2442
---
2020-01-15T19:19:31.5012323Z 
2020-01-15T19:19:31.5012564Z running 1003 tests
2020-01-15T19:19:50.4061259Z i................................................................................................... 100/1003
2020-01-15T19:20:00.7968061Z .................................................................................................... 200/1003
2020-01-15T19:20:08.1643627Z ..................iii......i......i...i......i...................................................... 300/1003
2020-01-15T19:20:13.3676801Z .................................................................................................... 400/1003
2020-01-15T19:20:20.3399270Z ..........................................i..i.....................................ii............... 500/1003
2020-01-15T19:20:34.0067270Z .................................................................................................... 700/1003
2020-01-15T19:20:34.0067270Z .................................................................................................... 700/1003
2020-01-15T19:20:39.7674439Z .............................iiii................................................................... 800/1003
2020-01-15T19:20:53.9184382Z .................................................................................................... 900/1003
2020-01-15T19:21:00.9216045Z ...................................................iiii............................................. 1000/1003
2020-01-15T19:21:01.0232770Z test result: ok. 983 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-01-15T19:21:01.0232810Z 
2020-01-15T19:21:01.0308408Z  finished in 171.559
2020-01-15T19:21:02.0128003Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-01-15T19:38:21.4076022Z Rustbook (x86_64-unknown-linux-gnu) - edition-guide
2020-01-15T19:38:21.8144482Z Building stage0 tool linkchecker (x86_64-unknown-linux-gnu)
2020-01-15T19:38:21.9706089Z    Compiling linkchecker v0.1.0 (/checkout/src/tools/linkchecker)
2020-01-15T19:38:23.4112460Z     Finished release [optimized] target(s) in 1.59s
2020-01-15T19:38:23.4379581Z core/ffi/struct.VaList.html:9: id is not unique: `deref-methods`
2020-01-15T19:38:25.9801670Z std/ffi/struct.CString.html:327: id is not unique: `deref-methods`
2020-01-15T19:38:26.0187065Z std/ffi/struct.OsString.html:258: id is not unique: `deref-methods`
2020-01-15T19:38:26.0308603Z std/ffi/struct.VaList.html:9: id is not unique: `deref-methods`
2020-01-15T19:38:28.6811971Z std/path/struct.PathBuf.html:515: id is not unique: `deref-methods`
2020-01-15T19:38:31.2635301Z thread 'main' panicked at 'found some broken links', src/tools/linkchecker/main.rs:43:9
2020-01-15T19:38:31.2674545Z 
2020-01-15T19:38:31.2675171Z 
2020-01-15T19:38:31.2676199Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/linkchecker" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/linkchecker" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc"
2020-01-15T19:38:31.2676755Z expected success, got: exit code: 101
---
2020-01-15T19:38:31.2756184Z   local time: Wed Jan 15 19:38:31 UTC 2020
2020-01-15T19:38:31.5460420Z   network time: Wed, 15 Jan 2020 19:38:31 GMT
2020-01-15T19:38:31.5464037Z == end clock drift check ==
2020-01-15T19:38:33.4930786Z 
2020-01-15T19:38:33.5040550Z ##[error]Bash exited with code '1'.
2020-01-15T19:38:33.5072163Z ##[section]Starting: Checkout
2020-01-15T19:38:33.5074086Z ==============================================================================
2020-01-15T19:38:33.5074141Z Task         : Get sources
2020-01-15T19:38:33.5074189Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GuillaumeGomez
Copy link
Member Author

Ok, fixed all the issues encountered. It now returns all implementations made on the type aliases.

Some(DefKind::TyAlias) => Some(cx.tcx.type_of(did).clean(cx)),
_ => None,
});
if let Some(type_alias) = type_alias {
Copy link
Contributor

@oli-obk oli-obk Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try deduplicating the ret.push with the one afterwards? Maybe for for_ in type_alias.into_iter().chain(self.for_.clean(cx)) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do it this way, we'll have to clone trait_ and items one extra time. I'll write something else instead to avoid the duplication of code.

@GuillaumeGomez
Copy link
Member Author

Updated!

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-16T20:37:35.9563445Z ========================== Starting Command Output ===========================
2020-01-16T20:37:35.9565010Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/fe1d4e29-afd8-4a4e-bc4f-f5e8fa2bb6bf.sh
2020-01-16T20:37:35.9565045Z 
2020-01-16T20:37:35.9567914Z ##[section]Finishing: Disable git automatic line ending conversion
2020-01-16T20:37:35.9574433Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68093/merge to s
2020-01-16T20:37:35.9576263Z Task         : Get sources
2020-01-16T20:37:35.9576295Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-16T20:37:35.9576378Z Version      : 1.0.0
2020-01-16T20:37:35.9576410Z Author       : Microsoft
---
2020-01-16T20:37:37.0180309Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-16T20:37:37.0195196Z ##[command]git config gc.auto 0
2020-01-16T20:37:37.0197842Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-16T20:37:37.0200228Z ##[command]git config --get-all http.proxy
2020-01-16T20:37:37.0207601Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68093/merge:refs/remotes/pull/68093/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GuillaumeGomez
Copy link
Member Author

Fixed formatting.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 17, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jan 17, 2020

📌 Commit 482dc77 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 17, 2020
tmandry added a commit to tmandry/rust that referenced this pull request Jan 17, 2020
tmandry added a commit to tmandry/rust that referenced this pull request Jan 18, 2020
tmandry added a commit to tmandry/rust that referenced this pull request Jan 18, 2020
bors added a commit that referenced this pull request Jan 18, 2020
Rollup of 9 pull requests

Successful merges:

 - #66660 (Don't warn about snake case for field puns.)
 - #68093 (Fix deref impl typedef)
 - #68204 (Use named fields for `{ast,hir}::ItemKind::Impl`)
 - #68256 (Do not ICE on malformed suggestion spans)
 - #68279 (Clean up E0198 explanation)
 - #68291 (Update sanitizer tests)
 - #68312 (Add regression test for integer literals in generic arguments in where clauses)
 - #68314 (Stop treating `FalseEdges` and `FalseUnwind` as having semantic value for const eval)
 - #68317 (Clean up E0199 explanation)

Failed merges:

r? @ghost
@bors bors merged commit 482dc77 into rust-lang:master Jan 18, 2020
@GuillaumeGomez GuillaumeGomez deleted the fix-deref-impl-typedef branch January 18, 2020 12:14
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustdoc doesn't follow type aliases in Deref's Target
9 participants