Git Product home page Git Product logo

Comments (10)

x4exr avatar x4exr commented on July 21, 2024

This seems low priority. I value this feature though, so I'm willing to contribute to fixing this my self. But Id like pointers in knowing where to find the code relating to printing out file links. Like which repository.

from rust.

workingjubilee avatar workingjubilee commented on July 21, 2024

This seems low priority. I value this feature though, so I'm willing to contribute to fixing this my self. But Id like pointers in knowing where to find the code relating to printing out file links. Like which repository.

uh, rust-lang/rust?

from rust.

workingjubilee avatar workingjubilee commented on July 21, 2024

aiui doctests are actually extracted into a new file by librustdoc and then compiled, with no awareness of what their line/column was in the original file and thus no ability to offset them. you would have to probably poke at https://github.com/rust-lang/rust/blob/aec67e238d366c4c41373b272f19dd79ff5ec0f0/src/librustdoc/doctest.rs at minimum to address this.

( initially also said https://github.com/rust-lang/rust/blob/aec67e238d366c4c41373b272f19dd79ff5ec0f0/compiler/rustc_builtin_macros/src/source_util.rs but I think that's a red herring, now that I've reviewed the relevant assert! code. )

from rust.

tbu- avatar tbu- commented on July 21, 2024

Related:

from rust.

x4exr avatar x4exr commented on July 21, 2024

By offset I meant I could probably first figure out what line the doctest itself is in the source file, then take that line number and add to what ever the current runner outputs. Seems simple enough? Or are there other things I need to worry about. My IDE seems to be able to figure out where a doctest lies (RustRover) assuming it is using some rust compiler API.

from rust.

workingjubilee avatar workingjubilee commented on July 21, 2024

By offset I meant I could probably first figure out what line the doctest itself is in the source file, then take that line number and add to what ever the current runner outputs. Seems simple enough?

The output is from the assert inside the compiled binary.

from rust.

workingjubilee avatar workingjubilee commented on July 21, 2024

The runner doesn't know anything, it is only repeating this from the binary:

#[stable(feature = "panic_hook_display", since = "1.26.0")]
impl fmt::Display for PanicInfo<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("panicked at ")?;
self.location.fmt(formatter)?;
formatter.write_str(":\n")?;
formatter.write_fmt(self.message)?;
Ok(())
}
}

It gets the location from here:

pub const fn caller() -> &'static Location<'static> {
crate::intrinsics::caller_location()
}

This is generated by compiler magic, about... here?

pub fn caller_location_ty(self) -> Ty<'tcx> {

But I believe the interesting code that actually determines the spans to output is here:

pub fn caller_location_span<T>(

Ideally we'd somehow convince rustdoc to use the original source spans while compiling this.

from rust.

workingjubilee avatar workingjubilee commented on July 21, 2024

oh, goofier solution:

during extraction, insert sufficient newlines.

from rust.

x4exr avatar x4exr commented on July 21, 2024

That seems be a good idea

from rust.

tbu- avatar tbu- commented on July 21, 2024

oh, goofier solution:

during extraction, insert sufficient newlines.

Might not work if the test is sufficiently close to the top of the file, I think.

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.