Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #57607

Merged
merged 35 commits into from
Jan 15, 2019
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f9f71cc
Fix poor worst case performance of set intersection (and union, somew…
ssomers Dec 21, 2018
ccba43d
Merge remote-tracking branch 'upstream/master'
ssomers Jan 9, 2019
60d1db6
Clean up and fix a bug in query plumbing
Zoxc Jan 9, 2019
8823bf0
Fix poor worst case performance of is_disjoint
ssomers Jan 9, 2019
565c39d
provide suggestion for invalid boolean cast
euclio Jan 9, 2019
cef2e2f
Merge remote-tracking branch 'upstream/master'
ssomers Jan 10, 2019
5c67ba6
Continue parser after trailing type argument attribute
estebank Jan 12, 2019
fc4b541
Continue parsing after lifetime in incorrect location
estebank Jan 12, 2019
d8610b3
Continue evaluating after parsing incorrect binary literal
estebank Jan 12, 2019
5d2f31c
Continue evaluating after missing `for` in `impl Trait for Foo`
estebank Jan 12, 2019
57f17e9
Continue evaluating after type argument in where clause
estebank Jan 12, 2019
65a8d7b
fix tests
estebank Jan 12, 2019
8bede50
Continue evaluating after incorrect float literal
estebank Jan 12, 2019
975f8b5
fix test
estebank Jan 12, 2019
8119017
Continue evaluating after finding incorrect .. in pattern
estebank Jan 12, 2019
de3c4be
Tweak type argument after assoc type error
estebank Jan 12, 2019
7feb802
Small tweaks to parser errors
estebank Jan 12, 2019
3ead6de
Tweak incorrect discriminator value variant error
estebank Jan 12, 2019
1550787
Add label for invalid literal suffix
estebank Jan 12, 2019
db74031
Remove unrelated errors from parse stderr tests
estebank Jan 13, 2019
28ea03e
Suggest correct location for lifetime parameters in use
estebank Jan 13, 2019
c4f6ef2
remove extern_in_paths.
Centril Jan 13, 2019
fb60400
Querify local proc_macro_decls_static
Xanewok Jan 12, 2019
59d7d7d
Querify local plugin_registrar_fn
Xanewok Jan 13, 2019
707a9a0
Retain original pass order
Xanewok Jan 13, 2019
3874c77
Recover from item trailing semicolon
estebank Jan 14, 2019
1fd971c
Add a debug_assert to Vec::set_len
scottmcm Dec 15, 2018
5bc95de
Rollup merge of #57043 - ssomers:master, r=alexcrichton
Centril Jan 14, 2019
8c001b1
Rollup merge of #57480 - Zoxc:query-fix, r=michaelwoerister
Centril Jan 14, 2019
816e31b
Rollup merge of #57481 - euclio:bool-cast-suggestion, r=estebank
Centril Jan 14, 2019
2f7a226
Rollup merge of #57540 - estebank:eval-more, r=petrochenkov
Centril Jan 14, 2019
2e10944
Rollup merge of #57570 - Xanewok:querify-some, r=Zoxc
Centril Jan 14, 2019
feb48f3
Rollup merge of #57572 - Centril:unaccept-extern-in-path, r=petrochenkov
Centril Jan 14, 2019
b03d414
Rollup merge of #57585 - estebank:trailing-semicolon, r=petrochenkov
Centril Jan 14, 2019
8a62e39
Rollup merge of #57589 - scottmcm:vec-set_len-debug_assert, r=alexcri…
Centril Jan 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions src/doc/unstable-book/src/language-features/extern-in-paths.md

This file was deleted.

2 changes: 2 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
@@ -819,6 +819,8 @@ impl<T> Vec<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn set_len(&mut self, new_len: usize) {
debug_assert!(new_len <= self.capacity());

self.len = new_len;
}

2 changes: 1 addition & 1 deletion src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ pub enum ExternCrateSource {
),
// Crate is loaded by `use`.
Use,
/// Crate is implicitly loaded by an absolute or an `extern::` path.
/// Crate is implicitly loaded by an absolute path.
Path,
}

4 changes: 0 additions & 4 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
@@ -69,8 +69,6 @@ pub struct Session {
pub parse_sess: ParseSess,
/// For a library crate, this is always none
pub entry_fn: Once<Option<(NodeId, Span, config::EntryFnType)>>,
pub plugin_registrar_fn: Once<Option<ast::NodeId>>,
pub proc_macro_decls_static: Once<Option<ast::NodeId>>,
pub sysroot: PathBuf,
/// The name of the root source file of the crate, in the local file system.
/// `None` means that there is no source file.
@@ -1177,8 +1175,6 @@ pub fn build_session_(
parse_sess: p_s,
// For a library crate, this is always none
entry_fn: Once::new(),
plugin_registrar_fn: Once::new(),
proc_macro_decls_static: Once::new(),
sysroot,
local_crate_source_file,
working_dir,
41 changes: 21 additions & 20 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
@@ -402,7 +402,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// expensive for some DepKinds.
if !self.dep_graph.is_fully_enabled() {
let null_dep_node = DepNode::new_no_params(::dep_graph::DepKind::Null);
return self.force_query_with_job::<Q>(key, job, null_dep_node).map(|(v, _)| v);
return Ok(self.force_query_with_job::<Q>(key, job, null_dep_node).0);
}

let dep_node = Q::to_dep_node(self, &key);
@@ -436,20 +436,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

if !dep_node.kind.is_input() {
if let Some(dep_node_index) = self.try_mark_green_and_read(&dep_node) {
return self.load_from_disk_and_cache_in_memory::<Q>(key,
job,
dep_node_index,
&dep_node)
return Ok(self.load_from_disk_and_cache_in_memory::<Q>(
key,
job,
dep_node_index,
&dep_node
))
}
}

match self.force_query_with_job::<Q>(key, job, dep_node) {
Ok((result, dep_node_index)) => {
self.dep_graph.read_index(dep_node_index);
Ok(result)
}
Err(e) => Err(e)
}
let (result, dep_node_index) = self.force_query_with_job::<Q>(key, job, dep_node);
self.dep_graph.read_index(dep_node_index);
Ok(result)
}

fn load_from_disk_and_cache_in_memory<Q: QueryDescription<'gcx>>(
@@ -458,7 +456,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
job: JobOwner<'a, 'gcx, Q>,
dep_node_index: DepNodeIndex,
dep_node: &DepNode
) -> Result<Q::Value, Box<CycleError<'gcx>>>
) -> Q::Value
{
// Note this function can be called concurrently from the same query
// We must ensure that this is handled correctly
@@ -523,7 +521,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

job.complete(&result, dep_node_index);

Ok(result)
result
}

