Skip to content

std::fmt future-proofing: should precision be static error for integral types? #24767

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

Closed
pnkfelix opened this issue Apr 24, 2015 · 4 comments · Fixed by #25002
Closed

std::fmt future-proofing: should precision be static error for integral types? #24767

pnkfelix opened this issue Apr 24, 2015 · 4 comments · Fixed by #25002

Comments

@pnkfelix
Copy link
Member

(spawned off of #24662)

The docs for the precision formatting parmeter http://doc.rust-lang.org/nightly/std/fmt/index.html#precision currently say:

For integral types, this has no meaning currently.

What that text apparently means today is "we silently ignore any such parameter"

The phrase "has no meaning currently" to me implies that we might add meaning in the future.

I do not even know if we could make this be a static error in a reasonable way for 1.0. But I figured I would ask the question: Should we consider trying to do so? Or should we just commit, for purposes of backwards compatibility, to this being a no-op for integral parameters?

@pnkfelix
Copy link
Member Author

nominating (for needs-decision, basically).

@sfackler
Copy link
Member

A somewhat related question would be "do we even make any back compat guarantees with respect to the output of formatters?" We obviously won't want to do anything totally crazy like making the default output format for integers hex, but will/should anyone care if we do start using the precision parameter in the future?

As one example, the Debug improvements RFC noted using the precision or width formatter to specify the indentation size in multi-line output as a possible future extension.

@pnkfelix
Copy link
Member Author

I think someone using format! to generate output that is intended to be read by other tools would very much care if we were to silently change the behavior of the precision parameter for the Display trait. It seems like it could be a very nasty bug for someone to track down from one Rust release to the next.

(That's essentially why I'm suggesting we consider trying to catch no-op cases like this today.)

(I also think that we would be within our rights to arbitrarily change the output behavior for the Debug trait.)

@pnkfelix
Copy link
Member Author

Consensus is to just say "is ignored for integral types", i.e. get rid of the word "currently" that implies it may change in the future.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 30, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue May 1, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue May 1, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue May 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants