profile
viewpoint

delete branch ollie27/rust

delete branch : rustbuild_rustdoc-js

delete time in 3 days

delete branch ollie27/rust

delete branch : skip_nth_last

delete time in 7 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,+}++fn limit_filename_len(filename: String) -> String {+    let nb_chars = filename.chars().count();+    if nb_chars > 35 {+        "...".to_string()+            + &filename[filename.char_indices().nth(nb_chars - 32).map(|x| x.0).unwrap_or(0)..]+    } else {+        filename+    }+}++#[derive(Serialize)]+struct CoverageCalculatorEntry {+    documented: u64,+    total: u64,+    percentage: f64, }  impl CoverageCalculator {+    fn new(output_format: Option<OutputFormat>) -> CoverageCalculator {+        CoverageCalculator { items: Default::default(), output_format }+    }++    fn to_json(&self) -> String {

It would be cleaner to implement Serialize for CoverageCalculator directly.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,+}++fn limit_filename_len(filename: String) -> String {+    let nb_chars = filename.chars().count();+    if nb_chars > 35 {+        "...".to_string()+            + &filename[filename.char_indices().nth(nb_chars - 32).map(|x| x.0).unwrap_or(0)..]+    } else {+        filename+    }+}++#[derive(Serialize)]+struct CoverageCalculatorEntry {+    documented: u64,+    total: u64,+    percentage: f64, }  impl CoverageCalculator {+    fn new(output_format: Option<OutputFormat>) -> CoverageCalculator {+        CoverageCalculator { items: Default::default(), output_format }+    }++    fn to_json(&self) -> String {+        let mut total = ItemCount::default();++        let mut json = self+            .items+            .iter()+            .filter_map(|(file, &count)| {+                count+                    .percentage()+                    .map(|percent| (limit_filename_len(file.to_string()), count, percent))+            })+            .map(|(name, count, percentage)| {+                total += count;++                (+                    name,+                    CoverageCalculatorEntry {+                        documented: count.with_docs,+                        total: count.total,+                        percentage: percentage,+                    },+                )+            })+            .collect::<BTreeMap<String, CoverageCalculatorEntry>>();+        json.insert(+            "total".to_owned(),+            CoverageCalculatorEntry {+                documented: total.with_docs,+                total: total.total,+                percentage: total.percentage().unwrap_or(0.0),+            },+        );+        serde_json::to_string_pretty(&json).expect("failed to convert JSON data to string")

If the JSON is to be consumed by some other tool then it doesn't need to be pretty printed.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,+}++fn limit_filename_len(filename: String) -> String {+    let nb_chars = filename.chars().count();+    if nb_chars > 35 {+        "...".to_string()+            + &filename[filename.char_indices().nth(nb_chars - 32).map(|x| x.0).unwrap_or(0)..]+    } else {+        filename+    }+}++#[derive(Serialize)]+struct CoverageCalculatorEntry {+    documented: u64,+    total: u64,+    percentage: f64, }  impl CoverageCalculator {+    fn new(output_format: Option<OutputFormat>) -> CoverageCalculator {+        CoverageCalculator { items: Default::default(), output_format }+    }++    fn to_json(&self) -> String {+        let mut total = ItemCount::default();++        let mut json = self+            .items+            .iter()+            .filter_map(|(file, &count)| {+                count+                    .percentage()+                    .map(|percent| (limit_filename_len(file.to_string()), count, percent))+            })+            .map(|(name, count, percentage)| {+                total += count;++                (+                    name,+                    CoverageCalculatorEntry {+                        documented: count.with_docs,+                        total: count.total,+                        percentage: percentage,+                    },+                )+            })+            .collect::<BTreeMap<String, CoverageCalculatorEntry>>();+        json.insert(+            "total".to_owned(),

As with the percentage, there's no reason to include the total in the JSON. It's just redundant information.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,+}++fn limit_filename_len(filename: String) -> String {+    let nb_chars = filename.chars().count();+    if nb_chars > 35 {+        "...".to_string()+            + &filename[filename.char_indices().nth(nb_chars - 32).map(|x| x.0).unwrap_or(0)..]+    } else {+        filename+    }+}++#[derive(Serialize)]+struct CoverageCalculatorEntry {

With the percentage removed this struct isn't needed, #[derive(Serialize)] can be added to ItemCount instead.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,+}++fn limit_filename_len(filename: String) -> String {+    let nb_chars = filename.chars().count();+    if nb_chars > 35 {+        "...".to_string()+            + &filename[filename.char_indices().nth(nb_chars - 32).map(|x| x.0).unwrap_or(0)..]+    } else {+        filename+    }+}++#[derive(Serialize)]+struct CoverageCalculatorEntry {+    documented: u64,+    total: u64,+    percentage: f64,

There's no reason to include the percentage in the JSON. Whatever is consuming the JSON can trivially calculate it if needed.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

+// compile-flags:-Z unstable-options --output-format

This test should be a rustdoc-ui test so we can check the error message.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,+}++fn limit_filename_len(filename: String) -> String {+    let nb_chars = filename.chars().count();+    if nb_chars > 35 {+        "...".to_string()+            + &filename[filename.char_indices().nth(nb_chars - 32).map(|x| x.0).unwrap_or(0)..]+    } else {+        filename+    }+}++#[derive(Serialize)]+struct CoverageCalculatorEntry {+    documented: u64,+    total: u64,+    percentage: f64, }  impl CoverageCalculator {+    fn new(output_format: Option<OutputFormat>) -> CoverageCalculator {+        CoverageCalculator { items: Default::default(), output_format }+    }++    fn to_json(&self) -> String {+        let mut total = ItemCount::default();++        let mut json = self+            .items+            .iter()+            .filter_map(|(file, &count)| {+                count+                    .percentage()+                    .map(|percent| (limit_filename_len(file.to_string()), count, percent))