#[inline(never)]
@@ -563,7 +561,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
key: Q::Key,
job: JobOwner<'_, 'gcx, Q>,
dep_node: DepNode)
-> Result<(Q::Value, DepNodeIndex), Box<CycleError<'gcx>>> {
-> (Q::Value, DepNodeIndex) {
// If the following assertion triggers, it can have two reasons:
// 1. Something is wrong with DepNode creation, either here or
// in DepGraph::try_mark_green()
@@ -610,7 +608,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

job.complete(&result, dep_node_index);

Ok((result, dep_node_index))
(result, dep_node_index)
}

/// Ensure that either this query has all green inputs or been executed.
@@ -657,11 +655,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// Ensure that only one of them runs the query
let job = match JobOwner::try_get(self, span, &key) {
TryGetJob::NotYetStarted(job) => job,
TryGetJob::JobCompleted(_) => return,
TryGetJob::JobCompleted(result) => {
if let Err(e) = result {
self.report_cycle(e).emit();
}
return
}
};
if let Err(e) = self.force_query_with_job::<Q>(key, job, dep_node) {
self.report_cycle(e).emit();
}
self.force_query_with_job::<Q>(key, job, dep_node);
}

pub(super) fn try_get_query<Q: QueryDescription<'gcx>>(
10 changes: 4 additions & 6 deletions src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
@@ -147,14 +147,12 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
})
.collect();

if let Some(id) = *tcx.sess.proc_macro_decls_static.get() {
let def_id = tcx.hir().local_def_id(id);
reachable_non_generics.insert(def_id, SymbolExportLevel::C);
if let Some(id) = tcx.proc_macro_decls_static(LOCAL_CRATE) {
reachable_non_generics.insert(id, SymbolExportLevel::C);
}

if let Some(id) = *tcx.sess.plugin_registrar_fn.get() {
let def_id = tcx.hir().local_def_id(id);
reachable_non_generics.insert(def_id, SymbolExportLevel::C);
if let Some(id) = tcx.plugin_registrar_fn(LOCAL_CRATE) {
reachable_non_generics.insert(id, SymbolExportLevel::C);
}

Lrc::new(reachable_non_generics)
6 changes: 3 additions & 3 deletions src/librustc_codegen_utils/symbol_names.rs
Original file line number Diff line number Diff line change
@@ -242,12 +242,12 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance

let node_id = tcx.hir().as_local_node_id(def_id);

if let Some(id) = node_id {
if *tcx.sess.plugin_registrar_fn.get() == Some(id) {
if def_id.is_local() {
if tcx.plugin_registrar_fn(LOCAL_CRATE) == Some(def_id) {
let disambiguator = tcx.sess.local_crate_disambiguator();
return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
}
if *tcx.sess.proc_macro_decls_static.get() == Some(id) {
if tcx.proc_macro_decls_static(LOCAL_CRATE) == Some(def_id) {
let disambiguator = tcx.sess.local_crate_disambiguator();
return tcx.sess.generate_proc_macro_decls_symbol(disambiguator);
}
17 changes: 10 additions & 7 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
@@ -1158,6 +1158,8 @@ where
}

pub fn default_provide(providers: &mut ty::query::Providers) {
proc_macro_decls::provide(providers);
plugin::build::provide(providers);
hir::provide(providers);
borrowck::provide(providers);
mir::provide(providers);
@@ -1212,13 +1214,6 @@ where
middle::entry::find_entry_point(sess, &hir_map, name)
});

sess.plugin_registrar_fn
.set(time(sess, "looking for plugin registrar", || {
plugin::build::find_plugin_registrar(sess.diagnostic(), &hir_map)
}));
sess.proc_macro_decls_static
.set(proc_macro_decls::find(&hir_map));

let mut local_providers = ty::query::Providers::default();
default_provide(&mut local_providers);
codegen_backend.provide(&mut local_providers);
@@ -1248,6 +1243,14 @@ where
// tcx available.
time(sess, "dep graph tcx init", || rustc_incremental::dep_graph_tcx_init(tcx));

time(sess, "looking for plugin registrar", || {
plugin::build::find_plugin_registrar(tcx)
});

time(sess, "looking for derive registrar", || {
proc_macro_decls::find(tcx)
});

time(sess, "loop checking", || loops::check_crate(tcx));

time(sess, "attribute checking", || {
26 changes: 21 additions & 5 deletions src/librustc_driver/proc_macro_decls.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::map::Map;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::hir;
use rustc::ty::TyCtxt;
use rustc::ty::query::Providers;
use syntax::ast;
use syntax::attr;

pub fn find(hir_map: &Map) -> Option<ast::NodeId> {
let krate = hir_map.krate();
pub fn find<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
tcx.proc_macro_decls_static(LOCAL_CRATE)
}

fn proc_macro_decls_static<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
cnum: CrateNum,
) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);

let mut finder = Finder { decls: None };
krate.visit_all_item_likes(&mut finder);
finder.decls
tcx.hir().krate().visit_all_item_likes(&mut finder);

finder.decls.map(|id| tcx.hir().local_def_id(id))
}

struct Finder {
@@ -30,3 +40,9 @@ impl<'v> ItemLikeVisitor<'v> for Finder {
}
}

pub(crate) fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
proc_macro_decls_static,
..*providers
};
}
4 changes: 2 additions & 2 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
//! a `pub fn new()`.
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::ty::{self, Ty};
use hir::Node;
use util::nodemap::NodeSet;
@@ -860,7 +860,7 @@ impl LintPass for PluginAsLibrary {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
if cx.sess().plugin_registrar_fn.get().is_some() {
if cx.tcx.plugin_registrar_fn(LOCAL_CRATE).is_some() {
// We're compiling a plugin; it's fine to link other plugins.
return;
}
9 changes: 3 additions & 6 deletions src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
@@ -482,13 +482,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
has_global_allocator: has_global_allocator,
has_panic_handler: has_panic_handler,
has_default_lib_allocator: has_default_lib_allocator,
plugin_registrar_fn: tcx.sess
.plugin_registrar_fn
.get()
.map(|id| tcx.hir().local_def_id(id).index),
plugin_registrar_fn: tcx.plugin_registrar_fn(LOCAL_CRATE).map(|id| id.index),
proc_macro_decls_static: if is_proc_macro {
let id = tcx.sess.proc_macro_decls_static.get().unwrap();
Some(tcx.hir().local_def_id(id).index)
let id = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap();
Some(id.index)
} else {
None
},
31 changes: 23 additions & 8 deletions src/librustc_plugin/build.rs
Original file line number Diff line number Diff line change
@@ -2,11 +2,12 @@
use syntax::ast;
use syntax::attr;
use errors;
use syntax_pos::Span;
use rustc::hir::map::Map;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::TyCtxt;
use rustc::ty::query::Providers;

struct RegistrarFinder {
registrars: Vec<(ast::NodeId, Span)> ,
@@ -30,21 +31,27 @@ impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
}

/// Find the function marked with `#[plugin_registrar]`, if any.
pub fn find_plugin_registrar(diagnostic: &errors::Handler,
hir_map: &Map)
-> Option<ast::NodeId> {
let krate = hir_map.krate();
pub fn find_plugin_registrar<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
tcx.plugin_registrar_fn(LOCAL_CRATE)
}

fn plugin_registrar_fn<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
cnum: CrateNum,
) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);

let mut finder = RegistrarFinder { registrars: Vec::new() };
krate.visit_all_item_likes(&mut finder);
tcx.hir().krate().visit_all_item_likes(&mut finder);

match finder.registrars.len() {
0 => None,
1 => {
let (node_id, _) = finder.registrars.pop().unwrap();
Some(node_id)
Some(tcx.hir().local_def_id(node_id))
},
_ => {
let diagnostic = tcx.sess.diagnostic();
let mut e = diagnostic.struct_err("multiple plugin registration functions found");
for &(_, span) in &finder.registrars {
e.span_note(span, "one is here");
@@ -55,3 +62,11 @@ pub fn find_plugin_registrar(diagnostic: &errors::Handler,
}
}
}


pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
plugin_registrar_fn,
..*providers
};
}
9 changes: 4 additions & 5 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
@@ -1015,7 +1015,7 @@ enum ModuleOrUniformRoot<'a> {
CrateRootAndExternPrelude,

