Skip to content

Commit 46f5aa9

Browse files
committed
Auto merge of #69474 - Dylan-DPC:rollup-ciotplu, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #67637 (Add primitive module to libcore) - #69387 (Deduplicate identifier printing a bit) - #69412 (Mark attributes consumed by `check_mod_attrs` as normal) - #69423 (syntax: Remove `Nt(Impl,Trait,Foreign)Item`) - #69429 (remove redundant clones and import) - #69457 (Clean up e0370 e0371) - #69468 ([master] Backport release notes of 1.41.1) Failed merges: r? @ghost
2 parents 55a777c + 8381862 commit 46f5aa9

File tree

30 files changed

+300
-119
lines changed

30 files changed

+300
-119
lines changed

RELEASES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.41.1 (2020-02-27)
2+
===========================
3+
4+
* [Always check types of static items][69145]
5+
* [Always check lifetime bounds of `Copy` impls][69145]
6+
* [Fix miscompilation in callers of `Layout::repeat`][69225]
7+
8+
[69225]: https://github.com/rust-lang/rust/issues/69225
9+
[69145]: https://github.com/rust-lang/rust/pull/69145
10+
111
Version 1.41.0 (2020-01-30)
212
===========================
313

src/libcore/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ mod bool;
267267
mod tuple;
268268
mod unit;
269269

270+
#[stable(feature = "core_primitive", since = "1.43.0")]
271+
pub mod primitive;
272+
270273
// Pull in the `core_arch` crate directly into libcore. The contents of
271274
// `core_arch` are in a different repository: rust-lang/stdarch.
272275
//

src/libcore/primitive.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//! This module reexports the primitive types to allow usage that is not
2+
//! possibly shadowed by other declared types.
3+
//!
4+
//! This is normally only useful in macro generated code.
5+
//!
6+
//! An example of this is when generating a new struct and an impl for it:
7+
//!
8+
//! ```rust,compile_fail
9+
//! pub struct bool;
10+
//!
11+
//! impl QueryId for bool {
12+
//! const SOME_PROPERTY: bool = true;
13+
//! }
14+
//!
15+
//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; }
16+
//! ```
17+
//!
18+
//! Note that the `SOME_PROPERTY` associated constant would not compile, as its
19+
//! type `bool` refers to the struct, rather than to the primitive bool type.
20+
//!
21+
//! A correct implementation could look like:
22+
//!
23+
//! ```rust
24+
//! # #[allow(non_camel_case_types)]
25+
//! pub struct bool;
26+
//!
27+
//! impl QueryId for bool {
28+
//! const SOME_PROPERTY: core::primitive::bool = true;
29+
//! }
30+
//!
31+
//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; }
32+
//! ```
33+
34+
#[stable(feature = "core_primitive", since = "1.43.0")]
35+
pub use bool;
36+
#[stable(feature = "core_primitive", since = "1.43.0")]
37+
pub use char;
38+
#[stable(feature = "core_primitive", since = "1.43.0")]
39+
pub use f32;
40+
#[stable(feature = "core_primitive", since = "1.43.0")]
41+
pub use f64;
42+
#[stable(feature = "core_primitive", since = "1.43.0")]
43+
pub use i128;
44+
#[stable(feature = "core_primitive", since = "1.43.0")]
45+
pub use i16;
46+
#[stable(feature = "core_primitive", since = "1.43.0")]
47+
pub use i32;
48+
#[stable(feature = "core_primitive", since = "1.43.0")]
49+
pub use i64;
50+
#[stable(feature = "core_primitive", since = "1.43.0")]
51+
pub use i8;
52+
#[stable(feature = "core_primitive", since = "1.43.0")]
53+
pub use isize;
54+
#[stable(feature = "core_primitive", since = "1.43.0")]
55+
pub use str;
56+
#[stable(feature = "core_primitive", since = "1.43.0")]
57+
pub use u128;
58+
#[stable(feature = "core_primitive", since = "1.43.0")]
59+
pub use u16;
60+
#[stable(feature = "core_primitive", since = "1.43.0")]
61+
pub use u32;
62+
#[stable(feature = "core_primitive", since = "1.43.0")]
63+
pub use u64;
64+
#[stable(feature = "core_primitive", since = "1.43.0")]
65+
pub use u8;
66+
#[stable(feature = "core_primitive", since = "1.43.0")]
67+
pub use usize;

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ impl<'tcx> GlobalCtxt<'tcx> {
15261526
ty::tls::with_related_context(tcx, |icx| {
15271527
let new_icx = ty::tls::ImplicitCtxt {
15281528
tcx,
1529-
query: icx.query.clone(),
1529+
query: icx.query,
15301530
diagnostics: icx.diagnostics,
15311531
layout_depth: icx.layout_depth,
15321532
task_deps: icx.task_deps,

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
14471447
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> {
14481448
fn to_predicate(&self) -> Predicate<'tcx> {
14491449
ty::Predicate::Trait(
1450-
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value.clone() }),
1450+
ty::Binder::dummy(ty::TraitPredicate { trait_ref: *self.value }),
14511451
self.constness,
14521452
)
14531453
}

src/librustc/ty/query/job.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'tcx> QueryLatch<'tcx> {
173173
return CycleError { usage, cycle };
174174
}
175175

176-
current_job = info.job.parent.clone();
176+
current_job = info.job.parent;
177177
}
178178

179179
panic!("did not find a cycle")

src/librustc_ast_pretty/pprust.rs

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::pp::{self, Breaks};
33

44
use rustc_span::edition::Edition;
55
use rustc_span::source_map::{SourceMap, Spanned};
6-
use rustc_span::symbol::{kw, sym};
6+
use rustc_span::symbol::{kw, sym, IdentPrinter};
77
use rustc_span::{BytePos, FileName, Span};
88
use syntax::ast::{self, BlockCheckMode, PatKind, RangeEnd, RangeSyntax};
99
use syntax::ast::{Attribute, GenericArg, MacArgs};
@@ -196,40 +196,6 @@ pub fn literal_to_string(lit: token::Lit) -> String {
196196
out
197197
}
198198

199-
/// Print an ident from AST, `$crate` is converted into its respective crate name.
200-
pub fn ast_ident_to_string(ident: ast::Ident, is_raw: bool) -> String {
201-
ident_to_string(ident.name, is_raw, Some(ident.span))
202-
}
203-
204-
// AST pretty-printer is used as a fallback for turning AST structures into token streams for
205-
// proc macros. Additionally, proc macros may stringify their input and expect it survive the
206-
// stringification (especially true for proc macro derives written between Rust 1.15 and 1.30).
207-
// So we need to somehow pretty-print `$crate` in a way preserving at least some of its
208-
// hygiene data, most importantly name of the crate it refers to.
209-
// As a result we print `$crate` as `crate` if it refers to the local crate
210-
// and as `::other_crate_name` if it refers to some other crate.
211-
// Note, that this is only done if the ident token is printed from inside of AST pretty-pringing,
212-
// but not otherwise. Pretty-printing is the only way for proc macros to discover token contents,
213-
// so we should not perform this lossy conversion if the top level call to the pretty-printer was
214-
// done for a token stream or a single token.
215-
fn ident_to_string(name: ast::Name, is_raw: bool, convert_dollar_crate: Option<Span>) -> String {
216-
if is_raw {
217-
format!("r#{}", name)
218-
} else {
219-
if name == kw::DollarCrate {
220-
if let Some(span) = convert_dollar_crate {
221-
let converted = span.ctxt().dollar_crate_name();
222-
return if converted.is_path_segment_keyword() {
223-
converted.to_string()
224-
} else {
225-
format!("::{}", converted)
226-
};
227-
}
228-
}
229-
name.to_string()
230-
}
231-
}
232-
233199
/// Print the token kind precisely, without converting `$crate` into its respective crate name.
234200
pub fn token_kind_to_string(tok: &TokenKind) -> String {
235201
token_kind_to_string_ext(tok, None)
@@ -280,7 +246,7 @@ fn token_kind_to_string_ext(tok: &TokenKind, convert_dollar_crate: Option<Span>)
280246
token::Literal(lit) => literal_to_string(lit),
281247

282248
/* Name components */
283-
token::Ident(s, is_raw) => ident_to_string(s, is_raw, convert_dollar_crate),
249+
token::Ident(s, is_raw) => IdentPrinter::new(s, is_raw, convert_dollar_crate).to_string(),
284250
token::Lifetime(s) => s.to_string(),
285251

286252
/* Other */
@@ -315,14 +281,11 @@ pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
315281
token::NtBlock(ref e) => block_to_string(e),
316282
token::NtStmt(ref e) => stmt_to_string(e),
317283
token::NtPat(ref e) => pat_to_string(e),
318-
token::NtIdent(e, is_raw) => ast_ident_to_string(e, is_raw),
284+
token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw).to_string(),
319285
token::NtLifetime(e) => e.to_string(),
320286
token::NtLiteral(ref e) => expr_to_string(e),
321287
token::NtTT(ref tree) => tt_to_string(tree.clone()),
322-
// FIXME(Centril): merge these variants.
323-
token::NtImplItem(ref e) | token::NtTraitItem(ref e) => assoc_item_to_string(e),
324288
token::NtVis(ref e) => vis_to_string(e),
325-
token::NtForeignItem(ref e) => foreign_item_to_string(e),
326289
}
327290
}
328291