The filenames shouldn't be shortened when outputting JSON.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 use crate::opts; use crate::passes::{self, Condition, DefaultPassOption}; use crate::theme; +#[derive(Clone, Copy, PartialEq, Eq, Debug)]+pub enum OutputFormat {+    Json,+    HTML,
    Html,
GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 pub struct RenderInfo {     pub deref_trait_did: Option<DefId>,     pub deref_mut_trait_did: Option<DefId>,     pub owned_box_did: Option<DefId>,+    pub output_format: Option<OutputFormat>,

I think the output_format field would fit better on DocContext than RenderInfo.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 impl ops::AddAssign for ItemCount {     } } -#[derive(Default)] struct CoverageCalculator {     items: BTreeMap<FileName, ItemCount>,+    output_format: Option<OutputFormat>,

output_format shouldn't be a field of CoverageCalculator, instead it should be passed as an argument to print_results.

GuillaumeGomez

comment created time in 8 days

Pull request review commentrust-lang/rust

--show-coverage json

 use crate::opts; use crate::passes::{self, Condition, DefaultPassOption}; use crate::theme; +#[derive(Clone, Copy, PartialEq, Eq, Debug)]+pub enum OutputFormat {+    Json,+    HTML,

This enum will need a third variant to represent the current output of --show-coverage. That way --show-coverage --output-format html will be an error.

GuillaumeGomez

comment created time in 8 days

pull request commentrust-lang/rust

Source code external url

the paths rustdoc generates are relative to the crate root (typically lib.rs) but docs.rs uses the root of the source archive

I don't see why this is an issue? We can just pass --source-root .../:crate/source instead of /:crate alone.

Well docs.rs would have to pass something like https://docs.rs/crate/lazy_static/1.4.0/source/src/, noting the src at the end which won't be the same for every crate.

rustdoc replaces .. in paths with up which doesn't work on docs.rs

I'm not sure what you mean by this, can you expand a little more?

Say you have a crate foo which contains:

#[path = "../bar.rs"]
pub mod bar;

The source file for bar.rs that rustdoc will create is src/foo/up/bar.rs.html.

I've also noticed that this PR appends the crate name to the passed in URL which again doesn't match what docs.rs would need at all.

For this to work cross crate docs.rs will have to not only pass the location of the current crate's source but also the location for all dependent crates in a similar way to --extern-html-root-url.

GuillaumeGomez

comment created time in 9 days

pull request commentrust-lang/rust

Fix running rustdoc-js test suite individually

As a bit of context, the code here was added by #49729 and I'm not sure using Option was ever correct. Also 606377740b6022664299b47c8dd8d3e65017021d looks like it fixed this same issue for rustdoc-ui.

r? @Mark-Simulacrum

ollie27

comment created time in 10 days

PR opened rust-lang/rust

Fix running rustdoc-js test suite individually

Without Compiletest.path set running x.py test src/test/rustdoc-js would run the rustdoc-js test suite with everything filtered out.

As this was the only place setting Compiletest.path to None this removes the Option wrapper as well.

+5 -5

0 comment

1 changed file

pr created time in 10 days

create barnchollie27/rust

branch : rustbuild_rustdoc-js

created branch time in 10 days

pull request commentrust-lang/rust

Keep code coloring in search results short text

To make it simple: with the current version, is this issue fixed?

No, you appear to be trying to treat a symptom rather than the cause. The issue with this PR is that plain_summary_line is no longer producing plain text but (malformed) HTML. As I've said you need to create a new function to render the HTML summaries for the search index and leave plain_summary_line alone.

GuillaumeGomez

comment created time in 10 days

pull request commentrust-lang/rust

Struct variant field search

This looks good to me.

@bors r+

GuillaumeGomez

comment created time in 10 days

pull request commentrust-lang/rust

Keep code coloring in search results short text

However, I don't think we ever use the search index content directly. Do you have a location in mind where it would be the case? Because otherwise, it'll greatly increase the search index size.

@GuillaumeGomez I don't know what you mean.

The search index summaries and the sidebar titles are generated separately. Currently they both use the plain_summary_line function. If you want to include HTML in the search index then you need to add a new function specifically for that rather than modifying plain_summary_line.

GuillaumeGomez

comment created time in 11 days

issue closedrust-lang/rust

Absolute path to *.pdb in the binary file

Can it be removed somehow?

image

closed time in 11 days

afonichev

issue commentrust-lang/rust

Absolute path to *.pdb in the binary file

The /PDBALTPATH linker argument controls this path. For example /PDBALTPATH:%_PDB% will cause only demo.pdb to be embedded in the binary.

Closing this issue as it's not really the right place to ask questions anyway.

afonichev

comment created time in 11 days

issue commentrust-lang/rust

format! allows named arguments to be referenced by position

This is pretty much a duplicate of #45256.

Amanieu

comment created time in 12 days

issue closedrust-lang/rust

Iterating through an unbounded range causes a panic

I tried this code:

fn main() {
    for i in 2147483646.. {
        println!("{}", i);
    }
}

I expected to see this happen: The numbers 2147483646 and 2147483647 should be printed, then the program should exit.

Instead, this happened: The standard library panicked.

Note that it might make sense to panic on overflow instead, but at least 2147483647 should printed first, since it's within the range of i32.

Playground

Meta

Version: stable (1.41.0), but panic also occurs on nightly (1.43.0-nightly (2020-02-10 e6ec0d125eba4074122b))

<!-- Include a backtrace in the code block by setting RUST_BACKTRACE=1 in your environment. E.g. RUST_BACKTRACE=1 cargo build. --> <details><summary>Backtrace</summary> <p>

... snip ...
  13: core::panicking::panic
             at src/libcore/panicking.rs:52
  14: <i32 as core::ops::arith::Add>::add
             at /rustc/e6ec0d125eba4074122b187032474b4174fb9d31/src/libcore/ops/arith.rs:94
  15: <i32 as core::iter::range::Step>::add_one
             at /rustc/e6ec0d125eba4074122b187032474b4174fb9d31/src/libcore/iter/range.rs:67
  16: core::iter::range::<impl core::iter::traits::iterator::Iterator for core::ops::range::RangeFrom<A>>::next
             at /rustc/e6ec0d125eba4074122b187032474b4174fb9d31/src/libcore/iter/range.rs:314
  17: playground::main
             at src/main.rs:2
... snip ...

</p> </details>

closed time in 13 days

jyn514

issue commentrust-lang/rust

Iterating through an unbounded range causes a panic

Duplicate of #25708

jyn514

comment created time in 13 days

Pull request review commentrust-lang/rust

