Refactor crate name handling; pass a TyCtxt into macro expansion#155844
Refactor crate name handling; pass a TyCtxt into macro expansion#155844jyn514 wants to merge 13 commits intorust-lang:mainfrom
Conversation
|
r? @eholk rustbot has assigned @eholk. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
This comment has been minimized.
This comment has been minimized.
This caught several bugs.
Using it is almost always a mistake. Get rid of the temptation. Rustdoc has to keep using it because it doesn't have a real crate name when parsing markdown files.
a3fd25e to
8cbe665
Compare
| let exe_path = tcx.output_filenames(()).path(OutputType::Exe); | ||
| let exe_stem = exe_path.filestem().unwrap().to_string_lossy(); | ||
| config.args.insert(0, exe_stem.to_string()); |
There was a problem hiding this comment.
@saethlin already approved these changes in #153924 (comment).
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
No complaints from me, but one question about the motivation. #153924 said:
Some of the early commits (involving |
Modified version of #153924 that doesn't try to change any dataflow, just clarify the existing behavior.
crate_namecleanups #155835, which has already been approved.TyCtxtinto macro expansion, and make some easy cleanups that are possible as a result. b84658a should be the only commit that changes behavior (in diagnostics), I kept it intentionally small.CrateNamestruct that documents the difference between the filestem and crate name. Previously the compiler confused the two (unsure if this was intentional, the code was quite complicated). I have preserved the behavior even though I'm not sure it's correct; a bunch of run-make tests depend on it.opts.crate_nameand mops up a last couple places that shouldn't have been using it.filestem()instead ofCrateName.I promise that I tried very hard not to change any behavior in this PR. Here is a transcript of some existing behavior on nightly: