Skip to content
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

Rollup of 9 pull requests #70033

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
965888a
Add Node.js to PR CI image
ollie27 Mar 12, 2020
3f58ab6
Allow `rustdoc-js` and `rustdoc-js-std` to use none default build dir…
ollie27 Mar 13, 2020
a5a786d
Block version-specific docs from search engines
kornelski Mar 14, 2020
4bd6ebc
Add long error explanation for E0634 #61137
Mar 14, 2020
efd3952
Make `newtype_index` methods const
ecstatic-morse Mar 10, 2020
680aa06
Rename `from_u32_const` -> `from_u32`
ecstatic-morse Mar 10, 2020
1f7b537
Add requisite feature gates for const assert
ecstatic-morse Mar 10, 2020
08d345e
Hold index of generator `self` arg in `const`
ecstatic-morse Mar 10, 2020
68dc24f
Clean up path separator in rustdoc book
TimotheeGerber Mar 14, 2020
ecb84c9
Clean up E0412 and E0422 explanations
GuillaumeGomez Mar 11, 2020
6f75d3f
Simplify `Qualif` interface
ecstatic-morse Dec 13, 2019
131433a
Change fenced code block type in rustdoc book
TimotheeGerber Mar 14, 2020
6d521ec
Fix punctuation in rustdoc book
TimotheeGerber Mar 14, 2020
138d29d
Update ui tests
GuillaumeGomez Mar 14, 2020
5760db1
Update src/librustc_error_codes/error_codes/E0634.md
ayushmishra2005 Mar 15, 2020
2974685
Update src/librustc_error_codes/error_codes/E0634.md
ayushmishra2005 Mar 15, 2020
a4ffbaa
Add more context to the literal overflow message
contrun Mar 14, 2020
621c42c
Render full attributes in rustdoc
varkor Mar 3, 2020
c599ec4
Add FIXME note
varkor Mar 3, 2020
91b826f
Rollup merge of #67335 - ecstatic-morse:qualif-refactor, r=eddyb
Dylan-DPC Mar 15, 2020
a338c0e
Rollup merge of #69686 - varkor:rustdoc-attributes, r=GuillaumeGomez
Dylan-DPC Mar 15, 2020
513702d
Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obk
Dylan-DPC Mar 15, 2020
1984cbd
Rollup merge of #69917 - GuillaumeGomez:cleanup-e0412, r=Dylan-DPC
Dylan-DPC Mar 15, 2020
dd5c112
Rollup merge of #69964 - ollie27:ci_nodejs, r=Mark-Simulacrum,Guillau…
Dylan-DPC Mar 15, 2020
66a1974
Rollup merge of #69992 - kornelski:robots, r=steveklabnik
Dylan-DPC Mar 15, 2020
ed37191
Rollup merge of #69995 - contrun:add-context-to-literal-overflow, r=e…
Dylan-DPC Mar 15, 2020
d733285
Rollup merge of #69998 - ayushmishra2005:doc/61137-add-long-error-cod…
Dylan-DPC Mar 15, 2020
b543b99
Rollup merge of #70014 - TimotheeGerber:small-fix-rustdoc-book, r=Dyl…
Dylan-DPC Mar 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ impl Step for RustdocTheme {

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocJSStd {
pub host: Interned<String>,
pub target: Interned<String>,
}

Expand All @@ -621,13 +620,16 @@ impl Step for RustdocJSStd {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustdocJSStd { host: run.host, target: run.target });
run.builder.ensure(RustdocJSStd { target: run.target });
}

fn run(self, builder: &Builder<'_>) {
if let Some(ref nodejs) = builder.config.nodejs {
let mut command = Command::new(nodejs);
command.args(&["src/tools/rustdoc-js-std/tester.js", &*self.host]);
command
.arg(builder.src.join("src/tools/rustdoc-js-std/tester.js"))
.arg(builder.doc_out(self.target))
.arg(builder.src.join("src/test/rustdoc-js-std"));
builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
builder.run(&mut command);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/x86_64-gnu-llvm-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev \
pkg-config \
zlib1g-dev \
xz-utils
xz-utils \
nodejs

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
19 changes: 2 additions & 17 deletions src/doc/robots.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
User-agent: *
Disallow: /0.3/
Disallow: /0.4/
Disallow: /0.5/
Disallow: /0.6/
Disallow: /0.7/
Disallow: /0.8/
Disallow: /0.9/
Disallow: /0.10/
Disallow: /0.11.0/
Disallow: /0.12.0/
Disallow: /1.0.0-alpha/
Disallow: /1.0.0-alpha.2/
Disallow: /1.0.0-beta/
Disallow: /1.0.0-beta.2/
Disallow: /1.0.0-beta.3/
Disallow: /1.0.0-beta.4/
Disallow: /1.0.0-beta.5/
Disallow: /1.
Disallow: /0.
Disallow: /book/first-edition/
Disallow: /book/second-edition/
Disallow: /stable/book/first-edition/
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/advanced-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The features listed on this page fall outside the rest of the main categories.

## `#[cfg(doc)]`: Documenting platform-/feature-specific information

For conditional compilation, Rustdoc treats your crate the same way the compiler does: Only things
For conditional compilation, Rustdoc treats your crate the same way the compiler does. Only things
from the host target are available (or from the given `--target` if present), and everything else is
"filtered out" from the crate. This can cause problems if your crate is providing different things
on different targets and you want your documentation to reflect all the available items you
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ Rustdoc only supports HTML output, and so this flag is redundant today.
Using this flag looks like this:

```bash
$ rustdoc src/lib.rs -o target\\doc
$ rustdoc src/lib.rs --output target\\doc
$ rustdoc src/lib.rs -o target/doc
$ rustdoc src/lib.rs --output target/doc
```

By default, `rustdoc`'s output appears in a directory named `doc` in
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/documentation-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ only shows the part you care about.
`should_panic` tells `rustdoc` that the code should compile correctly, but
not actually pass as a test.

```text
```rust
/// ```no_run
/// loop {
/// println!("Hello, world");
Expand Down
6 changes: 3 additions & 3 deletions src/doc/rustdoc/src/what-is-rustdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ $ cargo doc
Internally, this calls out to `rustdoc` like this:

```bash
$ rustdoc --crate-name docs srclib.rs -o <path>\docs\target\doc -L
dependency=<path>docs\target\debug\deps
$ rustdoc --crate-name docs src/lib.rs -o <path>/docs/target/doc -L
dependency=<path>/docs/target/debug/deps
```

You can see this with `cargo doc --verbose`.
Expand Down Expand Up @@ -128,4 +128,4 @@ Cargo currently does not understand standalone Markdown files, unfortunately.
## Summary

This covers the simplest use-cases of `rustdoc`. The rest of this book will
explain all of the options that `rustdoc` has, and how to use them.
explain all of the options that `rustdoc` has, and how to use them.
3 changes: 3 additions & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_if_match)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(const_transmute)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ rustc_index::newtype_index! {
}

impl UniverseIndex {
pub const ROOT: UniverseIndex = UniverseIndex::from_u32_const(0);
pub const ROOT: UniverseIndex = UniverseIndex::from_u32(0);

/// Returns the "next" universe index in order -- this new index
/// is considered to extend all previous universes. This
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_ast/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(const_if_match)]
#![feature(const_fn)] // For the `transmute` in `P::new`
#![feature(const_panic)]
#![feature(const_transmute)]
#![feature(crate_visibility_modifier)]
#![feature(label_break_value)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rustc_index::newtype_index! {
rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeId);

/// `NodeId` used to represent the root of the crate.
pub const CRATE_NODE_ID: NodeId = NodeId::from_u32_const(0);
pub const CRATE_NODE_ID: NodeId = NodeId::from_u32(0);