Remove `finished` flag from `MapWhile`

 pub trait Iterator {     /// The `-3` is no longer there, because it was consumed in order to see if     /// the iteration should stop, but wasn't placed back into the iterator.     ///+    /// Note that unlike [`take_while`] this iterator is **not** fused:

I don't think this needs to be documented. The lack of a FusedIterator impl should be enough to know it's not fused. Although in general if you need a fused iterator you should just call .fuse() whether it happens to implement FusedIterator or not.

Additionally I think that the behavior after .next() has returned None should be left unspecified, unless of course there is some use case for that behavior. I'd imagine that if you need access to more elements after the predicate has returned None you'd be better off just using .map(predicate).

WaffleLapkin

comment created time in 18 days

Pull request review commentrust-lang/rust

Add primitive module to libcore

+//! This module reexports the primitive types to allow usage that is not+//! possibly shadowed by other declared types.+//!+//! This is normally only useful in macro generated code.+//!+//! An example of this is when generating a new struct and an impl for it:+//!+//! ```rust,compile_fail+//! pub struct bool;+//!+//! impl QueryId for bool {+//!     const SOME_PROPERTY: bool = true;+//! }+//!+//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; }+//! ```+//!+//! Note that the `SOME_PROPERTY` associated constant would not compile, as its+//! type `bool` refers to the struct, rather than to the primitive bool type.+//!+//! A correct implementation could look like:+//!+//! ```rust+//! # #[allow(non_camel_case_types)]+//! pub struct bool;+//!+//! impl QueryId for bool {+//!     const SOME_PROPERTY: core::primitive::bool = true;+//! }+//!+//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; }+//! ```++// NOTE: This module should not contain any type definitions, only reexports. It+// is duplicated, not reexported, in std to avoid a rustdoc bug on attempting to+// inline primitive type documentation.

This issue should have been fixed so you should be able to use pub use core::primitive; in std as normal now.

Mark-Simulacrum

comment created time in 19 days

delete branch ollie27/rust

delete branch : once_with_copy

delete time in 20 days

Pull request review commentrust-lang/rust

Simplify `Skip::nth` and `Skip::last` implementations

 where      #[inline]     fn last(mut self) -> Option<I::Item> {-        if self.n == 0 {-            self.iter.last()-        } else {-            let next = self.next();-            if next.is_some() {-                // recurse. n should be 0.-                self.last().or(next)-            } else {-                None+        if self.n > 0 {+            // nth(n) skips n+1+            if self.iter.nth(self.n - 1).is_none() {+                return None;

That would work in this case but would make the code less symmetric with the other methods of Skip which is why I didn't use ? here.

ollie27

comment created time in 21 days

issue commentrust-lang/rust

Tracking issue for core::iter::once_with()

I noticed that this iterator has been stabilized a Copy impl which I assume wasn't intentional so I've submitted #68810 to remove it.

stjepang

comment created time in 22 days

PR opened rust-lang/rust

Remove Copy impl from OnceWith

Iterators typically don't implement Copy and this shouldn't be an exception.

+1 -1

0 comment

1 changed file

pr created time in 22 days

create barnchollie27/rust

branch : once_with_copy

created branch time in 22 days

pull request commentrust-lang/rust

Rustdoc copy local img

There will need to be some way to explicitly opt-in to this feature. As it stands this could break the docs for people already using relative paths to images. Additionally missing files should be errors.

The main issue I see with this implementation is that it resolves paths to the images relative to rustdoc's current directory. Even if that were changed to be relative to the source file, it can't be rustdoc which actually loads the file because rustdoc doesn't have access to the source files of external crates so cross-crate inlining won't work.

I think this will have to be implemented similarly to #[doc(include)] where the file is loaded by rustc, something like #[doc(include_image = "../image.png")] perhaps.

GuillaumeGomez

comment created time in 23 days

pull request commentrust-lang/rust

Keep code coloring in search results short text

@bors r-

The plain_summary_line function is used for more than just the search index. For example it's used for the sidebar titles so this PR results in: image

Additionally if the summaries for the search index are be rendered to HTML then the text will need to be HTML escaped. HTML rendering should use pulldown_cmark::html::push_html because that already handles HTML escaping along with supporting more than just the <code> tag.

GuillaumeGomez

comment created time in 24 days

issue openedrust-lang/rust

Invalid "a constant with a similar name exists: `_`" suggestion when a `const _` is in scope

For example (playground):

const _: () = ();

fn main() {
    a
}

Errors with:

error[E0425]: cannot find value `a` in this scope
 --> src/main.rs:4:5
  |
1 | const _: () = ();
  | ----------------- similarly named constant `_` defined here
...
4 |     a
  |     ^ help: a constant with a similar name exists: `_`

The same also happens with use Trait as _ (playground):

pub use Iterator as _;

fn foo<T: A>(x: T) {}
error[E0405]: cannot find trait `A` in this scope
    --> src/lib.rs:3:11
     |
3    |   fn foo<T: A>(x: T) {}
     |             ^ help: a trait with a similar name exists: `_`

The diagnostics shouldn't suggest things named underscore.

created time in 25 days

delete branch ollie27/rust

delete branch : doc_alloc_playground

delete time in 25 days

PR opened rust-lang/rust

Add `#![doc(html_playground_url = ...)]` to alloc crate

This adds the Run button to code examples just like the core and std docs have.

+1 -0

0 comment

1 changed file

pr created time in a month

create barnchollie27/rust

branch : doc_alloc_playground

created branch time in a month

delete branch ollie27/rust

delete branch : rustdoc_primitive_re-export

delete time in a month

pull request commentrust-lang/rust

Set lld flavor for MSVC to link.exe

Is this going to work properly for i686-pc-windows-msvc and thumbv7a-pc-windows-msvc which both add a few more things to pre_link_args?

Zoxc

comment created time in a month

pull request commentrust-lang/rust

Fix null synthetic_implementors error

Nice, r=me once the tidy error has been fixed.

Nominating for beta backport because it looks like it's just been branched.

GuillaumeGomez

comment created time in a month

issue commentrust-lang/rust

Compile error in main code when doc-testing a crate that has the same name as a module

Yeah, actually that error does look wrong. cargo seems to pass --extern this_crate=<path to libthis_crate.rlib> to rustdoc --test which rustdoc either needs to ignore or shouldn't be passed at all.

HeroicKatora

comment created time in a month

pull request commentrust-lang/rust

rustdoc: Fix re-exporting primitive types

Considering you took some parts of my code, you could have include my commit and work from it...

Sorry about that.

ollie27

comment created time in a month

PR opened rust-lang/rust

Simplify `Skip::nth` and `Skip::last` implementations

The main improvement is to make last no longer recursive.

+7 -13

0 comment

1 changed file

pr created time in a month

create barnchollie27/rust

branch : skip_nth_last

created branch time in a month

issue openedrust-lang/rust

Javascript `TypeError: synthetic_implementors is null` error on some trait pages

For example on the nightly docs https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html:

TypeError: synthetic_implementors is null main1.42.0.js:1:34607
    register_implementors https://doc.rust-lang.org/nightly/main1.42.0.js:1
    <anonymous> https://doc.rust-lang.org/nightly/main1.42.0.js:1
    <anonymous> https://doc.rust-lang.org/nightly/main1.42.0.js:7
ReferenceError: addSearchOptions is not defined search-index1.42.0.js:7:1
    <anonymous> https://doc.rust-lang.org/nightly/search-index1.42.0.js:7

Additionally most of the documentation doesn't load (but not every time):

image

I suspect this was caused by #68192 (cc @GuillaumeGomez).

created time in a month

delete branch ollie27/rust

delete branch : rustdoc_primitive_reexport

delete time in a month

pull request commentrust-lang/rust

Fix panic when reexporting primitive type in rustdoc

I had a go at fixing this such that the re-exports show up as pub use bool; with working links: #68556

GuillaumeGomez

comment created time in a month

PR opened rust-lang/rust

rustdoc: Fix re-exporting primitive types
  • Generate links to the primitive type docs for re-exports.
  • Don't ICE on cross crate primitive type re-exports.
  • Make primitive type re-exports show up cross crate.

Fixes #67646 Closes #67972

r? @GuillaumeGomez

+91 -17

0 comment

6 changed files

pr created time in a month

create barnchollie27/rust

branch : rustdoc_primitive_re-export

created branch time in a month

create barnchollie27/rust

branch : rustdoc_primitive_reexport

created branch time in a month

push eventollie27/rust

Oliver Middleton

commit sha b6a5f5ceae6ebb5ad3b4d014490e76dd71c5eb0b

rustdoc: Fix reexporting primitive types * Generate links to the primitive docs. * Don't ICE when on cross crate primitive type reexports. * Make cross crate primitive reexports show up as reexports.

view details

push time in a month

Pull request review commentrust-lang/rust

Add `Iterator::map_while`

 where     } } +/// An iterator that only accepts elements while `predicate` returns `Some(_)`.+///+/// This `struct` is created by the [`map_while`] method on [`Iterator`]. See its+/// documentation for more.+///+/// [`map_while`]: trait.Iterator.html#method.map_while+/// [`Iterator`]: trait.Iterator.html+#[must_use = "iterators are lazy and do nothing unless consumed"]+#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]+#[derive(Clone)]+pub struct MapWhile<I, P> {+    iter: I,+    finished: bool,