@@ -358,10 +321,6 @@ pub fn item_to_string(i: &ast::Item) -> String {
358321
to_string(|s| s.print_item(i))
359322
}
360323

361-
fn assoc_item_to_string(i: &ast::AssocItem) -> String {
362-
to_string(|s| s.print_assoc_item(i))
363-
}
364-
365324
pub fn generic_params_to_string(generic_params: &[ast::GenericParam]) -> String {
366325
to_string(|s| s.print_generic_params(generic_params))
367326
}
@@ -404,10 +363,6 @@ pub fn param_to_string(arg: &ast::Param) -> String {
404363
to_string(|s| s.print_param(arg, false))
405364
}
406365

407-
fn foreign_item_to_string(arg: &ast::ForeignItem) -> String {
408-
to_string(|s| s.print_foreign_item(arg))
409-
}
410-
411366
fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
412367
format!("{}{}", to_string(|s| s.print_visibility(vis)), s)
413368
}
@@ -819,7 +774,7 @@ impl<'a> PrintState<'a> for State<'a> {
819774
}
820775

821776
fn print_ident(&mut self, ident: ast::Ident) {
822-
self.s.word(ast_ident_to_string(ident, ident.is_raw_guess()));
777+
self.s.word(IdentPrinter::for_ast_ident(ident, ident.is_raw_guess()).to_string());
823778
self.ann.post(self, AnnNode::Ident(&ident))
824779
}
825780

src/librustc_codegen_ssa/mir/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
3131
_ => {
3232
let val = self.eval_mir_constant(constant)?;
3333
let ty = self.monomorphize(&constant.literal.ty);
34-
Ok(OperandRef::from_const(bx, val.clone(), ty))
34+
Ok(OperandRef::from_const(bx, val, ty))
3535
}
3636
}
3737
}

src/librustc_data_structures/obligation_forest/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<O: ForestObligation> ObligationForest<O> {
314314
return Ok(());
315315
}
316316

317-
match self.active_cache.entry(obligation.as_cache_key().clone()) {
317+
match self.active_cache.entry(obligation.as_cache_key()) {
318318
Entry::Occupied(o) => {
319319
let node = &mut self.nodes[*o.get()];
320320
if let Some(parent_index) = parent {
@@ -385,7 +385,7 @@ impl<O: ForestObligation> ObligationForest<O> {
385385
self.error_cache
386386
.entry(node.obligation_tree_id)
387387
.or_default()
388-
.insert(node.obligation.as_cache_key().clone());
388+
.insert(node.obligation.as_cache_key());
389389
}
390390

391391
/// Performs a pass through the obligation list. This must

src/librustc_error_codes/error_codes/E0370.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
The maximum value of an enum was reached, so it cannot be automatically
2-
set in the next enum value. Erroneous code example:
2+
set in the next enum value.
3+
4+
Erroneous code example:
35

46
```compile_fail,E0370
57
#[repr(i64)]

0 commit comments

Comments
 (0)