Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
897d278
libstd: Fix typos in doc
rick68 Sep 10, 2019
00d9db1
Added doc about behavior of extend on HashMap
Kixunil Oct 3, 2019
70c14dd
Move const generic regression tests to their old folder
varkor Oct 7, 2019
5e65e2b
Add a regression test for issue 62187
varkor Oct 7, 2019
2328a7e
Move stray issue tests into src/test/ui/issues
varkor Oct 7, 2019
4eba21e
Add regression test for #64792
varkor Oct 7, 2019
85b7aa2
Add a regression test for #57399
varkor Oct 7, 2019
c990744
Add a regression test for #57271
varkor Oct 7, 2019
5808971
Add ?Sized bound to a supertrait listing in E0038 error documentation
sugar700 Oct 8, 2019
2afd277
Fix calling function pointer const parameters. Also fixes inference of
skinnyBat Oct 1, 2019
a59eb6d
Pretty print function pointer const values.
skinnyBat Oct 2, 2019
cf3b561
Gate use of raw and function pointers in const generics behind
skinnyBat Oct 4, 2019
43badf9
Substitute and normalize all types of consts within collect const
skinnyBat Oct 4, 2019
9677cbe
Refactor pretty print const to use a big match statement
skinnyBat Oct 4, 2019
50ea5f4
Fix reify_fn_ptr test as we now pretty print const function pointers.
skinnyBat Oct 5, 2019
16b7f44
Update feature gate error message
skinnyBat Oct 7, 2019
5986fe2
Update ui tests
skinnyBat Oct 8, 2019
7dc4bf4
Change incorrect trait name in E0038 error documentation
sugar700 Oct 8, 2019
3f9d834
Add failing example for Self in supertrait listing in E0038 documenta…
sugar700 Oct 9, 2019
9dbd7be
Cache the DepNodeIndex of upstream crates in order to avoid multiple …
michaelwoerister Oct 9, 2019
003d5a6
self-profiling: Add events for tracking crate metadata loading relate…
michaelwoerister Oct 9, 2019
0ee6a96
Remove some outdated comments about dependency tracking from cstore_i…
michaelwoerister Oct 9, 2019
89cc046
Pretty print raw pointers in consts as '{pointer}'.
skinnyBat Oct 9, 2019
4bb1592
Suggest `if let` on `let` refutable binding
estebank Oct 9, 2019
af3f8de
Delegate is_{freeze,copy,sized}_raw to is_item_raw
mbStavola Oct 10, 2019
ee08114
Qualify LangItem
mbStavola Oct 10, 2019
a9853fc
Add 'unlikely' annotation to branch in crate DepNodeIndex caching.
michaelwoerister Oct 10, 2019
a185061
Sort long error code explanation by error code
GuillaumeGomez Oct 10, 2019
019fba8
Uncomment E0386 to let users have access to its old definition
GuillaumeGomez Oct 10, 2019
8569dd1
Preserve output of raw pointers in mir dump.
skinnyBat Oct 10, 2019
19bc0a8
Mark Path::join as must_use
matklad Oct 10, 2019
847ad6a
Add long error explanation for E0568
GuillaumeGomez Oct 8, 2019
3c62bdc
Update ui tests
GuillaumeGomez Oct 8, 2019
fb392c5
Don't cc rust-lang/compiler for toolstate changes
varkor Oct 10, 2019
9f69420
query generator kind for error reporting
csmoe Oct 10, 2019
e8af4c1
resolve: Mark macros starting with an underscore as used
petrochenkov Oct 9, 2019
1270140
expand: Simplify expansion of derives
petrochenkov Oct 9, 2019
ceb4c3f
stability: Do not use `buffer_lint` after lowering to HIR
petrochenkov Oct 10, 2019
06a02b5
Unification and cleanup of librustc_mir error codes
GuillaumeGomez Oct 10, 2019
c97d715
Fix issue 65284
varkor Oct 10, 2019
4fde07d
Rollup merge of #64337 - rick68:patch-17, r=Dylan-DPC
tmandry Oct 11, 2019
54769b0
Rollup merge of #64986 - skinny121:fn-ptr-const-generics, r=varkor
tmandry Oct 11, 2019
a12b9c0
Rollup merge of #65048 - Kixunil:patch-1, r=KodrAus
tmandry Oct 11, 2019
ece23fc
Rollup merge of #65191 - varkor:const-generics-test-cases, r=nikomats…
tmandry Oct 11, 2019
c4a9302
Rollup merge of #65200 - xfix:patch-20, r=GuillaumeGomez
tmandry Oct 11, 2019
b37301a
Rollup merge of #65205 - GuillaumeGomez:long-err-explanation-E0568, r…
tmandry Oct 11, 2019
5d55d46
Rollup merge of #65240 - michaelwoerister:sp-review-3, r=Mark-Simulacrum
tmandry Oct 11, 2019
f0dbdd6
Rollup merge of #65248 - estebank:mention-if-let, r=cramertj
tmandry Oct 11, 2019
4180187
Rollup merge of #65252 - petrochenkov:deriveholders2, r=matthewjasper
tmandry Oct 11, 2019
4e7633d
Rollup merge of #65263 - mbStavola:dedup-raw-item-fns, r=Centril
tmandry Oct 11, 2019
1d70283
Rollup merge of #65265 - GuillaumeGomez:cleanup-librustc_mir-err-code…
tmandry Oct 11, 2019
8be5481
Rollup merge of #65266 - rust-lang:must-use-join, r=dtolnay
tmandry Oct 11, 2019
f1d2d95
Rollup merge of #65276 - varkor:toolstate-no-ping, r=Mark-Simulacrum
tmandry Oct 11, 2019
2252ea1
Rollup merge of #65277 - csmoe:fix-move, r=estebank
tmandry Oct 11, 2019
1cecbff
Rollup merge of #65283 - petrochenkov:softstab2, r=estebank
tmandry Oct 11, 2019
9f143a7
Rollup merge of #65289 - varkor:issue-65284, r=estebank
tmandry Oct 11, 2019
1f8aa05
Rollup merge of #64337 - rick68:patch-17, r=Dylan-DPC
tmandry Oct 11, 2019
5670c7f
Rollup merge of #64986 - skinny121:fn-ptr-const-generics, r=varkor
tmandry Oct 11, 2019
b851efb
Rollup merge of #65048 - Kixunil:patch-1, r=KodrAus
tmandry Oct 11, 2019
c2e7af5
Rollup merge of #65191 - varkor:const-generics-test-cases, r=nikomats…
tmandry Oct 11, 2019
873f251
Rollup merge of #65200 - xfix:patch-20, r=GuillaumeGomez
tmandry Oct 11, 2019
b5c4a82
Rollup merge of #65205 - GuillaumeGomez:long-err-explanation-E0568, r…
tmandry Oct 11, 2019
f55e9b9
Rollup merge of #65263 - mbStavola:dedup-raw-item-fns, r=Centril
tmandry Oct 11, 2019
d26439d
Rollup merge of #65266 - rust-lang:must-use-join, r=dtolnay
tmandry Oct 11, 2019
7ed57bb
Rollup merge of #65276 - varkor:toolstate-no-ping, r=Mark-Simulacrum
tmandry Oct 11, 2019
d2501c2
Rollup merge of #65277 - csmoe:fix-move, r=estebank
tmandry Oct 11, 2019
1346802
Rollup merge of #65283 - petrochenkov:softstab2, r=estebank
tmandry Oct 11, 2019
c7c6cbf
Rollup merge of #65297 - tmandry:rollup-pe7a2i2, r=tmandry
tmandry Oct 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Gate use of raw and function pointers in const generics behind
const_compare_raw_pointers.
  • Loading branch information