It stops by having .next() return None. The finished field isn't needed to do that. After then it doesn't matter what .next() returns unless the iterator implements FusedIterator which MapWhile doesn't.

WaffleLapkin

comment created time in a month

Pull request review commentrust-lang/rust

Add `Iterator::map_while`

 where     } } +/// An iterator that only accepts elements while `predicate` returns `Some(_)`.+///+/// This `struct` is created by the [`map_while`] method on [`Iterator`]. See its+/// documentation for more.+///+/// [`map_while`]: trait.Iterator.html#method.map_while+/// [`Iterator`]: trait.Iterator.html+#[must_use = "iterators are lazy and do nothing unless consumed"]+#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]+#[derive(Clone)]+pub struct MapWhile<I, P> {+    iter: I,+    finished: bool,

Is the finished field needed? It looks like it's only used to make MapWhile fused but that seems unnecessary when you can instead just call .fuse() if needed.

WaffleLapkin

comment created time in a month

Pull request review commentrust-lang/rust

Add `Iterator::map_while`

 where     } } +/// An iterator that only accepts elements while `predicate` returns `Some(_)`.+///+/// This `struct` is created by the [`map_while`] method on [`Iterator`]. See its+/// documentation for more.+///+/// [`map_while`]: trait.Iterator.html#method.map_while+/// [`Iterator`]: trait.Iterator.html+#[must_use = "iterators are lazy and do nothing unless consumed"]+#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]+#[derive(Clone)]+pub struct MapWhile<I, P> {+    iter: I,+    finished: bool,+    predicate: P,+}++impl<I, P> MapWhile<I, P> {+    pub(super) fn new(iter: I, predicate: P) -> MapWhile<I, P> {+        MapWhile { iter, finished: false, predicate }+    }+}++#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]+impl<I: fmt::Debug, P> fmt::Debug for MapWhile<I, P> {+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+        f.debug_struct("MapWhile").field("iter", &self.iter).field("flag", &self.finished).finish()+    }+}++#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]+impl<B, I: Iterator, P> Iterator for MapWhile<I, P>+where+    P: FnMut(I::Item) -> Option<B>,+{+    type Item = B;++    #[inline]+    fn next(&mut self) -> Option<B> {+        if self.finished {+            None+        } else {+            let x = self.iter.next()?;+            let ret = (self.predicate)(x);+            self.finished = ret.is_none();+            ret+        }+    }++    #[inline]+    fn size_hint(&self) -> (usize, Option<usize>) {+        if self.finished {+            (0, Some(0))+        } else {+            let (_, upper) = self.iter.size_hint();+            (0, upper) // can't know a lower bound, due to the predicate+        }+    }++    #[inline]+    fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R+    where+        Self: Sized,+        Fold: FnMut(Acc, Self::Item) -> R,+        R: Try<Ok = Acc>,+    {+        fn check<'a, B, T, Acc, R: Try<Ok = Acc>>(+            flag: &'a mut bool,+            p: &'a mut impl FnMut(T) -> Option<B>,+            mut fold: impl FnMut(Acc, B) -> R + 'a,+        ) -> impl FnMut(Acc, T) -> LoopState<Acc, R> + 'a {+            move |acc, x| match p(x) {+                Some(item) => LoopState::from_try(fold(acc, item)),+                None => {+                    *flag = true;+                    LoopState::Break(Try::from_ok(acc))+                }+            }+        }++        if self.finished {+            Try::from_ok(init)+        } else {+            let flag = &mut self.finished;+            let p = &mut self.predicate;+            self.iter.try_fold(init, check(flag, p, fold)).into_try()+        }+    }+}+ #[stable(feature = "fused", since = "1.26.0")] impl<I, P> FusedIterator for TakeWhile<I, P>

This impl should stay next to the rest of the TakeWhile impls.

WaffleLapkin

comment created time in a month

issue commentrust-lang/rust

rustdoc only: duplicate lang item `panic_halt`

It looks like this was triggered by #66211 (cc. @kinnison). rustdoc now seems to load all crates passed by --extern even if they're unused in the code whereas rustc just ignores them. Adding extern crate panic_halt; or use panic_halt; to panic2 causes stable rustdoc and rustc to produce the same error message.

Is this issue affecting any real world code? It seems weird to list a dependency on panic-halt but not actually use it.

#66211 was to fix an ICE using the intra-doc-links feature but that's only available on nightly so it should be safe to revert #66211 on beta for now if needed.

TimNN

comment created time in a month

delete branch ollie27/rust

delete branch : skip_count

delete time in a month

issue commentrust-lang/rust

Compile error but success when doc-testing a crate that has the same name as a module

This should have been fixed recently by #68357. It errors correctly for me using rustdoc 1.42.0-nightly (41f41b235 2020-01-23). Does it still reproduce for you with the latest nightly?

HeroicKatora

comment created time in a month

Pull request review commentrust-lang/rust