/// When parsing and doing expansions, we initially give all AST nodes this AST
/// node value. Then later, in the renumber pass, we renumber them to have
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ E0626: include_str!("./error_codes/E0626.md"),
E0627: include_str!("./error_codes/E0627.md"),
E0631: include_str!("./error_codes/E0631.md"),
E0633: include_str!("./error_codes/E0633.md"),
E0634: include_str!("./error_codes/E0634.md"),
E0635: include_str!("./error_codes/E0635.md"),
E0636: include_str!("./error_codes/E0636.md"),
E0637: include_str!("./error_codes/E0637.md"),
Expand Down Expand Up @@ -589,7 +590,6 @@ E0748: include_str!("./error_codes/E0748.md"),
E0630,
E0632, // cannot provide explicit generic arguments when `impl Trait` is
// used in argument position
E0634, // type has conflicting packed representaton hints
E0640, // infer outlives requirements
// E0645, // trait aliases not finished
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes/E0412.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The type name used is not in scope.
A used type name is not in scope.

Erroneous code examples:

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_error_codes/error_codes/E0422.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
You are trying to use an identifier that is either undefined or not a struct.
An identifier that is neither defined nor a struct was used.

Erroneous code example:

```compile_fail,E0422
Expand Down
20 changes: 20 additions & 0 deletions src/librustc_error_codes/error_codes/E0634.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
A type has conflicting `packed` representation hints.

Erroneous code examples:

```compile_fail,E0634
#[repr(packed, packed(2))] // error!
struct Company(i32);

#[repr(packed(2))] // error!
#[repr(packed)]
struct Company(i32);
```

You cannot use conflicting `packed` hints on a same type. If you want to pack a
type to a given size, you should provide a size to packed:

```
#[repr(packed)] // ok!
struct Company(i32);
```
2 changes: 1 addition & 1 deletion src/librustc_hir/hir_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ rustc_data_structures::impl_stable_hash_via_hash!(ItemLocalId);

/// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_INDEX`.
pub const CRATE_HIR_ID: HirId =
HirId { owner: CRATE_DEF_INDEX, local_id: ItemLocalId::from_u32_const(0) };
HirId { owner: CRATE_DEF_INDEX, local_id: ItemLocalId::from_u32(0) };

pub const DUMMY_HIR_ID: HirId = HirId { owner: CRATE_DEF_INDEX, local_id: DUMMY_ITEM_LOCAL_ID };

Expand Down
2 changes: 2 additions & 0 deletions src/librustc_hir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html

