From a2b888675accccedec7601cc3bd67ca028b4757c Mon Sep 17 00:00:00 2001 From: kennytm Date: Sat, 5 Aug 2017 14:38:52 +0800 Subject: Implemented #[doc(cfg(...))]. This attribute has two effects: 1. Items with this attribute and their children will have the "This is supported on **** only" message attached in the documentation. 2. The items' doc tests will be skipped if the configuration does not match. --- src/libsyntax/feature_gate.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index aeb574bc3af..668732e6855 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -364,6 +364,9 @@ declare_features! ( // global allocators and their internals (active, global_allocator, "1.20.0", None), (active, allocator_internals, "1.20.0", None), + + // #[doc(cfg(...))] + (active, doc_cfg, "1.21.0", Some(43781)), ); declare_features! ( @@ -1157,6 +1160,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { self.context.check_attribute(attr, false); } + if attr.check_name("doc") { + if let Some(content) = attr.meta_item_list() { + if content.len() == 1 && content[0].check_name("cfg") { + gate_feature_post!(&self, doc_cfg, attr.span, + "#[doc(cfg(...))] is experimental" + ); + } + } + } + if self.context.features.proc_macro && attr::is_known(attr) { return } -- cgit 1.4.1-3-g733a5 From 177cbe01bee8cd7ee0929253b5cab0e8f5df0ce1 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 1 Aug 2017 14:30:46 +1200 Subject: Some tidying up around include! --- src/libsyntax/ext/source_util.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 3cdd3a4b2c3..4d385d5e9ee 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -183,13 +183,14 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke // resolve a file-system path to an absolute file-system path (if it // isn't already) fn res_rel_file(cx: &mut ExtCtxt, sp: syntax_pos::Span, arg: &Path) -> PathBuf { - // NB: relative paths are resolved relative to the compilation unit + // Relative paths are resolved relative to the file in which they are found + // after macro expansion (that is, they are unhygienic). if !arg.is_absolute() { let callsite = sp.source_callsite(); - let mut cu = PathBuf::from(&cx.codemap().span_to_filename(callsite)); - cu.pop(); - cu.push(arg); - cu + let mut path = PathBuf::from(&cx.codemap().span_to_filename(callsite)); + path.pop(); + path.push(arg); + path } else { arg.to_path_buf() } -- cgit 1.4.1-3-g733a5 From 47cb3c5bc28e1bb2ac2d2efb7796ceb17b4ab7de Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Fri, 11 Aug 2017 00:16:18 +0200 Subject: Fix some typos --- src/liballoc/allocator.rs | 2 +- src/liballoc/btree/node.rs | 4 ++-- src/libcore/iter/mod.rs | 2 +- src/libcore/iter/traits.rs | 2 +- src/libcore/num/dec2flt/algorithm.rs | 2 +- src/libcore/tests/num/mod.rs | 2 +- src/librustc/traits/specialize/specialization_graph.rs | 2 +- src/librustc/ty/adjustment.rs | 4 ++-- src/librustc_data_structures/stable_hasher.rs | 2 +- src/librustc_mir/dataflow/impls/mod.rs | 2 +- src/librustc_mir/hair/mod.rs | 2 +- src/librustc_trans/base.rs | 2 +- src/librustc_typeck/check/dropck.rs | 2 +- src/librustc_typeck/constrained_type_params.rs | 2 +- src/librustc_typeck/variance/constraints.rs | 2 +- src/librustdoc/clean/inline.rs | 2 +- src/libstd/panic.rs | 2 +- src/libstd/sys/redox/syscall/call.rs | 4 ++-- src/libstd/thread/mod.rs | 2 +- src/libsyntax/attr.rs | 2 +- src/libsyntax/parse/mod.rs | 2 +- 21 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/libsyntax') diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 42111301a9f..3ea7d349c9c 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -40,7 +40,7 @@ fn size_align() -> (usize, usize) { /// /// (Note however that layouts are *not* required to have positive /// size, even though many allocators require that all memory -/// requeusts have positive size. A caller to the `Alloc::alloc` +/// requests have positive size. A caller to the `Alloc::alloc` /// method must either ensure that conditions like this are met, or /// use specific allocators with looser requirements.) #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/src/liballoc/btree/node.rs b/src/liballoc/btree/node.rs index 06d3a113b94..7fe33c20e4f 100644 --- a/src/liballoc/btree/node.rs +++ b/src/liballoc/btree/node.rs @@ -132,7 +132,7 @@ impl InternalNode { /// An owned pointer to a node. This basically is either `Box>` or /// `Box>`. However, it contains no information as to which of the two types -/// of nodes is acutally behind the box, and, partially due to this lack of information, has no +/// of nodes is actually behind the box, and, partially due to this lack of information, has no /// destructor. struct BoxedNode { ptr: Unique> @@ -264,7 +264,7 @@ impl Root { // correct variance. /// A reference to a node. /// -/// This type has a number of paramaters that controls how it acts: +/// This type has a number of parameters that controls how it acts: /// - `BorrowType`: This can be `Immut<'a>` or `Mut<'a>` for some `'a` or `Owned`. /// When this is `Immut<'a>`, the `NodeRef` acts roughly like `&'a Node`, /// when this is `Mut<'a>`, the `NodeRef` acts roughly like `&'a mut Node`, diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 79e6b11beac..22b997a768e 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -1035,7 +1035,7 @@ unsafe impl TrustedLen for Zip /// Now consider this twist where we add a call to `rev`. This version will /// print `('c', 1), ('b', 2), ('a', 3)`. Note that the letters are reversed, /// but the values of the counter still go in order. This is because `map()` is -/// still being called lazilly on each item, but we are popping items off the +/// still being called lazily on each item, but we are popping items off the /// back of the vector now, instead of shifting them from the front. /// /// ```rust diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index ccfeb91aff1..19098f036ac 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -345,7 +345,7 @@ pub trait Extend { /// In a similar fashion to the [`Iterator`] protocol, once a /// `DoubleEndedIterator` returns `None` from a `next_back()`, calling it again /// may or may not ever return `Some` again. `next()` and `next_back()` are -/// interchangable for this purpose. +/// interchangeable for this purpose. /// /// [`Iterator`]: trait.Iterator.html /// diff --git a/src/libcore/num/dec2flt/algorithm.rs b/src/libcore/num/dec2flt/algorithm.rs index 42bc46c0c68..ccf3950c2ba 100644 --- a/src/libcore/num/dec2flt/algorithm.rs +++ b/src/libcore/num/dec2flt/algorithm.rs @@ -336,7 +336,7 @@ pub fn algorithm_m(f: &Big, e: i16) -> T { round_by_remainder(v, rem, q, z) } -/// Skip over most AlgorithmM iterations by checking the bit length. +/// Skip over most Algorithm M iterations by checking the bit length. fn quick_start(u: &mut Big, v: &mut Big, k: &mut i16) { // The bit length is an estimate of the base two logarithm, and log(u / v) = log(u) - log(v). // The estimate is off by at most 1, but always an under-estimate, so the error on log(u) diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index 046b81e19f7..400d53ce51a 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -566,7 +566,7 @@ assume_usize_width! { ); } -/// Conversinos where neither the min nor the max of $source can be represented by +/// Conversions where neither the min nor the max of $source can be represented by /// $target, but max/min of the target can be represented by the source. macro_rules! test_impl_try_from_signed_to_unsigned_err { ($fn_name:ident, $source:ty, $target:ty) => { diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index f80caeec460..611137562a9 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -31,7 +31,7 @@ use util::nodemap::{DefIdMap, FxHashMap}; /// /// - Parent extraction. In particular, the graph can give you the *immediate* /// parents of a given specializing impl, which is needed for extracting -/// default items amongst other thigns. In the simple "chain" rule, every impl +/// default items amongst other things. In the simple "chain" rule, every impl /// has at most one parent. pub struct Graph { // all impls have a parent; the "root" impls have as their parent the def_id diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index 62d137475f9..51436660779 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -29,7 +29,7 @@ use ty::subst::Substs; /// by `autoref`, to either a raw or borrowed pointer. In these cases unsize is /// `false`. /// -/// 2. A thin-to-fat coercon involves unsizing the underlying data. We start +/// 2. A thin-to-fat coercion involves unsizing the underlying data. We start /// with a thin pointer, deref a number of times, unsize the underlying data, /// then autoref. The 'unsize' phase may change a fixed length array to a /// dynamically sized one, a concrete object to a trait object, or statically @@ -52,7 +52,7 @@ use ty::subst::Substs; /// that case, we have the pointer we need coming in, so there are no /// autoderefs, and no autoref. Instead we just do the `Unsize` transformation. /// At some point, of course, `Box` should move out of the compiler, in which -/// case this is analogous to transformating a struct. E.g., Box<[i32; 4]> -> +/// case this is analogous to transforming a struct. E.g., Box<[i32; 4]> -> /// Box<[i32]> is an `Adjust::Unsize` with the target `Box<[i32]>`. #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Adjustment<'tcx> { diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 5e291ea3c15..6801aa455e1 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -193,7 +193,7 @@ impl Hasher for StableHasher { /// Something that implements `HashStable` can be hashed in a way that is -/// stable across multiple compiliation sessions. +/// stable across multiple compilation sessions. pub trait HashStable { fn hash_stable(&self, hcx: &mut CTX, diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index d5bdc71a705..e05a5a7341f 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -212,7 +212,7 @@ impl<'a, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedLvals<'a, 'tcx> { /// you if an l-value *might* be uninitialized at a given point in the /// control flow. But `MovingOutStatements` also includes the added /// data of *which* particular statement causing the deinitialization -/// that the borrow checker's error meessage may need to report. +/// that the borrow checker's error message may need to report. #[allow(dead_code)] pub struct MovingOutStatements<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index bb11cce7487..e32de6b9768 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -80,7 +80,7 @@ pub enum StmtKind<'tcx> { /// The Hair trait implementor translates their expressions (`&'tcx H::Expr`) /// into instances of this `Expr` enum. This translation can be done -/// basically as lazilly or as eagerly as desired: every recursive +/// basically as lazily or as eagerly as desired: every recursive /// reference to an expression in this enum is an `ExprRef<'tcx>`, which /// may in turn be another instance of this enum (boxed), or else an /// untranslated `&'tcx H::Expr`. Note that instances of `Expr` are very diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index e8032529b1f..3734e91d8c2 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -191,7 +191,7 @@ pub fn compare_simd_types<'a, 'tcx>( /// adjustment. /// /// The `old_info` argument is a bit funny. It is intended for use -/// in an upcast, where the new vtable for an object will be drived +/// in an upcast, where the new vtable for an object will be derived /// from the old one. pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>, source: Ty<'tcx>, diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index ed22cd1333e..72ff9eb6f5b 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -22,7 +22,7 @@ use util::nodemap::FxHashSet; use syntax_pos::Span; -/// check_drop_impl confirms that the Drop implementation identfied by +/// check_drop_impl confirms that the Drop implementation identified by /// `drop_impl_did` is not any more specialized than the type it is /// attached to (Issue #8142). /// diff --git a/src/librustc_typeck/constrained_type_params.rs b/src/librustc_typeck/constrained_type_params.rs index 7742194dfe6..37cb1f9280b 100644 --- a/src/librustc_typeck/constrained_type_params.rs +++ b/src/librustc_typeck/constrained_type_params.rs @@ -98,7 +98,7 @@ pub fn identify_constrained_type_params<'tcx>(tcx: ty::TyCtxt, /// Order the predicates in `predicates` such that each parameter is /// constrained before it is used, if that is possible, and add the -/// paramaters so constrained to `input_parameters`. For example, +/// parameters so constrained to `input_parameters`. For example, /// imagine the following impl: /// /// impl> Trait for U diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 284c9c5cfc3..4b0db749964 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -51,7 +51,7 @@ pub struct Constraint<'a> { pub variance: &'a VarianceTerm<'a>, } -/// To build constriants, we visit one item (type, trait) at a time +/// To build constraints, we visit one item (type, trait) at a time /// and look at its contents. So e.g. if we have /// /// struct Foo { diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index fa5a999adf1..9b4c4e479d0 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -495,7 +495,7 @@ fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static { /// A trait's generics clause actually contains all of the predicates for all of /// its associated types as well. We specifically move these clauses to the -/// associated types instead when displaying, so when we're genering the +/// associated types instead when displaying, so when we're generating the /// generics for the trait itself we need to be sure to remove them. /// We also need to remove the implied "recursive" Self: Trait bound. /// diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 58356bc43ee..10b3209257e 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -37,7 +37,7 @@ pub use panicking::{take_hook, set_hook, PanicInfo, Location}; /// In Rust a function can "return" early if it either panics or calls a /// function which transitively panics. This sort of control flow is not always /// anticipated, and has the possibility of causing subtle bugs through a -/// combination of two cricial components: +/// combination of two criticial components: /// /// 1. A data structure is in a temporarily invalid state when the thread /// panics. diff --git a/src/libstd/sys/redox/syscall/call.rs b/src/libstd/sys/redox/syscall/call.rs index ec9005c2cc3..9fc809eb821 100644 --- a/src/libstd/sys/redox/syscall/call.rs +++ b/src/libstd/sys/redox/syscall/call.rs @@ -40,7 +40,7 @@ pub unsafe fn brk(addr: usize) -> Result { /// /// * `EACCES` - permission is denied for one of the components of `path`, or `path` /// * `EFAULT` - `path` does not point to the process's addressible memory -/// * `EIO` - an I/O error occured +/// * `EIO` - an I/O error occurred /// * `ENOENT` - `path` does not exit /// * `ENOTDIR` - `path` is not a directory pub fn chdir(path: &str) -> Result { @@ -290,7 +290,7 @@ pub fn waitpid(pid: usize, status: &mut usize, options: usize) -> Result /// * `EAGAIN` - the file descriptor was opened with `O_NONBLOCK` and writing would block /// * `EBADF` - the file descriptor is not valid or is not open for writing /// * `EFAULT` - `buf` does not point to the process's addressible memory -/// * `EIO` - an I/O error occured +/// * `EIO` - an I/O error occurred /// * `ENOSPC` - the device containing the file descriptor has no room for data /// * `EPIPE` - the file descriptor refers to a pipe or socket whose reading end is closed pub fn write(fd: usize, buf: &[u8]) -> Result { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index cbd019c2c0e..80eb8ba93f7 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -531,7 +531,7 @@ pub fn current() -> Thread { /// /// However programmers will usually prefer to use, [`channel`]s, [`Condvar`]s, /// [`Mutex`]es or [`join`] for their synchronisation routines, as they avoid -/// thinking about thread schedulling. +/// thinking about thread scheduling. /// /// Note that [`channel`]s for example are implemented using this primitive. /// Indeed when you call `send` or `recv`, which are blocking, they will yield diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index a247fe7f8a5..d5caf458fd7 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -435,7 +435,7 @@ pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute { mk_spanned_attr_inner(span, id, item) } -/// Returns an innter attribute with the given value and span. +/// Returns an inner attribute with the given value and span. pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute { Attribute { id: id, diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 893bada2670..957164bab79 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -124,7 +124,7 @@ pub fn parse_expr_from_source_str(name: String, source: String, sess: &ParseSess /// Parses an item. /// -/// Returns `Ok(Some(item))` when successful, `Ok(None)` when no item was found, and`Err` +/// Returns `Ok(Some(item))` when successful, `Ok(None)` when no item was found, and `Err` /// when a syntax error occurred. pub fn parse_item_from_source_str(name: String, source: String, sess: &ParseSess) -> PResult>> { -- cgit 1.4.1-3-g733a5 From 8a4facc3c30d9dfbbfc1ddc6d413dfb0520699c6 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 8 Aug 2017 18:21:20 +0300 Subject: syntax: #[allow_internal_unsafe] bypasses the unsafe_code lint in macros. --- src/librustc/hir/lowering.rs | 1 + src/librustc_allocator/expand.rs | 1 + src/librustc_lint/builtin.rs | 25 +++++++++++++------- src/librustc_plugin/registry.rs | 22 ++++++++++++++---- src/librustc_resolve/macros.rs | 2 +- src/libsyntax/ext/base.rs | 16 +++++++++---- src/libsyntax/ext/derive.rs | 1 + src/libsyntax/ext/expand.rs | 27 ++++++++++++++++------ src/libsyntax/ext/tt/macro_rules.rs | 12 +++++++--- src/libsyntax/feature_gate.rs | 15 ++++++++++++ src/libsyntax/std_inject.rs | 1 + src/libsyntax/test.rs | 1 + src/libsyntax_ext/lib.rs | 14 +++++++++-- src/libsyntax_ext/proc_macro_registrar.rs | 1 + src/libsyntax_pos/hygiene.rs | 3 +++ src/libsyntax_pos/lib.rs | 10 ++++++++ ...ture-gate-allow-internal-unsafe-nested-macro.rs | 27 ++++++++++++++++++++++ .../run-pass-fulldeps/auxiliary/plugin_args.rs | 7 +++++- 18 files changed, 155 insertions(+), 31 deletions(-) create mode 100644 src/test/compile-fail/feature-gate-allow-internal-unsafe-nested-macro.rs (limited to 'src/libsyntax') diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 421a81c0d23..adf7d901be9 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -404,6 +404,7 @@ impl<'a> LoweringContext<'a> { format: codemap::CompilerDesugaring(Symbol::intern(reason)), span: Some(span), allow_internal_unstable: true, + allow_internal_unsafe: false, }, }); span.ctxt = SyntaxContext::empty().apply_mark(mark); diff --git a/src/librustc_allocator/expand.rs b/src/librustc_allocator/expand.rs index 676c3c51ea2..78b07a33389 100644 --- a/src/librustc_allocator/expand.rs +++ b/src/librustc_allocator/expand.rs @@ -79,6 +79,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> { format: MacroAttribute(Symbol::intern(name)), span: None, allow_internal_unstable: true, + allow_internal_unsafe: false, } }); let span = Span { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 88432e64290..7767cf43403 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -195,12 +195,23 @@ impl LintPass for UnsafeCode { } } +impl UnsafeCode { + fn report_unsafe(&self, cx: &LateContext, span: Span, desc: &'static str) { + // This comes from a macro that has #[allow_internal_unsafe]. + if span.allows_unsafe() { + return; + } + + cx.span_lint(UNSAFE_CODE, span, desc); + } +} + impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { if let hir::ExprBlock(ref blk) = e.node { // Don't warn about generated blocks, that'll just pollute the output. if blk.rules == hir::UnsafeBlock(hir::UserProvided) { - cx.span_lint(UNSAFE_CODE, blk.span, "usage of an `unsafe` block"); + self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); } } } @@ -208,11 +219,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { match it.node { hir::ItemTrait(hir::Unsafety::Unsafe, ..) => { - cx.span_lint(UNSAFE_CODE, it.span, "declaration of an `unsafe` trait") + self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait") } hir::ItemImpl(hir::Unsafety::Unsafe, ..) => { - cx.span_lint(UNSAFE_CODE, it.span, "implementation of an `unsafe` trait") + self.report_unsafe(cx, it.span, "implementation of an `unsafe` trait") } _ => return, @@ -228,12 +239,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { _: ast::NodeId) { match fk { FnKind::ItemFn(_, _, hir::Unsafety::Unsafe, ..) => { - cx.span_lint(UNSAFE_CODE, span, "declaration of an `unsafe` function") + self.report_unsafe(cx, span, "declaration of an `unsafe` function") } FnKind::Method(_, sig, ..) => { if sig.unsafety == hir::Unsafety::Unsafe { - cx.span_lint(UNSAFE_CODE, span, "implementation of an `unsafe` method") + self.report_unsafe(cx, span, "implementation of an `unsafe` method") } } @@ -244,9 +255,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) { if let hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(_)) = item.node { if sig.unsafety == hir::Unsafety::Unsafe { - cx.span_lint(UNSAFE_CODE, - item.span, - "declaration of an `unsafe` method") + self.report_unsafe(cx, item.span, "declaration of an `unsafe` method") } } } diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs index 3027489d65b..aac21f2af0d 100644 --- a/src/librustc_plugin/registry.rs +++ b/src/librustc_plugin/registry.rs @@ -102,9 +102,19 @@ impl<'a> Registry<'a> { panic!("user-defined macros may not be named `macro_rules`"); } self.syntax_exts.push((name, match extension { - NormalTT(ext, _, allow_internal_unstable) => { + NormalTT { + expander, + def_info: _, + allow_internal_unstable, + allow_internal_unsafe + } => { let nid = ast::CRATE_NODE_ID; - NormalTT(ext, Some((nid, self.krate_span)), allow_internal_unstable) + NormalTT { + expander, + def_info: Some((nid, self.krate_span)), + allow_internal_unstable, + allow_internal_unsafe + } } IdentTT(ext, _, allow_internal_unstable) => { IdentTT(ext, Some(self.krate_span), allow_internal_unstable) @@ -134,8 +144,12 @@ impl<'a> Registry<'a> { /// It builds for you a `NormalTT` that calls `expander`, /// and also takes care of interning the macro's name. pub fn register_macro(&mut self, name: &str, expander: MacroExpanderFn) { - self.register_syntax_extension(Symbol::intern(name), - NormalTT(Box::new(expander), None, false)); + self.register_syntax_extension(Symbol::intern(name), NormalTT { + expander: Box::new(expander), + def_info: None, + allow_internal_unstable: false, + allow_internal_unsafe: false, + }); } /// Register a compiler lint pass. diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 98eaa056177..7572c4aa680 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -313,7 +313,7 @@ impl<'a> base::Resolver for Resolver<'a> { fn check_unused_macros(&self) { for did in self.unused_macros.iter() { let id_span = match *self.macro_map[did] { - SyntaxExtension::NormalTT(_, isp, _) => isp, + SyntaxExtension::NormalTT { def_info, .. } => def_info, SyntaxExtension::DeclMacro(.., osp) => osp, _ => None, }; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 194d30e25d4..72b2552f64f 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -532,10 +532,16 @@ pub enum SyntaxExtension { /// A normal, function-like syntax extension. /// /// `bytes!` is a `NormalTT`. - /// - /// The `bool` dictates whether the contents of the macro can - /// directly use `#[unstable]` things (true == yes). - NormalTT(Box, Option<(ast::NodeId, Span)>, bool), + NormalTT { + expander: Box, + def_info: Option<(ast::NodeId, Span)>, + /// Whether the contents of the macro can + /// directly use `#[unstable]` things (true == yes). + allow_internal_unstable: bool, + /// Whether the contents of the macro can use `unsafe` + /// without triggering the `unsafe_code` lint. + allow_internal_unsafe: bool, + }, /// A function-like syntax extension that has an extra ident before /// the block. @@ -562,7 +568,7 @@ impl SyntaxExtension { pub fn kind(&self) -> MacroKind { match *self { SyntaxExtension::DeclMacro(..) | - SyntaxExtension::NormalTT(..) | + SyntaxExtension::NormalTT { .. } | SyntaxExtension::IdentTT(..) | SyntaxExtension::ProcMacro(..) => MacroKind::Bang, diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index e7c5d8278d9..38715f7275d 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -64,6 +64,7 @@ pub fn add_derived_markers(cx: &mut ExtCtxt, span: Span, traits: &[ast::Path] format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)), span: None, allow_internal_unstable: true, + allow_internal_unsafe: false, }, }); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 4843a66a750..9625602fa4a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -411,6 +411,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { format: MacroAttribute(Symbol::intern(&format!("{}", attr.path))), span: None, allow_internal_unstable: false, + allow_internal_unsafe: false, } }); @@ -458,7 +459,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let path = &mac.node.path; let ident = ident.unwrap_or_else(|| keywords::Invalid.ident()); - let validate_and_set_expn_info = |def_site_span, allow_internal_unstable| { + let validate_and_set_expn_info = |def_site_span, + allow_internal_unstable, + allow_internal_unsafe| { if ident.name != keywords::Invalid.name() { return Err(format!("macro {}! expects no ident argument, given '{}'", path, ident)); } @@ -467,7 +470,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { callee: NameAndSpan { format: MacroBang(Symbol::intern(&format!("{}", path))), span: def_site_span, - allow_internal_unstable: allow_internal_unstable, + allow_internal_unstable, + allow_internal_unsafe, }, }); Ok(()) @@ -476,20 +480,26 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let opt_expanded = match *ext { DeclMacro(ref expand, def_span) => { if let Err(msg) = validate_and_set_expn_info(def_span.map(|(_, s)| s), - false) { + false, false) { self.cx.span_err(path.span, &msg); return kind.dummy(span); } kind.make_from(expand.expand(self.cx, span, mac.node.stream())) } - NormalTT(ref expandfun, def_info, allow_internal_unstable) => { + NormalTT { + ref expander, + def_info, + allow_internal_unstable, + allow_internal_unsafe + } => { if let Err(msg) = validate_and_set_expn_info(def_info.map(|(_, s)| s), - allow_internal_unstable) { + allow_internal_unstable, + allow_internal_unsafe) { self.cx.span_err(path.span, &msg); return kind.dummy(span); } - kind.make_from(expandfun.expand(self.cx, span, mac.node.stream())) + kind.make_from(expander.expand(self.cx, span, mac.node.stream())) } IdentTT(ref expander, tt_span, allow_internal_unstable) => { @@ -504,7 +514,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { callee: NameAndSpan { format: MacroBang(Symbol::intern(&format!("{}", path))), span: tt_span, - allow_internal_unstable: allow_internal_unstable, + allow_internal_unstable, + allow_internal_unsafe: false, } }); @@ -540,6 +551,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { span: None, // FIXME probably want to follow macro_rules macros here. allow_internal_unstable: false, + allow_internal_unsafe: false, }, }); @@ -578,6 +590,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { format: MacroAttribute(pretty_name), span: None, allow_internal_unstable: false, + allow_internal_unsafe: false, } }; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 80b6794d1e3..7b3fe2bd993 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -269,7 +269,7 @@ pub fn compile(sess: &ParseSess, features: &RefCell, def: &ast::Item) valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()]) } - let exp: Box<_> = Box::new(MacroRulesMacroExpander { + let expander: Box<_> = Box::new(MacroRulesMacroExpander { name: def.ident, lhses: lhses, rhses: rhses, @@ -278,9 +278,15 @@ pub fn compile(sess: &ParseSess, features: &RefCell, def: &ast::Item) if body.legacy { let allow_internal_unstable = attr::contains_name(&def.attrs, "allow_internal_unstable"); - NormalTT(exp, Some((def.id, def.span)), allow_internal_unstable) + let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe"); + NormalTT { + expander, + def_info: Some((def.id, def.span)), + allow_internal_unstable, + allow_internal_unsafe + } } else { - SyntaxExtension::DeclMacro(exp, Some((def.id, def.span))) + SyntaxExtension::DeclMacro(expander, Some((def.id, def.span))) } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index aeb574bc3af..46ee126b9d9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -194,6 +194,14 @@ declare_features! ( // rustc internal (active, allow_internal_unstable, "1.0.0", None), + // Allows the use of #[allow_internal_unsafe]. This is an + // attribute on macro_rules! and can't use the attribute handling + // below (it has to be checked before expansion possibly makes + // macros disappear). + // + // rustc internal + (active, allow_internal_unsafe, "1.0.0", None), + // #23121. Array patterns have some hazards yet. (active, slice_patterns, "1.0.0", Some(23121)), @@ -735,6 +743,11 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG EXPLAIN_ALLOW_INTERNAL_UNSTABLE, cfg_fn!(allow_internal_unstable))), + ("allow_internal_unsafe", Normal, Gated(Stability::Unstable, + "allow_internal_unsafe", + EXPLAIN_ALLOW_INTERNAL_UNSAFE, + cfg_fn!(allow_internal_unsafe))), + ("fundamental", Whitelisted, Gated(Stability::Unstable, "fundamental", "the `#[fundamental]` attribute \ @@ -1045,6 +1058,8 @@ pub const EXPLAIN_TRACE_MACROS: &'static str = "`trace_macros` is not stable enough for use and is subject to change"; pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str = "allow_internal_unstable side-steps feature gating and stability checks"; +pub const EXPLAIN_ALLOW_INTERNAL_UNSAFE: &'static str = + "allow_internal_unsafe side-steps the unsafe_code lint"; pub const EXPLAIN_CUSTOM_DERIVE: &'static str = "`#[derive]` for custom traits is deprecated and will be removed in the future."; diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index d9ed96f293a..430976e7d3c 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -28,6 +28,7 @@ fn ignored_span(sp: Span) -> Span { format: MacroAttribute(Symbol::intern("std_inject")), span: None, allow_internal_unstable: true, + allow_internal_unsafe: false, } }); Span { ctxt: SyntaxContext::empty().apply_mark(mark), ..sp } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 887479a2472..c05e166e013 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -291,6 +291,7 @@ fn generate_test_harness(sess: &ParseSess, format: MacroAttribute(Symbol::intern("test")), span: None, allow_internal_unstable: true, + allow_internal_unsafe: false, } }); diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 5eab81dd28f..439538a8b5e 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -64,7 +64,12 @@ pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver, macro_rules! register { ($( $name:ident: $f:expr, )*) => { $( register(Symbol::intern(stringify!($name)), - NormalTT(Box::new($f as MacroExpanderFn), None, false)); + NormalTT { + expander: Box::new($f as MacroExpanderFn), + def_info: None, + allow_internal_unstable: false, + allow_internal_unsafe: false, + }); )* } } @@ -112,7 +117,12 @@ pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver, // format_args uses `unstable` things internally. register(Symbol::intern("format_args"), - NormalTT(Box::new(format::expand_format_args), None, true)); + NormalTT { + expander: Box::new(format::expand_format_args), + def_info: None, + allow_internal_unstable: true, + allow_internal_unsafe: false, + }); for (name, ext) in user_exts { register(name, ext); diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index ab6d73e5061..700386f68fe 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -368,6 +368,7 @@ fn mk_registrar(cx: &mut ExtCtxt, format: MacroAttribute(Symbol::intern("proc_macro")), span: None, allow_internal_unstable: true, + allow_internal_unsafe: false, } }); let span = Span { ctxt: SyntaxContext::empty().apply_mark(mark), ..DUMMY_SP }; diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 804b91ab09e..514cc26666e 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -310,6 +310,9 @@ pub struct NameAndSpan { /// features internally without forcing the whole crate to opt-in /// to them. pub allow_internal_unstable: bool, + /// Whether the macro is allowed to use `unsafe` internally + /// even if the user crate has `#![forbid(unsafe_code)]`. + pub allow_internal_unsafe: bool, /// The span of the macro definition itself. The macro may not /// have a sensible definition span (e.g. something defined /// completely inside libsyntax) in which case this is None. diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 7006f45455e..e162bc26412 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -153,6 +153,16 @@ impl Span { } } + /// Check if a span is "internal" to a macro in which `unsafe` + /// can be used without triggering the `unsafe_code` lint + // (that is, a macro marked with `#[allow_internal_unsafe]`). + pub fn allows_unsafe(&self) -> bool { + match self.ctxt.outer().expn_info() { + Some(info) => info.callee.allow_internal_unsafe, + None => false, + } + } + pub fn macro_backtrace(mut self) -> Vec { let mut prev_span = DUMMY_SP; let mut result = vec![]; diff --git a/src/test/compile-fail/feature-gate-allow-internal-unsafe-nested-macro.rs b/src/test/compile-fail/feature-gate-allow-internal-unsafe-nested-macro.rs new file mode 100644 index 00000000000..590dc619f2f --- /dev/null +++ b/src/test/compile-fail/feature-gate-allow-internal-unsafe-nested-macro.rs @@ -0,0 +1,27 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// gate-test-allow_internal_unsafe + +#![allow(unused_macros)] + +macro_rules! bar { + () => { + // more layers don't help: + #[allow_internal_unsafe] //~ ERROR allow_internal_unsafe side-steps + macro_rules! baz { + () => {} + } + } +} + +bar!(); + +fn main() {} diff --git a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs index 134e36c587b..8da2ae8b29a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs +++ b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs @@ -48,5 +48,10 @@ impl TTMacroExpander for Expander { pub fn plugin_registrar(reg: &mut Registry) { let args = reg.args().to_owned(); reg.register_syntax_extension(Symbol::intern("plugin_args"), - NormalTT(Box::new(Expander { args: args, }), None, false)); + NormalTT { + expander: Box::new(Expander { args: args, }), + def_info: None, + allow_internal_unstable: false, + allow_internal_unsafe: false, + }); } -- cgit 1.4.1-3-g733a5 From 64503b6ee7e6b861f5c1dc8e27a97cf231b59685 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Sat, 12 Aug 2017 18:00:57 +0900 Subject: Include 'let' keyword to the span for ast::Local --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7bf4c6799b3..15f05df58b5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3587,7 +3587,7 @@ impl<'a> Parser<'a> { /// Parse a local variable declaration fn parse_local(&mut self, attrs: ThinVec) -> PResult<'a, P> { - let lo = self.span; + let lo = self.prev_span; let pat = self.parse_pat()?; let ty = if self.eat(&token::Colon) { -- cgit 1.4.1-3-g733a5 From 3ab86fbab281ca059731c31fa2aee5d9afc7e6dc Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Fri, 11 Aug 2017 20:34:14 +0200 Subject: Fix some typos --- src/bootstrap/builder.rs | 4 ++-- src/bootstrap/doc.rs | 2 +- src/liballoc/allocator.rs | 6 +++--- src/liballoc/string.rs | 2 +- src/liballoc/vec.rs | 2 +- src/libcore/ops/place.rs | 2 +- src/libgraphviz/lib.rs | 2 +- src/librustc/hir/intravisit.rs | 2 +- src/librustc/hir/map/mod.rs | 2 +- src/librustc/hir/mod.rs | 2 +- src/librustc/infer/at.rs | 2 +- src/librustc/infer/higher_ranked/mod.rs | 2 +- src/librustc/infer/lattice.rs | 2 +- src/librustc/infer/region_inference/mod.rs | 2 +- src/librustc/lint/context.rs | 2 +- src/librustc/mir/mod.rs | 2 +- src/librustc/session/mod.rs | 4 ++-- src/librustc/traits/error_reporting.rs | 4 ++-- src/librustc/traits/project.rs | 2 +- .../traits/specialize/specialization_graph.rs | 4 ++-- src/librustc/ty/inhabitedness/def_id_forest.rs | 4 ++-- src/librustc/ty/item_path.rs | 2 +- src/librustc/ty/maps.rs | 2 +- src/librustc/util/common.rs | 2 +- src/librustc_borrowck/borrowck/check_loans.rs | 2 +- src/librustc_const_eval/eval.rs | 2 +- src/librustc_driver/driver.rs | 2 +- src/librustc_mir/build/scope.rs | 2 +- src/librustc_mir/dataflow/mod.rs | 6 +++--- src/librustc_mir/transform/erase_regions.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_save_analysis/json_dumper.rs | 2 +- src/librustc_save_analysis/sig.rs | 4 ++-- src/librustc_trans/base.rs | 2 +- src/librustc_trans/debuginfo/type_names.rs | 2 +- src/librustc_trans/mir/mod.rs | 2 +- src/librustc_typeck/check/method/mod.rs | 2 +- src/librustc_typeck/check/mod.rs | 10 ++++----- src/librustc_typeck/check/wfcheck.rs | 2 +- src/libstd/fs.rs | 2 +- src/libstd/net/tcp.rs | 2 +- src/libstd/net/udp.rs | 2 +- src/libstd/panic.rs | 2 +- src/libstd/panicking.rs | 25 +++++++++++----------- src/libstd/primitive_docs.rs | 2 +- src/libstd/sys/redox/ext/fs.rs | 2 +- src/libstd/sys/redox/ext/process.rs | 2 +- src/libstd/sys/unix/ext/fs.rs | 4 ++-- src/libstd/sys/unix/ext/net.rs | 2 +- src/libstd/sys/unix/ext/process.rs | 2 +- src/libstd/sys/windows/ext/fs.rs | 2 +- src/libsyntax/ast.rs | 6 +++--- src/libsyntax/codemap.rs | 4 ++-- 53 files changed, 83 insertions(+), 82 deletions(-) (limited to 'src/libsyntax') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index d7f795e4055..f49e0223fcb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -333,7 +333,7 @@ impl<'a> Builder<'a> { StepDescription::run(&Builder::get_step_descriptions(Kind::Doc), self, paths); } - /// Obtain a compiler at a given stage and for a given host. Explictly does + /// Obtain a compiler at a given stage and for a given host. Explicitly does /// not take `Compiler` since all `Compiler` instances are meant to be /// obtained through this function, since it ensures that they are valid /// (i.e., built and assembled). @@ -501,7 +501,7 @@ impl<'a> Builder<'a> { // crates). Let's say, for example that rustc itself depends on the // bitflags crate. If an external crate then depends on the // bitflags crate as well, we need to make sure they don't - // conflict, even if they pick the same verison of bitflags. We'll + // conflict, even if they pick the same version of bitflags. We'll // want to make sure that e.g. a plugin and rustc each get their // own copy of bitflags. diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 1ee578bb62b..8d5d9f09ba9 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -306,7 +306,7 @@ impl Step for Standalone { /// /// This will list all of `src/doc` looking for markdown files and appropriately /// perform transformations like substituting `VERSION`, `SHORT_HASH`, and - /// `STAMP` alongw ith providing the various header/footer HTML we've cutomized. + /// `STAMP` along with providing the various header/footer HTML we've customized. /// /// In the end, this is just a glorified wrapper around rustdoc! fn run(self, builder: &Builder) { diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 3ea7d349c9c..7b6700bfd49 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -240,7 +240,7 @@ impl Layout { /// /// Returns `Some((k, offset))`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the - /// start of the `next` embedded witnin the concatenated record + /// start of the `next` embedded within the concatenated record /// (assuming that the record itself starts at offset 0). /// /// On arithmetic overflow, returns `None`. @@ -297,7 +297,7 @@ impl Layout { /// /// Returns `(k, offset)`, where `k` is layout of the concatenated /// record and `offset` is the relative location, in bytes, of the - /// start of the `next` embedded witnin the concatenated record + /// start of the `next` embedded within the concatenated record /// (assuming that the record itself starts at offset 0). /// /// (The `offset` is always the same as `self.size()`; we use this @@ -544,7 +544,7 @@ pub unsafe trait Alloc { /// practice this means implementors should eschew allocating, /// especially from `self` (directly or indirectly). /// - /// Implementions of the allocation and reallocation methods + /// Implementations of the allocation and reallocation methods /// (e.g. `alloc`, `alloc_one`, `realloc`) are discouraged from /// panicking (or aborting) in the event of memory exhaustion; /// instead they should return an appropriate error from the diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 322b137e99f..3ed5d2df1ab 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -653,7 +653,7 @@ impl String { /// * `capacity` needs to be the correct value. /// /// Violating these may cause problems like corrupting the allocator's - /// internal datastructures. + /// internal data structures. /// /// The ownership of `ptr` is effectively transferred to the /// `String` which may then deallocate, reallocate or change the diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 160c0ba2ab0..5f68e59289d 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -374,7 +374,7 @@ impl Vec { /// * `capacity` needs to be the capacity that the pointer was allocated with. /// /// Violating these may cause problems like corrupting the allocator's - /// internal datastructures. For example it is **not** safe + /// internal data structures. For example it is **not** safe /// to build a `Vec` from a pointer to a C `char` array and a `size_t`. /// /// The ownership of `ptr` is effectively transferred to the diff --git a/src/libcore/ops/place.rs b/src/libcore/ops/place.rs index 19da887cbbf..9fb171e7b92 100644 --- a/src/libcore/ops/place.rs +++ b/src/libcore/ops/place.rs @@ -66,7 +66,7 @@ pub trait Place { /// or `Copy`, since the `make_place` method takes `self` by value. #[unstable(feature = "placement_new_protocol", issue = "27779")] pub trait Placer { - /// `Place` is the intermedate agent guarding the + /// `Place` is the intermediate agent guarding the /// uninitialized state for `Data`. type Place: InPlace; diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 7412a01e11e..c01938f5e11 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -548,7 +548,7 @@ impl<'a> LabelText<'a> { } /// Renders text as string suitable for a label in a .dot file. - /// This includes quotes or suitable delimeters. + /// This includes quotes or suitable delimiters. pub fn to_dot_string(&self) -> String { match self { &LabelStr(ref s) => format!("\"{}\"", s.escape_default()), diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 57198d8ca0b..2a0c76d99bf 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -87,7 +87,7 @@ pub enum NestedVisitorMap<'this, 'tcx: 'this> { /// Do not visit nested item-like things, but visit nested things /// that are inside of an item-like. /// - /// **This is the most common choice.** A very commmon pattern is + /// **This is the most common choice.** A very common pattern is /// to use `visit_all_item_likes()` as an outer loop, /// and to have the visitor that visits the contents of each item /// using this setting. diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 45b1d6c1841..919b205fdf9 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -248,7 +248,7 @@ pub struct Map<'hir> { pub forest: &'hir Forest, /// Same as the dep_graph in forest, just available with one fewer - /// deref. This is a gratuitious micro-optimization. + /// deref. This is a gratuitous micro-optimization. pub dep_graph: DepGraph, /// NodeIds are sequential integers from 0, so we can be diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index efe0504aa18..7f408900dec 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -496,7 +496,7 @@ impl Crate { &self.impl_items[&id] } - /// Visits all items in the crate in some determinstic (but + /// Visits all items in the crate in some deterministic (but /// unspecified) order. If you just need to process every item, /// but don't care about nesting, this method is the best choice. /// diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 756e0b5f9fb..3fd7ee27672 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -169,7 +169,7 @@ impl<'a, 'gcx, 'tcx> At<'a, 'gcx, 'tcx> { } /// Sets the "trace" values that will be used for - /// error-repporting, but doesn't actually perform any operation + /// error-reporting, but doesn't actually perform any operation /// yet (this is useful when you want to set the trace using /// distinct values from those you wish to operate upon). pub fn trace(self, diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index 9ecc8b0e66b..0d02420457e 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -589,7 +589,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { (result, map) } - /// Searches the region constriants created since `snapshot` was started + /// Searches the region constraints created since `snapshot` was started /// and checks to determine whether any of the skolemized regions created /// in `skol_map` would "escape" -- meaning that they are related to /// other regions in some way. If so, the higher-ranked subtyping doesn't diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index d4d090f0153..d5c1163cfc1 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -46,7 +46,7 @@ pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'f, 'gcx, 'tcx> // the LUB/GLB of `a` and `b` as appropriate. // // Subtle hack: ordering *may* be significant here. This method - // relates `v` to `a` first, which may help us to avoid unecessary + // relates `v` to `a` first, which may help us to avoid unnecessary // type variable obligations. See caller for details. fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; } diff --git a/src/librustc/infer/region_inference/mod.rs b/src/librustc/infer/region_inference/mod.rs index 57f2f748b24..5588b6d9add 100644 --- a/src/librustc/infer/region_inference/mod.rs +++ b/src/librustc/infer/region_inference/mod.rs @@ -128,7 +128,7 @@ pub enum UndoLogEntry<'tcx> { /// We added the given `given` AddGiven(Region<'tcx>, ty::RegionVid), - /// We added a GLB/LUB "combinaton variable" + /// We added a GLB/LUB "combination variable" AddCombination(CombineMapType, TwoRegions<'tcx>), /// During skolemization, we sometimes purge entries from the undo diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 6ee06dc0a81..17b5f6ad954 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -69,7 +69,7 @@ pub struct LintStore { /// is true if the lint group was added by a plugin. lint_groups: FxHashMap<&'static str, (Vec, bool)>, - /// Extra info for future incompatibility lints, descibing the + /// Extra info for future incompatibility lints, describing the /// issue or RFC that caused the incompatibility. future_incompatible: FxHashMap, } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 1e8dda0addf..74ce68b351d 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -695,7 +695,7 @@ impl<'tcx> Debug for TerminatorKind<'tcx> { impl<'tcx> TerminatorKind<'tcx> { /// Write the "head" part of the terminator; that is, its name and the data it uses to pick the - /// successor basic block, if any. The only information not inlcuded is the list of possible + /// successor basic block, if any. The only information not included is the list of possible /// successors, which may be rendered differently between the text and the graphviz format. pub fn fmt_head(&self, fmt: &mut W) -> fmt::Result { use self::TerminatorKind::*; diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index be39f95b988..3aea0722d0e 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -112,7 +112,7 @@ pub struct Session { /// Map from imported macro spans (which consist of /// the localized span for the macro body) to the - /// macro name and defintion span in the source crate. + /// macro name and definition span in the source crate. pub imported_macro_spans: RefCell>, incr_comp_session: RefCell, @@ -828,7 +828,7 @@ pub fn compile_result_from_err_count(err_count: usize) -> CompileResult { #[inline(never)] pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments) -> ! { // this wrapper mostly exists so I don't have to write a fully - // qualified path of None:: inside the bug!() macro defintion + // qualified path of None:: inside the bug!() macro definition opt_span_bug_fmt(file, line, None::, args); } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f0fc6998c9e..f23071de647 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -111,8 +111,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } - // returns if `cond` not occuring implies that `error` does not occur - i.e. that - // `error` occuring implies that `cond` occurs. + // returns if `cond` not occurring implies that `error` does not occur - i.e. that + // `error` occurring implies that `cond` occurs. fn error_implies(&self, cond: &ty::Predicate<'tcx>, error: &ty::Predicate<'tcx>) diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 7cce9c398bb..e70258007e4 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -1364,7 +1364,7 @@ impl<'tcx> ProjectionCache<'tcx> { } /// Try to start normalize `key`; returns an error if - /// normalization already occured (this error corresponds to a + /// normalization already occurred (this error corresponds to a /// cache hit, so it's actually a good thing). fn try_start(&mut self, key: ty::ProjectionTy<'tcx>) -> Result<(), ProjectionCacheEntry<'tcx>> { diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index 611137562a9..8b31cb599e4 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> Children { } /// Attempt to insert an impl into this set of children, while comparing for - /// specialiation relationships. + /// specialization relationships. fn insert(&mut self, tcx: TyCtxt<'a, 'gcx, 'tcx>, impl_def_id: DefId, @@ -206,7 +206,7 @@ impl<'a, 'gcx, 'tcx> Graph { // if the reference itself contains an earlier error (e.g., due to a // resolution failure), then we just insert the impl at the top level of - // the graph and claim that there's no overlap (in order to supress + // the graph and claim that there's no overlap (in order to suppress // bogus errors). if trait_ref.references_error() { debug!("insert: inserting dummy node for erroneous TraitRef {:?}, \ diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 231600f95ac..896682e2370 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -24,7 +24,7 @@ use ty::{DefId, DefIdTree}; #[derive(Clone)] pub struct DefIdForest { /// The minimal set of DefIds required to represent the whole set. - /// If A and B are DefIds in the DefIdForest, and A is a desecendant + /// If A and B are DefIds in the DefIdForest, and A is a descendant /// of B, then only B will be in root_ids. /// We use a SmallVec here because (for its use for cacheing inhabitedness) /// its rare that this will contain even two ids. @@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest { self.root_ids.is_empty() } - /// Test whether the forest conains a given DefId. + /// Test whether the forest contains a given DefId. pub fn contains(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, id: DefId) -> bool diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 73b577e2e87..76a20ed8f30 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -125,7 +125,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// If possible, this pushes a global path resolving to `external_def_id` that is visible /// from at least one local module and returns true. If the crate defining `external_def_id` is - /// declared with an `extern crate`, the path is guarenteed to use the `extern crate`. + /// declared with an `extern crate`, the path is guaranteed to use the `extern crate`. pub fn try_push_visible_item_path(self, buffer: &mut T, external_def_id: DefId) -> bool where T: ItemPathBuffer { diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index b871b36c948..a640da31eec 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -587,7 +587,7 @@ macro_rules! define_maps { } // FIXME(eddyb) Get more valid Span's on queries. - // def_span guard is necesary to prevent a recursive loop, + // def_span guard is necessary to prevent a recursive loop, // default_span calls def_span query internally. if span == DUMMY_SP && stringify!($name) != "def_span" { span = key.default_span(tcx) diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 244b7f35968..885be8464eb 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -224,7 +224,7 @@ pub trait MemoizationMap { type Key: Clone; type Value: Clone; - /// If `key` is present in the map, return the valuee, + /// If `key` is present in the map, return the value, /// otherwise invoke `op` and store the value in the map. /// /// NB: if the receiver is a `DepTrackingMap`, special care is diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index e70b7f89a67..c34bf4c3d28 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -472,7 +472,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { if new_loan.span == old_loan.span { // Both borrows are happening in the same place - // Meaning the borrow is occuring in a loop + // Meaning the borrow is occurring in a loop err.span_label( new_loan.span, format!("mutable borrow starts here in previous \ diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index eb45fd9c0e0..a1581b16041 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -106,7 +106,7 @@ impl<'a, 'tcx> ConstContext<'a, 'tcx> { } /// Evaluate a constant expression in a context where the expression isn't - /// guaranteed to be evaluatable. + /// guaranteed to be evaluable. pub fn eval(&self, e: &Expr) -> EvalResult<'tcx> { if self.tables.tainted_by_errors { signal!(e, TypeckError); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index c6d2d75e937..83bed33b111 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -974,7 +974,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, passes.push_pass(MIR_CONST, mir::transform::type_check::TypeckMir); passes.push_pass(MIR_CONST, mir::transform::rustc_peek::SanityCheck); - // We compute "constant qualifications" betwen MIR_CONST and MIR_VALIDATED. + // We compute "constant qualifications" between MIR_CONST and MIR_VALIDATED. // What we need to run borrowck etc. passes.push_pass(MIR_VALIDATED, mir::transform::qualify_consts::QualifyAndPromoteConstants); diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index a4a89a7f818..ce64f88d18e 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -113,7 +113,7 @@ pub struct Scope<'tcx> { /// for unwinding, for several reasons: /// * clang doesn't emit llvm.lifetime.end for C++ unwinding /// * LLVM's memory dependency analysis can't handle it atm - /// * pollutting the cleanup MIR with StorageDead creates + /// * polluting the cleanup MIR with StorageDead creates /// landing pads even though there's no actual destructors /// * freeing up stack space has no effect during unwinding needs_cleanup: bool, diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index d7ad9f9c09a..7c0137b18c0 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -333,11 +333,11 @@ pub trait BitDenotation { /// basic block) according to the effects of evaluating statement. /// /// This is used, in particular, for building up the - /// "transfer-function" represnting the overall-effect of the + /// "transfer-function" representing the overall-effect of the /// block, represented via GEN and KILL sets. /// /// The statement is identified as `bb_data[idx_stmt]`, where - /// `bb_data` is the sequence of statements identifed by `bb` in + /// `bb_data` is the sequence of statements identified by `bb` in /// the MIR. fn statement_effect(&self, sets: &mut BlockSets, @@ -349,7 +349,7 @@ pub trait BitDenotation { /// the terminator. /// /// This is used, in particular, for building up the - /// "transfer-function" represnting the overall-effect of the + /// "transfer-function" representing the overall-effect of the /// block, represented via GEN and KILL sets. /// /// The effects applied here cannot depend on which branch the diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index baf0522896c..89de847231c 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! This pass erases all early-bound regions from the types occuring in the MIR. +//! This pass erases all early-bound regions from the types occurring in the MIR. //! We want to do this once just before trans, so trans does not have to take //! care erasing regions all over the place. //! NOTE: We do NOT erase regions of statements that are relevant for diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b4f9ba4e8f7..da170e7fe22 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1621,7 +1621,7 @@ impl<'a> Resolver<'a> { return Some(module.parent.unwrap()); } - let mut module_expansion = module.expansion.modern(); // for backward compatability + let mut module_expansion = module.expansion.modern(); // for backward compatibility while let Some(parent) = module.parent { let parent_expansion = parent.expansion.modern(); if module_expansion.is_descendant_of(parent_expansion) && diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 30a698e6351..8dd191f4375 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -109,7 +109,7 @@ impl<'b, O: DumpOutput + 'b> JsonDumper { } if data.kind == DefKind::Mod && data.span.file_name.to_str().unwrap() != data.value { // If the module is an out-of-line defintion, then we'll make the - // defintion the first character in the module's file and turn the + // definition the first character in the module's file and turn the // the declaration into a reference to it. let rf = Ref { kind: RefKind::Mod, diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 3557b4752e7..6ef499694aa 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -387,7 +387,7 @@ impl Sig for ast::Item { sig.text.push('('); for i in &decl.inputs { - // FIXME shoudl descend into patterns to add defs. + // FIXME should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(offset + sig.text.len(), Some(i.id), scx)?; @@ -922,7 +922,7 @@ fn make_method_signature(id: NodeId, sig.text.push('('); for i in &m.decl.inputs { - // FIXME shoudl descend into patterns to add defs. + // FIXME should descend into patterns to add defs. sig.text.push_str(&pprust::pat_to_string(&i.pat)); sig.text.push_str(": "); let nested = i.ty.make(sig.text.len(), Some(i.id), scx)?; diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 63df33913ca..b4a2891f94c 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -488,7 +488,7 @@ impl Lifetime { // on), and `ptr` is nonzero-sized, then extracts the size of `ptr` // and the intrinsic for `lt` and passes them to `emit`, which is in // charge of generating code to call the passed intrinsic on whatever - // block of generated code is targetted for the intrinsic. + // block of generated code is targeted for the intrinsic. // // If LLVM lifetime intrinsic support is disabled (i.e. optimizations // off) or `ptr` is zero-sized, then no-op (does not call `emit`). diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index 6e36073107b..8cb2c2809f4 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -36,7 +36,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, qualified: bool, output: &mut String) { - // When targeting MSVC, emit C++ style type names for compatability with + // When targeting MSVC, emit C++ style type names for compatibility with // .natvis visualizers (and perhaps other existing native debuggers?) let cpp_like_names = cx.sess().target.target.options.is_like_msvc; diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index a7f12babb10..d0f7f27d5a8 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { (scope, source_info.span) } else { // Walk up the macro expansion chain until we reach a non-expanded span. - // We also stop at the function body level because no line stepping can occurr + // We also stop at the function body level because no line stepping can occur // at the level above that. let mut span = source_info.span; while span.ctxt != NO_EXPANSION && span.ctxt != self.mir.span.ctxt { diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 1ccb1e64a98..a1c987f22e0 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -219,7 +219,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// `lookup_method_in_trait` is used for overloaded operators. /// It does a very narrow slice of what the normal probe/confirm path does. /// In particular, it doesn't really do any probing: it simply constructs - /// an obligation for aparticular trait with the given self-type and checks + /// an obligation for a particular trait with the given self-type and checks /// whether that trait is implemented. /// /// FIXME(#18741) -- It seems likely that we can consolidate some of this diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 697d9de931a..17611af5ac4 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -529,7 +529,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// `foo(return)`; we warn on the `foo()` expression. (We then /// update the flag to `WarnedAlways` to suppress duplicate /// reports.) Similarly, if we traverse to a fresh statement (or - /// tail expression) from a `Always` setting, we will isssue a + /// tail expression) from a `Always` setting, we will issue a /// warning. This corresponds to something like `{return; /// foo();}` or `{return; 22}`, where we would warn on the /// `foo()` or `22`. @@ -538,7 +538,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// (including the "return slot") of type `!`. This is allowed /// if **either** the type of value being assigned is `!`, which /// means the current code is dead, **or** the expression's - /// divering flag is true, which means that a divering value was + /// diverging flag is true, which means that a diverging value was /// wrapped (e.g., `let x: ! = foo(return)`). /// /// To repeat the last point: an expression represents dead-code @@ -1895,7 +1895,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { value.fold_with(&mut BottomUpFolder { tcx: self.tcx, fldop: |ty| { if let ty::TyAnon(def_id, substs) = ty.sty { // Use the same type variable if the exact same TyAnon appears more - // than once in the return type (e.g. if it's pased to a type alias). + // than once in the return type (e.g. if it's passed to a type alias). let id = self.tcx.hir.as_local_node_id(def_id).unwrap(); if let Some(ty_var) = self.anon_types.borrow().get(&id) { return ty_var; @@ -4244,7 +4244,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } /// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a - /// suggetion can be made, `None` otherwise. + /// suggestion can be made, `None` otherwise. pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> { // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or // `while` before reaching it, as block tail returns are not available in them. @@ -4312,7 +4312,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// ``` /// /// This routine checks if the return expression in a block would make sense on its own as a - /// statement and the return type has been left as defaultor has been specified as `()`. If so, + /// statement and the return type has been left as default or has been specified as `()`. If so, /// it suggests adding a semicolon. fn suggest_missing_semicolon(&self, err: &mut DiagnosticBuilder<'tcx>, diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index cf5882bb9bd..31e14a6b630 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -255,7 +255,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { // We want to ensure: // // 1) that there are no items contained within - // the trait defintion + // the trait definition // // 2) that the definition doesn't violate the no-super trait rule // for auto traits. diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 062186ef708..1e692abaff2 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -657,7 +657,7 @@ impl OpenOptions { /// This function will return an error under a number of different /// circumstances. Some of these error conditions are listed here, together /// with their [`ErrorKind`]. The mapping to [`ErrorKind`]s is not part of - /// the compatiblity contract of the function, especially the `Other` kind + /// the compatibility contract of the function, especially the `Other` kind /// might change to more specific kinds in the future. /// /// * [`NotFound`]: The specified file does not exist and neither `create` diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index fdeca8bc5ca..20fd50ff630 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -351,7 +351,7 @@ impl TcpStream { self.0.write_timeout() } - /// Receives data on the socket from the remote adress to which it is + /// Receives data on the socket from the remote address to which it is /// connected, without removing that data from the queue. On success, /// returns the number of bytes peeked. /// diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 80151dc2b44..9aff9897885 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -622,7 +622,7 @@ impl UdpSocket { self.0.recv(buf) } - /// Receives data on the socket from the remote adress to which it is + /// Receives data on the socket from the remote address to which it is /// connected, without removing that data from the queue. On success, /// returns the number of bytes peeked. /// diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 10b3209257e..97b09b7e2ad 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -37,7 +37,7 @@ pub use panicking::{take_hook, set_hook, PanicInfo, Location}; /// In Rust a function can "return" early if it either panics or calls a /// function which transitively panics. This sort of control flow is not always /// anticipated, and has the possibility of causing subtle bugs through a -/// combination of two criticial components: +/// combination of two critical components: /// /// 1. A data structure is in a temporarily invalid state when the thread /// panics. diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 04e1a579dec..99567bd08bb 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -171,7 +171,7 @@ pub fn take_hook() -> Box { /// use std::panic; /// /// panic::set_hook(Box::new(|panic_info| { -/// println!("panic occured: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); +/// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); /// })); /// /// panic!("Normal panic"); @@ -196,7 +196,7 @@ impl<'a> PanicInfo<'a> { /// use std::panic; /// /// panic::set_hook(Box::new(|panic_info| { - /// println!("panic occured: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); + /// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap()); /// })); /// /// panic!("Normal panic"); @@ -221,9 +221,10 @@ impl<'a> PanicInfo<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured in file '{}' at line {}", location.file(), location.line()); + /// println!("panic occurred in file '{}' at line {}", location.file(), + /// location.line()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -249,9 +250,9 @@ impl<'a> PanicInfo<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { -/// println!("panic occured in file '{}' at line {}", location.file(), location.line()); +/// println!("panic occurred in file '{}' at line {}", location.file(), location.line()); /// } else { -/// println!("panic occured but can't get location information..."); +/// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -275,9 +276,9 @@ impl<'a> Location<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured in file '{}'", location.file()); + /// println!("panic occurred in file '{}'", location.file()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -297,9 +298,9 @@ impl<'a> Location<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured at line {}", location.line()); + /// println!("panic occurred at line {}", location.line()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// @@ -320,9 +321,9 @@ impl<'a> Location<'a> { /// /// panic::set_hook(Box::new(|panic_info| { /// if let Some(location) = panic_info.location() { - /// println!("panic occured at column {}", location.column()); + /// println!("panic occurred at column {}", location.column()); /// } else { - /// println!("panic occured but can't get location information..."); + /// println!("panic occurred but can't get location information..."); /// } /// })); /// diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 7be319d1954..c52899db437 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -906,7 +906,7 @@ mod prim_ref { } /// These markers can be combined, so `unsafe extern "stdcall" fn()` is a valid type. /// /// Like references in rust, function pointers are assumed to not be null, so if you want to pass a -/// function pointer over FFI and be able to accomodate null pointers, make your type +/// function pointer over FFI and be able to accommodate null pointers, make your type /// `Option` with your required signature. /// /// Function pointers implement the following traits: diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs index 9a0d1e06da3..5d4edc2cf92 100644 --- a/src/libstd/sys/redox/ext/fs.rs +++ b/src/libstd/sys/redox/ext/fs.rs @@ -121,7 +121,7 @@ pub trait OpenOptionsExt { #[stable(feature = "fs_ext", since = "1.1.0")] fn mode(&mut self, mode: u32) -> &mut Self; - /// Pass custom flags to the `flags` agument of `open`. + /// Pass custom flags to the `flags` argument of `open`. /// /// The bits that define the access mode are masked out with `O_ACCMODE`, to /// ensure they do not interfere with the access mode set by Rusts options. diff --git a/src/libstd/sys/redox/ext/process.rs b/src/libstd/sys/redox/ext/process.rs index c59524974bf..e68e180acf1 100644 --- a/src/libstd/sys/redox/ext/process.rs +++ b/src/libstd/sys/redox/ext/process.rs @@ -47,7 +47,7 @@ pub trait CommandExt { /// # Notes /// /// This closure will be run in the context of the child process after a - /// `fork`. This primarily means that any modificatons made to memory on + /// `fork`. This primarily means that any modifications made to memory on /// behalf of this closure will **not** be visible to the parent process. /// This is often a very constrained environment where normal operations /// like `malloc` or acquiring a mutex are not guaranteed to work (due to diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index 26710bf61d5..a94585723a1 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -46,7 +46,7 @@ pub trait FileExt { /// /// The current file cursor is not affected by this function. /// - /// When writing beyond the end of the file, the file is appropiately + /// When writing beyond the end of the file, the file is appropriately /// extended and the intermediate bytes are initialized with the value 0. /// /// Note that similar to `File::write`, it is not an error to return a @@ -168,7 +168,7 @@ pub trait OpenOptionsExt { #[stable(feature = "fs_ext", since = "1.1.0")] fn mode(&mut self, mode: u32) -> &mut Self; - /// Pass custom flags to the `flags` agument of `open`. + /// Pass custom flags to the `flags` argument of `open`. /// /// The bits that define the access mode are masked out with `O_ACCMODE`, to /// ensure they do not interfere with the access mode set by Rusts options. diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 7701ae25b41..d9ab07fe509 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -327,7 +327,7 @@ impl UnixStream { /// /// The returned `UnixStream` is a reference to the same stream that this /// object references. Both handles will read and write the same stream of - /// data, and options set on one stream will be propogated to the other + /// data, and options set on one stream will be propagated to the other /// stream. /// /// # Examples diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index 2961c4ec582..cde21b089a2 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -47,7 +47,7 @@ pub trait CommandExt { /// # Notes /// /// This closure will be run in the context of the child process after a - /// `fork`. This primarily means that any modificatons made to memory on + /// `fork`. This primarily means that any modifications made to memory on /// behalf of this closure will **not** be visible to the parent process. /// This is often a very constrained environment where normal operations /// like `malloc` or acquiring a mutex are not guaranteed to work (due to diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index a1c63e33588..d58a3505154 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -66,7 +66,7 @@ pub trait FileExt { /// from the current cursor. The current cursor **is** affected by this /// function, it is set to the end of the write. /// - /// When writing beyond the end of the file, the file is appropiately + /// When writing beyond the end of the file, the file is appropriately /// extended and the intermediate bytes are left uninitialized. /// /// Note that similar to `File::write`, it is not an error to return a diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 857d9a753cc..38ef79822c7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -563,8 +563,8 @@ pub enum PatKind { TupleStruct(Path, Vec>, Option), /// A possibly qualified path pattern. - /// Unquailfied path patterns `A::B::C` can legally refer to variants, structs, constants - /// or associated constants. Quailfied path patterns `::B::C`/`::B::C` can + /// Unqualified path patterns `A::B::C` can legally refer to variants, structs, constants + /// or associated constants. Qualified path patterns `::B::C`/`::B::C` can /// only legally refer to associated constants. Path(Option, Path), @@ -1838,7 +1838,7 @@ pub struct Item { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum ItemKind { - /// An`extern crate` item, with optional original crate name. + /// An `extern crate` item, with optional original crate name. /// /// E.g. `extern crate foo` or `extern crate foo_bar as foo` ExternCrate(Option), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index bfdcae7641d..6c48b4cadd8 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -761,7 +761,7 @@ mod tests { } /// Given a string like " ~~~~~~~~~~~~ ", produces a span - /// coverting that range. The idea is that the string has the same + /// converting that range. The idea is that the string has the same /// length as the input, and we uncover the byte positions. Note /// that this can span lines and so on. fn span_from_selection(input: &str, selection: &str) -> Span { @@ -771,7 +771,7 @@ mod tests { Span { lo: BytePos(left_index), hi: BytePos(right_index + 1), ctxt: NO_EXPANSION } } - /// Test span_to_snippet and span_to_lines for a span coverting 3 + /// Test span_to_snippet and span_to_lines for a span converting 3 /// lines in the middle of a file. #[test] fn span_to_snippet_and_lines_spanning_multiple_lines() { -- cgit 1.4.1-3-g733a5