Fix panic when reexporting primitive type in rustdoc

 fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)         // If we're re-exporting a re-export it may actually re-export something in         // two namespaces, so the target may be listed twice. Make sure we only         // visit each node at most once.-        for &item in cx.tcx.item_children(did).iter() {-            let def_id = item.res.def_id();-            if item.vis == ty::Visibility::Public {-                if did == def_id || !visited.insert(def_id) {-                    continue;-                }-                if let Some(i) = try_inline(cx, item.res, item.ident.name, None, visited) {-                    items.extend(i)-                }+        for &item in cx.tcx.item_children(did).iter().filter(|item| item.vis == ty::Visibility::Public) {+            let def_id = match clean::utils::res_to_def_id(cx, &item.res) {+                Some(did) => did,+                None => continue,+            };+            if did == def_id || !visited.insert(def_id) {+                continue;+            }

As the def_id is only used to avoid infinite recursion, we only really care about the def_id of modules so using mod_def_id() should be all that's needed to fix the ICE:

if let Some(def_id) = item.res.mod_def_id() {
    if did == def_id || !visited.insert(def_id) {
        continue;
    }
}
GuillaumeGomez

comment created time in a month

Pull request review commentrust-lang/rust

Fix panic when reexporting primitive type in rustdoc

 fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)         // If we're re-exporting a re-export it may actually re-export something in         // two namespaces, so the target may be listed twice. Make sure we only         // visit each node at most once.-        for &item in cx.tcx.item_children(did).iter() {-            let def_id = item.res.def_id();-            if item.vis == ty::Visibility::Public {-                if did == def_id || !visited.insert(def_id) {-                    continue;-                }-                if let Some(i) = try_inline(cx, item.res, item.ident.name, None, visited) {-                    items.extend(i)-                }+        for &item in cx.tcx.item_children(did).iter().filter(|item| item.vis == ty::Visibility::Public) {+            let def_id = match clean::utils::res_to_def_id(cx, &item.res) {+                Some(did) => did,+                None => continue,+            };+            if did == def_id || !visited.insert(def_id) {+                continue;+            }+            if let Res::PrimTy(ref primitive) = item.res {+                record_extern_fqn(cx, def_id, TypeKind::Primitive);+                cx.renderinfo.borrow_mut().inlined.insert(def_id);+                items.push(clean::Item {+                    source: cx.tcx.def_span(def_id).clean(cx),+                    name: Some(item.ident.clean(cx)),+                    attrs: cx.tcx.get_attrs(def_id).clean(cx),+                    inner: clean::ItemEnum::PrimitiveItem(clean::PrimitiveType::from(primitive)),+                    visibility: clean::Public,+                    stability: cx.tcx.lookup_stability(def_id).clean(cx),+                    deprecation: cx.tcx.lookup_deprecation(def_id).clean(cx),+                    def_id,+                });

It might be better to synthesize a clean::Import here rather than trying to directly inline primitive types.

GuillaumeGomez

comment created time in a month

pull request commentrust-lang/rust

Avoid overflow in `std::iter::Skip::count`

Won't this return a wrong value whenever self.n > 0 and self.iter.nth(self.n - 1) is a Some? Say, for (0..10).skip(3).

It looks correct to me. In that example it will call nth(2) which will return Some(2) which is the third item. At that point every item that needs to be skipped will have been skipped so count() will then return 7.

ollie27

comment created time in a month

delete branch ollie27/rust

delete branch : skip_count_overflow

delete time in a month

PR opened rust-lang/rust

Avoid overflow in `std::iter::Skip::count`

The call to count on the inner iterator can overflow even if Skip itself would return less that usize::max_value() items.

Fixes #68139

+16 -2

0 comment

2 changed files

pr created time in a month

create barnchollie27/rust

branch : skip_count

created branch time in a month

delete branch ollie27/rust

delete branch : rustdoc_lexer_panic

delete time in a month

Pull request review commentrust-lang/rust

Update RELEASES.md for 1.41.0

+Version 1.41.0 (2020-01-30)+===========================++Language+--------++- [You can now pass type parameters to foreign items when implementing+  traits.][65879] E.g. You can now write `impl<T> From<Foo> for Vec<T> {}`.+- [You can now arbitrarily nest receiver types in the `self` position.][64325] E.g. you can+  now write `fn foo(self: Box<Box<Self>>) {}`. Previously only `Self`, `&Self`,+  `&mut Self`, `Arc<Self>`, `Rc<Self>`, and `Box<Self>` were allowed.+- [You can now use any valid identifier in a `format_args` macro.][66847]+  Previously identifiers starting with an underscore were not allowed.+- [Visibility modifiers (e.g. `pub`) are now syntactically allowed on trait items and+  enum variants.][66183] These are still rejected semantically, but+  can be seen and parsed by procedural macros and conditional compilation.++Compiler+--------++- [Rustc will now warn if you have unused loop `'label`s.][66325]+- [Removed support for the `i686-unknown-dragonfly` target.][67255]+- [Added tier 3 support\* for the `riscv64gc-unknown-linux-gnu` target.][66661]+- [You can now pass an arguments file passing the `@path` syntax+  to rustc.][66172] Note that the format differs somewhat from what is+  found in other tooling; please see [the documentation][argfile-docs] for+  more information.+- [You can now provide `--extern` flag without a path, indicating that it is+  available from the search path or specified with an `-L` flag.][64882]++\* Refer to Rust's [platform support page][forge-platform-support] for more+information on Rust's tiered platform support.++[argfile-docs]: https://doc.rust-lang.org/nightly/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path++Libraries+---------++- [The `core::panic` module is now stable.][66771] It was already stable+  through `std`.+- [`NonZero*` numerics now implement `From<NonZero*>` if it's a smaller integer+  width.][66277] E.g. `NonZeroU16` now implements `From<NonZeroU8>`.+- [`MaybeUninit<T>` now implements `fmt::Debug`.][65013]++Stabilized APIs+---------------++- [`Result::map_or`]+- [`Result::map_or_else`]+- [`std::rc::Weak::weak_count`]+- [`std::rc::Weak::strong_count`]+- [`std::sync::Weak::weak_count`]+- [`std::sync::Weak::strong_count`]++Cargo+-----++- [Cargo will now document all the private items for binary crates+  by default.][cargo/7593]+- [`cargo-install` will now reinstall the package if it detects that it is out+  of date.][cargo/7560]+- [Cargo.lock now uses a more git friendly format that should help to reduce+  merge conflicts.][cargo/7579]+- [You can now override specific dependencies's build settings][cargo/7591] E.g.+  `[profile.dev.overrides.image] opt-level = 2` sets the `image` crate's+  optimisation level to `2` for debug builds. You can also use+  `[profile.<profile>.build_overrides]` to override build scripts and+  their dependencies.++Misc+----++- [You can now specify `edition` in documentation code blocks to compile the block+  for that edition.][66238] E.g. `edition2018` tells rustdoc that the code sample+  should be compiled the 2018 edition of Rust.+- [You can now provide custom themes to rustdoc with `--theme`, and check the+  current theme with `--check-theme`.][54733]+- [You can use `#[doc(cfg(item))]` to document that a item is only available with+  certain features.][61351]

