Rollup merge of #100350 - jhpratt:stringify-vis, r=cjgillot
Stringify non-shorthand visibility correctly This makes `stringify!(pub(in crate))` evaluate to `pub(in crate)` rather than `pub(crate)`, matching the behavior before the `crate` shorthand was removed. Further, this changes `stringify!(pub(in super))` to evaluate to `pub(in super)` rather than the current `pub(super)`. If the latter is not desired (it is _technically_ breaking), it can be undone. Fixes #99981 `@rustbot` label +C-bug +regression-from-stable-to-beta +T-compiler
This commit is contained in:
commit
6ae0414122
6 changed files with 18 additions and 9 deletions
|
@ -412,9 +412,9 @@ impl<'a> State<'a> {
|
|||
pub(crate) fn print_visibility(&mut self, vis: &ast::Visibility) {
|
||||
match vis.kind {
|
||||
ast::VisibilityKind::Public => self.word_nbsp("pub"),
|
||||
ast::VisibilityKind::Restricted { ref path, .. } => {
|
||||
ast::VisibilityKind::Restricted { ref path, id: _, shorthand } => {
|
||||
let path = Self::to_string(|s| s.print_path(path, false, 0));
|
||||
if path == "crate" || path == "self" || path == "super" {
|
||||
if shorthand && (path == "crate" || path == "self" || path == "super") {
|
||||
self.word_nbsp(format!("pub({})", path))
|
||||
} else {
|
||||
self.word_nbsp(format!("pub(in {})", path))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue