Skip to content

Commit 97eda01

Browse files
committed
Auto merge of #70034 - Dylan-DPC:rollup-5yg771j, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #69686 (Use `pprust` to print attributes in rustdoc) - #69858 (std: on Windows, use GetSystemTimePreciseAsFileTime if it is available) - #69917 (Cleanup E0412 and E0422) - #69964 (Add Node.js to PR CI image) - #69992 (Block version-specific docs from search engines) - #69995 (Add more context to the literal overflow message) - #69998 (Add long error explanation for E0634) - #70014 (Small fixes in rustdoc book) Failed merges: r? @ghost
2 parents 45ebd58 + 6b50a4c commit 97eda01

30 files changed

+177
-86
lines changed

src/bootstrap/test.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ impl Step for RustdocTheme {
607607

608608
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
609609
pub struct RustdocJSStd {
610-
pub host: Interned<String>,
611610
pub target: Interned<String>,
612611
}
613612

@@ -621,13 +620,16 @@ impl Step for RustdocJSStd {
621620
}
622621

623622
fn make_run(run: RunConfig<'_>) {
624-
run.builder.ensure(RustdocJSStd { host: run.host, target: run.target });
623+
run.builder.ensure(RustdocJSStd { target: run.target });
625624
}
626625

627626
fn run(self, builder: &Builder<'_>) {
628627
if let Some(ref nodejs) = builder.config.nodejs {
629628
let mut command = Command::new(nodejs);
630-
command.args(&["src/tools/rustdoc-js-std/tester.js", &*self.host]);
629+
command
630+
.arg(builder.src.join("src/tools/rustdoc-js-std/tester.js"))
631+
.arg(builder.doc_out(self.target))
632+
.arg(builder.src.join("src/test/rustdoc-js-std"));
631633
builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
632634
builder.run(&mut command);
633635
} else {

src/ci/docker/x86_64-gnu-llvm-7/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1616
libssl-dev \
1717
pkg-config \
1818
zlib1g-dev \
19-
xz-utils
19+
xz-utils \
20+
nodejs
2021

2122
COPY scripts/sccache.sh /scripts/
2223
RUN sh /scripts/sccache.sh

src/doc/robots.txt

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
User-agent: *
2-
Disallow: /0.3/
3-
Disallow: /0.4/
4-
Disallow: /0.5/
5-
Disallow: /0.6/
6-
Disallow: /0.7/
7-
Disallow: /0.8/
8-
Disallow: /0.9/
9-
Disallow: /0.10/
10-
Disallow: /0.11.0/
11-
Disallow: /0.12.0/
12-
Disallow: /1.0.0-alpha/
13-
Disallow: /1.0.0-alpha.2/
14-
Disallow: /1.0.0-beta/
15-
Disallow: /1.0.0-beta.2/
16-
Disallow: /1.0.0-beta.3/
17-
Disallow: /1.0.0-beta.4/
18-
Disallow: /1.0.0-beta.5/
2+
Disallow: /1.
3+
Disallow: /0.
194
Disallow: /book/first-edition/
205
Disallow: /book/second-edition/
216
Disallow: /stable/book/first-edition/

src/doc/rustdoc/src/advanced-features.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The features listed on this page fall outside the rest of the main categories.
44

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

7-
For conditional compilation, Rustdoc treats your crate the same way the compiler does: Only things
7+
For conditional compilation, Rustdoc treats your crate the same way the compiler does. Only things
88
from the host target are available (or from the given `--target` if present), and everything else is
99
"filtered out" from the crate. This can cause problems if your crate is providing different things
1010
on different targets and you want your documentation to reflect all the available items you

src/doc/rustdoc/src/command-line-arguments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ Rustdoc only supports HTML output, and so this flag is redundant today.
7979
Using this flag looks like this:
8080

8181
```bash
82-
$ rustdoc src/lib.rs -o target\\doc
83-
$ rustdoc src/lib.rs --output target\\doc
82+
$ rustdoc src/lib.rs -o target/doc
83+
$ rustdoc src/lib.rs --output target/doc
8484
```
8585

8686
By default, `rustdoc`'s output appears in a directory named `doc` in

src/doc/rustdoc/src/documentation-tests.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ only shows the part you care about.
314314
`should_panic` tells `rustdoc` that the code should compile correctly, but
315315
not actually pass as a test.
316316

317-
```text
317+
```rust
318318
/// ```no_run
319319
/// loop {
320320
/// println!("Hello, world");

src/doc/rustdoc/src/what-is-rustdoc.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ $ cargo doc
7878
Internally, this calls out to `rustdoc` like this:
7979

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

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

130130
This covers the simplest use-cases of `rustdoc`. The rest of this book will
131-
explain all of the options that `rustdoc` has, and how to use them.
131+
explain all of the options that `rustdoc` has, and how to use them.

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ E0626: include_str!("./error_codes/E0626.md"),
351351
E0627: include_str!("./error_codes/E0627.md"),
352352
E0631: include_str!("./error_codes/E0631.md"),
353353
E0633: include_str!("./error_codes/E0633.md"),
354+
E0634: include_str!("./error_codes/E0634.md"),
354355
E0635: include_str!("./error_codes/E0635.md"),
355356
E0636: include_str!("./error_codes/E0636.md"),
356357
E0637: include_str!("./error_codes/E0637.md"),
@@ -589,7 +590,6 @@ E0748: include_str!("./error_codes/E0748.md"),
589590
E0630,
590591
E0632, // cannot provide explicit generic arguments when `impl Trait` is
591592
// used in argument position
592-
E0634, // type has conflicting packed representaton hints
593593
E0640, // infer outlives requirements
594594
// E0645, // trait aliases not finished
595595
E0657, // `impl Trait` can only capture lifetimes bound at the fn level

src/librustc_error_codes/error_codes/E0412.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The type name used is not in scope.
1+
A used type name is not in scope.
22

33
Erroneous code examples:
44

src/librustc_error_codes/error_codes/E0422.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
You are trying to use an identifier that is either undefined or not a struct.
1+
An identifier that is neither defined nor a struct was used.
2+
23
Erroneous code example:
34

45
```compile_fail,E0422
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
A type has conflicting `packed` representation hints.
2+
3+
Erroneous code examples:
4+
5+
```compile_fail,E0634
6+
#[repr(packed, packed(2))] // error!
7+
struct Company(i32);
8+
9+
#[repr(packed(2))] // error!
10+
#[repr(packed)]
11+
struct Company(i32);
12+
```
13+
14+
You cannot use conflicting `packed` hints on a same type. If you want to pack a
15+
type to a given size, you should provide a size to packed:
16+
17+
```
18+
#[repr(packed)] // ok!
19+
struct Company(i32);
20+
```

src/librustc_lint/types.rs

+39-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn report_bin_hex_error(
165165
let mut err = lint.build(&format!("literal out of range for {}", t));
166166
err.note(&format!(
167167
"the literal `{}` (decimal `{}`) does not fit into \
168-
an `{}` and will become `{}{}`",
168+
the type `{}` and will become `{}{}`",
169169
repr_str, val, t, actually, t
170170
));
171171
if let Some(sugg_ty) = get_type_suggestion(&cx.tables.node_type(expr.hir_id), val, negative)
@@ -242,7 +242,7 @@ fn lint_int_literal<'a, 'tcx>(
242242
v: u128,
243243
) {
244244
let int_type = t.normalize(cx.sess().target.ptr_width);
245-
let (_, max) = int_ty_range(int_type);
245+
let (min, max) = int_ty_range(int_type);
246246
let max = max as u128;
247247
let negative = type_limits.negated_expr_id == e.hir_id;
248248

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

269269
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
270-
lint.build(&format!("literal out of range for `{}`", t.name_str())).emit()
270+
lint.build(&format!("literal out of range for `{}`", t.name_str()))
271+
.note(&format!(
272+
"the literal `{}` does not fit into the type `{}` whose range is `{}..={}`",
273+
cx.sess()
274+
.source_map()
275+
.span_to_snippet(lit.span)
276+
.ok()
277+
.expect("must get snippet from literal"),
278+
t.name_str(),
279+
min,
280+
max,
281+
))
282+
.emit();
271283
});
272284
}
273285
}
@@ -320,7 +332,19 @@ fn lint_uint_literal<'a, 'tcx>(
320332
return;
321333
}
322334
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
323-
lint.build(&format!("literal out of range for `{}`", t.name_str())).emit()
335+
lint.build(&format!("literal out of range for `{}`", t.name_str()))
336+
.note(&format!(
337+
"the literal `{}` does not fit into the type `{}` whose range is `{}..={}`",
338+
cx.sess()
339+
.source_map()
340+
.span_to_snippet(lit.span)
341+
.ok()
342+
.expect("must get snippet from literal"),
343+
t.name_str(),
344+
min,
345+
max,
346+
))
347+
.emit()
324348
});
325349
}
326350
}
@@ -352,7 +376,17 @@ fn lint_literal<'a, 'tcx>(
352376
};
353377
if is_infinite == Ok(true) {
354378
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
355-
lint.build(&format!("literal out of range for `{}`", t.name_str())).emit()
379+
lint.build(&format!("literal out of range for `{}`", t.name_str()))
380+
.note(&format!(
381+
"the literal `{}` does not fit into the type `{}` and will be converted to `std::{}::INFINITY`",
382+
cx.sess()
383+
.source_map()
384+
.span_to_snippet(lit.span)
385+
.expect("must get snippet from literal"),
386+
t.name_str(),
387+
t.name_str(),
388+
))
389+
.emit();
356390
});
357391
}
358392
}

src/librustdoc/html/render.rs

+3-23
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use std::sync::Arc;
4444

4545
use rustc::middle::privacy::AccessLevels;
4646
use rustc::middle::stability;
47-
use rustc_ast::ast;
4847
use rustc_ast_pretty::pprust;
4948
use rustc_data_structures::flock;
5049
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -3126,25 +3125,6 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum) {
31263125
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
31273126
}
31283127

3129-
fn render_attribute(attr: &ast::MetaItem) -> Option<String> {
3130-
let path = pprust::path_to_string(&attr.path);
3131-
3132-
if attr.is_word() {
3133-
Some(path)
3134-
} else if let Some(v) = attr.value_str() {
3135-
Some(format!("{} = {:?}", path, v))
3136-
} else if let Some(values) = attr.meta_item_list() {
3137-
let display: Vec<_> = values
3138-
.iter()
3139-
.filter_map(|attr| attr.meta_item().and_then(|mi| render_attribute(mi)))
3140-
.collect();
3141-
3142-
if !display.is_empty() { Some(format!("{}({})", path, display.join(", "))) } else { None }
3143-
} else {
3144-
None
3145-
}
3146-
}
3147-
31483128
const ATTRIBUTE_WHITELIST: &[Symbol] = &[
31493129
sym::export_name,
31503130
sym::lang,
@@ -3170,9 +3150,9 @@ fn render_attributes(w: &mut Buffer, it: &clean::Item, top: bool) {
31703150
if !ATTRIBUTE_WHITELIST.contains(&attr.name_or_empty()) {
31713151
continue;
31723152
}
3173-
if let Some(s) = render_attribute(&attr.meta().unwrap()) {
3174-
attrs.push_str(&format!("#[{}]\n", s));
3175-
}
3153+
3154+
// FIXME: this currently renders too many spaces as in: `#[repr(C, align (8))]`.
3155+
attrs.push_str(&pprust::attribute_to_string(&attr));
31763156
}
31773157
if !attrs.is_empty() {
31783158
write!(

src/libstd/sys/windows/c.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,10 @@ compat_fn! {
10451045
_dwBufferSize: DWORD) -> BOOL {
10461046
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
10471047
}
1048+
pub fn GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime: LPFILETIME)
1049+
-> () {
1050+
GetSystemTimeAsFileTime(lpSystemTimeAsFileTime)
1051+
}
10481052
pub fn SleepConditionVariableSRW(ConditionVariable: PCONDITION_VARIABLE,
10491053
SRWLock: PSRWLOCK,
10501054
dwMilliseconds: DWORD,

src/libstd/sys/windows/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl SystemTime {
7474
pub fn now() -> SystemTime {
7575
unsafe {
7676
let mut t: SystemTime = mem::zeroed();
77-
c::GetSystemTimeAsFileTime(&mut t.t);
77+
c::GetSystemTimePreciseAsFileTime(&mut t.t);
7878
t
7979
}
8080
}

src/test/rustdoc/attributes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ pub extern "C" fn g() {}
1515
pub enum Foo {
1616
Bar,
1717
}
18+
19+
// @has foo/struct.Repr.html '//*[@class="docblock attributes top-attr"]' '#[repr(C, align (8))]'
20+
#[repr(C, align(8))]
21+
pub struct Repr;

src/test/ui/conflicting-repr-hints.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ LL | | }
7676

7777
error: aborting due to 10 previous errors
7878

79-
Some errors have detailed explanations: E0566, E0587.
79+
Some errors have detailed explanations: E0566, E0587, E0634.
8080
For more information about an error, try `rustc --explain E0566`.

src/test/ui/enum/enum-discrim-too-small2.stderr

+7
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,31 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(overflowing_literals)]
1111
| ^^^^^^^^^^^^^^^^^^^^
12+
= note: the literal `223` does not fit into the type `i8` whose range is `-128..=127`
1213

1314
error: literal out of range for `i16`
1415
--> $DIR/enum-discrim-too-small2.rs:15:12
1516
|
1617
LL | Ci16 = 55555,
1718
| ^^^^^
19+
|
20+
= note: the literal `55555` does not fit into the type `i16` whose range is `-32768..=32767`
1821

1922
error: literal out of range for `i32`
2023
--> $DIR/enum-discrim-too-small2.rs:22:12
2124
|
2225
LL | Ci32 = 3_000_000_000,
2326
| ^^^^^^^^^^^^^
27+
|
28+
= note: the literal `3_000_000_000` does not fit into the type `i32` whose range is `-2147483648..=2147483647`
2429

2530
error: literal out of range for `i64`
2631
--> $DIR/enum-discrim-too-small2.rs:29:12
2732
|
2833
LL | Ci64 = 9223372036854775809,
2934
| ^^^^^^^^^^^^^^^^^^^
35+
|
36+
= note: the literal `9223372036854775809` does not fit into the type `i64` whose range is `-9223372036854775808..=9223372036854775807`
3037

3138
error: aborting due to 4 previous errors
3239

src/test/ui/issues/issue-63364.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | for n in 100_000.. {
55
| ^^^^^^^
66
|
77
= note: `#[deny(overflowing_literals)]` on by default
8+
= note: the literal `100_000` does not fit into the type `u16` whose range is `0..=65535`
89

910
error: aborting due to previous error
1011

src/test/ui/lint/deny-overflowing-literals.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | let x: u8 = 256;
55
| ^^^
66
|
77
= note: `#[deny(overflowing_literals)]` on by default
8+
= note: the literal `256` does not fit into the type `u8` whose range is `0..=255`
89

910
error: range endpoint is out of range for `u8`
1011
--> $DIR/deny-overflowing-literals.rs:5:14

src/test/ui/lint/lint-range-endpoint-overflow.stderr

+6
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@ error: literal out of range for `u8`
1515
|
1616
LL | let range_c = 0..=256;
1717
| ^^^
18+
|
19+
= note: the literal `256` does not fit into the type `u8` whose range is `0..=255`
1820

1921
error: literal out of range for `u8`
2022
--> $DIR/lint-range-endpoint-overflow.rs:7:19
2123
|
2224
LL | let range_d = 256..5;
2325
| ^^^
26+
|
27+
= note: the literal `256` does not fit into the type `u8` whose range is `0..=255`
2428

2529
error: literal out of range for `u8`
2630
--> $DIR/lint-range-endpoint-overflow.rs:8:22
2731
|
2832
LL | let range_e = 0..257;
2933
| ^^^
34+
|
35+
= note: the literal `257` does not fit into the type `u8` whose range is `0..=255`
3036

3137
error: range endpoint is out of range for `u8`
3238
--> $DIR/lint-range-endpoint-overflow.rs:9:20

src/test/ui/lint/lint-type-limits2.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ note: the lint level is defined here
1717
|
1818
LL | #![warn(overflowing_literals)]
1919
| ^^^^^^^^^^^^^^^^^^^^
20+
= note: the literal `128` does not fit into the type `i8` whose range is `-128..=127`
2021

2122
error: aborting due to previous error
2223

0 commit comments

Comments
 (0)