Skip to content

Commit e82261d

Browse files
committed
Auto merge of #50413 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests Successful merges: - #50302 (Add query search order check) - #50320 (Fix invalid path generation in rustdoc search) - #50349 (Rename "show type declaration" to "show declaration") - #50360 (Clarify wordings of the `unstable_name_collision` lint.) - #50365 (Use two vectors in nearest_common_ancestor.) - #50393 (Allow unaligned reads in constants) - #50401 (Revert "Implement FromStr for PathBuf") - #50406 (Forbid constructing empty identifiers from concat_idents) - #50407 (Always inline simple BytePos and CharPos methods.) - #50416 (check if the token is a lifetime before parsing) - #50417 (Update Cargo) - #50421 (Fix ICE when using a..=b in a closure.) Failed merges:
2 parents d68b0ec + 03a0402 commit e82261d

File tree

26 files changed

+162
-61
lines changed

26 files changed

+162
-61
lines changed

src/libcore/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ mod builtin {
606606
#[macro_export]
607607
#[cfg(dox)]
608608
macro_rules! concat_idents {
609-
($($e:ident),*) => ({ /* compiler built-in */ });
610-
($($e:ident,)*) => ({ /* compiler built-in */ });
609+
($($e:ident),+) => ({ /* compiler built-in */ });
610+
($($e:ident,)+) => ({ /* compiler built-in */ });
611611
}
612612

613613
/// Concatenates literals into a static string slice.

src/librustc/hir/lowering.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3121,9 +3121,9 @@ impl<'a> LoweringContext<'a> {
31213121
}
31223122
// Desugar `<start>..=<end>` to `std::ops::RangeInclusive::new(<start>, <end>)`
31233123
ExprKind::Range(Some(ref e1), Some(ref e2), RangeLimits::Closed) => {
3124-
// FIXME: Use head_sp directly after RangeInclusive::new() is stabilized in stage0.
3124+
// FIXME: Use e.span directly after RangeInclusive::new() is stabilized in stage0.
31253125
let span = self.allow_internal_unstable(CompilerDesugaringKind::DotFill, e.span);
3126-
let id = self.lower_node_id(e.id);
3126+
let id = self.next_id();
31273127
let e1 = self.lower_expr(e1);
31283128
let e2 = self.lower_expr(e2);
31293129
let ty_path = P(self.std_path(span, &["ops", "RangeInclusive"], false));

src/librustc/lint/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
507507

508508
let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISION) {
509509
"once this method is added to the standard library, \
510-
there will be ambiguity here, which will cause a hard error!"
510+
the ambiguity may cause an error or change in behavior!"
511511
.to_owned()
512512
} else if let Some(edition) = future_incompatible.edition {
513513
format!("{} in the {} edition!", STANDARD_MESSAGE, edition)

src/librustc/middle/region.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -690,21 +690,22 @@ impl<'tcx> ScopeTree {
690690
// the start. So this algorithm is faster.
691691
let mut ma = Some(scope_a);
692692
let mut mb = Some(scope_b);
693-
let mut seen: SmallVec<[Scope; 32]> = SmallVec::new();
693+
let mut seen_a: SmallVec<[Scope; 32]> = SmallVec::new();
694+
let mut seen_b: SmallVec<[Scope; 32]> = SmallVec::new();
694695
loop {
695696
if let Some(a) = ma {
696-
if seen.iter().position(|s| *s == a).is_some() {
697+
if seen_b.iter().position(|s| *s == a).is_some() {
697698
return a;
698699
}
699-
seen.push(a);
700+
seen_a.push(a);
700701
ma = self.parent_map.get(&a).map(|s| *s);
701702
}
702703

703704
if let Some(b) = mb {
704-
if seen.iter().position(|s| *s == b).is_some() {
705+
if seen_a.iter().position(|s| *s == b).is_some() {
705706
return b;
706707
}
707-
seen.push(b);
708+
seen_b.push(b);
708709
mb = self.parent_map.get(&b).map(|s| *s);
709710
}
710711

src/librustc_mir/hair/pattern/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
792792
ConstVal::Value(miri) => const_val_field(
793793
self.tcx, self.param_env, instance,
794794
variant_opt, field, miri, cv.ty,
795-
).unwrap(),
795+
).expect("field access failed"),
796796
_ => bug!("{:#?} is not a valid adt", cv),
797797
};
798798
self.const_to_pat(instance, val, id, span)

src/librustc_mir/interpret/eval_context.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1340,9 +1340,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
13401340
use syntax::ast::FloatTy;
13411341

13421342
let layout = self.layout_of(ty)?;
1343-
// do the strongest layout check of the two
1344-
let align = layout.align.max(ptr_align);
1345-
self.memory.check_align(ptr, align)?;
1343+
self.memory.check_align(ptr, ptr_align)?;
13461344

13471345
if layout.size.bytes() == 0 {
13481346
return Ok(Some(Value::ByVal(PrimVal::Undef)));

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ impl<'a> Cache {
14271427
}
14281428
if let Some(ref item_name) = item.name {
14291429
let path = self.paths.get(&item.def_id)
1430-
.map(|p| p.0.join("::").to_string())
1430+
.map(|p| p.0[..p.0.len() - 1].join("::"))
14311431
.unwrap_or("std".to_owned());
14321432
for alias in item.attrs.lists("doc")
14331433
.filter(|a| a.check_name("alias"))

src/librustdoc/html/static/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@
19961996
if (e.parentNode.id === "main") {
19971997
var otherMessage;
19981998
if (hasClass(e, "type-decl")) {
1999-
otherMessage = '&nbsp;Show&nbsp;type&nbsp;declaration';
1999+
otherMessage = '&nbsp;Show&nbsp;declaration';
20002000
}
20012001
e.parentNode.insertBefore(createToggle(otherMessage), e);
20022002
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {

src/libstd/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ pub mod builtin {
450450
#[unstable(feature = "concat_idents_macro", issue = "29599")]
451451
#[macro_export]
452452
macro_rules! concat_idents {
453-
($($e:ident),*) => ({ /* compiler built-in */ });
454-
($($e:ident,)*) => ({ /* compiler built-in */ });
453+
($($e:ident),+) => ({ /* compiler built-in */ });
454+
($($e:ident,)+) => ({ /* compiler built-in */ });
455455
}
456456

457457
/// Concatenates literals into a static string slice.

src/libstd/path.rs

-27
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ use io;
8787
use iter::{self, FusedIterator};
8888
use ops::{self, Deref};
8989
use rc::Rc;
90-
use str::FromStr;
9190
use sync::Arc;
9291

9392
use ffi::{OsStr, OsString};
@@ -1441,32 +1440,6 @@ impl From<String> for PathBuf {
14411440
}
14421441
}
14431442

1444-
/// Error returned from [`PathBuf::from_str`][`from_str`].
1445-
///
1446-
/// Note that parsing a path will never fail. This error is just a placeholder
1447-
/// for implementing `FromStr` for `PathBuf`.
1448-
///
1449-
/// [`from_str`]: struct.PathBuf.html#method.from_str
1450-
#[derive(Debug, Clone, PartialEq, Eq)]
1451-
#[stable(feature = "path_from_str", since = "1.26.0")]
1452-
pub enum ParsePathError {}
1453-
1454-
#[stable(feature = "path_from_str", since = "1.26.0")]
1455-
impl fmt::Display for ParsePathError {
1456-
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
1457-
match *self {}
1458-
}
1459-
}
1460-
1461-
#[stable(feature = "path_from_str", since = "1.26.0")]
1462-
impl FromStr for PathBuf {
1463-
type Err = ParsePathError;
1464-
1465-
fn from_str(s: &str) -> Result<Self, Self::Err> {
1466-
Ok(PathBuf::from(s))
1467-
}
1468-
}
1469-
14701443
#[stable(feature = "rust1", since = "1.0.0")]
14711444
impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
14721445
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {

src/libsyntax/ext/tt/macro_parser.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,13 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
835835
"path" => token::NtPath(panictry!(p.parse_path_common(PathStyle::Type, false))),
836836
"meta" => token::NtMeta(panictry!(p.parse_meta_item())),
837837
"vis" => token::NtVis(panictry!(p.parse_visibility(true))),
838-
"lifetime" => token::NtLifetime(p.expect_lifetime().ident),
838+
"lifetime" => if p.check_lifetime() {
839+
token::NtLifetime(p.expect_lifetime().ident)
840+
} else {
841+
let token_str = pprust::token_to_string(&p.token);
842+
p.fatal(&format!("expected a lifetime, found `{}`", &token_str)).emit();
843+
FatalError.raise();
844+
}
839845
// this is not supposed to happen, since it has been checked
840846
// when compiling the macro.
841847
_ => p.span_bug(sp, "invalid fragment specifier"),

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ impl<'a> Parser<'a> {
20422042
})
20432043
}
20442044

2045-
fn check_lifetime(&mut self) -> bool {
2045+
pub fn check_lifetime(&mut self) -> bool {
20462046
self.expected_tokens.push(TokenType::Lifetime);
20472047
self.token.is_lifetime()
20482048
}

src/libsyntax_ext/concat_idents.rs

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
3131
return base::DummyResult::expr(sp);
3232
}
3333

34+
if tts.is_empty() {
35+
cx.span_err(sp, "concat_idents! takes 1 or more arguments.");
36+
return DummyResult::expr(sp);
37+
}
38+
3439
let mut res_str = String::new();
3540
for (i, e) in tts.iter().enumerate() {
3641
if i & 1 == 1 {

src/libsyntax_pos/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1150,13 +1150,17 @@ pub struct CharPos(pub usize);
11501150
// have been unsuccessful
11511151

11521152
impl Pos for BytePos {
1153+
#[inline(always)]
11531154
fn from_usize(n: usize) -> BytePos { BytePos(n as u32) }
1155+
1156+
#[inline(always)]
11541157
fn to_usize(&self) -> usize { let BytePos(n) = *self; n as usize }
11551158
}
11561159

11571160
impl Add for BytePos {
11581161
type Output = BytePos;
11591162

1163+
#[inline(always)]
11601164
fn add(self, rhs: BytePos) -> BytePos {
11611165
BytePos((self.to_usize() + rhs.to_usize()) as u32)
11621166
}
@@ -1165,6 +1169,7 @@ impl Add for BytePos {
11651169
impl Sub for BytePos {
11661170
type Output = BytePos;
11671171

1172+
#[inline(always)]
11681173
fn sub(self, rhs: BytePos) -> BytePos {
11691174
BytePos((self.to_usize() - rhs.to_usize()) as u32)
11701175
}
@@ -1183,13 +1188,17 @@ impl Decodable for BytePos {
11831188
}
11841189

11851190
impl Pos for CharPos {
1191+
#[inline(always)]
11861192
fn from_usize(n: usize) -> CharPos { CharPos(n) }
1193+
1194+
#[inline(always)]
11871195
fn to_usize(&self) -> usize { let CharPos(n) = *self; n }
11881196
}
11891197

11901198
impl Add for CharPos {
11911199
type Output = CharPos;
11921200

1201+
#[inline(always)]
11931202
fn add(self, rhs: CharPos) -> CharPos {
11941203
CharPos(self.to_usize() + rhs.to_usize())
11951204
}
@@ -1198,6 +1207,7 @@ impl Add for CharPos {
11981207
impl Sub for CharPos {
11991208
type Output = CharPos;
12001209

1210+
#[inline(always)]
12011211
fn sub(self, rhs: CharPos) -> CharPos {
12021212
CharPos(self.to_usize() - rhs.to_usize())
12031213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test for issue #50381: non-lifetime passed to :lifetime.
12+
13+
#![feature(macro_lifetime_matcher)]
14+
15+
macro_rules! m { ($x:lifetime) => { } }
16+
17+
fn main() {
18+
m!(a);
19+
//~^ ERROR expected a lifetime, found `a`
20+
}

src/test/run-pass/issue-50415.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
// -------- Simplified test case --------
13+
14+
let _ = || 0..=1;
15+
16+
// -------- Original test case --------
17+
18+
let full_length = 1024;
19+
let range = {
20+
// do some stuff, omit here
21+
None
22+
};
23+
24+
let range = range.map(|(s, t)| s..=t).unwrap_or(0..=(full_length-1));
25+
26+
assert_eq!(range, 0..=1023);
27+
}

src/test/rustdoc-js/alias-2.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-order
12+
1113
const QUERY = '+';
1214

1315
const EXPECTED = {
1416
'others': [
15-
{ 'path': 'std::ops::AddAssign', 'name': 'AddAssign' },
16-
{ 'path': 'std::ops::Add', 'name': 'Add' },
17+
{ 'path': 'std::ops', 'name': 'AddAssign' },
18+
{ 'path': 'std::ops', 'name': 'Add' },
1719
],
1820
};

src/test/rustdoc-js/alias.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-order
12+
1113
const QUERY = '[';
1214

1315
const EXPECTED = {
1416
'others': [
1517
{ 'path': 'std', 'name': 'slice' },
16-
{ 'path': 'std::ops::IndexMut', 'name': 'IndexMut' },
17-
{ 'path': 'std::ops::Index', 'name': 'Index' },
18+
{ 'path': 'std::ops', 'name': 'IndexMut' },
19+
{ 'path': 'std::ops', 'name': 'Index' },
1820
],
1921
};

src/test/rustdoc-js/basic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const QUERY = 'String';
1313
const EXPECTED = {
1414
'others': [
1515
{ 'path': 'std::string', 'name': 'String' },
16-
{ 'path': 'std::ffi', 'name': 'OsString' },
1716
{ 'path': 'std::ffi', 'name': 'CString' },
17+
{ 'path': 'std::ffi', 'name': 'OsString' },
1818
],
1919
'in_args': [
2020
{ 'path': 'std::str', 'name': 'eq' },

src/test/ui/const-eval/ice-packed.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
#[derive(Copy, Clone, PartialEq, Eq)]
13+
#[repr(packed)]
14+
pub struct Num(u64);
15+
16+
impl Num {
17+
pub const ZERO: Self = Num(0);
18+
}
19+
20+
pub fn decrement(a: Num) -> Num {
21+
match a {
22+
Num::ZERO => Num::ZERO,
23+
a => Num(a.0 - 1)
24+
}
25+
}
26+
27+
fn main() {
28+
}

src/test/ui/inference_unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ use inference_unstable_itertools::IpuItertools;
2525
fn main() {
2626
assert_eq!('x'.ipu_flatten(), 1);
2727
//~^ WARN a method with this name may be added to the standard library in the future
28-
//~^^ WARN once this method is added to the standard library, there will be ambiguity here
28+
//~^^ WARN once this method is added to the standard library, the ambiguity may cause an error
2929
}

src/test/ui/inference_unstable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | assert_eq!('x'.ipu_flatten(), 1);
55
| ^^^^^^^^^^^
66
|
77
= note: #[warn(unstable_name_collision)] on by default
8-
= warning: once this method is added to the standard library, there will be ambiguity here, which will cause a hard error!
8+
= warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior!
99
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
1010
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method
1111
= note: add #![feature(ipu_flatten)] to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten`

src/test/ui/issue-50403.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(concat_idents)]
12+
13+
fn main() {
14+
let x = concat_idents!(); //~ ERROR concat_idents! takes 1 or more arguments
15+
}

src/test/ui/issue-50403.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: concat_idents! takes 1 or more arguments.
2+
--> $DIR/issue-50403.rs:14:13
3+
|
4+
LL | let x = concat_idents!(); //~ ERROR concat_idents! takes 1 or more arguments
5+
| ^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)