It's actually only #[cfg(doc)] that was stabilized in the end. #[doc(cfg(item))] is still unstable.

#[cfg(doc)] is enabled in rustdoc when building documentation and finding doctests.

XAMPPRocky

comment created time in a month

delete branch ollie27/rust

delete branch : rustdoc_async_unsafe

delete time in a month

PR opened rust-lang/rust

rustdoc: Correct order of `async` and `unsafe` in `async unsafe fn`s

The order was swapped in #61319 but rustdoc was never updated to match.

r? @GuillaumeGomez

+12 -5

0 comment

2 changed files

pr created time in a month

create barnchollie27/rust

branch : rustdoc_async_unsafe

created branch time in a month

delete branch ollie27/rust

delete branch : rustdoc_hightlight_fatal_errors

delete time in a month

delete branch ollie27/rust

delete branch : rustdoc_test_errors

delete time in a month

pull request commentrust-lang/rust

Add `ExactSizeIterator` impl for `iter::Chain`

If you take the iterator:

(0..usize::max_value()).chain(0..10).skip(usize::max_value())

It returns exactly 10 items and has a size_hint of (0, None) but that's fine because it doesn't implement ExactSizeIterator. With this PR it suddenly would which means that ExactSizeIterator would become completely meaningless or Skip wouldn't be able to implement it anymore. Either way this is very much a breaking change.

LukasKalbertodt

comment created time in a month

pull request commentrust-lang/rust

rustdoc: Catch fatal errors when syntax highlighting

The "simpler" solution in here I arrived to was to simply update the pulldown-cmark version.

I think you're thinking of a different issue. The syntax highlighting has nothing to do with pulldown-cmark. The unwinding here is coming from rustc's lexer and according to #63288 it's intentional, at least for now.

ollie27

comment created time in a month

issue commentrust-lang/rust

Rustdoc cannot infer type when using type_alias_impl_trait, while rustc works

@ollie27 Didn't you fixed something close to this recently? (I might be wrong though...)

I don't think so, no.

bjorn3

comment created time in a month

pull request commentrust-lang/rust

rustdoc: Fix handling of compile errors when running `rustdoc --test`

This is applying the fixes suggested in https://github.com/rust-lang/rust/issues/52243#issuecomment-404088408 so credit to @SimonSapin.

ollie27

comment created time in a month

PR opened rust-lang/rust

rustdoc: Fix handling of compile errors when running `rustdoc --test`
  • Call abort_if_errors so all errors actually stop rustdoc.
  • Don't panic with "compiler aborted in rustdoc!", instead just exit to avoid the ugly panic message.
  • Use rlib as the crate type when searching for doctests matching what is used for doc generation so #[no_std] crates don't create "no global memory allocator" errors.

Fixes #52243 Fixes #54010

r? @GuillaumeGomez

+69 -3

0 comment

9 changed files

pr created time in a month

create barnchollie27/rust

branch : rustdoc_test_errors

created branch time in a month

delete branch ollie27/rust

delete branch : rustdoc_highlight_panic

delete time in a month

PR opened rust-lang/rust

rustdoc: Catch fatal errors when syntax highlighting

For some errors the lexer will unwind so we need to handle that in addition to handling token::Unknown.

Fixes #56885

r? @GuillaumeGomez

+34 -4

0 comment

5 changed files

pr created time in a month

create barnchollie27/rust

branch : rustdoc_hightlight_fatal_errors

created branch time in a month

Pull request review commentrust-lang/rust

Prevent urls in headings

+#![crate_name = "foo"]++// @has foo/fn.foo.html+// !@has - '//a[@href="http://a.a"]'+// @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere'+// @has - '//a[@href="#another-one-urg"]' 'Another one urg'++/// fooo+///+/// # Implementing [stuff](http://a.a) somewhere
/// # Implementing [stuff](http://a.a "title") somewhere

We may as well check that the link title doesn't show up accidentally while we're at it.

GuillaumeGomez

comment created time in a month