#![feature(crate_visibility_modifier)]
#![feature(const_if_match)]
#![feature(const_fn)] // For the unsizing cast on `&[]`
#![feature(const_panic)]
#![feature(in_band_lifetimes)]
#![feature(specialization)]
#![recursion_limit = "256"]
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_index/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#![feature(allow_internal_unstable)]
#![feature(const_if_match)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(unboxed_closures)]
#![feature(test)]
#![feature(fn_traits)]
Expand Down
32 changes: 7 additions & 25 deletions src/librustc_index/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,62 +120,44 @@ macro_rules! newtype_index {
impl $type {
$v const MAX_AS_U32: u32 = $max;

$v const MAX: Self = Self::from_u32_const($max);
$v const MAX: Self = Self::from_u32($max);

#[inline]
$v fn from_usize(value: usize) -> Self {
$v const fn from_usize(value: usize) -> Self {
assert!(value <= ($max as usize));
unsafe {
Self::from_u32_unchecked(value as u32)
}
}

#[inline]
$v fn from_u32(value: u32) -> Self {
$v const fn from_u32(value: u32) -> Self {
assert!(value <= $max);
unsafe {
Self::from_u32_unchecked(value)
}
}

/// Hacky variant of `from_u32` for use in constants.
/// This version checks the "max" constraint by using an
/// invalid array dereference.
#[inline]
$v const fn from_u32_const(value: u32) -> Self {
// This will fail at const eval time unless `value <=
// max` is true (in which case we get the index 0).
// It will also fail at runtime, of course, but in a
// kind of wacky way.
let _ = ["out of range value used"][
!(value <= $max) as usize
];

unsafe {
Self { private: value }
}
}

#[inline]
$v const unsafe fn from_u32_unchecked(value: u32) -> Self {
Self { private: value }
}

/// Extracts the value of this index as an integer.
#[inline]
$v fn index(self) -> usize {
$v const fn index(self) -> usize {
self.as_usize()
}

/// Extracts the value of this index as a `u32`.
#[inline]
$v fn as_u32(self) -> u32 {
$v const fn as_u32(self) -> u32 {
self.private
}

/// Extracts the value of this index as a `usize`.
#[inline]
$v fn as_usize(self) -> usize {
$v const fn as_usize(self) -> usize {
self.as_u32() as usize
}
}
Expand Down Expand Up @@ -500,7 +482,7 @@ macro_rules! newtype_index {
const $name:ident = $constant:expr,
$($tokens:tt)*) => (
$(#[doc = $doc])*
$v const $name: $type = $type::from_u32_const($constant);
$v const $name: $type = $type::from_u32($constant);
$crate::newtype_index!(
@derives [$($derives,)*]
@attrs [$(#[$attrs])*]
Expand Down
44 changes: 39 additions & 5 deletions src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn report_bin_hex_error(
let mut err = lint.build(&format!("literal out of range for {}", t));
err.note(&format!(
"the literal `{}` (decimal `{}`) does not fit into \
an `{}` and will become `{}{}`",
the type `{}` and will become `{}{}`",
repr_str, val, t, actually, t
));
if let Some(sugg_ty) = get_type_suggestion(&cx.tables.node_type(expr.hir_id), val, negative)
Expand Down Expand Up @@ -242,7 +242,7 @@ fn lint_int_literal<'a, 'tcx>(
v: u128,
) {
let int_type = t.normalize(cx.sess().target.ptr_width);
let (_, max) = int_ty_range(int_type);
let (min, max) = int_ty_range(int_type);
let max = max as u128;
let negative = type_limits.negated_expr_id == e.hir_id;

Expand All @@ -267,7 +267,19 @@ fn lint_int_literal<'a, 'tcx>(
}

cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
lint.build(&format!("literal out of range for `{}`", t.name_str())).emit()
lint.build(&format!("literal out of range for `{}`", t.name_str()))
.note(&format!(
"the literal `{}` does not fit into the type `{}` whose range is `{}..={}`",
cx.sess()
.source_map()
.span_to_snippet(lit.span)
.ok()
.expect("must get snippet from literal"),
t.name_str(),
min,
max,
))
.emit();
});
}
}
Expand Down Expand Up @@ -320,7 +332,19 @@ fn lint_uint_literal<'a, 'tcx>(
return;
}
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
lint.build(&format!("literal out of range for `{}`", t.name_str())).emit()
lint.build(&format!("literal out of range for `{}`", t.name_str()))
.note(&format!(
"the literal `{}` does not fit into the type `{}` whose range is `{}..={}`",
cx.sess()
.source_map()
.span_to_snippet(lit.span)
.ok()
.expect("must get snippet from literal"),
t.name_str(),
min,
max,
))
.emit()
});
}
}
Expand Down Expand Up @@ -352,7 +376,17 @@ fn lint_literal<'a, 'tcx>(
};
if is_infinite == Ok(true) {
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
lint.build(&format!("literal out of range for `{}`", t.name_str())).emit()
lint.build(&format!("literal out of range for `{}`", t.name_str()))
.note(&format!(
"the literal `{}` does not fit into the type `{}` and will be converted to `std::{}::INFINITY`",
cx.sess()
.source_map()
.span_to_snippet(lit.span)
.expect("must get snippet from literal"),
t.name_str(),
t.name_str(),
))
.emit();
});
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Rust MIR: a lowered representation of Rust.
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_if_match)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(crate_visibility_modifier)]
#![feature(drain_filter)]
#![feature(exhaustive_patterns)]
Expand Down
Loading