skinnyBat committed Oct 8, 2019
commit cf3b561cea59f0063c9f51c9b058a6f2462bb31d
26 changes: 23 additions & 3 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,9 +1508,29 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
}

Node::GenericParam(param) => match &param.kind {
hir::GenericParamKind::Type { default: Some(ref ty), .. } |
hir::GenericParamKind::Const { ref ty, .. } => {
icx.to_ty(ty)
hir::GenericParamKind::Type { default: Some(ref ty), .. } => icx.to_ty(ty),
hir::GenericParamKind::Const { ty: ref hir_ty, .. } => {
let ty = icx.to_ty(hir_ty);
if !tcx.features().const_compare_raw_pointers {
let err = match ty.peel_refs().kind {
ty::FnPtr(_) => Some("function pointers"),
ty::RawPtr(_) => Some("raw pointers"),
_ => None,
};
if let Some(unsupported_type) = err {
feature_gate::emit_feature_err(
&tcx.sess.parse_sess,
sym::const_compare_raw_pointers,
hir_ty.span,
feature_gate::GateIssue::Language,
&format!(
"use of {} as const generic arguments are unstable",
unsupported_type
),
);
};
}
ty
}
x => {
if !fail {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/fn-const-param-call.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-pass

#![feature(const_generics)]
#![feature(const_generics, const_compare_raw_pointers)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

fn function() -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/fn-const-param-call.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/fn-const-param-call.rs:3:12
|
LL | #![feature(const_generics)]
LL | #![feature(const_generics, const_compare_raw_pointers)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/fn-const-param-infer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(const_generics)]
#![feature(const_generics, const_compare_raw_pointers)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

struct Checked<const F: fn(usize) -> bool>;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/fn-const-param-infer.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/fn-const-param-infer.rs:1:12
|
LL | #![feature(const_generics)]
LL | #![feature(const_generics, const_compare_raw_pointers)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
Expand Down
19 changes: 19 additions & 0 deletions src/test/ui/const-generics/raw-ptr-const-param-deref.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// run-pass
#![feature(const_generics, const_compare_raw_pointers)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

const A: u32 = 3;

struct Const<const P: *const u32>;

impl<const P: *const u32> Const<{P}> {
fn get() -> u32 {
unsafe {
*P
}
}
}

fn main() {
assert_eq!(Const::<{&A as *const _}>::get(), 3)
}
8 changes: 8 additions & 0 deletions src/test/ui/const-generics/raw-ptr-const-param-deref.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/raw-ptr-const-param-deref.rs:2:12
|
LL | #![feature(const_generics, const_compare_raw_pointers)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

9 changes: 9 additions & 0 deletions src/test/ui/const-generics/raw-ptr-const-param.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(const_generics, const_compare_raw_pointers)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

struct Const<const P: *const u32>;

fn main() {
let _: Const<{15 as *const _}> = Const::<{10 as *const _}>; //~ mismatched types
let _: Const<{10 as *const _}> = Const::<{10 as *const _}>;
}
20 changes: 20 additions & 0 deletions src/test/ui/const-generics/raw-ptr-const-param.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/raw-ptr-const-param.rs:1:12
|
LL | #![feature(const_generics, const_compare_raw_pointers)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

error[E0308]: mismatched types
--> $DIR/raw-ptr-const-param.rs:7:38
|
LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Scalar(0x000000000000000f) : *const u32`, found `Scalar(0x000000000000000a) : *const u32`
|
= note: expected type `Const<>`
found type `Const<>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
9 changes: 9 additions & 0 deletions src/test/ui/feature-gates/feature-gate-const_generics-ptr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
struct ConstFn<const F: fn()>;
//~^ ERROR const generics are unstable
//~^^ ERROR use of function pointers as const generic arguments are unstable

struct ConstPtr<const P: *const u32>;
//~^ ERROR const generics are unstable
//~^^ ERROR use of raw pointers as const generic arguments are unstable

fn main() {}
39 changes: 39 additions & 0 deletions src/test/ui/feature-gates/feature-gate-const_generics-ptr.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
error[E0658]: const generics are unstable
--> $DIR/feature-gate-const_generics-ptr.rs:1:22
|
LL | struct ConstFn<const F: fn()>;
| ^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
= help: add `#![feature(const_generics)]` to the crate attributes to enable

error[E0658]: const generics are unstable
--> $DIR/feature-gate-const_generics-ptr.rs:5:23
|
LL | struct ConstPtr<const P: *const u32>;
| ^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/44580
= help: add `#![feature(const_generics)]` to the crate attributes to enable

error[E0658]: use of function pointers as const generic arguments are unstable
--> $DIR/feature-gate-const_generics-ptr.rs:1:25
|
LL | struct ConstFn<const F: fn()>;
| ^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/53020
= help: add `#![feature(const_compare_raw_pointers)]` to the crate attributes to enable

error[E0658]: use of raw pointers as const generic arguments are unstable
--> $DIR/feature-gate-const_generics-ptr.rs:5:26
|
LL | struct ConstPtr<const P: *const u32>;
| ^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/53020
= help: add `#![feature(const_compare_raw_pointers)]` to the crate attributes to enable

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0658`.