Auto merge of #56557 - pietroalbini:rollup, r=pietroalbini
Rollup of 11 pull requests Successful merges: - #56315 (Rustdoc inline macro reexport) - #56332 ([rustdoc] Specific crate search) - #56362 (Stabilise exhaustive integer patterns) - #56426 (libsyntax_pos: A few tweaks) - #56441 (rustbuild: Fix issues with compiler docs) - #56446 (pass the parameter environment to `traits::find_associated_item`) - #56500 (cleanup: remove static lifetimes from consts) - #56525 (Avoid extra copy and syscall in std::env::current_exe) - #56528 (Remove unused dependency (rustc_lint -> rustc_mir)) - #56548 (Optimized string FromIterator + Extend impls) - #56553 (Don't print the profiling summary to stdout when -Zprofile-json is set) Failed merges: r? @ghost
This commit is contained in:
commit
367e783e6f
100 changed files with 700 additions and 400 deletions
|
@ -2352,7 +2352,6 @@ dependencies = [
|
|||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc 0.0.0",
|
||||
"rustc_data_structures 0.0.0",
|
||||
"rustc_mir 0.0.0",
|
||||
"rustc_target 0.0.0",
|
||||
"syntax 0.0.0",
|
||||
"syntax_pos 0.0.0",
|
||||
|
|
|
@ -697,9 +697,6 @@ impl Step for Rustc {
|
|||
return;
|
||||
}
|
||||
|
||||
// Build libstd docs so that we generate relative links.
|
||||
builder.ensure(Std { stage, target });
|
||||
|
||||
// Build rustc.
|
||||
builder.ensure(compile::Rustc { compiler, target });
|
||||
|
||||
|
@ -718,12 +715,16 @@ impl Step for Rustc {
|
|||
|
||||
// Find dependencies for top level crates.
|
||||
let mut compiler_crates = HashSet::new();
|
||||
for root_crate in &["rustc", "rustc_driver", "rustc_codegen_llvm"] {
|
||||
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
|
||||
let interned_root_crate = INTERNER.intern_str(root_crate);
|
||||
find_compiler_crates(builder, &interned_root_crate, &mut compiler_crates);
|
||||
}
|
||||
|
||||
for krate in &compiler_crates {
|
||||
// Create all crate output directories first to make sure rustdoc uses
|
||||
// relative links.
|
||||
// FIXME: Cargo should probably do this itself.
|
||||
t!(fs::create_dir_all(out_dir.join(krate)));
|
||||
cargo.arg("-p").arg(krate);
|
||||
}
|
||||
|
||||
|
@ -797,8 +798,8 @@ impl Step for Rustdoc {
|
|||
return;
|
||||
}
|
||||
|
||||
// Build libstd docs so that we generate relative links.
|
||||
builder.ensure(Std { stage, target });
|
||||
// Build rustc docs so that we generate relative links.
|
||||
builder.ensure(Rustc { stage, target });
|
||||
|
||||
// Build rustdoc.
|
||||
builder.ensure(tool::Rustdoc { host: compiler.host });
|
||||
|
@ -822,6 +823,10 @@ impl Step for Rustdoc {
|
|||
&[]
|
||||
);
|
||||
|
||||
// Only include compiler crates, no dependencies of those, such as `libc`.
|
||||
cargo.arg("--no-deps");
|
||||
cargo.arg("-p").arg("rustdoc");
|
||||
|
||||
cargo.env("RUSTDOCFLAGS", "--document-private-items");
|
||||
builder.run(&mut cargo);
|
||||
}
|
||||
|
|
|
@ -741,14 +741,14 @@ fn_anon_params
|
|||
;
|
||||
|
||||
fn_params_with_self
|
||||
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
|
||||
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
|
||||
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
|
||||
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
|
||||
| '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
|
||||
;
|
||||
|
||||
fn_anon_params_with_self
|
||||
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
|
||||
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
|
||||
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
|
||||
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
|
||||
| '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
|
||||
|
|
|
@ -577,7 +577,7 @@ impl String {
|
|||
return Cow::Borrowed("");
|
||||
};
|
||||
|
||||
const REPLACEMENT: &'static str = "\u{FFFD}";
|
||||
const REPLACEMENT: &str = "\u{FFFD}";
|
||||
|
||||
let mut res = String::with_capacity(v.len());
|
||||
res.push_str(first_valid);
|
||||
|
@ -1732,18 +1732,37 @@ impl<'a> FromIterator<&'a str> for String {
|
|||
#[stable(feature = "extend_string", since = "1.4.0")]
|
||||
impl FromIterator<String> for String {
|
||||
fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String {
|
||||
let mut buf = String::new();
|
||||
buf.extend(iter);
|
||||
buf
|
||||
let mut iterator = iter.into_iter();
|
||||
|
||||
// Because we're iterating over `String`s, we can avoid at least
|
||||
// one allocation by getting the first string from the iterator
|
||||
// and appending to it all the subsequent strings.
|
||||
match iterator.next() {
|
||||
None => String::new(),
|
||||
Some(mut buf) => {
|
||||
buf.extend(iterator);
|
||||
buf
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "herd_cows", since = "1.19.0")]
|
||||
impl<'a> FromIterator<Cow<'a, str>> for String {
|
||||
fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> String {
|
||||
let mut buf = String::new();
|
||||
buf.extend(iter);
|
||||
buf
|
||||
let mut iterator = iter.into_iter();
|
||||
|
||||
// Because we're iterating over CoWs, we can (potentially) avoid at least
|
||||
// one allocation by getting the first item and appending to it all the
|
||||
// subsequent items.
|
||||
match iterator.next() {
|
||||
None => String::new(),
|
||||
Some(cow) => {
|
||||
let mut buf = cow.into_owned();
|
||||
buf.extend(iterator);
|
||||
buf
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1753,9 +1772,7 @@ impl Extend<char> for String {
|
|||
let iterator = iter.into_iter();
|
||||
let (lower_bound, _) = iterator.size_hint();
|
||||
self.reserve(lower_bound);
|
||||
for ch in iterator {
|
||||
self.push(ch)
|
||||
}
|
||||
iterator.for_each(move |c| self.push(c));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1769,27 +1786,21 @@ impl<'a> Extend<&'a char> for String {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> Extend<&'a str> for String {
|
||||
fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I) {
|
||||
for s in iter {
|
||||
self.push_str(s)
|
||||
}
|
||||
iter.into_iter().for_each(move |s| self.push_str(s));
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "extend_string", since = "1.4.0")]
|
||||
impl Extend<String> for String {
|
||||
fn extend<I: IntoIterator<Item = String>>(&mut self, iter: I) {
|
||||
for s in iter {
|
||||
self.push_str(&s)
|
||||
}
|
||||
iter.into_iter().for_each(move |s| self.push_str(&s));
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "herd_cows", since = "1.19.0")]
|
||||
impl<'a> Extend<Cow<'a, str>> for String {
|
||||
fn extend<I: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: I) {
|
||||
for s in iter {
|
||||
self.push_str(&s)
|
||||
}
|
||||
iter.into_iter().for_each(move |s| self.push_str(&s));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1381,7 +1381,7 @@ impl<'a> Formatter<'a> {
|
|||
for part in formatted.parts {
|
||||
match *part {
|
||||
flt2dec::Part::Zero(mut nzeroes) => {
|
||||
const ZEROES: &'static str = // 64 zeroes
|
||||
const ZEROES: &str = // 64 zeroes
|
||||
"0000000000000000000000000000000000000000000000000000000000000000";
|
||||
while nzeroes > ZEROES.len() {
|
||||
self.buf.write_str(ZEROES)?;
|
||||
|
|
|
@ -80,7 +80,7 @@ pub(crate) fn is_printable(x: char) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
const SINGLETONS0U: &'static [(u8, u8)] = &[
|
||||
const SINGLETONS0U: &[(u8, u8)] = &[
|
||||
(0x00, 1),
|
||||
(0x03, 5),
|
||||
(0x05, 6),
|
||||
|
@ -122,7 +122,7 @@ const SINGLETONS0U: &'static [(u8, u8)] = &[
|
|||
(0xfe, 3),
|
||||
(0xff, 9),
|
||||
];
|
||||
const SINGLETONS0L: &'static [u8] = &[
|
||||
const SINGLETONS0L: &[u8] = &[
|
||||
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
|
||||
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
|
||||
0x0f, 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f,
|
||||
|
@ -162,7 +162,7 @@ const SINGLETONS0L: &'static [u8] = &[
|
|||
0x91, 0xfe, 0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9,
|
||||
0xd0, 0xd1, 0xd8, 0xd9, 0xe7, 0xfe, 0xff,
|
||||
];
|
||||
const SINGLETONS1U: &'static [(u8, u8)] = &[
|
||||
const SINGLETONS1U: &[(u8, u8)] = &[
|
||||
(0x00, 6),
|
||||
(0x01, 1),
|
||||
(0x03, 1),
|
||||
|
@ -197,7 +197,7 @@ const SINGLETONS1U: &'static [(u8, u8)] = &[
|
|||
(0xf0, 4),
|
||||
(0xf9, 4),
|
||||
];
|
||||
const SINGLETONS1L: &'static [u8] = &[
|
||||
const SINGLETONS1L: &[u8] = &[
|
||||
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
|
||||
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
|
||||
0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,
|
||||
|
@ -219,7 +219,7 @@ const SINGLETONS1L: &'static [u8] = &[
|
|||
0x78, 0x7d, 0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0,
|
||||
0xc0, 0xd0, 0x3f, 0x71, 0x72, 0x7b,
|
||||
];
|
||||
const NORMAL0: &'static [u8] = &[
|
||||
const NORMAL0: &[u8] = &[
|
||||
0x00, 0x20,
|
||||
0x5f, 0x22,
|
||||
0x82, 0xdf, 0x04,
|
||||
|
@ -363,7 +363,7 @@ const NORMAL0: &'static [u8] = &[
|
|||
0x1b, 0x03,
|
||||
0x0f, 0x0d,
|
||||
];
|
||||
const NORMAL1: &'static [u8] = &[
|
||||
const NORMAL1: &[u8] = &[
|
||||
0x5e, 0x22,
|
||||
0x7b, 0x05,
|
||||
0x03, 0x04,
|
||||
|
|
|
@ -381,7 +381,7 @@ macro_rules! define_dep_nodes {
|
|||
#[allow(dead_code, non_upper_case_globals)]
|
||||
pub mod label_strs {
|
||||
$(
|
||||
pub const $variant: &'static str = stringify!($variant);
|
||||
pub const $variant: &str = stringify!($variant);
|
||||
)*
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1201,7 +1201,7 @@ impl<'a> LoweringContext<'a> {
|
|||
None,
|
||||
P(hir::Path {
|
||||
def: self.expect_full_def(t.id),
|
||||
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfType.ident())],
|
||||
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfUpper.ident())],
|
||||
span: t.span,
|
||||
}),
|
||||
)),
|
||||
|
@ -2425,7 +2425,7 @@ impl<'a> LoweringContext<'a> {
|
|||
// Don't expose `Self` (recovered "keyword used as ident" parse error).
|
||||
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
|
||||
// Instead, use gensym("Self") to create a distinct name that looks the same.
|
||||
let ident = if param.ident.name == keywords::SelfType.name() {
|
||||
let ident = if param.ident.name == keywords::SelfUpper.name() {
|
||||
param.ident.gensym()
|
||||
} else {
|
||||
param.ident
|
||||
|
@ -2981,7 +2981,7 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
// Correctly resolve `self` imports
|
||||
if path.segments.len() > 1
|
||||
&& path.segments.last().unwrap().ident.name == keywords::SelfValue.name()
|
||||
&& path.segments.last().unwrap().ident.name == keywords::SelfLower.name()
|
||||
{
|
||||
let _ = path.segments.pop();
|
||||
if rename.is_none() {
|
||||
|
|
|
@ -475,7 +475,7 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn ty_param_name(&self, id: NodeId) -> Name {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfType.name(),
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfUpper.name(),
|
||||
Node::GenericParam(param) => param.name.ident().name,
|
||||
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ pub struct Path {
|
|||
|
||||
impl Path {
|
||||
pub fn is_global(&self) -> bool {
|
||||
!self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name()
|
||||
!self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ pub trait PpAnn {
|
|||
|
||||
pub struct NoAnn;
|
||||
impl PpAnn for NoAnn {}
|
||||
pub const NO_ANN: &'static dyn PpAnn = &NoAnn;
|
||||
pub const NO_ANN: &dyn PpAnn = &NoAnn;
|
||||
|
||||
impl PpAnn for hir::Crate {
|
||||
fn try_fetch_item(&self, item: ast::NodeId) -> Option<&hir::Item> {
|
||||
|
@ -1622,7 +1622,7 @@ impl<'a> State<'a> {
|
|||
if i > 0 {
|
||||
self.s.word("::")?
|
||||
}
|
||||
if segment.ident.name != keywords::CrateRoot.name() &&
|
||||
if segment.ident.name != keywords::PathRoot.name() &&
|
||||
segment.ident.name != keywords::DollarCrate.name() {
|
||||
self.print_ident(segment.ident)?;
|
||||
segment.with_generic_args(|generic_args| {
|
||||
|
@ -1636,7 +1636,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
|
||||
pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> {
|
||||
if segment.ident.name != keywords::CrateRoot.name() &&
|
||||
if segment.ident.name != keywords::PathRoot.name() &&
|
||||
segment.ident.name != keywords::DollarCrate.name() {
|
||||
self.print_ident(segment.ident)?;
|
||||
segment.with_generic_args(|generic_args| {
|
||||
|
@ -1664,7 +1664,7 @@ impl<'a> State<'a> {
|
|||
if i > 0 {
|
||||
self.s.word("::")?
|
||||
}
|
||||
if segment.ident.name != keywords::CrateRoot.name() &&
|
||||
if segment.ident.name != keywords::PathRoot.name() &&
|
||||
segment.ident.name != keywords::DollarCrate.name() {
|
||||
self.print_ident(segment.ident)?;
|
||||
segment.with_generic_args(|generic_args| {
|
||||
|
|
|
@ -134,14 +134,10 @@ impl_stable_hash_for!(struct ::syntax::attr::Stability {
|
|||
const_stability
|
||||
});
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>>
|
||||
for ::syntax::edition::Edition {
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
impl_stable_hash_for!(enum ::syntax::edition::Edition {
|
||||
Edition2015,
|
||||
Edition2018,
|
||||
});
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>>
|
||||
for ::syntax::attr::StabilityLevel {
|
||||
|
|
|
@ -24,15 +24,15 @@ mod impls_misc;
|
|||
mod impls_ty;
|
||||
mod impls_syntax;
|
||||
|
||||
pub const ATTR_DIRTY: &'static str = "rustc_dirty";
|
||||
pub const ATTR_CLEAN: &'static str = "rustc_clean";
|
||||
pub const ATTR_IF_THIS_CHANGED: &'static str = "rustc_if_this_changed";
|
||||
pub const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need";
|
||||
pub const ATTR_PARTITION_REUSED: &'static str = "rustc_partition_reused";
|
||||
pub const ATTR_PARTITION_CODEGENED: &'static str = "rustc_partition_codegened";
|
||||
pub const ATTR_EXPECTED_CGU_REUSE: &'static str = "rustc_expected_cgu_reuse";
|
||||
pub const ATTR_DIRTY: &str = "rustc_dirty";
|
||||
pub const ATTR_CLEAN: &str = "rustc_clean";
|
||||
pub const ATTR_IF_THIS_CHANGED: &str = "rustc_if_this_changed";
|
||||
pub const ATTR_THEN_THIS_WOULD_NEED: &str = "rustc_then_this_would_need";
|
||||
pub const ATTR_PARTITION_REUSED: &str = "rustc_partition_reused";
|
||||
pub const ATTR_PARTITION_CODEGENED: &str = "rustc_partition_codegened";
|
||||
pub const ATTR_EXPECTED_CGU_REUSE: &str = "rustc_expected_cgu_reuse";
|
||||
|
||||
pub const IGNORED_ATTRIBUTES: &'static [&'static str] = &[
|
||||
pub const IGNORED_ATTRIBUTES: &[&str] = &[
|
||||
"cfg",
|
||||
ATTR_IF_THIS_CHANGED,
|
||||
ATTR_THEN_THIS_WOULD_NEED,
|
||||
|
|
|
@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
let sp = ident.span;
|
||||
let var = self.variable(hir_id, sp);
|
||||
// Ignore unused self.
|
||||
if ident.name != keywords::SelfValue.name() {
|
||||
if ident.name != keywords::SelfLower.name() {
|
||||
if !self.warn_about_unused(sp, hir_id, entry_ln, var) {
|
||||
if self.live_on_entry(entry_ln, var).is_none() {
|
||||
self.report_dead_assign(hir_id, sp, var, true);
|
||||
|
|
|
@ -780,43 +780,42 @@ macro_rules! options {
|
|||
}
|
||||
|
||||
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
|
||||
pub const $stat: &'static [(&'static str, $setter_name,
|
||||
Option<&'static str>, &'static str)] =
|
||||
pub const $stat: &[(&str, $setter_name, Option<&str>, &str)] =
|
||||
&[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
|
||||
|
||||
#[allow(non_upper_case_globals, dead_code)]
|
||||
mod $mod_desc {
|
||||
pub const parse_bool: Option<&'static str> = None;
|
||||
pub const parse_opt_bool: Option<&'static str> =
|
||||
pub const parse_bool: Option<&str> = None;
|
||||
pub const parse_opt_bool: Option<&str> =
|
||||
Some("one of: `y`, `yes`, `on`, `n`, `no`, or `off`");
|
||||
pub const parse_string: Option<&'static str> = Some("a string");
|
||||
pub const parse_string_push: Option<&'static str> = Some("a string");
|
||||
pub const parse_pathbuf_push: Option<&'static str> = Some("a path");
|
||||
pub const parse_opt_string: Option<&'static str> = Some("a string");
|
||||
pub const parse_opt_pathbuf: Option<&'static str> = Some("a path");
|
||||
pub const parse_list: Option<&'static str> = Some("a space-separated list of strings");
|
||||
pub const parse_opt_list: Option<&'static str> = Some("a space-separated list of strings");
|
||||
pub const parse_uint: Option<&'static str> = Some("a number");
|
||||
pub const parse_passes: Option<&'static str> =
|
||||
pub const parse_string: Option<&str> = Some("a string");
|
||||
pub const parse_string_push: Option<&str> = Some("a string");
|
||||
pub const parse_pathbuf_push: Option<&str> = Some("a path");
|
||||
pub const parse_opt_string: Option<&str> = Some("a string");
|
||||
pub const parse_opt_pathbuf: Option<&str> = Some("a path");
|
||||
pub const parse_list: Option<&str> = Some("a space-separated list of strings");
|
||||
pub const parse_opt_list: Option<&str> = Some("a space-separated list of strings");
|
||||
pub const parse_uint: Option<&str> = Some("a number");
|
||||
pub const parse_passes: Option<&str> =
|
||||
Some("a space-separated list of passes, or `all`");
|
||||
pub const parse_opt_uint: Option<&'static str> =
|
||||
pub const parse_opt_uint: Option<&str> =
|
||||
Some("a number");
|
||||
pub const parse_panic_strategy: Option<&'static str> =
|
||||
pub const parse_panic_strategy: Option<&str> =
|
||||
Some("either `unwind` or `abort`");
|
||||
pub const parse_relro_level: Option<&'static str> =
|
||||
pub const parse_relro_level: Option<&str> =
|
||||
Some("one of: `full`, `partial`, or `off`");
|
||||
pub const parse_sanitizer: Option<&'static str> =
|
||||
pub const parse_sanitizer: Option<&str> =
|
||||
Some("one of: `address`, `leak`, `memory` or `thread`");
|
||||
pub const parse_linker_flavor: Option<&'static str> =
|
||||
pub const parse_linker_flavor: Option<&str> =
|
||||
Some(::rustc_target::spec::LinkerFlavor::one_of());
|
||||
pub const parse_optimization_fuel: Option<&'static str> =
|
||||
pub const parse_optimization_fuel: Option<&str> =
|
||||
Some("crate=integer");
|
||||
pub const parse_unpretty: Option<&'static str> =
|
||||
pub const parse_unpretty: Option<&str> =
|
||||
Some("`string` or `string=string`");
|
||||
pub const parse_lto: Option<&'static str> =
|
||||
pub const parse_lto: Option<&str> =
|
||||
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
|
||||
`fat`, or omitted");
|
||||
pub const parse_cross_lang_lto: Option<&'static str> =
|
||||
pub const parse_cross_lang_lto: Option<&str> =
|
||||
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), \
|
||||
or the path to the linker plugin");
|
||||
}
|
||||
|
|
|
@ -179,12 +179,12 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
|
|||
// "lib" (i.e. non-default), this value is used (see issue #16552).
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
const PRIMARY_LIB_DIR: &'static str = "lib64";
|
||||
const PRIMARY_LIB_DIR: &str = "lib64";
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
const PRIMARY_LIB_DIR: &'static str = "lib32";
|
||||
const PRIMARY_LIB_DIR: &str = "lib32";
|
||||
|
||||
const SECONDARY_LIB_DIR: &'static str = "lib";
|
||||
const SECONDARY_LIB_DIR: &str = "lib";
|
||||
|
||||
match option_env!("CFG_LIBDIR_RELATIVE") {
|
||||
Some(libdir) if libdir != "lib" => libdir.into(),
|
||||
|
@ -198,4 +198,4 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
|
|||
|
||||
// The name of rustc's own place to organize libraries.
|
||||
// Used to be "rustc", now the default is "rustlib"
|
||||
const RUST_LIB_DIR: &'static str = "rustlib";
|
||||
const RUST_LIB_DIR: &str = "rustlib";
|
||||
|
|
|
@ -826,7 +826,7 @@ impl Session {
|
|||
}
|
||||
|
||||
pub fn profiler<F: FnOnce(&mut SelfProfiler) -> ()>(&self, f: F) {
|
||||
if self.opts.debugging_opts.self_profile {
|
||||
if self.opts.debugging_opts.self_profile || self.opts.debugging_opts.profile_json {
|
||||
let mut profiler = self.self_profiling.borrow_mut();
|
||||
f(&mut profiler);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
|||
source_substs: &'tcx Substs<'tcx>,
|
||||
target_node: specialization_graph::Node)
|
||||
-> &'tcx Substs<'tcx> {
|
||||
debug!("translate_substs({:?}, {:?}, {:?}, {:?})",
|
||||
param_env, source_impl, source_substs, target_node);
|
||||
let source_trait_ref = infcx.tcx
|
||||
.impl_trait_ref(source_impl)
|
||||
.unwrap()
|
||||
|
@ -119,10 +121,13 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
|||
/// whichever applies.
|
||||
pub fn find_associated_item<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
item: &ty::AssociatedItem,
|
||||
substs: &'tcx Substs<'tcx>,
|
||||
impl_data: &super::VtableImplData<'tcx, ()>,
|
||||
) -> (DefId, &'tcx Substs<'tcx>) {
|
||||
debug!("find_associated_item({:?}, {:?}, {:?}, {:?})",
|
||||
param_env, item, substs, impl_data);
|
||||
assert!(!substs.needs_infer());
|
||||
|
||||
let trait_def_id = tcx.trait_id_of_impl(impl_data.impl_def_id).unwrap();
|
||||
|
@ -132,7 +137,7 @@ pub fn find_associated_item<'a, 'tcx>(
|
|||
match ancestors.defs(tcx, item.ident, item.kind, trait_def_id).next() {
|
||||
Some(node_item) => {
|
||||
let substs = tcx.infer_ctxt().enter(|infcx| {
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
let param_env = param_env.with_reveal_all();
|
||||
let substs = substs.rebase_onto(tcx, trait_def_id, impl_data.substs);
|
||||
let substs = translate_substs(&infcx, param_env, impl_data.impl_def_id,
|
||||
substs, node_item.node);
|
||||
|
@ -219,12 +224,17 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
|||
source_trait_ref: ty::TraitRef<'tcx>,
|
||||
target_impl: DefId)
|
||||
-> Result<&'tcx Substs<'tcx>, ()> {
|
||||
debug!("fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)",
|
||||
param_env, source_trait_ref, target_impl);
|
||||
|
||||
let selcx = &mut SelectionContext::new(&infcx);
|
||||
let target_substs = infcx.fresh_substs_for_item(DUMMY_SP, target_impl);
|
||||
let (target_trait_ref, mut obligations) = impl_trait_ref_and_oblig(selcx,
|
||||
param_env,
|
||||
target_impl,
|
||||
target_substs);
|
||||
debug!("fulfill_implication: target_trait_ref={:?}, obligations={:?}",
|
||||
target_trait_ref, obligations);
|
||||
|
||||
// do the impls unify? If not, no specialization.
|
||||
match infcx.at(&ObligationCause::dummy(), param_env)
|
||||
|
|
|
@ -33,8 +33,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> {
|
|||
if ty::tls::with(|tcx| tcx.sess.verbose()) {
|
||||
write!(
|
||||
f,
|
||||
"Obligation(predicate={:?},cause={:?},depth={})",
|
||||
self.predicate, self.cause, self.recursion_depth
|
||||
"Obligation(predicate={:?},cause={:?},param_env={:?},depth={})",
|
||||
self.predicate, self.cause, self.param_env, self.recursion_depth
|
||||
)
|
||||
} else {
|
||||
write!(
|
||||
|
|
|
@ -1493,12 +1493,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
BorrowckMode::Ast => match self.sess.edition() {
|
||||
Edition::Edition2015 => BorrowckMode::Ast,
|
||||
Edition::Edition2018 => BorrowckMode::Migrate,
|
||||
|
||||
// For now, future editions mean Migrate. (But it
|
||||
// would make a lot of sense for it to be changed to
|
||||
// `BorrowckMode::Mir`, depending on how we plan to
|
||||
// time the forcing of full migration to NLL.)
|
||||
_ => BorrowckMode::Migrate,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2710,7 +2704,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn mk_self_type(self) -> Ty<'tcx> {
|
||||
self.mk_ty_param(0, keywords::SelfType.name().as_interned_str())
|
||||
self.mk_ty_param(0, keywords::SelfUpper.name().as_interned_str())
|
||||
}
|
||||
|
||||
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> {
|
||||
|
|
|
@ -347,9 +347,10 @@ fn resolve_associated_item<'a, 'tcx>(
|
|||
) -> Option<Instance<'tcx>> {
|
||||
let def_id = trait_item.def_id;
|
||||
debug!("resolve_associated_item(trait_item={:?}, \
|
||||
param_env={:?}, \
|
||||
trait_id={:?}, \
|
||||
rcvr_substs={:?})",
|
||||
def_id, trait_id, rcvr_substs);
|
||||
def_id, param_env, trait_id, rcvr_substs);
|
||||
|
||||
let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs);
|
||||
let vtbl = tcx.codegen_fulfill_obligation((param_env, ty::Binder::bind(trait_ref)));
|
||||
|
@ -359,7 +360,7 @@ fn resolve_associated_item<'a, 'tcx>(
|
|||
match vtbl {
|
||||
traits::VtableImpl(impl_data) => {
|
||||
let (def_id, substs) = traits::find_associated_item(
|
||||
tcx, trait_item, rcvr_substs, &impl_data);
|
||||
tcx, param_env, trait_item, rcvr_substs, &impl_data);
|
||||
let substs = tcx.erase_regions(&substs);
|
||||
Some(ty::Instance::new(def_id, substs))
|
||||
}
|
||||
|
|
|
@ -1020,7 +1020,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
|
|||
}
|
||||
|
||||
pub fn for_self() -> ParamTy {
|
||||
ParamTy::new(0, keywords::SelfType.name().as_interned_str())
|
||||
ParamTy::new(0, keywords::SelfUpper.name().as_interned_str())
|
||||
}
|
||||
|
||||
pub fn for_def(def: &ty::GenericParamDef) -> ParamTy {
|
||||
|
@ -1035,7 +1035,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
|
|||
// FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere,
|
||||
// but this should only be possible when using `-Z continue-parse-after-error` like
|
||||
// `compile-fail/issue-36638.rs`.
|
||||
self.name == keywords::SelfType.name().as_str() && self.idx == 0
|
||||
self.name == keywords::SelfUpper.name().as_str() && self.idx == 0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1787,6 +1787,13 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_pointer_sized(&self) -> bool {
|
||||
match self.sty {
|
||||
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_machine(&self) -> bool {
|
||||
match self.sty {
|
||||
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => false,
|
||||
|
|
|
@ -28,7 +28,7 @@ use lazy_static;
|
|||
use session::Session;
|
||||
|
||||
// The name of the associated type for `Fn` return types
|
||||
pub const FN_OUTPUT_NAME: &'static str = "Output";
|
||||
pub const FN_OUTPUT_NAME: &str = "Output";
|
||||
|
||||
// Useful type to use with `Result<>` indicate that an error has already
|
||||
// been reported to the user, so no need to continue checking.
|
||||
|
|
|
@ -225,7 +225,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// These are weak symbols that point to the profile version and the
|
||||
// profile name, which need to be treated as exported so LTO doesn't nix
|
||||
// them.
|
||||
const PROFILER_WEAK_SYMBOLS: [&'static str; 2] = [
|
||||
const PROFILER_WEAK_SYMBOLS: [&str; 2] = [
|
||||
"__llvm_profile_raw_version",
|
||||
"__llvm_profile_filename",
|
||||
];
|
||||
|
|
|
@ -389,7 +389,7 @@ impl SymbolPathBuffer {
|
|||
|
||||
impl ItemPathBuffer for SymbolPathBuffer {
|
||||
fn root_mode(&self) -> &RootMode {
|
||||
const ABSOLUTE: &'static RootMode = &RootMode::Absolute;
|
||||
const ABSOLUTE: &RootMode = &RootMode::Absolute;
|
||||
ABSOLUTE
|
||||
}
|
||||
|
||||
|
|
|
@ -356,10 +356,10 @@ pub fn compile_input(
|
|||
|
||||
if sess.opts.debugging_opts.self_profile {
|
||||
sess.print_profiler_results();
|
||||
}
|
||||
|
||||
if sess.opts.debugging_opts.profile_json {
|
||||
sess.save_json_results();
|
||||
}
|
||||
if sess.opts.debugging_opts.profile_json {
|
||||
sess.save_json_results();
|
||||
}
|
||||
|
||||
controller_entry_point!(
|
||||
|
|
|
@ -40,9 +40,9 @@ use syntax::ast;
|
|||
use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED,
|
||||
ATTR_EXPECTED_CGU_REUSE};
|
||||
|
||||
const MODULE: &'static str = "module";
|
||||
const CFG: &'static str = "cfg";
|
||||
const KIND: &'static str = "kind";
|
||||
const MODULE: &str = "module";
|
||||
const CFG: &str = "cfg";
|
||||
const KIND: &str = "kind";
|
||||
|
||||
pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
|
|
|
@ -28,7 +28,7 @@ use rustc::session::config::nightly_options;
|
|||
use rustc_serialize::opaque::Encoder;
|
||||
|
||||
/// The first few bytes of files generated by incremental compilation
|
||||
const FILE_MAGIC: &'static [u8] = b"RSIC";
|
||||
const FILE_MAGIC: &[u8] = b"RSIC";
|
||||
|
||||
/// Change this if the header format changes
|
||||
const HEADER_FORMAT_VERSION: u16 = 0;
|
||||
|
@ -36,7 +36,7 @@ const HEADER_FORMAT_VERSION: u16 = 0;
|
|||
/// A version string that hopefully is always different for compiler versions
|
||||
/// with different encodings of incremental compilation artifacts. Contains
|
||||
/// the git commit hash.
|
||||
const RUSTC_VERSION: Option<&'static str> = option_env!("CFG_VERSION");
|
||||
const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
|
||||
|
||||
pub fn write_file_header(stream: &mut Encoder) {
|
||||
stream.emit_raw_bytes(FILE_MAGIC);
|
||||
|
|
|
@ -128,10 +128,10 @@ use std::time::{UNIX_EPOCH, SystemTime, Duration};
|
|||
|
||||
use rand::{RngCore, thread_rng};
|
||||
|
||||
const LOCK_FILE_EXT: &'static str = ".lock";
|
||||
const DEP_GRAPH_FILENAME: &'static str = "dep-graph.bin";
|
||||
const WORK_PRODUCTS_FILENAME: &'static str = "work-products.bin";
|
||||
const QUERY_CACHE_FILENAME: &'static str = "query-cache.bin";
|
||||
const LOCK_FILE_EXT: &str = ".lock";
|
||||
const DEP_GRAPH_FILENAME: &str = "dep-graph.bin";
|
||||
const WORK_PRODUCTS_FILENAME: &str = "work-products.bin";
|
||||
const QUERY_CACHE_FILENAME: &str = "query-cache.bin";
|
||||
|
||||
// We encode integers using the following base, so they are shorter than decimal
|
||||
// or hexadecimal numbers (we want short file and directory names). Since these
|
||||
|
|
|
@ -12,7 +12,6 @@ test = false
|
|||
[dependencies]
|
||||
log = "0.4"
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_mir = { path = "../librustc_mir"}
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
|
|
|
@ -36,7 +36,6 @@ extern crate syntax;
|
|||
extern crate rustc;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate rustc_mir;
|
||||
extern crate rustc_target;
|
||||
extern crate syntax_pos;
|
||||
extern crate rustc_data_structures;
|
||||
|
|
|
@ -473,7 +473,7 @@ impl UnusedImportBraces {
|
|||
match items[0].0.kind {
|
||||
ast::UseTreeKind::Simple(rename, ..) => {
|
||||
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
|
||||
if orig_ident.name == keywords::SelfValue.name() {
|
||||
if orig_ident.name == keywords::SelfLower.name() {
|
||||
return;
|
||||
}
|
||||
node_ident = rename.unwrap_or(orig_ident);
|
||||
|
|
|
@ -52,7 +52,7 @@ pub const METADATA_VERSION: u8 = 4;
|
|||
/// This header is followed by the position of the `CrateRoot`,
|
||||
/// which is encoded as a 32-bit big-endian unsigned integer,
|
||||
/// and further followed by the rustc version string.
|
||||
pub const METADATA_HEADER: &'static [u8; 12] =
|
||||
pub const METADATA_HEADER: &[u8; 12] =
|
||||
&[0, 0, 0, 0, b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
|
||||
|
||||
/// A value of type T referred to by its absolute position
|
||||
|
|
|
@ -263,7 +263,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
|||
// Deliberately fall into this case for all implicit self types,
|
||||
// so that we don't fall in to the next case with them.
|
||||
*kind == mir::ImplicitSelfKind::MutRef
|
||||
} else if Some(keywords::SelfValue.name()) == local_decl.name {
|
||||
} else if Some(keywords::SelfLower.name()) == local_decl.name {
|
||||
// Otherwise, check if the name is the self kewyord - in which case
|
||||
// we have an explicit self. Do the same thing in this case and check
|
||||
// for a `self: &mut Self` to suggest removing the `&mut`.
|
||||
|
|
|
@ -137,8 +137,8 @@ where MWF: MirWithFlowState<'tcx>,
|
|||
block: BasicBlock,
|
||||
mir: &Mir) -> io::Result<()> {
|
||||
// Header rows
|
||||
const HDRS: [&'static str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
|
||||
const HDR_FMT: &'static str = "bgcolor=\"grey\"";
|
||||
const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
|
||||
const HDR_FMT: &str = "bgcolor=\"grey\"";
|
||||
write!(w, "<table><tr><td rowspan=\"{}\">", HDRS.len())?;
|
||||
write!(w, "{:?}", block.index())?;
|
||||
write!(w, "</td></tr><tr>")?;
|
||||
|
|
|
@ -606,7 +606,7 @@ static X: i32 = 1;
|
|||
const C: i32 = 2;
|
||||
|
||||
// these three are not allowed:
|
||||
const CR: &'static mut i32 = &mut C;
|
||||
const CR: &mut i32 = &mut C;
|
||||
static STATIC_REF: &'static mut i32 = &mut X;
|
||||
static CONST_REF: &'static mut i32 = &mut C;
|
||||
```
|
||||
|
@ -1163,7 +1163,7 @@ You can also have this error while using a cell type:
|
|||
use std::cell::Cell;
|
||||
|
||||
const A: Cell<usize> = Cell::new(1);
|
||||
const B: &'static Cell<usize> = &A;
|
||||
const B: &Cell<usize> = &A;
|
||||
// error: cannot borrow a constant which may contain interior mutability,
|
||||
// create a static instead
|
||||
|
||||
|
@ -1171,10 +1171,10 @@ const B: &'static Cell<usize> = &A;
|
|||
struct C { a: Cell<usize> }
|
||||
|
||||
const D: C = C { a: Cell::new(1) };
|
||||
const E: &'static Cell<usize> = &D.a; // error
|
||||
const E: &Cell<usize> = &D.a; // error
|
||||
|
||||
// or:
|
||||
const F: &'static C = &D; // error
|
||||
const F: &C = &D; // error
|
||||
```
|
||||
|
||||
This is because cell types do operations that are not thread-safe. Due to this,
|
||||
|
|
|
@ -584,7 +584,6 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
-> Vec<Constructor<'tcx>>
|
||||
{
|
||||
debug!("all_constructors({:?})", pcx.ty);
|
||||
let exhaustive_integer_patterns = cx.tcx.features().exhaustive_integer_patterns;
|
||||
let ctors = match pcx.ty.sty {
|
||||
ty::Bool => {
|
||||
[true, false].iter().map(|&b| {
|
||||
|
@ -614,7 +613,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
.map(|v| Variant(v.did))
|
||||
.collect()
|
||||
}
|
||||
ty::Char if exhaustive_integer_patterns => {
|
||||
ty::Char => {
|
||||
vec![
|
||||
// The valid Unicode Scalar Value ranges.
|
||||
ConstantRange('\u{0000}' as u128,
|
||||
|
@ -629,14 +628,14 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
),
|
||||
]
|
||||
}
|
||||
ty::Int(ity) if exhaustive_integer_patterns => {
|
||||
ty::Int(ity) => {
|
||||
// FIXME(49937): refactor these bit manipulations into interpret.
|
||||
let bits = Integer::from_attr(&cx.tcx, SignedInt(ity)).size().bits() as u128;
|
||||
let min = 1u128 << (bits - 1);
|
||||
let max = (1u128 << (bits - 1)) - 1;
|
||||
vec![ConstantRange(min, max, pcx.ty, RangeEnd::Included)]
|
||||
}
|
||||
ty::Uint(uty) if exhaustive_integer_patterns => {
|
||||
ty::Uint(uty) => {
|
||||
// FIXME(49937): refactor these bit manipulations into interpret.
|
||||
let bits = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size().bits() as u128;
|
||||
let max = !0u128 >> (128 - bits);
|
||||
|
@ -775,8 +774,17 @@ impl<'tcx> IntRange<'tcx> {
|
|||
fn from_ctor(tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
ctor: &Constructor<'tcx>)
|
||||
-> Option<IntRange<'tcx>> {
|
||||
// Floating-point ranges are permitted and we don't want
|
||||
// to consider them when constructing integer ranges.
|
||||
fn is_integral<'tcx>(ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::Char | ty::Int(_) | ty::Uint(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
match ctor {
|
||||
ConstantRange(lo, hi, ty, end) => {
|
||||
ConstantRange(lo, hi, ty, end) if is_integral(ty) => {
|
||||
// Perform a shift if the underlying types are signed,
|
||||
// which makes the interval arithmetic simpler.
|
||||
let bias = IntRange::signed_bias(tcx, ty);
|
||||
|
@ -789,7 +797,7 @@ impl<'tcx> IntRange<'tcx> {
|
|||
Some(IntRange { range: lo..=(hi - offset), ty })
|
||||
}
|
||||
}
|
||||
ConstantValue(val) => {
|
||||
ConstantValue(val) if is_integral(val.ty) => {
|
||||
let ty = val.ty;
|
||||
if let Some(val) = val.assert_bits(tcx, ty::ParamEnv::empty().and(ty)) {
|
||||
let bias = IntRange::signed_bias(tcx, ty);
|
||||
|
@ -799,9 +807,7 @@ impl<'tcx> IntRange<'tcx> {
|
|||
None
|
||||
}
|
||||
}
|
||||
Single | Variant(_) | Slice(_) => {
|
||||
None
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,12 +939,10 @@ fn compute_missing_ctors<'a, 'tcx: 'a>(
|
|||
// If a constructor appears in a `match` arm, we can
|
||||
// eliminate it straight away.
|
||||
refined_ctors = vec![]
|
||||
} else if tcx.features().exhaustive_integer_patterns {
|
||||
if let Some(interval) = IntRange::from_ctor(tcx, used_ctor) {
|
||||
// Refine the required constructors for the type by subtracting
|
||||
// the range defined by the current constructor pattern.
|
||||
refined_ctors = interval.subtract_from(tcx, refined_ctors);
|
||||
}
|
||||
} else if let Some(interval) = IntRange::from_ctor(tcx, used_ctor) {
|
||||
// Refine the required constructors for the type by subtracting
|
||||
// the range defined by the current constructor pattern.
|
||||
refined_ctors = interval.subtract_from(tcx, refined_ctors);
|
||||
}
|
||||
|
||||
// If the constructor patterns that have been considered so far
|
||||
|
@ -1094,7 +1098,8 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
|
||||
// For privately empty and non-exhaustive enums, we work as if there were an "extra"
|
||||
// `_` constructor for the type, so we can never match over all constructors.
|
||||
let is_non_exhaustive = is_privately_empty || is_declared_nonexhaustive;
|
||||
let is_non_exhaustive = is_privately_empty || is_declared_nonexhaustive ||
|
||||
(pcx.ty.is_pointer_sized() && !cx.tcx.features().precise_pointer_size_matching);
|
||||
|
||||
if cheap_missing_ctors == MissingCtors::Empty && !is_non_exhaustive {
|
||||
split_grouped_constructors(cx.tcx, all_ctors, matrix, pcx.ty).into_iter().map(|c| {
|
||||
|
@ -1390,17 +1395,16 @@ fn slice_pat_covered_by_constructor<'tcx>(
|
|||
// Whether to evaluate a constructor using exhaustive integer matching. This is true if the
|
||||
// constructor is a range or constant with an integer type.
|
||||
fn should_treat_range_exhaustively(tcx: TyCtxt<'_, 'tcx, 'tcx>, ctor: &Constructor<'tcx>) -> bool {
|
||||
if tcx.features().exhaustive_integer_patterns {
|
||||
let ty = match ctor {
|
||||
ConstantValue(value) => value.ty,
|
||||
ConstantRange(_, _, ty, _) => ty,
|
||||
_ => return false,
|
||||
};
|
||||
if let ty::Char | ty::Int(_) | ty::Uint(_) = ty.sty {
|
||||
return true;
|
||||
}
|
||||
let ty = match ctor {
|
||||
ConstantValue(value) => value.ty,
|
||||
ConstantRange(_, _, ty, _) => ty,
|
||||
_ => return false,
|
||||
};
|
||||
if let ty::Char | ty::Int(_) | ty::Uint(_) = ty.sty {
|
||||
!ty.is_pointer_sized() || tcx.features().precise_pointer_size_matching
|
||||
} else {
|
||||
false
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// For exhaustive integer matching, some constructors are grouped within other constructors
|
||||
|
|
|
@ -24,7 +24,7 @@ use std::path::{Path, PathBuf};
|
|||
use super::graphviz::write_mir_fn_graphviz;
|
||||
use transform::MirSource;
|
||||
|
||||
const INDENT: &'static str = " ";
|
||||
const INDENT: &str = " ";
|
||||
/// Alignment for lining up comments following MIR statements
|
||||
pub(crate) const ALIGN: usize = 40;
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
}
|
||||
_ => None,
|
||||
}.map(|ctxt| Segment::from_ident(Ident::new(
|
||||
keywords::CrateRoot.name(), use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt)
|
||||
keywords::PathRoot.name(), use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt)
|
||||
)));
|
||||
|
||||
let prefix = crate_root.into_iter().chain(prefix_iter).collect::<Vec<_>>();
|
||||
|
@ -153,7 +153,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
|
||||
let empty_for_self = |prefix: &[Segment]| {
|
||||
prefix.is_empty() ||
|
||||
prefix.len() == 1 && prefix[0].ident.name == keywords::CrateRoot.name()
|
||||
prefix.len() == 1 && prefix[0].ident.name == keywords::PathRoot.name()
|
||||
};
|
||||
match use_tree.kind {
|
||||
ast::UseTreeKind::Simple(rename, ..) => {
|
||||
|
@ -164,7 +164,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
|
||||
if nested {
|
||||
// Correctly handle `self`
|
||||
if source.ident.name == keywords::SelfValue.name() {
|
||||
if source.ident.name == keywords::SelfLower.name() {
|
||||
type_ns_only = true;
|
||||
|
||||
if empty_for_self(&module_path) {
|
||||
|
@ -185,7 +185,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
}
|
||||
} else {
|
||||
// Disallow `self`
|
||||
if source.ident.name == keywords::SelfValue.name() {
|
||||
if source.ident.name == keywords::SelfLower.name() {
|
||||
resolve_error(self,
|
||||
use_tree.span,
|
||||
ResolutionError::SelfImportsOnlyAllowedWithin);
|
||||
|
@ -205,7 +205,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
// `crate_name` should not be interpreted as relative.
|
||||
module_path.push(Segment {
|
||||
ident: Ident {
|
||||
name: keywords::CrateRoot.name(),
|
||||
name: keywords::PathRoot.name(),
|
||||
span: source.ident.span,
|
||||
},
|
||||
id: Some(self.session.next_node_id()),
|
||||
|
@ -270,7 +270,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
// Ensure there is at most one `self` in the list
|
||||
let self_spans = items.iter().filter_map(|&(ref use_tree, _)| {
|
||||
if let ast::UseTreeKind::Simple(..) = use_tree.kind {
|
||||
if use_tree.ident().name == keywords::SelfValue.name() {
|
||||
if use_tree.ident().name == keywords::SelfLower.name() {
|
||||
return Some(use_tree.span);
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
let new_span = prefix[prefix.len() - 1].ident.span;
|
||||
let tree = ast::UseTree {
|
||||
prefix: ast::Path::from_ident(
|
||||
Ident::new(keywords::SelfValue.name(), new_span)
|
||||
Ident::new(keywords::SelfLower.name(), new_span)
|
||||
),
|
||||
kind: ast::UseTreeKind::Simple(
|
||||
Some(Ident::new(keywords::Underscore.name().gensymed(), new_span)),
|
||||
|
@ -344,13 +344,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
}
|
||||
|
||||
ItemKind::ExternCrate(orig_name) => {
|
||||
let module = if orig_name.is_none() && ident.name == keywords::SelfValue.name() {
|
||||
let module = if orig_name.is_none() && ident.name == keywords::SelfLower.name() {
|
||||
self.session
|
||||
.struct_span_err(item.span, "`extern crate self;` requires renaming")
|
||||
.span_suggestion(item.span, "try", "extern crate self as name;".into())
|
||||
.emit();
|
||||
return;
|
||||
} else if orig_name == Some(keywords::SelfValue.name()) {
|
||||
} else if orig_name == Some(keywords::SelfLower.name()) {
|
||||
if !self.session.features_untracked().extern_crate_self {
|
||||
emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span,
|
||||
GateIssue::Language, "`extern crate self` is unstable");
|
||||
|
@ -783,7 +783,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
"an `extern crate` loading macros must be at the crate root");
|
||||
}
|
||||
if let ItemKind::ExternCrate(Some(orig_name)) = item.node {
|
||||
if orig_name == keywords::SelfValue.name() {
|
||||
if orig_name == keywords::SelfLower.name() {
|
||||
self.session.span_err(attr.span,
|
||||
"`macro_use` is not supported on `extern crate self`");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
|
|||
match (path.get(0), path.get(1)) {
|
||||
// `{{root}}::ident::...` on both editions.
|
||||
// On 2015 `{{root}}` is usually added implicitly.
|
||||
(Some(fst), Some(snd)) if fst.ident.name == keywords::CrateRoot.name() &&
|
||||
(Some(fst), Some(snd)) if fst.ident.name == keywords::PathRoot.name() &&
|
||||
!snd.ident.is_path_segment_keyword() => {}
|
||||
// `ident::...` on 2018
|
||||
(Some(fst), _) if fst.ident.span.rust_2018() &&
|
||||
|
@ -61,7 +61,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
|
|||
parent_scope: &ParentScope<'b>,
|
||||
) -> Option<(Vec<Segment>, Option<String>)> {
|
||||
// Replace first ident with `self` and check if that is valid.
|
||||
path[0].ident.name = keywords::SelfValue.name();
|
||||
path[0].ident.name = keywords::SelfLower.name();
|
||||
let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
|
||||
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
|
||||
if let PathResult::Module(..) = result {
|
||||
|
|
|
@ -769,7 +769,7 @@ impl<'a, 'tcx, 'cl> Visitor<'tcx> for Resolver<'a, 'cl> {
|
|||
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
|
||||
}
|
||||
TyKind::ImplicitSelf => {
|
||||
let self_ty = keywords::SelfType.ident();
|
||||
let self_ty = keywords::SelfUpper.ident();
|
||||
let def = self.resolve_ident_in_lexical_scope(self_ty, TypeNS, Some(ty.id), ty.span)
|
||||
.map_or(Def::Err, |d| d.def());
|
||||
self.record_def(ty.id, PathResolution::new(def));
|
||||
|
@ -1679,7 +1679,7 @@ impl<'a, 'cl> hir::lowering::Resolver for Resolver<'a, 'cl> {
|
|||
components: &[&str],
|
||||
is_value: bool
|
||||
) -> hir::Path {
|
||||
let segments = iter::once(keywords::CrateRoot.ident())
|
||||
let segments = iter::once(keywords::PathRoot.ident())
|
||||
.chain(
|
||||
crate_root.into_iter()
|
||||
.chain(components.iter().cloned())
|
||||
|
@ -1721,7 +1721,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
|
|||
let path = if path_str.starts_with("::") {
|
||||
ast::Path {
|
||||
span,
|
||||
segments: iter::once(keywords::CrateRoot.ident())
|
||||
segments: iter::once(keywords::PathRoot.ident())
|
||||
.chain({
|
||||
path_str.split("::").skip(1).map(Ident::from_str)
|
||||
})
|
||||
|
@ -2036,7 +2036,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
let record_used = record_used_id.is_some();
|
||||
assert!(ns == TypeNS || ns == ValueNS);
|
||||
if ns == TypeNS {
|
||||
ident.span = if ident.name == keywords::SelfType.name() {
|
||||
ident.span = if ident.name == keywords::SelfUpper.name() {
|
||||
// FIXME(jseyfried) improve `Self` hygiene
|
||||
ident.span.with_ctxt(SyntaxContext::empty())
|
||||
} else {
|
||||
|
@ -2649,7 +2649,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
let mut self_type_rib = Rib::new(NormalRibKind);
|
||||
|
||||
// plain insert (no renaming, types are not currently hygienic....)
|
||||
self_type_rib.bindings.insert(keywords::SelfType.ident(), self_def);
|
||||
self_type_rib.bindings.insert(keywords::SelfUpper.ident(), self_def);
|
||||
self.ribs[TypeNS].push(self_type_rib);
|
||||
f(self);
|
||||
self.ribs[TypeNS].pop();
|
||||
|
@ -2660,7 +2660,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
{
|
||||
let self_def = Def::SelfCtor(impl_id);
|
||||
let mut self_type_rib = Rib::new(NormalRibKind);
|
||||
self_type_rib.bindings.insert(keywords::SelfType.ident(), self_def);
|
||||
self_type_rib.bindings.insert(keywords::SelfUpper.ident(), self_def);
|
||||
self.ribs[ValueNS].push(self_type_rib);
|
||||
f(self);
|
||||
self.ribs[ValueNS].pop();
|
||||
|
@ -3146,7 +3146,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
let item_span = path.last().unwrap().ident.span;
|
||||
let (mod_prefix, mod_str) = if path.len() == 1 {
|
||||
(String::new(), "this scope".to_string())
|
||||
} else if path.len() == 2 && path[0].ident.name == keywords::CrateRoot.name() {
|
||||
} else if path.len() == 2 && path[0].ident.name == keywords::PathRoot.name() {
|
||||
(String::new(), "the crate root".to_string())
|
||||
} else {
|
||||
let mod_path = &path[..path.len() - 1];
|
||||
|
@ -3515,13 +3515,13 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
}
|
||||
|
||||
fn self_type_is_available(&mut self, span: Span) -> bool {
|
||||
let binding = self.resolve_ident_in_lexical_scope(keywords::SelfType.ident(),
|
||||
let binding = self.resolve_ident_in_lexical_scope(keywords::SelfUpper.ident(),
|
||||
TypeNS, None, span);
|
||||
if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false }
|
||||
}
|
||||
|
||||
fn self_value_is_available(&mut self, self_span: Span, path_span: Span) -> bool {
|
||||
let ident = Ident::new(keywords::SelfValue.name(), self_span);
|
||||
let ident = Ident::new(keywords::SelfLower.name(), self_span);
|
||||
let binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, path_span);
|
||||
if let Some(LexicalScopeBinding::Def(def)) = binding { def != Def::Err } else { false }
|
||||
}
|
||||
|
@ -3673,7 +3673,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
};
|
||||
|
||||
if path.len() > 1 && !global_by_default && result.base_def() != Def::Err &&
|
||||
path[0].ident.name != keywords::CrateRoot.name() &&
|
||||
path[0].ident.name != keywords::PathRoot.name() &&
|
||||
path[0].ident.name != keywords::DollarCrate.name() {
|
||||
let unqualified_result = {
|
||||
match self.resolve_path_without_parent_scope(
|
||||
|
@ -3755,7 +3755,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
let name = ident.name;
|
||||
|
||||
allow_super &= ns == TypeNS &&
|
||||
(name == keywords::SelfValue.name() ||
|
||||
(name == keywords::SelfLower.name() ||
|
||||
name == keywords::Super.name());
|
||||
|
||||
if ns == TypeNS {
|
||||
|
@ -3779,24 +3779,24 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
return PathResult::Failed(ident.span, msg, false);
|
||||
}
|
||||
if i == 0 {
|
||||
if name == keywords::SelfValue.name() {
|
||||
if name == keywords::SelfLower.name() {
|
||||
let mut ctxt = ident.span.ctxt().modern();
|
||||
module = Some(ModuleOrUniformRoot::Module(
|
||||
self.resolve_self(&mut ctxt, self.current_module)));
|
||||
continue;
|
||||
}
|
||||
if name == keywords::Extern.name() ||
|
||||
name == keywords::CrateRoot.name() && ident.span.rust_2018() {
|
||||
name == keywords::PathRoot.name() && ident.span.rust_2018() {
|
||||
module = Some(ModuleOrUniformRoot::ExternPrelude);
|
||||
continue;
|
||||
}
|
||||
if name == keywords::CrateRoot.name() &&
|
||||
if name == keywords::PathRoot.name() &&
|
||||
ident.span.rust_2015() && self.session.rust_2018() {
|
||||
// `::a::b` from 2015 macro on 2018 global edition
|
||||
module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude);
|
||||
continue;
|
||||
}
|
||||
if name == keywords::CrateRoot.name() ||
|
||||
if name == keywords::PathRoot.name() ||
|
||||
name == keywords::Crate.name() ||
|
||||
name == keywords::DollarCrate.name() {
|
||||
// `::a::b`, `crate::a::b` or `$crate::a::b`
|
||||
|
@ -3809,12 +3809,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
|
||||
// Report special messages for path segment keywords in wrong positions.
|
||||
if ident.is_path_segment_keyword() && i != 0 {
|
||||
let name_str = if name == keywords::CrateRoot.name() {
|
||||
let name_str = if name == keywords::PathRoot.name() {
|
||||
"crate root".to_string()
|
||||
} else {
|
||||
format!("`{}`", name)
|
||||
};
|
||||
let msg = if i == 1 && path[0].ident.name == keywords::CrateRoot.name() {
|
||||
let msg = if i == 1 && path[0].ident.name == keywords::PathRoot.name() {
|
||||
format!("global paths cannot start with {}", name_str)
|
||||
} else {
|
||||
format!("{} in paths can only be used in start position", name_str)
|
||||
|
@ -3944,7 +3944,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
|
||||
// We're only interested in `use` paths which should start with
|
||||
// `{{root}}` or `extern` currently.
|
||||
if first_name != keywords::Extern.name() && first_name != keywords::CrateRoot.name() {
|
||||
if first_name != keywords::Extern.name() && first_name != keywords::PathRoot.name() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3953,7 +3953,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
Some(Segment { ident, .. }) if ident.name == keywords::Crate.name() => return,
|
||||
// Otherwise go below to see if it's an extern crate
|
||||
Some(_) => {}
|
||||
// If the path has length one (and it's `CrateRoot` most likely)
|
||||
// If the path has length one (and it's `PathRoot` most likely)
|
||||
// then we don't know whether we're gonna be importing a crate or an
|
||||
// item in our crate. Defer this lint to elsewhere
|
||||
None => return,
|
||||
|
@ -4740,7 +4740,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
} else {
|
||||
let ctxt = ident.span.ctxt();
|
||||
Some(Segment::from_ident(Ident::new(
|
||||
keywords::CrateRoot.name(), path.span.shrink_to_lo().with_ctxt(ctxt)
|
||||
keywords::PathRoot.name(), path.span.shrink_to_lo().with_ctxt(ctxt)
|
||||
)))
|
||||
};
|
||||
|
||||
|
@ -5090,17 +5090,17 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
|||
}
|
||||
|
||||
fn is_self_type(path: &[Segment], namespace: Namespace) -> bool {
|
||||
namespace == TypeNS && path.len() == 1 && path[0].ident.name == keywords::SelfType.name()
|
||||
namespace == TypeNS && path.len() == 1 && path[0].ident.name == keywords::SelfUpper.name()
|
||||
}
|
||||
|
||||
fn is_self_value(path: &[Segment], namespace: Namespace) -> bool {
|
||||
namespace == ValueNS && path.len() == 1 && path[0].ident.name == keywords::SelfValue.name()
|
||||
namespace == ValueNS && path.len() == 1 && path[0].ident.name == keywords::SelfLower.name()
|
||||
}
|
||||
|
||||
fn names_to_string(idents: &[Ident]) -> String {
|
||||
let mut result = String::new();
|
||||
for (i, ident) in idents.iter()
|
||||
.filter(|ident| ident.name != keywords::CrateRoot.name())
|
||||
.filter(|ident| ident.name != keywords::PathRoot.name())
|
||||
.enumerate() {
|
||||
if i > 0 {
|
||||
result.push_str("::");
|
||||
|
|
|
@ -167,7 +167,7 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
|
|||
|
||||
if path.segments[0].ident.name == keywords::DollarCrate.name() {
|
||||
let module = self.0.resolve_crate_root(path.segments[0].ident);
|
||||
path.segments[0].ident.name = keywords::CrateRoot.name();
|
||||
path.segments[0].ident.name = keywords::PathRoot.name();
|
||||
if !module.is_local() {
|
||||
let span = path.segments[0].ident.span;
|
||||
path.segments.insert(1, match module.kind {
|
||||
|
@ -674,7 +674,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
_ => Err(Determinacy::Determined),
|
||||
}
|
||||
WhereToResolve::CrateRoot => {
|
||||
let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span);
|
||||
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
|
||||
let root_module = self.resolve_crate_root(root_ident);
|
||||
let binding = self.resolve_ident_in_module_ext(
|
||||
ModuleOrUniformRoot::Module(root_module),
|
||||
|
@ -960,7 +960,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
break 'ok;
|
||||
}
|
||||
if rust_2015 {
|
||||
let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span);
|
||||
let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span);
|
||||
let root_module = self.resolve_crate_root(root_ident);
|
||||
if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module),
|
||||
orig_ident, ns, None, false, path_span)
|
||||
|
|
|
@ -198,7 +198,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
|
|||
.to_name_binding(self.arenas);
|
||||
return Ok(binding);
|
||||
} else if ident.name == keywords::Super.name() ||
|
||||
ident.name == keywords::SelfValue.name() {
|
||||
ident.name == keywords::SelfLower.name() {
|
||||
// FIXME: Implement these with renaming requirements so that e.g.
|
||||
// `use super;` doesn't work, but `use super as name;` does.
|
||||
// Fall through here to get an error from `early_resolve_...`.
|
||||
|
@ -1263,8 +1263,8 @@ fn import_path_to_string(names: &[Ident],
|
|||
subclass: &ImportDirectiveSubclass,
|
||||
span: Span) -> String {
|
||||
let pos = names.iter()
|
||||
.position(|p| span == p.span && p.name != keywords::CrateRoot.name());
|
||||
let global = !names.is_empty() && names[0].name == keywords::CrateRoot.name();
|
||||
.position(|p| span == p.span && p.name != keywords::PathRoot.name());
|
||||
let global = !names.is_empty() && names[0].name == keywords::PathRoot.name();
|
||||
if let Some(pos) = pos {
|
||||
let names = if global { &names[1..pos + 1] } else { &names[..pos + 1] };
|
||||
names_to_string(names)
|
||||
|
|
|
@ -234,7 +234,7 @@ macro_rules! supported_targets {
|
|||
$(mod $module;)*
|
||||
|
||||
/// List of supported targets
|
||||
const TARGETS: &'static [&'static str] = &[$($triple),*];
|
||||
const TARGETS: &[&str] = &[$($triple),*];
|
||||
|
||||
fn load_specific(target: &str) -> TargetResult {
|
||||
match target {
|
||||
|
|
|
@ -938,7 +938,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
|
|||
|
||||
opt_self = Some(ty::GenericParamDef {
|
||||
index: 0,
|
||||
name: keywords::SelfType.name().as_interned_str(),
|
||||
name: keywords::SelfUpper.name().as_interned_str(),
|
||||
def_id: tcx.hir.local_def_id(param_id),
|
||||
pure_wrt_drop: false,
|
||||
kind: ty::GenericParamDefKind::Type {
|
||||
|
@ -1007,7 +1007,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
|
|||
synthetic,
|
||||
..
|
||||
} => {
|
||||
if param.name.ident().name == keywords::SelfType.name() {
|
||||
if param.name.ident().name == keywords::SelfUpper.name() {
|
||||
span_bug!(
|
||||
param.span,
|
||||
"`Self` should not be the name of a regular parameter"
|
||||
|
|
|
@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
|
|||
let stripped_typarams = gens.params.iter().filter_map(|param| match param.kind {
|
||||
ty::GenericParamDefKind::Lifetime => None,
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
if param.name == keywords::SelfType.name().as_str() {
|
||||
if param.name == keywords::SelfUpper.name().as_str() {
|
||||
assert_eq!(param.index, 0);
|
||||
return None;
|
||||
}
|
||||
|
@ -3174,7 +3174,7 @@ fn qpath_to_string(p: &hir::QPath) -> String {
|
|||
if i > 0 {
|
||||
s.push_str("::");
|
||||
}
|
||||
if seg.ident.name != keywords::CrateRoot.name() {
|
||||
if seg.ident.name != keywords::PathRoot.name() {
|
||||
s.push_str(&*seg.ident.as_str());
|
||||
}
|
||||
}
|
||||
|
@ -3726,7 +3726,7 @@ fn resolve_type(cx: &DocContext,
|
|||
hir::Float(float_ty) => return Primitive(float_ty.into()),
|
||||
},
|
||||
Def::SelfTy(..) if path.segments.len() == 1 => {
|
||||
return Generic(keywords::SelfType.name().to_string());
|
||||
return Generic(keywords::SelfUpper.name().to_string());
|
||||
}
|
||||
Def::TyParam(..) if path.segments.len() == 1 => {
|
||||
return Generic(format!("{:#}", path));
|
||||
|
|
|
@ -57,6 +57,9 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
|
|||
{css_extension}\
|
||||
{favicon}\
|
||||
{in_header}\
|
||||
<style type=\"text/css\">\
|
||||
#crate-search{{background-image:url(\"{root_path}down-arrow{suffix}.svg\");}}\
|
||||
</style>\
|
||||
</head>\
|
||||
<body class=\"rustdoc {css_class}\">\
|
||||
<!--[if lte IE 8]>\
|
||||
|
@ -81,11 +84,16 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
|
|||
<nav class=\"sub\">\
|
||||
<form class=\"search-form js-only\">\
|
||||
<div class=\"search-container\">\
|
||||
<input class=\"search-input\" name=\"search\" \
|
||||
autocomplete=\"off\" \
|
||||
spellcheck=\"false\" \
|
||||
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
|
||||
type=\"search\">\
|
||||
<div>\
|
||||
<select id=\"crate-search\">\
|
||||
<option value=\"All crates\">All crates</option>\
|
||||
</select>\
|
||||
<input class=\"search-input\" name=\"search\" \
|
||||
autocomplete=\"off\" \
|
||||
spellcheck=\"false\" \
|
||||
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
|
||||
type=\"search\">\
|
||||
</div>\
|
||||
<a id=\"settings-menu\" href=\"{root_path}settings.html\">\
|
||||
<img src=\"{root_path}wheel{suffix}.svg\" width=\"18\" alt=\"Change settings\">\
|
||||
</a>\
|
||||
|
|
|
@ -793,6 +793,8 @@ fn write_shared(
|
|||
static_files::BRUSH_SVG)?;
|
||||
write(cx.dst.join(&format!("wheel{}.svg", cx.shared.resource_suffix)),
|
||||
static_files::WHEEL_SVG)?;
|
||||
write(cx.dst.join(&format!("down-arrow{}.svg", cx.shared.resource_suffix)),
|
||||
static_files::DOWN_ARROW_SVG)?;
|
||||
write_minify(cx.dst.join(&format!("light{}.css", cx.shared.resource_suffix)),
|
||||
static_files::themes::LIGHT,
|
||||
options.enable_minification)?;
|
||||
|
@ -1066,7 +1068,7 @@ themePicker.onblur = handleThemeButtonsBlur;
|
|||
&[(minifier::js::Keyword::Null, "N")]),
|
||||
&dst);
|
||||
}
|
||||
try_err!(writeln!(&mut w, "initSearch(searchIndex);"), &dst);
|
||||
try_err!(writeln!(&mut w, "initSearch(searchIndex);addSearchOptions(searchIndex);"), &dst);
|
||||
|
||||
if options.enable_index_page {
|
||||
if let Some(index_page) = options.index_page.clone() {
|
||||
|
|
1
src/librustdoc/html/static/down-arrow.svg
Normal file
1
src/librustdoc/html/static/down-arrow.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="128px" id="Layer_1" style="enable-background:new 0 0 128 128;" version="1.1" viewBox="0 0 128 128" width="128px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><line style="fill:none;stroke:#2F3435;stroke-width:12;stroke-linecap:square;stroke-miterlimit:10;" x1="111" x2="64" y1="40.5" y2="87.499"/><line style="fill:none;stroke:#2F3435;stroke-width:12;stroke-linecap:square;stroke-miterlimit:10;" x1="64" x2="17" y1="87.499" y2="40.5"/></g></svg>
|
After Width: | Height: | Size: 637 B |
|
@ -218,12 +218,14 @@ if (!String.prototype.endsWith) {
|
|||
//
|
||||
// So I guess you could say things are getting pretty interoperable.
|
||||
function getVirtualKey(ev) {
|
||||
if ("key" in ev && typeof ev.key != "undefined")
|
||||
if ("key" in ev && typeof ev.key != "undefined") {
|
||||
return ev.key;
|
||||
}
|
||||
|
||||
var c = ev.charCode || ev.keyCode;
|
||||
if (c == 27)
|
||||
if (c == 27) {
|
||||
return "Escape";
|
||||
}
|
||||
return String.fromCharCode(c);
|
||||
}
|
||||
|
||||
|
@ -431,12 +433,13 @@ if (!String.prototype.endsWith) {
|
|||
|
||||
/**
|
||||
* Executes the query and builds an index of results
|
||||
* @param {[Object]} query [The user query]
|
||||
* @param {[type]} searchWords [The list of search words to query
|
||||
* against]
|
||||
* @return {[type]} [A search index of results]
|
||||
* @param {[Object]} query [The user query]
|
||||
* @param {[type]} searchWords [The list of search words to query
|
||||
* against]
|
||||
* @param {[type]} filterCrates [Crate to search in if defined]
|
||||
* @return {[type]} [A search index of results]
|
||||
*/
|
||||
function execQuery(query, searchWords) {
|
||||
function execQuery(query, searchWords, filterCrates) {
|
||||
function itemTypeFromName(typename) {
|
||||
for (var i = 0; i < itemTypes.length; ++i) {
|
||||
if (itemTypes[i] === typename) {
|
||||
|
@ -812,6 +815,9 @@ if (!String.prototype.endsWith) {
|
|||
{
|
||||
val = extractGenerics(val.substr(1, val.length - 2));
|
||||
for (var i = 0; i < nSearchWords; ++i) {
|
||||
if (filterCrates !== undefined && searchIndex[i].crate !== filterCrates) {
|
||||
continue;
|
||||
}
|
||||
var in_args = findArg(searchIndex[i], val, true);
|
||||
var returned = checkReturned(searchIndex[i], val, true);
|
||||
var ty = searchIndex[i];
|
||||
|
@ -866,6 +872,9 @@ if (!String.prototype.endsWith) {
|
|||
var output = extractGenerics(parts[1]);
|
||||
|
||||
for (var i = 0; i < nSearchWords; ++i) {
|
||||
if (filterCrates !== undefined && searchIndex[i].crate !== filterCrates) {
|
||||
continue;
|
||||
}
|
||||
var type = searchIndex[i].type;
|
||||
var ty = searchIndex[i];
|
||||
if (!type) {
|
||||
|
@ -937,11 +946,11 @@ if (!String.prototype.endsWith) {
|
|||
var contains = paths.slice(0, paths.length > 1 ? paths.length - 1 : 1);
|
||||
|
||||
for (j = 0; j < nSearchWords; ++j) {
|
||||
var lev_distance;
|
||||
var ty = searchIndex[j];
|
||||
if (!ty) {
|
||||
if (!ty || (filterCrates !== undefined && ty.crate !== filterCrates)) {
|
||||
continue;
|
||||
}
|
||||
var lev_distance;
|
||||
var lev_add = 0;
|
||||
if (paths.length > 1) {
|
||||
var lev = checkPath(contains, paths[paths.length - 1], ty);
|
||||
|
@ -1326,7 +1335,7 @@ if (!String.prototype.endsWith) {
|
|||
return '<div>' + text + ' <div class="count">(' + nbElems + ')</div></div>';
|
||||
}
|
||||
|
||||
function showResults(results) {
|
||||
function showResults(results, filterCrates) {
|
||||
if (results['others'].length === 1 &&
|
||||
getCurrentValue('rustdoc-go-to-only-result') === "true") {
|
||||
var elem = document.createElement('a');
|
||||
|
@ -1344,8 +1353,13 @@ if (!String.prototype.endsWith) {
|
|||
var ret_in_args = addTab(results['in_args'], query, false);
|
||||
var ret_returned = addTab(results['returned'], query, false);
|
||||
|
||||
var filter = "";
|
||||
if (filterCrates !== undefined) {
|
||||
filter = " (in <b>" + filterCrates + "</b> crate)";
|
||||
}
|
||||
|
||||
var output = '<h1>Results for ' + escape(query.query) +
|
||||
(query.type ? ' (type: ' + escape(query.type) + ')' : '') + '</h1>' +
|
||||
(query.type ? ' (type: ' + escape(query.type) + ')' : '') + filter + '</h1>' +
|
||||
'<div id="titles">' +
|
||||
makeTabHeader(0, "In Names", ret_others[1]) +
|
||||
makeTabHeader(1, "In Parameters", ret_in_args[1]) +
|
||||
|
@ -1374,7 +1388,7 @@ if (!String.prototype.endsWith) {
|
|||
printTab(currentTab);
|
||||
}
|
||||
|
||||
function execSearch(query, searchWords) {
|
||||
function execSearch(query, searchWords, filterCrates) {
|
||||
var queries = query.raw.split(",");
|
||||
var results = {
|
||||
'in_args': [],
|
||||
|
@ -1385,7 +1399,7 @@ if (!String.prototype.endsWith) {
|
|||
for (var i = 0; i < queries.length; ++i) {
|
||||
var query = queries[i].trim();
|
||||
if (query.length !== 0) {
|
||||
var tmp = execQuery(getQuery(query), searchWords);
|
||||
var tmp = execQuery(getQuery(query), searchWords, filterCrates);
|
||||
|
||||
results['in_args'].push(tmp['in_args']);
|
||||
results['returned'].push(tmp['returned']);
|
||||
|
@ -1447,7 +1461,16 @@ if (!String.prototype.endsWith) {
|
|||
}
|
||||
}
|
||||
|
||||
function search(e) {
|
||||
function getFilterCrates() {
|
||||
var elem = document.getElementById("crate-search");
|
||||
|
||||
if (elem && elem.value !== "All crates" && rawSearchIndex.hasOwnProperty(elem.value)) {
|
||||
return elem.value;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function search(e, forced) {
|
||||
var params = getQueryStringParams();
|
||||
var query = getQuery(search_input.value.trim());
|
||||
|
||||
|
@ -1455,7 +1478,10 @@ if (!String.prototype.endsWith) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (query.query.length === 0 || query.id === currentResults) {
|
||||
if (query.query.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (forced !== true && query.id === currentResults) {
|
||||
if (query.query.length > 0) {
|
||||
putBackSearch(search_input);
|
||||
}
|
||||
|
@ -1475,7 +1501,8 @@ if (!String.prototype.endsWith) {
|
|||
}
|
||||
}
|
||||
|
||||
showResults(execSearch(query, index));
|
||||
var filterCrates = getFilterCrates();
|
||||
showResults(execSearch(query, index, filterCrates), filterCrates);
|
||||
}
|
||||
|
||||
function buildIndex(rawSearchIndex) {
|
||||
|
@ -1575,6 +1602,13 @@ if (!String.prototype.endsWith) {
|
|||
};
|
||||
search_input.onpaste = search_input.onchange;
|
||||
|
||||
var selectCrate = document.getElementById('crate-search');
|
||||
if (selectCrate) {
|
||||
selectCrate.onchange = function() {
|
||||
search(undefined, true);
|
||||
};
|
||||
}
|
||||
|
||||
// Push and pop states are used to add search results to the browser
|
||||
// history.
|
||||
if (browserSupportsHistoryApi()) {
|
||||
|
@ -2323,6 +2357,39 @@ if (!String.prototype.endsWith) {
|
|||
if (window.location.hash && window.location.hash.length > 0) {
|
||||
expandSection(window.location.hash.replace(/^#/, ''));
|
||||
}
|
||||
|
||||
function addSearchOptions(crates) {
|
||||
var elem = document.getElementById('crate-search');
|
||||
|
||||
if (!elem) {
|
||||
return;
|
||||
}
|
||||
var crates_text = [];
|
||||
for (var crate in crates) {
|
||||
if (crates.hasOwnProperty(crate)) {
|
||||
crates_text.push(crate);
|
||||
}
|
||||
}
|
||||
crates_text.sort(function(a, b) {
|
||||
var lower_a = a.toLowerCase();
|
||||
var lower_b = b.toLowerCase();
|
||||
|
||||
if (lower_a < lower_b) {
|
||||
return -1;
|
||||
} else if (lower_a > lower_b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
for (var i = 0; i < crates_text.length; ++i) {
|
||||
var option = document.createElement("option");
|
||||
option.value = crates_text[i];
|
||||
option.innerText = crates_text[i];
|
||||
elem.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
window.addSearchOptions = addSearchOptions;
|
||||
}());
|
||||
|
||||
// Sets the focus on the search bar at the top of the page
|
||||
|
|
|
@ -620,13 +620,36 @@ a {
|
|||
.search-container {
|
||||
position: relative;
|
||||
}
|
||||
.search-container > div {
|
||||
display: inline-flex;
|
||||
width: calc(100% - 34px);
|
||||
}
|
||||
#crate-search {
|
||||
margin-top: 5px;
|
||||
padding: 6px;
|
||||
padding-right: 19px;
|
||||
border: 0;
|
||||
border-right: 0;
|
||||
border-radius: 4px 0 0 4px;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
border-right: 1px solid;
|
||||
-moz-appearance: none;
|
||||
-webkit-appearance: none;
|
||||
/* Removes default arrow from firefox */
|
||||
text-indent: 0.01px;
|
||||
text-overflow: "";
|
||||
background-repeat: no-repeat;
|
||||
background-color: transparent;
|
||||
background-size: 16%;
|
||||
background-position: calc(100% - 1px) 56%;
|
||||
}
|
||||
.search-container > .top-button {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 10px;
|
||||
}
|
||||
.search-input {
|
||||
width: calc(100% - 34px);
|
||||
/* Override Normalize.css: we have margins and do
|
||||
not want to overflow - the `moz` attribute is necessary
|
||||
until Firefox 29, too early to drop at this point */
|
||||
|
@ -634,13 +657,14 @@ a {
|
|||
box-sizing: border-box !important;
|
||||
outline: none;
|
||||
border: none;
|
||||
border-radius: 1px;
|
||||
border-radius: 0 1px 1px 0;
|
||||
margin-top: 5px;
|
||||
padding: 10px 16px;
|
||||
font-size: 17px;
|
||||
transition: border-color 300ms ease;
|
||||
transition: border-radius 300ms ease-in-out;
|
||||
transition: box-shadow 300ms ease-in-out;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
|
|
|
@ -182,9 +182,15 @@ a.test-arrow {
|
|||
color: #999;
|
||||
}
|
||||
|
||||
#crate-search {
|
||||
color: #111;
|
||||
background-color: #f0f0f0;
|
||||
border-color: #000;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
color: #111;
|
||||
box-shadow: 0 0 0 1px #000, 0 0 0 2px transparent;
|
||||
box-shadow: 1px 0 0 1px #000, 0 0 0 2px transparent;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
|
|
|
@ -182,9 +182,16 @@ a.test-arrow {
|
|||
color: #999;
|
||||
}
|
||||
|
||||
#crate-search {
|
||||
color: #555;
|
||||
background-color: white;
|
||||
border-color: #e0e0e0;
|
||||
box-shadow: 0px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
color: #555;
|
||||
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
|
||||
box-shadow: 1px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ pub static BRUSH_SVG: &'static [u8] = include_bytes!("static/brush.svg");
|
|||
/// The file contents of `wheel.svg`, the icon used for the settings button.
|
||||
pub static WHEEL_SVG: &'static [u8] = include_bytes!("static/wheel.svg");
|
||||
|
||||
/// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox.
|
||||
pub static DOWN_ARROW_SVG: &'static [u8] = include_bytes!("static/down-arrow.svg");
|
||||
|
||||
/// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation
|
||||
/// output.
|
||||
pub static COPYRIGHT: &'static [u8] = include_bytes!("static/COPYRIGHT.txt");
|
||||
|
|
|
@ -100,7 +100,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
|||
None);
|
||||
// attach the crate's exported macros to the top-level module:
|
||||
let macro_exports: Vec<_> =
|
||||
krate.exported_macros.iter().map(|def| self.visit_local_macro(def)).collect();
|
||||
krate.exported_macros.iter().map(|def| self.visit_local_macro(def, None)).collect();
|
||||
self.module.macros.extend(macro_exports);
|
||||
self.module.is_crate = true;
|
||||
|
||||
|
@ -376,6 +376,10 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
|||
});
|
||||
true
|
||||
}
|
||||
Node::MacroDef(def) if !glob => {
|
||||
om.macros.push(self.visit_local_macro(def, renamed));
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
self.view_item_stack.remove(&def_node_id);
|
||||
|
@ -593,7 +597,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
|||
}
|
||||
|
||||
// convert each exported_macro into a doc item
|
||||
fn visit_local_macro(&self, def: &hir::MacroDef) -> Macro {
|
||||
fn visit_local_macro(
|
||||
&self,
|
||||
def: &hir::MacroDef,
|
||||
renamed: Option<ast::Name>
|
||||
) -> Macro {
|
||||
debug!("visit_local_macro: {}", def.name);
|
||||
let tts = def.body.trees().collect::<Vec<_>>();
|
||||
// Extract the spans of all matchers. They represent the "interface" of the macro.
|
||||
|
@ -602,7 +610,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
|||
Macro {
|
||||
def_id: self.cx.tcx.hir.local_def_id(def.id),
|
||||
attrs: def.attrs.clone(),
|
||||
name: def.name,
|
||||
name: renamed.unwrap_or(def.name),
|
||||
whence: def.span,
|
||||
matchers,
|
||||
stab: self.stability(def.id),
|
||||
|
|
|
@ -283,11 +283,14 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||
|
||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))]
|
||||
pub fn current_exe() -> io::Result<PathBuf> {
|
||||
let selfexe = PathBuf::from("/proc/self/exe");
|
||||
if selfexe.exists() {
|
||||
::fs::read_link(selfexe)
|
||||
} else {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "no /proc/self/exe available. Is /proc mounted?"))
|
||||
match ::fs::read_link("/proc/self/exe") {
|
||||
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"no /proc/self/exe available. Is /proc mounted?"
|
||||
))
|
||||
},
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ impl fmt::Debug for Lifetime {
|
|||
pub struct Path {
|
||||
pub span: Span,
|
||||
/// The segments in the path: the things separated by `::`.
|
||||
/// Global paths begin with `keywords::CrateRoot`.
|
||||
/// Global paths begin with `keywords::PathRoot`.
|
||||
pub segments: Vec<PathSegment>,
|
||||
}
|
||||
|
||||
|
@ -105,19 +105,8 @@ impl Path {
|
|||
}
|
||||
}
|
||||
|
||||
// Make a "crate root" segment for this path unless it already has it
|
||||
// or starts with something like `self`/`super`/`$crate`/etc.
|
||||
pub fn make_root(&self) -> Option<PathSegment> {
|
||||
if let Some(ident) = self.segments.get(0).map(|seg| seg.ident) {
|
||||
if ident.is_path_segment_keyword() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(PathSegment::crate_root(self.span.shrink_to_lo()))
|
||||
}
|
||||
|
||||
pub fn is_global(&self) -> bool {
|
||||
!self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name()
|
||||
!self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,8 +133,8 @@ impl PathSegment {
|
|||
pub fn from_ident(ident: Ident) -> Self {
|
||||
PathSegment { ident, id: DUMMY_NODE_ID, args: None }
|
||||
}
|
||||
pub fn crate_root(span: Span) -> Self {
|
||||
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span))
|
||||
pub fn path_root(span: Span) -> Self {
|
||||
PathSegment::from_ident(Ident::new(keywords::PathRoot.name(), span))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1688,7 +1677,7 @@ pub type ExplicitSelf = Spanned<SelfKind>;
|
|||
impl Arg {
|
||||
pub fn to_self(&self) -> Option<ExplicitSelf> {
|
||||
if let PatKind::Ident(BindingMode::ByValue(mutbl), ident, _) = self.pat.node {
|
||||
if ident.name == keywords::SelfValue.name() {
|
||||
if ident.name == keywords::SelfLower.name() {
|
||||
return match self.ty.node {
|
||||
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
|
||||
TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => {
|
||||
|
@ -1706,7 +1695,7 @@ impl Arg {
|
|||
|
||||
pub fn is_self(&self) -> bool {
|
||||
if let PatKind::Ident(_, ident, _) = self.pat.node {
|
||||
ident.name == keywords::SelfValue.name()
|
||||
ident.name == keywords::SelfLower.name()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -318,9 +318,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
args: Vec<ast::GenericArg>,
|
||||
bindings: Vec<ast::TypeBinding> )
|
||||
-> ast::Path {
|
||||
assert!(!idents.is_empty());
|
||||
let add_root = global && !idents[0].is_path_segment_keyword();
|
||||
let mut segments = Vec::with_capacity(idents.len() + add_root as usize);
|
||||
if add_root {
|
||||
segments.push(ast::PathSegment::path_root(span));
|
||||
}
|
||||
let last_ident = idents.pop().unwrap();
|
||||
let mut segments: Vec<ast::PathSegment> = vec![];
|
||||
|
||||
segments.extend(idents.into_iter().map(|ident| {
|
||||
ast::PathSegment::from_ident(ident.with_span_pos(span))
|
||||
}));
|
||||
|
@ -334,13 +338,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
id: ast::DUMMY_NODE_ID,
|
||||
args,
|
||||
});
|
||||
let mut path = ast::Path { span, segments };
|
||||
if global {
|
||||
if let Some(seg) = path.make_root() {
|
||||
path.segments.insert(0, seg);
|
||||
}
|
||||
}
|
||||
path
|
||||
ast::Path { span, segments }
|
||||
}
|
||||
|
||||
/// Constructs a qualified path.
|
||||
|
@ -625,7 +623,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
self.expr_path(self.path_ident(span, id))
|
||||
}
|
||||
fn expr_self(&self, span: Span) -> P<ast::Expr> {
|
||||
self.expr_ident(span, keywords::SelfValue.ident())
|
||||
self.expr_ident(span, keywords::SelfLower.ident())
|
||||
}
|
||||
|
||||
fn expr_binary(&self, sp: Span, op: ast::BinOpKind,
|
||||
|
|
|
@ -204,7 +204,7 @@ fn macro_bang_format(path: &ast::Path) -> ExpnFormat {
|
|||
path_str.push_str("::");
|
||||
}
|
||||
|
||||
if segment.ident.name != keywords::CrateRoot.name() &&
|
||||
if segment.ident.name != keywords::PathRoot.name() &&
|
||||
segment.ident.name != keywords::DollarCrate.name()
|
||||
{
|
||||
path_str.push_str(&segment.ident.as_str())
|
||||
|
|
|
@ -444,7 +444,6 @@ where
|
|||
macro_node_id,
|
||||
),
|
||||
Edition::Edition2018 => parse_sep_and_kleene_op_2018(input, span, sess, features, attrs),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,7 @@ macro_rules! declare_features {
|
|||
/// Represents active features that are currently being implemented or
|
||||
/// currently being considered for addition/removal.
|
||||
const ACTIVE_FEATURES:
|
||||
&'static [(&'static str, &'static str, Option<u32>,
|
||||
Option<Edition>, fn(&mut Features, Span))] =
|
||||
&[(&str, &str, Option<u32>, Option<Edition>, fn(&mut Features, Span))] =
|
||||
&[$((stringify!($feature), $ver, $issue, $edition, set!($feature))),+];
|
||||
|
||||
/// A set of features to be used by later passes.
|
||||
|
@ -439,8 +438,8 @@ declare_features! (
|
|||
// 'a: { break 'a; }
|
||||
(active, label_break_value, "1.28.0", Some(48594), None),
|
||||
|
||||
// Integer match exhaustiveness checking
|
||||
(active, exhaustive_integer_patterns, "1.30.0", Some(50907), None),
|
||||
// Exhaustive pattern matching on `usize` and `isize`.
|
||||
(active, precise_pointer_size_matching, "1.32.0", Some(56354), None),
|
||||
|
||||
// #[doc(keyword = "...")]
|
||||
(active, doc_keyword, "1.28.0", Some(51315), None),
|
||||
|
@ -686,6 +685,8 @@ declare_features! (
|
|||
(accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
|
||||
// Allows use of the :literal macro fragment specifier (RFC 1576)
|
||||
(accepted, macro_literal_matcher, "1.31.0", Some(35625), None),
|
||||
// Integer match exhaustiveness checking (RFC 2591)
|
||||
(accepted, exhaustive_integer_patterns, "1.32.0", Some(50907), None),
|
||||
// Use `?` as the Kleene "at most one" operator
|
||||
(accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None),
|
||||
// `Self` struct constructor (RFC 2302)
|
||||
|
@ -772,7 +773,7 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
|
|||
}
|
||||
|
||||
// Attributes that have a special meaning to rustc or rustdoc
|
||||
pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGate)] = &[
|
||||
pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeGate)] = &[
|
||||
// Normal attributes
|
||||
|
||||
("warn", Normal, Ungated),
|
||||
|
@ -1386,48 +1387,48 @@ fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue
|
|||
|
||||
}
|
||||
|
||||
const EXPLAIN_BOX_SYNTAX: &'static str =
|
||||
const EXPLAIN_BOX_SYNTAX: &str =
|
||||
"box expression syntax is experimental; you can call `Box::new` instead.";
|
||||
|
||||
pub const EXPLAIN_STMT_ATTR_SYNTAX: &'static str =
|
||||
pub const EXPLAIN_STMT_ATTR_SYNTAX: &str =
|
||||
"attributes on expressions are experimental.";
|
||||
|
||||
pub const EXPLAIN_ASM: &'static str =
|
||||
pub const EXPLAIN_ASM: &str =
|
||||
"inline assembly is not stable enough for use and is subject to change";
|
||||
|
||||
pub const EXPLAIN_GLOBAL_ASM: &'static str =
|
||||
pub const EXPLAIN_GLOBAL_ASM: &str =
|
||||
"`global_asm!` is not stable enough for use and is subject to change";
|
||||
|
||||
pub const EXPLAIN_CUSTOM_TEST_FRAMEWORKS: &'static str =
|
||||
pub const EXPLAIN_CUSTOM_TEST_FRAMEWORKS: &str =
|
||||
"custom test frameworks are an unstable feature";
|
||||
|
||||
pub const EXPLAIN_LOG_SYNTAX: &'static str =
|
||||
pub const EXPLAIN_LOG_SYNTAX: &str =
|
||||
"`log_syntax!` is not stable enough for use and is subject to change";
|
||||
|
||||
pub const EXPLAIN_CONCAT_IDENTS: &'static str =
|
||||
pub const EXPLAIN_CONCAT_IDENTS: &str =
|
||||
"`concat_idents` is not stable enough for use and is subject to change";
|
||||
|
||||
pub const EXPLAIN_FORMAT_ARGS_NL: &'static str =
|
||||
pub const EXPLAIN_FORMAT_ARGS_NL: &str =
|
||||
"`format_args_nl` is only for internal language use and is subject to change";
|
||||
|
||||
pub const EXPLAIN_TRACE_MACROS: &'static str =
|
||||
pub const EXPLAIN_TRACE_MACROS: &str =
|
||||
"`trace_macros` is not stable enough for use and is subject to change";
|
||||
pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str =
|
||||
pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &str =
|
||||
"allow_internal_unstable side-steps feature gating and stability checks";
|
||||
pub const EXPLAIN_ALLOW_INTERNAL_UNSAFE: &'static str =
|
||||
pub const EXPLAIN_ALLOW_INTERNAL_UNSAFE: &str =
|
||||
"allow_internal_unsafe side-steps the unsafe_code lint";
|
||||
|
||||
pub const EXPLAIN_CUSTOM_DERIVE: &'static str =
|
||||
pub const EXPLAIN_CUSTOM_DERIVE: &str =
|
||||
"`#[derive]` for custom traits is deprecated and will be removed in the future.";
|
||||
|
||||
pub const EXPLAIN_DEPR_CUSTOM_DERIVE: &'static str =
|
||||
pub const EXPLAIN_DEPR_CUSTOM_DERIVE: &str =
|
||||
"`#[derive]` for custom traits is deprecated and will be removed in the future. \
|
||||
Prefer using procedural macro custom derive.";
|
||||
|
||||
pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str =
|
||||
pub const EXPLAIN_DERIVE_UNDERSCORE: &str =
|
||||
"attributes of the form `#[derive_*]` are reserved for the compiler";
|
||||
|
||||
pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str =
|
||||
pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &str =
|
||||
"unsized tuple coercion is not stable enough for use and is subject to change";
|
||||
|
||||
struct PostExpansionVisitor<'a> {
|
||||
|
|
|
@ -22,8 +22,8 @@ enum InnerAttributeParsePolicy<'a> {
|
|||
NotPermitted { reason: &'a str },
|
||||
}
|
||||
|
||||
const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &'static str = "an inner attribute is not \
|
||||
permitted in this context";
|
||||
const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \
|
||||
permitted in this context";
|
||||
|
||||
impl<'a> Parser<'a> {
|
||||
/// Parse attributes that appear before an item
|
||||
|
|
|
@ -306,7 +306,7 @@ const UNICODE_ARRAY: &[(char, &str, char)] = &[
|
|||
('>', "Fullwidth Greater-Than Sign", '>'), ];
|
||||
|
||||
|
||||
const ASCII_ARRAY: &'static [(char, &'static str)] = &[
|
||||
const ASCII_ARRAY: &[(char, &str)] = &[
|
||||
(' ', "Space"),
|
||||
('_', "Underscore"),
|
||||
('-', "Minus/Hyphen"),
|
||||
|
|
|
@ -2082,7 +2082,7 @@ impl<'a> Parser<'a> {
|
|||
let mut segments = Vec::new();
|
||||
let mod_sep_ctxt = self.span.ctxt();
|
||||
if self.eat(&token::ModSep) {
|
||||
segments.push(PathSegment::crate_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)));
|
||||
segments.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)));
|
||||
}
|
||||
self.parse_path_segments(&mut segments, style, enable_warning)?;
|
||||
|
||||
|
@ -5508,7 +5508,7 @@ impl<'a> Parser<'a> {
|
|||
_ => unreachable!()
|
||||
};
|
||||
let isolated_self = |this: &mut Self, n| {
|
||||
this.look_ahead(n, |t| t.is_keyword(keywords::SelfValue)) &&
|
||||
this.look_ahead(n, |t| t.is_keyword(keywords::SelfLower)) &&
|
||||
this.look_ahead(n + 1, |t| t != &token::ModSep)
|
||||
};
|
||||
|
||||
|
@ -6330,7 +6330,7 @@ impl<'a> Parser<'a> {
|
|||
return Ok(vis)
|
||||
} else if self.look_ahead(2, |t| t == &token::CloseDelim(token::Paren)) &&
|
||||
self.look_ahead(1, |t| t.is_keyword(keywords::Super) ||
|
||||
t.is_keyword(keywords::SelfValue))
|
||||
t.is_keyword(keywords::SelfLower))
|
||||
{
|
||||
// `pub(self)` or `pub(super)`
|
||||
self.bump(); // `(`
|
||||
|
@ -6782,7 +6782,7 @@ impl<'a> Parser<'a> {
|
|||
let error_msg = "crate name using dashes are not valid in `extern crate` statements";
|
||||
let suggestion_msg = "if the original crate name uses dashes you need to use underscores \
|
||||
in the code";
|
||||
let mut ident = if self.token.is_keyword(keywords::SelfValue) {
|
||||
let mut ident = if self.token.is_keyword(keywords::SelfLower) {
|
||||
self.parse_path_segment_ident()
|
||||
} else {
|
||||
self.parse_ident()
|
||||
|
@ -7685,7 +7685,7 @@ impl<'a> Parser<'a> {
|
|||
let mod_sep_ctxt = self.span.ctxt();
|
||||
if self.eat(&token::ModSep) {
|
||||
prefix.segments.push(
|
||||
PathSegment::crate_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))
|
||||
PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -724,7 +724,7 @@ pub trait PrintState<'a> {
|
|||
if i > 0 {
|
||||
self.writer().word("::")?
|
||||
}
|
||||
if segment.ident.name != keywords::CrateRoot.name() &&
|
||||
if segment.ident.name != keywords::PathRoot.name() &&
|
||||
segment.ident.name != keywords::DollarCrate.name()
|
||||
{
|
||||
self.writer().word(segment.ident.as_str().get())?;
|
||||
|
@ -2463,7 +2463,7 @@ impl<'a> State<'a> {
|
|||
colons_before_params: bool)
|
||||
-> io::Result<()>
|
||||
{
|
||||
if segment.ident.name != keywords::CrateRoot.name() &&
|
||||
if segment.ident.name != keywords::PathRoot.name() &&
|
||||
segment.ident.name != keywords::DollarCrate.name() {
|
||||
self.print_ident(segment.ident)?;
|
||||
if let Some(ref args) = segment.args {
|
||||
|
|
|
@ -112,7 +112,7 @@ pub fn maybe_inject_crates_ref(
|
|||
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||
node: ast::ItemKind::Use(P(ast::UseTree {
|
||||
prefix: ast::Path {
|
||||
segments: iter::once(keywords::CrateRoot.ident())
|
||||
segments: iter::once(keywords::PathRoot.ident())
|
||||
.chain(
|
||||
[name, "prelude", "v1"].iter().cloned()
|
||||
.map(ast::Ident::from_str)
|
||||
|
|
|
@ -47,7 +47,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
|
||||
const OPTIONS: &[&str] = &["volatile", "alignstack", "intel"];
|
||||
|
||||
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
|
||||
sp: Span,
|
||||
|
|
|
@ -140,7 +140,7 @@ fn cs_clone_shallow(name: &str,
|
|||
let mut stmts = Vec::new();
|
||||
if is_union {
|
||||
// let _: AssertParamIsCopy<Self>;
|
||||
let self_ty = cx.ty_path(cx.path_ident(trait_span, keywords::SelfType.ident()));
|
||||
let self_ty = cx.ty_path(cx.path_ident(trait_span, keywords::SelfUpper.ident()));
|
||||
assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, "AssertParamIsCopy");
|
||||
} else {
|
||||
match *substr.fields {
|
||||
|
|
|
@ -938,7 +938,7 @@ impl<'a> MethodDef<'a> {
|
|||
let args = {
|
||||
let self_args = explicit_self.map(|explicit_self| {
|
||||
ast::Arg::from_self(explicit_self,
|
||||
keywords::SelfValue.ident().with_span_pos(trait_.span))
|
||||
keywords::SelfLower.ident().with_span_pos(trait_.span))
|
||||
});
|
||||
let nonself_args = arg_types.into_iter()
|
||||
.map(|(name, ty)| cx.arg(trait_.span, name, ty));
|
||||
|
|
|
@ -28,7 +28,7 @@ use syntax::symbol::Symbol;
|
|||
use syntax_pos::Span;
|
||||
use syntax::tokenstream;
|
||||
|
||||
pub const MACRO: &'static str = "global_asm";
|
||||
pub const MACRO: &str = "global_asm";
|
||||
|
||||
pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
|
||||
sp: Span,
|
||||
|
|
|
@ -30,8 +30,7 @@ use syntax_pos::{Span, DUMMY_SP};
|
|||
|
||||
use deriving;
|
||||
|
||||
const PROC_MACRO_KINDS: [&'static str; 3] =
|
||||
["proc_macro_derive", "proc_macro_attribute", "proc_macro"];
|
||||
const PROC_MACRO_KINDS: [&str; 3] = ["proc_macro_derive", "proc_macro_attribute", "proc_macro"];
|
||||
|
||||
struct ProcMacroDerive {
|
||||
trait_name: ast::Name,
|
||||
|
|
|
@ -13,7 +13,6 @@ use std::str::FromStr;
|
|||
|
||||
/// The edition of the compiler (RFC 2052)
|
||||
#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum Edition {
|
||||
// editions must be kept in order, oldest to newest
|
||||
|
||||
|
@ -33,7 +32,7 @@ pub enum Edition {
|
|||
// must be in order from oldest to newest
|
||||
pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018];
|
||||
|
||||
pub const EDITION_NAME_LIST: &'static str = "2015|2018";
|
||||
pub const EDITION_NAME_LIST: &str = "2015|2018";
|
||||
|
||||
pub const DEFAULT_EDITION: Edition = Edition::Edition2015;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use GLOBALS;
|
||||
use Span;
|
||||
use edition::Edition;
|
||||
use edition::{Edition, DEFAULT_EDITION};
|
||||
use symbol::Symbol;
|
||||
|
||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
|
@ -217,7 +217,7 @@ impl HygieneData {
|
|||
opaque_and_semitransparent: SyntaxContext(0),
|
||||
}],
|
||||
markings: FxHashMap::default(),
|
||||
default_edition: Edition::Edition2015,
|
||||
default_edition: DEFAULT_EDITION,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -349,11 +349,11 @@ declare_keywords! {
|
|||
// Special reserved identifiers used internally for elided lifetimes,
|
||||
// unnamed method parameters, crate root module, error recovery etc.
|
||||
(0, Invalid, "")
|
||||
(1, CrateRoot, "{{root}}")
|
||||
(1, PathRoot, "{{root}}")
|
||||
(2, DollarCrate, "$crate")
|
||||
(3, Underscore, "_")
|
||||
|
||||
// Keywords used in the language.
|
||||
// Keywords that are used in stable Rust.
|
||||
(4, As, "as")
|
||||
(5, Box, "box")
|
||||
(6, Break, "break")
|
||||
|
@ -378,8 +378,8 @@ declare_keywords! {
|
|||
(25, Pub, "pub")
|
||||
(26, Ref, "ref")
|
||||
(27, Return, "return")
|
||||
(28, SelfValue, "self")
|
||||
(29, SelfType, "Self")
|
||||
(28, SelfLower, "self")
|
||||
(29, SelfUpper, "Self")
|
||||
(30, Static, "static")
|
||||
(31, Struct, "struct")
|
||||
(32, Super, "super")
|
||||
|
@ -391,7 +391,7 @@ declare_keywords! {
|
|||
(38, Where, "where")
|
||||
(39, While, "while")
|
||||
|
||||
// Keywords reserved for future use.
|
||||
// Keywords that are used in unstable Rust or reserved for future use.
|
||||
(40, Abstract, "abstract")
|
||||
(41, Become, "become")
|
||||
(42, Do, "do")
|
||||
|
@ -404,9 +404,11 @@ declare_keywords! {
|
|||
(49, Virtual, "virtual")
|
||||
(50, Yield, "yield")
|
||||
|
||||
// Edition-specific keywords reserved for future use.
|
||||
(51, Async, "async") // >= 2018 Edition only
|
||||
(52, Dyn, "dyn") // >= 2018 Edition only
|
||||
// Edition-specific keywords that are used in stable Rust.
|
||||
(51, Dyn, "dyn") // >= 2018 Edition only
|
||||
|
||||
// Edition-specific keywords that are used in unstable Rust or reserved for future use.
|
||||
(52, Async, "async") // >= 2018 Edition only
|
||||
(53, Try, "try") // >= 2018 Edition only
|
||||
|
||||
// Special lifetime names
|
||||
|
@ -417,11 +419,15 @@ declare_keywords! {
|
|||
(56, Auto, "auto")
|
||||
(57, Catch, "catch")
|
||||
(58, Default, "default")
|
||||
(59, Union, "union")
|
||||
(60, Existential, "existential")
|
||||
(59, Existential, "existential")
|
||||
(60, Union, "union")
|
||||
}
|
||||
|
||||
impl Symbol {
|
||||
fn is_used_keyword_2018(self) -> bool {
|
||||
self == keywords::Dyn.name()
|
||||
}
|
||||
|
||||
fn is_unused_keyword_2018(self) -> bool {
|
||||
self >= keywords::Async.name() && self <= keywords::Try.name()
|
||||
}
|
||||
|
@ -436,7 +442,9 @@ impl Ident {
|
|||
|
||||
/// Returns `true` if the token is a keyword used in the language.
|
||||
pub fn is_used_keyword(self) -> bool {
|
||||
self.name >= keywords::As.name() && self.name <= keywords::While.name()
|
||||
// Note: `span.edition()` is relatively expensive, don't call it unless necessary.
|
||||
self.name >= keywords::As.name() && self.name <= keywords::While.name() ||
|
||||
self.name.is_used_keyword_2018() && self.span.rust_2018()
|
||||
}
|
||||
|
||||
/// Returns `true` if the token is a keyword reserved for possible future use.
|
||||
|
@ -454,11 +462,11 @@ impl Ident {
|
|||
/// A keyword or reserved identifier that can be used as a path segment.
|
||||
pub fn is_path_segment_keyword(self) -> bool {
|
||||
self.name == keywords::Super.name() ||
|
||||
self.name == keywords::SelfValue.name() ||
|
||||
self.name == keywords::SelfType.name() ||
|
||||
self.name == keywords::SelfLower.name() ||
|
||||
self.name == keywords::SelfUpper.name() ||
|
||||
self.name == keywords::Extern.name() ||
|
||||
self.name == keywords::Crate.name() ||
|
||||
self.name == keywords::CrateRoot.name() ||
|
||||
self.name == keywords::PathRoot.name() ||
|
||||
self.name == keywords::DollarCrate.name()
|
||||
}
|
||||
|
||||
|
|
38
src/test/run-pass/issue-55380.rs
Normal file
38
src/test/run-pass/issue-55380.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
pub trait Foo {
|
||||
fn abc() -> u32;
|
||||
fn def() -> u32;
|
||||
}
|
||||
|
||||
pub trait Marker {}
|
||||
|
||||
impl Marker for () {}
|
||||
|
||||
impl<T> Foo for T {
|
||||
default fn abc() -> u32 { 16 }
|
||||
default fn def() -> u32 { 42 }
|
||||
}
|
||||
|
||||
impl<T: Marker> Foo for T {
|
||||
fn def() -> u32 {
|
||||
Self::abc()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(<()>::def(), 16);
|
||||
assert_eq!(<i32>::def(), 42);
|
||||
}
|
|
@ -8,9 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x: u8 = 0;
|
||||
match x { //~ ERROR non-exhaustive patterns: `_` not covered
|
||||
0 ..= 255 => {}
|
||||
}
|
||||
}
|
||||
// exact-check
|
||||
|
||||
const QUERY = 'hashmap';
|
||||
const FILTER_CRATE = 'core';
|
||||
|
||||
const EXPECTED = {
|
||||
'others': [
|
||||
],
|
||||
};
|
28
src/test/rustdoc/inline_local/macro_by_example.rs
Normal file
28
src/test/rustdoc/inline_local/macro_by_example.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
/// docs for foo
|
||||
#[deprecated(since = "1.2.3", note = "text")]
|
||||
#[macro_export]
|
||||
macro_rules! foo {
|
||||
($($tt:tt)*) => {}
|
||||
}
|
||||
|
||||
// @has macro_by_example/macros/index.html
|
||||
pub mod macros {
|
||||
// @!has - 'pub use foo as bar;'
|
||||
// @has macro_by_example/macros/macro.bar.html
|
||||
// @has - '//*[@class="docblock"]' 'docs for foo'
|
||||
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text'
|
||||
// @has - '//a/@href' 'macro_by_example.rs.html#15-17'
|
||||
#[doc(inline)]
|
||||
pub use foo as bar;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
|
||||
--> $DIR/const-match-check.rs:35:15
|
||||
|
|
||||
LL | A = { let 0 = 0; 0 },
|
||||
| ^ pattern `_` not covered
|
||||
| ^ pattern `-2147483648i32..=-1i32` not covered
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
|
||||
--> $DIR/const-match-check.rs:41:24
|
||||
|
|
||||
LL | let x: [i32; { let 0 = 0; 0 }] = [];
|
||||
| ^ pattern `_` not covered
|
||||
| ^ pattern `-2147483648i32..=-1i32` not covered
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
|
||||
--> $DIR/const-match-check.rs:14:22
|
||||
|
|
||||
LL | const X: i32 = { let 0 = 0; 0 };
|
||||
| ^ pattern `_` not covered
|
||||
| ^ pattern `-2147483648i32..=-1i32` not covered
|
||||
|
||||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
|
||||
--> $DIR/const-match-check.rs:18:23
|
||||
|
|
||||
LL | static Y: i32 = { let 0 = 0; 0 };
|
||||
| ^ pattern `_` not covered
|
||||
| ^ pattern `-2147483648i32..=-1i32` not covered
|
||||
|
||||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
|
||||
--> $DIR/const-match-check.rs:23:26
|
||||
|
|
||||
LL | const X: i32 = { let 0 = 0; 0 };
|
||||
| ^ pattern `_` not covered
|
||||
| ^ pattern `-2147483648i32..=-1i32` not covered
|
||||
|
||||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
|
||||
--> $DIR/const-match-check.rs:29:26
|
||||
|
|
||||
LL | const X: i32 = { let 0 = 0; 0 };
|
||||
| ^ pattern `_` not covered
|
||||
| ^ pattern `-2147483648i32..=-1i32` not covered
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ use foo::d;
|
|||
const a: u8 = 2;
|
||||
|
||||
fn main() {
|
||||
let a = 4; //~ ERROR refutable pattern in local binding: `_` not covered
|
||||
let c = 4; //~ ERROR refutable pattern in local binding: `_` not covered
|
||||
let d = 4; //~ ERROR refutable pattern in local binding: `_` not covered
|
||||
let a = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
let c = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
let d = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
fn f() {} // Check that the `NOTE`s still work with an item here (c.f. issue #35115).
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
--> $DIR/const-pattern-irrefutable.rs:22:9
|
||||
|
|
||||
LL | let a = 4; //~ ERROR refutable pattern in local binding: `_` not covered
|
||||
LL | let a = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
| ^ interpreted as a constant pattern, not new variable
|
||||
|
||||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
--> $DIR/const-pattern-irrefutable.rs:23:9
|
||||
|
|
||||
LL | let c = 4; //~ ERROR refutable pattern in local binding: `_` not covered
|
||||
LL | let c = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
| ^ interpreted as a constant pattern, not new variable
|
||||
|
||||
error[E0005]: refutable pattern in local binding: `_` not covered
|
||||
error[E0005]: refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
--> $DIR/const-pattern-irrefutable.rs:24:9
|
||||
|
|
||||
LL | let d = 4; //~ ERROR refutable pattern in local binding: `_` not covered
|
||||
LL | let d = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` not covered
|
||||
| ^ interpreted as a constant pattern, not new variable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(exhaustive_integer_patterns)]
|
||||
#![feature(precise_pointer_size_matching)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
use std::{char, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128};
|
||||
use std::{char, u8, u16, u32, u64, u128, i8, i16, i32, i64, i128};
|
||||
|
||||
fn main() {
|
||||
let x: u8 = 0;
|
||||
|
@ -68,10 +69,6 @@ fn main() {
|
|||
'\u{E000}' ..= '\u{10_FFFF}' => {}
|
||||
}
|
||||
|
||||
match 0usize {
|
||||
0 ..= usize::MAX => {} // ok
|
||||
}
|
||||
|
||||
match 0u16 {
|
||||
0 ..= u16::MAX => {} // ok
|
||||
}
|
||||
|
@ -88,10 +85,6 @@ fn main() {
|
|||
0 ..= u128::MAX => {} // ok
|
||||
}
|
||||
|
||||
match 0isize {
|
||||
isize::MIN ..= isize::MAX => {} // ok
|
||||
}
|
||||
|
||||
match 0i8 {
|
||||
-128 ..= 127 => {} // ok
|
||||
}
|
||||
|
|
|
@ -1,83 +1,83 @@
|
|||
error: unreachable pattern
|
||||
--> $DIR/exhaustive_integer_patterns.rs:32:9
|
||||
--> $DIR/exhaustive_integer_patterns.rs:33:9
|
||||
|
|
||||
LL | 200 => {} //~ ERROR unreachable pattern
|
||||
| ^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/exhaustive_integer_patterns.rs:13:9
|
||||
--> $DIR/exhaustive_integer_patterns.rs:14:9
|
||||
|
|
||||
LL | #![deny(unreachable_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `128u8..=255u8` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:37:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:38:11
|
||||
|
|
||||
LL | match x { //~ ERROR non-exhaustive patterns
|
||||
| ^ pattern `128u8..=255u8` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `11u8..=19u8`, `31u8..=34u8`, `36u8..=69u8` and 1 more not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:42:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:43:11
|
||||
|
|
||||
LL | match x { //~ ERROR non-exhaustive patterns
|
||||
| ^ patterns `11u8..=19u8`, `31u8..=34u8`, `36u8..=69u8` and 1 more not covered
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/exhaustive_integer_patterns.rs:53:9
|
||||
--> $DIR/exhaustive_integer_patterns.rs:54:9
|
||||
|
|
||||
LL | -2..=20 => {} //~ ERROR unreachable pattern
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `-128i8..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:50:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:51:11
|
||||
|
|
||||
LL | match x { //~ ERROR non-exhaustive patterns
|
||||
| ^ patterns `-128i8..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `-128i8` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:99:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:92:11
|
||||
|
|
||||
LL | match 0i8 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^ pattern `-128i8` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `0i16` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:107:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:100:11
|
||||
|
|
||||
LL | match 0i16 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^ pattern `0i16` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `128u8..=255u8` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:125:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:118:11
|
||||
|
|
||||
LL | match 0u8 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^ pattern `128u8..=255u8` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `(0u8, Some(_))` and `(2u8..=255u8, Some(_))` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:137:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:130:11
|
||||
|
|
||||
LL | match (0u8, Some(())) { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^^^^^^^^^^^ patterns `(0u8, Some(_))` and `(2u8..=255u8, Some(_))` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `(126u8..=127u8, false)` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:142:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:135:11
|
||||
|
|
||||
LL | match (0u8, true) { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^^^^^^^ pattern `(126u8..=127u8, false)` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211455u128` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:162:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:155:11
|
||||
|
|
||||
LL | match 0u128 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^ pattern `340282366920938463463374607431768211455u128` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `5u128..=340282366920938463463374607431768211455u128` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:166:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:159:11
|
||||
|
|
||||
LL | match 0u128 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^ pattern `5u128..=340282366920938463463374607431768211455u128` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `0u128..=3u128` not covered
|
||||
--> $DIR/exhaustive_integer_patterns.rs:170:11
|
||||
--> $DIR/exhaustive_integer_patterns.rs:163:11
|
||||
|
|
||||
LL | match 0u128 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^ pattern `0u128..=3u128` not covered
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
--> $DIR/feature-gate-exhaustive_integer_patterns.rs:13:11
|
||||
|
|
||||
LL | match x { //~ ERROR non-exhaustive patterns: `_` not covered
|
||||
| ^ pattern `_` not covered
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(exclusive_range_pattern)]
|
||||
|
||||
use std::usize::MAX;
|
||||
|
||||
fn main() {
|
||||
match 0usize { //~ERROR non-exhaustive patterns: `_` not covered
|
||||
0..=MAX => {}
|
||||
}
|
||||
|
||||
match 0isize { //~ERROR non-exhaustive patterns: `_` not covered
|
||||
1..=20 => {}
|
||||
-5..3 => {}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
--> $DIR/feature-gate-precise_pointer_size_matching.rs:6:11
|
||||
|
|
||||
LL | match 0usize { //~ERROR non-exhaustive patterns: `_` not covered
|
||||
| ^^^^^^ pattern `_` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
--> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11
|
||||
|
|
||||
LL | match 0isize { //~ERROR non-exhaustive patterns: `_` not covered
|
||||
| ^^^^^^ pattern `_` not covered
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
|
@ -1,8 +1,8 @@
|
|||
error[E0005]: refutable pattern in `for` loop binding: `&_` not covered
|
||||
error[E0005]: refutable pattern in `for` loop binding: `&-2147483648i32..=0i32` not covered
|
||||
--> $DIR/for-loop-refutable-pattern-error-message.rs:12:9
|
||||
|
|
||||
LL | for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding
|
||||
| ^^ pattern `&_` not covered
|
||||
| ^^ pattern `&-2147483648i32..=0i32` not covered
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `-2147483648i32..=0i32` and `2i32..=2147483647i32` not covered
|
||||
--> $DIR/match-non-exhaustive.rs:12:11
|
||||
|
|
||||
LL | match 0 { 1 => () } //~ ERROR non-exhaustive patterns
|
||||
| ^ pattern `_` not covered
|
||||
| ^ patterns `-2147483648i32..=0i32` and `2i32..=2147483647i32` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
--> $DIR/match-non-exhaustive.rs:13:11
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#![allow(illegal_floating_point_literal_pattern)]
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
fn main() {
|
||||
match 0.0 {
|
||||
0.0..=1.0 => {}
|
||||
_ => {} // ok
|
||||
}
|
||||
|
||||
match 0.0 { //~ ERROR non-exhaustive patterns
|
||||
0.0..=1.0 => {}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
error[E0004]: non-exhaustive patterns: `_` not covered
|
||||
--> $DIR/non-exhaustive-float-range-match.rs:10:11
|
||||
|
|
||||
LL | match 0.0 { //~ ERROR non-exhaustive patterns
|
||||
| ^^^ pattern `_` not covered
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
|
@ -22,7 +22,8 @@ fn main() {
|
|||
match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
|
||||
None => {}
|
||||
}
|
||||
match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered
|
||||
match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)`
|
||||
// and `(_, _, 5i32..=2147483647i32)` not covered
|
||||
(_, _, 4) => {}
|
||||
}
|
||||
match (t::a, t::a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered
|
||||
|
|
|
@ -16,32 +16,32 @@ error[E0004]: non-exhaustive patterns: `Some(_)` not covered
|
|||
LL | match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
|
||||
| ^^^^^^^^ pattern `Some(_)` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `(_, _, _)` not covered
|
||||
error[E0004]: non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)` and `(_, _, 5i32..=2147483647i32)` not covered
|
||||
--> $DIR/non-exhaustive-match.rs:25:11
|
||||
|
|
||||
LL | match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered
|
||||
| ^^^^^^^^^ pattern `(_, _, _)` not covered
|
||||
LL | match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)`
|
||||
| ^^^^^^^^^ patterns `(_, _, -2147483648i32..=3i32)` and `(_, _, 5i32..=2147483647i32)` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `(a, a)` not covered
|
||||
--> $DIR/non-exhaustive-match.rs:28:11
|
||||
--> $DIR/non-exhaustive-match.rs:29:11
|
||||
|
|
||||
LL | match (t::a, t::a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered
|
||||
| ^^^^^^^^^^^^ pattern `(a, a)` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `b` not covered
|
||||
--> $DIR/non-exhaustive-match.rs:32:11
|
||||
--> $DIR/non-exhaustive-match.rs:33:11
|
||||
|
|
||||
LL | match t::a { //~ ERROR non-exhaustive patterns: `b` not covered
|
||||
| ^^^^ pattern `b` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `[]` not covered
|
||||
--> $DIR/non-exhaustive-match.rs:43:11
|
||||
--> $DIR/non-exhaustive-match.rs:44:11
|
||||
|
|
||||
LL | match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered
|
||||
| ^^^^ pattern `[]` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `[_, _, _, _]` not covered
|
||||
--> $DIR/non-exhaustive-match.rs:56:11
|
||||
--> $DIR/non-exhaustive-match.rs:57:11
|
||||
|
|
||||
LL | match *vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered
|
||||
| ^^^^ pattern `[_, _, _, _]` not covered
|
||||
|
|
33
src/test/ui/precise_pointer_size_matching.rs
Normal file
33
src/test/ui/precise_pointer_size_matching.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// normalize-stderr-32bit: "-2147483648isize" -> "$$ISIZE_MIN"
|
||||
// normalize-stderr-64bit: "-9223372036854775808isize" -> "$$ISIZE_MIN"
|
||||
// normalize-stderr-32bit: "2147483647isize" -> "$$ISIZE_MAX"
|
||||
// normalize-stderr-64bit: "9223372036854775807isize" -> "$$ISIZE_MAX"
|
||||
// normalize-stderr-32bit: "4294967295usize" -> "$$USIZE_MAX"
|
||||
// normalize-stderr-64bit: "18446744073709551615usize" -> "$$USIZE_MAX"
|
||||
|
||||
#![feature(precise_pointer_size_matching)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
use std::{usize, isize};
|
||||
|
||||
fn main() {
|
||||
match 0isize {
|
||||
isize::MIN ..= isize::MAX => {} // ok
|
||||
}
|
||||
|
||||
match 0usize {
|
||||
0 ..= usize::MAX => {} // ok
|
||||
}
|
||||
|
||||
match 0isize { //~ ERROR non-exhaustive patterns
|
||||
1 ..= 8 => {}
|
||||
-5 ..= 20 => {}
|
||||
}
|
||||
|
||||
match 0usize { //~ ERROR non-exhaustive patterns
|
||||
1 ..= 8 => {}
|
||||
5 ..= 20 => {}
|
||||
}
|
||||
}
|
15
src/test/ui/precise_pointer_size_matching.stderr
Normal file
15
src/test/ui/precise_pointer_size_matching.stderr
Normal file
|
@ -0,0 +1,15 @@
|
|||
error[E0004]: non-exhaustive patterns: `$ISIZE_MIN..=-6isize` and `21isize..=$ISIZE_MAX` not covered
|
||||
--> $DIR/precise_pointer_size_matching.rs:24:11
|
||||
|
|
||||
LL | match 0isize { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^^ patterns `$ISIZE_MIN..=-6isize` and `21isize..=$ISIZE_MAX` not covered
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `0usize` and `21usize..=$USIZE_MAX` not covered
|
||||
--> $DIR/precise_pointer_size_matching.rs:29:11
|
||||
|
|
||||
LL | match 0usize { //~ ERROR non-exhaustive patterns
|
||||
| ^^^^^^ patterns `0usize` and `21usize..=$USIZE_MAX` not covered
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
|
@ -14,5 +14,5 @@ fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
|
|||
|
||||
fn main() {
|
||||
let (1, (Some(1), 2..=3)) = (1, (None, 2));
|
||||
//~^ ERROR refutable pattern in local binding: `(_, _)` not covered
|
||||
//~^ ERROR refutable pattern in local binding: `(-2147483648i32..=0i32, _)` not covered
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ error[E0005]: refutable pattern in function argument: `(_, _)` not covered
|
|||
LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
|
||||
|
||||
error[E0005]: refutable pattern in local binding: `(_, _)` not covered
|
||||
error[E0005]: refutable pattern in local binding: `(-2147483648i32..=0i32, _)` not covered
|
||||
--> $DIR/refutable-pattern-errors.rs:16:9
|
||||
|
|
||||
LL | let (1, (Some(1), 2..=3)) = (1, (None, 2));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ pattern `(-2147483648i32..=0i32, _)` not covered
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// edition:2018
|
||||
|
||||
type A0 = dyn;
|
||||
type A1 = dyn::dyn; //~ERROR expected identifier, found reserved keyword
|
||||
type A1 = dyn::dyn; //~ERROR expected identifier, found keyword `dyn`
|
||||
type A2 = dyn<dyn, dyn>; //~ERROR expected identifier, found `<`
|
||||
type A3 = dyn<<dyn as dyn>::dyn>;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error: expected identifier, found reserved keyword `dyn`
|
||||
error: expected identifier, found keyword `dyn`
|
||||
--> $DIR/dyn-trait-compatibility.rs:4:16
|
||||
|
|
||||
LL | type A1 = dyn::dyn; //~ERROR expected identifier, found reserved keyword
|
||||
| ^^^ expected identifier, found reserved keyword
|
||||
LL | type A1 = dyn::dyn; //~ERROR expected identifier, found keyword `dyn`
|
||||
| ^^^ expected identifier, found keyword
|
||||
|
||||
error: expected identifier, found `<`
|
||||
--> $DIR/dyn-trait-compatibility.rs:5:14
|
||||
|
|
|
@ -259,6 +259,7 @@ function main(argv) {
|
|||
'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
|
||||
const expected = loadedFile.EXPECTED;
|
||||
const query = loadedFile.QUERY;
|
||||
const filter_crate = loadedFile.FILTER_CRATE;
|
||||
const ignore_order = loadedFile.ignore_order;
|
||||
const exact_check = loadedFile.exact_check;
|
||||
const should_fail = loadedFile.should_fail;
|
||||
|
|
Loading…
Reference in a new issue