/// Virtual module that denotes resolution in extern prelude.
/// Used for paths starting with `::` on 2018 edition or `extern::`.
/// Used for paths starting with `::` on 2018 edition.
ExternPrelude,

/// Virtual module that denotes resolution in current scope.
@@ -3836,8 +3836,7 @@ impl<'a> Resolver<'a> {
self.resolve_self(&mut ctxt, self.current_module)));
continue;
}
if name == keywords::Extern.name() ||
name == keywords::PathRoot.name() && ident.span.rust_2018() {
if name == keywords::PathRoot.name() && ident.span.rust_2018() {
module = Some(ModuleOrUniformRoot::ExternPrelude);
continue;
}
@@ -4004,8 +4003,8 @@ impl<'a> Resolver<'a> {
};

// We're only interested in `use` paths which should start with
// `{{root}}` or `extern` currently.
if first_name != keywords::Extern.name() && first_name != keywords::PathRoot.name() {
// `{{root}}` currently.
if first_name != keywords::PathRoot.name() {
return
}

26 changes: 22 additions & 4 deletions src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
@@ -257,10 +257,28 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
.emit();
}
CastError::CastToBool => {
struct_span_err!(fcx.tcx.sess, self.span, E0054, "cannot cast as `bool`")
.span_label(self.span, "unsupported cast")
.help("compare with zero instead")
.emit();
let mut err =
struct_span_err!(fcx.tcx.sess, self.span, E0054, "cannot cast as `bool`");

if self.expr_ty.is_numeric() {
match fcx.tcx.sess.source_map().span_to_snippet(self.expr.span) {
Ok(snippet) => {
err.span_suggestion_with_applicability(
self.span,
"compare with zero instead",
format!("{} != 0", snippet),
Applicability::MachineApplicable,
);
}
Err(_) => {
err.span_help(self.span, "compare with zero instead");
}
}
} else {
err.span_label(self.span, "unsupported cast");
}

err.emit();
}
CastError::CastToChar => {
type_error_struct!(fcx.tcx.sess, self.span, self.expr_ty, E0604,
67 changes: 60 additions & 7 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
@@ -410,9 +410,16 @@ impl<T, S> HashSet<T, S>
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> {
Intersection {
iter: self.iter(),
other,
if self.len() <= other.len() {
Intersection {
iter: self.iter(),
other,
}
} else {
Intersection {
iter: other.iter(),
other: self,
}
}
}

@@ -436,7 +443,15 @@ impl<T, S> HashSet<T, S>
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
Union { iter: self.iter().chain(other.difference(self)) }
if self.len() <= other.len() {
Union {
iter: self.iter().chain(other.difference(self)),
}
} else {
Union {
iter: other.iter().chain(self.difference(other)),
}
}
}

/// Returns the number of elements in the set.
@@ -584,7 +599,11 @@ impl<T, S> HashSet<T, S>
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_disjoint(&self, other: &HashSet<T, S>) -> bool {
self.iter().all(|v| !other.contains(v))
if self.len() <= other.len() {
self.iter().all(|v| !other.contains(v))
} else {
other.iter().all(|v| !self.contains(v))
}
}

/// Returns `true` if the set is a subset of another,
@@ -1494,6 +1513,7 @@ mod test_set {
fn test_intersection() {
let mut a = HashSet::new();
let mut b = HashSet::new();
assert!(a.intersection(&b).next().is_none());

assert!(a.insert(11));
assert!(a.insert(1));
@@ -1518,6 +1538,22 @@ mod test_set {
i += 1
}
assert_eq!(i, expected.len());

assert!(a.insert(9)); // make a bigger than b

i = 0;
for x in a.intersection(&b) {
assert!(expected.contains(x));
i += 1
}
assert_eq!(i, expected.len());

i = 0;
for x in b.intersection(&a) {
assert!(expected.contains(x));
i += 1
}
assert_eq!(i, expected.len());
}

#[test]
@@ -1573,11 +1609,11 @@ mod test_set {
fn test_union() {
let mut a = HashSet::new();
let mut b = HashSet::new();
assert!(a.union(&b).next().is_none());
assert!(b.union(&a).next().is_none());

assert!(a.insert(1));
assert!(a.insert(3));
assert!(a.insert(5));
assert!(a.insert(9));
assert!(a.insert(11));
assert!(a.insert(16));
assert!(a.insert(19));
@@ -1597,6 +1633,23 @@ mod test_set {
i += 1
}
assert_eq!(i, expected.len());

assert!(a.insert(9)); // make a bigger than b
assert!(a.insert(5));

i = 0;
for x in a.union(&b) {
assert!(expected.contains(x));
i += 1
}
assert_eq!(i, expected.len());

i = 0;
for x in b.union(&a) {
assert!(expected.contains(x));
i += 1
}
assert_eq!(i, expected.len());
}

#[test]
29 changes: 5 additions & 24 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -25,9 +25,9 @@ use syntax_pos::{Span, DUMMY_SP};
use errors::{DiagnosticBuilder, Handler};
use visit::{self, FnKind, Visitor};
use parse::ParseSess;
use symbol::{keywords, Symbol};
use symbol::Symbol;

use std::{env};
use std::env;

macro_rules! set {
($field: ident) => {{
@@ -372,9 +372,6 @@ declare_features! (
// Generic associated types (RFC 1598)
(active, generic_associated_types, "1.23.0", Some(44265), None),

// `extern` in paths
(active, extern_in_paths, "1.23.0", Some(55600), None),

// Infer static outlives requirements (RFC 2093).
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),

@@ -503,6 +500,9 @@ declare_features! (
// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
(removed, custom_derive, "1.0.0", Some(29644), None,
Some("subsumed by `#[proc_macro_derive]`")),
// Paths of the form: `extern::foo::bar`
(removed, extern_in_paths, "1.33.0", Some(55600), None,
Some("subsumed by `::foo::bar` paths")),
);

declare_features! (
@@ -1827,25 +1827,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
visit::walk_impl_item(self, ii);
}

fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
for segment in &path.segments {
// Identifiers we are going to check could come from a legacy macro (e.g., `#[test]`).
// For such macros identifiers must have empty context, because this context is
// used during name resolution and produced names must be unhygienic for compatibility.
// On the other hand, we need the actual non-empty context for feature gate checking
// because it's hygienic even for legacy macros. As previously stated, such context
// cannot be kept in identifiers, so it's kept in paths instead and we take it from
// there while keeping location info from the ident span.
let span = segment.ident.span.with_ctxt(path.span.ctxt());
if segment.ident.name == keywords::Extern.name() {
gate_feature_post!(&self, extern_in_paths, span,
"`extern` in paths is experimental");
}
}

visit::walk_path(self, path);
}

fn visit_vis(&mut self, vis: &'a ast::Visibility) {
if let ast::VisibilityKind::Crate(ast::CrateSugar::JustCrate) = vis.node {
gate_feature_post!(&self, crate_visibility_modifier, vis.span,
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
@@ -299,7 +299,7 @@ impl<'a> StringReader<'a> {

/// Report a lexical error with a given span.
fn err_span(&self, sp: Span, m: &str) {
self.sess.span_diagnostic.span_err(sp, m)
self.sess.span_diagnostic.struct_span_err(sp, m).emit();
}


8 changes: 7 additions & 1 deletion src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
@@ -520,6 +520,7 @@ fn filtered_float_lit(data: Symbol, suffix: Option<Symbol>, diag: Option<(Span,
} else {
let msg = format!("invalid suffix `{}` for float literal", suf);
diag.struct_span_err(span, &msg)
.span_label(span, format!("invalid suffix `{}`", suf))
.help("valid suffixes are `f32` and `f64`")
.emit();
}
@@ -673,7 +674,11 @@ fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
_ => None,
};
if let Some(err) = err {
err!(diag, |span, diag| diag.span_err(span, err));
err!(diag, |span, diag| {
diag.struct_span_err(span, err)
.span_label(span, "not supported")
.emit();
});
}
return filtered_float_lit(Symbol::intern(s), Some(suf), diag)
}
@@ -712,6 +717,7 @@ fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
} else {
let msg = format!("invalid suffix `{}` for numeric literal", suf);
diag.struct_span_err(span, &msg)
.span_label(span, format!("invalid suffix `{}`", suf))
.help("the suffix must be one of the integral types \
(`u32`, `isize`, etc)")
.emit();
215 changes: 152 additions & 63 deletions src/libsyntax/parse/parser.rs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
@@ -478,7 +478,6 @@ impl Ident {
self.name == keywords::Super.name() ||
self.name == keywords::SelfLower.name() ||
self.name == keywords::SelfUpper.name() ||
self.name == keywords::Extern.name() ||
self.name == keywords::Crate.name() ||
self.name == keywords::PathRoot.name() ||
self.name == keywords::DollarCrate.name()
5 changes: 1 addition & 4 deletions src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
-include ../tools.mk

all: extern_absolute_paths.rs extern_in_paths.rs krate2
all: extern_absolute_paths.rs krate2
$(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018 \
-Z unstable-options --extern krate2
cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
$(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018 \
-Z unstable-options --extern krate2
cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py

krate2: krate2.rs
$(RUSTC) $<

This file was deleted.

28 changes: 0 additions & 28 deletions src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error: trailing attribute after lifetime parameters
--> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25
|
LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
| ^^^^^^^
| ^^^^^^^ attributes must go before parameters

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error: trailing attribute after type parameters
--> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35
|
LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
| ^^^^^^^
| ^^^^^^^ attributes must go before parameters

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -5,12 +5,8 @@
struct RefIntPair<'a, 'b>(&'a u32, &'b u32);

fn hof_lt<Q>(_: Q)
where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
where Q: for <#[allow(unused)] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
//~^ ERROR trailing attribute after lifetime parameters
{
{}

}

fn main() {

}
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: trailing attribute after lifetime parameters
--> $DIR/attrs-with-no-formal-in-generics-3.rs:8:38
--> $DIR/attrs-with-no-formal-in-generics-3.rs:8:44
|
LL | where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
| ^^^^^^^
LL | where Q: for <#[allow(unused)] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
| ^^^^^^^ attributes must go before parameters

error: aborting due to previous error

9 changes: 7 additions & 2 deletions src/test/ui/cast/cast-as-bool.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
fn main() {
let u = 5 as bool;
//~^ ERROR cannot cast as `bool`
let u = 5 as bool; //~ ERROR cannot cast as `bool`
//~| HELP compare with zero instead
//~| SUGGESTION 5 != 0
let t = (1 + 2) as bool; //~ ERROR cannot cast as `bool`
//~| HELP compare with zero instead
//~| SUGGESTION (1 + 2) != 0
let v = "hello" as bool; //~ ERROR cannot cast as `bool`
}
18 changes: 14 additions & 4 deletions src/test/ui/cast/cast-as-bool.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
error[E0054]: cannot cast as `bool`
--> $DIR/cast-as-bool.rs:2:13
|
LL | let u = 5 as bool;
| ^^^^^^^^^ unsupported cast
LL | let u = 5 as bool; //~ ERROR cannot cast as `bool`
| ^^^^^^^^^ help: compare with zero instead: `5 != 0`

error[E0054]: cannot cast as `bool`
--> $DIR/cast-as-bool.rs:5:13
|
LL | let t = (1 + 2) as bool; //~ ERROR cannot cast as `bool`
| ^^^^^^^^^^^^^^^ help: compare with zero instead: `(1 + 2) != 0`

error[E0054]: cannot cast as `bool`
--> $DIR/cast-as-bool.rs:8:13
|
= help: compare with zero instead
LL | let v = "hello" as bool; //~ ERROR cannot cast as `bool`
| ^^^^^^^^^^^^^^^ unsupported cast

error: aborting due to previous error
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0054`.
4 changes: 1 addition & 3 deletions src/test/ui/cast/cast-rfc0401-2.stderr
Original file line number Diff line number Diff line change
@@ -2,9 +2,7 @@ error[E0054]: cannot cast as `bool`
--> $DIR/cast-rfc0401-2.rs:6:13
|
LL | let _ = 3 as bool;
| ^^^^^^^^^ unsupported cast
|
= help: compare with zero instead
| ^^^^^^^^^ help: compare with zero instead: `3 != 0`

error: aborting due to previous error

4 changes: 1 addition & 3 deletions src/test/ui/error-codes/E0054.stderr
Original file line number Diff line number Diff line change
@@ -2,9 +2,7 @@ error[E0054]: cannot cast as `bool`
--> $DIR/E0054.rs:3:24
|
LL | let x_is_nonzero = x as bool; //~ ERROR E0054
| ^^^^^^^^^ unsupported cast
|
= help: compare with zero instead
| ^^^^^^^^^ help: compare with zero instead: `x != 0`

error: aborting due to previous error

4 changes: 1 addition & 3 deletions src/test/ui/error-festival.stderr
Original file line number Diff line number Diff line change
@@ -52,9 +52,7 @@ error[E0054]: cannot cast as `bool`
--> $DIR/error-festival.rs:33:24
|
LL | let x_is_nonzero = x as bool;
| ^^^^^^^^^ unsupported cast
|
= help: compare with zero instead
| ^^^^^^^^^ help: compare with zero instead: `x != 0`

error[E0606]: casting `&u8` as `u32` is invalid
--> $DIR/error-festival.rs:37:18
5 changes: 0 additions & 5 deletions src/test/ui/feature-gates/feature-gate-extern_in_paths.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr

This file was deleted.

3 changes: 2 additions & 1 deletion src/test/ui/issues/issue-46186.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
struct Struct {
a: usize,
}; //~ ERROR expected item, found `;`
};
//~^ ERROR expected item, found `;`

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-46186.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: expected item, found `;`
--> $DIR/issue-46186.rs:3:2
|
LL | }; //~ ERROR expected item, found `;`
| ^ help: consider removing this semicolon
LL | };
| ^ help: remove this semicolon
|
= help: braced struct declarations are not followed by a semicolon

2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-49040.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#![allow(unused_variables)]; //~ ERROR expected item, found `;`
fn main() {}
fn foo() {}
9 changes: 7 additions & 2 deletions src/test/ui/issues/issue-49040.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,12 @@ error: expected item, found `;`
--> $DIR/issue-49040.rs:1:28
|
LL | #![allow(unused_variables)]; //~ ERROR expected item, found `;`
| ^ help: consider removing this semicolon
| ^ help: remove this semicolon

error: aborting due to previous error
error[E0601]: `main` function not found in crate `issue_49040`
|
= note: consider adding a `main` function to `$DIR/issue-49040.rs`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0601`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let s = extern::foo::Bar; //~ ERROR expected expression, found keyword `extern`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected expression, found keyword `extern`
--> $DIR/keyword-extern-as-identifier-expr.rs:2:13
|
LL | let s = extern::foo::Bar; //~ ERROR expected expression, found keyword `extern`
| ^^^^^^ expected expression

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let extern = 0; //~ ERROR expected pattern, found keyword `extern`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected pattern, found keyword `extern`
--> $DIR/keyword-extern-as-identifier-pat.rs:2:9
|
LL | let extern = 0; //~ ERROR expected pattern, found keyword `extern`
| ^^^^^^ expected pattern

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type A = extern::foo::bar; //~ ERROR expected `fn`, found `::`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected `fn`, found `::`
--> $DIR/keyword-extern-as-identifier-type.rs:1:16
|
LL | type A = extern::foo::bar; //~ ERROR expected `fn`, found `::`
| ^^ expected `fn` here

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use extern::foo; //~ ERROR expected identifier, found keyword `extern`

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/keyword/extern/keyword-extern-as-identifier-use.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error: expected identifier, found keyword `extern`
--> $DIR/keyword-extern-as-identifier-use.rs:1:5
|
LL | use extern::foo; //~ ERROR expected identifier, found keyword `extern`
| ^^^^^^ expected identifier, found keyword
help: you can escape reserved keywords to use them as identifiers
|
LL | use r#extern::foo; //~ ERROR expected identifier, found keyword `extern`
| ^^^^^^^^

error: aborting due to previous error

5 changes: 0 additions & 5 deletions src/test/ui/keyword/keyword-extern-as-identifier.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/keyword/keyword-extern-as-identifier.stderr

This file was deleted.

6 changes: 1 addition & 5 deletions src/test/ui/mismatched_types/cast-rfc0401.stderr
Original file line number Diff line number Diff line change
@@ -90,17 +90,13 @@ error[E0054]: cannot cast as `bool`
--> $DIR/cast-rfc0401.rs:39:13
|
LL | let _ = 3_i32 as bool; //~ ERROR cannot cast
| ^^^^^^^^^^^^^ unsupported cast
|
= help: compare with zero instead
| ^^^^^^^^^^^^^ help: compare with zero instead: `3_i32 != 0`

error[E0054]: cannot cast as `bool`
--> $DIR/cast-rfc0401.rs:40:13
|
LL | let _ = E::A as bool; //~ ERROR cannot cast
| ^^^^^^^^^^^^ unsupported cast
|
= help: compare with zero instead

error[E0604]: only `u8` can be cast as `char`, not `u32`
--> $DIR/cast-rfc0401.rs:41:13
4 changes: 2 additions & 2 deletions src/test/ui/old-suffixes-are-really-forbidden.stderr
Original file line number Diff line number Diff line change
@@ -2,15 +2,15 @@ error: invalid suffix `is` for numeric literal
--> $DIR/old-suffixes-are-really-forbidden.rs:2:13
|
LL | let a = 1_is; //~ ERROR invalid suffix
| ^^^^
| ^^^^ invalid suffix `is`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: invalid suffix `us` for numeric literal
--> $DIR/old-suffixes-are-really-forbidden.rs:3:13
|
LL | let b = 2_us; //~ ERROR invalid suffix
| ^^^^
| ^^^^ invalid suffix `us`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

24 changes: 12 additions & 12 deletions src/test/ui/parser/bad-lit-suffixes.stderr
Original file line number Diff line number Diff line change
@@ -2,49 +2,49 @@ error: ABI spec with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:5:5
|
LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid
| ^^^^^^^^^
| ^^^^^^^^^ ABI spec with a suffix is invalid

error: ABI spec with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:9:5
|
LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid
| ^^^^^^^^^
| ^^^^^^^^^ ABI spec with a suffix is invalid

error: string literal with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:13:5
|
LL | ""suffix; //~ ERROR string literal with a suffix is invalid
| ^^^^^^^^
| ^^^^^^^^ string literal with a suffix is invalid

error: byte string literal with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:14:5
|
LL | b""suffix; //~ ERROR byte string literal with a suffix is invalid
| ^^^^^^^^^
| ^^^^^^^^^ byte string literal with a suffix is invalid

error: string literal with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:15:5
|
LL | r#""#suffix; //~ ERROR string literal with a suffix is invalid
| ^^^^^^^^^^^
| ^^^^^^^^^^^ string literal with a suffix is invalid

error: byte string literal with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:16:5
|
LL | br#""#suffix; //~ ERROR byte string literal with a suffix is invalid
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ byte string literal with a suffix is invalid

error: char literal with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:17:5
|
LL | 'a'suffix; //~ ERROR char literal with a suffix is invalid
| ^^^^^^^^^
| ^^^^^^^^^ char literal with a suffix is invalid

error: byte literal with a suffix is invalid
--> $DIR/bad-lit-suffixes.rs:18:5
|
LL | b'a'suffix; //~ ERROR byte literal with a suffix is invalid
| ^^^^^^^^^^
| ^^^^^^^^^^ byte literal with a suffix is invalid

error: invalid width `1024` for integer literal
--> $DIR/bad-lit-suffixes.rs:20:5
@@ -82,31 +82,31 @@ error: invalid suffix `suffix` for numeric literal
--> $DIR/bad-lit-suffixes.rs:25:5
|
LL | 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal
| ^^^^^^^^^^
| ^^^^^^^^^^ invalid suffix `suffix`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: invalid suffix `suffix` for numeric literal
--> $DIR/bad-lit-suffixes.rs:26:5
|
LL | 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal
| ^^^^^^^^^^^
| ^^^^^^^^^^^ invalid suffix `suffix`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: invalid suffix `suffix` for float literal
--> $DIR/bad-lit-suffixes.rs:27:5
|
LL | 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal
| ^^^^^^^^^
| ^^^^^^^^^ invalid suffix `suffix`
|
= help: valid suffixes are `f32` and `f64`

error: invalid suffix `suffix` for float literal
--> $DIR/bad-lit-suffixes.rs:28:5
|
LL | 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ invalid suffix `suffix`
|
= help: valid suffixes are `f32` and `f64`

2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-pointer-type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn foo(_: *()) {
//~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
//~^ ERROR expected mut or const in raw pointer type
}

fn main() {}
6 changes: 4 additions & 2 deletions src/test/ui/parser/bad-pointer-type.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
error: expected mut or const in raw pointer type
--> $DIR/bad-pointer-type.rs:1:11
|
LL | fn foo(_: *()) {
| ^
| ^ expected mut or const in raw pointer type
|
= help: use `*mut T` or `*const T` as appropriate

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/parser/impl-parsing.stderr
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@ error: missing `for` in a trait impl
--> $DIR/impl-parsing.rs:6:11
|
LL | impl Trait Type {} //~ ERROR missing `for` in a trait impl
| ^
| ^ help: add `for` here

error: missing `for` in a trait impl
--> $DIR/impl-parsing.rs:7:11
|
LL | impl Trait .. {} //~ ERROR missing `for` in a trait impl
| ^
| ^ help: add `for` here

error: expected a trait, found type
--> $DIR/impl-parsing.rs:8:6
21 changes: 16 additions & 5 deletions src/test/ui/parser/issue-14303-fncall.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
fn main() {
(0..4)
.map(|x| x * 2)
.collect::<Vec<'a, usize, 'b>>()
//~^ ERROR lifetime parameters must be declared prior to type parameters
// can't run rustfix because it doesn't handle multipart suggestions correctly
// compile-flags: -Zborrowck=mir
// we need the above to avoid ast borrowck failure in recovered code

struct S<'a, T> {
a: &'a T,
b: &'a T,
}

fn foo<'a, 'b>(start: &'a usize, end: &'a usize) {
let _x = (*start..*end)
.map(|x| S { a: start, b: end })
.collect::<Vec<S<_, 'a>>>();
//~^ ERROR lifetime parameters must be declared prior to type parameters
}

fn main() {}
10 changes: 7 additions & 3 deletions src/test/ui/parser/issue-14303-fncall.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-fncall.rs:4:31
--> $DIR/issue-14303-fncall.rs:13:29
|
LL | .collect::<Vec<'a, usize, 'b>>()
| ^^
LL | .collect::<Vec<S<_, 'a>>>();
| ^^ must be declared prior to type parameters
help: move the lifetime parameter prior to the first type parameter
|
LL | .collect::<Vec<S<'a, _>>>();
| ^^^ --

error: aborting due to previous error

11 changes: 10 additions & 1 deletion src/test/ui/parser/issue-14303-path.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {}
mod foo {
pub struct X<'a, 'b, 'c, T> {
a: &'a str,
b: &'b str,
c: &'c str,
t: T,
}
}

fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
//~^ ERROR lifetime parameters must be declared prior to type parameters

fn main() {}
12 changes: 9 additions & 3 deletions src/test/ui/parser/issue-14303-path.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-path.rs:1:37
--> $DIR/issue-14303-path.rs:10:40
|
LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {}
| ^^
LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
| ^^ ^^ must be declared prior to type parameters
| |
| must be declared prior to type parameters
help: move the lifetime parameters prior to the first type parameter
|
LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, 'b, 'c, T>) {}
| ^^^ ^^^ --

error: aborting due to previous error

7 changes: 3 additions & 4 deletions src/test/ui/parser/issue-17383.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
enum X {
A =
b'a' //~ ERROR discriminator values can only be used with a field-less enum
,
B(isize)
A = 3,
//~^ ERROR discriminator values can only be used with a field-less enum
B(usize)
}

fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/parser/issue-17383.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: discriminator values can only be used with a field-less enum
--> $DIR/issue-17383.rs:3:9
--> $DIR/issue-17383.rs:2:9
|
LL | b'a' //~ ERROR discriminator values can only be used with a field-less enum
| ^^^^
LL | A = 3,
| ^ only valid in field-less enums

error: aborting due to previous error

5 changes: 4 additions & 1 deletion src/test/ui/parser/issue-1802-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// error-pattern:no valid digits found for number
fn log(a: i32, b: i32) {}

fn main() {
let error = 42;
log(error, 0b);
//~^ ERROR no valid digits found for number
}
2 changes: 1 addition & 1 deletion src/test/ui/parser/issue-1802-1.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: no valid digits found for number
--> $DIR/issue-1802-1.rs:3:16
--> $DIR/issue-1802-1.rs:5:16
|
LL | log(error, 0b);
| ^^
7 changes: 5 additions & 2 deletions src/test/ui/parser/issue-1802-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// error-pattern:no valid digits found for number
fn log(a: i32, b: i32) {}

fn main() {
log(error, 0b_usize);
let error = 42;
log(error, 0b);
//~^ ERROR no valid digits found for number
}
6 changes: 3 additions & 3 deletions src/test/ui/parser/issue-1802-2.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: no valid digits found for number
--> $DIR/issue-1802-2.rs:3:16
--> $DIR/issue-1802-2.rs:5:16
|
LL | log(error, 0b_usize);
| ^^^
LL | log(error, 0b);
| ^^

error: aborting due to previous error

9 changes: 8 additions & 1 deletion src/test/ui/parser/issue-27255.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
impl A .. {} //~ ERROR
trait A {}

impl A .. {}
//~^ ERROR missing `for` in a trait impl
//~| ERROR `impl Trait for .. {}` is an obsolete syntax

impl A usize {}
//~^ ERROR missing `for` in a trait impl

fn main() {}
22 changes: 18 additions & 4 deletions src/test/ui/parser/issue-27255.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
error: missing `for` in a trait impl
--> $DIR/issue-27255.rs:1:7
--> $DIR/issue-27255.rs:3:7
|
LL | impl A .. {} //~ ERROR
| ^
LL | impl A .. {}
| ^ help: add `for` here

error: aborting due to previous error
error: missing `for` in a trait impl
--> $DIR/issue-27255.rs:7:7
|
LL | impl A usize {}
| ^^^^^^ help: add `for` here

error: `impl Trait for .. {}` is an obsolete syntax
--> $DIR/issue-27255.rs:3:1
|
LL | impl A .. {}
| ^^^^^^^^^^^^
|
= help: use `auto trait Trait {}` instead

error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/parser/issue-32214.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ error: type parameters must be declared prior to associated type bindings
--> $DIR/issue-32214.rs:5:34
|
LL | pub fn test<W, I: Trait<Item=(), W> >() {}
| ^
| ^ must be declared prior to associated type bindings

error: aborting due to previous error

6 changes: 3 additions & 3 deletions src/test/ui/parser/lex-bad-numeric-literals.stderr
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ error: octal float literal is not supported
--> $DIR/lex-bad-numeric-literals.rs:5:5
|
LL | 0o2f32; //~ ERROR: octal float literal is not supported
| ^^^^^^
| ^^^^^^ not supported

error: int literal is too large
--> $DIR/lex-bad-numeric-literals.rs:16:5
@@ -128,13 +128,13 @@ error: octal float literal is not supported
--> $DIR/lex-bad-numeric-literals.rs:23:5
|
LL | 0o123f64; //~ ERROR: octal float literal is not supported
| ^^^^^^^^
| ^^^^^^^^ not supported

error: binary float literal is not supported
--> $DIR/lex-bad-numeric-literals.rs:25:5
|
LL | 0b101f64; //~ ERROR: binary float literal is not supported
| ^^^^^^^^
| ^^^^^^^^ not supported

error: aborting due to 23 previous errors

5 changes: 3 additions & 2 deletions src/test/ui/parser/no-binary-float-literal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// error-pattern:binary float literal is not supported

fn main() {
0b101010f64;
//~^ ERROR binary float literal is not supported
0b101.010;
//~^ ERROR binary float literal is not supported
0b101p4f64;
//~^ ERROR invalid suffix `p4f64` for numeric literal
}
18 changes: 16 additions & 2 deletions src/test/ui/parser/no-binary-float-literal.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
error: binary float literal is not supported
--> $DIR/no-binary-float-literal.rs:5:5
--> $DIR/no-binary-float-literal.rs:4:5
|
LL | 0b101.010;
| ^^^^^^^^^

error: aborting due to previous error
error: binary float literal is not supported
--> $DIR/no-binary-float-literal.rs:2:5
|
LL | 0b101010f64;
| ^^^^^^^^^^^ not supported

error: invalid suffix `p4f64` for numeric literal
--> $DIR/no-binary-float-literal.rs:6:5
|
LL | 0b101p4f64;
| ^^^^^^^^^^ invalid suffix `p4f64`
|
= help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: aborting due to 3 previous errors

6 changes: 4 additions & 2 deletions src/test/ui/parser/no-hex-float-literal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// error-pattern:hexadecimal float literal is not supported

fn main() {
0xABC.Df;
//~^ ERROR `{integer}` is a primitive type and therefore doesn't have fields
0x567.89;
//~^ ERROR hexadecimal float literal is not supported
0xDEAD.BEEFp-2f;
//~^ ERROR invalid suffix `f` for float literal
//~| ERROR `{integer}` is a primitive type and therefore doesn't have fields
}
25 changes: 23 additions & 2 deletions src/test/ui/parser/no-hex-float-literal.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
error: hexadecimal float literal is not supported
--> $DIR/no-hex-float-literal.rs:5:5
--> $DIR/no-hex-float-literal.rs:4:5
|
LL | 0x567.89;
| ^^^^^^^^

error: aborting due to previous error
error: invalid suffix `f` for float literal
--> $DIR/no-hex-float-literal.rs:6:18
|
LL | 0xDEAD.BEEFp-2f;
| ^^ invalid suffix `f`
|
= help: valid suffixes are `f32` and `f64`

error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> $DIR/no-hex-float-literal.rs:2:11
|
LL | 0xABC.Df;
| ^^

error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> $DIR/no-hex-float-literal.rs:6:12
|
LL | 0xDEAD.BEEFp-2f;
| ^^^^^

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0610`.
12 changes: 6 additions & 6 deletions src/test/ui/parser/no-unsafe-self.stderr
Original file line number Diff line number Diff line change
@@ -2,37 +2,37 @@ error: cannot pass `self` by raw pointer
--> $DIR/no-unsafe-self.rs:4:17
|
LL | fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer
| ^^^^
| ^^^^ cannot pass `self` by raw pointer

error: cannot pass `self` by raw pointer
--> $DIR/no-unsafe-self.rs:5:19
|
LL | fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer
| ^^^^
| ^^^^ cannot pass `self` by raw pointer

error: cannot pass `self` by raw pointer
--> $DIR/no-unsafe-self.rs:6:13
|
LL | fn bar(*self); //~ ERROR cannot pass `self` by raw pointer
| ^^^^
| ^^^^ cannot pass `self` by raw pointer

error: cannot pass `self` by raw pointer
--> $DIR/no-unsafe-self.rs:11:17
|
LL | fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer
| ^^^^
| ^^^^ cannot pass `self` by raw pointer

error: cannot pass `self` by raw pointer
--> $DIR/no-unsafe-self.rs:12:19
|
LL | fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer
| ^^^^
| ^^^^ cannot pass `self` by raw pointer

error: cannot pass `self` by raw pointer
--> $DIR/no-unsafe-self.rs:13:13
|
LL | fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer
| ^^^^
| ^^^^ cannot pass `self` by raw pointer

error: aborting due to 6 previous errors

5 changes: 3 additions & 2 deletions src/test/ui/parser/pat-tuple-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fn main() {
match 0 {
(pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..`
match (0, 1, 2) {
(pat, ..,) => {}
//~^ ERROR trailing comma is not permitted after `..`
}
}
4 changes: 2 additions & 2 deletions src/test/ui/parser/pat-tuple-2.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: trailing comma is not permitted after `..`
--> $DIR/pat-tuple-2.rs:3:17
|
LL | (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..`
| ^
LL | (pat, ..,) => {}
| ^ trailing comma is not permitted after `..`

error: aborting due to previous error

5 changes: 3 additions & 2 deletions src/test/ui/parser/pat-tuple-3.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fn main() {
match 0 {
(.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern
match (0, 1, 2) {
(.., pat, ..) => {}
//~^ ERROR `..` can only be used once per tuple or tuple struct pattern
}
}
4 changes: 2 additions & 2 deletions src/test/ui/parser/pat-tuple-3.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: `..` can only be used once per tuple or tuple struct pattern
--> $DIR/pat-tuple-3.rs:3:19
|
LL | (.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern
| ^^
LL | (.., pat, ..) => {}
| ^^ can only be used once per pattern

error: aborting due to previous error

17 changes: 8 additions & 9 deletions src/test/ui/parser/tag-variant-disr-non-nullary.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//error-pattern: discriminator values can only be used with a field-less enum

enum color {
red = 0xff0000,
green = 0x00ff00,
blue = 0x0000ff,
black = 0x000000,
white = 0xffffff,
other (str),
enum Color {
Red = 0xff0000,
//~^ ERROR discriminator values can only be used with a field-less enum
Green = 0x00ff00,
Blue = 0x0000ff,
Black = 0x000000,
White = 0xffffff,
Other(usize),
}

fn main() {}
15 changes: 12 additions & 3 deletions src/test/ui/parser/tag-variant-disr-non-nullary.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
error: discriminator values can only be used with a field-less enum
--> $DIR/tag-variant-disr-non-nullary.rs:8:13
--> $DIR/tag-variant-disr-non-nullary.rs:2:11
|
LL | white = 0xffffff,
| ^^^^^^^^
LL | Red = 0xff0000,
| ^^^^^^^^ only valid in field-less enums
LL | //~^ ERROR discriminator values can only be used with a field-less enum
LL | Green = 0x00ff00,
| ^^^^^^^^ only valid in field-less enums
LL | Blue = 0x0000ff,
| ^^^^^^^^ only valid in field-less enums
LL | Black = 0x000000,
| ^^^^^^^^ only valid in field-less enums
LL | White = 0xffffff,
| ^^^^^^^^ only valid in field-less enums

error: aborting due to previous error

1 change: 1 addition & 0 deletions src/test/ui/parser/where_with_bound.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn foo<T>() where <T>::Item: ToString, T: Iterator { }
//~^ ERROR generic parameters on `where` clauses are reserved for future use
//~| ERROR cannot find type `Item` in the crate root

fn main() {}
11 changes: 9 additions & 2 deletions src/test/ui/parser/where_with_bound.stderr
Original file line number Diff line number Diff line change
@@ -2,7 +2,14 @@ error: generic parameters on `where` clauses are reserved for future use
--> $DIR/where_with_bound.rs:1:19
|
LL | fn foo<T>() where <T>::Item: ToString, T: Iterator { }
| ^^^
| ^^^ currently unsupported

error: aborting due to previous error
error[E0412]: cannot find type `Item` in the crate root
--> $DIR/where_with_bound.rs:1:24
|
LL | fn foo<T>() where <T>::Item: ToString, T: Iterator { }
| ^^^^ not found in the crate root

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
5 changes: 0 additions & 5 deletions src/test/ui/rfc-2126-extern-in-paths/auxiliary/xcrate.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-1.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr

This file was deleted.

6 changes: 0 additions & 6 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr

This file was deleted.

5 changes: 0 additions & 5 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-3.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/rfc-2126-extern-in-paths/non-existent-3.stderr

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/rfc-2126-extern-in-paths/single-segment.rs

This file was deleted.

22 changes: 0 additions & 22 deletions src/test/ui/rfc-2126-extern-in-paths/single-segment.stderr

This file was deleted.

16 changes: 16 additions & 0 deletions src/test/ui/suggestions/recover-from-semicolon-trailing-item.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// verify that after encountering a semicolon after an item the parser recovers
mod M {};
//~^ ERROR expected item, found `;`
struct S {};
//~^ ERROR expected item, found `;`
fn foo(a: usize) {};
//~^ ERROR expected item, found `;`
fn main() {
struct X {}; // ok
let _: usize = S {};
//~^ ERROR mismatched types
let _: usize = X {};
//~^ ERROR mismatched types
foo("");
//~^ ERROR mismatched types
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
error: expected item, found `;`
--> $DIR/recover-from-semicolon-trailing-item.rs:2:9
|
LL | mod M {};
| ^ help: remove this semicolon

error: expected item, found `;`
--> $DIR/recover-from-semicolon-trailing-item.rs:4:12
|
LL | struct S {};
| ^ help: remove this semicolon
|
= help: braced struct declarations are not followed by a semicolon

error: expected item, found `;`
--> $DIR/recover-from-semicolon-trailing-item.rs:6:20
|
LL | fn foo(a: usize) {};
| ^ help: remove this semicolon

error[E0308]: mismatched types
--> $DIR/recover-from-semicolon-trailing-item.rs:10:20
|
LL | let _: usize = S {};
| ^^^^ expected usize, found struct `S`
|
= note: expected type `usize`
found type `S`

error[E0308]: mismatched types
--> $DIR/recover-from-semicolon-trailing-item.rs:12:20
|
LL | let _: usize = X {};
| ^^^^ expected usize, found struct `main::X`
|
= note: expected type `usize`
found type `main::X`

error[E0308]: mismatched types
--> $DIR/recover-from-semicolon-trailing-item.rs:14:9
|
LL | foo("");
| ^^ expected usize, found reference
|
= note: expected type `usize`
found type `&'static str`

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0308`.
2 changes: 0 additions & 2 deletions src/test/ui/traits/trait-object-vs-lifetime.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// A few contrived examples where lifetime should (or should not) be parsed as an object type.
// Lifetimes parsed as types are still rejected later by semantic checks.

// compile-flags: -Z continue-parse-after-error

struct S<'a, T>(&'a u8, T);

fn main() {
16 changes: 10 additions & 6 deletions src/test/ui/traits/trait-object-vs-lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
error: lifetime parameters must be declared prior to type parameters
--> $DIR/trait-object-vs-lifetime.rs:16:25
--> $DIR/trait-object-vs-lifetime.rs:14:25
|
LL | let _: S<'static +, 'static>;
| ^^^^^^^
| ^^^^^^^ must be declared prior to type parameters
help: move the lifetime parameter prior to the first type parameter
|
LL | let _: S<'static, 'static +>;
| ^^^^^^^^ --

error[E0224]: at least one non-builtin trait is required for an object type
--> $DIR/trait-object-vs-lifetime.rs:11:23
--> $DIR/trait-object-vs-lifetime.rs:9:23
|
LL | let _: S<'static, 'static +>;
| ^^^^^^^^^

error[E0107]: wrong number of lifetime arguments: expected 1, found 2
--> $DIR/trait-object-vs-lifetime.rs:13:23
--> $DIR/trait-object-vs-lifetime.rs:11:23
|
LL | let _: S<'static, 'static>;
| ^^^^^^^ unexpected lifetime argument

error[E0107]: wrong number of type arguments: expected 1, found 0
--> $DIR/trait-object-vs-lifetime.rs:13:12
--> $DIR/trait-object-vs-lifetime.rs:11:12
|
LL | let _: S<'static, 'static>;
| ^^^^^^^^^^^^^^^^^^^ expected 1 type argument

error[E0224]: at least one non-builtin trait is required for an object type
--> $DIR/trait-object-vs-lifetime.rs:16:14
--> $DIR/trait-object-vs-lifetime.rs:14:14
|
LL | let _: S<'static +, 'static>;
| ^^^^^^^^^