delete branch ollie27/rust

delete branch : rustdoc_invalid_syntax_highlight_escape

delete time in a month

delete branch ollie27/rust

delete branch : win_f32

delete time in a month

pull request commentrust-lang/rust

Don't use f64 shims for f32 cmath functions on non 32-bit x86 MSVC

It looks like the existing workaround was added in #26601 before the LLVM fix to support Windows XP.

Just to be clear, these shims were added to support the i686-pc-windows-msvc target which was also added in that PR. They were erroneously applied to all MSVC target including x86_64 as well which is what this PR fixes.

At some point we should drop XP support and remove the remaining shims...

The shims are still needed even in 32-bit x86 Windows 10 so we won't be able to remove them unfortunately.

ollie27

comment created time in a month

create barnchollie27/rust

branch : rustdoc_invalid_syntax_highlight_escape

created branch time in a month

pull request commentrust-lang/rust

Prevent urls in headings

@bors r-

GuillaumeGomez

comment created time in a month

Pull request review commentrust-lang/rust

Prevent urls in headings

 impl<'a, 'b, 'ids, I: Iterator<Item = Event<'a>>> Iterator for HeadingLinks<'a,                     }                     _ => {}                 }-                self.buf.push_back(event);+                match event {+                    Event::Start(Tag::Link(_, _, text)) => self.buf.push_back(Event::Text(text)),

text here is the link title which shouldn't be shown. We should just ignore it because it's only normally shown when hovering over a link. For example:

//! # foo [link](https://example.com/ "title")

Should simply render as:

image

not:

image

As this PR currently does.

GuillaumeGomez

comment created time in a month

delete branch ollie27/rust

delete branch : rustdoc_help_escape

delete time in a month

delete branch ollie27/rust

delete branch : rustdoc_unstable

delete time in a month

Pull request review commentrust-lang/rust

Fix deref impl typedef

 fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {     let mut lastpathid = 0usize;      for item in search_index {-        item.parent_idx = item.parent.map(|nodeid| {-            if nodeid_to_pathid.contains_key(&nodeid) {-                *nodeid_to_pathid.get(&nodeid).unwrap()+        item.parent_idx = match item.parent {+            Some(nodeid) => Some(if nodeid_to_pathid.contains_key(&nodeid) {+                *nodeid_to_pathid.get(&nodeid).expect("no pathid")             } else {                 let pathid = lastpathid;                 nodeid_to_pathid.insert(nodeid, pathid);                 lastpathid += 1; -                let &(ref fqp, short) = paths.get(&nodeid).unwrap();-                crate_paths.push((short, fqp.last().unwrap().clone()));+                if let Some(&(ref fqp, short)) = paths.get(&nodeid) {+                    crate_paths.push((short, fqp.last().expect("no fqp").clone()));+                } else {+                    continue;+                }

Again, what is this change for?

GuillaumeGomez

comment created time in a month

Pull request review commentrust-lang/rust

Fix deref impl typedef

 fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {     // has since been learned.     for &(did, ref item) in orphan_impl_items {         if let Some(&(ref fqp, _)) = paths.get(&did) {+            if item.name.is_none() {+                // this is most likely from a typedef+                continue;+            }

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

GuillaumeGomez

comment created time in a month

PR opened rust-lang/rust

rustdoc: HTML escape arrows on help popup

r? @GuillaumeGomez

+2 -2

0 comment

1 changed file

pr created time in a month

create barnchollie27/rust

branch : rustdoc_help_escape

created branch time in a month

pull request commentrust-lang/rust

rustdoc: Don't allow `#![feature(...)]` on stable or beta

Any way to add a test for this?

That's a good question but I couldn't think of a good way to add a test. I couldn't find any similar tests for rustc either. I did make a beta build locally to test this though.

ollie27

comment created time in a month

delete branch ollie27/rust

delete branch : rustbuild_books

delete time in a month

issue openedrust-lang/rust

`std::iter::Skip::count` can overflow even if the iterator would return less that `usize::max_value()` items

std::iter::Skip::count currently calls count on the inner iterator but that can overflow even if the Skip itself doesn't return more that usize::max_value() items.

For example:

(0..usize::max_value()).chain(0..10).skip(usize::max_value()).count()

This should return 10 but currently triggers an attempt to add with overflow (or returns 0 if overflow checks are disabled).

This is caused by https://github.com/rust-lang/rust/blob/1389494ac145a84dba025ff65969f7ab150c3f02/src/libcore/iter/adapters/mod.rs#L1817-L1820 which was added in #25035 which was merged between versions 1.0 and 1.1.

created time in a month

create barnchollie27/rust

branch : skip_count_overflow

created branch time in a month

Pull request review commentrust-lang/rust

Error codes checkup and rustdoc test fix

 impl Step for RustdocUi {     } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]+pub struct ErrorCodesCheck {

Yes it does. It uses error_index_generator to concatenate all of the error code docs into a single error-index.md file and then runs rustdoc --test on that: https://github.com/rust-lang/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/bootstrap/test.rs#L1411-L1436

GuillaumeGomez

comment created time in a month

Pull request review commentrust-lang/rust

Error codes checkup and rustdoc test fix

 impl Step for RustdocUi {     } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]+pub struct ErrorCodesCheck {

There is already a step to run rustdoc tests on the error index: https://github.com/rust-lang/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/bootstrap/test.rs#L1393

Does it not work properly?

GuillaumeGomez

comment created time in a month

more