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 16 pull requests #58566

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c654968
Deny the `overflowing_literals` lint for all editions
ollie27 Jan 17, 2019
a15916b
[WIP] add better error message for partial move
clintfred Feb 5, 2019
d4c52bf
error output updated by ./x.py test --stage 1 src/test/ui --increment…
clintfred Feb 6, 2019
f753d30
Suggest removing parentheses surrounding lifetimes
igorsdv Feb 5, 2019
9fa01da
Improve stability tags display
GuillaumeGomez Feb 8, 2019
69d948d
Fix search results interactions
GuillaumeGomez Feb 9, 2019
5d80584
Use less explicit shifting in std::net::ip
scottmcm Feb 12, 2019
4e5eda3
compute is_partial_move outside of the move_site loop for clarity
clintfred Feb 13, 2019
96fd218
check if `used_place` and `moved_place` are equal when determining if…
clintfred Feb 13, 2019
755b320
simplified conditional
clintfred Feb 13, 2019
cdd1c0e
Don't use an allocation for ItemId in StmtKind
Zoxc Feb 17, 2019
564c569
Monomorphize less code in fs::{read|write}
scottmcm Feb 17, 2019
8fbb013
Mention capping forbid lints
dwijnand Feb 17, 2019
3281e62
Remove UB in test_is_null test
KamilaBorowska Feb 17, 2019
0cf1a91
Remove UB in test_ptr_subtraction test
KamilaBorowska Feb 17, 2019
a23c40e
Add alias methods to PathBuf for underlying OsString
aaronstillwell Feb 17, 2019
dad211e
Modify doctest's auto-`fn main()` to allow `Result`s
llogiq Dec 3, 2018
dbf60d9
Fixes for implementation of PathBuf methods (aliases for OsString)
aaronstillwell Feb 17, 2019
35d8c44
Changed feature gate for new PathBuf methods
aaronstillwell Feb 17, 2019
ee948d9
Add regression test for a specialization-related ICE (#39448)
emlai Feb 17, 2019
55c25f8
Fix doc for rustc "-g" flag
TheBiggerGuy Feb 17, 2019
88e462b
Add links to codegen docs for rustc synonym flags
TheBiggerGuy Feb 17, 2019
0b9ad6e
Explain a panic in test case net::tcp::tests::double_bind
ssomers Feb 4, 2019
01bebdf
Merge remote-tracking branch 'upstream/master'
ssomers Feb 17, 2019
9312ca1
Add a note about 2018e if someone uses `try {` in 2015e
scottmcm Feb 18, 2019
c9fbcc1
Fixed doc example for Path::with_capacity
aaronstillwell Feb 18, 2019
de05548
re-blessing error output: ./x.py test src/test/ui --stage 1 --bless
clintfred Feb 18, 2019
47b2ba3
Rollup merge of #55632 - ollie27:deny_overflowing_literals, r=Centril
Mark-Simulacrum Feb 18, 2019
da18731
Rollup merge of #56470 - llogiq:process-termination-doctest, r=Guilla…
Mark-Simulacrum Feb 18, 2019
d9f3e58
Rollup merge of #58198 - igorsdv:suggest-removing-parentheses-surroun…
Mark-Simulacrum Feb 18, 2019
01771ff
Rollup merge of #58199 - clintfred:partial-move-err-msg, r=estebank
Mark-Simulacrum Feb 18, 2019
ce9b9f8
Rollup merge of #58303 - GuillaumeGomez:stability-tags-display, r=Qui…
Mark-Simulacrum Feb 18, 2019
42c1133
Rollup merge of #58336 - GuillaumeGomez:fix-search-results-interactio…
Mark-Simulacrum Feb 18, 2019
6842614
Rollup merge of #58392 - scottmcm:less-shifting-in-net-ip, r=oli-obk
Mark-Simulacrum Feb 18, 2019
2b85431
Rollup merge of #58528 - Zoxc:stmtkind-item, r=oli-obk
Mark-Simulacrum Feb 18, 2019
e2f306e
Rollup merge of #58530 - scottmcm:monomorphize-less, r=TimNN
Mark-Simulacrum Feb 18, 2019
8488327
Rollup merge of #58534 - dwijnand:mention-capping-forbid-lints, r=oli…
Mark-Simulacrum Feb 18, 2019
932ff67
Rollup merge of #58536 - xfix:remove-ub-in-pointer-tests, r=RalfJung
Mark-Simulacrum Feb 18, 2019
e882771
Rollup merge of #58539 - aaronstillwell:master, r=Mark-Simulacrum
Mark-Simulacrum Feb 18, 2019
a740ef1
Rollup merge of #58544 - TheBiggerGuy:rustc-doc-cli-args, r=TimNN
Mark-Simulacrum Feb 18, 2019
f2b237d
Rollup merge of #58545 - emlai:regression-test-for-39448, r=Centril
Mark-Simulacrum Feb 18, 2019
4b1eff8
Rollup merge of #58551 - ssomers:master, r=oli-obk
Mark-Simulacrum Feb 18, 2019
8a9191e
Rollup merge of #58555 - scottmcm:try-2015, r=Centril
Mark-Simulacrum Feb 18, 2019
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
4 changes: 2 additions & 2 deletions src/doc/rustc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ This flag prints out various information about the compiler.

## `-g`: include debug information

A synonym for `-C debug-level=2`.
A synonym for `-C debuginfo=2`, for more see [here](codegen-options/index.html#debuginfo).

## `-O`: optimize your code

A synonym for `-C opt-level=2`.
A synonym for `-C opt-level=2`, for more see [here](codegen-options/index.html#opt-level).

## `-o`: filename of the output

Expand Down
4 changes: 3 additions & 1 deletion src/doc/rustc/src/lints/levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ This lint level gives you that.
'forbid' is a special lint level that's stronger than 'deny'. It's the same
as 'deny' in that a lint at this level will produce an error, but unlike the
'deny' level, the 'forbid' level can not be overridden to be anything lower
than an error.
than an error. However, lint levels may still be capped with `--cap-lints`
(see below) so `rustc --cap-lints warn` will make lints set to 'forbid' just
warn.

## Configuring warning levels

Expand Down
20 changes: 20 additions & 0 deletions src/doc/rustc/src/lints/listing/deny-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ error: const items should never be #[no_mangle]
|
```

## overflowing-literals

This lint detects literal out of range for its type. Some
example code that triggers this lint:

```rust,compile_fail
let x: u8 = 1000;
```

This will produce:

```text
error: literal out of range for u8
--> src/main.rs:2:17
|
2 | let x: u8 = 1000;
| ^^^^
|
```

## parenthesized-params-in-types-and-modules

This lint detects incorrect parentheses. Some example code that triggers this
Expand Down
20 changes: 0 additions & 20 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,6 @@ warning: functions generic over types must be mangled
|
```

## overflowing-literals

This lint detects literal out of range for its type. Some
example code that triggers this lint:

```rust
let x: u8 = 1000;
```

This will produce:

```text
warning: literal out of range for u8
--> src/main.rs:2:17
|
2 | let x: u8 = 1000;
| ^^^^
|
```

## path-statements

This lint detects path statements with no effect. Some example code that
Expand Down
17 changes: 17 additions & 0 deletions src/doc/rustdoc/src/documentation-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ appears to the reader as the initial idea but works with doc tests:
/// ```
```

As of version 1.34.0, one can also omit the `fn main()`, but you will have to
disambiguate the error type:

```ignore
/// ```
/// use std::io;
/// let mut input = String::new();
/// io::stdin().read_line(&mut input)?;
/// # Ok::<(), io:Error>(())
/// ```
```

This is an unfortunate consequence of the `?` operator adding an implicit
conversion, so type inference fails because the type is not unique. Please note
that you must write the `(())` in one sequence without intermediate whitespace
so that rustdoc understands you want an implicit `Result`-returning function.

## Documenting macros

Here’s an example of documenting a macro:
Expand Down
11 changes: 6 additions & 5 deletions src/libcore/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ fn test() {
}

#[test]
#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic
fn test_is_null() {
let p: *const isize = null();
assert!(p.is_null());

let q = unsafe { p.offset(1) };
let q = p.wrapping_offset(1);
assert!(!q.is_null());

let mp: *mut isize = null_mut();
assert!(mp.is_null());

let mq = unsafe { mp.offset(1) };
let mq = mp.wrapping_offset(1);
assert!(!mq.is_null());

// Pointers to unsized types -- slices
Expand Down Expand Up @@ -208,7 +207,6 @@ fn test_ptr_addition() {
}

#[test]
#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic
fn test_ptr_subtraction() {
unsafe {
let xs = vec![0,1,2,3,4,5,6,7,8,9];
Expand All @@ -224,8 +222,11 @@ fn test_ptr_subtraction() {
let m_start = xs_mut.as_mut_ptr();
let mut m_ptr = m_start.offset(9);

while m_ptr >= m_start {
loop {
*m_ptr += *m_ptr;
if m_ptr == m_start {
break;
}
m_ptr = m_ptr.offset(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
visitor.visit_id(statement.id);
match statement.node {
StmtKind::Local(ref local) => visitor.visit_local(local),
StmtKind::Item(ref item) => visitor.visit_nested_item(**item),
StmtKind::Item(item) => visitor.visit_nested_item(item),
StmtKind::Expr(ref expression) |
StmtKind::Semi(ref expression) => {
visitor.visit_expr(expression)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt {
id: node_id,
hir_id,
node: hir::StmtKind::Item(P(item_id)),
node: hir::StmtKind::Item(item_id),
span: s.span,
}
})
Expand Down Expand Up @@ -4693,7 +4693,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt {
id: node_id,
hir_id,
node: hir::StmtKind::Item(P(item_id)),
node: hir::StmtKind::Item(item_id),
span: s.span,
}
})
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,9 @@ impl fmt::Debug for Stmt {
pub enum StmtKind {
/// A local (`let`) binding.
Local(P<Local>),

/// An item binding.
Item(P<ItemId>),
Item(ItemId),

/// An expression without a trailing semi-colon (must have unit type).
Expr(P<Expr>),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,8 @@ impl<'a> State<'a> {
}
self.end()?
}
hir::StmtKind::Item(ref item) => {
self.ann.nested(self, Nested::Item(**item))?
hir::StmtKind::Item(item) => {
self.ann.nested(self, Nested::Item(item))?
}
hir::StmtKind::Expr(ref expr) => {
self.space_if_not_bol()?;
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
use syntax::{ast, attr};
use syntax::errors::Applicability;
use rustc_target::spec::abi::Abi;
use syntax::edition::Edition;
use syntax_pos::Span;
use syntax::source_map;

Expand All @@ -34,9 +33,8 @@ declare_lint! {

declare_lint! {
OVERFLOWING_LITERALS,
Warn,
"literal out of range for its type",
Edition::Edition2018 => Deny
Deny,
"literal out of range for its type"
}

declare_lint! {
Expand Down
10 changes: 8 additions & 2 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
);

let mut is_loop_move = false;
let is_partial_move = move_site_vec.iter().any(|move_site| {
let move_out = self.move_data.moves[(*move_site).moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;
used_place != moved_place && used_place.is_prefix_of(moved_place)
});
for move_site in &move_site_vec {
let move_out = self.move_data.moves[(*move_site).moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;
Expand Down Expand Up @@ -175,8 +180,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
err.span_label(
span,
format!(
"value {} here after move",
desired_action.as_verb_in_past_tense()
"value {} here {}",
desired_action.as_verb_in_past_tense(),
if is_partial_move { "after partial move" } else { "after move" },
),
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_resolve/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ impl<'a> Resolver<'a> {
format!("{}!", path_str),
Applicability::MaybeIncorrect,
);
if path_str == "try" && span.rust_2015() {
err.note("if you want the `try` keyword, \
you need to be in the 2018 edition");
}
}
(Def::TyAlias(..), PathSource::Trait(_)) => {
err.span_label(span, "type aliases cannot be used as traits");
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2786,8 +2786,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
<tr class='{stab}{add}module-item'>\
<td><a class=\"{class}\" href=\"{href}\" \
title='{title}'>{name}</a>{unsafety_flag}</td>\
<td class='docblock-short'>{stab_tags}{docs}\
</td>\
<td class='docblock-short'>{stab_tags}{docs}</td>\
</tr>",
name = *myitem.name.as_ref().unwrap(),
stab_tags = stability_tags(myitem),
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ if (!DOMTokenList.prototype.remove) {
var actives = [[], [], []];
// "current" is used to know which tab we're looking into.
var current = 0;
onEachLazy(document.getElementsByClassName("search-results"), function(e) {
onEachLazy(document.getElementById("results").childNodes, function(e) {
onEachLazy(e.getElementsByClassName("highlighted"), function(e) {
actives[current].push(e);
});
Expand All @@ -1213,7 +1213,7 @@ if (!DOMTokenList.prototype.remove) {
removeClass(actives[currentTab][0], "highlighted");
} else if (e.which === 40) { // down
if (!actives[currentTab].length) {
var results = document.getElementsByClassName("search-results");
var results = document.getElementById("results").childNodes;
if (results.length > 0) {
var res = results[currentTab].getElementsByClassName("result");
if (res.length > 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ a.test-arrow {
box-shadow: 1px 0 0 1px #000, 0 0 0 2px transparent;
}

.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #404040; }
.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #404040; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #404040; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #404040; }

.module-item .stab {
color: #ddd;
}

.stab.unstable {background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #2f2f2f; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }

#help > div {
background: #4d4d4d;
border-color: #bfbfbf;
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/static/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ a.test-arrow {
box-shadow: 1px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
}

.module-item .stab {
color: #000;
}

.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
.stab.internal { background: #FFB9B3; border-color: #B71C1C; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }

.module-item .stab {
color: #000;
}

#help > div {
background: #e9e9e9;
border-color: #bfbfbf;
Expand Down
14 changes: 10 additions & 4 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,19 @@ pub fn make_test(s: &str,
}
}

if dont_insert_main || already_has_main {
// FIXME: This code cannot yet handle no_std test cases yet
if dont_insert_main || already_has_main || prog.contains("![no_std]") {
prog.push_str(everything_else);
} else {
prog.push_str("fn main() {\n");
let returns_result = everything_else.trim_end().ends_with("(())");
let (main_pre, main_post) = if returns_result {
("fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {",
"}\n_inner().unwrap() }")
} else {
("fn main() {\n", "\n}")
};
prog.extend([main_pre, everything_else, main_post].iter().cloned());
line_offset += 1;
prog.push_str(everything_else);
prog.push_str("\n}");
}

debug!("final doctest:\n{}", prog);
Expand Down
27 changes: 18 additions & 9 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ fn initial_buffer_size(file: &File) -> usize {
/// ```
#[stable(feature = "fs_read_write_bytes", since = "1.26.0")]
pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let mut file = File::open(path)?;
let mut bytes = Vec::with_capacity(initial_buffer_size(&file));
file.read_to_end(&mut bytes)?;
Ok(bytes)
fn inner(path: &Path) -> io::Result<Vec<u8>> {
let mut file = File::open(path)?;
let mut bytes = Vec::with_capacity(initial_buffer_size(&file));
file.read_to_end(&mut bytes)?;
Ok(bytes)
}
inner(path.as_ref())
}

/// Read the entire contents of a file into a string.
Expand Down Expand Up @@ -296,10 +299,13 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
/// ```
#[stable(feature = "fs_read_write", since = "1.26.0")]
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
let mut file = File::open(path)?;
let mut string = String::with_capacity(initial_buffer_size(&file));
file.read_to_string(&mut string)?;
Ok(string)
fn inner(path: &Path) -> io::Result<String> {
let mut file = File::open(path)?;
let mut string = String::with_capacity(initial_buffer_size(&file));
file.read_to_string(&mut string)?;
Ok(string)
}
inner(path.as_ref())
}

/// Write a slice as the entire contents of a file.
Expand All @@ -326,7 +332,10 @@ pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
/// ```
#[stable(feature = "fs_read_write_bytes", since = "1.26.0")]
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
File::create(path)?.write_all(contents.as_ref())
fn inner(path: &Path, contents: &[u8]) -> io::Result<()> {
File::create(path)?.write_all(contents)
}
inner(path.as_ref(), contents.as_ref())
}

impl File {
Expand Down
Loading